@motionscript/core 0.1.0 → 0.1.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/assets/asset-index.d.ts +1 -8
- package/dist/assets/asset-index.d.ts.map +1 -1
- package/dist/assets/asset-index.js +1 -8
- package/dist/assets/asset-index.js.map +1 -1
- package/dist/assets/catalog.d.ts +10 -72
- package/dist/assets/catalog.d.ts.map +1 -1
- package/dist/assets/catalog.js +3 -29
- package/dist/assets/catalog.js.map +1 -1
- package/dist/assets/errors.d.ts +8 -20
- package/dist/assets/errors.d.ts.map +1 -1
- package/dist/assets/errors.js +8 -20
- package/dist/assets/errors.js.map +1 -1
- package/dist/assets/index.d.ts.map +1 -1
- package/dist/assets/index.js.map +1 -1
- package/dist/assets/manager.d.ts +9 -51
- package/dist/assets/manager.d.ts.map +1 -1
- package/dist/assets/manager.js +13 -78
- package/dist/assets/manager.js.map +1 -1
- package/dist/assets/record.d.ts +2 -18
- package/dist/assets/record.d.ts.map +1 -1
- package/dist/assets/record.js.map +1 -1
- package/dist/assets/scope.d.ts +3 -18
- package/dist/assets/scope.d.ts.map +1 -1
- package/dist/assets/scope.js +2 -11
- package/dist/assets/scope.js.map +1 -1
- package/dist/attributes/audio/effects/chain.d.ts +2 -12
- package/dist/attributes/audio/effects/chain.d.ts.map +1 -1
- package/dist/attributes/audio/effects/chain.js +1 -7
- package/dist/attributes/audio/effects/chain.js.map +1 -1
- package/dist/attributes/audio/effects/registry.d.ts +3 -18
- package/dist/attributes/audio/effects/registry.d.ts.map +1 -1
- package/dist/attributes/audio/effects/registry.js +4 -23
- package/dist/attributes/audio/effects/registry.js.map +1 -1
- package/dist/attributes/audio/ramp.d.ts +5 -38
- package/dist/attributes/audio/ramp.d.ts.map +1 -1
- package/dist/attributes/audio/ramp.js +3 -28
- package/dist/attributes/audio/ramp.js.map +1 -1
- package/dist/attributes/audio/request.d.ts +10 -80
- package/dist/attributes/audio/request.d.ts.map +1 -1
- package/dist/attributes/audio/request.js +1 -4
- package/dist/attributes/audio/request.js.map +1 -1
- package/dist/attributes/audio/schedule.d.ts +2 -12
- package/dist/attributes/audio/schedule.d.ts.map +1 -1
- package/dist/attributes/audio/schedule.js +2 -11
- package/dist/attributes/audio/schedule.js.map +1 -1
- package/dist/attributes/audio/sound.d.ts +2 -26
- package/dist/attributes/audio/sound.d.ts.map +1 -1
- package/dist/attributes/audio/sound.js +1 -9
- package/dist/attributes/audio/sound.js.map +1 -1
- package/dist/attributes/audio/transition.d.ts +1 -8
- package/dist/attributes/audio/transition.d.ts.map +1 -1
- package/dist/attributes/audio/transition.js.map +1 -1
- package/dist/attributes/layout/alignment.d.ts +6 -38
- package/dist/attributes/layout/alignment.d.ts.map +1 -1
- package/dist/attributes/layout/alignment.js.map +1 -1
- package/dist/attributes/layout/insets.d.ts +2 -27
- package/dist/attributes/layout/insets.d.ts.map +1 -1
- package/dist/attributes/layout/insets.js.map +1 -1
- package/dist/attributes/layout/matrix2d.d.ts +29 -114
- package/dist/attributes/layout/matrix2d.d.ts.map +1 -1
- package/dist/attributes/layout/matrix2d.js +26 -110
- package/dist/attributes/layout/matrix2d.js.map +1 -1
- package/dist/attributes/layout/size.d.ts +3 -25
- package/dist/attributes/layout/size.d.ts.map +1 -1
- package/dist/attributes/layout/size.js +2 -18
- package/dist/attributes/layout/size.js.map +1 -1
- package/dist/attributes/layout/space3d.d.ts +16 -79
- package/dist/attributes/layout/space3d.d.ts.map +1 -1
- package/dist/attributes/layout/space3d.js +17 -81
- package/dist/attributes/layout/space3d.js.map +1 -1
- package/dist/attributes/layout/transform3d.d.ts +2 -23
- package/dist/attributes/layout/transform3d.d.ts.map +1 -1
- package/dist/attributes/layout/transform3d.js +1 -7
- package/dist/attributes/layout/transform3d.js.map +1 -1
- package/dist/attributes/layout/world-transform.d.ts +2 -16
- package/dist/attributes/layout/world-transform.d.ts.map +1 -1
- package/dist/attributes/layout/world-transform.js.map +1 -1
- package/dist/attributes/properties/decorator.d.ts +13 -73
- package/dist/attributes/properties/decorator.d.ts.map +1 -1
- package/dist/attributes/properties/decorator.js +9 -40
- package/dist/attributes/properties/decorator.js.map +1 -1
- package/dist/attributes/properties/typed.d.ts +6 -45
- package/dist/attributes/properties/typed.d.ts.map +1 -1
- package/dist/attributes/properties/typed.js +6 -37
- package/dist/attributes/properties/typed.js.map +1 -1
- package/dist/attributes/render3d/orbit.d.ts +11 -83
- package/dist/attributes/render3d/orbit.d.ts.map +1 -1
- package/dist/attributes/render3d/orbit.js +10 -73
- package/dist/attributes/render3d/orbit.js.map +1 -1
- package/dist/attributes/shape/corners/corner-radius.d.ts +1 -6
- package/dist/attributes/shape/corners/corner-radius.d.ts.map +1 -1
- package/dist/attributes/shape/corners/corner-radius.js.map +1 -1
- package/dist/attributes/shape/corners/corner-style.d.ts +4 -25
- package/dist/attributes/shape/corners/corner-style.d.ts.map +1 -1
- package/dist/attributes/shape/corners/corner-style.js +2 -12
- package/dist/attributes/shape/corners/corner-style.js.map +1 -1
- package/dist/attributes/shape/corners/corners.d.ts +2 -21
- package/dist/attributes/shape/corners/corners.d.ts.map +1 -1
- package/dist/attributes/shape/corners/corners.js +2 -12
- package/dist/attributes/shape/corners/corners.js.map +1 -1
- package/dist/attributes/shape/effects/backdrop.d.ts +2 -18
- package/dist/attributes/shape/effects/backdrop.d.ts.map +1 -1
- package/dist/attributes/shape/effects/backdrop.js +3 -26
- package/dist/attributes/shape/effects/backdrop.js.map +1 -1
- package/dist/attributes/shape/effects/chain.d.ts +36 -328
- package/dist/attributes/shape/effects/chain.d.ts.map +1 -1
- package/dist/attributes/shape/effects/chain.js +24 -242
- package/dist/attributes/shape/effects/chain.js.map +1 -1
- package/dist/attributes/shape/effects/effect-data.d.ts +19 -127
- package/dist/attributes/shape/effects/effect-data.d.ts.map +1 -1
- package/dist/attributes/shape/effects/effect-data.js +6 -33
- package/dist/attributes/shape/effects/effect-data.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/ascii.d.ts +6 -26
- package/dist/attributes/shape/effects/implementations/ascii.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/ascii.js +0 -3
- package/dist/attributes/shape/effects/implementations/ascii.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/bit-crush.d.ts +2 -21
- package/dist/attributes/shape/effects/implementations/bit-crush.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/bit-crush.js +0 -1
- package/dist/attributes/shape/effects/implementations/bit-crush.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/block-displace.d.ts +1 -14
- package/dist/attributes/shape/effects/implementations/block-displace.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/block-displace.js +0 -1
- package/dist/attributes/shape/effects/implementations/block-displace.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/bloom.d.ts +0 -1
- package/dist/attributes/shape/effects/implementations/bloom.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/bloom.js +0 -1
- package/dist/attributes/shape/effects/implementations/bloom.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/blur.d.ts +0 -1
- package/dist/attributes/shape/effects/implementations/blur.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/blur.js +0 -1
- package/dist/attributes/shape/effects/implementations/blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/bulge.d.ts +0 -1
- package/dist/attributes/shape/effects/implementations/bulge.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/bulge.js +0 -1
- package/dist/attributes/shape/effects/implementations/bulge.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/chromatic-aberration.d.ts +0 -1
- package/dist/attributes/shape/effects/implementations/chromatic-aberration.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/chromatic-aberration.js +0 -1
- package/dist/attributes/shape/effects/implementations/chromatic-aberration.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/color-adjustment.d.ts +1 -12
- package/dist/attributes/shape/effects/implementations/color-adjustment.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/color-adjustment.js +0 -1
- package/dist/attributes/shape/effects/implementations/color-adjustment.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/curves.d.ts +1 -11
- package/dist/attributes/shape/effects/implementations/curves.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/curves.js +1 -6
- package/dist/attributes/shape/effects/implementations/curves.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/directional-blur.d.ts +0 -1
- package/dist/attributes/shape/effects/implementations/directional-blur.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/directional-blur.js +0 -1
- package/dist/attributes/shape/effects/implementations/directional-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/dither.d.ts +4 -35
- package/dist/attributes/shape/effects/implementations/dither.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/dither.js +1 -7
- package/dist/attributes/shape/effects/implementations/dither.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/drop-shadow.d.ts +1 -22
- package/dist/attributes/shape/effects/implementations/drop-shadow.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/drop-shadow.js +0 -1
- package/dist/attributes/shape/effects/implementations/drop-shadow.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/duotone.d.ts +1 -9
- package/dist/attributes/shape/effects/implementations/duotone.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/duotone.js +0 -1
- package/dist/attributes/shape/effects/implementations/duotone.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/edges.d.ts +2 -15
- package/dist/attributes/shape/effects/implementations/edges.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/edges.js +0 -1
- package/dist/attributes/shape/effects/implementations/edges.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/glass.d.ts +1 -14
- package/dist/attributes/shape/effects/implementations/glass.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/glass.js +0 -1
- package/dist/attributes/shape/effects/implementations/glass.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/glow.d.ts +7 -47
- package/dist/attributes/shape/effects/implementations/glow.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/glow.js +1 -9
- package/dist/attributes/shape/effects/implementations/glow.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/grain.d.ts +1 -14
- package/dist/attributes/shape/effects/implementations/grain.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/grain.js +0 -1
- package/dist/attributes/shape/effects/implementations/grain.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/grayscale.d.ts +0 -1
- package/dist/attributes/shape/effects/implementations/grayscale.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/grayscale.js +0 -1
- package/dist/attributes/shape/effects/implementations/grayscale.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/halftone.d.ts +5 -29
- package/dist/attributes/shape/effects/implementations/halftone.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/halftone.js +0 -1
- package/dist/attributes/shape/effects/implementations/halftone.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/invert.d.ts +3 -12
- package/dist/attributes/shape/effects/implementations/invert.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/invert.js +0 -1
- package/dist/attributes/shape/effects/implementations/invert.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/kaleidoscope.d.ts +2 -19
- package/dist/attributes/shape/effects/implementations/kaleidoscope.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/kaleidoscope.js +1 -5
- package/dist/attributes/shape/effects/implementations/kaleidoscope.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/lut.d.ts +11 -36
- package/dist/attributes/shape/effects/implementations/lut.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/lut.js +2 -8
- package/dist/attributes/shape/effects/implementations/lut.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/magnify.d.ts +0 -1
- package/dist/attributes/shape/effects/implementations/magnify.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/magnify.js +0 -1
- package/dist/attributes/shape/effects/implementations/magnify.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/motion-blur.d.ts +3 -17
- package/dist/attributes/shape/effects/implementations/motion-blur.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/motion-blur.js +2 -11
- package/dist/attributes/shape/effects/implementations/motion-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/oil-paint.d.ts +1 -12
- package/dist/attributes/shape/effects/implementations/oil-paint.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/oil-paint.js +0 -1
- package/dist/attributes/shape/effects/implementations/oil-paint.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/outline.d.ts +2 -14
- package/dist/attributes/shape/effects/implementations/outline.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/outline.js +0 -1
- package/dist/attributes/shape/effects/implementations/outline.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/pixelate.d.ts +1 -15
- package/dist/attributes/shape/effects/implementations/pixelate.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/pixelate.js +0 -1
- package/dist/attributes/shape/effects/implementations/pixelate.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/posterize.d.ts +1 -10
- package/dist/attributes/shape/effects/implementations/posterize.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/posterize.js +0 -1
- package/dist/attributes/shape/effects/implementations/posterize.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/progressive-blur.d.ts +3 -26
- package/dist/attributes/shape/effects/implementations/progressive-blur.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/progressive-blur.js +1 -2
- package/dist/attributes/shape/effects/implementations/progressive-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/radial-blur.d.ts +2 -16
- package/dist/attributes/shape/effects/implementations/radial-blur.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/radial-blur.js +0 -1
- package/dist/attributes/shape/effects/implementations/radial-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/rgb-shift.d.ts +1 -13
- package/dist/attributes/shape/effects/implementations/rgb-shift.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/rgb-shift.js +0 -1
- package/dist/attributes/shape/effects/implementations/rgb-shift.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/scanlines.d.ts +1 -8
- package/dist/attributes/shape/effects/implementations/scanlines.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/scanlines.js +0 -1
- package/dist/attributes/shape/effects/implementations/scanlines.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/scatter.d.ts +0 -1
- package/dist/attributes/shape/effects/implementations/scatter.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/scatter.js +0 -1
- package/dist/attributes/shape/effects/implementations/scatter.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/shader.d.ts +10 -53
- package/dist/attributes/shape/effects/implementations/shader.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/shader.js +2 -9
- package/dist/attributes/shape/effects/implementations/shader.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/sharpen.d.ts +1 -12
- package/dist/attributes/shape/effects/implementations/sharpen.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/sharpen.js +0 -1
- package/dist/attributes/shape/effects/implementations/sharpen.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/streak.d.ts +1 -8
- package/dist/attributes/shape/effects/implementations/streak.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/streak.js +0 -1
- package/dist/attributes/shape/effects/implementations/streak.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/threshold.d.ts +1 -9
- package/dist/attributes/shape/effects/implementations/threshold.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/threshold.js +0 -1
- package/dist/attributes/shape/effects/implementations/threshold.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/twirl.d.ts +1 -13
- package/dist/attributes/shape/effects/implementations/twirl.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/twirl.js +0 -1
- package/dist/attributes/shape/effects/implementations/twirl.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/vignette.d.ts +1 -9
- package/dist/attributes/shape/effects/implementations/vignette.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/vignette.js +0 -1
- package/dist/attributes/shape/effects/implementations/vignette.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/vintage.d.ts +0 -1
- package/dist/attributes/shape/effects/implementations/vintage.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/vintage.js +0 -1
- package/dist/attributes/shape/effects/implementations/vintage.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/wave.d.ts +3 -24
- package/dist/attributes/shape/effects/implementations/wave.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/wave.js +1 -5
- package/dist/attributes/shape/effects/implementations/wave.js.map +1 -1
- package/dist/attributes/shape/effects/registry.d.ts +6 -41
- package/dist/attributes/shape/effects/registry.d.ts.map +1 -1
- package/dist/attributes/shape/effects/registry.js +7 -45
- package/dist/attributes/shape/effects/registry.js.map +1 -1
- package/dist/attributes/shape/effects/spec.d.ts +6 -30
- package/dist/attributes/shape/effects/spec.d.ts.map +1 -1
- package/dist/attributes/shape/effects/spec.js +3 -9
- package/dist/attributes/shape/effects/spec.js.map +1 -1
- package/dist/attributes/shape/fill/blend.d.ts +1 -17
- package/dist/attributes/shape/fill/blend.d.ts.map +1 -1
- package/dist/attributes/shape/fill/blend.js +2 -15
- package/dist/attributes/shape/fill/blend.js.map +1 -1
- package/dist/attributes/shape/fill/chain.d.ts +17 -125
- package/dist/attributes/shape/fill/chain.d.ts.map +1 -1
- package/dist/attributes/shape/fill/chain.js +22 -109
- package/dist/attributes/shape/fill/chain.js.map +1 -1
- package/dist/attributes/shape/fill/coerce.d.ts +10 -35
- package/dist/attributes/shape/fill/coerce.d.ts.map +1 -1
- package/dist/attributes/shape/fill/coerce.js +12 -47
- package/dist/attributes/shape/fill/coerce.js.map +1 -1
- package/dist/attributes/shape/fill/color/parser.d.ts +10 -44
- package/dist/attributes/shape/fill/color/parser.d.ts.map +1 -1
- package/dist/attributes/shape/fill/color/parser.js +15 -91
- package/dist/attributes/shape/fill/color/parser.js.map +1 -1
- package/dist/attributes/shape/fill/gradient-stops.d.ts +1 -8
- package/dist/attributes/shape/fill/gradient-stops.d.ts.map +1 -1
- package/dist/attributes/shape/fill/gradient-stops.js +2 -13
- package/dist/attributes/shape/fill/gradient-stops.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/canvas3d.d.ts +2 -24
- package/dist/attributes/shape/fill/implementations/canvas3d.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/canvas3d.js +2 -9
- package/dist/attributes/shape/fill/implementations/canvas3d.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/dot-grid.d.ts +1 -14
- package/dist/attributes/shape/fill/implementations/dot-grid.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/dot-grid.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/fractal-noise.d.ts +5 -28
- package/dist/attributes/shape/fill/implementations/fractal-noise.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/fractal-noise.js +0 -1
- package/dist/attributes/shape/fill/implementations/fractal-noise.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/grid.d.ts +8 -21
- package/dist/attributes/shape/fill/implementations/grid.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/grid.js +2 -8
- package/dist/attributes/shape/fill/implementations/grid.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/image.d.ts +13 -79
- package/dist/attributes/shape/fill/implementations/image.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/image.js +6 -23
- package/dist/attributes/shape/fill/implementations/image.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/noise.d.ts +2 -15
- package/dist/attributes/shape/fill/implementations/noise.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/noise.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/shader.d.ts +11 -45
- package/dist/attributes/shape/fill/implementations/shader.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/shader.js +5 -17
- package/dist/attributes/shape/fill/implementations/shader.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/video.d.ts +12 -64
- package/dist/attributes/shape/fill/implementations/video.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/video.js +12 -50
- package/dist/attributes/shape/fill/implementations/video.js.map +1 -1
- package/dist/attributes/shape/fill/lerp.d.ts +2 -13
- package/dist/attributes/shape/fill/lerp.d.ts.map +1 -1
- package/dist/attributes/shape/fill/lerp.js +2 -9
- package/dist/attributes/shape/fill/lerp.js.map +1 -1
- package/dist/attributes/shape/fill/media-preset.d.ts +8 -49
- package/dist/attributes/shape/fill/media-preset.d.ts.map +1 -1
- package/dist/attributes/shape/fill/media-preset.js +8 -35
- package/dist/attributes/shape/fill/media-preset.js.map +1 -1
- package/dist/attributes/shape/fill/registry.d.ts +2 -26
- package/dist/attributes/shape/fill/registry.d.ts.map +1 -1
- package/dist/attributes/shape/fill/registry.js +5 -40
- package/dist/attributes/shape/fill/registry.js.map +1 -1
- package/dist/attributes/shape/fill/union.d.ts +6 -30
- package/dist/attributes/shape/fill/union.d.ts.map +1 -1
- package/dist/attributes/shape/fill/union.js +1 -9
- package/dist/attributes/shape/fill/union.js.map +1 -1
- package/dist/attributes/shape/filters/chain.d.ts +15 -168
- package/dist/attributes/shape/filters/chain.d.ts.map +1 -1
- package/dist/attributes/shape/filters/chain.js +8 -132
- package/dist/attributes/shape/filters/chain.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/color-matrix.d.ts +1 -7
- package/dist/attributes/shape/filters/implementations/color-matrix.d.ts.map +1 -1
- package/dist/attributes/shape/filters/implementations/color-matrix.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/curves.d.ts +1 -7
- package/dist/attributes/shape/filters/implementations/curves.d.ts.map +1 -1
- package/dist/attributes/shape/filters/implementations/curves.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/echo.d.ts +1 -11
- package/dist/attributes/shape/filters/implementations/echo.d.ts.map +1 -1
- package/dist/attributes/shape/filters/implementations/echo.js.map +1 -1
- package/dist/attributes/shape/filters/index.d.ts +1 -6
- package/dist/attributes/shape/filters/index.d.ts.map +1 -1
- package/dist/attributes/shape/filters/index.js +0 -2
- package/dist/attributes/shape/filters/index.js.map +1 -1
- package/dist/attributes/shape/filters/registry.d.ts +5 -35
- package/dist/attributes/shape/filters/registry.d.ts.map +1 -1
- package/dist/attributes/shape/filters/registry.js +7 -50
- package/dist/attributes/shape/filters/registry.js.map +1 -1
- package/dist/attributes/shape/filters/union.d.ts +10 -51
- package/dist/attributes/shape/filters/union.d.ts.map +1 -1
- package/dist/attributes/shape/filters/union.js.map +1 -1
- package/dist/attributes/shape/path/anchors.d.ts +18 -106
- package/dist/attributes/shape/path/anchors.d.ts.map +1 -1
- package/dist/attributes/shape/path/anchors.js +15 -124
- package/dist/attributes/shape/path/anchors.js.map +1 -1
- package/dist/attributes/shape/path/bezier.d.ts +6 -54
- package/dist/attributes/shape/path/bezier.d.ts.map +1 -1
- package/dist/attributes/shape/path/bezier.js +10 -98
- package/dist/attributes/shape/path/bezier.js.map +1 -1
- package/dist/attributes/shape/path/index.d.ts +1 -11
- package/dist/attributes/shape/path/index.d.ts.map +1 -1
- package/dist/attributes/shape/path/index.js +1 -11
- package/dist/attributes/shape/path/index.js.map +1 -1
- package/dist/attributes/shape/path/measure.d.ts +5 -41
- package/dist/attributes/shape/path/measure.d.ts.map +1 -1
- package/dist/attributes/shape/path/measure.js +8 -57
- package/dist/attributes/shape/path/measure.js.map +1 -1
- package/dist/attributes/shape/path/morph.d.ts +4 -41
- package/dist/attributes/shape/path/morph.d.ts.map +1 -1
- package/dist/attributes/shape/path/morph.js +17 -117
- package/dist/attributes/shape/path/morph.js.map +1 -1
- package/dist/attributes/shape/path/ops.d.ts +5 -19
- package/dist/attributes/shape/path/ops.d.ts.map +1 -1
- package/dist/attributes/shape/path/ops.js.map +1 -1
- package/dist/attributes/shape/path/types.d.ts +10 -67
- package/dist/attributes/shape/path/types.d.ts.map +1 -1
- package/dist/attributes/shape/path/types.js +0 -1
- package/dist/attributes/shape/path/types.js.map +1 -1
- package/dist/attributes/shape/path/walk.d.ts +9 -63
- package/dist/attributes/shape/path/walk.d.ts.map +1 -1
- package/dist/attributes/shape/path/walk.js +21 -100
- package/dist/attributes/shape/path/walk.js.map +1 -1
- package/dist/attributes/shape/shaders/language.d.ts +2 -14
- package/dist/attributes/shape/shaders/language.d.ts.map +1 -1
- package/dist/attributes/shape/shaders/language.js +1 -8
- package/dist/attributes/shape/shaders/language.js.map +1 -1
- package/dist/attributes/shape/shaders/pack.d.ts +13 -78
- package/dist/attributes/shape/shaders/pack.d.ts.map +1 -1
- package/dist/attributes/shape/shaders/pack.js +1 -10
- package/dist/attributes/shape/shaders/pack.js.map +1 -1
- package/dist/attributes/shape/shaders/resolve.d.ts +1 -11
- package/dist/attributes/shape/shaders/resolve.d.ts.map +1 -1
- package/dist/attributes/shape/shaders/resolve.js +3 -28
- package/dist/attributes/shape/shaders/resolve.js.map +1 -1
- package/dist/attributes/shape/shaders/uniforms.d.ts +3 -24
- package/dist/attributes/shape/shaders/uniforms.d.ts.map +1 -1
- package/dist/attributes/shape/shaders/uniforms.js +0 -0
- package/dist/attributes/shape/shaders/uniforms.js.map +1 -1
- package/dist/attributes/shape/shadow/shadow.d.ts +3 -20
- package/dist/attributes/shape/shadow/shadow.d.ts.map +1 -1
- package/dist/attributes/shape/shadow/shadow.js +0 -3
- package/dist/attributes/shape/shadow/shadow.js.map +1 -1
- package/dist/attributes/shape/stroke/stroke.d.ts +9 -58
- package/dist/attributes/shape/stroke/stroke.d.ts.map +1 -1
- package/dist/attributes/shape/stroke/stroke.js +0 -6
- package/dist/attributes/shape/stroke/stroke.js.map +1 -1
- package/dist/attributes/shared/operators.d.ts +1 -8
- package/dist/attributes/shared/operators.d.ts.map +1 -1
- package/dist/attributes/shared/operators.js.map +1 -1
- package/dist/attributes/text/index.d.ts +1 -11
- package/dist/attributes/text/index.d.ts.map +1 -1
- package/dist/attributes/text/index.js +1 -11
- package/dist/attributes/text/index.js.map +1 -1
- package/dist/attributes/text/ops.d.ts +4 -30
- package/dist/attributes/text/ops.d.ts.map +1 -1
- package/dist/attributes/text/ops.js +7 -23
- package/dist/attributes/text/ops.js.map +1 -1
- package/dist/attributes/text/types.d.ts +5 -28
- package/dist/attributes/text/types.d.ts.map +1 -1
- package/dist/attributes/text/types.js.map +1 -1
- package/dist/browser/chunks/chunk-3ZIUZZC7.js +13 -0
- package/dist/browser/chunks/chunk-3ZIUZZC7.js.map +7 -0
- package/dist/browser/chunks/{chunk-CCGVIR4F.js → chunk-5TDMGUXQ.js} +3 -3
- package/dist/browser/chunks/chunk-5TDMGUXQ.js.map +7 -0
- package/dist/browser/chunks/chunk-7YOYMMXK.js +6 -0
- package/dist/browser/chunks/chunk-7YOYMMXK.js.map +7 -0
- package/dist/browser/chunks/{chunk-4BDLFEOC.js → chunk-GEJEQQER.js} +1 -1
- package/dist/browser/chunks/chunk-GEJEQQER.js.map +7 -0
- package/dist/browser/component.js +1 -1
- package/dist/browser/experimental.js +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/browser/manifest.json +1 -1
- package/dist/browser/sdk.js +1 -1
- package/dist/component.d.ts +3 -10
- package/dist/component.d.ts.map +1 -1
- package/dist/component.js +3 -10
- package/dist/component.js.map +1 -1
- package/dist/components/builtins/geometry/geometry.d.ts +15 -62
- package/dist/components/builtins/geometry/geometry.d.ts.map +1 -1
- package/dist/components/builtins/geometry/geometry.js.map +1 -1
- package/dist/components/builtins/geometry/shape-outline.d.ts +12 -61
- package/dist/components/builtins/geometry/shape-outline.d.ts.map +1 -1
- package/dist/components/builtins/geometry/shape-outline.js +29 -168
- package/dist/components/builtins/geometry/shape-outline.js.map +1 -1
- package/dist/components/builtins/layout/layout.d.ts +1 -14
- package/dist/components/builtins/layout/layout.d.ts.map +1 -1
- package/dist/components/builtins/layout/layout.js.map +1 -1
- package/dist/components/builtins/media/media.d.ts +11 -51
- package/dist/components/builtins/media/media.d.ts.map +1 -1
- package/dist/components/builtins/media/media.js +3 -7
- package/dist/components/builtins/media/media.js.map +1 -1
- package/dist/components/builtins/text/number-format.d.ts +14 -47
- package/dist/components/builtins/text/number-format.d.ts.map +1 -1
- package/dist/components/builtins/text/number-format.js +19 -69
- package/dist/components/builtins/text/number-format.js.map +1 -1
- package/dist/components/builtins/text/number-pattern.d.ts +3 -37
- package/dist/components/builtins/text/number-pattern.d.ts.map +1 -1
- package/dist/components/builtins/text/number-pattern.js +6 -48
- package/dist/components/builtins/text/number-pattern.js.map +1 -1
- package/dist/components/builtins/text/text-defaults.d.ts +7 -25
- package/dist/components/builtins/text/text-defaults.d.ts.map +1 -1
- package/dist/components/builtins/text/text-defaults.js +7 -25
- package/dist/components/builtins/text/text-defaults.js.map +1 -1
- package/dist/components/builtins/text/text-layout.d.ts +2 -11
- package/dist/components/builtins/text/text-layout.d.ts.map +1 -1
- package/dist/components/builtins/text/text-layout.js +7 -22
- package/dist/components/builtins/text/text-layout.js.map +1 -1
- package/dist/components/builtins/text/text.d.ts +8 -46
- package/dist/components/builtins/text/text.d.ts.map +1 -1
- package/dist/components/builtins/text/text.js.map +1 -1
- package/dist/components/builtins/three/canvas3d.d.ts +6 -51
- package/dist/components/builtins/three/canvas3d.d.ts.map +1 -1
- package/dist/components/builtins/three/canvas3d.js.map +1 -1
- package/dist/components/builtins/three/grid-geometry3d.d.ts +3 -39
- package/dist/components/builtins/three/grid-geometry3d.d.ts.map +1 -1
- package/dist/components/builtins/three/grid-geometry3d.js +8 -46
- package/dist/components/builtins/three/grid-geometry3d.js.map +1 -1
- package/dist/components/builtins/three/three.d.ts +22 -117
- package/dist/components/builtins/three/three.d.ts.map +1 -1
- package/dist/components/builtins/three/three.js +5 -17
- package/dist/components/builtins/three/three.js.map +1 -1
- package/dist/components/factory/api.d.ts.map +1 -1
- package/dist/components/factory/api.js.map +1 -1
- package/dist/components/factory/views.d.ts.map +1 -1
- package/dist/components/factory/views.js +0 -2
- package/dist/components/factory/views.js.map +1 -1
- package/dist/components/trees/2d/group-bounds.d.ts +12 -41
- package/dist/components/trees/2d/group-bounds.d.ts.map +1 -1
- package/dist/components/trees/2d/group-bounds.js +3 -22
- package/dist/components/trees/2d/group-bounds.js.map +1 -1
- package/dist/components/trees/2d/node-lifecycle.d.ts +8 -36
- package/dist/components/trees/2d/node-lifecycle.d.ts.map +1 -1
- package/dist/components/trees/2d/node-lifecycle.js +35 -127
- package/dist/components/trees/2d/node-lifecycle.js.map +1 -1
- package/dist/components/trees/2d/node-motion.d.ts +4 -36
- package/dist/components/trees/2d/node-motion.d.ts.map +1 -1
- package/dist/components/trees/2d/node-motion.js +3 -31
- package/dist/components/trees/2d/node-motion.js.map +1 -1
- package/dist/components/trees/2d/node-render.d.ts +3 -20
- package/dist/components/trees/2d/node-render.d.ts.map +1 -1
- package/dist/components/trees/2d/node-render.js +4 -23
- package/dist/components/trees/2d/node-render.js.map +1 -1
- package/dist/components/trees/2d/node-space.d.ts +4 -23
- package/dist/components/trees/2d/node-space.d.ts.map +1 -1
- package/dist/components/trees/2d/node-space.js +3 -17
- package/dist/components/trees/2d/node-space.js.map +1 -1
- package/dist/components/trees/2d/node-transform.d.ts +4 -33
- package/dist/components/trees/2d/node-transform.d.ts.map +1 -1
- package/dist/components/trees/2d/node-transform.js +4 -33
- package/dist/components/trees/2d/node-transform.js.map +1 -1
- package/dist/components/trees/2d/node2d.d.ts +112 -622
- package/dist/components/trees/2d/node2d.d.ts.map +1 -1
- package/dist/components/trees/2d/node2d.js +131 -605
- package/dist/components/trees/2d/node2d.js.map +1 -1
- package/dist/components/trees/audio/node-audio.d.ts +17 -65
- package/dist/components/trees/audio/node-audio.d.ts.map +1 -1
- package/dist/components/trees/audio/node-audio.js +18 -68
- package/dist/components/trees/audio/node-audio.js.map +1 -1
- package/dist/components/trees/node/node-editor-state.d.ts +5 -45
- package/dist/components/trees/node/node-editor-state.d.ts.map +1 -1
- package/dist/components/trees/node/node-editor-state.js +1 -13
- package/dist/components/trees/node/node-editor-state.js.map +1 -1
- package/dist/components/trees/node/node-reactive.d.ts +6 -53
- package/dist/components/trees/node/node-reactive.d.ts.map +1 -1
- package/dist/components/trees/node/node-reactive.js +4 -33
- package/dist/components/trees/node/node-reactive.js.map +1 -1
- package/dist/components/trees/node/node-time.d.ts +2 -15
- package/dist/components/trees/node/node-time.d.ts.map +1 -1
- package/dist/components/trees/node/node-time.js.map +1 -1
- package/dist/components/trees/node/node-walk.d.ts +7 -32
- package/dist/components/trees/node/node-walk.d.ts.map +1 -1
- package/dist/components/trees/node/node-walk.js +7 -32
- package/dist/components/trees/node/node-walk.js.map +1 -1
- package/dist/components/trees/node/node.d.ts +43 -248
- package/dist/components/trees/node/node.d.ts.map +1 -1
- package/dist/components/trees/node/node.js +51 -229
- package/dist/components/trees/node/node.js.map +1 -1
- package/dist/components/trees/root/canvas2d-node.d.ts +7 -60
- package/dist/components/trees/root/canvas2d-node.d.ts.map +1 -1
- package/dist/components/trees/root/canvas2d-node.js +7 -47
- package/dist/components/trees/root/canvas2d-node.js.map +1 -1
- package/dist/components/trees/three/node3d.d.ts +24 -112
- package/dist/components/trees/three/node3d.d.ts.map +1 -1
- package/dist/components/trees/three/node3d.js +22 -104
- package/dist/components/trees/three/node3d.js.map +1 -1
- package/dist/document/audio.d.ts +9 -21
- package/dist/document/audio.d.ts.map +1 -1
- package/dist/document/audio.js +13 -28
- package/dist/document/audio.js.map +1 -1
- package/dist/document/builtins.d.ts +3 -9
- package/dist/document/builtins.d.ts.map +1 -1
- package/dist/document/builtins.js +43 -89
- package/dist/document/builtins.js.map +1 -1
- package/dist/document/command-traits.d.ts +14 -37
- package/dist/document/command-traits.d.ts.map +1 -1
- package/dist/document/command-traits.js +22 -39
- package/dist/document/command-traits.js.map +1 -1
- package/dist/document/deny-globals.d.ts +9 -43
- package/dist/document/deny-globals.d.ts.map +1 -1
- package/dist/document/deny-globals.js +18 -58
- package/dist/document/deny-globals.js.map +1 -1
- package/dist/document/diff.d.ts +6 -16
- package/dist/document/diff.d.ts.map +1 -1
- package/dist/document/diff.js +5 -11
- package/dist/document/diff.js.map +1 -1
- package/dist/document/doc-index.d.ts +5 -13
- package/dist/document/doc-index.d.ts.map +1 -1
- package/dist/document/doc-index.js +0 -2
- package/dist/document/doc-index.js.map +1 -1
- package/dist/document/expression/compile.d.ts +2 -2
- package/dist/document/expression/compile.d.ts.map +1 -1
- package/dist/document/expression/compile.js +8 -18
- package/dist/document/expression/compile.js.map +1 -1
- package/dist/document/expression/index.d.ts +11 -41
- package/dist/document/expression/index.d.ts.map +1 -1
- package/dist/document/expression/index.js +11 -41
- package/dist/document/expression/index.js.map +1 -1
- package/dist/document/expression/ops.d.ts +3 -12
- package/dist/document/expression/ops.d.ts.map +1 -1
- package/dist/document/expression/ops.js +4 -20
- package/dist/document/expression/ops.js.map +1 -1
- package/dist/document/expression/parse.d.ts +4 -14
- package/dist/document/expression/parse.d.ts.map +1 -1
- package/dist/document/expression/parse.js +34 -55
- package/dist/document/expression/parse.js.map +1 -1
- package/dist/document/expression/refs.d.ts +2 -8
- package/dist/document/expression/refs.d.ts.map +1 -1
- package/dist/document/expression/refs.js +2 -6
- package/dist/document/expression/refs.js.map +1 -1
- package/dist/document/expression/types.d.ts +18 -63
- package/dist/document/expression/types.d.ts.map +1 -1
- package/dist/document/expression/types.js +4 -15
- package/dist/document/expression/types.js.map +1 -1
- package/dist/document/expression/walk.d.ts +6 -20
- package/dist/document/expression/walk.d.ts.map +1 -1
- package/dist/document/expression/walk.js +18 -44
- package/dist/document/expression/walk.js.map +1 -1
- package/dist/document/index.js +2 -3
- package/dist/document/index.js.map +1 -1
- package/dist/document/migrate.d.ts +7 -22
- package/dist/document/migrate.d.ts.map +1 -1
- package/dist/document/migrate.js +44 -15
- package/dist/document/migrate.js.map +1 -1
- package/dist/document/missing-node.d.ts +4 -11
- package/dist/document/missing-node.d.ts.map +1 -1
- package/dist/document/missing-node.js +2 -5
- package/dist/document/missing-node.js.map +1 -1
- package/dist/document/node-decorator.d.ts +12 -53
- package/dist/document/node-decorator.d.ts.map +1 -1
- package/dist/document/node-decorator.js +16 -57
- package/dist/document/node-decorator.js.map +1 -1
- package/dist/document/node-descriptor.d.ts +25 -62
- package/dist/document/node-descriptor.d.ts.map +1 -1
- package/dist/document/node-descriptor.js.map +1 -1
- package/dist/document/placement.d.ts +18 -41
- package/dist/document/placement.d.ts.map +1 -1
- package/dist/document/placement.js +4 -11
- package/dist/document/placement.js.map +1 -1
- package/dist/document/project.d.ts +19 -52
- package/dist/document/project.d.ts.map +1 -1
- package/dist/document/project.js +2 -6
- package/dist/document/project.js.map +1 -1
- package/dist/document/prop-evolution.d.ts +10 -20
- package/dist/document/prop-evolution.d.ts.map +1 -1
- package/dist/document/prop-evolution.js +3 -7
- package/dist/document/prop-evolution.js.map +1 -1
- package/dist/document/registry.d.ts +80 -318
- package/dist/document/registry.d.ts.map +1 -1
- package/dist/document/registry.js +43 -147
- package/dist/document/registry.js.map +1 -1
- package/dist/document/settled-index.d.ts +11 -23
- package/dist/document/settled-index.d.ts.map +1 -1
- package/dist/document/settled-index.js +15 -34
- package/dist/document/settled-index.js.map +1 -1
- package/dist/document/timeline-patch.d.ts +6 -15
- package/dist/document/timeline-patch.d.ts.map +1 -1
- package/dist/document/timeline-patch.js +12 -21
- package/dist/document/timeline-patch.js.map +1 -1
- package/dist/document/timeline.d.ts +56 -263
- package/dist/document/timeline.d.ts.map +1 -1
- package/dist/document/timeline.js +71 -275
- package/dist/document/timeline.js.map +1 -1
- package/dist/document/types.d.ts +90 -264
- package/dist/document/types.d.ts.map +1 -1
- package/dist/document/types.js +13 -30
- package/dist/document/types.js.map +1 -1
- package/dist/document/validate.d.ts +10 -40
- package/dist/document/validate.d.ts.map +1 -1
- package/dist/document/validate.js +72 -137
- package/dist/document/validate.js.map +1 -1
- package/dist/document/vocabulary.d.ts +4 -7
- package/dist/document/vocabulary.d.ts.map +1 -1
- package/dist/document/vocabulary.js +0 -1
- package/dist/document/vocabulary.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/layout/bounds.d.ts +1 -11
- package/dist/layout/bounds.d.ts.map +1 -1
- package/dist/layout/bounds.js.map +1 -1
- package/dist/layout/flex.d.ts +6 -20
- package/dist/layout/flex.d.ts.map +1 -1
- package/dist/layout/flex.js +7 -28
- package/dist/layout/flex.js.map +1 -1
- package/dist/layout/ops.d.ts +2 -11
- package/dist/layout/ops.d.ts.map +1 -1
- package/dist/layout/ops.js +2 -22
- package/dist/layout/ops.js.map +1 -1
- package/dist/layout/types.d.ts +11 -55
- package/dist/layout/types.d.ts.map +1 -1
- package/dist/layout/types.js.map +1 -1
- package/dist/platform/audio-sink.d.ts +7 -43
- package/dist/platform/audio-sink.d.ts.map +1 -1
- package/dist/platform/audio-sink.js +4 -29
- package/dist/platform/audio-sink.js.map +1 -1
- package/dist/platform/exporter.d.ts +5 -31
- package/dist/platform/exporter.d.ts.map +1 -1
- package/dist/platform/exporter.js.map +1 -1
- package/dist/platform/stepped-clock.d.ts +1 -16
- package/dist/platform/stepped-clock.d.ts.map +1 -1
- package/dist/platform/stepped-clock.js +1 -16
- package/dist/platform/stepped-clock.js.map +1 -1
- package/dist/platform/storage-adapter.d.ts +8 -68
- package/dist/platform/storage-adapter.d.ts.map +1 -1
- package/dist/platform/storage-adapter.js +8 -60
- package/dist/platform/storage-adapter.js.map +1 -1
- package/dist/platform/ticker.d.ts +11 -45
- package/dist/platform/ticker.d.ts.map +1 -1
- package/dist/platform/ticker.js +10 -37
- package/dist/platform/ticker.js.map +1 -1
- package/dist/project/config.d.ts +4 -14
- package/dist/project/config.d.ts.map +1 -1
- package/dist/project/config.js.map +1 -1
- package/dist/project/tree.d.ts +6 -35
- package/dist/project/tree.d.ts.map +1 -1
- package/dist/project/tree.js +1 -8
- package/dist/project/tree.js.map +1 -1
- package/dist/props/host.d.ts +2 -13
- package/dist/props/host.d.ts.map +1 -1
- package/dist/props/host.js.map +1 -1
- package/dist/props/layout.d.ts +1 -12
- package/dist/props/layout.d.ts.map +1 -1
- package/dist/props/layout.js +1 -12
- package/dist/props/layout.js.map +1 -1
- package/dist/props/observer.d.ts +1 -7
- package/dist/props/observer.d.ts.map +1 -1
- package/dist/props/observer.js.map +1 -1
- package/dist/props/slot.d.ts +6 -19
- package/dist/props/slot.d.ts.map +1 -1
- package/dist/props/slot.js +5 -14
- package/dist/props/slot.js.map +1 -1
- package/dist/render/canvas-render-context2d.d.ts +8 -68
- package/dist/render/canvas-render-context2d.d.ts.map +1 -1
- package/dist/render/canvas-render-context2d.js +8 -69
- package/dist/render/canvas-render-context2d.js.map +1 -1
- package/dist/render/clip-contains.d.ts +2 -16
- package/dist/render/clip-contains.d.ts.map +1 -1
- package/dist/render/clip-contains.js +21 -82
- package/dist/render/clip-contains.js.map +1 -1
- package/dist/render/clip.d.ts +7 -25
- package/dist/render/clip.d.ts.map +1 -1
- package/dist/render/clip.js +5 -17
- package/dist/render/clip.js.map +1 -1
- package/dist/render/descriptors/ellipse.d.ts.map +1 -1
- package/dist/render/descriptors/ellipse.js +0 -1
- package/dist/render/descriptors/ellipse.js.map +1 -1
- package/dist/render/descriptors/line.d.ts.map +1 -1
- package/dist/render/descriptors/line.js +0 -1
- package/dist/render/descriptors/line.js.map +1 -1
- package/dist/render/descriptors/path-builder.d.ts +4 -32
- package/dist/render/descriptors/path-builder.d.ts.map +1 -1
- package/dist/render/descriptors/path-builder.js +3 -25
- package/dist/render/descriptors/path-builder.js.map +1 -1
- package/dist/render/descriptors/path.d.ts +1 -11
- package/dist/render/descriptors/path.d.ts.map +1 -1
- package/dist/render/descriptors/path.js +0 -1
- package/dist/render/descriptors/path.js.map +1 -1
- package/dist/render/descriptors/polygon.d.ts.map +1 -1
- package/dist/render/descriptors/polygon.js +0 -1
- package/dist/render/descriptors/polygon.js.map +1 -1
- package/dist/render/descriptors/polygram.d.ts.map +1 -1
- package/dist/render/descriptors/polygram.js +0 -1
- package/dist/render/descriptors/polygram.js.map +1 -1
- package/dist/render/descriptors/rect.d.ts.map +1 -1
- package/dist/render/descriptors/rect.js +0 -1
- package/dist/render/descriptors/rect.js.map +1 -1
- package/dist/render/descriptors/richtext.d.ts.map +1 -1
- package/dist/render/descriptors/richtext.js +0 -1
- package/dist/render/descriptors/richtext.js.map +1 -1
- package/dist/render/descriptors/shape.d.ts +17 -77
- package/dist/render/descriptors/shape.d.ts.map +1 -1
- package/dist/render/descriptors/shape.js +13 -47
- package/dist/render/descriptors/shape.js.map +1 -1
- package/dist/render/descriptors/text.d.ts +15 -94
- package/dist/render/descriptors/text.d.ts.map +1 -1
- package/dist/render/descriptors/text.js +8 -50
- package/dist/render/descriptors/text.js.map +1 -1
- package/dist/render/descriptors/transform.d.ts +5 -16
- package/dist/render/descriptors/transform.d.ts.map +1 -1
- package/dist/render/descriptors/transform.js +1 -17
- package/dist/render/descriptors/transform.js.map +1 -1
- package/dist/render/graphics2d.d.ts +24 -116
- package/dist/render/graphics2d.d.ts.map +1 -1
- package/dist/render/graphics2d.js +23 -108
- package/dist/render/graphics2d.js.map +1 -1
- package/dist/render/measure-context.d.ts +5 -29
- package/dist/render/measure-context.d.ts.map +1 -1
- package/dist/render/measure-context.js.map +1 -1
- package/dist/render/null-render-context.d.ts +2 -20
- package/dist/render/null-render-context.d.ts.map +1 -1
- package/dist/render/null-render-context.js +2 -20
- package/dist/render/null-render-context.js.map +1 -1
- package/dist/render/render-context2d.d.ts +52 -208
- package/dist/render/render-context2d.d.ts.map +1 -1
- package/dist/render/render-context2d.js.map +1 -1
- package/dist/render/surface.d.ts +2 -19
- package/dist/render/surface.d.ts.map +1 -1
- package/dist/render/surface.js.map +1 -1
- package/dist/render/text-defaults.d.ts +1 -17
- package/dist/render/text-defaults.d.ts.map +1 -1
- package/dist/render/text-defaults.js +6 -40
- package/dist/render/text-defaults.js.map +1 -1
- package/dist/render/text-layout.d.ts +12 -55
- package/dist/render/text-layout.d.ts.map +1 -1
- package/dist/render/text-layout.js +2 -16
- package/dist/render/text-layout.js.map +1 -1
- package/dist/render3d/bounds3d.d.ts +10 -32
- package/dist/render3d/bounds3d.d.ts.map +1 -1
- package/dist/render3d/bounds3d.js +2 -12
- package/dist/render3d/bounds3d.js.map +1 -1
- package/dist/render3d/builders.d.ts +8 -35
- package/dist/render3d/builders.d.ts.map +1 -1
- package/dist/render3d/builders.js +8 -35
- package/dist/render3d/builders.js.map +1 -1
- package/dist/render3d/camera.d.ts +10 -57
- package/dist/render3d/camera.d.ts.map +1 -1
- package/dist/render3d/camera.js +4 -26
- package/dist/render3d/camera.js.map +1 -1
- package/dist/render3d/fill3d.d.ts +7 -45
- package/dist/render3d/fill3d.d.ts.map +1 -1
- package/dist/render3d/fill3d.js +15 -85
- package/dist/render3d/fill3d.js.map +1 -1
- package/dist/render3d/geometry.d.ts +18 -106
- package/dist/render3d/geometry.d.ts.map +1 -1
- package/dist/render3d/geometry.js +2 -20
- package/dist/render3d/geometry.js.map +1 -1
- package/dist/render3d/graphics3d.d.ts +29 -133
- package/dist/render3d/graphics3d.d.ts.map +1 -1
- package/dist/render3d/graphics3d.js +23 -110
- package/dist/render3d/graphics3d.js.map +1 -1
- package/dist/render3d/index.d.ts +1 -16
- package/dist/render3d/index.d.ts.map +1 -1
- package/dist/render3d/index.js +1 -16
- package/dist/render3d/index.js.map +1 -1
- package/dist/render3d/inert.d.ts.map +1 -1
- package/dist/render3d/inert.js +1 -14
- package/dist/render3d/inert.js.map +1 -1
- package/dist/render3d/light.d.ts +3 -26
- package/dist/render3d/light.d.ts.map +1 -1
- package/dist/render3d/light.js.map +1 -1
- package/dist/render3d/material.d.ts +13 -87
- package/dist/render3d/material.d.ts.map +1 -1
- package/dist/render3d/material.js +2 -16
- package/dist/render3d/material.js.map +1 -1
- package/dist/render3d/matrix4.d.ts +14 -68
- package/dist/render3d/matrix4.d.ts.map +1 -1
- package/dist/render3d/matrix4.js +11 -60
- package/dist/render3d/matrix4.js.map +1 -1
- package/dist/render3d/render-context3d.d.ts +13 -51
- package/dist/render3d/render-context3d.d.ts.map +1 -1
- package/dist/render3d/render-context3d.js +9 -21
- package/dist/render3d/render-context3d.js.map +1 -1
- package/dist/render3d/resources.d.ts +9 -53
- package/dist/render3d/resources.d.ts.map +1 -1
- package/dist/render3d/resources.js +8 -48
- package/dist/render3d/resources.js.map +1 -1
- package/dist/render3d/rounded-box.d.ts +7 -21
- package/dist/render3d/rounded-box.d.ts.map +1 -1
- package/dist/render3d/rounded-box.js +7 -46
- package/dist/render3d/rounded-box.js.map +1 -1
- package/dist/render3d/scene-settings.d.ts +20 -78
- package/dist/render3d/scene-settings.d.ts.map +1 -1
- package/dist/render3d/scene-settings.js.map +1 -1
- package/dist/render3d/scene3d.d.ts +11 -53
- package/dist/render3d/scene3d.d.ts.map +1 -1
- package/dist/render3d/scene3d.js +12 -59
- package/dist/render3d/scene3d.js.map +1 -1
- package/dist/render3d/segments.d.ts +2 -25
- package/dist/render3d/segments.d.ts.map +1 -1
- package/dist/render3d/segments.js +1 -11
- package/dist/render3d/segments.js.map +1 -1
- package/dist/render3d/texture.d.ts +25 -112
- package/dist/render3d/texture.d.ts.map +1 -1
- package/dist/render3d/texture.js +3 -27
- package/dist/render3d/texture.js.map +1 -1
- package/dist/render3d/tracking.d.ts +2 -19
- package/dist/render3d/tracking.d.ts.map +1 -1
- package/dist/render3d/tracking.js +2 -19
- package/dist/render3d/tracking.js.map +1 -1
- package/dist/render3d/transform.d.ts +14 -60
- package/dist/render3d/transform.d.ts.map +1 -1
- package/dist/render3d/transform.js +0 -2
- package/dist/render3d/transform.js.map +1 -1
- package/dist/render3d/vector3.d.ts +6 -48
- package/dist/render3d/vector3.d.ts.map +1 -1
- package/dist/render3d/vector3.js +4 -38
- package/dist/render3d/vector3.js.map +1 -1
- package/dist/render3d/walk.d.ts +3 -27
- package/dist/render3d/walk.d.ts.map +1 -1
- package/dist/render3d/walk.js +5 -33
- package/dist/render3d/walk.js.map +1 -1
- package/dist/runtime/asset-refine.d.ts +34 -20
- package/dist/runtime/asset-refine.d.ts.map +1 -1
- package/dist/runtime/asset-refine.js +127 -31
- package/dist/runtime/asset-refine.js.map +1 -1
- package/dist/runtime/asset-timeline.d.ts +14 -53
- package/dist/runtime/asset-timeline.d.ts.map +1 -1
- package/dist/runtime/asset-timeline.js +6 -27
- package/dist/runtime/asset-timeline.js.map +1 -1
- package/dist/runtime/asset-update.d.ts +7 -26
- package/dist/runtime/asset-update.d.ts.map +1 -1
- package/dist/runtime/asset-update.js +6 -18
- package/dist/runtime/asset-update.js.map +1 -1
- package/dist/runtime/audio-index.d.ts +0 -2
- package/dist/runtime/audio-index.d.ts.map +1 -1
- package/dist/runtime/audio-index.js +0 -2
- package/dist/runtime/audio-index.js.map +1 -1
- package/dist/runtime/builtin-context.d.ts +3 -9
- package/dist/runtime/builtin-context.d.ts.map +1 -1
- package/dist/runtime/builtin-context.js +3 -9
- package/dist/runtime/builtin-context.js.map +1 -1
- package/dist/runtime/clip-instance.d.ts +12 -39
- package/dist/runtime/clip-instance.d.ts.map +1 -1
- package/dist/runtime/clip-instance.js +21 -45
- package/dist/runtime/clip-instance.js.map +1 -1
- package/dist/runtime/clip-store.d.ts +26 -68
- package/dist/runtime/clip-store.d.ts.map +1 -1
- package/dist/runtime/clip-store.js +47 -81
- package/dist/runtime/clip-store.js.map +1 -1
- package/dist/runtime/engine.d.ts +31 -85
- package/dist/runtime/engine.d.ts.map +1 -1
- package/dist/runtime/engine.js +16 -49
- package/dist/runtime/engine.js.map +1 -1
- package/dist/runtime/frame-time.d.ts +4 -15
- package/dist/runtime/frame-time.d.ts.map +1 -1
- package/dist/runtime/frame-time.js +5 -12
- package/dist/runtime/frame-time.js.map +1 -1
- package/dist/runtime/index.d.ts +0 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +0 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/node-picking.d.ts +59 -139
- package/dist/runtime/node-picking.d.ts.map +1 -1
- package/dist/runtime/node-picking.js +87 -157
- package/dist/runtime/node-picking.js.map +1 -1
- package/dist/runtime/node-picking3d.d.ts +39 -96
- package/dist/runtime/node-picking3d.d.ts.map +1 -1
- package/dist/runtime/node-picking3d.js +98 -141
- package/dist/runtime/node-picking3d.js.map +1 -1
- package/dist/runtime/placement.d.ts +8 -17
- package/dist/runtime/placement.d.ts.map +1 -1
- package/dist/runtime/placement.js +7 -16
- package/dist/runtime/placement.js.map +1 -1
- package/dist/runtime/playback-controller.d.ts +78 -207
- package/dist/runtime/playback-controller.d.ts.map +1 -1
- package/dist/runtime/playback-controller.js +111 -226
- package/dist/runtime/playback-controller.js.map +1 -1
- package/dist/runtime/playback.d.ts +6 -14
- package/dist/runtime/playback.d.ts.map +1 -1
- package/dist/runtime/playback.js +6 -14
- package/dist/runtime/playback.js.map +1 -1
- package/dist/runtime/project-assets.d.ts +6 -14
- package/dist/runtime/project-assets.d.ts.map +1 -1
- package/dist/runtime/project-assets.js +7 -16
- package/dist/runtime/project-assets.js.map +1 -1
- package/dist/runtime/session.d.ts +22 -45
- package/dist/runtime/session.d.ts.map +1 -1
- package/dist/runtime/session.js +26 -46
- package/dist/runtime/session.js.map +1 -1
- package/dist/runtime/settle.d.ts +4 -10
- package/dist/runtime/settle.d.ts.map +1 -1
- package/dist/runtime/settle.js +4 -10
- package/dist/runtime/settle.js.map +1 -1
- package/dist/runtime/state-evaluator.d.ts +15 -37
- package/dist/runtime/state-evaluator.d.ts.map +1 -1
- package/dist/runtime/state-evaluator.js +27 -44
- package/dist/runtime/state-evaluator.js.map +1 -1
- package/dist/runtime/text-geometry.d.ts +18 -47
- package/dist/runtime/text-geometry.d.ts.map +1 -1
- package/dist/runtime/text-geometry.js +13 -27
- package/dist/runtime/text-geometry.js.map +1 -1
- package/dist/sdk/index.d.ts +1 -7
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +30 -138
- package/dist/sdk/index.js.map +1 -1
- package/dist/tween/command-decorator.d.ts +6 -26
- package/dist/tween/command-decorator.d.ts.map +1 -1
- package/dist/tween/command-decorator.js +1 -6
- package/dist/tween/command-decorator.js.map +1 -1
- package/dist/tween/command.d.ts +6 -53
- package/dist/tween/command.d.ts.map +1 -1
- package/dist/tween/command.js +5 -40
- package/dist/tween/command.js.map +1 -1
- package/dist/tween/ease/curve.d.ts +2 -17
- package/dist/tween/ease/curve.d.ts.map +1 -1
- package/dist/tween/ease/curve.js +1 -6
- package/dist/tween/ease/curve.js.map +1 -1
- package/dist/tween/ease/describe.d.ts +0 -11
- package/dist/tween/ease/describe.d.ts.map +1 -1
- package/dist/tween/ease/describe.js +0 -23
- package/dist/tween/ease/describe.js.map +1 -1
- package/dist/tween/ease/spec.d.ts +2 -18
- package/dist/tween/ease/spec.d.ts.map +1 -1
- package/dist/tween/ease/spec.js.map +1 -1
- package/dist/tween/inert.d.ts +1 -14
- package/dist/tween/inert.d.ts.map +1 -1
- package/dist/tween/inert.js +1 -14
- package/dist/tween/inert.js.map +1 -1
- package/dist/tween/lerp.d.ts +2 -26
- package/dist/tween/lerp.d.ts.map +1 -1
- package/dist/tween/lerp.js +2 -26
- package/dist/tween/lerp.js.map +1 -1
- package/dist/tween/loop.d.ts +9 -50
- package/dist/tween/loop.d.ts.map +1 -1
- package/dist/tween/loop.js +6 -31
- package/dist/tween/loop.js.map +1 -1
- package/dist/tween/prepare.d.ts +2 -30
- package/dist/tween/prepare.d.ts.map +1 -1
- package/dist/tween/prepare.js +2 -30
- package/dist/tween/prepare.js.map +1 -1
- package/dist/tween/stepper.d.ts +4 -25
- package/dist/tween/stepper.d.ts.map +1 -1
- package/dist/tween/stepper.js.map +1 -1
- package/dist/tween/to-command.d.ts +1 -8
- package/dist/tween/to-command.d.ts.map +1 -1
- package/dist/tween/to-command.js +2 -25
- package/dist/tween/to-command.js.map +1 -1
- package/dist/util/context.d.ts +4 -29
- package/dist/util/context.d.ts.map +1 -1
- package/dist/util/context.js +3 -15
- package/dist/util/context.js.map +1 -1
- package/dist/util/csv.d.ts +4 -29
- package/dist/util/csv.d.ts.map +1 -1
- package/dist/util/csv.js +3 -22
- package/dist/util/csv.js.map +1 -1
- package/dist/util/metrics.d.ts +2 -26
- package/dist/util/metrics.d.ts.map +1 -1
- package/dist/util/metrics.js +2 -26
- package/dist/util/metrics.js.map +1 -1
- package/dist/util/random.d.ts +20 -87
- package/dist/util/random.d.ts.map +1 -1
- package/dist/util/random.js +20 -87
- package/dist/util/random.js.map +1 -1
- package/dist/util/reference.d.ts +6 -35
- package/dist/util/reference.d.ts.map +1 -1
- package/dist/util/reference.js +1 -4
- package/dist/util/reference.js.map +1 -1
- package/dist/util/scheduler.d.ts +6 -27
- package/dist/util/scheduler.d.ts.map +1 -1
- package/dist/util/scheduler.js +8 -35
- package/dist/util/scheduler.js.map +1 -1
- package/package.json +1 -1
- package/dist/browser/chunks/chunk-4BDLFEOC.js.map +0 -7
- package/dist/browser/chunks/chunk-CCGVIR4F.js.map +0 -7
- package/dist/browser/chunks/chunk-N4WSN5WY.js +0 -13
- package/dist/browser/chunks/chunk-N4WSN5WY.js.map +0 -7
- package/dist/browser/chunks/chunk-WZSI3GSK.js +0 -6
- package/dist/browser/chunks/chunk-WZSI3GSK.js.map +0 -7
- package/dist/renamed-scene-names.d.ts +0 -17
- package/dist/renamed-scene-names.d.ts.map +0 -1
- package/dist/renamed-scene-names.js +0 -9
- package/dist/renamed-scene-names.js.map +0 -1
- package/dist/runtime/precompisition.d.ts +0 -24
- package/dist/runtime/precompisition.d.ts.map +0 -1
- package/dist/runtime/precompisition.js +0 -7
- package/dist/runtime/precompisition.js.map +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/attributes/shape/corners/corners.ts", "../../../src/attributes/shape/corners/corner-radius.ts", "../../../src/attributes/shape/corners/corner-style.ts", "../../../src/attributes/shape/effects/effect-data.ts", "../../../src/attributes/shape/fill/lerp.ts", "../../../src/attributes/shape/effects/spec.ts", "../../../src/attributes/shape/effects/implementations/motion-blur.ts", "../../../src/attributes/shape/effects/implementations/ascii.ts", "../../../src/attributes/shape/fill/blend.ts", "../../../src/attributes/shape/shaders/uniforms.ts", "../../../src/attributes/shape/shaders/language.ts", "../../../src/attributes/shape/effects/implementations/blur.ts", "../../../src/attributes/shape/effects/implementations/directional-blur.ts", "../../../src/attributes/shape/effects/implementations/grayscale.ts", "../../../src/attributes/shape/effects/implementations/pixelate.ts", "../../../src/attributes/shape/effects/implementations/bulge.ts", "../../../src/attributes/shape/effects/implementations/magnify.ts", "../../../src/attributes/shape/effects/implementations/bloom.ts", "../../../src/attributes/shape/effects/implementations/vintage.ts", "../../../src/attributes/shape/effects/implementations/chromatic-aberration.ts", "../../../src/attributes/shape/effects/implementations/invert.ts", "../../../src/attributes/shape/effects/implementations/scatter.ts", "../../../src/attributes/shape/effects/implementations/posterize.ts", "../../../src/attributes/shape/effects/implementations/shader.ts", "../../../src/attributes/shape/effects/implementations/outline.ts", "../../../src/attributes/shape/effects/implementations/drop-shadow.ts", "../../../src/attributes/shape/effects/implementations/vignette.ts", "../../../src/attributes/shape/effects/implementations/grain.ts", "../../../src/attributes/shape/effects/implementations/sharpen.ts", "../../../src/attributes/shape/effects/implementations/edges.ts", "../../../src/attributes/shape/effects/implementations/threshold.ts", "../../../src/attributes/shape/effects/implementations/radial-blur.ts", "../../../src/attributes/shape/effects/implementations/halftone.ts", "../../../src/attributes/shape/effects/implementations/dither.ts", "../../../src/attributes/shape/effects/implementations/duotone.ts", "../../../src/attributes/shape/effects/implementations/curves.ts", "../../../src/attributes/shape/effects/implementations/color-adjustment.ts", "../../../src/attributes/shape/effects/implementations/rgb-shift.ts", "../../../src/attributes/shape/effects/implementations/scanlines.ts", "../../../src/attributes/shape/effects/implementations/block-displace.ts", "../../../src/attributes/shape/effects/implementations/bit-crush.ts", "../../../src/attributes/shape/effects/implementations/streak.ts", "../../../src/attributes/shape/effects/implementations/glow.ts", "../../../src/attributes/shape/effects/implementations/oil-paint.ts", "../../../src/attributes/shape/effects/implementations/wave.ts", "../../../src/attributes/shape/effects/implementations/twirl.ts", "../../../src/attributes/shape/effects/implementations/progressive-blur.ts", "../../../src/attributes/shape/effects/implementations/kaleidoscope.ts", "../../../src/attributes/shape/effects/implementations/glass.ts", "../../../src/attributes/shape/effects/implementations/lut.ts", "../../../src/attributes/shape/effects/registry.ts", "../../../src/attributes/shape/shaders/resolve.ts", "../../../src/attributes/shape/effects/chain.ts", "../../../src/attributes/shape/effects/backdrop.ts", "../../../src/attributes/shape/fill/chain.ts", "../../../src/attributes/shape/fill/implementations/grid.ts", "../../../src/attributes/shape/filters/implementations/exposure.ts", "../../../src/attributes/shape/filters/implementations/blur.ts", "../../../src/attributes/shape/filters/implementations/grayscale.ts", "../../../src/attributes/shape/filters/implementations/alpha.ts", "../../../src/attributes/shape/filters/implementations/color-matrix.ts", "../../../src/attributes/shape/filters/implementations/curves.ts", "../../../src/attributes/shape/filters/implementations/color-adjustment.ts", "../../../src/attributes/shape/filters/implementations/posterize-time.ts", "../../../src/attributes/shape/filters/implementations/echo.ts", "../../../src/attributes/shape/filters/registry.ts", "../../../src/attributes/shape/filters/chain.ts", "../../../src/attributes/layout/alignment.ts", "../../../src/attributes/layout/insets.ts", "../../../src/attributes/shape/fill/media-preset.ts", "../../../src/attributes/shape/fill/implementations/image.ts", "../../../src/attributes/shape/fill/implementations/video.ts", "../../../src/render/descriptors/path-builder.ts", "../../../src/render/graphics2d.ts", "../../../src/render3d/texture.ts", "../../../src/render3d/fill3d.ts", "../../../src/render3d/inert.ts", "../../../src/render3d/graphics3d.ts", "../../../src/render3d/render-context3d.ts", "../../../src/render3d/scene-settings.ts", "../../../src/render3d/scene3d.ts", "../../../src/render3d/resources.ts", "../../../src/render3d/walk.ts", "../../../src/attributes/shape/fill/coerce.ts", "../../../src/attributes/shape/fill/implementations/color.ts", "../../../src/attributes/shape/fill/gradient-stops.ts", "../../../src/attributes/shape/fill/implementations/linear-gradient.ts", "../../../src/attributes/shape/fill/implementations/radial-gradient.ts", "../../../src/attributes/shape/fill/implementations/conic-gradient.ts", "../../../src/attributes/shape/fill/implementations/noise.ts", "../../../src/attributes/shape/fill/implementations/fractal-noise.ts", "../../../src/attributes/shape/fill/implementations/stripe.ts", "../../../src/attributes/shape/fill/implementations/dot-grid.ts", "../../../src/attributes/shape/fill/implementations/shader.ts", "../../../src/render3d/tracking.ts", "../../../src/attributes/shape/fill/implementations/canvas3d.ts", "../../../src/attributes/shape/fill/registry.ts", "../../../src/attributes/shape/shadow/shadow.ts", "../../../src/attributes/shape/stroke/stroke.ts", "../../../src/util/clamp.ts", "../../../src/tween/ease/describe.ts", "../../../src/tween/ease/constants.ts", "../../../src/tween/ease/curve.ts", "../../../src/tween/ease/spec.ts", "../../../src/attributes/audio/ramp.ts", "../../../src/attributes/audio/effects/chain.ts", "../../../src/attributes/audio/effects/implementations/gain.ts", "../../../src/attributes/audio/effects/implementations/highpass.ts", "../../../src/attributes/audio/effects/implementations/lowpass.ts", "../../../src/attributes/audio/effects/implementations/tremolo.ts", "../../../src/attributes/audio/effects/implementations/echo.ts", "../../../src/attributes/audio/effects/registry.ts", "../../../src/attributes/layout/matrix2d.ts", "../../../src/attributes/layout/space3d.ts", "../../../src/attributes/layout/size.ts", "../../../src/attributes/text/ops.ts", "../../../src/attributes/properties/decorator.ts", "../../../src/props/slot.ts", "../../../src/tween/to-command.ts", "../../../src/tween/loop.ts", "../../../src/tween/command.ts", "../../../src/tween/prepare.ts", "../../../src/util/context.ts", "../../../src/props/layout.ts", "../../../src/props/host.ts", "../../../src/tween/command-decorator.ts", "../../../src/props/observer.ts", "../../../src/tween/inert.ts", "../../../src/components/trees/node/node-reactive.ts", "../../../src/components/trees/node/node-time.ts", "../../../src/components/trees/node/node.ts", "../../../src/assets/errors.ts", "../../../src/layout/item.ts", "../../../src/layout/flex.ts", "../../../src/layout/freeform.ts", "../../../src/layout/grid.ts", "../../../src/layout/ops.ts", "../../../src/render3d/vector3.ts", "../../../src/render/clip.ts", "../../../src/attributes/properties/typed.ts", "../../../src/components/trees/2d/node-motion.ts", "../../../src/components/trees/2d/node-lifecycle.ts", "../../../src/attributes/layout/transform3d.ts", "../../../src/components/trees/2d/node-transform.ts", "../../../src/components/trees/2d/node-space.ts", "../../../src/components/trees/2d/node-render.ts", "../../../src/components/trees/2d/node2d.ts", "../../../src/components/trees/audio/node-audio.ts", "../../../src/components/trees/three/node3d.ts", "../../../src/document/node-decorator.ts", "../../../src/render/descriptors/shape.ts", "../../../src/render/descriptors/rect.ts", "../../../src/render/descriptors/ellipse.ts", "../../../src/render/descriptors/polygon.ts", "../../../src/render/descriptors/polygram.ts", "../../../src/render/descriptors/line.ts", "../../../src/render/clip-contains.ts", "../../../src/document/expression/types.ts", "../../../src/document/expression/parse.ts", "../../../src/document/expression/compile.ts", "../../../src/document/expression/walk.ts", "../../../src/document/expression/ops.ts", "../../../src/document/prop-evolution.ts", "../../../src/render/text-defaults.ts", "../../../src/render/canvas-render-context2d.ts", "../../../src/render/null-render-context.ts", "../../../src/components/factory/clip-of.ts", "../../../src/components/factory/timeline.ts", "../../../src/components/factory/type-def.ts", "../../../src/components/factory/views.ts", "../../../src/components/factory/factory.ts", "../../../src/components/trees/2d/group-bounds.ts", "../../../src/components/factory/component2d.ts", "../../../src/components/factory/types.ts", "../../../src/components/modules/corners.ts", "../../../src/components/modules/flow.ts", "../../../src/components/factory/commands-for.ts", "../../../src/components/modules/paint.ts", "../../../src/components/modules/shapes.ts", "../../../src/components/modules/aim.ts", "../../../src/render/descriptors/text.ts", "../../../src/components/modules/text-layout.ts", "../../../src/components/builtins/text/text-layout.ts", "../../../src/runtime/builtin-context.ts", "../../../src/components/factory/api.ts", "../../../src/components/modules/text-style.ts", "../../../src/components/factory/component-audio.ts", "../../../src/components/factory/component3d.ts", "../../../src/components/modules/material.ts", "../../../src/components/modules/three-entries.ts", "../../../src/components/modules/view3d.ts", "../../../src/components/builtins/three/grid-geometry3d.ts"],
|
|
4
|
+
"sourcesContent": ["import { LerpFunction } from \"@/tween/lerp\";\n\n/** A value supplied independently for each of the four corners. */\nexport interface Corners<T> {\n topLeft: T;\n topRight: T;\n bottomLeft: T;\n bottomRight: T;\n}\n\n/** The input grammar for any per-corner property, generic over the corner value `T`: a single `T` applies to all four; `{ topLeft, … }` overrides individual corners (the rest fall back to a previous value or the default); `{ top, bottom }` sets the top and/or bottom pair; `{ left, right }` the left and/or right pair. */\nexport type CornersInput<T> =\n | T\n | Partial<Corners<T>>\n | { top?: T; bottom?: T }\n | { left?: T; right?: T };\n\nexport type CornerScalarGuard<T> = (value: CornersInput<T>) => value is T;\n\nfunction makeUniform<T>(value: T): Corners<T> {\n return { topLeft: value, topRight: value, bottomLeft: value, bottomRight: value };\n}\n\n// The {top,bottom} / {left,right} shorthands map to corners here, a single test-pinned chokepoint.\nfunction fromTopBottom<T>(v: { top?: T; bottom?: T }, fb: Corners<T>): Corners<T> {\n return {\n topLeft: v.top ?? fb.topLeft,\n topRight: v.top ?? fb.topRight,\n bottomLeft: v.bottom ?? fb.bottomLeft,\n bottomRight: v.bottom ?? fb.bottomRight,\n };\n}\n\nfunction fromLeftRight<T>(v: { left?: T; right?: T }, fb: Corners<T>): Corners<T> {\n return {\n topLeft: v.left ?? fb.topLeft,\n topRight: v.right ?? fb.topRight,\n bottomLeft: v.left ?? fb.bottomLeft,\n bottomRight: v.right ?? fb.bottomRight,\n };\n}\n\n/** Resolves a {@link CornersInput} to a full {@link Corners}; precedence per corner is supplied value → `previous` → `fallback`. `isScalar` discriminates the scalar form from the object forms. */\nexport function resolveCorners<T>(\n value: CornersInput<T>,\n fallback: T,\n previous: Corners<T> | undefined,\n isScalar: CornerScalarGuard<T>,\n): Corners<T> {\n if (isScalar(value)) {\n return makeUniform(value);\n }\n\n const fb: Corners<T> = previous ?? makeUniform(fallback);\n const obj = value as Record<string, T | undefined>;\n\n // Per-corner keys take precedence over the axis shorthands when mixed, so\n // the more specific form wins.\n if (\"topLeft\" in obj || \"topRight\" in obj || \"bottomLeft\" in obj || \"bottomRight\" in obj) {\n const v = value as Partial<Corners<T>>;\n return {\n topLeft: v.topLeft ?? fb.topLeft,\n topRight: v.topRight ?? fb.topRight,\n bottomLeft: v.bottomLeft ?? fb.bottomLeft,\n bottomRight: v.bottomRight ?? fb.bottomRight,\n };\n }\n if (\"top\" in obj || \"bottom\" in obj) {\n return fromTopBottom(value as { top?: T; bottom?: T }, fb);\n }\n if (\"left\" in obj || \"right\" in obj) {\n return fromLeftRight(value as { left?: T; right?: T }, fb);\n }\n return { ...fb };\n}\n\n/** Interpolates each corner independently with the supplied per-value lerp. */\nexport function lerpCorners<T>(\n from: Corners<T>,\n to: Corners<T>,\n t: number,\n lerp: LerpFunction<T>,\n): Corners<T> {\n return {\n topLeft: lerp(from.topLeft, to.topLeft, t),\n topRight: lerp(from.topRight, to.topRight, t),\n bottomLeft: lerp(from.bottomLeft, to.bottomLeft, t),\n bottomRight: lerp(from.bottomRight, to.bottomRight, t),\n };\n}\n\n/** Returns true when all four corners are equal (under `eq`, default `Object.is`). */\nexport function isUniformCorners<T>(c: Corners<T>, eq: (a: T, b: T) => boolean = Object.is): boolean {\n return eq(c.topLeft, c.topRight) && eq(c.topLeft, c.bottomLeft) && eq(c.topLeft, c.bottomRight);\n}\n", "import { lerpNumber } from \"@/tween/lerp\";\nimport type { CornerRadiusOps } from \"@/attributes/shared/operators\";\nimport { Corners, CornersInput, resolveCorners, lerpCorners, isUniformCorners } from \"./corners\";\n\n/** Per-corner border radius values, all fully resolved to numbers. */\nexport type CornerRadiusResolved = Corners<number>;\n\n/** Corner radius input for a Rect: one number for all corners, or an object per corner (`{ topLeft, … }`) or axis (`{ top, bottom }` / `{ left, right }`); an already-resolved value passes through. Unspecified corners fall back to a previous value or 0. */\nexport type RectCornerRadius = CornersInput<number> | CornerRadiusResolved;\n\n/**\n * The corner-radius attribute's op set: `resolve`/`lerp` for `Shapes.corners`,\n * plus the uniform/zero checks a renderer needs to pick a cheap draw path.\n */\nexport const cornerRadiusOps: CornerRadiusOps = {\n // A resolved value is structurally a full per-corner `CornersInput<number>`,\n // so pin T=number and let resolveCorners re-resolve it idempotently.\n resolve: (value, previous) => resolveCorners(value as CornersInput<number>, 0, previous, (v): v is number => typeof v === \"number\"),\n lerp: (from, to, t) => lerpCorners(from, to, t, lerpNumber),\n isUniformInput: (value): value is number => typeof value === \"number\",\n isUniform: (value) => isUniformCorners(value),\n isZero: (value) => value.topLeft === 0 && value.topRight === 0 && value.bottomLeft === 0 && value.bottomRight === 0,\n};\n", "import { LerpFunction } from \"@/tween/lerp\";\nimport type { AttributeOps, HasUniformCheck } from \"@/attributes/shared/operators\";\nimport { Corners, CornersInput, resolveCorners, lerpCorners, isUniformCorners } from \"./corners\";\n\n/** How a corner with a non-zero radius is shaped: `'rounded'` (a circular arc) or `'angled'` (a straight chamfer). */\nexport type CornerStyle = \"rounded\" | \"angled\";\n\nexport type CornerStyleResolved = Corners<CornerStyle>;\n\n/** Corner style input for a Rect: one {@link CornerStyle} for all corners, or an object per corner (`{ topLeft, … }`) or axis (`{ top, bottom }` / `{ left, right }`); an already-resolved value passes through. Unspecified corners fall back to a previous value or `'rounded'`. */\nexport type RectCornerStyle = CornersInput<CornerStyle> | CornerStyleResolved;\n\n/** The corner-style op set. No zero check (style has no zero value); style is a discrete enum, so \"interpolating\" snaps at `t = 0.5`, as for other discrete properties (see the pixelate effect). */\nexport const cornerStyleOps: AttributeOps<RectCornerStyle, CornerStyleResolved>\n & HasUniformCheck<RectCornerStyle, CornerStyleResolved> = {\n resolve: (value, previous) => resolveCorners(value as CornersInput<CornerStyle>, \"rounded\", previous, (v): v is CornerStyle => v === \"rounded\" || v === \"angled\"),\n lerp: (from, to, t) => lerpCorners(from, to, t, (f, g) => (t < 0.5 ? f : g)),\n isUniformInput: (value): value is CornerStyle => value === \"rounded\" || value === \"angled\",\n isUniform: (value) => isUniformCorners(value),\n};\n\n/** Scalar corner style tween for shapes whose vertices don't map to named corners (polygons and polygrams apply one style to every vertex), instead of {@link cornerStyleOps}'s per-corner form. */\nexport const lerpCornerScalarStyle: LerpFunction<CornerStyle> = (from, to, t) => (t < 0.5 ? from : to);\n", "import type { Vector2 } from \"@/attributes/layout/vector2\";\nimport type { AssetScope } from \"@/assets/scope\";\nimport type { Color, NormalizedColor } from \"../fill/color/parser\";\nimport { parseColor } from \"../fill/color/parser\";\n\n/** `foreground` (default) is the node's own content; `backdrop` is what is already painted beneath it, clipped to the node's silhouette (Figma-style). */\nexport type EffectMode = \"foreground\" | \"backdrop\";\n\n/**\n * How a backend must realise an effect: `\"filter\"` (default) transforms colours in place and composes as a\n * plain image filter; `\"shader\"` resamples pixel positions, so it needs the content snapshotted into a texture.\n */\nexport type EffectSurface = \"filter\" | \"shader\";\n\n/** `\"both\"` is `{ x: 1, y: 1 }`; a {@link Vector2} gives fractional control per axis. */\nexport type EffectAxis = \"x\" | \"y\" | \"both\" | Vector2;\n\nexport function resolveEffectAxis(axis: EffectAxis): Vector2 {\n switch (axis) {\n case \"x\": return { x: 1, y: 0 };\n case \"y\": return { x: 0, y: 1 };\n case \"both\": return { x: 1, y: 1 };\n default: return { x: axis.x, y: axis.y };\n }\n}\n\nexport function sameEffectAxis(a: EffectAxis, b: EffectAxis): boolean {\n const av = resolveEffectAxis(a);\n const bv = resolveEffectAxis(b);\n return av.x === bv.x && av.y === bv.y;\n}\n\n/**\n * Colour options are stored **as authored** (CSS string, theme alias or tuple), not parsed at build time, so a\n * raw effect literal behaves like the builder form and a theme alias resolves against the current `setTheme`.\n */\nexport function resolveEffectColor(color: Color): NormalizedColor {\n return Array.isArray(color) ? color : parseColor(color);\n}\n\n/** Do two colour options resolve to the same RGBA? (`'red'` === `'#ff0000'`.) */\nexport function sameEffectColor(a: Color, b: Color): boolean {\n if (a === b) return true;\n const av = resolveEffectColor(a);\n const bv = resolveEffectColor(b);\n return av[0] === bv[0] && av[1] === bv[1] && av[2] === bv[2] && av[3] === bv[3];\n}\n\n/** Omitted `mode` is `\"foreground\"`; one uniform field means the backdrop classifier never branches on `type`. */\nexport interface ModedEffect {\n mode?: EffectMode;\n /**\n * Confine the effect's output to the node's own silhouette rather than the rectangle its bleed would fill\n * (a bloom that doesn't halo the page, a blur that doesn't fray the edge). Honoured on both render paths;\n * redundant in `mode: 'backdrop'`, which is already confined.\n */\n clip?: boolean;\n}\n\n/** Cross-cutting options accepted by every effect builder. A new chain-wide option goes here and in {@link EFFECT_OPTION_KEYS}. */\nexport type EffectOptions = ModedEffect;\n\n/** The {@link EffectOptions} keys {@link withEffectOptions} copies; `satisfies` keeps it in step with the interface. */\nexport const EFFECT_OPTION_KEYS = [\"mode\", \"clip\"] as const satisfies readonly (keyof EffectOptions)[];\n\n/** Merges options onto a built effect, **skipping undefined keys**: `equals()` compares `mode` directly, so an explicit `mode: undefined` would differ from an unset one. */\nexport function withEffectOptions<T extends object>(base: T, options?: EffectOptions): T & EffectOptions {\n const out = { ...base } as T & EffectOptions;\n if (!options) return out;\n for (const key of EFFECT_OPTION_KEYS) {\n const value = options[key];\n // Written through a widened view: `out[key]` would narrow to `never` under a union key.\n if (value !== undefined) (out as Record<string, unknown>)[key] = value;\n }\n return out;\n}\n\n/** Every builder takes one argument; those with a dominant scalar also accept it directly, so `blur(8)` equals `blur({ radius: 8 })`. `key` is the field a bare number maps onto. */\nexport function scalarOptions<O extends object>(\n arg: number | O | undefined,\n key: keyof O,\n): Partial<O> & EffectOptions {\n if (arg === undefined) return {};\n if (typeof arg === \"number\") return { [key]: arg } as Partial<O> & EffectOptions;\n return arg;\n}\n\nexport interface EffectData<T> {\n lerp: (from: T, to: T, t: number) => T;\n\n equals: (a: T, b: T) => boolean;\n\n /** Defaults to `\"filter\"`; may be a predicate when the surface depends on fields (a foreground shader composes as a filter, the same effect in backdrop mode resamples). */\n surface?: EffectSurface | ((effect: T) => EffectSurface);\n\n /**\n * Normalise an authored effect, called once per property write via `resolveChainEffects`, so this is the one\n * place a stored document can be migrated forward. **Return the effect unchanged when nothing needs\n * rewriting**: it runs on every write and identity avoids churn.\n */\n resolve?(effect: T): T;\n\n /** Declare textures the effect samples, as an image fill does; an undeclared asset reads as \"no texture\". */\n declare?(effect: T, assets: AssetScope): void;\n}\n", "// Per-channel colour interpolation on {@link NormalizedColor} tuples, for fill implementations that need it without the full fill-registry machinery.\n\nimport { Color, NormalizedColor, parseColor } from \"./color/parser\";\nimport type { AttributeOps } from \"@/attributes/shared/operators\";\n\n/** Linearly interpolates two normalized RGBA colors channel-by-channel. */\nexport function lerpColor(from: NormalizedColor, to: NormalizedColor, t: number): NormalizedColor {\n return [\n from[0] + (to[0] - from[0]) * t,\n from[1] + (to[1] - from[1]) * t,\n from[2] + (to[2] - from[2]) * t,\n from[3] + (to[3] - from[3]) * t,\n ];\n}\n\n/** Helpers the colour attribute carries beyond its mapper and lerp. */\nexport interface ColorOps {\n /** `#rrggbb`, or `#rrggbbaa` when not opaque, for a consumer that takes a colour as a string. */\n hex(value: Color): string;\n}\n\n/** The colour attribute's op set: parses a CSS string (or passes a normalized tuple through) and interpolates in normalized space. */\nexport const colorOps: AttributeOps<Color, NormalizedColor> & ColorOps = {\n resolve,\n lerp: lerpColor,\n hex(value) {\n const [r, g, b, a] = resolve(value);\n const alpha = byte(a);\n return `#${byte(r)}${byte(g)}${byte(b)}${alpha === \"ff\" ? \"\" : alpha}`;\n },\n};\n\nfunction resolve(value: Color): NormalizedColor {\n return Array.isArray(value) ? value : parseColor(value);\n}\n\nfunction byte(channel: number): string {\n return Math.round(Math.min(1, Math.max(0, channel)) * 255).toString(16).padStart(2, \"0\");\n}\n\n", "import { lerpNumber } from \"@/tween/lerp\";\nimport { lerpVector2, type Vector2 } from \"@/attributes/layout/vector2\";\nimport { lerpColor } from \"@/attributes/shape/fill/lerp\";\nimport type { Color } from \"@/attributes/shape/fill/color/parser\";\nimport type { AssetScope } from \"@/assets/scope\";\nimport type { EffectAxis, EffectData, EffectMode, EffectOptions, EffectSurface, ModedEffect } from \"./effect-data\";\nimport { resolveEffectColor, sameEffectAxis, sameEffectColor, scalarOptions, withEffectOptions } from \"./effect-data\";\n\n/** How a parameter's value is shaped: its default interpolation, equality and uniform encoding. */\nexport type EffectParamKind =\n | \"number\"\n | \"color\"\n | \"vec2\"\n | \"enum\"\n | \"boolean\"\n | \"axis\"\n | \"text\"\n | \"colors\"\n | \"numbers\"\n | \"points\"\n | \"table\"\n | \"uniforms\";\n\n/** What a number measures, for a host's units and a renderer's scaling. */\nexport type EffectParamUnit = \"px\" | \"deg\" | \"percent\" | \"factor\" | \"normalized\";\n\n/** The picker family an effect is listed under. */\nexport type EffectGroup = \"blur\" | \"light\" | \"color\" | \"stylize\" | \"distort\" | \"glitch\";\n\n/** The control an inspector should draw for a parameter. */\nexport type EffectParamControl = \"number\" | \"slider\" | \"angle\" | \"hue\" | \"segmented\" | \"select\" | \"text\" | \"color\" | \"point\" | \"toggle\";\n\n/** Per-parameter inspector hints. None of them changes what the effect does. */\nexport interface EffectParamHints {\n /** i18n leaf for the field's label; defaults to the parameter name. */\n readonly label?: string;\n readonly control?: EffectParamControl;\n /** Shown on the effect's row beside its name (one per effect). */\n readonly inline?: boolean;\n /** Inspector position; defaults to the declaration order. */\n readonly order?: number;\n /** For an angle: where 0° points (the bearing turns clockwise). Defaults to `\"right\"`. */\n readonly zero?: \"right\" | \"top\";\n /** i18n group for an enum's option labels. */\n readonly optionsLabel?: string;\n /** Not offered as a field: the value a fresh effect carries is kept as is. */\n readonly hidden?: boolean;\n /** Where a freshly inserted effect starts, when the builder default would show nothing. */\n readonly initial?: unknown;\n}\n\n/** Interpolates one parameter. `from`/`to` are the whole effects, for parameters that depend on a sibling. */\nexport type EffectParamLerp<T> = (a: T, b: T, t: number, from: Record<string, unknown>, to: Record<string, unknown>) => T;\n\n/** One parameter of a built-in effect: a stored field. `T` is the stored type, `In` what a builder accepts (`normalize` maps one to the other); only the serialisable fields reach {@link EffectDescriptor}. */\nexport interface EffectParamDef<T = unknown, In = T> extends EffectParamHints {\n readonly kind: EffectParamKind;\n /** What the builder writes when the option is omitted (an input, before `normalize`). */\n readonly default?: In;\n /** The stored field may be absent (`colorAdjustment`'s fields, `curves.channel`). */\n readonly optional?: boolean;\n /** The builder's options type requires it. */\n readonly required?: boolean;\n readonly min?: number;\n readonly max?: number;\n readonly step?: number;\n readonly unit?: EffectParamUnit;\n /** An enum's values, in the order a renderer indexes them. */\n readonly options?: readonly (string | number)[];\n readonly normalize?: (input: In) => T;\n /** `\"step\"` switches at the midpoint; omitted uses the kind's interpolation. */\n readonly lerp?: \"step\" | EffectParamLerp<T>;\n readonly equals?: (a: T, b: T) => boolean;\n /** Type carrier only; never set. */\n readonly __type?: [T, In];\n}\n\n/** An effect's parameters, by stored field name, in builder (and stored-key) order. */\nexport type EffectParamTable = Readonly<Record<string, EffectParamDef<any, any>>>;\n\n/** The declarative definition of a built-in effect: its parameters plus the behaviour that has to stay code. Core's types, builder defaults, `lerp`/`equals` and the host-facing {@link EffectDescriptor} derive from it, and renderers bind shader uniforms to its parameter names. */\nexport interface EffectSpec<T extends string = string, P extends EffectParamTable = EffectParamTable> {\n readonly type: T;\n readonly params: P;\n readonly group: EffectGroup;\n /** The option a bare number passed to the builder sets. */\n readonly scalar?: string;\n /** The builder's `mode` when none is given. */\n readonly defaultMode?: EffectMode;\n /** The one layer the effect does anything on. */\n readonly onlyOn?: EffectMode;\n /** Builder options at which the effect draws nothing, or `null` when it has none. */\n readonly neutral: Readonly<Record<string, unknown>> | null;\n readonly surface?: EffectData<any>[\"surface\"];\n readonly resolve?: (effect: any) => any;\n readonly declare?: (effect: any, assets: AssetScope) => void;\n /** Wraps or replaces the derived interpolation, which it is handed as `derived`. */\n readonly lerp?: (from: any, to: any, t: number, derived: (from: any, to: any, t: number) => any) => any;\n readonly equals?: (a: any, b: any) => boolean;\n}\n\ntype ParamValue<D> = D extends { readonly __type?: [infer T, unknown] } ? T : never;\ntype ParamInput<D> = D extends { readonly __type?: [unknown, infer I] } ? I : never;\ntype IsOptional<D> = D extends { readonly optional: true } ? true : false;\ntype IsRequired<D> = D extends { readonly required: true } ? true : false;\n\n/** The stored fields an effect's parameters describe. */\nexport type EffectFields<P extends EffectParamTable> = {\n -readonly [K in keyof P as IsOptional<P[K]> extends true ? never : K]: ParamValue<P[K]>;\n} & {\n -readonly [K in keyof P as IsOptional<P[K]> extends true ? K : never]?: ParamValue<P[K]>;\n};\n\n/** A builder's options for an effect: every parameter as input, plus `mode`/`clip`. */\nexport type EffectOptionsOf<P extends EffectParamTable> = {\n -readonly [K in keyof P as IsRequired<P[K]> extends true ? K : never]: ParamInput<P[K]>;\n} & {\n -readonly [K in keyof P as IsRequired<P[K]> extends true ? never : K]?: ParamInput<P[K]>;\n} & EffectOptions;\n\n/** The effect object a spec describes. */\nexport type EffectOf<S extends EffectSpec> = { type: S[\"type\"] } & ModedEffect & EffectFields<S[\"params\"]>;\n\nexport function defineEffect<const T extends string, const P extends EffectParamTable>(\n spec: EffectSpec<T, P>,\n): EffectSpec<T, P> {\n return spec;\n}\n\n/** The middle of the layer, every centre option's default. */\nexport const CENTER: Vector2 = { x: 0.5, y: 0.5 };\n\ntype Options<T, In = T> = Omit<EffectParamDef<T, In>, \"kind\" | \"__type\" | \"options\" | \"normalize\" | \"lerp\" | \"equals\">;\n// Kept out of the inferred options so a lambda here is typed by its parameter.\ntype Behaviour<T> = Pick<EffectParamDef<T>, \"lerp\" | \"equals\">;\n\n/** Parameter constructors for {@link defineEffect}. */\nexport const param = {\n number<const O extends Options<number>>(o: O & Behaviour<number> & { normalize?: (input: number) => number }): EffectParamDef<number> & NoInfer<O> & { kind: \"number\" } {\n return { kind: \"number\", ...o };\n },\n color<const O extends Options<Color>>(o: O & Behaviour<Color>): EffectParamDef<Color> & NoInfer<O> & { kind: \"color\" } {\n return { kind: \"color\", ...o };\n },\n /** A point or per-axis pair. `fromNumber` lets the builder take a bare number for it. */\n vec2<const O extends Options<Vector2, number | Vector2> & { fromNumber?: \"both\" | \"y\" }>(\n o: O & Behaviour<Vector2>,\n ): EffectParamDef<Vector2, O extends { fromNumber: string } ? number | Vector2 : Vector2> & NoInfer<O> & { kind: \"vec2\" } {\n const normalize = o.fromNumber === undefined\n ? undefined\n : o.fromNumber === \"both\"\n ? (v: number | Vector2) => (typeof v === \"number\" ? { x: v, y: v } : v)\n : (v: number | Vector2) => (typeof v === \"number\" ? { x: 0, y: v } : v);\n return { kind: \"vec2\", ...(normalize ? { normalize } : {}), ...o } as never;\n },\n choice<const V extends string | number, const O extends Options<V>>(\n options: readonly V[],\n o: O & Behaviour<V>,\n ): EffectParamDef<V> & NoInfer<O> & { kind: \"enum\"; options: readonly V[] } {\n return { kind: \"enum\", options, lerp: \"step\", ...o };\n },\n boolean<const O extends Options<boolean>>(o: O & Behaviour<boolean>): EffectParamDef<boolean> & NoInfer<O> & { kind: \"boolean\" } {\n return { kind: \"boolean\", lerp: \"step\", ...o };\n },\n axis<const O extends Options<EffectAxis>>(o: O & Behaviour<EffectAxis>): EffectParamDef<EffectAxis> & NoInfer<O> & { kind: \"axis\" } {\n return { kind: \"axis\", lerp: \"step\", ...o };\n },\n text<V extends string = string, const O extends Options<V> = Options<V>>(o: O & Behaviour<V>): EffectParamDef<V> & NoInfer<O> & { kind: \"text\" } {\n return { kind: \"text\", lerp: \"step\", ...o };\n },\n /** A parameter of stored type `T` no generic kind covers, curried so `T` is given and options inferred: `param.of<Color[]>()({ kind: \"colors\", … })`. Steps and compares by `===` unless given `lerp`/`equals`. */\n of<T>() {\n return <const O extends Options<T> & { kind: EffectParamKind }>(o: O & Behaviour<T>): EffectParamDef<T> & NoInfer<O> =>\n ({ lerp: \"step\", ...o }) as never;\n },\n};\n\nconst step = <T>(a: T, b: T, t: number): T => (t < 0.5 ? a : b);\nconst same = (a: unknown, b: unknown) => a === b;\nconst sameVector = (a: Vector2, b: Vector2) => a.x === b.x && a.y === b.y;\n\nconst KIND_LERP: Partial<Record<EffectParamKind, EffectParamLerp<any>>> = {\n number: lerpNumber,\n color: (a: Color, b: Color, t) => lerpColor(resolveEffectColor(a), resolveEffectColor(b), t),\n vec2: lerpVector2,\n};\n\nconst KIND_EQUALS: Partial<Record<EffectParamKind, (a: any, b: any) => boolean>> = {\n color: sameEffectColor,\n vec2: sameVector,\n axis: sameEffectAxis,\n};\n\nfunction paramLerp(def: EffectParamDef<any, any>): EffectParamLerp<unknown> {\n if (typeof def.lerp === \"function\") return def.lerp;\n const kind = def.lerp === \"step\" ? undefined : KIND_LERP[def.kind];\n if (!kind) return step;\n // An absent optional field tweens from what it means when absent.\n if (def.optional && def.default !== undefined) {\n const fallback = def.default;\n return (a, b, t, from, to) => kind(a ?? fallback, b ?? fallback, t, from, to);\n }\n return kind;\n}\n\n/** The derived `EffectData` of a spec: generic per-kind `lerp`/`equals` unless the spec gives its own. */\nexport function effectDataOf<S extends EffectSpec>(spec: S): EffectData<EffectOf<S>> {\n const entries = Object.entries(spec.params);\n const lerps = entries.map(([name, def]) => [name, paramLerp(def)] as const);\n const equals = entries.map(([name, def]) => [name, def.equals ?? KIND_EQUALS[def.kind] ?? same] as const);\n const derived = (from: EffectOf<S>, to: EffectOf<S>, t: number): EffectOf<S> => {\n const out: Record<string, unknown> = { type: spec.type };\n const f = from as unknown as Record<string, unknown>;\n const g = to as unknown as Record<string, unknown>;\n for (const [name, lerp] of lerps) out[name] = lerp(f[name], g[name], t, f, g);\n return out as EffectOf<S>;\n };\n const custom = spec.lerp;\n const data: EffectData<EffectOf<S>> = {\n lerp: custom ? (from, to, t) => custom(from, to, t, derived) : derived,\n equals: spec.equals ?? ((a, b) => {\n const x = a as unknown as Record<string, unknown>;\n const y = b as unknown as Record<string, unknown>;\n return equals.every(([name, eq]) => eq(x[name], y[name]));\n }),\n };\n if (spec.surface !== undefined) data.surface = spec.surface;\n if (spec.resolve) data.resolve = spec.resolve;\n if (spec.declare) data.declare = spec.declare;\n return data;\n}\n\n// Arrays are copied so editing one effect's list never reaches another's; objects (a centre point) are shared.\nconst copyDefault = (value: unknown) => (Array.isArray(value) ? [...value] : value);\n\n/**\n * Builds an effect from builder input: the scalar shorthand, then each\n * parameter's option or default (normalised), then `mode`/`clip`.\n */\nexport function buildEffect<S extends EffectSpec>(\n spec: S,\n arg: number | EffectOptionsOf<S[\"params\"]> | undefined,\n): EffectOf<S> {\n const o = (spec.scalar\n ? scalarOptions(arg as number | Record<string, unknown> | undefined, spec.scalar as never)\n : (arg ?? {})) as Record<string, unknown> & EffectOptions;\n const out: Record<string, unknown> = { type: spec.type };\n for (const [name, def] of Object.entries(spec.params)) {\n const value = o[name] ?? copyDefault(def.default);\n if (value === undefined) continue;\n out[name] = def.normalize ? def.normalize(value) : value;\n }\n const options = spec.defaultMode && o.mode === undefined ? { ...o, mode: spec.defaultMode } : o;\n return withEffectOptions(out, options) as unknown as EffectOf<S>;\n}\n\n/** A JSON value — what every field of an {@link EffectDescriptor} is made of. */\nexport type EffectJson = string | number | boolean | null | EffectJson[] | { [key: string]: EffectJson };\n\n/** One parameter of an {@link EffectDescriptor}. */\nexport interface EffectParamDescriptor {\n /** The stored field it writes. */\n name: string;\n kind: EffectParamKind;\n /** What the builder writes when it is omitted, as stored (colours as authored). */\n default?: EffectJson;\n /** The builder's options require it. */\n required?: boolean;\n /** The stored field may be absent. */\n optional?: boolean;\n min?: number;\n max?: number;\n step?: number;\n unit?: EffectParamUnit;\n options?: (string | number)[];\n /** Tweens continuously (false: switches at the midpoint). */\n animatable: boolean;\n /** i18n leaf for the label; the name unless the spec says otherwise. */\n label: string;\n control?: EffectParamControl;\n inline?: boolean;\n /** Inspector position. */\n order: number;\n zero?: \"right\" | \"top\";\n optionsLabel?: string;\n hidden?: boolean;\n initial?: EffectJson;\n}\n\n/** A built-in effect described for a host (fields, kinds, defaults, ranges, inspector layout) as plain JSON, shippable to a UI as is. */\nexport interface EffectDescriptor {\n type: string;\n group: EffectGroup;\n /** `\"dynamic\"`: depends on the effect's `mode` (the user shader). */\n surface: EffectSurface | \"dynamic\";\n scalar?: string;\n defaultMode?: EffectMode;\n onlyOn?: EffectMode;\n /** Stored fields at which it draws nothing (the rest at their defaults); `null` when it has none. */\n neutral: { [key: string]: EffectJson } | null;\n /** In stored-key order; sort by `order` for the inspector's. */\n params: EffectParamDescriptor[];\n}\n\nconst json = (value: unknown): EffectJson | undefined =>\n value === undefined ? undefined : (JSON.parse(JSON.stringify(value)) as EffectJson);\n\n/** The serialisable {@link EffectDescriptor} of a spec. */\nexport function describeSpec(spec: EffectSpec): EffectDescriptor {\n const params = Object.entries(spec.params).map(([name, def], index): EffectParamDescriptor => {\n const stored = def.default !== undefined && def.normalize ? def.normalize(def.default) : def.default;\n const out: EffectParamDescriptor = {\n name,\n kind: def.kind,\n animatable: def.lerp !== \"step\",\n label: def.label ?? name,\n order: def.order ?? index,\n };\n const optional = {\n default: json(stored),\n required: def.required,\n optional: def.optional,\n min: def.min,\n max: def.max,\n step: def.step,\n unit: def.unit,\n options: def.options ? [...def.options] : undefined,\n control: def.control,\n inline: def.inline,\n zero: def.zero,\n optionsLabel: def.optionsLabel,\n hidden: def.hidden,\n initial: json(def.initial),\n };\n for (const [key, value] of Object.entries(optional)) {\n if (value !== undefined) (out as unknown as Record<string, unknown>)[key] = value;\n }\n return out;\n });\n const out: EffectDescriptor = {\n type: spec.type,\n group: spec.group,\n surface: typeof spec.surface === \"function\" ? \"dynamic\" : (spec.surface ?? \"filter\"),\n neutral: spec.neutral === null ? null : (json(Object.fromEntries(Object.entries(spec.neutral).map(([name, value]) => {\n const normalize = spec.params[name]?.normalize;\n return [name, normalize ? normalize(value) : value];\n }))) as { [key: string]: EffectJson }),\n params,\n };\n if (spec.scalar) out.scalar = spec.scalar;\n if (spec.defaultMode) out.defaultMode = spec.defaultMode;\n if (spec.onlyOn) out.onlyOn = spec.onlyOn;\n return out;\n}\n", "import { lerpNumber } from \"@/tween/lerp\";\nimport { lerpVector2 } from \"@/attributes/layout/vector2\";\nimport type { ModedEffect, EffectData } from \"../effect-data\";\nimport { resolveEffectAxis } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** Shutter phase presets — see {@link MotionBlurEffect.alignment}. */\nexport type MotionBlurAlignment = \"behind\" | \"centered\" | \"ahead\" | number;\n\n/** Velocity-driven motion blur: unlike {@link DirectionalBlurEffect}'s authored smear, direction and length derive from the node's actual per-frame motion (sampled by the renderer), modelled on After Effects' shutter angle (`length`) and phase (`alignment`). A static node renders sharp. */\nexport interface MotionBlurEffect extends ModedEffect, EffectFields<typeof motionBlurSpec.params> {\n type: \"motionBlur\";\n}\n\n/** Resolve {@link MotionBlurEffect.alignment} to a shutter-phase number in −1…1. */\nexport function resolveMotionBlurAlignment(alignment: MotionBlurAlignment): number {\n switch (alignment) {\n case \"behind\": return -1;\n case \"centered\": return 0;\n case \"ahead\": return 1;\n default: return Math.max(-1, Math.min(1, alignment));\n }\n}\n\nexport const motionBlurSpec = defineEffect({\n type: \"motionBlur\",\n group: \"blur\",\n scalar: \"length\",\n neutral: { length: 0 },\n params: {\n /** Shutter \"openness\" as a percentage, the friendly form of a shutter angle: `100` ≈ 360° (a smear spanning the full per-frame displacement), `0` no blur. */\n length: param.number({ default: 50, min: 0, unit: \"percent\", label: \"shutter\", inline: true }),\n /** Shutter phase along the node's motion: `'behind'` (−1) trails it, `'centered'` (0) straddles, `'ahead'` (1) leads; a number in −1…1 sits between. */\n alignment: param.of<MotionBlurAlignment>()({\n kind: \"enum\",\n default: \"centered\",\n options: [\"centered\", \"behind\", \"ahead\"],\n optionsLabel: \"motionBlurAlignment\",\n // Resolved to a phase, so e.g. 'behind' → 'ahead' sweeps.\n lerp: (a, b, t) => lerpNumber(resolveMotionBlurAlignment(a), resolveMotionBlurAlignment(b), t),\n equals: (a, b) => resolveMotionBlurAlignment(a) === resolveMotionBlurAlignment(b),\n }),\n /** Renderer quality hint; above 32 switches to multi-tap accumulation. */\n samples: param.number({ default: 16, min: 1, step: 1, hidden: true }),\n /** Blur-length multiplier. */\n strength: param.number({ default: 1, min: 0, max: 2, control: \"slider\" }),\n /** Per-axis velocity scale. */\n axis: param.axis({\n default: \"both\",\n optionsLabel: \"effectAxis\",\n lerp: (a, b, t) => lerpVector2(resolveEffectAxis(a), resolveEffectAxis(b), t),\n }),\n },\n});\n\nexport const motionBlurEffect: EffectData<MotionBlurEffect> = effectDataOf(motionBlurSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/**\n * Built-in glyph ramps, each ordered **least ink first** (`charset[0]` for the darkest cells). On the default white ink\n * over black an empty cell is the darkest thing drawn, so least-ink-first is dark-to-light; with ink and background\n * inverted the same ramp is used back to front automatically, so a custom ramp is written once. `'standard'` is the\n * classic ten-step ramp, `'blocks'` Unicode shading blocks (most legible small, each step a fixed coverage fraction),\n * `'braille'` the finest, `'binary'` a two-tone cut, `'hex'` a nominal ramp (ink doesn't track the digit: texture, not tone).\n */\nexport type AsciiCharset = \"standard\" | \"blocks\" | \"braille\" | \"binary\" | \"hex\";\n\nexport const ASCII_CHARSETS: Record<AsciiCharset, string> = {\n standard: \" .:-=+*#%@\",\n blocks: \" ░▒▓█\",\n braille: \" ⠄⣀⣄⣤⣶⣷⣿\",\n binary: \"01\",\n hex: \"0123456789ABCDEF\",\n};\n\nexport function resolveAsciiCharset(charset: AsciiCharset | string): string {\n return ASCII_CHARSETS[charset as AsciiCharset] ?? charset;\n}\n\n/** ASCII art: the content is divided into cells, each cell's tone matched to a glyph. Glyphs come from a texture baked once per charset/font/size, the first effect to use the renderer's resource hook. */\nexport interface AsciiEffect extends ModedEffect, EffectFields<typeof asciiSpec.params> {\n type: \"ascii\";\n}\n\nexport const asciiSpec = defineEffect({\n type: \"ascii\",\n group: \"stylize\",\n // Reads one texel per cell and a glyph texture alongside it.\n surface: \"shader\",\n scalar: \"size\",\n // Replaces the image with glyphs at every size.\n neutral: null,\n params: {\n /** Cell size in pixels — the width of one character. */\n size: param.number({ default: 12, min: 2, unit: \"px\", label: \"cellSize\", inline: true }),\n /** A named ramp, or a custom string ordered least-ink-first. */\n charset: param.of<AsciiCharset | string>()({\n kind: \"enum\",\n default: \"standard\",\n options: Object.keys(ASCII_CHARSETS),\n optionsLabel: \"asciiCharset\",\n }),\n /** Family the glyphs are baked in; a monospace face reads best. */\n fontFamily: param.text({ default: \"monospace\" }),\n /** Glyph colour when `colored` is false. */\n ink: param.color({ default: \"white\" }),\n /** Colour behind the glyphs (`'transparent'` to overlay). */\n background: param.color({ default: \"black\" }),\n /** Tint each glyph with its own cell's colour instead of using `ink`. */\n colored: param.boolean({ default: false }),\n },\n});\n\nexport const asciiEffect: EffectData<AsciiEffect> = effectDataOf(asciiSpec);\n", "// Mirrors CSS `mix-blend-mode`; the renderer maps each string to an integer hash for fast uniform uploads.\n\n/** Every supported blend mode, in hash-index order. */\nexport const BlendModes = [\n \"multiply\",\n \"screen\",\n \"overlay\",\n \"darken\",\n \"lighten\",\n \"color-dodge\",\n \"color-burn\",\n \"hard-light\",\n \"soft-light\",\n \"difference\",\n \"exclusion\",\n \"hue\",\n \"saturation\",\n \"color\",\n \"luminosity\",\n \"normal\"\n] as const;\n\nexport type BlendMode = typeof BlendModes[number];\n\n/** Blend modes a node/layer can carry: the fill {@link BlendMode} set plus Figma's `pass-through` (the node default), where the layer is *not* isolated: its opacity scales each child/fill's contribution while they blend directly against the backdrop. Any other value isolates the node, flattening its children into a group that blends with the chosen mode. Fills never accept `pass-through`. */\nexport const NodeBlendModes = [...BlendModes, \"pass-through\"] as const;\n\nexport type NodeBlendMode = typeof NodeBlendModes[number];\n\n// Pre-built reverse lookup so getBlendModeHash is O(1).\nconst BLEND_MODE_HASH: Record<BlendMode, number> =\n Object.fromEntries(\n BlendModes.map((mode, i) => [mode, i])\n ) as Record<BlendMode, number>;\n\nexport function getBlendModeHash(blend: BlendMode): number {\n return BLEND_MODE_HASH[blend];\n}\n", "/** Uniform values shared by the `shader` fill and effect: authoring shapes, their canonical record, and how records interpolate and compare. The renderer binds the record to `struct Params` by name. */\n\nimport { lerpNumber } from '@/tween/lerp';\n\n/** A single uniform value: a float, or a flat array for a vector/matrix/array uniform. */\nexport type ShaderUniformValue = number | number[];\n\n/** A named uniform, in the positional `[{name, value}]` form older shader effects were written with. */\nexport interface ShaderUniform {\n name: string;\n value: ShaderUniformValue;\n}\n\n/** Uniform values keyed by the name they are declared under in the shader. */\nexport type ShaderUniformRecord = Record<string, ShaderUniformValue>;\n\n/** Warnings already emitted, keyed by scope + message: normalising runs on every resolve, so an unguarded warn is thousands of identical lines in an export. Cleared past a ceiling to stay bounded. */\nconst warned = new Set<string>();\n\nfunction warnOnce(scope: string, message: string): void {\n const key = `${scope}\u0000${message}`;\n if (warned.has(key)) return;\n if (warned.size > 512) warned.clear();\n warned.add(key);\n console.warn(`[shader] ${message}`);\n}\n\n/** Flatten a value to the float list it contributes, or null if it isn't numeric. */\nfunction flattenValue(name: string, value: unknown): ShaderUniformValue | null {\n if (typeof value === 'number') {\n if (!Number.isFinite(value)) {\n warnOnce('normalize', `uniform \"${name}\" is ${value}; ignoring it.`);\n return null;\n }\n return value;\n }\n if (!Array.isArray(value)) {\n warnOnce('normalize', `uniform \"${name}\" is not a number or number array; ignoring it.`);\n return null;\n }\n // `[[r,g,b,a], …]` is how an author naturally writes a colour array uniform,\n // and the renderer takes the whole thing as one flat float run either way.\n const flat = (value as unknown[]).flat(Infinity) as unknown[];\n const out: number[] = [];\n for (const entry of flat) {\n if (typeof entry !== 'number' || !Number.isFinite(entry)) {\n warnOnce('normalize', `uniform \"${name}\" contains a non-finite entry; ignoring it.`);\n return null;\n }\n out.push(entry);\n }\n return out;\n}\n\n/** Normalises either authoring shape (the record, or the positional `[{name, value}]` array older shader effects used) to a canonical record. Keys are **sorted**, so authors writing the same uniforms in different order produce the same object and `equals` agrees with the renderer (which reads by name). */\nexport function normalizeUniforms(\n input: ShaderUniformRecord | readonly ShaderUniform[] | undefined,\n): ShaderUniformRecord {\n if (!input) return {};\n const pairs: Array<[string, unknown]> = Array.isArray(input)\n ? (input as readonly ShaderUniform[]).map((u) => [u.name, u.value])\n : Object.entries(input as ShaderUniformRecord);\n\n const out: ShaderUniformRecord = {};\n for (const [name, value] of pairs.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))) {\n const flat = flattenValue(name, value);\n if (flat !== null) out[name] = flat;\n }\n return out;\n}\n\n/** Component-wise lerp. Mismatched shapes snap, since there is no in-between arity. */\nexport function lerpUniformValue(a: ShaderUniformValue, b: ShaderUniformValue, t: number): ShaderUniformValue {\n if (typeof a === 'number' && typeof b === 'number') return lerpNumber(a, b, t);\n if (Array.isArray(a) && Array.isArray(b)) {\n const len = Math.max(a.length, b.length);\n return Array.from({ length: len }, (_, i) => lerpNumber(a[i] ?? 0, b[i] ?? 0, t));\n }\n return t < 0.5 ? a : b;\n}\n\nexport function uniformValuesEqual(a: ShaderUniformValue, b: ShaderUniformValue): boolean {\n if (typeof a === 'number' && typeof b === 'number') return a === b;\n if (Array.isArray(a) && Array.isArray(b)) {\n return a.length === b.length && a.every((v, i) => v === b[i]);\n }\n return false;\n}\n\n/** Interpolates two uniform records over the **union** of their keys. A key on one side only holds its value instead of interpolating from zero (the shader still declares it; zero would read as snapping to black), which also makes the self-pair `lerpFillArray` builds for an unmatched layer a no-op. */\nexport function lerpUniformRecord(\n a: ShaderUniformRecord,\n b: ShaderUniformRecord,\n t: number,\n): ShaderUniformRecord {\n const out: ShaderUniformRecord = {};\n for (const name of [...Object.keys(a), ...Object.keys(b)].sort()) {\n if (name in out) continue;\n const from = a[name];\n const to = b[name];\n if (from === undefined) out[name] = to;\n else if (to === undefined) out[name] = from;\n else out[name] = lerpUniformValue(from, to, t);\n }\n return out;\n}\n\n/** Compare by key *set*, not insertion order. */\nexport function uniformRecordsEqual(a: ShaderUniformRecord, b: ShaderUniformRecord): boolean {\n const aKeys = Object.keys(a);\n if (aKeys.length !== Object.keys(b).length) return false;\n return aKeys.every((name) => {\n const other = b[name];\n return other !== undefined && uniformValuesEqual(a[name], other);\n });\n}\n", "/** WGSL, the only language the renderer runs for a custom shader. A fill defines `fn fill(in: FillIn) -> vec4f`, an effect `fn effect(in: EffectIn) -> vec4f`; uniforms are the members of `struct Params`, read as `u.<name>`. */\nexport type ShaderLanguage = \"wgsl\";\n\n/** Whether a shader fill, shader effect or shader pack is WGSL: its `language` is absent or `\"wgsl\"`. */\nexport function isWgslShader(shader: { language?: string }): boolean {\n return shader.language === undefined || shader.language === \"wgsl\";\n}\n\n/** The version of the WGSL contract a shader is written against (`FillIn` / `EffectIn`, the helpers, uniforms bound to `struct Params` by name; packages/renderer/DESIGN.md §6.3). Bumped only by a change that would draw an existing shader differently. WGSL fills and effects resolve with `contract` stamped when absent, so a stored document says what it was written for. */\nexport const WGSL_CONTRACT = 1;\n\n/** The contract a shader states, or the current one for a WGSL shader that states none; `undefined` for any other language. */\nexport function shaderContractOf(shader: { language?: string; contract?: number }): number | undefined {\n if (!isWgslShader(shader)) return undefined;\n return shader.contract ?? WGSL_CONTRACT;\n}\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\nexport interface BlurEffect extends ModedEffect, EffectFields<typeof blurSpec.params> {\n type: \"blur\";\n}\n\nexport const blurSpec = defineEffect({\n type: \"blur\",\n group: \"blur\",\n scalar: \"radius\",\n neutral: { radius: 0 },\n params: {\n /** Blur spread in pixels. */\n radius: param.number({ default: 0, required: true, min: 0, unit: \"px\", inline: true, initial: 4 }),\n },\n});\n\nexport const blurEffect: EffectData<BlurEffect> = effectDataOf(blurSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/**\n * Motion-blur-style directional (linear) blur. Unlike {@link BlurEffect}, which\n * blurs uniformly in all directions, this smears the node's own content along a\n * single axis.\n */\nexport interface DirectionalBlurEffect extends ModedEffect, EffectFields<typeof directionalBlurSpec.params> {\n type: \"directionalBlur\";\n}\n\nexport const directionalBlurSpec = defineEffect({\n type: \"directionalBlur\",\n group: \"blur\",\n scalar: \"radius\",\n neutral: { radius: 0 },\n params: {\n /** Smear length in pixels along `angle`. */\n radius: param.number({ default: 0, required: true, min: 0, unit: \"px\", label: \"length\", inline: true, order: 1, initial: 10 }),\n /** Smear axis in degrees — 0 = horizontal, 90 = vertical. */\n angle: param.number({ default: 0, unit: \"deg\", order: 0 }),\n },\n});\n\nexport const directionalBlurEffect: EffectData<DirectionalBlurEffect> = effectDataOf(directionalBlurSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\nexport interface GrayscaleEffect extends ModedEffect, EffectFields<typeof grayscaleSpec.params> {\n type: \"grayscale\";\n}\n\nexport const grayscaleSpec = defineEffect({\n type: \"grayscale\",\n group: \"color\",\n scalar: \"amount\",\n neutral: { amount: 0 },\n params: {\n /** 0–1: 0 = original, 1 = fully desaturated. */\n amount: param.number({ default: 0, required: true, min: 0, max: 1, control: \"slider\", inline: true, initial: 1 }),\n },\n});\n\nexport const grayscaleEffect: EffectData<GrayscaleEffect> = effectDataOf(grayscaleSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** After Effects-style Mosaic. `blocks` is the *number of blocks* across the node per axis (AE's \"Horizontal/Vertical Blocks\"): a count equal to the node's pixel dimension leaves the image untouched, lower is coarser. `sharpColors` (AE's \"Sharp Colors\") makes each block one solid colour (nearest-neighbour) instead of smoothly interpolated between centres. */\nexport interface PixelateEffect extends ModedEffect, EffectFields<typeof pixelateSpec.params> {\n type: \"pixelate\";\n}\n\nexport const pixelateSpec = defineEffect({\n type: \"pixelate\",\n group: \"stylize\",\n scalar: \"blocks\",\n // Resolution-relative: inert only while a block is finer than the pixel grid.\n neutral: { blocks: 1920 },\n params: {\n /** Block count per axis; a bare number sets both. */\n blocks: param.vec2({ default: 1, fromNumber: \"both\", required: true, min: 1, step: 1, initial: { x: 64, y: 64 } }),\n /** AE \"Sharp Colors\": solid blocks (true) vs. smoothly blended. */\n sharpColors: param.boolean({ default: true }),\n },\n});\n\nexport const pixelateEffect: EffectData<PixelateEffect> = effectDataOf(pixelateSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { CENTER, defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\nexport interface BulgeEffect extends ModedEffect, EffectFields<typeof bulgeSpec.params> {\n type: \"bulge\";\n}\n\nexport const bulgeSpec = defineEffect({\n type: \"bulge\",\n group: \"distort\",\n // Warps its source: samples a displaced texel per fragment.\n surface: \"shader\",\n scalar: \"strength\",\n neutral: { strength: 0 },\n params: {\n /** Positive bulges (barrel), negative pinches (pincushion). Range ≈ −1…1. */\n strength: param.number({ default: 0, required: true, min: -1, max: 1, control: \"slider\", inline: true, initial: 0.5 }),\n /** Lens centre in 0–1 layer coords. */\n center: param.vec2({ default: CENTER, min: 0, max: 1, step: 0.01, unit: \"normalized\", label: \"lensCenter\" }),\n },\n});\n\nexport const bulgeEffect: EffectData<BulgeEffect> = effectDataOf(bulgeSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { CENTER, defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\nexport interface MagnifyEffect extends ModedEffect, EffectFields<typeof magnifySpec.params> {\n type: \"magnify\";\n}\n\nexport const magnifySpec = defineEffect({\n type: \"magnify\",\n group: \"distort\",\n // Resamples the backdrop about `center`.\n surface: \"shader\",\n scalar: \"scale\",\n defaultMode: \"backdrop\",\n onlyOn: \"backdrop\",\n neutral: { scale: 1 },\n params: {\n /** Magnification factor — 1 = none, 2 = 2×, 0.5 = zoomed out. */\n scale: param.number({ default: 2, min: 0, step: 0.1, unit: \"factor\", label: \"magnification\", inline: true }),\n /** Magnify centre in 0–1 layer coords. */\n center: param.vec2({ default: CENTER, min: 0, max: 1, step: 0.01, unit: \"normalized\", label: \"lensCenter\" }),\n },\n});\n\nexport const magnifyEffect: EffectData<MagnifyEffect> = effectDataOf(magnifySpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\nexport interface BloomEffect extends ModedEffect, EffectFields<typeof bloomSpec.params> {\n type: \"bloom\";\n}\n\nexport const bloomSpec = defineEffect({\n type: \"bloom\",\n group: \"light\",\n scalar: \"intensity\",\n neutral: { intensity: 0 },\n params: {\n /** 0–1 luminance cutoff — only pixels brighter than this bloom. */\n threshold: param.number({ default: 0.7, min: 0, max: 1, control: \"slider\" }),\n /** Spread in pixels. */\n radius: param.number({ default: 12, min: 0, unit: \"px\" }),\n /** Additive multiplier for the bloom pass. */\n intensity: param.number({ default: 1, min: 0, max: 3, control: \"slider\", inline: true }),\n },\n});\n\nexport const bloomEffect: EffectData<BloomEffect> = effectDataOf(bloomSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\nexport interface VintageEffect extends ModedEffect, EffectFields<typeof vintageSpec.params> {\n type: \"vintage\";\n}\n\nexport const vintageSpec = defineEffect({\n type: \"vintage\",\n group: \"color\",\n scalar: \"amount\",\n neutral: { amount: 0, warmth: 0 },\n params: {\n /** 0–1: 0 = original, 1 = full sepia + desaturate. */\n amount: param.number({ default: 1, min: 0, max: 1, control: \"slider\", inline: true }),\n /** −1…1: negative = cool/cyan tint, positive = warm/amber. */\n warmth: param.number({ default: 0.2, min: -1, max: 1, control: \"slider\" }),\n },\n});\n\nexport const vintageEffect: EffectData<VintageEffect> = effectDataOf(vintageSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\nexport interface ChromaticAberrationEffect extends ModedEffect, EffectFields<typeof chromaticAberrationSpec.params> {\n type: \"chromaticAberration\";\n}\n\nexport const chromaticAberrationSpec = defineEffect({\n type: \"chromaticAberration\",\n group: \"glitch\",\n scalar: \"amount\",\n neutral: { amount: 0 },\n params: {\n /** Pixel offset distance for the R/B fringe. */\n amount: param.number({ default: 4, min: 0, unit: \"px\", inline: true }),\n /** Fringe axis in degrees — 0 = horizontal, R right / B left. */\n angle: param.number({ default: 0, unit: \"deg\" }),\n },\n});\n\nexport const chromaticAberrationEffect: EffectData<ChromaticAberrationEffect> = effectDataOf(chromaticAberrationSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** Which channel / colour component is inverted: a single `'red' | 'green' | 'blue'`; `'rgba'` (red, green, blue; alpha untouched); `'alpha'`; `'hue'` (rotated 180°); `'luminance'` (perceptual BT.709, preserving chroma). */\nexport type InvertChannel =\n | \"red\"\n | \"green\"\n | \"blue\"\n | \"rgba\"\n | \"alpha\"\n | \"hue\"\n | \"luminance\";\n\nexport interface InvertEffect extends ModedEffect, EffectFields<typeof invertSpec.params> {\n type: \"invert\";\n}\n\nexport const invertSpec = defineEffect({\n type: \"invert\",\n group: \"color\",\n scalar: \"strength\",\n neutral: { strength: 0 },\n params: {\n /** Which channel / colour component to invert. */\n channel: param.choice([\"rgba\", \"red\", \"green\", \"blue\", \"alpha\", \"hue\", \"luminance\"] satisfies InvertChannel[], { default: \"rgba\", optionsLabel: \"invertChannel\" }),\n /** 0–1: blend from original (0) to fully inverted (1). */\n strength: param.number({ default: 1, min: 0, max: 1, control: \"slider\", inline: true }),\n },\n});\n\nexport const invertEffect: EffectData<InvertEffect> = effectDataOf(invertSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\nexport interface ScatterEffect extends ModedEffect, EffectFields<typeof scatterSpec.params> {\n type: \"scatter\";\n}\n\nexport const scatterSpec = defineEffect({\n type: \"scatter\",\n group: \"glitch\",\n // Displaces each pixel by a hash of its position, so it needs random access\n // to its source. It was realised as a displacement-map ImageFilter until the\n // filter path's layer snapping was found to re-roll the field whenever the\n // node stood on a fractional pixel — see the renderer's `scatter` handler,\n // which carries the full account.\n surface: \"shader\",\n scalar: \"strength\",\n neutral: { strength: 0 },\n params: {\n /** Maximum random pixel displacement. */\n strength: param.number({ default: 10, min: 0, unit: \"px\", inline: true }),\n /** Axis pixels are scattered along. */\n axis: param.axis({ default: \"both\", label: \"direction\", optionsLabel: \"effectAxis\" }),\n },\n});\n\nexport const scatterEffect: EffectData<ScatterEffect> = effectDataOf(scatterSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** After Effects-style Posterize: quantizes each channel into `levels` evenly spaced steps (AE's single \"Level\"), collapsing gradients into flat bands. Below 2 there is nothing to band: a no-op. */\nexport interface PosterizeEffect extends ModedEffect, EffectFields<typeof posterizeSpec.params> {\n type: \"posterize\";\n}\n\nexport const posterizeSpec = defineEffect({\n type: \"posterize\",\n group: \"color\",\n // Reads its source texel-by-texel through a banding shader.\n surface: \"shader\",\n scalar: \"levels\",\n neutral: { levels: 255 },\n params: {\n /** Number of brightness levels per channel (≥ 2). */\n levels: param.number({ default: 4, min: 2, step: 1, inline: true }),\n },\n});\n\nexport const posterizeEffect: EffectData<PosterizeEffect> = effectDataOf(posterizeSpec);\n", "import { BlendModes, type BlendMode } from \"../../fill/blend\";\nimport type { ModedEffect, EffectData } from \"../effect-data\";\nimport {\n lerpUniformRecord,\n normalizeUniforms,\n uniformRecordsEqual,\n type ShaderUniform,\n type ShaderUniformRecord,\n} from \"../../shaders/uniforms\";\nimport { shaderContractOf, type ShaderLanguage } from \"../../shaders/language\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** A custom shader, classified by {@link EffectMode}: `'backdrop'` (`sample_src` reads a snapshot beneath the node; the result replaces the backdrop within the silhouette clip) or `'foreground'` (default; `sample_src` reads the node's own layer, and the output replaces it or composites with {@link blendMode}). The effect twin of a `shader` **fill**. */\nexport interface ShaderEffect extends ModedEffect {\n type: \"shader\";\n /** The program. WGSL defines `fn effect(in: EffectIn) -> vec4f` (premultiplied), reads input with `sample_src(uv)` / `sample_src_px(px)` (the node's layer, or the backdrop in `'backdrop'` mode), and its uniforms as `u`, the `struct Params` it declares. */\n source: string;\n /** The language `source` is written in; WGSL when absent. */\n language?: ShaderLanguage;\n /** WGSL only: the contract version it is written against; `resolve` stamps `WGSL_CONTRACT` when absent. */\n contract?: number;\n /** How far past the node's box (logical px) a WGSL effect may draw (a glow, a spilling ripple); the layer it runs over grows by it. Default 0. */\n reach?: number;\n /** Uniform values by name, lerped component-wise. The older positional `[{ name, value }]` array is normalised on the way in. */\n uniforms: ShaderUniformRecord | ShaderUniform[];\n /**\n * The shader pack this was built from. **Reserved, carried rather than read**: a pack resolves to plain uniforms\n * first, so the frame is identical with or without it. It exists for the trip back: a host reopening a saved scene\n * needs it to redraw the property panel. An id naming an unregistered pack is **not** an error: the shader still\n * renders, the host just cannot offer the panel.\n */\n shaderId?: string;\n /** Blend mode when `mode` is `'foreground'`; the output replaces the layer when absent. Ignored for `'backdrop'`. */\n blendMode?: BlendMode;\n}\n\n// The hand-written interface and the spec describe the same fields.\ntype ShaderFields = Omit<ShaderEffect, \"type\" | keyof ModedEffect>;\ntype SpecFields = EffectFields<typeof shaderSpec.params>;\nconst _specAgrees: [ShaderFields extends SpecFields ? true : false, SpecFields extends ShaderFields ? true : false] = [true, true];\n\n/** The {@link ShaderEffect} spec; interpolation, equality and surface stay hand-written since they concern a program and its uniform record. */\nexport const shaderSpec = defineEffect({\n type: \"shader\",\n group: \"stylize\",\n // An arbitrary user shader: neutrality is the author's to define.\n neutral: null,\n params: {\n source: param.text({ required: true, hidden: true }),\n language: {\n ...param.choice([\"wgsl\"] satisfies ShaderLanguage[], { optional: true, hidden: true }),\n // \"sksl\" is the retired value documents from before WGSL carry: it draws nothing and is reported.\n options: [\"wgsl\", \"sksl\"],\n },\n reach: param.number({ optional: true, min: 0, unit: \"px\", hidden: true }),\n uniforms: param.of<ShaderUniformRecord | ShaderUniform[]>()({ kind: \"uniforms\", default: {}, hidden: true }),\n shaderId: param.text({ optional: true, hidden: true }),\n blendMode: param.choice(BlendModes, { optional: true, optionsLabel: \"blendMode\" }),\n },\n // Returns the effect untouched when it already states its contract, which\n // is what keeps `resolveChainEffects` from copying an array per write.\n resolve: (effect: ShaderEffect) => {\n const contract = effect.contract ?? shaderContractOf(effect);\n return contract === effect.contract ? effect : { ...effect, contract };\n },\n // The program and blend snap at the midpoint (the source is the compile-cache key); only uniform values interpolate, over the union of names.\n lerp: (from: ShaderEffect, to: ShaderEffect, t: number): ShaderEffect => {\n const near = t < 0.5 ? from : to;\n return {\n type: \"shader\",\n source: near.source,\n ...(near.language !== undefined ? { language: near.language } : {}),\n ...(near.contract !== undefined ? { contract: near.contract } : {}),\n ...(from.reach !== undefined || to.reach !== undefined\n ? { reach: (from.reach ?? 0) + ((to.reach ?? 0) - (from.reach ?? 0)) * t }\n : {}),\n ...(near.shaderId !== undefined ? { shaderId: near.shaderId } : {}),\n mode: near.mode,\n blendMode: near.blendMode,\n uniforms: lerpUniformRecord(\n normalizeUniforms(from.uniforms),\n normalizeUniforms(to.uniforms),\n t,\n ),\n };\n },\n equals: (a: ShaderEffect, b: ShaderEffect) =>\n a.source === b.source &&\n a.language === b.language &&\n a.contract === b.contract &&\n (a.reach ?? 0) === (b.reach ?? 0) &&\n a.mode === b.mode &&\n a.blendMode === b.blendMode &&\n uniformRecordsEqual(normalizeUniforms(a.uniforms), normalizeUniforms(b.uniforms)),\n // A backdrop shader resamples what is beneath the node, so it needs a redraw scope.\n surface: (effect: ShaderEffect) => (effect.mode === \"backdrop\" ? \"shader\" : \"filter\"),\n});\n\nexport const shaderEffect = effectDataOf(shaderSpec) as unknown as EffectData<ShaderEffect>;\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** Where the outline sits relative to the silhouette, as in Figma and Illustrator: `\"outside\"` grows outward leaving the content untouched, `\"inside\"` eats inward so the footprint never changes, `\"center\"` straddles the edge. */\nexport type OutlinePosition = \"outside\" | \"center\" | \"inside\";\n\n/** A coloured band traced around the node's silhouette (the alpha outline): what a geometry stroke can't give when the silhouette comes from text, an image's alpha, or a subtree. */\nexport interface OutlineEffect extends ModedEffect, EffectFields<typeof outlineSpec.params> {\n type: \"outline\";\n}\n\nexport const outlineSpec = defineEffect({\n type: \"outline\",\n group: \"stylize\",\n // Reads a ring of neighbouring texels to dilate/erode the source's alpha.\n surface: \"shader\",\n scalar: \"width\",\n onlyOn: \"foreground\",\n neutral: { width: 0 },\n params: {\n /** Band thickness in pixels. */\n width: param.number({ default: 4, min: 0, unit: \"px\", inline: true }),\n /** Band colour. */\n color: param.color({ default: \"black\" }),\n /** Which side of the edge the band grows from. */\n position: param.choice([\"outside\", \"center\", \"inside\"] satisfies OutlinePosition[], { default: \"outside\", optionsLabel: \"outlinePosition\" }),\n },\n});\n\nexport const outlineEffect: EffectData<OutlineEffect> = effectDataOf(outlineSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** A shadow cast from the node's **alpha silhouette** rather than its geometry. A shape's `shadow` fills the node's outline, right for a rect or star but wrong for anything whose form comes from *pixels* (a cut-out PNG, alpha video, text, a subtree), which would cast a blurred rectangle. Computed from what the node drew, as {@link OutlineEffect} is to `stroke`. Offsets are in scene axes (positive `y` lifts the shadow), matching `ShadowProp.offset`, not the shader's y-down device space. */\nexport interface DropShadowEffect extends ModedEffect, EffectFields<typeof dropShadowSpec.params> {\n type: \"dropShadow\";\n}\n\nexport const dropShadowSpec = defineEffect({\n type: \"dropShadow\",\n group: \"stylize\",\n surface: \"shader\",\n // Softness is the knob a shadow is usually reached for by.\n scalar: \"blur\",\n onlyOn: \"foreground\",\n // Nowhere to fall, no softness and no growth: nothing of it is ever visible.\n neutral: { offsetX: 0, offsetY: 0, blur: 0, spread: 0 },\n params: {\n /** Horizontal displacement in pixels. */\n offsetX: param.number({ default: 0, unit: \"px\", label: \"shadowX\" }),\n /** Vertical displacement in pixels, positive being upward. */\n offsetY: param.number({ default: -8, unit: \"px\", label: \"shadowY\" }),\n /** Softness in pixels, on a `blur` effect's scale. */\n blur: param.number({ default: 16, min: 0, unit: \"px\", label: \"shadowBlur\", inline: true }),\n /** Grows the silhouette before blurring, in pixels. */\n spread: param.number({ default: 0, min: 0, unit: \"px\", label: \"shadowSpread\" }),\n /** Shadow colour. */\n color: param.color({ default: \"black\" }),\n },\n});\n\nexport const dropShadowEffect: EffectData<DropShadowEffect> = effectDataOf(dropShadowSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** Darkened corners (lens falloff). The node box is normalised to a unit ellipse, so the falloff follows its aspect ratio. Untouched inside `radius`; from there to `radius + softness` the tint ramps in with a smoothstep, reaching `amount` at the corners. */\nexport interface VignetteEffect extends ModedEffect, EffectFields<typeof vignetteSpec.params> {\n type: \"vignette\";\n}\n\nexport const vignetteSpec = defineEffect({\n type: \"vignette\",\n group: \"light\",\n // Needs each pixel's position within the node box to compute its falloff.\n surface: \"shader\",\n scalar: \"amount\",\n neutral: { amount: 0 },\n params: {\n /** 0–1 tint strength at the very edge. 0 = off. */\n amount: param.number({ default: 0.5, min: 0, max: 1, control: \"slider\", inline: true }),\n /** 0–1 normalised radius where the falloff starts (1 ≈ the box corners). */\n radius: param.number({ default: 0.75, min: 0, max: 1, control: \"slider\" }),\n /** 0–1 width of the ramp; 0 is a hard ring, 1 a long gradient. */\n softness: param.number({ default: 0.5, min: 0, max: 1, control: \"slider\" }),\n /** Tint colour — black darkens (the classic look), white blows the edges out. */\n color: param.color({ default: \"black\", label: \"tint\" }),\n },\n});\n\nexport const vignetteEffect: EffectData<VignetteEffect> = effectDataOf(vignetteSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** Film grain: per-pixel noise blended into the node's content. The noise is *signed* and scaled by local alpha, so it never bleeds past the silhouette or shifts average exposure. Static grain reads as texture rather than film, so {@link animated} re-seeds every frame from elapsed time; for a deterministic render (a pixel-diff test) leave it off and tween {@link seed} for the same shimmer frame-locked to the timeline. */\nexport interface GrainEffect extends ModedEffect, EffectFields<typeof grainSpec.params> {\n type: \"grain\";\n}\n\nexport const grainSpec = defineEffect({\n type: \"grain\",\n group: \"stylize\",\n // Hashes each pixel's position into a noise value.\n surface: \"shader\",\n scalar: \"amount\",\n neutral: { amount: 0 },\n params: {\n /** 0–1 noise amplitude. */\n amount: param.number({ default: 0.25, min: 0, max: 1, control: \"slider\", inline: true }),\n /** Grain cell size in pixels. */\n size: param.number({ default: 1, min: 1, unit: \"px\", label: \"grainSize\" }),\n /** Random field offset — animate it for frame-locked shimmer. */\n seed: param.number({ default: 0, step: 1 }),\n /** Re-seed every frame from elapsed time. */\n animated: param.boolean({ default: false }),\n /** Per-channel colour speckle instead of luminance noise. */\n colored: param.boolean({ default: false }),\n },\n});\n\nexport const grainEffect: EffectData<GrainEffect> = effectDataOf(grainSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** Unsharp mask: subtract a blurred copy from the content and add the difference back, `out = c + amount · (c − blur(c, radius))`. `radius` sets the scale of detail (small crisps texture, large adds \"clarity\"); past ~2 `amount` shows the classic halo. */\nexport interface SharpenEffect extends ModedEffect, EffectFields<typeof sharpenSpec.params> {\n type: \"sharpen\";\n}\n\nexport const sharpenSpec = defineEffect({\n type: \"sharpen\",\n group: \"blur\",\n // Convolves a neighbourhood, so it resamples.\n surface: \"shader\",\n scalar: \"amount\",\n neutral: { amount: 0 },\n params: {\n /** Edge-contrast boost. */\n amount: param.number({ default: 1, min: 0, max: 4, control: \"slider\", inline: true }),\n /** Radius of the blurred reference, in pixels. */\n radius: param.number({ default: 1, min: 0, unit: \"px\" }),\n },\n});\n\nexport const sharpenEffect: EffectData<SharpenEffect> = effectDataOf(sharpenSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** Which convolution kernel detects edges: `\"sobel\"` (default; thick, smooth, noise-tolerant), `\"prewitt\"` (no centre weighting: slightly thinner, noisier on gradients), `\"laplacian\"` (second derivative in one pass: finest lines, picks up texture the gradients smooth over). */\nexport type EdgeKernel = \"sobel\" | \"prewitt\" | \"laplacian\";\n\n/** Edge detection: replaces the content with the magnitude of its own gradient, so flat areas go black and boundaries light up. */\nexport interface EdgesEffect extends ModedEffect, EffectFields<typeof edgesSpec.params> {\n type: \"edges\";\n}\n\nexport const edgesSpec = defineEffect({\n type: \"edges\",\n group: \"stylize\",\n // Convolves a 3×3 neighbourhood.\n surface: \"shader\",\n scalar: \"strength\",\n neutral: { strength: 0 },\n params: {\n /** Multiplier on the detected gradient. */\n strength: param.number({ default: 1, min: 0, max: 4, control: \"slider\", inline: true }),\n /** Which operator measures the gradient. */\n kernel: param.choice([\"sobel\", \"prewitt\", \"laplacian\"] satisfies EdgeKernel[], { default: \"sobel\", optionsLabel: \"edgeKernel\" }),\n /** Detect per RGB channel instead of on luminance. */\n colored: param.boolean({ default: false }),\n },\n});\n\nexport const edgesEffect: EffectData<EdgesEffect> = effectDataOf(edgesSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** Two-tone cut: pixels brighter than `level` become white, the rest black. `smoothness` widens the cut into a ramp centred on `level`, anti-aliasing the boundary and, higher, keeping some midtone modelling. */\nexport interface ThresholdEffect extends ModedEffect, EffectFields<typeof thresholdSpec.params> {\n type: \"threshold\";\n}\n\nexport const thresholdSpec = defineEffect({\n type: \"threshold\",\n group: \"color\",\n // A non-linear per-pixel remap, drawn as its own pass.\n surface: \"shader\",\n scalar: \"level\",\n // Flattens colour to two tones at every level and smoothness.\n neutral: null,\n params: {\n /** 0–1 cut point. */\n level: param.number({ default: 0.5, min: 0, max: 1, control: \"slider\", inline: true }),\n /** 0–1 ramp width around the cut (just enough to anti-alias by default). */\n smoothness: param.number({ default: 0.05, min: 0, max: 1, control: \"slider\" }),\n },\n});\n\nexport const thresholdEffect: EffectData<ThresholdEffect> = effectDataOf(thresholdSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { CENTER, defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** Which way samples smear around {@link RadialBlurEffect.center}: `\"zoom\"` along the radius (a rush toward or away from the centre) or `\"spin\"` along the tangent. (After Effects' \"Type\"; that name is the effect discriminator here, so the field is `style`.) */\nexport type RadialBlurStyle = \"zoom\" | \"spin\";\n\n/** After Effects' Radial Blur: the source is sampled along a path radiating from (`zoom`) or circling (`spin`) a centre and the taps averaged. The centre stays sharp and the smear grows with distance, which reads as speed rather than softness. */\nexport interface RadialBlurEffect extends ModedEffect, EffectFields<typeof radialBlurSpec.params> {\n type: \"radialBlur\";\n}\n\nexport const radialBlurSpec = defineEffect({\n type: \"radialBlur\",\n group: \"blur\",\n // Resamples along a path per pixel.\n surface: \"shader\",\n scalar: \"amount\",\n neutral: { amount: 0 },\n params: {\n /** Smear length, 0–1. */\n amount: param.number({ default: 0.5, min: 0, max: 1, control: \"slider\", inline: true, order: 1 }),\n /** Radial rush (`'zoom'`) or rotational streak (`'spin'`). */\n style: param.choice([\"zoom\", \"spin\"] satisfies RadialBlurStyle[], { default: \"zoom\", control: \"segmented\", optionsLabel: \"radialBlurStyle\", order: 0 }),\n /** Blur centre in 0–1 layer coords. */\n center: param.vec2({ default: CENTER, min: 0, max: 1, step: 0.01, unit: \"normalized\", order: 2 }),\n /** Taps averaged per pixel (max 32). A quality knob, so it snaps. */\n samples: param.number({ default: 16, min: 2, max: 32, step: 1, lerp: \"step\", hidden: true, order: 3 }),\n },\n});\n\nexport const radialBlurEffect: EffectData<RadialBlurEffect> = effectDataOf(radialBlurSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** The screen pattern each cell is drawn with: `\"dot\"` (grows with tone), `\"line\"` (rules thicken with tone), `\"cross\"` (crossed rules, coarse engraving). */\nexport type HalftoneShape = \"dot\" | \"line\" | \"cross\";\n\n/** How many plates the screen separates into: `\"mono\"` (one black screen over luminance, newsprint), `\"cmyk\"` (four plates at the process angles C 15°, M 75°, Y 0°, K 45°; the shared darkness on a K plate keeps neutrals neutral, so it reads as *printed*), `\"rgb\"` (one per channel: cheaper, but with no K plate every grey prints three mid-dots and neutrals turn to colour noise). */\nexport type HalftoneSeparation = \"mono\" | \"rgb\" | \"cmyk\";\n\n/** Halftone screen (newsprint, comic-book): a rotated grid of cells whose tone becomes mark size, reproducing shading by dot area rather than intensity. `separation` picks the plates, see {@link HalftoneSeparation}. */\nexport interface HalftoneEffect extends ModedEffect, EffectFields<typeof halftoneSpec.params> {\n type: \"halftone\";\n}\n\nexport const halftoneSpec = defineEffect({\n type: \"halftone\",\n group: \"stylize\",\n // Cell position drives the mark, so it needs each pixel's coordinates.\n surface: \"shader\",\n scalar: \"size\",\n // Resolution-relative: inert only while the cell is finer than the pixel grid.\n neutral: { size: 0.5 },\n params: {\n /** Cell pitch in pixels. */\n size: param.number({ default: 8, min: 1, unit: \"px\", label: \"cellSize\", inline: true }),\n /** Screen rotation in degrees. */\n angle: param.number({ default: 45, unit: \"deg\", control: \"angle\", label: \"screenAngle\" }),\n /** Mark drawn per cell. */\n shape: param.choice([\"dot\", \"line\", \"cross\"] satisfies HalftoneShape[], { default: \"dot\", optionsLabel: \"halftoneShape\" }),\n /** Plates to screen into. */\n separation: param.choice([\"mono\", \"rgb\", \"cmyk\"] satisfies HalftoneSeparation[], { default: \"mono\", optionsLabel: \"halftoneSeparation\" }),\n },\n});\n\nexport const halftoneEffect: EffectData<HalftoneEffect> = effectDataOf(halftoneSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** Size of the Bayer threshold matrix (2×2, 4×4, 8×8): bigger carries more threshold levels, a finer pattern and wider apparent tonal range. */\nexport type DitherMatrix = 2 | 4 | 8;\n\n/** Where a pixel's threshold comes from: `'bayer'` (the ordered matrix; its lattice *is* the look, a visible crosshatch that can beat against the pixel grid at some `scale`s) or `'blue'` (void-and-cluster blue noise: homogeneous at every density, no lattice or moiré; texture rather than pattern). `matrix` only applies to `'bayer'`. */\nexport type DitherNoise = 'bayer' | 'blue';\n\n/** Ordered dithering: quantize to `levels` tones per channel after offsetting each pixel's rounding by a threshold pattern, trading banding for texture (how 8-bit hardware faked gradients). Unlike `posterize`, which has no pattern and so makes flat bands. */\nexport interface DitherEffect extends ModedEffect, EffectFields<typeof ditherSpec.params> {\n type: \"dither\";\n}\n\nexport const ditherSpec = defineEffect({\n type: \"dither\",\n group: \"stylize\",\n // The threshold depends on the pixel's position in the pattern.\n surface: \"shader\",\n scalar: \"levels\",\n neutral: { levels: 255 },\n params: {\n /** Output tones per channel, ≥ 2. */\n levels: param.number({ default: 2, min: 2, max: 32, step: 1, inline: true, order: 0 }),\n /** Bayer matrix size. Ignored when `noise` is `'blue'`. */\n matrix: param.choice([2, 4, 8] satisfies DitherMatrix[], { default: 4, optionsLabel: \"ditherMatrix\", order: 2 }),\n /** Pattern cell size in pixels. */\n scale: param.number({ default: 1, min: 1, step: 1, unit: \"px\", label: \"cellSize\", order: 3 }),\n /** Dither luminance to black and white. */\n monochrome: param.boolean({ default: false, order: 4 }),\n /** Threshold pattern; see {@link DitherNoise}. */\n noise: param.choice([\"bayer\", \"blue\"] satisfies DitherNoise[], { default: \"bayer\", label: \"ditherNoise\", optionsLabel: \"ditherNoise\", order: 1 }),\n },\n});\n\nexport const ditherEffect: EffectData<DitherEffect> = effectDataOf(ditherSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** Duotone / gradient map: the content's luminance remapped onto a two-colour ramp (black becomes `shadows`, white `highlights`); source chroma is discarded. */\nexport interface DuotoneEffect extends ModedEffect, EffectFields<typeof duotoneSpec.params> {\n type: \"duotone\";\n}\n\nexport const duotoneSpec = defineEffect({\n type: \"duotone\",\n group: \"color\",\n // A luminance ramp is a plain affine colour transform, so it composes as an\n // ImageFilter (the default surface) rather than needing a shader scope.\n scalar: \"amount\",\n neutral: { amount: 0 },\n params: {\n /** 0–1 blend from the original colours to the full ramp. */\n amount: param.number({ default: 1, min: 0, max: 1, control: \"slider\", inline: true }),\n /** Colour the darkest tones map to. */\n shadows: param.color({ default: \"black\" }),\n /** Colour the brightest tones map to. */\n highlights: param.color({ default: \"white\" }),\n },\n});\n\nexport const duotoneEffect: EffectData<DuotoneEffect> = effectDataOf(duotoneSpec);\n", "import { lerpNumber } from \"@/tween/lerp\";\nimport type { ModedEffect, EffectData } from \"../effect-data\";\nimport type { CurvesChannel } from \"../../filters/implementations/curves\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** Tone curve as a **node effect**, the same adjustment `Adjustments.curves` applies to a photo. Shares type name, fields and renderer handler with {@link CurvesFilter} (they differ only by the `mode` flag), so a curve doesn't mean two things depending on what it is attached to. */\nexport interface CurvesEffect extends ModedEffect, EffectFields<typeof curvesSpec.params> {\n type: \"curves\";\n}\n\nexport const curvesSpec = defineEffect({\n type: \"curves\",\n group: \"color\",\n // A curve is a *lookup*, which an affine colour matrix cannot express, so evaluating it per pixel needs the source as a readable shader (as `lut`): exact, at the cost of a pass. See the renderer's `curvesEffectHandler` for ordering.\n surface: \"shader\",\n neutral: { points: [[0, 0], [1, 1]] },\n params: {\n /** Curve control points as `[input, output]` pairs in 0–1. Move pairwise, as `curvesFilter.lerp`. */\n points: param.of<[number, number][]>()({\n kind: \"points\",\n required: true,\n lerp: (from, to, t) => from.map(([x, y], i) => {\n const [tx, ty] = to[i] ?? [x, y];\n return [lerpNumber(x, tx, t), lerpNumber(y, ty, t)] as [number, number];\n }),\n equals: (a, b) => a.length === b.length && a.every(([x, y], i) => x === b[i]?.[0] && y === b[i]?.[1]),\n }),\n /** Channel(s) the curve applies to. An intermediate channel name is meaningless, so it cuts. */\n channel: param.choice([\"rgb\", \"r\", \"g\", \"b\", \"a\"] satisfies CurvesChannel[], { default: \"rgb\", optional: true }),\n },\n});\n\nexport const curvesEffect: EffectData<CurvesEffect> = effectDataOf(curvesSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** Photographic tonal and colour adjustments as a **node effect** (the grading panel `Adjustments.colorAdjustment` gives an image fill); all fields optional and neutral by default. Shares its type name and renderer handler with `ColorAdjustmentFilter` except for `vignette`, which a colour matrix cannot do (it needs each pixel's position): use `Effects.vignette()`. */\nexport interface ColorAdjustmentEffect extends ModedEffect, EffectFields<typeof colorAdjustmentSpec.params> {\n type: \"colorAdjustment\";\n}\n\nexport const colorAdjustmentSpec = defineEffect({\n type: \"colorAdjustment\",\n group: \"color\",\n neutral: { contrast: 1, saturation: 1, temperature: 0 },\n // Every field is optional; `default` is what an absent one means.\n params: {\n /** −1…1, additive. */\n brightness: param.number({ default: 0, optional: true, min: -1, max: 1, control: \"slider\", inline: true }),\n /** 0…2, multiplicative around mid-grey. */\n contrast: param.number({ default: 1, optional: true, min: 0, max: 2, control: \"slider\" }),\n /** 0…3, multiplicative. */\n saturation: param.number({ default: 1, optional: true, min: 0, max: 3, control: \"slider\" }),\n /** Hue rotation in degrees. */\n hue: param.number({ default: 0, optional: true, unit: \"deg\", control: \"hue\" }),\n /** −1…1, saturation weighted toward muted colours. */\n vibrance: param.number({ default: 0, optional: true, min: -1, max: 1, control: \"slider\" }),\n /** −1…1, lifts or crushes the dark end. */\n shadows: param.number({ default: 0, optional: true, min: -1, max: 1, control: \"slider\" }),\n /** −1…1, lifts or crushes the bright end. */\n highlights: param.number({ default: 0, optional: true, min: -1, max: 1, control: \"slider\" }),\n /** −1…1, cool to warm. */\n temperature: param.number({ default: 0, optional: true, min: -1, max: 1, control: \"slider\" }),\n /** −1…1, green to magenta. */\n tint: param.number({ default: 0, optional: true, min: -1, max: 1, control: \"slider\", label: \"tintAmount\" }),\n },\n});\n\nexport const colorAdjustmentEffect: EffectData<ColorAdjustmentEffect> = effectDataOf(colorAdjustmentSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** Per-channel spatial offset: the red/green/blue planes pulled apart along independent vectors. Where `chromaticAberration` models a *lens* (symmetric fringing from one distance and angle), this is the digital-artefact version, each channel displaced wherever you point it: the RGB-tear of a glitch. Offsets are in px and scale with the node. */\nexport interface RgbShiftEffect extends ModedEffect, EffectFields<typeof rgbShiftSpec.params> {\n type: \"rgbShift\";\n}\n\nexport const rgbShiftSpec = defineEffect({\n type: \"rgbShift\",\n group: \"glitch\",\n // Samples each channel at a different position.\n surface: \"shader\",\n neutral: { red: { x: 0, y: 0 }, green: { x: 0, y: 0 }, blue: { x: 0, y: 0 } },\n params: {\n /** Red plane offset in px. */\n red: param.vec2({ default: { x: 4, y: 0 }, unit: \"px\", label: \"redOffset\" }),\n /** Green plane offset in px. */\n green: param.vec2({ default: { x: 0, y: 0 }, unit: \"px\", label: \"greenOffset\" }),\n /** Blue plane offset in px. */\n blue: param.vec2({ default: { x: -4, y: 0 }, unit: \"px\", label: \"blueOffset\" }),\n },\n});\n\nexport const rgbShiftEffect: EffectData<RgbShiftEffect> = effectDataOf(rgbShiftSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** CRT scanlines: periodic dark bands. `offset` scrolls the pattern (animating it past `spacing` gives a mistuned display's slow roll) and wraps, so a linear tween loops seamlessly. */\nexport interface ScanlinesEffect extends ModedEffect, EffectFields<typeof scanlinesSpec.params> {\n type: \"scanlines\";\n}\n\nexport const scanlinesSpec = defineEffect({\n type: \"scanlines\",\n group: \"stylize\",\n // The band a pixel falls in depends on its position.\n surface: \"shader\",\n scalar: \"darkness\",\n neutral: { darkness: 0 },\n params: {\n /** Distance between band centres in px. */\n spacing: param.number({ default: 4, min: 1, unit: \"px\", order: 1 }),\n /** 0–1 share of each period the dark band covers. */\n thickness: param.number({ default: 0.5, min: 0, max: 1, control: \"slider\", order: 2 }),\n /** 0–1 how far the bands darken. */\n darkness: param.number({ default: 0.5, min: 0, max: 1, control: \"slider\", inline: true, order: 0 }),\n /** Band offset in px — animate to roll the pattern; it wraps. */\n offset: param.number({ default: 0, unit: \"px\", order: 3 }),\n /** Band angle in degrees; 0 = horizontal. */\n angle: param.number({ default: 0, unit: \"deg\", control: \"angle\", order: 4 }),\n },\n});\n\nexport const scanlinesEffect: EffectData<ScanlinesEffect> = effectDataOf(scanlinesSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** Datamosh-style tearing: the content is cut into bands and each is displaced by a random amount. `density` is what separates it from noise: only that fraction of bands move, so the tear reads as a fault rather than static. Displacement is a pure function of band index and `seed`, so a frame re-renders identically; step `seed` in whole numbers to jump between glitch states. */\nexport interface BlockDisplaceEffect extends ModedEffect, EffectFields<typeof blockDisplaceSpec.params> {\n type: \"blockDisplace\";\n}\n\nexport const blockDisplaceSpec = defineEffect({\n type: \"blockDisplace\",\n group: \"glitch\",\n // Resamples the source at a displaced position.\n surface: \"shader\",\n scalar: \"amount\",\n neutral: { amount: 0 },\n params: {\n /** Maximum displacement in px. */\n amount: param.number({ default: 20, min: 0, unit: \"px\", inline: true }),\n /** Band thickness in px. */\n size: param.number({ default: 16, min: 1, unit: \"px\", label: \"bandSize\" }),\n /** 0–1 fraction of bands that move at all. */\n density: param.number({ default: 0.3, min: 0, max: 1, control: \"slider\" }),\n /** Random field offset — step it to jump between glitch states. */\n seed: param.number({ default: 0, step: 1 }),\n /** Which way bands slide. */\n axis: param.axis({ default: \"x\", label: \"direction\", optionsLabel: \"effectAxis\" }),\n },\n});\n\nexport const blockDisplaceEffect: EffectData<BlockDisplaceEffect> = effectDataOf(blockDisplaceSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** A fixed hardware palette to snap colours to: `'none'` (quantize each channel to `bits` instead), `'gameboy'` (the DMG's four greens), `'cga'` (palette 1 high-intensity: black, cyan, magenta, white), `'nes'` (a representative 16-colour cut of the NES master palette). */\nexport type BitCrushPalette = \"none\" | \"gameboy\" | \"cga\" | \"nes\";\n\n/** Colour-depth reduction: quantize each channel to `bits`, or snap each pixel to the nearest entry of a fixed hardware palette. Unlike `posterize` (an even grid per channel), it can force an arbitrary, uneven, historically specific set, which is what makes something look like a Game Boy rather than merely low-colour. Pair with `dither` so gradients survive the palette cut. */\nexport interface BitCrushEffect extends ModedEffect, EffectFields<typeof bitCrushSpec.params> {\n type: \"bitCrush\";\n}\n\nexport const bitCrushSpec = defineEffect({\n type: \"bitCrush\",\n group: \"stylize\",\n // A palette search is per-pixel non-linear; no LUT colour filter in this build.\n surface: \"shader\",\n scalar: \"bits\",\n neutral: { amount: 0 },\n params: {\n /** Bits per channel when `palette` is `'none'`, 1–8. */\n bits: param.number({ default: 3, min: 1, max: 8, step: 1, inline: true }),\n /** Fixed hardware palette to snap to. A halfway palette is meaningless, so it cuts. */\n palette: param.choice([\"none\", \"gameboy\", \"cga\", \"nes\"] satisfies BitCrushPalette[], { default: \"none\", optionsLabel: \"bitCrushPalette\" }),\n /** 0–1 blend between original and crushed. */\n amount: param.number({ default: 1, min: 0, max: 1, control: \"slider\" }),\n },\n});\n\nexport const bitCrushEffect: EffectData<BitCrushEffect> = effectDataOf(bitCrushSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** Anamorphic glare: a bright pass smeared along `angle` only and screened back on. Where `bloom` spreads light equally, this asymmetry is the whole look (the horizontal flare a wide lens throws off a highlight, not a halo). */\nexport interface StreakEffect extends ModedEffect, EffectFields<typeof streakSpec.params> {\n type: \"streak\";\n}\n\nexport const streakSpec = defineEffect({\n type: \"streak\",\n group: \"light\",\n // An anisotropic blur of a colour-matrix bright pass — all ImageFilter work.\n scalar: \"intensity\",\n neutral: { intensity: 0 },\n params: {\n /** Additive multiplier for the streak pass. */\n intensity: param.number({ default: 1, min: 0, max: 3, control: \"slider\", inline: true }),\n /** 0–1 luminance cutoff. */\n threshold: param.number({ default: 0.7, min: 0, max: 1, control: \"slider\" }),\n /** Smear length in pixels. */\n length: param.number({ default: 120, min: 0, unit: \"px\" }),\n /** Smear axis in degrees; 0 = horizontal. */\n angle: param.number({ default: 0, unit: \"deg\", control: \"angle\" }),\n },\n});\n\nexport const streakEffect: EffectData<StreakEffect> = effectDataOf(streakSpec);\n", "import { lerpNumber } from \"@/tween/lerp\";\nimport { lerpColor } from \"@/attributes/shape/fill/lerp\";\nimport { BlendModes } from \"@/attributes/shape/fill/blend\";\nimport type { Color } from \"@/attributes/shape/fill/color/parser\";\nimport type { ModedEffect, EffectData } from \"../effect-data\";\nimport { resolveEffectColor, sameEffectColor } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** What the glow reads for strength: `\"luminance\"` (bright pixels bleed; {@link GlowEffect.threshold} sets the cut) or `\"alpha\"` (every opaque pixel glows equally: a halo around a shape rather than light escaping an image). */\nexport type GlowChannel = \"luminance\" | \"alpha\";\n\n/** What the glow is coloured with: `\"none\"` keeps the source colours scaled by intensity, `\"solid\"` one {@link GlowEffect.color}, `\"ramp\"` maps strength through {@link GlowEffect.colors} / {@link GlowEffect.stops} (heat, neon, aurora). */\nexport type GlowTint = \"none\" | \"solid\" | \"ramp\";\n\n/** How the ramp repeats past one pass ({@link GlowEffect.cycles}): `\"repeat\"` restarts at the first stop (hard seam), `\"mirror\"` walks back down (seamless, halves the apparent frequency). */\nexport type GlowLoopStyle = \"mirror\" | \"repeat\";\n\n/** Where the source layer sits relative to the glow it produced. */\nexport type GlowOriginal = \"behind\" | \"front\" | \"hidden\";\n\n/** A glow: bright (or opaque) parts of a layer spread outward and composited back, optionally recoloured through a ramp. Unlike `bloom`, a `\"filter\"` effect bounded by the node's rect that can only screen its bright-pass back, this spreads past the box, chooses its compositing and can be coloured. See {@link EffectData.surface}. */\nexport interface GlowEffect extends ModedEffect, EffectFields<typeof glowSpec.params> {\n type: \"glow\";\n}\n\n// White at the core falling to a warm amber.\nconst GLOW_RAMP_COLORS: Color[] = [\"white\", \"#ffa640\"];\nconst GLOW_RAMP_STOPS: number[] = [0, 1];\n\nexport const glowSpec = defineEffect({\n type: \"glow\",\n group: \"light\",\n surface: \"shader\",\n scalar: \"intensity\",\n // `intensity: 0` alone is not enough: `original: 'hidden'` would carry over\n // from the effect being faded and erase the node.\n neutral: { intensity: 0, original: \"behind\" },\n // Kept from the hand-written lerp: ramps of different lengths snap the whole\n // glow, not only the ramp, at the midpoint.\n lerp: <G extends { colors: Color[] }>(from: G, to: G, t: number, derived: (a: G, b: G, t: number) => G) =>\n from.colors.length !== to.colors.length ? { ...(t < 0.5 ? from : to) } : derived(from, to, t),\n params: {\n /** What decides a pixel's glow strength. */\n channel: param.choice([\"luminance\", \"alpha\"] satisfies GlowChannel[], { default: \"luminance\", control: \"segmented\", optionsLabel: \"glowChannel\", order: 9 }),\n /** 0-1 luminance cutoff; read only when `channel` is `'luminance'`. */\n threshold: param.number({ default: 0.5, min: 0, max: 1, control: \"slider\", order: 0 }),\n /** Spread distance in pixels. */\n radius: param.number({ default: 25, min: 0, unit: \"px\", order: 1 }),\n /** Dilation applied before the blur, in pixels — gives the glow a solid core. */\n spread: param.number({ default: 0, min: 0, unit: \"px\", order: 2 }),\n /** Additive multiplier for the glow pass. */\n intensity: param.number({ default: 1, min: 0, max: 3, control: \"slider\", inline: true, order: 3 }),\n /** Which way the glow spreads; `'x'`/`'y'` give anamorphic streaks. */\n axis: param.axis({ default: \"both\", control: \"segmented\", optionsLabel: \"effectAxis\", order: 10 }),\n /** Where the source layer sits relative to the glow. */\n original: param.choice([\"behind\", \"front\", \"hidden\"] satisfies GlowOriginal[], { default: \"behind\", control: \"segmented\", optionsLabel: \"glowOriginal\", order: 11 }),\n /** How the glow merges with the layer. */\n blend: param.choice(BlendModes, { default: \"screen\", optionsLabel: \"blendMode\", order: 12 }),\n /** What the glow is coloured with. */\n tint: param.choice([\"none\", \"solid\", \"ramp\"] satisfies GlowTint[], { default: \"none\", control: \"segmented\", optionsLabel: \"glowTint\", order: 4 }),\n /** The glow's colour when `tint` is `'solid'`. */\n color: param.color({ default: \"white\", order: 5 }),\n /** Ramp colours when `tint` is `'ramp'`, parallel to `stops`. Componentwise for equal stop counts; otherwise there is no correspondence to interpolate along, so it snaps at the midpoint. */\n colors: param.of<Color[]>()({\n kind: \"colors\",\n default: GLOW_RAMP_COLORS,\n hidden: true,\n order: 13,\n lerp: (a, b, t) => (a.length !== b.length ? (t < 0.5 ? a : b) : a.map((c, i) => lerpColor(resolveEffectColor(c), resolveEffectColor(b[i]), t))),\n equals: (a, b) => a.length === b.length && a.every((c, i) => sameEffectColor(c, b[i])),\n }),\n /** Each ramp colour's position, 0-1 ascending (evenly spaced when absent). */\n stops: param.of<number[]>()({\n kind: \"numbers\",\n default: GLOW_RAMP_STOPS,\n hidden: true,\n order: 14,\n lerp: (a, b, t, from, to) => ((from.colors as Color[]).length !== (to.colors as Color[]).length\n ? (t < 0.5 ? a : b)\n : a.map((s, i) => lerpNumber(s, b[i] ?? s, t))),\n equals: (a, b) => a.length === b.length && a.every((s, i) => s === b[i]),\n }),\n /** How the ramp repeats past one pass. */\n loopStyle: param.choice([\"mirror\", \"repeat\"] satisfies GlowLoopStyle[], { default: \"mirror\", control: \"segmented\", optionsLabel: \"glowLoopStyle\", order: 6 }),\n /** Ramp traversals across the glow's strength range. */\n cycles: param.number({ default: 1, min: 1, max: 10, step: 0.1, order: 7 }),\n /** Offset along the ramp in degrees of one cycle; animate to move colour. */\n phase: param.number({ default: 0, unit: \"deg\", control: \"angle\", order: 8 }),\n },\n});\n\nexport const glowEffect: EffectData<GlowEffect> = effectDataOf(glowSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** Kuwahara filter, the painterly one: each pixel takes the mean of whichever of four overlapping quadrant windows is *flattest*, so flat areas smooth into strokes while edges stay crisp (a blur softens both). Cost grows with `radius²` (four windows of `(radius+1)²` samples): by far the most expensive effect. */\nexport interface OilPaintEffect extends ModedEffect, EffectFields<typeof oilPaintSpec.params> {\n type: \"oilPaint\";\n}\n\nexport const oilPaintSpec = defineEffect({\n type: \"oilPaint\",\n group: \"blur\",\n // Reads a large neighbourhood per pixel.\n surface: \"shader\",\n scalar: \"radius\",\n neutral: { radius: 0 },\n params: {\n /** Window radius in pixels — brush size, capped at 6. */\n radius: param.number({ default: 3, min: 0, max: 6, step: 1, unit: \"px\", label: \"brush\", inline: true }),\n },\n});\n\nexport const oilPaintEffect: EffectData<OilPaintEffect> = effectDataOf(oilPaintSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { CENTER, defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** How the wave's crests are laid out: `\"linear\"` (parallel crests travelling along `angle`: flags, heat shimmer) or `\"radial\"` (concentric rings from `center`: pond ripples, drop impacts). */\nexport type WaveShape = \"linear\" | \"radial\";\n\n/** Sine displacement, the procedural warp that needs no asset: pixels are resampled at an offset by a sine of their own coordinate (see `displace` for an image-driven warp). `phase` is in degrees and wraps, so a **linear tween of `phase` over 360 loops seamlessly**: how the wave travels. */\nexport interface WaveEffect extends ModedEffect, EffectFields<typeof waveSpec.params> {\n type: \"wave\";\n}\n\nexport const waveSpec = defineEffect({\n type: \"wave\",\n group: \"distort\",\n // Resamples the source at an offset position.\n surface: \"shader\",\n scalar: \"amplitude\",\n neutral: { amplitude: 0 },\n params: {\n /** Peak displacement in px per axis. A bare number means Y only: displacing along the direction of travel just smears. */\n amplitude: param.vec2({ default: 20, fromNumber: \"y\", unit: \"px\" }),\n /** Distance between crests in px. */\n wavelength: param.number({ default: 120, min: 1, unit: \"px\", inline: true }),\n /** Phase in degrees; tween over 360 for one seamless loop. */\n phase: param.number({ default: 0, step: 1, unit: \"deg\" }),\n /** Parallel bands or concentric rings. */\n shape: param.choice([\"linear\", \"radial\"] satisfies WaveShape[], { default: \"linear\", label: \"crestShape\", optionsLabel: \"waveShape\" }),\n /** Direction the crests advance along, in degrees. `'linear'` only. */\n angle: param.number({ default: 0, unit: \"deg\", control: \"angle\" }),\n /** Ring origin in 0–1 layer coords. `'radial'` only. */\n center: param.vec2({ default: CENTER, min: 0, max: 1, step: 0.01, unit: \"normalized\", label: \"ringCenter\" }),\n },\n});\n\nexport const waveEffect: EffectData<WaveEffect> = effectDataOf(waveSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { CENTER, defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** Twirl / swirl: the content rotates about `center` by an amount that falls off with distance (full `angle` at the centre, zero at the rim of `radius`), so it shears like a vortex rather than rotating rigidly. There is no wrap point: animating `angle` past a full turn keeps winding into an ever-tighter spiral. */\nexport interface TwirlEffect extends ModedEffect, EffectFields<typeof twirlSpec.params> {\n type: \"twirl\";\n}\n\nexport const twirlSpec = defineEffect({\n type: \"twirl\",\n group: \"distort\",\n // Resamples the source at a rotated position.\n surface: \"shader\",\n scalar: \"angle\",\n neutral: { angle: 0 },\n params: {\n /** Rotation at the centre in degrees. */\n angle: param.number({ default: 180, unit: \"deg\", label: \"twist\", inline: true }),\n /** 0–1 radius of influence (1 = the whole node). */\n radius: param.number({ default: 1, min: 0, max: 1, control: \"slider\", label: \"reach\" }),\n /** Vortex centre in 0–1 layer coords. */\n center: param.vec2({ default: CENTER, min: 0, max: 1, step: 0.01, unit: \"normalized\", label: \"vortexCenter\" }),\n },\n});\n\nexport const twirlEffect: EffectData<TwirlEffect> = effectDataOf(twirlSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { CENTER, defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** How the blur ramp is laid out: `\"linear\"` runs along `angle` (the fade-to-blur strip under a toolbar), `\"radial\"` runs outward from `center` (sharp middle, soft surround: a cheap tilt-shift). */\nexport type ProgressiveBlurShape = \"linear\" | \"radial\";\n\n/** Blur whose radius *ramps* from `startRadius` to `radius` between `start` and `end` along the ramp, so content dissolves into softness. **In `mode: 'backdrop'` this is the frosted panel with a falloff** (blur fading out at the edge, which a plain backdrop blur cannot express). Cost scales with `samples`, spent on the *widest* part of the ramp; pixels below `start` return the source untouched. */\nexport interface ProgressiveBlurEffect extends ModedEffect, EffectFields<typeof progressiveBlurSpec.params> {\n type: \"progressiveBlur\";\n}\n\nexport const progressiveBlurSpec = defineEffect({\n type: \"progressiveBlur\",\n group: \"blur\",\n // Averages a neighbourhood whose extent varies per pixel.\n surface: \"shader\",\n scalar: \"radius\",\n neutral: { radius: 0 },\n params: {\n /** Blur spread in px at the far end of the ramp. */\n radius: param.number({ default: 24, min: 0, unit: \"px\", label: \"endBlur\", order: 2 }),\n /** Blur spread in px at the near end of the ramp (0 is sharp). */\n startRadius: param.number({ default: 0, min: 0, unit: \"px\", label: \"startBlur\", order: 1 }),\n /** Ramp layout. */\n shape: param.choice([\"linear\", \"radial\"] satisfies ProgressiveBlurShape[], { default: \"linear\", control: \"segmented\", label: \"rampShape\", optionsLabel: \"rampShape\", order: 0 }),\n /** 0–1 where the blur starts building. */\n start: param.number({ default: 0, min: -0.5, max: 1.5, control: \"slider\", label: \"rampStart\", order: 3 }),\n /** 0–1 where it reaches `radius`. */\n end: param.number({ default: 1, min: -0.5, max: 1.5, control: \"slider\", label: \"rampEnd\", order: 4 }),\n /** Ramp direction in degrees; 0 = left-to-right, 90 = downward. */\n angle: param.number({ default: 90, unit: \"deg\", control: \"angle\", order: 5 }),\n /** Ramp origin in 0–1 layer coords. `'radial'` only. */\n center: param.vec2({ default: CENTER, min: 0, max: 1, step: 0.01, unit: \"normalized\", order: 6 }),\n /** Taps averaged at full radius, 2–32. A fractional count would just round, so it snaps. */\n samples: param.number({ default: 20, min: 2, max: 32, step: 1, lerp: \"step\", hidden: true, order: 7, initial: 16 }),\n },\n});\n\nexport const progressiveBlurEffect: EffectData<ProgressiveBlurEffect> = effectDataOf(progressiveBlurSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { CENTER, defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** Folds the content into `segments` mirrored wedges around `center`. Only the wedge starting at `angle` is read; the rest are it reflected or rotated, so animating `angle` keeps the pattern locked while *different source material* sweeps through (not the same as rotating the node). `segments` counts mirrored pairs (6 is the snowflake) and is discrete: a fractional fold would tear, so a tween snaps. */\nexport interface KaleidoscopeEffect extends ModedEffect, EffectFields<typeof kaleidoscopeSpec.params> {\n type: \"kaleidoscope\";\n}\n\nexport const kaleidoscopeSpec = defineEffect({\n type: \"kaleidoscope\",\n group: \"distort\",\n // Resamples the source at a reflected position.\n surface: \"shader\",\n scalar: \"segments\",\n // `segments` is discrete, so the neutral is the continuous blend.\n neutral: { amount: 0 },\n params: {\n /** Number of mirrored wedges; below 2 is a no-op. Discrete: a fractional wedge cannot tile the circle, so it rounds and a tween snaps. */\n segments: param.number({ default: 6, normalize: Math.round, min: 2, max: 64, step: 1, lerp: \"step\", inline: true }),\n /** Rotation of the pattern in degrees — animate to sweep the source. */\n angle: param.number({ default: 0, step: 1, unit: \"deg\" }),\n /** Fold origin in 0–1 layer coords. */\n center: param.vec2({ default: CENTER, min: 0, max: 1, step: 0.01, unit: \"normalized\", label: \"foldCenter\" }),\n /** Radial offset of the sampled wedge. */\n offset: param.number({ default: 0, min: -1, max: 1, control: \"slider\", label: \"wedgeOffset\" }),\n /** 0–1 blend from the original to the folded pattern. */\n amount: param.number({ default: 1, min: 0, max: 1, control: \"slider\" }),\n },\n});\n\nexport const kaleidoscopeEffect: EffectData<KaleidoscopeEffect> = effectDataOf(kaleidoscopeSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/** Figma's Glass: the backdrop seen through a slab whose edge curves down to the node's outline, refracted, split into a spectrum, optionally frosted, with a rim of light. Fields and units are Figma's (`depth`/`frost` px, `lightAngle` degrees clockwise from the top, the rest 0–100), so copied values render the same. Only meaningful on the **backdrop** (nothing to refract in a node's own paint), so `Effects.glass()` defaults `mode` to `'backdrop'`. */\nexport interface GlassEffect extends ModedEffect, EffectFields<typeof glassSpec.params> {\n type: \"glass\";\n}\n\nexport const glassSpec = defineEffect({\n type: \"glass\",\n group: \"light\",\n // Resamples the backdrop through a bevel, three times per fragment.\n surface: \"shader\",\n scalar: \"refraction\",\n defaultMode: \"backdrop\",\n onlyOn: \"backdrop\",\n // No curved edge means nothing to refract or light along.\n neutral: { depth: 0 },\n params: {\n /** Where the light comes from, in degrees clockwise from the top. */\n lightAngle: param.number({ default: -45, unit: \"deg\", control: \"angle\", zero: \"top\" }),\n /** 0–100 brightness of the light. */\n lightIntensity: param.number({ default: 80, min: 0, max: 100, unit: \"percent\" }),\n /** 0–100 how strongly the curved edge bends the backdrop. */\n refraction: param.number({ default: 80, min: 0, max: 100, step: 1, control: \"slider\", inline: true }),\n /** How far the curved edge reaches in from the outline, px. */\n depth: param.number({ default: 20, min: 0, max: 100, step: 1, unit: \"px\", control: \"slider\" }),\n /** 0–100 spectral split along the curved edge. */\n dispersion: param.number({ default: 50, min: 0, max: 100, step: 1, control: \"slider\" }),\n /** Backdrop blur radius, px. */\n frost: param.number({ default: 4, min: 0, max: 100, step: 1, unit: \"px\", control: \"slider\" }),\n /** 0–100 how far the projected light spreads in from the rim. */\n splay: param.number({ default: 0, min: 0, max: 100, step: 1, control: \"slider\" }),\n },\n});\n\nexport const glassEffect: EffectData<GlassEffect> = effectDataOf(glassSpec);\n", "import type { ModedEffect, EffectData } from \"../effect-data\";\nimport { defineEffect, effectDataOf, param, type EffectFields } from \"../spec\";\n\n/**\n * A 3D colour lookup table (the `.cube` a colourist hands you): not a formula but a measured cube of what each colour\n * should *become*, so no combination of curves and matrices substitutes for it. A node effect rather than a media-only\n * adjustment on purpose: outside {@link NonFilterEffect} everything is an `EffectAdjustment` too, so one implementation\n * grades an image fill and a whole node and the two stay the same look.\n *\n * The table is flat RGB triples, **red-fastest** (index `((b · size) + g) · size + r`, times three), the order a `.cube`\n * file writes, so a parser fills it with no transposition. It is a `Float32Array` treated as **immutable and shared**:\n * `equals` compares by reference and `lerp` hard-cuts it, because a 33³ cube is 107,811 floats (comparing per frame\n * costs more than the draw, interpolating allocates a cube per frame) and the renderer's GPU upload is cached against\n * this identity. Hand back the same array each frame for one upload per scene. Cross-fading two LUTs is a cut; dissolve\n * with two fills or {@link amount}.\n */\nexport interface LutEffect extends ModedEffect, EffectFields<typeof lutSpec.params> {\n type: \"lut\";\n}\n\nexport const lutSpec = defineEffect({\n type: \"lut\",\n group: \"color\",\n // It samples a second texture at a coordinate derived from the source's colour, so it needs the source as a readable shader, not a composable colour matrix.\n surface: \"shader\",\n // A LUT's neutral is its mix, not its table.\n neutral: { amount: 0 },\n params: {\n /** The cube: flat RGB triples, red-fastest. Compared by reference, cut by `lerp`. */\n table: param.of<Float32Array>()({ kind: \"table\", required: true, hidden: true }),\n /** Entries per axis. Cuts with the table: a table read at the wrong stride is garbage, not a wrong colour. */\n size: param.number({ required: true, min: 2, step: 1, lerp: \"step\", hidden: true }),\n /** 0–1 mix against the ungraded colour. */\n amount: param.number({ default: 1, min: 0, max: 1, control: \"slider\", inline: true }),\n },\n});\n\nexport const lutEffect: EffectData<LutEffect> = effectDataOf(lutSpec);\n", "import { NodeEffect } from \"./union\";\n\nimport { blurEffect, blurSpec } from \"./implementations/blur\";\nimport { directionalBlurEffect, directionalBlurSpec } from \"./implementations/directional-blur\";\nimport { grayscaleEffect, grayscaleSpec } from \"./implementations/grayscale\";\nimport { pixelateEffect, pixelateSpec } from \"./implementations/pixelate\";\nimport { bulgeEffect, bulgeSpec } from \"./implementations/bulge\";\nimport { magnifyEffect, magnifySpec } from \"./implementations/magnify\";\nimport { bloomEffect, bloomSpec } from \"./implementations/bloom\";\nimport { vintageEffect, vintageSpec } from \"./implementations/vintage\";\nimport { chromaticAberrationEffect, chromaticAberrationSpec } from \"./implementations/chromatic-aberration\";\nimport { invertEffect, invertSpec } from \"./implementations/invert\";\nimport { scatterEffect, scatterSpec } from \"./implementations/scatter\";\nimport { posterizeEffect, posterizeSpec } from \"./implementations/posterize\";\nimport { motionBlurEffect, motionBlurSpec } from \"./implementations/motion-blur\";\nimport { shaderEffect, shaderSpec } from \"./implementations/shader\";\nimport { outlineEffect, outlineSpec } from \"./implementations/outline\";\nimport { dropShadowEffect, dropShadowSpec } from \"./implementations/drop-shadow\";\nimport { vignetteEffect, vignetteSpec } from \"./implementations/vignette\";\nimport { grainEffect, grainSpec } from \"./implementations/grain\";\nimport { sharpenEffect, sharpenSpec } from \"./implementations/sharpen\";\nimport { edgesEffect, edgesSpec } from \"./implementations/edges\";\nimport { thresholdEffect, thresholdSpec } from \"./implementations/threshold\";\nimport { radialBlurEffect, radialBlurSpec } from \"./implementations/radial-blur\";\nimport { halftoneEffect, halftoneSpec } from \"./implementations/halftone\";\nimport { ditherEffect, ditherSpec } from \"./implementations/dither\";\nimport { duotoneEffect, duotoneSpec } from \"./implementations/duotone\";\nimport { curvesEffect, curvesSpec } from \"./implementations/curves\";\nimport { colorAdjustmentEffect, colorAdjustmentSpec } from \"./implementations/color-adjustment\";\nimport { rgbShiftEffect, rgbShiftSpec } from \"./implementations/rgb-shift\";\nimport { scanlinesEffect, scanlinesSpec } from \"./implementations/scanlines\";\nimport { blockDisplaceEffect, blockDisplaceSpec } from \"./implementations/block-displace\";\nimport { bitCrushEffect, bitCrushSpec } from \"./implementations/bit-crush\";\nimport { asciiEffect, asciiSpec } from \"./implementations/ascii\";\nimport { streakEffect, streakSpec } from \"./implementations/streak\";\nimport { glowEffect, glowSpec } from \"./implementations/glow\";\nimport { oilPaintEffect, oilPaintSpec } from \"./implementations/oil-paint\";\nimport { waveEffect, waveSpec } from \"./implementations/wave\";\nimport { twirlEffect, twirlSpec } from \"./implementations/twirl\";\nimport { progressiveBlurEffect, progressiveBlurSpec } from \"./implementations/progressive-blur\";\nimport { kaleidoscopeEffect, kaleidoscopeSpec } from \"./implementations/kaleidoscope\";\nimport { glassEffect, glassSpec } from \"./implementations/glass\";\nimport { lutEffect, lutSpec } from \"./implementations/lut\";\nimport { EffectData, EffectSurface, EFFECT_OPTION_KEYS } from \"./effect-data\";\nimport { describeSpec, type EffectDescriptor, type EffectSpec } from \"./spec\";\nimport type { AssetScope } from \"@/assets/scope\";\n\n\n/** Every built-in effect: its spec and the `EffectData` derived from it, in registration order. */\nconst BUILT_INS: readonly (readonly [EffectSpec, EffectData<any>])[] = [\n [blurSpec, blurEffect],\n [directionalBlurSpec, directionalBlurEffect],\n [grayscaleSpec, grayscaleEffect],\n [pixelateSpec, pixelateEffect],\n [bulgeSpec, bulgeEffect],\n [magnifySpec, magnifyEffect],\n [bloomSpec, bloomEffect],\n [vintageSpec, vintageEffect],\n [chromaticAberrationSpec, chromaticAberrationEffect],\n [invertSpec, invertEffect],\n [scatterSpec, scatterEffect],\n [posterizeSpec, posterizeEffect],\n [motionBlurSpec, motionBlurEffect],\n [shaderSpec, shaderEffect],\n [outlineSpec, outlineEffect],\n [dropShadowSpec, dropShadowEffect],\n [vignetteSpec, vignetteEffect],\n [grainSpec, grainEffect],\n [sharpenSpec, sharpenEffect],\n [edgesSpec, edgesEffect],\n [thresholdSpec, thresholdEffect],\n [radialBlurSpec, radialBlurEffect],\n [halftoneSpec, halftoneEffect],\n [ditherSpec, ditherEffect],\n [duotoneSpec, duotoneEffect],\n [curvesSpec, curvesEffect],\n [colorAdjustmentSpec, colorAdjustmentEffect],\n [rgbShiftSpec, rgbShiftEffect],\n [scanlinesSpec, scanlinesEffect],\n [blockDisplaceSpec, blockDisplaceEffect],\n [bitCrushSpec, bitCrushEffect],\n [asciiSpec, asciiEffect],\n [streakSpec, streakEffect],\n [glowSpec, glowEffect],\n [oilPaintSpec, oilPaintEffect],\n [waveSpec, waveEffect],\n [twirlSpec, twirlEffect],\n [progressiveBlurSpec, progressiveBlurEffect],\n [kaleidoscopeSpec, kaleidoscopeEffect],\n [glassSpec, glassEffect],\n [lutSpec, lutEffect],\n];\n\nconst EFFECTS = new Map<string, EffectData<NodeEffect>>(BUILT_INS.map(([spec, data]) => [spec.type, data]));\nconst SPECS = new Map<string, EffectSpec>(BUILT_INS.map(([spec]) => [spec.type, spec]));\n\nfunction dataFor(type: string): EffectData<NodeEffect> | undefined {\n return EFFECTS.get(type);\n}\n\n/** Normalises one authored effect (see {@link EffectData.resolve}); returned untouched when its type registers no `resolve`, which is every effect but one. */\nexport function resolveEffect(effect: NodeEffect): NodeEffect {\n const data = dataFor(effect.type);\n return data?.resolve ? data.resolve(effect) : effect;\n}\n\n/** Every registered effect type, in registration order: the roster itself, so a contract test sweeps the whole set rather than a hand-kept list. */\nexport const effectTypes = (): string[] => [...EFFECTS.keys()];\n\nexport function effectSpec(type: string): EffectSpec | undefined {\n return SPECS.get(type);\n}\n\nconst descriptors = new Map<string, EffectDescriptor>();\n\n/** A built-in effect type described for a host as plain JSON (see {@link EffectDescriptor}); `undefined` for a type core does not know. */\nexport function describeEffect(type: string): EffectDescriptor | undefined {\n const spec = effectSpec(type);\n if (!spec) return undefined;\n let out = descriptors.get(spec.type);\n if (!out) descriptors.set(spec.type, (out = describeSpec(spec)));\n return structuredClone(out);\n}\n\nexport function effectDescriptors(): EffectDescriptor[] {\n return [...SPECS.keys()].map((type) => describeEffect(type)!);\n}\n\nexport function hasEffect(type: string): boolean {\n return dataFor(type) !== undefined;\n}\n\n/** How a backend must realise `effect` (see {@link EffectSurface}); unknown types fall back to `\"filter\"`. */\nexport function effectSurface(effect: NodeEffect): EffectSurface {\n const surface = dataFor(effect.type)?.surface;\n if (surface === undefined) return \"filter\";\n return typeof surface === \"function\" ? surface(effect) : surface;\n}\n\nexport function declareEffect(effect: NodeEffect, assets: AssetScope): void {\n dataFor(effect.type)?.declare?.(effect, assets);\n}\n\n/** Interpolates two effects of the same type. The cross-cutting {@link EFFECT_OPTION_KEYS} (`mode`, `clip`) are carried here for every kind (switching at the midpoint), so an effect's own `lerp` only describes its parameters and a new option cannot be dropped by a hand-written copy. @internal */\nexport function lerpEffect(from: NodeEffect, to: NodeEffect, t: number): NodeEffect {\n if (from.type !== to.type) return t < 0.5 ? from : to;\n const data = dataFor(from.type);\n if (!data) return t < 0.5 ? from : to;\n const lerped = data.lerp(from, to, t);\n const source = t < 0.5 ? from : to;\n let out: NodeEffect | undefined;\n for (const key of EFFECT_OPTION_KEYS) {\n if (lerped[key] === source[key]) continue;\n // Copy lazily, and omit rather than write `undefined`: the equality\n // checks compare these fields directly.\n out ??= { ...lerped } as NodeEffect;\n const target = out as unknown as Record<string, unknown>;\n if (source[key] === undefined) delete target[key];\n else target[key] = source[key];\n }\n return out ?? lerped;\n}\n\n/** Whether two effects describe the same look: the effect's own `equals` compares its parameters; the type and {@link EFFECT_OPTION_KEYS} are compared here for every kind. @internal */\nexport function equalsEffect(a: NodeEffect, b: NodeEffect): boolean {\n if (a.type !== b.type) return false;\n if (EFFECT_OPTION_KEYS.some((key) => a[key] !== b[key])) return false;\n const data = dataFor(a.type);\n return data ? data.equals(a, b) : a === b;\n}\n", "import { parseColor } from \"../fill/color/parser\";\nimport type { ShaderUniformRecord, ShaderUniformValue } from \"./uniforms\";\nimport type { Shader, ShaderProperty } from \"./pack\";\n\n/** Overrides for a pack's properties, by property id. */\nexport type ShaderPropertyValues = Record<string, unknown>;\n\n/** Component names a multi-part property may map, in the order they index. */\nconst COMPONENTS = [\"x\", \"y\", \"z\", \"w\"] as const;\nconst COLOR_COMPONENTS = [\"r\", \"g\", \"b\", \"a\"] as const;\n\n/** Turns a pack's properties, plus overrides, into the uniform record the renderer writes. One property may feed several uniforms (see `ShaderPropertyBase.inputs`), so this is not a rename. The pack's own `uniforms` merge in first and properties win: the more specific statement of a value takes it. */\nexport function resolveShaderProperties(\n pack: Shader,\n overrides?: ShaderPropertyValues,\n): ShaderUniformRecord {\n const out: ShaderUniformRecord = { ...(pack.uniforms ?? {}) };\n\n for (const [id, property] of Object.entries(pack.properties)) {\n const supplied = overrides && id in overrides ? overrides[id] : property.default;\n const parts = componentsOf(property, supplied, id, pack.name);\n if (!parts) continue;\n for (const [component, uniform] of Object.entries(property.inputs)) {\n const value = parts[component];\n if (value === undefined) {\n warn(`shader \"${pack.name}\" property \"${id}\" has no \"${component}\" to write to \"${uniform}\".`);\n continue;\n }\n out[uniform] = value;\n }\n }\n\n if (overrides) {\n for (const id of Object.keys(overrides)) {\n if (id in pack.properties) continue;\n warn(`shader \"${pack.name}\" has no property \"${id}\"; the override is ignored.`);\n }\n }\n\n return out;\n}\n\n/** Splits one property's value across the components its `inputs` name. A property naming only `value` passes its whole value through; one naming `x`/`y` (or `r`/`g`/`b`/`a`) indexes into it, so a `point` can drive two separate `float` uniforms. */\nfunction componentsOf(\n property: ShaderProperty,\n value: unknown,\n id: string,\n where: string,\n): Record<string, ShaderUniformValue> | undefined {\n const flat = toUniformValue(property, value, id, where);\n if (flat === undefined) return undefined;\n\n const names = Object.keys(property.inputs);\n if (names.length === 1 && names[0] === \"value\") return { value: flat };\n\n const parts = typeof flat === \"number\" ? [flat] : flat;\n const out: Record<string, ShaderUniformValue> = { value: flat };\n for (const [index, name] of COMPONENTS.entries()) {\n if (parts[index] !== undefined) out[name] = parts[index];\n }\n for (const [index, name] of COLOR_COMPONENTS.entries()) {\n if (parts[index] !== undefined) out[name] = parts[index];\n }\n return out;\n}\n\nfunction toUniformValue(\n property: ShaderProperty,\n value: unknown,\n id: string,\n where: string,\n): ShaderUniformValue | undefined {\n switch (property.kind) {\n case \"number\":\n case \"slider\":\n case \"angle\":\n case \"hue\":\n return asFinite(value, id, where);\n\n // A `bool` cannot be a uniform member in WGSL; a float of 1 or 0 is what a shader can branch on.\n case \"boolean\":\n return value ? 1 : 0;\n\n case \"color\":\n return asColor(value, id, where);\n\n case \"vector\":\n case \"point\":\n return asFloats(value, id, where);\n\n // An unknown kind still resolves: its value reaches its uniforms\n // untouched, so a shader a host cannot fully draw still renders.\n default:\n return typeof value === \"number\" || Array.isArray(value)\n ? (value as ShaderUniformValue)\n : undefined;\n }\n}\n\nfunction asFinite(value: unknown, id: string, where: string): number | undefined {\n if (typeof value === \"number\" && Number.isFinite(value)) return value;\n warn(`shader \"${where}\" property \"${id}\" expects a number, got ${JSON.stringify(value)}.`);\n return undefined;\n}\n\n/** A colour as four floats in 0–1. A CSS string is parsed (via `parseColor`, the one place those are understood), so theme tokens, `oklch()` and `\"white/10\"` all reach a shader. */\nfunction asColor(value: unknown, id: string, where: string): number[] | undefined {\n if (typeof value === \"string\") {\n const [r, g, b, a] = parseColor(value);\n return [r, g, b, a];\n }\n return asFloats(value, id, where);\n}\n\nfunction asFloats(value: unknown, id: string, where: string): number[] | undefined {\n if (Array.isArray(value) && value.every((v) => typeof v === \"number\" && Number.isFinite(v))) {\n return value as number[];\n }\n if (typeof value === \"object\" && value !== null) {\n const point = value as { x?: unknown; y?: unknown };\n if (typeof point.x === \"number\" && typeof point.y === \"number\") return [point.x, point.y];\n }\n warn(`shader \"${where}\" property \"${id}\" expects numbers, got ${JSON.stringify(value)}.`);\n return undefined;\n}\n\nconst warned = new Set<string>();\n\nfunction warn(message: string): void {\n if (warned.has(message)) return;\n if (warned.size > 256) warned.clear();\n warned.add(message);\n console.warn(`[shader] ${message}`);\n}\n", "import { NodeEffect } from \"./union\";\nimport type { BlendMode } from \"../fill/blend\";\nimport type { EffectOptions } from \"./effect-data\";\nimport { scalarOptions, withEffectOptions } from \"./effect-data\";\nimport { resolveEffect, lerpEffect } from \"./registry\";\nimport { buildEffect, type EffectOptionsOf } from \"./spec\";\nimport { blurSpec } from \"./implementations/blur\";\nimport { directionalBlurSpec } from \"./implementations/directional-blur\";\nimport { grayscaleSpec } from \"./implementations/grayscale\";\nimport { pixelateSpec } from \"./implementations/pixelate\";\nimport { bulgeSpec } from \"./implementations/bulge\";\nimport { magnifySpec } from \"./implementations/magnify\";\nimport { bloomSpec } from \"./implementations/bloom\";\nimport { vintageSpec } from \"./implementations/vintage\";\nimport { chromaticAberrationSpec } from \"./implementations/chromatic-aberration\";\nimport { invertSpec } from \"./implementations/invert\";\nimport { scatterSpec } from \"./implementations/scatter\";\nimport { posterizeSpec } from \"./implementations/posterize\";\nimport { motionBlurSpec } from \"./implementations/motion-blur\";\nimport { outlineSpec } from \"./implementations/outline\";\nimport { dropShadowSpec } from \"./implementations/drop-shadow\";\nimport { vignetteSpec } from \"./implementations/vignette\";\nimport { lutSpec } from \"./implementations/lut\";\nimport { grainSpec } from \"./implementations/grain\";\nimport { sharpenSpec } from \"./implementations/sharpen\";\nimport { edgesSpec } from \"./implementations/edges\";\nimport { thresholdSpec } from \"./implementations/threshold\";\nimport { radialBlurSpec } from \"./implementations/radial-blur\";\nimport { halftoneSpec } from \"./implementations/halftone\";\nimport { ditherSpec } from \"./implementations/dither\";\nimport { duotoneSpec } from \"./implementations/duotone\";\nimport { curvesSpec } from \"./implementations/curves\";\nimport { rgbShiftSpec } from \"./implementations/rgb-shift\";\nimport { scanlinesSpec } from \"./implementations/scanlines\";\nimport { blockDisplaceSpec } from \"./implementations/block-displace\";\nimport { bitCrushSpec } from \"./implementations/bit-crush\";\nimport { asciiSpec } from \"./implementations/ascii\";\nimport { oilPaintSpec } from \"./implementations/oil-paint\";\nimport { streakSpec } from \"./implementations/streak\";\nimport { glowSpec } from \"./implementations/glow\";\nimport { waveSpec } from \"./implementations/wave\";\nimport { twirlSpec } from \"./implementations/twirl\";\nimport { progressiveBlurSpec } from \"./implementations/progressive-blur\";\nimport { kaleidoscopeSpec } from \"./implementations/kaleidoscope\";\nimport { glassSpec } from \"./implementations/glass\";\nimport type { AttributeOps } from \"@/attributes/shared/operators\";\nimport { normalizeUniforms, type ShaderUniform, type ShaderUniformRecord } from \"../shaders/uniforms\";\nimport { resolveShaderProperties, type ShaderPropertyValues } from \"../shaders/resolve\";\nimport type { EffectShader } from \"../shaders/pack\";\nimport type { ColorAdjustmentEffect } from \"./implementations/color-adjustment\";\n\n// Shared field vocabulary: `radius` px, `amount` 0-1, `angle` degrees, `center` 0-1 point, `axis` an {@link EffectAxis}.\n\n/** Gaussian blur. Scalar shorthand sets `radius`. */\nexport type BlurOptions = EffectOptionsOf<typeof blurSpec.params>;\n\n/** Directional (linear) blur. Scalar shorthand sets `radius`. */\nexport type DirectionalBlurOptions = EffectOptionsOf<typeof directionalBlurSpec.params>;\n\n/** Desaturation. Scalar shorthand sets `amount`. */\nexport type GrayscaleOptions = EffectOptionsOf<typeof grayscaleSpec.params>;\n\n/** After Effects-style Mosaic. Scalar shorthand sets `blocks`, a block count across the node: a count equal to the node's pixel size is pristine. */\nexport type PixelateOptions = EffectOptionsOf<typeof pixelateSpec.params>;\n\n/** Bulge / pinch lens over the node's content, or the backdrop. Scalar shorthand sets `strength`. */\nexport type BulgeOptions = EffectOptionsOf<typeof bulgeSpec.params>;\n\n/** Magnifier lens over the backdrop. Scalar shorthand sets `scale`. */\nexport type MagnifyOptions = EffectOptionsOf<typeof magnifySpec.params>;\n\n/** Bloom (glow). Scalar shorthand sets `intensity`. */\nexport type BloomOptions = EffectOptionsOf<typeof bloomSpec.params>;\n\n/** Vintage / film-look colour grading. Scalar shorthand sets `amount`. */\nexport type VintageOptions = EffectOptionsOf<typeof vintageSpec.params>;\n\n/** Lens-dispersion colour fringing. Scalar shorthand sets `amount`. */\nexport type ChromaticAberrationOptions = EffectOptionsOf<typeof chromaticAberrationSpec.params>;\n\n/** Colour invert. Scalar shorthand sets `strength`. */\nexport type InvertOptions = EffectOptionsOf<typeof invertSpec.params>;\n\n/** Per-pixel random jitter. Scalar shorthand sets `strength`. */\nexport type ScatterOptions = EffectOptionsOf<typeof scatterSpec.params>;\n\n/** Colour banding. Scalar shorthand sets `levels`. */\nexport type PosterizeOptions = EffectOptionsOf<typeof posterizeSpec.params>;\n\n/** Velocity-driven motion blur. Scalar shorthand sets `length`. */\nexport type MotionBlurOptions = EffectOptionsOf<typeof motionBlurSpec.params>;\n\n/** A custom shader. `mode` picks the layer `sample_src` reads: `'foreground'` (default) the node's own, or `'backdrop'` what is painted beneath it. */\nexport interface ShaderEffectOptions extends EffectOptions {\n /** WGSL program, or a registered shader pack. A pack resolves to plain uniforms here; the document keeps the resolved record plus a `shaderId` so a host can reopen its property panel. */\n source: string | EffectShader;\n /** Property overrides by id when {@link source} is a pack; unnamed ones take the pack default. Ignored with a warning for a bare string. */\n values?: ShaderPropertyValues;\n /** Uniform values by name, lerped between frames (default `{}`). The `[{ name, value }]` array form is bound by name too. */\n uniforms?: ShaderUniformRecord | ShaderUniform[];\n /** How a foreground shader composites onto the layer; its output replaces the layer when absent. */\n blendMode?: BlendMode;\n /** How far past the node's box (logical px) a WGSL effect may draw. Default 0. */\n reach?: number;\n}\n\n/** Coloured band around the node's silhouette. Scalar shorthand sets `width`. */\nexport type OutlineOptions = EffectOptionsOf<typeof outlineSpec.params>;\n\n/** Cast from the node's silhouette. Scalar shorthand sets `blur`. */\nexport type DropShadowOptions = EffectOptionsOf<typeof dropShadowSpec.params>;\n\n/** Darkened edges / lens falloff. Scalar shorthand sets `amount`. */\nexport type VignetteOptions = EffectOptionsOf<typeof vignetteSpec.params>;\n\n/** 3D colour lookup table; see {@link LutEffect}. No scalar shorthand: the dominant argument is a whole cube. */\nexport type LutOptions = EffectOptionsOf<typeof lutSpec.params>;\n\n/** Film grain. Scalar shorthand sets `amount`. */\nexport type GrainOptions = EffectOptionsOf<typeof grainSpec.params>;\n\n/** Unsharp-mask sharpen. Scalar shorthand sets `amount`. */\nexport type SharpenOptions = EffectOptionsOf<typeof sharpenSpec.params>;\n\n/** Edge detection. Scalar shorthand sets `strength`. */\nexport type EdgesOptions = EffectOptionsOf<typeof edgesSpec.params>;\n\n/** Two-tone luminance cut. Scalar shorthand sets `level`. */\nexport type ThresholdOptions = EffectOptionsOf<typeof thresholdSpec.params>;\n\n/** Zoom / spin blur about a point. Scalar shorthand sets `amount`. */\nexport type RadialBlurOptions = EffectOptionsOf<typeof radialBlurSpec.params>;\n\n/** Halftone print screen. Scalar shorthand sets `size`. */\nexport type HalftoneOptions = EffectOptionsOf<typeof halftoneSpec.params>;\n\n/** Ordered (Bayer) dithering. Scalar shorthand sets `levels`. */\nexport type DitherOptions = EffectOptionsOf<typeof ditherSpec.params>;\n\n/** Two-colour luminance ramp. Scalar shorthand sets `amount`. */\nexport type DuotoneOptions = EffectOptionsOf<typeof duotoneSpec.params>;\n\n/** Tone curve through control points. */\nexport type CurvesOptions = EffectOptionsOf<typeof curvesSpec.params>;\n\n/** Photographic grading. Every field is optional and defaults to neutral. */\nexport type ColorAdjustmentOptions = Omit<ColorAdjustmentEffect, 'type'> & EffectOptions;\n\n/** Per-channel RGB offset. Name `red`/`green`/`blue` for full control. */\nexport type RgbShiftOptions = EffectOptionsOf<typeof rgbShiftSpec.params> & {\n /** Shorthand: ±px horizontal spread of red vs. blue (default 4); `red`/`blue` override it. */\n amount?: number;\n};\n\n/** CRT scanlines. Scalar shorthand sets `darkness`. */\nexport type ScanlinesOptions = EffectOptionsOf<typeof scanlinesSpec.params>;\n\n/** Datamosh-style band tearing. Scalar shorthand sets `amount`. */\nexport type BlockDisplaceOptions = EffectOptionsOf<typeof blockDisplaceSpec.params>;\n\n/** ASCII art from a glyph grid. Scalar shorthand sets `size`. */\nexport type AsciiOptions = EffectOptionsOf<typeof asciiSpec.params>;\n\n/** Anamorphic glare — a bright pass smeared along one axis. Scalar shorthand sets `intensity`. */\nexport type StreakOptions = EffectOptionsOf<typeof streakSpec.params>;\n\n/** Bright (or opaque) areas spread outward and composited back. Scalar shorthand sets `intensity`. Unlike `bloom`, spreads past the node's box and can be coloured through a ramp. */\nexport type GlowOptions = EffectOptionsOf<typeof glowSpec.params>;\n\n/** Kuwahara brushwork. Scalar shorthand sets `radius`. */\nexport type OilPaintOptions = EffectOptionsOf<typeof oilPaintSpec.params>;\n\n/** Sine warp. Scalar shorthand sets `amplitude` on the Y axis — the everyday ripple. */\nexport type WaveOptions = EffectOptionsOf<typeof waveSpec.params>;\n\n/** Twirl / swirl vortex. Scalar shorthand sets `angle`. */\nexport type TwirlOptions = EffectOptionsOf<typeof twirlSpec.params>;\n\n/** Blur that ramps across the node; `mode: 'backdrop'` gives a frosted panel whose blur fades out. Scalar shorthand sets `radius`. */\nexport type ProgressiveBlurOptions = EffectOptionsOf<typeof progressiveBlurSpec.params>;\n\n/** Mirrored wedges around a point. Scalar shorthand sets `segments`. */\nexport type KaleidoscopeOptions = EffectOptionsOf<typeof kaleidoscopeSpec.params>;\n\n/**\n * Figma's Glass over the backdrop. Scalar shorthand sets `refraction`. Defaults are Figma's\n * (light -45 deg at 80, refraction 80, depth 20 px, dispersion 50, frost 4, splay 0) and `mode: 'backdrop'`;\n * the foreground is a no-op.\n */\nexport type GlassOptions = EffectOptionsOf<typeof glassSpec.params>;\n\n/** Colour-depth reduction. Scalar shorthand sets `bits`. */\nexport type BitCrushOptions = EffectOptionsOf<typeof bitCrushSpec.params>;\n\n/** Immutable, chainable list of node effects; each builder returns a new chain, so chains can be shared and branched. */\nexport class EffectChain {\n constructor(public list: NodeEffect[] = []) { }\n\n private append(effect: NodeEffect): EffectChain {\n return new EffectChain([...this.list, effect]);\n }\n\n /** `{ mode: \"backdrop\" }` blurs what is beneath the node (clipped to its silhouette, Figma-style). */\n blur(options: number | BlurOptions) {\n return this.append(buildEffect(blurSpec, options));\n }\n\n directionalBlur(options: number | DirectionalBlurOptions) {\n return this.append(buildEffect(directionalBlurSpec, options));\n }\n\n pixelate(options: number | PixelateOptions) {\n return this.append(buildEffect(pixelateSpec, options));\n }\n\n grayscale(options: number | GrayscaleOptions) {\n return this.append(buildEffect(grayscaleSpec, options));\n }\n\n /** A negative strength pinches instead of bulging; `mode: \"backdrop\"` makes a glass dome over the layers below. */\n bulge(options: number | BulgeOptions) {\n return this.append(buildEffect(bulgeSpec, options));\n }\n\n /** Lens fills the node's box, clipped to its silhouette, scaled about `center`. Defaults to `mode: 'backdrop'`. */\n magnify(options?: number | MagnifyOptions) {\n return this.append(buildEffect(magnifySpec, options));\n }\n\n bloom(options?: number | BloomOptions) {\n return this.append(buildEffect(bloomSpec, options));\n }\n\n vintage(options?: number | VintageOptions) {\n return this.append(buildEffect(vintageSpec, options));\n }\n\n chromaticAberration(options?: number | ChromaticAberrationOptions) {\n return this.append(buildEffect(chromaticAberrationSpec, options));\n }\n\n invert(options?: number | InvertOptions) {\n return this.append(buildEffect(invertSpec, options));\n }\n\n scatter(options?: number | ScatterOptions) {\n return this.append(buildEffect(scatterSpec, options));\n }\n\n posterize(options?: number | PosterizeOptions) {\n return this.append(buildEffect(posterizeSpec, options));\n }\n\n /** Smears along the node's actual per-frame motion (a static node stays sharp); `length` is the shutter angle, `alignment` the phase. */\n motionBlur(options?: number | MotionBlurOptions) {\n return this.append(buildEffect(motionBlurSpec, options));\n }\n\n /** Follows alpha silhouettes (text, cutouts, subtrees) that a geometry `stroke` can't. */\n outline(options?: number | OutlineOptions) {\n return this.append(buildEffect(outlineSpec, options));\n }\n\n /** Follows alpha silhouettes that a geometry `shadow` (which fills the node's path) can't. */\n dropShadow(options?: number | DropShadowOptions) {\n return this.append(buildEffect(dropShadowSpec, options));\n }\n\n /** Falloff follows the node's aspect ratio, so a wide node darkens along its short edges. */\n vignette(options?: number | VignetteOptions) {\n return this.append(buildEffect(vignetteSpec, options));\n }\n\n /** `amount` is the mix; everything else is the table. */\n lut(options: LutOptions) {\n return this.append(buildEffect(lutSpec, options));\n }\n\n /** Static grain reads as texture; pass `{ animated: true }` to re-seed per frame, or tween `seed` to stay deterministic. */\n grain(options?: number | GrainOptions) {\n return this.append(buildEffect(grainSpec, options));\n }\n\n sharpen(options?: number | SharpenOptions) {\n return this.append(buildEffect(sharpenSpec, options));\n }\n\n edges(options?: number | EdgesOptions) {\n return this.append(buildEffect(edgesSpec, options));\n }\n\n threshold(options?: number | ThresholdOptions) {\n return this.append(buildEffect(thresholdSpec, options));\n }\n\n radialBlur(options?: number | RadialBlurOptions) {\n return this.append(buildEffect(radialBlurSpec, options));\n }\n\n halftone(options?: number | HalftoneOptions) {\n return this.append(buildEffect(halftoneSpec, options));\n }\n\n dither(options?: number | DitherOptions) {\n return this.append(buildEffect(ditherSpec, options));\n }\n\n duotone(options?: number | DuotoneOptions) {\n return this.append(buildEffect(duotoneSpec, options));\n }\n\n curves(options: CurvesOptions) {\n return this.append(buildEffect(curvesSpec, options));\n }\n\n /** For darkened edges use {@link EffectChain.vignette}. */\n colorAdjustment(options: ColorAdjustmentOptions) {\n // Destructure `mode` out: `{ mode: undefined }` would plant the key on the effect, and `equals()` compares `mode` directly.\n const { mode, ...fields } = options;\n return this.append(withEffectOptions({ type: \"colorAdjustment\" as const, ...fields }, { mode }));\n }\n\n rgbShift(options?: number | RgbShiftOptions) {\n const o = scalarOptions(options, \"amount\");\n const spread = o.amount;\n return this.append(buildEffect(rgbShiftSpec, spread === undefined ? o : {\n ...o,\n red: o.red ?? { x: spread, y: 0 },\n blue: o.blue ?? { x: -spread, y: 0 },\n }));\n }\n\n /** Animate `offset` past `spacing` to roll the bands; the pattern wraps, so a linear tween loops. */\n scanlines(options?: number | ScanlinesOptions) {\n return this.append(buildEffect(scanlinesSpec, options));\n }\n\n /** Step `seed` in whole numbers to jump between glitch states rather than sliding. */\n blockDisplace(options?: number | BlockDisplaceOptions) {\n return this.append(buildEffect(blockDisplaceSpec, options));\n }\n\n /** Pair with {@link EffectChain.dither} so gradients survive the cut. */\n bitCrush(options?: number | BitCrushOptions) {\n return this.append(buildEffect(bitCrushSpec, options));\n }\n\n /** `background: 'transparent'` lays the glyphs over whatever is behind the node. */\n ascii(options?: number | AsciiOptions) {\n return this.append(buildEffect(asciiSpec, options));\n }\n\n /** By some margin the most expensive effect; keep `radius` small. */\n oilPaint(options?: number | OilPaintOptions) {\n return this.append(buildEffect(oilPaintSpec, options));\n }\n\n streak(options?: number | StreakOptions) {\n return this.append(buildEffect(streakSpec, options));\n }\n\n glow(options?: number | GlowOptions) {\n return this.append(buildEffect(glowSpec, options));\n }\n\n shader(options: ShaderEffectOptions) {\n const pack = typeof options.source === \"string\" ? undefined : options.source;\n if (pack && pack.scope !== \"effect\") {\n throw new Error(\n `Effects.shader was given a \"${(pack as { scope: string }).scope}\" shader ` +\n `(\"${pack.name}\"). A fill shader has no backdrop to sample and is bound to a ` +\n `shape's box; use Fills.shader.`,\n );\n }\n // A backdrop pack supplies the default; a caller may still say otherwise.\n const mode = options.mode ?? (pack?.backdrop ? \"backdrop\" : \"foreground\");\n const source = pack ? pack.source : (options.source as string);\n const uniforms = pack\n ? { ...resolveShaderProperties(pack, options.values), ...normalizeUniforms(options.uniforms ?? {}) }\n : (options.uniforms ?? {});\n const base = {\n type: \"shader\" as const,\n source,\n language: \"wgsl\" as const,\n ...(options.reach ? { reach: options.reach } : {}),\n uniforms,\n ...(pack?.id !== undefined ? { shaderId: pack.id } : {}),\n };\n // blendMode only applies to the foreground overlay; leaving it undefined\n // for a backdrop shader keeps `equals()` comparing like with like.\n const effect: NodeEffect = mode === \"foreground\" && options.blendMode\n ? { ...base, blendMode: options.blendMode }\n : base;\n return this.append(withEffectOptions(effect, { mode }));\n }\n\n /** Tween `phase` over 360 to travel the wave; it wraps, so a linear tween loops. */\n wave(options?: number | WaveOptions) {\n return this.append(buildEffect(waveSpec, options));\n }\n\n twirl(options?: number | TwirlOptions) {\n return this.append(buildEffect(twirlSpec, options));\n }\n\n progressiveBlur(options?: number | ProgressiveBlurOptions) {\n return this.append(buildEffect(progressiveBlurSpec, options));\n }\n\n /** Animating `angle` sweeps fresh source through the wedge while the pattern stays locked, unlike rotating the node. */\n kaleidoscope(options?: number | KaleidoscopeOptions) {\n return this.append(buildEffect(kaleidoscopeSpec, options));\n }\n\n glass(options?: number | GlassOptions) {\n return this.append(buildEffect(glassSpec, options));\n }\n\n *[Symbol.iterator]() {\n yield* this.list;\n }\n\n toJSON() {\n return this.list;\n }\n}\n\n/** A single effect, a chain, or an array mixing both (chains flatten in place). Resolved effects are `NodeEffect`s, so a read-back `effects` can be assigned straight back. */\nexport type Effect =\n | NodeEffect\n | EffectChain\n | (NodeEffect | EffectChain)[];\n\n/**\n * An empty {@link EffectChain}: `Effects.blur(8)` *is* `new EffectChain().blur(8)`, so each builder is\n * documented once, on the class. Chains are immutable, so sharing one instance is safe.\n */\nexport const Effects = new EffectChain();\n\n/** Normalises any {@link Effect} to `NodeEffect[]`, flattening chains and the plain arrays a chain serializes to. */\nexport function resolveChainEffects(effects: Effect | undefined): NodeEffect[] {\n if (effects === undefined) return [];\n if (effects instanceof EffectChain) return resolveAll(effects.list);\n if (Array.isArray(effects)) {\n const out: NodeEffect[] = [];\n for (const item of effects) {\n if (item instanceof EffectChain) out.push(...resolveAll(item.list));\n else if (Array.isArray(item)) out.push(...resolveChainEffects(item as Effect));\n else out.push(resolveEffect(item));\n }\n return out;\n }\n return [resolveEffect(effects)];\n}\n\n/**\n * Returns **the same array** when nothing needed resolving (almost always): this runs on every `effects`\n * write and `lerpEffectArray` short-circuits on `from === to`.\n */\nfunction resolveAll(list: NodeEffect[]): NodeEffect[] {\n let out: NodeEffect[] | undefined;\n for (let i = 0; i < list.length; i++) {\n const resolved = resolveEffect(list[i]);\n if (!out && resolved !== list[i]) out = list.slice(0, i);\n out?.push(resolved);\n }\n return out ?? list;\n}\n\nexport const effectsOps: AttributeOps<Effect, NodeEffect[]> = {\n resolve: (effects) => resolveChainEffects(effects),\n lerp: (from, to, t) => {\n if (from === to) return from;\n const maxLen = Math.max(from.length, to.length);\n const result: NodeEffect[] = [];\n for (let i = 0; i < maxLen; i++) {\n const a = from[i];\n const b = to[i];\n if (a && b) {\n result.push(lerpEffect(a, b, t));\n } else if (a) {\n result.push(a);\n } else if (b) {\n result.push(b);\n }\n }\n return result;\n },\n};\n", "import type { NodeEffect } from \"./union\";\nimport { effectSurface } from \"./registry\";\n\n/** Backdrop/foreground classification: every effect carries a uniform {@link EffectMode}, so it is a single field read with no branching on `effect.type`. `\"backdrop\"` runs on the content beneath the node (clipped to its silhouette); anything else is a foreground effect over its own content. */\n\nexport const isBackdropEffect = (effect: NodeEffect): boolean => effect.mode === \"backdrop\";\n\n/** Shared result for the common \"no effects\" case: both classifiers run once per node per frame and `.filter` allocates even with nothing to filter. */\nconst NONE: NodeEffect[] = [];\n\n/** The backdrop-targeting effects in `effects`, for the renderer's backdrop pass. */\nexport const backdropEffects = (effects: NodeEffect[]): NodeEffect[] =>\n effects.length === 0 ? NONE : effects.filter(isBackdropEffect);\n\n/** Foreground effects that warp/band the node's *own* content and so need a snapshot-and-redraw scope rather than a composable image filter. Driven by each effect's declared {@link EffectSurface}, so a new shader effect needs no edit here; chain order is kept (index 0 outermost). */\nexport function foregroundShaderEffects(effects: NodeEffect[]): NodeEffect[] {\n if (effects.length === 0) return NONE;\n return effects.filter((e) => e.mode !== \"backdrop\" && effectSurface(e) === \"shader\");\n}\n", "import type { Color } from \"./color/parser\";\nimport type { BlendMode } from \"./blend\";\nimport type { Vector2 } from \"@/attributes/layout/vector2\";\nimport type { MediaPresetProp, VideoPresetProp } from \"./media-preset\";\nimport type { FillProp, FillResolved, FillSpace } from \"./union\";\nimport { normalizeUniforms } from \"../shaders/uniforms\";\nimport { resolveShaderProperties, type ShaderPropertyValues } from \"../shaders/resolve\";\nimport type { FillShader } from \"../shaders/pack\";\nimport type { ImageCrop, ImageFit, ImageMatrix } from \"./implementations/image\";\nimport type { Alignment } from \"@/attributes/layout/alignment\";\nimport type { FractalNoiseFillProp } from \"./implementations/fractal-noise\";\nimport type { DotGridFillProp } from \"./implementations/dot-grid\";\nimport type { GridFillProp } from \"./implementations/grid\";\nimport type { ShaderFillProp } from \"./implementations/shader\";\nimport type { Scene3D } from \"@/render3d/scene3d\";\n\n/** Placement options shared by the image and video fill builders. */\nexport interface MediaPlacementOptions {\n /** How the (cropped) source is scaled into the node's bounds. Default `'fill'`. */\n fit?: ImageFit;\n /** Window onto the source, in fractions of its own size, applied before `fit`. */\n crop?: ImageCrop;\n /** Magnification on top of the fitted scale. `1` is the fitted size. */\n zoom?: number;\n /** The point held fixed as `zoom` scales; also the alignment when it doesn't cover. */\n anchor?: Alignment;\n /** Raw source→shape matrix; bypasses `crop`/`fit`/`zoom`/`anchor` and the bounds. */\n matrix?: ImageMatrix;\n}\n\n/** Author-facing options for a {@link FillChain.video} layer. */\nexport interface VideoFillOptions extends FillOptions, MediaPlacementOptions {\n /** The grade laid over the footage — an adjustment chain plus a 0–1 mix. */\n preset?: VideoPresetProp;\n /** Explicit source time in seconds. Omit and the clip plays by itself from when the node appeared; set only to drive the playhead yourself (`null` hands it back). */\n timestamp?: number | null;\n /** Whether playback advances with the node's clock. Defaults to `true`. */\n playing?: boolean;\n trimStart?: number;\n trimEnd?: number;\n /** Seconds after the painting node appears before playback begins. Default `0`. */\n playStart?: number;\n speed?: number;\n loop?: 'forward' | 'reverse' | 'none';\n duration?: number;\n}\n\n/** Cross-cutting options for every fill layer: the `opacity` / `blend` fields each fill prop accepts, plus the registry's generic `space` directive. */\nexport interface FillOptions {\n opacity?: number;\n blend?: BlendMode;\n space?: FillSpace;\n}\n\n/** Strip `undefined` option keys so the produced props stay minimal/comparable. */\nfunction withOptions<T extends object>(base: T, options: FillOptions = {}): T & FillOptions {\n const out = { ...base } as T & FillOptions;\n if (options.opacity !== undefined) out.opacity = options.opacity;\n if (options.blend !== undefined) out.blend = options.blend;\n if (options.space !== undefined) out.space = options.space;\n return out;\n}\n\n/** Immutable, chainable list of fill layers; each builder returns a new chain, so chains can be shared and branched. */\nexport class FillChain {\n constructor(public list: FillProp[] = []) { }\n\n color(color: Color, options?: FillOptions) {\n return new FillChain([...this.list, withOptions({ type: 'solid' as const, color }, options)]);\n }\n\n image(\n src: string,\n options?: FillOptions & MediaPlacementOptions & {\n /** The grade laid over the picture — an adjustment chain plus a 0–1 mix. */\n preset?: MediaPresetProp;\n },\n ) {\n const { fit, crop, zoom, anchor, matrix, preset, ...common } = options ?? {};\n // Forwarded unresolved: `imageFill.resolve` is the one place that\n // flattens a chain, so a fill built here and a fill written as a\n // literal cannot disagree about what a grade means.\n return new FillChain([...this.list, withOptions({\n type: 'image' as const,\n src,\n fit, crop, zoom, anchor, matrix,\n preset,\n }, common)]);\n }\n\n /** Plays by default: the source timestamp is derived as it paints, from how long the carrying node has existed, so the clip runs wherever the fill is used with nothing to advance. */\n video(src: string, options?: VideoFillOptions) {\n const { fit, crop, zoom, anchor, matrix, preset, timestamp, playing, trimStart, trimEnd, playStart, speed, loop, duration, ...common } = options ?? {};\n return new FillChain([...this.list, withOptions({\n type: 'video' as const,\n src,\n fit, crop, zoom, anchor, matrix, preset,\n timestamp,\n playing: playing ?? true,\n trimStart, trimEnd, playStart, speed, loop, duration,\n }, common)]);\n }\n\n\n linearGradient(colors: Color[], options?: FillOptions & { stops?: number[]; start?: Vector2; end?: Vector2 }) {\n const { stops, start, end, ...common } = options ?? {};\n return new FillChain([...this.list, withOptions({ type: 'linear-gradient' as const, colors, stops, start, end }, common)]);\n }\n\n radialGradient(colors: Color[], options?: FillOptions & { stops?: number[]; center?: Vector2; radius?: number }) {\n const { stops, center, radius, ...common } = options ?? {};\n return new FillChain([...this.list, withOptions({ type: 'radial-gradient' as const, colors, stops, center, radius }, common)]);\n }\n\n conicGradient(colors: Color[], options?: FillOptions & { stops?: number[]; center?: Vector2; startAngle?: number }) {\n const { stops, center, startAngle, ...common } = options ?? {};\n return new FillChain([...this.list, withOptions({ type: 'conic-gradient' as const, colors, stops, center, startAngle }, common)]);\n }\n\n /** Append a noise (speckle) fill. Tween `seed` to make the static crawl. */\n noise(options?: FillOptions & { size?: Vector2; density?: number; color?: Color; seed?: number }) {\n const { size, density, color, seed, ...common } = options ?? {};\n return new FillChain([...this.list, withOptions({ type: 'noise' as const, size, density, color, seed }, common)]);\n }\n\n /** A continuous field (cloud, marble, smoke), unlike the speckle of {@link noise}. Tween `offset` to flow through it, `seed` to churn to a different field. */\n fractalNoise(options?: FillOptions & Omit<FractalNoiseFillProp, 'type' | 'opacity' | 'blend'>) {\n const {\n basis, octaves, frequency, lacunarity, gain, seed, offset, angle,\n colors, stops, contrast, ...common\n } = options ?? {};\n return new FillChain([...this.list, withOptions(\n {\n type: 'fractalNoise' as const,\n basis, octaves, frequency, lacunarity, gain, seed, offset, angle,\n colors, stops, contrast,\n },\n common,\n )]);\n }\n\n /**\n * Custom shader fill. The WGSL `source` defines `fn fill(in: FillIn) -> vec4f` and declares uniforms as\n * `struct Params`, read as `u.<name>`. It returns **premultiplied** rgba without folding `opacity` in (already\n * applied; doing it twice squares it). Keep `source` constant: it is the compile-cache key, so it snaps at a\n * tween's midpoint and rebuilding it per frame compiles a program per frame. Changing values belong in uniforms.\n *\n * @example\n * Fills.shader(GLOW, { uniforms: { amount: 0.6 } })\n */\n shader(\n source: string | FillShader,\n options?: FillOptions\n & Omit<ShaderFillProp, 'type' | 'source' | 'language' | 'opacity' | 'blend' | 'shaderId'>\n & { values?: ShaderPropertyValues },\n ) {\n const pack = typeof source === 'string' ? undefined : source;\n if (pack && pack.scope !== 'fill') {\n throw new Error(\n `Fills.shader was given a \"${(pack as { scope: string }).scope}\" shader ` +\n `(\"${pack.name}\"). An effect shader samples a backdrop a fill does not have; ` +\n `use Effects.shader.`,\n );\n }\n const { uniforms, textures, values, ...common } = options ?? {};\n // A pack resolves to plain uniforms here; anything passed as `uniforms`\n // still wins, matching how an author value overrides a built-in.\n const resolved = pack\n ? { ...resolveShaderProperties(pack, values), ...normalizeUniforms(uniforms ?? {}) }\n : uniforms;\n return new FillChain([...this.list, withOptions(\n {\n type: 'shader' as const,\n source: typeof source === 'string' ? source : source.source,\n language: 'wgsl' as const,\n uniforms: resolved,\n textures,\n ...(pack?.id !== undefined ? { shaderId: pack.id } : {}),\n },\n common,\n )]);\n }\n\n stripe(options?: FillOptions & { gap?: number; strokeWidth?: number; angle?: number; color?: Color }) {\n const { gap, strokeWidth, angle, color, ...common } = options ?? {};\n return new FillChain([...this.list, withOptions({ type: 'stripe' as const, gap, strokeWidth, angle, color }, common)]);\n }\n\n /** Lattice of dots at a pixel pitch. Tween `offset` to drift the field under a still shape. */\n dotGrid(options?: FillOptions & Omit<DotGridFillProp, 'type' | 'opacity' | 'blend'>) {\n const { radius, spacing, offset, color, ...common } = options ?? {};\n return new FillChain([...this.list, withOptions(\n { type: 'dotGrid' as const, radius, spacing, offset, color },\n common,\n )]);\n }\n\n /** Ruled lines dividing the shape into cells, optionally with a finer ruling inside. Sized in divisions rather than px (unlike {@link dotGrid}), so it holds its structure as the shape resizes. */\n grid(options?: FillOptions & Omit<GridFillProp, 'type' | 'opacity' | 'blend'>) {\n const {\n divisions, subdivisions, offset, strokeWidth, subdivisionWidth, color, ...common\n } = options ?? {};\n return new FillChain([...this.list, withOptions(\n {\n type: 'grid' as const,\n divisions, subdivisions, offset, strokeWidth, subdivisionWidth, color,\n },\n common,\n )]);\n }\n\n /**\n * A 3D scene painted through the shape's own path. Takes a **built** {@link Scene3D}, never a builder; freshness\n * comes from where the value is produced (a `renderSelf`, or a `() => …` binding). Two same-type 3D layers\n * hard-cut rather than cross-fading (a command list has no in-between): stack them and tween opacities instead.\n */\n canvas3D(scene: Scene3D, options?: FillOptions & { maxPixelRatio?: number; antialias?: boolean }) {\n const { maxPixelRatio, antialias, ...common } = options ?? {};\n return new FillChain([...this.list, withOptions({ type: 'canvas3D' as const, scene, maxPixelRatio, antialias }, common)]);\n }\n\n *[Symbol.iterator]() {\n yield* this.list;\n }\n\n toJSON() {\n return this.list;\n }\n}\n\n/** Accepted shapes for a node's `fill`: a single fill, a `FillChain`, an already-resolved {@link FillResolved}, or an array mixing these (chains contribute their layers in place). */\nexport type Fill =\n | FillProp\n | FillResolved\n | FillChain\n | (FillProp | FillResolved | FillChain)[];\n\n/** An empty {@link FillChain}: `Fills.image(src)` *is* `new FillChain().image(src)`, so builders are documented once, on the class. Chains are immutable, so sharing one instance is safe. */\nexport const Fills = new FillChain();\n\n/** Normalises any {@link Fill} to `FillProp[]`. Already-resolved fills structurally satisfy `FillProp` and pass through (`resolveFill` re-normalises idempotently). */\nexport function resolveChainFill(fill: Fill | undefined): FillProp[] {\n if (fill == null) return [];\n if (fill instanceof FillChain) return fill.list;\n if (Array.isArray(fill)) {\n // Flatten chains used as array elements, and the plain array a chain serializes to (how it reads back from a stored document).\n const out: FillProp[] = [];\n for (const item of fill) {\n if (item instanceof FillChain) out.push(...item.list);\n else if (Array.isArray(item)) out.push(...resolveChainFill(item as Fill));\n else out.push(item as FillProp);\n }\n return out;\n }\n return [fill as FillProp];\n}\n", "import { Color, NormalizedColor, parseColor } from '../color/parser';\nimport type { BlendMode } from '../blend';\nimport type { FillData } from '../registry';\nimport { lerpNumber } from '@/tween/lerp';\nimport { Vector2 } from '@/attributes/layout/vector2';\n\n/**\n * Ruled lines in both axes (graph paper, a chart's backing, a layout guide). Measured in **divisions of the shape**, not\n * pixels (unlike {@link DotGridFillProp}): a grid of 8 stays 8 when the shape resizes, so it reads as structure rather\n * than a texture laid over it. Cells follow the box (a 16:9 shape divided 8 ways has 16:9 cells), since square cells\n * would leave a ragged strip down one side.\n *\n * {@link subdivisions} nests a finer grid inside each cell, by default at {@link MINOR_WIDTH_RATIO} of the division\n * line's width: thinner rather than fainter, since a half-width line antialiases lighter at any zoom, so the two orders\n * stay distinguishable at every scale without a second colour. {@link subdivisionWidth} overrides it.\n */\nexport interface GridFillProp {\n type: 'grid';\n /** How many cells the shape is divided into, per axis. Tween it to zoom the grid. */\n divisions?: number;\n /** How many finer cells nest inside each division. `1` draws no minor lines. */\n subdivisions?: number;\n /** Shifts the whole ruling, in px. */\n offset?: Vector2;\n /** Thickness of a division line, in px. `0` leaves the coarse ruling undrawn. */\n strokeWidth?: number;\n /** Thickness of a subdivision line, in px; defaults to {@link MINOR_WIDTH_RATIO} of {@link strokeWidth}. */\n subdivisionWidth?: number;\n color?: Color;\n opacity?: number;\n blend?: BlendMode;\n}\n\nexport interface GridFillResolved {\n type: 'grid';\n divisions: number;\n subdivisions: number;\n offset: Vector2;\n strokeWidth: number;\n subdivisionWidth: number;\n color: NormalizedColor;\n opacity?: number;\n blend?: BlendMode;\n}\n\n/** Quarters, hairline, no minor ruling — the plainest grid that is still one. */\nconst DEFAULT_DIVISIONS = 4;\nconst DEFAULT_SUBDIVISIONS = 1;\nconst DEFAULT_STROKE_WIDTH = 1;\n\n/** How thick a subdivision line is relative to a division one. */\nexport const MINOR_WIDTH_RATIO = 0.5;\n\nexport const gridFill: FillData<GridFillResolved> = {\n resolve: (prop: GridFillProp) => {\n const raw = prop.color ?? ([0, 0, 0, 1] as NormalizedColor);\n const strokeWidth = prop.strokeWidth ?? DEFAULT_STROKE_WIDTH;\n return {\n type: 'grid',\n divisions: prop.divisions ?? DEFAULT_DIVISIONS,\n subdivisions: prop.subdivisions ?? DEFAULT_SUBDIVISIONS,\n offset: prop.offset ?? { x: 0, y: 0 },\n strokeWidth,\n // From the width in force, so stating only `strokeWidth: 4` still gives a proportionate minor ruling.\n subdivisionWidth: prop.subdivisionWidth ?? strokeWidth * MINOR_WIDTH_RATIO,\n color: Array.isArray(raw) ? (raw as NormalizedColor) : parseColor(raw as string),\n opacity: prop.opacity,\n blend: prop.blend,\n };\n },\n // `divisions` interpolates continuously (a fractional count is a grid caught mid-zoom). The renderer rounds `subdivisions`, so the minor ruling nests a whole number of times and a tween steps instead of sliding fine lines out of alignment.\n lerp: (a, b, t) => ({\n divisions: lerpNumber(a.divisions, b.divisions, t),\n subdivisions: lerpNumber(a.subdivisions, b.subdivisions, t),\n offset: {\n x: lerpNumber(a.offset.x, b.offset.x, t),\n y: lerpNumber(a.offset.y, b.offset.y, t),\n },\n strokeWidth: lerpNumber(a.strokeWidth, b.strokeWidth, t),\n subdivisionWidth: lerpNumber(a.subdivisionWidth, b.subdivisionWidth, t),\n color: [\n lerpNumber(a.color[0], b.color[0], t),\n lerpNumber(a.color[1], b.color[1], t),\n lerpNumber(a.color[2], b.color[2], t),\n lerpNumber(a.color[3], b.color[3], t),\n ],\n opacity: lerpNumber(a.opacity ?? 1, b.opacity ?? 1, t),\n }),\n equals: (a, b) =>\n a.divisions === b.divisions &&\n a.subdivisions === b.subdivisions &&\n a.offset.x === b.offset.x && a.offset.y === b.offset.y &&\n a.strokeWidth === b.strokeWidth &&\n a.subdivisionWidth === b.subdivisionWidth &&\n a.color[0] === b.color[0] && a.color[1] === b.color[1] &&\n a.color[2] === b.color[2] && a.color[3] === b.color[3],\n};\n", "import type { FilterData } from \"../registry\";\nimport { lerpNumber } from \"@/tween/lerp\";\n\n/** Scales the overall luminance of the media layer. */\nexport interface ExposureFilter {\n type: 'exposure';\n /** Exposure multiplier. 1 = unchanged, >1 brighter, <1 darker. */\n amount: number;\n}\n\nexport const exposureFilter: FilterData<ExposureFilter> = {\n lerp: (from, to, t) => ({ type: \"exposure\", amount: lerpNumber(from.amount, to.amount, t) }),\n equals: (a, b) => a.amount === b.amount,\n};\n", "import type { FilterData } from \"../registry\";\nimport { lerpNumber } from \"@/tween/lerp\";\n\n/** Applies a Gaussian blur to the media layer. */\nexport interface BlurFilter {\n type: 'blur';\n /** Blur radius in pixels. */\n radius: number;\n}\n\nexport const blurFilter: FilterData<BlurFilter> = {\n lerp: (from, to, t) => ({ type: \"blur\", radius: lerpNumber(from.radius, to.radius, t) }),\n equals: (a, b) => a.radius === b.radius,\n};\n", "import type { FilterData } from \"../registry\";\nimport { lerpNumber } from \"@/tween/lerp\";\n\n/** Desaturates the media layer toward black and white. */\nexport interface GrayscaleFilter {\n type: 'grayscale';\n /** 0 = original, 1 = fully grayscale. */\n amount: number;\n}\n\nexport const grayscaleFilter: FilterData<GrayscaleFilter> = {\n lerp: (from, to, t) => ({ type: \"grayscale\", amount: lerpNumber(from.amount, to.amount, t) }),\n equals: (a, b) => a.amount === b.amount,\n};\n", "import type { FilterData } from \"../registry\";\nimport { lerpNumber } from \"@/tween/lerp\";\n\n/** Multiplies every pixel's alpha channel by `amount`, fading the entire layer. */\nexport interface AlphaFilter {\n type: 'alpha';\n /** 0 = fully transparent, 1 = unchanged. */\n amount: number;\n}\n\nexport const alphaFilter: FilterData<AlphaFilter> = {\n lerp: (from, to, t) => ({ type: \"alpha\", amount: lerpNumber(from.amount, to.amount, t) }),\n equals: (a, b) => a.amount === b.amount,\n};\n", "import type { FilterData } from \"../registry\";\nimport { lerpNumber } from \"@/tween/lerp\";\n\n/** An arbitrary 4×5 row-major colour transform: rows [R, G, B, A], each `[rScale, gScale, bScale, aScale, bias]`. For tints, channel swaps, anything the named filters don't cover. */\nexport interface ColorMatrixFilter {\n type: 'colorMatrix';\n /** 4×5 row-major color matrix. */\n matrix: number[];\n}\n\nexport const colorMatrixFilter: FilterData<ColorMatrixFilter> = {\n // Lerps each matrix coefficient independently; missing target coefficients\n // hold their source value so partial matrices still animate gracefully.\n lerp: (from, to, t) => ({\n type: \"colorMatrix\",\n matrix: from.matrix.map((v, i) => lerpNumber(v, to.matrix[i] ?? v, t)),\n }),\n equals: (a, b) => a.matrix.length === b.matrix.length && a.matrix.every((v, i) => v === b.matrix[i]),\n};\n", "import type { FilterData } from \"../registry\";\nimport { lerpNumber } from \"@/tween/lerp\";\n\n/** Which color channel(s) a curves adjustment targets. */\nexport type CurvesChannel = 'rgb' | 'r' | 'g' | 'b' | 'a';\n\n/** Remaps pixel values along a tone curve through [input, output] control points in [0, 1] (the renderer interpolates a smooth curve). Composite RGB by default; set `channel` for one. */\nexport interface CurvesFilter {\n type: 'curves';\n /** Curve control points as [input, output] pairs in [0, 1]. */\n points: [number, number][];\n /** Channel(s) to apply the curve to. Default 'rgb'. */\n channel?: CurvesChannel;\n}\n\nexport const curvesFilter: FilterData<CurvesFilter> = {\n // Channel hard-cuts at t=0.5 because interpolating between channel names\n // would produce meaningless intermediate states.\n lerp: (from, to, t) => ({\n type: \"curves\",\n channel: t < 0.5 ? from.channel : to.channel,\n points: from.points.map(([x, y], i) => {\n const [tx, ty] = to.points[i] ?? [x, y];\n return [lerpNumber(x, tx, t), lerpNumber(y, ty, t)] as [number, number];\n }),\n }),\n equals: (a, b) =>\n a.channel === b.channel &&\n a.points.length === b.points.length &&\n a.points.every(([x, y], i) => x === b.points[i]?.[0] && y === b.points[i]?.[1]),\n};\n", "import type { FilterData } from \"../registry\";\nimport { lerpNumber } from \"@/tween/lerp\";\n\n/**\n * A collection of photographic-style tonal and color adjustments.\n * All fields are optional; omitted fields use their neutral default.\n */\nexport interface ColorAdjustmentFilter {\n type: 'colorAdjustment';\n /** -1 to 1 (0 = unchanged). Shifts the overall lightness without clipping like exposure does. */\n brightness?: number;\n /** 0 to 2 (1 = unchanged). Spreads highlights and shadows further apart. */\n contrast?: number;\n /** 0 to 3 (1 = unchanged). Scales color saturation uniformly. */\n saturation?: number;\n /** Hue rotation in degrees (0 = unchanged), luma-preserving. Wraps at 360. */\n hue?: number;\n /** -1 to 1 (0 = unchanged). Boosts muted colors more than vibrant ones. */\n vibrance?: number;\n /** -1 to 1 (0 = unchanged). Lifts or crushes shadow regions. */\n shadows?: number;\n /** -1 to 1 (0 = unchanged). Brightens or dims highlight regions. */\n highlights?: number;\n /** -1 to 1 (0 = unchanged). Negative = cool (blue), positive = warm (orange). */\n temperature?: number;\n /** -1 to 1 (0 = unchanged). Negative = green shift, positive = magenta shift. */\n tint?: number;\n /** 0 to 1 (0 = none). Darkens the edges of the frame. */\n vignette?: number;\n}\n\nexport const colorAdjustmentFilter: FilterData<ColorAdjustmentFilter> = {\n lerp: (from, to, t) => ({\n type: \"colorAdjustment\",\n brightness: lerpNumber(from.brightness ?? 0, to.brightness ?? 0, t),\n contrast: lerpNumber(from.contrast ?? 1, to.contrast ?? 1, t),\n saturation: lerpNumber(from.saturation ?? 1, to.saturation ?? 1, t),\n hue: lerpNumber(from.hue ?? 0, to.hue ?? 0, t),\n vibrance: lerpNumber(from.vibrance ?? 0, to.vibrance ?? 0, t),\n shadows: lerpNumber(from.shadows ?? 0, to.shadows ?? 0, t),\n highlights: lerpNumber(from.highlights ?? 0, to.highlights ?? 0, t),\n temperature: lerpNumber(from.temperature ?? 0, to.temperature ?? 0, t),\n tint: lerpNumber(from.tint ?? 0, to.tint ?? 0, t),\n vignette: lerpNumber(from.vignette ?? 0, to.vignette ?? 0, t),\n }),\n equals: (a, b) =>\n a.brightness === b.brightness &&\n a.contrast === b.contrast &&\n a.saturation === b.saturation &&\n a.hue === b.hue &&\n a.vibrance === b.vibrance &&\n a.shadows === b.shadows &&\n a.highlights === b.highlights &&\n a.temperature === b.temperature &&\n a.tint === b.tint &&\n a.vignette === b.vignette,\n};\n", "import type { FilterData } from \"../registry\";\nimport { lerpNumber } from \"@/tween/lerp\";\n\n/**\n * Resamples a video fill to a lower frame rate, holding each source frame for a\n * `1 / fps` interval — the \"stop-motion\" / stutter look (After Effects' Posterize\n * Time). Purely temporal: it changes *which* source timestamp is shown, not the\n * pixels, so it is consumed in the video fill's per-frame `update()` (it never\n * reaches the pixel-filter / `setImageFilter` path). No-op on image fills.\n */\nexport interface PosterizeTimeFilter {\n type: 'posterizeTime';\n /** Target frame rate the source playhead snaps to, in frames per second. */\n fps: number;\n}\n\nexport const posterizeTimeFilter: FilterData<PosterizeTimeFilter> = {\n lerp: (from, to, t) => ({ type: \"posterizeTime\", fps: lerpNumber(from.fps, to.fps, t) }),\n equals: (a, b) => a.fps === b.fps,\n};\n", "import type { FilterData } from \"../registry\";\nimport type { BlendMode } from \"../../fill/blend\";\nimport { lerpNumber } from \"@/tween/lerp\";\n\n/** Composites the current video frame with a trail of past frames (After Effects' Echo), each delayed by `delay` seconds and faded by `decay`. It needs several decoded frames at once, so a dedicated multi-pass path in the video fill renderer draws it, not the `setImageFilter` chain. Video-only; a no-op on image fills. The trail reaches back `echoes * delay` source seconds; frames outside the adapter's decoded back-window are skipped (it fills in over the first second after a cold seek). */\nexport interface VideoEchoFilter {\n type: 'echo';\n /** Number of past-frame taps drawn behind the current frame. */\n echoes: number;\n /** Delay between successive taps, in source seconds. */\n delay: number;\n /** Per-tap alpha multiplier; tap `n` is drawn at `decay ** n`. Default 0.5. */\n decay?: number;\n /** Blend mode used to composite the echo taps. Default `'screen'`. */\n blend?: BlendMode;\n}\n\nexport const echoFilter: FilterData<VideoEchoFilter> = {\n lerp: (from, to, t) => ({\n type: \"echo\",\n echoes: Math.round(lerpNumber(from.echoes, to.echoes, t)),\n delay: lerpNumber(from.delay, to.delay, t),\n decay: lerpNumber(from.decay ?? 0.5, to.decay ?? 0.5, t),\n // Blend is a discrete enum, so it hard-cuts at the midpoint.\n blend: t < 0.5 ? from.blend : to.blend,\n }),\n equals: (a, b) =>\n a.echoes === b.echoes &&\n a.delay === b.delay &&\n (a.decay ?? 0.5) === (b.decay ?? 0.5) &&\n a.blend === b.blend,\n};\n", "import { MediaAdjustment, VideoOnlyAdjustment } from \"./union\";\nimport { declareEffect, effectSurface, hasEffect, lerpEffect } from \"../effects/registry\";\nimport type { NodeEffect } from \"../effects/union\";\nimport type { AssetScope } from \"@/assets/scope\";\n\nimport { exposureFilter } from \"./implementations/exposure\";\nimport { blurFilter } from \"./implementations/blur\";\nimport { grayscaleFilter } from \"./implementations/grayscale\";\nimport { alphaFilter } from \"./implementations/alpha\";\nimport { colorMatrixFilter } from \"./implementations/color-matrix\";\nimport { curvesFilter } from \"./implementations/curves\";\nimport { colorAdjustmentFilter } from \"./implementations/color-adjustment\";\nimport { posterizeTimeFilter } from \"./implementations/posterize-time\";\nimport { echoFilter } from \"./implementations/echo\";\n\n/** Any concrete filter object accepted on a media fill — pixel or video-only. */\nexport type AnyFilter = MediaAdjustment | VideoOnlyAdjustment;\n\n/** Interpolation and equality contract every filter implementation must implement. */\nexport interface FilterData<T extends AnyFilter> {\n lerp(from: T, to: T, t: number): T;\n equals(a: T, b: T): boolean;\n}\n\n/** Maps each filter `type` to its `FilterData` handler, as constants (no runtime registration step to forget). Holds only filters that exist *solely* as filters; most of the roster is {@link EffectAdjustment}, looked up in the effects registry so `dither` interpolates the same on a node or an image. */\nconst FILTERS = new Map<string, FilterData<AnyFilter>>([\n [\"exposure\", exposureFilter as FilterData<AnyFilter>],\n [\"blur\", blurFilter as FilterData<AnyFilter>],\n [\"grayscale\", grayscaleFilter as FilterData<AnyFilter>],\n [\"alpha\", alphaFilter as FilterData<AnyFilter>],\n [\"colorMatrix\", colorMatrixFilter as FilterData<AnyFilter>],\n [\"curves\", curvesFilter as FilterData<AnyFilter>],\n [\"colorAdjustment\", colorAdjustmentFilter as FilterData<AnyFilter>],\n [\"posterizeTime\", posterizeTimeFilter as FilterData<AnyFilter>],\n [\"echo\", echoFilter as FilterData<AnyFilter>],\n]);\n\n/** Video-only filter types, consumed by the video fill's per-frame `update()` (`posterizeTime`) or a dedicated multi-pass renderer (`echo`); `isPixelFilter` lets a renderer skip them when composing the pixel chain. */\nconst VIDEO_ONLY = new Set<string>([\"posterizeTime\", \"echo\"]);\n\nexport function isPixelFilter(type: string): boolean {\n return !VIDEO_ONLY.has(type);\n}\n\nexport function hasFilter(type: string): boolean {\n return FILTERS.has(type) || hasEffect(type);\n}\n\n/** Interpolates two filters, hard-cutting at t = 0.5 when types differ or are unregistered. A type with no dedicated `FilterData` is an {@link EffectAdjustment}, handed to `lerpEffect` so one interpolation serves a node or a fill. */\nexport function lerpFilter(from: AnyFilter, to: AnyFilter, t: number): AnyFilter {\n if (from.type !== to.type) return t < 0.5 ? from : to;\n const data = FILTERS.get(from.type);\n if (data) return data.lerp(from, to, t);\n return lerpEffect(from as NodeEffect, to as NodeEffect, t) as AnyFilter;\n}\n\n/** An {@link EffectAdjustment} can reference assets (`lut` samples an image), and an undeclared one reads as \"no lookup table\". */\nexport function declareFilter(filter: AnyFilter, assets: AssetScope): void {\n if (FILTERS.has(filter.type)) return;\n declareEffect(filter as NodeEffect, assets);\n}\n\n/** How a backend must realise `filter`: `\"shader\"` when it resamples pixel positions, so it wraps the fill's shader rather than composing into its `ImageFilter` chain. The filters defined here are all `\"filter\"`; an {@link EffectAdjustment} answers with its effect's declaration. */\nexport function filterSurface(filter: AnyFilter): \"filter\" | \"shader\" {\n if (FILTERS.has(filter.type)) return \"filter\";\n // A filter is applied to the fill's own pixels, so it is never a backdrop\n // effect however the underlying effect's `mode` predicate reads.\n return effectSurface({ ...filter, mode: \"foreground\" } as NodeEffect);\n}\n\n/** {@link lerpFilterArray} over two *optional* arrays, answering `undefined` when neither has a filter: a media fill's `lerp` is spread over the whole fill, so returning `[]` would allocate per fill per frame and turn an absent field into a present one. */\nexport function lerpOptionalFilters<T extends AnyFilter>(\n from: T[] | undefined,\n to: T[] | undefined,\n t: number,\n): T[] | undefined {\n if (!from?.length && !to?.length) return undefined;\n return lerpFilterArray(from ?? [], to ?? [], t) as T[];\n}\n\n/** Interpolates two filter arrays of possibly different lengths: indices in only one array are kept, matched ones lerped pairwise. */\nexport function lerpFilterArray(from: AnyFilter[], to: AnyFilter[], t: number): AnyFilter[] {\n const maxLen = Math.max(from.length, to.length);\n const result: AnyFilter[] = [];\n for (let i = 0; i < maxLen; i++) {\n const a = from[i];\n const b = to[i];\n if (a && b) {\n result.push(lerpFilter(a, b, t));\n } else if (a) {\n result.push(a);\n } else if (b) {\n result.push(b);\n }\n }\n return result;\n}\n", "import { MediaAdjustment, VideoOnlyAdjustment } from \"./union\";\nimport { EffectChain } from \"../effects/chain\";\nimport type { BlendMode } from \"../fill/blend\";\nimport type { ColorAdjustmentFilter } from \"./implementations/color-adjustment\";\nimport type { CurvesChannel } from \"./implementations/curves\";\nimport type { EffectOptions } from \"../effects/effect-data\";\nimport type {\n AsciiOptions,\n BitCrushOptions,\n BlockDisplaceOptions,\n BloomOptions,\n BulgeOptions,\n ChromaticAberrationOptions,\n DirectionalBlurOptions,\n DitherOptions,\n DuotoneOptions,\n EdgesOptions,\n GrainOptions,\n HalftoneOptions,\n InvertOptions,\n LutOptions,\n KaleidoscopeOptions,\n OilPaintOptions,\n PixelateOptions,\n PosterizeOptions,\n ProgressiveBlurOptions,\n RadialBlurOptions,\n RgbShiftOptions,\n ScanlinesOptions,\n ScatterOptions,\n SharpenOptions,\n ShaderEffectOptions,\n StreakOptions,\n ThresholdOptions,\n TwirlOptions,\n VignetteOptions,\n VintageOptions,\n WaveOptions,\n} from \"../effects/chain\";\n\n/** Any concrete filter a chain may hold — pixel or video-only. */\ntype AnyFilter = MediaAdjustment | VideoOnlyAdjustment;\n\n/**\n * An *adjustment* is what an author writes (`Adjustments.blur(8)`); a *filter* is the primitive the renderer\n * realises it as (`BlurFilter`, the `FilterData` handlers in `registry.ts`). Usually one-to-one, but a grade can\n * compose several primitives and the LUT lookup has no builder. Most builders delegate to the node-effect\n * roster ({@link EffectAdjustment} lists the exceptions). `colorAdjustment`'s options are named after the\n * primitive (`ColorAdjustmentFilterOptions`) to avoid `ColorAdjustmentAdjustmentOptions`.\n */\n\n/** Gaussian blur. Scalar shorthand sets `radius`. */\nexport interface BlurFilterOptions {\n /** Blur radius in pixels. */\n radius: number;\n}\n\n/** Desaturation. Scalar shorthand sets `amount`. */\nexport interface GrayscaleFilterOptions {\n /** 0 = original, 1 = fully grayscale. */\n amount: number;\n}\n\n/** Alpha (opacity) multiply. Scalar shorthand sets `amount`. */\nexport interface AlphaFilterOptions {\n /** 0 = fully transparent, 1 = unchanged. */\n amount: number;\n}\n\n/** Luminance scale. Scalar shorthand sets `amount`. */\nexport interface ExposureFilterOptions {\n /** Exposure multiplier. 1 = unchanged, >1 brighter, <1 darker. */\n amount: number;\n}\n\n/** Raw 4×5 row-major colour matrix. Array shorthand sets `matrix`. */\nexport interface ColorMatrixFilterOptions {\n /** 4×5 row-major colour matrix: rows R, G, B, A of `[r, g, b, a, bias]`. */\n matrix: number[];\n}\n\n/** Tone curve through control points. */\nexport interface CurvesFilterOptions {\n /** Curve control points as [input, output] pairs in [0, 1]. */\n points: [number, number][];\n /** Channel(s) to apply the curve to (default `'rgb'`). */\n channel?: CurvesChannel;\n}\n\n/** Photographic tonal/colour adjustments. All fields optional. */\nexport type ColorAdjustmentFilterOptions = Omit<ColorAdjustmentFilter, 'type'>;\n\n/** Stop-motion frame-rate resample (video only). Scalar shorthand sets `fps`. */\nexport interface PosterizeTimeFilterOptions {\n /** Target frame rate the source playhead snaps to. */\n fps: number;\n}\n\n/** Motion-trail echo of past frames (video only). */\nexport interface EchoFilterOptions {\n /** Number of past-frame taps drawn behind the current frame. */\n echoes: number;\n /** Delay between successive taps, in source seconds. */\n delay: number;\n /** Per-tap alpha multiplier; tap `n` is drawn at `decay ** n` (default 0.5). */\n decay?: number;\n /** Blend mode used to composite the echo taps (default `'screen'`). */\n blend?: BlendMode;\n}\n\n/** A node effect's builder options as a filter takes them: minus {@link EffectOptions} (`mode`), since a filter acts on the fill's own pixels and has no backdrop. */\ntype AsFilterOptions<T> = T extends number ? number : Omit<T, keyof EffectOptions>;\n\nfunction scalarFilter<O extends object>(arg: number | O, key: keyof O): O {\n return typeof arg === \"number\" ? ({ [key]: arg } as O) : arg;\n}\n\n/** Routes through the effect chain so defaults, scalar shorthands and normalisation have one definition. */\nfunction fromEffect(chain: EffectChain): AnyFilter {\n return chain.list[0] as AnyFilter;\n}\n\n/** Immutable, chainable list of media filters valid on an **image** fill; {@link VideoAdjustmentChain} adds the video-only temporal ones. */\nexport class AdjustmentChain {\n constructor(public list: AnyFilter[] = []) { }\n\n /** Returns the same class so the video subclass keeps its extra builders after an inherited one. */\n protected append(filter: AnyFilter): this {\n const Ctor = this.constructor as new (list: AnyFilter[]) => this;\n return new Ctor([...this.list, filter]);\n }\n\n blur(options: number | BlurFilterOptions) {\n const { radius } = scalarFilter(options, \"radius\");\n return this.append({ type: 'blur', radius });\n }\n\n grayscale(options: number | GrayscaleFilterOptions) {\n const { amount } = scalarFilter(options, \"amount\");\n return this.append({ type: 'grayscale', amount });\n }\n\n alpha(options: number | AlphaFilterOptions) {\n const { amount } = scalarFilter(options, \"amount\");\n return this.append({ type: 'alpha', amount });\n }\n\n exposure(options: number | ExposureFilterOptions) {\n const { amount } = scalarFilter(options, \"amount\");\n return this.append({ type: 'exposure', amount });\n }\n\n colorAdjustment(options: ColorAdjustmentFilterOptions) {\n return this.append({ type: 'colorAdjustment', ...options });\n }\n\n colorMatrix(options: number[] | ColorMatrixFilterOptions) {\n const matrix = Array.isArray(options) ? options : options.matrix;\n return this.append({ type: 'colorMatrix', matrix });\n }\n\n curves(options: CurvesFilterOptions) {\n return this.append({ type: 'curves', points: options.points, channel: options.channel });\n }\n\n directionalBlur(options: AsFilterOptions<number | DirectionalBlurOptions>) {\n return this.append(fromEffect(new EffectChain().directionalBlur(options)));\n }\n\n radialBlur(options?: AsFilterOptions<number | RadialBlurOptions>) {\n return this.append(fromEffect(new EffectChain().radialBlur(options)));\n }\n\n progressiveBlur(options?: AsFilterOptions<number | ProgressiveBlurOptions>) {\n return this.append(fromEffect(new EffectChain().progressiveBlur(options)));\n }\n\n bloom(options?: AsFilterOptions<number | BloomOptions>) {\n return this.append(fromEffect(new EffectChain().bloom(options)));\n }\n\n streak(options?: AsFilterOptions<number | StreakOptions>) {\n return this.append(fromEffect(new EffectChain().streak(options)));\n }\n\n sharpen(options?: AsFilterOptions<number | SharpenOptions>) {\n return this.append(fromEffect(new EffectChain().sharpen(options)));\n }\n\n invert(options?: AsFilterOptions<number | InvertOptions>) {\n return this.append(fromEffect(new EffectChain().invert(options)));\n }\n\n vintage(options?: AsFilterOptions<number | VintageOptions>) {\n return this.append(fromEffect(new EffectChain().vintage(options)));\n }\n\n duotone(options?: AsFilterOptions<number | DuotoneOptions>) {\n return this.append(fromEffect(new EffectChain().duotone(options)));\n }\n\n posterize(options?: AsFilterOptions<number | PosterizeOptions>) {\n return this.append(fromEffect(new EffectChain().posterize(options)));\n }\n\n threshold(options?: AsFilterOptions<number | ThresholdOptions>) {\n return this.append(fromEffect(new EffectChain().threshold(options)));\n }\n\n bitCrush(options?: AsFilterOptions<number | BitCrushOptions>) {\n return this.append(fromEffect(new EffectChain().bitCrush(options)));\n }\n\n dither(options?: AsFilterOptions<number | DitherOptions>) {\n return this.append(fromEffect(new EffectChain().dither(options)));\n }\n\n halftone(options?: AsFilterOptions<number | HalftoneOptions>) {\n return this.append(fromEffect(new EffectChain().halftone(options)));\n }\n\n /** Append film grain. Animate it by tweening `seed`. */\n grain(options?: AsFilterOptions<number | GrainOptions>) {\n return this.append(fromEffect(new EffectChain().grain(options)));\n }\n\n /** Append a 3D colour lookup table — see {@link EffectChain.lut}. */\n lut(options: AsFilterOptions<LutOptions>) {\n return this.append(fromEffect(new EffectChain().lut(options as LutOptions)));\n }\n\n scanlines(options?: AsFilterOptions<number | ScanlinesOptions>) {\n return this.append(fromEffect(new EffectChain().scanlines(options)));\n }\n\n pixelate(options: AsFilterOptions<number | PixelateOptions>) {\n return this.append(fromEffect(new EffectChain().pixelate(options)));\n }\n\n /** Cost grows with `radius^2`: the most expensive filter in the set. */\n oilPaint(options?: AsFilterOptions<number | OilPaintOptions>) {\n return this.append(fromEffect(new EffectChain().oilPaint(options)));\n }\n\n ascii(options?: AsFilterOptions<number | AsciiOptions>) {\n return this.append(fromEffect(new EffectChain().ascii(options)));\n }\n\n edges(options?: AsFilterOptions<number | EdgesOptions>) {\n return this.append(fromEffect(new EffectChain().edges(options)));\n }\n\n vignette(options?: AsFilterOptions<number | VignetteOptions>) {\n return this.append(fromEffect(new EffectChain().vignette(options)));\n }\n\n chromaticAberration(options?: AsFilterOptions<number | ChromaticAberrationOptions>) {\n return this.append(fromEffect(new EffectChain().chromaticAberration(options)));\n }\n\n rgbShift(options?: AsFilterOptions<number | RgbShiftOptions>) {\n return this.append(fromEffect(new EffectChain().rgbShift(options)));\n }\n\n scatter(options?: AsFilterOptions<number | ScatterOptions>) {\n return this.append(fromEffect(new EffectChain().scatter(options)));\n }\n\n blockDisplace(options?: AsFilterOptions<number | BlockDisplaceOptions>) {\n return this.append(fromEffect(new EffectChain().blockDisplace(options)));\n }\n\n bulge(options: AsFilterOptions<number | BulgeOptions>) {\n return this.append(fromEffect(new EffectChain().bulge(options)));\n }\n\n twirl(options?: AsFilterOptions<number | TwirlOptions>) {\n return this.append(fromEffect(new EffectChain().twirl(options)));\n }\n\n wave(options?: AsFilterOptions<number | WaveOptions>) {\n return this.append(fromEffect(new EffectChain().wave(options)));\n }\n\n kaleidoscope(options?: AsFilterOptions<number | KaleidoscopeOptions>) {\n return this.append(fromEffect(new EffectChain().kaleidoscope(options)));\n }\n\n shader(options: AsFilterOptions<ShaderEffectOptions>) {\n return this.append(fromEffect(new EffectChain().shader(options)));\n }\n\n *[Symbol.iterator]() {\n yield* this.list;\n }\n\n toJSON() {\n return this.list;\n }\n}\n\n/** The image chain plus the video-only temporal filters. */\nexport class VideoAdjustmentChain extends AdjustmentChain {\n posterizeTime(options: number | PosterizeTimeFilterOptions) {\n const { fps } = scalarFilter(options, \"fps\");\n return this.append({ type: 'posterizeTime', fps });\n }\n\n echo(options: EchoFilterOptions) {\n return this.append({ type: 'echo', ...options });\n }\n}\n\n/** Accepted shapes for an **image** fill's `filters` prop; video-only filters are excluded. */\nexport type ImageAdjustment = MediaAdjustment | MediaAdjustment[] | AdjustmentChain;\n\n/** Accepted shapes for a **video** fill's `filters` prop: pixel filters plus the video-only `posterizeTime` and `echo`. */\nexport type VideoAdjustment =\n | (MediaAdjustment | VideoOnlyAdjustment)\n | (MediaAdjustment | VideoOnlyAdjustment)[]\n | AdjustmentChain;\n\n/** Empty chain: `Adjustments.blur(8)` is `new AdjustmentChain().blur(8)`, so builders are documented once, on {@link AdjustmentChain}. Pixel filters only. */\nexport const Adjustments = new AdjustmentChain();\n\n/** {@link Adjustments} plus the video-only temporal builders. */\nexport const VideoAdjustments = new VideoAdjustmentChain();\n\n/** Normalises any `ImageAdjustment`/`VideoAdjustment` value to a plain filter array. */\nexport function resolveChainAdjustments(filters: ImageAdjustment | VideoAdjustment | undefined): AnyFilter[] {\n if (filters === undefined) return [];\n if (filters instanceof AdjustmentChain) return filters.list;\n if (Array.isArray(filters)) return filters;\n return [filters];\n}\n", "import { Vector2, lerpVector2 } from \"./vector2\";\nimport { BoxBounds } from \"@/layout/bounds\";\nimport type { AttributeOps } from \"@/attributes/shared/operators\";\n\n/** The nine named positions inside a box (`center`, `topLeft`, …), each a per-axis point in `[-1, 1]` (x -1 left … +1 right, y -1 bottom … +1 top: layout's y-up convention). */\nexport type AlignmentKey =\n | \"center\"\n | \"topLeft\"\n | \"topRight\"\n | \"bottomLeft\"\n | \"bottomRight\"\n | \"topCenter\"\n | \"bottomCenter\"\n | \"centerLeft\"\n | \"centerRight\";\n\n/** A normalised point inside a box: the one type behind every \"which point of this thing\" prop (`Node2D.pivot`, a container's `align`, a gradient's `center`, an image fill's `anchor`). They keep distinct names because they position different things, but share this `[-1, 1]` y-up space so a value read off one can be handed to another. A named position or a {@link Vector2}. */\nexport type Alignment = AlignmentKey | Vector2;\n\nconst ALIGNMENTS: Record<AlignmentKey, Vector2> = {\n topLeft: { x: -1, y: 1 },\n topCenter: { x: 0, y: 1 },\n topRight: { x: 1, y: 1 },\n centerLeft: { x: -1, y: 0 },\n center: { x: 0, y: 0 },\n centerRight: { x: 1, y: 0 },\n bottomLeft: { x: -1, y: -1 },\n bottomCenter: { x: 0, y: -1 },\n bottomRight: { x: 1, y: -1 },\n};\n\n/** The nine named alignment keys in reading order: top row left to right, then\n * the middle row, then the bottom row. */\nconst ALIGNMENT_KEYS: readonly AlignmentKey[] = Object.keys(ALIGNMENTS) as AlignmentKey[];\n\n// `resolve`'s own logic, pulled out only so the alignment-positioning helpers\n// below can reach it without going through a `this`-bound method call.\nfunction resolveOne(value: Alignment): Vector2 {\n if (typeof value === \"string\") {\n const named = Object.hasOwn(ALIGNMENTS, value) ? ALIGNMENTS[value] : undefined;\n if (!named) {\n throw new Error(`Unknown alignment value: '${value}'`);\n }\n return { ...named };\n }\n return { x: value.x, y: value.y };\n}\n\n/** The alignment attribute's op set: `resolve`/`lerp` for `pivot`, `align`, `center` and `anchor`, plus the shared alignment-*positioning* math for `Node2D` (constructor binding and one-shot `to()`): landing a named alignment (pivot `a`, y-up) on a target scene-space point puts the node's centre at `target - a·(size/2)`. */\n\nexport type AlignmentOps = {\n /** The nine named keys in reading order, top-left to bottom-right. */\n readonly keys: readonly AlignmentKey[];\n isKey(value: unknown): value is AlignmentKey;\n /** Validates a node's alignment props: at most one named alignment, never combined with an explicit `pivot` (the alignment derives one). */\n validateProps(props: Record<string, unknown>): void;\n findKey(props: Record<string, unknown>): AlignmentKey | undefined;\n /** Resolves a named alignment and the centre offset that lands it on `target` for a concrete layout rect (one-shot `to()`): the pivot plus the absolute `x`/`y` the centre moves to. */\n resolveTargetOnce(alignmentKey: AlignmentKey, rect: BoxBounds, target: Vector2): { pivot: Vector2; x: number; y: number };\n /** Reactive form for the constructor: returns the pivot to write plus `x`/`y` binding callbacks that re-evaluate when the target or the node's layout changes. */\n bindTarget(alignmentKey: AlignmentKey, getTarget: () => Vector2, getRect: () => BoxBounds): { pivot: Vector2; x: () => number; y: () => number };\n}\nexport const alignmentOps: AttributeOps<Alignment, Vector2> & AlignmentOps = {\n resolve: resolveOne,\n lerp: lerpVector2,\n keys: ALIGNMENT_KEYS,\n\n isKey(value): value is AlignmentKey {\n return typeof value === \"string\" && Object.hasOwn(ALIGNMENTS, value);\n },\n\n validateProps(props) {\n const present = ALIGNMENT_KEYS.filter(k => props[k] !== undefined);\n if (present.length > 1) {\n throw new Error(`Cannot set multiple alignment props at once: ${present.join(', ')}`);\n }\n if (present.length === 1 && props['pivot'] !== undefined) {\n throw new Error(`Cannot set both alignment prop '${present[0]}' and 'pivot' at the same time`);\n }\n },\n\n findKey(props) {\n return ALIGNMENT_KEYS.find(k => props[k] !== undefined);\n },\n\n resolveTargetOnce(alignmentKey, rect, target) {\n const a = resolveOne(alignmentKey);\n return {\n pivot: a,\n x: target.x - a.x * (rect.width / 2),\n y: target.y - a.y * (rect.height / 2),\n };\n },\n\n bindTarget(alignmentKey, getTarget, getRect) {\n const a = resolveOne(alignmentKey);\n return {\n pivot: a,\n x: () => getTarget().x - a.x * (getRect().width / 2),\n y: () => getTarget().y - a.y * (getRect().height / 2),\n };\n },\n};\n", "import { lerpNumber } from \"@/tween/lerp\";\nimport type { AttributeOps } from \"@/attributes/shared/operators\";\nimport type { BoxBounds } from \"@/layout/bounds\";\nimport { Size2D } from \"./size\";\n\n/** Fully resolved per-side edge insets. */\nexport interface InsetsResolved {\n left: number;\n right: number;\n top: number;\n bottom: number;\n}\n\n\nexport type InsetsProps = number | Partial<InsetsResolved> & {\n horizontal?: number;\n vertical?: number;\n};\n\n/** Accepted shapes for a four-sided inset prop, named for the shape, not one use (`Node2D.padding` insets a layout box in px, an image fill's `crop` a source in fractions). The loose {@link InsetsProps} (a number or per-side/symmetric object) plus the strict {@link InsetsResolved}; a read-back resolved value satisfies `InsetsProps`, so it passes through `insetsOps.resolve` idempotently. */\nexport type Insets = InsetsProps | InsetsResolved;\n\n\n/** The insets attribute's op set (padding, an image fill's `crop`, …). `insetBounds` subtracts a resolved inset from an outer size, with `x`/`y` the offset of the inner centre from the outer centre; `outsetSize` is its inverse. */\n\nexport interface InsetsOps {\n\n insetBounds(outerWidth: number, outerHeight: number, pad: InsetsResolved): BoxBounds;\n outsetSize(innerWidth: number, innerHeight: number, pad: InsetsResolved): Size2D;\n}\n\nexport const insetsOps: AttributeOps<InsetsProps, InsetsResolved> & InsetsOps = {\n resolve: (value: InsetsProps, previous?: InsetsResolved): InsetsResolved => {\n if (typeof value === \"number\") {\n return { left: value, right: value, top: value, bottom: value };\n }\n\n // Fallback resolution order: Specific side -> Symmetric shortcut -> Previous fallback -> Default 0\n return {\n left: value.left ?? value.horizontal ?? previous?.left ?? 0,\n right: value.right ?? value.horizontal ?? previous?.right ?? 0,\n top: value.top ?? value.vertical ?? previous?.top ?? 0,\n bottom: value.bottom ?? value.vertical ?? previous?.bottom ?? 0,\n };\n },\n lerp: (from: InsetsResolved, to: InsetsResolved, t: number): InsetsResolved => {\n return {\n left: lerpNumber(from.left, to.left, t),\n right: lerpNumber(from.right, to.right, t),\n top: lerpNumber(from.top, to.top, t),\n bottom: lerpNumber(from.bottom, to.bottom, t),\n };\n },\n insetBounds: (outerWidth, outerHeight, pad) => ({\n width: Math.max(0, outerWidth - pad.left - pad.right),\n height: Math.max(0, outerHeight - pad.top - pad.bottom),\n x: (pad.left - pad.right) / 2,\n y: (pad.top - pad.bottom) / 2,\n }),\n outsetSize: (innerWidth, innerHeight, pad) => ({\n width: innerWidth + pad.left + pad.right,\n height: innerHeight + pad.top + pad.bottom,\n }),\n};\n", "import { lerpNumber } from \"@/tween/lerp\";\nimport type { AssetScope } from \"@/assets/scope\";\nimport { declareFilter, lerpFilterArray } from \"../filters/registry\";\nimport { resolveChainAdjustments } from \"../filters/chain\";\nimport type { ImageAdjustment, VideoAdjustment } from \"../filters/chain\";\nimport type { MediaAdjustment, VideoOnlyAdjustment } from \"../filters/union\";\n\n/** A **preset**: the grade a media fill carries, an ordered chain of adjustments plus one dry/wet mix. Wrapped rather than a sibling prop because a look is constantly asked for as \"the same, but less\": one number about the whole chain, not smeared across each adjustment (scaling toward neutral is the approximation forced when the renderer can't mix). */\nexport interface MediaPresetProp {\n /** The chain: one adjustment, a plain array, or an {@link AdjustmentChain}. */\n adjustments?: ImageAdjustment;\n /** How much of the grade to apply, 0–1 (default 1): a real mix against the ungraded pixels, not a scaling of the chain's values. */\n intensity?: number;\n}\n\n/** {@link MediaPresetProp} for a video fill, which also admits the temporal adjustments. */\nexport interface VideoPresetProp {\n adjustments?: VideoAdjustment;\n intensity?: number;\n}\n\nexport interface MediaPresetResolved<A = MediaAdjustment> {\n adjustments: A[];\n intensity: number;\n}\n\n/** Normalises a fill's grade. `undefined` (not an empty preset) when there is none: an ungraded media fill takes a cheaper renderer path that an always-present key would forfeit. */\nexport function resolveMediaPreset(\n preset: MediaPresetProp | VideoPresetProp | undefined,\n): MediaPresetResolved<MediaAdjustment | VideoOnlyAdjustment> | undefined {\n const adjustments = resolveChainAdjustments(preset?.adjustments);\n if (adjustments.length === 0) return undefined;\n return {\n adjustments,\n // Clamped: an intensity outside 0–1 would make the renderer's mix extrapolate past the graded image.\n intensity: Math.min(1, Math.max(0, preset?.intensity ?? 1)),\n };\n}\n\n/**\n * Interpolates two presets: the chain pairwise (see {@link lerpFilterArray}), the mix as a number.\n *\n * **An absent preset is read as the other side's chain at `intensity: 0`**, not an empty chain: `lerpFilterArray` keeps\n * an index present on one side as-is, so tweening grayscaled to ungraded would hold the grayscale at full strength then\n * cut. Holding the chain and fading the mix is what \"remove this grade over half a second\" means.\n */\nexport function lerpMediaPreset<A extends MediaAdjustment | VideoOnlyAdjustment>(\n a: MediaPresetResolved<A> | undefined,\n b: MediaPresetResolved<A> | undefined,\n t: number,\n): MediaPresetResolved<A> | undefined {\n if (!a && !b) return undefined;\n const from = a ?? { adjustments: b!.adjustments, intensity: 0 };\n const to = b ?? { adjustments: a!.adjustments, intensity: 0 };\n return {\n adjustments: lerpFilterArray(from.adjustments, to.adjustments, t) as A[],\n intensity: lerpNumber(from.intensity, to.intensity, t),\n };\n}\n\nexport function declareMediaPreset(\n preset: MediaPresetResolved<MediaAdjustment | VideoOnlyAdjustment> | undefined,\n assets: AssetScope,\n): void {\n for (const adjustment of preset?.adjustments ?? []) declareFilter(adjustment, assets);\n}\n", "import type { BlendMode } from '../blend';\nimport type { MediaAdjustment } from '../../filters/union';\nimport type { FillData } from '../registry';\nimport {\n declareMediaPreset,\n lerpMediaPreset,\n resolveMediaPreset,\n type MediaPresetProp,\n type MediaPresetResolved,\n} from '../media-preset';\nimport { Alignment, alignmentOps } from '@/attributes/layout/alignment';\nimport { Insets, InsetsResolved, insetsOps } from '@/attributes/layout/insets';\nimport { Vector2, lerpVector2 } from '@/attributes/layout/vector2';\nimport { lerpNumber } from '@/tween/lerp';\n\n/**\n * How an image (or video frame) is scaled into its node's bounds: `'fill'` covers, cropping overflow (Figma-style\n * default); `'fit'` contains, letterboxing; `'tile'` repeats at native size (× `zoom`); `'stretch'` scales each axis\n * independently, distorting the aspect ratio.\n */\nexport type ImageFit = 'fill' | 'fit' | 'tile' | 'stretch';\n\n/** A raw image→shape matrix (3×3 row-major) as a 9-element `Float32Array` or nested array; see {@link ImageFillProp.matrix}. */\nexport type ImageMatrix = Float32Array | number[][];\n\n/** A window onto the source as **fractions of its own size** (0–1) inset from each edge (`{ left: 0.25 }` discards the left quarter), so a crop is resolution-independent and composes with `fit`/`zoom`/`anchor`, which treat the window as the whole image. An {@link Insets}, so its shorthands and tween come free. */\nexport type ImageCrop = Insets;\n\nexport interface ImageFillProp {\n type: 'image';\n src: string;\n\n fit?: ImageFit;\n\n /** Window onto the source, applied **before** `fit`. Not honoured by `fit: 'tile'` (the shader repeats the whole texture). */\n crop?: ImageCrop;\n\n /** Magnification **on top of** whatever `fit` resolved (`1` is the fitted size). A multiplier so it means the same under every mode; under `'tile'` it is the tile size multiplier. */\n zoom?: number;\n\n /**\n * The point held fixed as `zoom` scales, and the alignment of the image inside the bounds when it doesn't cover\n * them (default `'center'`). The same `[-1, 1]` y-up space as `pivot`/`align`: the named point of the source lands\n * on the same named point of the box. Ignored by `'tile'`, and inert under `'stretch'` at `zoom: 1`.\n */\n anchor?: Alignment;\n\n /** Raw image→shape matrix. Wins outright, bypassing `crop`/`fit`/`zoom`/`anchor` **and** the shape bounds, so it must carry the translation itself. Named `matrix`, not `transform`, which is a node's x/y/scale/rotation. */\n matrix?: ImageMatrix;\n\n /** The grade laid over this picture — see {@link MediaPresetProp}. */\n preset?: MediaPresetProp;\n opacity?: number;\n blend?: BlendMode;\n}\n\nexport interface ImageFillResolved {\n type: 'image';\n src: string;\n fit?: ImageFit;\n /** Fractional insets, all four sides present. */\n crop?: InsetsResolved;\n zoom?: number;\n /** Normalised `[-1, 1]` y-up point. */\n anchor?: Vector2;\n matrix?: ImageMatrix;\n /** Absent when the fill is ungraded — see {@link resolveMediaPreset}. */\n preset?: MediaPresetResolved<MediaAdjustment>;\n opacity?: number;\n blend?: BlendMode;\n}\n\n/** Zero crop — the whole source. Shared by the lerp when only one side crops. */\nconst NO_CROP: InsetsResolved = { left: 0, right: 0, top: 0, bottom: 0 };\nconst CENTER: Vector2 = { x: 0, y: 0 };\n\n/** Normalises the loose author shapes once so the backend's matrix builder reads plain values (`crop` four sides, `anchor` a vector) instead of re-deriving them per frame. */\n/** @internal */\nexport function resolveImagePlacement(\n prop: { crop?: ImageCrop; anchor?: Alignment },\n): { crop?: InsetsResolved; anchor?: Vector2 } {\n return {\n crop: prop.crop === undefined ? undefined : insetsOps.resolve(prop.crop),\n anchor: prop.anchor === undefined ? undefined : alignmentOps.resolve(prop.anchor),\n };\n}\n\n/** Interpolates the placement props shared by image and video fills, in one place so they cannot drift (both feed `computeImageMatrix`). */\n/** @internal */\nexport function lerpImagePlacement(\n a: { crop?: InsetsResolved; zoom?: number; anchor?: Vector2; matrix?: ImageMatrix },\n b: { crop?: InsetsResolved; zoom?: number; anchor?: Vector2; matrix?: ImageMatrix },\n t: number,\n): { crop?: InsetsResolved; zoom: number; anchor: Vector2; matrix?: ImageMatrix } {\n return {\n // A raw matrix is not interpolable: it snaps at the midpoint like `fit`; bind the prop to a thunk to move it.\n matrix: t < 0.5 ? a.matrix : b.matrix,\n // Stay `undefined` when neither side crops, so an uncropped fill keeps\n // taking the cheap path and reads back as it was authored.\n crop: a.crop || b.crop ? insetsOps.lerp(a.crop ?? NO_CROP, b.crop ?? NO_CROP, t) : undefined,\n zoom: lerpNumber(a.zoom ?? 1, b.zoom ?? 1, t),\n anchor: lerpVector2(a.anchor ?? CENTER, b.anchor ?? CENTER, t),\n };\n}\n\nexport const imageFill: FillData<ImageFillResolved> = {\n // `crop`/`anchor` are destructured out before the spread: an optional prop\n // re-added by a later spread widens to a *union* of both types, so leaving\n // them in would type the resolved crop as `ImageCrop | InsetsResolved`.\n resolve: ({ crop, anchor, preset, ...prop }: ImageFillProp): ImageFillResolved => ({\n ...prop,\n ...resolveImagePlacement({ crop, anchor }),\n preset: resolveMediaPreset(preset) as\n | MediaPresetResolved<MediaAdjustment>\n | undefined,\n }),\n lerp: (a, b, t) => ({\n src: t < 0.5 ? a.src : b.src,\n fit: t < 0.5 ? a.fit : b.fit,\n ...lerpImagePlacement(a, b, t),\n opacity: (a.opacity ?? 1) + ((b.opacity ?? 1) - (a.opacity ?? 1)) * t,\n // The grade animates with the fill; otherwise `lerpFill`'s spread would carry the *from* grade for the whole tween.\n preset: lerpMediaPreset(a.preset, b.preset, t),\n }),\n equals: (a, b) => a.src === b.src,\n declare: (fill, assets) => {\n assets.image(fill.src);\n declareMediaPreset(fill.preset, assets);\n },\n};\n", "import type { BlendMode } from '../blend';\nimport type { MediaAdjustment, VideoOnlyAdjustment } from '../../filters/union';\nimport type { PosterizeTimeFilter } from '../../filters/implementations/posterize-time';\nimport type { FillData } from '../registry';\nimport type { ImageCrop, ImageFit, ImageMatrix } from './image';\nimport { lerpImagePlacement, resolveImagePlacement } from './image';\nimport type { Alignment } from '@/attributes/layout/alignment';\nimport type { InsetsResolved } from '@/attributes/layout/insets';\nimport type { Vector2 } from '@/attributes/layout/vector2';\nimport { lerpNumber } from '@/tween/lerp';\nimport {\n declareMediaPreset,\n lerpMediaPreset,\n resolveMediaPreset,\n type MediaPresetResolved,\n type VideoPresetProp,\n} from '../media-preset';\n\n/** Adjustments a video fill carries — the pixel ones plus the video-only ones. */\ntype VideoFillFilter = MediaAdjustment | VideoOnlyAdjustment;\n\nexport interface VideoFillProp {\n type: 'video';\n src: string;\n /** How the (cropped) frame is scaled into the node's bounds. Defaults to `'fill'`. */\n fit?: ImageFit;\n crop?: ImageCrop;\n zoom?: number;\n anchor?: Alignment;\n /** Raw frame→shape matrix; wins over everything above. See {@link ImageFillProp.matrix}. */\n matrix?: ImageMatrix;\n /**\n * Source time to paint, in seconds: an **explicit override**. Omitted, the timestamp is derived at draw time from how\n * long the painting node has existed, so a video fill plays wherever paint is accepted. Pass `null` to hand the\n * playhead back to the clock (`Node2D.set` skips `undefined`, so `null` is what un-does a live override).\n */\n timestamp?: number | null;\n /** Whether the derived timestamp advances with the node's clock. Default `true`. */\n playing?: boolean;\n trimStart?: number;\n trimEnd?: number;\n /** Seconds after the painting node appears before playback begins (default `0`), for a fill joining an existing node (a video cross-faded in at 4s would otherwise open 4s into the clip). Negative starts the clip in progress. */\n playStart?: number;\n speed?: number;\n /** The grade laid over this footage — see {@link VideoPresetProp}. */\n preset?: VideoPresetProp;\n loop?: 'forward' | 'reverse' | 'none';\n duration?: number;\n opacity?: number;\n blend?: BlendMode;\n}\n\nexport interface VideoFillResolved {\n type: 'video';\n src: string;\n fit?: ImageFit;\n crop?: InsetsResolved;\n zoom?: number;\n anchor?: Vector2;\n matrix?: ImageMatrix;\n timestamp?: number | null;\n playing: boolean;\n trimStart?: number;\n trimEnd?: number;\n playStart?: number;\n speed?: number;\n /** Absent when the fill is ungraded — see {@link resolveMediaPreset}. */\n preset?: MediaPresetResolved<VideoFillFilter>;\n loop?: 'forward' | 'reverse' | 'none';\n duration?: number;\n opacity?: number;\n blend?: BlendMode;\n}\n\n/**\n * The source time a video fill paints at, given `elapsed` (how long the painting node has existed). A pure function of\n * the fill and the clock, derived at draw time rather than advanced per tick, so a video plays anywhere paint is\n * accepted (stroke, shadow, text run, raw `Graphics2D`) and frame N is identical however the playhead reached it.\n * `sourceDuration` resolves the `trimEnd` default and loop cycle; when unknown (non-positive or `undefined`) playback\n * runs linearly and unlooped.\n */\nexport function resolveVideoTimestamp(\n fill: VideoFillResolved,\n elapsed: number,\n sourceDuration?: number,\n): number {\n const start = fill.trimStart ?? 0;\n return posterizeTimestamp(fill, start, rawTimestamp(fill, elapsed, sourceDuration, start));\n}\n\n/** {@link resolveVideoTimestamp} before the posterize-time quantization. */\nfunction rawTimestamp(\n fill: VideoFillResolved,\n elapsed: number,\n sourceDuration: number | undefined,\n start: number,\n): number {\n // An authored timestamp wins outright: the author is driving the playhead.\n if (fill.timestamp != null) return fill.timestamp;\n // Paused with no authored time: hold the clip's first frame.\n if (!fill.playing) return start;\n\n const played = Math.max(0, elapsed - (fill.playStart ?? 0)) * (fill.speed ?? 1);\n return sourceTimeFor(played, start, trimEndFor(fill, sourceDuration), fill.loop, fill.duration);\n}\n\n/** The clip's out point: the fill's own, else the source's length once the container is open, else unbounded. `Infinity` is the unbounded sentinel, as on the audio side (`Sound.trimEnd`, `AudioRequest.endAt`). */\nexport function trimEndFor(\n fill: Pick<VideoFillResolved, 'trimEnd'>,\n sourceDuration: number | undefined,\n): number {\n const hasDuration = sourceDuration !== undefined && Number.isFinite(sourceDuration) && sourceDuration > 0;\n return fill.trimEnd ?? (hasDuration ? sourceDuration : Infinity);\n}\n\n/** Where `played` seconds of *consumed source* land inside the trimmed window after looping and clamping. Shared by the fill (linear in the clock) and a {@link Video} node on a `segments` schedule (a paused stretch consumes no source), so what \"wraps\" and \"stops\" mean lives once. */\nexport function sourceTimeFor(\n /** Seconds of source consumed so far — already scaled by playback rate. */\n played: number,\n start: number,\n /** The trim-out point, or `Infinity` while the source's length is unknown. */\n end: number,\n loop: 'forward' | 'reverse' | 'none' | undefined,\n /** An explicit loop-cycle length; defaults to the trimmed clip's own. */\n cycleLength?: number,\n): number {\n const rawLoopDuration = cycleLength ?? (end !== Infinity ? end - start : undefined);\n const loopDuration = rawLoopDuration !== undefined && rawLoopDuration > 0 ? rawLoopDuration : undefined;\n if ((loop ?? 'none') !== 'none' && loopDuration !== undefined) {\n const cycle = played % loopDuration;\n if (loop === 'reverse') {\n const ping = Math.floor(played / loopDuration) % 2 === 0;\n return start + (ping ? cycle : loopDuration - cycle);\n }\n return start + cycle;\n }\n const linear = start + played;\n return end !== Infinity ? Math.min(linear, end) : linear;\n}\n\n/** Posterize Time: snaps the source timestamp to a coarser grid, holding each frame a full 1/fps (`floor`, not round, matching After Effects). Done after trim/speed/loop so it lines up with the adapter's decoded-frame grid. */\nfunction posterizeTimestamp(fill: VideoFillResolved, start: number, timestamp: number): number {\n const posterize = fill.preset?.adjustments.find(\n (f): f is PosterizeTimeFilter => f.type === 'posterizeTime',\n );\n if (!posterize || posterize.fps <= 0) return timestamp;\n const grid = 1 / posterize.fps;\n return start + Math.floor((timestamp - start) / grid) * grid;\n}\n\nexport const videoFill: FillData<VideoFillResolved> = {\n // See `imageFill.resolve` for why `crop`/`anchor` are destructured out.\n resolve: ({ crop, anchor, preset, ...prop }: VideoFillProp): VideoFillResolved => ({\n ...prop,\n ...resolveImagePlacement({ crop, anchor }),\n preset: resolveMediaPreset(preset) as\n | MediaPresetResolved<VideoFillFilter>\n | undefined,\n playing: prop.playing ?? true,\n }),\n lerp: (a, b, t) => ({\n src: t < 0.5 ? a.src : b.src,\n fit: t < 0.5 ? a.fit : b.fit,\n ...lerpImagePlacement(a, b, t),\n loop: t < 0.5 ? a.loop : b.loop,\n duration: t < 0.5 ? a.duration : b.duration,\n trimStart: t < 0.5 ? a.trimStart : b.trimStart,\n trimEnd: t < 0.5 ? a.trimEnd : b.trimEnd,\n playStart: t < 0.5 ? a.playStart : b.playStart,\n playing: t < 0.5 ? a.playing : b.playing,\n opacity: (a.opacity ?? 1) + ((b.opacity ?? 1) - (a.opacity ?? 1)) * t,\n // Both derived stays derived: lerping `?? 0` would pin the result to an explicit timestamp and freeze the clip while the tween is live.\n timestamp: a.timestamp == null && b.timestamp == null\n ? undefined\n : lerpNumber(a.timestamp ?? 0, b.timestamp ?? 0, t),\n speed: lerpNumber(a.speed ?? 1, b.speed ?? 1, t),\n // See the note on `imageFill.lerp` — without this the *from* fill's\n // grade rides the whole tween and snaps at the end.\n preset: lerpMediaPreset(a.preset, b.preset, t),\n }),\n equals: (a, b) => a.src === b.src,\n declare: (fill, assets) => {\n assets.video(fill.src, { start: fill.trimStart ?? 0, end: fill.trimEnd });\n declareMediaPreset(fill.preset, assets);\n },\n};\n", "import { PathCommand } from \"./path\";\nimport type { PathState } from \"./path\";\n\n/** A full or partial revolution of an ellipse, in the **y-up** space commands are authored in (`y = 100` is 100px above the centre). Angles are degrees from 3 o'clock, counter-clockwise positive, as the `Ellipse` node. */\nexport interface EllipseArc {\n /** Centre. Both default to the origin. */\n x?: number;\n y?: number;\n width: number;\n /** Defaults to `width`, i.e. a circle. */\n height?: number;\n startAngle?: number;\n /** Degrees travelled; negative goes clockwise. Past ±360 it keeps looping. */\n sweep?: number;\n}\n\nexport class PathBuilder {\n private _cmds: PathCommand[] = [];\n private _x = 0;\n private _y = 0;\n private _startX = 0;\n private _startY = 0;\n private _open = false;\n\n moveTo(x: number, y: number): this {\n this._cmds.push({ type: \"M\", x, y });\n this._startX = x;\n this._startY = y;\n return this._at(x, y);\n }\n\n lineTo(x: number, y: number): this {\n this._cmds.push({ type: \"L\", x, y });\n return this._at(x, y);\n }\n\n bezierCurveTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): this {\n this._cmds.push({ type: \"C\", x1, y1, x2, y2, x, y });\n return this._at(x, y);\n }\n\n quadraticCurveTo(x1: number, y1: number, x: number, y: number): this {\n this._cmds.push({ type: \"Q\", x1, y1, x, y });\n return this._at(x, y);\n }\n\n /** The raw SVG arc command: an elliptical arc to (`x`, `y`), picked out of the four candidates by `largeArc`/`sweep`. */\n arcTo(rx: number, ry: number, rotation: number, largeArc: 0 | 1, sweep: 0 | 1, x: number, y: number): this {\n this._cmds.push({ type: \"A\", rx, ry, rotation, largeArc, sweep, x, y });\n return this._at(x, y);\n }\n\n /** An **open** elliptical arc: the perimeter of {@link EllipseArc} from `startAngle` through `sweep` degrees. Continues the current subpath (a straight line joins the pen to the arc's start when they differ), so `moveTo(...).arc(...)` is one unbroken curve; a new `M` would be a subpath break the walk teleports across. */\n arc(arc: EllipseArc): this {\n const { cx, cy, rx, ry, from, sweep } = resolveArc(arc);\n const start = pointOn(cx, cy, rx, ry, from);\n if (!this._open) this.moveTo(start.x, start.y);\n else if (start.x !== this._x || start.y !== this._y) this.lineTo(start.x, start.y);\n return this._sweep(cx, cy, rx, ry, from, sweep);\n }\n\n /** A **closed** subpath tracing an ellipse. A `sweep` short of a full turn closes across the chord; for a pie wedge or annular sector use an `Ellipse` node's `ratio`. */\n ellipse(arc: EllipseArc): this {\n const { cx, cy, rx, ry, from, sweep } = resolveArc(arc);\n const start = pointOn(cx, cy, rx, ry, from);\n this.moveTo(start.x, start.y);\n this._sweep(cx, cy, rx, ry, from, sweep);\n return this.close();\n }\n\n close(): this {\n this._cmds.push({ type: \"Z\" });\n return this._at(this._startX, this._startY);\n }\n\n toCommands(): PathCommand[] {\n return [...this._cmds];\n }\n\n toPathState(partial: Omit<Partial<PathState>, \"data\"> = {}): Partial<PathState> {\n return { ...partial, data: this._cmds };\n }\n\n /** Record where the pen ended up, so {@link arc} knows whether it has to join up to its start. */\n private _at(x: number, y: number): this {\n this._x = x;\n this._y = y;\n this._open = true;\n return this;\n }\n\n /** Emits the arc as segments of at most a quarter turn: one `A` can't express a full revolution (coincident endpoints leave it undefined) and is imprecise well before that, so the split makes `sweep` a real angle. */\n private _sweep(cx: number, cy: number, rx: number, ry: number, from: number, sweep: number): this {\n if (sweep === 0) return this;\n const steps = Math.ceil(Math.abs(sweep) / 90);\n const step = sweep / steps;\n const direction = sweep > 0 ? 1 : 0;\n for (let i = 1; i <= steps; i++) {\n const p = pointOn(cx, cy, rx, ry, from + step * i);\n this.arcTo(rx, ry, 0, 0, direction, p.x, p.y);\n }\n return this;\n }\n}\n\nfunction resolveArc(arc: EllipseArc): { cx: number; cy: number; rx: number; ry: number; from: number; sweep: number } {\n return {\n cx: arc.x ?? 0,\n cy: arc.y ?? 0,\n rx: arc.width / 2,\n ry: (arc.height ?? arc.width) / 2,\n from: arc.startAngle ?? 0,\n sweep: arc.sweep ?? 360,\n };\n}\n\nfunction pointOn(cx: number, cy: number, rx: number, ry: number, angle: number): { x: number; y: number } {\n const rad = (angle * Math.PI) / 180;\n return { x: cx + rx * Math.cos(rad), y: cy + ry * Math.sin(rad) };\n}\n", "import type { RectState } from \"./descriptors/rect\";\nimport type { EllipseState } from \"./descriptors/ellipse\";\nimport type { PathState } from \"./descriptors/path\";\nimport type { LineState } from \"./descriptors/line\";\nimport type { PolygonState } from \"./descriptors/polygon\";\nimport type { PolygramState } from \"./descriptors/polygram\";\nimport type { TextState } from \"./descriptors/text\";\nimport type { RichTextState } from \"./descriptors/richtext\";\nimport type { ShapeAlignmentInput } from \"./descriptors/shape\";\nimport { PathBuilder } from \"./descriptors/path-builder\";\nimport type { Fill } from \"@/attributes/shape/fill/chain\";\nimport type { Stroke } from \"@/attributes/shape/stroke/stroke\";\nimport type { Shadow } from \"@/attributes/shape/shadow/shadow\";\nimport type { NodeEffect } from \"@/attributes/shape/effects/union\";\n// A direct leaf import, not the `@/attributes` barrel: this file sits in a cycle (fill's canvas3d implementation ->\n// render3d -> Node2D -> RenderContext2D -> here) the barrel would close, leaving `effectsOps` undefined at module init.\nimport { type Effect, effectsOps } from \"@/attributes/shape/effects/chain\";\nimport type { Alignment } from \"@/attributes/layout/alignment\";\nimport type { MaskOptions } from \"@/attributes/mask/mask\";\n\n/** A union-level rotate/scale on the whole drawn silhouette. `center` is the pivot: an explicit {@link Vector2} in the graphics' local space or a named alignment resolved against the union's bounding box (default: its centre). */\nexport interface GraphicsTransform {\n rotation: number;\n scale: number;\n center?: Alignment;\n}\n\n/** The shape ops a {@link Graphics2D} can record, each carrying that shape's partial descriptor state. */\nexport type GraphicsShapeOp =\n | { kind: \"rect\"; state: Partial<RectState> & ShapeAlignmentInput }\n | { kind: \"ellipse\"; state: Partial<EllipseState> & ShapeAlignmentInput }\n | { kind: \"path\"; state: Partial<PathState> }\n | { kind: \"line\"; state: Partial<LineState> }\n | { kind: \"polygon\"; state: Partial<PolygonState> & ShapeAlignmentInput }\n | { kind: \"polygram\"; state: Partial<PolygramState> & ShapeAlignmentInput }\n | { kind: \"text\"; state: Partial<TextState> & ShapeAlignmentInput }\n | { kind: \"richText\"; state: Partial<RichTextState> & ShapeAlignmentInput };\n\n/** One recorded operation: shape ops declare geometry; paint ops (fill/stroke/shadow) apply to the accumulated shapes; cut/mask ops composite. Replayed in order via `RenderContext2D.draw()`. */\nexport type GraphicsOp =\n | GraphicsShapeOp\n | { kind: \"fill\"; fills: Fill }\n | { kind: \"stroke\"; strokes: Stroke }\n | { kind: \"shadow\"; shadows: Shadow }\n | { kind: \"cut\" }\n | { kind: \"mask\"; options?: MaskOptions }\n | { kind: \"applyMask\" }\n | { kind: \"endMask\" }\n | { kind: \"effects\"; effects: NodeEffect[] };\n\nconst SHAPE_KINDS = new Set<GraphicsOp[\"kind\"]>([\n \"rect\", \"ellipse\", \"path\", \"line\", \"polygon\", \"polygram\", \"text\", \"richText\",\n]);\n\n/**\n * A renderer-agnostic, chainable shape/paint builder: records shape declarations and paint/compositing ops without\n * touching a renderer, then `ctx.draw(graphics)` replays them against the backend.\n *\n * const g = new Graphics2D()\n * .ellipse({ width: 100, height: 100 })\n * .rect({ width: 40, height: 40, rotation: 30 }) // per-shape: tilts this rect only\n * .fill(Fills.color(\"red\"))\n * .stroke({ weight: 2, fill: \"black\" })\n * .rotation(15) // graphics-level: turns the whole union\n * .effects(Effects.blur(6)); // graphics-level: blurs the whole drawn union\n * ctx.draw(g);\n *\n * Shapes chained before a paint call combine into a single surface painted together (one gradient maps across all).\n * `cut()` uses the latest shape as a cutter against those before it; `mask()/applyMask()/endMask()` scope an inline mask.\n *\n * Transforms come in two flavours: a per-shape `rotation`/`scale` inside a shape's params is baked into that shape's\n * geometry before it joins the union, while graphics-level `.rotation(value, center?)` / `.scale(value, center?)`\n * transform the whole union about a pivot (default: its bounding-box centre). `opacity()` is also graphics-level: it\n * composites the whole drawn result as one layer, so a trailing `.opacity(0.4)` dims the union.\n *\n * `effects()` scopes like `fill()`: it applies to the shapes and paints accumulated since the previous `effects()` call\n * (or the start), then closes that group, so later shapes start fresh and unaffected. `.ellipse().ellipse().fill().effects(blur)`\n * blurs those two ellipses as one union while a following `.rect().fill()` stays crisp.\n */\nexport class Graphics2D {\n private _ops: GraphicsOp[] = [];\n private _opacity: number = 1;\n private _rotation: number = 0;\n private _scale: number = 1;\n private _transformCenter?: Alignment;\n\n rect(state: Partial<RectState> & ShapeAlignmentInput): this {\n this._ops.push({ kind: \"rect\", state });\n return this;\n }\n\n ellipse(state: Partial<EllipseState> & ShapeAlignmentInput): this {\n this._ops.push({ kind: \"ellipse\", state });\n return this;\n }\n\n path(state: Partial<PathState> | PathBuilder): this {\n const resolved = state instanceof PathBuilder ? state.toPathState() : state;\n this._ops.push({ kind: \"path\", state: resolved });\n return this;\n }\n\n line(state: Partial<LineState>): this {\n this._ops.push({ kind: \"line\", state });\n return this;\n }\n\n polygon(state: Partial<PolygonState> & ShapeAlignmentInput): this {\n this._ops.push({ kind: \"polygon\", state });\n return this;\n }\n\n polygram(state: Partial<PolygramState> & ShapeAlignmentInput): this {\n this._ops.push({ kind: \"polygram\", state });\n return this;\n }\n\n text(state: Partial<TextState> & ShapeAlignmentInput): this {\n this._ops.push({ kind: \"text\", state });\n return this;\n }\n\n richText(state: Partial<RichTextState> & ShapeAlignmentInput): this {\n this._ops.push({ kind: \"richText\", state });\n return this;\n }\n\n fill(fills: Fill): this {\n this._ops.push({ kind: \"fill\", fills });\n return this;\n }\n\n stroke(strokes: Stroke): this {\n this._ops.push({ kind: \"stroke\", strokes });\n return this;\n }\n\n shadow(shadows: Shadow): this {\n this._ops.push({ kind: \"shadow\", shadows });\n return this;\n }\n\n /** Uses the last-declared shape as a cutter: unions the shapes before it, subtracts it, and leaves the result as the current surface for subsequent shapes and paint. */\n cut(): this {\n this._ops.push({ kind: \"cut\" });\n return this;\n }\n\n /** Opens an inline mask scope: shapes until `applyMask()` are the mask, shapes after it are the content; close with `endMask()`. */\n mask(options?: MaskOptions): this {\n this._ops.push({ kind: \"mask\", options });\n return this;\n }\n\n applyMask(): this {\n this._ops.push({ kind: \"applyMask\" });\n return this;\n }\n\n endMask(): this {\n this._ops.push({ kind: \"endMask\" });\n return this;\n }\n\n /** Opacity of the whole graphics group (0-1): the entire drawn result composites into one layer at this alpha, so overlapping shapes don't double up. */\n opacity(opacity: number): this {\n this._opacity = opacity;\n return this;\n }\n\n /** Image effects for the current shape group, scoped like {@link fill}: shapes and paints since the previous `effects()` call (or the start) composite through the filter as one layer, so the effect reads the group's union silhouette (a blur bleeds across the combined edges). Closes the group: later shapes start fresh and unfiltered. Accepts an {@link Effect}, normalised to a `NodeEffect[]`. */\n effects(effects: Effect): this {\n this._ops.push({ kind: \"effects\", effects: effectsOps.resolve(effects) });\n return this;\n }\n\n /** Rotates the whole union (degrees) about `center` (an explicit {@link Vector2} or a named alignment resolved against the union's bounding box; default its centre), unlike a per-shape `rotation` inside a shape's params. */\n rotation(rotation: number, center?: Alignment): this {\n this._rotation = rotation;\n if (center !== undefined) this._transformCenter = center;\n return this;\n }\n\n /** Scales the whole union about `center`, as {@link rotation}. */\n scale(scale: number, center?: Alignment): this {\n this._scale = scale;\n if (center !== undefined) this._transformCenter = center;\n return this;\n }\n\n /** The recorded ops, in order. Consumed by `RenderContext2D.draw()`. */\n ops(): readonly GraphicsOp[] {\n return this._ops;\n }\n\n /** Graphics2D-level opacity (0–1) for the whole group. Default 1. */\n groupOpacity(): number {\n return this._opacity;\n }\n\n /** True when the whole graphics needs a composited layer (opacity < 1); each `effects` op scopes its own layer during replay (see {@link effects}). */\n needsGroupLayer(): boolean {\n return this._opacity < 1;\n }\n\n /** The union-level rotate/scale from {@link rotation} / {@link scale}, or `null` when both are identity; the renderer applies it as a canvas transform about `center` wrapping the drawn union. */\n groupTransform(): GraphicsTransform | null {\n if (this._rotation === 0 && this._scale === 1) return null;\n return { rotation: this._rotation, scale: this._scale, center: this._transformCenter };\n }\n\n /** True when there are no shape ops (only paint/compositing), so renderers can paint an externally-prepared surface (e.g. a boolean result) without resetting their shape accumulator. */\n isPaintOnly(): boolean {\n return !this._ops.some((op) => SHAPE_KINDS.has(op.kind));\n }\n\n /** A structural copy with its op list replaced and every group-level modifier carried over. A copy because a node may submit one `Graphics2D` more than once (`Text` draws the same ops for fill, overlay and stroke), each under different ambient state; rewriting the shared instance would leak one scope's resolution into the next. The seam `applyGraphicsTextDefaults` (see `render/text-defaults.ts`) folds inherited text defaults through. */\n /** @internal */\n _withOps(ops: GraphicsOp[]): Graphics2D {\n const next = new Graphics2D();\n next._ops = ops;\n next._opacity = this._opacity;\n next._rotation = this._rotation;\n next._scale = this._scale;\n next._transformCenter = this._transformCenter;\n return next;\n }\n}\n", "import type { Vector2 } from \"@/attributes/layout/vector2\";\n// Type-only, like `Color`: `render3d` is pure data and never reaches into the render or node layers at runtime (see SurfaceSource3D).\nimport type { Graphics2D } from \"@/render/graphics2d\";\nimport type { Node } from \"@/components/trees/node/node\";\nimport type { Node2D } from \"@/components/trees/2d/node2d\";\n\n/** How sampling behaves outside the 0–1 UV range. */\nexport type TextureWrap3D = \"clamp\" | \"repeat\" | \"mirror\";\n\n/** How texels are blended when the texture is scaled. */\nexport type TextureFilter3D = \"nearest\" | \"linear\";\n\n/** Colour space of the texture's data: `\"srgb\"` for colours an eye would see (albedo/`map`, `emissiveMap`), linearized before lighting; `\"linear\"` for data maps (`normalMap`, `roughnessMap`, `metalnessMap`, `aoMap`, `displacementMap`), which linearizing would corrupt. Each slot defaults correctly. */\nexport type TextureColorSpace3D = \"srgb\" | \"linear\";\n\n/** Sampler state shared by every texture source. */\nexport interface TextureOptions3D {\n wrapS?: TextureWrap3D;\n wrapT?: TextureWrap3D;\n /** UV scale. `[2, 2]` tiles twice on each axis (needs a `repeat` wrap). */\n repeat?: Vector2 | readonly [number, number];\n offset?: Vector2 | readonly [number, number];\n /** UV rotation in **degrees**, about {@link center}. */\n rotation?: number;\n center?: Vector2 | readonly [number, number];\n magFilter?: TextureFilter3D;\n minFilter?: TextureFilter3D;\n /** Sharpness at grazing angles. Clamped to the GPU's maximum. */\n anisotropy?: number;\n flipY?: boolean;\n colorSpace?: TextureColorSpace3D;\n}\n\n/** A texture from the project's asset manifest. `src` is found by the asset-tracking pass and requested through the ordinary image pipeline (as a 2D image fill), so pixels are resident before the frame draws. */\nexport interface ImageTexture3D extends TextureOptions3D {\n src: string;\n}\n\n/** Raw RGBA8888 bytes: the escape hatch for procedurally generated pixels (ramps, noise, LUTs, data as colour). */\nexport interface DataTexture3D extends TextureOptions3D {\n data: ArrayLike<number>;\n width: number;\n height: number;\n /** Bump to force a re-upload after mutating `data` in place (invisible to identity comparison). See {@link BufferGeometry3D.revision}. */\n revision?: number;\n}\n\n/**\n * A texture whose pixels are Motion Script's own 2D output, rasterized offscreen: puts a chart, readout or laid-out UI\n * onto 3D geometry. `source` is a value, a built {@link Graphics2D} or a `Node2D` subtree, supplied directly with no\n * indirection or tree placement.\n *\n * g3.plane({ map: Tex.surface(scopeGraphics, 1024, 640) })\n *\n * A `Node2D` source is adopted for binding by whatever paints the scene (asset catalog, inherited context, clock, so a\n * webfont shapes and an `<Image>` loads); it is never laid out or painted by the scene tree, only measured against\n * `width` x `height` and drawn into the buffer.\n *\n * **Hoist the source.** Building it inside the scene builder allocates a new subtree every frame (re-binding,\n * re-laying-out, defeating the texture cache, leaking). A hoisted source is a stable identity, so the renderer keys\n * the GPU texture off the source object (a `WeakMap`) and a source that goes out of scope becomes collectable.\n */\nexport interface SurfaceTexture3D extends TextureOptions3D {\n /** A built `Graphics2D`, or a `Node2D` subtree (typed structurally, see {@link SurfaceSource3D}). */\n source: SurfaceSource3D;\n /** Buffer width in pixels. This *is* the texture's resolution. */\n width: number;\n height: number;\n /**\n * Declares the source's pixels unchanging, so the buffer is rasterized once and reused. Set by `resolveFill3D` for a\n * fill chain; an author's own source is live by default, so an animated `Graphics2D` or prop-driven subtree works\n * with no bookkeeping. Needs {@link identity} to be cacheable.\n *\n * @internal\n */\n static?: boolean;\n /**\n * Cache identity for a synthesized source. An author's source is identified by the object itself (right for a hoisted\n * one); a source built for a fill is fresh every frame, so the value it was derived from supplies one.\n *\n * @internal\n */\n identity?: string;\n /** Ceiling on the buffer's device-pixel ratio, default 1 (the buffer is exactly `width` x `height`). A surface is sampled at whatever size the geometry occupies, so `width`/`height` is the real control; raise this only for a surface viewed close up that reads soft. */\n maxPixelRatio?: number;\n}\n\n/** What a {@link SurfaceTexture3D} paints from: a built {@link Graphics2D} or a {@link Node2D} subtree. Both imports are type-only: `render3d` is pure data, and a value import of `Node2D` would close a real cycle. Narrow with {@link resolveSurfaceSource}. */\nexport type SurfaceSource3D = Graphics2D | Node;\n\n// Declared against the dimension-agnostic base because that is what a built node is typed as, so\n// `Tex.surface(new Rect({ ... }), ...)` type-checks without a cast. It must be 2D in fact; `resolveSurfaceSource`\n// narrows, and a `Node3D` fails at render time.\n\n/** A {@link SurfaceSource3D} narrowed to the arm its renderer should take. */\nexport type ResolvedSurfaceSource =\n | { kind: \"graphics\"; graphics: Graphics2D }\n | { kind: \"node\"; node: Node2D };\n\n/** Narrows a surface source to the arm that draws it: a `Graphics2D` is replayed into a render context, a `Node2D` is laid out against the buffer and rendered. Structural, not `instanceof` (value imports would close the cycle): `Graphics2D` exposes `ops()` and a `Node2D` doesn't. */\nexport function resolveSurfaceSource(source: SurfaceSource3D): ResolvedSurfaceSource {\n return typeof (source as Graphics2D).ops === \"function\"\n ? { kind: \"graphics\", graphics: source as Graphics2D }\n : { kind: \"node\", node: source as Node2D };\n}\n\n/** A texture reference; a bare string is sugar for `{ src }` (`map: \"/wood.png\"`). */\nexport type Texture3D = string | ImageTexture3D | DataTexture3D | SurfaceTexture3D;\n\nexport function isDataTexture3D(texture: Texture3D): texture is DataTexture3D {\n return typeof texture !== \"string\" && \"data\" in texture;\n}\n\nexport function isSurfaceTexture3D(texture: Texture3D): texture is SurfaceTexture3D {\n return typeof texture !== \"string\" && \"source\" in texture;\n}\n\nexport function resolveTexture3D(texture: Texture3D): ImageTexture3D | DataTexture3D | SurfaceTexture3D {\n return typeof texture === \"string\" ? { src: texture } : texture;\n}\n\n/** The asset `src` a texture reads from, or `null` for a data or surface texture; the asset-tracking pass uses it, and `null` means \"nothing to request\". */\nexport function texture3DSource(texture: Texture3D): string | null {\n if (typeof texture === \"string\") return texture;\n if (isDataTexture3D(texture) || isSurfaceTexture3D(texture)) return null;\n return texture.src;\n}\n\n/** True for a string that names an asset rather than a colour: a leading `/` or `.` is a path, otherwise the extension decides. A bare name like `\"wood\"` is a colour, as the manifest couldn't resolve it either. */\nexport function looksLikeAssetPath(value: string): boolean {\n return value.startsWith(\"/\")\n || value.startsWith(\".\")\n || /\\.(png|jpe?g|webp|avif|svg|ktx2?|hdr|exr|mp4|webm|mov)$/i.test(value);\n}\n", "import { type Color, type NormalizedColor, parseColor } from \"@/attributes/shape/fill/color/parser\";\nimport { lerpColor } from \"@/attributes/shape/fill/lerp\";\nimport type { Fill } from \"@/attributes/shape/fill/chain\";\n// A value import, unlike the type-only ones in `texture.ts`: building the rect a fill chain paints into needs the\n// recorder. Safe because `render/graphics2d` reaches only the effects chain at runtime, never back into `render3d`.\nimport { Graphics2D } from \"@/render/graphics2d\";\nimport { looksLikeAssetPath } from \"./texture\";\nimport type { SurfaceSource3D, Texture3D } from \"./texture\";\n\nexport { looksLikeAssetPath };\n\n/** What a surface is made of: the same value a 2D `fill` takes (colour, gradient, image, video, noise, layer stack, and, since a `Node2D` subtree or `Graphics2D` is a fill too, any 2D content), so a mesh and a rect share one vocabulary. */\nexport type Fill3D = Color | Fill | Texture3D | SurfaceSource3D;\n\n/** What a {@link Fill3D} contributes to a material descriptor. */\nexport interface ResolvedFill3D {\n color?: Color;\n map?: Texture3D;\n}\n\n/** Sizing for the buffer a rich fill is rasterized into. */\nexport interface Fill3DOptions {\n /** Default 512. */\n width?: number;\n /** Default 512. */\n height?: number;\n}\n\nconst DEFAULT_SIZE = 512;\n\n/**\n * Resolves a {@link Fill3D} into the material fields it describes, by what the fill *is*: a **colour** stays a colour\n * (`material.color`, the common case, so it must not allocate a texture); a **texture** (asset path or `Texture3D`\n * descriptor) becomes `map`; **anything richer** (gradient, layer stack, `Node2D` subtree, `Graphics2D`, nested\n * `Scene3D`) is painted into an offscreen buffer and bound as `map` via the `Tex.surface` machinery. That last arm\n * makes the 2D and 3D fill vocabularies one: `Fills.canvas3D(scene)` in a chain renders 3D into a layer of a mesh's material.\n */\nexport function resolveFill3D(\n fill: Fill3D | undefined,\n options: Fill3DOptions = {},\n): ResolvedFill3D {\n if (fill === undefined || fill === null) return {};\n\n if (typeof fill === \"string\") {\n // A bare string is ambiguous between a colour and an asset path; resolved as the material handler resolved a `color` that looked like a file.\n return looksLikeAssetPath(fill) ? { map: fill } : { color: fill };\n }\n\n if (Array.isArray(fill)) {\n // A `Color` is also an array, of numbers; a fill chain is an array of layers (strings or objects).\n if (fill.every((entry) => typeof entry === \"number\")) {\n return { color: fill as unknown as Color };\n }\n return { map: rasterized(fill as Fill, options) };\n }\n\n if (typeof fill === \"object\") {\n if (isSurfaceSourceValue(fill)) return { map: surfaceFor(fill as SurfaceSource3D, options) };\n if (isTextureDescriptor(fill)) return { map: fill as Texture3D };\n if (isSolidLayer(fill)) return { color: (fill as { color: Color }).color };\n }\n\n return { map: rasterized(fill as Fill, options) };\n}\n\n/** A surface texture painting `source` directly. Identity comes from the source object, which `Tex.surface` already requires to be hoisted, so a source that goes out of scope stops being cached. */\nfunction surfaceFor(source: SurfaceSource3D, options: Fill3DOptions): Texture3D {\n return {\n source,\n width: options.width ?? DEFAULT_SIZE,\n height: options.height ?? DEFAULT_SIZE,\n };\n}\n\n/** A surface texture painting a fill chain into a rect that fills the buffer. Marked `static` with a derived identity: a chain describes the same pixels every frame unless one of its values moved, and without both a gradient on a cube would re-rasterize and re-upload a 512² buffer sixty times a second. A chain holding something live (a video layer, `Fills.canvas3D`) still re-rasterizes, as those carry object identity that `fillIdentity` folds in. */\nfunction rasterized(fill: Fill, options: Fill3DOptions): Texture3D {\n const width = options.width ?? DEFAULT_SIZE;\n const height = options.height ?? DEFAULT_SIZE;\n return {\n source: new Graphics2D().rect({ width, height }).fill(fill),\n width,\n height,\n static: true,\n identity: `fill:${fillIdentity(fill)}:${width}x${height}`,\n };\n}\n\nfunction isTextureDescriptor(value: object): boolean {\n return \"src\" in value || \"data\" in value || (\"source\" in value && \"width\" in value);\n}\n\n/** True for 2D content to be painted rather than a descriptor. Structural like `resolveSurfaceSource` (an `instanceof` would close a module cycle). A `Scene3D` also exposes `ops()` so it is excluded: it is a fill layer (`Fills.canvas3D`) and goes through the chain arm to composite with the rest of the stack. */\nfunction isSurfaceSourceValue(value: object): boolean {\n const bag = value as Record<string, unknown>;\n if (typeof bag.cameraDescriptor === \"function\") return false;\n if (typeof bag.ops === \"function\") return true;\n return typeof bag.id === \"string\" && typeof bag.attach === \"function\";\n}\n\nfunction isSolidLayer(value: object): boolean {\n const bag = value as Record<string, unknown>;\n if (bag.type !== \"solid\" || bag.color === undefined) return false;\n // Anything beyond the colour (opacity, blend, reference space) is a composite the colour slot can't express.\n return bag.opacity === undefined && bag.blend === undefined && bag.space === undefined;\n}\n\n/** Interpolates two fills. Colours interpolate; anything else holds the start and swaps at the end (there is no halfway between a gradient and a photograph; cross-fade with a stack and a tweened layer opacity, as in 2D). The colour test is cheap and allocation-free: resolving a rich fill builds a `Graphics2D` and texture descriptor, wasted on a tween that snaps. */\nexport function lerpFill3D(from: Fill3D, to: Fill3D, t: number): Fill3D {\n const start = asPlainColor(from);\n const end = asPlainColor(to);\n if (start !== null && end !== null) {\n return lerpColor(normalize(start), normalize(end), t) as unknown as Fill3D;\n }\n return t < 1 ? from : to;\n}\n\n/** The colour a fill *is*, or `null` when it is anything richer. No allocation. */\nfunction asPlainColor(fill: Fill3D | undefined): Color | null {\n if (fill === undefined || fill === null) return null;\n if (typeof fill === \"string\") return looksLikeAssetPath(fill) ? null : fill;\n if (Array.isArray(fill)) {\n return fill.every((entry) => typeof entry === \"number\") ? (fill as unknown as Color) : null;\n }\n if (typeof fill === \"object\" && isSolidLayer(fill)) return (fill as { color: Color }).color;\n return null;\n}\n\nfunction normalize(color: Color): NormalizedColor {\n return Array.isArray(color) ? (color as NormalizedColor) : parseColor(color);\n}\n\nconst objectIds = new WeakMap<object, string>();\nlet objectCounter = 0;\n\n/** A stable key for a fill value. Plain data is walked and sorted; anything with its own prototype (`Scene3D`, `Graphics2D`, video source) is keyed by object identity, cheaper than serialising and honest since two instances are two things. A `FillChain` is unwrapped first so building one inline gives the same key. */\nfunction fillIdentity(value: unknown): string {\n if (value === null || typeof value !== \"object\") return String(value);\n if (Array.isArray(value)) return `[${value.map(fillIdentity).join(\",\")}]`;\n\n const list = (value as { list?: unknown }).list;\n if (Array.isArray(list)) return fillIdentity(list);\n\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n let id = objectIds.get(value);\n if (id === undefined) {\n id = `@${objectCounter++}`;\n objectIds.set(value, id);\n }\n return id;\n }\n\n const bag = value as Record<string, unknown>;\n return `{${Object.keys(bag).sort().map((key) => `${key}:${fillIdentity(bag[key])}`).join(\",\")}}`;\n}\n", "import type { Graphics3DOp } from \"./graphics3d\";\nimport type { Material3D } from \"./material\";\n\n/** Development warnings for 3D inputs that are accepted, typed and recorded but acted on by no renderer: the post chain, HDR/EXR/cubemap environments, `params` on a geometry or environment, `extends` on a shader material, OBJ models. Each renders exactly like a scene without it, silently, which costs an afternoon; these say so once per session, in development, naming the input and what to do instead. Nothing here changes what is recorded. */\n\nconst warned = new Set<string>();\nlet development: boolean | undefined;\n\n/** Read once: in Node, `process.env` is a lookup per access. */\nfunction isDevelopment(): boolean {\n return (development ??= process.env.NODE_ENV !== \"production\");\n}\n\n/**\n * Print `message` once per `key`, in development only.\n * @internal\n */\nexport function warnInert3D(key: string, message: string): void {\n if (!isDevelopment() || warned.has(key)) return;\n warned.add(key);\n console.warn(`[motionscript] ${message}`);\n}\n\n/** Forget what has been warned, so a test can see the same warning again. @internal */\nexport function resetInertWarnings3D(): void {\n warned.clear();\n}\n\n/**\n * Check one recorded drawable for inputs the renderer ignores.\n * @internal\n */\nexport function inspectDrawable3D(op: Graphics3DOp): void {\n if (!isDevelopment()) return;\n\n if (\"geometry\" in op) {\n const params = op.geometry.params;\n if (params && Object.keys(params).length > 0) {\n warnInert3D(\n `geometry-params:${op.geometry.type}`,\n `\\`params\\` on a \"${op.geometry.type}\" geometry is not applied: three builds a geometry from its named fields and nothing assigns \\`params\\` onto it. `\n + \"Set the geometry's own fields instead. (`params` is applied on materials, lights and cameras.)\",\n );\n }\n }\n\n if (\"material\" in op) {\n const materials = Array.isArray(op.material) ? op.material : [op.material];\n for (const material of materials as readonly Material3D[]) {\n if (material.type === \"shader\" && material.extends != null) {\n warnInert3D(\n \"shader-extends\",\n `\\`extends: \"${material.extends}\"\\` on a shader material is not applied: the shader replaces the built-in model, so scene lighting, shadows and fog do not reach it. `\n + \"Write the lighting you need in the shader.\",\n );\n }\n }\n }\n\n if (op.kind === \"model\" && /\\.obj(?:$|[?#])/i.test(op.src)) {\n warnInert3D(\n \"model-obj\",\n `The model \"${op.src}\" is an OBJ file, and only glTF/GLB models load: it will draw nothing. Convert it to .glb.`,\n );\n }\n}\n", "import type { Color } from \"@/attributes/shape/fill/color/parser\";\nimport type {\n BoxGeometry3D, BufferGeometry3D, CapsuleGeometry3D, CircleGeometry3D, ConeGeometry3D,\n CylinderGeometry3D, ExtrudeGeometry3D, Geometry3D, LatheGeometry3D,\n PlaneGeometry3D, PolyhedronGeometry3D, RingGeometry3D, SphereGeometry3D,\n TorusGeometry3D, TorusKnotGeometry3D, TubeGeometry3D,\n} from \"./geometry\";\nimport type { Material3D, Shading3D } from \"./material\";\nimport type { Texture3D } from \"./texture\";\nimport { resolveFill3D, type Fill3D } from \"./fill3d\";\nimport { inspectDrawable3D } from \"./inert\";\nimport { type Transform3D, type Blend3D, type Faces3D } from \"./transform\";\nimport type { Vector3Input } from \"./vector3\";\n\n/** One clip of a model's baked animation, sampled at an explicit time. */\nexport interface ModelAnimation3D {\n /** Clip name, or its index in the file. Defaults to the first clip. */\n clip?: string | number;\n /** Seconds into the clip. **Explicit by design**: the renderer seeks to it rather than advancing by a delta, so animation is identical whether reached by playing forward or scrubbing back. */\n time: number;\n /** Blend weight, for cross-fading clips. Default 1. */\n weight?: number;\n}\n\n/** How a `line` op connects its points: in order, as disjoint start/end pairs, or in order and closed back to the start. */\nexport type LineMode3D = \"strip\" | \"segments\" | \"loop\";\n\n/** One recorded operation in a {@link Graphics3D} command list: what one node paints, like a `Graphics2D`. Hierarchy, lights and the camera are scene concerns recorded into a `Scene3D`. Geometry and material are inline sub-descriptors, not ops, since in a 3D graph they are properties of an object rather than children. */\nexport type Graphics3DOp =\n | { kind: \"mesh\"; geometry: Geometry3D; material: Material3D | readonly Material3D[]; transform?: Transform3D }\n | {\n kind: \"instances\";\n geometry: Geometry3D;\n material: Material3D;\n /** Per-instance placement. Length drives the instance count. */\n instances: readonly Transform3D[];\n /** Per-instance tint. Needs a material that reads instance colour. */\n colors?: readonly Color[];\n transform?: Transform3D;\n }\n | { kind: \"points\"; geometry: Geometry3D; material: Material3D; transform?: Transform3D }\n | {\n kind: \"line\";\n geometry: Geometry3D;\n material: Material3D;\n mode: LineMode3D;\n transform?: Transform3D;\n }\n | { kind: \"sprite\"; material: Material3D; transform?: Transform3D }\n | {\n kind: \"model\";\n src: string;\n animation?: readonly ModelAnimation3D[];\n /** Replace materials on the loaded graph, keyed by mesh or material name. */\n override?: Readonly<Record<string, Material3D>>;\n transform?: Transform3D;\n };\n\n/** Op kinds that put something in the scene; shared with `Scene3D` (this list plus `push`/`pop`/`light`/`camera`) so \"is anything drawn here\" has one definition. */\n/** @internal */\nexport const DRAWABLE_KINDS: ReadonlySet<string> = new Set([\n \"mesh\", \"light\", \"instances\", \"points\", \"line\", \"sprite\", \"model\",\n]);\n\n/**\n * Material fields promoted onto the geometry sugar methods so the common case is one flat call:\n * `.box({ width: 2, fill: \"red\", roughness: 0.3 })`. `fill` is the whole 2D fill vocabulary ({@link Fill3D}); the\n * rest is surface response rather than colour. These desugar at record time into a full {@link Material3D}\n * (`standard`, or `basic` when {@link unlit}), keeping the op list canonical. {@link material} bypasses the\n * shorthand; renderer-level knobs (`depthWrite`, `alphaTest`, `toneMapped`, `polygonOffset`, ...) live only there.\n */\nexport interface MaterialShorthand3D {\n /** A full descriptor (or an array, for multi-material). Wins over the rest. */\n material?: Material3D | readonly Material3D[];\n /** What the surface is made of: a colour, a texture, a gradient, 2D content. */\n fill?: Fill3D;\n opacity?: number;\n roughness?: number;\n metalness?: number;\n /** Self-illumination. Bloom in the post chain is what makes it glow. */\n emission?: Color;\n emissionStrength?: number;\n normalMap?: Texture3D;\n roughnessMap?: Texture3D;\n metalnessMap?: Texture3D;\n aoMap?: Texture3D;\n alphaMap?: Texture3D;\n envMapIntensity?: number;\n wireframe?: boolean;\n /** Facet or smooth shading. Default `\"smooth\"`. */\n shading?: Shading3D;\n /** Which faces to rasterize. Default `\"front\"`. */\n faces?: Faces3D;\n vertexColors?: boolean;\n blend?: Blend3D;\n /** Shade with an unlit `basic` material instead of `standard`. */\n unlit?: boolean;\n}\n\n/** Transform + material shorthand, accepted by every geometry sugar method. */\nexport type MeshShorthand3D = Transform3D & MaterialShorthand3D;\n\nconst TRANSFORM_KEYS = [\n \"position\", \"rotation\", \"quaternion\", \"scale\", \"lookAt\",\n \"visible\", \"shadow\", \"renderOrder\",\n] as const;\n\n/** Shorthand keys copied straight onto the built descriptor. `fill` is absent: it resolves into `color` and `map`, handled in {@link resolveMaterialShorthand3D}. */\nconst MATERIAL_SHORTHAND_KEYS = [\n \"opacity\", \"roughness\", \"metalness\",\n \"emission\", \"emissionStrength\", \"normalMap\", \"roughnessMap\",\n \"metalnessMap\", \"aoMap\", \"alphaMap\", \"envMapIntensity\", \"wireframe\",\n \"shading\", \"faces\", \"vertexColors\", \"blend\",\n] as const;\n\n/** Every key the shorthand owns, for stripping a geometry bag. */\nconst SHORTHAND_KEYS: readonly string[] = [...MATERIAL_SHORTHAND_KEYS, \"fill\", \"material\", \"unlit\"];\n\n/** Pulls the {@link Transform3D} fields out of a shorthand bag; `undefined` rather than `{}` when none, so the renderer can skip the matrix write. */\nfunction pickTransform(source: object): Transform3D | undefined {\n const bag = source as Record<string, unknown>;\n let out: Record<string, unknown> | undefined;\n for (const key of TRANSFORM_KEYS) {\n if (bag[key] !== undefined) (out ??= {})[key] = bag[key];\n }\n return out as Transform3D | undefined;\n}\n\n/**\n * Builds the material a shorthand bag describes; always one, so a drawable op never needs \"...or the default\"\n * handling. Exported because `Mesh3D` desugars the same bag from its props: one place decides how `fill` becomes\n * `color`-or-`map`, so a node and a builder call paint alike.\n *\n * @internal\n */\nexport function resolveMaterialShorthand3D(source: MaterialShorthand3D): Material3D | readonly Material3D[] {\n if (source.material !== undefined) return source.material;\n\n const material: Record<string, unknown> = { type: source.unlit ? \"basic\" : \"standard\" };\n\n const fill = resolveFill3D(source.fill);\n if (fill.color !== undefined) material.color = fill.color;\n if (fill.map !== undefined) material.map = fill.map;\n\n for (const key of MATERIAL_SHORTHAND_KEYS) {\n const value = (source as Record<string, unknown>)[key];\n if (value !== undefined) material[key] = value;\n }\n return material as unknown as Material3D;\n}\n\n/** Drop the shorthand/transform keys, leaving only a geometry's own params. */\nfunction pickGeometry<T>(source: object, type: string): T {\n const bag = source as Record<string, unknown>;\n const out: Record<string, unknown> = { type };\n for (const key in bag) {\n if (SHORTHAND_KEYS.includes(key)) continue;\n if ((TRANSFORM_KEYS as readonly string[]).includes(key)) continue;\n if (bag[key] !== undefined) out[key] = bag[key];\n }\n return out as T;\n}\n\n/** Geometry params only, with `type` and the inherited passthrough removed. */\ntype ParamsOf<G> = Omit<G, \"type\">;\n\n/**\n * What one 3D node draws: the `Graphics2D` of 3D. Records an ordered list of drawables (meshes, instanced meshes,\n * points, lines, sprites, models), each with its own geometry, material and local transform; camera, lights and\n * hierarchy belong to the `Node3D` tree and its scene. A built `Graphics3D` is spliced into a {@link RenderContext3D}.\n *\n * render: (ctx) => ctx.draw(new Graphics3D()\n * .box({ width: 2, cornerRadius: 0.15, fill: \"#e0533d\", roughness: 0.3 })),\n *\n * One flat bag, not chained paint: in 2D a `fill` is a group-scoped op over earlier shapes, but in 3D a material\n * belongs to exactly one object, so shape and material are stated together.\n *\n * Angles are DEGREES (Euler rotations, sweep arcs, UV rotation), matching 2D `rotation`; the renderer converts.\n *\n * Rebuilt from scratch every frame, so animation is reading the node's own state while building. A state entry\n * holding a non-number needs an explicit tween (`lerpVector3`, `lerpEuler3`, `slerpQuaternion`) or `to()` leaves it alone.\n *\n * Reconciliation identity is derived from the owning `Node3D` plus a signature of what the op draws; there is no `key` to set.\n *\n * Transforms and most material values are cheap in-place writes. Geometry parameters are not (three geometries are\n * immutable, so tweening `.box({ width })` reallocates every frame): scale the object instead. Fields marked\n * \"structural\" on `MaterialCommon3D` recompile the shader and should be set once.\n */\nexport class Graphics3D {\n private _ops: Graphics3DOp[] = [];\n\n /** Append one op, flagging (in development) inputs no renderer acts on. */\n private record(op: Graphics3DOp): void {\n inspectDrawable3D(op);\n this._ops.push(op);\n }\n\n /** Records a mesh from an explicit geometry and material; the sugar methods below funnel here. */\n mesh(\n geometry: Geometry3D,\n material?: Material3D | readonly Material3D[],\n transform?: Transform3D,\n ): this {\n this.record({\n kind: \"mesh\",\n geometry,\n material: material ?? { type: \"standard\" },\n transform,\n });\n return this;\n }\n\n /** Record a mesh from a geometry `type` plus a flat shorthand bag. */\n private sugar(type: Geometry3D[\"type\"], options?: MeshShorthand3D): this {\n const source: MeshShorthand3D = options ?? {};\n return this.mesh(\n pickGeometry<Geometry3D>(source, type),\n resolveMaterialShorthand3D(source),\n pickTransform(source),\n );\n }\n\n box(options?: ParamsOf<BoxGeometry3D> & MeshShorthand3D): this {\n return this.sugar(\"box\", options);\n }\n sphere(options?: ParamsOf<SphereGeometry3D> & MeshShorthand3D): this {\n return this.sugar(\"sphere\", options);\n }\n plane(options?: ParamsOf<PlaneGeometry3D> & MeshShorthand3D): this {\n return this.sugar(\"plane\", options);\n }\n cylinder(options?: ParamsOf<CylinderGeometry3D> & MeshShorthand3D): this {\n return this.sugar(\"cylinder\", options);\n }\n cone(options?: ParamsOf<ConeGeometry3D> & MeshShorthand3D): this {\n return this.sugar(\"cone\", options);\n }\n torus(options?: ParamsOf<TorusGeometry3D> & MeshShorthand3D): this {\n return this.sugar(\"torus\", options);\n }\n torusKnot(options?: ParamsOf<TorusKnotGeometry3D> & MeshShorthand3D): this {\n return this.sugar(\"torusKnot\", options);\n }\n circle(options?: ParamsOf<CircleGeometry3D> & MeshShorthand3D): this {\n return this.sugar(\"circle\", options);\n }\n ring(options?: ParamsOf<RingGeometry3D> & MeshShorthand3D): this {\n return this.sugar(\"ring\", options);\n }\n capsule(options?: ParamsOf<CapsuleGeometry3D> & MeshShorthand3D): this {\n return this.sugar(\"capsule\", options);\n }\n polyhedron(options: ParamsOf<PolyhedronGeometry3D> & MeshShorthand3D): this {\n return this.sugar(\"polyhedron\", options);\n }\n extrude(options: ParamsOf<ExtrudeGeometry3D> & MeshShorthand3D): this {\n return this.sugar(\"extrude\", options);\n }\n lathe(options: ParamsOf<LatheGeometry3D> & MeshShorthand3D): this {\n return this.sugar(\"lathe\", options);\n }\n tube(options: ParamsOf<TubeGeometry3D> & MeshShorthand3D): this {\n return this.sugar(\"tube\", options);\n }\n\n /** Records many copies of one geometry in a single draw call, for thousands of objects where a `mesh` per copy wouldn't keep up. */\n instances(\n geometry: Geometry3D,\n material: Material3D,\n instances: readonly Transform3D[],\n options?: { colors?: readonly Color[]; transform?: Transform3D },\n ): this {\n this.record({\n kind: \"instances\",\n geometry,\n material,\n instances,\n colors: options?.colors,\n transform: options?.transform,\n });\n return this;\n }\n\n /** Record a point cloud — one sprite-like dot per vertex of `geometry`. */\n points(\n geometry: Geometry3D,\n material?: Material3D,\n transform?: Transform3D,\n ): this {\n this.record({\n kind: \"points\",\n geometry,\n material: material ?? { type: \"points\" },\n transform,\n });\n return this;\n }\n\n /** Records a line from explicit `points` or a `geometry` (typically `Geo.edges(...)`). `closed` joins the last point to the first; `segments` treats points as disjoint start/end pairs, the form `Geo.edges(...)` produces. */\n line(options: {\n points?: readonly Vector3Input[];\n geometry?: Geometry3D;\n material?: Material3D;\n closed?: boolean;\n segments?: boolean;\n /** The line's paint. Cap and join have no meaning on a GL line. */\n stroke?: LineStroke3D;\n opacity?: number;\n transform?: Transform3D;\n } & Transform3D): this {\n const { points, geometry, material, closed, segments, stroke, opacity } = options;\n\n if (!points && !geometry) {\n throw new Error(\"Graphics3D.line() needs either `points` or `geometry`.\");\n }\n\n const resolved: Material3D = material ?? {\n type: stroke?.dash !== undefined ? \"lineDashed\" : \"lineBasic\",\n ...(stroke?.fill !== undefined ? { color: stroke.fill } : {}),\n ...(stroke?.weight !== undefined ? { width: stroke.weight } : {}),\n ...(stroke?.dash !== undefined\n ? { dashSize: stroke.dash[0], gapSize: stroke.dash[1] ?? stroke.dash[0] }\n : {}),\n ...(opacity !== undefined ? { opacity } : {}),\n } as Material3D;\n\n this.record({\n kind: \"line\",\n geometry: geometry ?? lineBuffer(points!),\n material: resolved,\n mode: segments ? \"segments\" : closed ? \"loop\" : \"strip\",\n transform: pickTransform(options),\n });\n return this;\n }\n\n /** Record a camera-facing textured quad. */\n sprite(options: { fill?: Fill3D; material?: Material3D; opacity?: number } & Transform3D): this {\n const { fill, material, opacity } = options;\n const paint = resolveFill3D(fill);\n const resolved: Material3D = material ?? {\n type: \"sprite\",\n ...(paint.map !== undefined ? { map: paint.map } : {}),\n ...(paint.color !== undefined ? { color: paint.color } : {}),\n ...(opacity !== undefined ? { opacity } : {}),\n } as Material3D;\n this.record({\n kind: \"sprite\",\n material: resolved,\n transform: pickTransform(options),\n });\n return this;\n }\n\n /** Records a loaded model. **glTF/GLB only**: any other format resolves to an empty slot and draws nothing (in development the first warns). Baked animation is sampled by explicit `time`, so a model stays frame-identical under scrubbing. */\n model(options: {\n src: string;\n animation?: ModelAnimation3D | readonly ModelAnimation3D[];\n override?: Readonly<Record<string, Material3D>>;\n } & Transform3D): this {\n const { src, animation, override } = options;\n this.record({\n kind: \"model\",\n src,\n animation: animation === undefined\n ? undefined\n : Array.isArray(animation) ? animation : [animation as ModelAnimation3D],\n override,\n transform: pickTransform(options),\n });\n return this;\n }\n\n /** The recorded ops, in order. Replayed by the renderer. */\n ops(): readonly Graphics3DOp[] {\n return this._ops;\n }\n\n /** True when this node draws nothing. */\n isEmpty(): boolean {\n return this._ops.length === 0;\n }\n}\n\n/** A 3D line's paint, mirroring the 2D `Stroke`. `cap`/`join` are absent (a GL line has no outline to cap); `weight` above 1 is ignored by most WebGL implementations, so draw a `tube` for a thick line. */\nexport interface LineStroke3D {\n /** The line's colour. Named `fill` to match the 2D `Stroke`. */\n fill?: Color;\n weight?: number;\n /** Dash and gap lengths, in world units. */\n dash?: readonly [number, number?];\n}\n\n/** The buffer each points array was last flattened into, and the revision it was uploaded under. */\nconst lineBuffers = new WeakMap<readonly Vector3Input[], { readonly position: Float32Array; readonly revision: number }>();\nlet lineRevision = 0;\n\n/** `points` as a line's buffer. The same array with the same values gets the same buffer and revision back, so an unchanged line uploads once; values are checked, so an in-place change still lands. */\nfunction lineBuffer(points: readonly Vector3Input[]): BufferGeometry3D {\n let kept = lineBuffers.get(points);\n if (!kept || !holds(kept.position, points)) {\n kept = { position: flattenPoints(points), revision: ++lineRevision };\n lineBuffers.set(points, kept);\n }\n return { type: \"buffer\", position: kept.position, revision: kept.revision };\n}\n\n/** Flatten `Vector3Input`s into the packed `[x, y, z, …]` a buffer wants. */\nfunction flattenPoints(points: readonly Vector3Input[]): Float32Array {\n const out = new Float32Array(points.length * 3);\n let i = 0;\n for (const point of points) {\n if (typeof point === \"number\") {\n out[i] = out[i + 1] = out[i + 2] = point;\n } else if (Array.isArray(point)) {\n out[i] = point[0] ?? 0;\n out[i + 1] = point[1] ?? 0;\n out[i + 2] = point[2] ?? 0;\n } else {\n const v = point as { x: number; y: number; z: number };\n out[i] = v.x ?? 0;\n out[i + 1] = v.y ?? 0;\n out[i + 2] = v.z ?? 0;\n }\n i += 3;\n }\n return out;\n}\n\n/** Whether `buffer` is what flattening `points` would give. */\nfunction holds(buffer: Float32Array, points: readonly Vector3Input[]): boolean {\n if (buffer.length !== points.length * 3) return false;\n let i = 0;\n for (const point of points) {\n let x: number, y: number, z: number;\n if (typeof point === \"number\") {\n x = y = z = point;\n } else if (Array.isArray(point)) {\n x = point[0] ?? 0;\n y = point[1] ?? 0;\n z = point[2] ?? 0;\n } else {\n const v = point as { x: number; y: number; z: number };\n x = v.x ?? 0;\n y = v.y ?? 0;\n z = v.z ?? 0;\n }\n if (buffer[i] !== Math.fround(x) || buffer[i + 1] !== Math.fround(y) || buffer[i + 2] !== Math.fround(z)) return false;\n i += 3;\n }\n return true;\n}\n", "import type { Graphics3D } from \"./graphics3d\";\nimport type { CameraData3D } from \"./camera\";\nimport type { LightData3D } from \"./light\";\nimport type {\n EnvironmentData3D, FogData3D, PostEffect3D, Shadows3D, ToneSettings3D,\n} from \"./scene-settings\";\nimport type { Transform3D } from \"./transform\";\nimport type { Color } from \"@/attributes/shape/fill/color/parser\";\n\n/** Per-node state for a `Node3D`'s draw scope, the 3D counterpart of `NodeRenderState`. No layout rect or motion: a 3D node's whole placement is its `transform`. */\nexport interface Node3DRenderState {\n /** Stable node identifier: keys the renderer's cache so a drawable survives a conditional sibling appearing or disappearing, where a positional index would renumber and rebuild the tail. */\n id: string;\n /** This node's placement relative to its parent. */\n transform?: Transform3D;\n}\n\n/**\n * The context passed to every `Node3D` when it draws itself: the 3D sibling of `RenderContext2D`, not its subclass\n * (they share no members: a 3D scene is a camera, lights and meshes, not paths, paint and clips). A {@link Graphics3D}\n * is what one node draws (geometry and material); everything belonging to the scene is a call on the context:\n *\n * protected renderSelf(ctx: RenderContext3D): void {\n * ctx.light({ type: \"ambient\", intensity: 0.4 });\n * }\n *\n * `begin(state)` / `end()` bracket each node's draw and carry its identity and placement, so nesting is the node\n * tree's and the renderer can cache per node. `Scene3D` is the shipped implementation, recording calls into a value\n * a backend replays.\n *\n * There is no `background`: behind a 3D scene is either a **2D fill** on the viewport (which composites correctly and\n * gets the whole fill chain) or a sky, part of {@link environment} since an HDRI that lights a scene is the panorama\n * seen behind it.\n */\nexport abstract class RenderContext3D {\n /** Opens a node draw scope, paired with {@link end}: everything recorded until then nests under this node and inherits its transform. */\n abstract begin(state: Node3DRenderState): void;\n\n abstract end(): void;\n\n abstract draw(graphics: Graphics3D): void;\n\n abstract light(light: LightData3D, transform?: Transform3D): void;\n\n /** Places the scene camera at the current scope. Recorded in the hierarchy, not as a scene-wide field, so a camera in a moving group is carried by it (composed like a mesh's world transform). No camera gets a default framing; with several, the last wins. */\n abstract camera(camera: CameraData3D): void;\n\n // Scene-wide settings have no position, so they are not hierarchical: a scene has one fog and one environment, and the last node to set one wins.\n\n /** Set the scene fog. A bare colour is sugar for `{ color }`; `null` clears it. */\n abstract fog(fog: FogData3D | Color | null): void;\n /** Set the image-based lighting environment and sky, or `null` for none. */\n abstract environment(environment: EnvironmentData3D | null): void;\n /** Enable/configure shadow casting for the whole scene. */\n abstract shadows(settings?: Shadows3D): void;\n /** Set tone mapping and exposure. */\n abstract tone(settings: ToneSettings3D): void;\n /** Append post-processing passes, applied in order after the scene renders. */\n abstract post(effects: PostEffect3D | readonly PostEffect3D[]): void;\n}\n", "import type { Color } from \"@/attributes/shape/fill/color/parser\";\nimport type { Passthrough3D } from \"./geometry\";\nimport type { Uniform3D } from \"./material\";\nimport type { Vector3Input } from \"./vector3\";\n\n/**\n /** Depth haze fading distant geometry toward a colour. One shape: {@link density} gives exponential fog, {@link near}/{@link far} linear. `color` is derived from the viewport's own fill when omitted; fog that doesn't match what is behind it reads as a grey wall, not distance. */\nexport interface FogData3D {\n color?: Color;\n /** Linear fog: distance at which fog begins. */\n near?: number;\n /** Linear fog: distance at which fog is total. */\n far?: number;\n /** Exponential-squared falloff. Wins over {@link near}/{@link far}. */\n density?: number;\n}\n\n/**\n * Image-based lighting and the sky it comes from, one control because an HDRI that lights a scene is the same\n * panorama seen behind it. A solid colour, gradient or flat image behind the scene is a **2D fill** on the\n * `Canvas3D`; only a sky that *reprojects* as the camera turns needs the 3D pass.\n *\n * What renders today: only {@link preset} `\"studio\"` (a neutral grey room generated per renderer). {@link src} and\n * {@link faces} are declared, tracked by the asset window and recorded, but no backend loads an HDR, EXR or cubemap,\n * so an environment naming only those lights nothing and draws no {@link background}. {@link params} is not applied\n * either. In development the first of each warns.\n */\nexport interface EnvironmentData3D extends Passthrough3D {\n /** A 360° panorama (`.hdr`/`.exr` for real IBL, or a plain image). **Not loaded yet**: see the type. */\n src?: string;\n /** Six faces in three's order: +X, −X, +Y, −Y, +Z, −Z. **Not loaded yet**: see the type. */\n faces?: readonly string[];\n /** A built-in studio interior. Needs no asset — the fastest way to good metal. The only environment that renders. */\n preset?: \"studio\";\n /** Multiplies the light received. Default 1. */\n intensity?: number;\n /** Rotate the panorama, in **degrees**. */\n rotation?: Vector3Input;\n /** Also draw it behind the scene, as an infinitely distant sky. Draws the `preset`; there is nothing to draw for `src`/`faces`. */\n background?: boolean;\n /** Blur applied to the background only, 0–1. Leaves the lighting sharp. */\n blur?: number;\n}\n\n/** Scene-wide shadow settings. `quality` stands in for the map resolution and filter three exposes separately (`pcf`, `pcfSoft`, `vsm`, `mapSize`), which are chosen together and aren't design decisions. Lights soften their own shadow; objects opt out with `shadow={false}`. Enabling shadows recompiles every receiving material, so treat it as setup, not something to animate. */\nexport interface ShadowSettings3D {\n enabled?: boolean;\n /** Default `\"medium\"`. */\n quality?: \"low\" | \"medium\" | \"high\";\n}\n\n/** Shadows as written on a viewport: a switch, or the settings. */\nexport type Shadows3D = boolean | ShadowSettings3D;\n\n/** Normalize a viewport's `shadows` prop. */\nexport function resolveShadows3D(value: Shadows3D | undefined): ShadowSettings3D | null {\n if (value === undefined || value === false) return null;\n if (value === true) return { enabled: true };\n return { enabled: true, ...value };\n}\n\n/** How HDR colour maps into displayable range: `\"aces\"` is the filmic default that handles bright highlights; `\"none\"` clips them. Materials opt out with `toneMapped: false` (UI-like overlays needing an exact colour). */\nexport type ToneMapping3D =\n | \"none\"\n | \"linear\"\n | \"reinhard\"\n | \"cineon\"\n | \"aces\"\n | \"agx\"\n | \"neutral\";\n\n/** Tone mapping and exposure, as a viewport carries them. */\nexport interface ToneSettings3D {\n mapping?: ToneMapping3D;\n /** Stops of exposure applied before mapping. Default 1. */\n exposure?: number;\n}\n\n/**\n * A full-frame post-processing pass after the scene renders. Short on purpose: a `Canvas3D` is a `Node2D`, so its\n * `effects` chain (vignette, grain, grading, blur, chromatic aberration) already runs over the composited result, and\n * viewport `antialias` does MSAA. What remains needs the 3D pass: `ssao` and `dof` read depth, `outline` reads object\n * ids, `bloom` reads **HDR radiance before tone mapping** (an emissive surface blooms here and merely brightens in 2D),\n * and `shaderPass` is the escape hatch. Post-processing forces an offscreen target, so any pass costs more than none.\n *\n * **No pass is applied yet.** The chain is recorded and read only to track the textures a `shaderPass` names; a scene\n * with `bloom` renders like one without, and so does every `params`. The first `post` set in development warns.\n * Meanwhile use the 2D `effects` of the `Canvas3D`.\n */\nexport type PostEffect3D =\n /** Bleeds light from bright pixels, in HDR. What makes `emission` actually glow. */\n | ({ type: \"bloom\"; strength?: number; radius?: number; threshold?: number } & Passthrough3D)\n /** Contact shadows in creases, from screen-space geometry. */\n | ({ type: \"ssao\"; radius?: number; intensity?: number } & Passthrough3D)\n | ({ type: \"outline\"; color?: Color; thickness?: number } & Passthrough3D)\n /** Depth of field. `focus` is the sharp distance, `aperture` the blur strength. */\n | ({ type: \"dof\"; focus?: number; aperture?: number; maxBlur?: number } & Passthrough3D)\n /** Anything expressible as one fragment pass inside the 3D composite. */\n | ({ type: \"shaderPass\"; fragment: string; uniforms?: Readonly<Record<string, Uniform3D>> } & Passthrough3D);\n", "import { DRAWABLE_KINDS, Graphics3D, type Graphics3DOp } from \"./graphics3d\";\nimport { RenderContext3D, type Node3DRenderState } from \"./render-context3d\";\nimport type { CameraData3D, OrthographicCameraData3D, PerspectiveCameraData3D } from \"./camera\";\nimport type { LightData3D } from \"./light\";\nimport {\n resolveShadows3D,\n type EnvironmentData3D, type FogData3D, type PostEffect3D,\n type ShadowSettings3D, type Shadows3D, type ToneSettings3D,\n} from \"./scene-settings\";\nimport { warnInert3D } from \"./inert\";\nimport type { Shadow3D, Transform3D } from \"./transform\";\nimport type { Color } from \"@/attributes/shape/fill/color/parser\";\n\n/** Options accepted by every `Camera3D` node and by {@link Scene3D.perspective}. */\ntype ParamsOf<T extends { type: string }> = Omit<T, \"type\">;\n\n/** One recorded operation: everything a node draws ({@link Graphics3DOp}) plus `push`/`pop` nesting, lights and the camera. */\nexport type Scene3DOp =\n | { kind: \"push\"; transform?: Transform3D }\n | { kind: \"pop\" }\n | { kind: \"light\"; light: LightData3D; transform?: Transform3D }\n | { kind: \"camera\"; camera: CameraData3D }\n | Graphics3DOp;\n\n/**\n * A recorded 3D scene and the {@link RenderContext3D} that records it (as `Graphics2D` is both builder and thing\n * handed to a backend): a `Node3D` tree draws into it, yielding a flat op list plus scene-wide settings that a\n * renderer replays. A `Canvas3D` normally opens one per frame; building one by hand lets a scene be shaded\n * through any 2D shape:\n *\n * const scene = new Scene3D().perspective({ distance: 6 }).draw(new Graphics3D().box({ fill: \"tomato\" }));\n * Text({ text: \"DEPTH\", fontSize: 320, fill: scene })\n *\n * A bare `Scene3D` coerces to a `canvas3D` fill, so `fill={scene}` and `fill={[\"#0b0d12\", scene]}` both work.\n */\nexport class Scene3D extends RenderContext3D {\n private _ops: Scene3DOp[] = [];\n private _camera: CameraData3D | null = null;\n private _fog: FogData3D | null = null;\n private _environment: EnvironmentData3D | null = null;\n private _shadows: ShadowSettings3D | null = null;\n private _tone: ToneSettings3D | null = null;\n private _post: PostEffect3D[] = [];\n /** Open `push` count, so {@link assertBalanced} can report a leak. */\n private _depth = 0;\n /** The `shadow` of each open node scope, innermost last; what a drawable stating none of its own takes. */\n private _shadowScopes: (Shadow3D | undefined)[] = [];\n\n override begin(state: Node3DRenderState): void {\n // The node's id rides on the transform's `key` (the renderer's identity slot), so a group is cached against the node that opened it, not its index among siblings.\n this._ops.push({ kind: \"push\", transform: { ...state.transform, key: state.id } });\n this._shadowScopes.push(state.transform?.shadow);\n this._depth++;\n }\n\n override end(): void {\n this._ops.push({ kind: \"pop\" });\n this._shadowScopes.pop();\n this._depth--;\n }\n\n /** Splices what a node draws into the scene at the current scope. Ops are copied: a `Graphics3D` is rebuilt every frame and the renderer walks a flat list. A drawable stating no `shadow` takes its node scope's, since a renderer reads casting/receiving off the mesh, never a group; a `shadow` on the op wins. */\n override draw(graphics: Graphics3D): this {\n const ops = graphics.ops();\n const scope = this._shadowScopes[this._shadowScopes.length - 1];\n for (let i = 0; i < ops.length; i++) {\n const op = ops[i];\n if (scope === undefined || op.transform?.shadow !== undefined) {\n this._ops.push(op);\n } else {\n this._ops.push({ ...op, transform: { ...op.transform, shadow: scope } });\n }\n }\n return this;\n }\n\n override light(light: LightData3D, transform?: Transform3D): this {\n this._ops.push({ kind: \"light\", light, transform });\n return this;\n }\n\n override camera(camera: CameraData3D): this {\n this._camera = camera;\n this._ops.push({ kind: \"camera\", camera });\n return this;\n }\n\n /** Set a perspective camera. The usual choice. */\n perspective(options?: ParamsOf<PerspectiveCameraData3D>): this {\n return this.camera({ type: \"perspective\", ...options } as PerspectiveCameraData3D);\n }\n\n /** Set an orthographic camera — parallel projection, for isometric looks. */\n orthographic(options?: ParamsOf<OrthographicCameraData3D>): this {\n return this.camera({ type: \"orthographic\", ...options } as OrthographicCameraData3D);\n }\n\n // Fields, not ops: a scene has one fog and one environment, and recording them positionally would imply an ordering that doesn't exist. Last writer wins.\n\n override fog(fog: FogData3D | Color | null): this {\n if (fog === null) {\n this._fog = null;\n } else if (typeof fog === \"object\" && !Array.isArray(fog)) {\n this._fog = fog as FogData3D;\n } else {\n this._fog = { color: fog as Color };\n }\n return this;\n }\n\n override environment(environment: EnvironmentData3D | null): this {\n if (environment) {\n if (environment.src !== undefined || (environment.faces?.length ?? 0) > 0) {\n warnInert3D(\n \"environment-src\",\n \"An environment's `src` and `faces` (HDR, EXR, cubemap) are recorded, and no backend loads them. Only `preset: \\\"studio\\\"` is rendered: \"\n + \"without a preset the scene gets no image-based light and its `background` is not drawn.\",\n );\n }\n if (environment.params && Object.keys(environment.params).length > 0) {\n warnInert3D(\n \"environment-params\",\n \"`params` on an environment is not applied: nothing assigns it onto the generated environment.\",\n );\n }\n }\n this._environment = environment;\n return this;\n }\n\n override shadows(settings?: Shadows3D): this {\n this._shadows = resolveShadows3D(settings ?? true);\n return this;\n }\n\n override tone(settings: ToneSettings3D): this {\n this._tone = settings;\n return this;\n }\n\n override post(effects: PostEffect3D | readonly PostEffect3D[]): this {\n const added = Array.isArray(effects) ? (effects as PostEffect3D[]) : [effects as PostEffect3D];\n if (added.length > 0) {\n warnInert3D(\n \"post\",\n `Post-processing (${added.map((effect) => `\"${effect.type}\"`).join(\", \")}) is recorded, and no backend applies a pass: the scene renders exactly as it would without \\`post\\`. `\n + \"Use the Canvas3D's 2D `effects` over the composited result instead.\",\n );\n }\n this._post.push(...added);\n return this;\n }\n\n /** The recorded ops, in order. Replayed by the renderer. */\n ops(): readonly Scene3DOp[] {\n return this._ops;\n }\n\n /** The camera, or `null` to let the renderer supply a default framing. */\n cameraDescriptor(): CameraData3D | null {\n return this._camera;\n }\n fogDescriptor(): FogData3D | null {\n return this._fog;\n }\n environmentDescriptor(): EnvironmentData3D | null {\n return this._environment;\n }\n shadowSettings(): ShadowSettings3D | null {\n return this._shadows;\n }\n toneSettings(): ToneSettings3D | null {\n return this._tone;\n }\n postEffects(): readonly PostEffect3D[] {\n return this._post;\n }\n\n /** True when nothing would be drawn (no mesh, light or other drawable); the node then skips the whole 3D pass. */\n isEmpty(): boolean {\n return !this._ops.some((op) => DRAWABLE_KINDS.has(op.kind));\n }\n\n /** Throws if `push` and `pop` are unbalanced, so a mismatched scope fails loudly rather than silently reparenting everything after it. A `Node3D` walk brackets `begin`/`end` itself, so this catches hand-built scenes. */\n assertBalanced(): void {\n if (this._depth !== 0) {\n const verb = this._depth > 0 ? \"unclosed begin()\" : \"extra end()\";\n throw new Error(\n `Scene3D has ${Math.abs(this._depth)} ${verb}.`,\n );\n }\n }\n}\n", "/** Backend seams for 3D runtime and resource loading. Core describes 3D scenes but can't import `three`, so it declares the capability here and the backend registers an implementation at module load (like `StorageAdapter`, `Ticker`; \"core owns *whether*, backend owns *how*\"). With no backend registered every function is an inert no-op, keeping core usable headless and in unit tests. */\n\nimport type { Disposer } from \"@/assets/record\";\n\n/** Loads the backend's 3D runtime. Idempotent and memoised by the backend. */\nexport type Canvas3DWarmup = () => Promise<void>;\n\n/** Loads a resource core can't decode itself; `kind` picks the backend loader and the returned {@link Disposer} frees the parsed result when the asset window moves past it. */\nexport type Canvas3DResourceKind = \"hdr\" | \"exr\" | \"gltf\" | \"obj\" | \"cubemap\";\nexport type Canvas3DResourceLoader = (kind: Canvas3DResourceKind, src: string) => Promise<Disposer>;\n\n/** The cache key a loader-backed resource is tracked and stored under. Stated once because **two packages must agree and neither owns both ends**: core's `declare3DResources` declares the key into the asset scope and the backend's loader later looks the parsed result up by it; a hand-built string could cache under a key nothing reads (a model that silently never appears). `src` goes last and unescaped (a URL may hold colons), so a reader splits on the first two separators and takes the rest whole; see {@link parseCanvas3DResourceKey}. */\nexport function canvas3DResourceKey(kind: Canvas3DResourceKind, src: string): string {\n return `three:${kind}:${src}`;\n}\n\n/** The `kind` and `src` a {@link canvas3DResourceKey} was built from, or `null` when the string isn't one. The backend's warm queue holds keys, not pairs, and `warmPendingCanvas3D` re-drives whatever is outstanding from only that. */\nexport function parseCanvas3DResourceKey(\n key: string,\n): { kind: Canvas3DResourceKind; src: string } | null {\n if (!key.startsWith(\"three:\")) return null;\n const rest = key.slice(\"three:\".length);\n const split = rest.indexOf(\":\");\n if (split <= 0) return null;\n return {\n kind: rest.slice(0, split) as Canvas3DResourceKind,\n src: rest.slice(split + 1),\n };\n}\n\nlet warmup: Canvas3DWarmup | null = null;\nlet resourceLoader: Canvas3DResourceLoader | null = null;\n\n/** Registers the 3D runtime loader; called by the backend before it draws, never at import. */\nexport function registerCanvas3DWarmup(fn: Canvas3DWarmup): void {\n warmup = fn;\n}\n\n/** Registers the loader for resource types core can't decode (HDR/EXR env maps, glTF/OBJ models); called once by the backend. */\nexport function registerCanvas3DResourceLoader(fn: Canvas3DResourceLoader): void {\n resourceLoader = fn;\n}\n\n/**\n * Kicks off loading the 3D runtime. `Canvas3D.declareAssets()` loads it through the asset timeline before any frame\n * draws, so the first 3D frame normally finds it resident and the render pass stays synchronous (the renderer keeps\n * a per-frame fallback).\n *\n * @internal\n */\nexport function warmCanvas3D(): Promise<void> | void {\n return warmup?.();\n}\n\n/** The registered resource loader, or `null` when no backend supplied one. @internal */\nexport function canvas3DResourceLoader(): Canvas3DResourceLoader | null {\n return resourceLoader;\n}\n\n/** True when a backend has registered a 3D runtime. @internal */\nexport function hasCanvas3DBackend(): boolean {\n return warmup !== null;\n}\n", "/** Structural walks over a built {@link Graphics3D} or {@link Scene3D}. {@link forEachTexture3D} sweeps for textures: asset discovery uses it during precomp to decide what to load and the renderer at paint time to find surface textures to rasterize first. One shared sweep stops the two drifting: a texture slot added to a material must be seen by both, or a map loads and never draws (or draws and never loads). */\n\nimport type { Graphics3D } from \"./graphics3d\";\nimport { Scene3D } from \"./scene3d\";\nimport type { Material3D } from \"./material\";\nimport { looksLikeAssetPath, type Texture3D } from \"./texture\";\n\n/** Material fields that hold a {@link Texture3D}. */\nexport const TEXTURE_KEYS: readonly string[] = [\n \"map\", \"alphaMap\", \"aoMap\", \"normalMap\", \"displacementMap\", \"envMap\",\n \"lightMap\", \"emissionMap\", \"roughnessMap\", \"metalnessMap\", \"specularMap\",\n \"gradientMap\", \"matcap\", \"clearcoatMap\", \"clearcoatNormalMap\",\n \"clearcoatRoughnessMap\", \"transmissionMap\", \"thicknessMap\",\n];\n\n/** True for a texture descriptor object (vs. a plain uniform value). Structural, as {@link Texture3D} has no `type` discriminant: each member is branded by its own payload key. */\nexport function isTextureLike(value: unknown): boolean {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return false;\n return \"src\" in value || \"data\" in value || \"source\" in value;\n}\n\n/** Visits every {@link Texture3D} a scene references (material map slots, shader and post-effect uniforms), duplicates included. Does **not** cover model/environment resources, which go through the backend's loader (see `declare3DResources`). */\nexport function forEachTexture3D(g3: Graphics3D | Scene3D, visit: (texture: Texture3D) => void): void {\n const uniforms = (bag: Record<string, unknown> | undefined): void => {\n if (!bag) return;\n for (const key in bag) {\n const value = bag[key];\n // A bare string is a texture path only when it looks like one; any other string is a colour uniform.\n if ((typeof value === \"string\" && looksLikeAssetPath(value)) || isTextureLike(value)) {\n visit(value as Texture3D);\n }\n }\n };\n\n const material = (value: Material3D | readonly Material3D[] | undefined): void => {\n if (value === undefined) return;\n const list = Array.isArray(value) ? value : [value as Material3D];\n for (const entry of list) {\n const bag = entry as unknown as Record<string, unknown>;\n for (const key of TEXTURE_KEYS) {\n if (bag[key] !== undefined) visit(bag[key] as Texture3D);\n }\n // A shader's uniforms can hold textures too.\n uniforms(bag.uniforms as Record<string, unknown> | undefined);\n }\n };\n\n for (const op of g3.ops()) {\n switch (op.kind) {\n case \"mesh\":\n case \"points\":\n case \"line\":\n case \"instances\":\n material(op.material);\n break;\n case \"sprite\":\n material(op.material);\n break;\n case \"model\":\n if (op.override) {\n for (const key in op.override) material(op.override[key]);\n }\n break;\n // push/pop/light reference no textures.\n }\n }\n\n // Only a whole scene has a post chain. The environment's panorama isn't visited: the backend's HDR/EXR loader handles it, declared by `trackEnvironment`.\n if (!(g3 instanceof Scene3D)) return;\n\n for (const effect of g3.postEffects()) {\n uniforms((effect as { uniforms?: Record<string, unknown> }).uniforms);\n }\n}\n", "/**\n * Cross-type fill coercion for tweening. The renderer dispatches by `fill.type`, so an in-between frame must be a\n * fully-formed fill of one concrete type: when a tween's endpoints differ, both are promoted to a common type, then\n * that type's `lerp` runs.\n *\n * - `color` is a degenerate gradient: against a gradient, the color expands into a uniform gradient (every stop that\n * color), which renders identically to the flat color, so frame 0 of color→gradient looks like the color.\n * - Two *different* gradient types share no geometry, so coerce toward the destination (`to`) type: colors/stops/opacity\n * interpolate while geometry adopts the destination's, snapped at frame 0.\n *\n * Coercion never mutates its input.\n */\n\nimport type { NormalizedColor } from \"./color/parser\";\nimport type { FillResolved, FillCommon, FillSpace } from \"./union\";\nimport type { BlendMode } from \"./blend\";\nimport type { SolidFillResolved } from \"./implementations/color\";\nimport type { LinearGradientFillResolved } from \"./implementations/linear-gradient\";\nimport type { RadialGradientFillResolved } from \"./implementations/radial-gradient\";\nimport type { ConicGradientFillResolved } from \"./implementations/conic-gradient\";\n\n/** Resolved fills that carry a `colors` array (every gradient variant), with {@link FillCommon} (`space`) mixed in as the registry's `FillResolved` does. */\ntype GradientResolved = FillCommon & (\n | LinearGradientFillResolved\n | RadialGradientFillResolved\n | ConicGradientFillResolved\n);\n\n/** Fill types that can participate in cross-type color/gradient tweening. */\nconst GRADIENT_TYPES = new Set<FillResolved[\"type\"]>([\n \"linear-gradient\",\n \"radial-gradient\",\n \"conic-gradient\",\n]);\n\nexport function isGradientType(type: FillResolved[\"type\"]): boolean {\n return GRADIENT_TYPES.has(type);\n}\n\n/** True if `a` and `b` can be tweened across differing types: each a color or gradient, at least one a gradient (same-type pairs never reach coercion). */\nexport function canCoerce(a: FillResolved, b: FillResolved): boolean {\n const aColorish = a.type === \"solid\" || isGradientType(a.type);\n const bColorish = b.type === \"solid\" || isGradientType(b.type);\n if (!aColorish || !bColorish) return false;\n // At least one gradient — color↔color is same-type and never reaches here.\n return isGradientType(a.type) || isGradientType(b.type);\n}\n\nfunction evenStops(count: number): number[] {\n return Array.from({ length: count }, (_, i) => i / Math.max(1, count - 1));\n}\n\n/** Expands a solid color into a `targetType` gradient with every stop that color, matching `stopCount` so it lerps cleanly against the real gradient. Geometry defaults match each gradient's `resolve()` so it renders as the flat color. */\nfunction colorToGradient(\n color: NormalizedColor,\n opacity: number | undefined,\n blend: BlendMode | undefined,\n space: FillSpace | undefined,\n targetType: GradientResolved[\"type\"],\n stopCount: number,\n): GradientResolved {\n const n = Math.max(2, stopCount);\n const colors: NormalizedColor[] = Array.from({ length: n }, () => [...color] as NormalizedColor);\n const stops = evenStops(n);\n const common = { colors, stops, opacity, blend, space };\n\n switch (targetType) {\n case \"linear-gradient\":\n return { type: \"linear-gradient\", ...common, start: { x: -1, y: 1 }, end: { x: 1, y: -1 } };\n case \"radial-gradient\":\n return { type: \"radial-gradient\", ...common, center: { x: 0, y: 0 }, radius: 100 };\n case \"conic-gradient\":\n return { type: \"conic-gradient\", ...common, center: { x: 0, y: 0 }, startAngle: 0 };\n }\n}\n\n/** Re-types a gradient as `targetType`, carrying colors/stops/opacity and adopting the target's default geometry (the geometries are not interpolatable). */\nfunction retypeGradient(\n g: GradientResolved,\n targetType: GradientResolved[\"type\"],\n): GradientResolved {\n if (g.type === targetType) return g;\n const common = { colors: g.colors, stops: g.stops, opacity: g.opacity, blend: g.blend, space: g.space };\n switch (targetType) {\n case \"linear-gradient\":\n return { type: \"linear-gradient\", ...common, start: { x: -1, y: 1 }, end: { x: 1, y: -1 } };\n case \"radial-gradient\":\n return { type: \"radial-gradient\", ...common, center: { x: 0, y: 0 }, radius: 100 };\n case \"conic-gradient\":\n return { type: \"conic-gradient\", ...common, center: { x: 0, y: 0 }, startAngle: 0 };\n }\n}\n\n/** Promotes two differing-type fills to a common type so the registry can lerp them; both results share `result[0].type`. Caller must have checked {@link canCoerce}. */\nexport function coercePair(a: FillResolved, b: FillResolved): [FillResolved, FillResolved] {\n const aIsColor = a.type === \"solid\";\n const bIsColor = b.type === \"solid\";\n\n // color → gradient: expand the color to match the gradient's type.\n if (aIsColor && !bIsColor) {\n const grad = b as GradientResolved;\n const expanded = colorToGradient(\n (a as SolidFillResolved).color, a.opacity, a.blend, a.space, grad.type, grad.colors.length,\n );\n return [expanded, grad];\n }\n // gradient → color: expand the color (b) to match the gradient's (a) type.\n if (bIsColor && !aIsColor) {\n const grad = a as GradientResolved;\n const expanded = colorToGradient(\n (b as SolidFillResolved).color, b.opacity, b.blend, b.space, grad.type, grad.colors.length,\n );\n return [grad, expanded];\n }\n\n // Two different gradient types: coerce toward the destination (b) type.\n const ga = a as GradientResolved;\n const gb = b as GradientResolved;\n return [retypeGradient(ga, gb.type), gb];\n}\n", "import { Color, NormalizedColor, parseColor } from '../color/parser';\nimport type { BlendMode } from '../blend';\nimport type { FillData } from '../registry';\nimport { lerpNumber } from '@/tween/lerp';\n\nexport interface SolidFillProp {\n type: 'solid';\n color: Color;\n opacity?: number;\n blend?: BlendMode;\n}\n\nexport interface SolidFillResolved {\n type: 'solid';\n color: NormalizedColor;\n opacity?: number;\n blend?: BlendMode;\n}\n\nexport const colorFill: FillData<SolidFillResolved> = {\n resolve: (prop: SolidFillProp) => ({\n type: 'solid',\n color: Array.isArray(prop.color)\n ? (prop.color as NormalizedColor)\n : parseColor(prop.color as string),\n opacity: prop.opacity,\n blend: prop.blend,\n }),\n lerp: (a, b, t) => ({\n color: [\n lerpNumber(a.color[0], b.color[0], t),\n lerpNumber(a.color[1], b.color[1], t),\n lerpNumber(a.color[2], b.color[2], t),\n lerpNumber(a.color[3], b.color[3], t),\n ],\n opacity: (a.opacity ?? 1) + ((b.opacity ?? 1) - (a.opacity ?? 1)) * t,\n }),\n equals: (a, b) => a.color === b.color,\n};\n", "import type { NormalizedColor } from './color/parser';\nimport { lerpColor } from './lerp';\n\n/** A colour ramp: `colors[i]` sits at `stops[i]` (ascending, 0 to 1). */\nexport interface ColorRamp {\n colors: NormalizedColor[];\n stops: number[];\n}\n\n/** The colour of `ramp` at `position`: clamped past either end, linear between stops. */\nfunction sampleRamp(ramp: ColorRamp, position: number): NormalizedColor {\n const { colors, stops } = ramp;\n const last = colors.length - 1;\n if (position <= stops[0]) return colors[0];\n if (position >= stops[last]) return colors[last];\n let hi = 1;\n while (stops[hi] < position) hi++;\n const lo = hi - 1;\n const span = stops[hi] - stops[lo];\n return lerpColor(colors[lo], colors[hi], span > 0 ? (position - stops[lo]) / span : 0);\n}\n\n/** The colour of `ramp` for the `k`-th of several stops sharing `position`: the ramp's own stop there when it has one (a hard edge keeps both sides), else the interpolated value. */\nfunction colorAt(ramp: ColorRamp, position: number, k: number): NormalizedColor {\n const first = ramp.stops.indexOf(position);\n if (first === -1) return sampleRamp(ramp, position);\n let count = 1;\n while (ramp.stops[first + count] === position) count++;\n return ramp.colors[first + Math.min(k, count - 1)];\n}\n\nconst sameStops = (a: number[], b: number[]) => a.length === b.length && a.every((s, i) => s === b[i]);\n\n/** Interpolates two colour ramps: same stop positions blend stop by stop; otherwise both are resampled onto the union of positions (a position either ramp doubles, as for a hard edge, stays doubled), so a 2-stop to 3-stop tween is the destination ramp at `t = 1`, not the source's stop count with the destination's colours merged in. */\nexport function lerpColorRamp(a: ColorRamp, b: ColorRamp, t: number): ColorRamp {\n if (sameStops(a.stops, b.stops)) {\n return {\n colors: a.colors.map((c, i) => lerpColor(c, b.colors[i], t)),\n stops: a.stops.slice(),\n };\n }\n const count = new Map<number, number>();\n for (const ramp of [a, b]) {\n const own = new Map<number, number>();\n for (const s of ramp.stops) own.set(s, (own.get(s) ?? 0) + 1);\n for (const [s, n] of own) count.set(s, Math.max(count.get(s) ?? 0, n));\n }\n const colors: NormalizedColor[] = [];\n const stops: number[] = [];\n for (const position of [...count.keys()].sort((x, y) => x - y)) {\n for (let k = 0; k < count.get(position)!; k++) {\n colors.push(lerpColor(colorAt(a, position, k), colorAt(b, position, k), t));\n stops.push(position);\n }\n }\n return { colors, stops };\n}\n", "import { Color, NormalizedColor, parseColor } from '../color/parser';\nimport type { BlendMode } from '../blend';\nimport type { FillData } from '../registry';\nimport { lerpColorRamp } from '../gradient-stops';\nimport { lerpVector2, Vector2 } from '@/attributes/layout/vector2';\n\nexport interface LinearGradientFillProp {\n type: 'linear-gradient';\n colors: Color[];\n stops?: number[];\n start?: Vector2;\n end?: Vector2;\n opacity?: number;\n blend?: BlendMode;\n}\n\nexport interface LinearGradientFillResolved {\n type: 'linear-gradient';\n colors: NormalizedColor[];\n stops: number[];\n start: Vector2;\n end: Vector2;\n opacity?: number;\n blend?: BlendMode;\n}\n\nfunction toNormalized(c: Color): NormalizedColor {\n return Array.isArray(c) ? (c as NormalizedColor) : parseColor(c as string);\n}\n\nexport const linearGradientFill: FillData<LinearGradientFillResolved> = {\n resolve: (prop: LinearGradientFillProp) => ({\n type: 'linear-gradient',\n colors: prop.colors.map(toNormalized),\n stops: prop.stops ?? prop.colors.map((_, i) => i / Math.max(1, prop.colors.length - 1)),\n start: prop.start ?? { x: -1, y: 1 },\n end: prop.end ?? { x: 1, y: -1 },\n opacity: prop.opacity,\n blend: prop.blend,\n }),\n lerp: (a, b, t) => ({\n ...lerpColorRamp(a, b, t),\n start: lerpVector2(a.start, b.start, t),\n end: lerpVector2(a.end, b.end, t),\n opacity: (a.opacity ?? 1) + ((b.opacity ?? 1) - (a.opacity ?? 1)) * t,\n }),\n equals: (a, b) =>\n a.start.x === b.start.x && a.start.y === b.start.y &&\n a.end.x === b.end.x && a.end.y === b.end.y &&\n a.colors.length === b.colors.length &&\n a.colors.every((c, i) => c === b.colors[i]),\n};\n", "import { Color, NormalizedColor, parseColor } from '../color/parser';\nimport type { BlendMode } from '../blend';\nimport type { FillData } from '../registry';\nimport { lerpColorRamp } from '../gradient-stops';\nimport { lerpNumber } from '@/tween/lerp';\nimport { lerpVector2, Vector2 } from '@/attributes/layout/vector2';\n\nexport interface RadialGradientFillProp {\n type: 'radial-gradient';\n colors: Color[];\n stops?: number[];\n center?: Vector2;\n radius?: number;\n opacity?: number;\n blend?: BlendMode;\n}\n\nexport interface RadialGradientFillResolved {\n type: 'radial-gradient';\n colors: NormalizedColor[];\n stops: number[];\n center: Vector2;\n radius: number;\n opacity?: number;\n blend?: BlendMode;\n}\n\nfunction toNormalized(c: Color): NormalizedColor {\n return Array.isArray(c) ? (c as NormalizedColor) : parseColor(c as string);\n}\n\nexport const radialGradientFill: FillData<RadialGradientFillResolved> = {\n resolve: (prop: RadialGradientFillProp) => ({\n type: 'radial-gradient',\n colors: prop.colors.map(toNormalized),\n stops: prop.stops ?? prop.colors.map((_, i) => i / Math.max(1, prop.colors.length - 1)),\n center: prop.center ?? { x: 0, y: 0 },\n radius: prop.radius ?? 100,\n opacity: prop.opacity,\n blend: prop.blend,\n }),\n lerp: (a, b, t) => ({\n ...lerpColorRamp(a, b, t),\n center: lerpVector2(a.center, b.center, t),\n radius: lerpNumber(a.radius, b.radius, t),\n opacity: lerpNumber(a.opacity ?? 1, b.opacity ?? 1, t),\n }),\n equals: (a, b) =>\n a.center.x === b.center.x && a.center.y === b.center.y &&\n a.radius === b.radius &&\n a.colors.length === b.colors.length &&\n a.colors.every((c, i) => c === b.colors[i]),\n};\n", "import { Color, NormalizedColor, parseColor } from '../color/parser';\nimport type { BlendMode } from '../blend';\nimport type { FillData } from '../registry';\nimport { lerpColorRamp } from '../gradient-stops';\nimport { lerpNumber } from '@/tween/lerp';\nimport { lerpVector2, Vector2 } from '@/attributes/layout/vector2';\n\nexport interface ConicGradientFillProp {\n type: 'conic-gradient';\n colors: Color[];\n stops?: number[];\n center?: Vector2;\n startAngle?: number;\n opacity?: number;\n blend?: BlendMode;\n}\n\nexport interface ConicGradientFillResolved {\n type: 'conic-gradient';\n colors: NormalizedColor[];\n stops: number[];\n center: Vector2;\n startAngle?: number;\n opacity?: number;\n blend?: BlendMode;\n}\n\nfunction toNormalized(c: Color): NormalizedColor {\n return Array.isArray(c) ? (c as NormalizedColor) : parseColor(c as string);\n}\n\nexport const conicGradientFill: FillData<ConicGradientFillResolved> = {\n resolve: (prop: ConicGradientFillProp) => ({\n type: 'conic-gradient',\n colors: prop.colors.map(toNormalized),\n stops: prop.stops ?? prop.colors.map((_, i) => i / Math.max(1, prop.colors.length - 1)),\n center: prop.center ?? { x: 0, y: 0 },\n startAngle: prop.startAngle,\n opacity: prop.opacity,\n blend: prop.blend,\n }),\n lerp: (a, b, t) => ({\n ...lerpColorRamp(a, b, t),\n center: lerpVector2(a.center, b.center, t),\n startAngle: lerpNumber(a.startAngle ?? 0, b.startAngle ?? 0, t),\n opacity: lerpNumber(a.opacity ?? 1, b.opacity ?? 1, t),\n }),\n equals: (a, b) =>\n a.center.x === b.center.x && a.center.y === b.center.y &&\n (a.startAngle ?? 0) === (b.startAngle ?? 0) &&\n a.colors.length === b.colors.length &&\n a.colors.every((c, i) => c === b.colors[i]),\n};\n", "import { Color, NormalizedColor, parseColor } from '../color/parser';\nimport type { BlendMode } from '../blend';\nimport type { FillData } from '../registry';\nimport { lerpNumber } from '@/tween/lerp';\nimport { Vector2 } from '@/attributes/layout/vector2';\n\n/** Sparse per-pixel speckle (dust, static, stipple), painted inside the shape's own path as another fill layer. Unlike `Effects.grain`, which modulates whatever was already drawn (children, or the backdrop), reach for this to texture one shape. For a continuous field (cloud, marble, smoke) see {@link FractalNoiseFillProp}. */\nexport interface NoiseFillProp {\n type: 'noise';\n size?: Vector2;\n density?: number;\n color?: Color;\n /** Random field offset; tween it to make the speckle crawl (otherwise the field is fixed). */\n seed?: number;\n opacity?: number;\n blend?: BlendMode;\n}\n\nexport interface NoiseFillResolved {\n type: 'noise';\n size: Vector2;\n density: number;\n color: NormalizedColor;\n seed: number;\n opacity?: number;\n blend?: BlendMode;\n}\n\nexport const noiseFill: FillData<NoiseFillResolved> = {\n resolve: (prop: NoiseFillProp) => {\n const raw = prop.color ?? ([0, 0, 0, 1] as NormalizedColor);\n return {\n type: 'noise',\n size: prop.size ?? { x: 1, y: 1 },\n density: prop.density ?? 1,\n color: Array.isArray(raw) ? (raw as NormalizedColor) : parseColor(raw as string),\n seed: prop.seed ?? 0,\n opacity: prop.opacity,\n blend: prop.blend,\n };\n },\n lerp: (a, b, t) => ({\n size: {\n x: lerpNumber(a.size.x, b.size.x, t),\n y: lerpNumber(a.size.y, b.size.y, t),\n },\n density: lerpNumber(a.density, b.density, t),\n seed: lerpNumber(a.seed, b.seed, t),\n color: [\n lerpNumber(a.color[0], b.color[0], t),\n lerpNumber(a.color[1], b.color[1], t),\n lerpNumber(a.color[2], b.color[2], t),\n lerpNumber(a.color[3], b.color[3], t),\n ],\n opacity: lerpNumber(a.opacity ?? 1, b.opacity ?? 1, t),\n }),\n equals: (a, b) =>\n a.size.x === b.size.x && a.size.y === b.size.y &&\n a.density === b.density &&\n a.seed === b.seed &&\n a.color[0] === b.color[0] && a.color[1] === b.color[1] &&\n a.color[2] === b.color[2] && a.color[3] === b.color[3],\n};\n", "import { Color, NormalizedColor, parseColor } from '../color/parser';\nimport type { BlendMode } from '../blend';\nimport type { FillData } from '../registry';\nimport { lerpColorRamp } from '../gradient-stops';\nimport { lerpNumber } from '@/tween/lerp';\nimport { lerpVector2, Vector2 } from '@/attributes/layout/vector2';\n\n/**\n * Which noise function the octaves are summed from: `'value'` (smoothed; cheapest and softest: clouds, haze, paper),\n * `'simplex'` (gradient; more even, the default for anything organic up close), `'ridged'` (simplex folded and inverted\n * so zero crossings become sharp crests: mountains, lightning, marble), `'worley'` (cellular distance field, giving\n * edges rather than blur: scales, cracked earth, caustics).\n */\nexport type FractalNoiseBasis = 'value' | 'simplex' | 'ridged' | 'worley';\n\n/** Fractal (fBm) noise, the procedural material source: unlike the per-pixel speckle of {@link NoiseFillProp}, a continuous *field* of octaves summed at rising frequency and falling amplitude (cloud, smoke, marble, terrain). Composes with the effect layer (`duotone` over it is marble, `threshold` an organic matte). `seed` shifts the whole field; tween `offset` instead to *travel* through it, which reads as flowing. */\nexport interface FractalNoiseFillProp {\n type: 'fractalNoise';\n /** Which noise function the octaves come from (default `'simplex'`). */\n basis?: FractalNoiseBasis;\n /** How many octaves are summed, 1–8 (default 4). Each one doubles the cost. */\n octaves?: number;\n /** Cycles of the first octave across the shape — a number, or per-axis (default 3). */\n frequency?: number | Vector2;\n /** Frequency multiplier per octave (default 2). */\n lacunarity?: number;\n /** Amplitude multiplier per octave; below 1 the detail fades in (default 0.5). */\n gain?: number;\n /** Field offset — random-access into the noise. Animate to drift. */\n seed?: number;\n /** Pan through the field, in cycles. Animate to make the pattern flow. */\n offset?: Vector2;\n /** Rotation of the field in degrees (default 0). */\n angle?: number;\n /** Colours the 0–1 field maps onto, low to high (default black → white). */\n colors?: Color[];\n /** Positions of each colour in 0–1 (default evenly spaced). */\n stops?: number[];\n /** Steepen (>1) or flatten (<1) the field before the ramp (default 1). */\n contrast?: number;\n opacity?: number;\n blend?: BlendMode;\n}\n\nexport interface FractalNoiseFillResolved {\n type: 'fractalNoise';\n basis: FractalNoiseBasis;\n octaves: number;\n frequency: Vector2;\n lacunarity: number;\n gain: number;\n seed: number;\n offset: Vector2;\n angle: number;\n colors: NormalizedColor[];\n stops: number[];\n contrast: number;\n opacity?: number;\n blend?: BlendMode;\n}\n\nfunction toNormalized(c: Color): NormalizedColor {\n return Array.isArray(c) ? (c as NormalizedColor) : parseColor(c as string);\n}\n\nconst BLACK: NormalizedColor = [0, 0, 0, 1];\nconst WHITE: NormalizedColor = [1, 1, 1, 1];\n\nconst toFrequency = (f: number | Vector2 | undefined): Vector2 =>\n f === undefined ? { x: 3, y: 3 } : typeof f === 'number' ? { x: f, y: f } : f;\n\nexport const fractalNoiseFill: FillData<FractalNoiseFillResolved> = {\n resolve: (prop: FractalNoiseFillProp) => {\n const colors = prop.colors?.length ? prop.colors.map(toNormalized) : [BLACK, WHITE];\n return {\n type: 'fractalNoise',\n basis: prop.basis ?? 'simplex',\n // Clamped here rather than in the shader so `equals` and the cache\n // key see the same value the renderer loops over.\n octaves: Math.max(1, Math.min(8, Math.round(prop.octaves ?? 4))),\n frequency: toFrequency(prop.frequency),\n lacunarity: prop.lacunarity ?? 2,\n gain: prop.gain ?? 0.5,\n seed: prop.seed ?? 0,\n offset: prop.offset ?? { x: 0, y: 0 },\n angle: prop.angle ?? 0,\n colors,\n stops: prop.stops ?? colors.map((_, i) => i / Math.max(1, colors.length - 1)),\n contrast: prop.contrast ?? 1,\n opacity: prop.opacity,\n blend: prop.blend,\n };\n },\n lerp: (a, b, t) => ({\n // The basis picks a different noise function entirely, so there is no\n // in-between field to cross to — snap, like every other enum-valued option.\n basis: t < 0.5 ? a.basis : b.basis,\n // Octave count bounds the shader's loop; a fractional one would round.\n octaves: t < 0.5 ? a.octaves : b.octaves,\n frequency: lerpVector2(a.frequency, b.frequency, t),\n lacunarity: lerpNumber(a.lacunarity, b.lacunarity, t),\n gain: lerpNumber(a.gain, b.gain, t),\n seed: lerpNumber(a.seed, b.seed, t),\n offset: lerpVector2(a.offset, b.offset, t),\n angle: lerpNumber(a.angle, b.angle, t),\n ...lerpColorRamp(a, b, t),\n contrast: lerpNumber(a.contrast, b.contrast, t),\n opacity: lerpNumber(a.opacity ?? 1, b.opacity ?? 1, t),\n }),\n equals: (a, b) =>\n a.basis === b.basis &&\n a.octaves === b.octaves &&\n a.frequency.x === b.frequency.x && a.frequency.y === b.frequency.y &&\n a.lacunarity === b.lacunarity &&\n a.gain === b.gain &&\n a.seed === b.seed &&\n a.offset.x === b.offset.x && a.offset.y === b.offset.y &&\n a.angle === b.angle &&\n a.contrast === b.contrast &&\n a.colors.length === b.colors.length &&\n a.colors.every((c, i) => {\n const d = b.colors[i];\n return d != null && c[0] === d[0] && c[1] === d[1] && c[2] === d[2] && c[3] === d[3];\n }) &&\n a.stops.length === b.stops.length &&\n a.stops.every((s, i) => s === b.stops[i]),\n};\n", "import { Color, NormalizedColor, parseColor } from '../color/parser';\nimport type { BlendMode } from '../blend';\nimport type { FillData } from '../registry';\nimport { lerpNumber } from '@/tween/lerp';\n\nexport interface StripeFillProp {\n type: 'stripe';\n gap?: number;\n strokeWidth?: number;\n angle?: number;\n color?: Color;\n opacity?: number;\n blend?: BlendMode;\n}\n\nexport interface StripeFillResolved {\n type: 'stripe';\n gap?: number;\n strokeWidth?: number;\n angle?: number;\n color?: NormalizedColor;\n opacity?: number;\n blend?: BlendMode;\n}\n\nexport const stripeFill: FillData<StripeFillResolved> = {\n resolve: (prop: StripeFillProp) => ({\n type: 'stripe',\n gap: prop.gap,\n strokeWidth: prop.strokeWidth,\n angle: prop.angle,\n color: prop.color != null\n ? Array.isArray(prop.color)\n ? (prop.color as NormalizedColor)\n : parseColor(prop.color as string)\n : undefined,\n opacity: prop.opacity,\n blend: prop.blend,\n }),\n lerp: (a, b, t) => ({\n gap: lerpNumber(a.gap ?? 8, b.gap ?? 8, t),\n strokeWidth: lerpNumber(a.strokeWidth ?? 1, b.strokeWidth ?? 1, t),\n angle: lerpNumber(a.angle ?? -45, b.angle ?? -45, t),\n color: a.color && b.color ? [\n lerpNumber(a.color[0], b.color[0], t),\n lerpNumber(a.color[1], b.color[1], t),\n lerpNumber(a.color[2], b.color[2], t),\n lerpNumber(a.color[3], b.color[3], t),\n ] : (a.color ?? b.color),\n opacity: lerpNumber(a.opacity ?? 1, b.opacity ?? 1, t),\n }),\n equals: (a, b) =>\n a.gap === b.gap &&\n a.strokeWidth === b.strokeWidth &&\n a.angle === b.angle &&\n a.color?.[0] === b.color?.[0] && a.color?.[1] === b.color?.[1] &&\n a.color?.[2] === b.color?.[2] && a.color?.[3] === b.color?.[3],\n};\n", "import { Color, NormalizedColor, parseColor } from '../color/parser';\nimport type { BlendMode } from '../blend';\nimport type { FillData } from '../registry';\nimport { lerpNumber } from '@/tween/lerp';\nimport { Vector2 } from '@/attributes/layout/vector2';\n\n/** A regular lattice of dots (graph paper, halftone look, a design tool's canvas backdrop). Measured in **pixels**, like {@link StripeFillProp} and unlike {@link GridFillProp}: a dot field is a texture, so its pitch shouldn't change when the shape is resized, and `offset` (sliding the lattice to parallax) is geometry that moving the node can't fake. Drawn from a shader, not a baked tile, so fractional values stay exact and animating costs a uniform write. */\nexport interface DotGridFillProp {\n type: 'dotGrid';\n /** Dot radius in px. Larger than half of {@link spacing} makes the dots merge. */\n radius?: number;\n /** Distance between one dot's centre and the next, in px, on both axes. */\n spacing?: number;\n /** Shifts the whole lattice, in px. Tween it to drift the field. */\n offset?: Vector2;\n color?: Color;\n opacity?: number;\n blend?: BlendMode;\n}\n\nexport interface DotGridFillResolved {\n type: 'dotGrid';\n radius: number;\n spacing: number;\n offset: Vector2;\n color: NormalizedColor;\n opacity?: number;\n blend?: BlendMode;\n}\n\n/** A 2px dot every 16px: reads as graph paper at 100% without dominating it. */\nconst DEFAULT_RADIUS = 2;\nconst DEFAULT_SPACING = 16;\n\nexport const dotGridFill: FillData<DotGridFillResolved> = {\n resolve: (prop: DotGridFillProp) => {\n const raw = prop.color ?? ([0, 0, 0, 1] as NormalizedColor);\n return {\n type: 'dotGrid',\n radius: prop.radius ?? DEFAULT_RADIUS,\n spacing: prop.spacing ?? DEFAULT_SPACING,\n offset: prop.offset ?? { x: 0, y: 0 },\n color: Array.isArray(raw) ? (raw as NormalizedColor) : parseColor(raw as string),\n opacity: prop.opacity,\n blend: prop.blend,\n };\n },\n lerp: (a, b, t) => ({\n radius: lerpNumber(a.radius, b.radius, t),\n spacing: lerpNumber(a.spacing, b.spacing, t),\n offset: {\n x: lerpNumber(a.offset.x, b.offset.x, t),\n y: lerpNumber(a.offset.y, b.offset.y, t),\n },\n color: [\n lerpNumber(a.color[0], b.color[0], t),\n lerpNumber(a.color[1], b.color[1], t),\n lerpNumber(a.color[2], b.color[2], t),\n lerpNumber(a.color[3], b.color[3], t),\n ],\n opacity: lerpNumber(a.opacity ?? 1, b.opacity ?? 1, t),\n }),\n equals: (a, b) =>\n a.radius === b.radius &&\n a.spacing === b.spacing &&\n a.offset.x === b.offset.x && a.offset.y === b.offset.y &&\n a.color[0] === b.color[0] && a.color[1] === b.color[1] &&\n a.color[2] === b.color[2] && a.color[3] === b.color[3],\n};\n", "import type { BlendMode } from '../blend';\nimport type { FillData } from '../registry';\nimport {\n lerpUniformRecord,\n normalizeUniforms,\n uniformRecordsEqual,\n type ShaderUniform,\n type ShaderUniformRecord,\n} from '../../shaders/uniforms';\nimport { shaderContractOf, type ShaderLanguage } from '../../shaders/language';\n\n/** Ceiling on bound textures: more than a handful is really a 3D scene, and the cap stops a typo in a generated list exhausting texture units. */\nconst MAX_TEXTURES = 4;\n\nexport interface ShaderTexture {\n /** The name the shader pack gives this texture. */\n name: string;\n /** Asset path, resolved like any other image fill's `src`. */\n src: string;\n}\n\n/**\n * A custom WGSL shader painted as a fill. The source defines `fn fill(in: FillIn) -> vec4f` returning **premultiplied**\n * rgba; `in` carries `uv` (0-1 across the box), `local` (px from the top-left), `size`, `time` and `scale` (device px\n * per px), and uniforms are `u`, a `struct Params` it declares. The first of `textures` is what `sample_texture(uv)`\n * reads. It must *not* fold `opacity` in: the layer's opacity is already applied, so doing it again squares it.\n *\n * `source` is the compile-cache key, so it **snaps** at a tween's midpoint (tweening it would compile a program per\n * frame): hoist it to module scope and put everything that changes in a uniform, an in-place write.\n *\n * Rect({ fill: Fills.shader(src, { uniforms: { amount: 0.4 } }) })\n */\nexport interface ShaderFillProp {\n type: 'shader';\n /** The program. Hoist it; don't rebuild it per frame. */\n source: string;\n /** The language `source` is written in; WGSL when absent. */\n language?: ShaderLanguage;\n /** WGSL only: the contract version it is written against (`WGSL_CONTRACT` when absent). */\n contract?: number;\n /**\n * The shader pack this was built from. **Reserved, carried rather than read**: a pack resolves to plain uniforms\n * first, so the frame is identical with or without it. It exists for the trip back: a host reopening a saved scene\n * needs it to redraw the property panel. An id naming an unregistered pack is **not** an error: the shader still\n * renders, the host just cannot offer the panel.\n */\n shaderId?: string;\n /** Uniform values keyed by declared name; the positional `[{name, value}]` array is accepted too so a shader moves between an effect and a fill unchanged. */\n uniforms?: ShaderUniformRecord | readonly ShaderUniform[];\n textures?: readonly ShaderTexture[];\n opacity?: number;\n blend?: BlendMode;\n}\n\nexport interface ShaderFillResolved {\n type: 'shader';\n source: string;\n language: ShaderLanguage;\n contract?: number;\n shaderId?: string;\n uniforms: ShaderUniformRecord;\n textures?: ShaderTexture[];\n opacity?: number;\n blend?: BlendMode;\n}\n\nfunction resolveTextures(textures: readonly ShaderTexture[] | undefined): ShaderTexture[] | undefined {\n if (!textures?.length) return undefined;\n const out: ShaderTexture[] = [];\n for (const texture of textures) {\n if (!texture?.name || !texture?.src) continue;\n if (out.length >= MAX_TEXTURES) {\n console.warn(`[shader] A shader fill declares more than ${MAX_TEXTURES} textures; the rest are ignored.`);\n break;\n }\n out.push({ name: texture.name, src: texture.src });\n }\n return out.length ? out : undefined;\n}\n\nfunction withContract(shader: { language?: string; contract?: number }): { contract?: number } {\n const contract = shaderContractOf(shader);\n return contract === undefined ? {} : { contract };\n}\n\nfunction texturesEqual(a: ShaderTexture[] | undefined, b: ShaderTexture[] | undefined): boolean {\n if (a === b) return true;\n if (!a || !b || a.length !== b.length) return false;\n return a.every((t, i) => t.name === b[i].name && t.src === b[i].src);\n}\n\nexport const shaderFill: FillData<ShaderFillResolved> = {\n resolve: (prop: ShaderFillProp) => ({\n type: 'shader',\n source: prop.source ?? '',\n // A stored document may still say \"sksl\"; carried so the renderer can report it.\n language: prop.language ?? 'wgsl',\n ...withContract(prop),\n // Carried, never read: see `ShaderFillProp.shaderId`. Omitted when absent\n // so `equals` compares like with like for a fill that never had one.\n ...(prop.shaderId !== undefined ? { shaderId: prop.shaderId } : {}),\n // Normalised and key-sorted here (not at paint time) so `equals` and structural diffs see the canonical record the renderer binds.\n uniforms: normalizeUniforms(prop.uniforms),\n textures: resolveTextures(prop.textures),\n opacity: prop.opacity,\n blend: prop.blend,\n }),\n\n // `source` and `textures` snap; only uniform values and `opacity` interpolate (the source is the compile-cache key, so\n // there is nothing halfway between programs). Returns neither `type` nor `blend`: `FillResult` omits both and `lerpFill`\n // reassembles via `{ ...a, ...lerp(...) }`, which also makes the ragged-array self-pair work.\n lerp: (a, b, t) => ({\n source: t < 0.5 ? a.source : b.source,\n language: t < 0.5 ? a.language : b.language,\n ...withContract(t < 0.5 ? a : b),\n uniforms: lerpUniformRecord(a.uniforms, b.uniforms, t),\n textures: t < 0.5 ? a.textures : b.textures,\n opacity: (a.opacity ?? 1) + ((b.opacity ?? 1) - (a.opacity ?? 1)) * t,\n }),\n\n equals: (a, b) =>\n a.source === b.source &&\n a.contract === b.contract &&\n uniformRecordsEqual(a.uniforms, b.uniforms) &&\n texturesEqual(a.textures, b.textures),\n\n // Runs off the same descriptors the renderer binds, so what gets loaded can't\n // drift from what gets sampled.\n declare: (fill, assets) => {\n for (const texture of fill.textures ?? []) assets.image(texture.src);\n },\n};\n", "/** Asset discovery for 3D scenes: walks a {@link Graphics3D}'s or {@link Scene3D}'s descriptors for referenced resources and declares them into an {@link AssetScope}, so the asset timeline to `AssetManager.loadAt` chain has them resident before the frame renders, which keeps the 3D draw synchronous. It runs off the same descriptors the render consumes (the node builds its `Graphics3D` through one method both paths call), so what loads can't drift from what draws. */\n\nimport type { AssetScope } from \"@/assets/scope\";\nimport type { LoaderFn } from \"@/assets/record\";\nimport type { Graphics3D } from \"./graphics3d\";\nimport { Scene3D } from \"./scene3d\";\nimport type { Geometry3D } from \"./geometry\";\nimport type { EnvironmentData3D } from \"./scene-settings\";\nimport { isSurfaceTexture3D, resolveSurfaceSource, texture3DSource } from \"./texture\";\nimport {\n canvas3DResourceKey, canvas3DResourceLoader,\n type Canvas3DResourceKind, type Canvas3DResourceLoader,\n} from \"./resources\";\nimport { forEachTexture3D } from \"./walk\";\n\n/** Declares every asset a 3D scene or drawable list needs: textures as images, models and environment panoramas through the backend's loader, each `Tex.surface` node source as a subtree of the declaring node. A `Graphics2D` surface source declares nothing. */\nexport function declare3DResources(g3: Graphics3D | Scene3D, assets: AssetScope): void {\n forEachTexture3D(g3, (value) => {\n if (isSurfaceTexture3D(value)) {\n const source = resolveSurfaceSource(value.source);\n if (source.kind === \"node\") assets.subtree(source.node);\n return;\n }\n const src = texture3DSource(value);\n if (src !== null) assets.image(src);\n });\n\n const geometry = (value: Geometry3D | undefined): void => {\n if (value === undefined) return;\n if (value.type === \"modelGeometry\") {\n declareLoader(\"gltf\", value.src, assets);\n } else if (value.type === \"edges\" || value.type === \"wireframe\") {\n geometry(value.source);\n }\n };\n\n for (const op of g3.ops()) {\n switch (op.kind) {\n case \"mesh\":\n case \"points\":\n case \"line\":\n case \"instances\":\n geometry(op.geometry);\n break;\n case \"model\":\n declareLoader(\"gltf\", op.src, assets);\n break;\n }\n }\n\n if (g3 instanceof Scene3D) declareEnvironment(g3.environmentDescriptor(), assets);\n}\n\n/** An environment's panoramas. A `preset` is generated and needs nothing. */\nexport function declareEnvironment(\n environment: Pick<EnvironmentData3D, \"src\" | \"faces\"> | null,\n assets: AssetScope,\n): void {\n if (environment === null) return;\n if (environment.src !== undefined) declareLoader(hdrKind(environment.src), environment.src, assets);\n for (const face of environment.faces ?? []) declareLoader(hdrKind(face), face, assets);\n}\n\n// Stable per backend loader and key, so declaring a resource again hands the scope\n// the same function rather than tripping its conflicting-loader check.\nconst resourceLoads = new WeakMap<Canvas3DResourceLoader, Map<string, LoaderFn>>();\n\nfunction declareLoader(kind: Canvas3DResourceKind, src: string, assets: AssetScope): void {\n const load = canvas3DResourceLoader();\n if (!load) return;\n const key = canvas3DResourceKey(kind, src);\n let byKey = resourceLoads.get(load);\n if (!byKey) resourceLoads.set(load, (byKey = new Map()));\n let fn = byKey.get(key);\n if (!fn) byKey.set(key, (fn = () => load(kind, src)));\n assets.loader(key, fn);\n}\n\nfunction hdrKind(src: string): Canvas3DResourceKind {\n const lower = src.toLowerCase();\n if (lower.endsWith(\".exr\")) return \"exr\";\n return \"hdr\";\n}\n", "import type { BlendMode } from '../blend';\nimport type { FillData } from '../registry';\nimport type { Scene3D } from '@/render3d/scene3d';\nimport { declare3DResources } from '@/render3d/tracking';\n\n/** A 3D scene painted as a fill: the renderer draws it to a texture and shades the shape's own path with it, so it clips to whatever painted it, stacks with other fills and inherits the layer's `opacity`/`blend`/`space`. The payload is a **built** {@link Scene3D}, never a builder callback: freshness comes from where the value is produced (a `renderSelf`, or a `() => …` binding), as for every other fill. */\nexport interface Canvas3DFillProp {\n type: 'canvas3D';\n scene: Scene3D;\n /** Ceiling on the 3D buffer's device-pixel ratio (default 2), so a high-scale export doesn't allocate a quadratically larger buffer (a 4× export of a 1080p shape would ask for 16×). */\n maxPixelRatio?: number;\n /** Multisample the 3D pass. Default true. */\n antialias?: boolean;\n opacity?: number;\n blend?: BlendMode;\n}\n\nexport interface Canvas3DFillResolved {\n type: 'canvas3D';\n scene: Scene3D;\n maxPixelRatio?: number;\n antialias?: boolean;\n opacity?: number;\n blend?: BlendMode;\n}\n\nexport const canvas3DFill: FillData<Canvas3DFillResolved> = {\n // Nothing to normalise — the defaults for maxPixelRatio/antialias are applied\n // at render time so the resolved shape stays minimal and comparable.\n resolve: (prop: Canvas3DFillProp) => ({ ...prop }),\n\n // A scene is a command list with no value halfway between two, so it snaps like an image fill's `src`; only `opacity` interpolates. Returns neither `type` nor `blend`: `FillResult` omits both and `lerpFill` reassembles via `{ ...a, ...lerp(...) }`, which also makes the ragged-array self-pair work.\n lerp: (a, b, t) => ({\n scene: t < 0.5 ? a.scene : b.scene,\n maxPixelRatio: a.maxPixelRatio ?? b.maxPixelRatio,\n antialias: a.antialias ?? b.antialias,\n opacity: (a.opacity ?? 1) + ((b.opacity ?? 1) - (a.opacity ?? 1)) * t,\n }),\n\n // Reference identity is the only comparison a Scene3D supports (no structural hash; `ops()` returns its live array).\n equals: (a, b) => a.scene === b.scene,\n\n // Runs off the same descriptors the renderer consumes, so what gets loaded\n // cannot drift from what gets drawn.\n declare: (fill, assets) => {\n declare3DResources(fill.scene, assets);\n },\n};\n", "import type { AssetScope } from \"@/assets/scope\";\nimport { FillProp, FillResolved, FillSpace } from \"./union\";\nimport { Fill, resolveChainFill } from \"./chain\";\nimport { canCoerce, coercePair } from \"./coerce\";\nimport type { AttributeOps } from \"@/attributes/shared/operators\";\n\nimport { colorFill } from \"./implementations/color\";\nimport { linearGradientFill } from \"./implementations/linear-gradient\";\nimport { radialGradientFill } from \"./implementations/radial-gradient\";\nimport { conicGradientFill } from \"./implementations/conic-gradient\";\nimport { noiseFill } from \"./implementations/noise\";\nimport { fractalNoiseFill } from \"./implementations/fractal-noise\";\nimport { stripeFill } from \"./implementations/stripe\";\nimport { dotGridFill } from \"./implementations/dot-grid\";\nimport { gridFill } from \"./implementations/grid\";\nimport { shaderFill } from \"./implementations/shader\";\nimport { imageFill } from \"./implementations/image\";\nimport { videoFill } from \"./implementations/video\";\nimport { canvas3DFill } from \"./implementations/canvas3d\";\n// The one value import from `render3d` into the fill layer (bare-scene coercion in `resolveFill`); acyclic since `render3d` imports `Color` back type-only.\nimport { Scene3D } from \"@/render3d/scene3d\";\n\ntype FillResult<T extends FillResolved> = Omit<Omit<T, \"type\">, \"blend\">;\n\nexport interface FillData<T extends FillResolved> {\n resolve(prop: any): T;\n equals(a: T, b: T): boolean;\n lerp(from: FillResult<T>, to: FillResult<T>, t: number): FillResult<T>;\n declare?(fill: T, assets: AssetScope): void;\n}\n\nconst FILLS = new Map<string, FillData<FillResolved>>([\n [\"solid\", colorFill as FillData<FillResolved>],\n [\"linear-gradient\", linearGradientFill as FillData<FillResolved>],\n [\"radial-gradient\", radialGradientFill as FillData<FillResolved>],\n [\"conic-gradient\", conicGradientFill as FillData<FillResolved>],\n [\"noise\", noiseFill as FillData<FillResolved>],\n [\"fractalNoise\", fractalNoiseFill as FillData<FillResolved>],\n [\"stripe\", stripeFill as FillData<FillResolved>],\n [\"dotGrid\", dotGridFill as FillData<FillResolved>],\n [\"grid\", gridFill as FillData<FillResolved>],\n [\"shader\", shaderFill as FillData<FillResolved>],\n [\"image\", imageFill as FillData<FillResolved>],\n [\"video\", videoFill as FillData<FillResolved>],\n [\"canvas3D\", canvas3DFill as FillData<FillResolved>],\n]);\n\nfunction get(name: string): FillData<FillResolved> {\n const data = FILLS.get(name);\n if (!data) throw new Error(`Fill \"${name}\" is not registered`);\n return data;\n}\n\nexport function resolveFill(prop: FillProp): FillResolved {\n if (typeof prop === \"string\") return resolveFill({ type: \"solid\", color: prop });\n // A bare built scene is shorthand for a 3D fill, the same way a bare CSS\n // string is shorthand for a solid one.\n if (prop instanceof Scene3D) return resolveFill({ type: \"canvas3D\", scene: prop });\n const resolved = get(prop.type).resolve(prop);\n // `space` is a cross-cutting rendering directive (like `blend`); carry it\n // through generically so each fill `resolve()` doesn't have to know about it.\n const space = (prop as { space?: FillSpace }).space;\n return space !== undefined ? { ...resolved, space } : resolved;\n}\n\n/** What an empty media slot paints: an image fill naming no source, which the renderer draws as the transparency checkerboard. Both media nodes use it so they draw the same placeholder. Resolved once and shared: it has no props, and the per-fill state keyed by identity (`paintSlot`, `preflighted`) is scoped to one node's `applyFills`, where this appears once. Declared here because resolving needs {@link resolveFill}, which sits on this side of the dependency. */\nexport const UNSET_MEDIA_FILL: FillResolved = resolveFill({\n type: \"image\",\n src: \"\",\n} as FillProp);\n\n/** True when `a` and `b` can be interpolated into one fill by {@link lerpFill}: same type and `blend`, or a color/gradient pair {@link canCoerce} can promote. Other pairs (color↔image, image↔video, differing blends) have no single-type in-between; {@link fillOps}'s `lerp` cross-fades them as two stacked layers. */\nexport function canLerpFill(a: FillResolved, b: FillResolved): boolean {\n if (a.type === b.type) return a.blend === b.blend;\n return canCoerce(a, b);\n}\n\nexport function lerpFill(a: FillResolved, b: FillResolved, t: number): FillResolved {\n const clamped = Math.min(1, Math.max(0, t));\n\n // Cross-type tween (color↔gradient, or differing gradients): promote both to a common type, then lerp; blend cannot interpolate, so it snaps with the coerced shape.\n if (a.type !== b.type) {\n if (!canCoerce(a, b)) {\n throw new Error(`No registered lerp for fills of type \"${a.type}\" and \"${b.type}\"`);\n }\n const [ca, cb] = coercePair(a, b);\n return { ...ca, ...get(ca.type).lerp(ca, cb, clamped) };\n }\n\n if (a.blend !== b.blend) {\n throw new Error(`No registered lerp for fills of type \"${a.type}\" and \"${b.type}\"`);\n }\n return { ...a, ...get(a.type).lerp(a, b, clamped) };\n}\n\nfunction scaleOpacity(fill: FillResolved, factor: number): FillResolved {\n return { ...fill, opacity: (fill.opacity ?? 1) * Math.max(0, factor) };\n}\n\nexport function declareFill(fill: FillResolved, assets: AssetScope): void {\n FILLS.get(fill.type)?.declare?.(fill, assets);\n}\n\nexport const fillOps: AttributeOps<Fill, FillResolved[]> = {\n resolve: (prop) => resolveChainFill(prop).map(resolveFill),\n lerp: (from, to, t) => {\n if (from === to) return from;\n if (!from.length && !to.length) return [];\n const clamped = Math.min(1, Math.max(0, t));\n const maxLength = Math.max(from.length, to.length);\n const result: FillResolved[] = [];\n for (let i = 0; i < maxLength; i++) {\n const f = from[i];\n const tf = to[i];\n if (f && tf) {\n // Interpolate in place when the fills share an interpolatable shape; otherwise cross-fade, painting the outgoing fill fading out beneath the incoming one. Dropped endpoints are omitted so a static one-fill array stays a single layer.\n if (canLerpFill(f, tf)) {\n result.push(lerpFill(f, tf, clamped));\n } else {\n if (clamped < 1) result.push(scaleOpacity(f, 1 - clamped));\n if (clamped > 0) result.push(scaleOpacity(tf, clamped));\n }\n } else if (f) {\n result.push(lerpFill(f, { ...f, opacity: 0 }, clamped));\n } else if (tf) {\n result.push(lerpFill({ ...tf, opacity: 0 }, tf, clamped));\n }\n }\n return result;\n },\n};\n", "import { fillOps } from '../fill/registry';\nimport { FillResolved } from '../fill/union';\nimport { Fill } from '../fill/chain';\nimport { Vector2, lerpVector2 } from '@/attributes/layout/vector2';\nimport type { AttributeOps } from '@/attributes/shared/operators';\n\nexport interface ShadowProp {\n blur?: number;\n /** Offset of the shadow from the shape, in px. Defaults to `{ x: 0, y: 0 }`. */\n offset?: Vector2;\n /** Any loose fill: a CSS color string, fill prop object, resolved fill, or {@link FillChain}/array of layers. */\n fill?: Fill;\n /** When true, the shadow is cast inward (inset) instead of as a drop shadow. Defaults to false. */\n inner?: boolean;\n /** Grows (positive) or shrinks (negative) the silhouette before offset and blur, like CSS `box-shadow` spread. Only honoured for ellipses and rectangles, whose geometry resizes cleanly. Defaults to 0. */\n spread?: number;\n}\n/** Fully resolved shadow: all fields normalised, defaults applied. */\nexport interface ShadowResolved {\n blur: number;\n offset?: Vector2;\n fill: FillResolved[];\n /** When true, the shadow is cast inward (inset) instead of as a drop shadow. */\n inner: boolean;\n /** Silhouette grow (positive) / shrink (negative) before blur, in px. Only ellipses and rects honour it. */\n spread: number;\n}\n\n/** Accepted shapes for a node's `shadow`: a loose {@link ShadowProp}, an array of them (stacked), or already-resolved values, which pass through `resolveShadow` idempotently so a read-back `shadow` can be assigned straight back. */\nexport type Shadow =\n | ShadowProp\n | ShadowResolved\n | (ShadowProp | ShadowResolved)[];\n\nexport function resolveShadow(prop: ShadowProp, previous?: ShadowResolved): ShadowResolved {\n return {\n blur: prop.blur ?? previous?.blur ?? 0,\n offset: prop.offset ?? previous?.offset,\n fill: prop.fill != null ? fillOps.resolve(prop.fill) : (previous?.fill ?? fillOps.resolve('transparent')),\n inner: prop.inner ?? previous?.inner ?? false,\n spread: prop.spread ?? previous?.spread ?? 0,\n };\n}\n\nfunction lerpShadow(from: ShadowResolved, to: ShadowResolved, t: number): ShadowResolved {\n return {\n blur: from.blur + (to.blur - from.blur) * t,\n offset: lerpVector2(from.offset ?? { x: 0, y: 0 }, to.offset ?? { x: 0, y: 0 }, t),\n fill: fillOps.lerp(from.fill, to.fill, t),\n // inner/outer is a discrete kind — keep the start's until the tween completes.\n inner: t < 1 ? from.inner : to.inner,\n spread: from.spread + (to.spread - from.spread) * t,\n };\n}\n\nexport const shadowOps: AttributeOps<Shadow, ShadowResolved[]> = {\n resolve: (prop, previous) => {\n if (prop == null) return [];\n const arr = Array.isArray(prop) ? prop : [prop];\n return arr.map((p, i) => resolveShadow(p as ShadowProp, previous?.[i]));\n },\n lerp: (from, to, t) => {\n if (from === to) return from;\n const len = Math.max(from.length, to.length);\n const result: ShadowResolved[] = [];\n for (let i = 0; i < len; i++) {\n const f = from[i];\n const tf = to[i];\n if (!f) { result.push(tf); continue; }\n if (!tf) { result.push(f); continue; }\n result.push(lerpShadow(f, tf, t));\n }\n return result;\n },\n};\n", "import { fillOps } from '@/attributes/shape/fill/registry';\nimport { FillResolved } from '../fill/union';\nimport { Fill } from '../fill/chain';\nimport type { AttributeOps } from '@/attributes/shared/operators';\n\n/** Where the stroke sits relative to the shape's edge, in `[-1, 1]`: -1 fully inside, 0 centred (straddling), +1 fully outside; named values map to the endpoints, intermediate numbers bias partway (like Figma's stroke alignment). */\nexport type StrokeAlign = number | 'inside' | 'center' | 'outside';\n\n/** Resolve a loose `align` prop to a clamped number in [-1, 1]. */\nexport function resolveStrokeAlign(align: StrokeAlign | undefined, fallback: number): number {\n if (align == null) return fallback;\n if (typeof align === 'number') return Math.max(-1, Math.min(1, align));\n switch (align) {\n case 'inside': return -1;\n case 'center': return 0;\n case 'outside': return 1;\n }\n return fallback;\n}\n\nexport type StrokeCap = 'butt' | 'round' | 'square';\n\n/** A shape one end of an open contour wears in place of a cap, sized by `capScale`: `arrow` is an open chevron, `triangle`/`stealth` filled heads with their tip on the path's end, `dot`/`box`/`diamond`/`bar` centred on it. */\nexport type StrokeMarker = 'arrow' | 'triangle' | 'stealth' | 'dot' | 'box' | 'diamond' | 'bar';\n\n/** What one end of an open contour wears: a cap, or a marker. */\nexport type StrokeEnd = StrokeCap | StrokeMarker;\n\n/** A marker's length as a multiple of the stroke's weight, where none is given. */\nexport const DEFAULT_CAP_SCALE = 4;\n\nexport function isStrokeMarker(end: StrokeEnd | undefined): end is StrokeMarker {\n switch (end) {\n case 'arrow':\n case 'triangle':\n case 'stealth':\n case 'dot':\n case 'box':\n case 'diamond':\n case 'bar': return true;\n }\n return false;\n}\n\nexport type StrokeJoin = 'miter' | 'round' | 'bevel';\n\nexport function resolveStrokeCap(cap: StrokeCap | undefined, fallback: StrokeCap): StrokeCap {\n if (cap == null) return fallback;\n switch (cap) {\n case 'butt':\n case 'round':\n case 'square': return cap;\n }\n return fallback;\n}\n\nexport function resolveStrokeEnd(end: StrokeEnd | undefined, fallback: StrokeCap): StrokeEnd {\n return isStrokeMarker(end) ? end : resolveStrokeCap(end, fallback);\n}\n\nexport function resolveStrokeJoin(join: StrokeJoin | undefined, fallback: StrokeJoin): StrokeJoin {\n if (join == null) return fallback;\n switch (join) {\n case 'miter':\n case 'round':\n case 'bevel': return join;\n }\n return fallback;\n}\n\nexport interface StrokeProp {\n weight?: number;\n /** Any loose fill: a CSS color string, fill prop object, resolved fill, or {@link FillChain}/array of layers. */\n fill?: Fill;\n /** Dash pattern. A single number `n` becomes `[n, n]`. */\n dash?: number | number[];\n dashOffset?: number;\n /** `'inside'` (-1), `'center'` (0), `'outside'` (1) or a number in [-1, 1]. Defaults to `'inside'`, so the stroke stays within the shape's measured bounds (like a CSS border). */\n align?: StrokeAlign;\n /** How the ends of each dash and of an open stroke are shaped (default `'butt'`); `startCap`/`endCap` override it at the path's two ends. */\n cap?: StrokeCap;\n /** The cap or marker at the start of each open contour, in place of `cap`. */\n startCap?: StrokeEnd;\n /** The cap or marker at the end of each open contour, in place of `cap`. */\n endCap?: StrokeEnd;\n /** A marker's length as a multiple of `weight` (default `4`) so a head keeps its proportion as the stroke thickens; on a short contour it shrinks to fit. */\n capScale?: number;\n /** How two segments meet at a corner (default `'miter'`). */\n join?: StrokeJoin;\n /** Maximum miter length to stroke width ratio before a `'miter'` join truncates to a bevel (default 4). */\n miterLimit?: number;\n}\n\n/** Fully resolved stroke: all fields normalised, defaults applied. */\nexport interface StrokeResolved {\n weight: number;\n fill: FillResolved[];\n dash?: number[];\n dashOffset: number;\n align: number;\n /** End-cap shape for dash ends, and for open strokes' ends unless overridden. */\n cap: StrokeCap;\n /** Absent means the end follows `cap`. */\n startCap?: StrokeEnd;\n endCap?: StrokeEnd;\n capScale: number;\n join: StrokeJoin;\n miterLimit: number;\n}\n\n/** Accepted shapes for a node's `stroke`: a loose {@link StrokeProp}, an array of them (stacked bottom-to-top), or already-resolved values, which pass through `resolveStroke` idempotently so a read-back `stroke` can be assigned straight back. */\nexport type Stroke =\n | StrokeProp\n | StrokeResolved\n | (StrokeProp | StrokeResolved)[];\n\nexport function resolveStroke(prop: StrokeProp, previous?: StrokeResolved): StrokeResolved {\n let dash: number[] | undefined;\n if (prop.dash != null) {\n const raw = Array.isArray(prop.dash) ? prop.dash : [prop.dash];\n dash = raw.length === 1 ? [raw[0], raw[0]] : raw;\n } else {\n dash = previous?.dash;\n }\n const cap = resolveStrokeCap(prop.cap, previous?.cap ?? 'butt');\n return {\n weight: prop.weight ?? previous?.weight ?? 1,\n fill: prop.fill != null ? fillOps.resolve(prop.fill) : (previous?.fill ?? fillOps.resolve('transparent')),\n dash,\n dashOffset: prop.dashOffset ?? previous?.dashOffset ?? 0,\n align: resolveStrokeAlign(prop.align, previous?.align ?? -1),\n cap,\n startCap: prop.startCap != null ? resolveStrokeEnd(prop.startCap, cap) : previous?.startCap,\n endCap: prop.endCap != null ? resolveStrokeEnd(prop.endCap, cap) : previous?.endCap,\n capScale: Math.max(0, prop.capScale ?? previous?.capScale ?? DEFAULT_CAP_SCALE),\n join: resolveStrokeJoin(prop.join, previous?.join ?? 'miter'),\n miterLimit: prop.miterLimit ?? previous?.miterLimit ?? 4,\n };\n}\n\nfunction lerpDashArray(from: number[] | undefined, to: number[] | undefined, t: number): number[] | undefined {\n const fArray = from || [];\n const tArray = to || [];\n if (fArray.length === 0 && tArray.length === 0) return from;\n\n const len = Math.max(fArray.length, tArray.length);\n const result: number[] = new Array(len);\n for (let i = 0; i < len; i++) {\n // Pad shorter arrays with 0 to ensure smooth transitions.\n const fVal = fArray[i] ?? 0;\n const tVal = tArray[i] ?? 0;\n result[i] = fVal + (tVal - fVal) * t;\n }\n return result;\n}\n\nfunction lerpStroke(from: StrokeResolved, to: StrokeResolved, t: number): StrokeResolved {\n return {\n weight: from.weight + (to.weight - from.weight) * t,\n fill: fillOps.lerp(from.fill, to.fill, t),\n dash: lerpDashArray(from.dash, to.dash, t) as number[],\n dashOffset: from.dashOffset + (to.dashOffset - from.dashOffset) * t,\n align: from.align + (to.align - from.align) * t,\n // cap/join are discrete enums — snap at the midpoint.\n cap: t < 0.5 ? from.cap : to.cap,\n startCap: t < 0.5 ? from.startCap : to.startCap,\n endCap: t < 0.5 ? from.endCap : to.endCap,\n capScale: from.capScale + (to.capScale - from.capScale) * t,\n join: t < 0.5 ? from.join : to.join,\n miterLimit: from.miterLimit + (to.miterLimit - from.miterLimit) * t,\n };\n}\n\nexport const strokeOps: AttributeOps<Stroke, StrokeResolved[]> = {\n resolve: (prop, previous) => {\n if (prop == null) return [];\n const arr = Array.isArray(prop) ? prop : [prop];\n return arr.map((p, i) => resolveStroke(p as StrokeProp, previous?.[i]));\n },\n lerp: (from, to, t) => {\n if (from === to) return from;\n const len = Math.max(from.length, to.length);\n const result: StrokeResolved[] = [];\n for (let i = 0; i < len; i++) {\n const f = from[i];\n const tf = to[i];\n if (!f) { result.push(tf); continue; }\n if (!tf) { result.push(f); continue; }\n result.push(lerpStroke(f, tf, t));\n }\n return result;\n },\n};\n", "/**\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", "import type { EasingFunction } from \"./type\";\n\n/**\n * Descriptions of engine-built easings, by function.\n *\n * Every engine easing is an anonymous closure, so `fn.name` is `\"\"` and cannot\n * tell two of them apart. A constructor that knows what it built records a short,\n * deterministic description here, which is what a cache key can be built from.\n */\nconst descriptions = new WeakMap<EasingFunction, string>();\n\n/** Record what `ease` is, and hand it back. @internal */\nexport function describeEase<F extends EasingFunction>(ease: F, description: string): F {\n descriptions.set(ease, description);\n return ease;\n}\n\n/** What an engine-built ease was recorded as, or `undefined` for any other function. @internal */\nexport function easeDescription(ease: EasingFunction): string | undefined {\n return descriptions.get(ease);\n}\n", "import { clamp01 } from \"@/util/clamp\";\nimport { EasingFunction } from \"./type\";\nimport { describeEase } from \"./describe\";\n\nexport type StandardEase =\n | 'sine' | 'quad' | 'cubic' | 'quart' | 'quint'\n | 'expo' | 'circ' | 'back' | 'elastic' | 'bounce';\n\n/** Default ease family used when no `type` is specified. */\nexport const DEFAULT_EASE: StandardEase = 'quad';\n\nexport interface EaseConfig {\n /** Standard ease family (default: 'quad'). */\n type?: StandardEase;\n /** Used by 'back' (default: 1.70158). */\n overshoot?: number;\n /** Used by 'elastic' (default: 1). */\n amplitude?: number;\n /** Used by 'elastic' (default: 0.3). */\n period?: number;\n}\n\nexport type EaseParams = StandardEase | EaseConfig;\n\nconst PI = Math.PI;\n\ntype ResolvedConfig = EaseConfig & { type: StandardEase };\n\nconst parseConfig = (params?: EaseParams): ResolvedConfig => {\n if (params === undefined) return { type: DEFAULT_EASE };\n if (typeof params === 'string') return { type: params };\n return { ...params, type: params.type ?? DEFAULT_EASE };\n};\n\n// \"Ease in\" curve for each standard family, parameterized by an EaseConfig.\n// easeOut/easeInOut are derived from this via reflection, matching the\n// classic Penner construction.\nconst inMath: Record<StandardEase, (t: number, config: EaseConfig) => number> = {\n sine: (t) => 1 - Math.cos((t * PI) / 2),\n quad: (t) => t * t,\n cubic: (t) => t * t * t,\n quart: (t) => t * t * t * t,\n quint: (t) => t * t * t * t * t,\n expo: (t) => (t === 0 ? 0 : Math.pow(2, 10 * (t - 1))),\n circ: (t) => 1 - Math.sqrt(1 - t * t),\n back: (t, config) => {\n const s = config.overshoot ?? 1.70158;\n return t * t * ((s + 1) * t - s);\n },\n elastic: (t, config) => {\n if (t === 0 || t === 1) return t;\n const a = config.amplitude ?? 1;\n const p = config.period ?? 0.3;\n const s = (p / (2 * PI)) * Math.asin(1 / a);\n return -(a * Math.pow(2, 10 * (t - 1)) * Math.sin(((t - 1 - s) * 2 * PI) / p));\n },\n bounce: (t) => {\n const bounceOut = (x: number) => {\n const n1 = 7.5625;\n const d1 = 2.75;\n if (x < 1 / d1) return n1 * x * x;\n if (x < 2 / d1) return n1 * (x -= 1.5 / d1) * x + 0.75;\n if (x < 2.5 / d1) return n1 * (x -= 2.25 / d1) * x + 0.9375;\n return n1 * (x -= 2.625 / d1) * x + 0.984375;\n };\n return 1 - bounceOut(1 - t);\n },\n};\n\n/** A key-ready description of a standard ease: its direction, family and every tuning value. */\nconst describeConfig = (direction: 'in' | 'out' | 'inOut', config: ResolvedConfig): string =>\n `${direction}:${config.type}:${config.overshoot ?? '_'}:${config.amplitude ?? '_'}:${config.period ?? '_'}`;\n\nexport const linear = (): EasingFunction => describeEase((t) => clamp01(t), 'lin');\n\nexport const easeIn = (params?: EaseParams): EasingFunction => {\n const config = parseConfig(params);\n return describeEase((t) => inMath[config.type](clamp01(t), config), describeConfig('in', config));\n};\n\nexport const easeOut = (params?: EaseParams): EasingFunction => {\n const config = parseConfig(params);\n return describeEase((t) => 1 - inMath[config.type](1 - clamp01(t), config), describeConfig('out', config));\n};\n\nexport const easeInOut = (params?: EaseParams): EasingFunction => {\n const config = parseConfig(params);\n // 'back' and 'elastic' need different default tuning at the midpoint than\n // their easeIn/easeOut counterparts (the classic Penner in-out variants\n // scale overshoot and default period differently), so resolve those here\n // rather than reusing the easeIn/easeOut defaults verbatim.\n const inOutConfig: ResolvedConfig = config.type === 'back'\n ? { ...config, overshoot: (config.overshoot ?? 1.70158) * 1.525 }\n : config.type === 'elastic'\n ? { ...config, period: config.period ?? 0.45 }\n : config;\n return describeEase((t) => {\n t = clamp01(t);\n return t < 0.5\n ? inMath[inOutConfig.type](2 * t, inOutConfig) / 2\n : 1 - inMath[inOutConfig.type](2 * (1 - t), inOutConfig) / 2;\n }, describeConfig('inOut', config));\n};\n", "import type { EasingFunction } from \"./type\";\nimport { describeEase } from \"./describe\";\n\n/** A hand-drawn timing function: cubic Bézier segments from (0, 0) to (1, 1), x being progress and y how far along the animation is. It is what an `EaseSpec` of `kind: \"custom\"` carries inline, so a drawn curve travels with the document. Two things keep it a function of x, both enforced: a control point is clamped into its own segment's x span, and an absent handle resolves to the Catmull-Rom tangent. y is deliberately unclamped: overshooting and settling back is a real move. */\n\n/** A point in curve space, or a handle offset within it. */\nexport interface CurveVector {\n x: number;\n y: number;\n}\n\n/** One control point of a custom easing curve. */\nexport interface CurvePoint {\n x: number;\n y: number;\n /** The handle steering the segment leaving this point. Absent = auto. */\n out?: CurveVector;\n /** The handle steering the segment arriving at it. Absent = auto. */\n in?: CurveVector;\n}\n\n/** One cubic Bézier segment of the curve, in absolute curve space. */\nexport interface EaseCurveSegment {\n p0: CurveVector;\n c1: CurveVector;\n c2: CurveVector;\n p3: CurveVector;\n}\n\nconst clamp = (value: number, min: number, max: number): number => Math.min(max, Math.max(min, value));\n\n/** The curve as Bézier segments, every auto handle and every clamp resolved. */\nexport function curveSegments(points: readonly CurvePoint[]): EaseCurveSegment[] {\n const segments: EaseCurveSegment[] = [];\n for (let i = 0; i < points.length - 1; i++) {\n const p0 = points[i];\n const p3 = points[i + 1];\n const before = points[i - 1] ?? p0;\n const after = points[i + 2] ?? p3;\n\n const c1 = p0.out\n ? { x: p0.x + p0.out.x, y: p0.y + p0.out.y }\n : { x: p0.x + (p3.x - before.x) / 6, y: p0.y + (p3.y - before.y) / 6 };\n const c2 = p3.in\n ? { x: p3.x + p3.in.x, y: p3.y + p3.in.y }\n : { x: p3.x - (after.x - p0.x) / 6, y: p3.y - (after.y - p0.y) / 6 };\n\n segments.push({\n p0: { x: p0.x, y: p0.y },\n c1: { x: clamp(c1.x, p0.x, p3.x), y: c1.y },\n c2: { x: clamp(c2.x, p0.x, p3.x), y: c2.y },\n p3: { x: p3.x, y: p3.y },\n });\n }\n return segments;\n}\n\n/** A cubic Bézier evaluated on one axis. */\nfunction bezier(a: number, b: number, c: number, d: number, t: number): number {\n const mt = 1 - t;\n return mt * mt * mt * a + 3 * mt * mt * t * b + 3 * mt * t * t * c + t * t * t * d;\n}\n\n/** The curve parameter at which a segment reaches `x`: bisection rather than Newton, since x is monotonic along the segment while Newton's derivative goes to zero at the flat ends of an ease-in-out. */\nexport function curveSegmentT(segment: EaseCurveSegment, x: number): number {\n let low = 0;\n let high = 1;\n for (let i = 0; i < 30; i++) {\n const mid = (low + high) / 2;\n const at = bezier(segment.p0.x, segment.c1.x, segment.c2.x, segment.p3.x, mid);\n if (at < x) low = mid;\n else high = mid;\n }\n return (low + high) / 2;\n}\n\n/** Whether `value` is a drawable curve: two or more finite points. */\nexport function isEaseCurve(value: unknown): value is CurvePoint[] {\n return Array.isArray(value) && value.length >= 2 && value.every(isFinitePoint);\n}\n\nfunction isFinitePoint(value: unknown): value is CurveVector {\n if (typeof value !== \"object\" || value === null) return false;\n const { x, y } = value as Partial<CurveVector>;\n return typeof x === \"number\" && Number.isFinite(x) && typeof y === \"number\" && Number.isFinite(y);\n}\n\n/** The easing a curve runs as: progress in, eased progress out. */\nexport function curveEase(points: readonly CurvePoint[]): EasingFunction {\n const segments = curveSegments(points);\n if (segments.length === 0) return describeEase((x) => x, 'lin');\n\n return describeEase((x) => {\n if (x <= 0) return segments[0].p0.y;\n const last = segments[segments.length - 1];\n if (x >= 1) return last.p3.y;\n\n let segment = last;\n for (const candidate of segments) {\n if (x <= candidate.p3.x) {\n segment = candidate;\n break;\n }\n }\n const t = curveSegmentT(segment, x);\n return bezier(segment.p0.y, segment.c1.y, segment.c2.y, segment.p3.y, t);\n }, `curve:${JSON.stringify(points)}`);\n}\n", "import { easeIn, easeInOut, easeOut, linear, type EaseParams, type StandardEase } from \"./constants\";\nimport { curveEase, isEaseCurve, type CurvePoint } from \"./curve\";\nimport { easeDescription } from \"./describe\";\nimport type { EasingFunction } from \"./type\";\n\n/** How something eases, as data: `kind` picks the direction and `args` the family and its knobs, mirroring the families in `tween/ease/constants.ts`. `kind: \"custom\"` takes a drawn curve in `args`, or the key of an ease the host passed to `Registry.addEase` / `RegistryOptions.eases`. */\nexport interface EaseSpec {\n kind: \"linear\" | \"in\" | \"out\" | \"inOut\" | \"custom\";\n /** Family and parameters (`\"quad\"`, or `{ type: \"back\", overshoot: 2 }`) for every `kind` but `\"custom\"`, whose `args` is the drawn curve itself (a {@link CurvePoint} chain from (0, 0) to (1, 1), so timing travels with the document) or a `Registry.addEase` key. */\n args?: EaseParams | CurvePoint[] | string;\n}\n\nexport const EASE_KINDS: ReadonlySet<string> = new Set<EaseSpec[\"kind\"]>([\"linear\", \"in\", \"out\", \"inOut\", \"custom\"]);\n\n/** The function `spec` runs as. A registry key resolves through `lookup`, and throws without one. */\nexport function easeOfSpec(spec: EaseSpec, lookup?: (key: string) => EasingFunction | undefined, known?: () => readonly string[]): EasingFunction {\n switch (spec.kind) {\n case \"linear\": return linear();\n case \"in\": return easeIn(spec.args as EaseParams | undefined);\n case \"out\": return easeOut(spec.args as EaseParams | undefined);\n case \"inOut\": return easeInOut(spec.args as EaseParams | undefined);\n case \"custom\": {\n const key = spec.args;\n if (isEaseCurve(key)) return curveEase(key);\n if (typeof key !== \"string\") {\n throw new Error(`A \"custom\" ease needs a curve or its Registry.addEase key in \\`args\\` (got ${JSON.stringify(spec.args)}).`);\n }\n const fn = lookup?.(key);\n if (!fn) {\n const registered = known?.().join(\", \") || \"none\";\n throw new Error(lookup\n ? `No ease registered under \"${key}\". Registered: ${registered}.`\n : `The ease \"${key}\" names a Registry entry, which nothing here can resolve; use a standard ease or a drawn curve.`);\n }\n return fn;\n }\n }\n}\n\nconst STANDARD: ReadonlySet<string> = new Set<StandardEase>([\"sine\", \"quad\", \"cubic\", \"quart\", \"quint\", \"expo\", \"circ\", \"back\", \"elastic\", \"bounce\"]);\n\n/** The spec an engine-built ease was made from, or `undefined` for a function the engine did not build. */\nexport function specOfEase(ease: EasingFunction): EaseSpec | undefined {\n const description = easeDescription(ease);\n if (description === undefined) return undefined;\n if (description === \"lin\") return { kind: \"linear\" };\n if (description.startsWith(\"curve:\")) return { kind: \"custom\", args: JSON.parse(description.slice(6)) as CurvePoint[] };\n const [direction, type, overshoot, amplitude, period] = description.split(\":\");\n if ((direction !== \"in\" && direction !== \"out\" && direction !== \"inOut\") || !STANDARD.has(type)) return undefined;\n const tuning = { overshoot, amplitude, period };\n const config: Record<string, unknown> = { type };\n for (const [name, value] of Object.entries(tuning)) {\n if (value !== undefined && value !== \"_\") config[name] = Number(value);\n }\n return { kind: direction, args: Object.keys(config).length === 1 ? (type as StandardEase) : (config as EaseParams) };\n}\n", "import { linear } from \"@/tween/ease/constants\";\nimport { easeOfSpec, specOfEase, type EaseSpec } from \"@/tween/ease/spec\";\nimport type { EasingFunction } from \"@/tween/ease/type\";\nimport { lerpNumber } from \"@/tween/lerp\";\nimport type { AttributeOps } from \"@/attributes/shared/operators\";\n\n/** One point of a {@link Ramp}: a value placed `at` seconds after the start or `before` seconds before the end, plus the ease of the segment arriving at it (linear when absent). */\nexport type RampKey =\n | { readonly at: number; readonly before?: undefined; readonly value: number; readonly ease?: EaseSpec }\n | { readonly before: number; readonly at?: undefined; readonly value: number; readonly ease?: EaseSpec };\n\n/** Automation for one audio param, as plain JSON. A `before` key stays put when the clip is trimmed, so \"the last second\" means the last second of any length. */\nexport interface Ramp {\n readonly keys: readonly RampKey[];\n}\n\n/** An audio param: a constant, or a {@link Ramp}. */\nexport type Param = number | Ramp;\n\nexport interface ResolvedRampKey {\n readonly time: number;\n readonly value: number;\n readonly ease: EasingFunction;\n /** Linear into this key, so a device can schedule a cheap ramp rather than a baked curve. */\n readonly linear: boolean;\n}\n\ninterface Segment {\n readonly from?: number;\n readonly to?: number;\n readonly duration?: number;\n readonly ease?: EaseSpec;\n}\n\n/** An ease as data, or an engine-built function (which records the data it came from). */\nexport type RampEase = EaseSpec | EasingFunction;\n\nconst segmentsOf = new WeakMap<RampChain, readonly Segment[]>();\n\n/** The fluent builder `ramp(0, 1, 0.5).hold().ramp(1, 0, 1)`; its only own field is `keys`, so it is a {@link Ramp}. Segments before the first bare `hold()` place from the start, after it from the end, and the hold fills the middle. */\nexport class RampChain implements Ramp {\n readonly keys: readonly RampKey[];\n\n constructor(segments: readonly Segment[] = []) {\n segmentsOf.set(this, segments);\n this.keys = keysOf(segments);\n }\n\n ramp(from: number, to: number, duration: number, options?: { readonly ease?: RampEase }): RampChain {\n return this._append({ from, to, duration, ease: specOf(options?.ease) });\n }\n\n hold(duration?: number): RampChain {\n return this._append({ duration });\n }\n\n private _append(segment: Segment): RampChain {\n return new RampChain([...(segmentsOf.get(this) ?? []), segment]);\n }\n}\n\nexport function ramp(from: number, to: number, duration: number, options?: { readonly ease?: RampEase }): RampChain {\n return new RampChain().ramp(from, to, duration, options);\n}\n\n/** A hold; bare `hold()` stretches to fill the middle of the clip. */\nexport function hold(duration?: number): RampChain {\n return new RampChain().hold(duration);\n}\n\nfunction specOf(ease: RampEase | undefined): EaseSpec | undefined {\n if (ease === undefined) return undefined;\n const spec = typeof ease === \"function\" ? specOfEase(ease) : ease;\n if (!spec) {\n throw new TypeError(\"A ramp's ease is stored as data, and this function has none: pass an EaseSpec, or an engine-built ease (easeIn, easeOut, easeInOut, curveEase).\");\n }\n return spec.kind === \"linear\" ? undefined : spec;\n}\n\nfunction keysOf(segments: readonly Segment[]): RampKey[] {\n let previous: number | undefined;\n const values = segments.map((s) => {\n const from = s.from ?? previous;\n const to = s.to ?? from;\n previous = to;\n return { from, to };\n });\n\n const keys: RampKey[] = [];\n const push = (key: RampKey): void => {\n const last = keys[keys.length - 1];\n if (last && !key.ease && last.at === key.at && last.before === key.before && last.value === key.value) return;\n keys.push(key);\n };\n const withEase = (s: Segment) => (s.ease ? { ease: s.ease } : {});\n\n const fill = segments.findIndex((s) => s.duration === undefined);\n const head = fill < 0 ? segments.length : fill;\n let at = 0;\n for (let i = 0; i < head; i++) {\n const s = segments[i];\n const duration = Math.max(0, s.duration ?? 0);\n const { from, to } = values[i];\n if (from !== undefined) push({ at, value: from });\n if (to !== undefined) push({ at: at + duration, value: to, ...withEase(s) });\n at += duration;\n }\n if (fill < 0) return keys;\n\n const tail = segments.slice(fill + 1);\n if (tail.some((s) => s.duration === undefined) && process.env.NODE_ENV !== \"production\") {\n console.warn(\"[motionscript] A ramp has more than one bare hold(); only the first stretches, the rest are zero-length.\");\n }\n let before = tail.reduce((sum, s) => sum + Math.max(0, s.duration ?? 0), 0);\n for (let i = fill + 1; i < segments.length; i++) {\n const s = segments[i];\n const duration = Math.max(0, s.duration ?? 0);\n const { from, to } = values[i];\n if (from !== undefined) push({ before, value: from });\n before -= duration;\n if (to !== undefined) push({ before: Math.max(0, before), value: to, ...withEase(s) });\n }\n return keys;\n}\n\n/** Whether `p` is a {@link Ramp}: anything with a `keys` array, a parsed copy included. */\nexport function isRamp(p: unknown): p is Ramp {\n return typeof p === \"object\" && p !== null && Array.isArray((p as Ramp).keys);\n}\n\nconst LINEAR = linear();\nconst resolved = new WeakMap<Ramp, { readonly length: number; readonly keys: readonly ResolvedRampKey[] }>();\n\n/** The keys of `ramp` placed on a clip `length` seconds long, in time order. Times clamp to the clip (a longer ramp is cut, not squeezed); crossed anchors sort by where they land, with a development warning. */\nexport function resolveRamp(ramp: Ramp, length: number): readonly ResolvedRampKey[] {\n const clip = Number.isFinite(length) && length > 0 ? length : 0;\n const cached = resolved.get(ramp);\n if (cached && cached.length === clip) return cached.keys;\n\n let crossed = false;\n let last = -Infinity;\n const keys = ramp.keys.map((key) => {\n const time = Math.min(clip, Math.max(0, key.before !== undefined ? clip - key.before : key.at ?? 0));\n if (time < last) crossed = true;\n last = time;\n const ease = key.ease ? easeOfSpec(key.ease) : LINEAR;\n return { time, value: key.value, ease, linear: !key.ease || key.ease.kind === \"linear\" };\n });\n if (crossed) {\n keys.sort((a, b) => a.time - b.time);\n if (process.env.NODE_ENV !== \"production\") {\n console.warn(`[motionscript] A ramp's start and end keys cross on a ${clip.toFixed(3)}s clip; they play in the order they land.`);\n }\n }\n resolved.set(ramp, { length: clip, keys });\n return keys;\n}\n\n/** The value of `ramp` at `t` seconds into a clip `length` seconds long, `fallback` when it has no keys. */\nexport function sampleRamp(ramp: Ramp, t: number, length: number, fallback: number): number {\n const keys = resolveRamp(ramp, length);\n if (keys.length === 0) return fallback;\n if (t <= keys[0].time) return keys[0].value;\n for (let i = 1; i < keys.length; i++) {\n const key = keys[i];\n if (t > key.time) continue;\n const previous = keys[i - 1];\n const span = key.time - previous.time;\n return lerpNumber(previous.value, key.value, key.ease(span > 0 ? (t - previous.time) / span : 1));\n }\n return keys[keys.length - 1].value;\n}\n\nexport function staticValue(p: Param, fallback = 0): number {\n if (!isRamp(p)) return p;\n let first: RampKey | undefined;\n for (const key of p.keys) {\n if (key.at !== undefined && (first?.at === undefined || key.at < first.at)) first = key;\n }\n return (first ?? p.keys[0])?.value ?? fallback;\n}\n\n/** Equal for two params exactly when they sound the same: what tells a device a param was edited. */\nexport function paramKey(p: Param | undefined): string {\n if (p === undefined) return \"_\";\n return isRamp(p) ? `r${JSON.stringify(p.keys)}` : String(p);\n}\n\n/** Two numbers lerp; a ramp on either side hard-cuts at the midpoint. */\nexport function lerpParam(from: Param, to: Param, t: number): Param {\n if (typeof from === \"number\" && typeof to === \"number\") return lerpNumber(from, to, t);\n return t < 0.5 ? from : to;\n}\n\nexport function equalsParam(a: Param | undefined, b: Param | undefined): boolean {\n if (a === b) return true;\n if (typeof a === \"number\" || typeof b === \"number\" || a === undefined || b === undefined) return false;\n return paramKey(a) === paramKey(b);\n}\n\nexport const audioParamOps: AttributeOps<Param, Param> = {\n resolve: (value) => value,\n lerp: lerpParam,\n};\n\nconst INTEGRATION_STEP = 0.001;\n/** The most cells one table holds: past it a long source gets coarser cells, not a bigger table. */\nconst MAX_CELLS = 20000;\n\n/** `∫ 1/speed` tabulated once per ramp and source length: `clip[i]` is the clip seconds spent by the start of cell `i`, making either direction a lookup (walking from zero per query was quadratic). */\ninterface SpeedTable {\n readonly step: number;\n readonly clip: Float64Array;\n readonly rate: Float64Array;\n}\n\nconst speedTables = new WeakMap<Ramp, Map<string, SpeedTable>>();\n\nfunction speedTableOf(speed: Ramp, sourceLength: number, step: number): SpeedTable {\n let byLength = speedTables.get(speed);\n if (!byLength) speedTables.set(speed, (byLength = new Map()));\n const key = `${sourceLength}:${step}`;\n const cached = byLength.get(key);\n if (cached) return cached;\n const cells = Math.max(1, Math.min(MAX_CELLS, Math.ceil(sourceLength / step)));\n const size = sourceLength / cells;\n const clip = new Float64Array(cells + 1);\n const rate = new Float64Array(cells);\n for (let i = 0; i < cells; i++) {\n rate[i] = Math.max(1e-6, sampleRamp(speed, (i + 0.5) * size, sourceLength, 1));\n clip[i + 1] = clip[i] + size / rate[i];\n }\n const table = { step: size, clip, rate };\n if (byLength.size >= 8) byLength.clear();\n byLength.set(key, table);\n return table;\n}\n\n/** Clip seconds spent playing the first `upper` source seconds under a speed ramp: `∫ 1/speed(τ) dτ`, with the ramp placed on `sourceLength` and speed floored just above zero. */\nexport function integrateSpeedToClipTime(speed: Ramp, sourceLength: number, upper: number = sourceLength, step = INTEGRATION_STEP): number {\n const end = Math.min(upper, sourceLength);\n if (end <= 0) return 0;\n const table = speedTableOf(speed, sourceLength, step);\n const cell = Math.min(table.rate.length - 1, Math.floor(end / table.step));\n return table.clip[cell] + (end - cell * table.step) / table.rate[cell];\n}\n\n/** Inverse of {@link integrateSpeedToClipTime}: the source seconds reached after `clipElapsed` clip seconds. */\nexport function sourceTimeAtClipElapsed(speed: Ramp, sourceLength: number, clipElapsed: number, step = INTEGRATION_STEP): number {\n if (clipElapsed <= 0 || sourceLength <= 0) return 0;\n const table = speedTableOf(speed, sourceLength, step);\n const { clip, rate } = table;\n if (clipElapsed >= clip[clip.length - 1]) return sourceLength;\n let lo = 0;\n let hi = rate.length - 1;\n while (lo < hi) {\n const mid = (lo + hi + 1) >> 1;\n if (clip[mid] <= clipElapsed) lo = mid;\n else hi = mid - 1;\n }\n return Math.min(sourceLength, lo * table.step + (clipElapsed - clip[lo]) * rate[lo]);\n}\n", "import { AudioEffect } from \"./union\";\nimport { Param, isRamp } from \"../ramp\";\n\n/** Every builder takes one options object; those with one dominant param also take it directly (a number or a {@link Ramp}), so `AudioEffects.lowpass(ramp(8000, 400, 2))` works. */\n\n/** Gain. Param shorthand sets `value`. */\nexport interface GainEffectOptions {\n /** 1 = unchanged, 0 = silent, >1 = louder. */\n value: Param;\n}\n\n/** High-pass filter. Param shorthand sets `frequency`. */\nexport interface HighPassEffectOptions {\n /** Rolls off content below this frequency, in Hz. */\n frequency: Param;\n /** Resonance at the cutoff (default 1). */\n q?: Param;\n}\n\n/** Low-pass filter. Param shorthand sets `frequency`. */\nexport interface LowPassEffectOptions {\n /** Rolls off content above this frequency, in Hz. */\n frequency: Param;\n /** Resonance at the cutoff (default 1). */\n q?: Param;\n}\n\n/** Amplitude wobble. Param shorthand sets `rate`. */\nexport interface TremoloEffectOptions {\n /** Wobble rate in Hz. */\n rate: Param;\n /** Modulation depth, 0–1 (default 0.5). */\n depth?: Param;\n}\n\n/** Delay line with feedback. Param shorthand sets `delay`. */\nexport interface EchoEffectOptions {\n /** Delay time in seconds. */\n delay: Param;\n /** Feedback amount, 0–<1 (default 0.4). */\n feedback?: Param;\n /** Wet mix, 0–1 (default 0.5). */\n mix?: Param;\n}\n\n/** A ramp is an object too, so the shorthand test has to ask {@link isRamp}, or it reads as an options bag. */\nfunction scalarParam<O extends object>(arg: Param | O, key: keyof O): O {\n return typeof arg === \"number\" || isRamp(arg) ? ({ [key]: arg } as O) : (arg as O);\n}\n\n/** Immutable, chainable list of audio effects applied in order (index 0 closest to the source): `AudioEffects.gain(1.5).lowpass(800).echo(0.3)`. */\nexport class AudioEffectChain {\n constructor(public list: AudioEffect[] = []) { }\n\n private append(effect: AudioEffect): AudioEffectChain {\n return new AudioEffectChain([...this.list, effect]);\n }\n\n gain(options: Param | GainEffectOptions) {\n const { value } = scalarParam(options, \"value\");\n return this.append({ type: 'gain', value });\n }\n\n /** Alias for {@link gain}. */\n volume(options: Param | GainEffectOptions) {\n return this.gain(options);\n }\n\n /** Rolls off content below `frequency` Hz. */\n highpass(options: Param | HighPassEffectOptions) {\n const { frequency, q } = scalarParam(options, \"frequency\");\n return this.append({ type: 'highpass', frequency, q });\n }\n\n /** Rolls off content above `frequency` Hz. */\n lowpass(options: Param | LowPassEffectOptions) {\n const { frequency, q } = scalarParam(options, \"frequency\");\n return this.append({ type: 'lowpass', frequency, q });\n }\n\n /** A `rate` Hz wobble at `depth` (0–1). */\n tremolo(options: Param | TremoloEffectOptions) {\n const { rate, depth } = scalarParam(options, \"rate\");\n return this.append({ type: 'tremolo', rate, depth: depth ?? 0.5 });\n }\n\n /** `delay` seconds, `feedback` 0–<1, optional wet `mix` 0–1. */\n echo(options: Param | EchoEffectOptions) {\n const { delay, feedback, mix } = scalarParam(options, \"delay\");\n return this.append({ type: 'echo', delay, feedback: feedback ?? 0.4, mix });\n }\n\n *[Symbol.iterator]() {\n yield* this.list;\n }\n\n toJSON() {\n return this.list;\n }\n}\n\n/** What an `effects` prop accepts: one effect, a plain array, or a chain. */\nexport type AudioEffectsInput = AudioEffect[] | AudioEffectChain | AudioEffect;\n\n/** An empty {@link AudioEffectChain}: `AudioEffects.gain(1.5)` is `new AudioEffectChain().gain(1.5)`. */\nexport const AudioEffects = new AudioEffectChain();\n\nexport function resolveAudioEffects(effects: AudioEffectsInput | undefined): AudioEffect[] {\n if (effects === undefined) return [];\n if (effects instanceof AudioEffectChain) return effects.list;\n if (Array.isArray(effects)) return effects;\n return [effects];\n}\n", "import type { AudioEffectData } from \"../registry\";\nimport { Param, lerpParam, equalsParam } from \"../../ramp\";\n\n/** Scales the clip's amplitude by a linear factor. */\nexport interface GainEffect {\n type: 'gain';\n /** Linear gain multiplier. 1 = unchanged, 0 = silent, >1 = louder. May be a ramp. */\n value: Param;\n}\n\nexport const gainEffect: AudioEffectData<GainEffect> = {\n lerp: (from, to, t) => ({ type: \"gain\", value: lerpParam(from.value, to.value, t) }),\n equals: (a, b) => equalsParam(a.value, b.value),\n};\n", "import type { AudioEffectData } from \"../registry\";\nimport { Param, lerpParam, equalsParam } from \"../../ramp\";\n\n/** Attenuates frequencies below `frequency`, passing the highs through. */\nexport interface HighPassEffect {\n type: 'highpass';\n /** Cutoff frequency in Hz. Content below this is rolled off. May be a ramp. */\n frequency: Param;\n /** Resonance (Q) at the cutoff. Default 1. May be a ramp. */\n q?: Param;\n}\n\nexport const highPassEffect: AudioEffectData<HighPassEffect> = {\n lerp: (from, to, t) => ({\n type: \"highpass\",\n frequency: lerpParam(from.frequency, to.frequency, t),\n q: lerpParam(from.q ?? 1, to.q ?? 1, t),\n }),\n equals: (a, b) => equalsParam(a.frequency, b.frequency) && equalsParam(a.q ?? 1, b.q ?? 1),\n};\n", "import type { AudioEffectData } from \"../registry\";\nimport { Param, lerpParam, equalsParam } from \"../../ramp\";\n\n/** Attenuates frequencies above `frequency`, passing the lows through. */\nexport interface LowPassEffect {\n type: 'lowpass';\n /** Cutoff frequency in Hz. Content above this is rolled off. May be a ramp. */\n frequency: Param;\n /** Resonance (Q) at the cutoff. Default 1. May be a ramp. */\n q?: Param;\n}\n\nexport const lowPassEffect: AudioEffectData<LowPassEffect> = {\n lerp: (from, to, t) => ({\n type: \"lowpass\",\n frequency: lerpParam(from.frequency, to.frequency, t),\n q: lerpParam(from.q ?? 1, to.q ?? 1, t),\n }),\n equals: (a, b) => equalsParam(a.frequency, b.frequency) && equalsParam(a.q ?? 1, b.q ?? 1),\n};\n", "import type { AudioEffectData } from \"../registry\";\nimport { Param, lerpParam, equalsParam } from \"../../ramp\";\n\n/** Modulates the clip's amplitude with a low-frequency oscillator for a wobble effect. */\nexport interface TremoloEffect {\n type: 'tremolo';\n /** Modulation rate in Hz (how fast the volume pulses). May be a ramp. */\n rate: Param;\n /** Modulation depth, 0–1. 0 = no effect, 1 = full dips to silence. May be a ramp. */\n depth: Param;\n}\n\nexport const tremoloEffect: AudioEffectData<TremoloEffect> = {\n lerp: (from, to, t) => ({\n type: \"tremolo\",\n rate: lerpParam(from.rate, to.rate, t),\n depth: lerpParam(from.depth, to.depth, t),\n }),\n equals: (a, b) => equalsParam(a.rate, b.rate) && equalsParam(a.depth, b.depth),\n};\n", "import type { AudioEffectData } from \"../registry\";\nimport { Param, lerpParam, equalsParam } from \"../../ramp\";\n\n/** Adds a delayed, fading repeat of the signal (a feedback echo / simple delay). */\nexport interface EchoEffect {\n type: 'echo';\n /** Delay before the first repeat, in seconds. May be a ramp. */\n delay: Param;\n /** Feedback amount, 0–<1. Each repeat is scaled by this; higher = more repeats. May be a ramp. */\n feedback: Param;\n /** Wet/dry mix, 0–1. 0 = dry only, 1 = full wet. Default 0.5. May be a ramp. */\n mix?: Param;\n}\n\nexport const echoEffect: AudioEffectData<EchoEffect> = {\n lerp: (from, to, t) => ({\n type: \"echo\",\n delay: lerpParam(from.delay, to.delay, t),\n feedback: lerpParam(from.feedback, to.feedback, t),\n mix: lerpParam(from.mix ?? 0.5, to.mix ?? 0.5, t),\n }),\n equals: (a, b) =>\n equalsParam(a.delay, b.delay) && equalsParam(a.feedback, b.feedback) && equalsParam(a.mix ?? 0.5, b.mix ?? 0.5),\n};\n", "import { AudioEffect } from \"@/attributes/audio/effects/union\";\nimport { type AudioEffectsInput, resolveAudioEffects } from \"@/attributes/audio/effects/chain\";\nimport type { AttributeOps } from \"@/attributes/shared/operators\";\nimport { gainEffect } from \"./implementations/gain\";\nimport { highPassEffect } from \"./implementations/highpass\";\nimport { lowPassEffect } from \"./implementations/lowpass\";\nimport { tremoloEffect } from \"./implementations/tremolo\";\nimport { echoEffect } from \"./implementations/echo\";\n\n/** Interpolation and equality contract every registered audio effect must implement. */\nexport interface AudioEffectData<T extends AudioEffect> {\n lerp(from: T, to: T, t: number): T;\n equals(a: T, b: T): boolean;\n}\n\n/** Every built-in effect's handler keyed by `type` (a missing one is a type error). Seeded here rather than registered by each effect's module: core is `sideEffects: false`, so a module imported only to run `register` may be dropped by a bundler and the effect would hard-cut instead of interpolating, silently. */\nconst BUILT_IN_EFFECTS: { [K in AudioEffect[\"type\"]]: AudioEffectData<Extract<AudioEffect, { type: K }>> } = {\n gain: gainEffect,\n highpass: highPassEffect,\n lowpass: lowPassEffect,\n tremolo: tremoloEffect,\n echo: echoEffect,\n};\n\nexport class AudioEffectRegistry {\n private static registry = new Map<string, AudioEffectData<AudioEffect>>(\n Object.entries(BUILT_IN_EFFECTS) as [string, AudioEffectData<AudioEffect>][],\n );\n\n /** Throws if the same `type` is registered twice, to catch accidental double-imports. */\n static register<T extends AudioEffect>(type: string, data: AudioEffectData<T>): void {\n if (this.registry.has(type)) {\n throw new Error(`Audio effect \"${type}\" is already registered`);\n }\n this.registry.set(type, data as AudioEffectData<AudioEffect>);\n }\n\n static get(type: string): AudioEffectData<AudioEffect> | undefined {\n return this.registry.get(type);\n }\n\n static has(type: string): boolean {\n return this.registry.has(type);\n }\n\n /** Interpolates two effects, hard-cutting at t = 0.5 when types differ or are unregistered. */\n static lerp(from: AudioEffect, to: AudioEffect, t: number): AudioEffect {\n if (from.type !== to.type) return t < 0.5 ? from : to;\n const data = this.registry.get(from.type);\n return data ? data.lerp(from, to, t) : (t < 0.5 ? from : to);\n }\n\n /** Interpolates two effect arrays of possibly different lengths: indices in only one are kept, matched ones lerped pairwise. */\n static lerpArray(from: AudioEffect[], to: AudioEffect[], t: number): AudioEffect[] {\n const maxLen = Math.max(from.length, to.length);\n const result: AudioEffect[] = [];\n for (let i = 0; i < maxLen; i++) {\n const a = from[i];\n const b = to[i];\n if (a && b) {\n result.push(AudioEffectRegistry.lerp(a, b, t));\n } else if (a) {\n result.push(a);\n } else if (b) {\n result.push(b);\n }\n }\n return result;\n }\n}\n\nexport const audioEffectsOps: AttributeOps<AudioEffectsInput, AudioEffect[]> = {\n resolve: resolveAudioEffects,\n lerp: AudioEffectRegistry.lerpArray,\n};\n", "import { Vector2 } from \"@/attributes/layout/vector2\";\n\n/**\n * A 2D transform stored as the members of a 3x3 matrix `| a c e | b d f | g h i |` (DOM column order), so matrices\n * compose in draw order: `parent.multiply(child)` is the world transform of `child`. Point mapping is\n * `x' = (a·x + c·y + e) / w`, `y' = (b·x + d·y + f) / w`, `w = g·x + h·y + i`.\n *\n * **The bottom row is optional; omitted means `[0 0 1]`**, an ordinary affine transform. A node tilted out of its\n * plane projects through a homography, which does not fit in six numbers; a single matrix type keeps the renderer\n * and the hit test from disagreeing about where a node is.\n */\n/** @internal */\nexport interface Matrix2D {\n a: number; b: number; c: number; d: number; e: number; f: number;\n /** Perspective row, x term. Omitted on an affine transform (means `0`). */\n g?: number;\n /** Perspective row, y term. Omitted on an affine transform (means `0`). */\n h?: number;\n /** Perspective row, constant term. Omitted on an affine transform (means `1`). */\n i?: number;\n}\n\n/** @internal Whether `m` carries a perspective row — i.e. whether `w` is not always 1. */\nexport function isProjective(m: Matrix2D): boolean {\n return (m.g ?? 0) !== 0 || (m.h ?? 0) !== 0 || (m.i ?? 1) !== 1;\n}\n\n/** Guards the perspective divide: clamping a vanishing-line point (`w = 0`) to a tiny same-signed `w` sends it far off-screen instead of poisoning anchors, hit tests and layout with Infinity/NaN. */\nconst MIN_W = 1e-6;\nfunction safeW(w: number): number {\n if (w > MIN_W || w < -MIN_W) return w;\n return w < 0 ? -MIN_W : MIN_W;\n}\n\n/** @internal The identity transform. */\nexport function identity(): Matrix2D {\n return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 };\n}\n\n/** @internal Pure translation by (tx, ty). */\nexport function translation(tx: number, ty: number): Matrix2D {\n return { a: 1, b: 0, c: 0, d: 1, e: tx, f: ty };\n}\n\n/** `m1 · m2`: applies `m2` first, then `m1`. Two affine matrices take the six-member path (every composition in a 3D-free scene); the 3x3 product runs only when a side carries a perspective row. */\n/** @internal */\nexport function multiply(m1: Matrix2D, m2: Matrix2D): Matrix2D {\n if (isProjective(m1) || isProjective(m2)) return multiplyProjective(m1, m2);\n return {\n a: m1.a * m2.a + m1.c * m2.b,\n b: m1.b * m2.a + m1.d * m2.b,\n c: m1.a * m2.c + m1.c * m2.d,\n d: m1.b * m2.c + m1.d * m2.d,\n e: m1.a * m2.e + m1.c * m2.f + m1.e,\n f: m1.b * m2.e + m1.d * m2.f + m1.f,\n };\n}\n\nfunction multiplyProjective(m1: Matrix2D, m2: Matrix2D): Matrix2D {\n const g1 = m1.g ?? 0, h1 = m1.h ?? 0, i1 = m1.i ?? 1;\n const g2 = m2.g ?? 0, h2 = m2.h ?? 0, i2 = m2.i ?? 1;\n return {\n a: m1.a * m2.a + m1.c * m2.b + m1.e * g2,\n c: m1.a * m2.c + m1.c * m2.d + m1.e * h2,\n e: m1.a * m2.e + m1.c * m2.f + m1.e * i2,\n b: m1.b * m2.a + m1.d * m2.b + m1.f * g2,\n d: m1.b * m2.c + m1.d * m2.d + m1.f * h2,\n f: m1.b * m2.e + m1.d * m2.f + m1.f * i2,\n g: g1 * m2.a + h1 * m2.b + i1 * g2,\n h: g1 * m2.c + h1 * m2.d + i1 * h2,\n i: g1 * m2.e + h1 * m2.f + i1 * i2,\n };\n}\n\n/** @internal Map a point through the transform. */\nexport function applyToPoint(m: Matrix2D, p: Vector2): Vector2 {\n const x = m.a * p.x + m.c * p.y + m.e;\n const y = m.b * p.x + m.d * p.y + m.f;\n if (!isProjective(m)) return { x, y };\n const w = safeW((m.g ?? 0) * p.x + (m.h ?? 0) * p.y + (m.i ?? 1));\n return { x: x / w, y: y / w };\n}\n\n/** The inverse, or `null` when `m` is singular (zero scale). Maps a viewport point back into a node's local space for hit testing. */\n/** @internal */\nexport function invert(m: Matrix2D): Matrix2D | null {\n if (isProjective(m)) return invertProjective(m);\n const det = m.a * m.d - m.b * m.c;\n if (det === 0 || !Number.isFinite(det)) return null;\n const inv = 1 / det;\n return {\n a: m.d * inv,\n b: -m.b * inv,\n c: -m.c * inv,\n d: m.a * inv,\n e: (m.c * m.f - m.d * m.e) * inv,\n f: (m.b * m.e - m.a * m.f) * inv,\n };\n}\n\n/** Inverse of a homography (adjugate over determinant); still a homography, so picking keeps working with {@link applyToPoint} on a tilted node. */\nfunction invertProjective(m: Matrix2D): Matrix2D | null {\n const { a, b, c, d, e, f } = m;\n const g = m.g ?? 0, h = m.h ?? 0, i = m.i ?? 1;\n // Cofactors of the 3×3 | a c e | / | b d f | / | g h i |.\n const A = d * i - f * h;\n const C = f * g - b * i;\n const E = b * h - d * g;\n const det = a * A + c * C + e * E;\n if (det === 0 || !Number.isFinite(det)) return null;\n const inv = 1 / det;\n return {\n a: A * inv,\n c: (e * h - c * i) * inv,\n e: (c * f - e * d) * inv,\n b: C * inv,\n d: (a * i - e * g) * inv,\n f: (e * b - a * f) * inv,\n g: E * inv,\n h: (c * g - a * h) * inv,\n i: (a * d - c * b) * inv,\n };\n}\n\n/**\n * The viewport transform a camera scope pushes, in canvas (y-down) space; a transcription of `RenderContext2D.beginCamera`:\n * `translate(vx, vy) · rotate(-heading) · scale(zoom) · translate(-lookAt.x, +lookAt.y)`. `lookAt` is y-up, hence the\n * sign flip; `vx`/`vy` are the viewport centre. Keep in step with {@link nodeLocalMatrix} and the renderer.\n */\n/** @internal */\nexport function cameraMatrix(\n vx: number, vy: number, lookAt: Vector2, zoom: number, heading: number,\n): Matrix2D {\n const rad = (-heading * Math.PI) / 180;\n const cos = Math.cos(rad);\n const sin = Math.sin(rad);\n // rotate(-heading) · scale(zoom): clockwise canvas convention, as in nodeLocalMatrix.\n const a = zoom * cos;\n const b = zoom * sin;\n const c = zoom * -sin;\n const d = zoom * cos;\n // Fold the trailing translate(-lookAt.x, +lookAt.y) into e/f.\n const tx = -lookAt.x;\n const ty = lookAt.y;\n return { a, b, c, d, e: vx + a * tx + c * ty, f: vy + b * tx + d * ty };\n}\n\n/**\n * Local transform for a node, matching the renderer's `RenderContext2D.transform` exactly (canvas y-down):\n * `T(cx + pivotX, cy + pivotY) · R(deg) · S(scale) · T(-pivotX, -pivotY)`. `rotation` is degrees clockwise;\n * `cx`/`cy` are the node's layout-cell origin; the pivot offsets are in pixels.\n */\n/** @internal */\nexport function nodeLocalMatrix(\n cx: number, cy: number, rotation: number, scale: number, pivotX: number, pivotY: number,\n): Matrix2D {\n const rad = (rotation * Math.PI) / 180;\n const cos = Math.cos(rad);\n const sin = Math.sin(rad);\n // R(deg) · S(scale): clockwise rotation in canvas (y-down) is\n // | cos -sin | · | s 0 | = | s·cos -s·sin |\n // | sin cos | | 0 s | | s·sin s·cos |\n const a = scale * cos;\n const b = scale * sin;\n const c = scale * -sin;\n const d = scale * cos;\n // Fold the pivot translations into e/f:\n // T(cx+pivotX, cy+pivotY) · (RS) · T(-pivotX, -pivotY)\n return {\n a, b, c, d,\n e: cx + pivotX - (a * pivotX + c * pivotY),\n f: cy + pivotY - (b * pivotX + d * pivotY),\n };\n}\n\n/** The out-of-plane half of a node's transform: mirrors, the two extra rotation axes, the push along z and the perspective divide. See {@link nodeProjectedMatrix}. */\n/** @internal */\nexport interface Projection3D {\n /** Tilt about the horizontal axis, degrees. Positive tips the top away. */\n rotationX: number;\n /** Tilt about the vertical axis, degrees. Positive swings the right edge away. */\n rotationY: number;\n /**\n * In-plane rotation of the 3D block, degrees clockwise (the Z axis of `Rx · Ry · Rz`). Separate from the node's\n * `rotation`: that is the node's **shape** (box, outline and handles turn with it), this is paint. They add, but\n * editing one never moves the other.\n */\n rotationZ: number;\n /** Push along the view axis in px, applied after the rotations. Inert without `perspective`. */\n depth: number;\n /** Viewer distance in px. `0` is no perspective at all — a parallel projection. */\n perspective: number;\n /** Mirror across the node's vertical centre line. */\n flipHorizontal: boolean;\n /** Mirror across the node's horizontal centre line. */\n flipVertical: boolean;\n}\n\n/** @internal Every field of a {@link Projection3D} at rest — the plain 2D node. */\nexport const NO_PROJECTION_3D: Projection3D = {\n rotationX: 0,\n rotationY: 0,\n rotationZ: 0,\n depth: 0,\n perspective: 0,\n flipHorizontal: false,\n flipVertical: false,\n};\n\n/** Whether `p` asks for anything {@link nodeLocalMatrix} cannot express; the gate in front of every projective path, so 3D-free scenes keep the affine matrix and `multiply`. */\n/** @internal */\nexport function hasProjection3D(p: Projection3D): boolean {\n return (\n p.rotationX !== 0 ||\n p.rotationY !== 0 ||\n p.rotationZ !== 0 ||\n p.flipHorizontal ||\n p.flipVertical ||\n (p.perspective !== 0 && p.depth !== 0)\n );\n}\n\n/**\n * Whether a plane has turned its back on the viewer (behind `backfaceVisible`). Read off the tilt alone: the normal's\n * z is `cos(rotationX)·cos(rotationY)`; in-plane rotation and, deliberately, a *mirror* don't change it. CSS derives\n * it from the whole matrix, so `scaleX(-1)` hides the element, a surprising way to lose a node you only flipped.\n */\n/** @internal */\nexport function facesAway(rotationX: number, rotationY: number): boolean {\n const rad = Math.PI / 180;\n return Math.cos(rotationX * rad) * Math.cos(rotationY * rad) < 0;\n}\n\n/**\n * A node's local transform with the out-of-plane half folded in; reduces exactly to {@link nodeLocalMatrix} when\n * {@link hasProjection3D} is false. Composition, innermost first:\n *\n * `T(pivot) · P(perspective) · Tz(depth) · Rx · Ry · Rz(rotationZ + rotation) · S(scale) · T(-pivot) · F(flip)`\n *\n * The mirrors reflect about the node's own centre, not the pivot, so flipping cannot move the node. The Z angle is\n * the sum of `rotation` (shape) and {@link Projection3D.rotationZ} (paint), which stay two numbers (see\n * `Node2D._localMatrix`). Content is planar (`z = 0`), so everything collapses to a 3x3 homography over `(x, y, 1)`;\n * the projected z survives only as the perspective row. Parameters as {@link nodeLocalMatrix}, `p` the out-of-plane fields.\n */\n/** @internal */\nexport function nodeProjectedMatrix(\n cx: number, cy: number, rotation: number, scale: number, pivotX: number, pivotY: number,\n p: Projection3D,\n): Matrix2D {\n if (!hasProjection3D(p)) {\n return nodeLocalMatrix(cx, cy, rotation, scale, pivotX, pivotY);\n }\n const rad = Math.PI / 180;\n const ca = Math.cos(p.rotationX * rad), sa = Math.sin(p.rotationX * rad);\n const cb = Math.cos(p.rotationY * rad), sb = Math.sin(p.rotationY * rad);\n // The two in-plane rotations compose into one angle — see the note above.\n const cz = (rotation + p.rotationZ) * rad;\n const cc = Math.cos(cz), sc = Math.sin(cz);\n\n // The two columns of Rx·Ry·Rz that a z = 0 point can reach, scaled.\n const A = cb * cc * scale;\n const C = -cb * sc * scale;\n const B = (sa * sb * cc + ca * sc) * scale;\n const D = (ca * cc - sa * sb * sc) * scale;\n // The row that would have been the projected z, had we kept one.\n const G = (sa * sc - ca * sb * cc) * scale;\n const H = (ca * sb * sc + sa * cc) * scale;\n\n // Perspective: a point at depth z lands at x/w with w = 1 - z/perspective.\n // No perspective means a parallel projection — z is simply dropped, w stays\n // 1, and the result is affine (which is also why `depth` alone does nothing).\n const invP = p.perspective !== 0 ? 1 / p.perspective : 0;\n const g = -G * invP;\n const h = -H * invP;\n // The z the pivot itself sits at: -(G·pivotX + H·pivotY) is what the shift to\n // pivot-relative coordinates leaves in the z row, and `depth` is the push\n // along it, applied after the tilt (so it moves the whole tilted plane).\n const i = 1 - (p.depth - (G * pivotX + H * pivotY)) * invP;\n\n // Numerators about the pivot, then the trailing translate folded in. A\n // translate composes onto a homography as `+ t·w`, hence the g/h/i terms.\n const tx = cx + pivotX;\n const ty = cy + pivotY;\n\n // The mirrors, applied innermost and about the node's own centre (a final column negation, `M · diag(fx, fy, 1)`).\n // Not about the pivot like everything else: composing with the pivot, as CSS's `scaleX(-1)` does, makes a node\n // hinged off-centre swing when flipped. The frame is already centred, so a column scale leaves `e`/`f`/`i`\n // untouched and \"a flip cannot move the node\" falls out of the arithmetic.\n const fx = p.flipHorizontal ? -1 : 1;\n const fy = p.flipVertical ? -1 : 1;\n return {\n a: (A + tx * g) * fx,\n c: (C + tx * h) * fy,\n e: -(A * pivotX + C * pivotY) + tx * i,\n b: (B + ty * g) * fx,\n d: (D + ty * h) * fy,\n f: -(B * pivotX + D * pivotY) + ty * i,\n g: g * fx,\n h: h * fy,\n i,\n };\n}\n", "import { lerpNumber } from \"@/tween/lerp\";\nimport type { Matrix2D, Projection3D } from \"./matrix2d\";\nimport type { Vector2 } from \"./vector2\";\n\n/** The maths of a 2.5D space: flat nodes in one 3D frame seen through a single orbiting camera. Works in the space root's canvas frame (x right, y **down**, z toward the viewer), so a node's transform is {@link import(\"./matrix2d\").nodeProjectedMatrix}'s rotation block with the perspective divide lifted out and applied once, by the camera. */\n\n/** A point a camera is aimed at. `z` is depth, toward the viewer, as a node's `depth` is. */\nexport interface LookAt extends Vector2 {\n z?: number;\n}\n\n/** Lerp a {@link LookAt}, leaving `z` off when neither end has one so a flat camera stays two numbers. */\nexport function lerpLookAt(from: LookAt, to: LookAt, t: number): LookAt {\n const out: LookAt = { x: lerpNumber(from.x, to.x, t), y: lerpNumber(from.y, to.y, t) };\n if (from.z !== undefined || to.z !== undefined) out.z = lerpNumber(from.z ?? 0, to.z ?? 0, t);\n return out;\n}\n\n/**\n * A space root's camera for one frame. `orbit`/`elevation` mean what they do on `Camera3D` (`render3d/camera.ts`):\n * orbit 0 is head-on, positive orbit moves toward +x, positive elevation lifts. `perspective` is the distance from\n * `lookAt` at `dolly: 0` (CSS convention, so the focus plane draws 1:1; `0` is parallel). `zoom` and `heading` apply\n * after projection: lens zoom and roll.\n */\n/** @internal */\nexport interface SpaceCamera {\n perspective: number;\n orbit: number;\n elevation: number;\n dolly: number;\n /** Authored y-up, like every other scene point. */\n lookAt: LookAt;\n zoom: number;\n heading: number;\n viewportX: number;\n viewportY: number;\n}\n\n/** Row-major 3×4 affine transform: `[r00 r01 r02 tx, r10 r11 r12 ty, r20 r21 r22 tz]`. */\n/** @internal */\nexport type Affine3 = readonly number[];\n\n/** @internal `a · b` — applies `b` first, the same order as `matrix2d`'s `multiply`. */\nexport function multiplyAffine3(a: Affine3, b: Affine3): Affine3 {\n const out = new Array<number>(12);\n for (let r = 0; r < 3; r++) {\n const a0 = a[r * 4], a1 = a[r * 4 + 1], a2 = a[r * 4 + 2], a3 = a[r * 4 + 3];\n out[r * 4] = a0 * b[0] + a1 * b[4] + a2 * b[8];\n out[r * 4 + 1] = a0 * b[1] + a1 * b[5] + a2 * b[9];\n out[r * 4 + 2] = a0 * b[2] + a1 * b[6] + a2 * b[10];\n out[r * 4 + 3] = a0 * b[3] + a1 * b[7] + a2 * b[11] + a3;\n }\n return out;\n}\n\n/**\n * A node's transform in its parent's 3D frame: {@link import(\"./matrix2d\").nodeProjectedMatrix} without the perspective,\n * which in a space belongs to the camera: `T(cx + pivotX, cy + pivotY, depth) · Rx · Ry · Rz(rotation + rotationZ) ·\n * S(scale) · T(-pivot) · F(flip)`. The scale is uniform in all three axes, so a scaled group scales its children's depth too.\n */\n/** @internal */\nexport function nodeSpaceMatrix(\n cx: number, cy: number, rotation: number, scale: number, pivotX: number, pivotY: number,\n p: Projection3D,\n): Affine3 {\n const rad = Math.PI / 180;\n const ca = Math.cos(p.rotationX * rad), sa = Math.sin(p.rotationX * rad);\n const cb = Math.cos(p.rotationY * rad), sb = Math.sin(p.rotationY * rad);\n const cz = (rotation + p.rotationZ) * rad;\n const cc = Math.cos(cz), sc = Math.sin(cz);\n\n const r00 = cb * cc * scale, r01 = -cb * sc * scale, r02 = sb * scale;\n const r10 = (sa * sb * cc + ca * sc) * scale, r11 = (ca * cc - sa * sb * sc) * scale, r12 = -sa * cb * scale;\n const r20 = (sa * sc - ca * sb * cc) * scale, r21 = (ca * sb * sc + sa * cc) * scale, r22 = ca * cb * scale;\n\n // Mirrors negate the two in-plane columns only, about the node's own centre —\n // the same in-place reflection `nodeProjectedMatrix` makes.\n const fx = p.flipHorizontal ? -1 : 1;\n const fy = p.flipVertical ? -1 : 1;\n return [\n r00 * fx, r01 * fy, r02, cx + pivotX - (r00 * pivotX + r01 * pivotY),\n r10 * fx, r11 * fy, r12, cy + pivotY - (r10 * pivotX + r11 * pivotY),\n r20 * fx, r21 * fy, r22, p.depth - (r20 * pivotX + r21 * pivotY),\n ];\n}\n\n/** The camera's view of the root frame: `T(0, 0, dolly) · R(camera)ᵀ · T(-lookAt)`. Built from the camera's own axes, not a look-at basis, so there is no pole to clamp: elevation past 90° keeps turning. */\n/** @internal */\nexport function spaceViewMatrix(cam: SpaceCamera): Affine3 {\n const rad = Math.PI / 180;\n const sa = Math.sin(cam.orbit * rad), ca = Math.cos(cam.orbit * rad);\n const se = Math.sin(cam.elevation * rad), ce = Math.cos(cam.elevation * rad);\n // Rows: the camera's right, screen-down and toward-camera axes.\n const r0 = ca, r1 = 0, r2 = -sa;\n const d0 = sa * se, d1 = ce, d2 = ca * se;\n const f0 = sa * ce, f1 = -se, f2 = ca * ce;\n const tx = cam.lookAt.x, ty = -cam.lookAt.y, tz = cam.lookAt.z ?? 0;\n return [\n r0, r1, r2, -(r0 * tx + r1 * ty + r2 * tz),\n d0, d1, d2, -(d0 * tx + d1 * ty + d2 * tz),\n f0, f1, f2, -(f0 * tx + f1 * ty + f2 * tz) + cam.dolly,\n ];\n}\n\n/** Projects a view-space transform to the screen: the homography taking a node's local `(x, y, 1)` to the root's canvas, perspective divide, zoom and roll included. At rest it is exactly `cameraMatrix · local`, so turning a space on is invisible until something moves in depth. */\n/** @internal */\nexport function spaceScreenMatrix(cam: SpaceCamera, view: Affine3): Matrix2D {\n const invP = cam.perspective > 0 ? 1 / cam.perspective : 0;\n const wx = -view[8] * invP;\n const wy = -view[9] * invP;\n const w0 = 1 - view[11] * invP;\n\n const rad = (-cam.heading * Math.PI) / 180;\n const k = cam.zoom;\n const c00 = k * Math.cos(rad), c01 = -k * Math.sin(rad);\n const c10 = k * Math.sin(rad), c11 = k * Math.cos(rad);\n const vx = cam.viewportX, vy = cam.viewportY;\n\n const m: Matrix2D = {\n a: c00 * view[0] + c01 * view[4] + vx * wx,\n c: c00 * view[1] + c01 * view[5] + vx * wy,\n e: c00 * view[3] + c01 * view[7] + vx * w0,\n b: c10 * view[0] + c11 * view[4] + vy * wx,\n d: c10 * view[1] + c11 * view[5] + vy * wy,\n f: c10 * view[3] + c11 * view[7] + vy * w0,\n };\n // A parallel projection stays affine, so it keeps the six-number fast paths.\n if (invP !== 0) {\n m.g = wx;\n m.h = wy;\n m.i = w0;\n }\n return m;\n}\n\n/** A node's box in view space: what sorting, culling and the backface test read. */\n/** @internal */\nexport interface SpacePlane {\n /** The four corners, `x, y, z` each, top-left clockwise. */\n corners: readonly number[];\n cx: number;\n cy: number;\n cz: number;\n /** Unit normal, pointing out of the node's front. */\n nx: number;\n ny: number;\n nz: number;\n}\n\n/** `box` (the node's ink, centred and y-down) through `view`. The normal is the transform's z column, which a mirror never touches: a flip reflects without turning around, so it cannot show its back. */\n/** @internal */\nexport function spacePlane(view: Affine3, box: { x: number; y: number; width: number; height: number }): SpacePlane {\n const hw = box.width / 2, hh = box.height / 2;\n const us = [box.x - hw, box.x + hw, box.x + hw, box.x - hw];\n const vs = [box.y - hh, box.y - hh, box.y + hh, box.y + hh];\n const corners = new Array<number>(12);\n for (let i = 0; i < 4; i++) {\n const u = us[i], v = vs[i];\n corners[i * 3] = view[0] * u + view[1] * v + view[3];\n corners[i * 3 + 1] = view[4] * u + view[5] * v + view[7];\n corners[i * 3 + 2] = view[8] * u + view[9] * v + view[11];\n }\n const nl = Math.hypot(view[2], view[6], view[10]) || 1;\n return {\n corners,\n cx: view[0] * box.x + view[1] * box.y + view[3],\n cy: view[4] * box.x + view[5] * box.y + view[7],\n cz: view[8] * box.x + view[9] * box.y + view[11],\n nx: view[2] / nl,\n ny: view[6] / nl,\n nz: view[10] / nl,\n };\n}\n\n/** Below this `w` a point is at or behind the camera. Not zero: a point just in front of the lens projects so far out that float32 path maths loses it. */\nconst NEAR_W = 0.01;\n\n/** Within this fraction of edge-on, a plane projects to a sliver narrower than a pixel. */\nconst EDGE_ON = 1e-3;\n\n/** `side` is positive when the camera is in front of `plane`; `edgeOn` when it lies (almost) in the plane. */\n/** @internal */\nexport function cameraSide(cam: SpaceCamera, plane: SpacePlane): { side: number; edgeOn: boolean } {\n if (cam.perspective > 0) {\n const dx = -plane.cx, dy = -plane.cy, dz = cam.perspective - plane.cz;\n const side = plane.nx * dx + plane.ny * dy + plane.nz * dz;\n return { side, edgeOn: Math.abs(side) <= EDGE_ON * Math.hypot(dx, dy, dz) };\n }\n return { side: plane.nz, edgeOn: Math.abs(plane.nz) <= EDGE_ON };\n}\n\n/** How much of `plane` is in front of the camera. A parallel projection has no near plane. */\n/** @internal */\nexport function nearCoverage(cam: SpaceCamera, plane: SpacePlane): \"all\" | \"some\" | \"none\" {\n if (cam.perspective <= 0) return \"all\";\n let inFront = 0;\n for (let i = 0; i < 4; i++) {\n if (1 - plane.corners[i * 3 + 2] / cam.perspective > NEAR_W) inFront++;\n }\n return inFront === 4 ? \"all\" : inFront === 0 ? \"none\" : \"some\";\n}\n\n/** The part of `box` (local, y-down) in front of the camera under homography `screen`, as a polygon in the same frame, or `null` when none is. `margin` grows the box first so a shadow or stroke past the ink isn't cut at its edge. */\n/** @internal */\nexport function nearCutPolygon(\n screen: Matrix2D,\n box: { x: number; y: number; width: number; height: number },\n margin: number,\n): Vector2[] | null {\n const g = screen.g ?? 0, h = screen.h ?? 0, i = screen.i ?? 1;\n const hw = box.width / 2 + margin, hh = box.height / 2 + margin;\n const square: Vector2[] = [\n { x: box.x - hw, y: box.y - hh },\n { x: box.x + hw, y: box.y - hh },\n { x: box.x + hw, y: box.y + hh },\n { x: box.x - hw, y: box.y + hh },\n ];\n const w = (p: Vector2) => g * p.x + h * p.y + i - NEAR_W;\n const out: Vector2[] = [];\n for (let k = 0; k < square.length; k++) {\n const a = square[k], b = square[(k + 1) % square.length];\n const wa = w(a), wb = w(b);\n if (wa >= 0) out.push(a);\n if ((wa >= 0) !== (wb >= 0)) {\n const t = wa / (wa - wb);\n out.push({ x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t });\n }\n }\n return out.length >= 3 ? out : null;\n}\n\n/** Two points closer than this in view space (px) count as touching. */\nconst SIDE_EPS = 0.01;\n\n/** Which side of `a`'s plane `b` lies on from the camera: `1` in front, `-1` behind, `0` straddling or coplanar. `camSide` is `a`'s {@link cameraSide}. */\nfunction sideOf(a: SpacePlane, b: SpacePlane, camSide: number): number {\n let front = 0, back = 0;\n for (let i = 0; i < 4; i++) {\n const d = a.nx * (b.corners[i * 3] - a.cx) + a.ny * (b.corners[i * 3 + 1] - a.cy) + a.nz * (b.corners[i * 3 + 2] - a.cz);\n if (d > SIDE_EPS) front++;\n else if (d < -SIDE_EPS) back++;\n }\n if (front === 0 && back === 0) return 0;\n const facing = camSide > 0 ? 1 : -1;\n if (back === 0) return facing;\n if (front === 0) return -facing;\n return 0;\n}\n\nfunction farness(cam: SpaceCamera, p: SpacePlane): number {\n if (cam.perspective > 0) return p.cx * p.cx + p.cy * p.cy + (cam.perspective - p.cz) ** 2;\n return -p.cz;\n}\n\n/**\n * `-1` when `a` must paint before `b`, `1` after, `0` when either order is right (coplanar siblings keep authored\n * order). A plane test first, exact for anything that does not intersect: parallel layers (a parallax stack) and\n * coplanar ones resolve there. Only planes cutting through each other fall back to centre distance; no painter's\n * order is right for those anyway.\n */\nfunction compareInSpace(cam: SpaceCamera, a: SpacePlane, b: SpacePlane): number {\n const ca = cameraSide(cam, a);\n if (!ca.edgeOn) {\n const s = sideOf(a, b, ca.side);\n if (s !== 0) return s > 0 ? -1 : 1;\n if (isCoplanar(a, b)) return 0;\n }\n const cb = cameraSide(cam, b);\n if (!cb.edgeOn) {\n const s = sideOf(b, a, cb.side);\n if (s !== 0) return s > 0 ? 1 : -1;\n }\n const fa = farness(cam, a), fb = farness(cam, b);\n return fa === fb ? 0 : fa > fb ? -1 : 1;\n}\n\nfunction isCoplanar(a: SpacePlane, b: SpacePlane): boolean {\n for (let i = 0; i < 4; i++) {\n const d = a.nx * (b.corners[i * 3] - a.cx) + a.ny * (b.corners[i * 3 + 1] - a.cy) + a.nz * (b.corners[i * 3 + 2] - a.cz);\n if (Math.abs(d) > SIDE_EPS) return false;\n }\n return true;\n}\n\n/** A stage's camera as its props state it — what a host reads off the root row. */\nexport interface SpaceCameraProps {\n perspective: number;\n orbit: number;\n elevation: number;\n dolly: number;\n lookAt: LookAt;\n zoom: number;\n heading: number;\n}\n\n/** A point in a space, y-up like every scene point, `z` toward the viewer. */\nexport interface SpacePoint {\n x: number;\n y: number;\n z: number;\n}\n\nfunction rootCamera(props: SpaceCameraProps): SpaceCamera {\n return { ...props, viewportX: 0, viewportY: 0 };\n}\n\n/** The space's camera maths for a host drawing over the picture (a gizmo aiming the camera), using the renderer's own arithmetic so it can't drift. Points are in viewport space: origin at the centre, y-up. */\nexport const space3dOps = {\n lerpLookAt,\n\n /** Where scene point `point` lands in the viewport through `camera`, or `null` behind the lens. */\n project(camera: SpaceCameraProps, point: LookAt): Vector2 | null {\n const cam = rootCamera(camera);\n const v = spaceViewMatrix(cam);\n const x = point.x, y = -point.y, z = point.z ?? 0;\n const vx = v[0] * x + v[1] * y + v[2] * z + v[3];\n const vy = v[4] * x + v[5] * y + v[6] * z + v[7];\n const vz = v[8] * x + v[9] * y + v[10] * z + v[11];\n const w = cam.perspective > 0 ? 1 - vz / cam.perspective : 1;\n if (w <= NEAR_W) return null;\n const rad = (-cam.heading * Math.PI) / 180;\n const px = (cam.zoom * vx) / w, py = (cam.zoom * vy) / w;\n return {\n x: Math.cos(rad) * px - Math.sin(rad) * py,\n y: -(Math.sin(rad) * px + Math.cos(rad) * py),\n };\n },\n\n /** The displacement at the camera's focus, in the plane facing it through `lookAt`, that moves the picture there by `vector`. Inverse of a pan: dragging the picture by `vector` moves `lookAt` by minus this. */\n focusVector(camera: SpaceCameraProps, vector: Vector2): SpacePoint {\n const cam = rootCamera(camera);\n const rad = (-cam.heading * Math.PI) / 180;\n const k = cam.zoom || 1;\n const cx = vector.x, cy = -vector.y;\n const px = (Math.cos(rad) * cx + Math.sin(rad) * cy) / k;\n const py = (-Math.sin(rad) * cx + Math.cos(rad) * cy) / k;\n // A focus pushed nearer by the dolly draws larger, so it moves less for the same drag.\n const w = cam.perspective > 0 ? 1 - cam.dolly / cam.perspective : 1;\n const v = spaceViewMatrix(cam);\n const ux = px * w, uy = py * w;\n // The view's first two rows are the camera's right and screen-down axes.\n return {\n x: ux * v[0] + uy * v[4],\n y: -(ux * v[1] + uy * v[5]),\n z: ux * v[2] + uy * v[6],\n };\n },\n};\n\n/** Past this many siblings the pairwise order costs more than it is worth, and the centres decide. */\nconst PAIRWISE_LIMIT = 96;\n\n/** The order to paint siblings in, far to near, as indices into `planes`. Pairwise {@link compareInSpace} relations become edges and a stable topological sort taking the lowest ready index keeps `layerOrder` where geometry has no opinion. A cycle (which no painter's order can draw) is broken at its farthest node. */\n/** @internal */\nexport function spacePaintOrder(cam: SpaceCamera, planes: readonly SpacePlane[]): number[] {\n const n = planes.length;\n if (n > PAIRWISE_LIMIT) {\n return planes\n .map((_, i) => i)\n .sort((a, b) => farness(cam, planes[b]) - farness(cam, planes[a]) || a - b);\n }\n\n const after: number[][] = Array.from({ length: n }, () => []);\n const blockers = new Array<number>(n).fill(0);\n for (let i = 0; i < n; i++) {\n for (let j = i + 1; j < n; j++) {\n const r = compareInSpace(cam, planes[i], planes[j]);\n if (r < 0) { after[i].push(j); blockers[j]++; }\n else if (r > 0) { after[j].push(i); blockers[i]++; }\n }\n }\n\n const order: number[] = [];\n const done = new Array<boolean>(n).fill(false);\n while (order.length < n) {\n let next = -1;\n for (let i = 0; i < n; i++) {\n if (!done[i] && blockers[i] === 0) { next = i; break; }\n }\n if (next === -1) {\n let far = -Infinity;\n for (let i = 0; i < n; i++) {\n if (done[i]) continue;\n const f = farness(cam, planes[i]);\n if (f > far) { far = f; next = i; }\n }\n }\n done[next] = true;\n order.push(next);\n for (const j of after[next]) blockers[j]--;\n }\n return order;\n}\n", "import { lerpNumber } from \"@/tween/lerp\";\nimport type { AttributeOps } from \"@/attributes/shared/operators\";\n\nexport interface Size2D {\n width: number;\n height: number;\n}\n\n/** The {@link Size2D} attribute's op set: `lerp` interpolates `width`/`height` independently; `expand` fills the `size` shorthand (same value on both axes) into `width`/`height` in place. Explicit `width`/`height` win (`{ size: 200, width: 100 }` keeps `width: 100`, fills `height: 200`). A reactive `size: () => SizeInput` binds both axes to the callback, evaluated per axis. */\nexport const size2DOps: AttributeOps<Size2D, Size2D> & { expand(props: Record<string, unknown>): void } = {\n resolve: (value) => value,\n lerp: (from, to, t) => ({ width: lerpNumber(from.width, to.width, t), height: lerpNumber(from.height, to.height, t) }),\n expand: (props) => {\n if (props.size === undefined) return;\n if (props.width === undefined) props.width = props.size;\n if (props.height === undefined) props.height = props.size;\n },\n};\n\n/** Sizing behavior for a node dimension: `\"fill\"` expands to fill the parent's space, `\"hug\"` shrinks to the node's own content. */\n/** @internal */\nexport type SizeType = \"fill\" | \"hug\";\n\n/** @internal */\nexport type SizeInput = SizeType | number;\n\n/** The `SizeInput` op set (`width`/`height`'s): `lerp` interpolates numbers and hard-switches at t=1 when either end is a keyword; `resolveLayout` turns a `SizeInput` into a concrete number given the available space and the size contents need; `isAuto` reports whether a dimension needs layout to resolve at all (a keyword). */\nexport const sizeInputOps: AttributeOps<SizeInput, SizeInput> & {\n resolveLayout(input: SizeInput, availableSize: number, contentSize: number): number;\n isAuto(input: SizeInput): boolean;\n} = {\n resolve: (value) => value,\n lerp: (from, to, t) => {\n if (typeof from === \"number\" && typeof to === \"number\") {\n return lerpNumber(from, to, t);\n }\n return t === 1 ? to : from;\n },\n resolveLayout: (input, availableSize, contentSize) => {\n if (typeof input === \"number\") return input;\n if (input === \"fill\") return availableSize;\n if (input === \"hug\") return contentSize;\n return availableSize;\n },\n isAuto: (input) => typeof input !== \"number\",\n};\n", "/** Every text operation on one object: `textOps` carries the attribute's `resolve`/`lerp` plus what a `TextStyle` needs (preset lookup, merge, a style's resolve/lerp pair) and span flattening. The two defaults cascades (`applyTextDefaults` beside `DefaultTextStyle`, `applyGraphicsTextDefaults` beside `draw()`) belong to their channels, not here. */\nimport type { AttributeOps } from \"@/attributes/shared/operators\";\nimport { fillOps } from \"@/attributes/shape/fill/registry\";\nimport type { FillResolved } from \"@/attributes/shape/fill/union\";\nimport { getTypographyPreset } from \"@/attributes/shape/fill/color/parser\";\nimport { strokeOps, type StrokeResolved } from \"@/attributes/shape/stroke/stroke\";\nimport { shadowOps, type ShadowResolved } from \"@/attributes/shape/shadow/shadow\";\nimport { lerpNumber } from \"@/tween/lerp\";\nimport type { ResolvedTextSpan, TextCase, TextShapingKey, TextSpan, TextStyle } from \"./types\";\n\nexport const TEXT_STYLE_KEYS = [\n 'fontFamily', 'fontSize', 'fontWeight', 'fontStyle',\n 'letterSpacing', 'lineHeight', 'textAlign', 'fill', 'stroke', 'shadow',\n] as const satisfies readonly (keyof TextStyle)[];\n\n/** Keys a drawn `text`/`richText` op can inherit; `fill`/`stroke`/`shadow` are absent because in a `Graphics2D` they are group-scoped ops, and defaulting one would change which shapes the group's paint covers. */\nexport const TEXT_SHAPING_KEYS = [\n 'fontFamily', 'fontSize', 'fontWeight', 'fontStyle',\n 'letterSpacing', 'lineHeight', 'textAlign',\n] as const satisfies readonly TextShapingKey[];\n\n/** A style that sets nothing. Frozen and shared, so the empty case allocates nothing. */\nexport const EMPTY_TEXT_STYLE: TextStyle = Object.freeze({});\n\n\nexport interface TextOps {\n /** A `theme.typography` preset (case-insensitive), or {@link EMPTY_TEXT_STYLE} when none is registered. */\n preset(name: string): TextStyle;\n /** The keys `over` sets, laid onto `base`. Returns `base` itself when `over` sets nothing. */\n mergeStyle(base: TextStyle, over: TextStyle | undefined): TextStyle;\n /** `style ?? previous` per field, paints resolved. Idempotent, like every mapper. */\n resolveStyle(style: TextStyle | undefined, previous: TextStyle): TextStyle;\n /** Interpolates two font sizes; `'autofit'` is a mode, not a magnitude, so it steps at the midpoint. */\n lerpFontSize(a: number | \"autofit\" | undefined, b: number | \"autofit\" | undefined, t: number): number | \"autofit\" | undefined;\n /** Interpolate two resolved styles; categorical and one-sided fields step at the midpoint. */\n lerpStyle(from: TextStyle, to: TextStyle, t: number): TextStyle;\n /** A style as `Text` constructor props: unset keys dropped, the family falling back to the host's. */\n styleProps(style: TextStyle): Record<string, unknown>;\n\n /** A span tree flattened against `base`: its text-bearing spans, in document order. */\n flatten(spans: readonly TextSpan[], base: Omit<ResolvedTextSpan, \"text\">): ResolvedTextSpan[];\n\n /** `text` recased **at its own length**: a character whose mapping would add characters (`ß` → `SS`) keeps its own form, since run offsets, selections and caret slots index the string as typed. */\n applyCase(text: string, textCase: TextCase): string;\n}\n\n\nexport const textOps: AttributeOps<string, string> & TextOps = {\n // A string needs no normalization.\n resolve: (value) => value,\n lerp,\n\n preset,\n mergeStyle,\n resolveStyle,\n lerpStyle,\n lerpFontSize,\n styleProps,\n\n flatten,\n\n applyCase,\n};\n\n\n/** Types and untypes: the common prefix and suffix hold still while `from`'s differing middle shrinks away and `to`'s grows in. */\nfunction lerp(from: string, to: string, t: number): string {\n if (t <= 0) return from;\n if (t >= 1) return to;\n\n let pre = 0;\n const maxPre = Math.min(from.length, to.length);\n while (pre < maxPre && from.charCodeAt(pre) === to.charCodeAt(pre)) pre++;\n\n let suf = 0;\n const maxSuf = Math.min(from.length - pre, to.length - pre);\n while (\n suf < maxSuf &&\n from.charCodeAt(from.length - 1 - suf) === to.charCodeAt(to.length - 1 - suf)\n ) suf++;\n\n const removeLen = from.length - pre - suf;\n const addLen = to.length - pre - suf;\n const totalLen = removeLen + addLen;\n if (totalLen === 0) return to;\n\n const prefix = from.substring(0, pre);\n const suffix = from.substring(from.length - suf);\n const split = removeLen / totalLen;\n\n if (t < split) {\n const localT = split === 0 ? 1 : t / split;\n const midLen = Math.round(removeLen * (1 - localT));\n return prefix + from.substring(pre, pre + midLen) + suffix;\n }\n const localT = split === 1 ? 1 : (t - split) / (1 - split);\n const midLen = Math.round(addLen * localT);\n return prefix + to.substring(pre, pre + midLen) + suffix;\n}\n\n// Read per call rather than cached, so a `setTheme` between frames needs no invalidation.\nfunction preset(name: string): TextStyle {\n return (getTypographyPreset(name) as TextStyle | undefined) ?? EMPTY_TEXT_STYLE;\n}\n\nfunction mergeStyle(base: TextStyle, over: TextStyle | undefined): TextStyle {\n let out: Record<string, unknown> | null = null;\n for (const key of TEXT_STYLE_KEYS) {\n const value = over?.[key];\n if (value !== undefined) (out ??= { ...base })[key] = value;\n }\n return (out as TextStyle | null) ?? base;\n}\n\nfunction resolveStyle(style: TextStyle | undefined, previous: TextStyle): TextStyle {\n const s = style ?? {};\n return {\n fontFamily: s.fontFamily ?? previous.fontFamily,\n fontSize: s.fontSize ?? previous.fontSize,\n fontWeight: s.fontWeight ?? previous.fontWeight,\n fontStyle: s.fontStyle ?? previous.fontStyle,\n letterSpacing: s.letterSpacing ?? previous.letterSpacing,\n lineHeight: s.lineHeight ?? previous.lineHeight,\n textAlign: s.textAlign ?? previous.textAlign,\n fill: fillOps.resolve(s.fill ?? previous.fill ?? []),\n stroke: strokeOps.resolve(s.stroke ?? previous.stroke ?? []),\n shadow: shadowOps.resolve(s.shadow ?? previous.shadow ?? []),\n };\n}\n\nfunction lerpStyle(from: TextStyle, to: TextStyle, t: number): TextStyle {\n return {\n fontFamily: t < 0.5 ? from.fontFamily : to.fontFamily,\n fontSize: lerpFontSize(from.fontSize, to.fontSize, t),\n fontWeight: lerpOptionalNumber(from.fontWeight, to.fontWeight, t),\n fontStyle: t < 0.5 ? from.fontStyle : to.fontStyle,\n letterSpacing: lerpOptionalNumber(from.letterSpacing, to.letterSpacing, t),\n lineHeight: lerpOptionalNumber(from.lineHeight, to.lineHeight, t),\n textAlign: t < 0.5 ? from.textAlign : to.textAlign,\n fill: fillOps.lerp(from.fill as FillResolved[], to.fill as FillResolved[], t),\n stroke: strokeOps.lerp(from.stroke as StrokeResolved[], to.stroke as StrokeResolved[], t),\n shadow: shadowOps.lerp(from.shadow as ShadowResolved[], to.shadow as ShadowResolved[], t),\n };\n}\n\n// An `undefined` key spread onto a node is stored as a value, so unset keys are dropped. The base is a fresh object per\n// call because `mergeStyle` returns it as-is when `style` sets nothing, and the frozen `EMPTY_TEXT_STYLE` would be handed\n// out as props. `fontFamily` is deliberately not backfilled from `hostTextFamily()`: that would make the component's own\n// theme an author-set prop, and `applyTextDefaults` skips keys the props already carry, so `<DefaultTextStyle>` and\n// `theme.typography.default` would never be consulted. Unset, the host family stays last, in `requireFontFamily`.\nfunction styleProps(style: TextStyle): Record<string, unknown> {\n return mergeStyle({}, style) as Record<string, unknown>;\n}\n\nfunction flatten(spans: readonly TextSpan[], base: Omit<ResolvedTextSpan, \"text\">): ResolvedTextSpan[] {\n const out: ResolvedTextSpan[] = [];\n const walk = (span: TextSpan, inherited: Omit<ResolvedTextSpan, \"text\">): void => {\n const merged = {\n fontFamily: span.fontFamily ?? inherited.fontFamily,\n fontSize: span.fontSize ?? inherited.fontSize,\n fontWeight: span.fontWeight ?? inherited.fontWeight,\n fontStyle: span.fontStyle ?? inherited.fontStyle,\n letterSpacing: span.letterSpacing ?? inherited.letterSpacing,\n fill: span.fill != null ? fillOps.resolve(span.fill) : inherited.fill,\n stroke: span.stroke != null ? strokeOps.resolve(span.stroke) : inherited.stroke,\n };\n if (span.text) out.push({ text: span.text, ...merged });\n for (const child of span.children ?? []) walk(child, merged);\n };\n for (const span of spans) walk(span, base);\n return out;\n}\n\n// A letter, digit or apostrophe continues a word, so `don't` and `3rd` keep\n// their second halves as typed while `well-known` becomes `Well-Known`.\nconst WORD_CHAR = /[\\p{L}\\p{N}'\\u2019]/u;\n\nfunction applyCase(text: string, textCase: TextCase): string {\n if (textCase !== 'upper' && textCase !== 'lower' && textCase !== 'title') return text;\n let out = \"\";\n let prev = \"\";\n for (const ch of text) {\n const recase = textCase === 'upper' || (textCase === 'title' && !WORD_CHAR.test(prev));\n const mapped = textCase === 'lower' ? ch.toLowerCase() : recase ? ch.toUpperCase() : ch;\n out += mapped.length === ch.length ? mapped : ch;\n prev = ch;\n }\n return out;\n}\n\n// `\"autofit\"` is a mode, not a magnitude.\nfunction lerpFontSize(\n a: number | \"autofit\" | undefined,\n b: number | \"autofit\" | undefined,\n t: number,\n): number | \"autofit\" | undefined {\n if (typeof a === \"number\" && typeof b === \"number\") return lerpNumber(a, b, t);\n return t < 0.5 ? a : b;\n}\n\n// Defaulting the missing side to 0 would animate a weight down to nothing on its way to \"unset\".\nfunction lerpOptionalNumber(a: number | undefined, b: number | undefined, t: number): number | undefined {\n if (a == null || b == null) return t < 0.5 ? a : b;\n return lerpNumber(a, b, t);\n}\n", "import { TweenFn } from \"@/props/host\";\n\nexport interface PropOptions<Ext, Int> {\n /** Lerp the *internal* (post-mapper) value during `to()`. Each step is stored as it returns, not mapped again, so a prop that must hold a range under an overshooting ease clamps here too. */\n tween?: TweenFn<Int>;\n /** Converts the external input into the internal stored value. Receives the previous internal value as the second arg when available. */\n mapper?: (ext: Ext, prev?: Int) => Int;\n}\n\n\nexport interface PropertyMeta {\n key: string;\n default?: unknown;\n options?: PropOptions<any, any>;\n /** How a host edits this prop — see {@link PropertyEditor}. */\n editor?: PropertyEditor;\n}\n\n/** What a host needs to draw a control for a property. Declared **on the property**, not in a separate `fields` list beside the class, which drifts when one is renamed. Nothing here is read while rendering. */\nexport interface PropertyEditor {\n /** The control to draw; inferred when absent (a typed entry knows its own, a plain `property` reads the default's type). */\n kind?: string;\n /** Bounds and granularity for a numeric control. */\n min?: number;\n max?: number;\n step?: number;\n /** What the number means, for a host that labels it — `\"°\"`, `\"s\"`, `\"×\"`. */\n unit?: string;\n options?: readonly string[];\n /** Whether a document may tween it. Defaults to true. */\n animatable?: boolean;\n /** The controls *inside* an object-valued prop (an axis config, a theme), drawn as a group and kept attached to their parent prop. */\n properties?: Record<string, PropertyEditor>;\n /** Whatever a control needs that this vocabulary does not name. */\n [option: string]: unknown;\n}\n\nexport const PROPERTY_META = Symbol(\"propertyMeta\");\n\n/** Every `property` on an instance's class, inherited included, ordered base -> subclass so `initProps` applies them in declaration order. A subclass redeclaring a key replaces the inherited declaration whole, at the position the base gave it. */\nexport function getPropertyMeta(instance: object): PropertyMeta[] {\n return mostDerived<PropertyMeta>(instance, PROPERTY_META);\n}\n\n/** The per-key declarations stored under `symbol` along the prototype chain: base first, one entry per key, the most-derived of each. */\nexport function mostDerived<M extends { key: string }>(instance: object, symbol: symbol): M[] {\n const chain: object[] = [];\n let proto = Object.getPrototypeOf(instance);\n while (proto && proto !== Object.prototype) {\n chain.unshift(proto);\n proto = Object.getPrototypeOf(proto);\n }\n const result: M[] = [];\n const at = new Map<string, number>();\n for (const p of chain) {\n if (!Object.prototype.hasOwnProperty.call(p, symbol)) continue;\n for (const m of (p as Record<symbol, M[]>)[symbol]) {\n const i = at.get(m.key);\n if (i === undefined) {\n at.set(m.key, result.length);\n result.push(m);\n } else {\n result[i] = m;\n }\n }\n }\n return result;\n}\n\n/** A registration for one member of a node class, applied to the prototype under the member's key by {@link declareMembers}. */\nexport type MemberRegistration = (target: object, key: string) => void;\n\n/**\n * Registers properties and commands on a node class, in the order given. Core's own base classes declare their props\n * as `declare` fields and register them here, right after the class body. Order is meaningful: {@link getPropertyMeta}\n * lists properties in registration order, which is the order `Registry.describe` hands a host's inspector. Node types\n * outside core are components (`component2d`), which do this themselves.\n *\n * @example\n * ```ts\n * declareMembers(Dial, {\n * level: property({ default: 0 }),\n * turn: command({ args: [\"by\"] }),\n * });\n * ```\n */\nexport function declareMembers<C extends abstract new (...args: never[]) => object>(\n ctor: C,\n members: { [K in keyof InstanceType<C> & string]?: MemberRegistration },\n): void {\n for (const [key, register] of Object.entries(members) as [string, MemberRegistration][]) {\n register(ctor.prototype as object, key);\n }\n}\n\n/**\n * Declares a property on a `Node` subclass, applied to the prototype under the property's key (directly or through\n * {@link declareMembers}). `default` is used when the key is absent from the constructor `props`; `mapper` / `tween`\n * are forwarded to `applyProp()`. Redeclaring an inherited key overrides it; see {@link getPropertyMeta}.\n */\nexport function property<Ext = any, Int = Ext>(opts?: {\n default?: Ext;\n mapper?: (ext: Ext, prev?: Int) => Int;\n tween?: TweenFn<Int>;\n} & PropertyEditor) {\n return function (target: object, propertyKey: string | symbol): void {\n const key = propertyKey as string;\n // `default`, `mapper` and `tween` drive the prop slot; everything else is\n // the editor's, and is carried rather than interpreted.\n const { default: fallback, mapper, tween, ...editor } = opts ?? {};\n const meta: PropertyMeta = {\n key,\n default: fallback,\n options: (mapper != null || tween != null)\n ? { mapper: mapper as ((ext: any) => any) | undefined, tween: tween as TweenFn<any> | undefined }\n : undefined,\n ...(Object.keys(editor).length > 0 ? { editor: editor as PropertyEditor } : {}),\n };\n\n // Store metadata on the class prototype (own property so getPropertyMeta\n // can distinguish each class's own entries from inherited ones).\n if (!Object.prototype.hasOwnProperty.call(target, PROPERTY_META)) {\n (target as any)[PROPERTY_META] = [];\n }\n const list: PropertyMeta[] = (target as any)[PROPERTY_META];\n if (!list.some(m => m.key === key)) {\n list.push(meta);\n }\n };\n}\n", "import type { SlotObserver } from \"./observer\";\n\n/** A captured state of a {@link PropSlot} (the thunk it was bound to, or the plain value), from {@link PropSlot.snapshot} to {@link PropSlot.restoreFrom}. */\n/** @internal */\nexport interface PropSnapshot<T> {\n value: T;\n /** Present only for a bound slot; restoring one re-binds rather than freezing it. */\n fn?: () => T;\n}\n\n/**\n * @internal The observer every slot reports to, or `null` — which is every frame of\n * playback, so the hot path pays one null check. Installed by `observeSlots`.\n */\nexport let _observer: SlotObserver | null = null;\n\n/** @internal Only this module can reassign the binding. Returns the observer it replaced. */\nexport function _setObserver(observer: SlotObserver | null): SlotObserver | null {\n const previous = _observer;\n _observer = observer;\n return previous;\n}\n\n/**\n * The storage behind one `property`: a plain value, or a thunk evaluated on every read. There is no dependency graph and\n * nothing to invalidate: a bound slot recomputes when asked, so a document expression (`\"=4[g]+3\"`), an author's\n * `width={() => …}` and an alignment binding reading a box written mid-layout are all correct without declaring an\n * edge. (A cache-and-invalidate version could only get the last one right by observing the write, and paid for it at\n * every write path.) The bet is that recomputing is cheaper than tracking: bindings are arithmetic over a few reads.\n */\nexport class PropSlot<T> {\n private _value: T;\n private _fn: (() => T) | null = null;\n private _running = false;\n\n /** `_host` and `_name` only label the slot for an observer — see `slotLabel`. */\n constructor(\n initial: T,\n readonly _host: { readonly id: string } | null = null,\n readonly _name: string = \"\",\n ) {\n this._value = initial;\n }\n\n get(): T {\n // Before the re-entrancy check, so a binding's own reads are recorded\n // under whatever read it.\n if (_observer !== null) _observer.read(this);\n // A binding that reads its own slot re-enters here mid-evaluation —\n // `bind(() => mapper(ext(), slot.get()))` is how a mapper is handed the\n // previous value. It gets the last settled one instead of recursing.\n if (!this._fn || this._running) return this._value;\n this._running = true;\n try {\n return (this._value = this._fn());\n } finally {\n this._running = false;\n }\n }\n\n set(value: T): void {\n if (_observer !== null) _observer.write(this);\n this._fn = null;\n this._value = value;\n }\n\n bind(fn: () => T): void {\n if (_observer !== null) _observer.write(this);\n this._fn = fn;\n }\n\n /** Freeze a bound slot at what it currently computes. */\n unbind(): void {\n if (!this._fn) return;\n if (_observer !== null) _observer.write(this);\n this._value = this.get();\n this._fn = null;\n }\n\n isBound(): boolean {\n return this._fn !== null;\n }\n\n snapshot(): PropSnapshot<T> {\n return this._fn ? { value: this.get(), fn: this._fn } : { value: this._value };\n }\n\n restoreFrom(snap: PropSnapshot<T>): void {\n if (snap.fn) this.bind(snap.fn);\n else this.set(snap.value);\n }\n\n /** Releases the bound closure and the value slot. The slot is inert after this. */\n dispose(): void {\n this._fn = null;\n this._value = undefined as unknown as T;\n }\n}\n", "import { clamp01 } from \"@/util/clamp\";\nimport { EasingFunction } from \"@/tween/ease/type\";\nimport { Steppable, TweenStepper } from \"@/tween/stepper\";\nimport { Command } from \"./command\";\n\n/** Implemented by a node (or other host) to be driven by {@link toCommand}: `_prepareStep` resolves one tween into a flat, mutation-driving {@link TweenStepper}, the primitive both the flat `parallel` fast path and the command's evaluation are built from. */\nexport interface AnimationTarget<P> {\n _prepareStep(props: Partial<P>, duration: number, easing?: EasingFunction): TweenStepper;\n}\n\n/** The {@link Command} `node.to(...)` returns: one tween on one target, **single, not chainable** (sequencing is the timeline's: a command carries its own `at`). Implements {@link Command} and {@link Steppable} (the flat driver). `at` and `_stepper` each keep their **own** prepared stepper: preparing snapshots the tween's `from` from the live target, so two drivers must never fight over one mutable stepper. */\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 /** The props this command writes at normalized `t`, applied as a side effect (direct cell writes through the prepared stepper, like `driveCommand`) rather than returned: only the target's `_prepareStep` knows how to apply a custom tween function or mapped prop correctly. */\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\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", "/**\n * Repetition as data: how many times a command runs and which way each pass goes. A loop is a **placement** property\n * like `at` and `duration` (when it runs, never what it does), so the wrapper goes around a built `Command` and `to`,\n * `fillTo`, `countTo` and custom commands all loop by the same code. It stays seekable: `at(t)` maps `t` onto a pass\n * and asks the inner command for that pass's frame, so scrubbing into the fourth repetition costs the same as the first.\n */\n\nimport { clamp01 } from \"@/util/clamp\";\n\n/** Which way a pass runs. `alternate` makes a bounce (out and back) one command with two passes, not two commands kept in step by hand. */\nexport type LoopDirection = \"normal\" | \"reverse\" | \"alternate\";\n\n/** How a command repeats. Absent on a command is \"runs once\". */\nexport interface LoopSpec {\n /** Absent is `\"normal\"`. */\n direction?: LoopDirection;\n /** Repeats **after** the first pass: `0` is no loop, `3` plays four passes, `null` repeats for as long as there is clip left to fill. (Repeats, not total passes, so \"repeat twice\" is `2` and the no-op is `0`.) */\n count: number | null;\n}\n\n/** Total passes: repeats plus the first one, or `Infinity` for an unlimited loop. */\nexport function loopPasses(loop: LoopSpec): number {\n return loop.count === null ? Infinity : Math.max(0, Math.floor(loop.count)) + 1;\n}\n\n/** Whether a loop changes anything: an unlimited one always does, a counted one only past zero. */\nexport function loopRepeats(loop: LoopSpec | undefined): loop is LoopSpec {\n return loop !== undefined && (loop.count === null || loop.count >= 1);\n}\n\n/** Seconds a looped command occupies. `fill` is what an unlimited loop covers (the clip's remaining time): it does not *define* a length, so `documentDuration` counts one pass and this stretches it. */\nexport function loopSpan(loop: LoopSpec, duration: number, fill = duration): number {\n if (duration <= 0) return duration;\n if (loop.count === null) return Math.max(duration, fill);\n return duration * loopPasses(loop);\n}\n\n/** Where in one pass `elapsed` lands, as normalized time for the inner command. Past the last pass of a counted loop it holds at that pass's end, so the value a loop leaves is the value the next command tweens from. */\nexport function loopPhase(loop: LoopSpec, elapsed: number, duration: number): number {\n if (duration <= 0) return 1;\n const passes = loopPasses(loop);\n const capped = Math.min(Math.max(elapsed, 0) / duration, passes);\n // `passes - 1` holds the final pass at its end instead of rolling over to a\n // pass that does not exist. `Infinity - 1` is still `Infinity`, so an\n // unlimited loop is never capped.\n const index = Math.min(Math.floor(capped), passes - 1);\n const t = clamp01(capped - index);\n switch (loop.direction ?? \"normal\") {\n case \"reverse\": return 1 - t;\n case \"alternate\": return index % 2 === 0 ? t : 1 - t;\n default: return t;\n }\n}\n", "import { clamp01 } from \"@/util/clamp\";\nimport { EasingFunction } from \"./ease/type\";\nimport { loopPasses, loopPhase, loopSpan, type LoopSpec } from \"./loop\";\nimport { LerpFunction } from \"./lerp\";\nimport { Steppable, TweenStepper } from \"./stepper\";\n\n/** A named animation as a value: `at(t)` is a pure function of normalized time, so a host can ask what frame N looks like without replaying 0..N-1. Pure only once *built* (a factory reads the node's current props to fix its start), so out-of-order evaluation must build commands in timeline order. */\nexport interface Command<P = Record<string, unknown>> extends Steppable {\n readonly duration: number;\n at(t: number): Partial<P>;\n}\n\n/** The single argument a `command()` method takes: its own params under `data` plus shared timing, one object so a manifest can read a command's shape off `T`. `duration`/`data` are optional for synchronous or data-free commands. `R` differs from `T` when `data` is loose author input (`Fill`) but `lerp` works on its resolved form. */\nexport interface CommandArgs<T = Record<string, unknown>, R = T> {\n data?: T;\n duration?: number;\n easing?: EasingFunction;\n lerp?: LerpFunction<R>;\n}\n\nconst SETTLES = Symbol(\"settles\");\n\n/** Marks a command whose `at` reads only what it captured when built and only writes prop slots, end values all at `at(1)`, so a timeline may hold it finished by writing those instead of running it (see `document/settled-index`). */\nexport function settling<C extends { at(t: number): unknown }>(command: C): C {\n (command as unknown as Record<symbol, boolean>)[SETTLES] = true;\n return command;\n}\n\nexport function settles(command: { at(t: number): unknown }): boolean {\n return (command as unknown as Record<symbol, boolean>)[SETTLES] === true;\n}\n\nexport function isCommand(x: unknown): x is Command {\n return typeof (x as Command)?.at === \"function\"\n && typeof (x as Command)?.duration === \"number\";\n}\n\n/** What a {@link Command} writes its evaluated props onto. */\nexport interface CommandTarget<P> {\n set(props: Partial<P>): void;\n}\n\n/** Build a {@link Command} from a pure `t → props` function. `easing` is applied inside, so `at` itself takes raw normalized time. */\nexport function makeCommand<P>(\n target: CommandTarget<P>,\n at: (t: number) => Partial<P>,\n duration: number,\n easing?: EasingFunction,\n): Command<P> {\n const value = (t: number): Partial<P> => at(easing ? easing(clamp01(t)) : clamp01(t));\n return fromValue(target, duration, value);\n}\n\n/** A {@link Command} whose product is a side effect (state a `set()` can't reach). `apply` must be a pure function of `t`: it runs for any `t`, any number of times, in any order, so accumulating (`x += …`) drifts the instant anything scrubs. */\nexport function driveCommand(\n duration: number,\n apply: (t: number) => void,\n easing?: EasingFunction,\n): Command<Record<string, never>> {\n const sink: CommandTarget<Record<string, never>> = { set: () => { } };\n return makeCommand(sink, (t) => {\n apply(t);\n return {};\n }, duration, easing);\n}\n\n/** Repeats `command` as one seekable {@link Command} lasting every pass. Wrapping works for every command: the inner one is asked for a pass-local `t`, and its easing applies per pass (three bounces, not one ease over three). `fill` is the seconds an unlimited loop may cover (default one pass). A stamp (`duration === 0`) is returned untouched. */\nexport function loopCommand<P>(command: Command<P>, loop: LoopSpec, fill?: number): Command<P> {\n const one = command.duration;\n if (one <= 0 || loopPasses(loop) <= 1) return command;\n const duration = loopSpan(loop, one, fill);\n const value = (t: number): Partial<P> => command.at(loopPhase(loop, clamp01(t) * duration, one));\n\n return {\n duration,\n at: value,\n _stepper(): TweenStepper {\n let elapsed = 0;\n return {\n seek: (e: number) => {\n elapsed = e;\n value(e / duration);\n },\n advance: (dt: number): boolean => {\n elapsed += dt;\n const done = elapsed >= duration;\n value(done ? 1 : elapsed / duration);\n return done;\n },\n };\n },\n };\n}\n\n/** Runs `commands` one after another as a single seekable {@link Command}; a finished child holds at `at(1)`, so an early-written prop keeps its value. */\nexport function commandSequence<P>(\n target: CommandTarget<P>,\n ...commands: Command<P>[]\n): Command<P> {\n const duration = commands.reduce((sum, c) => sum + c.duration, 0);\n\n return fromValue(target, duration, (t) => {\n const elapsed = t * duration;\n const props: Partial<P> = {};\n let cursor = 0;\n for (const command of commands) {\n if (elapsed < cursor) break;\n const local = command.duration > 0 ? (elapsed - cursor) / command.duration : 1;\n Object.assign(props, command.at(clamp01(local)));\n cursor += command.duration;\n }\n return props;\n });\n}\n\n/** Run `commands` together as one {@link Command}, ending when the longest does. Later commands win on a shared prop. */\nexport function commandParallel<P>(\n target: CommandTarget<P>,\n ...commands: Command<P>[]\n): Command<P> {\n const duration = commands.reduce((max, c) => Math.max(max, c.duration), 0);\n\n return fromValue(target, duration, (t) => {\n const elapsed = t * duration;\n const props: Partial<P> = {};\n for (const command of commands) {\n const local = command.duration > 0 ? elapsed / command.duration : 1;\n Object.assign(props, command.at(clamp01(local)));\n }\n return props;\n });\n}\n\nfunction fromValue<P>(\n target: CommandTarget<P>,\n duration: number,\n value: (t: number) => Partial<P>,\n): Command<P> {\n const progress = (elapsed: number): number => (duration > 0 ? elapsed / duration : 1);\n\n return {\n duration,\n // Writes as well as returns: a host evaluating a timeline calls `at(t)` and discards the result, so a command that only *described* its frame was inert wherever a document is seeked.\n at(t: number): Partial<P> {\n const props = value(t);\n target.set(props);\n return props;\n },\n\n _stepper(): TweenStepper {\n let elapsed = 0;\n return {\n seek: (e: number) => {\n elapsed = e;\n target.set(value(progress(e)));\n },\n advance: (dt: number): boolean => {\n elapsed += dt;\n const done = elapsed >= duration;\n target.set(value(done ? 1 : progress(elapsed)));\n return done;\n },\n };\n },\n };\n}\n", "import type { PropSlot } from \"@/props/slot\";\n\n/** Snapshots the numeric property values on `target` for the keys in `to` and returns a lerp callback writing interpolated values back each frame. The snapshot is taken at call time, so call it immediately before the animation starts. Keys with `undefined` are ignored; `t` must already be eased by the caller. */\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/** Like {@link prepareNumericTween}, but writes directly to the backing {@link PropSlot}s, skipping the mapper lookup and `_writeProp` indirection per step. Only valid for numeric props whose `end` is already in stored space: the caller resolves slots, maps the destination and captures `from`/`end` (`cells[i]`, `from[i]`, `end[i]`). The arrays are reused each step, so the cost is one `slot.set(number)` per property with no allocation. */\n/** @internal */\nexport function prepareNumericCellTween(\n cells: PropSlot<number>[],\n from: number[],\n end: number[],\n): (t: number) => void {\n return (t: number) => {\n for (let i = 0; i < cells.length; i++) {\n cells[i].set(from[i] + (end[i] - from[i]) * t);\n }\n };\n}\n", "/** Typed context tokens for passing inherited data down the node tree, like React's `createContext` / `useContext` but resolved over the scene-node tree. A {@link Context} is an opaque token with a phantom type `T` and a default; providers attach a value to the {@link ContextMap} pushed to descendants, and `node.useContext(token)` reads the nearest ancestor's value or the default. */\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 readonly name?: string;\n}\n\n/**\n * @example\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 */\nexport function createContext<T>(defaultValue: T, name?: string): Context<T> {\n return { id: Symbol(name ?? \"context\"), defaultValue, name };\n}\n\n/** An immutable, layered token→value map carried down the tree. Each provider derives a child map via {@link with}, so a deeper provider shadows a shallower one (nearest-ancestor-wins) with no stack bookkeeping. */\nexport class ContextMap {\n private constructor(private readonly entries: ReadonlyMap<symbol, unknown>) { }\n\n static readonly EMPTY = new ContextMap(new Map());\n\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 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", "import type { PropSlot } from \"./slot\";\n\n/** What a prop accessor reads its slots from and writes through. */\ninterface LaidOutHost {\n __cells?: { layout: PropLayout; list: readonly (PropSlot<unknown> | undefined)[] };\n _writeProp?(field: string, value: unknown): void;\n}\n\nconst LAYOUTS = new WeakMap<object, PropLayout>();\n\n/** Where each prop of one node class sits in its instances' slot lists, and the accessors that read it, defined once on the class's prototype so every node of a type shares one hidden class and a prop read in layout or render stays monomorphic. Accessors reach their slot by index (closures made at one site share feedback, so a lookup by name would see every prop of every class). An instance that hasn't registered a field, or a prototype that already defines one, reads and writes as if the accessor were absent. */\nexport class PropLayout {\n static of(proto: object): PropLayout {\n let layout = LAYOUTS.get(proto);\n if (!layout) LAYOUTS.set(proto, (layout = new PropLayout(proto)));\n return layout;\n }\n\n /** `field`'s index, or -1 when no instance has registered it. */\n indexOf(field: string): number {\n return this._index.get(field) ?? -1;\n }\n\n /** `field`'s index, given its accessor the first time any instance registers it. */\n place(field: string): number {\n let i = this._index.get(field);\n if (i !== undefined) return i;\n this._index.set(field, (i = this._index.size));\n if (Object.prototype.hasOwnProperty.call(this._proto, field)) {\n this._foreign.add(field);\n } else {\n Object.defineProperty(this._proto, field, {\n get: this._getter(i, field),\n set: this._setter(i, field),\n enumerable: true,\n configurable: true,\n });\n }\n return i;\n }\n\n /** Whether reading `field` on `host` reaches this layout's accessor. */\n serves(host: object, field: string): boolean {\n return !this._foreign.has(field) && !Object.prototype.hasOwnProperty.call(host, field);\n }\n\n private constructor(private readonly _proto: object) {\n this._parent = Object.getPrototypeOf(_proto) as object | null;\n }\n\n private readonly _parent: object | null;\n private readonly _index = new Map<string, number>();\n private readonly _foreign = new Set<string>();\n\n private _getter(i: number, field: string): (this: LaidOutHost) => unknown {\n const layout = this;\n const parent = this._parent;\n return function () {\n const cells = this.__cells;\n const slot = cells !== undefined && cells.layout === layout ? cells.list[i] : undefined;\n if (slot !== undefined) return slot.get();\n return parent === null ? undefined : Reflect.get(parent, field, this);\n };\n }\n\n private _setter(i: number, field: string): (this: LaidOutHost, value: unknown) => void {\n const layout = this;\n const parent = this._parent;\n return function (value) {\n const cells = this.__cells;\n if (cells !== undefined && cells.layout === layout && cells.list[i] !== undefined) {\n this._writeProp!(field, value);\n } else if (parent !== null) {\n Reflect.set(parent, field, value, this);\n } else {\n Object.defineProperty(this, field, { value, writable: true, enumerable: true, configurable: true });\n }\n };\n }\n}\n", "import { PropLayout } from \"./layout\";\nimport { PropSlot } from \"./slot\";\n\n/** @internal */\nexport type TweenFn<T> = (from: T, to: T, t: number) => T;\n\n/** The slots behind an object's `property`-declared fields plus the per-field metadata `set()` and `to()` route through. One object rather than three loose maps because every public field on the host (a `Node`) is published API. @internal */\nexport interface PropCells {\n /** Field → its live slot. Present for every registered prop. */\n slots: Map<string, PropSlot<any>>;\n /** The host class's prop indices; {@link list} holds its slots by them. */\n layout: PropLayout;\n /** Field → its slot, by {@link layout} index: what the prop accessors read. */\n list: (PropSlot<any> | undefined)[];\n /** Field → how it interpolates, for props a numeric lerp cannot cover. */\n tweens?: Map<string, TweenFn<any>>;\n /** Field → external prop value to internal slot value, for fields that need it. */\n mappers?: Map<string, (ext: any, prev?: any) => any>;\n}\n\n/** @internal */\nexport interface PropHost {\n /** See {@link PropCells}. Absent until the first prop is registered; cleared by `dispose()`. */\n __cells?: PropCells;\n}\n\n/** @internal */\nexport function getPropSlot(obj: PropHost, name: string): PropSlot<any> | undefined {\n return obj.__cells?.slots.get(name);\n}\n\n/** The host's slots, created on first use. @internal */\nexport function ensureCells(obj: PropHost): PropCells {\n // Every field from the start, so all cells share one shape and the prop accessors' reads of them stay monomorphic.\n return obj.__cells ??= { slots: new Map(), layout: PropLayout.of(Object.getPrototypeOf(obj) as object), list: [], tweens: undefined, mappers: undefined };\n}\n", "import { mostDerived, type PropertyEditor } from \"@/attributes/properties/decorator\";\n\n/**\n * Marks a method as a command: a named, parameterised animation a host can offer, place on a timeline and store by\n * name. Metadata only. `args` maps a stored command's `params` onto `data`'s keys (see {@link CommandMeta.args}); every\n * command takes one {@link CommandArgs} argument so a manifest can read its shape off `T`.\n *\n * ```ts\n * class Chart extends Node2D<ChartProps> {\n * showSeries({ data, duration = 1, easing }: CommandArgs<{ index: number }>): Command<ChartProps> { … }\n * }\n * declareMembers(Chart, { showSeries: command({ args: [\"index\"] }) });\n * ```\n */\n\n/** One argument a command takes, in the same vocabulary a property uses ({@link PropertyEditor}) — a range, an enum, a unit. A bare string is a name with nothing else to say. */\nexport interface CommandArgDescriptor extends PropertyEditor {\n key: string;\n default?: unknown;\n}\n\nexport type CommandArg = string | CommandArgDescriptor;\n\n/** Symbol under which `command` metadata is stored on class prototypes. */\nexport const COMMAND_META = Symbol(\"commandMeta\");\n\nexport interface CommandMeta {\n /** The key a host stores and dispatches on: the method name unless `command({ key })` renamed it. */\n key: string;\n method: string;\n /** Display name; built-ins leave this unset and localize by {@link key} instead. */\n name?: string;\n /** Keys of `params` that become `data`'s fields, written here rather than derived from the method's parameter names (a minifier mangles them, and the document vocabulary is `data`/`duration`/`easing`). */\n args?: readonly CommandArg[];\n /** Brings its target in: a timeline holds its first frame from when the target could first show it, so the resting node never flashes up ahead of it (window in `docs/timeline.md`). */\n entrance?: boolean;\n}\n\nexport interface CommandOptions {\n /** Publishes the method under another key, for a name the method cannot take (a prop, an inherited method). */\n key?: string;\n name?: string;\n args?: readonly CommandArg[];\n entrance?: boolean;\n}\n\n/** Every `command` on an instance's class, inherited included, base → subclass; a redeclared key replaces the inherited declaration at the position the base gave it. */\nexport function getCommandMeta(instance: object): CommandMeta[] {\n return mostDerived<CommandMeta>(instance, COMMAND_META);\n}\n\nexport function command(options?: CommandOptions) {\n return function (target: object, propertyKey: string | symbol): void {\n const method = propertyKey as string;\n const key = options?.key ?? method;\n if (!Object.prototype.hasOwnProperty.call(target, COMMAND_META)) {\n (target as Record<symbol, unknown>)[COMMAND_META] = [];\n }\n const list = (target as Record<symbol, unknown>)[COMMAND_META] as CommandMeta[];\n if (list.some(m => m.key === key)) return;\n list.push({\n key,\n method,\n ...(options?.name ? { name: options.name } : {}),\n ...(options?.args ? { args: options.args } : {}),\n ...(options?.entrance ? { entrance: true } : {}),\n });\n };\n}\n", "import { _setObserver, type PropSlot } from \"./slot\";\n\n/** What the slots touched inside {@link observeSlots} are reported to. Reads and writes are recorded rather than declared: a dependency is whatever a computation actually touched, bindings included, so nothing annotates a prop as mattering to anyone. */\nexport interface SlotObserver {\n read(slot: PropSlot<unknown>): void;\n write(slot: PropSlot<unknown>): void;\n /** A node's clock was read — a result that depends on it is not a function of slots alone. */\n clock?(host: { readonly id: string }): void;\n}\n\n/** The {@link PropSlot._name} of `Node2D`'s laid-out box. */\nexport const LAYOUT_SLOT = \"layoutBounds\";\n/** A document variable's slot is named this plus the variable id. */\nexport const VAR_PREFIX = \"var:\";\n/** A timeline node's presence pseudo-slot is named this plus the node id. */\nexport const PRESENCE_PREFIX = \"presence:\";\n/** A node's child list and parent link, as a pseudo-slot on that node. */\nexport const STRUCTURE_SLOT = \"structure\";\n\n/** Run `fn` with every slot read and write reported to `observer`. An inner scope shadows an outer one. */\nexport function observeSlots<T>(observer: SlotObserver, fn: () => T): T {\n const previous = _setObserver(observer);\n try {\n return fn();\n } finally {\n _setObserver(previous);\n }\n}\n\n/** Run `fn` with nothing observing, inside a scope that is. */\nexport function unobserved<T>(fn: () => T): T {\n const previous = _setObserver(null);\n try {\n return fn();\n } finally {\n _setObserver(previous);\n }\n}\n\n/** `\"card.x\"` for a node's prop, the bare name for a hostless slot (`\"var:g\"`). */\nexport function slotLabel(slot: PropSlot<unknown>): string {\n return slot._host ? `${slot._host.id}.${slot._name}` : slot._name;\n}\n", "import { TweenStepper } from \"./stepper\";\nimport type { Command } from \"./command\";\n\n/** An animation that occupies its duration and writes nothing: what a command on an **unmounted** node becomes. Such a node has no box, surface or timeline, but the timeline slot it was placed in is entitled to its duration; a real command of the right length keeps the scene's timing where throwing would abort the pass and returning nothing would silently shorten it. The failure (animating a node the author forgot to `add`) reads as \"nothing moved\", which is what shows on screen anyway. */\nexport function inertCommand<P>(target: object, duration: number): Command<P> {\n void target;\n return {\n duration,\n at: () => ({}) as Partial<P>,\n _stepper: () => inertStepper(duration),\n };\n}\n\n/** The {@link TweenStepper} half of {@link inertCommand}: runs its clock, writes nothing. */\nexport function inertStepper(duration: number): TweenStepper {\n let elapsed = 0;\n return {\n seek: (e: number) => { elapsed = e; },\n advance: (dt: number): boolean => {\n elapsed += dt;\n return elapsed >= duration;\n },\n };\n}\n", "import { PropSlot, PropSnapshot } from \"@/props/slot\";\nimport { ensureCells, PropHost, TweenFn } from \"@/props/host\";\nimport { EasingFunction } from \"@/tween/ease/type\";\nimport { driveCommand, type Command } from \"@/tween/command\";\nimport { TweenStepper } from \"@/tween/stepper\";\nimport { PropOptions } from \"@/attributes/properties/decorator\";\n\n/** Companion implementation of {@link Node2D}'s property machinery and save/restore stack: free functions over a narrow {@link ReactiveHost}, so `node.ts` keeps thin delegators (and the hot-path `set`/`_writeProp` inline). */\n\n/** The slice of a {@link Node2D} these helpers touch: the {@link PropHost} maps plus the write/tween seams. `_writeProp` and `_prepareStep` stay methods on `Node2D` and are called through, preserving subclass behaviour and the inline hot path. */\n/** @internal */\nexport interface ReactiveHost extends PropHost {\n readonly id: string;\n _writeProp(field: string, value: unknown): void;\n _prepareStep(to: Record<string, unknown>, duration: number, easing?: EasingFunction): TweenStepper;\n _stateStack: Map<string, PropSnapshot<any>>[];\n}\n\n/** Creates the {@link PropSlot} for a freshly declared prop, places it in its class's `PropLayout` (whose prototype accessor routes writes through `host._writeProp`) and registers its tween/mapper metadata. */\n/** @internal */\nexport function registerProp<Int>(host: ReactiveHost, field: string, options?: PropOptions<any, Int>): void {\n const slot = new PropSlot<Int>(undefined as unknown as Int, host, field);\n const cells = ensureCells(host);\n cells.slots.set(field, slot);\n cells.list[cells.layout.place(field)] = slot;\n if (options?.tween) {\n (cells.tweens ??= new Map()).set(field, options.tween as TweenFn<any>);\n }\n if (options?.mapper) {\n (cells.mappers ??= new Map()).set(field, options.mapper as (ext: any, prev?: any) => any);\n }\n // Something of the instance's own, or its class's, already answers to the name: shadow it.\n if (!cells.layout.serves(host, field)) {\n Object.defineProperty(host, field, {\n get: () => slot.get(),\n set: (value: any) => host._writeProp(field, value),\n enumerable: true,\n configurable: true,\n });\n }\n}\n\n/** Applies (or re-applies) a prop's initial value plus optional tween/mapper. A repeat call for a field reuses the cell and only refines tween/mapper, so a subclass can override a parent default without losing the cell or its bindings. */\n/** @internal */\nexport function applyProp<Ext, Int = Ext>(\n host: ReactiveHost,\n field: string,\n initial: Ext | (() => Ext) | undefined,\n options?: PropOptions<Ext, Int>,\n): void {\n const existing = host.__cells?.slots.get(field);\n if (!existing) {\n registerProp<Int>(host, field, options);\n } else if (options) {\n if (options.tween) {\n (ensureCells(host).tweens ??= new Map()).set(field, options.tween as TweenFn<any>);\n }\n if (options.mapper) {\n (ensureCells(host).mappers ??= new Map()).set(field, options.mapper as (ext: any, prev?: any) => any);\n }\n }\n host._writeProp(field, initial);\n}\n\n/** Snapshot every registered prop's current value/binding into a plain object. */\n/** @internal */\nexport function collectProperties(host: ReactiveHost): Record<string, any> {\n const result: Record<string, any> = {};\n if (host.__cells) {\n for (const key of host.__cells.slots.keys()) {\n result[key] = (host as any)[key];\n }\n }\n return result;\n}\n\n/** Every declared prop of a node as the value **or binding** its slot holds (see {@link Node2D.captureProps}), keyed by name. Opaque on purpose: a slot holds the *mapped* internal form, and reading it out to write back through `set` is the round-trip a layer avoids. */\nexport type PropLayer = Map<string, PropSnapshot<any>>;\n\n/** Snapshot every prop slot (value or binding) into a fresh layer. */\n/** @internal */\nexport function captureLayer(host: ReactiveHost): PropLayer {\n const layer: PropLayer = new Map();\n const slots = host.__cells?.slots;\n if (!slots) return layer;\n for (const [key, slot] of slots) {\n layer.set(key, slot.snapshot());\n }\n return layer;\n}\n\n/** @internal */\nexport function saveState(host: ReactiveHost): void {\n if (!host.__cells) return;\n host._stateStack.push(captureLayer(host));\n}\n\n/** Pop the top snapshot layer, or `undefined` if the stack is empty. */\n/** @internal */\nexport function popState(host: ReactiveHost): PropLayer | undefined {\n return host._stateStack.pop();\n}\n\n/** Instantly reapply a snapshot layer to every captured slot. */\n/** @internal */\nexport function applySnapshotLayer(host: ReactiveHost, layer: PropLayer): void {\n const slots = host.__cells?.slots;\n if (!slots) return;\n for (const [key, snap] of layer) {\n slots.get(key)?.restoreFrom(snap);\n }\n}\n\n/** Animated restore: tweens numeric / custom-tweenable props toward their saved resolved values, then reapplies the full snapshot so bindings are restored (not frozen at the landing value) and non-tweened props snap. A {@link Command}: the `_prepareStep` stepper is a pure function of elapsed time, and the snapshot reapply fires at `t === 1` (the shape `packages/components/code`'s `runTransition` uses). `_prepareStep` runs **lazily on first evaluation**, since it snapshots each `from` off the live node; building eagerly would capture the node as of the `restore()` call, which can differ if the caller does more to it in between. */\n/** @internal */\nexport function restoreAnimated(\n host: ReactiveHost,\n layer: PropLayer | undefined,\n duration: number,\n easing?: EasingFunction,\n): Command<Record<string, never>> {\n let stepper: TweenStepper | null = null;\n\n return driveCommand(duration, (t) => {\n if (!stepper) {\n // `to()` reads each snapshot's resolved `value` (correct even for a\n // bound slot), so the node animates back to where it *was*.\n const target: Record<string, unknown> = {};\n if (layer) {\n for (const [key, snap] of layer) {\n target[key] = snap.value;\n }\n }\n stepper = host._prepareStep(target, duration);\n }\n stepper.seek(t * duration);\n if (layer && t >= 1) applySnapshotLayer(host, layer);\n }, easing);\n}\n", "/** A node's place on the scene's clock (`node.time`), advanced once per frame by `Node.attach`; consumed by motion sampling, the render context's `elapsed` and anything a node's `tick()` derives from time. `creation` is seeded on the **first** advance, not at construction, so `elapsed` measures time *in the scene* (what entrance animations, a video's playhead and per-node dissolves mean): a node built in the generator's third second reads `elapsed === 0` on its first frame. */\nexport interface NodeTime {\n /** Seconds since the clip started. */\n readonly total: number;\n /** The clip time at which this node was first advanced. */\n readonly creation: number;\n /** How long this node has existed: `total - creation`. */\n readonly elapsed: number;\n}\n\n/**\n * The writable form the runtime advances; nodes hand out {@link NodeTime}, the same shape read-only.\n *\n * @internal\n */\nexport interface MutableNodeTime {\n total: number;\n creation: number;\n elapsed: number;\n /** Whether {@link advanceNodeTime} has seeded `creation` yet. */\n started: boolean;\n}\n\n/** The zeroed holder a node keeps for its lifetime. @internal */\nexport function createNodeTime(): MutableNodeTime {\n return { total: 0, creation: 0, elapsed: 0, started: false };\n}\n\n/** Advance `time` to `total` clip-seconds, seeding `creation` on first tick. @internal */\nexport function advanceNodeTime(time: MutableNodeTime, total: number): void {\n if (!time.started) {\n time.creation = total;\n time.started = true;\n }\n time.total = total;\n time.elapsed = total - time.creation;\n}\n", "import { _observer, PropSlot } from \"@/props/slot\";\nimport { STRUCTURE_SLOT } from \"@/props/observer\";\nimport { PropHost, type PropCells } from \"@/props/host\";\nimport { EasingFunction } from \"@/tween/ease/type\";\nimport { toCommand } from \"@/tween/to-command\";\nimport { makeCommand, type Command, type CommandArgs, type CommandTarget } from \"@/tween/command\";\nimport { prepareNumericCellTween } from \"@/tween/prepare\";\nimport { inertCommand, inertStepper } from \"@/tween/inert\";\nimport { TweenStepper } from \"@/tween/stepper\";\nimport { RefTarget } from \"@/util/reference\";\nimport { Context, ContextMap } from \"@/util/context\";\nimport { AssetCatalog } from \"@/assets/catalog\";\nimport type { AssetScope } from \"@/assets/scope\";\nimport { declareMembers, getPropertyMeta, PropOptions } from \"@/attributes/properties/decorator\";\nimport {\n applyProp,\n applySnapshotLayer,\n collectProperties,\n popState,\n restoreAnimated,\n saveState,\n} from \"./node-reactive\";\nimport type { PropLayer } from \"./node-reactive\";\nimport { advanceNodeTime, createNodeTime, type MutableNodeTime, type NodeTime } from \"@/components/trees/node/node-time\";\nimport type { PropInputs } from \"@/attributes/properties/inputs\";\nimport { command } from \"@/tween/command-decorator\";\n\nexport type { NodeTime } from \"@/components/trees/node/node-time\";\nexport type { PropInput, PropInputs } from \"@/attributes/properties/inputs\";\n\nexport type NodeDimension = \"2d\" | \"3d\" | \"audio\";\n\n/** Where a node of each dimension is allowed to live, for the mismatch error. */\nconst HOSTS_OF: Record<NodeDimension, string> = {\n \"2d\": \"2D nodes go in the 2D tree, or inside a Canvas3D as a HUD over its scene.\",\n \"3d\": \"Put 3D nodes inside a Canvas3D, which is the one node that holds both.\",\n audio: \"Put audio nodes under an AudioBus, or directly on the scene root.\",\n};\n\nexport interface NodeMetadata<T extends Node> {\n /** Written with this node at construction. Typed {@link RefTarget} rather than `Reference<T>` so a ref declared as one of `T`'s supertypes is accepted (`createRef<Node2D>()` on a `<Rect>`). */\n ref?: RefTarget<T>;\n}\n\nexport type NodeConfig<T extends Node, P> = PropInputs<P> & NodeMetadata<T>;\n\n/** What {@link Node.attach} needs to put a subtree into a live scene: available assets, ancestor-provided context, and the playhead. */\nexport interface AttachScope {\n assets: AssetCatalog;\n context: ContextMap;\n /** Clip-relative time, in seconds. */\n time: number;\n}\n\n/** A `children` child: a Node, nested arrays of them, or falsy (so `.map()` results and `cond && Rect(...)` work); the constructor flattens and drops all but `Node` instances. */\nexport type NodeChildren = Node | false | null | undefined | NodeChildren[];\n\n/** The props every node has, in either dimension. Deliberately tiny: box-on-a-page props live on {@link Node2DProps}, thing-in-space props on `Node3DProps`; a prop meaningless for half the tree is worse than none. */\nexport interface NodeProps {\n children: NodeChildren;\n /** Seeds {@link Node.id}; a document's `NodeSpec.id` supplies it (see `Registry.instantiate`). Defaults to a UUID. */\n id?: string;\n /** The handle a node is referenced by (`\"=[card.x]\"` reads `x` of the node keyed `card`), as against {@link NodeProps.id}, which addresses it. Never generated, and unique per document (`document/validate.ts`). */\n key?: string;\n}\n\n/**\n * The dimension-agnostic base of the scene graph; where a node is and how it draws belong to {@link Node2D} /\n * `Node3D`, which meet only at `Canvas3D` (mixing elsewhere throws, see {@link acceptsChild}). Subclasses call\n * {@link initProps} from their own constructor: field initializers run after `super()`, so applying defaults here would write into cells that don't exist yet.\n */\nexport abstract class Node<P extends NodeProps = NodeProps> implements PropHost {\n /** A getter so it is answerable from the prototype during construction, before subclass field initializers run. */\n abstract get dimension(): NodeDimension;\n\n /** The trees this type takes children from, answerable from the prototype as {@link dimension} is. */\n get _childTrees(): readonly NodeDimension[] {\n return [this.dimension];\n }\n\n constructor(props?: NodeConfig<any, P>) {\n // Retained by reference before any default application, so a provider's provideContext sees exactly what the\n // author passed and a subclass expanding sugar in place (`size`, `transform3D`) is reflected.\n this._props = props;\n // Neither is a property: identity doesn't tween, so it stays out of the table set(), to() and the baseline restore iterate.\n const identity = props as { id?: string; key?: string } | undefined;\n this.key = identity?.key;\n // Nullish, never falsy: `\"\"` is the scene root's real id (`checkRootShape` in document/validate.ts), and a UUID\n // in its place would give the host a root no document row mentions.\n this.id = identity?.id ?? crypto.randomUUID();\n }\n\n /** See {@link NodeProps.key}. */\n key?: string;\n\n private _hidden = false;\n private _locked = false;\n\n /** Hidden by the editor: no paint, no pick, no layout slot. See {@link NodeEditorState.hidden}. */\n get hidden(): boolean {\n return this._hidden;\n }\n\n /** Locked by the editor — unpickable, but drawn. See {@link NodeEditorState.locked}. */\n get locked(): boolean {\n return this._locked;\n }\n\n /** @internal Written only by `applyEditorStates`, which owns both flags for the whole tree; not a setter pair, so one can't be set leaving the other stale. */\n _setEditorState(hidden: boolean, locked: boolean): void {\n this._hidden = hidden;\n this._locked = locked;\n }\n\n /** Fires the `ref` and applies every declared property from `props`. Called by the concrete constructor, not this one: field initializers run after `super()`, so doing it here would write into cells that are still `undefined`. */\n protected initProps(props?: NodeConfig<any, P>): void {\n if (props?.ref) {\n props.ref(this as any);\n }\n\n for (const meta of getPropertyMeta(this)) {\n const propsVal = props ? (props as any)[meta.key] : undefined;\n const initial = propsVal !== undefined ? propsVal : meta.default;\n this.applyProp(meta.key, initial, meta.options);\n }\n }\n\n /** Adopts the `children` prop, after the concrete constructor's defaults are in place so a child never lands in a parent that hasn't sized itself. */\n protected adoptChildrenProp(props?: NodeConfig<any, P>): void {\n if (props && (props as any).children) {\n const raw = Array.isArray((props as any).children) ? (props as any).children : [(props as any).children];\n const flat = (raw as unknown[]).flat(Infinity)\n .filter((c: unknown): c is Node => c instanceof Node);\n if (flat.length > 0) this._addChildren(flat);\n }\n }\n\n /** Whether `child` may be adopted. A node takes children of its own dimension; `Canvas3D` takes 2D and 3D, `Canvas2D` takes 2D and audio. Mixing elsewhere is rejected because a `Box3D` under a `Rect` would be skipped by both walks and silently never appear. */\n protected acceptsChild(child: Node): boolean {\n return child.dimension === this.dimension;\n }\n\n /** Throw if `child` cannot go here: by its tree, by what this node takes, or by where the child says it goes. */\n protected assertAcceptsChild(child: Node): void {\n if (!this.acceptsChild(child)) {\n const why = child.dimension === this.dimension ? this._childRule() : HOSTS_OF[child.dimension];\n throw new TypeError(`${this.className} (${this.dimension}) cannot hold ${child.className} (${child.dimension}).${why ? ` ${why}` : \"\"}`);\n }\n const refusal = child._parentRefusal(this);\n if (refusal) throw new TypeError(refusal);\n }\n\n /** What this node takes, for the error when it refuses a child of its own tree. */\n protected _childRule(): string {\n return \"\";\n }\n\n /** Why this node cannot go inside `parent`, or `null`: only a node that names its parents refuses one. */\n _parentRefusal(_parent: Node): string | null {\n return null;\n }\n\n private _assets: AssetCatalog | null = null;\n protected _parent: Node | null = null;\n\n /** Whether this node is in a live scene tree; gates measure/layout/render, asset declaration and every command (checked where the framework dispatches, not per method). */\n private _mounted = false;\n\n get mounted(): boolean {\n return this._mounted;\n }\n\n get parent(): Node | null {\n if (_observer !== null) _observer.read(this._structureSlot());\n return this._parent;\n }\n\n get assets(): AssetCatalog {\n if (!this._assets) throw new Error(\"Assets not bound — this node is not attached to a scene. See Node.attach().\");\n return this._assets;\n }\n\n private _context: ContextMap = ContextMap.EMPTY;\n /** True once {@link attach} has reached this node. */\n private _contextBound = false;\n\n /** Raw constructor props, retained so {@link provideContext} can see which keys were explicitly passed. Kept through {@link dispose} so a reused instance re-derives context on the next attach. */\n protected _props?: NodeConfig<any, P>;\n\n /** Read the nearest ancestor provider's value for `ctx` (or its default). */\n useContext<T>(ctx: Context<T>): T {\n return this._context.get(ctx);\n }\n\n readonly id: string;\n\n /**\n * The slots behind this node's `property` fields; the authoring surface is the props and `set()`/`to()`/`captureProps()`.\n *\n * @internal\n */\n __cells?: PropCells;\n\n protected _children: Node[] = [];\n\n /** Flattens a constructor's raw `children` prop into its `Node`s without mutating or adding them, so {@link applyDefaultSize} overrides can inspect children's resolved `width`/`height` before attachment. */\n protected static flattenChildrenProp(props: { children?: unknown } | undefined): Node[] {\n const childProp = props ? props.children : undefined;\n if (!childProp) return [];\n const raw = Array.isArray(childProp) ? childProp : [childProp];\n return (raw as unknown[]).flat(Infinity).filter((c: unknown): c is Node => c instanceof Node);\n }\n\n /** Declares a prop: creates a {@link PropSlot}-backed accessor for `field`, applies the initial value (a callback binds, otherwise constant) and registers tween/mapper metadata. A repeat call for the same field is a value assignment, so a subclass can override a parent's default without losing the slot or its bindings. */\n protected applyProp<Ext, Int = Ext>(\n field: string,\n initial: Ext | (() => Ext) | undefined,\n options?: PropOptions<Ext, Int>,\n ): void {\n applyProp(this, field, initial, options);\n }\n\n /** @internal Hot-path prop write (mapper- and binding-aware). Public-but-underscored like `_prepareStep` so reactive companions in this directory can call it; not part of the authoring surface. */\n _writeProp(field: string, value: unknown): void {\n if (value === undefined) return;\n const slot = this.__cells?.slots.get(field);\n if (!slot) return;\n const mapper = this.__cells?.mappers?.get(field);\n if (typeof value === \"function\") {\n const extFn = value as () => any;\n if (mapper) {\n // A binding reading `undefined` (a node reference to an absent node) leaves the prop as a node built without\n // it and skips the mapper, which holds the shape the prop's readers go through.\n let unset: { value: unknown } | undefined;\n slot.bind(() => {\n const read = extFn();\n return read === undefined\n ? (unset ??= { value: this._unsetValue(field, mapper) }).value\n : mapper(read, slot.get());\n });\n } else {\n slot.bind(extFn);\n }\n } else {\n slot.set(mapper ? mapper(value, slot.get()) : value);\n }\n }\n\n get properties(): P {\n return collectProperties(this) as P;\n }\n\n /** This node's class name, for messages and a host's type column. Not an authored identity ({@link id}, {@link key}) nor the registry key in `NodeSpec.type`: a minifier may rename a class. */\n get className(): string {\n return this.constructor.name;\n }\n\n set(props: { [K in keyof P]?: P[K] | (() => P[K]) }): void {\n const slots = this.__cells?.slots;\n if (!slots) return;\n // Iterate the caller's keys (usually 1-3), not every registered prop (15+): set() runs in the per-frame hot path.\n // Unknown keys are ignored, which lets a subclass distribute its sugar (2D's `size`, `transform3D`) into real keys and delegate here.\n for (const key in props) {\n const val = (props as any)[key];\n if (val !== undefined && slots.has(key)) this._writeProp(key, val);\n }\n }\n\n to<D extends Partial<P> = Partial<P>>(args: CommandArgs<D> & { duration: number }): Command<P> {\n return toCommand<P>(this, args.data ?? {}, args.duration, args.easing);\n }\n\n /** Builds a {@link Command} from a pure function of normalized time: an animation this node can be evaluated at, not only run. The pair to {@link to}, for commands whose values at `t` aren't a prop list. Snapshot the starting state outside `at`: reading a prop inside it would re-read what the command is writing. */\n protected command<Props = P>(\n at: (t: number) => Partial<Props>,\n duration: number = 1,\n easing?: EasingFunction,\n ): Command<Props> {\n if (!this._mounted) return inertCommand<Props>(this, duration);\n return makeCommand<Props>(\n this as unknown as CommandTarget<Props>,\n at,\n duration,\n easing,\n );\n }\n\n /** Resolves one `to()` step into a flat {@link TweenStepper}: per-key setup (mapper, numeric-vs-custom routing) happens once here, so `advance(dt)` is allocation-free. Used by a chain's iterator path and the batched `parallel` path. A subclass with positional sugar expands `to` in place, then delegates here. */\n _prepareStep(to: Partial<P>, duration: number, easing?: EasingFunction): TweenStepper {\n if (!this._mounted) return inertStepper(duration);\n // A tween runs in stored space: the destination is mapped once here and every step writes a stored value as is.\n // Writing through the setter would map twice, which only an idempotent mapper survives.\n const numCells: PropSlot<number>[] = [];\n const numFrom: number[] = [];\n const numEnd: number[] = [];\n const customLerps: Array<(t: number) => void> = [];\n const stringSnaps: Array<[PropSlot<string>, string]> = [];\n\n for (const key of Object.keys(to)) {\n const slot = this.__cells?.slots.get(key);\n if (!slot) continue;\n const extVal = (to as any)[key];\n const mapper = this.__cells?.mappers?.get(key);\n const targetVal = mapper ? mapper(extVal, (this as any)[key]) : extVal;\n const tweenFn = this.__cells?.tweens?.get(key);\n if (tweenFn) {\n const from = (this as any)[key];\n customLerps.push((t) => {\n slot.set(tweenFn(from, targetVal, t));\n });\n } else if (typeof targetVal === 'number') {\n numCells.push(slot as PropSlot<number>);\n numFrom.push((this as any)[key] as number);\n numEnd.push(targetVal as number);\n } else if (typeof targetVal === 'string') {\n stringSnaps.push([slot as PropSlot<string>, targetVal]);\n }\n }\n\n const lerp = prepareNumericCellTween(numCells, numFrom, numEnd);\n const hasCustom = customLerps.length > 0;\n const hasSnaps = stringSnaps.length > 0;\n\n const apply = (t: number): void => {\n const easedT = easing ? easing(t) : t;\n lerp(easedT);\n if (hasCustom) for (const fn of customLerps) fn(easedT);\n // A discrete prop snaps at the end. Applied here, not only in `advance`, because a `seek` past the end has\n // reached that end; otherwise `seek(duration)` and running to `duration` would differ.\n if (hasSnaps && t >= 1) for (const [slot, val] of stringSnaps) slot.set(val);\n };\n\n let elapsed = 0;\n return {\n // Tracks `elapsed` so a seek and a subsequent advance agree on where the tween is.\n seek: (e: number) => {\n elapsed = e;\n apply(duration > 0 ? Math.min(e / duration, 1) : 1);\n },\n advance: (dt: number): boolean => {\n elapsed += dt;\n if (elapsed < duration) {\n apply(elapsed / duration);\n return false;\n }\n apply(1);\n return true;\n },\n };\n }\n\n /** What a node constructed without `field` holds: its declared default, through the mapper. */\n private _unsetValue(field: string, mapper: (ext: any, prev?: any) => any): unknown {\n const declared = getPropertyMeta(this).find((meta) => meta.key === field)?.default;\n const initial = typeof declared === \"function\" ? declared() : declared;\n return initial === undefined ? undefined : mapper(initial, undefined);\n }\n\n // State stack (save / restore): a per-node LIFO of property snapshots, as Motion Canvas's save()/restore().\n\n /** @internal LIFO stack of save() snapshot layers. Underscore-internal so the prop companion can read it; not authoring surface. */\n _stateStack: PropLayer[] = [];\n\n /** Pushes a snapshot of every reactive prop onto the save stack. Bindings are saved as bindings (not resolved values), so {@link restore} re-binds them. Calls stack. */\n save(): void {\n saveState(this);\n }\n\n /** Pops the latest {@link save} snapshot and rolls back to it. With no (or zero) `duration` every prop is reapplied instantly; with one, numeric and custom-tween props animate back, then the full snapshot is reapplied to re-bind reactive props and snap non-tweenable ones. No-op on an empty stack. */\n restore(): void;\n restore(args: CommandArgs<Record<string, never>> & { duration: number }): Command<Record<string, never>>;\n restore(args?: CommandArgs<Record<string, never>>): void | Command<Record<string, never>> {\n const layer = popState(this);\n const duration = args?.duration;\n if (duration === undefined || duration <= 0) {\n if (layer) applySnapshotLayer(this, layer);\n return;\n }\n return restoreAnimated(this, layer, duration, args?.easing);\n }\n\n protected _time: MutableNodeTime = createNodeTime();\n\n /** This node's place on the scene clock. See {@link NodeTime}. */\n public get time(): NodeTime {\n if (_observer !== null) _observer.clock?.(this);\n return this._time;\n }\n\n /**\n * Advances this node's clock (not its subtree: {@link attach} already recurses) and samples its derived render\n * state. Sampling happens here, not at render: this runs on every advanced frame in every playback path while\n * `render` runs only for displayed ones, so velocity is right on the first frame after a scrub. It runs before\n * `generator.next()` (so audio scheduling in generator bodies reads the right time), so x/y still hold the\n * previous frame's value and velocity trails the rendered position by one constant frame.\n */\n private _advanceOwnTime(total: number): void {\n advanceNodeTime(this._time, total);\n this._sample();\n }\n\n /** @internal Per-node half of `sampleTree`; nothing to derive here, {@link Node2D} samples its motion. */\n _sample(): void { }\n\n /** @internal Per-node half of `primeMotionTree`: records the current position as the motion history's previous frame at `at`, deriving no velocity. */\n _primeMotion(at: number): void { }\n\n /**\n * Puts this subtree into the scene: marks it mounted, binds the asset catalog and inherited context, advances its\n * clock to `scope.time`. Cheap to call every frame: an unchanged catalog/context short-circuits and\n * {@link resolveContext} fires only on first attach.\n *\n * @internal Driven by `ClipInstance` per frame, and by {@link add} for a mid-frame subtree.\n */\n attach(scope: AttachScope): void {\n const first = !this._mounted;\n this._mounted = true;\n\n if (this._assets !== scope.assets) this._assets = scope.assets;\n\n const next = this.provideContext(scope.context);\n // Unchanged map, already bound, and not the first attach: the subtree already holds `next`, so only the time half runs.\n const contextChanged = !this._contextBound || this._context !== next;\n if (contextChanged) {\n this._context = next;\n this._contextBound = true;\n }\n if (first) this.resolveContext(next);\n\n this._advanceOwnTime(scope.time);\n\n if (this._children.length === 0) return;\n const childScope = next === scope.context ? scope : { ...scope, context: next };\n for (const child of this._children) child.attach(childScope);\n }\n\n /**\n * Takes this subtree out of the scene without tearing it down, so it can be attached elsewhere (`reparent`); {@link dispose} tears down.\n *\n * @internal Driven by {@link remove}/{@link clear}.\n */\n detach(): void {\n if (!this._mounted) return;\n this._mounted = false;\n for (const child of this._children) child.detach();\n }\n\n /** The scope this node was last attached with, for handing to a late child. */\n private _currentScope(): AttachScope | null {\n return this._assets && this._contextBound\n ? { assets: this._assets, context: this._context, time: this._time.total }\n : null;\n }\n\n /** Attach `child` if this node is itself attached; otherwise leave it for the walk. */\n /** @internal Shared with `Node2D.addChildAt`, which splices rather than pushes. */\n protected _attachChild(child: Node): void {\n if (!this._mounted) return;\n const scope = this._currentScope();\n if (scope) child.attach(scope);\n }\n\n /** Applies inherited context values once, after linking into the tree and ancestor providers resolve (a component's `inherit` entries). */\n protected resolveContext(ctx: ContextMap): void { }\n\n /** The {@link ContextMap} for descendants; a component's `provide` adds tokens, the base passes the parent's through. */\n protected provideContext(parent: ContextMap): ContextMap {\n return parent;\n }\n\n /** Binds `node`'s asset catalog, context and clock without making it a child, for a node used as a pixel source (`Tex.surface`) and laid out on demand. */\n protected attachDetached(node: Node): void {\n const scope = this._currentScope();\n if (scope) node.attach(scope);\n }\n\n /** Declares what this node draws from its props and inherited context alone, never `layoutBounds` or the clock: the runtime records what this reads and re-runs it only when those props are written, so any other dependency is a change nobody will ask about. */\n declareAssets(assets: AssetScope): void { }\n\n get children(): Node[] {\n if (_observer !== null) _observer.read(this._structureSlot());\n return this._children;\n }\n\n /** Every child, both dimensions, unfiltered (unlike {@link children}, which {@link Node2D} filters): for index-matching the authored tree, as picking does. */\n get _allChildren(): readonly Node[] {\n if (_observer !== null) _observer.read(this._structureSlot());\n return this._children;\n }\n\n /** Adds children (a node, array, or nested mix; falsy entries dropped). A child of the other dimension throws, see {@link acceptsChild}. */\n add(child: NodeChildren): void {\n if (child instanceof Node) {\n this._addChild(child);\n return;\n }\n const flat = Node.flattenChildrenProp({ children: child });\n if (flat.length > 0) this._addChildren(flat);\n }\n\n /** Remove children — same shapes as {@link add}. Not a child of this one is a no-op. */\n remove(child: NodeChildren): void {\n if (child instanceof Node) {\n this._removeChild(child);\n return;\n }\n for (const node of Node.flattenChildrenProp({ children: child })) {\n this._removeChild(node);\n }\n }\n\n clear(): void {\n for (const child of this._children) {\n if (_observer !== null) this._structureChanged(child);\n child._parent = null;\n child.detach();\n }\n this._children.length = 0;\n }\n\n /** Inserts `child` at `index`. On {@link Node} because it's tree machinery (`ClipTimeline.syncPresence` calls it on whatever a spec's `parentId` names, not always 2D); `Node2D` overrides it for the animated insert, which measures the child off-tree. */\n addChildAt(args: CommandArgs<{ child: Node; index: number }>): void | Command<Record<string, never>> {\n const { child, index } = args.data as { child: Node; index: number };\n this.assertAcceptsChild(child);\n this._insertChildAt(child, index);\n }\n\n /** @internal Shared with `Node2D.addChildAt`'s instant branch. */\n protected _insertChildAt(child: Node, index: number): void {\n if (_observer !== null) this._structureChanged(child);\n this._children.splice(index, 0, child);\n child._parent = this;\n this._attachChild(child);\n }\n\n /**\n * @internal The pseudo-slot {@link children} and {@link parent} report to an\n * observer. Allocated on first observation, so a tree nobody observes carries none.\n */\n _structureSlot(): PropSlot<null> {\n return this._structure ??= new PropSlot<null>(null, this, STRUCTURE_SLOT);\n }\n\n /** @internal Report a child entering or leaving this node — its parent link changes with it. Call only while observed. */\n _structureChanged(child: Node | null): void {\n _observer!.write(this._structureSlot());\n if (child) _observer!.write(child._structureSlot());\n }\n\n private _structure: PropSlot<null> | null = null;\n\n private _addChild(child: Node): void {\n this.assertAcceptsChild(child);\n if (_observer !== null) this._structureChanged(child);\n this._children.push(child);\n child._parent = this;\n this._attachChild(child);\n }\n\n private _addChildren(children: Node[]): void {\n for (const child of children) this.assertAcceptsChild(child);\n if (_observer !== null) for (const child of children) this._structureChanged(child);\n this._children.push(...children);\n for (const child of children) child._parent = this;\n for (const child of children) this._attachChild(child);\n }\n\n private _removeChild(child: Node): void {\n const i = this._children.indexOf(child);\n if (i < 0) return;\n if (_observer !== null) this._structureChanged(child);\n const [removed] = this._children.splice(i, 1);\n if (removed) {\n removed._parent = null;\n removed.detach();\n }\n }\n\n dispose(): void {\n if (this.__cells) {\n for (const slot of this.__cells.slots.values()) {\n slot.dispose();\n }\n }\n this.__cells = undefined;\n this._assets = null;\n this._mounted = false;\n // _props is retained (authored identity) so provideContext still works after reuse.\n this._context = ContextMap.EMPTY;\n this._contextBound = false;\n }\n}\n\ndeclareMembers(Node, {\n to: command(),\n restore: command(),\n addChildAt: command({ args: [\"child\", \"index\"] }),\n});\n", "import type { AssetType } from \"./record\";\n\n/**\n * A frame reached for an asset that was never loaded: the counterweight to declared asset tracking. A node states what\n * it needs from `Node.declareAssets`; if it misses something the renderer finds nothing at paint. A skipped layer would\n * be a frame that renders *almost* right (a photo missing, a heading in the fallback face), possibly only seconds in and\n * only on a cold load, so throwing turns it into a located failure: caught per scene during precomp as a `BuildError`,\n * and stopping the frame at playback.\n *\n * It means \"declared but not loaded, or never declared\", and deliberately **not** a *time-varying* miss: a video frame\n * the decode window has not reached is an asset that loaded fine, `warmPendingVideo` settles those, and they paint the\n * nearest decoded frame.\n */\nexport class AssetNotLoadedError extends Error {\n readonly assetType: AssetType;\n readonly src: string;\n /** The innermost drawing node, stamped by `Node2D.render` on the way out. */\n nodeId?: string;\n\n constructor(assetType: AssetType, src: string, hint?: string) {\n super(`${assetType} asset \"${src}\" is not loaded. ` + (hint ?? declareHint(assetType)));\n this.name = \"AssetNotLoadedError\";\n this.assetType = assetType;\n this.src = src;\n }\n}\n\n/** How to declare an asset of `assetType`: the scope method, or a command's sound. */\nfunction declareHint(assetType: AssetType): string {\n if (assetType === \"audio\") return \"Play it from a command (`timeline.sound(...)`), so the asset timeline loads it before this frame draws.\";\n return `Declare it from the node's declareAssets() (e.g. assets.${assetType}(...)), so the asset timeline loads it before this frame draws.`;\n}\n", "import type { Size2D, SizeInput } from \"@/attributes/layout/size\";\nimport type { MeasureContext2D } from \"@/render/measure-context\";\nimport type { SizeConstraints } from \"./constraints\";\nimport type { LayoutItem } from \"./types\";\n\n/** An item's size under `constraints` — through its own `measure` when it has one. */\nexport function measureItem(\n item: LayoutItem,\n constraints: SizeConstraints,\n measurer: MeasureContext2D | undefined,\n): Size2D {\n if (item.measure) {\n const size = item.measure(constraints, measurer);\n return { width: size.width ?? 0, height: size.height ?? 0 };\n }\n return {\n width: extentOf(item.width, constraints.maxWidth),\n height: extentOf(item.height, constraints.maxHeight),\n };\n}\n\nfunction extentOf(input: SizeInput, available: number | undefined): number {\n if (typeof input === \"number\") return input;\n return input === \"fill\" ? available ?? 0 : 0;\n}\n", "import { clamp } from \"@/util/clamp\";\nimport type { Size2D } from \"@/attributes/layout/size\";\nimport type { Vector2 } from \"@/attributes/layout/vector2\";\nimport type { MeasureContext2D } from \"@/render/measure-context\";\nimport type { BoxBounds } from \"./bounds\";\nimport type { SizeConstraints } from \"./constraints\";\nimport type { FlowLine, FlowMeasure, FlowSpace, GapSize, LayoutItem } from \"./types\";\nimport { measureItem } from \"./item\";\n\ntype RunMeasure = Pick<FlowMeasure, \"sizes\" | \"lines\" | \"gapScales\" | \"hug\">;\n\n/** Measures an unwrapped run as one line: fixed items first, then `fill` items share the rest of the main axis by `flex`. */\nexport function measureRun(\n items: readonly LayoutItem[],\n horizontal: boolean,\n gap: GapSize,\n space: FlowSpace,\n measurer: MeasureContext2D | undefined,\n): RunMeasure {\n const main = horizontal ? \"width\" : \"height\";\n const cross = horizontal ? \"height\" : \"width\";\n const hugsMain = (horizontal ? space.hugWidth : space.hugHeight) === true;\n const hugsCross = (horizontal ? space.hugHeight : space.hugWidth) === true;\n const bounded: SizeConstraints = { maxWidth: space.width, maxHeight: space.height };\n\n const n = items.length;\n const sizes: Size2D[] = new Array(n);\n const gapScales = items.map((item) => sanitizeGapScale(item.gapScale));\n // Weighted rather than a flat `n - 1`, so an item collapsing mid insert/remove\n // gives back exactly one gap wherever it sits. All weights 1 is `gap * (n - 1)`.\n const totalGap = gap === \"auto\" ? 0 : gap * Math.max(0, gapScales.reduce((sum, w) => sum + w, 0) - 1);\n\n // Fixed-main items first. On a hugging cross axis, `fill`-cross items wait:\n // what they fill is the deepest of these.\n let fixedMain = 0;\n let deepest = 0;\n for (let i = 0; i < n; i++) {\n if (items[i][main] === \"fill\" || (hugsCross && items[i][cross] === \"fill\")) continue;\n sizes[i] = measureItem(items[i], bounded, measurer);\n fixedMain += sizes[i][main];\n if (sizes[i][cross] > deepest) deepest = sizes[i][cross];\n }\n const fillCross = hugsCross ? deepest : space[cross];\n if (hugsCross) {\n for (let i = 0; i < n; i++) {\n if (items[i][main] === \"fill\" || items[i][cross] !== \"fill\") continue;\n const size = measureItem(items[i], bounded, measurer);\n sizes[i] = withCross(size, fillCross, horizontal);\n fixedMain += size[main];\n }\n }\n\n const free = Math.max(0, space[main] - totalGap - fixedMain);\n let flexSum = 0;\n for (const item of items) if (item[main] === \"fill\") flexSum += sanitizeFlex(item.flex);\n\n for (let i = 0; i < n; i++) {\n const item = items[i];\n if (item[main] !== \"fill\") continue;\n let share: number;\n let size: Size2D;\n if (hugsMain) {\n size = measureFillOnHugAxis(item, horizontal, space, measurer);\n share = size[main];\n } else {\n share = flexSum > 0 ? free * sanitizeFlex(item.flex) / flexSum : 0;\n size = measureItem(item, horizontal\n ? { maxWidth: share, maxHeight: space.height }\n : { maxWidth: space.width, maxHeight: share }, measurer);\n }\n const depth = item[cross] === \"fill\" ? fillCross : size[cross];\n sizes[i] = horizontal ? { width: share, height: depth } : { width: depth, height: share };\n }\n\n let extent = totalGap;\n let depth = 0;\n for (const size of sizes) {\n extent += size[main];\n if (size[cross] > depth) depth = size[cross];\n }\n return {\n sizes,\n lines: n > 0 ? [{ start: 0, end: n, cross: depth }] : [],\n gapScales,\n hug: horizontal ? { width: extent, height: depth } : { width: depth, height: extent },\n };\n}\n\n/** A `fill`-main item on a main axis the container hugs has nothing to share (Figma disallows it), so it measures unconstrained like a hug item; a bare `fill` leaf would echo Infinity and take the container's hug size with it, so it collapses to 0. Shared by {@link measureRun} and {@link measureWrap} so a run hugs to the same size wrapped or not. */\nfunction measureFillOnHugAxis(\n item: LayoutItem,\n horizontal: boolean,\n space: FlowSpace,\n measurer: MeasureContext2D | undefined,\n): Size2D {\n const size = measureItem(item, horizontal\n ? { maxWidth: Infinity, maxHeight: space.height }\n : { maxWidth: space.width, maxHeight: Infinity }, measurer);\n const main = horizontal ? \"width\" : \"height\";\n return Number.isFinite(size[main]) ? size : { ...size, [main]: 0 };\n}\n\n/**\n * Measures a wrapped run: every item at natural size, broken greedily into lines that fit the main axis. Two rules\n * differ from {@link measureRun}, both Figma's: **a hugging main axis does not wrap**, and **`fill` on the main axis is\n * not divided** (which line an item lands on is what this pass decides, so it measures to the whole main axis and takes\n * a line to itself). Cross-axis `fill` stretches to its own line, the only reading that survives a reflow.\n */\nexport function measureWrap(\n items: readonly LayoutItem[],\n horizontal: boolean,\n gap: GapSize,\n crossGap: number,\n space: FlowSpace,\n measurer: MeasureContext2D | undefined,\n): RunMeasure {\n const main = horizontal ? \"width\" : \"height\";\n const cross = horizontal ? \"height\" : \"width\";\n const hugsMain = (horizontal ? space.hugWidth : space.hugHeight) === true;\n const limit = hugsMain ? Infinity : space[main];\n // Flat, not gapScale-weighted: placement spaces the lines this breaks, and a\n // weighting across a break would put the two out of step. An animated insert\n // in a wrapped run slides instead of collapsing its gap.\n const step = gap === \"auto\" ? 0 : gap;\n const bounded: SizeConstraints = { maxWidth: space.width, maxHeight: space.height };\n // A `fill` item on a hugging main axis measures as it does unwrapped (see\n // `measureFillOnHugAxis`): the full extent is what a *bounded* axis offers it,\n // and a hugging one offers none.\n const sizes = items.map((item) => hugsMain && item[main] === \"fill\"\n ? measureFillOnHugAxis(item, horizontal, space, measurer)\n : measureItem(item, bounded, measurer));\n\n const lines: FlowLine[] = [];\n let widest = 0;\n let stack = 0;\n let start = 0;\n while (start < sizes.length) {\n // A line always takes at least one item, so an over-long one overflows its\n // own line rather than being pushed onto an empty one forever.\n let end = start + 1;\n let extent = sizes[start][main];\n while (end < sizes.length && extent + step + sizes[end][main] <= limit) {\n extent += step + sizes[end][main];\n end++;\n }\n // A line's thickness is its deepest item, not counting the ones that fill\n // the cross axis — what they fill is the answer being computed.\n let depth = 0;\n for (let i = start; i < end; i++) {\n if (items[i][cross] !== \"fill\" && sizes[i][cross] > depth) depth = sizes[i][cross];\n }\n for (let i = start; i < end; i++) {\n if (items[i][cross] === \"fill\") sizes[i] = withCross(sizes[i], depth, horizontal);\n }\n lines.push({ start, end, cross: depth });\n if (extent > widest) widest = extent;\n stack += depth;\n start = end;\n }\n stack += crossGap * Math.max(0, lines.length - 1);\n return {\n sizes,\n lines,\n gapScales: sizes.map(() => 1),\n hug: horizontal ? { width: widest, height: stack } : { width: stack, height: widest },\n };\n}\n\n/** Places a run's lines in the content box, centre-relative and y-up. Positions are worked out in reading order (from the start edges) and converted once at the end. */\nexport function placeRun(\n sizes: readonly Size2D[],\n lines: readonly FlowLine[],\n gapScales: readonly number[],\n horizontal: boolean,\n gap: GapSize,\n crossGap: number,\n align: Vector2,\n inner: Size2D,\n): BoxBounds[] {\n const main = horizontal ? \"width\" : \"height\";\n const cross = horizontal ? \"height\" : \"width\";\n // `align` is y-up and a run reads top-down, so y's fraction is flipped.\n const mainFraction = horizontal ? (1 + align.x) / 2 : (1 - align.y) / 2;\n const crossFraction = horizontal ? (1 - align.y) / 2 : (1 + align.x) / 2;\n\n let stack = crossGap * Math.max(0, lines.length - 1);\n for (const line of lines) stack += line.cross;\n let lineStart = crossFraction * (inner[cross] - stack);\n\n const boxes: BoxBounds[] = new Array(sizes.length);\n for (const line of lines) {\n const count = line.end - line.start;\n let extent = 0;\n let weight = 0;\n for (let i = line.start; i < line.end; i++) {\n extent += sizes[i][main];\n weight += gapScales[i];\n }\n\n let gapAfter: (i: number) => number;\n let lead = 0;\n if (gap === \"auto\") {\n // Spread within each line, so a short last line is as loose as the full ones.\n const spread = count > 1 ? Math.max(0, inner[main] - extent) / (count - 1) : 0;\n gapAfter = () => spread;\n extent += spread * (count - 1);\n } else {\n // A boundary takes the mean of its neighbours' weights, so the run spans\n // `gap * (Σweight − 1)` — what measureRun reserved. That leaves half a gap\n // over for a collapsing first item, which hangs before the visible run so\n // the content edge holds still at any alignment.\n const weightAt = (i: number): number => (i < line.end ? gapScales[i] : 1);\n gapAfter = (i) => gap * (gapScales[i] + weightAt(i + 1)) / 2;\n extent += gap * Math.max(0, weight - 1);\n lead = gap * (1 - gapScales[line.start]) / 2;\n }\n\n let at = mainFraction * (inner[main] - extent) - lead;\n for (let i = line.start; i < line.end; i++) {\n const size = sizes[i];\n const across = lineStart + crossFraction * (line.cross - size[cross]);\n boxes[i] = fromReadingOrder(horizontal ? at : across, horizontal ? across : at, size, inner);\n at += size[main] + gapAfter(i);\n }\n lineStart += line.cross + crossGap;\n }\n return boxes;\n}\n\n// From a top-left corner in the content box (y-down) to the content box's centre, y-up.\nfunction fromReadingOrder(left: number, top: number, size: Size2D, inner: Size2D): BoxBounds {\n return {\n x: left + size.width / 2 - inner.width / 2,\n y: inner.height / 2 - top - size.height / 2,\n width: size.width,\n height: size.height,\n };\n}\n\nfunction withCross(size: Size2D, depth: number, horizontal: boolean): Size2D {\n return horizontal ? { width: size.width, height: depth } : { width: depth, height: size.height };\n}\n\nfunction sanitizeFlex(value: number | undefined): number {\n if (value == null) return 1;\n return Number.isFinite(value) && value >= 0 ? value : 1;\n}\n\n// Clamped so an eased tween overshooting 0 ↔ 1 can't push a gap negative or past full.\nfunction sanitizeGapScale(value: number | undefined): number {\n if (value == null) return 1;\n return Number.isFinite(value) ? clamp(value, 0, 1) : 1;\n}\n", "import type { Size2D } from \"@/attributes/layout/size\";\nimport type { Vector2 } from \"@/attributes/layout/vector2\";\nimport type { MeasureContext2D } from \"@/render/measure-context\";\nimport type { BoxBounds } from \"./bounds\";\nimport type { FlowSpace, LayoutItem } from \"./types\";\nimport { measureItem } from \"./item\";\n\n/** Every item measured against the whole content box; the content is the largest of them. */\nexport function measureFreeform(\n items: readonly LayoutItem[],\n space: FlowSpace,\n measurer: MeasureContext2D | undefined,\n): { sizes: Size2D[]; hug: Size2D } {\n const constraints = { maxWidth: space.width, maxHeight: space.height };\n const sizes: Size2D[] = [];\n const hug = { width: 0, height: 0 };\n for (const item of items) {\n const size = measureItem(item, constraints, measurer);\n sizes.push(size);\n if (size.width > hug.width) hug.width = size.width;\n if (size.height > hug.height) hug.height = size.height;\n }\n return { sizes, hug };\n}\n\n/**\n * Each item aligned in the content box, centre-relative and y-up. Slack is\n * clamped at 0, so an item larger than the box stays centred on it.\n */\nexport function placeFreeform(sizes: readonly Size2D[], inner: Size2D, align: Vector2): BoxBounds[] {\n return sizes.map((size) => ({\n x: align.x * Math.max(0, inner.width - size.width) / 2,\n y: align.y * Math.max(0, inner.height - size.height) / 2,\n width: size.width,\n height: size.height,\n }));\n}\n", "import type { Size2D } from \"@/attributes/layout/size\";\nimport type { MeasureContext2D } from \"@/render/measure-context\";\nimport type { BoxBounds } from \"./bounds\";\nimport type { SizeConstraints } from \"./constraints\";\nimport type { FlowSpace, LayoutItem } from \"./types\";\nimport { measureItem } from \"./item\";\n\n/**\n * Measures a grid: `columns` equal tracks across the width, and rows sized to\n * their content — or, when the height is bounded, divided equally so a\n * `fill`-height item has a share to fill. Each item's cell comes back from the\n * content box's top-left, y-down.\n */\nexport function measureGrid(\n items: readonly LayoutItem[],\n columns: number,\n columnGap: number,\n rowGap: number,\n space: FlowSpace,\n measurer: MeasureContext2D | undefined,\n): { sizes: Size2D[]; cells: BoxBounds[]; hug: Size2D } {\n const count = Math.max(1, Math.round(columns));\n const track = Math.max(0, (space.width - columnGap * (count - 1)) / count);\n const placements = autoPlace(items, count);\n const rowCount = placements.reduce((max, p) => Math.max(max, p.row + p.rowSpan), 0);\n\n const bounded = space.hugHeight !== true && rowCount > 0;\n const equalRow = bounded ? Math.max(0, (space.height - rowGap * (rowCount - 1)) / rowCount) : 0;\n const rows = new Array<number>(rowCount).fill(equalRow);\n\n const sizes = items.map((item, i) => {\n const p = placements[i];\n const width = span(track, p.colSpan, columnGap);\n const constraints: SizeConstraints = bounded\n ? { maxWidth: width, maxHeight: span(equalRow, p.rowSpan, rowGap) }\n : { maxWidth: width };\n const size = measureItem(item, constraints, measurer);\n // Bounded rows are already equal, and content may not grow one past its share.\n if (!bounded) grow(rows, p.row, p.rowSpan, size.height, rowGap);\n return size;\n });\n\n const tops: number[] = [];\n let top = 0;\n for (const height of rows) {\n tops.push(top);\n top += height + rowGap;\n }\n const cells = placements.map((p) => ({\n x: p.col * (track + columnGap),\n y: tops[p.row] ?? 0,\n width: span(track, p.colSpan, columnGap),\n height: spannedRows(rows, p.row, p.rowSpan, rowGap),\n }));\n const height = rows.reduce((sum, h) => sum + h, 0) + rowGap * Math.max(0, rowCount - 1);\n return { sizes, cells, hug: { width: space.width, height } };\n}\n\n/** Each item's cell, clamped to the content box, centre-relative and y-up. */\nexport function placeGrid(cells: readonly BoxBounds[], inner: Size2D): BoxBounds[] {\n return cells.map((cell) => ({\n x: cell.x + cell.width / 2 - inner.width / 2,\n y: inner.height / 2 - cell.y - cell.height / 2,\n width: Math.min(cell.width, inner.width),\n height: Math.min(cell.height, inner.height),\n }));\n}\n\n// Left to right, wrapping when a span would overflow the columns. An item with\n// both `column` and `row` is placed there, 1-based, and left out of the flow.\nfunction autoPlace(items: readonly LayoutItem[], columns: number) {\n const placements: { col: number; row: number; colSpan: number; rowSpan: number }[] = [];\n const taken: boolean[][] = [];\n const isFree = (row: number, col: number, colSpan: number, rowSpan: number): boolean => {\n for (let r = 0; r < rowSpan; r++) {\n for (let c = 0; c < colSpan; c++) {\n if (taken[row + r]?.[col + c]) return false;\n }\n }\n return true;\n };\n const take = (row: number, col: number, colSpan: number, rowSpan: number): void => {\n for (let r = 0; r < rowSpan; r++) {\n taken[row + r] ??= [];\n for (let c = 0; c < colSpan; c++) taken[row + r][col + c] = true;\n }\n };\n\n let row = 0;\n let col = 0;\n for (const item of items) {\n const colSpan = Math.min(item.colSpan ?? 1, columns);\n const rowSpan = item.rowSpan ?? 1;\n if (item.column !== undefined && item.row !== undefined) {\n take(item.row - 1, item.column - 1, colSpan, rowSpan);\n placements.push({ col: item.column - 1, row: item.row - 1, colSpan, rowSpan });\n continue;\n }\n for (;;) {\n if (col + colSpan > columns) {\n row++;\n col = 0;\n }\n if (isFree(row, col, colSpan, rowSpan)) break;\n col++;\n }\n take(row, col, colSpan, rowSpan);\n placements.push({ col, row, colSpan, rowSpan });\n col += colSpan;\n }\n return placements;\n}\n\n// Content-sized rows grow to fit an item; a spanning item puts whatever its rows\n// are short of into the first of them.\nfunction grow(rows: number[], row: number, rowSpan: number, height: number, gap: number): void {\n if (rowSpan === 1) {\n if (height > rows[row]) rows[row] = height;\n return;\n }\n const short = height - spannedRows(rows, row, rowSpan, gap);\n if (short > 0) rows[row] += short;\n}\n\nfunction span(track: number, count: number, gap: number): number {\n return track * count + gap * (count - 1);\n}\n\nfunction spannedRows(rows: readonly number[], from: number, count: number, gap: number): number {\n let height = gap * (count - 1);\n for (let r = from; r < from + count; r++) height += rows[r] ?? 0;\n return height;\n}\n", "/** Every layout operation on one object, for the node tree and for anything a node lays out itself (a row of `Graphics2D` shapes in `renderSelf`). Takes plain data, returns boxes, writes nothing it is handed. Its `resolve`/`lerp` pair is the `flow` prop's, so a tween between modes lives in the prop's value and a seek restores the blend. Boxes are centred on the content box and y-up (`Graphics2D` space); `Node2D` converts once where it hands a box to a child. */\nimport { alignmentOps } from \"@/attributes/layout/alignment\";\nimport { insetsOps, type InsetsResolved } from \"@/attributes/layout/insets\";\nimport { sizeInputOps, type Size2D, type SizeInput } from \"@/attributes/layout/size\";\nimport type { Vector2 } from \"@/attributes/layout/vector2\";\nimport type { AttributeOps } from \"@/attributes/shared/operators\";\nimport type { MeasureContext2D } from \"@/render/measure-context\";\nimport { lerpNumber } from \"@/tween/lerp\";\nimport type { BoxBounds } from \"./bounds\";\nimport type { SizeConstraints } from \"./constraints\";\nimport { measureRun, measureWrap, placeRun } from \"./flex\";\nimport { measureFreeform, placeFreeform } from \"./freeform\";\nimport { measureGrid, placeGrid } from \"./grid\";\nimport type { FlowMeasure, FlowMode, FlowResolved, FlowSettings, FlowSpace, LayoutItem } from \"./types\";\n\nexport interface FlowOps {\n /** Lays `items` out in a box of `box`'s size, inset by `settings.padding`; boxes come back centred on `box` and y-up. Pass a `measurer` when an item measures text. */\n arrange<I extends LayoutItem>(\n settings: FlowSettings, items: readonly I[], box: Size2D, measurer?: MeasureContext2D,\n ): BoxBounds[];\n /** The first half of `arrange`: each item's size, and the extent a hugging container wraps. */\n measure<I extends LayoutItem>(\n settings: FlowSettings, items: readonly I[], space: FlowSpace, measurer?: MeasureContext2D,\n ): FlowMeasure<I>;\n /** The second half: each item's box in a content box of `inner`'s size. */\n place(measure: FlowMeasure, settings: FlowSettings, inner: Size2D): BoxBounds[];\n /** Whether `measure` still holds for a content box of `inner`'s size. */\n reusable(measure: FlowMeasure, inner: Size2D): boolean;\n /** Where `settings` would put one more item of `size`, centred and y-up like `place`; `null` for a run or grid, where the slot depends on the others. */\n freeSlot(settings: FlowSettings, inner: Size2D, size: Size2D): BoxBounds | null;\n\n /** The content box a `width` × `height` container measures its items in. */\n contentBox(\n sizing: Pick<LayoutItem, \"width\" | \"height\">, constraints: SizeConstraints, padding: InsetsResolved,\n ): FlowSpace;\n /** The container's own size, given the `hug` extent its items came to. */\n size(\n sizing: Pick<LayoutItem, \"width\" | \"height\">, constraints: SizeConstraints, padding: InsetsResolved, hug: Size2D,\n ): Size2D;\n\n /** What is wrong with a run laid out in a box of `box`'s size, or `null`. */\n collapsedRun(measure: FlowMeasure, box: Size2D): string | null;\n}\n\nconst CENTRE: Vector2 = { x: 0, y: 0 };\n\nfunction arrange<I extends LayoutItem>(\n settings: FlowSettings, items: readonly I[], box: Size2D, measurer?: MeasureContext2D,\n): BoxBounds[] {\n const inner = insetsOps.insetBounds(box.width, box.height, insetsOps.resolve(settings.padding ?? 0));\n const boxes = place(measure(settings, items, inner, measurer), settings, inner);\n // `insetBounds` offsets the content box y-down; the boxes are y-up.\n return boxes.map((b) => ({ x: b.x + inner.x, y: b.y - inner.y, width: b.width, height: b.height }));\n}\n\nfunction measure<I extends LayoutItem>(\n settings: FlowSettings, items: readonly I[], space: FlowSpace, measurer?: MeasureContext2D,\n): FlowMeasure<I> {\n const flow = settings.flow ?? \"freeform\";\n if (typeof flow === \"string\") return measureMode(flow, settings, items, space, measurer);\n const from = measureMode(flow.from, settings, items, space, measurer);\n const to = measureMode(flow.to, settings, items, space, measurer);\n return { ...to, hug: lerpSize(from.hug, to.hug, flow.t), from, t: flow.t };\n}\n\nfunction place(measure: FlowMeasure, settings: FlowSettings, inner: Size2D): BoxBounds[] {\n const to = placeMode(measure, settings, inner);\n const from = measure.from;\n if (!from) return to;\n const fromBoxes = placeMode(from, settings, inner);\n const t = measure.t ?? 1;\n return to.map((box, i) => ({\n x: lerpNumber(fromBoxes[i].x, box.x, t),\n y: lerpNumber(fromBoxes[i].y, box.y, t),\n width: lerpNumber(fromBoxes[i].width, box.width, t),\n height: lerpNumber(fromBoxes[i].height, box.height, t),\n }));\n}\n\n// Yoga's rule: reuse on an axis laid out at the size it was measured in, or — on\n// an axis that hugs — at exactly what it hugged. Anything else, a parent laid this\n// out at a size it did not measure it for, and the measure is stale.\nfunction reusable(measure: FlowMeasure, inner: Size2D): boolean {\n const { space, hug } = measure;\n return fits(inner.width, space.width, space.hugWidth, hug.width)\n && fits(inner.height, space.height, space.hugHeight, hug.height);\n}\n\nfunction contentBox(\n sizing: Pick<LayoutItem, \"width\" | \"height\">, constraints: SizeConstraints, padding: InsetsResolved,\n): FlowSpace {\n const width = outerFor(sizing.width, constraints.maxWidth);\n const height = outerFor(sizing.height, constraints.maxHeight);\n const inner = insetsOps.insetBounds(width, height, padding);\n return {\n width: inner.width,\n height: inner.height,\n hugWidth: sizing.width === \"hug\",\n hugHeight: sizing.height === \"hug\",\n };\n}\n\nfunction size(\n sizing: Pick<LayoutItem, \"width\" | \"height\">, constraints: SizeConstraints, padding: InsetsResolved, hug: Size2D,\n): Size2D {\n const hugged = insetsOps.outsetSize(hug.width, hug.height, padding);\n return {\n width: sizing.width === \"hug\" ? hugged.width : outerFor(sizing.width, constraints.maxWidth),\n height: sizing.height === \"hug\" ? hugged.height : outerFor(sizing.height, constraints.maxHeight),\n };\n}\n\n/** A run laid out in a box of length 0 on its main axis, with items that have a size. Always a bug, and a quiet one: a run places from the box's centre, so content is displaced by half a box it does not visibly have (\"the scene loaded at 0,0\"). A box holding only collapsed items is legitimately empty (an animated insert or remove mid-flight). */\nfunction collapsedRun(measure: FlowMeasure, box: Size2D): string | null {\n if (measure.mode !== \"horizontal\" && measure.mode !== \"vertical\") return null;\n if ((measure.mode === \"horizontal\" ? box.width : box.height) > 0) return null;\n const sized = measure.sizes.filter((s) => s.width > 0 || s.height > 0).length;\n if (sized === 0) return null;\n return `is laying out ${sized} sized child${sized === 1 ? \"\" : \"ren\"} in a run of length 0 `\n + `(${box.width}×${box.height}, ${measure.mode}). `\n + `They will be positioned from its centre rather than its leading edge.`;\n}\n\n// A `from` that is itself a blend — a tween built mid-blend — starts from where it was heading.\nfunction lerp(from: FlowResolved, to: FlowResolved, t: number): FlowResolved {\n const a = typeof from === \"string\" ? from : from.to;\n const b = typeof to === \"string\" ? to : to.to;\n return t >= 1 || a === b ? b : { from: a, to: b, t };\n}\n\nfunction measureMode<I extends LayoutItem>(\n mode: FlowMode, settings: FlowSettings, items: readonly I[], space: FlowSpace, measurer: MeasureContext2D | undefined,\n): FlowMeasure<I> {\n if (mode === \"freeform\") return { mode, items, space, ...measureFreeform(items, space, measurer) };\n if (mode === \"grid\") {\n const grid = measureGrid(items, settings.columns ?? 1, mainGap(settings), crossGap(settings), space, measurer);\n return { mode, items, space, ...grid };\n }\n const horizontal = mode === \"horizontal\";\n const run = settings.wrap\n ? measureWrap(items, horizontal, settings.gap ?? 0, crossGap(settings), space, measurer)\n : measureRun(items, horizontal, settings.gap ?? 0, space, measurer);\n return { mode, items, space, ...run };\n}\n\nfunction placeMode(measure: FlowMeasure, settings: FlowSettings, inner: Size2D): BoxBounds[] {\n if (measure.mode === \"grid\") return placeGrid(measure.cells ?? [], inner);\n const align = alignOf(settings);\n if (measure.mode === \"freeform\") return placeFreeform(measure.sizes, inner, align);\n return placeRun(\n measure.sizes, measure.lines ?? [], measure.gapScales ?? [], measure.mode === \"horizontal\",\n settings.gap ?? 0, crossGap(settings), align, inner,\n );\n}\n\nfunction freeSlot(settings: FlowSettings, inner: Size2D, size: Size2D): BoxBounds | null {\n if ((settings.flow ?? \"freeform\") !== \"freeform\") return null;\n return placeFreeform([size], inner, alignOf(settings))[0];\n}\n\n// A container stores `align` resolved, so only a named key needs resolving here.\nfunction alignOf(settings: FlowSettings): Vector2 {\n const align = settings.align;\n if (align === undefined) return CENTRE;\n return typeof align === \"string\" ? alignmentOps.resolve(align) : align;\n}\n\nfunction mainGap(settings: FlowSettings): number {\n const gap = settings.gap ?? 0;\n return gap === \"auto\" ? 0 : gap;\n}\n\nfunction crossGap(settings: FlowSettings): number {\n return settings.crossGap ?? mainGap(settings);\n}\n\n// A hugging axis measures its items against all the room it could have.\nfunction outerFor(input: SizeInput, max: number | undefined): number {\n const available = max ?? 0;\n return input === \"hug\" ? available : sizeInputOps.resolveLayout(input, available, 0);\n}\n\nfunction lerpSize(from: Size2D, to: Size2D, t: number): Size2D {\n return { width: lerpNumber(from.width, to.width, t), height: lerpNumber(from.height, to.height, t) };\n}\n\nfunction fits(laid: number, measured: number, hugs: boolean | undefined, hugged: number): boolean {\n return near(laid, measured) || (hugs === true && near(laid, hugged));\n}\n\nfunction near(a: number, b: number): boolean {\n if (a === b) return true;\n if (!Number.isFinite(a) || !Number.isFinite(b)) return false;\n return Math.abs(a - b) <= 1e-6 * Math.max(1, Math.abs(a), Math.abs(b));\n}\n\nexport const flowOps: AttributeOps<FlowMode, FlowResolved> & FlowOps = {\n resolve: (value) => value,\n lerp,\n\n arrange,\n measure,\n place,\n reusable,\n freeSlot,\n\n contentBox,\n size,\n\n collapsedRun,\n};\n", "import { lerpNumber } from \"@/tween/lerp\";\nimport type { AttributeOps } from \"@/attributes/shared/operators\";\n\n/** A 3D point or offset: core's {@link Vector2} one dimension up, in the same plain-object idiom. */\nexport interface Vector3 {\n x: number;\n y: number;\n z: number;\n}\n\n/**\n * Loose forms accepted anywhere a {@link Vector3} is expected:\n *\n * - an object — `{ x: 1, y: 2, z: 3 }`\n * - a 3-tuple — `[1, 2, 3]`\n * - a scalar, broadcast to all three axes — `0` means the origin, `2` means\n * `{ x: 2, y: 2, z: 2 }` (handy for uniform scale and `lookAt: 0`)\n */\nexport type Vector3Input = Vector3 | readonly [number, number, number] | number;\n\nconst ZERO: Vector3 = { x: 0, y: 0, z: 0 };\n\nexport function resolveVector3(input: Vector3Input | undefined): Vector3 {\n if (input === undefined) return { ...ZERO };\n if (typeof input === \"number\") return { x: input, y: input, z: input };\n if (Array.isArray(input)) return { x: input[0] ?? 0, y: input[1] ?? 0, z: input[2] ?? 0 };\n const v = input as Vector3;\n return { x: v.x ?? 0, y: v.y ?? 0, z: v.z ?? 0 };\n}\n\n/** Component-wise lerp (`t=0` is `from`, `t=1` is `to`). Pass as a prop's `tween` so 3D vectors animate (`property({ default, tween: lerpVector3 })`, or a `Types.vector3` entry); without one `to()` leaves the prop alone. */\nexport function lerpVector3(from: Vector3, to: Vector3, t: number): Vector3 {\n return {\n x: lerpNumber(from.x, to.x, t),\n y: lerpNumber(from.y, to.y, t),\n z: lerpNumber(from.z, to.z, t),\n };\n}\n\n/** The `Vector3` attribute's op set — a 3D position or scale. */\nexport const vector3Ops: AttributeOps<Vector3Input, Vector3> = {\n resolve: (value) => resolveVector3(value),\n lerp: lerpVector3,\n};\n\n/**\n * Map an optional {@link Vector3Input}: an unset prop stays unset (a thunk that\n * returns `undefined` included) instead of resolving to the origin, which would\n * turn \"no aim\" into \"aim at the origin\".\n */\nexport function resolveOptionalVector3(input: Vector3Input | undefined): Vector3 | undefined {\n return input === undefined ? undefined : resolveVector3(input);\n}\n\n/** Lerp for a vector prop that may be unset (a node's `lookAt`, a camera's or light's `target`). With no start value, `unset: \"origin\"` blends from the origin (the renderer's reading for `target`); `unset: \"snap\"` holds it unset and swaps at the end, the only honest reading for `lookAt` (unset is \"do not aim\"). A `to` that ends unset leaves the start in place. */\nexport function lerpOptionalVector3(\n from: Vector3 | undefined,\n to: Vector3 | undefined,\n t: number,\n unset: \"origin\" | \"snap\",\n): Vector3 | undefined {\n if (to === undefined) return from;\n if (from !== undefined) return lerpVector3(from, to, t);\n if (unset === \"origin\") return lerpVector3(ZERO, to, t);\n return t >= 1 ? to : from;\n}\n\n/** The order Euler angles are applied in. Matches three's own naming. */\nexport type EulerOrder = \"XYZ\" | \"YXZ\" | \"ZXY\" | \"ZYX\" | \"YZX\" | \"XZY\";\n\n/** An Euler rotation in **degrees** (matching 2D `rotation`); the renderer converts. */\nexport interface Euler3 extends Vector3 {\n order?: EulerOrder;\n}\n\n/** Component-wise lerp of two Euler rotations in degrees; `order` is discrete and snaps at the halfway point. Euler interpolation gimbals near the poles and takes the \"wrong\" path past 180°: for a tumble use a {@link Quaternion} prop and {@link slerpQuaternion}. */\nexport function lerpEuler3(from: Euler3, to: Euler3, t: number): Euler3 {\n return {\n x: lerpNumber(from.x, to.x, t),\n y: lerpNumber(from.y, to.y, t),\n z: lerpNumber(from.z, to.z, t),\n order: t < 0.5 ? from.order : to.order,\n };\n}\n\n/** The `Euler3` attribute's op set — a rotation in degrees, per axis. */\nexport const euler3Ops: AttributeOps<Vector3Input | Euler3, Euler3> = {\n resolve: (input) => {\n const v = resolveVector3(input as Vector3Input);\n const order = (input as Euler3)?.order;\n return order ? { ...v, order } : v;\n },\n lerp: lerpEuler3,\n};\n\nexport interface Quaternion {\n x: number;\n y: number;\n z: number;\n w: number;\n}\n\nexport const IDENTITY_QUATERNION: Quaternion = { x: 0, y: 0, z: 0, w: 1 };\n\n/** Shortest-arc spherical lerp, the correct quaternion tween (a component-wise lerp leaves the unit hypersphere, so rotation speed varies). Negates `to` when `dot < 0` so the rotation takes the short way; falls back to a normalized linear blend when nearly parallel and `sin(theta)` would underflow. */\nexport function slerpQuaternion(from: Quaternion, to: Quaternion, t: number): Quaternion {\n let { x, y, z, w } = to;\n let dot = from.x * x + from.y * y + from.z * z + from.w * w;\n\n // Both q and -q describe the same rotation; pick the nearer representative.\n if (dot < 0) {\n x = -x; y = -y; z = -z; w = -w;\n dot = -dot;\n }\n\n // Nearly parallel — slerp's sin(theta) denominator underflows, and a linear\n // blend is indistinguishable at this angle anyway.\n if (dot > 0.9995) {\n return normalizeQuaternion({\n x: lerpNumber(from.x, x, t),\n y: lerpNumber(from.y, y, t),\n z: lerpNumber(from.z, z, t),\n w: lerpNumber(from.w, w, t),\n });\n }\n\n const theta = Math.acos(dot);\n const sinTheta = Math.sin(theta);\n const a = Math.sin((1 - t) * theta) / sinTheta;\n const b = Math.sin(t * theta) / sinTheta;\n\n return {\n x: from.x * a + x * b,\n y: from.y * a + y * b,\n z: from.z * a + z * b,\n w: from.w * a + w * b,\n };\n}\n\n/** Scale a quaternion back to unit length. Returns identity for a zero quat. */\nexport function normalizeQuaternion(q: Quaternion): Quaternion {\n const length = Math.hypot(q.x, q.y, q.z, q.w);\n if (length === 0) return { ...IDENTITY_QUATERNION };\n return { x: q.x / length, y: q.y / length, z: q.z / length, w: q.w / length };\n}\n\n/** Convert an {@link Euler3} (degrees) to a {@link Quaternion}. */\nexport function quaternionFromEuler(euler: Euler3): Quaternion {\n const half = Math.PI / 360; // deg → rad, then halved for the half-angle form\n const cx = Math.cos(euler.x * half), sx = Math.sin(euler.x * half);\n const cy = Math.cos(euler.y * half), sy = Math.sin(euler.y * half);\n const cz = Math.cos(euler.z * half), sz = Math.sin(euler.z * half);\n\n switch (euler.order ?? \"XYZ\") {\n case \"YXZ\":\n return {\n x: sx * cy * cz + cx * sy * sz,\n y: cx * sy * cz - sx * cy * sz,\n z: cx * cy * sz - sx * sy * cz,\n w: cx * cy * cz + sx * sy * sz,\n };\n case \"ZXY\":\n return {\n x: sx * cy * cz - cx * sy * sz,\n y: cx * sy * cz + sx * cy * sz,\n z: cx * cy * sz + sx * sy * cz,\n w: cx * cy * cz - sx * sy * sz,\n };\n case \"ZYX\":\n return {\n x: sx * cy * cz - cx * sy * sz,\n y: cx * sy * cz + sx * cy * sz,\n z: cx * cy * sz - sx * sy * cz,\n w: cx * cy * cz + sx * sy * sz,\n };\n case \"YZX\":\n return {\n x: sx * cy * cz + cx * sy * sz,\n y: cx * sy * cz + sx * cy * sz,\n z: cx * cy * sz - sx * sy * cz,\n w: cx * cy * cz - sx * sy * sz,\n };\n case \"XZY\":\n return {\n x: sx * cy * cz - cx * sy * sz,\n y: cx * sy * cz - sx * cy * sz,\n z: cx * cy * sz + sx * sy * cz,\n w: cx * cy * cz + sx * sy * sz,\n };\n case \"XYZ\":\n default:\n return {\n x: sx * cy * cz + cx * sy * sz,\n y: cx * sy * cz - sx * cy * sz,\n z: cx * cy * sz + sx * sy * cz,\n w: cx * cy * cz - sx * sy * sz,\n };\n }\n}\n\n/** The `Quaternion` attribute's op set: resolve is the identity, lerp shortest-arc slerps. */\nexport const quaternionOps: AttributeOps<Quaternion, Quaternion> = {\n resolve: (value) => value,\n lerp: slerpQuaternion,\n};\n", "import type { RectState } from \"./descriptors/rect\";\nimport type { EllipseState } from \"./descriptors/ellipse\";\nimport type { PathState } from \"./descriptors/path\";\nimport type { LineState } from \"./descriptors/line\";\nimport type { PolygonState } from \"./descriptors/polygon\";\nimport type { PolygramState } from \"./descriptors/polygram\";\nimport type { ShapeAlignmentInput } from \"./descriptors/shape\";\nimport { PathBuilder } from \"./descriptors/path-builder\";\n\n/** The shape ops a {@link Clip} can record: the {@link Graphics2D} geometry primitives minus text/image (no clippable outline). */\nexport type ClipShapeOp =\n | { kind: \"rect\"; state: Partial<RectState> & ShapeAlignmentInput }\n | { kind: \"ellipse\"; state: Partial<EllipseState> & ShapeAlignmentInput }\n | { kind: \"path\"; state: Partial<PathState> }\n | { kind: \"line\"; state: Partial<LineState> }\n | { kind: \"polygon\"; state: Partial<PolygonState> & ShapeAlignmentInput }\n | { kind: \"polygram\"; state: Partial<PolygramState> & ShapeAlignmentInput };\n\n/** One recorded op in a {@link Clip}: shape ops add geometry to the region; `cut` subtracts the last-declared shape from those before it. Replayed into a single clip path via `RenderContext2D.beginClip()`. */\nexport type ClipOp = ClipShapeOp | { kind: \"cut\" };\n\n/**\n * A renderer-agnostic, chainable clip-region builder: `Graphics2D` for clipping. Shapes combine (a union, with\n * `cut()`s subtracted), so a clip can be any compound silhouette, not just one rect or ellipse:\n *\n * const c = new Clip()\n * .rect({ width: 200, height: 120, cornerRadius: 16 })\n * .ellipse({ x: 80, width: 60, height: 60 }) // unions with the rect\n * .ellipse({ x: -80, width: 40, height: 40 })\n * .cut(); // punches the last hole\n * ctx.beginClip(c);\n * ...draw clipped content...\n * ctx.endClip();\n *\n * It carries no paint, only the outline: what a shape returns from `clipSelf()` to define both its `clip` boundary and\n * the silhouette its backdrop effects are confined to, so one definition drives every clip the node needs.\n */\nexport class Clip {\n private _ops: ClipOp[] = [];\n\n rect(state: Partial<RectState> & ShapeAlignmentInput): this {\n this._ops.push({ kind: \"rect\", state });\n return this;\n }\n\n ellipse(state: Partial<EllipseState> & ShapeAlignmentInput): this {\n this._ops.push({ kind: \"ellipse\", state });\n return this;\n }\n\n /** Add a vector path to the clip region, from a `PathState` or a `PathBuilder`. */\n path(state: Partial<PathState> | PathBuilder): this {\n const resolved = state instanceof PathBuilder ? state.toPathState() : state;\n this._ops.push({ kind: \"path\", state: resolved });\n return this;\n }\n\n line(state: Partial<LineState>): this {\n this._ops.push({ kind: \"line\", state });\n return this;\n }\n\n polygon(state: Partial<PolygonState> & ShapeAlignmentInput): this {\n this._ops.push({ kind: \"polygon\", state });\n return this;\n }\n\n polygram(state: Partial<PolygramState> & ShapeAlignmentInput): this {\n this._ops.push({ kind: \"polygram\", state });\n return this;\n }\n\n /** Uses the last-declared shape as a cutter: unions the shapes before it and subtracts that one, punching a hole. Mirrors {@link Graphics2D.cut}. */\n cut(): this {\n this._ops.push({ kind: \"cut\" });\n return this;\n }\n\n /** The recorded ops, in order. Consumed by `RenderContext2D.beginClip()`. */\n ops(): readonly ClipOp[] {\n return this._ops;\n }\n\n /** True when no shape op has been recorded — the clip region is empty. */\n isEmpty(): boolean {\n return !this._ops.some((op) => op.kind !== \"cut\");\n }\n}\n", "import { TweenFn } from \"@/props/host\";\nimport { property } from \"./decorator\";\n\nimport { type Fill } from \"@/attributes/shape/fill/chain\";\nimport { FillResolved } from \"@/attributes/shape/fill/union\";\nimport { fillOps } from \"@/attributes/shape/fill/registry\";\n\nimport { type Effect, effectsOps } from \"@/attributes/shape/effects/chain\";\nimport { NodeEffect } from \"@/attributes/shape/effects/union\";\n\nimport { Insets, InsetsResolved, insetsOps } from \"@/attributes/layout/insets\";\nimport { Alignment, alignmentOps } from \"@/attributes/layout/alignment\";\nimport { Vector2 } from \"@/attributes/layout/vector2\";\nimport { flowOps } from \"@/layout/ops\";\nimport type { FlowMode, FlowResolved } from \"@/layout/types\";\n\nimport { type AudioEffectsInput } from \"@/attributes/audio/effects/chain\";\nimport { audioEffectsOps } from \"@/attributes/audio/effects/registry\";\nimport { AudioEffect } from \"@/attributes/audio/effects/union\";\nimport { type Param, audioParamOps } from \"@/attributes/audio/ramp\";\n\nimport {\n quaternionOps, lerpOptionalVector3, resolveOptionalVector3,\n type Quaternion, type Vector3, type Vector3Input,\n} from \"@/render3d/vector3\";\n\n/** Attribute-typed variants of `property` for the props the tree bases declare themselves. A rich attribute is only declarative and tweenable because its `property` carries the matching *mapper* (loose input → resolved) and *tween*, together an `AttributeOps`; these pre-bake each pair (`fillProperty()` is `property({ default: [], mapper: fillOps.resolve, tween: fillOps.lerp, kind: \"fills\" })`). */\ninterface AttributePropOptions<Ext, Int> {\n default?: Ext;\n mapper?: (ext: Ext, prev?: Int) => Int;\n tween?: TweenFn<Int>;\n}\n\n/** Builds one attribute-typed `property` from its {@link AttributeOps}. `fallback` is a factory so array/object defaults aren't one instance shared by every property; an **explicit** `default: undefined` means \"no default\" and is honoured. */\nfunction attributeProperty<Ext, Int>(\n fallback: () => Ext,\n mapper?: (ext: Ext, prev?: Int) => Int,\n tween?: TweenFn<Int>,\n /** The control a host draws for this attribute, when it is not the default. */\n kind?: string,\n) {\n return (opts?: AttributePropOptions<Ext, Int> & { kind?: string }) =>\n property<Ext, Int>({\n default: opts && \"default\" in opts ? opts.default : fallback(),\n mapper: opts?.mapper ?? mapper,\n tween: opts?.tween ?? tween,\n ...(opts?.kind ?? kind ? { kind: opts?.kind ?? kind } : {}),\n });\n}\n\n/** A fill-layer property: a CSS string, a fill prop object, a `Fills` chain, or an array of them, lerped layer by layer. */\nexport const fillProperty = attributeProperty<Fill, FillResolved[]>(() => [], fillOps.resolve, fillOps.lerp, \"fills\");\n\nexport const effectsProperty = attributeProperty<Effect, NodeEffect[]>(() => [], effectsOps.resolve, effectsOps.lerp, \"effects\");\n\nexport const insetsProperty = attributeProperty<Insets, InsetsResolved>(() => 0, insetsOps.resolve, insetsOps.lerp, \"insets\");\n\n/** A named position (`'center'`, …) resolved to a {@link Vector2} in `[-1, 1]` and tweened as a vector, so `'centerLeft' → 'centerRight'` slides. */\nexport const alignmentProperty = attributeProperty<Alignment, Vector2>(() => \"center\", alignmentOps.resolve, alignmentOps.lerp, \"alignment\");\n\n/** Mid-tween it holds both modes and how far along, so a seek restoring the prop restores the blend. */\nexport const flowProperty = attributeProperty<FlowMode, FlowResolved>(() => \"freeform\", undefined, flowOps.lerp);\n\n/** A 3D point that may be unset (a node's `lookAt`): defaults to unset rather than the origin, stays unset when a binding returns `undefined`, and tweens from `unset`'s reading of an unset start (see {@link lerpOptionalVector3}). */\nexport function optionalVector3Property(unset: \"origin\" | \"snap\") {\n return property<Vector3Input | undefined, Vector3 | undefined>({\n default: undefined,\n mapper: resolveOptionalVector3,\n tween: (from, to, t) => lerpOptionalVector3(from, to, t, unset),\n kind: \"vector3\",\n });\n}\n\n/** A rotation as a unit quaternion, interpolated with shortest-arc slerp. */\nexport const quaternionProperty = attributeProperty<Quaternion, Quaternion>(\n () => ({ x: 0, y: 0, z: 0, w: 1 }), undefined, quaternionOps.lerp, \"quaternion\",\n);\n\n/** An audio level (gain, pan). A `Param`, not a `number`, because an `AudioRequest` is a schedule record built once during precomp: a per-frame prop write would be read on one frame and never again. A `Ramp` *is* the automation lane, so the tween interpolates whole ramps. */\nexport const audioParamProperty = attributeProperty<Param, Param>(() => 0, undefined, audioParamOps.lerp, \"audioParam\");\n\n/** An audio effect chain. Without it the chain is an object-valued prop and `Node._prepareStep` silently drops those: the tween would run its duration and write nothing. */\nexport const audioEffectsProperty = attributeProperty<AudioEffectsInput, AudioEffect[]>(\n () => [], audioEffectsOps.resolve, audioEffectsOps.lerp, \"audioEffects\",\n);\n", "import { NodeRenderState } from \"@/render/render-context2d\";\nimport { Vector2 } from \"@/attributes/layout/vector2\";\n\n/** Companion for {@link Node2D}'s clock advance and motion sampling: the backward-difference math as a pure function over reused scratch state (the {@link MotionHistory} is created once per node), with no per-frame allocation. Reactive prop reads stay in Node2D's `_sampleMotion`. */\n\n/** Largest frame delta we trust for a velocity estimate (seconds). Larger gaps (scrub/seek) read as \"unknown\". */\n/** @internal */\nexport const MAX_MOTION_DT = 0.2;\n\n/** Per-node rolling history for the backward-difference velocity estimate: allocated once, mutated in place by {@link sampleMotion}. */\n/** @internal */\nexport interface MotionHistory {\n prevPos: Vector2 | null;\n prevTime: number;\n prevRotation: number;\n prevScale: number;\n}\n\n/** Records the current position as the history's previous frame **without** deriving a velocity: the seam a driven scene primes through. A generator scene walks time one `dt` at a time, so its history is the frame before; a driven scene jumps to any frame, so differencing against \"wherever the playhead last was\" would make velocity depend on how the viewer got there (a quick scrub smears a static node, holding still doesn't, stepping back reads zero). Priming with the position one frame earlier makes it depend on the frame alone. */\n/** @internal */\nexport function primeMotion(\n history: MotionHistory,\n x: number,\n y: number,\n rotation: number,\n scale: number,\n at: number,\n): void {\n if (!history.prevPos) history.prevPos = { x, y };\n else { history.prevPos.x = x; history.prevPos.y = y; }\n history.prevTime = at;\n history.prevRotation = rotation;\n history.prevScale = scale;\n}\n\n/** Create the zeroed history holder a node keeps for its lifetime. */\n/** @internal */\nexport function createMotionHistory(): MotionHistory {\n return { prevPos: null, prevTime: 0, prevRotation: 0, prevScale: 1 };\n}\n\n/** Computes this frame's motion into the reused `state` as a backward difference against `history`, then rolls the history. Velocity is zero when no trustworthy delta exists (first frame, or a non-monotonic jump: only `0 < dt <= MAX` is trusted, so a scrub reads \"unknown\" not a huge velocity). `x`/`y` are the world position (y-down) from `layoutBounds + x` / `layoutBounds - y`; layout-dependent fields are filled at draw time. */\n/** @internal */\nexport function sampleMotion(\n state: NodeRenderState,\n history: MotionHistory,\n x: number,\n y: number,\n rotation: number,\n scale: number,\n now: number,\n): void {\n const dt = now - history.prevTime;\n const prev = history.prevPos;\n if (prev && dt > 0 && dt <= MAX_MOTION_DT) {\n const vx = (x - prev.x) / dt;\n const vy = (y - prev.y) / dt;\n state.dt = dt;\n state.velocity.x = vx;\n state.velocity.y = vy;\n state.speed = Math.hypot(vx, vy);\n state.direction = (Math.atan2(vy, vx) * 180) / Math.PI;\n state.angularVelocity = (rotation - history.prevRotation) / dt;\n state.scaleVelocity = (scale - history.prevScale) / dt;\n } else {\n state.dt = 0;\n state.velocity.x = 0;\n state.velocity.y = 0;\n state.speed = 0;\n state.direction = 0;\n state.angularVelocity = 0;\n state.scaleVelocity = 0;\n }\n\n if (!prev) history.prevPos = { x, y };\n else { prev.x = x; prev.y = y; }\n history.prevTime = now;\n history.prevRotation = rotation;\n history.prevScale = scale;\n}\n", "import { EasingFunction } from \"@/tween/ease/type\";\nimport { commandParallel, commandSequence, driveCommand, type Command } from \"@/tween/command\";\nimport { SizeConstraints } from \"@/layout/constraints\";\nimport type { Node2D, Node2DProps } from \"./node2d\";\n\n/** Measures `child`'s natural size without attaching it to `parent`, so siblings don't shift for a frame. Uses the constraints and scope the parent retained from its last measure pass (`parent.lastMeasure`); `null` if it hasn't been measured yet (nothing on screen to reflow against). */\nfunction measureDetached(parent: Node2D, child: Node2D): { width: number; height: number } | null {\n const pass = parent.lastMeasure;\n const scope = pass?.measurer;\n // The scope (text measurement) is the essential input and only exists once the parent has been laid out.\n if (!scope) return null;\n // Bounded by the parent's constraints, else its laid-out box, else unbounded (a hug child shrink-wraps regardless).\n const constraints: SizeConstraints = pass?.constraints ?? {\n maxWidth: parent.measuredWidth || Number.MAX_SAFE_INTEGER,\n maxHeight: parent.measuredHeight || Number.MAX_SAFE_INTEGER,\n };\n const size = child.measure(constraints, scope);\n return { width: size.width ?? 0, height: size.height ?? 0 };\n}\n\n/**\n * Companion for {@link Node2D}'s animated child management: the animated overloads, returned as {@link Command}s\n * built from `child.to(...)` with {@link commandSequence}/{@link commandParallel}. The sync variants stay inline on Node2D.\n *\n * Each command's setup (measuring, collapsing, attaching/detaching/reparenting) runs **lazily, once, on the first\n * evaluation**, not when the function is called. That is load-bearing: a caller often creates the command, lays the\n * parent out, then drives it, relying on a fresh `lastMeasure` when {@link addChildAtAnimated} measures; measuring\n * eagerly would read whatever scope the parent had at call time, often none.\n *\n * The container's `gap` is handled by the per-child `gapScale` tweened in parallel with the child's box (flex folds\n * each child's `gapScale` into its gap budget), so no helper needs the parent's axis or gap value.\n */\n\n/**\n /** Fraction of an insert/remove's `duration` spent on size + gap motion; the rest is the opacity fade. Sequential phases (grow then fade in; fade out then shrink) keep a fading child from overlapping siblings that are still sliding. */\nconst SIZE_PHASE = 0.7;\n\n/**\n * Animated `addChildAt`: inserts the child **already collapsed to 0**, then grows it in (opacity up, box 0 to its\n * natural size) so siblings slide over rather than jump; the mirror of {@link removeChildAtAnimated}.\n *\n * A `\"hug\"`/`\"fill\"` axis has no size until laid out, so it is measured **detached** ({@link measureDetached}) before\n * attaching, keeping siblings from seeing it at full width for a frame. The tween needs numeric endpoints, so the\n * original size token is restored when the command ends. With no retained scope (parent not yet measured) such an\n * axis keeps its authored token and fades in without a width tween.\n */\nexport function addChildAtAnimated(\n parent: Node2D,\n child: Node2D,\n index: number,\n duration: number,\n easing?: EasingFunction,\n): Command<Record<string, never>> {\n let animation: Command<Node2DProps> | null = null;\n let isNumericW = false;\n let isNumericH = false;\n let origW: Node2DProps[\"width\"];\n let origH: Node2DProps[\"height\"];\n\n const setup = (): Command<Node2DProps> => {\n const targetOpacity = child.opacity;\n // Remember the authored size tokens to restore a hug/fill axis after the grow-in.\n origW = child.width;\n origH = child.height;\n isNumericW = typeof origW === \"number\";\n isNumericH = typeof origH === \"number\";\n\n // Pre-measure non-numeric axes while detached, so sizing can't shift existing siblings.\n const detached = isNumericW && isNumericH ? null : measureDetached(parent, child);\n\n // Grow-to target: the authored size for a numeric axis, else the detached measurement (no width tween if unmeasured).\n const tweenW = isNumericW || detached !== null;\n const tweenH = isNumericH || detached !== null;\n const targetW = isNumericW ? (origW as number) : (detached?.width ?? 0);\n const targetH = isNumericH ? (origH as number) : (detached?.height ?? 0);\n\n // Collapse tweenable axes to 0 before inserting so the child takes no room; `gapScale: 0` also suppresses its gap, so the flanking gap opens from 0.\n child.set({\n opacity: 0,\n gapScale: 0,\n ...(tweenW ? { width: 0 } : {}),\n ...(tweenH ? { height: 0 } : {}),\n } as Partial<Node2DProps>);\n parent.addChildAt({ data: { child, index } });\n\n const sizeProps: Partial<Node2DProps> = {};\n if (tweenW) sizeProps.width = targetW;\n if (tweenH) sizeProps.height = targetH;\n // Two sequential phases so the fading-in child never overlaps sliding siblings: open the box and gap (opacity held\n // at 0), then fade in. `gapScale` 0 -> 1 tracks the size so siblings slide continuously.\n const grow = duration * SIZE_PHASE;\n const fade = duration - grow;\n return commandSequence<Node2DProps>(\n child,\n commandParallel<Node2DProps>(\n child,\n child.to({ data: sizeProps, duration: grow, easing }),\n child.to({ data: { gapScale: 1 } as Partial<Node2DProps>, duration: grow, easing }),\n ),\n child.to({ data: { opacity: targetOpacity } as Partial<Node2DProps>, duration: fade, easing }),\n );\n };\n\n return driveCommand(duration, (t) => {\n if (!animation) animation = setup();\n animation.at(t);\n if (t >= 1) {\n // Restore any hug/fill token so the child reflows naturally from here; the tween already landed on its measured pixel size.\n const restore: Partial<Node2DProps> = {};\n if (!isNumericW) restore.width = origW;\n if (!isNumericH) restore.height = origH;\n if (!isNumericW || !isNumericH) child.set(restore as Partial<Node2DProps>);\n }\n });\n}\n\n/** Animated `removeChildAt`: fades and sizes the child out, then detaches it. The child stays in the tree until the end (`t === 1`), so a host seeking earlier sees it mid-fade; seeking back below the end re-attaches it at its original index, keeping the animation a function of `t` in both directions (as `packages/components/code`'s insert/remove). */\nexport function removeChildAtAnimated(\n parent: Node2D,\n index: number,\n duration: number,\n easing?: EasingFunction,\n): Command<Record<string, never>> {\n let child: Node2D | null = null;\n let animation: Command<Node2DProps> | null = null;\n let setupDone = false;\n\n const setup = (): void => {\n setupDone = true;\n // Out of range: nothing to animate (`child`/`animation` stay null and every apply() is a no-op).\n if (index < 0 || index >= parent.children.length) return;\n child = parent.children[index];\n\n // Pin to the current rendered size so the shrink reflows siblings.\n const lw = child.measuredWidth;\n const lh = child.measuredHeight;\n child.set({ width: lw, height: lh } as Partial<Node2DProps>);\n\n // Mirror of the insert: fade out first (box held at full size), then collapse the box and close the gap (`gapScale` 1 -> 0).\n const fade = duration * (1 - SIZE_PHASE);\n const shrink = duration - fade;\n animation = commandSequence<Node2DProps>(\n child,\n child.to({ data: { opacity: 0 } as Partial<Node2DProps>, duration: fade, easing }),\n commandParallel<Node2DProps>(\n child,\n child.to({ data: { width: 0, height: 0 } as Partial<Node2DProps>, duration: shrink, easing }),\n child.to({ data: { gapScale: 0 } as Partial<Node2DProps>, duration: shrink, easing }),\n ),\n );\n };\n\n return driveCommand(duration, (t) => {\n if (!setupDone) setup();\n if (!animation || !child) return;\n const done = t >= 1;\n if (!done && child.parent !== parent) {\n // Seeking back into the animation after it reached the end: put the child back.\n parent.addChildAt({ data: { child, index: Math.min(index, parent.children.length) } });\n }\n animation.at(t);\n if (done) {\n parent.remove(child);\n // The same node can be re-added later (scenes reuse refs) and a plain addChild wouldn't reset `gapScale`; restore the default so a stale 0 can't swallow a gap.\n child.set({ gapScale: 1 } as Partial<Node2DProps>);\n }\n });\n}\n\n/** Animated `reparent`: fades and sizes the node out of its parent, then reparents and fades it in. The handoff is at the midpoint (`t === 0.5`); seeking across it either way moves the node between parents, as {@link removeChildAtAnimated}. */\nexport function reparentAnimated(\n node: Node2D,\n newParent: Node2D,\n duration: number,\n easing?: EasingFunction,\n): Command<Record<string, never>> {\n const half = duration / 2;\n let animation: Command<Node2DProps> | null = null;\n let oldParent: Node2D | null = null;\n\n const setup = (): Command<Node2DProps> => {\n const targetOpacity = node.opacity;\n oldParent = node.parent;\n\n // Pin to the current rendered size so the exit shrink reflows the old parent.\n const lw = node.measuredWidth;\n const lh = node.measuredHeight;\n node.set({ width: lw, height: lh } as Partial<Node2DProps>);\n\n // One flat sequence (exit over the first half, enter over the second): `commandSequence` re-settles every prior phase\n // on each call, so the enter tweens' `from` is right even when a host seeks straight into the enter half.\n const exitFade = half * (1 - SIZE_PHASE);\n const exitShrink = half - exitFade;\n const enterGrow = half * SIZE_PHASE;\n const enterFade = half - enterGrow;\n return commandSequence<Node2DProps>(\n node,\n node.to({ data: { opacity: 0 } as Partial<Node2DProps>, duration: exitFade, easing }),\n commandParallel<Node2DProps>(\n node,\n node.to({ data: { width: 0, height: 0 } as Partial<Node2DProps>, duration: exitShrink, easing }),\n node.to({ data: { gapScale: 0 } as Partial<Node2DProps>, duration: exitShrink, easing }),\n ),\n commandParallel<Node2DProps>(\n node,\n node.to({ data: { width: lw, height: lh } as Partial<Node2DProps>, duration: enterGrow, easing }),\n node.to({ data: { gapScale: 1 } as Partial<Node2DProps>, duration: enterGrow, easing }),\n ),\n node.to({ data: { opacity: targetOpacity } as Partial<Node2DProps>, duration: enterFade, easing }),\n );\n };\n\n return driveCommand(duration, (t) => {\n if (!animation) animation = setup();\n const elapsed = t * duration;\n const inNewParent = elapsed >= half;\n if (inNewParent && node.parent !== newParent) {\n if (oldParent) oldParent.remove(node);\n newParent.add(node);\n } else if (!inNewParent && node.parent !== oldParent) {\n newParent.remove(node);\n if (oldParent) oldParent.add(node);\n }\n animation.at(t);\n });\n}\n", "import { Alignment } from \"@/attributes/layout/alignment\";\n\n/** The out-of-plane transform as one bag, shorthand for the individual `rotationX` / `rotationY` / `depth` / `perspective` / `backfaceVisible` / `flipHorizontal` / `flipVertical` / `transformOrigin` props on {@link Node2D}. Only sugar: {@link expandTransform3D} writes each field onto the prop it names before anything reads either, so a tween of `transform3D.rotationY` and of `rotationY` are the same tween. Named `NodeTransform3D` because `Transform3D` in `render3d` places a mesh in a real 3D scene; this tilts a flat node as a browser tilts a `<div>`. */\nexport interface NodeTransform3D {\n /** Tilt about the horizontal axis, degrees. Positive tips the top away. */\n rotationX?: number;\n /** Tilt about the vertical axis, degrees. Positive swings the right edge away. */\n rotationY?: number;\n /** In-plane rotation belonging to the 3D block, degrees. Separate from the node's own `rotation`. */\n rotationZ?: number;\n /** Push along the view axis in px (CSS `translateZ`). Inert without `perspective`. */\n depth?: number;\n /** Viewer distance in px. `0` (default) is a parallel projection — no perspective. */\n perspective?: number;\n /** Whether the node still paints once it has turned past edge-on. Default `true`. */\n backfaceVisible?: boolean;\n /** Mirror across the vertical centre line (CSS `scaleX(-1)`). */\n flipHorizontal?: boolean;\n /** Mirror across the horizontal centre line (CSS `scaleY(-1)`). */\n flipVertical?: boolean;\n /** The point the whole transform turns about — CSS `transform-origin`. Defaults to the node's `pivot`. */\n origin?: Alignment;\n}\n\n/** The prop each {@link NodeTransform3D} field expands to. `origin` is the one rename. */\nconst TRANSFORM_3D_KEYS: ReadonlyArray<[keyof NodeTransform3D, string]> = [\n [\"rotationX\", \"rotationX\"],\n [\"rotationY\", \"rotationY\"],\n [\"rotationZ\", \"rotationZ\"],\n [\"depth\", \"depth\"],\n [\"perspective\", \"perspective\"],\n [\"backfaceVisible\", \"backfaceVisible\"],\n [\"flipHorizontal\", \"flipHorizontal\"],\n [\"flipVertical\", \"flipVertical\"],\n [\"origin\", \"transformOrigin\"],\n];\n\n/** Expands the `transform3D` shorthand onto the individual props in place. An explicitly named prop in the same object wins over the bag's field (as `size` vs `width`); a whole-bag callback is left alone, having no per-field value to distribute. */\n/** @internal */\nexport function expandTransform3D(props: Record<string, unknown>): void {\n const bag = props.transform3D;\n if (bag === undefined || bag === null || typeof bag !== \"object\") return;\n const source = bag as Record<string, unknown>;\n for (const [field, prop] of TRANSFORM_3D_KEYS) {\n const value = source[field];\n if (value !== undefined && props[prop] === undefined) props[prop] = value;\n }\n}\n", "import { Vector2 } from \"@/attributes/layout/vector2\";\nimport {\n Matrix2D,\n NO_PROJECTION_3D,\n applyToPoint,\n nodeProjectedMatrix,\n type Projection3D,\n} from \"@/attributes/layout/matrix2d\";\n\n/** Companion for {@link Node2D}'s transform/anchor/world-space math: pure geometry, reusing `attributes/layout/matrix2d.ts`. Reactive prop reads and the parent-chain walk stay in Node2D's getters. */\n\n/** Rotates a centred offset `(ox, oy)` (y-up) by `rotationDeg` (clockwise) and translates by the node's `(x, y)` into a parent-relative anchor point; fast path when un-rotated. Drives the local anchor getters. */\n/** @internal */\nexport function rotateOffset(x: number, y: number, rotationDeg: number, ox: number, oy: number): Vector2 {\n if (rotationDeg === 0) return { x: x + ox, y: y + oy };\n const rad = (rotationDeg * Math.PI) / 180;\n const cos = Math.cos(rad);\n const sin = Math.sin(rad);\n // Canvas rotation is clockwise; in y-up space that means\n // x' = cos*ox + sin*oy, y' = -sin*ox + cos*oy.\n return {\n x: x + cos * ox + sin * oy,\n y: y - sin * ox + cos * oy,\n };\n}\n\n/** This node's local transform in canvas (y-down) space, matching the renderer's `applyTransform`. `cx`/`cy` are the positioned centre (`layoutBounds + x`, `layoutBounds - y`); `pivot` is the resolved normalised pivot. `projection` carries the out-of-plane half (mirrors, tilt, depth, perspective) and defaults to none (a plain affine matrix). Both consumers go through here (`Node2D._localMatrix`, hence `worldMatrix`/`global`/picking, and `Node2D.applyTransform`, hence the renderer), so there is one definition of the arithmetic; they differ in one argument: only the renderer passes the projection, as mirrors and tilt are paint, not shape. */\n/** @internal */\nexport function localMatrix(\n cx: number,\n cy: number,\n rotation: number,\n scale: number,\n pivot: Vector2,\n width: number,\n height: number,\n projection: Projection3D = NO_PROJECTION_3D,\n): Matrix2D {\n const pivotX = pivot.x * (width / 2);\n const pivotY = -pivot.y * (height / 2);\n return nodeProjectedMatrix(cx, cy, rotation, scale, pivotX, pivotY, projection);\n}\n\n/** The nine world-space anchor points produced by mapping centered y-up offsets through `m`. */\n/** @internal */\nexport interface WorldAnchors {\n center: Vector2;\n topLeft: Vector2;\n topRight: Vector2;\n bottomLeft: Vector2;\n bottomRight: Vector2;\n topCenter: Vector2;\n bottomCenter: Vector2;\n centerLeft: Vector2;\n centerRight: Vector2;\n}\n\n/** Maps this node's centred y-up offsets through the world matrix `m` into the nine world-space anchors (y-up). The matrix is canvas y-down, so y is flipped in and back out; `halfW`/`halfH` are half the layout size. */\n/** @internal */\nexport function worldAnchors(m: Matrix2D, halfW: number, halfH: number): WorldAnchors {\n const at = (ox: number, oy: number): Vector2 => {\n const p = applyToPoint(m, { x: ox, y: -oy });\n return { x: p.x, y: -p.y };\n };\n return {\n center: at(0, 0),\n topLeft: at(-halfW, halfH),\n topRight: at(halfW, halfH),\n bottomLeft: at(-halfW, -halfH),\n bottomRight: at(halfW, -halfH),\n topCenter: at(0, halfH),\n bottomCenter: at(0, -halfH),\n centerLeft: at(-halfW, 0),\n centerRight: at(halfW, 0),\n };\n}\n", "import { identity, invert, multiply, type Matrix2D } from \"@/attributes/layout/matrix2d\";\nimport {\n cameraSide,\n multiplyAffine3,\n nearCoverage,\n nearCutPolygon,\n spacePaintOrder,\n spacePlane,\n spaceScreenMatrix,\n spaceViewMatrix,\n type Affine3,\n type SpaceCamera,\n type SpacePlane,\n} from \"@/attributes/layout/space3d\";\nimport { Clip } from \"@/render/clip\";\nimport { PathBuilder } from \"@/render/descriptors/path-builder\";\nimport type { Node2D } from \"./node2d\";\n\n/** Companion for {@link Node2D}'s 2.5D space: where a node sits in one for a frame and the order siblings paint in. The renderer and picking both build frames here, so a box around a node can't disagree with where it was painted. */\n\n/** Where one node sits in a space for one frame. */\n/** @internal */\nexport interface SpaceFrame {\n /** The node the space is seen from — whose camera it is. */\n readonly root: Node2D;\n readonly camera: SpaceCamera;\n /** This node's local frame → view space. */\n readonly view: Affine3;\n /** This node's local frame → the root's canvas: the whole projection. */\n readonly screen: Matrix2D;\n /** What this node's scope leaves on the canvas, relative to the root's: `screen`, or its parent's when it pushes nothing. */\n readonly pushed: Matrix2D;\n /** What the node concats in `applyTransform`: the parent's `pushed` undone, then `screen`. */\n readonly local: Matrix2D;\n /** No tilt and no depth: the node lies in its parent's plane. */\n readonly flat: boolean;\n readonly plane: SpacePlane;\n /** False when the node is edge-on or wholly behind the camera: nothing of its own to draw and no usable matrix to push, though its children (placed by their own frames) are still drawn. */\n readonly paints: boolean;\n readonly facesAway: boolean;\n /** Confines the node's own paint to what is in front of the lens, while the lens is passing through it. */\n readonly nearCut: Clip | null;\n}\n\nconst IDENTITY: Matrix2D = identity();\n\n/** The frame a space root hands its children: the camera over the root's own plane. */\n/** @internal */\nexport function spaceRootFrame(root: Node2D, camera: SpaceCamera): SpaceFrame {\n const view = spaceViewMatrix(camera);\n return {\n root,\n camera,\n view,\n screen: spaceScreenMatrix(camera, view),\n pushed: IDENTITY,\n local: IDENTITY,\n flat: true,\n plane: spacePlane(view, { x: 0, y: 0, width: 0, height: 0 }),\n paints: false,\n facesAway: false,\n nearCut: null,\n };\n}\n\n/** `child`'s frame, placed in `parent`'s. */\n/** @internal */\nexport function spaceChildFrame(parent: SpaceFrame, child: Node2D): SpaceFrame {\n const own = child._spaceMatrix();\n const view = multiplyAffine3(parent.view, own);\n const camera = parent.camera;\n const screen = spaceScreenMatrix(camera, view);\n const box = inkBox(child);\n const plane = spacePlane(view, box);\n const { side, edgeOn } = cameraSide(camera, plane);\n const coverage = nearCoverage(camera, plane);\n\n let local = IDENTITY;\n let paints = !edgeOn && coverage !== \"none\";\n if (paints) {\n if (parent.pushed === IDENTITY) {\n local = screen;\n } else {\n const undo = invert(parent.pushed);\n if (undo) local = multiply(undo, screen);\n else paints = false;\n }\n }\n\n return {\n root: parent.root,\n camera,\n view,\n screen,\n pushed: paints ? screen : parent.pushed,\n local,\n flat: own[2] === 0 && own[6] === 0 && own[8] === 0 && own[9] === 0 && own[11] === 0,\n plane,\n paints,\n facesAway: !edgeOn && side < 0,\n nearCut: paints && coverage === \"some\" ? nearCutClip(screen, box) : null,\n };\n}\n\n/** The frame `node` is placed by, or `null` when in no space: the walk picking takes (the renderer threads frames down). In a space when an ancestor opens one and every node between hands its children on via {@link Node2D._rendersChildrenInSpace}; a mask or nested camera flattens its subtree into its own plane. */\n/** @internal */\nexport function spaceFrameOf(node: Node2D): SpaceFrame | null {\n const chain: Node2D[] = [];\n for (let n: Node2D | null = node.parent; n; n = n.parent) {\n const camera = n._spaceCamera();\n if (camera) {\n let frame = spaceRootFrame(n, camera);\n for (let i = chain.length - 1; i >= 0; i--) frame = spaceChildFrame(frame, chain[i]);\n return spaceChildFrame(frame, node);\n }\n if (!n._rendersChildrenInSpace()) return null;\n chain.push(n);\n }\n return null;\n}\n\n/** The frame `parent` passes its children, whether it is a space root or a node inside one. */\n/** @internal */\nexport function spaceFrameForChildren(parent: Node2D): SpaceFrame | null {\n const camera = parent._spaceCamera();\n if (camera) return spaceRootFrame(parent, camera);\n if (!parent._rendersChildrenInSpace()) return null;\n return spaceFrameOf(parent);\n}\n\n/** The order `children` paint in, far to near, as indices; siblings all in their parent's plane need no test and keep authored order. */\n/** @internal */\nexport function spaceChildOrder(frames: readonly SpaceFrame[]): number[] {\n if (frames.length < 2 || frames.every((f) => f.flat)) return frames.map((_, i) => i);\n return spacePaintOrder(frames[0].camera, frames.map((f) => f.plane));\n}\n\n/** The node's ink in its own frame, centred and y-down — the frame its matrices map from. */\nfunction inkBox(node: Node2D): { x: number; y: number; width: number; height: number } {\n const b = node._localBounds();\n return { x: b.x, y: -b.y, width: b.width, height: b.height };\n}\n\n/** Grown past the ink by this, plus half the box: a shadow, stroke or glow must not be cut along the edge while the lens passes through. */\nconst NEAR_CUT_MARGIN = 128;\n\nfunction nearCutClip(screen: Matrix2D, box: { x: number; y: number; width: number; height: number }): Clip | null {\n const polygon = nearCutPolygon(screen, box, Math.max(box.width, box.height) / 2 + NEAR_CUT_MARGIN);\n if (!polygon) return null;\n // Path commands are authored y-up; the polygon is in the node's y-down frame.\n const path = new PathBuilder().moveTo(polygon[0].x, -polygon[0].y);\n for (let i = 1; i < polygon.length; i++) path.lineTo(polygon[i].x, -polygon[i].y);\n // A symmetric frame keeps the path where it was drawn rather than centring it on its own box.\n const reach = Math.max(...polygon.map((p) => Math.max(Math.abs(p.x), Math.abs(p.y))));\n return new Clip().path(path.close().toPathState({ centerBounds: [-reach, -reach, reach, reach] }));\n}\n", "import { RenderContext2D, SpaceRects } from \"@/render/render-context2d\";\nimport { Clip } from \"@/render/clip\";\nimport { BoxBounds } from \"@/layout/bounds\";\nimport { NodeEffect } from \"@/attributes/shape/effects/union\";\nimport { backdropEffects, foregroundShaderEffects } from \"@/attributes/shape/effects/backdrop\";\n\n/**\n * The **pure, leaf** pieces of {@link Node2D}'s render pipeline: they take\n * resolved inputs and the `ctx`, never call back into the node, so the\n * orchestration on the class reads without the scope bookkeeping.\n */\n\n/** Reference rect for fills with `space:'parent'`, in this node's local space (origin at its positioned centre, y-down); the viewport (`space:'global'`) is the renderer's. This node's rotation/scale aren't folded in: the rect is the axis-aligned parent box, as gradients expect. `{}` for a root (no parent). */\n/** @internal */\nexport function computeSpaceRects(\n parentRect: BoxBounds | undefined,\n thisRect: BoxBounds,\n x: number,\n y: number,\n): SpaceRects {\n if (!parentRect) return {};\n const ox = thisRect.x + x;\n const oy = thisRect.y - y;\n return {\n parent: {\n left: -parentRect.width / 2 - ox,\n top: -parentRect.height / 2 - oy,\n right: parentRect.width / 2 - ox,\n bottom: parentRect.height / 2 - oy,\n },\n };\n}\n\n/** Backdrop effects (blur, grayscale, ..., magnify, backdrop shader) beneath the node, clipped to its silhouette and drawn before its own content, so what's underneath is filtered while its edges stay sharp. No-op without backdrop effects or a silhouette `clip`. */\n/** @internal */\nexport function applyBackdropEffects(\n ctx: RenderContext2D,\n effects: NodeEffect[],\n clip: Clip | null,\n width: number,\n height: number,\n): void {\n const backdrop = backdropEffects(effects);\n if (backdrop.length === 0) return;\n if (!clip || clip.isEmpty()) return;\n\n // Clip to the silhouette first so the backdrop passes are confined to the node.\n ctx.beginClip(clip);\n ctx.beginEffects(backdrop, \"backdrop\", width, height);\n ctx.endEffects();\n ctx.endClip();\n}\n\n/** Runs `body` inside the node's `foreground` effect scope (posterize wrapping bulge) so those shader effects warp/band everything it paints: the inner half of `renderContentWithEffects`, whose backdrop pass runs first. Skipped when there are none, keeping begin/end matched. */\n/** @internal */\nexport function applyContentEffectScope(\n ctx: RenderContext2D,\n effects: NodeEffect[],\n width: number,\n height: number,\n body: () => void,\n): void {\n const foreground = foregroundShaderEffects(effects);\n const hasForeground = foreground.length > 0;\n if (hasForeground) ctx.beginEffects(foreground, \"foreground\", width, height);\n body();\n if (hasForeground) ctx.endEffects();\n}\n", "import { _observer, PropSlot } from \"@/props/slot\";\nimport { LAYOUT_SLOT } from \"@/props/observer\";\nimport { EasingFunction } from \"@/tween/ease/type\";\nimport { type Command, type CommandArgs } from \"@/tween/command\";\nimport { TweenStepper } from \"@/tween/stepper\";\nimport type { AssetScope } from \"@/assets/scope\";\nimport { AssetNotLoadedError } from \"@/assets/errors\";\nimport { declareMembers, property } from \"@/attributes/properties/decorator\";\nimport { effectsProperty, insetsProperty, alignmentProperty } from \"@/attributes/properties/typed\";\nimport { createMotionHistory, MotionHistory, sampleMotion, primeMotion } from \"./node-motion\";\nimport { addChildAtAnimated, removeChildAtAnimated, reparentAnimated } from \"./node-lifecycle\";\n\nimport type { NodeEffect } from \"@/attributes/shape/effects/union\";\nimport type { NodeBlendMode } from \"@/attributes/shape/fill/blend\";\nimport { BoxBounds } from \"@/layout/bounds\";\nimport { Vector2 } from \"@/attributes/layout/vector2\";\nimport { Alignment, alignmentOps } from \"@/attributes/layout/alignment\";\nimport type { WorldTransform } from \"@/attributes/layout/world-transform\";\nimport { Node, type NodeConfig, type NodeDimension, type NodeProps } from \"@/components/trees/node/node\";\nimport {\n applyToPoint,\n facesAway,\n hasProjection3D,\n invert,\n Matrix2D,\n multiply,\n type Projection3D,\n} from \"@/attributes/layout/matrix2d\";\nimport { expandTransform3D, type NodeTransform3D } from \"@/attributes/layout/transform3d\";\nimport { multiplyAffine3, nodeSpaceMatrix, type Affine3, type SpaceCamera } from \"@/attributes/layout/space3d\";\nimport { localMatrix, rotateOffset, worldAnchors } from \"./node-transform\";\nimport { spaceChildFrame, spaceChildOrder, spaceRootFrame, type SpaceFrame } from \"./node-space\";\nimport {\n applyBackdropEffects as applyBackdropEffectsImpl,\n applyContentEffectScope,\n computeSpaceRects,\n} from \"./node-render\";\nimport { SizeConstraints } from \"@/layout/constraints\";\nimport { NodeRenderState, RenderContext2D, RenderPass2D, SpaceRects } from \"@/render/render-context2d\";\nimport { Clip } from \"@/render/clip\";\nimport { TransformState } from \"@/render/descriptors/transform\";\nimport { command } from \"@/tween/command-decorator\";\nimport { PathBuilder } from \"@/render/descriptors/path-builder\";\nimport type { PathData } from \"@/render/descriptors/path\";\nimport { pathOps } from \"@/attributes/shape/path/ops\";\nimport { Size2D, SizeInput, size2DOps, sizeInputOps } from \"@/attributes/layout/size\";\nimport { Effect } from \"@/attributes/shape/effects/chain\";\nimport { Insets, InsetsResolved, insetsOps } from \"@/attributes/layout/insets\";\nimport { lerpPerspective } from \"@/tween/lerp\";\nimport { MeasureContext2D } from \"@/render/measure-context\";\nimport { flowOps } from \"@/layout/ops\";\nimport type { FlowMeasure, FlowSettings } from \"@/layout/types\";\n\n/** Shared empty stand-in when the context never reads reference rects; the shape `computeSpaceRects` returns for a parentless node. */\nconst NO_SPACE_RECTS: SpaceRects = {};\n\n/** The node centre in the normalised `[-1, 1]` alignment space — `pivot`'s own default. */\nconst ORIGIN_2D: Vector2 = { x: 0, y: 0 };\n\n/**\n * A slot's turn, size, tilt, depth and fade in a parent's arrangement (a ring of cards, tiles on a\n * sphere). Applied about the box centre and before the child's own transform, so the child's\n * `x`/`y`/`rotation`/`scale` and their commands stay relative to the slot. Answered by the parent\n * ({@link Node2D._placementOf}) rather than stored on the child, so a reparented child can't carry a stale slot.\n */\nexport interface ChildPlacement {\n /** In-plane turn, degrees clockwise. */\n readonly rotation: number;\n readonly scale: number;\n /** Tilt, degrees — as the child's own `rotationX`/`rotationY`. */\n readonly rotationX: number;\n readonly rotationY: number;\n /** Push toward the viewer, px. Only a space gives it perspective. */\n readonly depth: number;\n /** Multiplies the child's own opacity. */\n readonly opacity: number;\n}\n\n/**\n * A parent's own coordinates for where its children sit (graph units, say). Position only: a child\n * keeps its size, turn and scale. Answered by the parent ({@link Node2D._planeOf}), like a slot.\n */\nexport interface ChildPlane {\n /** A child's `x`/`y` as a pixel offset, y-up, from the centre of its layout box. */\n toOffset(x: number, y: number): Vector2;\n toCoords(x: number, y: number): Vector2;\n}\n\n/**\n * A point an editor can drag to set one of the node's `Vector2` props. `at` is in the node's own\n * frame, y-up from its origin, the frame {@link Node2D._localBounds} is in.\n */\nexport interface NodeHandle {\n readonly prop: string;\n readonly at: Vector2;\n}\n\nconst NO_HANDLES: readonly NodeHandle[] = [];\n\n// Filled per call and read synchronously by the matrix builders, like `_projectionScratch`.\nconst SLOT_PROJECTION: Projection3D = {\n rotationX: 0, rotationY: 0, rotationZ: 0, depth: 0, perspective: 0,\n flipHorizontal: false, flipVertical: false,\n};\n\nfunction slotProjection(placement: ChildPlacement): Projection3D {\n SLOT_PROJECTION.rotationX = placement.rotationX;\n SLOT_PROJECTION.rotationY = placement.rotationY;\n SLOT_PROJECTION.depth = placement.depth;\n return SLOT_PROJECTION;\n}\n\n/** No settings: centred freeform, which is how a plain node arranges its children. */\nconst DEFAULT_FLOW: FlowSettings = Object.freeze({});\n\n/** Where a node last placed its children, and by what flow: see {@link Node2D._childSpace}. */\nexport interface ChildSpace {\n readonly settings: FlowSettings;\n readonly inner: BoxBounds;\n}\n\nconst NO_CONTENT: Size2D = { width: 0, height: 0 };\n\nexport { Node } from \"@/components/trees/node/node\";\nexport type { NodeChildren, NodeConfig, NodeMetadata, NodeDimension, NodeProps } from \"@/components/trees/node/node\";\nexport type { WorldTransform } from \"@/attributes/layout/world-transform\";\nexport type { PropInput, PropInputs } from \"@/attributes/properties/inputs\";\n\n/** @internal */\nexport interface CameraScope {\n /** World point (y-up) the viewport centres on — what the camera is aimed at. */\n lookAt: Vector2;\n zoom: number;\n /** Viewport rotation in degrees; the renderer applies it as `rotate(-heading)`. */\n heading: number;\n}\n\nexport interface Node2DProps extends NodeProps {\n x: number; // 0 is center, negative is left, positive is right\n y: number; // 0 is center, negative is down, positive is up\n width: SizeInput;\n height: SizeInput;\n /** Weight `[0, 1]` for the gap this child contributes to its parent's flex run; collapse a child without the gap popping. */\n gapScale: number;\n /** Sugar for `width` and `height`; an explicit `width` or `height` wins (`{ size: 200, width: 100 }` is 100 by 200). */\n size: SizeInput;\n scale: number;\n rotation: number;\n opacity: number;\n /** Layer blend mode. `'pass-through'` (default) does not isolate the node — its opacity scales each child/fill while they blend against the backdrop. Any other mode isolates the node and blends its flattened result against the backdrop. */\n blend: NodeBlendMode;\n effects: Effect;\n padding: Insets;\n /** When true, content drawn outside this node's outline is clipped away (see {@link Node2D.clipSelf}). */\n clip: boolean;\n /**\n * Pivot for rotation and scale: a named alignment (`'center'`, `'topRight'`, ...) or a normalised\n * {@link Vector2} (`(0,0)` centre, `(-1,1)` top-left). Set automatically when an alignment positioning prop is used.\n */\n pivot: Alignment;\n\n // Mirrors and the third dimension: the CSS transform functions that still apply to a flat plane.\n // `rotation` supplies the Z axis (see `transform3D`); every one turns about `pivot`, or `transformOrigin` where set.\n\n /** Mirror across the vertical centre line (CSS `scaleX(-1)`); the box and layout don't move. */\n flipHorizontal: boolean;\n /** Mirror across the horizontal centre line — CSS's `scaleY(-1)`. See {@link flipHorizontal}. */\n flipVertical: boolean;\n /** Tilt about the horizontal axis, in **degrees**. Positive tips the top edge away from the viewer. */\n rotationX: number;\n /** Tilt about the vertical axis, in **degrees**. Positive swings the right edge away from the viewer. */\n rotationY: number;\n /**\n * In-plane rotation of the 3D transform, degrees clockwise. Independent of {@link rotation}, which\n * turns the node's shape (box and selection outline); this is paint-only and spins the picture inside a\n * box that stays put. They add.\n */\n rotationZ: number;\n /** Push along the view axis, px (CSS `translateZ`); positive is toward the viewer. Inert without {@link perspective}. */\n depth: number;\n /**\n * Distance from the viewer to the node's plane, px. `0` (default) is a parallel projection: a tilt\n * squashes evenly instead of receding. Smaller is more dramatic (~800-1500 reads like a page on a desk).\n * Per node, not inherited as in CSS: a scene graph has no viewport element, and a node carrying its own\n * can be nested and animated without its depth depending on where it was dropped.\n */\n perspective: number;\n /** Whether the node paints once turned past edge-on (CSS `backface-visibility`, default visible); `false` gives the card flip. Decided by tilt alone (see `facesAway`), so {@link flipHorizontal} doesn't hide it. */\n backfaceVisible: boolean;\n /** Origin every rotation, scale and mirror turns about (CSS `transform-origin`), same vocabulary as {@link pivot}. Unset it is the pivot; set it wins for the whole transform, so there is one origin as in CSS. */\n transformOrigin: Alignment;\n /** The 3D props in one bag: construction sugar expanded into the individual props before anything reads them, like {@link size}. Its `rotationZ` is not {@link rotation}. */\n transform3D: NodeTransform3D;\n\n // Alignment positioning: any one of these, instead of or beside x/y, offsets the node so the alignment\n // lands at the scene-space point. Callbacks re-evaluate when the value or this node's layout changes.\n center: Vector2 | (() => Vector2);\n topLeft: Vector2 | (() => Vector2);\n topRight: Vector2 | (() => Vector2);\n bottomLeft: Vector2 | (() => Vector2);\n bottomRight: Vector2 | (() => Vector2);\n topCenter: Vector2 | (() => Vector2);\n bottomCenter: Vector2 | (() => Vector2);\n centerLeft: Vector2 | (() => Vector2);\n centerRight: Vector2 | (() => Vector2);\n\n /** Share of free main-axis space relative to sibling `fill` children (Flutter's `Expanded(flex:)`), default 1. Setting it without `width`/`height` defaults both to `'fill'`. */\n flex: number;\n\n // Grid placement, read only by a parent whose `flow` is 'grid'.\n /** 1-based column index for explicit grid placement. Undefined = auto-placed. */\n column: number;\n /** 1-based row index for explicit grid placement. Undefined = auto-placed. */\n row: number;\n /** How many grid columns this child spans. Default 1. */\n colSpan: number;\n /** How many grid rows this child spans. Default 1. */\n rowSpan: number;\n}\n\n/**\n * The 2D tree's base: what every `component2d` lowers onto, and the scene root ({@link Canvas2D}).\n * Props are {@link PropSlot}-backed (a value or a thunk); `to()` returns a {@link Command}; `measure()`\n * runs top-down, then `layout()` places the node and its children.\n */\nexport class Node2D<P extends Node2DProps = Node2DProps> extends Node<P> {\n get dimension(): NodeDimension { return \"2d\"; }\n\n /** Null only for a detached node or the root; the base tree holds both dimensions, so this is typed rather than cast. */\n protected get parent2D(): Node2D | null {\n const parent = this._parent;\n return parent instanceof Node2D ? parent : null;\n }\n\n /** Narrowed to the 2D tree: only a `Node2D` can adopt a `Node2D` (see {@link Node.acceptsChild}). */\n override get parent(): Node2D | null {\n if (_observer !== null) _observer.read(this._structureSlot());\n return this.parent2D;\n }\n\n /** Children in the 2D tree. `Canvas3D` also holds `Node3D` children outside it (reached through its own accessor); otherwise the live array is returned uncopied. */\n override get children(): Node2D[] {\n if (_observer !== null) _observer.read(this._structureSlot());\n const all = this._children;\n for (let i = 0; i < all.length; i++) {\n if (!(all[i] instanceof Node2D)) {\n return all.filter((c): c is Node2D => c instanceof Node2D);\n }\n }\n return all as Node2D[];\n }\n\n constructor(props?: NodeConfig<any, P>) {\n super(props);\n\n // Expand the `size`/`transform3D` sugar in place, so the `_props` object `super()` kept carries the expanded values.\n if (props) {\n size2DOps.expand(props as Record<string, unknown>);\n expandTransform3D(props as Record<string, unknown>);\n }\n\n // Deferred from `super()`: the cells these props write into are this class's own fields, which only initialize after `super()` returns.\n this.initProps(props);\n\n // `flex` signals intent to fill the main axis, so an unset width/height defaults to 'fill' and skips the has-children default.\n if (props && (props as any).flex !== undefined) {\n if (props.width === undefined) this.applyProp(\"width\", \"fill\", { tween: sizeInputOps.lerp });\n if (props.height === undefined) this.applyProp(\"height\", \"fill\", { tween: sizeInputOps.lerp });\n } else {\n this.applyDefaultSize(props);\n }\n\n // Alignment positioning: validate, derive pivot, bind x/y reactively (the `to()` path uses the one-shot form).\n if (props) {\n alignmentOps.validateProps(props as Record<string, unknown>);\n const alignmentKey = alignmentOps.findKey(props as Record<string, unknown>);\n if (alignmentKey) {\n const raw = (props as any)[alignmentKey] as Vector2 | (() => Vector2);\n const getTarget: () => Vector2 = typeof raw === 'function' ? raw : () => raw;\n const { pivot, x, y } = alignmentOps.bindTarget(alignmentKey, getTarget, () => this._layoutBounds.get());\n this._writeProp('pivot', pivot);\n this._writeProp('x', x);\n this._writeProp('y', y);\n }\n }\n\n this.adoptChildrenProp(props);\n }\n\n override set(props: { [K in keyof P]?: P[K] | (() => P[K]) }): void {\n // `size` has no slot; write it to width/height (explicit width/height in the same call wins).\n const sizeVal = (props as any).size;\n // `transform3D` is expanded up front so the generic loop writes its fields; only the rare object case allocates.\n if ((props as any).transform3D !== undefined) {\n props = { ...props };\n expandTransform3D(props as Record<string, unknown>);\n }\n super.set(props);\n if (sizeVal !== undefined) {\n if ((props as any).width === undefined) this._writeProp('width', sizeVal);\n if ((props as any).height === undefined) this._writeProp('height', sizeVal);\n }\n }\n\n override _prepareStep(to: Partial<P>, duration: number, easing?: EasingFunction): TweenStepper {\n // Expand the sugar before anchor validation and per-key tween setup see it.\n size2DOps.expand(to as Record<string, unknown>);\n expandTransform3D(to as Record<string, unknown>);\n\n // `pivot` is a transient origin for this step's rotation and scale (the object-form option of\n // moveTo/rotateTo/scaleTo, or a bare `to()` key). Not a prop, so strip it before anything else sees it.\n const explicitPivot = (to as { pivot?: Alignment }).pivot;\n if (explicitPivot !== undefined) delete (to as { pivot?: Alignment }).pivot;\n\n alignmentOps.validateProps(to as Record<string, unknown>);\n\n // An alignment key in the target resolves to x/y targets plus a transform origin (one-shot alignmentOps math).\n const alignmentKey = alignmentOps.findKey(to as Record<string, unknown>);\n if (alignmentKey) {\n const raw = (to as any)[alignmentKey] as Vector2;\n const { pivot, x, y } = alignmentOps.resolveTargetOnce(alignmentKey, this._layoutBounds.get(), raw);\n // Written to `transformOrigin`, not `pivot`: `pivot` is the node's permanent origin, set at construction,\n // and a tween's alignment must not re-point later rotations. An explicit step `pivot` overrides the\n // alignment-derived value: where a position is stated against and where a rotation turns are separate questions.\n this._writeProp('transformOrigin', explicitPivot !== undefined ? alignmentOps.resolve(explicitPivot) : pivot);\n (to as any).x = x;\n (to as any).y = y;\n } else if (explicitPivot !== undefined) {\n this._writeProp('transformOrigin', alignmentOps.resolve(explicitPivot));\n }\n\n return super._prepareStep(to, duration, easing);\n }\n\n /** Effects are the only assets a bare node declares; component paint entries declare their own. */\n override declareAssets(assets: AssetScope): void {\n assets.effects(this.effects as NodeEffect[]);\n }\n\n override _sample(): void {\n this._sampleMotion();\n }\n\n override _primeMotion(at: number): void {\n const r = this.layoutBounds;\n const o = this._offset();\n primeMotion(\n this._motionHistory,\n (r?.x ?? 0) + o.x,\n (r?.y ?? 0) - o.y,\n this.rotation,\n this.scale,\n at,\n );\n }\n\n declare x: number;\n declare y: number;\n declare width: SizeInput;\n declare height: SizeInput;\n declare scale: number;\n declare rotation: number;\n declare opacity: number;\n declare blend: NodeBlendMode;\n declare effects: Effect;\n declare padding: Insets;\n\n declare readonly pivot: Alignment;\n\n // Mirrors and the third dimension (see Node2DProps). Angles and depth tween like x/y; booleans snap at the end of a\n // tween; `perspective` tweens in reciprocal space ({@link lerpPerspective}).\n\n declare flipHorizontal: boolean;\n declare flipVertical: boolean;\n declare rotationX: number;\n declare rotationY: number;\n /** The 3D block's in-plane rotation, degrees — distinct from {@link rotation}. See {@link Node2DProps.rotationZ}. */\n declare rotationZ: number;\n declare depth: number;\n /** Tweened in reciprocal space ({@link lerpPerspective}): the projection varies with `1/perspective`, so a linear lerp flashes a near-degenerate projection at the start of a `0 -> n` tween. */\n declare perspective: number;\n declare backfaceVisible: boolean;\n /**\n * `undefined` means \"follow the pivot\", which no default could say since every alignment is a real point.\n * Hence a plain `property`, not `alignmentProperty()` (which folds a missing default to `'center'`).\n */\n declare transformOrigin: Alignment | undefined;\n\n /** When true, content drawn by this node's children is clipped to its outline (see {@link clipSelf}). */\n declare clip: boolean;\n\n declare flex: number;\n /** Flex gap weight `[0, 1]`, default 1. The animated `addChildAt`/`removeChildAt` drive it so the gap opens and closes with the child's box (see {@link addChildAtAnimated}); settable so a host can collapse a child in place. */\n declare gapScale: number;\n declare column: number | undefined;\n declare row: number | undefined;\n declare colSpan: number;\n declare rowSpan: number;\n\n private readonly _layoutBounds = new PropSlot<BoxBounds>({ x: 0, y: 0, width: 0, height: 0 }, this, LAYOUT_SLOT);\n\n /**\n * Limits and measurer from the last {@link measure} pass, so off-tree work (the animated child-insert in\n * `node-lifecycle.ts`) can size a detached hug child without shifting siblings. Undefined until measured.\n *\n * @internal\n */\n lastMeasure?: { constraints: SizeConstraints; measurer: MeasureContext2D };\n\n /** The box the last layout pass allocated: size, and position in the parent's space (canvas y-down). Reactive. Written only via {@link setLayoutBounds}, where the layout invariants live. */\n get layoutBounds(): BoxBounds { return this._layoutBounds.get(); }\n\n /** {@link flattenChildrenProp} narrowed to children that take part in 2D layout (not 3D or audio). */\n protected static flowChildrenProp(props: { children?: unknown } | undefined): Node2D[] {\n return Node2D.flattenChildrenProp(props).filter((c): c is Node2D => c instanceof Node2D);\n }\n\n /** True if any child requests `\"fill\"` on `axis`, so a size default can avoid hugging a child that would have nothing to fill. */\n protected static hasFillChild(children: Node2D[], axis: \"width\" | \"height\"): boolean {\n return children.some((c) => (axis === \"width\" ? c.width : c.height) === \"fill\");\n }\n\n /** Hug when given children, fill when empty. Skipped when `flex` is set (implies `'fill'`); `component2d` replaces it with the component rule. */\n protected applyDefaultSize(props?: NodeConfig<any, P>): void {\n const hasChildren = Node2D.flowChildrenProp(props).length > 0;\n const defaultSize = hasChildren ? \"hug\" : \"fill\";\n if (!props || props.width === undefined) this.applyProp(\"width\", defaultSize, { tween: sizeInputOps.lerp });\n if (!props || props.height === undefined) this.applyProp(\"height\", defaultSize, { tween: sizeInputOps.lerp });\n }\n\n // Each helper returns its `Command` unwrapped: a `Command` can be evaluated at a time, anything that only advances can't.\n\n /**\n * Animate `x`/`y` to a position, along `path`, or onto another node. `pivot` sets\n * {@link Node2DProps.transformOrigin} (carried forward until restated), not the permanent {@link pivot}.\n *\n * `path` or `target` replaces the `x`/`y` destination (stating both is an error). A path is walked by arc\n * length and its coordinates are `x`/`y` values in the library-wide y-up space. `target` is a node id and\n * `targetAnchor` the point of its box (centre when absent), resolved when the command is built; an absent\n * target leaves the node in place. With both, the path is turned and scaled about its start until its end lands on the target.\n *\n * @example\n * node.moveTo({ data: { x: 200, y: 100, pivot: 'topRight' }, duration: 0.5 });\n * node.moveTo({ data: { path: new PathBuilder().arc({ width: 600, startAngle: 180, sweep: -180 }) }, duration: 2 });\n * node.moveTo({ data: { target: 'card', targetAnchor: 'topRight' }, duration: 1 });\n */\n moveTo(\n args: CommandArgs<{\n x?: number;\n y?: number;\n path?: PathData | PathBuilder;\n target?: string;\n targetAnchor?: Alignment;\n pivot?: Alignment;\n }> & { duration: number },\n ): Command<P> {\n const { path, target, targetAnchor, ...destination } = args.data ?? {};\n const positioned = destination.x !== undefined || destination.y !== undefined;\n const aimed = typeof target === \"string\" && target !== \"\";\n if (aimed && positioned) {\n throw new Error(\n \"moveTo takes a `target` or an `x`/`y` destination, not both — the target's anchor is where the move ends.\",\n );\n }\n const aim = aimed ? this._pointOnNode(target, targetAnchor) : null;\n if (path === undefined || path === null) {\n return this.to({ data: { ...destination, ...aim } as Partial<P>, duration: args.duration, easing: args.easing });\n }\n if (positioned) {\n throw new Error(\n \"moveTo takes a `path` or an `x`/`y` destination, not both — the path's own end is where the move ends.\",\n );\n }\n const sampler = pathOps.sampler(path instanceof PathBuilder ? path.toCommands() : path);\n const { length } = sampler;\n const first = sampler.frameAt(0);\n const last = sampler.frameAt(length);\n const fit = aim && first && last ? pathOps.endFit(first, last, aim) : null;\n const origin = destination.pivot;\n return this.command<P>((t) => {\n const frame = sampler.frameAt(length * t);\n // A degenerate path has no point to be at, so the move writes\n // nothing rather than collapsing the node onto the origin.\n if (!frame) return {} as Partial<P>;\n const point = fit ? fit(frame) : frame;\n const at = { x: point.x, y: point.y } as Partial<P>;\n if (origin !== undefined) (at as { transformOrigin?: Alignment }).transformOrigin = origin;\n return at;\n }, args.duration, args.easing);\n }\n\n fadeTo(args: CommandArgs<{ opacity: number }> & { duration: number }): Command<P> {\n return this.to({ data: args.data as Partial<P>, duration: args.duration, easing: args.easing });\n }\n\n /** Animate `rotation` (degrees, clockwise); `pivot` behaves as in {@link moveTo}. */\n rotateTo(args: CommandArgs<{ rotation: number; pivot?: Alignment }> & { duration: number }): Command<P> {\n return this.to({ data: args.data as Partial<P>, duration: args.duration, easing: args.easing });\n }\n\n /** Animate `scale`; `pivot` behaves as in {@link moveTo}. */\n scaleTo(args: CommandArgs<{ scale: number; pivot?: Alignment }> & { duration: number }): Command<P> {\n return this.to({ data: args.data as Partial<P>, duration: args.duration, easing: args.easing });\n }\n\n /** Animate `width`, `height` and `padding`, whichever are given. A size keyword (`'fill'`, `'hug'`) snaps; a number interpolates. */\n layoutTo(args: CommandArgs<{ width?: SizeInput; height?: SizeInput; padding?: Insets }> & { duration: number }): Command<P> {\n return this.to({ data: _stated(args.data) as Partial<P>, duration: args.duration, easing: args.easing });\n }\n\n /** Swell to `factor` times the size and settle back; ends as it began. */\n pulse(args: CommandArgs<{ factor?: number }> & { duration: number }): Command<P> {\n const rest = this.scale;\n const factor = args.data?.factor ?? 1.2;\n return this.command<P>(\n (t) => ({ scale: rest * (1 + (factor - 1) * Math.sin(Math.PI * t)) }) as Partial<P>,\n args.duration,\n args.easing,\n );\n }\n\n /** Rock about the node's own turn, `angle` degrees each way for `turns` swings, building up and dying away; ends as it began. */\n wiggle(args: CommandArgs<{ angle?: number; turns?: number }> & { duration: number }): Command<P> {\n const rest = this.rotation;\n const angle = args.data?.angle ?? 8;\n const turns = args.data?.turns ?? 3;\n return this.command<P>(\n (t) => ({ rotation: rest + angle * Math.sin(2 * Math.PI * turns * t) * Math.sin(Math.PI * t) }) as Partial<P>,\n args.duration,\n args.easing,\n );\n }\n\n effectTo(args: CommandArgs<{ effects: Effect }> & { duration: number }): Command<P> {\n return this.to({ data: _stated(args.data) as Partial<P>, duration: args.duration, easing: args.easing });\n }\n\n get measuredWidth(): number {\n return this.layoutBounds.width;\n }\n\n get measuredHeight(): number {\n return this.layoutBounds.height;\n }\n\n // Alignment points: getters read `layoutBounds` and x/y/rotation, and a bound prop recomputes on every read,\n // so a callback built from them stays current.\n\n /** Rotate offset (ox, oy) by this node's rotation (degrees clockwise) around the node center. */\n private _rotateOffset(ox: number, oy: number): Vector2 {\n const o = this._offset();\n return rotateOffset(o.x, o.y, this.rotation, ox, oy);\n }\n\n /** Center of the node — equivalent to its x/y position (0,0 is the center of the layout cell). */\n get center(): Vector2 {\n const o = this._offset();\n return { x: o.x, y: o.y };\n }\n\n get topLeft(): Vector2 {\n const r = this.layoutBounds;\n return this._rotateOffset(-r.width / 2, r.height / 2);\n }\n\n get topRight(): Vector2 {\n const r = this.layoutBounds;\n return this._rotateOffset(r.width / 2, r.height / 2);\n }\n\n get bottomLeft(): Vector2 {\n const r = this.layoutBounds;\n return this._rotateOffset(-r.width / 2, -r.height / 2);\n }\n\n get bottomRight(): Vector2 {\n const r = this.layoutBounds;\n return this._rotateOffset(r.width / 2, -r.height / 2);\n }\n\n get topCenter(): Vector2 {\n const r = this.layoutBounds;\n return this._rotateOffset(0, r.height / 2);\n }\n\n get bottomCenter(): Vector2 {\n const r = this.layoutBounds;\n return this._rotateOffset(0, -r.height / 2);\n }\n\n get centerLeft(): Vector2 {\n const r = this.layoutBounds;\n return this._rotateOffset(-r.width / 2, 0);\n }\n\n get centerRight(): Vector2 {\n const r = this.layoutBounds;\n return this._rotateOffset(r.width / 2, 0);\n }\n\n // Global (world-space) transform: unlike the parent-relative alignment getters above, these fold in the full\n // ancestor chain. Each read walks live props, so a binding over them stays current.\n\n /**\n * This node's local transform in canvas (y-down) space; {@link worldMatrix} composes it up the chain, and\n * every world-space reading comes from it ({@link global}, `runtime/node-picking.ts`, editor overlays).\n *\n * Deliberately flat: a node that mirrors or tilts is painted through a projected matrix (see\n * {@link applyTransform}) but measures and hit-tests as its upright rectangle, because handles, outlines and\n * alignment targets mean nothing on a trapezoid (a foreshortened \"width\" edge, a corner behind the viewer).\n */\n /** @internal Composed with the camera scopes in between by `runtime/node-picking.ts`. */\n _localMatrix(): Matrix2D {\n const r = this.layoutBounds;\n const slot = this._slotMatrix();\n const { x: ox, y: oy } = this._offset();\n if (slot) {\n return multiply(slot, localMatrix(\n ox, -oy, this.rotation, this.scale, this._transformOrigin(),\n r?.width ?? 0, r?.height ?? 0,\n ));\n }\n const cx = (r?.x ?? 0) + ox;\n const cy = (r?.y ?? 0) - oy;\n // No projection: geometry stays flat while paint does not (see above).\n return localMatrix(\n cx, cy, this.rotation, this.scale, this._transformOrigin(),\n r?.width ?? 0, r?.height ?? 0,\n );\n }\n\n /** @internal The slot {@link _placementOf} puts this node in, from its parent. */\n _placement(): ChildPlacement | null {\n return this.parent2D?._placementOf(this) ?? null;\n }\n\n /** The slot this node places `child` in beyond its layout box, or `null` when the box says it all. The renderer, picking and `global` follow it. See {@link ChildPlacement}. */\n /** @internal */\n _placementOf(_child: Node2D): ChildPlacement | null {\n return null;\n }\n\n /** The coordinates `child`'s `x`/`y` are in, or `null` for pixels. A `null` child asks for a not-yet-added one (where a host would drop or paste it). See {@link ChildPlane}. */\n /** @internal */\n _planeOf(_child: Node2D | null): ChildPlane | null {\n return null;\n }\n\n /**\n * Where its own layout would centre a not-yet-added child of `size`, y-down from its centre; `null` when it\n * arranges children in a run or grid (the run decides) or has laid none out.\n */\n /** @internal */\n _slotFor(size: Size2D): Vector2 | null {\n const space = this._childSpace;\n const box = space ? flowOps.freeSlot(space.settings, space.inner, size) : null;\n return space && box ? { x: space.inner.x + box.x, y: space.inner.y - box.y } : null;\n }\n\n /** Where its centre sits from the point `x`/`y` place, in the parent's frame (y-down), at `rotation` and `scale`: what turning about an off-centre pivot adds. */\n /** @internal */\n _centreShift(rotation = this.rotation, scale = this.scale): Vector2 {\n const r = this.layoutBounds;\n const own = localMatrix(0, 0, rotation, scale, this._transformOrigin(), r?.width ?? 0, r?.height ?? 0);\n return applyToPoint(own, { x: 0, y: 0 });\n }\n\n /** The points an editor may drag on this node, where they sit now; none by default. See {@link NodeHandle}. */\n /** @internal */\n _handles(): readonly NodeHandle[] {\n return NO_HANDLES;\n }\n\n /** The value `prop` takes for its handle to sit at `at`, in this node's own frame; `null` when it has none. */\n /** @internal */\n _handleValue(_prop: string, _at: Vector2): Vector2 | null {\n return null;\n }\n\n private readonly _offsetScratch: Vector2 = { x: 0, y: 0 };\n\n /** `x`/`y` as the pixel offset the parent sees; every position read goes through here so paint, picking and `global` agree under a {@link ChildPlane}. The result is reused: read it at once. */\n /** @internal */\n _offset(): Vector2 {\n const plane = this.parent2D?._planeOf(this);\n if (plane) return plane.toOffset(this.x, this.y);\n const o = this._offsetScratch;\n o.x = this.x;\n o.y = this.y;\n return o;\n }\n\n /**\n * The flat part of this node's slot: the layout box's centre turned and scaled by the slot, or `null` with\n * no slot. With `paint`, also the slot's tilt, which only paint sees.\n */\n /** @internal Also the plane `runtime/node-picking.ts` drags a placed node across. */\n _slotMatrix(paint = false): Matrix2D | null {\n const slot = this._placement();\n if (!slot) return null;\n const r = this.layoutBounds;\n return localMatrix(\n r?.x ?? 0, r?.y ?? 0, slot.rotation, slot.scale, ORIGIN_2D, 0, 0,\n paint ? slotProjection(slot) : undefined,\n );\n }\n\n /** @internal {@link _slotMatrix} in a space, where the slot's tilt and depth are geometry. */\n _slotAffine(): Affine3 | null {\n const slot = this._placement();\n if (!slot) return null;\n const r = this.layoutBounds;\n return nodeSpaceMatrix(r?.x ?? 0, r?.y ?? 0, slot.rotation, slot.scale, 0, 0, slotProjection(slot));\n }\n\n /** `transformOrigin` where set, else the alignment-derived `pivot`; read by {@link _localMatrix} and {@link applyTransform} alike. */\n private _transformOrigin(): Vector2 {\n return (this.transformOrigin as Vector2 | undefined) ?? (this.pivot as Vector2);\n }\n\n // Reused like `_transformScratch`: `_localMatrix` runs per ancestor per `global` read, and the Projection3D\n // consumers read it synchronously without retaining it.\n private readonly _projectionScratch: Projection3D = {\n rotationX: 0, rotationY: 0, rotationZ: 0, depth: 0, perspective: 0,\n flipHorizontal: false, flipVertical: false,\n };\n\n /** Out-of-plane fields for the matrix builders and the backface test. A space root overrides it: its 3D props aim the camera rather than turn the root. */\n protected _projection(): Projection3D {\n const p = this._projectionScratch;\n p.rotationX = this.rotationX;\n p.rotationY = this.rotationY;\n p.rotationZ = this.rotationZ;\n p.depth = this.depth;\n p.perspective = this.perspective;\n p.flipHorizontal = this.flipHorizontal;\n p.flipVertical = this.flipVertical;\n return p;\n }\n\n /** @internal This node's transform in its parent's 3D frame, when it is inside a space. See `node-space.ts`. */\n _spaceMatrix(): Affine3 {\n const r = this.layoutBounds;\n const width = r?.width ?? 0;\n const height = r?.height ?? 0;\n const origin = this._transformOrigin();\n const slot = this._slotAffine();\n const { x: ox, y: oy } = this._offset();\n if (slot) {\n return multiplyAffine3(slot, nodeSpaceMatrix(\n ox, -oy, this.rotation, this.scale,\n origin.x * (width / 2), -origin.y * (height / 2),\n this._projection(),\n ));\n }\n return nodeSpaceMatrix(\n (r?.x ?? 0) + ox, (r?.y ?? 0) - oy, this.rotation, this.scale,\n origin.x * (width / 2), -origin.y * (height / 2),\n this._projection(),\n );\n }\n\n /** Product of every ancestor's local matrix, root down; walks the live parent chain per call. */\n protected worldMatrix(): Matrix2D {\n const local = this._localMatrix();\n const parent = this.parent2D;\n return parent ? multiply(parent.worldMatrix(), local) : local;\n }\n\n /**\n * Absolute scene coordinates for the alignment points and metrics, folded through the ancestor chain; every\n * field is reactive. See {@link WorldTransform}.\n *\n * For reading only: `x`/`y` are parent-relative, so landing on `other` under a different parent needs\n * `x: () => other.global.x - myParent.global.x` (a shared parent origin needs no compensation).\n */\n get global(): WorldTransform {\n const r = this.layoutBounds;\n const anchors = worldAnchors(this.worldMatrix(), (r?.width ?? 0) / 2, (r?.height ?? 0) / 2);\n\n // Rotation sums; scale and opacity multiply, matching the renderer's nested transforms and pass-through alpha fold.\n let rotation = 0;\n let scale = 1;\n let opacity = 1;\n for (let n: Node2D | null = this; n; n = n.parent2D) {\n const slot = n._placement();\n rotation += n.rotation + (slot?.rotation ?? 0);\n scale *= n.scale * (slot?.scale ?? 1);\n opacity *= n.opacity * (slot?.opacity ?? 1);\n }\n\n return {\n x: anchors.center.x,\n y: anchors.center.y,\n ...anchors,\n rotation,\n scale,\n opacity,\n };\n }\n\n /** The `x`/`y` that put this node on `anchor` of node `id`, or `null` if no such 2D node is here right now. */\n private _pointOnNode(id: string, anchor: Alignment | undefined): Vector2 | null {\n const target = findNode2D(this, id);\n if (!target) return null;\n\n const a = alignmentOps.resolve(anchor ?? \"center\");\n const box = target.layoutBounds;\n const world = applyToPoint(target.worldMatrix(), {\n x: a.x * ((box?.width ?? 0) / 2),\n y: -a.y * ((box?.height ?? 0) / 2),\n });\n const parent = this.parent2D;\n const toParent = parent ? invert(parent.worldMatrix()) : null;\n if (parent && !toParent) return null;\n const local = toParent ? applyToPoint(toParent, world) : world;\n const own = this.layoutBounds;\n const x = local.x - (own?.x ?? 0);\n const y = (own?.y ?? 0) - local.y;\n return parent?._planeOf(this)?.toCoords(x, y) ?? { x, y };\n }\n\n // Typed to the shared base because a tree holds both dimensions; the guard rejects a Node3D before it lands where\n // it would never draw. Registered as a command on {@link Node}, which owns the instant insert.\n override addChildAt(args: CommandArgs<{ child: Node; index: number }> & { duration?: undefined }): void;\n override addChildAt(args: CommandArgs<{ child: Node; index: number }> & { duration: number }): Command<Record<string, never>>;\n override addChildAt(args: CommandArgs<{ child: Node; index: number }>): void | Command<Record<string, never>> {\n const { child, index } = args.data as { child: Node; index: number };\n this.assertAcceptsChild(child);\n if (args.duration === undefined) {\n this._insertChildAt(child, index);\n return;\n }\n // Past the guard this is a 2D child; the animated insert measures it off-tree, which only a laid-out node can do.\n return addChildAtAnimated(this, child as Node2D, index, args.duration, args.easing);\n }\n\n removeChildAt(args: CommandArgs<{ index: number }> & { duration?: undefined }): Node2D | null;\n removeChildAt(args: CommandArgs<{ index: number }> & { duration: number }): Command<Record<string, never>>;\n removeChildAt(args: CommandArgs<{ index: number }>): (Node2D | null) | Command<Record<string, never>> {\n const index = (args.data as { index: number }).index;\n if (args.duration === undefined) {\n if (index < 0 || index >= this._children.length) return null;\n if (_observer !== null) this._structureChanged(this._children[index]);\n const [removed] = this._children.splice(index, 1);\n if (removed) {\n (removed as Node2D)._parent = null;\n removed.detach();\n }\n return (removed as Node2D) ?? null;\n }\n return removeChildAtAnimated(this, index, args.duration, args.easing);\n }\n\n // Reused per frame so applyTransform doesn't allocate a descriptor per node per frame; ctx.transform reads it synchronously and never retains it.\n private readonly _transformScratch: TransformState = {\n x: 0, y: 0, width: 0, height: 0,\n scale: 1, rotation: 0, opacity: 1, blend: 'pass-through',\n effects: [], pivot: { x: 0, y: 0 },\n };\n\n // Motion (velocity/direction/speed/angular/scale) is sampled once per frame from ellapse() as a backward\n // difference, on every advanced frame (not just rendered ones) so velocity stays right through a scrub.\n // ellapse() runs before the frame's generator.next(), so x/y hold the previous frame's value: velocity trails\n // the rendered position by one constant frame. Layout-dependent fields (rects) can't resolve here, since layout\n // hasn't run for advanced-but-unrendered frames; renderState() fills them at draw time.\n\n /** Allocated once; mutated in place by {@link _sampleMotion}. */\n private readonly _motionHistory: MotionHistory = createMotionHistory();\n\n /** Reused per-node state handed to `ctx.begin()` (mirrors `_transformScratch`). */\n private readonly _renderState: NodeRenderState = {\n id: this.id,\n rects: {},\n elapsed: 0,\n dt: 0,\n velocity: { x: 0, y: 0 },\n direction: 0,\n speed: 0,\n angularVelocity: 0,\n scaleVelocity: 0,\n };\n\n /**\n * Computes motion into {@link _renderState} as a backward difference against the previous frame, then rolls the\n * history. Velocity is zero when no trustworthy delta exists (first frame, or a non-monotonic time jump: only\n * `0 < dt <= MAX` is trusted, so a scrub doesn't read as a huge velocity). World position matches\n * {@link applyTransform} (y-down).\n */\n protected _sampleMotion(): void {\n // Reactive world position (y-down, as applyTransform); the math lives in sampleMotion (no per-frame alloc).\n const r = this.layoutBounds;\n const o = this._offset();\n const x = (r?.x ?? 0) + o.x;\n const y = (r?.y ?? 0) - o.y;\n sampleMotion(this._renderState, this._motionHistory, x, y, this.rotation, this.scale, this._time.total);\n }\n\n /**\n * Pushes this node's transform. A node in its own plane passes the decomposed fields; one that mirrors or tilts\n * passes a precomposed {@link TransformState.matrix}. This is the one place the out-of-plane half is applied:\n * mirrors and tilt are paint, not geometry (see {@link _localMatrix}).\n */\n protected applyTransform(ctx: RenderContext2D): void {\n const r = this.layoutBounds;\n const s = this._transformScratch;\n const { x: ox, y: oy } = this._offset();\n s.x = (r?.x ?? 0) + ox;\n s.y = (r?.y ?? 0) - oy;\n s.width = r?.width ?? 0;\n s.height = r?.height ?? 0;\n s.scale = this.scale;\n s.rotation = this.rotation;\n s.opacity = this.opacity;\n s.blend = this.blend;\n s.effects = this.effects as NodeEffect[];\n s.pivot = this._transformOrigin();\n const slotOpacity = this._placement()?.opacity;\n if (slotOpacity !== undefined) s.opacity *= slotOpacity;\n const frame = this._spaceFrame;\n const slot = frame ? null : this._slotMatrix(true);\n if (frame) {\n s.matrix = frame.local;\n } else if (slot) {\n s.matrix = multiply(slot, localMatrix(\n ox, -oy, s.rotation, s.scale, s.pivot, s.width, s.height, this._projection(),\n ));\n } else {\n const projection = this._projection();\n s.matrix = hasProjection3D(projection)\n ? localMatrix(s.x, s.y, s.rotation, s.scale, s.pivot, s.width, s.height, projection)\n : undefined;\n }\n ctx.transform(s);\n }\n\n /** What the node paints under its children, between the transform push and the children render: the root's fill. */\n protected renderSelf(ctx: RenderContext2D): void { }\n\n /** What the node paints over its children, clipped to its silhouette: the root's overlay. */\n protected renderOverlay(ctx: RenderContext2D): void { }\n\n /** Outline as a {@link Clip}: confines children when `clip` is set and bounds backdrop effects. `null` (default) is no outline. A component answers with the shape its `render` paints. */\n protected clipSelf(): Clip | null { return null; }\n\n /**\n * The camera scope pushed around this node's children (`beginCamera`), or `null`; non-null exactly when the node\n * opens one, so a consumer can reproduce the renderer's transform and viewport clip. Read by\n * `runtime/node-picking.ts`: a camera applies at render time only, so it isn't part of {@link worldMatrix}.\n */\n /** @internal */\n _cameraScope(): CameraScope | null { return null; }\n\n /** The camera this node opens a 2.5D space with, or `null`; only a space root overrides it. See `node-space.ts`. */\n /** @internal */\n _spaceCamera(): SpaceCamera | null { return null; }\n\n /** Whether children pass on into the space this node sits in. False for a node that composites its children itself (mask, boolean, nested camera), flattening them into its own plane. Picking reads it; the renderer agrees because such a node never reaches the base {@link renderChildren}. */\n /** @internal */\n _rendersChildrenInSpace(): boolean { return true; }\n\n /** @internal Set by the parent for the length of this node's render while it is inside a space. */\n _spaceFrame: SpaceFrame | null = null;\n\n /** Whether the renderer confines children to this node's box: `clip` set with an outline to clip to (a bare `clip` without {@link clipSelf} is a no-op, see {@link applyClip}), or a camera scope clipping to the viewport. Picking skips a whole subtree outside a confining node. */\n /** @internal */\n _confinesChildren(): boolean {\n if (this._cameraScope() !== null) return true;\n if (!this.clip) return false;\n const clip = this.clipSelf();\n return clip !== null && !clip.isEmpty();\n }\n\n /**\n * Whether `local` (node-centred, y-up, rotation and scale removed) is inside the node within `tolerance` scene\n * units of its edge, applied outward as grab-slop (an editor passes a zoom-corrected value). Defaults to the\n * layout box; a component narrows it to the outline its `render` paints.\n */\n protected hitTestSelf(local: Vector2, tolerance: number): boolean {\n const b = this._localBounds();\n return Math.abs(local.x - b.x) <= b.width / 2 + tolerance\n && Math.abs(local.y - b.y) <= b.height / 2 + tolerance;\n }\n\n /**\n * Extent of the node's ink in its own space, **y-up and relative to the node's centre** (unlike `layoutBounds`,\n * canvas y-down relative to the parent): what an editor boxes and the default {@link hitTestSelf} grabs.\n * Defaults to the layout box. Separate from the layout rect because a boolean group or mask draws where its\n * children's ink is, possibly off-centre; a component's `bounds` answers here without perturbing layout.\n */\n /** @internal */\n _localBounds(): BoxBounds {\n return { x: 0, y: 0, width: this.measuredWidth, height: this.measuredHeight };\n }\n\n /** @internal Dispatch seam so `node-picking.ts` can reach the protected override. */\n _hitTestSelf(local: Vector2, tolerance: number): boolean {\n return this.hitTestSelf(local, tolerance);\n }\n\n /** Opens `clipSelf()`'s outline as a clip scope; returns whether one was opened (so the caller closes it). */\n protected applyClip(ctx: RenderContext2D): boolean {\n const clip = this.clipSelf();\n if (!clip || clip.isEmpty()) return false;\n ctx.beginClip(clip);\n return true;\n }\n\n /** Backdrop effects (blur, magnify, backdrop shader, ...) beneath the node, confined to its silhouette, so content underneath is filtered while the node's own edges stay sharp. One scope runs them all; no-op without a {@link clipSelf} outline. */\n private applyBackdropEffects(ctx: RenderContext2D): void {\n const effects = this.effects as NodeEffect[];\n // Bail before building the silhouette: `clipSelf()` allocates a Clip and op list, and a node with no effects is the overwhelmingly common case.\n if (effects.length === 0) return;\n applyBackdropEffectsImpl(ctx, effects, this.clipSelf(), this.layoutBounds?.width ?? 0, this.layoutBounds?.height ?? 0);\n }\n\n /** Runs `body` (own painting + children) inside the effect scopes, outermost first: {@link applyBackdropEffects} beneath the node, then a `foreground` scope capturing everything `body` paints. The caller has already pushed {@link applyTransform}. */\n protected renderContentWithEffects(ctx: RenderContext2D, body: () => void): void {\n this.applyBackdropEffects(ctx);\n applyContentEffectScope(ctx, this.effects as NodeEffect[], this.layoutBounds?.width ?? 0, this.layoutBounds?.height ?? 0, body);\n }\n\n protected renderChildren(ctx: RenderPass2D): void {\n // A node opening its own space flattens its subtree into its own plane, whatever space it sits in (as picking's `spaceFrameOf` does, checking for a camera first).\n const camera = this._spaceCamera();\n if (camera) {\n this._renderInSpace(ctx, spaceRootFrame(this, camera));\n return;\n }\n const frame = this._spaceFrame;\n if (frame) {\n this._renderInSpace(ctx, frame);\n return;\n }\n for (const child of this._children) if (child instanceof Node2D) child.render(ctx);\n }\n\n /** Paints children placed in `frame` far to near, each with its frame set only for its own render, so a node reached any other way (a mask's children, a `Tex.surface` source) draws flat. */\n /** @internal A space root opens its space through this. */\n protected _renderInSpace(ctx: RenderPass2D, frame: SpaceFrame): void {\n const children: Node2D[] = [];\n for (const child of this._children) if (child instanceof Node2D) children.push(child);\n const frames = children.map((child) => spaceChildFrame(frame, child));\n // Order is invisible to a walk that only discovers assets.\n const order = ctx.drawsVisibleOnly ? spaceChildOrder(frames) : frames.map((_, i) => i);\n for (const i of order) {\n const child = children[i];\n child._spaceFrame = frames[i];\n try {\n child.render(ctx);\n } finally {\n child._spaceFrame = null;\n }\n }\n }\n\n /** Run `paint` confined to `cut` — the part of the node in front of the lens — when there is one. */\n private _paintInFront(ctx: RenderContext2D, cut: Clip | null, paint: () => void): void {\n if (!cut) {\n paint();\n return;\n }\n ctx.beginClip(cut);\n try {\n paint();\n } finally {\n ctx.endClip();\n }\n }\n\n /** Per-frame render state for the scope {@link render} opens. Motion was sampled when the clock advanced; only layout-dependent fields are filled here. */\n private renderState(ctx: RenderContext2D): NodeRenderState {\n const s = this._renderState;\n // Skipped when the context never resolves `space:'parent'` fills: the precomp pass walks every node purely to discover assets, so this would be a per-node per-frame allocation nothing reads.\n s.rects = ctx.readsSpaceRects ? this._spaceRects() : NO_SPACE_RECTS;\n s.elapsed = this._time.elapsed;\n return s;\n }\n\n /** Reference rects for `space:'parent'` fills, in this node's local space (origin at its positioned centre, y-down). The viewport (`space:'global'`) is the renderer's job. This node's rotation/scale aren't folded in: the rect is the axis-aligned parent box, which gradients expect. */\n protected _spaceRects(): SpaceRects {\n const o = this._offset();\n return computeSpaceRects(this.parent2D?.layoutBounds, this.layoutBounds, o.x, o.y);\n }\n\n /** Draws this node and its subtree: skip checks, then this node's draw scope around {@link renderContent}. Takes a {@link RenderPass2D} because opening the scope is this method's job; callees get the narrower surface so nothing below can open one. */\n render(ctx: RenderPass2D): void {\n if (!this.mounted) return;\n // A zero-opacity subtree paints nothing, so a visible-only context needn't walk it (a chart's reserved-gutter axis,\n // cross-fades). `drawsVisibleOnly` is false on the tracking walk, which must still descend so an invisible\n // node's fonts and images are discovered before it fades in.\n if (ctx.drawsVisibleOnly && this.opacity * (this._placement()?.opacity ?? 1) <= 0) return;\n // Hidden by the editor; same tracking-walk exemption, so a node hidden then shown has its assets discovered.\n if (ctx.drawsVisibleOnly && this.hidden) return;\n // Past edge-on and declining to show its back paints nothing either (same tracking-walk exemption: a face-down\n // card's assets must still be discovered). In a space the camera decides facing, not the node's own tilt.\n const frame = this._spaceFrame;\n if (ctx.drawsVisibleOnly && !this.backfaceVisible && this._facesAway(frame)) return;\n // Edge-on or behind the lens, a node whose children lie in its own plane\n // has nothing anywhere to show.\n if (ctx.drawsVisibleOnly && frame && !frame.paints && !this._rendersChildrenInSpace()) return;\n\n try {\n ctx.begin(this.renderState(ctx));\n try {\n this.renderContent(ctx);\n } finally {\n ctx.end();\n }\n } catch (error) {\n // The innermost node claims it, so the runtime can learn the segment against the node that drew.\n if (error instanceof AssetNotLoadedError) error.nodeId ??= this.id;\n throw error;\n }\n }\n\n /** Everything this node paints: transform, effect envelope, own drawing, children, overlay. A component's `render` replaces it, keeping every guard {@link render} performs above it. */\n protected renderContent(ctx: RenderPass2D): void {\n this.applyTransform(ctx);\n const frame = this._spaceFrame;\n // Edge-on or behind the lens: no plane of its own, but its children are placed by frames of their own.\n if (frame && !frame.paints) {\n this.renderChildren(ctx);\n return;\n }\n const cut = frame?.nearCut ?? null;\n this.renderContentWithEffects(ctx, () => {\n this._paintInFront(ctx, cut, () => this.renderSelf(ctx));\n // Built once from clipSelf(); `clipped` is false with no outline, keeping endClip() balanced.\n const clipped = this.clip && this.applyClip(ctx);\n this.renderChildren(ctx);\n if (clipped) ctx.endClip();\n this._paintInFront(ctx, cut, () => this.renderOverlay(ctx));\n });\n }\n\n /** Whether the node shows its back — to the space's camera when it is in one, else by its own tilt. */\n private _facesAway(frame: SpaceFrame | null): boolean {\n if (frame) return frame.facesAway;\n const p = this._projection();\n return facesAway(p.rotationX, p.rotationY);\n }\n\n /** What {@link measure} hands {@link layoutChildren} within a pass; consumed there. */\n private _flowMeasure: FlowMeasure<Node2D> | null = null;\n\n /** The content box children were last placed in (y-down from this node's centre) and the flow that placed them; what {@link _slotFor} answers from. A component's flow layout records it too (`Flow.layout`). */\n /** @internal */\n _childSpace: ChildSpace | null = null;\n private _flowWarned = false;\n\n /** Records the allocated bounds without touching children. Compared field by field (callers build fresh literals, so identity always differs, even for a node sitting still) to keep the object stable for the aliasing reason below. */\n protected setLayoutBounds(rect: BoxBounds): void {\n const current = this._layoutBounds.get();\n if (\n current.x === rect.x\n && current.y === rect.y\n && current.width === rect.width\n && current.height === rect.height\n ) return;\n // Stores the new object rather than mutating: `layoutBounds` is handed to its public reader, `computeSpaceRects`\n // and bound anchors, and mutating it would alias under all of them.\n this._layoutBounds.set(rect);\n }\n\n /** Children this node lays out itself: its 2D children minus hidden ones. Measure and layout iterate this, not `children`. Returns the live array when nothing is filtered, so an ordinary tree allocates nothing per pass. */\n flowChildren(): Node2D[] {\n const children = this._children;\n // Only a hidden child, or a 3D child under a `Canvas3D`, leaves the flow; both rare enough to check before allocating.\n let i = 0;\n for (; i < children.length; i++) {\n const child = children[i];\n if (!(child instanceof Node2D) || child.hidden) break;\n }\n if (i === children.length) return children as Node2D[];\n // A hidden child gives up its cell and its gap (`display: none`, not `visibility: hidden`).\n return children.filter((c): c is Node2D => c instanceof Node2D && !c.hidden);\n }\n\n /** The inset children are laid out within; a node with a stroke to clear adds the part that intrudes (see `Paint.inset`). */\n effectivePadding(): InsetsResolved {\n return this.padding as InsetsResolved;\n }\n\n /** Centred freeform by default. The root answers with its layout props; a component lays children out with `Flow`. */\n protected flowArrangement(): FlowSettings {\n return DEFAULT_FLOW;\n }\n\n layout(rect: BoxBounds, scope: MeasureContext2D): void {\n this.setLayoutBounds(rect);\n this.layoutChildren(rect, scope);\n }\n\n /** Places flow children in `rect`'s content box by {@link flowArrangement}. Reuses {@link measure}'s result when the box is the one it measured in (or exactly what an axis hugged), else re-measures: a box the node wasn't measured for would leave the children arranged wrong. */\n protected layoutChildren(rect: BoxBounds, scope: MeasureContext2D): void {\n const pending = this._flowMeasure;\n this._flowMeasure = null;\n const inner = insetsOps.insetBounds(rect.width, rect.height, this.effectivePadding());\n const settings = this.flowArrangement();\n this._childSpace = { settings, inner };\n const children = this.flowChildren();\n if (children.length === 0) return;\n\n const measured = pending && flowOps.reusable(pending, inner)\n ? pending\n : flowOps.measure(settings, children, {\n width: inner.width,\n height: inner.height,\n hugWidth: this.width === \"hug\",\n hugHeight: this.height === \"hug\",\n }, scope);\n\n // Boxes are y-up from the content box's centre; a layout rect is y-down from this node's.\n const boxes = flowOps.place(measured, settings, inner);\n for (let i = 0; i < boxes.length; i++) {\n const box = boxes[i];\n measured.items[i].layout(\n { x: inner.x + box.x, y: inner.y - box.y, width: box.width, height: box.height },\n scope,\n );\n }\n\n if (this._flowWarned) return;\n const warning = flowOps.collapsedRun(measured, rect);\n if (warning === null) return;\n this._flowWarned = true;\n console.warn(`[motionscript] \"${this.className}\" ${warning}`);\n }\n\n /** Resolves `width`/`height`: a `'hug'` axis wraps the flow children (by {@link flowArrangement}) plus padding; the result is kept for {@link layoutChildren}. Only flow children are measured: a canvas-pinned child is sized against the canvas, so hugging it would wrap a box this node never contains. */\n measure(constraints: SizeConstraints, scope: MeasureContext2D): Partial<Size2D> {\n this.lastMeasure = { constraints, measurer: scope };\n const padding = this.effectivePadding();\n const children = this.flowChildren();\n if (children.length === 0) {\n this._flowMeasure = null;\n return flowOps.size(this, constraints, padding, NO_CONTENT);\n }\n const space = flowOps.contentBox(this, constraints, padding);\n const measured = flowOps.measure(this.flowArrangement(), children, space, scope);\n this._flowMeasure = measured;\n return flowOps.size(this, constraints, padding, measured.hug);\n }\n\n reparent(args: CommandArgs<{ newParent: Node2D }> & { duration?: undefined }): void;\n reparent(args: CommandArgs<{ newParent: Node2D }> & { duration: number }): Command<Record<string, never>>;\n reparent(args: CommandArgs<{ newParent: Node2D }>): void | Command<Record<string, never>> {\n const newParent = (args.data as { newParent: Node2D }).newParent;\n if (args.duration === undefined) {\n const old = this.parent;\n if (old) old.remove(this);\n newParent.add(this);\n return;\n }\n return reparentAnimated(this, newParent, args.duration, args.easing);\n }\n\n}\n\ndeclareMembers(Node2D, {\n x: property({ default: 0 }),\n y: property({ default: 0 }),\n width: property({ default: 'fill', tween: sizeInputOps.lerp }),\n height: property({ default: 'fill', tween: sizeInputOps.lerp }),\n scale: property({ default: 1 }),\n rotation: property({ default: 0 }),\n opacity: property({ default: 1 }),\n blend: property({ default: 'pass-through' }),\n effects: effectsProperty(),\n padding: insetsProperty(),\n pivot: alignmentProperty(),\n flipHorizontal: property({ default: false }),\n flipVertical: property({ default: false }),\n rotationX: property({ default: 0 }),\n rotationY: property({ default: 0 }),\n rotationZ: property({ default: 0 }),\n depth: property({ default: 0 }),\n perspective: property({ default: 0, tween: lerpPerspective }),\n backfaceVisible: property({ default: true }),\n transformOrigin: property<Alignment | undefined, Vector2 | undefined>({\n default: undefined,\n // `null` is unset too: a document read back from JSON has no `undefined`.\n mapper: (v) => (v == null ? undefined : alignmentOps.resolve(v)),\n // Tweening into an origin from \"none\" starts where it ends: there is no point to travel from.\n tween: (from, to, t) => alignmentOps.lerp(from ?? to ?? ORIGIN_2D, to ?? ORIGIN_2D, t),\n }),\n clip: property({ default: false }),\n flex: property({ default: 1 }),\n gapScale: property({ default: 1 }),\n column: property({ default: undefined }),\n row: property({ default: undefined }),\n colSpan: property({ default: 1 }),\n rowSpan: property({ default: 1 }),\n\n moveTo: command({\n args: [\n \"x\",\n \"y\",\n { key: \"path\", kind: \"path\" },\n { key: \"target\", kind: \"nodeRef\" },\n { key: \"targetAnchor\", kind: \"alignment\" },\n ],\n }),\n fadeTo: command({ args: [\"opacity\"] }),\n rotateTo: command({ args: [\"rotation\"] }),\n scaleTo: command({ args: [\"scale\"] }),\n layoutTo: command({ args: [{ key: \"width\", kind: \"size\" }, { key: \"height\", kind: \"size\" }, { key: \"padding\", kind: \"insets\" }] }),\n pulse: command({ args: [{ key: \"factor\", kind: \"number\", min: 0, step: 0.05, unit: \"×\", default: 1.2 }] }),\n wiggle: command({\n args: [\n { key: \"angle\", kind: \"number\", min: 0, unit: \"°\", default: 8 },\n { key: \"turns\", kind: \"number\", min: 1, step: 1, default: 3 },\n ],\n }),\n effectTo: command({ args: [{ key: \"effects\", kind: \"effects\" }] }),\n removeChildAt: command({ args: [\"index\"] }),\n reparent: command({ args: [\"newParent\"] }),\n});\n\n/** A command's `data` without the arguments a document left out, which arrive as `undefined` and must not be tweened to. */\nfunction _stated<T extends object>(data: T | undefined): Partial<T> {\n const stated: Partial<T> = {};\n for (const key in data) {\n if (data[key] !== undefined) stated[key] = data[key];\n }\n return stated;\n}\n\n/** The 2D node `id` names anywhere in the tree `from` is in, or `null`. */\nexport function findNode2D(from: Node, id: string): Node2D | null {\n let root = from;\n while (root.parent) root = root.parent;\n return findUnder(root, id);\n}\n\nfunction findUnder(at: Node, id: string): Node2D | null {\n if (at.id === id) return at instanceof Node2D ? at : null;\n for (const child of at._allChildren) {\n const found = findUnder(child, id);\n if (found) return found;\n }\n return null;\n}\n\n/** Where `node`'s frame sits in `host`'s: its centre as a y-up offset, and its turn and scale relative to it. */\nexport function frameIn(host: Node2D, node: Node2D): Vector2 & Pick<WorldTransform, \"rotation\" | \"scale\"> {\n const there = node.global;\n const here = host.global;\n const inverse = here.scale === 0 ? 0 : 1 / here.scale;\n const offset = rotateOffset(0, 0, -here.rotation, (there.x - here.x) * inverse, (there.y - here.y) * inverse);\n return { x: offset.x, y: offset.y, rotation: there.rotation - here.rotation, scale: there.scale * inverse };\n}\n", "import { declareMembers, property } from \"@/attributes/properties/decorator\";\nimport { audioEffectsProperty, audioParamProperty } from \"@/attributes/properties/typed\";\nimport { type AudioEffectsInput } from \"@/attributes/audio/effects/chain\";\nimport type { AudioEffect } from \"@/attributes/audio/effects/union\";\nimport type { Param } from \"@/attributes/audio/ramp\";\nimport type { AudioTransition } from \"@/attributes/audio/transition\";\nimport type { AudioBusStop } from \"@/attributes/audio/request\";\nimport type { NodeSpan } from \"@/document/types\";\nimport { Node, type NodeConfig, type NodeDimension, type NodeProps } from \"@/components/trees/node/node\";\nimport type { EasingFunction } from \"@/tween/ease/type\";\nimport type { TweenStepper } from \"@/tween/stepper\";\n\nexport interface NodeAudioProps extends NodeProps {\n /** Linear gain. 1 leaves the signal alone, 0 silences it. */\n volume: Param;\n /** Stereo position: -1 hard left, 0 centre, +1 hard right. */\n pan: Param;\n /** Silence this node and, on a bus, everything under it. */\n mute: boolean;\n /** Effects applied in array order, index 0 closest to the source. */\n effects: AudioEffectsInput;\n /** A fade over its first `duration` seconds, on top of `volume`. */\n transitionIn: AudioTransition | undefined;\n /** A fade over its last `duration` seconds, on top of `volume`. */\n transitionOut: AudioTransition | undefined;\n}\n\n/**\n * The third scene graph: things that make sound. Sibling to `Node2D`/`Node3D` and thin because a sounding node has\n * no box and no place in space; it inherits tree, identity, props, commands, context and clock from {@link Node} and\n * adds a level, stereo position, mute, effect chain and how it enters and leaves. Two kinds: `SoundNode` (a leaf that\n * plays a file) and `AudioBus` (a group everything beneath it feeds).\n *\n * Levels are ramps, not tweens: `volume` and `pan` are {@link Param}, so a fade is a ramp (`ramp(1, 0, 1)`) or a\n * `transitionOut`. A tween writes a prop once per frame, while sound is scheduled once ahead of time and runs at\n * 48 kHz, so a per-frame write would reach the graph on one frame only and `to({ volume })` would read as animated on\n * the timeline yet render flat. `_prepareStep` refuses it.\n */\nexport class NodeAudio<P extends NodeAudioProps = NodeAudioProps> extends Node<P> {\n get dimension(): NodeDimension { return \"audio\"; }\n\n declare volume: Param;\n declare pan: Param;\n declare mute: boolean;\n declare effects: AudioEffectsInput;\n declare transitionIn: AudioTransition | undefined;\n declare transitionOut: AudioTransition | undefined;\n\n constructor(props?: NodeConfig<any, P>) {\n super(props);\n // Deferred from `super()`: field initializers run after it, so applying props earlier would write into cells that don't exist yet.\n this.initProps(props);\n this.adoptChildrenProp(props);\n }\n\n /** This node's children in the audio tree. */\n get childrenAudio(): NodeAudio[] {\n return this._allChildren.filter((c): c is NodeAudio => c instanceof NodeAudio);\n }\n\n /**\n * This bus's identity in the platform's graph: one chain everything under it feeds. The authored id, else the\n * structural path for a code-built bus. Neither alone works, and being wrong is silent (the string reaches\n * `AssetManager.stableKey`, so a changing one re-fetches and re-schedules every clip on the bus): a document row's id\n * is fixed while its child index moves as `syncPresence` adds and removes siblings, whereas a code-built bus has no\n * authored id but its parent builds it in the same slot every time.\n *\n * @internal\n */\n get _busId(): string {\n const authored = this._props?.id;\n return `bus:${typeof authored === \"string\" ? authored : structuralPathOf(this)}`;\n }\n\n /** Refuses a tween on a level, naming the curve that works. Loud because the failure is otherwise invisible: the command runs its duration and the timeline draws a bar, yet the render is flat (see the class docblock). */\n override _prepareStep(to: Partial<P>, duration: number, easing?: EasingFunction): TweenStepper {\n for (const key of TWEEN_REFUSED) {\n if (!(key in to)) continue;\n throw new TypeError(\n `${this.className}: \"${key}\" cannot be tweened — an audio param is scheduled once, ` +\n `not written per frame, so a tween on it would render flat. Automate it with a ` +\n `ramp instead: ${key}: ramp(1, 0, 1), or transitionOut: { duration: 1 }.`,\n );\n }\n return super._prepareStep(to, duration, easing);\n }\n}\n\ndeclareMembers(NodeAudio, {\n volume: audioParamProperty({ default: 1 }),\n pan: audioParamProperty({ default: 0 }),\n mute: property({ default: false }),\n effects: audioEffectsProperty(),\n transitionIn: property({ default: undefined }),\n transitionOut: property({ default: undefined }),\n});\n\nconst TWEEN_REFUSED = [\"volume\", \"pan\", \"speed\"] as const;\n\n/** The buses a node feeds, **source-adjacent first**. Walks audio ancestors only, stopping at the first non-audio parent (the `Canvas2D` root), which is not a bus. */\nexport function busPathOf(node: NodeAudio, spanOf: SpanOf): AudioBusStop[] | undefined {\n const stops: AudioBusStop[] = [];\n let parent = node.parent;\n while (parent instanceof NodeAudio) {\n stops.push(stopOf(parent, spanOf));\n parent = parent.parent;\n }\n return stops.length > 0 ? stops : undefined;\n}\n\n/** {@link busPathOf}, with `bus` itself as the first stop. */\nexport function busPathTo(bus: NodeAudio, spanOf: SpanOf): AudioBusStop[] {\n return [stopOf(bus, spanOf), ...(busPathOf(bus, spanOf) ?? [])];\n}\n\n/** When a node is in the tree, in clip seconds: the span a bus stop carries. */\nexport type SpanOf = (node: Node) => Readonly<NodeSpan>;\n\n/** The bus in `from`'s scene with node id `id`, or `null`. Lets something outside the audio tree (a `Video`, whose audio is welded to its picture) feed a bus by the same id a `SoundNode` under it writes in `parentId`, rather than a second vocabulary. */\nexport function findBusById(from: Node, id: string): NodeAudio | null {\n let root: Node = from;\n while (root.parent) root = root.parent;\n return searchBus(root, id);\n}\n\nfunction searchBus(node: Node, id: string): NodeAudio | null {\n if (node instanceof NodeAudio && node.id === id) return node;\n for (const child of node._allChildren) {\n const found = searchBus(child, id);\n if (found) return found;\n }\n return null;\n}\n\n/** One bus, flattened to the plain data a platform builds its chain from. */\nfunction stopOf(bus: NodeAudio, spanOf: SpanOf): AudioBusStop {\n const effects = bus.effects as unknown as AudioEffect[];\n const span = spanOf(bus);\n return {\n id: bus._busId,\n volume: bus.volume,\n pan: bus.pan,\n mute: bus.mute,\n ...(effects.length > 0 ? { effects } : {}),\n ...(bus.transitionIn ? { transitionIn: bus.transitionIn } : {}),\n ...(bus.transitionOut ? { transitionOut: bus.transitionOut } : {}),\n startAt: span.start,\n endAt: span.end,\n };\n}\n\n/** A node's child-index path from its tree root, joined with \".\": the identity `nodePath` gives the runtime, computed bottom-up since a node declaring audio knows its parents, not its walk index. Stable across a rebuild of an unchanged tree, which both bus ids and clip request ids need. */\nexport function structuralPathOf(node: Node): string {\n const parts: string[] = [];\n let current: Node | null = node;\n while (current) {\n const parent: Node | null = current.parent;\n if (!parent) break;\n parts.push(String(parent._allChildren.indexOf(current)));\n current = parent;\n }\n return parts.reverse().join(\".\");\n}\n", "import { declareMembers, property } from \"@/attributes/properties/decorator\";\nimport { optionalVector3Property, quaternionProperty } from \"@/attributes/properties/typed\";\nimport {\n resolveVector3,\n type Euler3, type EulerOrder, type Quaternion, type Vector3, type Vector3Input,\n} from \"@/render3d/vector3\";\nimport type { RenderContext3D } from \"@/render3d/render-context3d\";\nimport { Scene3D } from \"@/render3d/scene3d\";\nimport { declare3DResources } from \"@/render3d/tracking\";\nimport type { AssetScope } from \"@/assets/scope\";\nimport type { Shadow3D, Transform3D } from \"@/render3d/transform\";\nimport { Node, type NodeConfig, type NodeDimension, type NodeProps } from \"@/components/trees/node/node\";\nimport type { Command, CommandArgs } from \"@/tween/command\";\nimport { command } from \"@/tween/command-decorator\";\nimport type { EasingFunction } from \"@/tween/ease/type\";\nimport type { TweenStepper } from \"@/tween/stepper\";\n\nexport interface Node3DProps extends NodeProps {\n /** Position in the parent's local space. A scalar sets all three axes. */\n position: Vector3Input;\n x: number;\n y: number;\n z: number;\n /** Euler rotation in **degrees**, matching 2D `rotation`; ignored when {@link quaternion} is set. */\n rotation: Vector3Input | Euler3;\n /** Rotation about one axis, in **degrees**. Same names as 2D's. */\n rotationX: number;\n rotationY: number;\n rotationZ: number;\n /** The order the Euler axes are applied in. Default `\"XYZ\"`. */\n rotationOrder: EulerOrder;\n /** Unit quaternion; wins over {@link rotation}. Use it for tumbles where Euler would gimbal. */\n quaternion: Quaternion;\n /** Per-axis scale; a scalar scales uniformly. Default 1. */\n scale: Vector3Input;\n scaleX: number;\n scaleY: number;\n scaleZ: number;\n /** World-space point to orient toward, applied after {@link position}; wins over {@link rotation} and {@link quaternion}. */\n lookAt: Vector3Input | undefined;\n /** Hide without removing: the cached renderer object stays alive. */\n visible: boolean;\n /** Shadow participation, default `true` so enabling shadows for the scene is enough. `false` opts out; `\"cast\"`/`\"receive\"` for one half. */\n shadow: Shadow3D;\n /** Draw-order override, for tuning transparent sorting. */\n renderOrder: number;\n}\n\n/** A 3D parent's own coordinates for where its children sit (graph units, say). Position only, as a 2D `ChildPlane`. Answered by the parent ({@link Node3D._spaceOf}, or `Canvas3D._spaceOf` for the viewport's own children). */\nexport interface ChildSpace3D {\n /** A child's `x`/`y`/`z` as a point in the parent's local space. */\n toLocal(x: number, y: number, z: number): Vector3;\n}\n\n/** A parent that may place its 3D children in coordinates of its own: a `Node3D`, or a 3D viewport. */\ninterface SpaceHolder3D {\n _spaceOf(child: Node3D | null): ChildSpace3D | null;\n}\n\n/** The coordinates `node`'s parent places it by, or `null` when they are the parent's local space. The parent may be a 3D node or the viewport holding it. */\n/** @internal */\nexport function parentSpaceOf(node: Node3D): ChildSpace3D | null {\n const parent = node.parent as Partial<SpaceHolder3D> | null;\n return typeof parent?._spaceOf === \"function\" ? parent._spaceOf(node) : null;\n}\n\n/** The three axis props each vector prop distributes into, in order. */\nconst VECTOR_SUGAR: Readonly<Record<string, readonly [string, string, string]>> = {\n position: [\"x\", \"y\", \"z\"],\n rotation: [\"rotationX\", \"rotationY\", \"rotationZ\"],\n scale: [\"scaleX\", \"scaleY\", \"scaleZ\"],\n};\n\n/**\n * A thing in 3D space, the root of the 3D scene graph: the sibling of {@link Node2D}, with the same tree,\n * `to()`/`set()`, refs, context and clock inherited from {@link Node}. Only placement and drawing differ: there is no\n * `width`, `padding`, anchor or flex, since a 3D node's whole placement is its transform.\n *\n * Canvas3D({ children: [Camera3D(...), AmbientLight3D(...), Group3D({ ref: rig, children: [Box3D(...)] })] })\n * rig().to({ data: { rotationY: 360, y: 1 }, duration: 2 });\n *\n * Axes are scalars and vectors are sugar: `x`/`y`/`z`, `rotationX/Y/Z` and `scaleX/Y/Z` are the real props (named as in\n * 2D) and `position`, `rotation`, `scale` distribute into them, as `Node2D` distributes `size`. That is what makes\n * `to({ y: 3 })` work: a single vector prop would have nothing to interpolate on the other axes.\n *\n * Lives only under a `Canvas3D` (the one node holding both dimensions); a `Rect` parent throws (see\n * {@link Node.acceptsChild}). Every 3D node type is a `component3d` lowering onto this class and drawing from its `render`.\n */\nexport class Node3D<P extends Node3DProps = Node3DProps> extends Node<P> {\n get dimension(): NodeDimension { return \"3d\"; }\n\n declare x: number;\n declare y: number;\n declare z: number;\n\n declare rotationX: number;\n declare rotationY: number;\n declare rotationZ: number;\n declare rotationOrder: EulerOrder;\n\n declare quaternion: Quaternion;\n\n declare scaleX: number;\n declare scaleY: number;\n declare scaleZ: number;\n\n declare lookAt: Vector3Input | undefined;\n declare visible: boolean;\n declare shadow: Shadow3D;\n declare renderOrder: number;\n\n constructor(props?: NodeConfig<any, P>) {\n super(props);\n // Distributed before `initProps`, which applies only registered props: a `position` left in the bag would be dropped.\n this.initProps(distributeVectors(props) as NodeConfig<any, P>);\n this.adoptChildrenProp(props);\n }\n\n /** Animate the position, whichever axes are given; the rest stay where they are. */\n moveTo(args: CommandArgs<{ x?: number; y?: number; z?: number }> & { duration: number }): Command<P> {\n return this.to({ data: stated(args.data) as Partial<P>, duration: args.duration, easing: args.easing });\n }\n\n /** Animate the Euler rotation, in degrees, whichever axes are given. */\n rotateTo(\n args: CommandArgs<{ rotationX?: number; rotationY?: number; rotationZ?: number }> & { duration: number },\n ): Command<P> {\n return this.to({ data: stated(args.data) as Partial<P>, duration: args.duration, easing: args.easing });\n }\n\n /** Animate the scale: `scale` on every axis, and any axis given beside it on that one. */\n scaleTo(\n args: CommandArgs<{ scale?: number; scaleX?: number; scaleY?: number; scaleZ?: number }> & { duration: number },\n ): Command<P> {\n return this.to({ data: stated(args.data) as Partial<P>, duration: args.duration, easing: args.easing });\n }\n\n /** This node's position, composed from the axis props. */\n get position(): Vector3 {\n return { x: this.x, y: this.y, z: this.z };\n }\n set position(value: Vector3Input) {\n this.set({ position: value } as never);\n }\n\n /** This node's Euler rotation in degrees, composed from the axis props. */\n get rotation(): Euler3 {\n return { x: this.rotationX, y: this.rotationY, z: this.rotationZ, order: this.rotationOrder };\n }\n set rotation(value: Vector3Input | Euler3) {\n this.set({ rotation: value } as never);\n }\n\n /** This node's scale, composed from the axis props. */\n get scale(): Vector3 {\n return { x: this.scaleX, y: this.scaleY, z: this.scaleZ };\n }\n set scale(value: Vector3Input) {\n this.set({ scale: value } as never);\n }\n\n /** Distributes the vector sugar into axis props, then writes as usual (like `Node2D.set`'s `size`): `position` has no slot, so it becomes three writes. An explicit axis in the same call wins, so `{ position: p, y: 0 }` means what it reads like. */\n override set(props: { [K in keyof P]?: P[K] | (() => P[K]) }): void {\n super.set(distributeVectors(props) as typeof props);\n }\n\n /** The tween half of the same rule: expanded here so `to({ position })` and `to({ x, y, z })` produce identical steppers. */\n override _prepareStep(to: Partial<P>, duration: number, easing?: EasingFunction): TweenStepper {\n return super._prepareStep(distributeVectors(to) as Partial<P>, duration, easing);\n }\n\n /** This node's placement in the renderer's vocabulary, sampled fresh each frame from the prop slots. `quaternion` is emitted only when set away from identity: it wins over `rotation` in a {@link Transform3D}, so always sending it would make `rotation` do nothing. */\n protected transform3D(): Transform3D {\n const quaternion = this.quaternion as unknown as Quaternion;\n const identityQuaternion =\n quaternion.x === 0 && quaternion.y === 0 && quaternion.z === 0 && quaternion.w === 1;\n const space = parentSpaceOf(this);\n return {\n position: space ? space.toLocal(this.x, this.y, this.z) : this.position,\n rotation: this.rotation,\n quaternion: identityQuaternion ? undefined : quaternion,\n scale: this.scale,\n lookAt: this.lookAt,\n visible: this.visible,\n shadow: this.shadow,\n renderOrder: this.renderOrder,\n };\n }\n\n /** The coordinates `child`'s `x`/`y`/`z` are in, or `null` for this node's local space. A `null` child is one not here yet. */\n /** @internal */\n _spaceOf(_child: Node3D | null): ChildSpace3D | null {\n return null;\n }\n\n /** The transform on this node's *group* (the scope its children nest in); defaults to its own placement. A camera answers identity and places itself instead: three aims a camera's -Z at `lookAt` but a plain group's +Z, so the group transform would point the shot backwards. */\n protected groupTransform(): Transform3D {\n return this.transform3D();\n }\n\n /** Draws this node's own contribution (a `ctx.draw(...)` for geometry, `ctx.light(...)` for a light, nothing for a plain {@link Group3D}); children are recorded after it, nested inside its transform. */\n protected renderSelf(ctx: RenderContext3D): void { }\n\n /** Records this node and its subtree into `ctx`. An invisible node still opens its scope: `visible: false` is a renderer-side flag on a live object, so hiding and showing rebuilds no GPU resources, where skipping the walk would sweep the subtree out of the cache. */\n render(ctx: RenderContext3D): void {\n // The editor's flag folds into `visible` (honoured by the picking walk) rather than adding a second \"do not show\"\n // flag; the scope still opens, as above.\n if (this.hidden) {\n ctx.begin({ id: this.id, transform: { ...this.groupTransform(), visible: false } });\n ctx.end();\n return;\n }\n ctx.begin({ id: this.id, transform: this.groupTransform() });\n this.renderSelf(ctx);\n for (const child of this._children) {\n if (child instanceof Node3D) child.render(ctx);\n }\n ctx.end();\n }\n\n /** What {@link renderSelf} records, never {@link render}: placement lives on the group scope, so moving a node doesn't change what it declares. */\n declareAssets(assets: AssetScope): void {\n if (this.renderSelf === Node3D.prototype.renderSelf) return;\n const scene = new Scene3D();\n this.renderSelf(scene);\n declare3DResources(scene, assets);\n }\n}\n\ndeclareMembers(Node3D, {\n x: property({ default: 0 }),\n y: property({ default: 0 }),\n z: property({ default: 0 }),\n rotationX: property({ default: 0 }),\n rotationY: property({ default: 0 }),\n rotationZ: property({ default: 0 }),\n rotationOrder: property({ default: \"XYZ\" }),\n quaternion: quaternionProperty(),\n scaleX: property({ default: 1 }),\n scaleY: property({ default: 1 }),\n scaleZ: property({ default: 1 }),\n lookAt: optionalVector3Property(\"snap\"),\n visible: property({ default: true }),\n shadow: property({ default: true }),\n renderOrder: property({ default: 0 }),\n\n moveTo: command({ args: [\"x\", \"y\", \"z\"] }),\n rotateTo: command({ args: [\"rotationX\", \"rotationY\", \"rotationZ\"] }),\n scaleTo: command({\n args: [{ key: \"scale\", kind: \"number\", min: 0, step: 0.05, unit: \"×\" }, \"scaleX\", \"scaleY\", \"scaleZ\"],\n }),\n});\n\n/** Expands `position`/`rotation`/`scale` into axis props; the bag is returned untouched when it names none. A **binding** expands into three bindings each taking one component of the resolved vector, so `position={() => lift()}` stays reactive rather than frozen at bind time. */\nfunction distributeVectors<T extends object>(props: T | undefined): T | undefined {\n if (!props) return props;\n\n let out: Record<string, unknown> | undefined;\n\n for (const key in VECTOR_SUGAR) {\n const value = (props as Record<string, unknown>)[key];\n if (value === undefined) continue;\n\n out ??= { ...(props as Record<string, unknown>) };\n delete out[key];\n\n const axes = VECTOR_SUGAR[key];\n\n if (typeof value === \"function\") {\n const read = value as () => Vector3Input;\n for (let i = 0; i < 3; i++) {\n const axis = axes[i];\n if (out[axis] !== undefined) continue;\n out[axis] = () => componentOf(resolveVector3(read()), i);\n }\n continue;\n }\n\n const vector = resolveVector3(value as Vector3Input);\n for (let i = 0; i < 3; i++) {\n const axis = axes[i];\n if (out[axis] === undefined) out[axis] = componentOf(vector, i);\n }\n\n // `order` rides on an Euler and has nowhere else to go.\n if (key === \"rotation\") {\n const order = (value as Euler3).order;\n if (order !== undefined && out.rotationOrder === undefined) out.rotationOrder = order;\n }\n }\n\n return (out as T) ?? props;\n}\n\n/** `data` without the keys left unstated, so a tween never aims an axis at `undefined`. */\nfunction stated<T extends object>(data: T | undefined): Partial<T> {\n const out: Partial<T> = {};\n for (const key in data) if (data[key] !== undefined) out[key] = data[key];\n return out;\n}\n\nfunction componentOf(vector: Vector3, index: number): number {\n return index === 0 ? vector.x : index === 1 ? vector.y : vector.z;\n}\n", "import type { NodeTypeDescriptor } from \"./node-descriptor\";\n\nexport const NODE_META = Symbol(\"nodeMeta\");\n\n/**\n * Declare a node class's document key, and nothing else. It does not register: registration happens when the\n * class is handed to a `Registry` (`new Engine(platform, { nodes: [Blob] })`), so the order modules happened\n * to be imported in is never part of engine state.\n *\n * A component factory makes this for the class it generates (`component2d({ key })`); a hand-written class\n * calls `node(\"blob\")(Blob)` itself.\n *\n * The full form (`node({ key, forkable, layout, seed })`) declares what a host needs to offer the type; none\n * of it is read while rendering (see {@link NodeTypeDescriptor}).\n *\n * The key is written out, not taken from the class name: a minifier may rename `Blob` to `o`, and stored\n * documents contain the key, so a derived one would silently rewrite every document's vocabulary in a\n * production bundle.\n */\nexport function node(type: string | NodeTypeDescriptor) {\n /**\n * Looser than `NodeConstructor`: a real node class declares its own props type, and requiring assignability\n * would reject the classes this exists for.\n */\n return function <T extends new (...args: never[]) => object>(ctor: T): T {\n const descriptor: NodeTypeDescriptor = typeof type === \"string\" ? { key: type } : type;\n (ctor.prototype as Record<symbol, unknown>)[NODE_META] = descriptor;\n return ctor;\n };\n}\n\n/**\n * Own prototype only: a subclass inherits its parent's methods but not its identity, and a `Card extends Rect`\n * answering to `\"rect\"` would collide with the real one.\n */\nexport function getNodeDescriptor(ctor: new (...args: never[]) => object): NodeTypeDescriptor | undefined {\n const proto = ctor.prototype as Record<symbol, unknown> | undefined;\n if (!proto || !Object.prototype.hasOwnProperty.call(proto, NODE_META)) return undefined;\n return proto[NODE_META] as NodeTypeDescriptor;\n}\n", "import { TransformState } from \"./transform\";\nimport { AlignmentKey, Alignment, alignmentOps } from \"@/attributes/layout/alignment\";\nimport { Vector2 } from \"@/attributes/layout/vector2\";\n\n/** Per-shape descriptor state. Shapes carry geometry and a local transform (`rotation`/`scale` baked into the path before it joins the union) but not layer effects: effects, opacity and blend apply to the whole drawn union via {@link Graphics2D.effects}, `Graphics2D.opacity()` and the node, so `ShapeState` omits those `TransformState` fields. */\nexport interface ShapeState extends Omit<TransformState, \"effects\" | \"pivot\" | \"opacity\" | \"blend\"> {\n start: number;\n end: number;\n /** Pivot for the shape's local rotation/scale: a named alignment (`.rect({ pivot: 'topRight' })`) or an explicit `Vector2`. `with*Descriptor` normalises it via {@link resolveShapePivot}, so resolved state always carries a concrete pivot. */\n pivot: Alignment;\n}\n\n/** Normalises a `pivot` input to a `Vector2` (a named alignment to its `[-1, 1]` pivot; default centre). Idempotent, so both `with*Descriptor` and the renderer can call it. */\nexport function resolveShapePivot(pivot: Alignment | undefined): Vector2 {\n return alignmentOps.resolve(pivot ?? { x: 0, y: 0 });\n}\n\n// Cardinal-alignment positioning: a shape can be placed by a named alignment instead of its centre `x`/`y`, like a\n// node (`.rect({ topRight: { x, y }, width, height })`). Targets are in the same y-UP author space as `x`/`y`.\n// As with a node, an alignment also sets the shape's `pivot`, so a later `rotation`/`scale` turns about the pinned corner.\n\n/** The cardinal-alignment positioning props a descriptor accepts (input-only, absent from the resolved `*State`). Pass at most one, and not with `x`, `y` or `pivot`; each value is the y-up point the alignment lands on. */\nexport interface ShapeAlignmentInput {\n center?: Vector2;\n topLeft?: Vector2;\n topRight?: Vector2;\n bottomLeft?: Vector2;\n bottomRight?: Vector2;\n topCenter?: Vector2;\n bottomCenter?: Vector2;\n centerLeft?: Vector2;\n centerRight?: Vector2;\n}\n\nexport const SHAPE_ALIGNMENT_KEYS: AlignmentKey[] = [\n \"center\", \"topLeft\", \"topRight\", \"bottomLeft\", \"bottomRight\",\n \"topCenter\", \"bottomCenter\", \"centerLeft\", \"centerRight\",\n];\n\n/** Validates a descriptor's alignment usage like `alignmentOps.validateProps`, also rejecting `x`/`y`. Throws on more than one alignment, or an alignment combined with `pivot`, `x` or `y`. */\nexport function validateShapeAlignmentProps(descriptor: Record<string, unknown>): void {\n const present = SHAPE_ALIGNMENT_KEYS.filter(k => descriptor[k] !== undefined);\n if (present.length > 1) {\n throw new Error(`Cannot set multiple shape alignment props at once: ${present.join(\", \")}`);\n }\n if (present.length === 1) {\n const conflict = ([\"pivot\", \"x\", \"y\"] as const).find(k => descriptor[k] !== undefined);\n if (conflict) {\n throw new Error(`Cannot set both shape alignment prop '${present[0]}' and '${conflict}' at the same time`);\n }\n }\n}\n\n/** Drops the input-only alignment keys so a `{ ...descriptor }` spread doesn't leak them onto the resolved `*State` (its x/y/pivot already carry their effect). Shallow copy. */\nexport function stripShapeAlignmentKeys<T extends object>(descriptor: T): Omit<T, keyof ShapeAlignmentInput> {\n const out = { ...descriptor } as Record<string, unknown>;\n for (const k of SHAPE_ALIGNMENT_KEYS) delete out[k];\n return out as Omit<T, keyof ShapeAlignmentInput>;\n}\n\n/**\n * Resolves a descriptor's positioning into a concrete centre `x`/`y` and `pivot` (y-up author space), handling the\n * alignment shorthand: the centre that lands alignment `a` on `target` is `target - a * (size / 2)`, and `pivot`\n * becomes `a` (as `Node2D`'s auto-pivot). Otherwise `x`/`y`/`pivot` pass through; `pivot` alone never repositions\n * here, because this re-runs on already-resolved state (`BaseShape.resolveState`) and would double-apply it. The\n * `pivot` + plain `x`/`y` shorthand ({@link resolvePivotPosition}) bakes its offset in once, earlier, to preserve that.\n */\nexport function resolveShapeAlignment(\n descriptor: Partial<ShapeState> & ShapeAlignmentInput,\n width: number,\n height: number,\n): { x: number; y: number; pivot: Alignment } {\n validateShapeAlignmentProps(descriptor as Record<string, unknown>);\n\n const alignmentKey = SHAPE_ALIGNMENT_KEYS.find(k => (descriptor as Record<string, unknown>)[k] !== undefined);\n if (alignmentKey) {\n const target = (descriptor as Record<string, Vector2>)[alignmentKey];\n const a = alignmentOps.resolve(alignmentKey); // normalised [-1,1], y-up\n return {\n x: target.x - a.x * (width / 2),\n y: target.y - a.y * (height / 2),\n pivot: a,\n };\n }\n\n return {\n x: descriptor.x ?? 0,\n y: descriptor.y ?? 0,\n pivot: descriptor.pivot ?? { x: 0, y: 0 },\n };\n}\n\n/**\n * Folds a plain `pivot` + `x`/`y` into an equivalent resolved centre, so `{ x, y, pivot: 'topRight' }` lands the\n * top-right corner at `(x, y)` like `{ topRight: { x, y } }`, using the same `target - a * (size / 2)` formula.\n *\n * Must run exactly once, on the raw author-facing descriptor and before {@link resolveShapeAlignment} (in\n * `flipPositionY`, not `with*Descriptor`): `BaseShape.resolveState` re-runs the latter on resolved state, where\n * this output is indistinguishable from a plain descriptor and would double the offset. No-op with an alignment present or a centre/absent `pivot`.\n */\nexport function resolvePivotPosition<T extends Partial<ShapeState> & ShapeAlignmentInput>(\n descriptor: T,\n width: number,\n height: number,\n): T {\n const alignmentKey = SHAPE_ALIGNMENT_KEYS.find(k => (descriptor as Record<string, unknown>)[k] !== undefined);\n if (alignmentKey || descriptor.pivot === undefined) return descriptor;\n\n const a = alignmentOps.resolve(descriptor.pivot); // normalised [-1,1], y-up\n if (a.x === 0 && a.y === 0) return descriptor;\n\n const target = { x: descriptor.x ?? 0, y: descriptor.y ?? 0 };\n return {\n ...descriptor,\n x: target.x - a.x * (width / 2),\n y: target.y - a.y * (height / 2),\n pivot: a,\n };\n}\n", "import { RectCornerRadius } from \"@/attributes/shape/corners/corner-radius\";\nimport { RectCornerStyle } from \"@/attributes/shape/corners/corner-style\";\nimport { ShapeAlignmentInput, ShapeState, resolveShapeAlignment, resolveShapePivot, stripShapeAlignmentKeys } from \"./shape\";\n\n\nexport interface RectState extends ShapeState {\n width: number;\n height: number;\n // Loose input or already resolved (both are part of RectCornerRadius/RectCornerStyle): the node resolves via its\n // property mapper and the renderer re-resolves idempotently.\n cornerRadius: RectCornerRadius;\n cornerStyle: RectCornerStyle;\n}\n\nexport function withRectDescriptor(descriptor: Partial<RectState> & ShapeAlignmentInput): RectState {\n const width = descriptor.width ?? 0;\n const height = descriptor.height ?? 0;\n const { x, y, pivot } = resolveShapeAlignment(descriptor, width, height);\n return {\n ...stripShapeAlignmentKeys(descriptor),\n rotation: descriptor.rotation ?? 0,\n scale: descriptor.scale ?? 1,\n x,\n y,\n start: descriptor.start ?? 0,\n end: descriptor.end ?? 1,\n pivot: resolveShapePivot(pivot),\n\n width,\n height,\n cornerRadius: descriptor.cornerRadius ?? 0,\n cornerStyle: descriptor.cornerStyle ?? \"rounded\",\n };\n}\n", "import { ShapeAlignmentInput, ShapeState, resolveShapeAlignment, resolveShapePivot, stripShapeAlignmentKeys } from \"./shape\";\nexport interface EllipseState extends ShapeState {\n width: number;\n height: number;\n ratio: number;\n sweep: number;\n startAngle: number;\n}\n\nexport function withEllipseDescriptor(descriptor: Partial<EllipseState> & ShapeAlignmentInput): EllipseState {\n const width = descriptor.width ?? 0;\n const height = descriptor.height ?? 0;\n const { x, y, pivot } = resolveShapeAlignment(descriptor, width, height);\n return {\n ...stripShapeAlignmentKeys(descriptor),\n rotation: descriptor.rotation ?? 0,\n scale: descriptor.scale ?? 1,\n x,\n y,\n start: descriptor.start ?? 0,\n end: descriptor.end ?? 1,\n pivot: resolveShapePivot(pivot),\n\n width,\n height,\n ratio: descriptor.ratio ?? 0,\n sweep: descriptor.sweep ?? 360,\n startAngle: descriptor.startAngle ?? 0,\n };\n}", "import { CornerStyle } from \"@/attributes/shape/corners/corner-style\";\nimport { ShapeAlignmentInput, ShapeState, resolveShapeAlignment, resolveShapePivot, stripShapeAlignmentKeys } from \"./shape\";\n\nexport interface PolygonState extends ShapeState {\n width: number;\n height: number;\n sides: number;\n /** Vertex rounding radius in pixels (applied uniformly to every vertex). */\n cornerRadius: number;\n /** Vertex shape: `'rounded'` (circular arc) or `'angled'` (chamfer). */\n cornerStyle: CornerStyle;\n}\n\nexport function withPolygonDescriptor(descriptor: Partial<PolygonState> & ShapeAlignmentInput): PolygonState {\n const width = descriptor.width ?? 0;\n const height = descriptor.height ?? 0;\n const { x, y, pivot } = resolveShapeAlignment(descriptor, width, height);\n return {\n ...stripShapeAlignmentKeys(descriptor),\n rotation: descriptor.rotation ?? 0,\n scale: descriptor.scale ?? 1,\n x,\n y,\n start: descriptor.start ?? 0,\n end: descriptor.end ?? 1,\n pivot: resolveShapePivot(pivot),\n\n width,\n height,\n sides: descriptor.sides ?? 5,\n cornerRadius: descriptor.cornerRadius ?? 0,\n cornerStyle: descriptor.cornerStyle ?? \"rounded\",\n };\n}\n", "import { CornerStyle } from \"@/attributes/shape/corners/corner-style\";\nimport { ShapeAlignmentInput, ShapeState, resolveShapeAlignment, resolveShapePivot, stripShapeAlignmentKeys } from \"./shape\";\n\nexport interface PolygramState extends ShapeState {\n width: number;\n height: number;\n sides: number;\n ratio: number;\n /** Vertex rounding radius in pixels (applied uniformly to every vertex). */\n cornerRadius: number;\n /** Vertex shape: `'rounded'` (circular arc) or `'angled'` (chamfer). */\n cornerStyle: CornerStyle;\n}\n\nexport function withPolygramDescriptor(descriptor: Partial<PolygramState> & ShapeAlignmentInput): PolygramState {\n const width = descriptor.width ?? 0;\n const height = descriptor.height ?? 0;\n const { x, y, pivot } = resolveShapeAlignment(descriptor, width, height);\n return {\n ...stripShapeAlignmentKeys(descriptor),\n rotation: descriptor.rotation ?? 0,\n scale: descriptor.scale ?? 1,\n x,\n y,\n start: descriptor.start ?? 0,\n end: descriptor.end ?? 1,\n pivot: resolveShapePivot(pivot),\n\n width,\n height,\n sides: descriptor.sides ?? 5,\n ratio: descriptor.ratio ?? 0.5,\n cornerRadius: descriptor.cornerRadius ?? 0,\n cornerStyle: descriptor.cornerStyle ?? \"rounded\",\n };\n}\n", "import { Vector2 } from \"@/attributes/layout/vector2\";\nimport { ShapeState, resolveShapePivot } from \"./shape\";\n\nexport interface LineState extends ShapeState {\n points: Vector2[];\n radius: number;\n closed: boolean;\n}\n\nexport function withLineDescriptor(descriptor: Partial<LineState>): LineState {\n return {\n rotation: descriptor.rotation ?? 0,\n scale: descriptor.scale ?? 1,\n x: descriptor.x ?? 0,\n y: descriptor.y ?? 0,\n start: descriptor.start ?? 0,\n end: descriptor.end ?? 1,\n width: descriptor.width ?? 0,\n height: descriptor.height ?? 0,\n pivot: resolveShapePivot(descriptor.pivot),\n\n points: descriptor.points ?? [],\n radius: descriptor.radius ?? 0,\n closed: descriptor.closed ?? false,\n };\n}\n", "import { Vector2 } from \"@/attributes/layout/vector2\";\nimport { Clip, ClipOp, ClipShapeOp } from \"./clip\";\nimport { withRectDescriptor } from \"./descriptors/rect\";\nimport { withEllipseDescriptor } from \"./descriptors/ellipse\";\nimport { withPolygonDescriptor } from \"./descriptors/polygon\";\nimport { withPolygramDescriptor } from \"./descriptors/polygram\";\nimport { withLineDescriptor } from \"./descriptors/line\";\nimport { cornerRadiusOps } from \"@/attributes/shape/corners/corner-radius\";\n\n/**\n * Point-in-region tests for {@link Clip}, so a click follows a shape's silhouette rather than its bounding box.\n * Geometry only, since a `Clip` is a declarative record of primitives rather than a built path: a shape declares its\n * outline once in `clipSelf()` and both the pixels and the grab region derive from it. Points and descriptor\n * coordinates are **y-up author space** (the renderer flips at draw time, see `flipPositionY`), so\n * `startAngle`/`sweep` measure counter-clockwise from +x.\n */\n\nconst EPS = 1e-9;\n\n/** Whether `point` is inside the region a {@link Clip} describes, within `tolerance` scene units of its edge. Shape ops union; a `cut` subtracts the preceding shape from everything before it, as the renderer replays. `tolerance` widens each shape outward, a cutter included (a slightly larger bite), keeping the test forgiving rather than making a hole's rim unpickable. */\nexport function containsClip(clip: Clip, point: Vector2, tolerance = 0): boolean {\n return containsOps(clip.ops(), point, tolerance);\n}\n\nexport function containsOps(ops: readonly ClipOp[], point: Vector2, tolerance = 0): boolean {\n let inside = false;\n // Held back so a following `cut` can subtract it instead of unioning it.\n let pending: ClipShapeOp | null = null;\n\n const flush = (): void => {\n if (pending && containsShape(pending, point, tolerance)) inside = true;\n pending = null;\n };\n\n for (const op of ops) {\n if (op.kind === \"cut\") {\n // The pending shape is the cutter: it never joins the union and punches what came before.\n if (pending && containsShape(pending, point, tolerance)) inside = false;\n pending = null;\n continue;\n }\n flush();\n pending = op;\n }\n flush();\n return inside;\n}\n\n/** Dispatches a shape op to its containment test after undoing its local rotation/scale about its pivot, mirroring `BaseShape.applyShapeTransform`. */\nfunction containsShape(op: ClipShapeOp, point: Vector2, tolerance: number): boolean {\n switch (op.kind) {\n case \"rect\": {\n const s = withRectDescriptor(op.state);\n const p = toShapeLocal(point, s, s.width, s.height);\n return p !== null && containsRect(p, s.width, s.height, cornerRadiusOps.resolve(s.cornerRadius), tolerance);\n }\n case \"ellipse\": {\n const s = withEllipseDescriptor(op.state);\n const p = toShapeLocal(point, s, s.width, s.height);\n return p !== null && containsEllipse(p, s.width, s.height, s.ratio, s.sweep, s.startAngle, tolerance);\n }\n case \"polygon\": {\n const s = withPolygonDescriptor(op.state);\n const p = toShapeLocal(point, s, s.width, s.height);\n return p !== null && containsPolyline(p, polygonVertices(s.width, s.height, s.sides), true, tolerance);\n }\n case \"polygram\": {\n const s = withPolygramDescriptor(op.state);\n const p = toShapeLocal(point, s, s.width, s.height);\n return p !== null && containsPolyline(p, polygramVertices(s.width, s.height, s.sides, s.ratio), true, tolerance);\n }\n case \"line\": {\n const s = withLineDescriptor(op.state);\n const p = toShapeLocal(point, s, s.width, s.height);\n if (p === null || s.points.length === 0) return false;\n // As a clip region a polyline is filled with its contour implicitly closed, so test the enclosed area first, then the band around the stroke.\n if (s.points.length >= 3 && containsPolyline(p, s.points, true, tolerance)) return true;\n return nearPolyline(p, s.points, s.closed, tolerance);\n }\n case \"path\": {\n // A Bézier winding test isn't worth carrying and no built-in shape emits a `path` clip, only a hand-built `Clip`; fall back to the declared box.\n const s = op.state;\n const local = { x: point.x - (s.x ?? 0), y: point.y - (s.y ?? 0) };\n return containsRect(local, s.width ?? 0, s.height ?? 0, cornerRadiusOps.resolve(0), tolerance);\n }\n }\n}\n\ninterface ShapePlacement {\n x: number;\n y: number;\n rotation: number;\n scale: number;\n pivot: unknown;\n}\n\n/** Maps `point` out of the shape's `x`/`y`/`rotation`/`scale` (about its pivot) into its un-transformed, centred frame; `null` when scale is zero (collapsed, encloses nothing). */\nfunction toShapeLocal(point: Vector2, s: ShapePlacement, width: number, height: number): Vector2 | null {\n if (s.scale === 0) return null;\n const pivot = s.pivot as Vector2;\n // Pivot is normalised [-1, 1] about the centre, y-up here (the renderer negates y in canvas space).\n const px = pivot.x * (width / 2);\n const py = pivot.y * (height / 2);\n const dx = point.x - (s.x + px);\n const dy = point.y - (s.y + py);\n // Undo the clockwise rotation: in y-up space the forward map is\n // (cos·x + sin·y, -sin·x + cos·y), so the inverse swaps the sine signs.\n const rad = (s.rotation * Math.PI) / 180;\n const cos = Math.cos(rad);\n const sin = Math.sin(rad);\n const rx = (cos * dx - sin * dy) / s.scale;\n const ry = (sin * dx + cos * dy) / s.scale;\n return { x: rx + px, y: ry + py };\n}\n\ninterface Corners4 { topLeft: number; topRight: number; bottomRight: number; bottomLeft: number }\n\n/** Box centred on the origin with per-corner rounding; a corner excludes the point only beyond its quarter-circle, so a plain rect reduces to the box test. `cornerStyle` is ignored: an `'angled'` chamfer cuts inside the arc, so the arc over-estimates by a sliver, the forgiving direction for a grab. */\nfunction containsRect(p: Vector2, width: number, height: number, radius: Corners4, tolerance: number): boolean {\n const halfW = width / 2 + tolerance;\n const halfH = height / 2 + tolerance;\n if (Math.abs(p.x) > halfW || Math.abs(p.y) > halfH) return false;\n\n // Test the nearest corner's arc; radii clamp to half the side as any rounded-rect rasteriser clamps them.\n const maxR = Math.min(width, height) / 2;\n const r = Math.min(\n maxR,\n p.x <= 0\n ? (p.y >= 0 ? radius.topLeft : radius.bottomLeft)\n : (p.y >= 0 ? radius.topRight : radius.bottomRight),\n );\n if (r <= 0) return true;\n\n // Centre of that corner's arc, then the \"outside the quarter-circle\" check, which only bites inside the corner square.\n const sx = Math.sign(p.x || 1);\n const sy = Math.sign(p.y || 1);\n const dx = p.x - sx * (width / 2 - r);\n const dy = p.y - sy * (height / 2 - r);\n if (Math.sign(dx || 1) !== sx || Math.sign(dy || 1) !== sy) return true;\n return dx * dx + dy * dy <= (r + tolerance) * (r + tolerance);\n}\n\n/**\n * Ellipse with the `ratio`/`sweep`/`startAngle` family the renderer draws (see `EllipseShape.buildSVGPath`), so the\n * grab region is what was painted: `ratio` <= 0 is a disk (or wedge for a partial sweep); 0 < `ratio` < 1 an annulus /\n * annular sector (the hole is not hittable); `ratio` >= 1 collapses to the bare outer curve, hit only near it.\n */\nfunction containsEllipse(\n p: Vector2, width: number, height: number,\n ratio: number, sweep: number, startAngle: number,\n tolerance: number,\n): boolean {\n const rx = width / 2;\n const ry = height / 2;\n if (rx <= 0 || ry <= 0) return false;\n\n const clamped = Math.max(0, Math.min(1, ratio));\n const full = Math.abs(sweep) >= 360;\n\n // Outside the outer curve (grown by tolerance) can never hit.\n if (norm(p, rx + tolerance, ry + tolerance) > 1) return false;\n\n if (clamped > 0) {\n const inner = norm(p, Math.max(EPS, rx * clamped - tolerance), Math.max(EPS, ry * clamped - tolerance));\n if (inner < 1) return false;\n }\n\n if (full) return true;\n return withinSweep(Math.atan2(p.y / ry, p.x / rx) * (180 / Math.PI), startAngle, sweep, p, tolerance);\n}\n\n/** Normalised radius of `p` on an ellipse of half-axes `rx`/`ry` (1 = on the curve). */\nfunction norm(p: Vector2, rx: number, ry: number): number {\n return Math.hypot(p.x / rx, p.y / ry);\n}\n\n/** Whether `angleDeg` is in the arc `[startAngle, startAngle + sweep]` (negative sweeps handled), with `tolerance` converted to angular slack at the point's radius so grab-slop widens the wedge's straight edges too. */\nfunction withinSweep(\n angleDeg: number, startAngle: number, sweep: number,\n p: Vector2, tolerance: number,\n): boolean {\n const lo = sweep >= 0 ? startAngle : startAngle + sweep;\n const span = Math.abs(sweep);\n // Near the centre every angle is within tolerance of the wedge.\n const radius = Math.hypot(p.x, p.y);\n if (radius <= tolerance) return true;\n const slack = tolerance > 0 ? (tolerance / Math.max(radius, EPS)) * (180 / Math.PI) : 0;\n let delta = (angleDeg - lo) % 360;\n if (delta < 0) delta += 360;\n // Accept the wrap-around side within slack as well.\n return delta <= span + slack || delta >= 360 - slack;\n}\n\n/** Vertices of a regular polygon inscribed in `width` x `height`, y-up. The renderer starts at the top vertex and steps clockwise in canvas space; in y-up that is `+π/2` stepping negative. */\nexport function polygonVertices(width: number, height: number, sides: number): Vector2[] {\n const n = Math.max(3, Math.round(sides));\n const rx = width / 2;\n const ry = height / 2;\n const step = (2 * Math.PI) / n;\n const out: Vector2[] = [];\n for (let i = 0; i < n; i++) {\n const a = Math.PI / 2 - i * step;\n out.push({ x: rx * Math.cos(a), y: ry * Math.sin(a) });\n }\n return out;\n}\n\n/** Vertices of a star polygon: outer radius 1 alternating with inner radius `ratio`. */\nexport function polygramVertices(width: number, height: number, sides: number, ratio: number): Vector2[] {\n const n = Math.max(3, Math.round(sides));\n const r = Math.max(0, Math.min(1, ratio));\n const rx = width / 2;\n const ry = height / 2;\n const step = Math.PI / n;\n const out: Vector2[] = [];\n for (let i = 0; i < n * 2; i++) {\n const a = Math.PI / 2 - i * step;\n const k = i % 2 === 0 ? 1 : r;\n out.push({ x: rx * k * Math.cos(a), y: ry * k * Math.sin(a) });\n }\n return out;\n}\n\n/** Even-odd crossing test against a polygon, widened by `tolerance` (a point just outside an edge counts). `closed` also closes the last-to-first segment for the tolerance band. */\nfunction containsPolyline(p: Vector2, verts: readonly Vector2[], closed: boolean, tolerance: number): boolean {\n if (verts.length >= 3 && pointInPolygon(p, verts)) return true;\n return tolerance > 0 && nearPolyline(p, verts, closed, tolerance);\n}\n\n/** Even-odd crossing test against a closed polygon. No tolerance band. */\nexport function pointInPolygon(p: Vector2, verts: readonly Vector2[]): boolean {\n if (verts.length < 3) return false;\n let inside = false;\n for (let i = 0, j = verts.length - 1; i < verts.length; j = i++) {\n const a = verts[i];\n const b = verts[j];\n if ((a.y > p.y) !== (b.y > p.y) && p.x < ((b.x - a.x) * (p.y - a.y)) / (b.y - a.y) + a.x) {\n inside = !inside;\n }\n }\n return inside;\n}\n\n/** Whether `p` is within `tolerance` of any segment of the polyline. */\nexport function nearPolyline(p: Vector2, pts: readonly Vector2[], closed: boolean, tolerance: number): boolean {\n if (pts.length === 0) return false;\n if (pts.length === 1) return Math.hypot(p.x - pts[0].x, p.y - pts[0].y) <= tolerance;\n const last = closed ? pts.length : pts.length - 1;\n for (let i = 0; i < last; i++) {\n if (distanceToSegment(p, pts[i], pts[(i + 1) % pts.length]) <= tolerance) return true;\n }\n return false;\n}\n\n/** Shortest distance from `p` to the segment `a`–`b`. */\nexport function distanceToSegment(p: Vector2, a: Vector2, b: Vector2): number {\n const dx = b.x - a.x;\n const dy = b.y - a.y;\n const lenSq = dx * dx + dy * dy;\n if (lenSq <= EPS) return Math.hypot(p.x - a.x, p.y - a.y);\n let t = ((p.x - a.x) * dx + (p.y - a.y) * dy) / lenSq;\n t = t < 0 ? 0 : t > 1 ? 1 : t;\n return Math.hypot(p.x - (a.x + t * dx), p.y - (a.y + t * dy));\n}\n", "/**\n * The module is four representations and the steps between them: a prop value, the marked string `\"=4[g]+3\"`,\n * the AST per dialect (parse), and a prop binding (compile). The `=` marks a document prop as a formula, which\n * is recognition, not grammar (`=` is no dialect's character), so the walk strips it and the parser never sees\n * one.\n */\n\n/** Thrown for a formula that cannot be parsed or whose reference resolves to nothing. */\nexport class ExpressionError extends Error {\n readonly source: string;\n readonly position: number;\n readonly path?: string;\n\n constructor(message: string, source: string, position = -1, path?: string) {\n const where = position >= 0 ? ` (at character ${position + 1} of \"${source}\")` : ` (in \"${source}\")`;\n super(`${message}${where}${path ? ` at ${path}` : \"\"}`);\n this.name = \"ExpressionError\";\n this.source = source;\n this.position = position;\n this.path = path;\n }\n}\n\nexport type BinaryOp = \"+\" | \"-\" | \"*\" | \"/\" | \"%\" | \"^\";\n\n/** Public so a host can lint or rewrite one. */\nexport type ExpressionNode =\n | { kind: \"const\"; value: number }\n | { kind: \"ref\"; name: string }\n | { kind: \"unary\"; op: \"-\"; operand: ExpressionNode }\n | { kind: \"binary\"; op: BinaryOp; left: ExpressionNode; right: ExpressionNode }\n | { kind: \"call\"; name: string; args: ExpressionNode[] };\n\n/** Resolver-free, so it can be checked without a scene. */\nexport interface ParsedExpression {\n readonly source: string;\n readonly root: ExpressionNode;\n readonly refs: readonly string[];\n /**\n * True when the formula is exactly one reference. The document's compiled binding then returns the variable's\n * value untouched rather than coercing it to a number, which lets a variable hold a colour or `Vector2`. A\n * dialect with bare-identifier references sets it for a lone variable too (`\"x\"`), where it means nothing;\n * only the document's compiler reads it.\n */\n readonly passthrough: boolean;\n}\n\nexport interface FnArity {\n arity: [number, number];\n}\n\n/**\n * The grammar is fixed (precedence, implicit multiplication, right-associative `^`, scientific notation); what\n * a language may disagree about is here. That is how the document's `sin` is degrees and a function plot's\n * radians without two parsers.\n */\nexport interface ExpressionDialect {\n functions: Record<string, FnArity>;\n constants: Record<string, number>;\n /**\n * `\"bracket\"` is `[id]` and the only mode where `[` is a legal character; `\"bare\"` makes any identifier that\n * is not a call or a constant a reference.\n */\n refs: \"bracket\" | \"bare\";\n unknownName(name: string): string;\n}\n\n/** The read is what the compiled binding calls, once per evaluation of the prop it drives. */\nexport type VariableResolver = (name: string) => (() => unknown) | undefined;\n\nexport type CompiledValue =\n | { dynamic: false; value: unknown }\n | { dynamic: true; read: () => unknown };\n\nexport interface CompiledProps {\n /**\n * Handed to the node's constructor as-is. A bound prop is absent here rather than a placeholder: a constructor\n * reads raw props for things like a default size, and a placeholder would answer with a lie.\n */\n literal: Record<string, unknown>;\n bindings: Record<string, () => unknown>;\n hasBindings: boolean;\n}\n\nexport interface ExpressionSite {\n path: string;\n source: string;\n}\n", "/**\n * The one scanner and grammar, parameterized only by {@link ExpressionDialect}: what dialects genuinely\n * disagree about is a table (which functions exist, whether `sin` takes degrees, how a reference is spelled).\n * Having one avoids rules that agree where documented and diverge elsewhere (`1.2.3` scanned as a single token\n * becoming an invisible `NaN`; `\\r` rejected; no arity check on variadics).\n *\n * Precedence is ordinary arithmetic with right-associative `^` and implicit multiplication between adjacent\n * primaries, which makes `4[g]+3` read as written. `unary` sits above `power`, so `-2^2` is `-4`, and the\n * exponent parses as a unary so `2^3^2` is 512 and `2^-3` is legal.\n */\nimport { ExpressionError } from \"./types\";\nimport type { BinaryOp, ExpressionDialect, ExpressionNode, FnArity, ParsedExpression } from \"./types\";\n\nconst DEG = Math.PI / 180;\n\ninterface DocumentFn extends FnArity {\n apply(args: number[]): number;\n}\n\n/**\n * Deliberately small and closed: an expression is stored in a document and evaluated by whatever version of\n * the library opens it later, so every name is public contract. Trig is in degrees because every other angle\n * in the library is.\n */\nexport const DOCUMENT_FUNCTIONS: Record<string, DocumentFn> = {\n abs: { arity: [1, 1], apply: (a) => Math.abs(a[0]) },\n sign: { arity: [1, 1], apply: (a) => Math.sign(a[0]) },\n sqrt: { arity: [1, 1], apply: (a) => Math.sqrt(a[0]) },\n floor: { arity: [1, 1], apply: (a) => Math.floor(a[0]) },\n ceil: { arity: [1, 1], apply: (a) => Math.ceil(a[0]) },\n round: { arity: [1, 2], apply: (a) => (a.length > 1 && a[1] !== 0 ? Math.round(a[0] / a[1]) * a[1] : Math.round(a[0])) },\n min: { arity: [1, Infinity], apply: (a) => Math.min(...a) },\n max: { arity: [1, Infinity], apply: (a) => Math.max(...a) },\n clamp: { arity: [3, 3], apply: (a) => Math.min(Math.max(a[0], a[1]), a[2]) },\n mod: { arity: [2, 2], apply: (a) => ((a[0] % a[1]) + a[1]) % a[1] },\n pow: { arity: [2, 2], apply: (a) => a[0] ** a[1] },\n log: { arity: [1, 2], apply: (a) => (a.length > 1 ? Math.log(a[0]) / Math.log(a[1]) : Math.log(a[0])) },\n exp: { arity: [1, 1], apply: (a) => Math.exp(a[0]) },\n mix: { arity: [3, 3], apply: (a) => a[0] + (a[1] - a[0]) * a[2] },\n smoothstep: {\n arity: [3, 3],\n apply: (a) => {\n if (Number.isNaN(a[0]) || Number.isNaN(a[1]) || Number.isNaN(a[2])) return NaN;\n /** Equal edges: a step at the edge, like `step`, with no divide by zero. */\n if (a[0] === a[1]) return a[2] < a[0] ? 0 : 1;\n const t = Math.min(Math.max((a[2] - a[0]) / (a[1] - a[0]), 0), 1);\n return t * t * (3 - 2 * t);\n },\n },\n step: { arity: [2, 2], apply: (a) => (Number.isNaN(a[0]) || Number.isNaN(a[1]) ? NaN : a[1] < a[0] ? 0 : 1) },\n sin: { arity: [1, 1], apply: (a) => Math.sin(a[0] * DEG) },\n cos: { arity: [1, 1], apply: (a) => Math.cos(a[0] * DEG) },\n tan: { arity: [1, 1], apply: (a) => Math.tan(a[0] * DEG) },\n asin: { arity: [1, 1], apply: (a) => Math.asin(a[0]) / DEG },\n acos: { arity: [1, 1], apply: (a) => Math.acos(a[0]) / DEG },\n atan: { arity: [1, 1], apply: (a) => Math.atan(a[0]) / DEG },\n atan2: { arity: [2, 2], apply: (a) => Math.atan2(a[0], a[1]) / DEG },\n hypot: { arity: [2, Infinity], apply: (a) => Math.hypot(...a) },\n};\n\nconst DOCUMENT_CONSTANTS: Record<string, number> = {\n pi: Math.PI,\n tau: Math.PI * 2,\n e: Math.E,\n};\n\nexport const DOCUMENT_DIALECT: ExpressionDialect = {\n functions: DOCUMENT_FUNCTIONS,\n constants: DOCUMENT_CONSTANTS,\n refs: \"bracket\",\n unknownName: (name) =>\n `unknown name \"${name}\" — a variable is referenced as \"[${name}]\"; ` +\n `bare names are the constants ${sortedKeys(DOCUMENT_CONSTANTS).join(\", \")}`,\n};\n\nexport function sortedKeys(table: Record<string, unknown>): string[] {\n return Object.keys(table).sort();\n}\n\ntype TokenKind = \"number\" | \"ref\" | \"ident\" | \"op\" | \"(\" | \")\" | \",\" | \"end\";\n\ninterface Token {\n kind: TokenKind;\n text: string;\n value: number;\n pos: number;\n}\n\nconst OPERATORS = new Set([\"+\", \"-\", \"*\", \"/\", \"%\", \"^\"]);\n\nfunction isDigit(ch: string | undefined): boolean {\n return ch !== undefined && ch >= \"0\" && ch <= \"9\";\n}\n\nfunction tokenize(source: string, dialect: ExpressionDialect): Token[] {\n const tokens: Token[] = [];\n let i = 0;\n\n while (i < source.length) {\n const ch = source[i];\n\n if (ch === \" \" || ch === \"\\t\" || ch === \"\\n\" || ch === \"\\r\") {\n i++;\n continue;\n }\n\n if (isDigit(ch) || (ch === \".\" && isDigit(source[i + 1]))) {\n const start = i;\n while (isDigit(source[i])) i++;\n if (source[i] === \".\") {\n i++;\n while (isDigit(source[i])) i++;\n }\n if (source[i] === \"e\" || source[i] === \"E\") {\n const mark = i;\n i++;\n if (source[i] === \"+\" || source[i] === \"-\") i++;\n if (isDigit(source[i])) {\n while (isDigit(source[i])) i++;\n } else {\n /**\n * `2e` followed by something else is `2` times the identifier `e`, not a malformed exponent.\n */\n i = mark;\n }\n }\n /**\n * A second `.` ends a number that has already had one, so `1.2.3` is neither a single token (a silent `NaN`)\n * nor `1.2 * 0.3`.\n */\n if (source[i] === \".\") throw new ExpressionError('unexpected character \".\"', source, i);\n tokens.push({ kind: \"number\", text: \"\", value: Number(source.slice(start, i)), pos: start });\n continue;\n }\n\n /**\n * `[` is legal only where a reference is spelled with one, so a plot equation gets \"unexpected character\" here\n * rather than a message about variable references it has never heard of.\n */\n if (ch === \"[\" && dialect.refs === \"bracket\") {\n const start = i;\n const end = source.indexOf(\"]\", i + 1);\n if (end === -1) throw new ExpressionError(\"unclosed `[` — a variable reference is written `[id]`\", source, start);\n const name = source.slice(i + 1, end).trim();\n if (name.length === 0) throw new ExpressionError(\"empty variable reference `[]`\", source, start);\n if (name.includes(\"[\")) throw new ExpressionError(\"variable references cannot nest\", source, start);\n tokens.push({ kind: \"ref\", text: name, value: 0, pos: start });\n i = end + 1;\n continue;\n }\n\n if (/[A-Za-z_]/.test(ch)) {\n const start = i;\n while (i < source.length && /[A-Za-z0-9_]/.test(source[i])) i++;\n tokens.push({ kind: \"ident\", text: source.slice(start, i), value: 0, pos: start });\n continue;\n }\n\n if (OPERATORS.has(ch)) {\n tokens.push({ kind: \"op\", text: ch, value: 0, pos: i++ });\n continue;\n }\n if (ch === \"(\" || ch === \")\" || ch === \",\") {\n tokens.push({ kind: ch as TokenKind, text: ch, value: 0, pos: i++ });\n continue;\n }\n\n throw new ExpressionError(`unexpected character \"${ch}\"`, source, i);\n }\n\n tokens.push({ kind: \"end\", text: \"\", value: 0, pos: source.length });\n return tokens;\n}\n\n/** `source` is the formula alone: the walk that recognised it stripped the `=`, which is no grammar's. */\nexport function parse(source: string, dialect: ExpressionDialect = DOCUMENT_DIALECT): ParsedExpression {\n if (source.trim().length === 0) throw new ExpressionError(\"empty expression\", source);\n\n const tokens = tokenize(source, dialect);\n const refs: string[] = [];\n let index = 0;\n\n const peek = (): Token => tokens[index];\n const next = (): Token => tokens[index++];\n\n const addRef = (name: string): ExpressionNode => {\n if (!refs.includes(name)) refs.push(name);\n return { kind: \"ref\", name };\n };\n\n const startsPrimary = (t: Token): boolean =>\n t.kind === \"number\" || t.kind === \"ref\" || t.kind === \"ident\" || t.kind === \"(\";\n\n function parseAdditive(): ExpressionNode {\n let left = parseMultiplicative();\n for (;;) {\n const t = peek();\n if (t.kind === \"op\" && (t.text === \"+\" || t.text === \"-\")) {\n next();\n left = { kind: \"binary\", op: t.text, left, right: parseMultiplicative() };\n continue;\n }\n return left;\n }\n }\n\n function parseMultiplicative(): ExpressionNode {\n let left = parseUnary();\n for (;;) {\n const t = peek();\n if (t.kind === \"op\" && (t.text === \"*\" || t.text === \"/\" || t.text === \"%\")) {\n next();\n left = { kind: \"binary\", op: t.text as BinaryOp, left, right: parseUnary() };\n continue;\n }\n /** Juxtaposition is multiplication: `4[g]`, `2(x+1)`, `[a][b]`, `2pi`. */\n if (startsPrimary(t)) {\n left = { kind: \"binary\", op: \"*\", left, right: parseUnary() };\n continue;\n }\n return left;\n }\n }\n\n function parseUnary(): ExpressionNode {\n const t = peek();\n if (t.kind === \"op\" && (t.text === \"-\" || t.text === \"+\")) {\n next();\n const operand = parseUnary();\n return t.text === \"-\" ? { kind: \"unary\", op: \"-\", operand } : operand;\n }\n return parsePower();\n }\n\n function parsePower(): ExpressionNode {\n const base = parsePrimary();\n const t = peek();\n if (t.kind === \"op\" && t.text === \"^\") {\n next();\n /**\n * Right-associative, and binds tighter than unary minus on its right: `2^-1` is a half, not an error.\n */\n return { kind: \"binary\", op: \"^\", left: base, right: parseUnary() };\n }\n return base;\n }\n\n function parseCall(name: string, pos: number): ExpressionNode {\n /**\n * Own keys only: `toString(1)` must be an unknown function, not a lookup that finds `Object.prototype`'s.\n */\n const def = Object.hasOwn(dialect.functions, name) ? dialect.functions[name] : undefined;\n if (!def) {\n throw new ExpressionError(\n `unknown function \"${name}\" — available: ${sortedKeys(dialect.functions).join(\", \")}`,\n source, pos,\n );\n }\n const args: ExpressionNode[] = [];\n if (peek().kind !== \")\") {\n for (;;) {\n args.push(parseAdditive());\n if (peek().kind !== \",\") break;\n next();\n }\n }\n const close = next();\n if (close.kind !== \")\") throw new ExpressionError(`expected \\`)\\` closing ${name}(`, source, close.pos);\n\n const [min, max] = def.arity;\n if (args.length < min || args.length > max) {\n const want = max === Infinity ? `at least ${min}` : min === max ? `${min}` : `${min}–${max}`;\n // Singular only when `want` names the number one (`1`, `at least 1`), never for a range.\n const plural = (max === Infinity || min === max) && min === 1 ? \"\" : \"s\";\n throw new ExpressionError(\n `${name}() takes ${want} argument${plural}, got ${args.length}`,\n source, pos,\n );\n }\n return { kind: \"call\", name, args };\n }\n\n function parsePrimary(): ExpressionNode {\n const t = next();\n switch (t.kind) {\n case \"number\":\n return { kind: \"const\", value: t.value };\n case \"ref\":\n return addRef(t.text);\n case \"(\": {\n const inner = parseAdditive();\n const close = next();\n if (close.kind !== \")\") throw new ExpressionError(\"expected `)`\", source, close.pos);\n return inner;\n }\n case \"ident\": {\n if (peek().kind === \"(\") {\n next();\n return parseCall(t.text, t.pos);\n }\n /**\n * Folded here, before a bare identifier can become a reference, so a dialect's constant can never also be one\n * of its free variables.\n */\n const constant = Object.hasOwn(dialect.constants, t.text) ? dialect.constants[t.text] : undefined;\n if (constant !== undefined) return { kind: \"const\", value: constant };\n if (dialect.refs === \"bare\") return addRef(t.text);\n throw new ExpressionError(dialect.unknownName(t.text), source, t.pos);\n }\n default:\n throw new ExpressionError(\n t.kind === \"end\" ? \"expression ends early\" : `unexpected \"${t.text}\"`,\n source, t.pos,\n );\n }\n }\n\n const root = parseAdditive();\n const trailing = peek();\n if (trailing.kind !== \"end\") throw new ExpressionError(`unexpected \"${trailing.text}\"`, source, trailing.pos);\n\n return { source, root, refs, passthrough: root.kind === \"ref\" };\n}\n", "/**\n * The tree is compiled into closures once rather than walked per read, which matters when a hundred props read\n * the same variable every frame. `@motionscript/math` compiles the same AST its own way and shares the front\n * end, not this file.\n */\nimport { DOCUMENT_FUNCTIONS } from \"./parse\";\nimport { ExpressionError } from \"./types\";\nimport type { ExpressionNode, ParsedExpression, VariableResolver } from \"./types\";\n\n/**\n * A number is itself, a boolean `1` or `0`, a string what `Number` reads (`\"5\"` is 5, `\"0x10\"` is 16) unless\n * empty after trimming; anything else is `NaN`. Deliberate: a `width` of `NaN` is visible in the first frame,\n * where a silent `0` (what `Number(\"\")` gives) looks like a deliberate collapse and gets debugged as layout.\n */\nfunction toNumber(value: unknown): number {\n if (typeof value === \"number\") return value;\n if (typeof value === \"boolean\") return value ? 1 : 0;\n if (typeof value === \"string\") return value.trim() === \"\" ? NaN : Number(value);\n return NaN;\n}\n\n/**\n * `path` is where in the props bag the formula was written, so a reference to something undeclared names the\n * prop, not just the formula.\n */\nexport function compile(parsed: ParsedExpression, resolve: VariableResolver, path?: string): () => unknown {\n const readOf = (name: string): (() => unknown) => {\n const read = resolve(name);\n if (!read) {\n throw new ExpressionError(\n `\"${name}\" resolves to nothing in this document — a reference names a variable ` +\n `(declared with a \"variable\" command), a constant (a \\`constants\\` row), or another ` +\n `node's prop as \"[key.prop]\" (\\`key\\` on that node's row)`,\n parsed.source, -1, path,\n );\n }\n return read;\n };\n\n // A lone `[x]` hands the value over untouched: see `passthrough`.\n if (parsed.passthrough) return readOf((parsed.root as { name: string }).name);\n\n const emit = (node: ExpressionNode): (() => number) => {\n switch (node.kind) {\n case \"const\": {\n const { value } = node;\n return () => value;\n }\n case \"ref\": {\n const read = readOf(node.name);\n return () => toNumber(read());\n }\n case \"unary\": {\n const operand = emit(node.operand);\n return () => -operand();\n }\n case \"binary\": {\n const left = emit(node.left);\n const right = emit(node.right);\n switch (node.op) {\n case \"+\": return () => left() + right();\n case \"-\": return () => left() - right();\n case \"*\": return () => left() * right();\n case \"/\": return () => left() / right();\n case \"%\": return () => left() % right();\n case \"^\": return () => left() ** right();\n }\n break;\n }\n case \"call\": {\n const { apply } = DOCUMENT_FUNCTIONS[node.name];\n const args = node.args.map(emit);\n return () => apply(args.map((a) => a()));\n }\n }\n throw new ExpressionError(\"unsupported expression node\", parsed.source, -1, path);\n };\n\n return emit(parsed.root);\n}\n", "/**\n * Recognition, and the one walk over an authored prop value, parameterized by what to do with a string. `bind`\n * returns a replacement so containers are rebuilt around it; `collect` returns its input, so nothing is\n * rebuilt. Paths are carried so an `ExpressionError` from a formula nested inside a `fill` array names the\n * prop it was written in.\n */\nimport { compile } from \"./compile\";\nimport { parse } from \"./parse\";\nimport type { CompiledProps, CompiledValue, ExpressionSite, VariableResolver } from \"./types\";\n\n/**\n * `\"==\"` is the escape, so `\"==total\"` is the literal `\"=total\"`, and a bare `\"=\"` is just that string. Both\n * are handled by {@link unescape}, which every literal path runs values through.\n */\nexport function isSource(value: unknown): value is string {\n return typeof value === \"string\" && value.length > 1 && value[0] === \"=\" && value[1] !== \"=\";\n}\n\nexport function unescape(value: string): string {\n return value.startsWith(\"==\") ? value.slice(1) : value;\n}\n\ntype StringHandler = (source: string, path: string) => CompiledValue;\n\nconst STATIC = (value: unknown): CompiledValue => ({ dynamic: false, value });\n\n/**\n * An expression is recognised at any depth because half the props worth driving are compound (`{\"origin\":\n * {\"x\": \"=[g]\", \"y\": 0}}`). A container holding one is rebuilt on each recompute; one holding none is passed\n * through by identity, so a scene using no expressions allocates nothing and compares equal to its document.\n */\nfunction walk(value: unknown, path: string, onString: StringHandler): CompiledValue {\n if (typeof value === \"string\") return onString(value, path);\n\n if (Array.isArray(value)) {\n const parts = value.map((v, i) => walk(v, `${path}[${i}]`, onString));\n if (parts.some((p) => p.dynamic)) {\n return { dynamic: true, read: () => parts.map((p) => (p.dynamic ? p.read() : p.value)) };\n }\n /** Rebuild only if a leaf changed, so the common case keeps the document's own array. */\n const rebuilt = parts.map((p) => (p as { value: unknown }).value);\n return STATIC(rebuilt.every((v, i) => v === value[i]) ? value : rebuilt);\n }\n\n if (isPlainObject(value)) {\n const keys = Object.keys(value);\n const parts = keys.map((k) => walk(value[k], `${path}.${k}`, onString));\n if (parts.some((p) => p.dynamic)) {\n return {\n dynamic: true,\n read: () => {\n const out: Record<string, unknown> = {};\n keys.forEach((k, i) => {\n const part = parts[i];\n out[k] = part.dynamic ? part.read() : part.value;\n });\n return out;\n },\n };\n }\n if (!parts.some((p, i) => (p as { value: unknown }).value !== value[keys[i]])) return STATIC(value);\n const rebuilt: Record<string, unknown> = {};\n keys.forEach((k, i) => { rebuilt[k] = (parts[i] as { value: unknown }).value; });\n return STATIC(rebuilt);\n }\n\n return STATIC(value);\n}\n\nexport function bind(value: unknown, resolve: VariableResolver, path = \"props\"): CompiledValue {\n return walk(value, path, (source, at) =>\n isSource(source)\n /**\n * The `=` is the document's marker, not the grammar's: strip it here and the parser never sees one.\n */\n ? { dynamic: true, read: compile(parse(source.slice(1)), resolve, at) }\n : STATIC(unescape(source)));\n}\n\nexport function bindProps(\n props: Record<string, unknown> | undefined,\n resolve: VariableResolver,\n path = \"props\",\n): CompiledProps {\n const literal: Record<string, unknown> = {};\n const bindings: Record<string, () => unknown> = {};\n let hasBindings = false;\n\n for (const key of Object.keys(props ?? {})) {\n const compiled = bind(props![key], resolve, `${path}.${key}`);\n if (compiled.dynamic) {\n bindings[key] = compiled.read;\n hasBindings = true;\n } else {\n literal[key] = compiled.value;\n }\n }\n return { literal, bindings, hasBindings };\n}\n\n/** Used by the validator, to check each parses and names a declared variable before anything is built. */\nexport function collect(value: unknown, path: string): ExpressionSite[] {\n const out: ExpressionSite[] = [];\n walk(value, path, (source, at) => {\n if (isSource(source)) out.push({ path: at, source });\n return STATIC(source);\n });\n return out;\n}\n\n/** The grammar has no string literals, so a `[` is always a reference. */\nconst REF = /\\[([^[\\]]+)\\]/g;\n\n/**\n * `rename` sees each reference as written (`\"fade\"`, `\"card.x\"`) and returns its replacement, or `undefined`\n * to keep it; for a host moving a subtree between documents. A value with nothing to rewrite comes back by\n * identity, as with {@link bind}.\n */\nexport function renameRefs<T>(value: T, rename: (ref: string) => string | undefined): T {\n const result = walk(value, \"\", (source) => {\n if (!isSource(source)) return STATIC(source);\n return STATIC(source.replace(REF, (whole, ref: string) => {\n // The parser trims a reference's name (`[ g ]` reads `g`), so the callback sees it trimmed too.\n const next = rename(ref.trim());\n return next === undefined ? whole : `[${next}]`;\n }));\n });\n return (result as { value: T }).value;\n}\n\nfunction isPlainObject(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n", "/**\n * Every expression operation on one object, the shape `pathOps` has. Unlike `pathOps` it is not an\n * `AttributeOps`: an expression is not an attribute and has no `resolve`/`lerp` pair; only the naming\n * convention transfers. One grammar is behind it, with a dialect choosing the function library and reference\n * spelling, so `sin` is degrees here and radians in a plot.\n */\nimport { DOCUMENT_DIALECT, parse, sortedKeys } from \"./parse\";\nimport { compile } from \"./compile\";\nimport { bind, bindProps, collect, isSource, renameRefs, unescape } from \"./walk\";\nimport type {\n CompiledProps, CompiledValue, ExpressionDialect, ExpressionSite,\n ParsedExpression, VariableResolver,\n} from \"./types\";\n\nfunction parseSource(source: string, dialect: ExpressionDialect = DOCUMENT_DIALECT): ParsedExpression {\n return parse(isSource(source) ? source.slice(1) : source, dialect);\n}\n\nexport interface ExpressionOps {\n /** `\"==\"` escapes a literal string starting with `=`. */\n isSource(value: unknown): value is string;\n unescape(value: string): string;\n\n /** Parse a formula, with or without its leading `=`. */\n parse(source: string, dialect?: ExpressionDialect): ParsedExpression;\n tryParse(source: string, dialect?: ExpressionDialect): { expression: ParsedExpression } | { error: string };\n\n compile(parsed: ParsedExpression, resolve: VariableResolver, path?: string): () => unknown;\n bind(value: unknown, resolve: VariableResolver, path?: string): CompiledValue;\n bindProps(props: Record<string, unknown> | undefined, resolve: VariableResolver, path?: string): CompiledProps;\n\n collect(value: unknown, path: string): ExpressionSite[];\n /** `undefined` keeps one. */\n renameRefs<T>(value: T, rename: (ref: string) => string | undefined): T;\n functions(): string[];\n constants(): string[];\n readonly dialect: ExpressionDialect;\n}\n\nexport const expressionOps: ExpressionOps = {\n isSource,\n unescape,\n\n parse: parseSource,\n tryParse: (source, dialect) => {\n try {\n return { expression: parseSource(source, dialect) };\n } catch (e) {\n return { error: e instanceof Error ? e.message : String(e) };\n }\n },\n\n compile,\n bind,\n bindProps,\n\n collect,\n renameRefs,\n functions: () => sortedKeys(DOCUMENT_DIALECT.functions),\n constants: () => sortedKeys(DOCUMENT_DIALECT.constants),\n dialect: DOCUMENT_DIALECT,\n};\n", "import { expressionOps } from \"./expression/ops\";\nimport type { Registry } from \"./registry\";\n\n/**\n * Declared by a component spec's `renamed`, `deprecated` and `migrate`, applied to a row's props whenever one\n * is built, and callable by a host rewriting stored rows. Unlike a document migration there is no version to\n * go by: a row stored a year ago and one stored today pass through the same rules, so every rule must leave a\n * current value alone.\n */\nexport interface PropEvolution {\n /** Old key → the entry it became. A row setting both keeps the new one. */\n readonly renamed: Readonly<Record<string, string>>;\n /** Entry → why it is deprecated and what to use instead. It still works. */\n readonly deprecated: Readonly<Record<string, string>>;\n /**\n * Keyed by an old key from {@link renamed}, it converts only what was stored under that key (a unit change\n * rides on a rename); keyed by an entry, it runs on every stored value and must hand a current one back\n * unchanged. `undefined` drops the prop back to its default.\n */\n readonly migrate: Readonly<Record<string, (value: unknown) => unknown>>;\n}\n\nexport interface PropNote {\n prop: string;\n message: string;\n}\n\nexport interface PropMigration {\n props: Record<string, unknown>;\n changes: PropNote[];\n deprecated: PropNote[];\n}\n\nconst PROP_EVOLUTION = Symbol(\"propEvolution\");\n\n/** @internal Record `evolution` on a node class; a component factory does this for its generated class. */\nexport function declarePropEvolution(ctor: abstract new (...args: never[]) => object, evolution: PropEvolution): void {\n (ctor.prototype as Record<symbol, unknown>)[PROP_EVOLUTION] = evolution;\n}\n\n/** @internal What {@link declarePropEvolution} recorded on this exact class. */\nexport function propEvolutionOf(ctor: abstract new (...args: never[]) => object): PropEvolution | undefined {\n const proto = ctor.prototype as Record<symbol, unknown> | undefined;\n if (!proto || !Object.prototype.hasOwnProperty.call(proto, PROP_EVOLUTION)) return undefined;\n return proto[PROP_EVOLUTION] as PropEvolution;\n}\n\n/**\n * A type this registry does not know, or one that never changed, hands `props` back as it is. Applies to a\n * `to`/`set` command's args too, which are a props diff. An expression is moved by a rename but handed to no\n * value hook: a formula's result cannot be converted by rewriting it, so it is noted and left as written.\n */\nexport function migrateNodeProps(registry: Registry, type: string, props: Record<string, unknown>): PropMigration {\n const ctor = registry.node(type)?.ctor;\n const evolution = ctor ? propEvolutionOf(ctor) : undefined;\n return evolution ? applyPropEvolution(evolution, props) : { props, changes: [], deprecated: [] };\n}\n\n/** @internal {@link migrateNodeProps} once the type's rules are in hand. */\nexport function applyPropEvolution(evolution: PropEvolution, props: Record<string, unknown>): PropMigration {\n const changes: PropNote[] = [];\n const deprecated: PropNote[] = [];\n let out: Record<string, unknown> | null = null;\n const write = () => (out ??= { ...props });\n const isExpression = (value: unknown) => expressionOps.collect(value, \"\").length > 0;\n\n const convert = (key: string, value: unknown, at: string): unknown => {\n const hook = evolution.migrate[key];\n if (!hook || value === undefined) return value;\n if (isExpression(value)) {\n changes.push({ prop: at, message: `\"${at}\" is an expression, so its value was left as written.` });\n return value;\n }\n return hook(value);\n };\n\n for (const [from, to] of Object.entries(evolution.renamed)) {\n if (!Object.hasOwn(props, from)) continue;\n const target = write();\n const value = convert(from, props[from], from);\n delete target[from];\n if (props[to] !== undefined) {\n changes.push({ prop: from, message: `\"${from}\" was renamed \"${to}\", which the row also sets; the old value was dropped.` });\n continue;\n }\n if (value === undefined) delete target[to];\n else target[to] = value;\n changes.push({ prop: from, message: `\"${from}\" was renamed \"${to}\".` });\n }\n\n for (const key of Object.keys(evolution.migrate)) {\n if (Object.hasOwn(evolution.renamed, key)) continue;\n const current = (out ?? props)[key];\n if (current === undefined) continue;\n const next = convert(key, current, key);\n if (next === current) continue;\n const target = write();\n if (next === undefined) delete target[key];\n else target[key] = next;\n changes.push({ prop: key, message: next === undefined ? `\"${key}\" was dropped back to its default.` : `\"${key}\" was migrated.` });\n }\n\n for (const [key, message] of Object.entries(evolution.deprecated)) {\n if ((out ?? props)[key] !== undefined) deprecated.push({ prop: key, message });\n }\n return { props: out ?? props, changes, deprecated };\n}\n", "import { EMPTY_TEXT_STYLE, TEXT_SHAPING_KEYS, textOps } from \"@/attributes/text/ops\";\nimport type { ResolvedTextSpan, TextShapingKey, TextStyle } from \"@/attributes/text/types\";\nimport { Graphics2D, type GraphicsOp, type GraphicsShapeOp } from \"./graphics2d\";\n\ntype TextOp = Extract<GraphicsShapeOp, { kind: \"text\" }>;\ntype RichTextOp = Extract<GraphicsShapeOp, { kind: \"richText\" }>;\n\n/** The span-level half of {@link TEXT_SHAPING_KEYS}: a `richText` op carries typography per span, so defaults are filled span by span, except `lineHeight`/`textAlign`, which lay out the whole block and live on the op. */\nconst SPAN_KEYS = [\n 'fontFamily', 'fontSize', 'fontWeight', 'fontStyle', 'letterSpacing',\n] as const satisfies readonly TextShapingKey[];\n\n/** The `richText` op's own layout keys — the ones that aren't per-span. */\nconst RICHTEXT_BLOCK_KEYS = [\n 'lineHeight', 'textAlign',\n] as const satisfies readonly TextShapingKey[];\n\n/** `graphics` with `style` filled into every `text`/`richText` op that left a shaping field unset: the drawn-text half of `<DefaultTextStyle>`. A `Text` node inherits through the context channel at bind; a raw `Graphics2D` has no node to bind, so it inherits here at draw time from the scope it is drawn in. Called from `RenderContext2D.draw`, so custom `ctx.draw(...)`, offscreen rasterization and the precomp asset walk see the same resolved ops (an inherited font actually *loads*). A key is unset only when `undefined`: an op naming a value wins. Returns `graphics` itself when nothing changes. */\nexport function applyGraphicsTextDefaults(graphics: Graphics2D, style: TextStyle): Graphics2D {\n // Not gated on `style` alone: an op naming a `variant` has something to inherit even in a scope that sets nothing. The lazy copy below keeps the walk cheap.\n const ambient = hasShapingDefaults(style) ? style : EMPTY_TEXT_STYLE;\n\n const ops = graphics.ops();\n let next: GraphicsOp[] | null = null;\n for (let i = 0; i < ops.length; i++) {\n const op = ops[i];\n if (op.kind !== \"text\" && op.kind !== \"richText\") continue;\n const effective = effectiveStyle(op.state.variant, ambient);\n if (!hasShapingDefaults(effective)) continue;\n const patched = op.kind === \"text\"\n ? patchText(op, effective)\n : patchRichText(op, effective);\n if (!patched) continue;\n // Copy lazily: an op list with nothing to fill in keeps its identity, so a fully specified Text node allocates nothing.\n if (!next) next = ops.slice();\n next[i] = patched;\n }\n return next ? graphics._withOps(next) : graphics;\n}\n\n/** The defaults one op inherits: its `variant`'s preset laid over the enclosing scope's (explicit beats variant beats inherited `<DefaultTextStyle>`). Merged here, not by the caller, because the ambient scope is per subtree while a variant is per op, so they can't be flattened before the walk. */\nfunction effectiveStyle(variant: string | undefined, ambient: TextStyle): TextStyle {\n return textOps.mergeStyle(ambient, variant ? textOps.preset(variant) : undefined);\n}\n\n/** Does `style` set anything a drawn text op could inherit? */\nfunction hasShapingDefaults(style: TextStyle): boolean {\n for (const key of TEXT_SHAPING_KEYS) {\n if (style[key] !== undefined) return true;\n }\n return false;\n}\n\nfunction patchText(op: TextOp, style: TextStyle): TextOp | null {\n const state = fillUnset(op.state, style, TEXT_SHAPING_KEYS);\n return state ? { kind: \"text\", state: state as TextOp[\"state\"] } : null;\n}\n\nfunction patchRichText(op: RichTextOp, style: TextStyle): RichTextOp | null {\n let state = fillUnset(op.state, style, RICHTEXT_BLOCK_KEYS);\n const spans = patchSpans(op.state.spans, style);\n if (spans) state = { ...(state ?? op.state), spans };\n return state ? { kind: \"richText\", state: state as RichTextOp[\"state\"] } : null;\n}\n\n/** The spans with defaults filled in, or `null` when none needed any. */\nfunction patchSpans(\n spans: ResolvedTextSpan[] | undefined,\n style: TextStyle,\n): ResolvedTextSpan[] | null {\n if (!spans || spans.length === 0) return null;\n // A span has no autofit mode (it is sized by its block), so an inherited `'autofit'` is skipped rather than written through as a bad number.\n const spanStyle = style.fontSize === \"autofit\" ? { ...style, fontSize: undefined } : style;\n let next: ResolvedTextSpan[] | null = null;\n for (let i = 0; i < spans.length; i++) {\n const patched = fillUnset(spans[i], spanStyle, SPAN_KEYS);\n if (patched) (next ??= spans.slice())[i] = patched as unknown as ResolvedTextSpan;\n }\n return next;\n}\n\n/** A copy of `target` with each of `keys` it leaves `undefined` taken from `style`, or `null` when none needed filling. */\nfunction fillUnset(target: object, style: TextStyle, keys: readonly TextShapingKey[]): Record<string, unknown> | null {\n const current = target as Record<string, unknown>;\n let out: Record<string, unknown> | null = null;\n for (const key of keys) {\n if (current[key] !== undefined) continue;\n const value = style[key];\n if (value === undefined) continue;\n (out ??= { ...current })[key] = value;\n }\n return out;\n}\n", "import { Graphics2D } from \"./graphics2d\";\nimport type { Clip } from \"./clip\";\nimport type { RenderIssue } from \"./render-issue\";\nimport type { TransformState } from \"./descriptors/transform\";\nimport type { FontStyle, TextStyle } from \"@/attributes/text/types\";\nimport type { Size2D } from \"@/attributes/layout/size\";\nimport type { Vector2 } from \"@/attributes/layout/vector2\";\nimport type { MaskOptions } from \"@/attributes/mask/mask\";\nimport type { BooleanOperation } from \"@/attributes/mask/boolean\";\nimport { TextState } from \"./descriptors/text\";\nimport { TextBlockLayout } from \"./text-layout\";\nimport { EMPTY_TEXT_STYLE, textOps } from \"@/attributes/text/ops\";\nimport { applyGraphicsTextDefaults } from \"./text-defaults\";\nimport type { NodeRenderState, RasterizedSurface, RenderContext2D, RenderPass2D, SpaceRects, EffectTarget } from \"./render-context2d\";\nimport type { NodeEffect } from \"@/attributes/shape/effects/union\";\n\n/** The base every {@link RenderContext2D} backend extends. Owns what is the same whatever is rasterized (text-default stack, node scope stack, disposal) plus the host-facing half (`execute`, `screenshot`, `unmount`) the interface leaves out. **`draw` is final by convention**: it resolves ambient text defaults onto the op list and hands it to {@link drawGraphics}; owning that step here keeps the real renderer and the precomp asset walk agreeing on which font an under-specified `text` op uses. */\nexport abstract class CanvasRenderContext2D implements RenderPass2D {\n abstract measureText(text: string, fontSize: number, fontFamily: string, fontWeight?: number, letterSpacing?: number, fontStyle?: FontStyle): Size2D;\n\n // Inherited text-style defaults (see RenderContext2D.pushTextStyle).\n\n /** Defaults for the current draw scope, innermost last. Each entry is already merged onto the one below (see {@link pushTextStyle}), so the top is the effective style. */\n private readonly textStyleStack: TextStyle[] = [];\n\n pushTextStyle(style: TextStyle | null): void {\n this.textStyleStack.push(style === null ? EMPTY_TEXT_STYLE : textOps.mergeStyle(this.defaultTextStyle, style));\n }\n\n popTextStyle(): void {\n this.textStyleStack.pop();\n }\n\n /** The defaults in effect: innermost {@link pushTextStyle} scope, else the project's `theme.typography.default`. Carries all ten {@link TEXT_STYLE_KEYS}, but only shaping ones reach a `Graphics2D` op (see `TEXT_SHAPING_KEYS`). */\n get defaultTextStyle(): TextStyle {\n return this.textStyleStack[this.textStyleStack.length - 1] ?? textOps.preset(\"default\");\n }\n\n /** See {@link RenderContext2D.draw}. Final by convention — override {@link drawGraphics}. */\n draw(graphics: Graphics2D): void {\n this.drawGraphics(applyGraphicsTextDefaults(graphics, this.defaultTextStyle));\n }\n\n /** Paint a `Graphics2D` whose text ops have already been resolved against the\n * ambient defaults. Backends implement this instead of {@link draw}. */\n protected abstract drawGraphics(graphics: Graphics2D): void;\n\n /** `null` by default, so a backend that never reports glyph positions only gives up on-canvas text editing. See {@link RenderContext2D.layoutTextBlock}. */\n layoutTextBlock(state: Partial<TextState>): TextBlockLayout | null {\n return null;\n }\n\n protected currentNodeStack: string[] = [];\n\n protected currentNodeId(): string {\n if (this.currentNodeStack.length === 0) {\n throw new Error(\"No current node in context\");\n }\n\n return this.currentNodeStack[this.currentNodeStack.length - 1];\n }\n\n /** Remove all renderer-side resources for the current node (called on unmount). */\n abstract unmount(): void;\n\n private _disposed = false;\n /** `true` after `dispose()` — the context must not be used after this point. */\n isDisposed(): boolean {\n return this._disposed;\n }\n dispose(): void {\n this._disposed = true;\n }\n\n /** Runs `callback`, which issues shape/paint calls, then flushes to the render target. A throwing callback still throws, and the next pass starts clean. */\n abstract execute(callback: () => void): void;\n /** What the frames since the last call drew without failing but not as the document says (a missing blend mode, a shader that doesn't compile, a lost GPU device), once per kind, feature and node; a bare string is a `shader` issue. Playback reports them as render errors, export hands them to `onIssue`. */\n takeRenderIssues(): Array<RenderIssue | string> {\n return [];\n }\n /** Capture the current frame as a base-64 PNG data URL, or `undefined` if unsupported. */\n abstract screenshot(): string | undefined;\n\n abstract transform(state: Partial<TransformState>): RenderContext2D;\n\n abstract beginBoolean(op: BooleanOperation): void;\n abstract endBoolean(): void;\n\n abstract beginMask(options?: MaskOptions): void;\n abstract applyMask(): void;\n abstract endMask(): void;\n\n abstract beginClip(clip: Clip): void;\n abstract endClip(): void;\n\n /** See {@link RenderContext2D.beginEffects}. No-op by default. */\n beginEffects(effects: NodeEffect[], target: EffectTarget, width: number, height: number): void { }\n endEffects(): void { }\n\n /** See {@link RenderContext2D.rasterize}. Returns `null` by default. */\n rasterize(\n width: number,\n height: number,\n draw: () => void,\n pixelRatio?: number,\n ): RasterizedSurface | null {\n return null;\n }\n\n abstract beginCamera(viewport: { x: number; y: number; width: number; height: number }, lookAt: Vector2, zoom: number, heading: number): void;\n abstract endCamera(): void;\n\n /** Render state per node on the draw stack, parallel to `currentNodeStack`, so `space: 'parent'` fills can resolve their reference rect and motion effects read the node's velocity. */\n protected renderStateStack: NodeRenderState[] = [];\n\n readonly readsSpaceRects: boolean = true;\n\n readonly drawsVisibleOnly: boolean = true;\n\n begin(state: NodeRenderState): void {\n this.currentNodeStack.push(state.id);\n this.renderStateStack.push(state);\n }\n\n end(): void {\n this.currentNodeStack.pop();\n this.renderStateStack.pop();\n }\n\n /** Reference rects for the node currently being drawn (parent / viewport). */\n protected currentSpaceRects(): SpaceRects {\n return this.renderStateStack[this.renderStateStack.length - 1]?.rects ?? {};\n }\n\n /** Full render state (incl. velocity) for the node currently being drawn, if any. */\n protected currentRenderState(): NodeRenderState | undefined {\n return this.renderStateStack[this.renderStateStack.length - 1];\n }\n\n /** Closes every node and text-style scope still open; a backend calls it when a pass ends so a pass that threw can't leave the next inside its scopes. */\n protected _resetScopes(): void {\n this.textStyleStack.length = 0;\n this.currentNodeStack.length = 0;\n this.renderStateStack.length = 0;\n }\n}\n", "import type { RenderContext2D } from \"./render-context2d\";\nimport { CanvasRenderContext2D } from \"./canvas-render-context2d\";\nimport { Graphics2D } from \"./graphics2d\";\nimport { Clip } from \"./clip\";\nimport { TransformState } from \"./descriptors/transform\";\nimport { BooleanOperation } from \"@/attributes/mask/boolean\";\nimport { MaskOptions } from \"@/attributes/mask/mask\";\nimport { Vector2 } from \"@/attributes/layout/vector2\";\nimport type { Size2D } from \"@/attributes/layout/size\";\n\n/** Shared, since nothing here measures anything and no caller mutates it. */\nconst ZERO_SIZE: Size2D = { width: 0, height: 0 };\n\n/** A `RenderContext2D` that runs a render pass and rasterizes nothing: every hook is inert but the *walk* is real (`render()` recurses, `draw()` applies text defaults, a {@link rasterize} subtree is entered), so it exercises the traversal, ordering and skip rules a backend would see. For tests and hosts driving structure without pixels. Deliberately **not** an asset-discovery pass: nodes declare assets (see `Node.declareAssets`), and collecting them from what a walk paints is the coupling that made a font impossible to load before the layout that named it. */\nexport class NullRenderContext extends CanvasRenderContext2D {\n /** Parent-space rects cost a resolution pass per node and nothing here reads them; this walk is about which nodes are visited, not where they land. */\n override readonly readsSpaceRects = false;\n\n protected drawGraphics(graphics: Graphics2D): void { }\n\n measureText(): Size2D {\n return ZERO_SIZE;\n }\n\n unmount(): void { }\n\n execute(callback: () => void): void {\n callback();\n }\n\n screenshot(): string | undefined {\n return undefined;\n }\n\n /** Nothing is rasterized, but the subtree is still walked. */\n override rasterize(width: number, height: number, draw: () => void): null {\n draw();\n return null;\n }\n\n transform(state: Partial<TransformState>): RenderContext2D {\n return this;\n }\n\n beginBoolean(op: BooleanOperation): void { }\n endBoolean(): void { }\n\n beginMask(_options?: MaskOptions): void { }\n applyMask(): void { }\n endMask(): void { }\n\n beginClip(clip: Clip): void { }\n endClip(): void { }\n\n beginCamera(\n _viewport: { x: number; y: number; width: number; height: number },\n _centerOn: Vector2,\n _zoom: number,\n _heading: number,\n ): void { }\n endCamera(): void { }\n}\n", "import { Clip } from \"@/render/clip\";\nimport type { Graphics2D } from \"@/render/graphics2d\";\n\n/** The outline a shape's ops describe, as a clip: what `clip: true` cuts children to and picking tests against. */\nexport function clipOf(shape: Graphics2D): Clip {\n const clip = new Clip();\n for (const op of shape.ops()) {\n switch (op.kind) {\n case \"rect\": clip.rect(op.state); break;\n case \"ellipse\": clip.ellipse(op.state); break;\n case \"path\": clip.path(op.state); break;\n case \"line\": clip.line(op.state); break;\n case \"polygon\": clip.polygon(op.state); break;\n case \"polygram\": clip.polygram(op.state); break;\n case \"cut\": clip.cut(); break;\n default: break;\n }\n }\n return clip;\n}\n", "import type { Node } from \"@/components/trees/node/node\";\nimport { getCommandMeta } from \"@/tween/command-decorator\";\nimport { driveCommand, settles, settling, type Command, type CommandArgs } from \"@/tween/command\";\nimport type { EasingFunction } from \"@/tween/ease/type\";\nimport type { NodeView, Piece, PieceData, SoundOptions, Timeline } from \"@/components/factory/api\";\nimport type { ComponentHost } from \"@/components/factory/views\";\n\nconst piece = (data: PieceData): Piece => ({ _piece: data });\n\n/** What a command is handed for one placement: its args and timing, and the builders for its pieces. */\nexport function makeTimeline(args: object, duration: number, easing: EasingFunction | undefined, node: NodeView): Timeline<any, any> {\n return {\n args,\n duration,\n easing,\n node,\n tween: (targets) => piece({ kind: \"tween\", targets: targets as Record<string, unknown> }),\n animate: (frame, options) => piece({ kind: \"animate\", frame: frame as (t: number) => Record<string, unknown>, eased: options?.eased !== false }),\n ease: (t) => (easing ? easing(t) : t),\n sound: (src, options) => piece({ kind: \"sound\", src, options: options ?? {} }),\n wait: (seconds) => piece({ kind: \"wait\", seconds }),\n together: (pieces) => piece({ kind: \"together\", pieces }),\n sequence: (pieces) => piece({ kind: \"sequence\", pieces }),\n stagger: (pieces, options) => piece({ kind: \"stagger\", pieces, overlap: options?.overlap ?? 0 }),\n };\n}\n\n/** A sound a command plays, in seconds from the command's start; `until` absent plays to its own end. */\nexport interface CommandSound {\n readonly at: number;\n readonly until: number | undefined;\n readonly src: string;\n readonly options: SoundOptions;\n}\n\n/** A built piece: how long it lasts, the frame it writes `elapsed` seconds in, whether that only tweens slots, and its sounds. */\ninterface Timed {\n readonly duration: number;\n readonly settles: boolean;\n readonly sounds: readonly CommandSound[];\n apply(elapsed: number): void;\n}\n\nconst SILENT: readonly CommandSound[] = [];\n\n/**\n * A leaf, built and run to its end at once, so the piece after it reads where\n * it finished — the rule the timeline already keeps between whole commands.\n */\nfunction leaf(command: Command<Record<string, unknown>>, duration: number, pure = true): Timed {\n command.at(1);\n return { duration, settles: pure, sounds: SILENT, apply: (elapsed) => command.at(duration > 0 ? elapsed / duration : 1) };\n}\n\nfunction placed(parts: readonly Timed[], offsets: readonly number[]): Timed {\n const duration = parts.reduce((max, part, i) => Math.max(max, offsets[i] + part.duration), 0);\n return {\n duration,\n settles: parts.every((part) => part.settles),\n sounds: parts.flatMap((part, i) => part.sounds.map((s) => ({\n ...s, at: s.at + offsets[i], until: s.until === undefined ? undefined : s.until + offsets[i],\n }))),\n apply(elapsed) {\n // A part that hasn't started writes nothing: what came before it stands.\n for (let i = 0; i < parts.length; i++) {\n if (elapsed < offsets[i]) continue;\n parts[i].apply(Math.min(elapsed - offsets[i], parts[i].duration));\n }\n },\n };\n}\n\n/** A piece built against the tree as the pieces before it left it, spread over `duration`. */\nfunction timedOf(host: ComponentHost, p: Piece, duration: number, easing: EasingFunction | undefined): Timed {\n const data = p._piece;\n switch (data.kind) {\n case \"tween\":\n return leaf(host.to({ data: data.targets, duration, easing }) as Command<Record<string, unknown>>, duration);\n case \"animate\":\n return leaf(host._animate(data.frame, duration, data.eased ? easing : undefined) as Command<Record<string, unknown>>, duration);\n case \"child\":\n return leaf((data.node as Node).to({ data: data.targets, duration, easing }) as Command<Record<string, unknown>>, duration);\n case \"run\": {\n // Any command of the child's, so it settles only if that one does.\n const run = runCommand(data.node as Node, data.name, data.args, duration, easing);\n return leaf(run, duration, settles(run));\n }\n case \"wait\":\n return { duration: data.seconds, settles: true, sounds: SILENT, apply: () => { } };\n case \"sound\":\n // Scheduled ahead of time, not written per frame: the clip's audio reads it off the built command.\n return { duration: 0, settles: true, sounds: data.src ? [{ at: 0, until: undefined, src: data.src, options: data.options }] : SILENT, apply: () => { } };\n case \"together\": {\n const parts = data.pieces.map((part) => timedOf(host, part, duration, easing));\n return placed(parts, parts.map(() => 0));\n }\n case \"sequence\": {\n // Untimed pieces share what fixed `wait`s leave of the span.\n const fixed = data.pieces.reduce((sum, part) => sum + (part._piece.kind === \"wait\" ? part._piece.seconds : 0), 0);\n const flexible = data.pieces.filter((part) => part._piece.kind !== \"wait\").length;\n const each = flexible > 0 ? Math.max(0, duration - fixed) / flexible : 0;\n const parts: Timed[] = [];\n const offsets: number[] = [];\n let cursor = 0;\n for (const part of data.pieces) {\n const timed = timedOf(host, part, each, easing);\n parts.push(timed);\n offsets.push(cursor);\n cursor += timed.duration;\n }\n return placed(parts, offsets);\n }\n case \"stagger\": {\n const n = data.pieces.length;\n if (n === 0) return { duration, settles: true, sounds: SILENT, apply: () => { } };\n const step = 1 - Math.min(1, Math.max(0, data.overlap));\n // n pieces, each `each` long, started `each * step` apart, span the command exactly.\n const each = duration / (1 + (n - 1) * step);\n const parts = data.pieces.map((part) => timedOf(host, part, each, easing));\n return placed(parts, parts.map((_, i) => i * each * step));\n }\n }\n}\n\nfunction runCommand(node: Node, name: string, args: object | undefined, duration: number, easing: EasingFunction | undefined): Command<Record<string, unknown>> {\n const meta = getCommandMeta(node).find((m) => m.key === name);\n const method = meta ? (node as unknown as Record<string, unknown>)[meta.method] : undefined;\n if (typeof method !== \"function\") throw new Error(`${node.className} has no command \"${name}\".`);\n const built = (method as (args: CommandArgs) => unknown).call(node, { data: (args ?? {}) as Record<string, unknown>, duration, easing });\n if (!built || typeof built !== \"object\" || !(\"at\" in built)) throw new Error(`${node.className}.${name} did not return a command.`);\n return built as Command<Record<string, unknown>>;\n}\n\nconst SOUNDS = new WeakMap<object, { readonly host: Node; readonly sounds: readonly CommandSound[] }>();\n\n/** The sounds a built command plays, and the node playing them. */\nexport function commandSoundsOf(command: object): { readonly host: Node; readonly sounds: readonly CommandSound[] } | undefined {\n return SOUNDS.get(command);\n}\n\n/** The command a component's function returned, as the timeline places it. */\nexport function commandOf(host: ComponentHost, p: Piece, duration: number, easing: EasingFunction | undefined): Command<Record<string, unknown>> {\n // A lone tween is the engine's own `to`, exactly as a class's command would return it.\n if (p._piece.kind === \"tween\") return settling(host.to({ data: p._piece.targets, duration, easing }) as Command<Record<string, unknown>>);\n const timed = timedOf(host, p, duration, easing);\n const command = driveCommand(duration, (t) => timed.apply(t * duration)) as unknown as Command<Record<string, unknown>>;\n // A sound is cut when its command ends; a command with no length lets it play out.\n const sounds = timed.sounds.map((s) => (s.until === undefined && duration > 0 ? { ...s, until: duration } : s));\n if (sounds.length > 0) SOUNDS.set(command, { host, sounds });\n return timed.settles ? settling(command) : command;\n}\n", "import type { PropertyEditor } from \"@/attributes/properties/decorator\";\nimport type { TweenFn } from \"@/props/host\";\nimport type { Context } from \"@/util/context\";\n\n/**\n * Where an entry takes its value when the author left it unset: from the\n * context its ancestors provide (`use`), given what was set (`given`). Read on\n * the node's first attach. `undefined` keeps the default.\n */\nexport type Inherit = (use: <T>(context: Context<T>) => T, given: Readonly<Record<string, unknown>>) => unknown;\n\n/** What a state entry is at runtime: the `property` options it lowers onto, plus whether it is private. */\nexport interface TypeDef {\n /** Loose author form; mapped on construction. A function here is a factory, called once per node. */\n readonly default: unknown;\n readonly mapper?: (ext: any, prev?: any) => unknown;\n readonly tween?: TweenFn<any>;\n readonly editor: PropertyEditor;\n readonly private: boolean;\n readonly inherit?: Inherit;\n}\n\nexport const TYPE_DEF = \"_def\";\n\nexport function isTypeLike(value: unknown): value is { readonly _def: TypeDef } {\n return (typeof value === \"object\" || typeof value === \"function\") && value !== null && TYPE_DEF in value;\n}\n\n/** A literal state entry (`value: 0`, `label: 'Hi'`, `on: true`) as the Type it stands for. */\nexport function defOf(entry: unknown): TypeDef {\n if (isTypeLike(entry)) return entry._def;\n switch (typeof entry) {\n case \"number\": return { default: entry, editor: { kind: \"number\" }, private: false };\n case \"string\": return { default: entry, editor: { kind: \"text\" }, private: false };\n case \"boolean\": return { default: entry, editor: { kind: \"boolean\" }, private: false };\n default: throw new TypeError(`A state entry is a Types.* value, a number, a string or a boolean; got ${String(entry)}.`);\n }\n}\n", "import type { Size2D } from \"@/attributes/layout/size\";\nimport type { SizeConstraints } from \"@/layout/constraints\";\nimport type { Node2D, CameraScope } from \"@/components/trees/2d/node2d\";\nimport type { Node } from \"@/components/trees/node/node\";\nimport type { Graphics2D } from \"@/render/graphics2d\";\nimport type { MeasureContext2D } from \"@/render/measure-context\";\nimport type { RenderPass2D } from \"@/render/render-context2d\";\nimport type { Clip } from \"@/render/clip\";\nimport { NullRenderContext } from \"@/render/null-render-context\";\nimport { Graphics2D as GraphicsClass } from \"@/render/graphics2d\";\nimport { frameIn, Node2D as Node2DClass } from \"@/components/trees/2d/node2d\";\nimport { Node3D } from \"@/components/trees/three/node3d\";\nimport { Scene3D } from \"@/render3d/scene3d\";\nimport type { BooleanOperation } from \"@/attributes/mask/boolean\";\nimport type { MaskOptions } from \"@/attributes/mask/mask\";\nimport type { ChildBoundsMode } from \"@/components/trees/2d/group-bounds\";\nimport type { SpaceCamera } from \"@/attributes/layout/space3d\";\nimport type { TextStyle } from \"@/attributes/text/types\";\nimport type { MergePaint, ChildView, Clock, Component, Element, FontSpec, Max, Measurer, NodeFrame, NodeView, Piece, RenderContext2D } from \"@/components/factory/api\";\nimport { clipOf } from \"@/components/factory/clip-of\";\nimport type { PropHost } from \"@/props/host\";\nimport type { PropLayout } from \"@/props/layout\";\n\n/**\n * What a render did with its children beyond drawing them: composited them\n * (the ink bounds that leaves), looked at them through a camera, or stood them\n * in a 2.5D space. Picking and the space machinery read it between frames.\n */\nexport interface Composite {\n readonly bounds?: ChildBoundsMode;\n readonly camera?: CameraScope;\n readonly space?: SpaceCamera;\n /** The scene its 3D children were rendered into: what picking projects through. */\n readonly scene?: Scene3D;\n}\n\n/** The node a view stands for: how the engine's own modules (`Paint`, `Flow`) reach past the public surface. */\nexport const NODE = Symbol(\"componentNode\");\n\n/** What a generated node exposes to its views and modules. Never part of the authoring surface. */\nexport interface ComponentHost extends Node2D {\n _renderOwnChildren(pass: RenderPass2D): void;\n _animate(frame: (t: number) => Record<string, unknown>, duration: number, easing: unknown): unknown;\n _lastShape: Graphics2D | null;\n /** The composite its last render or probe declared; `undefined` before either. */\n _record: Composite | null | undefined;\n}\n\n/**\n * Measure and layout run synchronously, one node at a time, so the node being\n * laid out and its measurer are a single slot rather than state on every view.\n */\ninterface Pass {\n readonly node: Node2D;\n readonly scope: MeasureContext2D;\n readonly room: Max;\n readonly sizes: Map<Node2D, Size2D>;\n}\n\nlet pass: Pass | null = null;\n\nexport function withPass<T>(node: Node2D, scope: MeasureContext2D, room: Max, run: () => T): T {\n const outer = pass;\n pass = { node, scope, room, sizes: new Map() };\n try {\n return run();\n } finally {\n pass = outer;\n }\n}\n\nconst decided = new WeakSet<Node2D>();\n\n/** An engine module sized this node itself in this measure: its factory reports the size as it stands. */\nexport function markDecided(node: Node2D): void {\n decided.add(node);\n}\n\nexport function takeDecided(node: Node2D): boolean {\n return decided.delete(node);\n}\n\nexport function currentPass(): Pass {\n if (!pass) throw new Error(\"A component's measure or layout helper ran outside a measure or layout pass.\");\n return pass;\n}\n\nfunction measureChild(node: Node2D, max: Max): Size2D {\n const p = currentPass();\n const constraints: SizeConstraints = { maxWidth: max.width, maxHeight: max.height };\n const measured = node.measure(constraints, p.scope);\n const size = { width: measured.width ?? 0, height: measured.height ?? 0 };\n p.sizes.set(node, size);\n return size;\n}\n\nconst childViews = new WeakMap<Node2D, ChildViewImpl>();\n\n/** A child as its parent's fields see it. One per child node, reused every frame. */\nclass ChildViewImpl implements ChildView {\n readonly [NODE]: Node2D;\n readonly state: never;\n\n constructor(node: Node2D) {\n this[NODE] = node;\n // The node's own accessors are its resolved values; a proxy keeps a parent from writing through them.\n // Its props live on the prototype, so the proxy lists them as its own, as a spread or `Object.keys` expects.\n this.state = new Proxy(node, {\n set: () => { throw new TypeError(\"A child's state is read-only to its parent; animate it with a command.\"); },\n ownKeys: (target) => {\n const keys = Reflect.ownKeys(target);\n const own = new Set(keys);\n for (const key of propsOf(target)) if (!own.has(key)) keys.push(key);\n return keys;\n },\n getOwnPropertyDescriptor: (target, key) => {\n const own = Reflect.getOwnPropertyDescriptor(target, key);\n if (own || typeof key !== \"string\" || !propsOf(target).has(key)) return own;\n return { value: Reflect.get(target, key), writable: false, enumerable: true, configurable: true };\n },\n }) as never;\n }\n\n get id(): string { return this[NODE].id; }\n get key(): never { return (keyOf(this[NODE]) ?? this[NODE].className) as never; }\n\n get size(): Size2D {\n // Outside a pass (a command being built), the size it was last laid out at, as a command's own node reports.\n if (!pass) {\n const box = this[NODE].layoutBounds;\n return { width: box?.width ?? 0, height: box?.height ?? 0 };\n }\n return pass.sizes.get(this[NODE]) ?? measureChild(this[NODE], pass.room);\n }\n\n get children(): readonly ChildView[] {\n const node = this[NODE] as Node2D & { _commandChildren?(): readonly ChildView[] };\n return node._commandChildren ? node._commandChildren() : node.children.map(childView);\n }\n\n measure(max: Max): Size2D {\n return measureChild(this[NODE], max);\n }\n\n to(targets: object): Piece {\n return { _piece: { kind: \"child\", node: this[NODE], targets: targets as Record<string, unknown> } };\n }\n\n run(name: string, args?: object): Piece {\n return { _piece: { kind: \"run\", node: this[NODE], name, args } };\n }\n}\n\nconst NO_PROPS: ReadonlySet<string> = new Set();\n\nfunction propsOf(node: object): ReadonlySet<string> {\n const slots = (node as PropHost).__cells?.slots;\n return slots ? new Set(slots.keys()) : NO_PROPS;\n}\n\nexport function childView(node: Node2D | Node): ChildView {\n let view = childViews.get(node as Node2D);\n if (!view) childViews.set(node as Node2D, view = new ChildViewImpl(node as Node2D));\n return view as unknown as ChildView;\n}\n\nexport function nodeOfView(view: ChildView<any>): Node2D {\n return (view as unknown as ChildViewImpl)[NODE];\n}\n\nconst nodeViews = new WeakMap<Node, WeakMap<Node, NodeViewImpl>>();\n\nconst NO_FRAME: NodeFrame = { x: 0, y: 0, rotation: 0, scale: 1 };\n\n/** A node outside a component's own children (an ancestor, a referenced node), as one reader's fields read it. */\nclass NodeViewImpl implements NodeView {\n readonly [NODE]: Node;\n readonly state: never;\n\n constructor(node: Node, readonly reader: Node) {\n this[NODE] = node;\n // A component's state as its own fields read it: a reference of its own is a view from where it stands.\n // Anything else it has (a 2D node's cardinal points) reads off the node.\n const fields = (node as { _view?: object })._view ?? node;\n this.state = new Proxy(fields, {\n get: (target, key) => {\n // Its constructor is the node's: what a host asks to tell what kind of node it reads.\n if (key === \"constructor\") return node.constructor;\n if (key in target) return Reflect.get(target, key);\n const value = Reflect.get(node, key) as unknown;\n // A method of the node runs on the node, not on this read-only view.\n return typeof value === \"function\" ? (value as (...args: unknown[]) => unknown).bind(node) : value;\n },\n set: () => { throw new TypeError(\"Another node's state is read-only to a component; animate it with a command.\"); },\n }) as never;\n }\n\n get id(): string { return this[NODE].id; }\n get key(): never { return (keyOf(this[NODE] as Node2D) ?? this[NODE].className) as never; }\n\n get size(): Size2D {\n const node = this[NODE];\n const box = node instanceof Node2DClass ? node.layoutBounds : undefined;\n return { width: box?.width ?? 0, height: box?.height ?? 0 };\n }\n\n get frame(): NodeFrame {\n const node = this[NODE];\n return node instanceof Node2DClass && this.reader instanceof Node2DClass ? frameIn(this.reader, node) : NO_FRAME;\n }\n}\n\n/** `node` as `reader` sees it. One view per pair. */\nexport function nodeView(node: Node, reader: Node): NodeView {\n let byReader = nodeViews.get(node);\n if (!byReader) nodeViews.set(node, byReader = new WeakMap());\n let view = byReader.get(reader);\n if (!view) byReader.set(reader, view = new NodeViewImpl(node, reader));\n return view;\n}\n\nexport function nodeOfNodeView(view: NodeView): Node {\n return (view as unknown as NodeViewImpl)[NODE];\n}\n\nconst found = new WeakMap<Node, Map<string, Node>>();\n\n/** The node with `id` in `reader`'s scene, as `reader` sees it, or `null`. Remembered per reader while it stays in the scene. */\nexport function referenced(reader: Node, id: unknown): NodeView | null {\n if (typeof id !== \"string\" || id === \"\") return null;\n let known = found.get(reader);\n let node = known?.get(id);\n if (!node || node.id !== id || rootOf(node) !== rootOf(reader)) {\n node = findIn(rootOf(reader), id) ?? undefined;\n if (!node) {\n known?.delete(id);\n return null;\n }\n if (!known) found.set(reader, known = new Map());\n known.set(id, node);\n }\n return nodeView(node, reader);\n}\n\nfunction rootOf(node: Node): Node {\n let at = node;\n while (at.parent) at = at.parent;\n return at;\n}\n\nfunction findIn(at: Node, id: string): Node | null {\n if (at.id === id) return at;\n for (const child of at._allChildren) {\n const hit = findIn(child, id);\n if (hit) return hit;\n }\n return null;\n}\n\nlet keyOf: (node: Node2D) => string | undefined = () => undefined;\n/** Set by the factory module, which owns the node descriptors. */\nexport function setKeyLookup(lookup: (node: Node2D) => string | undefined): void {\n keyOf = lookup;\n}\n\n/**\n * One prototype of getters per component, so a node's `state` is a single\n * object made once: every read goes straight to the node's own slot, and a\n * frame allocates nothing to hand its fields their values.\n */\nexport interface ViewShape {\n readonly proto: object;\n /** Own, so `{ ...state }` copies every entry; the getters themselves are shared. */\n readonly entries: PropertyDescriptorMap;\n}\n\nexport function stateViewPrototype(keys: readonly string[], references: ReadonlySet<string> = new Set()): ViewShape {\n const entries: PropertyDescriptorMap = {};\n for (const key of keys) {\n entries[key] = references.has(key)\n ? { get(this: { [NODE]: Node }) { return referenced(this[NODE], (this[NODE] as unknown as Record<string, unknown>)[key]); }, enumerable: true }\n : { get: entryGetter(key), enumerable: true };\n }\n const proto = {};\n // The children of the node's own tree, as its commands see them too.\n Object.defineProperty(proto, \"children\", {\n get(this: { [NODE]: { _commandChildren(): readonly ChildView[] } }) { return this[NODE]._commandChildren(); },\n enumerable: false,\n });\n return { proto, entries };\n}\n\n/** Reads the entry's slot by its index in the node's layout, found once per layout: no lookup by name per read. */\nfunction entryGetter(key: string): (this: { [NODE]: object }) => unknown {\n let layout: PropLayout | undefined;\n let i = -1;\n return function () {\n const node = this[NODE];\n const cells = (node as PropHost).__cells;\n if (cells !== undefined) {\n if (cells.layout !== layout) {\n i = cells.layout.indexOf(key);\n // An entry not registered yet is looked for again next time.\n layout = i < 0 ? undefined : cells.layout;\n }\n const slot = i < 0 ? undefined : cells.list[i];\n if (slot !== undefined) return slot.get();\n }\n return (node as Record<string, unknown>)[key];\n };\n}\n\nexport function stateView(shape: ViewShape, node: object): object {\n const view = Object.create(shape.proto) as { [NODE]: object };\n Object.defineProperties(view, shape.entries);\n view[NODE] = node;\n return view;\n}\n\n/** A command's `state`: where it starts, so a frame function reading it never sees its own writes. */\nexport function snapshot(view: object): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const key in view) out[key] = (view as Record<string, unknown>)[key];\n return out;\n}\n\nexport class MeasurerImpl implements Measurer {\n max: Max = {};\n scope: MeasureContext2D | null = null;\n\n constructor(readonly host: Node) { }\n\n get time(): Clock {\n return this.host.time;\n }\n\n text(text: string, font: FontSpec): Size2D {\n if (!this.scope) throw new Error(\"measurer.text was called outside measure.\");\n return this.scope.measureText(text, font.fontSize, font.fontFamily, font.fontWeight, font.letterSpacing);\n }\n}\n\n/** Reused every frame: `pass` and `cut` are rewritten before each render. */\nexport class RenderContextImpl implements RenderContext2D {\n pass: RenderPass2D | null = null;\n /** The near-plane cut a 2.5D space puts in front of this node's own paint. */\n cut: Clip | null = null;\n\n /**\n * `probing`: `render` runs only to find the shape it paints (for clip and\n * picking outside a frame), so nothing is drawn and no child is visited.\n */\n constructor(readonly host: ComponentHost, readonly probing = false) { }\n\n get size(): Size2D {\n const box = this.host.layoutBounds;\n return { width: box?.width ?? 0, height: box?.height ?? 0 };\n }\n\n get time(): Clock {\n return this.host.time;\n }\n\n draw(graphics: Graphics2D | readonly Graphics2D[] | null | undefined): void {\n if (!graphics || this.probing) return;\n const out = this.target();\n if (Array.isArray(graphics)) for (const g of graphics) out.draw(g);\n else out.draw(graphics as Graphics2D);\n }\n\n children(): void {\n if (this.probing) return;\n // Drawn plainly, so a space or composite the last frame declared no longer holds for them.\n if (!this.composite) this.host._record = null;\n this.host._renderOwnChildren(this.target());\n }\n\n /** What this render has declared so far. Its host's record follows at once, so the children it draws see it. */\n composite: Composite | null = null;\n\n private _declare(composite: Composite): void {\n this.composite = { ...this.composite, ...composite };\n if (!this.probing) this.host._record = this.composite;\n }\n\n mask(options: MaskOptions): void {\n this._declare({ bounds: \"first\" });\n if (this.probing) return;\n const out = this.target();\n const [stencil, ...content] = this.host.children;\n if (!stencil) return;\n if (content.length === 0) {\n stencil.render(out);\n return;\n }\n out.beginMask({ mode: options.mode, inverted: options.inverted });\n stencil.render(out);\n out.applyMask();\n for (const child of content) child.render(out);\n out.endMask();\n }\n\n merge(op: BooleanOperation, paint: MergePaint): void {\n this._declare({ bounds: op === \"subtract\" ? \"first\" : op === \"intersect\" ? \"intersect\" : \"union\" });\n if (this.probing) return;\n const out = this.target();\n out.beginBoolean(op);\n for (const child of this.host._allChildren) if (child instanceof Node2DClass) child.render(out);\n out.endBoolean();\n // A drawing with no shape of its own paints the merged outline.\n out.draw(new GraphicsClass().shadow(paint.shadow).fill(paint.fill));\n if (paint.overlay && (paint.overlay as unknown[]).length > 0) out.draw(new GraphicsClass().fill(paint.overlay));\n out.draw(new GraphicsClass().stroke(paint.stroke));\n }\n\n /** Your children, through a camera viewing your box: aimed at `lookAt`, zoomed, turned by `heading`. */\n camera(scope: CameraScope): void {\n this._declare({ camera: scope });\n if (this.probing) return;\n const out = this.target();\n const rect = this.host.layoutBounds;\n out.beginCamera({ x: rect?.x ?? 0, y: -(rect?.y ?? 0), width: rect?.width ?? 0, height: rect?.height ?? 0 }, scope.lookAt, scope.zoom, scope.heading);\n for (const child of this.host._allChildren) if (child instanceof Node2DClass) child.render(out);\n out.endCamera();\n }\n\n /** Your 3D children, rendered in order into a new scene. */\n scene3D(): Scene3D {\n const scene = new Scene3D();\n for (const child of this.host._allChildren) if (child instanceof Node3D) child.render(scene);\n this._declare({ scene });\n return scene;\n }\n\n /** Your children, standing in one 2.5D space seen by `camera`, drawn far to near. */\n space(camera: SpaceCamera): void {\n this._declare({ space: camera });\n if (!this.probing) this.host._renderOwnChildren(this.target());\n }\n\n textStyle(style: TextStyle | null, body: () => void): void {\n if (this.probing) return body();\n const out = this.target();\n out.pushTextStyle(style);\n try {\n body();\n } finally {\n out.popTextStyle();\n }\n }\n\n clip(shape: Graphics2D, body: () => void): void {\n if (this.probing) return body();\n const outline = clipOf(shape);\n // No outline is no clip, as a node with no `clipSelf` confines nothing.\n if (outline.isEmpty()) return body();\n const out = this.target();\n out.beginClip(outline);\n try {\n body();\n } finally {\n out.endClip();\n }\n }\n\n /** An ancestor stands this node in a space: one opens it, and nothing between them flattens. */\n get inSpace(): boolean {\n for (let at = this.host.parent; at; at = at.parent) {\n if (!(at instanceof Node2DClass)) return false;\n if (at._spaceCamera()) return true;\n if (!at._rendersChildrenInSpace()) return false;\n }\n return false;\n }\n\n ancestor<K extends string, S, C>(component: Component<K, S, C, any, any, any>): NodeView<Element<K, S, C>> | null {\n for (let at = this.host.parent; at; at = at.parent) {\n if (at instanceof component.node) return nodeView(at, this.host) as unknown as NodeView<Element<K, S, C>>;\n }\n return null;\n }\n\n /** Paint `body` in front of the space's near plane, as `Node2D` does for its own paint. */\n inFront(body: () => void): void {\n if (this.probing) return;\n const out = this.target();\n if (!this.cut) {\n body();\n return;\n }\n out.beginClip(this.cut);\n try {\n body();\n } finally {\n out.endClip();\n }\n }\n\n target(): RenderPass2D {\n if (this.probing) return PROBE_PASS;\n if (!this.pass) throw new Error(\"A component's render context was used outside render.\");\n return this.pass;\n }\n}\n\n/** Where a probe's scoped calls (a clip, a camera) land: a pass that draws nothing. */\nconst PROBE_PASS: RenderPass2D = new NullRenderContext();\n\nexport function internalsOf(ctx: RenderContext2D): RenderContextImpl {\n if (!(ctx instanceof RenderContextImpl)) throw new TypeError(\"Paint.draw takes the render context its render field was given.\");\n return ctx;\n}\n", "import type { Disposer } from \"@/assets/record\";\nimport type { AssetScope } from \"@/assets/scope\";\nimport { getPropertyMeta, property, type PropertyMeta } from \"@/attributes/properties/decorator\";\nimport type { FillResolved } from \"@/attributes/shape/fill/union\";\nimport type { ShadowResolved } from \"@/attributes/shape/shadow/shadow\";\nimport type { StrokeResolved } from \"@/attributes/shape/stroke/stroke\";\nimport { node } from \"@/document/node-decorator\";\nimport { declarePropEvolution } from \"@/document/prop-evolution\";\nimport type { Node } from \"@/components/trees/node/node\";\nimport { settling, type Command, type CommandArgs } from \"@/tween/command\";\nimport { command, type CommandArg } from \"@/tween/command-decorator\";\nimport type { EasingFunction } from \"@/tween/ease/type\";\nimport type { ContextMap } from \"@/util/context\";\nimport type { ChildView, Loader, Provided, StateSpec } from \"@/components/factory/api\";\nimport { commandOf, makeTimeline } from \"@/components/factory/timeline\";\nimport { defOf, isTypeLike, type TypeDef } from \"@/components/factory/type-def\";\nimport { nodeOfView, nodeView, snapshot, stateView, stateViewPrototype, type ViewShape } from \"@/components/factory/views\";\n\n/**\n * What every factory does, whatever tree it builds for: declare the state on a\n * generated subclass of the tree's base, publish the commands, run the\n * `children` builder, provide and inherit context, and declare assets. Each\n * factory adds only its own tree's hooks on top.\n */\n\n/** The fields every factory takes. */\nexport interface CoreSpec {\n readonly key: string;\n readonly state?: StateSpec;\n readonly defaults?: Record<string, unknown>;\n readonly renamed?: Readonly<Record<string, string>>;\n readonly deprecated?: Readonly<Record<string, string>>;\n readonly migrate?: Readonly<Record<string, (value: unknown) => unknown>>;\n readonly commands?: Record<string, unknown>;\n readonly children?: (state: never) => unknown;\n readonly provide?: (state: never, inherited: <T>(context: { readonly id: symbol; readonly defaultValue: T }) => T) => readonly Provided[];\n readonly load?: (loader: Loader, state: never) => void;\n /** `[]` takes none; `null` (the default) anything of its tree; components, or `\"2d\"`/`\"3d\"`/`\"audio\"`, only those. */\n readonly allowedChildren?: readonly unknown[] | null;\n /** The components it goes only inside; unsaid, wherever its tree allows. */\n readonly allowedParents?: readonly unknown[];\n}\n\n/** A spec, resolved against the base it lowers onto. */\nexport interface Lowering {\n readonly spec: CoreSpec;\n readonly entries: Map<string, TypeDef>;\n readonly defaults: Record<string, unknown>;\n readonly builtIn: ReadonlyMap<string, PropertyMeta>;\n readonly view: ViewShape;\n /** Built-in entries whose default a factory applies itself (a 2D size), not by redeclaring the property. */\n readonly ownsDefault: ReadonlySet<string>;\n}\n\ntype NodeBase = abstract new (...args: any[]) => Node;\n\nexport function lowering(spec: CoreSpec, Base: NodeBase, ownsDefault: ReadonlySet<string> = new Set()): Lowering {\n const builtIn = new Map(getPropertyMeta(Object.create(Base.prototype as object)).map((m) => [m.key, m]));\n const entries = new Map<string, TypeDef>(Object.entries(spec.state ?? {}).map(([k, e]) => [k, defOf(e)]));\n const defaults = (spec.defaults ?? {}) as Record<string, unknown>;\n // A default for an own entry is that entry's default; for a built-in one, a redeclaration.\n for (const [key, value] of Object.entries(defaults)) {\n if (typeof value === \"function\") continue;\n const own = entries.get(key);\n if (own) entries.set(key, { ...own, default: value });\n else if (!builtIn.has(key)) throw new TypeError(`${spec.key}: \"defaults.${key}\" names no entry.`);\n }\n checkEvolution(spec, (key) => entries.has(key) || builtIn.has(key));\n // A reference entry holds an id; its fields read a view of the node it names.\n const references = new Set([...entries].filter(([, def]) => def.editor.kind === \"nodeRef\").map(([key]) => key));\n return { spec, entries, defaults, builtIn, view: stateViewPrototype([...builtIn.keys(), ...entries.keys()], references), ownsDefault };\n}\n\nexport function factoryDefault(def: TypeDef): unknown {\n return typeof def.default === \"function\" ? (def.default as () => unknown)() : def.default;\n}\n\n/** The members every generated node has, whatever its tree. */\nexport interface ComponentNode extends Node {\n _view: object;\n /** How many nodes the `children` builder made. */\n _built: number;\n _commandChildren(): readonly ChildView[];\n _animate(frame: (t: number) => Record<string, unknown>, duration: number, easing: unknown): unknown;\n}\n\n/** The base every tree's generated class extends: `Base` with the spec's state, context, assets and children. */\nexport function componentBase<T extends NodeBase>(Base: T, l: Lowering): T & (abstract new (...args: any[]) => ComponentNode) {\n const { spec: s, entries, defaults } = l;\n\n abstract class Componentized extends (Base as unknown as abstract new (...args: any[]) => Node) implements Partial<ComponentNode> {\n declare _view: object;\n declare _built: number;\n declare _assembling: boolean;\n declare _provided: { parent: ContextMap; values: readonly Provided[]; map: ContextMap } | undefined;\n\n constructor(...args: any[]) {\n const props = args[0] as Record<string, unknown> | undefined;\n const given = s.children ? props?.children : undefined;\n super(s.children && props ? { ...props, children: undefined } : props);\n this._view = stateView(l.view, this);\n this._built = 0;\n\n for (const [key, def] of entries) {\n if (def.private) this.applyProp(key, factoryDefault(def), { mapper: def.mapper, tween: def.tween });\n else if (typeof def.default === \"function\" && props?.[key] === undefined) this._writeProp(key, factoryDefault(def));\n }\n let built: Readonly<Record<string, unknown>> | undefined;\n for (const [key, value] of Object.entries(defaults)) {\n if (typeof value === \"function\" && props?.[key] === undefined) {\n const asBuilt = (built ??= Object.freeze({ ...props }));\n this._writeProp(key, () => (value as (state: object, given: object) => unknown)(this._view, asBuilt));\n }\n }\n\n if (s.children) {\n // Live, like the field state, so a binding the builder writes reads the node as it changes.\n const builderState = stateView(l.view, this);\n const authored = [given ?? []].flat(Infinity).filter(Boolean);\n if (s.allowedChildren != null) for (const child of authored) this.assertAcceptsChild(child as Node);\n Object.defineProperty(builderState, \"children\", { value: authored });\n const built = [s.children(builderState as never)].flat(Infinity).filter(Boolean) as Node[];\n this._assembling = true;\n try {\n for (const part of built) this.add(part);\n } finally {\n this._assembling = false;\n }\n this._built = built.length;\n }\n }\n\n /** Each entry the author left unset that inherits takes what its ancestors provide, once, on first attach. */\n protected override resolveContext(ctx: ContextMap): void {\n super.resolveContext(ctx);\n const given = (this._props ?? {}) as Record<string, unknown>;\n const self = this as unknown as Record<string, unknown>;\n for (const [key, def] of entries) {\n if (!def.inherit || given[key] !== undefined) continue;\n const value = def.inherit((context) => ctx.get(context), given);\n if (value !== undefined) self[key] = value;\n }\n }\n\n protected override provideContext(parent: ContextMap): ContextMap {\n if (!s.provide) return super.provideContext(parent);\n const provided = s.provide(this._view as never, (context) => parent.get(context as never));\n // The same map while nothing changed, so the subtree isn't re-bound every attach.\n const memo = this._provided;\n if (memo && memo.parent === parent && memo.values.length === provided.length\n && memo.values.every((p, i) => p.context === provided[i].context && p.value === provided[i].value)) return memo.map;\n let map = parent;\n for (const { context, value } of provided) if (map.get(context) !== value) map = map.with(context, value);\n this._provided = { parent, values: provided, map };\n return map;\n }\n\n override declareAssets(assets: AssetScope): void {\n super.declareAssets(assets);\n const self = this as unknown as Record<string, unknown>;\n for (const [key, def] of entries) declareEntry(assets, def.editor.kind ?? \"\", self[key]);\n if (s.load) s.load(loaderOf(assets), this._view as never);\n }\n\n protected override acceptsChild(child: Node): boolean {\n const allowed = s.allowedChildren;\n if (allowed === undefined || allowed === null || (this._assembling && allowed.length === 0)) return super.acceptsChild(child);\n return allowed.some((rule) => matches(child, rule));\n }\n\n protected override _childRule(): string {\n const allowed = s.allowedChildren;\n if (!allowed) return super._childRule();\n return allowed.length === 0 ? \"It takes no children.\" : `It takes only ${namesOf(allowed)}.`;\n }\n\n override _parentRefusal(parent: Node): string | null {\n const allowed = s.allowedParents;\n if (!allowed || allowed.some((rule) => matches(parent, rule))) return null;\n return `${this.className} goes only inside ${namesOf(allowed)}, not ${parent.className}.`;\n }\n\n /** The children a command's builders see: none, unless the tree says which. */\n _commandChildren(): readonly ChildView[] {\n return [];\n }\n\n _animate(frame: (t: number) => Record<string, unknown>, duration: number, easing: unknown) {\n return this.command(frame, duration, easing as EasingFunction | undefined);\n }\n }\n return Componentized as unknown as T & (abstract new (...args: any[]) => ComponentNode);\n}\n\ntype CommandFn = (timeline: unknown, state: unknown, children: unknown) => never;\n\n/**\n * Declare the state and commands on the generated class, register its key, and\n * hand back the component value.\n */\nexport function finishComponent(Generated: abstract new (...args: any[]) => Node, l: Lowering): object {\n const { spec: s, entries, defaults, builtIn } = l;\n Object.defineProperty(Generated, \"name\", { value: pascal(s.key) });\n const proto = Generated.prototype as unknown as Record<string, unknown>;\n // A node is a context provider by overriding these: only one that provides, or inherits, keeps them.\n if (!s.provide) deleteUpTo(proto, \"provideContext\");\n if (![...entries.values()].some((def) => def.inherit)) deleteUpTo(proto, \"resolveContext\");\n if (s.allowedChildren === undefined || s.allowedChildren === null) {\n deleteUpTo(proto, \"acceptsChild\");\n deleteUpTo(proto, \"_childRule\");\n }\n if (!s.allowedParents) deleteUpTo(proto, \"_parentRefusal\");\n const allowed = s.allowedChildren;\n if (allowed) {\n const trees = [...new Set(allowed.map((rule) => (typeof rule === \"string\"\n ? rule\n : (Object.create((rule as { node: { prototype: object } }).node.prototype) as Node).dimension)))];\n Object.defineProperty(proto, \"_childTrees\", { get: () => trees, configurable: true });\n }\n\n for (const [key, def] of entries) {\n if (def.private) continue;\n property({ default: typeof def.default === \"function\" ? undefined : def.default, mapper: def.mapper, tween: def.tween, ...def.editor })(proto, key);\n }\n for (const [key, value] of Object.entries(defaults)) {\n if (entries.has(key) || l.ownsDefault.has(key) || typeof value === \"function\") continue;\n const inherited = builtIn.get(key)!;\n property({ default: value, mapper: inherited.options?.mapper, tween: inherited.options?.tween, ...inherited.editor })(proto, key);\n }\n\n const base = Object.getPrototypeOf(Object.getPrototypeOf(proto)) as object;\n for (const [key, entry] of Object.entries(s.commands ?? {})) {\n // Commands have their own namespace: a key a node already uses (`remove`, `to`) publishes through another method name.\n const method = key in base ? `_command_${key}` : key;\n let args: CommandArg[] | undefined;\n const entrance = typeof entry === \"object\" && (entry as { entrance?: boolean }).entrance === true;\n if (typeof entry === \"function\") {\n proto[method] = function (this: ComponentNode, cmd: CommandArgs & { duration?: number } = {}): Command<Record<string, unknown>> {\n const duration = cmd.duration ?? 0;\n const timeline = makeTimeline({}, duration, cmd.easing, nodeView(this, this));\n const piece = (entry as CommandFn)(timeline, snapshot(this._view), this._commandChildren());\n return commandOf(this as never, piece, duration, cmd.easing);\n };\n } else {\n const { args: declared, run, easing: ownEasing } = entry as { args: readonly string[] | StateSpec; run?: CommandFn; easing?: EasingFunction };\n if (Array.isArray(declared)) {\n const names = declared as readonly string[];\n for (const name of names) {\n if (!entries.has(name) && !builtIn.has(name)) throw new TypeError(`${s.key}.${key}: args names \"${name}\", which is no entry.`);\n }\n // Each arg is its entry: what a host shows for it is what the entry means.\n args = names.map((name) => ({ key: name, ...(entries.get(name)?.editor ?? builtIn.get(name)?.editor ?? {}) }));\n proto[method] = function (this: Node, cmd: CommandArgs & { duration?: number } = {}) {\n const data = argsRecord(cmd.data, names);\n const stated: Record<string, unknown> = {};\n for (const name of names) if (data[name] !== undefined) stated[name] = data[name];\n return settling(this.to({ data: stated as never, duration: cmd.duration ?? 0, easing: cmd.easing ?? ownEasing }));\n };\n } else {\n const own = declared as StateSpec;\n args = Object.entries(own).map(([k, e]) => {\n const def = defOf(e);\n return { key: k, default: isTypeLike(e) ? factoryDefault(def) : e, ...def.editor };\n });\n proto[method] = function (this: ComponentNode, cmd: CommandArgs & { duration?: number } = {}) {\n const duration = cmd.duration ?? 0;\n const easing = cmd.easing ?? ownEasing;\n const timeline = makeTimeline(resolveArgs(own, cmd.data), duration, easing, nodeView(this, this));\n const piece = run!(timeline, snapshot(this._view), this._commandChildren());\n return commandOf(this as never, piece, duration, easing);\n };\n }\n }\n command({ key, ...(args ? { args } : {}), ...(entrance ? { entrance } : {}) })(proto, method);\n }\n\n if (s.renamed || s.deprecated || s.migrate) {\n declarePropEvolution(Generated, { renamed: s.renamed ?? {}, deprecated: s.deprecated ?? {}, migrate: s.migrate ?? {} });\n }\n node({ key: s.key })(Generated as never);\n return componentValue(s.key, Generated as unknown as new (props?: Record<string, unknown>) => object);\n}\n\n/** A rename lands on an entry from a key that is none; a deprecation and a hook name what is there to evolve. */\nfunction checkEvolution(spec: CoreSpec, isEntry: (key: string) => boolean): void {\n for (const [from, to] of Object.entries(spec.renamed ?? {})) {\n if (isEntry(from)) throw new TypeError(`${spec.key}: \"renamed.${from}\" is still an entry; a renamed key must be gone.`);\n if (!isEntry(to)) throw new TypeError(`${spec.key}: \"renamed.${from}\" names \"${to}\", which is no entry.`);\n }\n for (const key of Object.keys(spec.deprecated ?? {})) {\n if (!isEntry(key)) throw new TypeError(`${spec.key}: \"deprecated.${key}\" names no entry.`);\n }\n for (const key of Object.keys(spec.migrate ?? {})) {\n if (!isEntry(key) && !Object.hasOwn(spec.renamed ?? {}, key)) {\n throw new TypeError(`${spec.key}: \"migrate.${key}\" names neither an entry nor a renamed key.`);\n }\n }\n}\n\n/** Remove the generated override of `name`, wherever between the class and its base it sits. */\nfunction deleteUpTo(proto: Record<string, unknown>, name: string): void {\n for (let at: Record<string, unknown> | null = proto; at; at = Object.getPrototypeOf(at) as Record<string, unknown> | null) {\n if (Object.prototype.hasOwnProperty.call(at, name)) {\n delete at[name];\n return;\n }\n }\n}\n\n/**\n * What a factory hands back: call it (`Rect({...})`) or `new` it, either way a\n * node of the generated class, which is also what `instanceof` tests.\n */\nexport function componentValue(key: string, Generated: new (props?: Record<string, unknown>) => object): object {\n const make = function (props?: object) {\n return new Generated(props as Record<string, unknown>);\n };\n make.prototype = Generated.prototype;\n Object.defineProperty(make, \"name\", { value: Generated.name });\n return Object.assign(make, {\n key,\n node: Generated,\n is: (child: unknown) => nodeOfView(child as never) instanceof Generated,\n });\n}\n\nfunction pascal(key: string): string {\n return key.replace(/(^|[-_ ])(\\w)/g, (_, _sep, c: string) => c.toUpperCase());\n}\n\n/** Whether `node` is of `rule`: a component, or a whole tree by name. */\nfunction matches(node: Node, rule: unknown): boolean {\n return typeof rule === \"string\"\n ? node.dimension === rule\n : node instanceof (rule as { node: abstract new (...args: never[]) => unknown }).node;\n}\n\nfunction namesOf(rules: readonly unknown[]): string {\n const names = rules.map((rule) => (typeof rule === \"string\" ? `any ${rule.toUpperCase()} node` : (rule as { node: { name: string } }).node.name));\n return names.length === 1 ? names[0] : `${names.slice(0, -1).join(\", \")} or ${names.at(-1)}`;\n}\n\n/** One document arg: the bare value from a paint command, or the args record from the registry. */\nfunction argsRecord(data: unknown, names: readonly string[]): Record<string, unknown> {\n if (names.length === 1) {\n const plain = typeof data === \"object\" && data !== null && !Array.isArray(data) && Object.getPrototypeOf(data) === Object.prototype;\n if (!(plain && names[0] in (data as object))) return { [names[0]]: data };\n }\n return (data ?? {}) as Record<string, unknown>;\n}\n\nfunction resolveArgs(spec: StateSpec, data: unknown): Record<string, unknown> {\n const given = (data ?? {}) as Record<string, unknown>;\n const out: Record<string, unknown> = {};\n for (const key in spec) {\n const def = defOf(spec[key]);\n const value = given[key] === undefined ? factoryDefault(def) : given[key];\n out[key] = def.mapper ? def.mapper(value) : value;\n }\n return out;\n}\n\nfunction declareEntry(assets: AssetScope, kind: string, value: unknown): void {\n if (value === undefined || value === null || value === \"\") return;\n switch (kind) {\n case \"fills\": return assets.fill(value as FillResolved[]);\n case \"strokes\": for (const stroke of value as StrokeResolved[]) assets.fill(stroke.fill); return;\n case \"shadows\": for (const shadow of value as ShadowResolved[]) assets.fill(shadow.fill); return;\n case \"image\": return assets.image(value as string);\n case \"video\": return assets.video(value as string);\n case \"font\": return assets.font(value as string);\n }\n}\n\n/** One wrapper per load function: the scope warns when a key's second declaration hands it a different one. */\nconst tasks = new WeakMap<() => Promise<unknown>, () => Promise<void | Disposer>>();\n\nfunction taskOf(load: () => Promise<unknown>): () => Promise<void | Disposer> {\n let task = tasks.get(load);\n if (!task) {\n task = async () => {\n const loaded = await load();\n return typeof loaded === \"function\" ? (loaded as Disposer) : undefined;\n };\n tasks.set(load, task);\n }\n return task;\n}\n\nfunction loaderOf(assets: AssetScope): Loader {\n return {\n font: (family, weight) => assets.font(family, weight),\n image: (src) => assets.image(src),\n video: (src, trim) => assets.video(src, trim),\n task: (key, load, options) => assets.loader(key, taskOf(load), { gate: options?.before === \"layout\" ? \"layout\" : \"render\" }),\n fill: (fills) => assets.fill(fills),\n };\n}\n", "import { Node2D } from \"@/components/trees/2d/node2d\";\nimport { BoxBounds } from \"@/layout/bounds\";\nimport { Vector2 } from \"@/attributes/layout/vector2\";\nimport { multiply, translation } from \"@/attributes/layout/matrix2d\";\nimport { worldAnchors } from \"@/components/trees/2d/node-transform\";\n\n/**\n * The ink extent of a node whose drawing is made **out of its children** (a {@link BooleanGroup}, a\n * {@link MaskGroup}), whose layout cell is otherwise a fiction: nothing is drawn or grabbable at its edges and it\n * doesn't move with the parts. This is what {@link Node2D._localBounds} exists to fix, a separate seam from\n * `measure()` (the box moves, the layout does not).\n *\n * A bounding box is what you *can* work out without running the boolean. A union is exact\n * (`bounds(A ∪ B) = bounds(A) ∪ bounds(B)`) and also the honest answer for `exclude` (a subset, parts still visible).\n * `subtract` can only cut into the first child and `intersect` lives inside every child. Each mode states which it\n * is; the result is a *superset* of the true silhouette for `subtract`/`intersect` and exact for the others, never a\n * box the drawing spills out of.\n *\n * This composes with a resize that scales the children about the corner the drag holds still: an axis-aligned scale\n * about a point commutes with union and intersection, so scaling every child by `k` scales the answer by exactly `k`.\n */\nexport type ChildBoundsMode =\n /** Every child's ink, together — `union` and `exclude`. */\n | \"union\"\n /** The first child's ink alone — `subtract`'s base, and a mask's stencil. */\n | \"first\"\n /** Where every child's ink overlaps — `intersect`. */\n | \"intersect\";\n\n/** Min/max in the node's own local space, y-up, relative to its centre. */\ninterface Span {\n minX: number;\n minY: number;\n maxX: number;\n maxY: number;\n}\n\n/** The four corners of `child`'s ink in its **parent's** local space (y-up from the parent's centre): shift the child's matrix onto the ink's own centre (canvas y-down vs y-up bounds, hence the sign), then read the corners, as `nodeBox` does. Correct for rotated, scaled or off-centre ink. */\nfunction inkCorners(child: Node2D): Vector2[] {\n const b = child._localBounds();\n const local = child._localMatrix();\n const m =\n b.x === 0 && b.y === 0 ? local : multiply(local, translation(b.x, -b.y));\n const a = worldAnchors(m, b.width / 2, b.height / 2);\n return [a.topLeft, a.topRight, a.bottomRight, a.bottomLeft];\n}\n\n/** The axis-aligned span of a point set, or `null` for an empty one. */\nfunction spanOf(points: Vector2[]): Span | null {\n if (points.length === 0) return null;\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n for (const p of points) {\n if (p.x < minX) minX = p.x;\n if (p.x > maxX) maxX = p.x;\n if (p.y < minY) minY = p.y;\n if (p.y > maxY) maxY = p.y;\n }\n return { minX, minY, maxX, maxY };\n}\n\nfunction toBounds(span: Span): BoxBounds {\n return {\n x: (span.minX + span.maxX) / 2,\n y: (span.minY + span.maxY) / 2,\n width: span.maxX - span.minX,\n height: span.maxY - span.minY,\n };\n}\n\n/** The extent of `node`'s children's ink in its own local space, or `null` with nothing to measure (no children, or an `intersect` whose parts don't overlap). `null` is the caller's cue to keep the layout cell: it stays put and grabbable, which a node you need to drop another child into must be. */\nexport function childInkBounds(\n node: Node2D,\n mode: ChildBoundsMode\n): BoxBounds | null {\n const children = node.children;\n if (children.length === 0) return null;\n\n if (mode === \"first\") {\n const span = spanOf(inkCorners(children[0]));\n return span ? toBounds(span) : null;\n }\n\n if (mode === \"union\") {\n const span = spanOf(children.flatMap(inkCorners));\n return span ? toBounds(span) : null;\n }\n\n let span: Span | null = null;\n for (const child of children) {\n const next = spanOf(inkCorners(child));\n if (!next) return null;\n span = span\n ? {\n minX: Math.max(span.minX, next.minX),\n minY: Math.max(span.minY, next.minY),\n maxX: Math.min(span.maxX, next.maxX),\n maxY: Math.min(span.maxY, next.maxY),\n }\n : next;\n // The parts have stopped overlapping: nothing is drawn, so there is no box.\n if (span.minX > span.maxX || span.minY > span.maxY) return null;\n }\n return span ? toBounds(span) : null;\n}\n", "import { sizeInputOps } from \"@/attributes/layout/size\";\nimport type { FlowMode } from \"@/layout/types\";\nimport type { Vector2 } from \"@/attributes/layout/vector2\";\nimport { getNodeDescriptor } from \"@/document/node-decorator\";\nimport type { BoxBounds } from \"@/layout/bounds\";\nimport type { SizeConstraints } from \"@/layout/constraints\";\nimport { flowOps } from \"@/layout/ops\";\nimport { Node2D, type ChildPlacement, type ChildPlane, type CameraScope, type NodeHandle } from \"@/components/trees/2d/node2d\";\nimport type { Clip } from \"@/render/clip\";\nimport { containsClip } from \"@/render/clip-contains\";\nimport type { Graphics2D } from \"@/render/graphics2d\";\nimport type { MeasureContext2D } from \"@/render/measure-context\";\nimport type { RenderPass2D } from \"@/render/render-context2d\";\nimport type { Allowed, Box2DState, ChildView, Component, Element, LayoutBox, Merge, Placement2D, Spec2D, StateSpec } from \"@/components/factory/api\";\nimport { clipOf } from \"@/components/factory/clip-of\";\nimport { componentBase, finishComponent, lowering, type CoreSpec } from \"@/components/factory/factory\";\nimport {\n childView, MeasurerImpl, RenderContextImpl, setKeyLookup, withPass, takeDecided, type ComponentHost, type Composite,\n} from \"@/components/factory/views\";\nimport { childInkBounds } from \"@/components/trees/2d/group-bounds\";\nimport type { SpaceCamera } from \"@/attributes/layout/space3d\";\nimport { NO_PROJECTION_3D, type Projection3D } from \"@/attributes/layout/matrix2d\";\nimport type { ChildSpace3D } from \"@/components/trees/three/node3d\";\nimport type { Scene3D } from \"@/render3d/scene3d\";\n\n\nconst NO_INSETS = { left: 0, right: 0, top: 0, bottom: 0 };\nconst SIZE_KEYS = new Set([\"width\", \"height\"]);\n\nsetKeyLookup((n) => getNodeDescriptor(n.constructor as new () => object)?.key);\n\ntype AnySpec = Spec2D<string, any, any, any, any, any>;\n\nfunction slotOf(p: Placement2D): ChildPlacement | null {\n if (p.rotation === undefined && p.scale === undefined && p.opacity === undefined\n && p.depth === undefined && p.rotationX === undefined && p.rotationY === undefined) return null;\n return {\n rotation: p.rotation ?? 0, scale: p.scale ?? 1, opacity: p.opacity ?? 1,\n depth: p.depth ?? 0, rotationX: p.rotationX ?? 0, rotationY: p.rotationY ?? 0,\n };\n}\n\n/**\n * A 2D component: laid out in a box, drawn with `Graphics2D`. Lowers the spec\n * onto a generated `Node2D` subclass, so a registry, a document and a host see\n * an ordinary node type.\n */\nexport function component2d<\n const K extends string,\n const S extends StateSpec = {},\n const C = {},\n const A extends Allowed = null,\n const B extends Element = never,\n>(spec: Spec2D<K, Merge<Box2DState, S>, S, C, A, B>): Component<K, Merge<Box2DState, S>, C, A> {\n const s = spec as unknown as AnySpec;\n const l = lowering(s as unknown as CoreSpec, Node2D, SIZE_KEYS);\n const { defaults } = l;\n const flows = l.entries.has(\"flow\");\n\n class Generated extends componentBase(Node2D, l) implements ComponentHost {\n _lastShape: Graphics2D | null = null;\n declare _measurer: MeasurerImpl;\n declare _ctx: RenderContextImpl;\n declare _probe: RenderContextImpl | undefined;\n declare _record: Composite | null | undefined;\n declare _slots: Map<Node2D, ChildPlacement> | null;\n declare _planes: Map<Node2D, ChildPlane> | null;\n declare _box: LayoutBox | null;\n\n constructor(props?: Record<string, unknown>) {\n super(props);\n this._measurer = new MeasurerImpl(this);\n this._ctx = new RenderContextImpl(this);\n this._slots = null;\n this._planes = null;\n this._box = null;\n // A node made of other nodes hugs them, unless told otherwise; `flex` already said fill.\n if (this._built > 0 && props?.flex === undefined) {\n for (const axis of SIZE_KEYS) {\n if (props?.[axis] === undefined && defaults[axis] === undefined) this.applyProp(axis, \"hug\", { tween: sizeInputOps.lerp });\n }\n }\n }\n\n /**\n * Hug what it was given, fill when given nothing, and fill a main axis a\n * child fills, so a hugging parent doesn't leave that child no room: the\n * rule shapes have today. A `defaults` size replaces it.\n */\n protected override applyDefaultSize(props?: Record<string, unknown>): void {\n const given = Node2D.flowChildrenProp(props);\n const flow = (props?.flow as FlowMode | undefined) ?? \"freeform\";\n // A flow container fills where a child fills, as shapes do; anything else hugs or fills, as `Node2D` does.\n const main = flows\n ? { width: flow !== \"vertical\", height: flow === \"vertical\" || flow === \"freeform\" }\n : { width: false, height: false };\n for (const axis of [\"width\", \"height\"] as const) {\n if (props?.[axis] !== undefined) continue;\n const declared = defaults[axis];\n const value = declared !== undefined && typeof declared !== \"function\" ? declared\n : given.length === 0 || (main[axis] && Node2D.hasFillChild(given, axis)) ? \"fill\" : \"hug\";\n this.applyProp(axis, value, { tween: sizeInputOps.lerp });\n }\n }\n\n override measure(constraints: SizeConstraints, scope: MeasureContext2D) {\n if (!s.measure) return super.measure(constraints, scope);\n this.lastMeasure = { constraints, measurer: scope };\n const m = this._measurer;\n m.max = { width: constraints.maxWidth, height: constraints.maxHeight };\n m.scope = scope;\n const natural = withPass(this, scope, m.max, () => s.measure!(m, this._view as never, this.flowChildren().map(childView) as never));\n // An engine module may have sized the node itself (text reports its own height even when it fills).\n if (takeDecided(this)) return natural;\n // The engine applies width and height: `hug` keeps the natural size, a number or `fill` replaces it.\n return flowOps.size(this, constraints, NO_INSETS, natural);\n }\n\n protected override layoutChildren(rect: BoxBounds, scope: MeasureContext2D): void {\n if (!s.layout) return super.layoutChildren(rect, scope);\n const children = this.flowChildren();\n const box: LayoutBox = { x: 0, y: 0, width: rect.width, height: rect.height, time: this.time };\n this._box = box;\n // A layout that places children by `Flow` records where a new one would go; any other leaves none.\n this._childSpace = null;\n const placements = withPass(this, scope, { width: rect.width, height: rect.height },\n () => s.layout!(box, this._view as never, children.map(childView) as never));\n let slots: Map<Node2D, ChildPlacement> | null = null;\n let planes: Map<Node2D, ChildPlane> | null = null;\n placements.forEach((p, i) => {\n const child = children[i];\n if (!child) return;\n child.layout({ x: p.x, y: 0 - p.y, width: p.width, height: p.height }, scope);\n const slot = slotOf(p);\n if (slot) (slots ??= new Map()).set(child, slot);\n if (p.plane) (planes ??= new Map()).set(child, p.plane);\n });\n this._slots = slots;\n this._planes = planes;\n }\n\n override _placementOf(child: Node2D): ChildPlacement | null {\n return this._slots?.get(child) ?? super._placementOf(child);\n }\n\n override _planeOf(child: Node2D | null): ChildPlane | null {\n if (child) return this._planes?.get(child) ?? null;\n const box = this._box ?? { x: 0, y: 0, width: this.layoutBounds?.width ?? 0, height: this.layoutBounds?.height ?? 0, time: this.time };\n return s.plane ? s.plane(box, this._view as never) : null;\n }\n\n protected override renderContent(pass: RenderPass2D): void {\n if (!s.render) return super.renderContent(pass);\n this.applyTransform(pass);\n const frame = this._spaceFrame;\n // Edge-on or behind the lens: nothing of its own to draw, but its children have frames of their own.\n if (frame && !frame.paints) {\n this.renderChildren(pass);\n return;\n }\n const ctx = this._ctx;\n ctx.pass = pass;\n ctx.cut = frame?.nearCut ?? null;\n ctx.composite = null;\n try {\n this.renderContentWithEffects(pass, () => s.render!(ctx, this._view as never));\n } finally {\n ctx.pass = null;\n ctx.cut = null;\n // A render that stopped compositing clears the record; one that composites set it as it went.\n this._record = ctx.composite;\n }\n }\n\n /** The outline `render` paints now, found by running it with nothing drawn: picking and backdrop effects read it. */\n protected override clipSelf(): Clip | null {\n this._probeRender();\n return this._lastShape ? clipOf(this._lastShape) : null;\n }\n\n // What `render` does with the children, read from its last run: these are asked every frame,\n // so they never re-run it. Before its first frame, one probe answers.\n\n /** A composite, or a camera, paints its children into its own plane: none of them stands in a space. */\n override _rendersChildrenInSpace(): boolean {\n const r = this._observed();\n return !(r?.bounds || r?.camera) && super._rendersChildrenInSpace();\n }\n\n override _localBounds(): BoxBounds {\n const bounds = this._observed()?.bounds;\n return (bounds && childInkBounds(this, bounds)) ?? super._localBounds();\n }\n\n override _cameraScope(): CameraScope | null {\n return this._observed()?.camera ?? super._cameraScope();\n }\n\n override _spaceCamera(): SpaceCamera | null {\n return this._observed()?.space ?? super._spaceCamera();\n }\n\n /** A space's root is the space's frame, not a plane tilted in it. */\n protected override _projection(): Projection3D {\n return this._observed()?.space ? NO_PROJECTION_3D : super._projection();\n }\n\n /** A render that builds a 3D scene views one: picking projects its 3D children through it. */\n _isViewport3D(): boolean {\n return this._observed()?.scene !== undefined;\n }\n\n /** The scene `render` builds now, built afresh. */\n _scene3D(): Scene3D | null {\n return this._probeRender()?.scene ?? null;\n }\n\n _observed(): Composite | null {\n if (this._record === undefined) this._probeRender();\n return this._record ?? null;\n }\n\n /** Run `render` drawing nothing: the outline it paints, and what it does with the children. */\n _probeRender(): Composite | null {\n if (!s.render) return (this._record = null);\n const probe = (this._probe ??= new RenderContextImpl(this, true));\n this._lastShape = null;\n probe.composite = null;\n s.render(probe, this._view as never);\n return (this._record = probe.composite);\n }\n\n protected override hitTestSelf(local: Vector2, tolerance: number): boolean {\n const clip = this.clipSelf();\n if (!clip || clip.isEmpty()) return super.hitTestSelf(local, tolerance);\n return containsClip(clip, local, tolerance);\n }\n\n _renderOwnChildren(pass: RenderPass2D): void {\n this.renderChildren(pass);\n }\n\n override _commandChildren(): readonly ChildView[] {\n return this.flowChildren().map(childView);\n }\n }\n\n const proto = Generated.prototype as unknown as Record<string, unknown>;\n if (s.handles) {\n const handles = Object.entries(s.handles);\n const sizeOf = (node: Node2D) => ({ width: node.layoutBounds?.width ?? 0, height: node.layoutBounds?.height ?? 0 });\n proto._handles = function (this: Generated): readonly NodeHandle[] {\n const out: NodeHandle[] = [];\n for (const [prop, handle] of handles) {\n const at = handle.at(this._view as never, sizeOf(this));\n if (at) out.push({ prop, at });\n }\n return out;\n };\n proto._handleValue = function (this: Generated, prop: string, at: Vector2): Vector2 | null {\n const handle = s.handles![prop];\n if (!handle) return null;\n return handle.value ? handle.value(at, this._view as never, sizeOf(this)) : { x: at.x, y: at.y };\n };\n }\n if (s.bounds) {\n const bounds = s.bounds;\n proto._localBounds = function (this: Generated): BoxBounds {\n return bounds({ width: this.layoutBounds?.width ?? 0, height: this.layoutBounds?.height ?? 0 }, this._view as never);\n };\n }\n if (s.space) {\n const space = s.space;\n // The coordinates its 3D children stand in: read where each child places itself, and by picking.\n (Generated.prototype as unknown as { _spaceOf: () => ChildSpace3D | null })._spaceOf = function (this: Generated) {\n return space(this._view as never);\n };\n }\n\n return finishComponent(Generated, l) as unknown as Component<K, Merge<Box2DState, S>, C, A>;\n}\n", "import { alignmentOps, type Alignment } from \"@/attributes/layout/alignment\";\nimport { insetsOps, type InsetsProps, type InsetsResolved } from \"@/attributes/layout/insets\";\nimport { sizeInputOps, type SizeInput } from \"@/attributes/layout/size\";\nimport { vector2Ops, type Vector2 } from \"@/attributes/layout/vector2\";\nimport type { PropertyEditor } from \"@/attributes/properties/decorator\";\nimport { cornerRadiusOps, type CornerRadiusResolved, type RectCornerRadius } from \"@/attributes/shape/corners/corner-radius\";\nimport { cornerStyleOps, type CornerStyleResolved, type RectCornerStyle } from \"@/attributes/shape/corners/corner-style\";\nimport { effectsOps, type Effect } from \"@/attributes/shape/effects/chain\";\nimport type { NodeEffect } from \"@/attributes/shape/effects/union\";\nimport type { Fill } from \"@/attributes/shape/fill/chain\";\nimport type { Color, NormalizedColor } from \"@/attributes/shape/fill/color/parser\";\nimport { colorOps } from \"@/attributes/shape/fill/lerp\";\nimport { fillOps } from \"@/attributes/shape/fill/registry\";\nimport type { FillResolved } from \"@/attributes/shape/fill/union\";\nimport { pathOps } from \"@/attributes/shape/path/ops\";\nimport { shadowOps, type Shadow, type ShadowResolved } from \"@/attributes/shape/shadow/shadow\";\nimport { strokeOps, type Stroke, type StrokeResolved } from \"@/attributes/shape/stroke/stroke\";\nimport { textOps } from \"@/attributes/text/ops\";\nimport type { TweenFn } from \"@/props/host\";\nimport type { PathData } from \"@/render/descriptors/path\";\nimport type { AnyType, InOf, Inputs, NodeView, OutOf, StateSpec, Type, Values } from \"@/components/factory/api\";\nimport { defOf, type Inherit, type TypeDef } from \"@/components/factory/type-def\";\n\nexport interface EntryOptions {\n /** Not in documents or calls; only commands write it. A seek restores it like any entry. */\n readonly private?: boolean;\n /** `false`: `to` switches it rather than moving it. */\n readonly animatable?: boolean;\n /** Where it comes from when the author leaves it unset: what an ancestor provides. */\n readonly inherit?: Inherit;\n}\n\nexport interface NumberOptions extends EntryOptions {\n readonly min?: number;\n readonly max?: number;\n readonly step?: number;\n readonly unit?: string;\n /** Shown multiplied by this: `100` with `unit: \"%\"` for a 0–1 fraction. */\n readonly scale?: number;\n}\n\nexport interface TextOptions extends EntryOptions {\n /** `to` types the text out instead of switching at the end. */\n readonly typing?: boolean;\n /** It holds lines, not a label. */\n readonly multiline?: boolean;\n}\n\ntype PrivateOf<O> = O extends { readonly private: true } ? true : false;\n\n/** An attribute type: usable bare (`Types.fill`) or called with a default (`Types.fill('red')`). */\nexport interface Attribute<In, Out> extends Type<In, Out, false> {\n <const O extends EntryOptions = {}>(initial?: In, options?: EntryOptions & O): Type<In, Out, PrivateOf<O>>;\n}\n\nfunction make<In, Out, P extends boolean>(def: TypeDef): Type<In, Out, P> {\n return { _def: def } as Type<In, Out, P>;\n}\n\n/** The editor half of an options object: what the value means, never how an app shows it. */\nfunction meaning(kind: string, options: object | undefined, extra?: PropertyEditor): PropertyEditor {\n const { private: _private, typing: _typing, inherit: _inherit, ...rest } = (options ?? {}) as Record<string, unknown>;\n return { kind, ...extra, ...rest };\n}\n\nfunction attribute<In, Out>(\n kind: string, fallback: In, mapper?: (ext: any, prev?: any) => Out, tween?: TweenFn<Out>,\n): Attribute<In, Out> {\n const base: TypeDef = { default: fallback, mapper, tween, editor: { kind }, private: false };\n const call = <const O extends EntryOptions = {}>(initial?: In, options?: EntryOptions & O): Type<In, Out, PrivateOf<O>> =>\n make({ ...base, default: initial === undefined ? base.default : initial, editor: meaning(kind, options), private: options?.private === true, inherit: options?.inherit });\n return Object.assign(call, { _def: base }) as unknown as Attribute<In, Out>;\n}\n\nfunction defaultsOf(shape: StateSpec): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const key in shape) out[key] = defOf(shape[key]).default;\n return out;\n}\n\n/**\n * What a state entry can be. Each lowers onto the `property` options of the\n * attribute it names, so a Type and a typed property are the same pair.\n */\nexport const Types = {\n number<const O extends NumberOptions = {}>(initial = 0, options?: NumberOptions & O): Type<number, number, PrivateOf<O>> {\n return make({ default: initial, editor: meaning(\"number\", options), private: options?.private === true, inherit: options?.inherit });\n },\n text<const O extends TextOptions = {}>(initial = \"\", options?: TextOptions & O): Type<string, string, PrivateOf<O>> {\n return make({ default: initial, tween: options?.typing ? textOps.lerp : undefined, editor: meaning(\"text\", options), private: options?.private === true, inherit: options?.inherit });\n },\n boolean<const O extends EntryOptions = {}>(initial = false, options?: EntryOptions & O): Type<boolean, boolean, PrivateOf<O>> {\n return make({ default: initial, editor: meaning(\"boolean\", options), private: options?.private === true, inherit: options?.inherit });\n },\n oneOf<const V extends readonly string[], const O extends EntryOptions = {}>(\n values: V, options?: EntryOptions & O & { readonly default?: V[number] },\n ): Type<V[number], V[number], PrivateOf<O>> {\n const { default: initial, ...rest } = options ?? ({} as O & { default?: V[number] });\n return make({ default: initial ?? values[0], editor: meaning(\"enum\", rest, { options: values }), private: options?.private === true, inherit: options?.inherit });\n },\n\n fill: attribute<Fill, FillResolved[]>(\"fills\", [], fillOps.resolve, fillOps.lerp),\n stroke: attribute<Stroke, StrokeResolved[]>(\"strokes\", [], strokeOps.resolve, strokeOps.lerp),\n shadow: attribute<Shadow, ShadowResolved[]>(\"shadows\", [], shadowOps.resolve, shadowOps.lerp),\n effects: attribute<Effect, NodeEffect[]>(\"effects\", [], effectsOps.resolve, effectsOps.lerp),\n color: attribute<Color, NormalizedColor>(\"color\", \"black\", colorOps.resolve, colorOps.lerp),\n cornerRadius: attribute<RectCornerRadius, CornerRadiusResolved>(\"cornerRadius\", 0, cornerRadiusOps.resolve, cornerRadiusOps.lerp),\n cornerStyle: attribute<RectCornerStyle, CornerStyleResolved>(\"cornerStyle\", \"rounded\", cornerStyleOps.resolve, cornerStyleOps.lerp),\n path: attribute<PathData, PathData>(\"path\", \"\", undefined, pathOps.lerp),\n insets: attribute<InsetsProps, InsetsResolved>(\"insets\", 0, insetsOps.resolve, insetsOps.lerp),\n alignment: attribute<Alignment, Vector2>(\"alignment\", \"center\", alignmentOps.resolve, alignmentOps.lerp),\n vector2: attribute<Vector2, Vector2>(\"vector2\", { x: 0, y: 0 }, undefined, vector2Ops.lerp),\n size: attribute<SizeInput, SizeInput>(\"size\", \"fill\", undefined, sizeInputOps.lerp),\n\n /** A point in the component's own frame: an editor can drag it. */\n point<const O extends EntryOptions = {}>(initial: Vector2 = { x: 0, y: 0 }, options?: EntryOptions & O): Type<Vector2, Vector2, PrivateOf<O>> {\n return make({ default: initial, tween: vector2Ops.lerp, editor: meaning(\"point\", options), private: options?.private === true, inherit: options?.inherit });\n },\n list<const T extends AnyType, const O extends EntryOptions = {}>(item: T, options?: EntryOptions & O): Type<InOf<T>[], OutOf<T>[], PrivateOf<O>> {\n return make({ default: () => [], editor: meaning(\"list\", options, { item: item._def.editor }), private: options?.private === true, inherit: options?.inherit });\n },\n object<const S extends StateSpec>(shape: S): Type<Inputs<S>, Values<S>> {\n return make({ default: () => defaultsOf(shape), editor: { kind: \"object\" }, private: false });\n },\n custom<In, Out = In, const O extends EntryOptions = {}>(initial: In, options?: EntryOptions & O & {\n readonly resolve?: (value: In) => Out;\n readonly lerp?: (from: Out, to: Out, t: number) => Out;\n /** What the value is, when a host can't tell from the default (`\"vector2\"`), and its parts. */\n readonly kind?: string;\n readonly properties?: PropertyEditor[\"properties\"];\n }): Type<In, Out, PrivateOf<O>> {\n const { resolve, lerp, private: _private, inherit: _inherit, ...rest } = options ?? ({} as NonNullable<typeof options>);\n // No kind of its own: a host reads one off the default, as for a bare `property`.\n return make({ default: initial, mapper: resolve, tween: lerp, editor: rest as PropertyEditor, private: options?.private === true, inherit: options?.inherit });\n },\n image: (src = \"\"): Type<string> => make({ default: src, editor: { kind: \"image\" }, private: false }),\n video: (src = \"\"): Type<string> => make({ default: src, editor: { kind: \"video\" }, private: false }),\n audio: (src = \"\"): Type<string> => make({ default: src, editor: { kind: \"audio\" }, private: false }),\n font: (family = \"\"): Type<string> => make({ default: family, editor: { kind: \"font\" }, private: false }),\n /** Another node, by id: a document holds the id, and a field reads a view of that node (or `null`). */\n nodeRef: (initial = \"\"): Type<string, NodeView | null> => make({ default: initial, editor: { kind: \"nodeRef\", animatable: false }, private: false }),\n /** A seed for deterministic randomness: procedural motion stays a function of time. */\n seed: (initial = 1): Type<number> => make({ default: initial, editor: { kind: \"seed\" }, private: false }),\n};\n", "import type { Size2D } from \"@/attributes/layout/size\";\nimport type { CornerRadiusResolved, RectCornerRadius } from \"@/attributes/shape/corners/corner-radius\";\nimport type { CornerStyleResolved, RectCornerStyle } from \"@/attributes/shape/corners/corner-style\";\nimport { Graphics2D } from \"@/render/graphics2d\";\nimport type { Values } from \"@/components/factory/api\";\nimport { Types, type Attribute } from \"@/components/factory/types\";\n\n// Typed out so the declarations name what the corners take by their own modules: a kit's emit reaches those through the sdk.\nexport const state: { cornerRadius: Attribute<RectCornerRadius, CornerRadiusResolved>; cornerStyle: Attribute<RectCornerStyle, CornerStyleResolved> } = {\n cornerRadius: Types.cornerRadius,\n cornerStyle: Types.cornerStyle,\n};\n\n/** A rectangle the size of the box, with these corners. */\nexport function rect(size: Size2D, s: Values<typeof state>): Graphics2D {\n return new Graphics2D().rect({ width: size.width, height: size.height, cornerRadius: s.cornerRadius, cornerStyle: s.cornerStyle });\n}\n", "import type { Alignment } from \"@/attributes/layout/alignment\";\nimport type { InsetsResolved } from \"@/attributes/layout/insets\";\nimport { insetsOps } from \"@/attributes/layout/insets\";\nimport type { Size2D } from \"@/attributes/layout/size\";\nimport type { Vector2 } from \"@/attributes/layout/vector2\";\nimport type { BoxBounds } from \"@/layout/bounds\";\nimport { flowOps } from \"@/layout/ops\";\nimport type { FlowMeasure, FlowMode, FlowResolved, FlowSettings, GapSize } from \"@/layout/types\";\nimport type { Node2D } from \"@/components/trees/2d/node2d\";\nimport type { ChildView, Measurer, Placement2D, Values } from \"@/components/factory/api\";\nimport { Types, type Attribute } from \"@/components/factory/types\";\nimport { currentPass, nodeOfView } from \"@/components/factory/views\";\n\n/** The Rect layout engine: freeform, runs, wrapped runs and grids. */\nexport const state = {\n flow: Types.custom<FlowMode, FlowResolved>(\"freeform\", { lerp: flowOps.lerp }),\n gap: Types.custom<GapSize>(0),\n wrap: false,\n crossGap: Types.custom<number | undefined>(undefined),\n columns: Types.number(1),\n // Typed out so the declarations name Alignment by its own module: a kit's emit reaches it through the sdk.\n align: Types.alignment as Attribute<Alignment, Vector2>,\n};\n\nexport type FlowState = Values<typeof state> & {\n readonly padding: InsetsResolved;\n readonly width: import(\"@/attributes/layout/size\").SizeInput;\n readonly height: import(\"@/attributes/layout/size\").SizeInput;\n};\n\nconst NO_CONTENT: Size2D = { width: 0, height: 0 };\n\n/** The measure a container took, kept for its layout in the same pass (as `Node2D` keeps its own). */\nconst pending = new WeakMap<Node2D, FlowMeasure<Node2D>>();\n\nfunction padded(s: FlowState, inset: InsetsResolved | undefined): InsetsResolved {\n const p = s.padding;\n if (!inset) return p;\n return { left: p.left + inset.left, right: p.right + inset.right, top: p.top + inset.top, bottom: p.bottom + inset.bottom };\n}\n\n/** `inset` is room the children must clear beyond `padding`: a stroke, say. */\nexport function measure(measurer: Measurer, s: FlowState, children: readonly ChildView<any>[], inset?: InsetsResolved): Size2D {\n const { node, scope } = currentPass();\n const padding = padded(s, inset);\n const constraints = { maxWidth: measurer.max.width, maxHeight: measurer.max.height };\n if (children.length === 0) {\n pending.delete(node);\n return flowOps.size(s, constraints, padding, NO_CONTENT);\n }\n const space = flowOps.contentBox(s, constraints, padding);\n const measured = flowOps.measure(s as FlowSettings, children.map(nodeOfView), space, scope);\n pending.set(node, measured);\n return flowOps.size(s, constraints, padding, measured.hug);\n}\n\nexport function layout(box: BoxBounds, s: FlowState, children: readonly ChildView<any>[], inset?: InsetsResolved): readonly Placement2D[] {\n const { node, scope } = currentPass();\n const kept = pending.get(node);\n pending.delete(node);\n const inner = insetsOps.insetBounds(box.width, box.height, padded(s, inset));\n // Where a child that is not here yet would land: a host dropping one in asks.\n node._childSpace = { settings: { flow: s.flow, align: s.align }, inner };\n if (children.length === 0) return [];\n const measured = kept && flowOps.reusable(kept, inner)\n ? kept\n : flowOps.measure(s as FlowSettings, children.map(nodeOfView), {\n width: inner.width, height: inner.height, hugWidth: s.width === \"hug\", hugHeight: s.height === \"hug\",\n }, scope);\n // `place` answers y-up from the content box's centre; a placement is y-up from the component's.\n return flowOps.place(measured, s as FlowSettings, inner).map((b) => ({\n x: inner.x + b.x, y: b.y - inner.y, width: b.width, height: b.height,\n }));\n}\n", "import type { CommandsSpec, Kids, Piece, StateSpec, Values } from \"@/components/factory/api\";\n\n/**\n * A command as a module exports it: checked against the module's own state\n * where it is written, then loose about the state it is run with, so it fits\n * any component that spreads the module's state in.\n */\ntype Portable<A> =\n A extends readonly unknown[] ? { readonly args: A; readonly run?: undefined }\n : unknown extends A ? (timeline: any, state: any, children: any) => Piece\n : { readonly args: A; run(timeline: any, state: any, children: any): Piece };\n\n/** A module's commands, typed against the state it exports. */\nexport function commandsFor<const S extends StateSpec, const C>(\n state: S,\n commands: CommandsSpec<C, S, Values<S>, Kids>,\n): { readonly [N in keyof C]: Portable<C[N]> } {\n return commands as never;\n}\n", "import type { InsetsResolved } from \"@/attributes/layout/insets\";\nimport type { Fill } from \"@/attributes/shape/fill/chain\";\nimport type { FillResolved } from \"@/attributes/shape/fill/union\";\nimport type { ShadowResolved } from \"@/attributes/shape/shadow/shadow\";\nimport type { StrokeResolved } from \"@/attributes/shape/stroke/stroke\";\nimport type { GraphicsOp, Graphics2D } from \"@/render/graphics2d\";\nimport type { RenderContext2D, Values } from \"@/components/factory/api\";\nimport { clipOf } from \"@/components/factory/clip-of\";\nimport { commandsFor } from \"@/components/factory/commands-for\";\nimport { Types } from \"@/components/factory/types\";\nimport { internalsOf } from \"@/components/factory/views\";\n\nconst FRACTION = { min: 0, max: 1, step: 0.01, scale: 100, unit: \"%\" } as const;\n\n/** Fill, stroke and shadow for anything with a shape, and the commands that move them. */\nexport const state = {\n fill: Types.fill,\n stroke: Types.stroke,\n shadow: Types.shadow,\n overlay: Types.fill,\n start: Types.number(0, FRACTION),\n end: Types.number(1, FRACTION),\n};\n\nexport const commands = commandsFor(state, {\n fillTo: { args: [\"fill\"] },\n strokeTo: { args: [\"stroke\"] },\n shadowTo: { args: [\"shadow\"] },\n overlayTo: { args: [\"overlay\"] },\n progressTo: { args: [\"start\", \"end\"] },\n /** A stretch of the outline travels along it, and leaves it as it was. */\n flash: {\n args: { portion: Types.number(0.25, { ...FRACTION, min: 0.01 }) },\n run: (timeline, s) => {\n const rest = { start: s.start, end: s.end };\n const portion = Math.min(1, Math.max(0.01, timeline.args.portion));\n return timeline.animate((t) => {\n if (t <= 0 || t >= 1) return rest;\n const head = t * (1 + portion);\n return { start: Math.max(0, head - portion), end: Math.min(1, head) };\n });\n },\n },\n});\n\n/** What `draw` reads; a component that spreads `Paint.state` without `overlay` passes as it is. */\nexport type PaintState = Omit<Values<typeof state>, \"overlay\"> & { readonly overlay?: readonly FillResolved[]; readonly clip: boolean };\n\nexport interface DrawOptions {\n /** Paint with this instead of `state.fill` (a video frame under it, a 3D scene over it). */\n readonly fill?: Fill;\n /** Draw the children some other way (through a camera, in a space). Default: `ctx.children()`. */\n readonly children?: () => void;\n /**\n * What `clip` confines the children to and picking tests, when it isn't the\n * shape drawn: a path's box, or `null` for none (then picking takes the box).\n */\n readonly clipShape?: Graphics2D | null;\n /** Draw the overlay some other way (masked by a picture), from the trimmed shape. Default: the shape filled with `overlay`. */\n readonly overlay?: (base: Graphics2D) => Graphics2D | null;\n}\n\nconst TRIMMED = new Set<GraphicsOp[\"kind\"]>([\"rect\", \"ellipse\", \"path\", \"line\", \"polygon\", \"polygram\"]);\n\nfunction trimmed(shape: Graphics2D, start: number, end: number): Graphics2D {\n return shape._withOps(shape.ops().map((op) => (TRIMMED.has(op.kind)\n ? { ...op, state: { ...(op as { state: object }).state, start, end } } as GraphicsOp\n : op)));\n}\n\n/** A fresh copy to paint: a `Graphics2D` records into itself, and each paint needs the bare shape. */\nfunction copy(shape: Graphics2D): Graphics2D {\n return shape._withOps([...shape.ops()]);\n}\n\n/** A shadow is cast by the stroke when nothing visible fills the shape. */\nfunction castsShadowFromStroke(state: PaintState): boolean {\n if ((state.shadow as ShadowResolved[]).length === 0) return false;\n return !(state.fill as FillResolved[]).some((layer) => (layer.opacity ?? 1) > 0);\n}\n\n/**\n * Shadow and fill, then the children (clipped to the shape when `clip` is set),\n * then overlay and stroke, all trimmed by `start`/`end`: the paint order every\n * shape has, in one function.\n */\nexport function draw(ctx: RenderContext2D, s: PaintState, shape: Graphics2D | null, options: DrawOptions = {}): void {\n const c = internalsOf(ctx);\n const out = c.target();\n const confining = options.clipShape === undefined ? shape : options.clipShape;\n c.host._lastShape = confining;\n if (c.probing) {\n // Children drawn some other way may declare a camera or a space: the probe needs to see that.\n options.children?.();\n return;\n }\n const base = shape ? trimmed(shape, s.start, s.end) : null;\n\n c.inFront(() => {\n if (base) out.draw(copy(base).shadow(s.shadow).fill(options.fill ?? s.fill));\n });\n\n const outline = s.clip && confining ? clipOf(confining) : null;\n const clipped = outline !== null && !outline.isEmpty();\n if (clipped) out.beginClip(outline);\n if (options.children) options.children();\n else ctx.children();\n if (clipped) out.endClip();\n\n c.inFront(() => {\n if (!base) return;\n if (s.overlay && s.overlay.length > 0) {\n const overlay = options.overlay ? options.overlay(copy(base)) : copy(base).fill(s.overlay as FillResolved[]);\n if (overlay) out.draw(overlay);\n }\n const stroke = s.stroke as StrokeResolved[];\n if (stroke.length === 0) return;\n out.draw(castsShadowFromStroke(s) ? copy(base).shadow(s.shadow).stroke(stroke) : copy(base).stroke(stroke));\n });\n}\n\n/** How far the stroke reaches inside the shape, so children clear it. The widest stroke wins, not the sum. */\nexport function inset(s: Values<typeof state>): InsetsResolved {\n let extra = 0;\n for (const stroke of s.stroke as StrokeResolved[]) {\n const intrusion = stroke.weight * (1 - stroke.align) / 2;\n if (intrusion > extra) extra = intrusion;\n }\n return { left: extra, right: extra, top: extra, bottom: extra };\n}\n", "import type { Size2D } from \"@/attributes/layout/size\";\nimport type { CornerStyle } from \"@/attributes/shape/corners/corner-style\";\nimport { pathOps } from \"@/attributes/shape/path/ops\";\nimport { shapeOutlinePixels, type ShapeOutlineKind, type ShapeOutlineOptions } from \"@/components/builtins/geometry/shape-outline\";\nimport type { PathData } from \"@/render/descriptors/path\";\nimport { Graphics2D } from \"@/render/graphics2d\";\n\n/** Each outline a built-in shape paints, from its box and its own entries. `Paint.draw` trims and paints it. */\n\nexport function ellipse(size: Size2D, s: { readonly startAngle: number; readonly sweep: number; readonly ratio: number }): Graphics2D {\n return new Graphics2D().ellipse({ width: size.width, height: size.height, startAngle: s.startAngle, sweep: s.sweep, ratio: s.ratio });\n}\n\nexport interface PolygonShape {\n readonly sides: number;\n readonly cornerRadius: number;\n readonly cornerStyle: CornerStyle;\n}\n\nexport function polygon(size: Size2D, s: PolygonShape): Graphics2D {\n return new Graphics2D().polygon({ width: size.width, height: size.height, sides: s.sides, cornerRadius: s.cornerRadius, cornerStyle: s.cornerStyle });\n}\n\nexport function polygram(size: Size2D, s: PolygonShape & { readonly ratio: number }): Graphics2D {\n return new Graphics2D().polygram({\n width: size.width, height: size.height, sides: s.sides, ratio: s.ratio, cornerRadius: s.cornerRadius, cornerStyle: s.cornerStyle,\n });\n}\n\n/** The box, as a shape: what a path clips its children to. */\nexport function box(size: Size2D): Graphics2D {\n return new Graphics2D().rect({ x: 0, y: 0, width: size.width, height: size.height });\n}\n\n/** Path data in the unit space of the box (y up), drawn at the box's size. */\nexport function unitPath(size: Size2D, data: PathData): Graphics2D {\n const { width: w, height: h } = size;\n return new Graphics2D().path({\n data: pathOps.anchorCommands(pathOps.anchors(data), (p) => ({ x: p.x * w, y: -p.y * h })),\n centerBounds: [-w / 2, -h / 2, w / 2, h / 2],\n });\n}\n\n/** Path data at face value, centred on its own bounds. */\nexport function facePath(data: PathData): Graphics2D {\n const b = pathOps.bounds(data);\n return new Graphics2D().path({ data, centerBounds: b ? [b.minX, b.minY, b.maxX, b.maxY] : undefined });\n}\n\n/** A named outline (triangle, star, …) fitted to the box. */\nexport function outline(kind: ShapeOutlineKind, size: Size2D, options: Omit<ShapeOutlineOptions, \"width\" | \"height\">): Graphics2D {\n const { width: w, height: h } = size;\n return new Graphics2D().path({\n data: pathOps.anchorCommands(shapeOutlinePixels(kind, { ...options, width: w, height: h }), (p) => ({ x: p.x, y: -p.y })),\n centerBounds: [-w / 2, -h / 2, w / 2, h / 2],\n });\n}\n\n/** A rect's corners, to spread in (`...Shapes.corners`), and the rect they round. */\nexport { state as corners, rect } from \"@/components/modules/corners\";\n", "import { lerpVector2, type Vector2 } from \"@/attributes/layout/vector2\";\nimport { Node2D } from \"@/components/trees/2d/node2d\";\nimport type { Node } from \"@/components/trees/node/node\";\nimport type { RenderContext2D, Values } from \"@/components/factory/api\";\nimport { commandsFor } from \"@/components/factory/commands-for\";\nimport { Types } from \"@/components/factory/types\";\nimport { internalsOf, nodeOfNodeView } from \"@/components/factory/views\";\n\n/** Where a 2D camera looks: a point, a zoom and a heading, or a node below it to follow. */\nexport const state = {\n zoom: Types.number(1, { min: 0.01, step: 0.1, unit: \"×\" }),\n lookAt: Types.custom<Vector2>({ x: 0, y: 0 }, { lerp: lerpVector2, kind: \"vector2\", properties: { x: { kind: \"number\" }, y: { kind: \"number\" } } }),\n heading: Types.number(0, { step: 1, unit: \"°\" }),\n follow: Types.nodeRef(),\n};\n\nexport const commands = commandsFor(state, {\n zoomTo: { args: [\"zoom\"] },\n panTo: { args: [\"lookAt\"] },\n headingTo: { args: [\"heading\"] },\n});\n\ntype AimState = Values<typeof state>;\n\n/** The point the camera centres on: `lookAt`, offset from the followed node when there is one below it. */\nexport function aim(ctx: RenderContext2D, s: AimState): Vector2 {\n const target = s.follow;\n if (!target) return s.lookAt;\n const node = nodeOfNodeView(target);\n if (!(node instanceof Node2D) || !within(node, internalsOf(ctx).host)) return s.lookAt;\n const at = target.frame;\n return { x: at.x + s.lookAt.x, y: at.y + s.lookAt.y };\n}\n\n/** The children, through this camera. */\nexport function camera(ctx: RenderContext2D, s: AimState): void {\n ctx.camera({ lookAt: aim(ctx, s), zoom: s.zoom, heading: s.heading });\n}\n\nfunction within(node: Node, ancestor: Node): boolean {\n for (let at = node.parent; at; at = at.parent) if (at === ancestor) return true;\n return false;\n}\n", "import type { FontStyle, TextAlign, TextDecoration, VerticalAlign } from \"@/attributes/text/types\";\nimport { FillResolved } from \"@/attributes/shape/fill/union\";\nimport { StrokeResolved } from \"@/attributes/shape/stroke/stroke\";\nimport { PathData } from \"./path\";\nimport { ShapeAlignmentInput, ShapeState, resolveShapeAlignment, resolveShapePivot, stripShapeAlignmentKeys } from \"./shape\";\nimport { hostTextFamily } from \"@/components/builtins/text/text-defaults\";\n\n/** Size a segmented block's pieces shape at on an `'autofit'` node: the layout probes with it, since no single piece can be asked for the size the block settles on. */\nexport const AUTOFIT_PROBE_SIZE = 100;\n\n/**\n * One contiguous piece of a Text node split at run boundaries, carrying its shaping inputs (`text` plus the five\n * font fields) and per-run draw-time overrides: `opacity` folded into paint alpha, optional `fill`/`stroke`\n * (falling back to the node's), and a transform about the run's centred position. Present only when a Text node\n * has styled runs or a reveal window. An absent optional font field means \"the node's own\", resolved where the paragraph is built.\n */\nexport interface TextSegment {\n text: string;\n fontFamily?: string;\n fontSize?: number;\n fontStyle?: FontStyle;\n fontWeight: number;\n letterSpacing: number;\n textDecoration?: TextDecoration;\n opacity: number;\n x: number;\n y: number;\n scale: number;\n rotation: number;\n fill?: FillResolved[];\n stroke?: StrokeResolved[];\n}\n\nexport interface TextState extends ShapeState {\n text: string;\n /** Typography preset key (`theme.typography`), as a `Text` node's `variant`. Resolved at draw (a drawn op has no bind step): above the enclosing `<DefaultTextStyle>`, below anything the op states. Unresolved names are ignored so a renamed preset loses styling rather than failing to draw. */\n variant?: string;\n fontSize: number | 'autofit';\n fontFamily: string;\n fontWeight: number;\n fontStyle: FontStyle;\n letterSpacing: number;\n lineHeight: number;\n textAlign: TextAlign;\n /** Where the block sits in a box taller or shorter than it; only a `height` gives it one. */\n verticalAlign: VerticalAlign;\n textDecoration: TextDecoration;\n wrap: boolean;\n minFontSize: number;\n width: number;\n height: number;\n /** Per-piece overrides for styled runs: shaped together as one paragraph, each shaped run painted with its piece's overrides instead of the node's single fill. */\n segments?: TextSegment[];\n /** Wraps the text around this path (text-on-path): glyphs follow it, centred on their baseline, and glyphs past the end are clipped. Mutually exclusive with `segments` in v1. */\n path?: PathData | null;\n}\n\n\n/**\n * The family this text is set in: the last rung of the cascade, and the only one that can refuse. The engine never\n * substitutes a face of its own (that would hide a font that was never declared, and so never loaded); it falls\n * back to {@link hostTextFamily}, a face the application named once at its composition root, else throws. By here\n * the op/prop, `variant` preset, enclosing `<DefaultTextStyle>` and theme `default` preset were all silent, hence\n * the message naming them.\n *\n * Exported so the measure path enforces the same policy: shaping to measure happens before any op is validated and\n * the shaper reads `.length` off each family name, so a missing family would otherwise die inside the wasm naming no scene, node or prop.\n */\nexport function requireFontFamily(descriptor: { fontFamily?: string; text?: string }): string {\n const family = descriptor.fontFamily;\n if (typeof family === \"string\" && family !== \"\") return family;\n const host = hostTextFamily();\n if (host !== \"\") return host;\n const text = descriptor.text ? ` drawing \"${descriptor.text.slice(0, 32)}\"` : \"\";\n throw new Error(\n `Text${text} has no fontFamily. Set one on the text itself, on an `\n + `enclosing <DefaultTextStyle>, or as the theme's \\`default\\` typography `\n + `preset — there is no fallback face.`,\n );\n}\n\nexport function withTextDescriptor(descriptor: Partial<TextState> & ShapeAlignmentInput): TextState {\n const width = descriptor.width ?? 0;\n const height = descriptor.height ?? 0;\n const { x, y, pivot } = resolveShapeAlignment(descriptor, width, height);\n return {\n ...stripShapeAlignmentKeys(descriptor),\n rotation: descriptor.rotation ?? 0,\n scale: descriptor.scale ?? 1,\n x,\n y,\n start: descriptor.start ?? 0,\n end: descriptor.end ?? 1,\n pivot: resolveShapePivot(pivot),\n text: descriptor.text ?? \"\",\n fontSize: descriptor.fontSize ?? 48,\n fontFamily: requireFontFamily(descriptor),\n fontWeight: descriptor.fontWeight ?? 400,\n fontStyle: descriptor.fontStyle ?? 'normal',\n letterSpacing: descriptor.letterSpacing ?? 0,\n lineHeight: descriptor.lineHeight ?? 0,\n textAlign: descriptor.textAlign ?? 'center',\n verticalAlign: descriptor.verticalAlign ?? 'center',\n textDecoration: descriptor.textDecoration ?? 'none',\n wrap: descriptor.wrap ?? false,\n minFontSize: descriptor.minFontSize ?? 12,\n width: descriptor.width ?? 0,\n height: descriptor.height ?? 0,\n segments: descriptor.segments,\n path: descriptor.path ?? null,\n };\n}\n", "import type { Size2D } from \"@/attributes/layout/size\";\nimport type { ShadowResolved } from \"@/attributes/shape/shadow/shadow\";\nimport type { StrokeResolved } from \"@/attributes/shape/stroke/stroke\";\nimport type { Node2D } from \"@/components/trees/2d/node2d\";\nimport {\n declareGlyphAssets, declareRichAssets, measureGlyphs, measureRich, richState, textState,\n type RichValues, type TextSource, type TextValues,\n} from \"@/components/builtins/text/text-layout\";\nimport type { TextState } from \"@/render/descriptors/text\";\nimport { Graphics2D } from \"@/render/graphics2d\";\nimport type { Loader, Measurer, RenderContext2D } from \"@/components/factory/api\";\nimport { currentPass, internalsOf, markDecided } from \"@/components/factory/views\";\n\n/**\n * Glyphs: measured, drawn and loaded by the shared functions in `components/builtins/text/text-layout.ts`.\n * `source` is where the string comes from: a `text` entry, a formatted number.\n */\n\nexport type { TextSource, TextValues, RichValues };\n\ntype Painted = { readonly shadow: unknown; readonly fill: unknown; readonly stroke: unknown };\n\n/** The block's own size, which a filling text still reports, so a hugging ancestor sees its content. */\nexport function measure(measurer: Measurer, s: TextValues, source: TextSource): Size2D {\n const { node, scope } = currentPass();\n markDecided(node);\n return measureGlyphs(s, source, { maxWidth: measurer.max.width, maxHeight: measurer.max.height }, scope);\n}\n\nconst drawn = new WeakMap<Node2D, { readonly s: TextValues; readonly source: TextSource }>();\n\n/** The glyphs, shadow and fill, then the children, then the stroke. A styled piece paints itself, so the node's own paint steps aside. */\nexport function draw(ctx: RenderContext2D, s: TextValues & Painted, source: TextSource): void {\n const c = internalsOf(ctx);\n drawn.set(c.host, { s, source });\n if (c.probing) return;\n const out = c.target();\n const state = textState(s, source, c.host.layoutBounds);\n const segmented = state.segments != null;\n c.inFront(() => {\n const g = new Graphics2D().text(state).shadow(s.shadow as ShadowResolved[]);\n if (!segmented) g.fill(s.fill as never);\n out.draw(g);\n });\n ctx.children();\n c.inFront(() => {\n const stroke = s.stroke as StrokeResolved[];\n if (stroke.length === 0 || segmented) return;\n out.draw(new Graphics2D().text(state).stroke(stroke));\n });\n}\n\nexport function load(loader: Loader, s: TextValues, source: TextSource): void {\n declareGlyphAssets(s, source, loader);\n}\n\n/** What a node drew its glyphs as, for a host's caret geometry. `null` for a node that draws none. */\nexport function textStateOf(node: Node2D): Partial<TextState> | null {\n const last = drawn.get(node);\n return last ? textState(last.s, last.source, node.layoutBounds) : null;\n}\n\nexport function measureRichText(measurer: Measurer, s: RichValues): Size2D {\n const { scope } = currentPass();\n return measureRich(s, { maxWidth: measurer.max.width, maxHeight: measurer.max.height }, scope);\n}\n\nexport function drawRichText(ctx: RenderContext2D, s: RichValues): void {\n const c = internalsOf(ctx);\n if (c.probing) return;\n const out = c.target();\n c.inFront(() => out.draw(new Graphics2D().richText(richState(s, c.host.layoutBounds))));\n ctx.children();\n}\n\nexport function loadRichText(loader: Loader, s: RichValues): void {\n declareRichAssets(s, loader);\n}\n", "import type { AssetScope } from \"@/assets/scope\";\nimport type { Size2D, SizeInput } from \"@/attributes/layout/size\";\nimport type { FillResolved } from \"@/attributes/shape/fill/union\";\nimport { pathOps } from \"@/attributes/shape/path/ops\";\nimport type { StrokeResolved } from \"@/attributes/shape/stroke/stroke\";\nimport { textOps } from \"@/attributes/text/ops\";\nimport type {\n FontStyle, ResolvedTextRun, ResolvedTextSpan, TextAlign, TextCase, TextDecoration, TextSpan, VerticalAlign,\n} from \"@/attributes/text/types\";\nimport type { RichTextState } from \"@/render/descriptors/richtext\";\nimport type { SizeConstraints } from \"@/layout/constraints\";\nimport type { PathData } from \"@/render/descriptors/path\";\nimport type { TextSegment, TextState } from \"@/render/descriptors/text\";\nimport type { MeasureContext2D } from \"@/render/measure-context\";\nimport { AUTOFIT_PROBE_SIZE } from \"@/render/descriptors/text\";\n\n/**\n * Setting a string in a face: measuring the block, cutting it into styled\n * pieces, and the descriptor it draws as. Plain functions over resolved values,\n * behind the components' `TextLayout` module.\n */\n\n/** The shaping fields a glyph node reads, resolved. */\nexport interface TextValues {\n readonly fontFamily: string;\n readonly fontSize: number | \"autofit\";\n readonly fontWeight: number;\n readonly fontStyle: FontStyle;\n readonly letterSpacing: number;\n readonly lineHeight: number;\n readonly textAlign: TextAlign;\n readonly verticalAlign: VerticalAlign;\n readonly textDecoration: TextDecoration;\n readonly textCase: TextCase;\n readonly minFontSize: number;\n readonly fill: unknown;\n readonly stroke: unknown;\n readonly start: number;\n readonly end: number;\n readonly width: SizeInput;\n readonly height: SizeInput;\n}\n\n/** Where the string comes from, and what styles parts of it. */\nexport interface TextSource {\n readonly text: string;\n readonly wraps: boolean;\n /** The path the glyphs ride, for text-on-path. */\n readonly glyphPath: PathData | null;\n /** Stretches a document styles apart from the node: `Text`'s `runs`. */\n readonly runs: readonly ResolvedTextRun[];\n}\n\nexport function casedText(s: TextValues, src: TextSource): string {\n return textOps.applyCase(src.text, s.textCase);\n}\n\n/** The block's size: hugged to its glyphs, filled across, and its own height even when it fills, so a hugging ancestor sees its content. */\nexport function measureGlyphs(s: TextValues, src: TextSource, constraints: SizeConstraints, scope: MeasureContext2D): Size2D {\n // Text-on-path: the visual extent is the path's bounding box (node-local coords, like Path), not a line box.\n if (src.glyphPath != null) {\n const { width, height } = pathOps.size(src.glyphPath);\n const wm = s.width;\n const hm = s.height;\n return {\n width: typeof wm === \"number\" ? wm : wm === \"hug\" ? width : (constraints.maxWidth ?? width),\n height: typeof hm === \"number\" ? hm : hm === \"hug\" ? height : (constraints.maxHeight ?? height),\n };\n }\n\n const measureFontSize = s.fontSize === \"autofit\" ? 16 : s.fontSize;\n const paragraphs = casedText(s, src).split(\"\\n\");\n\n // A styled run changes the box (one word set two sizes up makes the line taller and the block wider), so with styled\n // runs the intrinsic size is summed across the pieces, each in its own style.\n const styled = textSegments(s, src);\n const lineStyles = styled === null\n ? null\n : measureStyledLines(styled, {\n fontFamily: s.fontFamily,\n fontSize: measureFontSize,\n fontStyle: s.fontStyle,\n fontWeight: s.fontWeight,\n letterSpacing: s.letterSpacing,\n });\n\n const lineH = measureFontSize * s.lineHeight;\n const intrinsicW = lineStyles\n ? Math.max(...lineStyles.map(line => line.runs.reduce(\n (w, run) => w + scope.measureText(run.text, run.fontSize, run.fontFamily, run.fontWeight, run.letterSpacing, run.fontStyle).width,\n 0,\n )))\n : Math.max(...paragraphs.map(l => scope.measureText(l, measureFontSize, s.fontFamily, s.fontWeight, s.letterSpacing, s.fontStyle).width));\n\n const wm = s.width;\n const hm = s.height;\n const resolvedW = typeof wm === \"number\" ? wm : wm === \"hug\" ? intrinsicW : constraints.maxWidth ?? 0;\n\n // With wrap on and a finite box narrower than the text, height must account for wrapped lines, each as tall as its tallest run.\n const wraps = src.wraps && resolvedW > 0;\n const lineSizes = lineStyles === null\n ? null\n : wraps\n ? wrappedLineSizes(lineStyles, resolvedW, scope)\n : lineStyles.map(line => Math.max(...line.runs.map(run => run.fontSize)));\n const intrinsicH = lineSizes\n ? lineSizes.reduce((h, size) => h + size * s.lineHeight, 0)\n : (wraps\n ? paragraphs.reduce((n, p) => n + countWrappedLines(p, resolvedW, measureFontSize, s.fontFamily, s.fontWeight, scope, s.letterSpacing, s.fontStyle), 0)\n : paragraphs.length) * lineH;\n\n return { width: resolvedW, height: typeof hm === \"number\" ? hm : intrinsicH };\n}\n\n/** The string cut at every style boundary, each piece styled by the runs over it (the later winning), folding in the Write On reveal window. `null` when neither is active, keeping rendering's single-op path, and always `null` on a path, where the string is one run. */\nexport function textSegments(s: TextValues, src: TextSource): TextSegment[] | null {\n if (src.glyphPath != null) return null;\n const runs = src.runs.filter(r => r.end > r.start);\n const text = casedText(s, src);\n if (text.length === 0) return null;\n\n // Write On: a glyph has no path to trim, so `start`/`end` are a character-reveal window (opacity over a range of characters).\n const hasReveal = s.start > 0 || s.end < 1;\n if (runs.length === 0 && !hasReveal) return null;\n\n // A hard cut at whole characters, one at a time, the way DaVinci's Write On does.\n const revealStart = Math.round(s.start * text.length);\n const revealEnd = Math.round(s.end * text.length);\n\n // `'autofit'` settles on a size the block is measured into, which no single\n // piece can be asked for, so pieces shape at the probe size.\n const nodeFontSize = typeof s.fontSize === \"number\" ? s.fontSize : AUTOFIT_PROBE_SIZE;\n const fill = s.fill as FillResolved[];\n const stroke = s.stroke as StrokeResolved[];\n\n const cuts = new Set<number>([0, text.length]);\n for (const run of runs) { cuts.add(run.start); cuts.add(run.end); }\n if (hasReveal) {\n cuts.add(revealStart);\n cuts.add(revealEnd);\n }\n const points = [...cuts].filter(c => c >= 0 && c <= text.length).sort((a, b) => a - b);\n\n const segments: TextSegment[] = [];\n for (let i = 0; i < points.length - 1; i++) {\n const start = points[i];\n const end = points[i + 1];\n if (end <= start) continue;\n\n // Every shaping field is stated, so the paragraph builder and the caret\n // read a piece the same way.\n const seg: TextSegment = {\n text: text.slice(start, end),\n fontFamily: s.fontFamily,\n fontSize: nodeFontSize,\n fontStyle: s.fontStyle,\n fontWeight: s.fontWeight,\n letterSpacing: s.letterSpacing,\n textDecoration: s.textDecoration,\n opacity: 1,\n x: 0,\n y: 0,\n scale: 1,\n rotation: 0,\n fill,\n stroke,\n };\n\n for (const run of runs) {\n if (start < run.start || end > run.end) continue;\n if (run.fontFamily !== undefined) seg.fontFamily = run.fontFamily;\n if (run.fontSize !== undefined) seg.fontSize = run.fontSize;\n if (run.fontStyle !== undefined) seg.fontStyle = run.fontStyle;\n if (run.fontWeight !== undefined) seg.fontWeight = run.fontWeight;\n if (run.letterSpacing !== undefined) seg.letterSpacing = run.letterSpacing;\n if (run.textDecoration !== undefined) seg.textDecoration = run.textDecoration;\n if (run.fill !== undefined) seg.fill = run.fill;\n if (run.stroke !== undefined) seg.stroke = run.stroke;\n }\n\n if (hasReveal && !(start >= revealStart && end <= revealEnd)) seg.opacity = 0;\n segments.push(seg);\n }\n return segments;\n}\n\n/** The descriptor the block draws as, in a box of `size`. Picking's caret geometry reads the same one. */\nexport function textState(s: TextValues, src: TextSource, size: Size2D | undefined): Partial<TextState> {\n return {\n text: casedText(s, src),\n fontSize: s.fontSize,\n fontFamily: s.fontFamily,\n fontWeight: s.fontWeight,\n fontStyle: s.fontStyle,\n letterSpacing: s.letterSpacing,\n lineHeight: s.lineHeight,\n textAlign: s.textAlign,\n verticalAlign: s.verticalAlign,\n textDecoration: s.textDecoration,\n wrap: src.wraps,\n minFontSize: s.minFontSize,\n width: size?.width ?? 0,\n height: size?.height ?? 0,\n segments: textSegments(s, src) ?? undefined,\n path: src.glyphPath,\n };\n}\n\n/** The node's own face plus whatever a piece sets in another, and the pieces' paints; naming a family here lets it load before layout rather than being discovered by measuring against the fallback face. */\nexport function declareGlyphAssets(s: TextValues, src: TextSource, assets: Pick<AssetScope, \"font\" | \"fill\">): void {\n // Nothing may name a family at all; an `undefined` key is not a font to load.\n if (s.fontFamily) assets.font(s.fontFamily, s.fontWeight);\n for (const segment of textSegments(s, src) ?? []) {\n const family = segment.fontFamily ?? s.fontFamily;\n if (family) assets.font(family, segment.fontWeight);\n assets.fill(segment.fill ?? []);\n for (const stroke of segment.stroke ?? []) assets.fill(stroke.fill);\n }\n}\n\n/** One shaped piece of a line, as measuring needs it: its text and the face it is set in. */\ninterface StyledRun {\n text: string;\n fontFamily: string;\n fontSize: number;\n fontStyle: FontStyle;\n fontWeight: number;\n letterSpacing: number;\n}\n\n/** The segments as lines of runs, split at every newline; an empty line keeps the node's own face. */\nfunction measureStyledLines(segments: TextSegment[], fallback: Omit<StyledRun, \"text\">): { runs: StyledRun[] }[] {\n const lines: { runs: StyledRun[] }[] = [{ runs: [] }];\n for (const segment of segments) {\n const style: Omit<StyledRun, \"text\"> = {\n fontFamily: segment.fontFamily ?? fallback.fontFamily,\n fontSize: segment.fontSize ?? fallback.fontSize,\n fontStyle: segment.fontStyle ?? fallback.fontStyle,\n fontWeight: segment.fontWeight,\n letterSpacing: segment.letterSpacing,\n };\n const parts = segment.text.split(\"\\n\");\n for (let i = 0; i < parts.length; i++) {\n if (i > 0) lines.push({ runs: [] });\n lines[lines.length - 1].runs.push({ text: parts[i], ...style });\n }\n }\n for (const line of lines) {\n if (line.runs.length === 0) line.runs.push({ ...fallback, text: \"\" });\n }\n return lines;\n}\n\n/** Each wrapped line's tallest run, breaking at whitespace the way the paragraph builder does. */\nfunction wrappedLineSizes(lines: { runs: StyledRun[] }[], maxWidth: number, scope: MeasureContext2D): number[] {\n const sizes: number[] = [];\n for (const line of lines) {\n const tokens: { width: number; size: number; space: boolean }[] = [];\n for (const run of line.runs) {\n for (const part of run.text.split(/(\\s+)/)) {\n if (part.length === 0) continue;\n const space = /^\\s+$/.test(part);\n const width = scope.measureText(part, run.fontSize, run.fontFamily, run.fontWeight, run.letterSpacing, run.fontStyle).width;\n const last = tokens[tokens.length - 1];\n if (last && !last.space && !space) {\n last.width += width;\n last.size = Math.max(last.size, run.fontSize);\n } else {\n tokens.push({ width, size: run.fontSize, space });\n }\n }\n }\n if (tokens.length === 0) {\n sizes.push(Math.max(...line.runs.map(run => run.fontSize)));\n continue;\n }\n let lineW = tokens[0].width;\n let size = tokens[0].size;\n for (const token of tokens.slice(1)) {\n if (lineW + token.width <= maxWidth) {\n lineW += token.width;\n size = Math.max(size, token.size);\n } else {\n sizes.push(size);\n lineW = token.space ? 0 : token.width;\n size = token.space ? 0 : token.size;\n }\n }\n sizes.push(size > 0 ? size : Math.max(...line.runs.map(run => run.fontSize)));\n }\n return sizes;\n}\n\nfunction countWrappedLines(\n paragraph: string,\n maxWidth: number,\n fontSize: number,\n fontFamily: string,\n fontWeight: number,\n scope: MeasureContext2D,\n letterSpacing = 0,\n fontStyle: FontStyle = \"normal\",\n): number {\n if (paragraph.length === 0) return 1;\n if (scope.measureText(paragraph, fontSize, fontFamily, fontWeight, letterSpacing, fontStyle).width <= maxWidth) return 1;\n const words = paragraph.split(/(\\s+)/).filter(w => w.length > 0);\n let lines = 1;\n let lineW = 0;\n for (const word of words) {\n const w = scope.measureText(word, fontSize, fontFamily, fontWeight, letterSpacing, fontStyle).width;\n if (lineW === 0) {\n lineW = w;\n } else if (lineW + w <= maxWidth) {\n lineW += w;\n } else {\n lines++;\n lineW = /^\\s+$/.test(word) ? 0 : w;\n }\n }\n return lines;\n}\n\n/** What a rich-text node reads: spans, and the face they inherit from. */\nexport interface RichValues {\n readonly spans: readonly TextSpan[];\n readonly fontFamily: string;\n readonly fontSize: number;\n readonly fontWeight: number;\n readonly fontStyle: FontStyle;\n readonly letterSpacing: number;\n readonly lineHeight: number;\n readonly textAlign: TextAlign;\n readonly fill: unknown;\n readonly stroke: unknown;\n readonly width: SizeInput;\n readonly height: SizeInput;\n}\n\n/** Every span flattened to a run, each field it leaves unset taken from the node. */\nexport function richRuns(s: RichValues): ResolvedTextSpan[] {\n return textOps.flatten(s.spans, {\n fontFamily: s.fontFamily,\n fontSize: s.fontSize,\n fontWeight: s.fontWeight,\n fontStyle: s.fontStyle,\n letterSpacing: s.letterSpacing,\n fill: s.fill as FillResolved[],\n stroke: s.stroke as StrokeResolved[],\n });\n}\n\n/** Lines broken only at `\\n`, each as tall as its tallest run; an empty node keeps one line of its own size. */\nexport function measureRich(s: RichValues, constraints: SizeConstraints, scope: MeasureContext2D): Size2D {\n let lineW = 0;\n let maxLineH = 0;\n let totalW = 0;\n let totalH = 0;\n const finishLine = () => {\n if (lineW > totalW) totalW = lineW;\n totalH += maxLineH;\n lineW = 0;\n maxLineH = 0;\n };\n for (const run of richRuns(s)) {\n const lh = run.fontSize * s.lineHeight;\n const segments = run.text.split(\"\\n\");\n for (let i = 0; i < segments.length; i++) {\n if (i > 0) finishLine();\n lineW += scope.measureText(segments[i], run.fontSize, run.fontFamily, run.fontWeight, run.letterSpacing, run.fontStyle).width;\n if (lh > maxLineH) maxLineH = lh;\n }\n }\n finishLine();\n if (totalH === 0) totalH = s.fontSize * s.lineHeight;\n const wm = s.width;\n const hm = s.height;\n return {\n width: typeof wm === \"number\" ? wm : wm === \"hug\" ? totalW : constraints.maxWidth ?? 0,\n height: typeof hm === \"number\" ? hm : hm === \"hug\" ? totalH : constraints.maxHeight ?? 0,\n };\n}\n\nexport function richState(s: RichValues, size: Size2D | undefined): Partial<RichTextState> {\n return { spans: richRuns(s), lineHeight: s.lineHeight, textAlign: s.textAlign, width: size?.width ?? 0, height: size?.height ?? 0 };\n}\n\nexport function declareRichAssets(s: RichValues, assets: Pick<AssetScope, \"font\" | \"fill\">): void {\n for (const run of richRuns(s)) {\n if (run.fontFamily) assets.font(run.fontFamily, run.fontWeight);\n assets.fill(run.fill);\n for (const stroke of run.stroke) assets.fill(stroke.fill);\n }\n}\n", "import { createContext } from \"@/util/context\";\nimport type { TextStyle } from \"@/attributes/text/types\";\n\n/**\n * Ordinary {@link createContext} tokens, the same primitive authors use, so theme, text-style, seed and\n * user-defined context travel one path down the node tree.\n */\n\nexport const TextStyleToken = createContext<TextStyle>({}, \"text-style\");\n\nexport const ThemeToken = createContext<Record<string, unknown>>({}, \"theme\");\n\nexport const DataToken = createContext<Record<string, unknown>>({}, \"data\");\n\n/** Consumed by author code; not yet wired into per-node randomness. */\nexport const SeedToken = createContext<string | number | undefined>(undefined, \"seed\");\n", "/** The types of the component factories. */\nimport type { Alignment } from \"@/attributes/layout/alignment\";\nimport type { InsetsProps, InsetsResolved } from \"@/attributes/layout/insets\";\nimport type { Size2D, SizeInput } from \"@/attributes/layout/size\";\nimport type { Vector2 } from \"@/attributes/layout/vector2\";\nimport type { Effect } from \"@/attributes/shape/effects/chain\";\nimport type { NodeEffect } from \"@/attributes/shape/effects/union\";\nimport type { NodeBlendMode } from \"@/attributes/shape/fill/blend\";\nimport type { BoxBounds } from \"@/layout/bounds\";\nimport type { PropInputs } from \"@/attributes/properties/inputs\";\nimport type { CameraScope, ChildPlane, Node2D, Node2DProps } from \"@/components/trees/2d/node2d\";\nimport type { Node } from \"@/components/trees/node/node\";\nimport type { SpaceCamera } from \"@/attributes/layout/space3d\";\nimport type { TextStyle } from \"@/attributes/text/types\";\nimport type { AudioEffectsInput } from \"@/attributes/audio/effects/chain\";\nimport type { Param } from \"@/attributes/audio/ramp\";\nimport type { AudioTransition } from \"@/attributes/audio/transition\";\nimport type { AudioEffect } from \"@/attributes/audio/effects/union\";\nimport type { Context } from \"@/util/context\";\nimport type { RefTarget } from \"@/util/reference\";\nimport type { Command } from \"@/tween/command\";\nimport type { Graphics2D } from \"@/render/graphics2d\";\nimport type { BooleanOperation } from \"@/attributes/mask/boolean\";\nimport type { MaskOptions } from \"@/attributes/mask/mask\";\nimport type { FillResolved } from \"@/attributes/shape/fill/union\";\nimport type { ShadowResolved } from \"@/attributes/shape/shadow/shadow\";\nimport type { StrokeResolved } from \"@/attributes/shape/stroke/stroke\";\nimport type { EasingFunction } from \"@/tween/ease/type\";\nimport type { TypeDef } from \"@/components/factory/type-def\";\nimport type { Color } from \"@/attributes/shape/fill/color/parser\";\nimport type { ChildSpace3D, Node3D } from \"@/components/trees/three/node3d\";\nimport type { CameraData3D } from \"@/render3d/camera\";\nimport type { Graphics3D } from \"@/render3d/graphics3d\";\nimport type { Scene3D } from \"@/render3d/scene3d\";\nimport type { LightData3D } from \"@/render3d/light\";\nimport type { EnvironmentData3D, FogData3D } from \"@/render3d/scene-settings\";\nimport type { Shadow3D, Transform3D } from \"@/render3d/transform\";\nimport type { Euler3, EulerOrder, Quaternion, Vector3, Vector3Input } from \"@/render3d/vector3\";\n\ndeclare const typeBrand: unique symbol;\n\n/** A state entry's whole definition: what it accepts, what it resolves to, whether it is private. */\nexport interface Type<In, Out = In, Private extends boolean = false> {\n readonly [typeBrand]?: { readonly in: In; readonly out: Out; readonly private: Private };\n /** @internal The runtime half: default, mapper, tween, meaning. */\n readonly _def: TypeDef;\n}\n\nexport type AnyType = Type<any, any, boolean>;\n/** What a `state` field may hold: a Type, or a plain number, string or boolean default. */\nexport type Entry = AnyType | number | string | boolean;\nexport type StateSpec = { readonly [key: string]: Entry };\n\ntype TypeOf<E> =\n E extends AnyType ? E\n : E extends number ? Type<number>\n : E extends string ? Type<string>\n : E extends boolean ? Type<boolean>\n : never;\nexport type InOf<E> = TypeOf<E> extends Type<infer I, any, any> ? I : never;\nexport type OutOf<E> = TypeOf<E> extends Type<any, infer O, any> ? O : never;\ntype IsPrivate<E> = TypeOf<E> extends Type<any, any, infer P> ? P : false;\ntype IsReadOnly<E> = [InOf<E>] extends [never] ? true : false;\n\n/** The resolved, typed values a field reads. */\nexport type Values<S> = { readonly [K in keyof S]: OutOf<S[K]> };\n/** What a call or document may set: public entries, loose form, or a binding. */\nexport type Inputs<S> = {\n [K in keyof S as IsPrivate<S[K]> extends true ? never : IsReadOnly<S[K]> extends true ? never : K]?:\n InOf<S[K]> | (() => InOf<S[K]>);\n};\n/** What a command may write: any entry, public or private, loose form. */\nexport type Writes<S> = {\n [K in keyof S as IsReadOnly<S[K]> extends true ? never : K]?: InOf<S[K]>;\n};\n\nexport interface Box2DState {\n readonly x: Type<number>;\n readonly y: Type<number>;\n readonly width: Type<SizeInput>;\n readonly height: Type<SizeInput>;\n readonly rotation: Type<number>;\n readonly scale: Type<number>;\n readonly opacity: Type<number>;\n readonly pivot: Type<Alignment, Vector2>;\n readonly padding: Type<InsetsProps, InsetsResolved>;\n readonly effects: Type<Effect, NodeEffect[]>;\n readonly blend: Type<NodeBlendMode>;\n readonly clip: Type<boolean>;\n readonly flex: Type<number>;\n readonly rotationX: Type<number>;\n readonly rotationY: Type<number>;\n readonly depth: Type<number>;\n readonly perspective: Type<number>;\n}\n\n/** What every audio component has: its level, its place in the stereo field, and its own effects. */\nexport interface BoxAudioState {\n readonly volume: Type<Param>;\n readonly pan: Type<Param>;\n readonly mute: Type<boolean>;\n readonly effects: Type<AudioEffectsInput, AudioEffect[]>;\n readonly transitionIn: Type<AudioTransition | undefined>;\n readonly transitionOut: Type<AudioTransition | undefined>;\n}\n\ntype BuiltIn2DCommand = \"moveTo\" | \"fadeTo\" | \"rotateTo\" | \"scaleTo\" | \"layoutTo\" | \"effectTo\" | \"pulse\" | \"wiggle\" | \"to\" | \"set\";\n\ntype Merge<P, S> = Omit<P, keyof S> & S;\n\ndeclare const elementBrand: unique symbol;\n\n/** What calling a component returns. In this slice, the built node itself. */\nexport interface Element<out K extends string = string, out S = unknown, out C = unknown> {\n readonly [elementBrand]?: { readonly key: K; readonly state: S; readonly commands: C };\n}\n\ntype AnyComponent = Component<string, any, any, any, any, any>;\n/** A whole tree, in `allowedChildren`: any component of it. */\ntype TreeName = \"2d\" | \"3d\" | \"audio\";\ntype Allowed = readonly (AnyComponent | TreeName)[] | null;\n\ntype ElementOf<A> =\n A extends null | undefined ? Element<string, Box2DState, {}>\n : A extends readonly [] ? never\n : A extends readonly (infer M)[] ? (M extends Component<infer K, infer S, infer C, any, any, any> ? Element<K, S, C> : M extends TreeName ? Element : never)\n : never;\n\n/** Any node, in the nested and falsy forms a class's `children` took: what a component allowing whole trees accepts. */\ntype ChildrenOfTrees = Element | Node | false | null | undefined | readonly ChildrenOfTrees[];\n\n/** Any 2D node, in the nested and falsy forms a class's `children` took: what a component allowing anything accepts. */\nexport type Children2D = Element | Node2D | false | null | undefined | readonly Children2D[];\n\ntype ChildrenProp<A> = [ElementOf<A>] extends [never]\n ? { readonly children?: never }\n : A extends null | undefined ? { readonly children?: Children2D }\n : A extends readonly TreeName[] ? { readonly children?: ChildrenOfTrees }\n : { readonly children?: readonly ElementOf<A>[] };\n\n/** Built-in placement a 2D node takes beyond its entries: alignment keys (`center`, `topLeft`…), `transform3D`, `flex`. */\ntype Placement2DProps<S> = PropInputs<Omit<Node2DProps, keyof S | \"children\">>;\n\n/**\n * What every call takes beside its entries: an id, a document key, and a\n * `ref` the node `R` is handed to while it is built, before its props apply.\n * A ref of a supertype of `R` is taken too (see {@link RefTarget}).\n */\ninterface CallMetadata<R> {\n readonly id?: string;\n readonly key?: string;\n readonly ref?: RefTarget<R>;\n}\n\nexport type CallProps<S, A, R = Node2D> = Inputs<S> & Placement2DProps<S> & ChildrenProp<A> & CallMetadata<R>;\n\n/** The node class generated from a spec: what a registry or an engine is handed. */\nexport type NodeClass<S, A, N extends Node = Node2D, P = CallProps<S, A>> = new (props?: P) => N;\n\n/** What a component of a non-2D tree is called with: its entries, children of its tree, an id. */\nexport type TreeCallProps<S, R = Node> = Inputs<S> & CallMetadata<R> & {\n readonly children?: readonly (Element | Node)[];\n};\n\n/** The node a component of state `S` and commands `C` builds on `N`: what `new` returns and a `ref` is handed. */\nexport type BuiltNode<S, C, N extends Node = Node2D> = NodeValues<S, N> & CommandMethods<C, N>;\n\nexport interface Component<K extends string, S, C, A, N extends Node = Node2D, P = CallProps<S, A, BuiltNode<S, C, N>>> {\n (props?: P): Element<K, S, C>;\n /** Builds the same node as a call, typed as the node: for engine code written against a class. */\n new (props?: P): BuiltNode<S, C, N>;\n readonly key: K;\n /** The generated node class: hand it to an engine (`nodes: [Gauge.node]`) or a registry. */\n readonly node: NodeClass<S, A, N, P>;\n /** Narrows a child view: `children.filter(BarSeries.is)`. */\n is(child: ChildView<any>): child is ChildView<Element<K, S, C>>;\n}\n\n/**\n * The node a component builds, as engine code and tests holding one see it: the\n * node, and each entry's resolved value. Authoring code works with `Element`.\n */\nexport type NodeOf<C> = C extends Component<any, infer S, infer M, any, infer N, any> ? BuiltNode<S, M, N> : never;\n/** A command, called on the node as a class's `command` method is. */\nexport type CommandMethods<C, N extends Node = Node2D> = {\n [K in Exclude<keyof C, keyof N>]: (args?: { readonly data?: unknown; readonly duration?: number; readonly easing?: EasingFunction }) => Command<Record<string, unknown>>;\n};\nexport type NodeValues<S, N extends Node = Node2D> =\n (N extends Node2D ? Node2D<Node2DProps & EntryProps<S>> : N) & { -readonly [E in Exclude<keyof S, keyof N>]: OutOf<S[E]> };\n/** Each entry's loose form, as `set` and `to` take it. */\ntype EntryProps<S> = { [E in Exclude<keyof S, keyof Node2DProps>]: InOf<S[E]> };\n\ntype StateOfElement<E> = E extends Element<any, infer S, any> ? S : never;\ntype CommandsOfElement<E> = E extends Element<any, any, infer C>\n ? unknown extends C ? string : (keyof C & string) | BuiltIn2DCommand\n : never;\n\n/** A child, as a parent's fields see it. */\nexport interface ChildView<out E extends Element = Element> {\n readonly id: string;\n readonly key: E extends Element<infer K> ? K : string;\n readonly state: Values<StateOfElement<E>>;\n /** Its size, measured against the room this pass gives it; outside a pass (in a command), the size it was last laid out at. */\n readonly size: Size2D;\n /** Its own children, as it hands them to its fields: how a command reaches parts nested inside a child. */\n readonly children: readonly ChildView[];\n measure(max: Max): Size2D;\n to(targets: Writes<StateOfElement<E>>): Piece;\n run(name: CommandsOfElement<E>, args?: object): Piece;\n}\n\nexport interface Max {\n readonly width?: number;\n readonly height?: number;\n}\n\nexport interface FontSpec {\n readonly fontFamily: string;\n readonly fontSize: number;\n readonly fontWeight?: number;\n readonly letterSpacing?: number;\n}\n\nexport interface Measurer {\n readonly max: Max;\n /** The node's clock: a size that changes with time (a spin, a flow) reads it here. */\n readonly time: Clock;\n text(text: string, font: FontSpec): Size2D;\n}\n\nexport interface Clock {\n readonly total: number;\n readonly elapsed: number;\n}\n\n/** What `load` declares: everything that must be in before the node is measured or drawn. */\nexport interface Loader {\n font(family: string, weight?: number | string): void;\n image(src: string): void;\n video(src: string, trim?: { readonly start?: number; readonly end?: number }): void;\n /**\n * Async setup. `before: \"layout\"` holds measuring too (a font engine, MathJax); the default holds only the frame.\n * A function `load` resolves to frees what it loaded when the asset's window is evicted.\n */\n task(key: string, load: () => Promise<unknown>, options?: { readonly before?: \"layout\" | \"render\" }): void;\n /** A paint the component works out itself (a run's fill); paint entries load themselves. */\n fill(fills: FillResolved | readonly FillResolved[]): void;\n}\n\n/** A value a component hands its subtree under a context, which `Types.*({ inherit })` entries read. */\nexport interface Provided<T = unknown> {\n readonly context: Context<T>;\n readonly value: T;\n}\n\nexport function provides<T>(context: Context<T>, value: T): Provided<T> {\n return { context, value };\n}\n\nexport interface RenderContext2D {\n readonly size: Size2D;\n readonly time: Clock;\n draw(graphics: Graphics2D | readonly Graphics2D[] | null | undefined): void;\n /** Draws your children here. */\n children(): void;\n /** Your first child is the stencil; the rest draw through it. */\n mask(options: MaskOptions): void;\n /** Your children become one shape by `op`, painted with `paint`. */\n merge(op: BooleanOperation, paint: MergePaint): void;\n /** Your children through a camera viewing your box. */\n camera(scope: CameraScope): void;\n /** Your children standing in one 2.5D space seen by `camera`, drawn far to near. */\n space(camera: SpaceCamera): void;\n /**\n * Your 3D children rendered into a new scene, for a fill (`Fills.canvas3D`) or\n * more drawing. Picking projects through the same scene.\n */\n scene3D(): Scene3D;\n /** Run `body` with `style` the default for text drawn in it; `null` refuses the inherited style. */\n textStyle(style: TextStyle | null, body: () => void): void;\n /** Run `body` with what it draws confined to `shape`'s outline. */\n clip(shape: Graphics2D, body: () => void): void;\n /**\n * Run `body` as your own paint: standing in a 2.5D space, only what lies in\n * front of the lens shows, as a class's own paint does. `Paint.draw` does this\n * for the paint it draws; a component drawing with `draw` wraps it here.\n */\n inFront(body: () => void): void;\n /** Whether an ancestor already stands you in a 2.5D space, so a space of your own would nest in it. */\n readonly inSpace: boolean;\n /** Your nearest ancestor that `component` built, read-only, or `null` when none is above you. */\n ancestor<K extends string, S, C>(component: Component<K, S, C, any, any, any>): NodeView<Element<K, S, C>> | null;\n}\n\n/** Another node as a component reads it: its id, its resolved state and the size it was laid out at. */\nexport interface NodeView<out E extends Element = Element> {\n readonly id: string;\n readonly key: E extends Element<infer K> ? K : string;\n /** As its own fields read it: a reference entry of its own is a view of that node from where it stands. */\n readonly state: Values<StateOfElement<E>>;\n readonly size: Size2D;\n /** Where it stands in the reader's own frame (y up from the reader's centre): offset, turn and scale. */\n readonly frame: NodeFrame;\n}\n\nexport interface NodeFrame {\n readonly x: number;\n readonly y: number;\n readonly rotation: number;\n readonly scale: number;\n}\n\n/** What a merged shape is painted with: a shape's resolved paint entries. */\nexport interface MergePaint {\n readonly fill: FillResolved[];\n readonly stroke: StrokeResolved[];\n readonly shadow: ShadowResolved[];\n readonly overlay?: FillResolved[];\n}\n\n/** Where a 2D child goes: a box centred on (x, y) from your centre, y up, plus an optional slot transform. */\nexport interface Placement2D {\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n readonly rotation?: number;\n readonly scale?: number;\n readonly opacity?: number;\n readonly depth?: number;\n readonly rotationX?: number;\n readonly rotationY?: number;\n /** What the child's own `x`/`y` mean in your units (a graph's): read wherever its position is, by paint, picking and a host's drag. */\n readonly plane?: ChildPlane;\n}\n\n/** Your content box, as `layout` is handed it, and the node's clock for a layout that moves with time. */\nexport interface LayoutBox extends BoxBounds {\n readonly time: Clock;\n}\n\n/** A point an editor can drag to set an entry: where it sits in your frame (y up from your centre), and the value dropping it there gives. */\nexport interface Handle<V> {\n at(state: V, size: Size2D): Vector2 | null;\n /** Where it was dropped, as the entry's value; by default the point itself. */\n value?(at: Vector2, state: V, size: Size2D): Vector2;\n}\n\ndeclare const pieceBrand: unique symbol;\n/** A timed piece of a command. */\nexport interface Piece {\n readonly [pieceBrand]?: true;\n /** @internal */\n readonly _piece: PieceData;\n}\n\n/** @internal */\nexport type PieceData =\n | { readonly kind: \"tween\"; readonly targets: Record<string, unknown> }\n | { readonly kind: \"animate\"; readonly frame: (t: number) => Record<string, unknown>; readonly eased: boolean }\n | { readonly kind: \"wait\"; readonly seconds: number }\n | { readonly kind: \"sound\"; readonly src: string; readonly options: SoundOptions }\n | { readonly kind: \"together\" | \"sequence\"; readonly pieces: readonly Piece[] }\n | { readonly kind: \"stagger\"; readonly pieces: readonly Piece[]; readonly overlap: number }\n | { readonly kind: \"child\"; readonly node: object; readonly targets: Record<string, unknown> }\n | { readonly kind: \"run\"; readonly node: object; readonly name: string; readonly args: object | undefined };\n\n/** How a sound plays: today's `AudioClip` fields, and the bus it feeds when its node isn't one. */\nexport interface SoundOptions {\n readonly trimStart?: number;\n readonly trimEnd?: number;\n readonly loop?: boolean;\n readonly volume?: Param;\n readonly speed?: Param;\n readonly effects?: AudioEffectsInput;\n readonly transitionIn?: AudioTransition;\n readonly transitionOut?: AudioTransition;\n /** Missing from the catalog, it is skipped rather than an error. */\n readonly optional?: boolean;\n /** The id of the bus it feeds. A sound node feeds the buses it sits in. */\n readonly bus?: string;\n /** Ends with its source rather than staying open: a picture's sound, which stops when the picture does. */\n readonly closed?: boolean;\n}\n\nexport interface Timeline<A = {}, S = {}> {\n readonly args: A;\n readonly duration: number;\n readonly easing: EasingFunction | undefined;\n /** The node this command acts on, read-only: its id (a seed), its size. */\n readonly node: NodeView;\n tween(targets: Writes<S>): Piece;\n /** `frame` at each point of the command; `eased: false` hands it linear progress, to ease per part with `ease`. */\n animate(frame: (t: number) => Writes<S>, options?: { readonly eased?: boolean }): Piece;\n /** The command's easing at `t`. */\n ease(t: number): number;\n /** `src` plays from here: cut when the command ends, or to its own end when the command has no length. */\n sound(src: string, options?: SoundOptions): Piece;\n wait(seconds: number): Piece;\n together(pieces: readonly Piece[]): Piece;\n sequence(pieces: readonly Piece[]): Piece;\n stagger(pieces: readonly Piece[], options?: { readonly overlap?: number }): Piece;\n}\n\ntype Kids = readonly ChildView<any>[];\n\nexport type CommandEntry<A, S, V, K> =\n // The names as written, so a module's command fits any state holding those entries.\n | (A extends readonly unknown[] ? { readonly args: A & readonly (keyof Writes<S> & string)[]; readonly run?: undefined; readonly easing?: EasingFunction; readonly entrance?: boolean } : never)\n | ((timeline: Timeline<{}, S>, state: V, children: K) => Piece)\n // `easing`: what the command eases by when its row gives none. `entrance`:\n // the timeline holds its first frame ahead of it (`CommandMeta.entrance`).\n | (A extends readonly unknown[] ? never : { readonly args: A; run(timeline: Timeline<Values<A>, S>, state: V, children: K): Piece; readonly easing?: EasingFunction; readonly entrance?: boolean });\n\nexport type CommandsSpec<C, S, V, K> = { [N in keyof C]: CommandEntry<C[N], S, V, K> };\n\nexport type FieldState<All, A> = Values<All> & { readonly children: readonly ChildView<ElementOf<A>>[] };\nexport type BuilderState<All, A> = Values<All> & { readonly children: readonly ElementOf<A>[] };\ntype OwnKids<A, B> = readonly ChildView<[B] extends [never] ? ElementOf<A> : Extract<B, Element>>[];\n\n/**\n * New defaults for entries, own or built in. A function is a binding: handed the\n * live state, and `given`, what the call or document row set when the node was\n * built (which never changes), for a default derived from those.\n */\nexport type Defaults<All, A> = {\n readonly [E in keyof All]?: InOf<All[E]> | ((state: FieldState<All, A>, given: Readonly<Record<string, unknown>>) => InOf<All[E]>);\n};\n\nexport interface Spec2D<K extends string, All, S, C, A, B> {\n readonly key: K;\n readonly state?: S;\n readonly defaults?: Defaults<All, A>;\n /** Old prop keys a stored row may still carry → the entry each became. */\n readonly renamed?: Readonly<Record<string, string>>;\n /** Entries that still work but should no longer be set: why, and what to use instead. */\n readonly deprecated?: Readonly<Record<string, string>>;\n /** Value hooks by entry, or by an old key in `renamed` to convert only what was stored under it (`migrateNodeProps`). */\n readonly migrate?: Readonly<Record<string, (value: unknown) => unknown>>;\n readonly allowedChildren?: A;\n /** The components it goes only inside; unsaid, wherever its tree allows. A row elsewhere fails its build. */\n readonly allowedParents?: readonly AnyComponent[];\n readonly children?: (state: BuilderState<All, A>) => readonly B[];\n readonly commands?: CommandsSpec<C, All, FieldState<All, A>, OwnKids<A, B>>;\n readonly load?: (loader: Loader, state: FieldState<All, A>) => void;\n /** What the subtree inherits: the nearest provider's value for each context, `inherited` reading what's above. */\n readonly provide?: (state: FieldState<All, A>, inherited: <T>(context: Context<T>) => T) => readonly Provided[];\n readonly measure?: (measurer: Measurer, state: FieldState<All, A>, children: OwnKids<A, B>) => Size2D;\n readonly layout?: (box: LayoutBox, state: FieldState<All, A>, children: OwnKids<A, B>) => readonly Placement2D[];\n /** What a child not added yet would take its `x`/`y` in: where a host drops or pastes one. Layout's `plane` answers for the rest. */\n readonly plane?: (box: LayoutBox, state: FieldState<All, A>) => ChildPlane | null;\n /** Points an editor can drag, by the entry each sets. */\n readonly handles?: { readonly [entry: string]: Handle<FieldState<All, A>> };\n /** Your bounds when they are not your box (a mark's ink): what selection and picking take. */\n readonly bounds?: (size: Size2D, state: FieldState<All, A>) => BoxBounds;\n readonly render?: (ctx: RenderContext2D, state: FieldState<All, A>) => void;\n /** The coordinates your 3D children's `x`, `y`, `z` are in (a graph's units), for a viewport over them. */\n readonly space?: (state: FieldState<All, A>) => ChildSpace3D | null;\n}\n\n/** A sound, or a bus mixing what is in it. It has no box and draws nothing: sound comes from its commands. */\nexport interface SpecAudio<K extends string, All, S, C, A, B> {\n readonly key: K;\n readonly state?: S;\n readonly defaults?: Defaults<All, A>;\n /** Old prop keys a stored row may still carry → the entry each became. */\n readonly renamed?: Readonly<Record<string, string>>;\n /** Entries that still work but should no longer be set: why, and what to use instead. */\n readonly deprecated?: Readonly<Record<string, string>>;\n /** Value hooks by entry, or by an old key in `renamed` to convert only what was stored under it (`migrateNodeProps`). */\n readonly migrate?: Readonly<Record<string, (value: unknown) => unknown>>;\n readonly allowedChildren?: A;\n /** The components it goes only inside; unsaid, wherever its tree allows. A row elsewhere fails its build. */\n readonly allowedParents?: readonly AnyComponent[];\n readonly children?: (state: BuilderState<All, A>) => readonly B[];\n readonly commands?: CommandsSpec<C, All, FieldState<All, A>, Kids>;\n readonly load?: (loader: Loader, state: FieldState<All, A>) => void;\n readonly provide?: (state: FieldState<All, A>, inherited: <T>(context: Context<T>) => T) => readonly Provided[];\n}\n\n/** What every 3D component has: its place, turn and scale, and how the scene shows it. */\nexport interface Transform3DState {\n readonly x: Type<number>;\n readonly y: Type<number>;\n readonly z: Type<number>;\n readonly rotationX: Type<number>;\n readonly rotationY: Type<number>;\n readonly rotationZ: Type<number>;\n readonly rotationOrder: Type<EulerOrder>;\n readonly quaternion: Type<Quaternion>;\n readonly scaleX: Type<number>;\n readonly scaleY: Type<number>;\n readonly scaleZ: Type<number>;\n readonly lookAt: Type<Vector3Input | undefined, Vector3 | undefined>;\n readonly visible: Type<boolean>;\n readonly shadow: Type<Shadow3D>;\n readonly renderOrder: Type<number>;\n}\n\n/** A 3D call's vector forms of the axes: `position: [x, y, z]`, `rotation`, `scale` (one number scales all three). */\nexport interface Placement3DProps {\n readonly position?: Vector3Input | (() => Vector3Input);\n readonly rotation?: Vector3Input | Euler3 | (() => Vector3Input | Euler3);\n readonly scale?: Vector3Input | (() => Vector3Input);\n}\n\nexport type CallProps3D<S, R = Node3D> = TreeCallProps<S, R> & Placement3DProps;\n\n/** What a 3D `render` draws into: today's scene calls, with a camera standing where its node stands. */\nexport interface RenderContext3D {\n readonly time: Clock;\n /**\n * `render` runs only so what it draws loads, and nothing is shown: only the\n * materials, models and environment count, so geometry built from data may be skipped.\n */\n readonly declaring: boolean;\n draw(graphics: Graphics3D | null | undefined): void;\n light(light: LightData3D, transform?: Transform3D): void;\n /** The scene's camera, placed by this node's transform. A node that stands one is no group: its children stay in its parent's space. */\n camera(camera: CameraData3D): void;\n fog(fog: FogData3D | Color | null): void;\n environment(environment: EnvironmentData3D | null): void;\n}\n\nexport interface Spec3D<K extends string, All, S, C, A, B> {\n readonly key: K;\n readonly state?: S;\n readonly defaults?: Defaults<All, A>;\n /** Old prop keys a stored row may still carry → the entry each became. */\n readonly renamed?: Readonly<Record<string, string>>;\n /** Entries that still work but should no longer be set: why, and what to use instead. */\n readonly deprecated?: Readonly<Record<string, string>>;\n /** Value hooks by entry, or by an old key in `renamed` to convert only what was stored under it (`migrateNodeProps`). */\n readonly migrate?: Readonly<Record<string, (value: unknown) => unknown>>;\n readonly allowedChildren?: A;\n /** The components it goes only inside; unsaid, wherever its tree allows. A row elsewhere fails its build. */\n readonly allowedParents?: readonly AnyComponent[];\n readonly children?: (state: BuilderState<All, A>) => readonly B[];\n readonly commands?: CommandsSpec<C, All, FieldState<All, A>, Kids>;\n readonly load?: (loader: Loader, state: FieldState<All, A>) => void;\n readonly provide?: (state: FieldState<All, A>, inherited: <T>(context: Context<T>) => T) => readonly Provided[];\n readonly render?: (ctx: RenderContext3D, state: FieldState<All, A>) => void;\n /** The coordinates your 3D children's `x`, `y`, `z` are in (a graph's units): where each lands in yours. */\n readonly space?: (state: FieldState<All, A>) => ChildSpace3D | null;\n}\n\nexport type { Merge, Kids, Allowed, AnyComponent };\n", "import type { Fill } from \"@/attributes/shape/fill/chain\";\nimport type { Shadow } from \"@/attributes/shape/shadow/shadow\";\nimport type { Stroke } from \"@/attributes/shape/stroke/stroke\";\nimport { textOps } from \"@/attributes/text/ops\";\nimport type { FontStyle, TextAlign, TextStyle } from \"@/attributes/text/types\";\nimport { TextStyleToken } from \"@/runtime/builtin-context\";\nimport { provides, type Provided, type Values } from \"@/components/factory/api\";\nimport type { Inherit } from \"@/components/factory/type-def\";\nimport { Types } from \"@/components/factory/types\";\n\n/**\n * The face text is set in, each field taken, when the author leaves it unset,\n * from the cascade: the theme's `default` typography, under the nearest\n * provider's style, under the node's own `variant` preset.\n */\n\nfunction cascade(use: Parameters<Inherit>[0], given: Readonly<Record<string, unknown>>): TextStyle {\n const variant = given.variant as string | undefined;\n return textOps.mergeStyle(\n textOps.mergeStyle(textOps.preset(\"default\"), use(TextStyleToken)),\n variant ? textOps.preset(variant) : undefined,\n );\n}\n\n/** What `key` inherits. `autofit: false` refuses an inherited `'autofit'` size, for a node that can't fit to its box. */\nexport function inherit(key: keyof TextStyle, options: { readonly autofit?: boolean } = {}): Inherit {\n return (use, given) => {\n const value = cascade(use, given)[key];\n return key === \"fontSize\" && value === \"autofit\" && options.autofit === false ? undefined : value;\n };\n}\n\nexport const state = {\n // No default: a face nobody chose is one never declared and never loaded, so the renderer says so.\n fontFamily: Types.custom<string>(undefined as unknown as string, { inherit: inherit(\"fontFamily\") }),\n fontSize: Types.custom<number | \"autofit\">(48, {\n lerp: (a, b, t) => textOps.lerpFontSize(a, b, t) as number | \"autofit\",\n inherit: inherit(\"fontSize\"),\n }),\n fontWeight: Types.number(400, { inherit: inherit(\"fontWeight\") }),\n fontStyle: Types.custom<FontStyle>(\"normal\", { inherit: inherit(\"fontStyle\") }),\n letterSpacing: Types.number(0, { inherit: inherit(\"letterSpacing\") }),\n lineHeight: Types.number(1.2, { inherit: inherit(\"lineHeight\") }),\n textAlign: Types.custom<TextAlign>(\"center\", { inherit: inherit(\"textAlign\") }),\n verticalAlign: Types.oneOf([\"top\", \"center\", \"bottom\"], { default: \"center\" }),\n textDecoration: Types.oneOf([\"none\", \"underline\", \"line-through\"]),\n textCase: Types.oneOf([\"none\", \"upper\", \"lower\", \"title\"]),\n minFontSize: Types.number(12),\n variant: Types.custom<string | undefined>(undefined),\n fill: Types.fill(undefined, { inherit: inherit(\"fill\") }),\n stroke: Types.stroke(undefined, { inherit: inherit(\"stroke\") }),\n shadow: Types.shadow(undefined, { inherit: inherit(\"shadow\") }),\n};\n\n/** The style a provider sets: each field left unset is inherited from above. */\nexport const provided = {\n fontFamily: Types.custom<string | undefined>(undefined),\n fontSize: Types.custom<number | \"autofit\" | undefined>(undefined),\n fontWeight: Types.custom<number | undefined>(undefined),\n fontStyle: Types.custom<FontStyle | undefined>(undefined),\n letterSpacing: Types.custom<number | undefined>(undefined),\n lineHeight: Types.custom<number | undefined>(undefined),\n textAlign: Types.custom<TextAlign | undefined>(undefined),\n fill: Types.custom<Fill | undefined>(undefined),\n stroke: Types.custom<Stroke | undefined>(undefined),\n shadow: Types.custom<Shadow | undefined>(undefined),\n};\n\n/** The subtree's style: the inherited one with this provider's fields laid over it. */\nexport function provide(s: Values<typeof provided>, inherited: <T>(context: { readonly id: symbol; readonly defaultValue: T }) => T): readonly Provided[] {\n return [provides(TextStyleToken, textOps.mergeStyle(inherited(TextStyleToken), s as TextStyle))];\n}\n\n/** This provider's own fields, as the default for text drawn under it. */\nexport function current(s: Values<typeof provided>): TextStyle {\n return textOps.mergeStyle({}, s as TextStyle);\n}\n", "import { NodeAudio } from \"@/components/trees/audio/node-audio\";\nimport type { Allowed, BoxAudioState, BuiltNode, ChildView, Component, Element, Merge, SpecAudio, StateSpec, TreeCallProps } from \"@/components/factory/api\";\nimport { componentBase, finishComponent, lowering, type CoreSpec } from \"@/components/factory/factory\";\nimport { childView } from \"@/components/factory/views\";\n\n/**\n * An audio component: a sound, or a bus mixing the sounds in it. Lowers onto a\n * generated `NodeAudio` subclass. It has no audio field: what it plays comes\n * from its commands' `timeline.sound`.\n */\nexport function componentAudio<\n const K extends string,\n const S extends StateSpec = {},\n const C = {},\n const A extends Allowed = null,\n const B extends Element = never,\n>(spec: SpecAudio<K, Merge<BoxAudioState, S>, S, C, A, B>): Component<K, Merge<BoxAudioState, S>, C, A, NodeAudio, TreeCallProps<Merge<BoxAudioState, S>, BuiltNode<Merge<BoxAudioState, S>, C, NodeAudio>>> {\n const l = lowering(spec as unknown as CoreSpec, NodeAudio);\n\n class Generated extends componentBase(NodeAudio, l) {\n override _commandChildren(): readonly ChildView[] {\n return this.childrenAudio.map(childView);\n }\n }\n\n return finishComponent(Generated, l) as never;\n}\n", "import type { AssetScope } from \"@/assets/scope\";\nimport type { Color } from \"@/attributes/shape/fill/color/parser\";\nimport { getNodeDescriptor } from \"@/document/node-decorator\";\nimport type { Node } from \"@/components/trees/node/node\";\nimport { Node3D, type ChildSpace3D } from \"@/components/trees/three/node3d\";\nimport type { CameraData3D } from \"@/render3d/camera\";\nimport type { Graphics3D } from \"@/render3d/graphics3d\";\nimport type { LightData3D } from \"@/render3d/light\";\nimport type { RenderContext3D as SceneTarget } from \"@/render3d/render-context3d\";\nimport type { EnvironmentData3D, FogData3D } from \"@/render3d/scene-settings\";\nimport { declareEnvironment } from \"@/render3d/tracking\";\nimport type { Transform3D } from \"@/render3d/transform\";\nimport type {\n Allowed, BuiltNode, CallProps3D, ChildView, Clock, Component, Element, Merge, RenderContext3D, Spec3D, StateSpec, Transform3DState,\n} from \"@/components/factory/api\";\nimport { componentBase, finishComponent, lowering, type CoreSpec } from \"@/components/factory/factory\";\nimport { childView, setKeyLookup } from \"@/components/factory/views\";\n\nsetKeyLookup((n) => getNodeDescriptor(n.constructor as new () => object)?.key);\n\ntype AnySpec = Spec3D<string, any, any, any, any, any>;\n\ninterface Host3D extends Node3D {\n _ownTransform(): Transform3D;\n}\n\n/** What a 3D `render` draws into: the scene being built, with a camera placed where its node stands. */\nclass RenderContext3DImpl implements RenderContext3D {\n target: SceneTarget | null = null;\n /** Set when `render` asks for a camera: such a node is no group, and stands its camera instead. */\n camera3D = false;\n environment3D: EnvironmentData3D | null = null;\n declaring = false;\n\n constructor(readonly host: Host3D) { }\n\n get time(): Clock {\n return this.host.time;\n }\n\n draw(graphics: Graphics3D | null | undefined): void {\n if (graphics) this.target?.draw(graphics);\n }\n\n light(light: LightData3D, transform?: Transform3D): void {\n this.target?.light(light, transform);\n }\n\n camera(camera: CameraData3D): void {\n this.camera3D = true;\n this.target?.camera({ ...this.host._ownTransform(), ...camera } as CameraData3D);\n }\n\n fog(fog: FogData3D | Color | null): void {\n this.target?.fog(fog);\n }\n\n environment(environment: EnvironmentData3D | null): void {\n this.environment3D = environment;\n this.target?.environment(environment);\n }\n}\n\n/**\n * A 3D component: placed by its transform, drawn with `Graphics3D`, lights and\n * cameras. Lowers onto a generated `Node3D` subclass; its children render\n * after it, in its space.\n */\nexport function component3d<\n const K extends string,\n const S extends StateSpec = {},\n const C = {},\n const A extends Allowed = null,\n const B extends Element = never,\n>(spec: Spec3D<K, Merge<Transform3DState, S>, S, C, A, B>): Component<K, Merge<Transform3DState, S>, C, A, Node3D, CallProps3D<Merge<Transform3DState, S>, BuiltNode<Merge<Transform3DState, S>, C, Node3D>>> {\n const s = spec as unknown as AnySpec;\n const l = lowering(s as unknown as CoreSpec, Node3D);\n\n class Generated extends componentBase(Node3D, l) implements Host3D {\n declare _ctx3d: RenderContext3DImpl;\n declare _isCamera: boolean | undefined;\n\n constructor(props?: Record<string, unknown>) {\n super(props);\n this._ctx3d = new RenderContext3DImpl(this);\n }\n\n protected override renderSelf(ctx: SceneTarget): void {\n if (!s.render) return;\n const c = this._ctx3d;\n c.target = ctx;\n try {\n s.render(c, this._view as never);\n } finally {\n c.target = null;\n }\n }\n\n /** A node that stands a camera places the camera, not a group: its children stay in the parent's space. */\n protected override groupTransform(): Transform3D {\n return this._rendersCamera() ? {} : super.groupTransform();\n }\n\n _rendersCamera(): boolean {\n if (this._isCamera === undefined) {\n const c = this._ctx3d;\n c.camera3D = false;\n if (s.render) s.render(c, this._view as never);\n this._isCamera = c.camera3D;\n }\n return this._isCamera;\n }\n\n _ownTransform(): Transform3D {\n return this.transform3D();\n }\n\n /** What `render` draws loads itself: its textures and models, and an environment map it sets. */\n override declareAssets(assets: AssetScope): void {\n const c = this._ctx3d;\n c.environment3D = null;\n c.declaring = true;\n try {\n super.declareAssets(assets);\n } finally {\n c.declaring = false;\n }\n declareEnvironment(c.environment3D, assets);\n }\n\n override _commandChildren(): readonly ChildView[] {\n return (this.children as Node[]).filter((c) => c instanceof Node3D).map(childView);\n }\n }\n\n if (s.space) {\n const space = s.space;\n (Generated.prototype as unknown as { _spaceOf: (child: Node3D | null) => ChildSpace3D | null })._spaceOf = function (this: Generated) {\n return space(this._view as never);\n };\n }\n\n return finishComponent(Generated, l) as never;\n}\n", "import { lerpFill3D, resolveFill3D, type Fill3D } from \"@/render3d/fill3d\";\nimport type { Geometry3D } from \"@/render3d/geometry\";\nimport { Graphics3D, resolveMaterialShorthand3D, type MaterialShorthand3D } from \"@/render3d/graphics3d\";\nimport type { Material3D, Shading3D } from \"@/render3d/material\";\nimport type { Texture3D } from \"@/render3d/texture\";\nimport type { Blend3D, Faces3D } from \"@/render3d/transform\";\nimport type { Values } from \"@/components/factory/api\";\nimport { Types } from \"@/components/factory/types\";\nimport { optional, optionalColor } from \"@/components/modules/three-entries\";\n\n/** `Mesh3D`'s surface: a material, or the shorthand entries one is built from. */\nexport const state = {\n material: optional<Material3D | readonly Material3D[]>(),\n fill: Types.custom<Fill3D>(\"white\", { lerp: lerpFill3D }),\n opacity: optional<number>(),\n roughness: optional<number>(),\n metalness: optional<number>(),\n emission: optionalColor(),\n emissionStrength: optional<number>(),\n normalMap: optional<Texture3D>(),\n roughnessMap: optional<Texture3D>(),\n metalnessMap: optional<Texture3D>(),\n aoMap: optional<Texture3D>(),\n alphaMap: optional<Texture3D>(),\n envMapIntensity: optional<number>(),\n wireframe: optional<boolean>(),\n shading: optional<Shading3D>(),\n faces: optional<Faces3D>(),\n vertexColors: optional<boolean>(),\n blend: optional<Blend3D>(),\n unlit: Types.custom(false),\n};\n\ntype MaterialState = Values<typeof state>;\n\nconst SHORTHAND_KEYS = [\n \"opacity\", \"roughness\", \"metalness\",\n \"emission\", \"emissionStrength\", \"normalMap\", \"roughnessMap\",\n \"metalnessMap\", \"aoMap\", \"alphaMap\", \"envMapIntensity\", \"wireframe\",\n \"shading\", \"faces\", \"vertexColors\", \"blend\",\n] as const;\n\n/** The entries that are set, as a material shorthand. */\nexport function shorthand(s: MaterialState): MaterialShorthand3D {\n const out: Record<string, unknown> = {};\n if (s.material !== undefined) out.material = s.material;\n if (s.fill !== undefined) out.fill = s.fill;\n for (const key of SHORTHAND_KEYS) if (s[key] !== undefined) out[key] = s[key];\n if (s.unlit) out.unlit = true;\n return out as MaterialShorthand3D;\n}\n\n/** `geometry` with this surface; nothing without one. */\nexport function mesh(s: MaterialState, geometry: Geometry3D | undefined): Graphics3D {\n const g3 = new Graphics3D();\n if (geometry) g3.mesh(geometry, resolveMaterialShorthand3D(shorthand(s)));\n return g3;\n}\n\n/** The one material instanced copies share: the first, when the shorthand resolves to several. */\nexport function single(s: MaterialState): Material3D {\n const resolved = resolveMaterialShorthand3D(shorthand(s));\n return (Array.isArray(resolved) ? resolved[0] : resolved) as Material3D;\n}\n\nconst POINTS_KEYS = [\"opacity\", \"alphaMap\", \"blend\", \"vertexColors\"] as const;\n\n/** A points material: the given one, or the fill's colour and map with what a point cloud reads. */\nexport function points(s: MaterialState): Material3D {\n if (s.material !== undefined) return (Array.isArray(s.material) ? s.material[0] : s.material) as Material3D;\n const material: Record<string, unknown> = { type: \"points\" };\n const fill = resolveFill3D(s.fill);\n if (fill.color !== undefined) material.color = fill.color;\n if (fill.map !== undefined) material.map = fill.map;\n for (const key of POINTS_KEYS) if (s[key] !== undefined) material[key] = s[key];\n return material as unknown as Material3D;\n}\n", "import type { Color, NormalizedColor } from \"@/attributes/shape/fill/color/parser\";\nimport { colorOps } from \"@/attributes/shape/fill/lerp\";\nimport { lerpOptionalVector3, resolveOptionalVector3, type Vector3, type Vector3Input } from \"@/render3d/vector3\";\nimport type { Type } from \"@/components/factory/api\";\nimport { Types, type EntryOptions } from \"@/components/factory/types\";\n\n/** The 3D tree's entries that start unset: the renderer's own default applies until one is given. */\n\nexport function optional<T>(): Type<T | undefined> {\n return Types.custom<T | undefined>(undefined);\n}\n\n/** A number, unset until given, with a number's hints. */\nexport function optionalNumber<const H extends NumberHints>(hints: H): Type<number | undefined> {\n return Types.custom<number | undefined, number | undefined, H>(undefined, { kind: \"number\", ...hints }) as Type<number | undefined>;\n}\n\ninterface NumberHints extends EntryOptions {\n readonly min?: number;\n readonly max?: number;\n readonly step?: number;\n readonly unit?: string;\n}\n\nexport function optionalColor(): Type<Color | undefined, NormalizedColor | undefined> {\n return Types.custom<Color | undefined, NormalizedColor | undefined>(undefined, {\n resolve: (v) => (v === undefined ? undefined : colorOps.resolve(v)),\n lerp: colorOps.lerp as (from: NormalizedColor | undefined, to: NormalizedColor | undefined, t: number) => NormalizedColor | undefined,\n kind: \"color\",\n });\n}\n\n/** A point, unset until given: tweening from unset starts at the origin, or snaps. */\nexport function optionalVector3(unset: \"origin\" | \"snap\"): Type<Vector3Input | undefined, Vector3 | undefined> {\n return Types.custom<Vector3Input | undefined, Vector3 | undefined>(undefined, {\n resolve: resolveOptionalVector3,\n lerp: (from, to, t) => lerpOptionalVector3(from, to, t, unset),\n kind: \"vector3\",\n });\n}\n\n/** Each of `keys` the state has set: what a scene descriptor takes. */\nexport function defined<T>(s: object, keys: readonly string[]): T {\n const out: Record<string, unknown> = {};\n for (const key of keys) {\n const value = (s as Record<string, unknown>)[key];\n if (value !== undefined) out[key] = value;\n }\n return out as T;\n}\n\n/** `{ type, ...defined(s, keys) }`. */\nexport function stated<T>(type: string, s: object, keys: readonly string[]): T {\n return { type, ...defined<object>(s, keys) } as T;\n}\n", "import type { LoaderFn } from \"@/assets/record\";\nimport { cameraOrbit, lerpColor3D, resolveColor3D } from \"@/attributes/render3d/orbit\";\nimport type { Color, NormalizedColor } from \"@/attributes/shape/fill/color/parser\";\nimport { Fills } from \"@/attributes/shape/fill/chain\";\nimport type { FillResolved } from \"@/attributes/shape/fill/union\";\nimport { gridGeometry3D, type Grid3DOptions } from \"@/components/builtins/three/grid-geometry3d\";\nimport type { BufferGeometry3D } from \"@/render3d/geometry\";\nimport { Graphics3D } from \"@/render3d/graphics3d\";\nimport { warmCanvas3D } from \"@/render3d/resources\";\nimport { resolveShadows3D, type PostEffect3D, type Shadows3D, type ToneMapping3D } from \"@/render3d/scene-settings\";\nimport { Scene3D } from \"@/render3d/scene3d\";\nimport type { Canvas3DFillResolved } from \"@/attributes/shape/fill/implementations/canvas3d\";\nimport { isSurfaceTexture3D, resolveSurfaceSource } from \"@/render3d/texture\";\nimport { forEachTexture3D } from \"@/render3d/walk\";\nimport type { Loader, RenderContext2D, Type, Values } from \"@/components/factory/api\";\nimport { Types } from \"@/components/factory/types\";\nimport { internalsOf } from \"@/components/factory/views\";\nimport * as Corners from \"@/components/modules/corners\";\nimport * as Paint from \"@/components/modules/paint\";\nimport { optional } from \"@/components/modules/three-entries\";\n\n/**\n * A viewport onto its 3D children: the default camera and light rig a scene\n * gets when it has none of its own, the floor grid, and the render settings.\n */\n\nfunction color3D(initial: Color): Type<Color, NormalizedColor> {\n return Types.custom<Color, NormalizedColor>(initial, { resolve: resolveColor3D, lerp: lerpColor3D });\n}\n\nexport const state = {\n orbit: Types.number(35, { step: 1, unit: \"°\" }),\n elevation: Types.number(20, { min: -89, max: 89, step: 1, unit: \"°\" }),\n zoom: Types.number(12, { min: 0.01, step: 0.1 }),\n fov: Types.custom(45),\n ambientIntensity: Types.custom(0.45),\n ambientColor: color3D(\"#ffffff\"),\n keyIntensity: Types.custom(2.4),\n keyColor: color3D(\"#ffffff\"),\n showGrid: Types.custom(false),\n gridSize: Types.custom(40),\n gridDivisions: Types.custom(40),\n gridMajorEvery: Types.custom(5),\n gridColor: color3D(\"#26292f\"),\n gridMajorColor: color3D(\"#363a42\"),\n showAxes: Types.custom(false),\n axisXColor: color3D(\"#c8404f\"),\n axisZColor: color3D(\"#2f6fd0\"),\n gridFade: Types.custom(0.55),\n gridFadeColor: color3D(\"#0b0d12\"),\n maxPixelRatio: Types.custom(2),\n antialias: Types.custom(true),\n shadows: Types.custom<Shadows3D>(false),\n tone: optional<ToneMapping3D>(),\n exposure: optional<number>(),\n post: optional<PostEffect3D | readonly PostEffect3D[]>(),\n};\n\nexport const commands = {\n /** Swing the default camera: only the angles given move. */\n orbitTo: { args: [\"orbit\", \"elevation\", \"zoom\"] as const },\n};\n\ntype ViewState = Values<typeof state> & { readonly fill: FillResolved[] };\n\nconst loadThreeRuntime: LoaderFn = async () => {\n await warmCanvas3D();\n};\n\n/**\n * The 3D runtime, warmed before the first frame, and whatever `extend` draws:\n * pass the `extend` your render hands {@link draw}, so its textures, models and\n * surfaces load before a frame needs them, as a 3D child's own drawing does.\n */\nexport function load(loader: Loader, extend?: (scene: Scene3D) => void): void {\n loader.task(\"three:runtime\", loadThreeRuntime);\n if (!extend) return;\n const scene = new Scene3D();\n extend(scene);\n const fill: Canvas3DFillResolved = { type: \"canvas3D\", scene };\n loader.fill(fill);\n}\n\nconst grids = new WeakMap<object, { readonly key: string; readonly geometry: BufferGeometry3D }>();\n\n/**\n * Your 3D children's scene with this view's settings, its grid, and the default\n * camera and lights where the scene has none; `extend` draws more into it last.\n * `null` when there is nothing to show.\n */\nexport function scene(ctx: RenderContext2D, s: ViewState, extend?: (scene: Scene3D) => void): Scene3D | null {\n const scene = ctx.scene3D();\n const hasChildren = scene.ops().length > 0;\n const shadows = resolveShadows3D(s.shadows);\n if (shadows) scene.shadows(shadows);\n if (s.tone !== undefined || s.exposure !== undefined) scene.tone({ mapping: s.tone, exposure: s.exposure });\n if (s.post !== undefined) scene.post(s.post);\n const fog = scene.fogDescriptor();\n if (fog && fog.color === undefined) {\n const base = baseColor(s.fill);\n if (base !== undefined) scene.fog({ ...fog, color: base });\n }\n if (s.showGrid) {\n scene.draw(new Graphics3D().line({\n geometry: gridOf(internalsOf(ctx).host, s),\n segments: true,\n material: { type: \"lineBasic\", vertexColors: true, toneMapped: false },\n }));\n }\n if (!extend && scene.isEmpty() && !hasChildren) return null;\n if (scene.cameraDescriptor() === null) {\n scene.perspective({ fov: s.fov, orbit: cameraOrbit(s.orbit), elevation: s.elevation, distance: s.zoom });\n }\n if (!scene.ops().some((op) => op.kind === \"light\")) {\n scene\n .light({ type: \"ambient\", intensity: s.ambientIntensity, color: s.ambientColor })\n .light({ type: \"directional\", intensity: s.keyIntensity, color: s.keyColor }, { position: [4, 6, 3] })\n .light({ type: \"directional\", intensity: s.keyIntensity * 0.35, color: s.keyColor }, { position: [-5, -2, -4] });\n }\n extend?.(scene);\n return scene.isEmpty() ? null : scene;\n}\n\n/** The box painted, with the scene as its top fill layer. */\nexport function draw(ctx: RenderContext2D, s: ViewState & Parameters<typeof Paint.draw>[1] & Values<typeof Corners.state>, extend?: (scene: Scene3D) => void): void {\n const built = scene(ctx, s, extend);\n const internals = internalsOf(ctx);\n if (built && !internals.probing) {\n built.assertBalanced();\n // A surface texture draws a detached 2D node: it renders in this node's scope.\n const host = internals.host as unknown as { attachDetached(node: object): void };\n forEachTexture3D(built, (texture) => {\n if (!isSurfaceTexture3D(texture)) return;\n const source = resolveSurfaceSource(texture.source);\n if (source.kind === \"node\") host.attachDetached(source.node);\n });\n }\n const fill = built ? [...s.fill, ...Fills.canvas3D(built, { maxPixelRatio: s.maxPixelRatio, antialias: s.antialias })] : s.fill;\n Paint.draw(ctx, s, Corners.rect(ctx.size, s), { fill: fill as never });\n}\n\nfunction gridOf(host: object, s: ViewState): BufferGeometry3D {\n const options: Grid3DOptions = {\n size: s.gridSize,\n divisions: Math.max(1, Math.round(s.gridDivisions)),\n majorEvery: Math.max(1, Math.round(s.gridMajorEvery)),\n minorColor: s.gridColor,\n majorColor: s.gridMajorColor,\n axisXColor: s.axisXColor,\n axisZColor: s.axisZColor,\n showAxes: s.showAxes,\n fadeTo: fadeColor(s),\n fade: s.gridFade,\n };\n const key = JSON.stringify(options);\n let kept = grids.get(host);\n if (kept?.key !== key) grids.set(host, kept = { key, geometry: gridGeometry3D(options) });\n return kept.geometry;\n}\n\n/** The grid fades into the first visible solid fill, so it melts into the background. */\nfunction fadeColor(s: ViewState): Color {\n for (const layer of s.fill as unknown as readonly ({ type?: string; color?: unknown } | null)[]) {\n if (layer?.type !== \"solid\") continue;\n const color = layer.color;\n if (typeof color === \"string\") return color;\n if (Array.isArray(color) && (color[3] ?? 1) > 0) return color as Color;\n }\n return s.gridFadeColor;\n}\n\nfunction baseColor(fill: readonly FillResolved[]): Color | undefined {\n for (const layer of fill) {\n if (layer && (layer as { type?: string }).type === \"solid\") return (layer as unknown as { color: Color }).color;\n }\n return undefined;\n}\n", "import type { BufferGeometry3D } from \"@/render3d/geometry\";\nimport type { Color } from \"@/attributes/shape/fill/color/parser\";\n\nimport { resolveColor3D } from \"@/attributes/render3d/orbit\"\n\n/** How the ground plane is drawn — the fields the Canvas 3D's schema states. */\nexport interface Grid3DOptions {\n /** Total extent of the grid, in scene units. It spans `±size / 2` on both axes. */\n size: number\n /** How many cells across. One minor line per cell boundary. */\n divisions: number\n /** Every Nth minor line is drawn in {@link majorColor} instead. */\n majorEvery: number\n minorColor: Color\n majorColor: Color\n /** The line through `z = 0`. Red by convention, in every 3D tool there is. */\n axisXColor: Color\n /** The line through `x = 0`. Blue by the same convention. */\n axisZColor: Color\n /** Whether to draw the two axis lines at all. */\n showAxes: boolean\n /** What the far edge fades into (the colour behind the grid). Lerps each vertex's *colour* toward this instead of dropping alpha, since the descriptor has no per-vertex alpha; over an opaque background the two are indistinguishable and this needs no blending or sort order. A {@link Color} because it is read off the node's fill stack (`Canvas3DView.fadeColor`), where a resolved paint holds a normalized tuple. */\n fadeTo: Color\n /** How much of the way to the edge the fade has finished, in `[0, 1]`; `0` disables it. Distance is radial from the origin, so the grid dissolves into a disc rather than leaving four corners visible after the edges have gone (a horizon, not a square table). */\n fade: number\n}\n\n/** The ground plane as one buffer of line segments. **One geometry, not three**: minor lines, major lines and axes differ only in colour (a vertex attribute), so three ops would be three draw calls and three chances for the sort order to bury an axis. One op with `vertexColors: true` on one unlit material also allows the distance fade, which varies along each line. The arrays are freshly allocated, so the caller caches them (see {@link Canvas3DView}, which marks the result `staticData`); rebuilding per frame would be ~10k floats and a full re-upload. */\nexport function gridGeometry3D(options: Grid3DOptions): BufferGeometry3D {\n const { size, divisions, majorEvery, showAxes, fade } = options\n\n const half = size / 2\n const step = size / divisions\n const minor = rgb(options.minorColor)\n const major = rgb(options.majorColor)\n const axisX = rgb(options.axisXColor)\n const axisZ = rgb(options.axisZColor)\n const fadeTo = rgb(options.fadeTo)\n\n const position: number[] = []\n const color: number[] = []\n\n /** One segment, with each end faded by its own distance from the origin. */\n const segment = (\n ax: number,\n az: number,\n bx: number,\n bz: number,\n tint: readonly [number, number, number]\n ): void => {\n // y is a hair above zero for the axes only (see the call sites).\n position.push(ax, 0, az, bx, 0, bz)\n pushFaded(color, tint, fadeTo, fadeAt(ax, az, half, fade))\n pushFaded(color, tint, fadeTo, fadeAt(bx, bz, half, fade))\n }\n\n for (let i = 0; i <= divisions; i++) {\n const offset = -half + i * step\n // Counted from the centre line so \"every Nth\" is symmetric about the origin; otherwise major lines drift off-centre on an odd division count.\n const fromCentre = Math.abs(i - divisions / 2)\n const isCentre = Math.abs(offset) < step / 2\n // Centre lines are the axes' own: skipped when axes are drawn, ordinary major lines otherwise.\n if (isCentre && showAxes) continue\n\n const tint =\n Number.isInteger(fromCentre) && fromCentre % majorEvery === 0\n ? major\n : minor\n\n segment(offset, -half, offset, half, tint)\n segment(-half, offset, half, offset, tint)\n }\n\n if (showAxes) {\n // Same plane as the grid: the axes replace the two centre lines rather than sitting over them, so nothing z-fights.\n segment(-half, 0, half, 0, axisX)\n segment(0, -half, 0, half, axisZ)\n }\n\n return {\n type: \"buffer\",\n position: new Float32Array(position),\n color: new Float32Array(color),\n // Nothing here is lit (a grid is emissive), so asking for normals would be a wasted pass.\n computeNormals: false,\n // True only because the caller caches: see this module's note.\n staticData: true,\n }\n}\n\n/** How faded a point is, in `[0, 1]` (1 is fully the background). Squared falloff: a linear ramp over a plane at a shallow angle reads as a hard edge, compressing most of the ramp into the last pixels before the horizon. */\nfunction fadeAt(\n x: number,\n z: number,\n half: number,\n fade: number\n): number {\n if (fade <= 0) return 0\n const distance = Math.hypot(x, z) / half\n const start = 1 - fade\n if (distance <= start) return 0\n const t = Math.min(1, (distance - start) / Math.max(fade, 1e-6))\n return t * t\n}\n\n/** Push one vertex colour, lerped `t` of the way from `tint` toward `fadeTo`. */\nfunction pushFaded(\n out: number[],\n tint: readonly [number, number, number],\n fadeTo: readonly [number, number, number],\n t: number\n): void {\n out.push(\n tint[0] + (fadeTo[0] - tint[0]) * t,\n tint[1] + (fadeTo[1] - tint[1]) * t,\n tint[2] + (fadeTo[2] - tint[2]) * t\n )\n}\n\n/** A colour as the linear RGB triple a vertex attribute holds. `resolveColor3D` gives normalized sRGB but three reads vertex colours as **linear**; skipping the conversion paints an sRGB 0.16 at about 0.4 (a grid that shouts instead of whispering). */\nfunction rgb(value: Color): [number, number, number] {\n const [r, g, b] = resolveColor3D(value)\n return [srgbToLinear(r), srgbToLinear(g), srgbToLinear(b)]\n}\n\n/** The sRGB transfer function, inverted. three's own `SRGBToLinear`. */\nfunction srgbToLinear(channel: number): number {\n return channel < 0.04045\n ? channel * 0.0773993808\n : Math.pow(channel * 0.9478672986 + 0.0521327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GAAUxB,EAAY,CAC3B,QAAW4B,KAAS5B,EAAE,KAA2E,CAC7F,GAAI4B,GAAO,OAAS,QAAS,SAC7B,IAAMC,EAAQD,EAAM,MAEpB,GADI,OAAOC,GAAU,UACjB,MAAM,QAAQA,CAAK,IAAMA,EAAM,CAAC,GAAK,GAAK,EAAG,OAAOA,CAC5D,CACA,OAAO7B,EAAE,aACb,CAEA,SAASM,GAAUT,EAA6B,CAC5C,QAAW+B,KAAS/B,EAChB,GAAI+B,GAAUA,EAA4B,OAAS,QAAS,OAAQA,EAAsC,KAGlH",
|
|
6
|
+
"names": ["makeUniform", "value", "fromTopBottom", "v", "fb", "fromLeftRight", "resolveCorners", "fallback", "previous", "isScalar", "obj", "lerpCorners", "from", "to", "t", "lerp", "isUniformCorners", "c", "eq", "cornerRadiusOps", "value", "previous", "resolveCorners", "v", "from", "to", "t", "lerpCorners", "lerpNumber", "isUniformCorners", "cornerStyleOps", "value", "previous", "resolveCorners", "v", "from", "to", "t", "lerpCorners", "f", "g", "isUniformCorners", "lerpCornerScalarStyle", "resolveEffectAxis", "axis", "sameEffectAxis", "a", "b", "av", "bv", "resolveEffectColor", "color", "parseColor", "sameEffectColor", "EFFECT_OPTION_KEYS", "withEffectOptions", "base", "options", "out", "key", "value", "scalarOptions", "arg", "lerpColor", "from", "to", "t", "colorOps", "resolve", "value", "r", "g", "b", "a", "alpha", "byte", "parseColor", "channel", "CENTER", "param", "o", "normalize", "v", "options", "step", "a", "b", "t", "same", "sameVector", "KIND_LERP", "lerpNumber", "lerpColor", "resolveEffectColor", "lerpVector2", "KIND_EQUALS", "sameEffectColor", "sameEffectAxis", "paramLerp", "def", "kind", "fallback", "from", "to", "effectDataOf", "spec", "entries", "lerps", "name", "equals", "derived", "out", "g", "lerp", "custom", "data", "x", "y", "eq", "copyDefault", "value", "buildEffect", "arg", "scalarOptions", "withEffectOptions", "json", "describeSpec", "params", "index", "stored", "optional", "key", "resolveMotionBlurAlignment", "alignment", "motionBlurSpec", "param", "a", "b", "t", "lerpNumber", "lerpVector2", "resolveEffectAxis", "motionBlurEffect", "effectDataOf", "ASCII_CHARSETS", "resolveAsciiCharset", "charset", "asciiSpec", "param", "asciiEffect", "effectDataOf", "BlendModes", "NodeBlendModes", "BLEND_MODE_HASH", "mode", "i", "getBlendModeHash", "blend", "warned", "warnOnce", "scope", "message", "key", "flattenValue", "name", "value", "flat", "out", "entry", "normalizeUniforms", "input", "pairs", "u", "a", "b", "lerpUniformValue", "t", "lerpNumber", "len", "_", "uniformValuesEqual", "v", "i", "lerpUniformRecord", "from", "to", "uniformRecordsEqual", "aKeys", "other", "isWgslShader", "shader", "WGSL_CONTRACT", "shaderContractOf", "blurSpec", "param", "blurEffect", "effectDataOf", "directionalBlurSpec", "param", "directionalBlurEffect", "effectDataOf", "grayscaleSpec", "param", "grayscaleEffect", "effectDataOf", "pixelateSpec", "param", "pixelateEffect", "effectDataOf", "bulgeSpec", "param", "CENTER", "bulgeEffect", "effectDataOf", "magnifySpec", "param", "CENTER", "magnifyEffect", "effectDataOf", "bloomSpec", "param", "bloomEffect", "effectDataOf", "vintageSpec", "param", "vintageEffect", "effectDataOf", "chromaticAberrationSpec", "param", "chromaticAberrationEffect", "effectDataOf", "invertSpec", "param", "invertEffect", "effectDataOf", "scatterSpec", "param", "scatterEffect", "effectDataOf", "posterizeSpec", "param", "posterizeEffect", "effectDataOf", "shaderSpec", "param", "BlendModes", "effect", "contract", "shaderContractOf", "from", "to", "t", "near", "lerpUniformRecord", "normalizeUniforms", "a", "b", "uniformRecordsEqual", "shaderEffect", "effectDataOf", "outlineSpec", "param", "outlineEffect", "effectDataOf", "dropShadowSpec", "param", "dropShadowEffect", "effectDataOf", "vignetteSpec", "param", "vignetteEffect", "effectDataOf", "grainSpec", "param", "grainEffect", "effectDataOf", "sharpenSpec", "param", "sharpenEffect", "effectDataOf", "edgesSpec", "param", "edgesEffect", "effectDataOf", "thresholdSpec", "param", "thresholdEffect", "effectDataOf", "radialBlurSpec", "param", "CENTER", "radialBlurEffect", "effectDataOf", "halftoneSpec", "param", "halftoneEffect", "effectDataOf", "ditherSpec", "param", "ditherEffect", "effectDataOf", "duotoneSpec", "param", "duotoneEffect", "effectDataOf", "curvesSpec", "param", "from", "to", "t", "x", "y", "tx", "ty", "lerpNumber", "a", "b", "i", "curvesEffect", "effectDataOf", "colorAdjustmentSpec", "param", "colorAdjustmentEffect", "effectDataOf", "rgbShiftSpec", "param", "rgbShiftEffect", "effectDataOf", "scanlinesSpec", "param", "scanlinesEffect", "effectDataOf", "blockDisplaceSpec", "param", "blockDisplaceEffect", "effectDataOf", "bitCrushSpec", "param", "bitCrushEffect", "effectDataOf", "streakSpec", "param", "streakEffect", "effectDataOf", "GLOW_RAMP_COLORS", "GLOW_RAMP_STOPS", "glowSpec", "from", "to", "t", "derived", "param", "BlendModes", "a", "b", "c", "i", "lerpColor", "resolveEffectColor", "sameEffectColor", "s", "lerpNumber", "glowEffect", "effectDataOf", "oilPaintSpec", "param", "oilPaintEffect", "effectDataOf", "waveSpec", "param", "CENTER", "waveEffect", "effectDataOf", "twirlSpec", "param", "CENTER", "twirlEffect", "effectDataOf", "progressiveBlurSpec", "param", "CENTER", "progressiveBlurEffect", "effectDataOf", "kaleidoscopeSpec", "param", "CENTER", "kaleidoscopeEffect", "effectDataOf", "glassSpec", "param", "glassEffect", "effectDataOf", "lutSpec", "param", "lutEffect", "effectDataOf", "BUILT_INS", "blurSpec", "blurEffect", "directionalBlurSpec", "directionalBlurEffect", "grayscaleSpec", "grayscaleEffect", "pixelateSpec", "pixelateEffect", "bulgeSpec", "bulgeEffect", "magnifySpec", "magnifyEffect", "bloomSpec", "bloomEffect", "vintageSpec", "vintageEffect", "chromaticAberrationSpec", "chromaticAberrationEffect", "invertSpec", "invertEffect", "scatterSpec", "scatterEffect", "posterizeSpec", "posterizeEffect", "motionBlurSpec", "motionBlurEffect", "shaderSpec", "shaderEffect", "outlineSpec", "outlineEffect", "dropShadowSpec", "dropShadowEffect", "vignetteSpec", "vignetteEffect", "grainSpec", "grainEffect", "sharpenSpec", "sharpenEffect", "edgesSpec", "edgesEffect", "thresholdSpec", "thresholdEffect", "radialBlurSpec", "radialBlurEffect", "halftoneSpec", "halftoneEffect", "ditherSpec", "ditherEffect", "duotoneSpec", "duotoneEffect", "curvesSpec", "curvesEffect", "colorAdjustmentSpec", "colorAdjustmentEffect", "rgbShiftSpec", "rgbShiftEffect", "scanlinesSpec", "scanlinesEffect", "blockDisplaceSpec", "blockDisplaceEffect", "bitCrushSpec", "bitCrushEffect", "asciiSpec", "asciiEffect", "streakSpec", "streakEffect", "glowSpec", "glowEffect", "oilPaintSpec", "oilPaintEffect", "waveSpec", "waveEffect", "twirlSpec", "twirlEffect", "progressiveBlurSpec", "progressiveBlurEffect", "kaleidoscopeSpec", "kaleidoscopeEffect", "glassSpec", "glassEffect", "lutSpec", "lutEffect", "EFFECTS", "spec", "data", "SPECS", "dataFor", "type", "resolveEffect", "effect", "effectSpec", "type", "SPECS", "descriptors", "describeEffect", "spec", "out", "describeSpec", "effectDescriptors", "hasEffect", "dataFor", "effectSurface", "effect", "surface", "declareEffect", "assets", "lerpEffect", "from", "to", "t", "data", "lerped", "source", "key", "EFFECT_OPTION_KEYS", "target", "COMPONENTS", "COLOR_COMPONENTS", "resolveShaderProperties", "pack", "overrides", "out", "id", "property", "supplied", "parts", "componentsOf", "component", "uniform", "value", "warn", "where", "flat", "toUniformValue", "names", "index", "name", "asFinite", "asColor", "asFloats", "g", "b", "a", "parseColor", "v", "point", "warned", "message", "EffectChain", "_EffectChain", "list", "effect", "options", "buildEffect", "blurSpec", "directionalBlurSpec", "pixelateSpec", "grayscaleSpec", "bulgeSpec", "magnifySpec", "bloomSpec", "vintageSpec", "chromaticAberrationSpec", "invertSpec", "scatterSpec", "posterizeSpec", "motionBlurSpec", "outlineSpec", "dropShadowSpec", "vignetteSpec", "lutSpec", "grainSpec", "sharpenSpec", "edgesSpec", "thresholdSpec", "radialBlurSpec", "halftoneSpec", "ditherSpec", "duotoneSpec", "curvesSpec", "mode", "fields", "withEffectOptions", "o", "scalarOptions", "spread", "rgbShiftSpec", "scanlinesSpec", "blockDisplaceSpec", "bitCrushSpec", "asciiSpec", "oilPaintSpec", "streakSpec", "glowSpec", "pack", "source", "uniforms", "resolveShaderProperties", "normalizeUniforms", "base", "waveSpec", "twirlSpec", "progressiveBlurSpec", "kaleidoscopeSpec", "glassSpec", "Effects", "resolveChainEffects", "effects", "resolveAll", "out", "item", "resolveEffect", "i", "resolved", "effectsOps", "from", "to", "t", "maxLen", "result", "a", "b", "lerpEffect", "isBackdropEffect", "effect", "NONE", "backdropEffects", "effects", "foregroundShaderEffects", "e", "effectSurface", "withOptions", "base", "options", "out", "FillChain", "_FillChain", "list", "color", "src", "fit", "crop", "zoom", "anchor", "matrix", "preset", "common", "timestamp", "playing", "trimStart", "trimEnd", "playStart", "speed", "loop", "duration", "colors", "stops", "start", "end", "center", "radius", "startAngle", "size", "density", "seed", "basis", "octaves", "frequency", "lacunarity", "gain", "offset", "angle", "contrast", "source", "pack", "uniforms", "textures", "values", "resolved", "resolveShaderProperties", "normalizeUniforms", "gap", "strokeWidth", "spacing", "divisions", "subdivisions", "subdivisionWidth", "scene", "maxPixelRatio", "antialias", "Fills", "resolveChainFill", "fill", "item", "DEFAULT_DIVISIONS", "DEFAULT_SUBDIVISIONS", "DEFAULT_STROKE_WIDTH", "MINOR_WIDTH_RATIO", "gridFill", "prop", "raw", "strokeWidth", "parseColor", "a", "b", "t", "lerpNumber", "exposureFilter", "from", "to", "t", "lerpNumber", "a", "b", "blurFilter", "from", "to", "t", "lerpNumber", "a", "b", "grayscaleFilter", "from", "to", "t", "lerpNumber", "a", "b", "alphaFilter", "from", "to", "t", "lerpNumber", "a", "b", "colorMatrixFilter", "from", "to", "t", "v", "i", "lerpNumber", "a", "b", "curvesFilter", "from", "to", "t", "x", "y", "tx", "ty", "lerpNumber", "a", "b", "i", "colorAdjustmentFilter", "from", "to", "t", "lerpNumber", "a", "b", "posterizeTimeFilter", "from", "to", "t", "lerpNumber", "a", "b", "echoFilter", "from", "to", "t", "lerpNumber", "a", "b", "FILTERS", "exposureFilter", "blurFilter", "grayscaleFilter", "alphaFilter", "colorMatrixFilter", "curvesFilter", "colorAdjustmentFilter", "posterizeTimeFilter", "echoFilter", "VIDEO_ONLY", "isPixelFilter", "type", "hasFilter", "hasEffect", "lerpFilter", "from", "to", "t", "data", "lerpEffect", "declareFilter", "filter", "assets", "declareEffect", "filterSurface", "effectSurface", "lerpFilterArray", "from", "to", "t", "maxLen", "result", "a", "b", "lerpFilter", "scalarFilter", "arg", "key", "fromEffect", "chain", "AdjustmentChain", "list", "filter", "Ctor", "options", "radius", "amount", "matrix", "EffectChain", "VideoAdjustmentChain", "fps", "Adjustments", "VideoAdjustments", "resolveChainAdjustments", "filters", "ALIGNMENTS", "ALIGNMENT_KEYS", "resolveOne", "value", "named", "alignmentOps", "lerpVector2", "props", "present", "k", "alignmentKey", "rect", "target", "a", "getTarget", "getRect", "insetsOps", "value", "previous", "from", "to", "t", "lerpNumber", "outerWidth", "outerHeight", "pad", "innerWidth", "innerHeight", "resolveMediaPreset", "preset", "adjustments", "resolveChainAdjustments", "lerpMediaPreset", "a", "b", "t", "from", "to", "lerpFilterArray", "lerpNumber", "declareMediaPreset", "assets", "adjustment", "declareFilter", "NO_CROP", "CENTER", "resolveImagePlacement", "prop", "insetsOps", "alignmentOps", "lerpImagePlacement", "a", "b", "t", "lerpNumber", "lerpVector2", "imageFill", "crop", "anchor", "preset", "resolveMediaPreset", "lerpMediaPreset", "fill", "assets", "declareMediaPreset", "resolveVideoTimestamp", "fill", "elapsed", "sourceDuration", "start", "posterizeTimestamp", "rawTimestamp", "played", "sourceTimeFor", "trimEndFor", "hasDuration", "end", "loop", "cycleLength", "rawLoopDuration", "loopDuration", "cycle", "ping", "linear", "timestamp", "posterize", "f", "grid", "videoFill", "crop", "anchor", "preset", "prop", "resolveImagePlacement", "resolveMediaPreset", "a", "b", "t", "lerpImagePlacement", "lerpNumber", "lerpMediaPreset", "assets", "declareMediaPreset", "PathBuilder", "x", "y", "x1", "y1", "x2", "y2", "rx", "ry", "rotation", "largeArc", "sweep", "arc", "cx", "cy", "from", "resolveArc", "start", "pointOn", "partial", "steps", "step", "direction", "i", "p", "angle", "rad", "SHAPE_KINDS", "Graphics2D", "_Graphics2D", "state", "resolved", "PathBuilder", "fills", "strokes", "shadows", "options", "opacity", "effects", "effectsOps", "rotation", "center", "scale", "op", "ops", "next", "resolveSurfaceSource", "source", "isDataTexture3D", "texture", "isSurfaceTexture3D", "resolveTexture3D", "texture3DSource", "looksLikeAssetPath", "value", "DEFAULT_SIZE", "resolveFill3D", "fill", "options", "looksLikeAssetPath", "entry", "rasterized", "isSurfaceSourceValue", "surfaceFor", "isTextureDescriptor", "isSolidLayer", "source", "width", "height", "Graphics2D", "fillIdentity", "value", "bag", "lerpFill3D", "from", "to", "t", "start", "asPlainColor", "end", "lerpColor", "normalize", "color", "parseColor", "objectIds", "objectCounter", "list", "prototype", "id", "key", "warned", "development", "isDevelopment", "warnInert3D", "key", "message", "inspectDrawable3D", "op", "isDevelopment", "params", "warnInert3D", "materials", "material", "DRAWABLE_KINDS", "TRANSFORM_KEYS", "MATERIAL_SHORTHAND_KEYS", "SHORTHAND_KEYS", "pickTransform", "source", "bag", "out", "key", "resolveMaterialShorthand3D", "material", "fill", "resolveFill3D", "value", "pickGeometry", "type", "Graphics3D", "op", "inspectDrawable3D", "geometry", "transform", "options", "instances", "points", "closed", "segments", "stroke", "opacity", "resolved", "lineBuffer", "paint", "src", "animation", "override", "lineBuffers", "lineRevision", "kept", "holds", "flattenPoints", "i", "point", "v", "buffer", "x", "y", "z", "RenderContext3D", "resolveShadows3D", "value", "Scene3D", "RenderContext3D", "state", "graphics", "ops", "scope", "i", "op", "light", "transform", "camera", "options", "fog", "environment", "warnInert3D", "settings", "resolveShadows3D", "effects", "added", "effect", "DRAWABLE_KINDS", "verb", "canvas3DResourceKey", "kind", "src", "parseCanvas3DResourceKey", "key", "rest", "split", "warmup", "resourceLoader", "registerCanvas3DWarmup", "fn", "registerCanvas3DResourceLoader", "warmCanvas3D", "canvas3DResourceLoader", "hasCanvas3DBackend", "TEXTURE_KEYS", "isTextureLike", "value", "forEachTexture3D", "g3", "visit", "uniforms", "bag", "key", "looksLikeAssetPath", "material", "list", "entry", "op", "Scene3D", "effect", "GRADIENT_TYPES", "isGradientType", "type", "canCoerce", "a", "b", "aColorish", "bColorish", "evenStops", "count", "_", "i", "colorToGradient", "color", "opacity", "blend", "space", "targetType", "stopCount", "n", "colors", "stops", "common", "retypeGradient", "g", "coercePair", "aIsColor", "bIsColor", "grad", "expanded", "ga", "gb", "colorFill", "prop", "parseColor", "a", "b", "t", "lerpNumber", "sampleRamp", "ramp", "position", "colors", "stops", "last", "hi", "lo", "span", "lerpColor", "colorAt", "k", "first", "count", "sameStops", "a", "b", "s", "i", "lerpColorRamp", "t", "c", "own", "n", "x", "y", "toNormalized", "c", "parseColor", "linearGradientFill", "prop", "_", "i", "a", "b", "t", "lerpColorRamp", "lerpVector2", "toNormalized", "c", "parseColor", "radialGradientFill", "prop", "_", "i", "a", "b", "t", "lerpColorRamp", "lerpVector2", "lerpNumber", "toNormalized", "c", "parseColor", "conicGradientFill", "prop", "_", "i", "a", "b", "t", "lerpColorRamp", "lerpVector2", "lerpNumber", "noiseFill", "prop", "raw", "parseColor", "a", "b", "t", "lerpNumber", "toNormalized", "c", "parseColor", "BLACK", "WHITE", "toFrequency", "f", "fractalNoiseFill", "prop", "colors", "_", "i", "a", "b", "t", "lerpVector2", "lerpNumber", "lerpColorRamp", "d", "s", "stripeFill", "prop", "parseColor", "a", "b", "t", "lerpNumber", "DEFAULT_RADIUS", "DEFAULT_SPACING", "dotGridFill", "prop", "raw", "parseColor", "a", "b", "t", "lerpNumber", "MAX_TEXTURES", "resolveTextures", "textures", "out", "texture", "withContract", "shader", "contract", "shaderContractOf", "texturesEqual", "a", "b", "t", "i", "shaderFill", "prop", "normalizeUniforms", "lerpUniformRecord", "uniformRecordsEqual", "fill", "assets", "declare3DResources", "g3", "assets", "forEachTexture3D", "value", "isSurfaceTexture3D", "source", "resolveSurfaceSource", "src", "texture3DSource", "geometry", "declareLoader", "op", "Scene3D", "declareEnvironment", "environment", "hdrKind", "face", "resourceLoads", "kind", "load", "canvas3DResourceLoader", "key", "canvas3DResourceKey", "byKey", "fn", "canvas3DFill", "prop", "a", "b", "t", "fill", "assets", "declare3DResources", "FILLS", "colorFill", "linearGradientFill", "radialGradientFill", "conicGradientFill", "noiseFill", "fractalNoiseFill", "stripeFill", "dotGridFill", "gridFill", "shaderFill", "imageFill", "videoFill", "canvas3DFill", "get", "name", "data", "resolveFill", "prop", "Scene3D", "resolved", "space", "UNSET_MEDIA_FILL", "canLerpFill", "a", "b", "canCoerce", "lerpFill", "t", "clamped", "ca", "cb", "coercePair", "scaleOpacity", "fill", "factor", "declareFill", "assets", "fillOps", "resolveChainFill", "from", "to", "maxLength", "result", "i", "f", "tf", "resolveShadow", "prop", "previous", "fillOps", "lerpShadow", "from", "to", "t", "lerpVector2", "shadowOps", "p", "i", "len", "result", "f", "tf", "resolveStrokeAlign", "align", "fallback", "DEFAULT_CAP_SCALE", "isStrokeMarker", "end", "resolveStrokeCap", "cap", "resolveStrokeEnd", "resolveStrokeJoin", "join", "resolveStroke", "prop", "previous", "dash", "raw", "fillOps", "lerpDashArray", "from", "to", "t", "fArray", "tArray", "len", "result", "i", "fVal", "tVal", "lerpStroke", "strokeOps", "p", "f", "tf", "clamp", "value", "min", "max", "clamp01", "t", "descriptions", "describeEase", "ease", "description", "easeDescription", "DEFAULT_EASE", "PI", "parseConfig", "params", "inMath", "t", "config", "s", "a", "p", "x", "describeConfig", "direction", "linear", "describeEase", "clamp01", "easeIn", "easeOut", "easeInOut", "inOutConfig", "clamp", "value", "min", "max", "curveSegments", "points", "segments", "i", "p0", "p3", "before", "after", "c1", "c2", "bezier", "a", "b", "c", "d", "t", "mt", "curveSegmentT", "segment", "x", "low", "high", "mid", "isEaseCurve", "isFinitePoint", "y", "curveEase", "describeEase", "last", "candidate", "EASE_KINDS", "easeOfSpec", "spec", "lookup", "known", "linear", "easeIn", "easeOut", "easeInOut", "key", "isEaseCurve", "curveEase", "fn", "registered", "STANDARD", "specOfEase", "ease", "description", "easeDescription", "direction", "type", "overshoot", "amplitude", "period", "tuning", "config", "name", "value", "segmentsOf", "RampChain", "_RampChain", "segments", "keysOf", "from", "to", "duration", "options", "specOf", "segment", "ramp", "hold", "ease", "spec", "specOfEase", "previous", "values", "s", "keys", "push", "key", "last", "withEase", "fill", "head", "at", "i", "tail", "before", "sum", "isRamp", "p", "LINEAR", "linear", "resolved", "resolveRamp", "length", "clip", "cached", "crossed", "time", "easeOfSpec", "b", "sampleRamp", "fallback", "span", "lerpNumber", "staticValue", "first", "paramKey", "lerpParam", "t", "equalsParam", "a", "audioParamOps", "value", "INTEGRATION_STEP", "MAX_CELLS", "speedTables", "speedTableOf", "speed", "sourceLength", "step", "byLength", "cells", "size", "rate", "table", "integrateSpeedToClipTime", "upper", "end", "cell", "sourceTimeAtClipElapsed", "clipElapsed", "lo", "hi", "mid", "scalarParam", "arg", "key", "isRamp", "AudioEffectChain", "_AudioEffectChain", "list", "effect", "options", "value", "frequency", "q", "rate", "depth", "delay", "feedback", "mix", "AudioEffects", "resolveAudioEffects", "effects", "gainEffect", "from", "to", "t", "lerpParam", "a", "b", "equalsParam", "highPassEffect", "from", "to", "t", "lerpParam", "a", "b", "equalsParam", "lowPassEffect", "from", "to", "t", "lerpParam", "a", "b", "equalsParam", "tremoloEffect", "from", "to", "t", "lerpParam", "a", "b", "equalsParam", "echoEffect", "from", "to", "t", "lerpParam", "a", "b", "equalsParam", "BUILT_IN_EFFECTS", "gainEffect", "highPassEffect", "lowPassEffect", "tremoloEffect", "echoEffect", "AudioEffectRegistry", "_AudioEffectRegistry", "type", "data", "from", "to", "t", "maxLen", "result", "i", "b", "audioEffectsOps", "resolveAudioEffects", "isProjective", "m", "MIN_W", "safeW", "w", "identity", "translation", "tx", "ty", "multiply", "m1", "m2", "multiplyProjective", "g1", "h1", "i1", "g2", "h2", "i2", "applyToPoint", "p", "x", "y", "invert", "invertProjective", "det", "inv", "a", "b", "c", "d", "e", "f", "g", "h", "i", "A", "C", "E", "cameraMatrix", "vx", "vy", "lookAt", "zoom", "heading", "rad", "cos", "sin", "nodeLocalMatrix", "cx", "cy", "rotation", "scale", "pivotX", "pivotY", "NO_PROJECTION_3D", "hasProjection3D", "facesAway", "rotationX", "rotationY", "nodeProjectedMatrix", "ca", "sa", "cb", "sb", "cz", "cc", "sc", "B", "D", "G", "H", "invP", "fx", "fy", "lerpLookAt", "from", "to", "t", "out", "lerpNumber", "multiplyAffine3", "a", "b", "a0", "a1", "a2", "a3", "nodeSpaceMatrix", "cx", "cy", "rotation", "scale", "pivotX", "pivotY", "p", "rad", "ca", "sa", "cb", "sb", "cz", "cc", "sc", "r00", "r01", "r02", "r10", "r11", "r12", "r20", "r21", "r22", "fx", "fy", "spaceViewMatrix", "cam", "se", "ce", "r0", "r1", "r2", "d0", "d1", "d2", "f0", "f1", "f2", "tx", "ty", "tz", "spaceScreenMatrix", "view", "invP", "wx", "wy", "w0", "k", "c00", "c01", "c10", "c11", "vx", "vy", "m", "spacePlane", "box", "hw", "hh", "us", "vs", "corners", "i", "u", "v", "nl", "NEAR_W", "EDGE_ON", "cameraSide", "plane", "dx", "dy", "dz", "side", "nearCoverage", "inFront", "nearCutPolygon", "screen", "margin", "g", "h", "square", "w", "wa", "wb", "SIDE_EPS", "sideOf", "camSide", "front", "back", "d", "facing", "farness", "compareInSpace", "s", "isCoplanar", "fa", "fb", "rootCamera", "props", "space3dOps", "camera", "point", "x", "y", "z", "vz", "px", "py", "vector", "ux", "uy", "PAIRWISE_LIMIT", "spacePaintOrder", "planes", "_", "after", "blockers", "j", "r", "order", "done", "next", "far", "f", "size2DOps", "value", "from", "to", "t", "lerpNumber", "props", "sizeInputOps", "input", "availableSize", "contentSize", "TEXT_STYLE_KEYS", "TEXT_SHAPING_KEYS", "EMPTY_TEXT_STYLE", "textOps", "value", "lerp", "preset", "mergeStyle", "resolveStyle", "lerpStyle", "lerpFontSize", "styleProps", "flatten", "applyCase", "from", "to", "t", "pre", "maxPre", "suf", "maxSuf", "removeLen", "addLen", "totalLen", "prefix", "suffix", "split", "localT", "midLen", "name", "getTypographyPreset", "base", "over", "out", "key", "style", "previous", "s", "fillOps", "strokeOps", "shadowOps", "lerpOptionalNumber", "spans", "walk", "span", "inherited", "merged", "child", "WORD_CHAR", "text", "textCase", "prev", "ch", "recase", "mapped", "a", "b", "lerpNumber", "PROPERTY_META", "getPropertyMeta", "instance", "mostDerived", "symbol", "chain", "proto", "result", "at", "p", "m", "i", "declareMembers", "ctor", "members", "key", "register", "property", "opts", "target", "propertyKey", "fallback", "mapper", "tween", "editor", "meta", "list", "_observer", "_setObserver", "observer", "previous", "PropSlot", "initial", "_host", "_name", "value", "fn", "snap", "ToCommand", "target", "props", "duration", "easing", "clamp01", "toCommand", "loopPasses", "loop", "loopRepeats", "loopSpan", "duration", "fill", "loopPhase", "elapsed", "passes", "capped", "index", "t", "clamp01", "SETTLES", "settling", "command", "settles", "isCommand", "x", "makeCommand", "target", "at", "duration", "easing", "fromValue", "t", "clamp01", "driveCommand", "apply", "loopCommand", "loop", "fill", "one", "loopPasses", "loopSpan", "value", "loopPhase", "elapsed", "e", "dt", "done", "commandSequence", "commands", "sum", "c", "props", "cursor", "local", "commandParallel", "max", "progress", "prepareNumericTween", "target", "to", "keys", "k", "from", "end", "t", "i", "prepareNumericCellTween", "cells", "createContext", "defaultValue", "name", "ContextMap", "_ContextMap", "entries", "ctx", "value", "next", "LAYOUTS", "PropLayout", "_PropLayout", "proto", "layout", "field", "i", "host", "_proto", "parent", "cells", "slot", "value", "getPropSlot", "obj", "name", "ensureCells", "PropLayout", "COMMAND_META", "getCommandMeta", "instance", "mostDerived", "command", "options", "target", "propertyKey", "method", "key", "list", "m", "LAYOUT_SLOT", "VAR_PREFIX", "PRESENCE_PREFIX", "STRUCTURE_SLOT", "observeSlots", "observer", "fn", "previous", "_setObserver", "unobserved", "slotLabel", "slot", "inertCommand", "target", "duration", "inertStepper", "elapsed", "e", "dt", "registerProp", "host", "field", "options", "slot", "PropSlot", "cells", "ensureCells", "value", "applyProp", "initial", "collectProperties", "result", "key", "captureLayer", "layer", "slots", "saveState", "popState", "applySnapshotLayer", "snap", "restoreAnimated", "duration", "easing", "stepper", "driveCommand", "t", "target", "createNodeTime", "advanceNodeTime", "time", "total", "HOSTS_OF", "Node", "_Node", "props", "identity", "hidden", "locked", "meta", "getPropertyMeta", "propsVal", "initial", "flat", "c", "child", "why", "refusal", "_parent", "_observer", "ContextMap", "ctx", "childProp", "field", "options", "applyProp", "value", "slot", "mapper", "extFn", "unset", "read", "collectProperties", "slots", "key", "val", "args", "toCommand", "at", "duration", "easing", "makeCommand", "inertCommand", "to", "inertStepper", "numCells", "numFrom", "numEnd", "customLerps", "stringSnaps", "extVal", "targetVal", "tweenFn", "from", "t", "lerp", "prepareNumericCellTween", "hasCustom", "hasSnaps", "apply", "easedT", "fn", "elapsed", "e", "dt", "declared", "saveState", "layer", "popState", "applySnapshotLayer", "restoreAnimated", "createNodeTime", "total", "advanceNodeTime", "scope", "first", "next", "childScope", "parent", "node", "assets", "index", "PropSlot", "STRUCTURE_SLOT", "children", "i", "removed", "declareMembers", "command", "AssetNotLoadedError", "assetType", "src", "hint", "declareHint", "measureItem", "item", "constraints", "measurer", "size", "extentOf", "input", "available", "measureRun", "items", "horizontal", "gap", "space", "measurer", "main", "cross", "hugsMain", "hugsCross", "bounded", "n", "sizes", "gapScales", "item", "sanitizeGapScale", "totalGap", "sum", "w", "fixedMain", "deepest", "i", "measureItem", "fillCross", "size", "withCross", "free", "flexSum", "sanitizeFlex", "share", "measureFillOnHugAxis", "depth", "extent", "measureWrap", "crossGap", "limit", "step", "lines", "widest", "stack", "start", "end", "placeRun", "align", "inner", "mainFraction", "crossFraction", "line", "lineStart", "boxes", "count", "weight", "gapAfter", "lead", "spread", "weightAt", "at", "across", "fromReadingOrder", "left", "top", "value", "clamp", "measureFreeform", "items", "space", "measurer", "constraints", "sizes", "hug", "item", "size", "measureItem", "placeFreeform", "inner", "align", "measureGrid", "items", "columns", "columnGap", "rowGap", "space", "measurer", "count", "track", "placements", "autoPlace", "rowCount", "max", "p", "bounded", "equalRow", "rows", "sizes", "item", "i", "width", "span", "constraints", "size", "measureItem", "grow", "tops", "top", "height", "cells", "spannedRows", "sum", "h", "placeGrid", "inner", "cell", "taken", "isFree", "row", "col", "colSpan", "rowSpan", "r", "c", "take", "gap", "short", "from", "CENTRE", "arrange", "settings", "items", "box", "measurer", "inner", "insetsOps", "place", "measure", "b", "space", "flow", "measureMode", "from", "to", "lerpSize", "placeMode", "fromBoxes", "t", "i", "lerpNumber", "reusable", "hug", "fits", "contentBox", "sizing", "constraints", "padding", "width", "outerFor", "height", "size", "hugged", "collapsedRun", "sized", "s", "lerp", "a", "mode", "measureFreeform", "grid", "measureGrid", "mainGap", "crossGap", "horizontal", "run", "measureWrap", "measureRun", "placeGrid", "align", "alignOf", "placeFreeform", "placeRun", "freeSlot", "alignmentOps", "gap", "input", "max", "available", "sizeInputOps", "laid", "measured", "hugs", "near", "flowOps", "value", "ZERO", "resolveVector3", "input", "v", "lerpVector3", "from", "to", "t", "lerpNumber", "vector3Ops", "value", "resolveOptionalVector3", "lerpOptionalVector3", "unset", "lerpEuler3", "euler3Ops", "order", "IDENTITY_QUATERNION", "slerpQuaternion", "x", "y", "z", "w", "dot", "normalizeQuaternion", "theta", "sinTheta", "a", "b", "q", "length", "quaternionFromEuler", "euler", "half", "cx", "sx", "cy", "sy", "cz", "sz", "quaternionOps", "Clip", "state", "resolved", "PathBuilder", "op", "attributeProperty", "fallback", "mapper", "tween", "kind", "opts", "property", "fillProperty", "fillOps", "effectsProperty", "effectsOps", "insetsProperty", "insetsOps", "alignmentProperty", "alignmentOps", "flowProperty", "flowOps", "optionalVector3Property", "unset", "resolveOptionalVector3", "from", "to", "t", "lerpOptionalVector3", "quaternionProperty", "quaternionOps", "audioParamProperty", "audioParamOps", "audioEffectsProperty", "audioEffectsOps", "primeMotion", "history", "x", "y", "rotation", "scale", "at", "createMotionHistory", "sampleMotion", "state", "now", "dt", "prev", "vx", "vy", "measureDetached", "parent", "child", "pass", "scope", "constraints", "size", "SIZE_PHASE", "addChildAtAnimated", "index", "duration", "easing", "animation", "isNumericW", "isNumericH", "origW", "origH", "setup", "targetOpacity", "detached", "tweenW", "tweenH", "targetW", "targetH", "sizeProps", "grow", "fade", "commandSequence", "commandParallel", "driveCommand", "t", "restore", "removeChildAtAnimated", "setupDone", "lw", "lh", "shrink", "done", "reparentAnimated", "node", "newParent", "half", "oldParent", "exitFade", "exitShrink", "enterGrow", "enterFade", "inNewParent", "TRANSFORM_3D_KEYS", "expandTransform3D", "props", "bag", "source", "field", "prop", "value", "rotateOffset", "x", "y", "rotationDeg", "ox", "oy", "rad", "cos", "sin", "localMatrix", "cx", "cy", "rotation", "scale", "pivot", "width", "height", "projection", "NO_PROJECTION_3D", "pivotX", "pivotY", "nodeProjectedMatrix", "worldAnchors", "m", "halfW", "halfH", "at", "p", "applyToPoint", "IDENTITY", "identity", "spaceRootFrame", "root", "camera", "view", "spaceViewMatrix", "spaceScreenMatrix", "spacePlane", "spaceChildFrame", "parent", "child", "own", "multiplyAffine3", "screen", "box", "inkBox", "plane", "side", "edgeOn", "cameraSide", "coverage", "nearCoverage", "local", "paints", "undo", "invert", "multiply", "nearCutClip", "spaceFrameOf", "node", "chain", "frame", "spaceFrameForChildren", "spaceChildOrder", "frames", "f", "_", "i", "spacePaintOrder", "b", "NEAR_CUT_MARGIN", "polygon", "nearCutPolygon", "path", "PathBuilder", "reach", "p", "Clip", "computeSpaceRects", "parentRect", "thisRect", "x", "y", "ox", "oy", "applyBackdropEffects", "ctx", "effects", "clip", "width", "height", "backdrop", "backdropEffects", "applyContentEffectScope", "body", "foreground", "foregroundShaderEffects", "hasForeground", "NO_SPACE_RECTS", "ORIGIN_2D", "NO_HANDLES", "SLOT_PROJECTION", "slotProjection", "placement", "DEFAULT_FLOW", "NO_CONTENT", "Node2D", "_Node2D", "Node", "parent", "_observer", "all", "i", "c", "props", "size2DOps", "expandTransform3D", "sizeInputOps", "alignmentOps", "alignmentKey", "raw", "getTarget", "pivot", "x", "y", "sizeVal", "to", "duration", "easing", "explicitPivot", "assets", "at", "r", "o", "primeMotion", "PropSlot", "LAYOUT_SLOT", "children", "axis", "defaultSize", "args", "path", "target", "targetAnchor", "destination", "positioned", "aimed", "aim", "sampler", "pathOps", "PathBuilder", "length", "first", "last", "fit", "origin", "t", "frame", "point", "_stated", "rest", "factor", "angle", "turns", "ox", "oy", "rotateOffset", "slot", "multiply", "localMatrix", "cx", "cy", "_child", "size", "space", "box", "flowOps", "rotation", "scale", "own", "applyToPoint", "_prop", "_at", "plane", "paint", "nodeSpaceMatrix", "p", "width", "height", "multiplyAffine3", "local", "anchors", "worldAnchors", "opacity", "n", "id", "anchor", "findNode2D", "a", "world", "toParent", "invert", "child", "index", "addChildAtAnimated", "removed", "removeChildAtAnimated", "createMotionHistory", "sampleMotion", "ctx", "s", "slotOpacity", "projection", "hasProjection3D", "clip", "tolerance", "b", "effects", "applyBackdropEffects", "body", "applyContentEffectScope", "camera", "spaceRootFrame", "frames", "spaceChildFrame", "order", "spaceChildOrder", "_", "cut", "computeSpaceRects", "error", "AssetNotLoadedError", "clipped", "facesAway", "rect", "current", "scope", "pending", "inner", "insetsOps", "settings", "measured", "boxes", "warning", "constraints", "padding", "newParent", "old", "reparentAnimated", "declareMembers", "property", "effectsProperty", "insetsProperty", "alignmentProperty", "lerpPerspective", "v", "from", "command", "data", "stated", "key", "root", "findUnder", "found", "frameIn", "host", "node", "there", "here", "inverse", "offset", "NodeAudio", "_NodeAudio", "Node", "props", "c", "authored", "structuralPathOf", "to", "duration", "easing", "key", "TWEEN_REFUSED", "declareMembers", "audioParamProperty", "property", "audioEffectsProperty", "busPathOf", "node", "spanOf", "stops", "parent", "stopOf", "busPathTo", "bus", "findBusById", "from", "id", "root", "searchBus", "child", "found", "effects", "span", "parts", "current", "parentSpaceOf", "node", "parent", "VECTOR_SUGAR", "Node3D", "_Node3D", "Node", "props", "distributeVectors", "args", "stated", "value", "to", "duration", "easing", "quaternion", "identityQuaternion", "space", "_child", "ctx", "child", "assets", "scene", "Scene3D", "declare3DResources", "declareMembers", "property", "quaternionProperty", "optionalVector3Property", "command", "out", "key", "axes", "read", "i", "axis", "componentOf", "resolveVector3", "vector", "order", "data", "index", "NODE_META", "node", "type", "ctor", "descriptor", "getNodeDescriptor", "proto", "resolveShapePivot", "pivot", "alignmentOps", "SHAPE_ALIGNMENT_KEYS", "validateShapeAlignmentProps", "descriptor", "present", "k", "conflict", "stripShapeAlignmentKeys", "out", "resolveShapeAlignment", "width", "height", "alignmentKey", "target", "a", "resolvePivotPosition", "withRectDescriptor", "descriptor", "width", "height", "x", "y", "pivot", "resolveShapeAlignment", "stripShapeAlignmentKeys", "resolveShapePivot", "withEllipseDescriptor", "descriptor", "width", "height", "x", "y", "pivot", "resolveShapeAlignment", "stripShapeAlignmentKeys", "resolveShapePivot", "withPolygonDescriptor", "descriptor", "width", "height", "x", "y", "pivot", "resolveShapeAlignment", "stripShapeAlignmentKeys", "resolveShapePivot", "withPolygramDescriptor", "descriptor", "width", "height", "x", "y", "pivot", "resolveShapeAlignment", "stripShapeAlignmentKeys", "resolveShapePivot", "withLineDescriptor", "descriptor", "resolveShapePivot", "EPS", "containsClip", "clip", "point", "tolerance", "containsOps", "ops", "inside", "pending", "flush", "containsShape", "op", "s", "withRectDescriptor", "p", "toShapeLocal", "containsRect", "cornerRadiusOps", "withEllipseDescriptor", "containsEllipse", "withPolygonDescriptor", "containsPolyline", "polygonVertices", "withPolygramDescriptor", "polygramVertices", "withLineDescriptor", "nearPolyline", "local", "width", "height", "pivot", "px", "py", "dx", "dy", "rad", "cos", "sin", "rx", "ry", "radius", "halfW", "halfH", "maxR", "r", "sx", "sy", "ratio", "sweep", "startAngle", "clamped", "full", "norm", "withinSweep", "angleDeg", "lo", "span", "slack", "delta", "sides", "n", "step", "out", "i", "a", "k", "verts", "closed", "pointInPolygon", "j", "b", "pts", "last", "distanceToSegment", "lenSq", "t", "ExpressionError", "message", "source", "position", "path", "where", "DEG", "DOCUMENT_FUNCTIONS", "a", "DOCUMENT_CONSTANTS", "DOCUMENT_DIALECT", "name", "sortedKeys", "table", "OPERATORS", "isDigit", "ch", "tokenize", "source", "dialect", "tokens", "i", "start", "mark", "ExpressionError", "end", "parse", "refs", "index", "peek", "next", "addRef", "startsPrimary", "t", "parseAdditive", "left", "parseMultiplicative", "parseUnary", "operand", "parsePower", "base", "parsePrimary", "parseCall", "pos", "def", "args", "close", "min", "max", "want", "plural", "inner", "constant", "root", "trailing", "toNumber", "value", "compile", "parsed", "resolve", "path", "readOf", "name", "read", "ExpressionError", "emit", "node", "operand", "left", "right", "apply", "DOCUMENT_FUNCTIONS", "args", "a", "isSource", "value", "unescape", "STATIC", "walk", "path", "onString", "parts", "v", "i", "p", "rebuilt", "isPlainObject", "keys", "k", "out", "part", "bind", "resolve", "source", "at", "compile", "parse", "bindProps", "props", "literal", "bindings", "hasBindings", "key", "compiled", "collect", "REF", "renameRefs", "rename", "whole", "ref", "next", "parseSource", "source", "dialect", "DOCUMENT_DIALECT", "parse", "isSource", "expressionOps", "unescape", "e", "compile", "bind", "bindProps", "collect", "renameRefs", "sortedKeys", "PROP_EVOLUTION", "declarePropEvolution", "ctor", "evolution", "propEvolutionOf", "proto", "migrateNodeProps", "registry", "type", "props", "applyPropEvolution", "changes", "deprecated", "out", "write", "isExpression", "value", "expressionOps", "convert", "key", "at", "hook", "from", "to", "target", "current", "next", "message", "SPAN_KEYS", "RICHTEXT_BLOCK_KEYS", "applyGraphicsTextDefaults", "graphics", "style", "ambient", "hasShapingDefaults", "EMPTY_TEXT_STYLE", "ops", "next", "op", "effective", "effectiveStyle", "patched", "patchText", "patchRichText", "variant", "textOps", "key", "TEXT_SHAPING_KEYS", "state", "fillUnset", "spans", "patchSpans", "spanStyle", "i", "target", "keys", "current", "out", "value", "CanvasRenderContext2D", "style", "EMPTY_TEXT_STYLE", "textOps", "graphics", "applyGraphicsTextDefaults", "state", "effects", "target", "width", "height", "draw", "pixelRatio", "ZERO_SIZE", "NullRenderContext", "CanvasRenderContext2D", "graphics", "callback", "width", "height", "draw", "state", "op", "_options", "clip", "_viewport", "_centerOn", "_zoom", "_heading", "clipOf", "shape", "clip", "Clip", "op", "piece", "data", "makeTimeline", "args", "duration", "easing", "node", "targets", "frame", "options", "t", "src", "seconds", "pieces", "SILENT", "leaf", "command", "pure", "elapsed", "placed", "parts", "offsets", "max", "part", "i", "s", "timedOf", "host", "p", "run", "runCommand", "settles", "fixed", "sum", "flexible", "each", "cursor", "timed", "n", "step", "_", "name", "meta", "getCommandMeta", "m", "method", "built", "SOUNDS", "commandSoundsOf", "commandOf", "settling", "driveCommand", "sounds", "TYPE_DEF", "isTypeLike", "value", "defOf", "entry", "NODE", "pass", "withPass", "node", "scope", "room", "run", "outer", "decided", "markDecided", "takeDecided", "currentPass", "measureChild", "max", "p", "constraints", "measured", "size", "childViews", "ChildViewImpl", "target", "keys", "own", "key", "propsOf", "keyOf", "box", "childView", "targets", "name", "args", "NO_PROPS", "slots", "view", "nodeOfView", "nodeViews", "NO_FRAME", "NodeViewImpl", "reader", "fields", "value", "Node2D", "frameIn", "nodeView", "byReader", "nodeOfNodeView", "found", "referenced", "id", "known", "rootOf", "findIn", "at", "child", "hit", "setKeyLookup", "lookup", "stateViewPrototype", "references", "entries", "entryGetter", "proto", "layout", "i", "cells", "slot", "stateView", "shape", "snapshot", "out", "MeasurerImpl", "host", "text", "font", "RenderContextImpl", "probing", "graphics", "g", "composite", "options", "stencil", "content", "op", "paint", "Graphics2D", "rect", "scene", "Scene3D", "Node3D", "camera", "style", "body", "outline", "clipOf", "component", "PROBE_PASS", "NullRenderContext", "internalsOf", "ctx", "lowering", "spec", "Base", "ownsDefault", "builtIn", "getPropertyMeta", "m", "entries", "k", "e", "defOf", "defaults", "key", "value", "own", "checkEvolution", "references", "def", "stateViewPrototype", "factoryDefault", "componentBase", "l", "s", "Componentized", "args", "props", "given", "stateView", "built", "asBuilt", "builderState", "authored", "child", "part", "ctx", "self", "context", "parent", "provided", "memo", "p", "i", "map", "assets", "declareEntry", "loaderOf", "allowed", "rule", "matches", "namesOf", "frame", "duration", "easing", "finishComponent", "Generated", "pascal", "proto", "deleteUpTo", "trees", "property", "inherited", "base", "entry", "method", "entrance", "cmd", "timeline", "makeTimeline", "nodeView", "piece", "snapshot", "commandOf", "declared", "run", "ownEasing", "names", "name", "data", "argsRecord", "stated", "settling", "isTypeLike", "resolveArgs", "command", "declarePropEvolution", "node", "componentValue", "isEntry", "from", "to", "at", "make", "nodeOfView", "_", "_sep", "c", "rules", "out", "kind", "stroke", "shadow", "tasks", "taskOf", "load", "task", "loaded", "family", "weight", "src", "trim", "options", "fills", "inkCorners", "child", "b", "local", "m", "multiply", "translation", "a", "worldAnchors", "spanOf", "points", "minX", "minY", "maxX", "maxY", "p", "toBounds", "span", "childInkBounds", "node", "mode", "children", "next", "NO_INSETS", "SIZE_KEYS", "setKeyLookup", "n", "getNodeDescriptor", "slotOf", "p", "component2d", "spec", "s", "l", "lowering", "Node2D", "defaults", "flows", "Generated", "componentBase", "props", "MeasurerImpl", "RenderContextImpl", "axis", "sizeInputOps", "given", "flow", "main", "declared", "value", "constraints", "scope", "m", "natural", "withPass", "childView", "takeDecided", "flowOps", "rect", "children", "box", "placements", "slots", "planes", "i", "child", "slot", "pass", "frame", "ctx", "clipOf", "r", "bounds", "childInkBounds", "NO_PROJECTION_3D", "probe", "local", "tolerance", "clip", "containsClip", "proto", "handles", "sizeOf", "node", "out", "prop", "handle", "at", "space", "finishComponent", "make", "def", "meaning", "kind", "options", "extra", "_private", "_typing", "_inherit", "rest", "attribute", "fallback", "mapper", "tween", "base", "initial", "defaultsOf", "shape", "out", "key", "defOf", "Types", "textOps", "values", "fillOps", "strokeOps", "shadowOps", "effectsOps", "colorOps", "cornerRadiusOps", "cornerStyleOps", "pathOps", "insetsOps", "alignmentOps", "vector2Ops", "sizeInputOps", "item", "resolve", "lerp", "src", "family", "corners_exports", "__export", "rect", "state", "state", "Types", "rect", "size", "s", "Graphics2D", "flow_exports", "__export", "layout", "measure", "state", "state", "Types", "flowOps", "NO_CONTENT", "pending", "padded", "s", "inset", "p", "measure", "measurer", "children", "node", "scope", "currentPass", "padding", "constraints", "space", "measured", "nodeOfView", "layout", "box", "kept", "inner", "insetsOps", "b", "commandsFor", "state", "commands", "paint_exports", "__export", "commands", "draw", "inset", "state", "FRACTION", "state", "Types", "commands", "commandsFor", "timeline", "s", "rest", "portion", "t", "head", "TRIMMED", "trimmed", "shape", "start", "end", "op", "copy", "castsShadowFromStroke", "layer", "draw", "ctx", "options", "c", "internalsOf", "out", "confining", "base", "outline", "clipOf", "clipped", "overlay", "stroke", "inset", "extra", "intrusion", "shapes_exports", "__export", "box", "state", "ellipse", "facePath", "outline", "polygon", "polygram", "rect", "unitPath", "ellipse", "size", "s", "Graphics2D", "polygon", "polygram", "box", "unitPath", "data", "w", "h", "pathOps", "p", "facePath", "b", "outline", "kind", "options", "shapeOutlinePixels", "aim_exports", "__export", "aim", "camera", "commands", "state", "state", "Types", "lerpVector2", "commands", "commandsFor", "aim", "ctx", "s", "target", "node", "nodeOfNodeView", "Node2D", "within", "internalsOf", "at", "camera", "ancestor", "AUTOFIT_PROBE_SIZE", "requireFontFamily", "descriptor", "family", "host", "hostTextFamily", "text", "withTextDescriptor", "width", "height", "x", "y", "pivot", "resolveShapeAlignment", "stripShapeAlignmentKeys", "resolveShapePivot", "text_layout_exports", "__export", "draw", "drawRichText", "load", "loadRichText", "measure", "measureRichText", "textStateOf", "casedText", "s", "src", "textOps", "measureGlyphs", "constraints", "scope", "width", "height", "pathOps", "wm", "hm", "measureFontSize", "paragraphs", "styled", "textSegments", "lineStyles", "measureStyledLines", "lineH", "intrinsicW", "line", "w", "run", "l", "resolvedW", "wraps", "lineSizes", "wrappedLineSizes", "intrinsicH", "h", "size", "n", "p", "countWrappedLines", "runs", "r", "text", "hasReveal", "revealStart", "revealEnd", "nodeFontSize", "AUTOFIT_PROBE_SIZE", "fill", "stroke", "cuts", "points", "c", "a", "b", "segments", "i", "start", "end", "seg", "textState", "declareGlyphAssets", "assets", "segment", "family", "fallback", "lines", "style", "parts", "maxWidth", "sizes", "tokens", "part", "space", "last", "lineW", "token", "paragraph", "fontSize", "fontFamily", "fontWeight", "letterSpacing", "fontStyle", "words", "word", "richRuns", "measureRich", "maxLineH", "totalW", "totalH", "finishLine", "lh", "richState", "declareRichAssets", "measure", "measurer", "s", "source", "node", "scope", "currentPass", "markDecided", "measureGlyphs", "drawn", "draw", "ctx", "c", "internalsOf", "out", "state", "textState", "segmented", "g", "Graphics2D", "stroke", "load", "loader", "declareGlyphAssets", "textStateOf", "last", "measureRichText", "measureRich", "drawRichText", "richState", "loadRichText", "declareRichAssets", "TextStyleToken", "createContext", "ThemeToken", "DataToken", "SeedToken", "provides", "context", "value", "text_style_exports", "__export", "current", "inherit", "provide", "provided", "state", "cascade", "use", "given", "variant", "textOps", "TextStyleToken", "inherit", "key", "options", "value", "state", "Types", "a", "b", "t", "provided", "provide", "s", "inherited", "provides", "current", "componentAudio", "spec", "l", "lowering", "NodeAudio", "Generated", "componentBase", "childView", "finishComponent", "setKeyLookup", "n", "getNodeDescriptor", "RenderContext3DImpl", "host", "graphics", "light", "transform", "camera", "fog", "environment", "component3d", "spec", "s", "l", "lowering", "Node3D", "Generated", "componentBase", "props", "ctx", "c", "assets", "declareEnvironment", "childView", "space", "finishComponent", "material_exports", "__export", "mesh", "points", "shorthand", "single", "state", "optional", "Types", "optionalNumber", "hints", "optionalColor", "v", "colorOps", "optionalVector3", "unset", "resolveOptionalVector3", "from", "to", "t", "lerpOptionalVector3", "defined", "s", "keys", "out", "key", "value", "stated", "type", "state", "optional", "Types", "lerpFill3D", "optionalColor", "SHORTHAND_KEYS", "shorthand", "s", "out", "key", "mesh", "geometry", "g3", "Graphics3D", "resolveMaterialShorthand3D", "single", "resolved", "POINTS_KEYS", "points", "material", "fill", "resolveFill3D", "view3d_exports", "__export", "commands", "draw", "load", "scene", "state", "gridGeometry3D", "options", "size", "divisions", "majorEvery", "showAxes", "fade", "half", "step", "minor", "rgb", "major", "axisX", "axisZ", "fadeTo", "position", "color", "segment", "ax", "az", "bx", "bz", "tint", "pushFaded", "fadeAt", "i", "offset", "fromCentre", "x", "z", "distance", "start", "t", "out", "value", "r", "g", "b", "resolveColor3D", "srgbToLinear", "channel", "color3D", "initial", "Types", "resolveColor3D", "lerpColor3D", "state", "optional", "commands", "loadThreeRuntime", "warmCanvas3D", "load", "loader", "extend", "scene", "Scene3D", "fill", "grids", "ctx", "s", "hasChildren", "shadows", "resolveShadows3D", "fog", "base", "baseColor", "Graphics3D", "gridOf", "internalsOf", "cameraOrbit", "op", "draw", "built", "internals", "host", "forEachTexture3D", "texture", "isSurfaceTexture3D", "source", "resolveSurfaceSource", "Fills", "rect", "options", "fadeColor", "key", "kept", "gridGeometry3D", "layer", "color"]
|
|
7
|
+
}
|