@motionscript/core 0.1.0-alpha.7 → 0.1.0-alpha.8
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 +6 -0
- package/NOTICE +15 -14
- package/README.md +4 -4
- package/dist/assets/manager.d.ts.map +1 -1
- package/dist/assets/manager.js +7 -5
- package/dist/assets/manager.js.map +1 -1
- package/dist/attributes/audio/effects/chain.d.ts +73 -0
- package/dist/attributes/audio/effects/chain.d.ts.map +1 -0
- package/dist/attributes/audio/effects/chain.js +67 -0
- package/dist/attributes/audio/effects/chain.js.map +1 -0
- package/dist/attributes/audio/effects/implementations/echo.d.ts +14 -0
- package/dist/attributes/audio/effects/implementations/echo.d.ts.map +1 -0
- package/dist/attributes/audio/effects/implementations/echo.js +11 -0
- package/dist/attributes/audio/effects/implementations/echo.js.map +1 -0
- package/dist/attributes/audio/effects/implementations/gain.d.ts +10 -0
- package/dist/attributes/audio/effects/implementations/gain.d.ts.map +1 -0
- package/dist/attributes/audio/effects/implementations/gain.js +6 -0
- package/dist/attributes/audio/effects/implementations/gain.js.map +1 -0
- package/dist/attributes/audio/effects/implementations/highpass.d.ts +12 -0
- package/dist/attributes/audio/effects/implementations/highpass.d.ts.map +1 -0
- package/dist/attributes/audio/effects/implementations/highpass.js +10 -0
- package/dist/attributes/audio/effects/implementations/highpass.js.map +1 -0
- package/dist/attributes/audio/effects/implementations/lowpass.d.ts +12 -0
- package/dist/attributes/audio/effects/implementations/lowpass.d.ts.map +1 -0
- package/dist/attributes/audio/effects/implementations/lowpass.js +10 -0
- package/dist/attributes/audio/effects/implementations/lowpass.js.map +1 -0
- package/dist/attributes/audio/effects/implementations/tremolo.d.ts +12 -0
- package/dist/attributes/audio/effects/implementations/tremolo.d.ts.map +1 -0
- package/dist/attributes/audio/effects/implementations/tremolo.js +10 -0
- package/dist/attributes/audio/effects/implementations/tremolo.js.map +1 -0
- package/dist/attributes/audio/effects/index.d.ts +12 -0
- package/dist/attributes/audio/effects/index.d.ts.map +1 -0
- package/dist/attributes/audio/effects/index.js +4 -0
- package/dist/attributes/audio/effects/index.js.map +1 -0
- package/dist/attributes/audio/effects/registry.d.ts +36 -0
- package/dist/attributes/audio/effects/registry.d.ts.map +1 -0
- package/dist/attributes/audio/effects/registry.js +80 -0
- package/dist/attributes/audio/effects/registry.js.map +1 -0
- package/dist/attributes/audio/effects/union.d.ts +14 -0
- package/dist/attributes/audio/effects/union.d.ts.map +1 -0
- package/dist/attributes/audio/effects/union.js +24 -0
- package/dist/attributes/audio/effects/union.js.map +1 -0
- package/dist/attributes/audio/ramp.d.ts +103 -0
- package/dist/attributes/audio/ramp.d.ts.map +1 -0
- package/dist/attributes/audio/ramp.js +246 -0
- package/dist/attributes/audio/ramp.js.map +1 -0
- package/dist/attributes/audio/request.d.ts +24 -13
- package/dist/attributes/audio/request.d.ts.map +1 -1
- package/dist/attributes/audio/request.js +4 -3
- package/dist/attributes/audio/request.js.map +1 -1
- package/dist/attributes/audio/schedule.d.ts +21 -13
- package/dist/attributes/audio/schedule.d.ts.map +1 -1
- package/dist/attributes/audio/schedule.js +42 -28
- package/dist/attributes/audio/schedule.js.map +1 -1
- package/dist/attributes/audio/sound.d.ts +15 -12
- package/dist/attributes/audio/sound.d.ts.map +1 -1
- package/dist/attributes/audio/sound.js +8 -10
- package/dist/attributes/audio/sound.js.map +1 -1
- package/dist/attributes/audio/transition.d.ts +33 -0
- package/dist/attributes/audio/transition.d.ts.map +1 -0
- package/dist/attributes/audio/transition.js +48 -0
- package/dist/attributes/audio/transition.js.map +1 -0
- package/dist/attributes/index.d.ts +4 -3
- package/dist/attributes/index.d.ts.map +1 -1
- package/dist/attributes/index.js +4 -7
- package/dist/attributes/index.js.map +1 -1
- package/dist/attributes/layout/matrix2d.d.ts +2 -2
- package/dist/attributes/layout/matrix2d.js.map +1 -1
- package/dist/attributes/layout/space3d.js +1 -1
- package/dist/attributes/layout/space3d.js.map +1 -1
- package/dist/attributes/properties/typed.d.ts +7 -7
- package/dist/attributes/properties/typed.d.ts.map +1 -1
- package/dist/attributes/properties/typed.js +6 -6
- package/dist/attributes/properties/typed.js.map +1 -1
- package/dist/attributes/shape/corners/corner-radius.d.ts +1 -2
- package/dist/attributes/shape/corners/corner-radius.d.ts.map +1 -1
- package/dist/attributes/shape/corners/corner-radius.js +1 -2
- package/dist/attributes/shape/corners/corner-radius.js.map +1 -1
- package/dist/attributes/shape/effects/chain.d.ts +96 -409
- package/dist/attributes/shape/effects/chain.d.ts.map +1 -1
- package/dist/attributes/shape/effects/chain.js +93 -283
- package/dist/attributes/shape/effects/chain.js.map +1 -1
- package/dist/attributes/shape/effects/effect-data.d.ts +1 -1
- package/dist/attributes/shape/effects/effect-data.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/ascii.d.ts +45 -13
- package/dist/attributes/shape/effects/implementations/ascii.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/ascii.js +29 -23
- package/dist/attributes/shape/effects/implementations/ascii.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/bit-crush.d.ts +32 -7
- package/dist/attributes/shape/effects/implementations/bit-crush.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/bit-crush.js +17 -15
- package/dist/attributes/shape/effects/implementations/bit-crush.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/block-displace.d.ts +46 -10
- package/dist/attributes/shape/effects/implementations/block-displace.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/block-displace.js +21 -19
- package/dist/attributes/shape/effects/implementations/block-displace.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/bloom.d.ts +32 -7
- package/dist/attributes/shape/effects/implementations/bloom.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/bloom.js +17 -11
- package/dist/attributes/shape/effects/implementations/bloom.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/blur.d.ts +16 -3
- package/dist/attributes/shape/effects/implementations/blur.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/blur.js +13 -5
- package/dist/attributes/shape/effects/implementations/blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/bulge.d.ts +28 -9
- package/dist/attributes/shape/effects/implementations/bulge.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/bulge.js +15 -14
- package/dist/attributes/shape/effects/implementations/bulge.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/chromatic-aberration.d.ts +21 -5
- package/dist/attributes/shape/effects/implementations/chromatic-aberration.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/chromatic-aberration.js +15 -10
- package/dist/attributes/shape/effects/implementations/chromatic-aberration.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/color-adjustment.d.ts +96 -26
- package/dist/attributes/shape/effects/implementations/color-adjustment.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/color-adjustment.js +29 -26
- package/dist/attributes/shape/effects/implementations/color-adjustment.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/curves.d.ts +20 -6
- package/dist/attributes/shape/effects/implementations/curves.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/curves.js +26 -23
- package/dist/attributes/shape/effects/implementations/curves.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/directional-blur.d.ts +26 -5
- package/dist/attributes/shape/effects/implementations/directional-blur.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/directional-blur.js +15 -10
- package/dist/attributes/shape/effects/implementations/directional-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/dither.d.ts +58 -11
- package/dist/attributes/shape/effects/implementations/dither.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/dither.js +26 -20
- package/dist/attributes/shape/effects/implementations/dither.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/drop-shadow.d.ts +46 -14
- package/dist/attributes/shape/effects/implementations/drop-shadow.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/drop-shadow.js +24 -29
- package/dist/attributes/shape/effects/implementations/drop-shadow.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/duotone.d.ts +26 -7
- package/dist/attributes/shape/effects/implementations/duotone.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/duotone.js +17 -16
- package/dist/attributes/shape/effects/implementations/duotone.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/edges.d.ts +29 -7
- package/dist/attributes/shape/effects/implementations/edges.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/edges.js +17 -14
- package/dist/attributes/shape/effects/implementations/edges.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/glass.d.ts +76 -19
- package/dist/attributes/shape/effects/implementations/glass.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/glass.js +28 -22
- package/dist/attributes/shape/effects/implementations/glass.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/glow.d.ts +149 -42
- package/dist/attributes/shape/effects/implementations/glow.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/glow.js +74 -72
- package/dist/attributes/shape/effects/implementations/glow.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/grain.d.ts +43 -11
- package/dist/attributes/shape/effects/implementations/grain.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/grain.js +21 -18
- package/dist/attributes/shape/effects/implementations/grain.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/grayscale.d.ts +17 -3
- package/dist/attributes/shape/effects/implementations/grayscale.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/grayscale.js +13 -5
- package/dist/attributes/shape/effects/implementations/grayscale.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/halftone.d.ts +40 -9
- package/dist/attributes/shape/effects/implementations/halftone.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/halftone.js +20 -16
- package/dist/attributes/shape/effects/implementations/halftone.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/invert.d.ts +23 -5
- package/dist/attributes/shape/effects/implementations/invert.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/invert.js +15 -10
- package/dist/attributes/shape/effects/implementations/invert.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/kaleidoscope.d.ts +57 -18
- package/dist/attributes/shape/effects/implementations/kaleidoscope.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/kaleidoscope.js +25 -22
- package/dist/attributes/shape/effects/implementations/kaleidoscope.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/lut.d.ts +34 -7
- package/dist/attributes/shape/effects/implementations/lut.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/lut.js +20 -16
- package/dist/attributes/shape/effects/implementations/lut.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/magnify.d.ts +27 -9
- package/dist/attributes/shape/effects/implementations/magnify.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/magnify.js +17 -14
- package/dist/attributes/shape/effects/implementations/magnify.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/motion-blur.d.ts +54 -19
- package/dist/attributes/shape/effects/implementations/motion-blur.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/motion-blur.js +42 -20
- package/dist/attributes/shape/effects/implementations/motion-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/oil-paint.d.ts +17 -3
- package/dist/attributes/shape/effects/implementations/oil-paint.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/oil-paint.js +13 -9
- package/dist/attributes/shape/effects/implementations/oil-paint.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/outline.d.ts +28 -8
- package/dist/attributes/shape/effects/implementations/outline.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/outline.js +18 -17
- package/dist/attributes/shape/effects/implementations/outline.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/pixelate.d.ts +25 -6
- package/dist/attributes/shape/effects/implementations/pixelate.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/pixelate.js +16 -14
- package/dist/attributes/shape/effects/implementations/pixelate.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/posterize.d.ts +14 -3
- package/dist/attributes/shape/effects/implementations/posterize.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/posterize.js +13 -9
- package/dist/attributes/shape/effects/implementations/posterize.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/progressive-blur.d.ts +91 -26
- package/dist/attributes/shape/effects/implementations/progressive-blur.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/progressive-blur.js +27 -28
- package/dist/attributes/shape/effects/implementations/progressive-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/radial-blur.d.ts +49 -10
- package/dist/attributes/shape/effects/implementations/radial-blur.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/radial-blur.js +19 -20
- package/dist/attributes/shape/effects/implementations/radial-blur.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/rgb-shift.d.ts +36 -6
- package/dist/attributes/shape/effects/implementations/rgb-shift.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/rgb-shift.js +16 -15
- package/dist/attributes/shape/effects/implementations/rgb-shift.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/scanlines.d.ts +52 -11
- package/dist/attributes/shape/effects/implementations/scanlines.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/scanlines.js +21 -18
- package/dist/attributes/shape/effects/implementations/scanlines.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/scatter.d.ts +23 -9
- package/dist/attributes/shape/effects/implementations/scatter.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/scatter.js +15 -12
- package/dist/attributes/shape/effects/implementations/scatter.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/shader.d.ts +90 -34
- package/dist/attributes/shape/effects/implementations/shader.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/shader.js +42 -26
- package/dist/attributes/shape/effects/implementations/shader.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/sharpen.d.ts +23 -5
- package/dist/attributes/shape/effects/implementations/sharpen.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/sharpen.js +16 -11
- package/dist/attributes/shape/effects/implementations/sharpen.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/streak.d.ts +40 -9
- package/dist/attributes/shape/effects/implementations/streak.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/streak.js +19 -16
- package/dist/attributes/shape/effects/implementations/streak.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/threshold.d.ts +24 -5
- package/dist/attributes/shape/effects/implementations/threshold.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/threshold.js +17 -11
- package/dist/attributes/shape/effects/implementations/threshold.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/twirl.d.ts +35 -8
- package/dist/attributes/shape/effects/implementations/twirl.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/twirl.js +17 -16
- package/dist/attributes/shape/effects/implementations/twirl.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/vignette.d.ts +37 -7
- package/dist/attributes/shape/effects/implementations/vignette.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/vignette.js +19 -18
- package/dist/attributes/shape/effects/implementations/vignette.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/vintage.d.ts +24 -5
- package/dist/attributes/shape/effects/implementations/vintage.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/vintage.js +15 -10
- package/dist/attributes/shape/effects/implementations/vintage.js.map +1 -1
- package/dist/attributes/shape/effects/implementations/wave.d.ts +61 -14
- package/dist/attributes/shape/effects/implementations/wave.d.ts.map +1 -1
- package/dist/attributes/shape/effects/implementations/wave.js +26 -23
- package/dist/attributes/shape/effects/implementations/wave.js.map +1 -1
- package/dist/attributes/shape/effects/index.d.ts +4 -2
- package/dist/attributes/shape/effects/index.d.ts.map +1 -1
- package/dist/attributes/shape/effects/index.js +1 -1
- package/dist/attributes/shape/effects/index.js.map +1 -1
- package/dist/attributes/shape/effects/registry.d.ts +11 -0
- package/dist/attributes/shape/effects/registry.d.ts.map +1 -1
- package/dist/attributes/shape/effects/registry.js +113 -102
- package/dist/attributes/shape/effects/registry.js.map +1 -1
- package/dist/attributes/shape/effects/spec.d.ts +229 -0
- package/dist/attributes/shape/effects/spec.d.ts.map +1 -0
- package/dist/attributes/shape/effects/spec.js +178 -0
- package/dist/attributes/shape/effects/spec.js.map +1 -0
- package/dist/attributes/shape/fill/chain.d.ts +7 -9
- package/dist/attributes/shape/fill/chain.d.ts.map +1 -1
- package/dist/attributes/shape/fill/chain.js +9 -11
- package/dist/attributes/shape/fill/chain.js.map +1 -1
- package/dist/attributes/shape/fill/implementations/shader.d.ts +27 -26
- package/dist/attributes/shape/fill/implementations/shader.d.ts.map +1 -1
- package/dist/attributes/shape/fill/implementations/shader.js +20 -14
- package/dist/attributes/shape/fill/implementations/shader.js.map +1 -1
- package/dist/attributes/shape/fill/index.d.ts +1 -1
- package/dist/attributes/shape/fill/index.d.ts.map +1 -1
- package/dist/attributes/shape/fill/index.js.map +1 -1
- package/dist/attributes/shape/fill/registry.d.ts +1 -2
- package/dist/attributes/shape/fill/registry.d.ts.map +1 -1
- package/dist/attributes/shape/fill/registry.js +1 -2
- package/dist/attributes/shape/fill/registry.js.map +1 -1
- package/dist/attributes/shape/filters/chain.d.ts +2 -6
- package/dist/attributes/shape/filters/chain.d.ts.map +1 -1
- package/dist/attributes/shape/filters/chain.js +1 -5
- package/dist/attributes/shape/filters/chain.js.map +1 -1
- package/dist/attributes/shape/filters/implementations/color-matrix.d.ts +2 -2
- 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/registry.d.ts +1 -1
- package/dist/attributes/shape/filters/registry.d.ts.map +1 -1
- package/dist/attributes/shape/filters/registry.js +3 -3
- package/dist/attributes/shape/filters/registry.js.map +1 -1
- package/dist/attributes/shape/filters/union.d.ts +2 -3
- 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/shaders/index.d.ts +2 -0
- package/dist/attributes/shape/shaders/index.d.ts.map +1 -1
- package/dist/attributes/shape/shaders/index.js +2 -0
- package/dist/attributes/shape/shaders/index.js.map +1 -1
- package/dist/attributes/shape/shaders/language.d.ts +26 -0
- package/dist/attributes/shape/shaders/language.d.ts.map +1 -0
- package/dist/attributes/shape/shaders/language.js +20 -0
- package/dist/attributes/shape/shaders/language.js.map +1 -0
- package/dist/attributes/shape/shaders/pack.d.ts +25 -11
- package/dist/attributes/shape/shaders/pack.d.ts.map +1 -1
- package/dist/attributes/shape/shaders/pack.js +9 -4
- package/dist/attributes/shape/shaders/pack.js.map +1 -1
- package/dist/attributes/shape/shaders/resolve.d.ts +4 -5
- package/dist/attributes/shape/shaders/resolve.d.ts.map +1 -1
- package/dist/attributes/shape/shaders/resolve.js +3 -6
- package/dist/attributes/shape/shaders/resolve.js.map +1 -1
- package/dist/attributes/shape/shaders/uniforms.d.ts +41 -0
- package/dist/attributes/shape/shaders/uniforms.d.ts.map +1 -0
- package/dist/attributes/shape/shaders/uniforms.js +0 -0
- package/dist/attributes/shape/shaders/uniforms.js.map +1 -0
- package/dist/browser/chunks/chunk-AOT33LMS.js +13 -0
- package/dist/browser/chunks/chunk-AOT33LMS.js.map +7 -0
- package/dist/browser/chunks/chunk-GKM6UZJR.js +6 -0
- package/dist/browser/chunks/chunk-GKM6UZJR.js.map +7 -0
- package/dist/browser/experimental.js +1 -1
- package/dist/browser/experimental.js.map +4 -4
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +2 -2
- package/dist/browser/manifest.json +1 -1
- package/dist/browser/sdk.js +1 -1
- package/dist/components/builtins/audio/audio.d.ts +14 -5
- package/dist/components/builtins/audio/audio.d.ts.map +1 -1
- package/dist/components/builtins/audio/audio.js +10 -13
- package/dist/components/builtins/audio/audio.js.map +1 -1
- package/dist/components/builtins/geometry/composite.d.ts +3 -3
- package/dist/components/builtins/media/media.d.ts +7 -7
- package/dist/components/builtins/media/media.d.ts.map +1 -1
- package/dist/components/builtins/media/media.js +4 -10
- package/dist/components/builtins/media/media.js.map +1 -1
- package/dist/components/builtins/text/text.d.ts +12 -12
- package/dist/components/builtins/text/text.d.ts.map +1 -1
- package/dist/components/builtins/text/text.js +3 -0
- package/dist/components/builtins/text/text.js.map +1 -1
- package/dist/components/factory/api.d.ts +38 -11
- package/dist/components/factory/api.d.ts.map +1 -1
- package/dist/components/factory/api.js.map +1 -1
- package/dist/components/factory/component3d.d.ts.map +1 -1
- package/dist/components/factory/component3d.js +11 -3
- package/dist/components/factory/component3d.js.map +1 -1
- package/dist/components/factory/factory.d.ts +3 -0
- package/dist/components/factory/factory.d.ts.map +1 -1
- package/dist/components/factory/factory.js +39 -5
- package/dist/components/factory/factory.js.map +1 -1
- package/dist/components/modules/text-style.d.ts +1 -1
- package/dist/components/trees/2d/node-render.d.ts +1 -1
- package/dist/components/trees/2d/node-render.js +1 -1
- package/dist/components/trees/2d/node-render.js.map +1 -1
- package/dist/components/trees/2d/node2d.d.ts +1 -1
- package/dist/components/trees/2d/node2d.js +1 -1
- package/dist/components/trees/2d/node2d.js.map +1 -1
- package/dist/components/trees/audio/node-audio.d.ts +16 -9
- package/dist/components/trees/audio/node-audio.d.ts.map +1 -1
- package/dist/components/trees/audio/node-audio.js +15 -11
- package/dist/components/trees/audio/node-audio.js.map +1 -1
- package/dist/document/command-traits.d.ts +12 -2
- package/dist/document/command-traits.d.ts.map +1 -1
- package/dist/document/command-traits.js +34 -6
- package/dist/document/command-traits.js.map +1 -1
- package/dist/document/index.d.ts +8 -0
- package/dist/document/index.d.ts.map +1 -1
- package/dist/document/index.js +4 -0
- package/dist/document/index.js.map +1 -1
- package/dist/document/migrate.d.ts +70 -0
- package/dist/document/migrate.d.ts.map +1 -0
- package/dist/document/migrate.js +202 -0
- package/dist/document/migrate.js.map +1 -0
- package/dist/document/missing-node.d.ts +27 -0
- package/dist/document/missing-node.d.ts.map +1 -0
- package/dist/document/missing-node.js +48 -0
- package/dist/document/missing-node.js.map +1 -0
- package/dist/document/node-descriptor.d.ts +4 -0
- package/dist/document/node-descriptor.d.ts.map +1 -1
- package/dist/document/node-descriptor.js.map +1 -1
- package/dist/document/placement.d.ts +2 -1
- package/dist/document/placement.d.ts.map +1 -1
- package/dist/document/placement.js.map +1 -1
- package/dist/document/project.d.ts +2 -0
- package/dist/document/project.d.ts.map +1 -1
- package/dist/document/project.js +1 -0
- package/dist/document/project.js.map +1 -1
- package/dist/document/prop-evolution.d.ts +51 -0
- package/dist/document/prop-evolution.d.ts.map +1 -0
- package/dist/document/prop-evolution.js +83 -0
- package/dist/document/prop-evolution.js.map +1 -0
- package/dist/document/registry.d.ts +16 -0
- package/dist/document/registry.d.ts.map +1 -1
- package/dist/document/registry.js +30 -4
- package/dist/document/registry.js.map +1 -1
- package/dist/document/settled-index.d.ts +2 -0
- package/dist/document/settled-index.d.ts.map +1 -1
- package/dist/document/settled-index.js +5 -5
- package/dist/document/settled-index.js.map +1 -1
- package/dist/document/timeline-patch.d.ts +4 -0
- package/dist/document/timeline-patch.d.ts.map +1 -1
- package/dist/document/timeline-patch.js +28 -3
- package/dist/document/timeline-patch.js.map +1 -1
- package/dist/document/timeline.d.ts +45 -1
- package/dist/document/timeline.d.ts.map +1 -1
- package/dist/document/timeline.js +172 -42
- package/dist/document/timeline.js.map +1 -1
- package/dist/document/types.d.ts +14 -28
- package/dist/document/types.d.ts.map +1 -1
- package/dist/document/types.js.map +1 -1
- package/dist/document/validate.d.ts +17 -5
- package/dist/document/validate.d.ts.map +1 -1
- package/dist/document/validate.js +158 -21
- package/dist/document/validate.js.map +1 -1
- package/dist/document/vocabulary.d.ts +28 -0
- package/dist/document/vocabulary.d.ts.map +1 -0
- package/dist/document/vocabulary.js +42 -0
- package/dist/document/vocabulary.js.map +1 -0
- package/dist/experimental.d.ts +68 -8
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +22 -8
- package/dist/experimental.js.map +1 -1
- package/dist/platform/exporter.d.ts +13 -0
- package/dist/platform/exporter.d.ts.map +1 -1
- package/dist/platform/exporter.js.map +1 -1
- package/dist/renamed-scene-names.d.ts +1 -1
- package/dist/renamed-scene-names.d.ts.map +1 -1
- package/dist/renamed-scene-names.js +1 -1
- package/dist/renamed-scene-names.js.map +1 -1
- package/dist/render/canvas-render-context2d.d.ts +9 -0
- package/dist/render/canvas-render-context2d.d.ts.map +1 -1
- package/dist/render/canvas-render-context2d.js +10 -0
- package/dist/render/canvas-render-context2d.js.map +1 -1
- package/dist/render/clip-contains.js +1 -1
- package/dist/render/clip-contains.js.map +1 -1
- package/dist/render/descriptors/text.d.ts +2 -2
- package/dist/render/descriptors/text.js +2 -2
- package/dist/render/descriptors/text.js.map +1 -1
- package/dist/render/index.d.ts +2 -0
- package/dist/render/index.d.ts.map +1 -1
- package/dist/render/index.js +1 -0
- package/dist/render/index.js.map +1 -1
- package/dist/render/render-context2d.d.ts +1 -1
- package/dist/render/render-context2d.js.map +1 -1
- package/dist/render/render-issue.d.ts +39 -0
- package/dist/render/render-issue.d.ts.map +1 -0
- package/dist/render/render-issue.js +29 -0
- package/dist/render/render-issue.js.map +1 -0
- package/dist/render/surface.d.ts +2 -2
- package/dist/render/surface.js.map +1 -1
- package/dist/render3d/graphics3d.d.ts.map +1 -1
- package/dist/render3d/graphics3d.js +54 -5
- package/dist/render3d/graphics3d.js.map +1 -1
- package/dist/runtime/asset-refine.js +2 -1
- package/dist/runtime/asset-refine.js.map +1 -1
- package/dist/runtime/asset-timeline.d.ts +10 -0
- package/dist/runtime/asset-timeline.d.ts.map +1 -1
- package/dist/runtime/asset-timeline.js.map +1 -1
- package/dist/runtime/asset-update.d.ts.map +1 -1
- package/dist/runtime/asset-update.js +7 -0
- package/dist/runtime/asset-update.js.map +1 -1
- package/dist/runtime/clip-instance.d.ts +3 -1
- package/dist/runtime/clip-instance.d.ts.map +1 -1
- package/dist/runtime/clip-instance.js +4 -0
- package/dist/runtime/clip-instance.js.map +1 -1
- package/dist/runtime/clip-store.d.ts.map +1 -1
- package/dist/runtime/clip-store.js +17 -2
- package/dist/runtime/clip-store.js.map +1 -1
- package/dist/runtime/engine.d.ts +5 -3
- package/dist/runtime/engine.d.ts.map +1 -1
- package/dist/runtime/engine.js +2 -1
- package/dist/runtime/engine.js.map +1 -1
- package/dist/runtime/playback-controller.d.ts.map +1 -1
- package/dist/runtime/playback-controller.js +14 -4
- package/dist/runtime/playback-controller.js.map +1 -1
- package/dist/runtime/session.d.ts +7 -3
- package/dist/runtime/session.d.ts.map +1 -1
- package/dist/runtime/session.js +11 -4
- package/dist/runtime/session.js.map +1 -1
- package/dist/runtime/text-geometry.d.ts +1 -1
- package/dist/runtime/text-geometry.js.map +1 -1
- package/dist/sdk/index.d.ts +8 -6
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/index.js +10 -3
- package/dist/sdk/index.js.map +1 -1
- package/dist/tween/command-decorator.d.ts +7 -0
- package/dist/tween/command-decorator.d.ts.map +1 -1
- package/dist/tween/command-decorator.js +1 -0
- package/dist/tween/command-decorator.js.map +1 -1
- package/dist/tween/ease/describe.d.ts +2 -0
- package/dist/tween/ease/describe.d.ts.map +1 -1
- package/dist/tween/ease/describe.js +4 -0
- package/dist/tween/ease/describe.js.map +1 -1
- package/dist/tween/ease/spec.d.ts +31 -0
- package/dist/tween/ease/spec.d.ts.map +1 -0
- package/dist/tween/ease/spec.js +51 -0
- package/dist/tween/ease/spec.js.map +1 -0
- package/dist/tween/index.d.ts +1 -0
- package/dist/tween/index.d.ts.map +1 -1
- package/dist/tween/index.js +1 -0
- package/dist/tween/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/browser/chunks/chunk-D4FSTPML.js +0 -14
- package/dist/browser/chunks/chunk-D4FSTPML.js.map +0 -7
- package/dist/browser/chunks/chunk-RTNATFWX.js +0 -5
- package/dist/browser/chunks/chunk-RTNATFWX.js.map +0 -7
package/dist/experimental.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experimental.js","sourceRoot":"","sources":["../src/experimental.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"experimental.js","sourceRoot":"","sources":["../src/experimental.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,cAAc,IAAI,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACzF,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAEjE,kFAAkF;AAClF,iEAAiE;AACjE,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC;AACxC,oEAAoE;AACpE,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;AAC9C,iEAAiE;AACjE,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC;AACxC,iEAAiE;AACjE,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC;AACxC,2DAA2D;AAC3D,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC;AAC5B,8DAA8D;AAC9D,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,CAAC;AAQlC,OAAO,KAAK,KAAK,MAAM,4BAA4B,CAAC;AACpD,OAAO,KAAK,IAAI,MAAM,2BAA2B,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAC;AACxD,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAK,GAAG,MAAM,0BAA0B,CAAC;AAChD,OAAO,KAAK,SAAS,MAAM,iCAAiC,CAAC;AAC7D,OAAO,KAAK,UAAU,MAAM,kCAAkC,CAAC;AAC/D,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAC1D,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC","sourcesContent":["/**\r\n * @deprecated A duplicate of the stable authoring surface, kept until the next\r\n * major: import from `@motionscript/sdk` (or `@motionscript/core/sdk`), where\r\n * `TextStyle` is `Typeface` and `Corners` is `Shapes.corners` / `Shapes.rect`.\r\n */\r\nimport { component2d as _component2d } from \"@/components/factory/component2d\";\r\nimport { componentAudio as _componentAudio } from \"@/components/factory/component-audio\";\r\nimport { component3d as _component3d } from \"@/components/factory/component3d\";\r\nimport { commandsFor as _commandsFor } from \"@/components/factory/commands-for\";\r\nimport { Types as _Types } from \"@/components/factory/types\";\r\nimport { provides as _provides } from \"@/components/factory/api\";\r\n\r\n// Re-export statements cannot carry `@deprecated`, so the values are re-declared.\r\n/** @deprecated Import `component2d` from `@motionscript/sdk`. */\r\nexport const component2d = _component2d;\r\n/** @deprecated Import `componentAudio` from `@motionscript/sdk`. */\r\nexport const componentAudio = _componentAudio;\r\n/** @deprecated Import `component3d` from `@motionscript/sdk`. */\r\nexport const component3d = _component3d;\r\n/** @deprecated Import `commandsFor` from `@motionscript/sdk`. */\r\nexport const commandsFor = _commandsFor;\r\n/** @deprecated Import `Types` from `@motionscript/sdk`. */\r\nexport const Types = _Types;\r\n/** @deprecated Import `provides` from `@motionscript/sdk`. */\r\nexport const provides = _provides;\r\n\r\nexport type { Attribute, EntryOptions, NumberOptions, TextOptions } from \"@/components/factory/types\";\r\nexport type {\r\n Box2DState, BoxAudioState, CallProps, ChildView, Children2D, Component, Element, Entry, InOf, Inputs, Loader,\r\n Measurer, MergePaint, NodeOf, NodeView, OutOf, Piece, Placement2D, Provided, RenderContext2D, SoundOptions, StateSpec,\r\n Timeline, Type, Values, Writes, Merge, BuiltNode, CallProps3D, Placement3DProps, RenderContext3D, Transform3DState, Handle, LayoutBox, NodeFrame,\r\n} from \"@/components/factory/api\";\r\nexport * as Paint from \"@/components/modules/paint\";\r\nexport * as Flow from \"@/components/modules/flow\";\r\nexport * as Corners from \"@/components/modules/corners\";\r\nexport * as Shapes from \"@/components/modules/shapes\";\r\nexport * as Aim from \"@/components/modules/aim\";\r\nexport * as TextStyle from \"@/components/modules/text-style\";\r\nexport * as TextLayout from \"@/components/modules/text-layout\";\r\nexport * as Material from \"@/components/modules/material\";\r\nexport * as View3D from \"@/components/modules/view3d\";\r\n"]}
|
|
@@ -2,6 +2,7 @@ import { AssetManifest } from "../assets/manifest.js";
|
|
|
2
2
|
import type { ProjectDocument } from "../document/project.js";
|
|
3
3
|
import type { Registry } from "../document/registry.js";
|
|
4
4
|
import type { FrameSpec } from "../runtime/frame-time.js";
|
|
5
|
+
import type { RenderIssue } from "../render/render-issue.js";
|
|
5
6
|
/**
|
|
6
7
|
* Encoding settings, passed through to whatever the platform's exporter uses.
|
|
7
8
|
*
|
|
@@ -33,6 +34,12 @@ export interface ExportVideoRequest {
|
|
|
33
34
|
/** Progress through the export, in `[0, 1]`. */
|
|
34
35
|
onProgress?: (progress: number) => void;
|
|
35
36
|
signal?: AbortSignal;
|
|
37
|
+
/**
|
|
38
|
+
* What the renderer drew but not as the document says, once per kind,
|
|
39
|
+
* feature and node. A lost GPU device fails the export with a
|
|
40
|
+
* `RenderBackendError` instead.
|
|
41
|
+
*/
|
|
42
|
+
onIssue?: (issue: RenderIssue) => void;
|
|
36
43
|
encode?: EncodeOptions;
|
|
37
44
|
}
|
|
38
45
|
/** What an {@link Exporter} needs to encode one frame. */
|
|
@@ -45,6 +52,12 @@ export interface ExportStillRequest {
|
|
|
45
52
|
format?: "png" | "jpeg";
|
|
46
53
|
quality?: number;
|
|
47
54
|
signal?: AbortSignal;
|
|
55
|
+
/**
|
|
56
|
+
* What the renderer drew but not as the document says, once per kind,
|
|
57
|
+
* feature and node. A lost GPU device fails the export with a
|
|
58
|
+
* `RenderBackendError` instead.
|
|
59
|
+
*/
|
|
60
|
+
onIssue?: (issue: RenderIssue) => void;
|
|
48
61
|
}
|
|
49
62
|
export interface ExportedStill {
|
|
50
63
|
bytes: Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exporter.d.ts","sourceRoot":"","sources":["../../src/platform/exporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"exporter.d.ts","sourceRoot":"","sources":["../../src/platform/exporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpD,4DAA4D;AAC5D,MAAM,WAAW,UAAU;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACf;AAED,2DAA2D;AAC3D,MAAM,WAAW,kBAAkB;IAC/B,8FAA8F;IAC9F,OAAO,EAAE,eAAe,CAAC;IACzB,sEAAsE;IACtE,QAAQ,EAAE,QAAQ,CAAC;IACnB,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,gDAAgD;IAChD,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC,MAAM,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED,0DAA0D;AAC1D,MAAM,WAAW,kBAAkB;IAC/B,OAAO,EAAE,eAAe,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;CAC1C;AAED,MAAM,WAAW,aAAa;IAC1B,KAAK,EAAE,UAAU,CAAC;IAClB,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACrB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACrE,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CACpE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exporter.js","sourceRoot":"","sources":["../../src/platform/exporter.ts"],"names":[],"mappings":"","sourcesContent":["import { AssetManifest } from \"@/assets/manifest\";\r\nimport type { ProjectDocument } from \"@/document/project\";\r\nimport type { Registry } from \"@/document/registry\";\r\nimport type { FrameSpec } from \"@/runtime/frame-time\";\r\n\r\n/**\r\n * Encoding settings, passed through to whatever the platform's exporter uses.\r\n *\r\n * Deliberately `unknown`-shaped rather than a union of every codec option each\r\n * backend might take: `core` has no opinion about encoders.\r\n */\r\nexport type EncodeOptions = Record<string, unknown>;\r\n\r\n/** A run of project frames: `start` included, `end` not. */\r\nexport interface FrameRange {\r\n start: number;\r\n end: number;\r\n}\r\n\r\n/** What an {@link Exporter} needs to encode a timeline. */\r\nexport interface ExportVideoRequest {\r\n /** The project, its fps and viewport resolved — see `Session.document`. Carries its theme. */\r\n project: ProjectDocument;\r\n /** The vocabulary its clips compile against: the opening engine's. */\r\n registry: Registry;\r\n /** Resolution multiplier on the viewport. Default 1. */\r\n scale?: number;\r\n manifest?: AssetManifest;\r\n includeAudio?: boolean;\r\n /**\r\n * Encode only these frames, as a file of their own that starts at 0. It is\r\n * always silent: a range is one segment of a split export, whose audio is\r\n * mixed once over the whole timeline.\r\n */\r\n frames?: FrameRange;\r\n /** Progress through the export, in `[0, 1]`. */\r\n onProgress?: (progress: number) => void;\r\n signal?: AbortSignal;\r\n encode?: EncodeOptions;\r\n}\r\n\r\n/** What an {@link Exporter} needs to encode one frame. */\r\nexport interface ExportStillRequest {\r\n project: ProjectDocument;\r\n registry: Registry;\r\n frame: FrameSpec;\r\n scale?: number;\r\n manifest?: AssetManifest;\r\n format?: \"png\" | \"jpeg\";\r\n quality?: number;\r\n signal?: AbortSignal;\r\n}\r\n\r\nexport interface ExportedStill {\r\n bytes: Uint8Array;\r\n /** The frame actually captured — the request clamped into range. */\r\n frame: number;\r\n totalFrames: number;\r\n}\r\n\r\n/**\r\n * How a `Session` turns itself into bytes.\r\n *\r\n * A **port**: `core` declares it, a platform implements it, and the dependency\r\n * runs platform → core like every other seam here — which is what lets\r\n * `Session.export()` exist in `core` without importing anything that encodes.\r\n */\r\nexport interface Exporter {\r\n exportVideo(request: ExportVideoRequest): Promise<Uint8Array | void>;\r\n exportStill(request: ExportStillRequest): Promise<ExportedStill>;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"exporter.js","sourceRoot":"","sources":["../../src/platform/exporter.ts"],"names":[],"mappings":"","sourcesContent":["import { AssetManifest } from \"@/assets/manifest\";\r\nimport type { ProjectDocument } from \"@/document/project\";\r\nimport type { Registry } from \"@/document/registry\";\r\nimport type { FrameSpec } from \"@/runtime/frame-time\";\r\nimport type { RenderIssue } from \"@/render/render-issue\";\r\n\r\n/**\r\n * Encoding settings, passed through to whatever the platform's exporter uses.\r\n *\r\n * Deliberately `unknown`-shaped rather than a union of every codec option each\r\n * backend might take: `core` has no opinion about encoders.\r\n */\r\nexport type EncodeOptions = Record<string, unknown>;\r\n\r\n/** A run of project frames: `start` included, `end` not. */\r\nexport interface FrameRange {\r\n start: number;\r\n end: number;\r\n}\r\n\r\n/** What an {@link Exporter} needs to encode a timeline. */\r\nexport interface ExportVideoRequest {\r\n /** The project, its fps and viewport resolved — see `Session.document`. Carries its theme. */\r\n project: ProjectDocument;\r\n /** The vocabulary its clips compile against: the opening engine's. */\r\n registry: Registry;\r\n /** Resolution multiplier on the viewport. Default 1. */\r\n scale?: number;\r\n manifest?: AssetManifest;\r\n includeAudio?: boolean;\r\n /**\r\n * Encode only these frames, as a file of their own that starts at 0. It is\r\n * always silent: a range is one segment of a split export, whose audio is\r\n * mixed once over the whole timeline.\r\n */\r\n frames?: FrameRange;\r\n /** Progress through the export, in `[0, 1]`. */\r\n onProgress?: (progress: number) => void;\r\n signal?: AbortSignal;\r\n /**\r\n * What the renderer drew but not as the document says, once per kind,\r\n * feature and node. A lost GPU device fails the export with a\r\n * `RenderBackendError` instead.\r\n */\r\n onIssue?: (issue: RenderIssue) => void;\r\n encode?: EncodeOptions;\r\n}\r\n\r\n/** What an {@link Exporter} needs to encode one frame. */\r\nexport interface ExportStillRequest {\r\n project: ProjectDocument;\r\n registry: Registry;\r\n frame: FrameSpec;\r\n scale?: number;\r\n manifest?: AssetManifest;\r\n format?: \"png\" | \"jpeg\";\r\n quality?: number;\r\n signal?: AbortSignal;\r\n /**\r\n * What the renderer drew but not as the document says, once per kind,\r\n * feature and node. A lost GPU device fails the export with a\r\n * `RenderBackendError` instead.\r\n */\r\n onIssue?: (issue: RenderIssue) => void;\r\n}\r\n\r\nexport interface ExportedStill {\r\n bytes: Uint8Array;\r\n /** The frame actually captured — the request clamped into range. */\r\n frame: number;\r\n totalFrames: number;\r\n}\r\n\r\n/**\r\n * How a `Session` turns itself into bytes.\r\n *\r\n * A **port**: `core` declares it, a platform implements it, and the dependency\r\n * runs platform → core like every other seam here — which is what lets\r\n * `Session.export()` exist in `core` without importing anything that encodes.\r\n */\r\nexport interface Exporter {\r\n exportVideo(request: ExportVideoRequest): Promise<Uint8Array | void>;\r\n exportStill(request: ExportStillRequest): Promise<ExportedStill>;\r\n}\r\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { integrateSpeedToClipTime, sourceTimeAtClipElapsed } from './attributes/audio/
|
|
1
|
+
import { integrateSpeedToClipTime, sourceTimeAtClipElapsed } from './attributes/audio/ramp.js';
|
|
2
2
|
import type { NodeEffect } from './attributes/shape/effects/union.js';
|
|
3
3
|
import { ClipTimeline } from './document/timeline.js';
|
|
4
4
|
import type { VisualDocument } from './document/types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renamed-scene-names.d.ts","sourceRoot":"","sources":["../src/renamed-scene-names.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"renamed-scene-names.d.ts","sourceRoot":"","sources":["../src/renamed-scene-names.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAC5F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIvD,qDAAqD;AACrD,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC;AAC3C,mDAAmD;AACnD,eAAO,MAAM,aAAa,qBAAe,CAAC;AAC1C,mDAAmD;AACnD,MAAM,MAAM,aAAa,GAAG,YAAY,CAAC;AACzC,iDAAiD;AACjD,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC;AACrC,+DAA+D;AAC/D,eAAO,MAAM,yBAAyB,iCAA2B,CAAC;AAClE,8DAA8D;AAC9D,eAAO,MAAM,wBAAwB,gCAA0B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { integrateSpeedToClipTime, sourceTimeAtClipElapsed } from './attributes/audio/
|
|
1
|
+
import { integrateSpeedToClipTime, sourceTimeAtClipElapsed } from './attributes/audio/ramp.js';
|
|
2
2
|
import { ClipTimeline } from './document/timeline.js';
|
|
3
3
|
/** @deprecated Renamed to {@link ClipTimeline}. */
|
|
4
4
|
export const SceneTimeline = ClipTimeline;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renamed-scene-names.js","sourceRoot":"","sources":["../src/renamed-scene-names.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"renamed-scene-names.js","sourceRoot":"","sources":["../src/renamed-scene-names.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAE5F,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAOnD,mDAAmD;AACnD,MAAM,CAAC,MAAM,aAAa,GAAG,YAAY,CAAC;AAK1C,+DAA+D;AAC/D,MAAM,CAAC,MAAM,yBAAyB,GAAG,wBAAwB,CAAC;AAClE,8DAA8D;AAC9D,MAAM,CAAC,MAAM,wBAAwB,GAAG,uBAAuB,CAAC","sourcesContent":["import { integrateSpeedToClipTime, sourceTimeAtClipElapsed } from './attributes/audio/ramp';\r\nimport type { NodeEffect } from './attributes/shape/effects/union';\r\nimport { ClipTimeline } from './document/timeline';\r\nimport type { VisualDocument } from './document/types';\r\n\r\n// The names the document API had before \"scene\" became \"clip\", kept until 1.0.\r\n\r\n/** @deprecated Renamed to {@link VisualDocument}. */\r\nexport type SceneDocument = VisualDocument;\r\n/** @deprecated Renamed to {@link ClipTimeline}. */\r\nexport const SceneTimeline = ClipTimeline;\r\n/** @deprecated Renamed to {@link ClipTimeline}. */\r\nexport type SceneTimeline = ClipTimeline;\r\n/** @deprecated Renamed to {@link NodeEffect}. */\r\nexport type SceneEffect = NodeEffect;\r\n/** @deprecated Renamed to {@link integrateSpeedToClipTime}. */\r\nexport const integrateSpeedToSceneTime = integrateSpeedToClipTime;\r\n/** @deprecated Renamed to {@link sourceTimeAtClipElapsed}. */\r\nexport const sourceTimeAtSceneElapsed = sourceTimeAtClipElapsed;\r\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Graphics2D } from "./graphics2d.js";
|
|
2
2
|
import type { Clip } from "./clip.js";
|
|
3
|
+
import type { RenderIssue } from "./render-issue.js";
|
|
3
4
|
import type { TransformState } from "./descriptors/transform.js";
|
|
4
5
|
import type { FontStyle, TextStyle } from "../attributes/text/types.js";
|
|
5
6
|
import type { Size2D } from "../attributes/layout/size.js";
|
|
@@ -77,6 +78,14 @@ export declare abstract class CanvasRenderContext2D implements RenderPass2D {
|
|
|
77
78
|
* that throws still throws, and the next pass starts from a clean context.
|
|
78
79
|
*/
|
|
79
80
|
abstract execute(callback: () => void): void;
|
|
81
|
+
/**
|
|
82
|
+
* What the frames since the last call drew without failing but not as the
|
|
83
|
+
* document says (a blend mode the backend lacks, a shader that does not
|
|
84
|
+
* compile, a lost GPU device), once per kind, feature and node. The
|
|
85
|
+
* playback controller reports them as render errors; an export hands them
|
|
86
|
+
* to its `onIssue`. A bare string is a `shader` issue.
|
|
87
|
+
*/
|
|
88
|
+
takeRenderIssues(): Array<RenderIssue | string>;
|
|
80
89
|
/** Capture the current frame as a base-64 PNG data URL, or `undefined` if unsupported. */
|
|
81
90
|
abstract screenshot(): string | undefined;
|
|
82
91
|
abstract transform(state: Partial<TransformState>): RenderContext2D;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas-render-context2d.d.ts","sourceRoot":"","sources":["../../src/render/canvas-render-context2d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGhD,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACtI,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAEnE;;;;;;;;;;;;;;;;GAgBG;AACH,8BAAsB,qBAAsB,YAAW,YAAY;IAC/D,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE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@ -80,6 +80,16 @@ export class CanvasRenderContext2D {
|
|
|
80
80
|
dispose() {
|
|
81
81
|
this._disposed = true;
|
|
82
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* What the frames since the last call drew without failing but not as the
|
|
85
|
+
* document says (a blend mode the backend lacks, a shader that does not
|
|
86
|
+
* compile, a lost GPU device), once per kind, feature and node. The
|
|
87
|
+
* playback controller reports them as render errors; an export hands them
|
|
88
|
+
* to its `onIssue`. A bare string is a `shader` issue.
|
|
89
|
+
*/
|
|
90
|
+
takeRenderIssues() {
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
83
93
|
/** See {@link RenderContext2D.beginEffects}. No-op by default. */
|
|
84
94
|
beginEffects(effects, target, width, height) { }
|
|
85
95
|
endEffects() { }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas-render-context2d.js","sourceRoot":"","sources":["../../src/render/canvas-render-context2d.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAI5D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAgB,qBAAqB;IAGvC,0EAA0E;IAC1E,4EAA4E;IAC5E,2EAA2E;IAC3E,wEAAwE;IACxE,qEAAqE;IACrE,0EAA0E;IAE1E;;;;OAIG;IACc,cAAc,GAAgB,EAAE,CAAC;IAElD,iDAAiD;IACjD,aAAa,CAAC,KAAuB;QACjC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC,CAAC;IACnH,CAAC;IAED,iEAAiE;IACjE,YAAY;QACR,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC;IAC9B,CAAC;IAED;;;;;;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,GAAY,IAAI,CAAC;IAE1C,sCAAsC;IACtC,KAAK,CAAC,KAAsB;QACxB,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACrC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,+DAA+D;IAC/D,GAAG;QACC,IAAI,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC;IAChC,CAAC;IAED,8EAA8E;IACpE,iBAAiB;QACvB,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC;IAChF,CAAC;IAED,qFAAqF;IAC3E,kBAAkB;QACxB,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACnE,CAAC;IAED;;;;OAIG;IACO,YAAY;QAClB,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;QAC/B,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;IACrC,CAAC;CACJ","sourcesContent":["import { Graphics2D } from \"./graphics2d\";\r\nimport type { Clip } from \"./clip\";\r\nimport type { TransformState } from \"./descriptors/transform\";\r\nimport type { FontStyle, TextStyle } from \"@/attributes/text/types\";\r\nimport type { Size2D } from \"@/attributes/layout/size\";\r\nimport type { Vector2 } from \"@/attributes/layout/vector2\";\r\nimport type { MaskOptions } from \"@/attributes/mask/mask\";\r\nimport type { BooleanOperation } from \"@/attributes/mask/boolean\";\r\nimport { TextState } from \"./descriptors/text\";\r\nimport { TextBlockLayout } from \"./text-layout\";\r\nimport { EMPTY_TEXT_STYLE, textOps } from \"@/attributes/text/ops\";\r\nimport { applyGraphicsTextDefaults } from \"./text-defaults\";\r\nimport type { NodeRenderState, RasterizedSurface, RenderContext2D, RenderPass2D, SpaceRects, EffectTarget } from \"./render-context2d\";\r\nimport type { NodeEffect } from \"@/attributes/shape/effects/union\";\r\n\r\n/**\r\n * The base every {@link RenderContext2D} backend extends.\r\n *\r\n * It owns the parts of a render context that are the *same* whatever is being\r\n * rasterized — the text-default stack, the node scope stack, disposal — plus\r\n * the host-facing half of the surface (`execute`, `screenshot`, `unmount`),\r\n * which the {@link RenderContext2D} interface deliberately leaves out because a\r\n * node has no business driving a render pass from inside one.\r\n *\r\n * **`draw` is final by convention.** It resolves the ambient text defaults onto\r\n * the op list and hands the result to {@link drawGraphics}, which is where a\r\n * backend does its actual drawing. Owning that step here rather than in each\r\n * backend is what keeps the real renderer and the precomp asset walk agreeing\r\n * on which font an under-specified `text` op shapes with: a family that one\r\n * resolves and the other does not is a font that never loads and glyphs that\r\n * never paint.\r\n */\r\nexport abstract class CanvasRenderContext2D implements RenderPass2D {\r\n abstract measureText(text: string, fontSize: number, fontFamily: string, fontWeight?: number, letterSpacing?: number, fontStyle?: FontStyle): Size2D;\r\n\r\n // ---- Inherited text-style defaults ------------------------------------\r\n // `<DefaultTextStyle>` reaches a `Text`/`RichText` node through the context\r\n // map, applied once when the node binds. A raw `Graphics2D` has no node to\r\n // bind, so it inherits the same defaults here instead — pushed around a\r\n // subtree's draw scope, and folded into each `text`/`richText` op by\r\n // `draw()`. Same vocabulary (`TextStyle`), same precedence, two channels.\r\n\r\n /**\r\n * Defaults in effect for the current draw scope, innermost last. Each entry\r\n * is **already merged** onto the one below it (see {@link pushTextStyle}), so\r\n * the top of the stack is the effective style and reading it costs nothing.\r\n */\r\n private readonly textStyleStack: TextStyle[] = [];\r\n\r\n /** See {@link RenderContext2D.pushTextStyle}. */\r\n pushTextStyle(style: TextStyle | null): void {\r\n this.textStyleStack.push(style === null ? EMPTY_TEXT_STYLE : textOps.mergeStyle(this.defaultTextStyle, style));\r\n }\r\n\r\n /** Close the innermost scope opened by {@link pushTextStyle}. */\r\n popTextStyle(): void {\r\n this.textStyleStack.pop();\r\n }\r\n\r\n /**\r\n * The text-style defaults in effect right now — the innermost\r\n * {@link pushTextStyle} scope, or the project's `theme.typography.default`\r\n * when no scope is open.\r\n *\r\n * Carries all ten {@link TEXT_STYLE_KEYS}, but only the shaping ones reach a\r\n * `Graphics2D` op; see `TEXT_SHAPING_KEYS` for why `fill`/`stroke`/`shadow`\r\n * stay a node-level concern.\r\n */\r\n get defaultTextStyle(): TextStyle {\r\n return this.textStyleStack[this.textStyleStack.length - 1] ?? textOps.preset(\"default\");\r\n }\r\n\r\n /** See {@link RenderContext2D.draw}. Final by convention — override {@link drawGraphics}. */\r\n draw(graphics: Graphics2D): void {\r\n this.drawGraphics(applyGraphicsTextDefaults(graphics, this.defaultTextStyle));\r\n }\r\n\r\n /** Paint a `Graphics2D` whose text ops have already been resolved against the\r\n * ambient defaults. Backends implement this instead of {@link draw}. */\r\n protected abstract drawGraphics(graphics: Graphics2D): void;\r\n\r\n /**\r\n * See {@link RenderContext2D.layoutTextBlock}. Concrete rather than abstract,\r\n * and `null` by default, so a backend that has no need to report glyph\r\n * positions is unaffected — the only thing it gives up is on-canvas text\r\n * editing in a host built on it.\r\n */\r\n layoutTextBlock(state: Partial<TextState>): TextBlockLayout | null {\r\n return null;\r\n }\r\n\r\n /** Stack of node ids currently being drawn, innermost last. */\r\n protected currentNodeStack: string[] = [];\r\n\r\n /** Returns the id of the innermost node currently being drawn. */\r\n protected currentNodeId(): string {\r\n if (this.currentNodeStack.length === 0) {\r\n throw new Error(\"No current node in context\");\r\n }\r\n\r\n return this.currentNodeStack[this.currentNodeStack.length - 1];\r\n }\r\n\r\n /** Remove all renderer-side resources for the current node (called on unmount). */\r\n abstract unmount(): void;\r\n\r\n private _disposed = false;\r\n /** `true` after `dispose()` — the context must not be used after this point. */\r\n isDisposed(): boolean {\r\n return this._disposed;\r\n }\r\n dispose(): void {\r\n this._disposed = true;\r\n }\r\n\r\n /**\r\n * Execute `callback`, which issues shape/paint calls, and flush the result\r\n * to the underlying render target (canvas, SVG document, etc.). A callback\r\n * that throws still throws, and the next pass starts from a clean context.\r\n */\r\n abstract execute(callback: () => void): void;\r\n /** Capture the current frame as a base-64 PNG data URL, or `undefined` if unsupported. */\r\n abstract screenshot(): string | undefined;\r\n\r\n abstract transform(state: Partial<TransformState>): RenderContext2D;\r\n\r\n abstract beginBoolean(op: BooleanOperation): void;\r\n abstract endBoolean(): void;\r\n\r\n abstract beginMask(options?: MaskOptions): void;\r\n abstract applyMask(): void;\r\n abstract endMask(): void;\r\n\r\n abstract beginClip(clip: Clip): void;\r\n abstract endClip(): void;\r\n\r\n /** See {@link RenderContext2D.beginEffects}. No-op by default. */\r\n beginEffects(effects: NodeEffect[], target: EffectTarget, width: number, height: number): void { }\r\n endEffects(): void { }\r\n\r\n /** See {@link RenderContext2D.rasterize}. Returns `null` by default. */\r\n rasterize(\r\n width: number,\r\n height: number,\r\n draw: () => void,\r\n pixelRatio?: number,\r\n ): RasterizedSurface | null {\r\n return null;\r\n }\r\n\r\n abstract beginCamera(viewport: { x: number; y: number; width: number; height: number }, lookAt: Vector2, zoom: number, heading: number): void;\r\n abstract endCamera(): void;\r\n\r\n /**\r\n * Per-node render state for each node on the draw stack, in push order\r\n * (innermost last). Kept parallel to `currentNodeStack` so fills with\r\n * `space: 'parent'` can resolve their reference rect and so\r\n * motion-driven effects can read the current node's velocity.\r\n */\r\n protected renderStateStack: NodeRenderState[] = [];\r\n\r\n /** See {@link RenderContext2D.readsSpaceRects}. */\r\n readonly readsSpaceRects: boolean = true;\r\n\r\n /** See {@link RenderContext2D.drawsVisibleOnly}. */\r\n readonly drawsVisibleOnly: boolean = true;\r\n\r\n /** See {@link RenderPass2D.begin}. */\r\n begin(state: NodeRenderState): void {\r\n this.currentNodeStack.push(state.id);\r\n this.renderStateStack.push(state);\r\n }\r\n\r\n /** Close the innermost node draw scope opened by `begin()`. */\r\n end(): void {\r\n this.currentNodeStack.pop();\r\n this.renderStateStack.pop();\r\n }\r\n\r\n /** Reference rects for the node currently being drawn (parent / viewport). */\r\n protected currentSpaceRects(): SpaceRects {\r\n return this.renderStateStack[this.renderStateStack.length - 1]?.rects ?? {};\r\n }\r\n\r\n /** Full render state (incl. velocity) for the node currently being drawn, if any. */\r\n protected currentRenderState(): NodeRenderState | undefined {\r\n return this.renderStateStack[this.renderStateStack.length - 1];\r\n }\r\n\r\n /**\r\n * Close every node and text-style scope still open. A backend calls this\r\n * when a pass ends, so a pass that threw cannot leave the next one inside\r\n * its scopes.\r\n */\r\n protected _resetScopes(): void {\r\n this.textStyleStack.length = 0;\r\n this.currentNodeStack.length = 0;\r\n this.renderStateStack.length = 0;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"canvas-render-context2d.js","sourceRoot":"","sources":["../../src/render/canvas-render-context2d.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAI5D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAgB,qBAAqB;IAGvC,0EAA0E;IAC1E,4EAA4E;IAC5E,2EAA2E;IAC3E,wEAAwE;IACxE,qEAAqE;IACrE,0EAA0E;IAE1E;;;;OAIG;IACc,cAAc,GAAgB,EAAE,CAAC;IAElD,iDAAiD;IACjD,aAAa,CAAC,KAAuB;QACjC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC,CAAC;IACnH,CAAC;IAED,iEAAiE;IACjE,YAAY;QACR,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC;IAC9B,CAAC;IAED;;;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mDAAmD;IAC1C,eAAe,GAAY,IAAI,CAAC;IAEzC,oDAAoD;IAC3C,gBAAgB,GAAY,IAAI,CAAC;IAE1C,sCAAsC;IACtC,KAAK,CAAC,KAAsB;QACxB,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACrC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,+DAA+D;IAC/D,GAAG;QACC,IAAI,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC;IAChC,CAAC;IAED,8EAA8E;IACpE,iBAAiB;QACvB,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC;IAChF,CAAC;IAED,qFAAqF;IAC3E,kBAAkB;QACxB,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACnE,CAAC;IAED;;;;OAIG;IACO,YAAY;QAClB,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;QAC/B,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;IACrC,CAAC;CACJ","sourcesContent":["import { Graphics2D } from \"./graphics2d\";\r\nimport type { Clip } from \"./clip\";\r\nimport type { RenderIssue } from \"./render-issue\";\r\nimport type { TransformState } from \"./descriptors/transform\";\r\nimport type { FontStyle, TextStyle } from \"@/attributes/text/types\";\r\nimport type { Size2D } from \"@/attributes/layout/size\";\r\nimport type { Vector2 } from \"@/attributes/layout/vector2\";\r\nimport type { MaskOptions } from \"@/attributes/mask/mask\";\r\nimport type { BooleanOperation } from \"@/attributes/mask/boolean\";\r\nimport { TextState } from \"./descriptors/text\";\r\nimport { TextBlockLayout } from \"./text-layout\";\r\nimport { EMPTY_TEXT_STYLE, textOps } from \"@/attributes/text/ops\";\r\nimport { applyGraphicsTextDefaults } from \"./text-defaults\";\r\nimport type { NodeRenderState, RasterizedSurface, RenderContext2D, RenderPass2D, SpaceRects, EffectTarget } from \"./render-context2d\";\r\nimport type { NodeEffect } from \"@/attributes/shape/effects/union\";\r\n\r\n/**\r\n * The base every {@link RenderContext2D} backend extends.\r\n *\r\n * It owns the parts of a render context that are the *same* whatever is being\r\n * rasterized — the text-default stack, the node scope stack, disposal — plus\r\n * the host-facing half of the surface (`execute`, `screenshot`, `unmount`),\r\n * which the {@link RenderContext2D} interface deliberately leaves out because a\r\n * node has no business driving a render pass from inside one.\r\n *\r\n * **`draw` is final by convention.** It resolves the ambient text defaults onto\r\n * the op list and hands the result to {@link drawGraphics}, which is where a\r\n * backend does its actual drawing. Owning that step here rather than in each\r\n * backend is what keeps the real renderer and the precomp asset walk agreeing\r\n * on which font an under-specified `text` op shapes with: a family that one\r\n * resolves and the other does not is a font that never loads and glyphs that\r\n * never paint.\r\n */\r\nexport abstract class CanvasRenderContext2D implements RenderPass2D {\r\n abstract measureText(text: string, fontSize: number, fontFamily: string, fontWeight?: number, letterSpacing?: number, fontStyle?: FontStyle): Size2D;\r\n\r\n // ---- Inherited text-style defaults ------------------------------------\r\n // `<DefaultTextStyle>` reaches a `Text`/`RichText` node through the context\r\n // map, applied once when the node binds. A raw `Graphics2D` has no node to\r\n // bind, so it inherits the same defaults here instead — pushed around a\r\n // subtree's draw scope, and folded into each `text`/`richText` op by\r\n // `draw()`. Same vocabulary (`TextStyle`), same precedence, two channels.\r\n\r\n /**\r\n * Defaults in effect for the current draw scope, innermost last. Each entry\r\n * is **already merged** onto the one below it (see {@link pushTextStyle}), so\r\n * the top of the stack is the effective style and reading it costs nothing.\r\n */\r\n private readonly textStyleStack: TextStyle[] = [];\r\n\r\n /** See {@link RenderContext2D.pushTextStyle}. */\r\n pushTextStyle(style: TextStyle | null): void {\r\n this.textStyleStack.push(style === null ? EMPTY_TEXT_STYLE : textOps.mergeStyle(this.defaultTextStyle, style));\r\n }\r\n\r\n /** Close the innermost scope opened by {@link pushTextStyle}. */\r\n popTextStyle(): void {\r\n this.textStyleStack.pop();\r\n }\r\n\r\n /**\r\n * The text-style defaults in effect right now — the innermost\r\n * {@link pushTextStyle} scope, or the project's `theme.typography.default`\r\n * when no scope is open.\r\n *\r\n * Carries all ten {@link TEXT_STYLE_KEYS}, but only the shaping ones reach a\r\n * `Graphics2D` op; see `TEXT_SHAPING_KEYS` for why `fill`/`stroke`/`shadow`\r\n * stay a node-level concern.\r\n */\r\n get defaultTextStyle(): TextStyle {\r\n return this.textStyleStack[this.textStyleStack.length - 1] ?? textOps.preset(\"default\");\r\n }\r\n\r\n /** See {@link RenderContext2D.draw}. Final by convention — override {@link drawGraphics}. */\r\n draw(graphics: Graphics2D): void {\r\n this.drawGraphics(applyGraphicsTextDefaults(graphics, this.defaultTextStyle));\r\n }\r\n\r\n /** Paint a `Graphics2D` whose text ops have already been resolved against the\r\n * ambient defaults. Backends implement this instead of {@link draw}. */\r\n protected abstract drawGraphics(graphics: Graphics2D): void;\r\n\r\n /**\r\n * See {@link RenderContext2D.layoutTextBlock}. Concrete rather than abstract,\r\n * and `null` by default, so a backend that has no need to report glyph\r\n * positions is unaffected — the only thing it gives up is on-canvas text\r\n * editing in a host built on it.\r\n */\r\n layoutTextBlock(state: Partial<TextState>): TextBlockLayout | null {\r\n return null;\r\n }\r\n\r\n /** Stack of node ids currently being drawn, innermost last. */\r\n protected currentNodeStack: string[] = [];\r\n\r\n /** Returns the id of the innermost node currently being drawn. */\r\n protected currentNodeId(): string {\r\n if (this.currentNodeStack.length === 0) {\r\n throw new Error(\"No current node in context\");\r\n }\r\n\r\n return this.currentNodeStack[this.currentNodeStack.length - 1];\r\n }\r\n\r\n /** Remove all renderer-side resources for the current node (called on unmount). */\r\n abstract unmount(): void;\r\n\r\n private _disposed = false;\r\n /** `true` after `dispose()` — the context must not be used after this point. */\r\n isDisposed(): boolean {\r\n return this._disposed;\r\n }\r\n dispose(): void {\r\n this._disposed = true;\r\n }\r\n\r\n /**\r\n * Execute `callback`, which issues shape/paint calls, and flush the result\r\n * to the underlying render target (canvas, SVG document, etc.). A callback\r\n * that throws still throws, and the next pass starts from a clean context.\r\n */\r\n abstract execute(callback: () => void): void;\r\n /**\r\n * What the frames since the last call drew without failing but not as the\r\n * document says (a blend mode the backend lacks, a shader that does not\r\n * compile, a lost GPU device), once per kind, feature and node. The\r\n * playback controller reports them as render errors; an export hands them\r\n * to its `onIssue`. A bare string is a `shader` issue.\r\n */\r\n takeRenderIssues(): Array<RenderIssue | string> {\r\n return [];\r\n }\r\n /** Capture the current frame as a base-64 PNG data URL, or `undefined` if unsupported. */\r\n abstract screenshot(): string | undefined;\r\n\r\n abstract transform(state: Partial<TransformState>): RenderContext2D;\r\n\r\n abstract beginBoolean(op: BooleanOperation): void;\r\n abstract endBoolean(): void;\r\n\r\n abstract beginMask(options?: MaskOptions): void;\r\n abstract applyMask(): void;\r\n abstract endMask(): void;\r\n\r\n abstract beginClip(clip: Clip): void;\r\n abstract endClip(): void;\r\n\r\n /** See {@link RenderContext2D.beginEffects}. No-op by default. */\r\n beginEffects(effects: NodeEffect[], target: EffectTarget, width: number, height: number): void { }\r\n endEffects(): void { }\r\n\r\n /** See {@link RenderContext2D.rasterize}. Returns `null` by default. */\r\n rasterize(\r\n width: number,\r\n height: number,\r\n draw: () => void,\r\n pixelRatio?: number,\r\n ): RasterizedSurface | null {\r\n return null;\r\n }\r\n\r\n abstract beginCamera(viewport: { x: number; y: number; width: number; height: number }, lookAt: Vector2, zoom: number, heading: number): void;\r\n abstract endCamera(): void;\r\n\r\n /**\r\n * Per-node render state for each node on the draw stack, in push order\r\n * (innermost last). Kept parallel to `currentNodeStack` so fills with\r\n * `space: 'parent'` can resolve their reference rect and so\r\n * motion-driven effects can read the current node's velocity.\r\n */\r\n protected renderStateStack: NodeRenderState[] = [];\r\n\r\n /** See {@link RenderContext2D.readsSpaceRects}. */\r\n readonly readsSpaceRects: boolean = true;\r\n\r\n /** See {@link RenderContext2D.drawsVisibleOnly}. */\r\n readonly drawsVisibleOnly: boolean = true;\r\n\r\n /** See {@link RenderPass2D.begin}. */\r\n begin(state: NodeRenderState): void {\r\n this.currentNodeStack.push(state.id);\r\n this.renderStateStack.push(state);\r\n }\r\n\r\n /** Close the innermost node draw scope opened by `begin()`. */\r\n end(): void {\r\n this.currentNodeStack.pop();\r\n this.renderStateStack.pop();\r\n }\r\n\r\n /** Reference rects for the node currently being drawn (parent / viewport). */\r\n protected currentSpaceRects(): SpaceRects {\r\n return this.renderStateStack[this.renderStateStack.length - 1]?.rects ?? {};\r\n }\r\n\r\n /** Full render state (incl. velocity) for the node currently being drawn, if any. */\r\n protected currentRenderState(): NodeRenderState | undefined {\r\n return this.renderStateStack[this.renderStateStack.length - 1];\r\n }\r\n\r\n /**\r\n * Close every node and text-style scope still open. A backend calls this\r\n * when a pass ends, so a pass that threw cannot leave the next one inside\r\n * its scopes.\r\n */\r\n protected _resetScopes(): void {\r\n this.textStyleStack.length = 0;\r\n this.currentNodeStack.length = 0;\r\n this.renderStateStack.length = 0;\r\n }\r\n}\r\n"]}
|
|
@@ -8,7 +8,7 @@ import { cornerRadiusOps } from "../attributes/shape/corners/corner-radius.js";
|
|
|
8
8
|
* Point-in-region tests for {@link Clip}, used by node hit testing so a click
|
|
9
9
|
* follows a shape's silhouette rather than its bounding box.
|
|
10
10
|
*
|
|
11
|
-
* Geometry only — no renderer
|
|
11
|
+
* Geometry only — no renderer — because a `Clip` is a declarative
|
|
12
12
|
* record of primitives rather than a built path. That is what lets hit testing
|
|
13
13
|
* live in `core` and share one outline definition with clipping and backdrop
|
|
14
14
|
* effects: a shape declares its outline once, in `clipSelf()`, and both the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clip-contains.js","sourceRo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EAAE,CAAU,EAAE,CAAU;IAChE,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACrB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACrB,MAAM,KAAK,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IAChC,IAAI,KAAK,IAAI,GAAG;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,KAAK,CAAC;IACtD,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import { Vector2 } from \"@/attributes/layout/vector2\";\r\nimport { Clip, ClipOp, ClipShapeOp } from \"./clip\";\r\nimport { withRectDescriptor } from \"./descriptors/rect\";\r\nimport { withEllipseDescriptor } from \"./descriptors/ellipse\";\r\nimport { withPolygonDescriptor } from \"./descriptors/polygon\";\r\nimport { withPolygramDescriptor } from \"./descriptors/polygram\";\r\nimport { withLineDescriptor } from \"./descriptors/line\";\r\nimport { cornerRadiusOps } from \"@/attributes/shape/corners/corner-radius\";\r\n\r\n/**\r\n * Point-in-region tests for {@link Clip}, used by node hit testing so a click\r\n * follows a shape's silhouette rather than its bounding box.\r\n *\r\n * Geometry only — no renderer, no CanvasKit — because a `Clip` is a declarative\r\n * record of primitives rather than a built path. That is what lets hit testing\r\n * live in `core` and share one outline definition with clipping and backdrop\r\n * effects: a shape declares its outline once, in `clipSelf()`, and both the\r\n * pixels and the grab region derive from it.\r\n *\r\n * Every point and every descriptor coordinate here is in **y-up author space**\r\n * (the space `Graphics2D`/`Clip` descriptors are written in; the renderer flips to\r\n * canvas y-down at draw time — see `flipPositionY`). Angles follow from that:\r\n * `startAngle`/`sweep` measure counter-clockwise from +x.\r\n */\r\n\r\n/** Guard against divide-by-zero on collapsed geometry. */\r\nconst EPS = 1e-9;\r\n\r\n/**\r\n * Whether `point` falls inside the region a {@link Clip} describes, within\r\n * `tolerance` scene units of its edge.\r\n *\r\n * Shape ops union; a `cut` subtracts the immediately preceding shape from\r\n * everything declared before it, mirroring how the renderer replays the op list.\r\n * `tolerance` widens each shape outward — including a cutter, which therefore\r\n * takes a slightly larger bite, keeping the test forgiving in both directions\r\n * rather than making a hole's rim unpickable.\r\n */\r\nexport function containsClip(clip: Clip, point: Vector2, tolerance = 0): boolean {\r\n return containsOps(clip.ops(), point, tolerance);\r\n}\r\n\r\n/** {@link containsClip} over a raw op list. */\r\nexport function containsOps(ops: readonly ClipOp[], point: Vector2, tolerance = 0): boolean {\r\n let inside = false;\r\n // The shape immediately preceding the current position, held back so a\r\n // following `cut` can subtract it instead of unioning it.\r\n let pending: ClipShapeOp | null = null;\r\n\r\n const flush = (): void => {\r\n if (pending && containsShape(pending, point, tolerance)) inside = true;\r\n pending = null;\r\n };\r\n\r\n for (const op of ops) {\r\n if (op.kind === \"cut\") {\r\n // The pending shape is the cutter: it never joins the union, and it\r\n // punches whatever was accumulated before it.\r\n if (pending && containsShape(pending, point, tolerance)) inside = false;\r\n pending = null;\r\n continue;\r\n }\r\n flush();\r\n pending = op;\r\n }\r\n flush();\r\n return inside;\r\n}\r\n\r\n/**\r\n * Dispatch one shape op to its own containment test, after undoing the shape's\r\n * local rotation/scale about its pivot — mirroring `BaseShape.applyShapeTransform`,\r\n * which bakes that same transform into the drawn path.\r\n */\r\nfunction containsShape(op: ClipShapeOp, point: Vector2, tolerance: number): boolean {\r\n switch (op.kind) {\r\n case \"rect\": {\r\n const s = withRectDescriptor(op.state);\r\n const p = toShapeLocal(point, s, s.width, s.height);\r\n return p !== null && containsRect(p, s.width, s.height, cornerRadiusOps.resolve(s.cornerRadius), tolerance);\r\n }\r\n case \"ellipse\": {\r\n const s = withEllipseDescriptor(op.state);\r\n const p = toShapeLocal(point, s, s.width, s.height);\r\n return p !== null && containsEllipse(p, s.width, s.height, s.ratio, s.sweep, s.startAngle, tolerance);\r\n }\r\n case \"polygon\": {\r\n const s = withPolygonDescriptor(op.state);\r\n const p = toShapeLocal(point, s, s.width, s.height);\r\n return p !== null && containsPolyline(p, polygonVertices(s.width, s.height, s.sides), true, tolerance);\r\n }\r\n case \"polygram\": {\r\n const s = withPolygramDescriptor(op.state);\r\n const p = toShapeLocal(point, s, s.width, s.height);\r\n return p !== null && containsPolyline(p, polygramVertices(s.width, s.height, s.sides, s.ratio), true, tolerance);\r\n }\r\n case \"line\": {\r\n const s = withLineDescriptor(op.state);\r\n const p = toShapeLocal(point, s, s.width, s.height);\r\n if (p === null || s.points.length === 0) return false;\r\n // As a clip region a polyline is filled with its contour implicitly\r\n // closed, whether or not `closed` was set — so test the enclosed area\r\n // first, then fall back to the band around the stroke itself.\r\n if (s.points.length >= 3 && containsPolyline(p, s.points, true, tolerance)) return true;\r\n return nearPolyline(p, s.points, s.closed, tolerance);\r\n }\r\n case \"path\": {\r\n // An arbitrary Bézier winding test is not worth carrying, and no\r\n // built-in shape emits a `path` clip — only a hand-built `Clip` can.\r\n // Fall back to the declared box.\r\n const s = op.state;\r\n const local = { x: point.x - (s.x ?? 0), y: point.y - (s.y ?? 0) };\r\n return containsRect(local, s.width ?? 0, s.height ?? 0, cornerRadiusOps.resolve(0), tolerance);\r\n }\r\n }\r\n}\r\n\r\n/** The positioning fields every shape descriptor resolves to. */\r\ninterface ShapePlacement {\r\n x: number;\r\n y: number;\r\n rotation: number;\r\n scale: number;\r\n pivot: unknown;\r\n}\r\n\r\n/**\r\n * Map `point` out of the shape's own `x`/`y`/`rotation`/`scale` (about its\r\n * pivot) and into the shape's un-transformed, centred frame. Returns `null` when\r\n * the scale is zero — the shape has collapsed and encloses nothing.\r\n */\r\nfunction toShapeLocal(point: Vector2, s: ShapePlacement, width: number, height: number): Vector2 | null {\r\n if (s.scale === 0) return null;\r\n const pivot = s.pivot as Vector2;\r\n // Pivot is normalised [-1, 1] about the shape centre, y-up here (the\r\n // renderer negates its y because it works in canvas space).\r\n const px = pivot.x * (width / 2);\r\n const py = pivot.y * (height / 2);\r\n // Relative to the pivot, in the parent's (unrotated) frame.\r\n const dx = point.x - (s.x + px);\r\n const dy = point.y - (s.y + py);\r\n // Undo the clockwise rotation: in y-up space the forward map is\r\n // (cos·x + sin·y, -sin·x + cos·y), so the inverse swaps the sine signs.\r\n const rad = (s.rotation * Math.PI) / 180;\r\n const cos = Math.cos(rad);\r\n const sin = Math.sin(rad);\r\n const rx = (cos * dx - sin * dy) / s.scale;\r\n const ry = (sin * dx + cos * dy) / s.scale;\r\n // Back to centre-relative: the pivot sits (px, py) from the centre.\r\n return { x: rx + px, y: ry + py };\r\n}\r\n\r\n// ─── Primitives ──────────────────────────────────────────────────────────────\r\n\r\ninterface Corners4 { topLeft: number; topRight: number; bottomRight: number; bottomLeft: number }\r\n\r\n/**\r\n * Axis-aligned box centred on the origin, with per-corner rounding. A corner is\r\n * only excluded when the point sits beyond that corner's quarter-circle, so a\r\n * plain rect (all radii 0) reduces to the box test exactly. `cornerStyle` is not\r\n * consulted: an `'angled'` chamfer cuts strictly inside the arc, so testing the\r\n * arc over-estimates by a sliver — the forgiving direction for a grab test.\r\n */\r\nfunction containsRect(p: Vector2, width: number, height: number, radius: Corners4, tolerance: number): boolean {\r\n const halfW = width / 2 + tolerance;\r\n const halfH = height / 2 + tolerance;\r\n if (Math.abs(p.x) > halfW || Math.abs(p.y) > halfH) return false;\r\n\r\n // Pick the corner the point is nearest and test its arc. Radii are clamped\r\n // the way any rounded-rect rasteriser clamps them: never past half the side.\r\n const maxR = Math.min(width, height) / 2;\r\n const r = Math.min(\r\n maxR,\r\n p.x <= 0\r\n ? (p.y >= 0 ? radius.topLeft : radius.bottomLeft)\r\n : (p.y >= 0 ? radius.topRight : radius.bottomRight),\r\n );\r\n if (r <= 0) return true;\r\n\r\n // Centre of that corner's arc, then the usual \"outside the quarter-circle\"\r\n // check — which only bites inside the corner square itself.\r\n const sx = Math.sign(p.x || 1);\r\n const sy = Math.sign(p.y || 1);\r\n const dx = p.x - sx * (width / 2 - r);\r\n const dy = p.y - sy * (height / 2 - r);\r\n if (Math.sign(dx || 1) !== sx || Math.sign(dy || 1) !== sy) return true;\r\n return dx * dx + dy * dy <= (r + tolerance) * (r + tolerance);\r\n}\r\n\r\n/**\r\n * Ellipse, honouring the same `ratio`/`sweep`/`startAngle` family the renderer\r\n * draws (see `EllipseShape.buildSVGPath`), so the grab region is the region that\r\n * was actually painted:\r\n *\r\n * - `ratio` ≤ 0 → solid disk, or a wedge for a partial sweep\r\n * - 0 < `ratio` < 1 → annulus / annular sector (the hole is not hittable)\r\n * - `ratio` ≥ 1 → the band has collapsed to the bare outer curve, so only\r\n * points near that curve hit\r\n */\r\nfunction containsEllipse(\r\n p: Vector2, width: number, height: number,\r\n ratio: number, sweep: number, startAngle: number,\r\n tolerance: number,\r\n): boolean {\r\n const rx = width / 2;\r\n const ry = height / 2;\r\n if (rx <= 0 || ry <= 0) return false;\r\n\r\n const clamped = Math.max(0, Math.min(1, ratio));\r\n const full = Math.abs(sweep) >= 360;\r\n\r\n // Outside the outer curve (grown by tolerance) can never hit.\r\n if (norm(p, rx + tolerance, ry + tolerance) > 1) return false;\r\n\r\n if (clamped > 0) {\r\n const inner = norm(p, Math.max(EPS, rx * clamped - tolerance), Math.max(EPS, ry * clamped - tolerance));\r\n if (inner < 1) return false;\r\n }\r\n\r\n if (full) return true;\r\n return withinSweep(Math.atan2(p.y / ry, p.x / rx) * (180 / Math.PI), startAngle, sweep, p, tolerance);\r\n}\r\n\r\n/** Normalised radius of `p` on an ellipse of half-axes `rx`/`ry` (1 = on the curve). */\r\nfunction norm(p: Vector2, rx: number, ry: number): number {\r\n return Math.hypot(p.x / rx, p.y / ry);\r\n}\r\n\r\n/**\r\n * Whether `angleDeg` lies within the arc `[startAngle, startAngle + sweep]`,\r\n * with `tolerance` converted to angular slack at the point's own radius so\r\n * grab-slop widens the wedge's straight edges too. Handles negative sweeps.\r\n */\r\nfunction withinSweep(\r\n angleDeg: number, startAngle: number, sweep: number,\r\n p: Vector2, tolerance: number,\r\n): boolean {\r\n const lo = sweep >= 0 ? startAngle : startAngle + sweep;\r\n const span = Math.abs(sweep);\r\n // Near the centre every angle is within tolerance of the wedge.\r\n const radius = Math.hypot(p.x, p.y);\r\n if (radius <= tolerance) return true;\r\n const slack = tolerance > 0 ? (tolerance / Math.max(radius, EPS)) * (180 / Math.PI) : 0;\r\n let delta = (angleDeg - lo) % 360;\r\n if (delta < 0) delta += 360;\r\n // Accept the wrap-around side within slack as well.\r\n return delta <= span + slack || delta >= 360 - slack;\r\n}\r\n\r\n/**\r\n * Vertices of a regular polygon inscribed in `width`×`height`, y-up author\r\n * space. The renderer starts at the top vertex and steps clockwise in canvas\r\n * space; in y-up that is `+π/2` stepping negative.\r\n */\r\nexport function polygonVertices(width: number, height: number, sides: number): Vector2[] {\r\n const n = Math.max(3, Math.round(sides));\r\n const rx = width / 2;\r\n const ry = height / 2;\r\n const step = (2 * Math.PI) / n;\r\n const out: Vector2[] = [];\r\n for (let i = 0; i < n; i++) {\r\n const a = Math.PI / 2 - i * step;\r\n out.push({ x: rx * Math.cos(a), y: ry * Math.sin(a) });\r\n }\r\n return out;\r\n}\r\n\r\n/** Vertices of a star polygon: outer radius 1 alternating with inner radius `ratio`. */\r\nexport function polygramVertices(width: number, height: number, sides: number, ratio: number): Vector2[] {\r\n const n = Math.max(3, Math.round(sides));\r\n const r = Math.max(0, Math.min(1, ratio));\r\n const rx = width / 2;\r\n const ry = height / 2;\r\n const step = Math.PI / n;\r\n const out: Vector2[] = [];\r\n for (let i = 0; i < n * 2; i++) {\r\n const a = Math.PI / 2 - i * step;\r\n const k = i % 2 === 0 ? 1 : r;\r\n out.push({ x: rx * k * Math.cos(a), y: ry * k * Math.sin(a) });\r\n }\r\n return out;\r\n}\r\n\r\n/**\r\n * Even-odd crossing test against a polygon, widened by `tolerance`: a point just\r\n * outside an edge still counts. `closed` also closes the last→first segment for\r\n * the tolerance band.\r\n */\r\nfunction containsPolyline(p: Vector2, verts: readonly Vector2[], closed: boolean, tolerance: number): boolean {\r\n if (verts.length >= 3 && pointInPolygon(p, verts)) return true;\r\n return tolerance > 0 && nearPolyline(p, verts, closed, tolerance);\r\n}\r\n\r\n/** Even-odd crossing test against a closed polygon. No tolerance band. */\r\nexport function pointInPolygon(p: Vector2, verts: readonly Vector2[]): boolean {\r\n if (verts.length < 3) return false;\r\n let inside = false;\r\n for (let i = 0, j = verts.length - 1; i < verts.length; j = i++) {\r\n const a = verts[i];\r\n const b = verts[j];\r\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) {\r\n inside = !inside;\r\n }\r\n }\r\n return inside;\r\n}\r\n\r\n/** Whether `p` is within `tolerance` of any segment of the polyline. */\r\nexport function nearPolyline(p: Vector2, pts: readonly Vector2[], closed: boolean, tolerance: number): boolean {\r\n if (pts.length === 0) return false;\r\n if (pts.length === 1) return Math.hypot(p.x - pts[0].x, p.y - pts[0].y) <= tolerance;\r\n const last = closed ? pts.length : pts.length - 1;\r\n for (let i = 0; i < last; i++) {\r\n if (distanceToSegment(p, pts[i], pts[(i + 1) % pts.length]) <= tolerance) return true;\r\n }\r\n return false;\r\n}\r\n\r\n/** Shortest distance from `p` to the segment `a`–`b`. */\r\nexport function distanceToSegment(p: Vector2, a: Vector2, b: Vector2): number {\r\n const dx = b.x - a.x;\r\n const dy = b.y - a.y;\r\n const lenSq = dx * dx + dy * dy;\r\n if (lenSq <= EPS) return Math.hypot(p.x - a.x, p.y - a.y);\r\n let t = ((p.x - a.x) * dx + (p.y - a.y) * dy) / lenSq;\r\n t = t < 0 ? 0 : t > 1 ? 1 : t;\r\n return Math.hypot(p.x - (a.x + t * dx), p.y - (a.y + t * dy));\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"clip-contains.js","sourceRoot":"","sources":["../../src/render/clip-contains.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAE3E;;;;;;;;;;;;;;GAcG;AAEH,0DAA0D;AAC1D,MAAM,GAAG,GAAG,IAAI,CAAC;AAEjB;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAAC,IAAU,EAAE,KAAc,EAAE,SAAS,GAAG,CAAC;IAClE,OAAO,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AACrD,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,WAAW,CAAC,GAAsB,EAAE,KAAc,EAAE,SAAS,GAAG,CAAC;IAC7E,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,uEAAu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IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import { Vector2 } from \"@/attributes/layout/vector2\";\r\nimport { Clip, ClipOp, ClipShapeOp } from \"./clip\";\r\nimport { withRectDescriptor } from \"./descriptors/rect\";\r\nimport { withEllipseDescriptor } from \"./descriptors/ellipse\";\r\nimport { withPolygonDescriptor } from \"./descriptors/polygon\";\r\nimport { withPolygramDescriptor } from \"./descriptors/polygram\";\r\nimport { withLineDescriptor } from \"./descriptors/line\";\r\nimport { cornerRadiusOps } from \"@/attributes/shape/corners/corner-radius\";\r\n\r\n/**\r\n * Point-in-region tests for {@link Clip}, used by node hit testing so a click\r\n * follows a shape's silhouette rather than its bounding box.\r\n *\r\n * Geometry only — no renderer — because a `Clip` is a declarative\r\n * record of primitives rather than a built path. That is what lets hit testing\r\n * live in `core` and share one outline definition with clipping and backdrop\r\n * effects: a shape declares its outline once, in `clipSelf()`, and both the\r\n * pixels and the grab region derive from it.\r\n *\r\n * Every point and every descriptor coordinate here is in **y-up author space**\r\n * (the space `Graphics2D`/`Clip` descriptors are written in; the renderer flips to\r\n * canvas y-down at draw time — see `flipPositionY`). Angles follow from that:\r\n * `startAngle`/`sweep` measure counter-clockwise from +x.\r\n */\r\n\r\n/** Guard against divide-by-zero on collapsed geometry. */\r\nconst EPS = 1e-9;\r\n\r\n/**\r\n * Whether `point` falls inside the region a {@link Clip} describes, within\r\n * `tolerance` scene units of its edge.\r\n *\r\n * Shape ops union; a `cut` subtracts the immediately preceding shape from\r\n * everything declared before it, mirroring how the renderer replays the op list.\r\n * `tolerance` widens each shape outward — including a cutter, which therefore\r\n * takes a slightly larger bite, keeping the test forgiving in both directions\r\n * rather than making a hole's rim unpickable.\r\n */\r\nexport function containsClip(clip: Clip, point: Vector2, tolerance = 0): boolean {\r\n return containsOps(clip.ops(), point, tolerance);\r\n}\r\n\r\n/** {@link containsClip} over a raw op list. */\r\nexport function containsOps(ops: readonly ClipOp[], point: Vector2, tolerance = 0): boolean {\r\n let inside = false;\r\n // The shape immediately preceding the current position, held back so a\r\n // following `cut` can subtract it instead of unioning it.\r\n let pending: ClipShapeOp | null = null;\r\n\r\n const flush = (): void => {\r\n if (pending && containsShape(pending, point, tolerance)) inside = true;\r\n pending = null;\r\n };\r\n\r\n for (const op of ops) {\r\n if (op.kind === \"cut\") {\r\n // The pending shape is the cutter: it never joins the union, and it\r\n // punches whatever was accumulated before it.\r\n if (pending && containsShape(pending, point, tolerance)) inside = false;\r\n pending = null;\r\n continue;\r\n }\r\n flush();\r\n pending = op;\r\n }\r\n flush();\r\n return inside;\r\n}\r\n\r\n/**\r\n * Dispatch one shape op to its own containment test, after undoing the shape's\r\n * local rotation/scale about its pivot — mirroring `BaseShape.applyShapeTransform`,\r\n * which bakes that same transform into the drawn path.\r\n */\r\nfunction containsShape(op: ClipShapeOp, point: Vector2, tolerance: number): boolean {\r\n switch (op.kind) {\r\n case \"rect\": {\r\n const s = withRectDescriptor(op.state);\r\n const p = toShapeLocal(point, s, s.width, s.height);\r\n return p !== null && containsRect(p, s.width, s.height, cornerRadiusOps.resolve(s.cornerRadius), tolerance);\r\n }\r\n case \"ellipse\": {\r\n const s = withEllipseDescriptor(op.state);\r\n const p = toShapeLocal(point, s, s.width, s.height);\r\n return p !== null && containsEllipse(p, s.width, s.height, s.ratio, s.sweep, s.startAngle, tolerance);\r\n }\r\n case \"polygon\": {\r\n const s = withPolygonDescriptor(op.state);\r\n const p = toShapeLocal(point, s, s.width, s.height);\r\n return p !== null && containsPolyline(p, polygonVertices(s.width, s.height, s.sides), true, tolerance);\r\n }\r\n case \"polygram\": {\r\n const s = withPolygramDescriptor(op.state);\r\n const p = toShapeLocal(point, s, s.width, s.height);\r\n return p !== null && containsPolyline(p, polygramVertices(s.width, s.height, s.sides, s.ratio), true, tolerance);\r\n }\r\n case \"line\": {\r\n const s = withLineDescriptor(op.state);\r\n const p = toShapeLocal(point, s, s.width, s.height);\r\n if (p === null || s.points.length === 0) return false;\r\n // As a clip region a polyline is filled with its contour implicitly\r\n // closed, whether or not `closed` was set — so test the enclosed area\r\n // first, then fall back to the band around the stroke itself.\r\n if (s.points.length >= 3 && containsPolyline(p, s.points, true, tolerance)) return true;\r\n return nearPolyline(p, s.points, s.closed, tolerance);\r\n }\r\n case \"path\": {\r\n // An arbitrary Bézier winding test is not worth carrying, and no\r\n // built-in shape emits a `path` clip — only a hand-built `Clip` can.\r\n // Fall back to the declared box.\r\n const s = op.state;\r\n const local = { x: point.x - (s.x ?? 0), y: point.y - (s.y ?? 0) };\r\n return containsRect(local, s.width ?? 0, s.height ?? 0, cornerRadiusOps.resolve(0), tolerance);\r\n }\r\n }\r\n}\r\n\r\n/** The positioning fields every shape descriptor resolves to. */\r\ninterface ShapePlacement {\r\n x: number;\r\n y: number;\r\n rotation: number;\r\n scale: number;\r\n pivot: unknown;\r\n}\r\n\r\n/**\r\n * Map `point` out of the shape's own `x`/`y`/`rotation`/`scale` (about its\r\n * pivot) and into the shape's un-transformed, centred frame. Returns `null` when\r\n * the scale is zero — the shape has collapsed and encloses nothing.\r\n */\r\nfunction toShapeLocal(point: Vector2, s: ShapePlacement, width: number, height: number): Vector2 | null {\r\n if (s.scale === 0) return null;\r\n const pivot = s.pivot as Vector2;\r\n // Pivot is normalised [-1, 1] about the shape centre, y-up here (the\r\n // renderer negates its y because it works in canvas space).\r\n const px = pivot.x * (width / 2);\r\n const py = pivot.y * (height / 2);\r\n // Relative to the pivot, in the parent's (unrotated) frame.\r\n const dx = point.x - (s.x + px);\r\n const dy = point.y - (s.y + py);\r\n // Undo the clockwise rotation: in y-up space the forward map is\r\n // (cos·x + sin·y, -sin·x + cos·y), so the inverse swaps the sine signs.\r\n const rad = (s.rotation * Math.PI) / 180;\r\n const cos = Math.cos(rad);\r\n const sin = Math.sin(rad);\r\n const rx = (cos * dx - sin * dy) / s.scale;\r\n const ry = (sin * dx + cos * dy) / s.scale;\r\n // Back to centre-relative: the pivot sits (px, py) from the centre.\r\n return { x: rx + px, y: ry + py };\r\n}\r\n\r\n// ─── Primitives ──────────────────────────────────────────────────────────────\r\n\r\ninterface Corners4 { topLeft: number; topRight: number; bottomRight: number; bottomLeft: number }\r\n\r\n/**\r\n * Axis-aligned box centred on the origin, with per-corner rounding. A corner is\r\n * only excluded when the point sits beyond that corner's quarter-circle, so a\r\n * plain rect (all radii 0) reduces to the box test exactly. `cornerStyle` is not\r\n * consulted: an `'angled'` chamfer cuts strictly inside the arc, so testing the\r\n * arc over-estimates by a sliver — the forgiving direction for a grab test.\r\n */\r\nfunction containsRect(p: Vector2, width: number, height: number, radius: Corners4, tolerance: number): boolean {\r\n const halfW = width / 2 + tolerance;\r\n const halfH = height / 2 + tolerance;\r\n if (Math.abs(p.x) > halfW || Math.abs(p.y) > halfH) return false;\r\n\r\n // Pick the corner the point is nearest and test its arc. Radii are clamped\r\n // the way any rounded-rect rasteriser clamps them: never past half the side.\r\n const maxR = Math.min(width, height) / 2;\r\n const r = Math.min(\r\n maxR,\r\n p.x <= 0\r\n ? (p.y >= 0 ? radius.topLeft : radius.bottomLeft)\r\n : (p.y >= 0 ? radius.topRight : radius.bottomRight),\r\n );\r\n if (r <= 0) return true;\r\n\r\n // Centre of that corner's arc, then the usual \"outside the quarter-circle\"\r\n // check — which only bites inside the corner square itself.\r\n const sx = Math.sign(p.x || 1);\r\n const sy = Math.sign(p.y || 1);\r\n const dx = p.x - sx * (width / 2 - r);\r\n const dy = p.y - sy * (height / 2 - r);\r\n if (Math.sign(dx || 1) !== sx || Math.sign(dy || 1) !== sy) return true;\r\n return dx * dx + dy * dy <= (r + tolerance) * (r + tolerance);\r\n}\r\n\r\n/**\r\n * Ellipse, honouring the same `ratio`/`sweep`/`startAngle` family the renderer\r\n * draws (see `EllipseShape.buildSVGPath`), so the grab region is the region that\r\n * was actually painted:\r\n *\r\n * - `ratio` ≤ 0 → solid disk, or a wedge for a partial sweep\r\n * - 0 < `ratio` < 1 → annulus / annular sector (the hole is not hittable)\r\n * - `ratio` ≥ 1 → the band has collapsed to the bare outer curve, so only\r\n * points near that curve hit\r\n */\r\nfunction containsEllipse(\r\n p: Vector2, width: number, height: number,\r\n ratio: number, sweep: number, startAngle: number,\r\n tolerance: number,\r\n): boolean {\r\n const rx = width / 2;\r\n const ry = height / 2;\r\n if (rx <= 0 || ry <= 0) return false;\r\n\r\n const clamped = Math.max(0, Math.min(1, ratio));\r\n const full = Math.abs(sweep) >= 360;\r\n\r\n // Outside the outer curve (grown by tolerance) can never hit.\r\n if (norm(p, rx + tolerance, ry + tolerance) > 1) return false;\r\n\r\n if (clamped > 0) {\r\n const inner = norm(p, Math.max(EPS, rx * clamped - tolerance), Math.max(EPS, ry * clamped - tolerance));\r\n if (inner < 1) return false;\r\n }\r\n\r\n if (full) return true;\r\n return withinSweep(Math.atan2(p.y / ry, p.x / rx) * (180 / Math.PI), startAngle, sweep, p, tolerance);\r\n}\r\n\r\n/** Normalised radius of `p` on an ellipse of half-axes `rx`/`ry` (1 = on the curve). */\r\nfunction norm(p: Vector2, rx: number, ry: number): number {\r\n return Math.hypot(p.x / rx, p.y / ry);\r\n}\r\n\r\n/**\r\n * Whether `angleDeg` lies within the arc `[startAngle, startAngle + sweep]`,\r\n * with `tolerance` converted to angular slack at the point's own radius so\r\n * grab-slop widens the wedge's straight edges too. Handles negative sweeps.\r\n */\r\nfunction withinSweep(\r\n angleDeg: number, startAngle: number, sweep: number,\r\n p: Vector2, tolerance: number,\r\n): boolean {\r\n const lo = sweep >= 0 ? startAngle : startAngle + sweep;\r\n const span = Math.abs(sweep);\r\n // Near the centre every angle is within tolerance of the wedge.\r\n const radius = Math.hypot(p.x, p.y);\r\n if (radius <= tolerance) return true;\r\n const slack = tolerance > 0 ? (tolerance / Math.max(radius, EPS)) * (180 / Math.PI) : 0;\r\n let delta = (angleDeg - lo) % 360;\r\n if (delta < 0) delta += 360;\r\n // Accept the wrap-around side within slack as well.\r\n return delta <= span + slack || delta >= 360 - slack;\r\n}\r\n\r\n/**\r\n * Vertices of a regular polygon inscribed in `width`×`height`, y-up author\r\n * space. The renderer starts at the top vertex and steps clockwise in canvas\r\n * space; in y-up that is `+π/2` stepping negative.\r\n */\r\nexport function polygonVertices(width: number, height: number, sides: number): Vector2[] {\r\n const n = Math.max(3, Math.round(sides));\r\n const rx = width / 2;\r\n const ry = height / 2;\r\n const step = (2 * Math.PI) / n;\r\n const out: Vector2[] = [];\r\n for (let i = 0; i < n; i++) {\r\n const a = Math.PI / 2 - i * step;\r\n out.push({ x: rx * Math.cos(a), y: ry * Math.sin(a) });\r\n }\r\n return out;\r\n}\r\n\r\n/** Vertices of a star polygon: outer radius 1 alternating with inner radius `ratio`. */\r\nexport function polygramVertices(width: number, height: number, sides: number, ratio: number): Vector2[] {\r\n const n = Math.max(3, Math.round(sides));\r\n const r = Math.max(0, Math.min(1, ratio));\r\n const rx = width / 2;\r\n const ry = height / 2;\r\n const step = Math.PI / n;\r\n const out: Vector2[] = [];\r\n for (let i = 0; i < n * 2; i++) {\r\n const a = Math.PI / 2 - i * step;\r\n const k = i % 2 === 0 ? 1 : r;\r\n out.push({ x: rx * k * Math.cos(a), y: ry * k * Math.sin(a) });\r\n }\r\n return out;\r\n}\r\n\r\n/**\r\n * Even-odd crossing test against a polygon, widened by `tolerance`: a point just\r\n * outside an edge still counts. `closed` also closes the last→first segment for\r\n * the tolerance band.\r\n */\r\nfunction containsPolyline(p: Vector2, verts: readonly Vector2[], closed: boolean, tolerance: number): boolean {\r\n if (verts.length >= 3 && pointInPolygon(p, verts)) return true;\r\n return tolerance > 0 && nearPolyline(p, verts, closed, tolerance);\r\n}\r\n\r\n/** Even-odd crossing test against a closed polygon. No tolerance band. */\r\nexport function pointInPolygon(p: Vector2, verts: readonly Vector2[]): boolean {\r\n if (verts.length < 3) return false;\r\n let inside = false;\r\n for (let i = 0, j = verts.length - 1; i < verts.length; j = i++) {\r\n const a = verts[i];\r\n const b = verts[j];\r\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) {\r\n inside = !inside;\r\n }\r\n }\r\n return inside;\r\n}\r\n\r\n/** Whether `p` is within `tolerance` of any segment of the polyline. */\r\nexport function nearPolyline(p: Vector2, pts: readonly Vector2[], closed: boolean, tolerance: number): boolean {\r\n if (pts.length === 0) return false;\r\n if (pts.length === 1) return Math.hypot(p.x - pts[0].x, p.y - pts[0].y) <= tolerance;\r\n const last = closed ? pts.length : pts.length - 1;\r\n for (let i = 0; i < last; i++) {\r\n if (distanceToSegment(p, pts[i], pts[(i + 1) % pts.length]) <= tolerance) return true;\r\n }\r\n return false;\r\n}\r\n\r\n/** Shortest distance from `p` to the segment `a`–`b`. */\r\nexport function distanceToSegment(p: Vector2, a: Vector2, b: Vector2): number {\r\n const dx = b.x - a.x;\r\n const dy = b.y - a.y;\r\n const lenSq = dx * dx + dy * dy;\r\n if (lenSq <= EPS) return Math.hypot(p.x - a.x, p.y - a.y);\r\n let t = ((p.x - a.x) * dx + (p.y - a.y) * dy) / lenSq;\r\n t = t < 0 ? 0 : t > 1 ? 1 : t;\r\n return Math.hypot(p.x - (a.x + t * dx), p.y - (a.y + t * dy));\r\n}\r\n"]}
|
|
@@ -57,7 +57,7 @@ export interface TextSegment {
|
|
|
57
57
|
*
|
|
58
58
|
* The caret model can describe a segmented block exactly as long as this holds
|
|
59
59
|
* of every piece: differently-styled runs are still one paragraph, laid out and
|
|
60
|
-
* measured together, so
|
|
60
|
+
* measured together, so the shaper's own rects for each character are where the glyphs
|
|
61
61
|
* are. A piece that is *moved*, turned or scaled about its own centre is not in
|
|
62
62
|
* that paragraph's space any more, and a slot measured from it would point at
|
|
63
63
|
* where the character would have been. See `textBlockLayout`, which is the one
|
|
@@ -134,7 +134,7 @@ export interface TextState extends ShapeState {
|
|
|
134
134
|
*
|
|
135
135
|
* Exported so the **measure** path enforces the same policy from the same
|
|
136
136
|
* definition. Shaping a paragraph to measure it happens before any op is
|
|
137
|
-
* validated, and
|
|
137
|
+
* validated, and the shaper reads `.length` off every family name — so text with no
|
|
138
138
|
* family used to die inside the wasm with `Cannot read properties of undefined`,
|
|
139
139
|
* naming no scene, node or prop, while the identical case at draw time produced
|
|
140
140
|
* the message above. One policy, two verdicts, and the useless one came first.
|
|
@@ -11,7 +11,7 @@ export const AUTOFIT_PROBE_SIZE = 100;
|
|
|
11
11
|
*
|
|
12
12
|
* The caret model can describe a segmented block exactly as long as this holds
|
|
13
13
|
* of every piece: differently-styled runs are still one paragraph, laid out and
|
|
14
|
-
* measured together, so
|
|
14
|
+
* measured together, so the shaper's own rects for each character are where the glyphs
|
|
15
15
|
* are. A piece that is *moved*, turned or scaled about its own centre is not in
|
|
16
16
|
* that paragraph's space any more, and a slot measured from it would point at
|
|
17
17
|
* where the character would have been. See `textBlockLayout`, which is the one
|
|
@@ -48,7 +48,7 @@ export function isStyleOnlySegment(segment) {
|
|
|
48
48
|
*
|
|
49
49
|
* Exported so the **measure** path enforces the same policy from the same
|
|
50
50
|
* definition. Shaping a paragraph to measure it happens before any op is
|
|
51
|
-
* validated, and
|
|
51
|
+
* validated, and the shaper reads `.length` off every family name — so text with no
|
|
52
52
|
* family used to die inside the wasm with `Cannot read properties of undefined`,
|
|
53
53
|
* naming no scene, node or prop, while the identical case at draw time produced
|
|
54
54
|
* the message above. One policy, two verdicts, and the useless one came first.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/render/descriptors/text.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmC,qBAAqB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAC7H,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAE1E;;;;GAIG;AACH,MAAM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;QAChC,QAAQ,EAAE,UAAU,CAAC,QAAQ,IAAI,CAAC;QAClC,KAAK,EAAE,UAAU,CAAC,KAAK,IAAI,CAAC;QAC5B,CAAC;QACD,CAAC;QACD,KAAK,EAAE,UAAU,CAAC,KAAK,IAAI,CAAC;QAC5B,GAAG,EAAE,UAAU,CAAC,GAAG,IAAI,CAAC;QACxB,KAAK,EAAE,iBAAiB,CAAC,KAAK,CAAC;QAC/B,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,EAAE;QAC3B,QAAQ,EAAE,UAAU,CAAC,QAAQ,IAAI,EAAE;QACnC,UAAU,EAAE,iBAAiB,CAAC,UAAU,CAAC;QACzC,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,GAAG;QACxC,SAAS,EAAE,UAAU,CAAC,SAAS,IAAI,QAAQ;QAC3C,aAAa,EAAE,UAAU,CAAC,aAAa,IAAI,CAAC;QAC5C,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,CAAC;QACtC,SAAS,EAAE,UAAU,CAAC,SAAS,IAAI,QAAQ;QAC3C,aAAa,EAAE,UAAU,CAAC,aAAa,IAAI,QAAQ;QACnD,cAAc,EAAE,UAAU,CAAC,cAAc,IAAI,MAAM;QACnD,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,KAAK;QAC9B,WAAW,EAAE,UAAU,CAAC,WAAW,IAAI,EAAE;QACzC,KAAK,EAAE,UAAU,CAAC,KAAK,IAAI,CAAC;QAC5B,MAAM,EAAE,UAAU,CAAC,MAAM,IAAI,CAAC;QAC9B,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,IAAI;KAChC,CAAC;AACN,CAAC","sourcesContent":["import type { FontStyle, TextAlign, TextDecoration, VerticalAlign } from \"@/attributes/text/types\";\r\nimport { FillResolved } from \"@/attributes/shape/fill/union\";\r\nimport { StrokeResolved } from \"@/attributes/shape/stroke/stroke\";\r\nimport { PathData } from \"./path\";\r\nimport { ShapeAlignmentInput, ShapeState, resolveShapeAlignment, resolveShapePivot, stripShapeAlignmentKeys } from \"./shape\";\r\nimport { hostTextFamily } from \"@/components/builtins/text/text-defaults\";\r\n\r\n/**\r\n * The size a segmented block's pieces shape at on an `'autofit'` node: the\r\n * size the layout probes with, since no single piece can be asked for the\r\n * size the block settles on.\r\n */\r\nexport const AUTOFIT_PROBE_SIZE = 100;\r\n\r\n/**\r\n * One contiguous piece of a Text node split at run boundaries. Pieces\r\n * carry their effective shaping inputs (`text` plus the five font fields) and\r\n * draw-time overrides applied per shaped run: `opacity` folded into the paint\r\n * alpha, an optional `fill`/`stroke` override (falls back to the node's when\r\n * omitted), and a transform applied about the run's centered position.\r\n *\r\n * Present only when a Text node has styled runs or a reveal window; otherwise\r\n * the node renders as a single string with no segments.\r\n *\r\n * **Every shaping field is stated, none inherited at draw time.** `fontFamily`,\r\n * `fontSize` and `fontStyle` joined `fontWeight` and `letterSpacing` here so a\r\n * run can change its *face* and not only its weight — which is\r\n * what an editor built on this needs to offer per-character styling at all. The\r\n * paragraph builder already takes all five per run (it is what `RichText` sets),\r\n * so the cost of the three is a wider segment and nothing else.\r\n *\r\n * They are optional only so an older caller's segments still lay out: absent\r\n * means \"the node's own\", resolved where the paragraph is built rather than\r\n * left for the renderer to guess.\r\n */\r\nexport interface TextSegment {\r\n text: string;\r\n /** Override family for this piece; falls back to the node's when undefined. */\r\n fontFamily?: string;\r\n /** Override size for this piece; falls back to the node's when undefined. */\r\n fontSize?: number;\r\n /** Override slant for this piece; falls back to the node's when undefined. */\r\n fontStyle?: FontStyle;\r\n fontWeight: number;\r\n letterSpacing: number;\r\n /** Override decoration for this piece; falls back to the node's when undefined. */\r\n textDecoration?: TextDecoration;\r\n opacity: number;\r\n x: number;\r\n y: number;\r\n scale: number;\r\n rotation: number;\r\n /** Override fill for this piece; falls back to the node's fill when undefined. */\r\n fill?: FillResolved[];\r\n /** Override stroke for this piece; falls back to the node's stroke when undefined. */\r\n stroke?: StrokeResolved[];\r\n}\r\n\r\n/**\r\n * Whether `segment` only *styles* its characters — no transform of its own.\r\n *\r\n * The caret model can describe a segmented block exactly as long as this holds\r\n * of every piece: differently-styled runs are still one paragraph, laid out and\r\n * measured together, so Skia's own rects for each character are where the glyphs\r\n * are. A piece that is *moved*, turned or scaled about its own centre is not in\r\n * that paragraph's space any more, and a slot measured from it would point at\r\n * where the character would have been. See `textBlockLayout`, which is the one\r\n * caller and turns a false here into \"no caret model for this shape\".\r\n */\r\nexport function isStyleOnlySegment(segment: TextSegment): boolean {\r\n return segment.x === 0 && segment.y === 0\r\n && segment.scale === 1 && segment.rotation === 0;\r\n}\r\n\r\nexport interface TextState extends ShapeState {\r\n text: string;\r\n /**\r\n * A named typography preset to shape against — `theme.typography`'s key, the\r\n * same one a `Text` node's `variant` prop selects.\r\n *\r\n * A node reads its variant once, at bind; a drawn op has no bind step, so it\r\n * is resolved at draw alongside the inherited defaults (see\r\n * `applyGraphicsTextDefaults`). It sits *between* the two: above the\r\n * enclosing `<DefaultTextStyle>`, below anything the op states itself.\r\n *\r\n * Optional, and unresolved names are ignored rather than an error — a scene\r\n * that renames a preset should lose the styling, not fail to draw.\r\n */\r\n variant?: string;\r\n fontSize: number | 'autofit';\r\n fontFamily: string;\r\n fontWeight: number;\r\n fontStyle: FontStyle;\r\n letterSpacing: number;\r\n lineHeight: number;\r\n textAlign: TextAlign;\r\n /** Where the block sits in a box taller or shorter than it; only a `height` gives it one. */\r\n verticalAlign: VerticalAlign;\r\n textDecoration: TextDecoration;\r\n wrap: boolean;\r\n minFontSize: number;\r\n width: number;\r\n height: number;\r\n /**\r\n * Per-piece overrides when the node has styled runs. When set,\r\n * the renderer shapes these pieces together (one paragraph) and paints each\r\n * shaped run with its piece's overrides instead of the node's single fill.\r\n */\r\n segments?: TextSegment[];\r\n /**\r\n * When set, the text is wrapped around this path (text-on-path) instead of\r\n * laid out as straight lines: each glyph is positioned and rotated to follow\r\n * the path, centered on its baseline, and glyphs past the path end are\r\n * clipped. Mutually exclusive with `segments` in v1.\r\n */\r\n path?: PathData | null;\r\n}\r\n\r\n\r\n/**\r\n * The family this text is set in — the last rung of the cascade, and the only\r\n * one that can refuse.\r\n *\r\n * It used to fall back to `\"Arial\"`, which is the wrong shape of answer for a\r\n * renderer whose whole job is that the picture is the one that was asked for:\r\n * substituting a face the *engine* picked produces text in a typeface the author\r\n * never chose, at metrics they never measured, in a frame that looks finished,\r\n * and hides a font that was never declared and so never loaded.\r\n *\r\n * What it falls back to instead is {@link hostTextFamily} — a face the\r\n * **application** named, once, at its composition root, out of the fonts it\r\n * actually vendors. That is a different bargain: a host that ships a typeface\r\n * registers it in every manifest, so a chart axis that nobody styled comes out\r\n * in it and paints glyphs, while the engine still refuses to invent a face of\r\n * its own. A host that declares nothing gets the error below, which is the right\r\n * answer for a headless render whose fonts all come from a manifest.\r\n *\r\n * By the time an op reaches here the whole ladder above has been walked — the op\r\n * or prop itself, a `variant` preset, the enclosing `<DefaultTextStyle>`, then\r\n * the theme's `default` typography preset — so this is only ever reached when\r\n * every one of them was silent. The message names them because \"no font family\"\r\n * is not actionable and \"set one on the text, on a DefaultTextStyle, or as the\r\n * theme's default preset\" is.\r\n *\r\n * Exported so the **measure** path enforces the same policy from the same\r\n * definition. Shaping a paragraph to measure it happens before any op is\r\n * validated, and Skia reads `.length` off every family name — so text with no\r\n * family used to die inside the wasm with `Cannot read properties of undefined`,\r\n * naming no scene, node or prop, while the identical case at draw time produced\r\n * the message above. One policy, two verdicts, and the useless one came first.\r\n */\r\nexport function requireFontFamily(descriptor: { fontFamily?: string; text?: string }): string {\r\n const family = descriptor.fontFamily;\r\n if (typeof family === \"string\" && family !== \"\") return family;\r\n const host = hostTextFamily();\r\n if (host !== \"\") return host;\r\n const text = descriptor.text ? ` drawing \"${descriptor.text.slice(0, 32)}\"` : \"\";\r\n throw new Error(\r\n `Text${text} has no fontFamily. Set one on the text itself, on an `\r\n + `enclosing <DefaultTextStyle>, or as the theme's \\`default\\` typography `\r\n + `preset — there is no fallback face.`,\r\n );\r\n}\r\n\r\nexport function withTextDescriptor(descriptor: Partial<TextState> & ShapeAlignmentInput): TextState {\r\n const width = descriptor.width ?? 0;\r\n const height = descriptor.height ?? 0;\r\n const { x, y, pivot } = resolveShapeAlignment(descriptor, width, height);\r\n return {\r\n ...stripShapeAlignmentKeys(descriptor),\r\n opacity: descriptor.opacity ?? 1,\r\n rotation: descriptor.rotation ?? 0,\r\n scale: descriptor.scale ?? 1,\r\n x,\r\n y,\r\n start: descriptor.start ?? 0,\r\n end: descriptor.end ?? 1,\r\n pivot: resolveShapePivot(pivot),\r\n text: descriptor.text ?? \"\",\r\n fontSize: descriptor.fontSize ?? 48,\r\n fontFamily: requireFontFamily(descriptor),\r\n fontWeight: descriptor.fontWeight ?? 400,\r\n fontStyle: descriptor.fontStyle ?? 'normal',\r\n letterSpacing: descriptor.letterSpacing ?? 0,\r\n lineHeight: descriptor.lineHeight ?? 0,\r\n textAlign: descriptor.textAlign ?? 'center',\r\n verticalAlign: descriptor.verticalAlign ?? 'center',\r\n textDecoration: descriptor.textDecoration ?? 'none',\r\n wrap: descriptor.wrap ?? false,\r\n minFontSize: descriptor.minFontSize ?? 12,\r\n width: descriptor.width ?? 0,\r\n height: descriptor.height ?? 0,\r\n segments: descriptor.segments,\r\n path: descriptor.path ?? null,\r\n };\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/render/descriptors/text.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmC,qBAAqB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAC7H,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAE1E;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AA8CtC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAoB;IACnD,OAAO,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI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C,KAAK,IAAI,CAAC;QAC5B,GAAG,EAAE,UAAU,CAAC,GAAG,IAAI,CAAC;QACxB,KAAK,EAAE,iBAAiB,CAAC,KAAK,CAAC;QAC/B,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,EAAE;QAC3B,QAAQ,EAAE,UAAU,CAAC,QAAQ,IAAI,EAAE;QACnC,UAAU,EAAE,iBAAiB,CAAC,UAAU,CAAC;QACzC,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,GAAG;QACxC,SAAS,EAAE,UAAU,CAAC,SAAS,IAAI,QAAQ;QAC3C,aAAa,EAAE,UAAU,CAAC,aAAa,IAAI,CAAC;QAC5C,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,CAAC;QACtC,SAAS,EAAE,UAAU,CAAC,SAAS,IAAI,QAAQ;QAC3C,aAAa,EAAE,UAAU,CAAC,aAAa,IAAI,QAAQ;QACnD,cAAc,EAAE,UAAU,CAAC,cAAc,IAAI,MAAM;QACnD,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,KAAK;QAC9B,WAAW,EAAE,UAAU,CAAC,WAAW,IAAI,EAAE;QACzC,KAAK,EAAE,UAAU,CAAC,KAAK,IAAI,CAAC;QAC5B,MAAM,EAAE,UAAU,CAAC,MAAM,IAAI,CAAC;QAC9B,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,IAAI;KAChC,CAAC;AACN,CAAC","sourcesContent":["import type { FontStyle, TextAlign, TextDecoration, VerticalAlign } from \"@/attributes/text/types\";\r\nimport { FillResolved } from \"@/attributes/shape/fill/union\";\r\nimport { StrokeResolved } from \"@/attributes/shape/stroke/stroke\";\r\nimport { PathData } from \"./path\";\r\nimport { ShapeAlignmentInput, ShapeState, resolveShapeAlignment, resolveShapePivot, stripShapeAlignmentKeys } from \"./shape\";\r\nimport { hostTextFamily } from \"@/components/builtins/text/text-defaults\";\r\n\r\n/**\r\n * The size a segmented block's pieces shape at on an `'autofit'` node: the\r\n * size the layout probes with, since no single piece can be asked for the\r\n * size the block settles on.\r\n */\r\nexport const AUTOFIT_PROBE_SIZE = 100;\r\n\r\n/**\r\n * One contiguous piece of a Text node split at run boundaries. Pieces\r\n * carry their effective shaping inputs (`text` plus the five font fields) and\r\n * draw-time overrides applied per shaped run: `opacity` folded into the paint\r\n * alpha, an optional `fill`/`stroke` override (falls back to the node's when\r\n * omitted), and a transform applied about the run's centered position.\r\n *\r\n * Present only when a Text node has styled runs or a reveal window; otherwise\r\n * the node renders as a single string with no segments.\r\n *\r\n * **Every shaping field is stated, none inherited at draw time.** `fontFamily`,\r\n * `fontSize` and `fontStyle` joined `fontWeight` and `letterSpacing` here so a\r\n * run can change its *face* and not only its weight — which is\r\n * what an editor built on this needs to offer per-character styling at all. The\r\n * paragraph builder already takes all five per run (it is what `RichText` sets),\r\n * so the cost of the three is a wider segment and nothing else.\r\n *\r\n * They are optional only so an older caller's segments still lay out: absent\r\n * means \"the node's own\", resolved where the paragraph is built rather than\r\n * left for the renderer to guess.\r\n */\r\nexport interface TextSegment {\r\n text: string;\r\n /** Override family for this piece; falls back to the node's when undefined. */\r\n fontFamily?: string;\r\n /** Override size for this piece; falls back to the node's when undefined. */\r\n fontSize?: number;\r\n /** Override slant for this piece; falls back to the node's when undefined. */\r\n fontStyle?: FontStyle;\r\n fontWeight: number;\r\n letterSpacing: number;\r\n /** Override decoration for this piece; falls back to the node's when undefined. */\r\n textDecoration?: TextDecoration;\r\n opacity: number;\r\n x: number;\r\n y: number;\r\n scale: number;\r\n rotation: number;\r\n /** Override fill for this piece; falls back to the node's fill when undefined. */\r\n fill?: FillResolved[];\r\n /** Override stroke for this piece; falls back to the node's stroke when undefined. */\r\n stroke?: StrokeResolved[];\r\n}\r\n\r\n/**\r\n * Whether `segment` only *styles* its characters — no transform of its own.\r\n *\r\n * The caret model can describe a segmented block exactly as long as this holds\r\n * of every piece: differently-styled runs are still one paragraph, laid out and\r\n * measured together, so the shaper's own rects for each character are where the glyphs\r\n * are. A piece that is *moved*, turned or scaled about its own centre is not in\r\n * that paragraph's space any more, and a slot measured from it would point at\r\n * where the character would have been. See `textBlockLayout`, which is the one\r\n * caller and turns a false here into \"no caret model for this shape\".\r\n */\r\nexport function isStyleOnlySegment(segment: TextSegment): boolean {\r\n return segment.x === 0 && segment.y === 0\r\n && segment.scale === 1 && segment.rotation === 0;\r\n}\r\n\r\nexport interface TextState extends ShapeState {\r\n text: string;\r\n /**\r\n * A named typography preset to shape against — `theme.typography`'s key, the\r\n * same one a `Text` node's `variant` prop selects.\r\n *\r\n * A node reads its variant once, at bind; a drawn op has no bind step, so it\r\n * is resolved at draw alongside the inherited defaults (see\r\n * `applyGraphicsTextDefaults`). It sits *between* the two: above the\r\n * enclosing `<DefaultTextStyle>`, below anything the op states itself.\r\n *\r\n * Optional, and unresolved names are ignored rather than an error — a scene\r\n * that renames a preset should lose the styling, not fail to draw.\r\n */\r\n variant?: string;\r\n fontSize: number | 'autofit';\r\n fontFamily: string;\r\n fontWeight: number;\r\n fontStyle: FontStyle;\r\n letterSpacing: number;\r\n lineHeight: number;\r\n textAlign: TextAlign;\r\n /** Where the block sits in a box taller or shorter than it; only a `height` gives it one. */\r\n verticalAlign: VerticalAlign;\r\n textDecoration: TextDecoration;\r\n wrap: boolean;\r\n minFontSize: number;\r\n width: number;\r\n height: number;\r\n /**\r\n * Per-piece overrides when the node has styled runs. When set,\r\n * the renderer shapes these pieces together (one paragraph) and paints each\r\n * shaped run with its piece's overrides instead of the node's single fill.\r\n */\r\n segments?: TextSegment[];\r\n /**\r\n * When set, the text is wrapped around this path (text-on-path) instead of\r\n * laid out as straight lines: each glyph is positioned and rotated to follow\r\n * the path, centered on its baseline, and glyphs past the path end are\r\n * clipped. Mutually exclusive with `segments` in v1.\r\n */\r\n path?: PathData | null;\r\n}\r\n\r\n\r\n/**\r\n * The family this text is set in — the last rung of the cascade, and the only\r\n * one that can refuse.\r\n *\r\n * It used to fall back to `\"Arial\"`, which is the wrong shape of answer for a\r\n * renderer whose whole job is that the picture is the one that was asked for:\r\n * substituting a face the *engine* picked produces text in a typeface the author\r\n * never chose, at metrics they never measured, in a frame that looks finished,\r\n * and hides a font that was never declared and so never loaded.\r\n *\r\n * What it falls back to instead is {@link hostTextFamily} — a face the\r\n * **application** named, once, at its composition root, out of the fonts it\r\n * actually vendors. That is a different bargain: a host that ships a typeface\r\n * registers it in every manifest, so a chart axis that nobody styled comes out\r\n * in it and paints glyphs, while the engine still refuses to invent a face of\r\n * its own. A host that declares nothing gets the error below, which is the right\r\n * answer for a headless render whose fonts all come from a manifest.\r\n *\r\n * By the time an op reaches here the whole ladder above has been walked — the op\r\n * or prop itself, a `variant` preset, the enclosing `<DefaultTextStyle>`, then\r\n * the theme's `default` typography preset — so this is only ever reached when\r\n * every one of them was silent. The message names them because \"no font family\"\r\n * is not actionable and \"set one on the text, on a DefaultTextStyle, or as the\r\n * theme's default preset\" is.\r\n *\r\n * Exported so the **measure** path enforces the same policy from the same\r\n * definition. Shaping a paragraph to measure it happens before any op is\r\n * validated, and the shaper reads `.length` off every family name — so text with no\r\n * family used to die inside the wasm with `Cannot read properties of undefined`,\r\n * naming no scene, node or prop, while the identical case at draw time produced\r\n * the message above. One policy, two verdicts, and the useless one came first.\r\n */\r\nexport function requireFontFamily(descriptor: { fontFamily?: string; text?: string }): string {\r\n const family = descriptor.fontFamily;\r\n if (typeof family === \"string\" && family !== \"\") return family;\r\n const host = hostTextFamily();\r\n if (host !== \"\") return host;\r\n const text = descriptor.text ? ` drawing \"${descriptor.text.slice(0, 32)}\"` : \"\";\r\n throw new Error(\r\n `Text${text} has no fontFamily. Set one on the text itself, on an `\r\n + `enclosing <DefaultTextStyle>, or as the theme's \\`default\\` typography `\r\n + `preset — there is no fallback face.`,\r\n );\r\n}\r\n\r\nexport function withTextDescriptor(descriptor: Partial<TextState> & ShapeAlignmentInput): TextState {\r\n const width = descriptor.width ?? 0;\r\n const height = descriptor.height ?? 0;\r\n const { x, y, pivot } = resolveShapeAlignment(descriptor, width, height);\r\n return {\r\n ...stripShapeAlignmentKeys(descriptor),\r\n opacity: descriptor.opacity ?? 1,\r\n rotation: descriptor.rotation ?? 0,\r\n scale: descriptor.scale ?? 1,\r\n x,\r\n y,\r\n start: descriptor.start ?? 0,\r\n end: descriptor.end ?? 1,\r\n pivot: resolveShapePivot(pivot),\r\n text: descriptor.text ?? \"\",\r\n fontSize: descriptor.fontSize ?? 48,\r\n fontFamily: requireFontFamily(descriptor),\r\n fontWeight: descriptor.fontWeight ?? 400,\r\n fontStyle: descriptor.fontStyle ?? 'normal',\r\n letterSpacing: descriptor.letterSpacing ?? 0,\r\n lineHeight: descriptor.lineHeight ?? 0,\r\n textAlign: descriptor.textAlign ?? 'center',\r\n verticalAlign: descriptor.verticalAlign ?? 'center',\r\n textDecoration: descriptor.textDecoration ?? 'none',\r\n wrap: descriptor.wrap ?? false,\r\n minFontSize: descriptor.minFontSize ?? 12,\r\n width: descriptor.width ?? 0,\r\n height: descriptor.height ?? 0,\r\n segments: descriptor.segments,\r\n path: descriptor.path ?? null,\r\n };\r\n}\r\n"]}
|
package/dist/render/index.d.ts
CHANGED
|
@@ -22,4 +22,6 @@ export { caretCount } from './text-layout.js';
|
|
|
22
22
|
export type { TextBlockLayout, TextBlockLine, TextBlockSource } from './text-layout.js';
|
|
23
23
|
/** @internal */ export { NullRenderContext } from './null-render-context.js';
|
|
24
24
|
export type { RenderSurface } from './surface.js';
|
|
25
|
+
export { RenderBackendError, isFatalRenderIssue, renderIssueKey, toRenderIssue } from './render-issue.js';
|
|
26
|
+
export type { RenderIssue, RenderIssueKind } from './render-issue.js';
|
|
25
27
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAAA,gBAAgB,CAAC,cAAc,uBAAuB,CAAC;AACvD,gBAAgB,CAAC,cAAc,oBAAoB,CAA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EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACnI,gBAAgB,CAAC,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACnF,gBAAgB,CAAC,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG3E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrF,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE3E,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACvG,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/render/index.js
CHANGED
|
@@ -17,4 +17,5 @@
|
|
|
17
17
|
// `getTextLayout`, so they are part of the editor-facing surface.
|
|
18
18
|
export { caretCount } from './text-layout.js';
|
|
19
19
|
/** @internal */ export { NullRenderContext } from './null-render-context.js';
|
|
20
|
+
export { RenderBackendError, isFatalRenderIssue, renderIssueKey, toRenderIssue } from './render-issue.js';
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
package/dist/render/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAAA,gBAAgB,CAAC,cAAc,uBAAuB,CAAC;AACvD,gBAAgB,CAAC,cAAc,oBAAoB,CAAC;AAEpD,gBAAgB,CAAC,cAAc,oBAAoB,CAAC;AACpD,gBAAgB,CAAC,cAAc,wBAAwB,CAAC;AAGxD,gBAAgB,CAAC,cAAc,yBAAyB,CAAC;AACzD,gBAAgB,CAAC,cAAc,qBAAqB,CAAC;AAErD,gBAAgB,CAAC,cAAc,oBAAoB,CAAC;AACpD,gBAAgB,CAAC,cAAc,4BAA4B,CAAC;AAC5D,gBAAgB,CAAC,cAAc,oBAAoB,CAAC;AACpD,gBAAgB,CAAC,cAAc,uBAAuB,CAAC;AACvD,gBAAgB,CAAC,cAAc,wBAAwB,CAAC;AAExD,gBAAgB,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG3D,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE/C,gBAAgB,CAAC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAIjK,gBAAgB,CAAC,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAEnF,iFAAiF;AACjF,kEAAkE;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["/** @internal */ export * from './descriptors/ellipse';\r\n/** @internal */ export * from './descriptors/rect';\r\n\r\n/** @internal */ export * from './descriptors/text';\r\n/** @internal */ export * from './descriptors/richtext';\r\n\r\n\r\n/** @internal */ export * from './descriptors/transform';\r\n/** @internal */ export * from './descriptors/shape';\r\n\r\n/** @internal */ export * from './descriptors/path';\r\n/** @internal */ export * from './descriptors/path-builder';\r\n/** @internal */ export * from './descriptors/line';\r\n/** @internal */ export * from './descriptors/polygon';\r\n/** @internal */ export * from './descriptors/polygram';\r\n\r\n/** @internal */ export { Graphics2D } from './graphics2d';\r\n/** @internal */ export type { GraphicsOp, GraphicsShapeOp, GraphicsTransform } from './graphics2d';\r\n\r\n/** @internal */ export { Clip } from './clip';\r\n/** @internal */ export type { ClipOp, ClipShapeOp } from './clip';\r\n/** @internal */ export { containsClip, containsOps, pointInPolygon, nearPolyline, distanceToSegment, polygonVertices, polygramVertices } from './clip-contains';\r\n\r\n/** @internal */ export type { RenderContext2D, RenderPass2D } from './render-context2d';\r\n/** @internal */ export type { SpaceRect, SpaceRects, NodeRenderState, EffectTarget, RasterizedSurface } from './render-context2d';\r\n/** @internal */ export { CanvasRenderContext2D } from './canvas-render-context2d';\r\n/** @internal */ export type { MeasureContext2D } from \"./measure-context\";\r\n// Public rather than internal: a host drawing its own text caret reads these off\r\n// `getTextLayout`, so they are part of the editor-facing surface.\r\nexport { caretCount } from './text-layout';\r\nexport type { TextBlockLayout, TextBlockLine, TextBlockSource } from './text-layout';\r\n/** @internal */ export { NullRenderContext } from './null-render-context';\r\n\r\nexport type { RenderSurface } from './surface';\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAAA,gBAAgB,CAAC,cAAc,uBAAuB,CAAC;AACvD,gBAAgB,CAAC,cAAc,oBAAoB,CAAC;AAEpD,gBAAgB,CAAC,cAAc,oBAAoB,CAAC;AACpD,gBAAgB,CAAC,cAAc,wBAAwB,CAAC;AAGxD,gBAAgB,CAAC,cAAc,yBAAyB,CAAC;AACzD,gBAAgB,CAAC,cAAc,qBAAqB,CAAC;AAErD,gBAAgB,CAAC,cAAc,oBAAoB,CAAC;AACpD,gBAAgB,CAAC,cAAc,4BAA4B,CAAC;AAC5D,gBAAgB,CAAC,cAAc,oBAAoB,CAAC;AACpD,gBAAgB,CAAC,cAAc,uBAAuB,CAAC;AACvD,gBAAgB,CAAC,cAAc,wBAAwB,CAAC;AAExD,gBAAgB,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG3D,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE/C,gBAAgB,CAAC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAIjK,gBAAgB,CAAC,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAEnF,iFAAiF;AACjF,kEAAkE;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG3E,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["/** @internal */ export * from './descriptors/ellipse';\r\n/** @internal */ export * from './descriptors/rect';\r\n\r\n/** @internal */ export * from './descriptors/text';\r\n/** @internal */ export * from './descriptors/richtext';\r\n\r\n\r\n/** @internal */ export * from './descriptors/transform';\r\n/** @internal */ export * from './descriptors/shape';\r\n\r\n/** @internal */ export * from './descriptors/path';\r\n/** @internal */ export * from './descriptors/path-builder';\r\n/** @internal */ export * from './descriptors/line';\r\n/** @internal */ export * from './descriptors/polygon';\r\n/** @internal */ export * from './descriptors/polygram';\r\n\r\n/** @internal */ export { Graphics2D } from './graphics2d';\r\n/** @internal */ export type { GraphicsOp, GraphicsShapeOp, GraphicsTransform } from './graphics2d';\r\n\r\n/** @internal */ export { Clip } from './clip';\r\n/** @internal */ export type { ClipOp, ClipShapeOp } from './clip';\r\n/** @internal */ export { containsClip, containsOps, pointInPolygon, nearPolyline, distanceToSegment, polygonVertices, polygramVertices } from './clip-contains';\r\n\r\n/** @internal */ export type { RenderContext2D, RenderPass2D } from './render-context2d';\r\n/** @internal */ export type { SpaceRect, SpaceRects, NodeRenderState, EffectTarget, RasterizedSurface } from './render-context2d';\r\n/** @internal */ export { CanvasRenderContext2D } from './canvas-render-context2d';\r\n/** @internal */ export type { MeasureContext2D } from \"./measure-context\";\r\n// Public rather than internal: a host drawing its own text caret reads these off\r\n// `getTextLayout`, so they are part of the editor-facing surface.\r\nexport { caretCount } from './text-layout';\r\nexport type { TextBlockLayout, TextBlockLine, TextBlockSource } from './text-layout';\r\n/** @internal */ export { NullRenderContext } from './null-render-context';\r\n\r\nexport type { RenderSurface } from './surface';\r\nexport { RenderBackendError, isFatalRenderIssue, renderIssueKey, toRenderIssue } from './render-issue';\r\nexport type { RenderIssue, RenderIssueKind } from './render-issue';\r\n"]}
|
|
@@ -210,7 +210,7 @@ export interface RenderContext2D extends MeasureContext2D {
|
|
|
210
210
|
* - `'backdrop'` — warps/filters the canvas content already painted *beneath*
|
|
211
211
|
* the node, clipped to the active silhouette clip, so the node's own edges
|
|
212
212
|
* stay sharp (Figma-style). Used for backdrop-flagged filters (blur,
|
|
213
|
-
* grayscale, pixelate, …), magnify, backdrop posterize, and backdrop
|
|
213
|
+
* grayscale, pixelate, …), magnify, backdrop posterize, and backdrop shader.
|
|
214
214
|
*
|
|
215
215
|
* The renderer decides per effect whether to compose it as an `ImageFilter`
|
|
216
216
|
* or run it as a snapshot/redraw shader — callers never route by effect type.
|