@rafaelaugusto/jolt 0.1.0-beta.9 → 0.1.0-rc.10
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/README.md +171 -23
- package/dist/animate.d.ts +25 -4
- package/dist/animate.d.ts.map +1 -1
- package/dist/animate.js +87 -31
- package/dist/animate.js.map +1 -1
- package/dist/blur/index.d.ts +6 -0
- package/dist/blur/index.d.ts.map +1 -0
- package/dist/blur/index.js +196 -0
- package/dist/blur/index.js.map +1 -0
- package/dist/blur/native.d.ts +17 -0
- package/dist/blur/native.d.ts.map +1 -0
- package/dist/blur/native.js +44 -0
- package/dist/blur/native.js.map +1 -0
- package/dist/blur/types.d.ts +32 -0
- package/dist/blur/types.d.ts.map +1 -0
- package/dist/blur/types.js +2 -0
- package/dist/blur/types.js.map +1 -0
- package/dist/bottom-sheet/geometry.d.ts +3 -0
- package/dist/bottom-sheet/geometry.d.ts.map +1 -0
- package/dist/bottom-sheet/geometry.js +2 -0
- package/dist/bottom-sheet/geometry.js.map +1 -0
- package/dist/bottom-sheet/index.d.ts +66 -0
- package/dist/bottom-sheet/index.d.ts.map +1 -0
- package/dist/bottom-sheet/index.js +512 -0
- package/dist/bottom-sheet/index.js.map +1 -0
- package/dist/bottom-sheet/native.d.ts +16 -0
- package/dist/bottom-sheet/native.d.ts.map +1 -0
- package/dist/bottom-sheet/native.js +179 -0
- package/dist/bottom-sheet/native.js.map +1 -0
- package/dist/color.d.ts +2 -4
- package/dist/color.d.ts.map +1 -1
- package/dist/color.js +1 -41
- package/dist/color.js.map +1 -1
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +40 -1
- package/dist/config.js.map +1 -1
- package/dist/core/arrival.d.ts +19 -0
- package/dist/core/arrival.d.ts.map +1 -0
- package/dist/core/arrival.js +19 -0
- package/dist/core/arrival.js.map +1 -0
- package/dist/core/circle-math.d.ts +90 -0
- package/dist/core/circle-math.d.ts.map +1 -0
- package/dist/core/circle-math.js +395 -0
- package/dist/core/circle-math.js.map +1 -0
- package/dist/core/color.d.ts +5 -0
- package/dist/core/color.d.ts.map +1 -0
- package/dist/core/color.js +42 -0
- package/dist/core/color.js.map +1 -0
- package/dist/core/decay.d.ts +12 -0
- package/dist/core/decay.d.ts.map +1 -0
- package/dist/core/decay.js +29 -0
- package/dist/core/decay.js.map +1 -0
- package/dist/core/decoration.d.ts +5 -0
- package/dist/core/decoration.d.ts.map +1 -0
- package/dist/core/decoration.js +22 -0
- package/dist/core/decoration.js.map +1 -0
- package/dist/core/drag-physics.d.ts +25 -0
- package/dist/core/drag-physics.d.ts.map +1 -0
- package/dist/core/drag-physics.js +75 -0
- package/dist/core/drag-physics.js.map +1 -0
- package/dist/core/driver.d.ts +41 -0
- package/dist/core/driver.d.ts.map +1 -0
- package/dist/core/driver.js +2 -0
- package/dist/core/driver.js.map +1 -0
- package/dist/core/easing.d.ts +10 -0
- package/dist/core/easing.d.ts.map +1 -0
- package/dist/core/easing.js +88 -0
- package/dist/core/easing.js.map +1 -0
- package/dist/core/gesture-math.d.ts +22 -0
- package/dist/core/gesture-math.d.ts.map +1 -0
- package/dist/core/gesture-math.js +45 -0
- package/dist/core/gesture-math.js.map +1 -0
- package/dist/core/gradient.d.ts +16 -0
- package/dist/core/gradient.d.ts.map +1 -0
- package/dist/core/gradient.js +27 -0
- package/dist/core/gradient.js.map +1 -0
- package/dist/core/gravity.d.ts +13 -0
- package/dist/core/gravity.d.ts.map +1 -0
- package/dist/core/gravity.js +84 -0
- package/dist/core/gravity.js.map +1 -0
- package/dist/core/haptic.d.ts +10 -0
- package/dist/core/haptic.d.ts.map +1 -0
- package/dist/core/haptic.js +19 -0
- package/dist/core/haptic.js.map +1 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +6 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/liquid-grid.d.ts +3 -0
- package/dist/core/liquid-grid.d.ts.map +1 -0
- package/dist/core/liquid-grid.js +24 -0
- package/dist/core/liquid-grid.js.map +1 -0
- package/dist/core/numeric-map.d.ts +11 -0
- package/dist/core/numeric-map.d.ts.map +1 -0
- package/dist/core/numeric-map.js +48 -0
- package/dist/core/numeric-map.js.map +1 -0
- package/dist/core/ownership.d.ts +7 -0
- package/dist/core/ownership.d.ts.map +1 -0
- package/dist/core/ownership.js +23 -0
- package/dist/core/ownership.js.map +1 -0
- package/dist/core/playback.d.ts +49 -0
- package/dist/core/playback.d.ts.map +1 -0
- package/dist/core/playback.js +58 -0
- package/dist/core/playback.js.map +1 -0
- package/dist/core/presets.d.ts +298 -0
- package/dist/core/presets.d.ts.map +1 -0
- package/dist/core/presets.js +127 -0
- package/dist/core/presets.js.map +1 -0
- package/dist/core/properties.d.ts +8 -0
- package/dist/core/properties.d.ts.map +1 -0
- package/dist/core/properties.js +33 -0
- package/dist/core/properties.js.map +1 -0
- package/dist/core/reorder.d.ts +12 -0
- package/dist/core/reorder.d.ts.map +1 -0
- package/dist/core/reorder.js +30 -0
- package/dist/core/reorder.js.map +1 -0
- package/dist/core/roll-diff.d.ts +22 -0
- package/dist/core/roll-diff.d.ts.map +1 -0
- package/dist/core/roll-diff.js +36 -0
- package/dist/core/roll-diff.js.map +1 -0
- package/dist/core/sampling.d.ts +35 -0
- package/dist/core/sampling.d.ts.map +1 -0
- package/dist/core/sampling.js +123 -0
- package/dist/core/sampling.js.map +1 -0
- package/dist/core/scroll-header.d.ts +19 -0
- package/dist/core/scroll-header.d.ts.map +1 -0
- package/dist/core/scroll-header.js +56 -0
- package/dist/core/scroll-header.js.map +1 -0
- package/dist/core/sequence.d.ts +32 -0
- package/dist/core/sequence.d.ts.map +1 -0
- package/dist/core/sequence.js +367 -0
- package/dist/core/sequence.js.map +1 -0
- package/dist/core/shape-path.d.ts +10 -0
- package/dist/core/shape-path.d.ts.map +1 -0
- package/dist/core/shape-path.js +106 -0
- package/dist/core/shape-path.js.map +1 -0
- package/dist/core/sheet-geometry.d.ts +23 -0
- package/dist/core/sheet-geometry.d.ts.map +1 -0
- package/dist/core/sheet-geometry.js +55 -0
- package/dist/core/sheet-geometry.js.map +1 -0
- package/dist/core/spring.d.ts +31 -0
- package/dist/core/spring.d.ts.map +1 -0
- package/dist/core/spring.js +80 -0
- package/dist/core/spring.js.map +1 -0
- package/dist/core/state-transition.d.ts +16 -0
- package/dist/core/state-transition.d.ts.map +1 -0
- package/dist/core/state-transition.js +66 -0
- package/dist/core/state-transition.js.map +1 -0
- package/dist/core/svg-path.d.ts +32 -0
- package/dist/core/svg-path.d.ts.map +1 -0
- package/dist/core/svg-path.js +282 -0
- package/dist/core/svg-path.js.map +1 -0
- package/dist/core/track.d.ts +38 -0
- package/dist/core/track.d.ts.map +1 -0
- package/dist/core/track.js +476 -0
- package/dist/core/track.js.map +1 -0
- package/dist/core/transition.d.ts +116 -0
- package/dist/core/transition.d.ts.map +1 -0
- package/dist/core/transition.js +211 -0
- package/dist/core/transition.js.map +1 -0
- package/dist/decay.d.ts +1 -10
- package/dist/decay.d.ts.map +1 -1
- package/dist/decay.js +1 -21
- package/dist/decay.js.map +1 -1
- package/dist/decoration.d.ts +2 -5
- package/dist/decoration.d.ts.map +1 -1
- package/dist/decoration.js +2 -21
- package/dist/decoration.js.map +1 -1
- package/dist/drag-physics.d.ts +1 -19
- package/dist/drag-physics.d.ts.map +1 -1
- package/dist/drag-physics.js +1 -74
- package/dist/drag-physics.js.map +1 -1
- package/dist/drag.d.ts +17 -3
- package/dist/drag.d.ts.map +1 -1
- package/dist/drag.js +34 -11
- package/dist/drag.js.map +1 -1
- package/dist/driver/android-gradient.d.ts +5 -0
- package/dist/driver/android-gradient.d.ts.map +1 -0
- package/dist/driver/android-gradient.js +99 -0
- package/dist/driver/android-gradient.js.map +1 -0
- package/dist/driver/android-particles.d.ts +6 -0
- package/dist/driver/android-particles.d.ts.map +1 -0
- package/dist/driver/android-particles.js +93 -0
- package/dist/driver/android-particles.js.map +1 -0
- package/dist/driver/android.d.ts.map +1 -1
- package/dist/driver/android.js +51 -8
- package/dist/driver/android.js.map +1 -1
- package/dist/driver/frame.d.ts +3 -0
- package/dist/driver/frame.d.ts.map +1 -0
- package/dist/driver/frame.js +7 -0
- package/dist/driver/frame.js.map +1 -0
- package/dist/driver/index.d.ts +3 -34
- package/dist/driver/index.d.ts.map +1 -1
- package/dist/driver/index.js.map +1 -1
- package/dist/driver/ios-gradient.d.ts +5 -0
- package/dist/driver/ios-gradient.d.ts.map +1 -0
- package/dist/driver/ios-gradient.js +131 -0
- package/dist/driver/ios-gradient.js.map +1 -0
- package/dist/driver/ios-scroll-delegate.d.ts +4 -0
- package/dist/driver/ios-scroll-delegate.d.ts.map +1 -0
- package/dist/driver/ios-scroll-delegate.js +26 -0
- package/dist/driver/ios-scroll-delegate.js.map +1 -0
- package/dist/driver/ios.d.ts.map +1 -1
- package/dist/driver/ios.js +9 -0
- package/dist/driver/ios.js.map +1 -1
- package/dist/easing.d.ts +1 -7
- package/dist/easing.d.ts.map +1 -1
- package/dist/easing.js +1 -70
- package/dist/easing.js.map +1 -1
- package/dist/engine.d.ts +33 -30
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +210 -71
- package/dist/engine.js.map +1 -1
- package/dist/gesture-native.d.ts +28 -0
- package/dist/gesture-native.d.ts.map +1 -0
- package/dist/gesture-native.js +61 -0
- package/dist/gesture-native.js.map +1 -0
- package/dist/gestures/index.d.ts +69 -0
- package/dist/gestures/index.d.ts.map +1 -0
- package/dist/gestures/index.js +262 -0
- package/dist/gestures/index.js.map +1 -0
- package/dist/glass/index.d.ts +55 -0
- package/dist/glass/index.d.ts.map +1 -0
- package/dist/glass/index.js +205 -0
- package/dist/glass/index.js.map +1 -0
- package/dist/gradient-binding.d.ts +37 -0
- package/dist/gradient-binding.d.ts.map +1 -0
- package/dist/gradient-binding.js +108 -0
- package/dist/gradient-binding.js.map +1 -0
- package/dist/gradient.d.ts +98 -0
- package/dist/gradient.d.ts.map +1 -0
- package/dist/gradient.js +514 -0
- package/dist/gradient.js.map +1 -0
- package/dist/gravity.d.ts +2 -0
- package/dist/gravity.d.ts.map +1 -0
- package/dist/gravity.js +2 -0
- package/dist/gravity.js.map +1 -0
- package/dist/haptics.d.ts +3 -9
- package/dist/haptics.d.ts.map +1 -1
- package/dist/haptics.js +102 -46
- package/dist/haptics.js.map +1 -1
- package/dist/image-effect.d.ts +1 -0
- package/dist/image-effect.d.ts.map +1 -1
- package/dist/image-effect.js +10 -2
- package/dist/image-effect.js.map +1 -1
- package/dist/index.d.ts +22 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/inspector/index.d.ts +86 -0
- package/dist/inspector/index.d.ts.map +1 -0
- package/dist/inspector/index.js +419 -0
- package/dist/inspector/index.js.map +1 -0
- package/dist/inspector/plot.d.ts +4 -0
- package/dist/inspector/plot.d.ts.map +1 -0
- package/dist/inspector/plot.js +23 -0
- package/dist/inspector/plot.js.map +1 -0
- package/dist/inspector/probe.d.ts +19 -0
- package/dist/inspector/probe.d.ts.map +1 -0
- package/dist/inspector/probe.js +37 -0
- package/dist/inspector/probe.js.map +1 -0
- package/dist/inspector/tuning.d.ts +19 -0
- package/dist/inspector/tuning.d.ts.map +1 -0
- package/dist/inspector/tuning.js +37 -0
- package/dist/inspector/tuning.js.map +1 -0
- package/dist/interactive-navigation/index.d.ts +46 -0
- package/dist/interactive-navigation/index.d.ts.map +1 -0
- package/dist/interactive-navigation/index.js +351 -0
- package/dist/interactive-navigation/index.js.map +1 -0
- package/dist/interactive-navigation/modal.d.ts +34 -0
- package/dist/interactive-navigation/modal.d.ts.map +1 -0
- package/dist/interactive-navigation/modal.js +253 -0
- package/dist/interactive-navigation/modal.js.map +1 -0
- package/dist/keyboard.d.ts +24 -0
- package/dist/keyboard.d.ts.map +1 -1
- package/dist/keyboard.js +199 -6
- package/dist/keyboard.js.map +1 -1
- package/dist/liquid-grid.d.ts +1 -2
- package/dist/liquid-grid.d.ts.map +1 -1
- package/dist/liquid-grid.js +1 -23
- package/dist/liquid-grid.js.map +1 -1
- package/dist/live-paint.d.ts +11 -0
- package/dist/live-paint.d.ts.map +1 -0
- package/dist/live-paint.js +66 -0
- package/dist/live-paint.js.map +1 -0
- package/dist/live-spring-driver.d.ts +63 -0
- package/dist/live-spring-driver.d.ts.map +1 -0
- package/dist/live-spring-driver.js +157 -0
- package/dist/live-spring-driver.js.map +1 -0
- package/dist/mixer.d.ts +61 -0
- package/dist/mixer.d.ts.map +1 -0
- package/dist/mixer.js +323 -0
- package/dist/mixer.js.map +1 -0
- package/dist/motion-scope.d.ts +10 -3
- package/dist/motion-scope.d.ts.map +1 -1
- package/dist/motion-scope.js +103 -35
- package/dist/motion-scope.js.map +1 -1
- package/dist/motion-states.d.ts +14 -7
- package/dist/motion-states.d.ts.map +1 -1
- package/dist/motion-states.js +136 -74
- package/dist/motion-states.js.map +1 -1
- package/dist/motion-value.d.ts +241 -0
- package/dist/motion-value.d.ts.map +1 -0
- package/dist/motion-value.js +1276 -0
- package/dist/motion-value.js.map +1 -0
- package/dist/native/index.d.ts +10 -0
- package/dist/native/index.d.ts.map +1 -0
- package/dist/native/index.js +6 -0
- package/dist/native/index.js.map +1 -0
- package/dist/native-properties.d.ts +28 -0
- package/dist/native-properties.d.ts.map +1 -0
- package/dist/native-properties.js +154 -0
- package/dist/native-properties.js.map +1 -0
- package/dist/native-property-driver.d.ts +19 -0
- package/dist/native-property-driver.d.ts.map +1 -0
- package/dist/native-property-driver.js +69 -0
- package/dist/native-property-driver.js.map +1 -0
- package/dist/native-property.d.ts +37 -0
- package/dist/native-property.d.ts.map +1 -0
- package/dist/native-property.js +285 -0
- package/dist/native-property.js.map +1 -0
- package/dist/particles.d.ts +5 -2
- package/dist/particles.d.ts.map +1 -1
- package/dist/particles.js +16 -10
- package/dist/particles.js.map +1 -1
- package/dist/path.d.ts.map +1 -1
- package/dist/path.js +2 -2
- package/dist/path.js.map +1 -1
- package/dist/physics/index.d.ts +164 -0
- package/dist/physics/index.d.ts.map +1 -0
- package/dist/physics/index.js +399 -0
- package/dist/physics/index.js.map +1 -0
- package/dist/physics/native.d.ts +59 -0
- package/dist/physics/native.d.ts.map +1 -0
- package/dist/physics/native.js +74 -0
- package/dist/physics/native.js.map +1 -0
- package/dist/playback-group.d.ts.map +1 -1
- package/dist/playback-group.js +17 -1
- package/dist/playback-group.js.map +1 -1
- package/dist/playback.d.ts +1 -24
- package/dist/playback.d.ts.map +1 -1
- package/dist/playback.js +1 -34
- package/dist/playback.js.map +1 -1
- package/dist/predictive-back/index.d.ts +45 -0
- package/dist/predictive-back/index.d.ts.map +1 -0
- package/dist/predictive-back/index.js +220 -0
- package/dist/predictive-back/index.js.map +1 -0
- package/dist/predictive-back/presentation.d.ts +4 -0
- package/dist/predictive-back/presentation.d.ts.map +1 -0
- package/dist/predictive-back/presentation.js +3 -0
- package/dist/predictive-back/presentation.js.map +1 -0
- package/dist/presets.d.ts +2 -297
- package/dist/presets.d.ts.map +1 -1
- package/dist/presets.js +2 -125
- package/dist/presets.js.map +1 -1
- package/dist/press.d.ts.map +1 -1
- package/dist/press.js +11 -2
- package/dist/press.js.map +1 -1
- package/dist/properties.d.ts +2 -6
- package/dist/properties.d.ts.map +1 -1
- package/dist/properties.js +3 -33
- package/dist/properties.js.map +1 -1
- package/dist/reorder/handle.d.ts +6 -0
- package/dist/reorder/handle.d.ts.map +1 -0
- package/dist/reorder/handle.js +10 -0
- package/dist/reorder/handle.js.map +1 -0
- package/dist/reorder/index.d.ts +14 -0
- package/dist/reorder/index.d.ts.map +1 -0
- package/dist/reorder/index.js +243 -0
- package/dist/reorder/index.js.map +1 -0
- package/dist/reorder/list-view.d.ts +5 -0
- package/dist/reorder/list-view.d.ts.map +1 -0
- package/dist/reorder/list-view.js +238 -0
- package/dist/reorder/list-view.js.map +1 -0
- package/dist/reorder/model.d.ts +2 -0
- package/dist/reorder/model.d.ts.map +1 -0
- package/dist/reorder/model.js +2 -0
- package/dist/reorder/model.js.map +1 -0
- package/dist/reorder/realized.d.ts +14 -0
- package/dist/reorder/realized.d.ts.map +1 -0
- package/dist/reorder/realized.js +263 -0
- package/dist/reorder/realized.js.map +1 -0
- package/dist/reorder/surface.d.ts +6 -0
- package/dist/reorder/surface.d.ts.map +1 -0
- package/dist/reorder/surface.js +10 -0
- package/dist/reorder/surface.js.map +1 -0
- package/dist/reorder/types.d.ts +94 -0
- package/dist/reorder/types.d.ts.map +1 -0
- package/dist/reorder/types.js +2 -0
- package/dist/reorder/types.js.map +1 -0
- package/dist/roll-diff.d.ts +2 -21
- package/dist/roll-diff.d.ts.map +1 -1
- package/dist/roll-diff.js +1 -35
- package/dist/roll-diff.js.map +1 -1
- package/dist/sampling.d.ts +2 -0
- package/dist/sampling.d.ts.map +1 -0
- package/dist/sampling.js +2 -0
- package/dist/sampling.js.map +1 -0
- package/dist/scene-appearance.d.ts +14 -0
- package/dist/scene-appearance.d.ts.map +1 -0
- package/dist/scene-appearance.js +68 -0
- package/dist/scene-appearance.js.map +1 -0
- package/dist/scene-camera.d.ts +5 -0
- package/dist/scene-camera.d.ts.map +1 -0
- package/dist/scene-camera.js +23 -0
- package/dist/scene-camera.js.map +1 -0
- package/dist/scene-shader.d.ts +18 -0
- package/dist/scene-shader.d.ts.map +1 -0
- package/dist/scene-shader.js +76 -0
- package/dist/scene-shader.js.map +1 -0
- package/dist/scroll-header/geometry.d.ts +2 -0
- package/dist/scroll-header/geometry.d.ts.map +1 -0
- package/dist/scroll-header/geometry.js +2 -0
- package/dist/scroll-header/geometry.js.map +1 -0
- package/dist/scroll-header/index.d.ts +71 -0
- package/dist/scroll-header/index.d.ts.map +1 -0
- package/dist/scroll-header/index.js +627 -0
- package/dist/scroll-header/index.js.map +1 -0
- package/dist/scroll-header/native.d.ts +36 -0
- package/dist/scroll-header/native.d.ts.map +1 -0
- package/dist/scroll-header/native.js +58 -0
- package/dist/scroll-header/native.js.map +1 -0
- package/dist/scroll-header/surface.d.ts +6 -0
- package/dist/scroll-header/surface.d.ts.map +1 -0
- package/dist/scroll-header/surface.js +12 -0
- package/dist/scroll-header/surface.js.map +1 -0
- package/dist/seekable-timeline.d.ts +32 -0
- package/dist/seekable-timeline.d.ts.map +1 -0
- package/dist/seekable-timeline.js +284 -0
- package/dist/seekable-timeline.js.map +1 -0
- package/dist/sensors/index.d.ts +69 -0
- package/dist/sensors/index.d.ts.map +1 -0
- package/dist/sensors/index.js +149 -0
- package/dist/sensors/index.js.map +1 -0
- package/dist/sensors/native.d.ts +20 -0
- package/dist/sensors/native.d.ts.map +1 -0
- package/dist/sensors/native.js +48 -0
- package/dist/sensors/native.js.map +1 -0
- package/dist/sequence.d.ts +24 -0
- package/dist/sequence.d.ts.map +1 -1
- package/dist/sequence.js +25 -204
- package/dist/sequence.js.map +1 -1
- package/dist/shapes/android.d.ts +3 -0
- package/dist/shapes/android.d.ts.map +1 -0
- package/dist/shapes/android.js +51 -0
- package/dist/shapes/android.js.map +1 -0
- package/dist/shapes/index.d.ts +6 -0
- package/dist/shapes/index.d.ts.map +1 -0
- package/dist/shapes/index.js +252 -0
- package/dist/shapes/index.js.map +1 -0
- package/dist/shapes/ios.d.ts +3 -0
- package/dist/shapes/ios.d.ts.map +1 -0
- package/dist/shapes/ios.js +164 -0
- package/dist/shapes/ios.js.map +1 -0
- package/dist/shapes/native.d.ts +18 -0
- package/dist/shapes/native.d.ts.map +1 -0
- package/dist/shapes/native.js +10 -0
- package/dist/shapes/native.js.map +1 -0
- package/dist/shapes/path.d.ts +2 -0
- package/dist/shapes/path.d.ts.map +1 -0
- package/dist/shapes/path.js +2 -0
- package/dist/shapes/path.js.map +1 -0
- package/dist/shapes/types.d.ts +55 -0
- package/dist/shapes/types.d.ts.map +1 -0
- package/dist/shapes/types.js +11 -0
- package/dist/shapes/types.js.map +1 -0
- package/dist/shared-layout/index.d.ts +40 -0
- package/dist/shared-layout/index.d.ts.map +1 -0
- package/dist/shared-layout/index.js +267 -0
- package/dist/shared-layout/index.js.map +1 -0
- package/dist/shared-layout/native.d.ts +15 -0
- package/dist/shared-layout/native.d.ts.map +1 -0
- package/dist/shared-layout/native.js +79 -0
- package/dist/shared-layout/native.js.map +1 -0
- package/dist/shared-layout/timing.d.ts +9 -0
- package/dist/shared-layout/timing.d.ts.map +1 -0
- package/dist/shared-layout/timing.js +68 -0
- package/dist/shared-layout/timing.js.map +1 -0
- package/dist/shared-navigation/entry.d.ts +51 -0
- package/dist/shared-navigation/entry.d.ts.map +1 -0
- package/dist/shared-navigation/entry.js +619 -0
- package/dist/shared-navigation/entry.js.map +1 -0
- package/dist/shared-navigation/index.d.ts +58 -0
- package/dist/shared-navigation/index.d.ts.map +1 -0
- package/dist/shared-navigation/index.js +323 -0
- package/dist/shared-navigation/index.js.map +1 -0
- package/dist/shared-navigation/return-signal.d.ts +16 -0
- package/dist/shared-navigation/return-signal.d.ts.map +1 -0
- package/dist/shared-navigation/return-signal.js +35 -0
- package/dist/shared-navigation/return-signal.js.map +1 -0
- package/dist/shared-navigation/return-target.d.ts +34 -0
- package/dist/shared-navigation/return-target.d.ts.map +1 -0
- package/dist/shared-navigation/return-target.js +218 -0
- package/dist/shared-navigation/return-target.js.map +1 -0
- package/dist/shared-navigation/scope.d.ts +4 -0
- package/dist/shared-navigation/scope.d.ts.map +1 -0
- package/dist/shared-navigation/scope.js +2 -0
- package/dist/shared-navigation/scope.js.map +1 -0
- package/dist/shared-navigation/targets.d.ts +6 -0
- package/dist/shared-navigation/targets.d.ts.map +1 -0
- package/dist/shared-navigation/targets.js +36 -0
- package/dist/shared-navigation/targets.js.map +1 -0
- package/dist/size-layout.d.ts +19 -0
- package/dist/size-layout.d.ts.map +1 -0
- package/dist/size-layout.js +230 -0
- package/dist/size-layout.js.map +1 -0
- package/dist/size.d.ts +19 -0
- package/dist/size.d.ts.map +1 -0
- package/dist/size.js +259 -0
- package/dist/size.js.map +1 -0
- package/dist/spring.d.ts +1 -21
- package/dist/spring.d.ts.map +1 -1
- package/dist/spring.js +1 -53
- package/dist/spring.js.map +1 -1
- package/dist/svg-path.d.ts +1 -13
- package/dist/svg-path.d.ts.map +1 -1
- package/dist/svg-path.js +1 -280
- package/dist/svg-path.js.map +1 -1
- package/dist/testing/clock.d.ts +40 -0
- package/dist/testing/clock.d.ts.map +1 -0
- package/dist/testing/clock.js +116 -0
- package/dist/testing/clock.js.map +1 -0
- package/dist/testing/handoff-recorder.d.ts +8 -0
- package/dist/testing/handoff-recorder.d.ts.map +1 -0
- package/dist/testing/handoff-recorder.js +77 -0
- package/dist/testing/handoff-recorder.js.map +1 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +5 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/native.d.ts +46 -0
- package/dist/testing/native.d.ts.map +1 -0
- package/dist/testing/native.js +313 -0
- package/dist/testing/native.js.map +1 -0
- package/dist/testing/presentation.d.ts +11 -0
- package/dist/testing/presentation.d.ts.map +1 -0
- package/dist/testing/presentation.js +45 -0
- package/dist/testing/presentation.js.map +1 -0
- package/dist/testing/replay.d.ts +39 -0
- package/dist/testing/replay.d.ts.map +1 -0
- package/dist/testing/replay.js +99 -0
- package/dist/testing/replay.js.map +1 -0
- package/dist/testing/scroll-handoff-native.d.ts +10 -0
- package/dist/testing/scroll-handoff-native.d.ts.map +1 -0
- package/dist/testing/scroll-handoff-native.js +151 -0
- package/dist/testing/scroll-handoff-native.js.map +1 -0
- package/dist/testing/scroll-handoff.d.ts +25 -0
- package/dist/testing/scroll-handoff.d.ts.map +1 -0
- package/dist/testing/scroll-handoff.js +127 -0
- package/dist/testing/scroll-handoff.js.map +1 -0
- package/dist/testing/sensors.d.ts +13 -0
- package/dist/testing/sensors.d.ts.map +1 -0
- package/dist/testing/sensors.js +26 -0
- package/dist/testing/sensors.js.map +1 -0
- package/dist/testing/trace.d.ts +101 -0
- package/dist/testing/trace.d.ts.map +1 -0
- package/dist/testing/trace.js +263 -0
- package/dist/testing/trace.js.map +1 -0
- package/dist/timed-animation.d.ts +38 -0
- package/dist/timed-animation.d.ts.map +1 -0
- package/dist/timed-animation.js +177 -0
- package/dist/timed-animation.js.map +1 -0
- package/dist/track.d.ts +5 -28
- package/dist/track.d.ts.map +1 -1
- package/dist/track.js +10 -230
- package/dist/track.js.map +1 -1
- package/dist/transition.d.ts +1 -63
- package/dist/transition.d.ts.map +1 -1
- package/dist/transition.js +1 -90
- package/dist/transition.js.map +1 -1
- package/dist/types.d.ts +15 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/value-observers.d.ts +22 -0
- package/dist/value-observers.d.ts.map +1 -0
- package/dist/value-observers.js +122 -0
- package/dist/value-observers.js.map +1 -0
- package/dist/value-track.d.ts +22 -0
- package/dist/value-track.d.ts.map +1 -0
- package/dist/value-track.js +71 -0
- package/dist/value-track.js.map +1 -0
- package/dist/vue/index.d.ts +33 -3
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +118 -3
- package/dist/vue/index.js.map +1 -1
- package/dist/web/blur.d.ts +27 -0
- package/dist/web/blur.d.ts.map +1 -0
- package/dist/web/blur.js +152 -0
- package/dist/web/blur.js.map +1 -0
- package/dist/web/bottom-sheet.d.ts +40 -0
- package/dist/web/bottom-sheet.d.ts.map +1 -0
- package/dist/web/bottom-sheet.js +308 -0
- package/dist/web/bottom-sheet.js.map +1 -0
- package/dist/web/compose.d.ts +28 -0
- package/dist/web/compose.d.ts.map +1 -0
- package/dist/web/compose.js +156 -0
- package/dist/web/compose.js.map +1 -0
- package/dist/web/curve.d.ts +10 -0
- package/dist/web/curve.d.ts.map +1 -0
- package/dist/web/curve.js +46 -0
- package/dist/web/curve.js.map +1 -0
- package/dist/web/decay.d.ts +14 -0
- package/dist/web/decay.d.ts.map +1 -0
- package/dist/web/decay.js +62 -0
- package/dist/web/decay.js.map +1 -0
- package/dist/web/diagnostics.d.ts +59 -0
- package/dist/web/diagnostics.d.ts.map +1 -0
- package/dist/web/diagnostics.js +72 -0
- package/dist/web/diagnostics.js.map +1 -0
- package/dist/web/drag.d.ts +135 -0
- package/dist/web/drag.d.ts.map +1 -0
- package/dist/web/drag.js +466 -0
- package/dist/web/drag.js.map +1 -0
- package/dist/web/effect.d.ts +70 -0
- package/dist/web/effect.d.ts.map +1 -0
- package/dist/web/effect.js +290 -0
- package/dist/web/effect.js.map +1 -0
- package/dist/web/geometry.d.ts +6 -0
- package/dist/web/geometry.d.ts.map +1 -0
- package/dist/web/geometry.js +36 -0
- package/dist/web/geometry.js.map +1 -0
- package/dist/web/gesture-scroll.d.ts +20 -0
- package/dist/web/gesture-scroll.d.ts.map +1 -0
- package/dist/web/gesture-scroll.js +99 -0
- package/dist/web/gesture-scroll.js.map +1 -0
- package/dist/web/gestures.d.ts +63 -0
- package/dist/web/gestures.d.ts.map +1 -0
- package/dist/web/gestures.js +542 -0
- package/dist/web/gestures.js.map +1 -0
- package/dist/web/glass.d.ts +20 -0
- package/dist/web/glass.d.ts.map +1 -0
- package/dist/web/glass.js +117 -0
- package/dist/web/glass.js.map +1 -0
- package/dist/web/gradient.d.ts +43 -0
- package/dist/web/gradient.d.ts.map +1 -0
- package/dist/web/gradient.js +366 -0
- package/dist/web/gradient.js.map +1 -0
- package/dist/web/haptics.d.ts +17 -0
- package/dist/web/haptics.d.ts.map +1 -0
- package/dist/web/haptics.js +87 -0
- package/dist/web/haptics.js.map +1 -0
- package/dist/web/image-effect.d.ts +29 -0
- package/dist/web/image-effect.d.ts.map +1 -0
- package/dist/web/image-effect.js +371 -0
- package/dist/web/image-effect.js.map +1 -0
- package/dist/web/image-surface.d.ts +38 -0
- package/dist/web/image-surface.d.ts.map +1 -0
- package/dist/web/image-surface.js +182 -0
- package/dist/web/image-surface.js.map +1 -0
- package/dist/web/index.d.ts +3 -0
- package/dist/web/index.d.ts.map +1 -0
- package/dist/web/index.js +3 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/interaction.d.ts +38 -0
- package/dist/web/interaction.d.ts.map +1 -0
- package/dist/web/interaction.js +85 -0
- package/dist/web/interaction.js.map +1 -0
- package/dist/web/interactive-modal.d.ts +21 -0
- package/dist/web/interactive-modal.d.ts.map +1 -0
- package/dist/web/interactive-modal.js +223 -0
- package/dist/web/interactive-modal.js.map +1 -0
- package/dist/web/interactive-navigation.d.ts +28 -0
- package/dist/web/interactive-navigation.d.ts.map +1 -0
- package/dist/web/interactive-navigation.js +227 -0
- package/dist/web/interactive-navigation.js.map +1 -0
- package/dist/web/items.d.ts +28 -0
- package/dist/web/items.d.ts.map +1 -0
- package/dist/web/items.js +110 -0
- package/dist/web/items.js.map +1 -0
- package/dist/web/keyboard.d.ts +35 -0
- package/dist/web/keyboard.d.ts.map +1 -0
- package/dist/web/keyboard.js +235 -0
- package/dist/web/keyboard.js.map +1 -0
- package/dist/web/layout.d.ts +171 -0
- package/dist/web/layout.d.ts.map +1 -0
- package/dist/web/layout.js +157 -0
- package/dist/web/layout.js.map +1 -0
- package/dist/web/liquid.d.ts +24 -0
- package/dist/web/liquid.d.ts.map +1 -0
- package/dist/web/liquid.js +65 -0
- package/dist/web/liquid.js.map +1 -0
- package/dist/web/loading.d.ts +21 -0
- package/dist/web/loading.d.ts.map +1 -0
- package/dist/web/loading.js +153 -0
- package/dist/web/loading.js.map +1 -0
- package/dist/web/motion-states.d.ts +43 -0
- package/dist/web/motion-states.d.ts.map +1 -0
- package/dist/web/motion-states.js +243 -0
- package/dist/web/motion-states.js.map +1 -0
- package/dist/web/navigation-entry.d.ts +31 -0
- package/dist/web/navigation-entry.d.ts.map +1 -0
- package/dist/web/navigation-entry.js +269 -0
- package/dist/web/navigation-entry.js.map +1 -0
- package/dist/web/particles.d.ts +44 -0
- package/dist/web/particles.d.ts.map +1 -0
- package/dist/web/particles.js +234 -0
- package/dist/web/particles.js.map +1 -0
- package/dist/web/physics.d.ts +93 -0
- package/dist/web/physics.d.ts.map +1 -0
- package/dist/web/physics.js +588 -0
- package/dist/web/physics.js.map +1 -0
- package/dist/web/plan.d.ts +13 -0
- package/dist/web/plan.d.ts.map +1 -0
- package/dist/web/plan.js +164 -0
- package/dist/web/plan.js.map +1 -0
- package/dist/web/platform-host.d.ts +5 -0
- package/dist/web/platform-host.d.ts.map +1 -0
- package/dist/web/platform-host.js +2 -0
- package/dist/web/platform-host.js.map +1 -0
- package/dist/web/pointer.d.ts +43 -0
- package/dist/web/pointer.d.ts.map +1 -0
- package/dist/web/pointer.js +295 -0
- package/dist/web/pointer.js.map +1 -0
- package/dist/web/press.d.ts +26 -0
- package/dist/web/press.d.ts.map +1 -0
- package/dist/web/press.js +170 -0
- package/dist/web/press.js.map +1 -0
- package/dist/web/progress.d.ts +17 -0
- package/dist/web/progress.d.ts.map +1 -0
- package/dist/web/progress.js +69 -0
- package/dist/web/progress.js.map +1 -0
- package/dist/web/properties.d.ts +25 -0
- package/dist/web/properties.d.ts.map +1 -0
- package/dist/web/properties.js +62 -0
- package/dist/web/properties.js.map +1 -0
- package/dist/web/public.d.ts +163 -0
- package/dist/web/public.d.ts.map +1 -0
- package/dist/web/public.js +71 -0
- package/dist/web/public.js.map +1 -0
- package/dist/web/reorder.d.ts +38 -0
- package/dist/web/reorder.d.ts.map +1 -0
- package/dist/web/reorder.js +560 -0
- package/dist/web/reorder.js.map +1 -0
- package/dist/web/return-target.d.ts +21 -0
- package/dist/web/return-target.d.ts.map +1 -0
- package/dist/web/return-target.js +75 -0
- package/dist/web/return-target.js.map +1 -0
- package/dist/web/reveal.d.ts +17 -0
- package/dist/web/reveal.d.ts.map +1 -0
- package/dist/web/reveal.js +134 -0
- package/dist/web/reveal.js.map +1 -0
- package/dist/web/runtime.d.ts +359 -0
- package/dist/web/runtime.d.ts.map +1 -0
- package/dist/web/runtime.js +2768 -0
- package/dist/web/runtime.js.map +1 -0
- package/dist/web/scene.d.ts +28 -0
- package/dist/web/scene.d.ts.map +1 -0
- package/dist/web/scene.js +41 -0
- package/dist/web/scene.js.map +1 -0
- package/dist/web/scheduler.d.ts +34 -0
- package/dist/web/scheduler.d.ts.map +1 -0
- package/dist/web/scheduler.js +105 -0
- package/dist/web/scheduler.js.map +1 -0
- package/dist/web/scope.d.ts +31 -0
- package/dist/web/scope.d.ts.map +1 -0
- package/dist/web/scope.js +306 -0
- package/dist/web/scope.js.map +1 -0
- package/dist/web/scroll-header.d.ts +53 -0
- package/dist/web/scroll-header.d.ts.map +1 -0
- package/dist/web/scroll-header.js +395 -0
- package/dist/web/scroll-header.js.map +1 -0
- package/dist/web/scroll.d.ts +80 -0
- package/dist/web/scroll.d.ts.map +1 -0
- package/dist/web/scroll.js +247 -0
- package/dist/web/scroll.js.map +1 -0
- package/dist/web/sensors.d.ts +61 -0
- package/dist/web/sensors.d.ts.map +1 -0
- package/dist/web/sensors.js +364 -0
- package/dist/web/sensors.js.map +1 -0
- package/dist/web/sequence.d.ts +26 -0
- package/dist/web/sequence.d.ts.map +1 -0
- package/dist/web/sequence.js +28 -0
- package/dist/web/sequence.js.map +1 -0
- package/dist/web/shape.d.ts +35 -0
- package/dist/web/shape.d.ts.map +1 -0
- package/dist/web/shape.js +195 -0
- package/dist/web/shape.js.map +1 -0
- package/dist/web/shared-layout.d.ts +46 -0
- package/dist/web/shared-layout.d.ts.map +1 -0
- package/dist/web/shared-layout.js +454 -0
- package/dist/web/shared-layout.js.map +1 -0
- package/dist/web/shared-navigation.d.ts +32 -0
- package/dist/web/shared-navigation.d.ts.map +1 -0
- package/dist/web/shared-navigation.js +183 -0
- package/dist/web/shared-navigation.js.map +1 -0
- package/dist/web/size.d.ts +59 -0
- package/dist/web/size.d.ts.map +1 -0
- package/dist/web/size.js +312 -0
- package/dist/web/size.js.map +1 -0
- package/dist/web/spring-value.d.ts +53 -0
- package/dist/web/spring-value.d.ts.map +1 -0
- package/dist/web/spring-value.js +193 -0
- package/dist/web/spring-value.js.map +1 -0
- package/dist/web/stroke.d.ts +118 -0
- package/dist/web/stroke.d.ts.map +1 -0
- package/dist/web/stroke.js +470 -0
- package/dist/web/stroke.js.map +1 -0
- package/dist/web/style.d.ts +12 -0
- package/dist/web/style.d.ts.map +1 -0
- package/dist/web/style.js +131 -0
- package/dist/web/style.js.map +1 -0
- package/dist/web/surface-effect.d.ts +30 -0
- package/dist/web/surface-effect.d.ts.map +1 -0
- package/dist/web/surface-effect.js +134 -0
- package/dist/web/surface-effect.js.map +1 -0
- package/dist/web/symbol-effect.d.ts +15 -0
- package/dist/web/symbol-effect.d.ts.map +1 -0
- package/dist/web/symbol-effect.js +186 -0
- package/dist/web/symbol-effect.js.map +1 -0
- package/dist/web/text-effect.d.ts +20 -0
- package/dist/web/text-effect.d.ts.map +1 -0
- package/dist/web/text-effect.js +347 -0
- package/dist/web/text-effect.js.map +1 -0
- package/dist/web/timers.d.ts +14 -0
- package/dist/web/timers.d.ts.map +1 -0
- package/dist/web/timers.js +57 -0
- package/dist/web/timers.js.map +1 -0
- package/dist/web/types.d.ts +39 -0
- package/dist/web/types.d.ts.map +1 -0
- package/dist/web/types.js +6 -0
- package/dist/web/types.js.map +1 -0
- package/dist/web/value-playback.d.ts +44 -0
- package/dist/web/value-playback.d.ts.map +1 -0
- package/dist/web/value-playback.js +75 -0
- package/dist/web/value-playback.js.map +1 -0
- package/dist/web/value.d.ts +118 -0
- package/dist/web/value.d.ts.map +1 -0
- package/dist/web/value.js +318 -0
- package/dist/web/value.js.map +1 -0
- package/dist/web/viewport.d.ts +36 -0
- package/dist/web/viewport.d.ts.map +1 -0
- package/dist/web/viewport.js +297 -0
- package/dist/web/viewport.js.map +1 -0
- package/dist/web/vue/attachment.d.ts +7 -0
- package/dist/web/vue/attachment.d.ts.map +1 -0
- package/dist/web/vue/attachment.js +50 -0
- package/dist/web/vue/attachment.js.map +1 -0
- package/dist/web/vue/index.d.ts +35 -0
- package/dist/web/vue/index.d.ts.map +1 -0
- package/dist/web/vue/index.js +346 -0
- package/dist/web/vue/index.js.map +1 -0
- package/dist/web/vue/viewport-directive.d.ts +12 -0
- package/dist/web/vue/viewport-directive.d.ts.map +1 -0
- package/dist/web/vue/viewport-directive.js +85 -0
- package/dist/web/vue/viewport-directive.js.map +1 -0
- package/dist/web/zoomable.d.ts +41 -0
- package/dist/web/zoomable.d.ts.map +1 -0
- package/dist/web/zoomable.js +401 -0
- package/dist/web/zoomable.js.map +1 -0
- package/dist/zoomable.d.ts +1 -1
- package/dist/zoomable.d.ts.map +1 -1
- package/package.json +142 -8
- package/platforms/android/include.gradle +10 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/BlurEffect.java +101 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/CircleMath.java +190 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/CircleWorld.java +253 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/ColorMath.java +44 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/DecorationTarget.java +7 -6
- package/platforms/android/java/org/rafaelaugusto/jolt/GestureSession.java +227 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/GestureSurface.java +54 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/GradientLayer.java +246 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/KeyboardFrame.java +53 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/KeyboardFrameFollower.java +57 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/KeyboardObserver.java +97 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/KeyframeFactory.java +26 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/LiveSpring.java +331 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/MotionProbe.java +70 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/ParticleEmitter.java +192 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/ParticleSimulation.java +114 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/PredictiveBackSession.java +212 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/RealizedReorder.java +161 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/ReorderHandle.java +25 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/ReorderSession.java +213 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/ReorderSurface.java +27 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/ScrollHeader.java +281 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/ScrollHeaderSurface.java +39 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/ScrollInput.java +107 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/SensorMath.java +28 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/SensorSource.java +217 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/ShapeLayer.java +130 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/SharedLayoutFlight.java +287 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/SharedNavigationScene.java +115 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/SpringState.java +39 -0
- package/platforms/android/proguard-rules.pro +21 -0
- package/platforms/ios/build.xcconfig +1 -1
- package/platforms/ios/src/JoltBlur.h +14 -0
- package/platforms/ios/src/JoltBlur.m +86 -0
- package/platforms/ios/src/JoltCircleMath.h +230 -0
- package/platforms/ios/src/JoltCircleWorld.h +19 -0
- package/platforms/ios/src/JoltCircleWorld.m +243 -0
- package/platforms/ios/src/JoltColorMath.h +40 -0
- package/platforms/ios/src/JoltGestureSession.h +23 -0
- package/platforms/ios/src/JoltGestureSession.m +251 -0
- package/platforms/ios/src/JoltInteractiveModal.h +16 -0
- package/platforms/ios/src/JoltInteractiveModal.m +178 -0
- package/platforms/ios/src/JoltInteractiveNavigation.h +23 -0
- package/platforms/ios/src/JoltInteractiveNavigation.m +255 -0
- package/platforms/ios/src/JoltLivePaint.h +12 -0
- package/platforms/ios/src/JoltLivePaint.m +131 -0
- package/platforms/ios/src/JoltLiveSpring.h +30 -0
- package/platforms/ios/src/JoltLiveSpring.m +385 -0
- package/platforms/ios/src/JoltMotionProbe.h +9 -0
- package/platforms/ios/src/JoltMotionProbe.m +72 -0
- package/platforms/ios/src/JoltRealizedReorder.h +13 -0
- package/platforms/ios/src/JoltRealizedReorder.m +148 -0
- package/platforms/ios/src/JoltReorderSession.h +15 -0
- package/platforms/ios/src/JoltReorderSession.m +205 -0
- package/platforms/ios/src/JoltScrollHeader.h +15 -0
- package/platforms/ios/src/JoltScrollHeader.m +244 -0
- package/platforms/ios/src/JoltSensorMath.h +39 -0
- package/platforms/ios/src/JoltSensorSource.h +13 -0
- package/platforms/ios/src/JoltSensorSource.m +201 -0
- package/platforms/ios/src/JoltSharedLayoutFlight.h +19 -0
- package/platforms/ios/src/JoltSharedLayoutFlight.m +250 -0
- package/platforms/ios/src/JoltSpringState.h +35 -0
- package/platforms/ios/src/module.modulemap +13 -0
- package/src/android-plugin.d.ts +518 -0
- package/src/animate.ts +152 -20
- package/src/blur/index.ts +195 -0
- package/src/blur/native.ts +70 -0
- package/src/blur/types.ts +32 -0
- package/src/bottom-sheet/geometry.ts +2 -0
- package/src/bottom-sheet/index.ts +610 -0
- package/src/bottom-sheet/native.ts +220 -0
- package/src/color.ts +2 -56
- package/src/config.ts +39 -1
- package/src/core/arrival.ts +30 -0
- package/src/core/circle-math.ts +418 -0
- package/src/core/color.ts +55 -0
- package/src/core/decay.ts +54 -0
- package/src/core/decoration.ts +32 -0
- package/src/core/drag-physics.ts +110 -0
- package/src/core/driver.ts +53 -0
- package/src/core/easing.ts +120 -0
- package/src/core/gesture-math.ts +53 -0
- package/src/core/gradient.ts +32 -0
- package/src/core/gravity.ts +107 -0
- package/src/core/haptic.ts +34 -0
- package/src/core/index.ts +24 -0
- package/src/core/liquid-grid.ts +28 -0
- package/src/core/numeric-map.ts +58 -0
- package/src/core/ownership.ts +21 -0
- package/src/core/playback.ts +112 -0
- package/src/core/presets.ts +139 -0
- package/src/core/properties.ts +40 -0
- package/src/core/reorder.ts +53 -0
- package/src/core/roll-diff.ts +57 -0
- package/src/core/sampling.ts +173 -0
- package/src/core/scroll-header.ts +100 -0
- package/src/core/sequence.ts +380 -0
- package/src/core/shape-path.ts +127 -0
- package/src/core/sheet-geometry.ts +91 -0
- package/src/core/spring.ts +135 -0
- package/src/core/state-transition.ts +97 -0
- package/src/core/svg-path.ts +360 -0
- package/src/core/track.ts +664 -0
- package/src/core/transition.ts +367 -0
- package/src/decay.ts +1 -45
- package/src/decoration.ts +7 -33
- package/src/drag-physics.ts +1 -110
- package/src/drag.ts +67 -21
- package/src/driver/android-gradient.ts +116 -0
- package/src/driver/android-particles.ts +118 -0
- package/src/driver/android.ts +72 -15
- package/src/driver/frame.ts +10 -0
- package/src/driver/index.ts +3 -46
- package/src/driver/ios-gradient.ts +136 -0
- package/src/driver/ios-scroll-delegate.ts +23 -0
- package/src/driver/ios.ts +10 -0
- package/src/easing.ts +1 -100
- package/src/engine.ts +233 -108
- package/src/gesture-native.ts +139 -0
- package/src/gestures/index.ts +365 -0
- package/src/glass/index.ts +218 -0
- package/src/gradient-binding.ts +140 -0
- package/src/gradient.ts +656 -0
- package/src/gravity.ts +1 -0
- package/src/haptics.ts +108 -61
- package/src/image-effect.ts +10 -2
- package/src/index.ts +62 -7
- package/src/inspector/index.ts +523 -0
- package/src/inspector/plot.ts +27 -0
- package/src/inspector/probe.ts +50 -0
- package/src/inspector/tuning.ts +51 -0
- package/src/interactive-navigation/index.ts +434 -0
- package/src/interactive-navigation/modal.ts +306 -0
- package/src/ios-plugin.d.ts +326 -0
- package/src/keyboard.ts +231 -7
- package/src/liquid-grid.ts +1 -28
- package/src/live-paint.ts +78 -0
- package/src/live-spring-driver.ts +260 -0
- package/src/mixer.ts +354 -0
- package/src/motion-scope.ts +109 -35
- package/src/motion-states.ts +159 -98
- package/src/motion-value.ts +1491 -0
- package/src/native/index.ts +30 -0
- package/src/native-properties.ts +188 -0
- package/src/native-property-driver.ts +123 -0
- package/src/native-property.ts +366 -0
- package/src/particles.ts +18 -17
- package/src/path.ts +2 -1
- package/src/physics/index.ts +582 -0
- package/src/physics/native.ts +136 -0
- package/src/playback-group.ts +17 -1
- package/src/playback.ts +1 -62
- package/src/predictive-back/index.ts +280 -0
- package/src/predictive-back/presentation.ts +6 -0
- package/src/presets.ts +2 -128
- package/src/press.ts +10 -2
- package/src/properties.ts +4 -45
- package/src/reorder/handle.ts +9 -0
- package/src/reorder/index.ts +272 -0
- package/src/reorder/list-view.ts +262 -0
- package/src/reorder/model.ts +1 -0
- package/src/reorder/realized.ts +305 -0
- package/src/reorder/surface.ts +10 -0
- package/src/reorder/types.ts +89 -0
- package/src/roll-diff.ts +2 -57
- package/src/sampling.ts +1 -0
- package/src/scene-appearance.ts +92 -0
- package/src/scene-camera.ts +30 -0
- package/src/scene-shader.ts +139 -0
- package/src/scroll-header/geometry.ts +1 -0
- package/src/scroll-header/index.ts +833 -0
- package/src/scroll-header/native.ts +121 -0
- package/src/scroll-header/surface.ts +11 -0
- package/src/seekable-timeline.ts +330 -0
- package/src/sensors/index.ts +246 -0
- package/src/sensors/native.ts +72 -0
- package/src/sequence.ts +65 -198
- package/src/shapes/android.ts +63 -0
- package/src/shapes/index.ts +278 -0
- package/src/shapes/ios.ts +194 -0
- package/src/shapes/native.ts +27 -0
- package/src/shapes/path.ts +1 -0
- package/src/shapes/types.ts +63 -0
- package/src/shared-layout/index.ts +343 -0
- package/src/shared-layout/native.ts +138 -0
- package/src/shared-layout/timing.ts +87 -0
- package/src/shared-navigation/entry.ts +695 -0
- package/src/shared-navigation/index.ts +420 -0
- package/src/shared-navigation/return-signal.ts +41 -0
- package/src/shared-navigation/return-target.ts +251 -0
- package/src/shared-navigation/scope.ts +3 -0
- package/src/shared-navigation/targets.ts +38 -0
- package/src/size-layout.ts +265 -0
- package/src/size.ts +313 -0
- package/src/spring.ts +1 -95
- package/src/svg-path.ts +1 -355
- package/src/testing/clock.ts +128 -0
- package/src/testing/handoff-recorder.ts +98 -0
- package/src/testing/index.ts +4 -0
- package/src/testing/native.ts +386 -0
- package/src/testing/presentation.ts +46 -0
- package/src/testing/replay.ts +149 -0
- package/src/testing/scroll-handoff-native.ts +201 -0
- package/src/testing/scroll-handoff.ts +140 -0
- package/src/testing/sensors.ts +41 -0
- package/src/testing/trace.ts +340 -0
- package/src/timed-animation.ts +192 -0
- package/src/track.ts +13 -347
- package/src/transition.ts +1 -179
- package/src/types.ts +16 -3
- package/src/value-observers.ts +147 -0
- package/src/value-track.ts +82 -0
- package/src/vue/index.ts +147 -1
- package/src/web/blur.ts +206 -0
- package/src/web/bottom-sheet.ts +358 -0
- package/src/web/compose.ts +211 -0
- package/src/web/curve.ts +55 -0
- package/src/web/decay.ts +76 -0
- package/src/web/diagnostics.ts +121 -0
- package/src/web/drag.ts +583 -0
- package/src/web/effect.ts +324 -0
- package/src/web/geometry.ts +40 -0
- package/src/web/gesture-scroll.ts +129 -0
- package/src/web/gestures.ts +667 -0
- package/src/web/glass.ts +152 -0
- package/src/web/gradient.ts +432 -0
- package/src/web/haptics.ts +98 -0
- package/src/web/image-effect.ts +442 -0
- package/src/web/image-surface.ts +196 -0
- package/src/web/index.ts +17 -0
- package/src/web/interaction.ts +136 -0
- package/src/web/interactive-modal.ts +247 -0
- package/src/web/interactive-navigation.ts +279 -0
- package/src/web/items.ts +173 -0
- package/src/web/keyboard.ts +282 -0
- package/src/web/layout.ts +207 -0
- package/src/web/liquid.ts +112 -0
- package/src/web/loading.ts +201 -0
- package/src/web/motion-states.ts +304 -0
- package/src/web/navigation-entry.ts +325 -0
- package/src/web/particles.ts +328 -0
- package/src/web/physics.ts +765 -0
- package/src/web/plan.ts +226 -0
- package/src/web/platform-host.ts +5 -0
- package/src/web/pointer.ts +336 -0
- package/src/web/press.ts +217 -0
- package/src/web/progress.ts +71 -0
- package/src/web/properties.ts +76 -0
- package/src/web/public.ts +503 -0
- package/src/web/reorder.ts +718 -0
- package/src/web/return-target.ts +103 -0
- package/src/web/reveal.ts +178 -0
- package/src/web/runtime.ts +3477 -0
- package/src/web/scene.ts +76 -0
- package/src/web/scheduler.ts +106 -0
- package/src/web/scope.ts +403 -0
- package/src/web/scroll-header.ts +492 -0
- package/src/web/scroll.ts +295 -0
- package/src/web/sensors.ts +468 -0
- package/src/web/sequence.ts +60 -0
- package/src/web/shape.ts +260 -0
- package/src/web/shared-layout.ts +572 -0
- package/src/web/shared-navigation.ts +238 -0
- package/src/web/size.ts +368 -0
- package/src/web/spring-value.ts +218 -0
- package/src/web/stroke.ts +547 -0
- package/src/web/style.ts +170 -0
- package/src/web/surface-effect.ts +133 -0
- package/src/web/symbol-effect.ts +224 -0
- package/src/web/text-effect.ts +464 -0
- package/src/web/timers.ts +51 -0
- package/src/web/types.ts +48 -0
- package/src/web/value-playback.ts +104 -0
- package/src/web/value.ts +371 -0
- package/src/web/viewport.ts +341 -0
- package/src/web/vue/attachment.ts +47 -0
- package/src/web/vue/index.ts +364 -0
- package/src/web/vue/viewport-directive.ts +99 -0
- package/src/web/zoomable.ts +521 -0
- package/src/zoomable.ts +1 -1
|
@@ -0,0 +1,2768 @@
|
|
|
1
|
+
import { createInteractiveNavigation, } from './interactive-navigation.js';
|
|
2
|
+
import { createNavigationEntry, } from './navigation-entry.js';
|
|
3
|
+
import { createGlass } from './glass.js';
|
|
4
|
+
import { createSensor, SensorValueNode, } from './sensors.js';
|
|
5
|
+
import { animationHaptics, requestHaptic } from './haptics.js';
|
|
6
|
+
import { resolveHaptic } from '../core/haptic.js';
|
|
7
|
+
import { createKeyboardSubscription, createKeyboardFollower, } from './keyboard.js';
|
|
8
|
+
import { createBottomSheet } from './bottom-sheet.js';
|
|
9
|
+
import { createInteractiveModal, } from './interactive-modal.js';
|
|
10
|
+
import { createSharedNavigation, } from './shared-navigation.js';
|
|
11
|
+
import { createPhysicsWorld, } from './physics.js';
|
|
12
|
+
import { createSymbolEffect, } from './symbol-effect.js';
|
|
13
|
+
import { createParticles, createConfetti, } from './particles.js';
|
|
14
|
+
import { createBlur } from './blur.js';
|
|
15
|
+
import { createShape } from './shape.js';
|
|
16
|
+
import { createLiquid } from './liquid.js';
|
|
17
|
+
import { createImageEffect, } from './image-effect.js';
|
|
18
|
+
import { createZoomable } from './zoomable.js';
|
|
19
|
+
import { createGradient } from './gradient.js';
|
|
20
|
+
import { createShimmer, createLoader, } from './loading.js';
|
|
21
|
+
import { createReveal } from './reveal.js';
|
|
22
|
+
import { createTextAnimation, createRoll, } from './text-effect.js';
|
|
23
|
+
import { createScrollHeader } from './scroll-header.js';
|
|
24
|
+
import { createReorder } from './reorder.js';
|
|
25
|
+
import { createGestures } from './gestures.js';
|
|
26
|
+
import { StrokeSurface } from './stroke.js';
|
|
27
|
+
import { createItemsAnimation, } from './items.js';
|
|
28
|
+
import { createMotionStates, } from './motion-states.js';
|
|
29
|
+
import { ContextTimers } from './timers.js';
|
|
30
|
+
import { composePrepared } from '../core/sequence.js';
|
|
31
|
+
import { sequenceSteps } from './sequence.js';
|
|
32
|
+
import { decayPlans } from './decay.js';
|
|
33
|
+
import { ProgressNode } from './progress.js';
|
|
34
|
+
import { registerPlayback, playbackSource, } from '../core/playback.js';
|
|
35
|
+
import { setArrival, setArrivalTiming } from '../core/arrival.js';
|
|
36
|
+
import { valuePlan, valueTrack } from './value-playback.js';
|
|
37
|
+
import { createDrag, dragOptions, dragPlans, dragCurve, assertDragSpace, } from './drag.js';
|
|
38
|
+
import { createWebScope } from './scope.js';
|
|
39
|
+
import { createPointerFollow, } from './pointer.js';
|
|
40
|
+
import { createViewportEntrance, } from './viewport.js';
|
|
41
|
+
import { renderedAncestors } from './geometry.js';
|
|
42
|
+
import { DiagnosticCollector, } from './diagnostics.js';
|
|
43
|
+
import { createSharedLayout, } from './shared-layout.js';
|
|
44
|
+
import { createTrack } from '../core/track.js';
|
|
45
|
+
import { springs as springDefinitions, resolveTransition } from '../core/transition.js';
|
|
46
|
+
import { createOwnership } from '../core/ownership.js';
|
|
47
|
+
import { validateProgress } from '../core/playback.js';
|
|
48
|
+
import { presets as builtins } from '../core/presets.js';
|
|
49
|
+
import { compose, poseAt, formatPose } from './compose.js';
|
|
50
|
+
import { SpringValueNode } from './spring-value.js';
|
|
51
|
+
import { FrameScheduler } from './scheduler.js';
|
|
52
|
+
import { numericMap } from '../core/numeric-map.js';
|
|
53
|
+
import { scrollAxis, ScrollValueNode, ScrollLinkedNode, scrollPlan, } from './scroll.js';
|
|
54
|
+
import { NumericValue, MotionInputNode, DerivedValueNode, ColorMappedNode, } from './value.js';
|
|
55
|
+
import { flatten, sampled } from './curve.js';
|
|
56
|
+
import { prepare } from './plan.js';
|
|
57
|
+
import { readProperty, resolveProperty, parseColor } from './style.js';
|
|
58
|
+
import { SizeOperation, validateSize, } from './size.js';
|
|
59
|
+
import { LayoutOperation, validateLayout } from './layout.js';
|
|
60
|
+
import { sceneSteps } from './scene.js';
|
|
61
|
+
import { coreProperty, expand, isColor, isRadius, isTransform, keyframeProperties, transformProperties, cssName, } from './properties.js';
|
|
62
|
+
import { createPress, validatePressState } from './press.js';
|
|
63
|
+
import { identity, keyOf, multiplicative, properties, } from './types.js';
|
|
64
|
+
const clone = (state) => ({
|
|
65
|
+
bindings: new Map(state.bindings),
|
|
66
|
+
entries: new Map(state.entries),
|
|
67
|
+
rest: new Map(state.rest),
|
|
68
|
+
});
|
|
69
|
+
// Only a co-ownership guard is shared. Configuration, presets, clocks and tokens
|
|
70
|
+
// belong to each runtime; this weak registry cannot retain a document or target.
|
|
71
|
+
const owners = new WeakMap();
|
|
72
|
+
class Surface {
|
|
73
|
+
runtime;
|
|
74
|
+
target;
|
|
75
|
+
state;
|
|
76
|
+
effect;
|
|
77
|
+
disposed = false;
|
|
78
|
+
rebuilds = 0;
|
|
79
|
+
frameCount = 0;
|
|
80
|
+
path = 'finite';
|
|
81
|
+
original;
|
|
82
|
+
written;
|
|
83
|
+
paint = new Map();
|
|
84
|
+
className;
|
|
85
|
+
origin;
|
|
86
|
+
baseline;
|
|
87
|
+
geometryObserver;
|
|
88
|
+
geometryLeases = new Set();
|
|
89
|
+
get geometryObservers() {
|
|
90
|
+
return this.geometryObserver ? 1 : 0;
|
|
91
|
+
}
|
|
92
|
+
task = {
|
|
93
|
+
read: () => {
|
|
94
|
+
try {
|
|
95
|
+
this.assert();
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
this.runtime.release(this.target);
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
update: () => !this.disposed &&
|
|
103
|
+
[...this.state.entries.values()].some((e) => !e.owner.paused && !e.owner.pending),
|
|
104
|
+
write: () => {
|
|
105
|
+
if (!this.disposed && this.state.bindings.size && this.path !== 'scroll-timeline')
|
|
106
|
+
this.render(this.runtime.now());
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
rest(state = this.state) {
|
|
110
|
+
return [
|
|
111
|
+
...state.rest.values(),
|
|
112
|
+
...[...state.bindings.values()].map((e) => ({
|
|
113
|
+
property: e.property,
|
|
114
|
+
value: e.source.get(),
|
|
115
|
+
})),
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
render(at) {
|
|
119
|
+
this.write(formatPose(poseAt(this.snapshot(this.state, at), this.rest()), this.baseline));
|
|
120
|
+
}
|
|
121
|
+
write(style) {
|
|
122
|
+
this.target.style.transform = style.transform;
|
|
123
|
+
this.target.style.opacity = style.opacity;
|
|
124
|
+
this.written = {
|
|
125
|
+
transform: this.target.style.transform,
|
|
126
|
+
opacity: this.target.style.opacity,
|
|
127
|
+
};
|
|
128
|
+
for (const [name, value] of Object.entries(style.paint ?? {})) {
|
|
129
|
+
let held = this.paint.get(name);
|
|
130
|
+
if (!held) {
|
|
131
|
+
held = {
|
|
132
|
+
original: this.target.style.getPropertyValue(name),
|
|
133
|
+
priority: this.target.style.getPropertyPriority(name),
|
|
134
|
+
written: '',
|
|
135
|
+
};
|
|
136
|
+
this.paint.set(name, held);
|
|
137
|
+
}
|
|
138
|
+
this.target.style.setProperty(name, value);
|
|
139
|
+
held.written = this.target.style.getPropertyValue(name);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
constructor(runtime, target) {
|
|
143
|
+
this.runtime = runtime;
|
|
144
|
+
this.target = target;
|
|
145
|
+
if (owners.has(target))
|
|
146
|
+
throw new Error('The target is already owned by another Web runtime.');
|
|
147
|
+
const css = runtime.view.getComputedStyle(target);
|
|
148
|
+
const baseline = new runtime.view.DOMMatrix(css.transform === 'none' ? undefined : css.transform);
|
|
149
|
+
if (!baseline.is2D)
|
|
150
|
+
throw new TypeError('Web motion requires a static 2D CSS transform baseline.');
|
|
151
|
+
if (['inline', 'none', 'contents'].includes(css.display))
|
|
152
|
+
throw new TypeError('The motion surface must have a transformable box.');
|
|
153
|
+
if ([css.translate, css.rotate, css.scale].some((v) => v !== 'none'))
|
|
154
|
+
throw new TypeError('Individual CSS transforms must be none on a motion surface.');
|
|
155
|
+
if (target.getAnimations().length ||
|
|
156
|
+
css.transitionDuration.split(',').some((v) => parseFloat(v) > 0))
|
|
157
|
+
throw new TypeError('Existing animations and transitions must be removed from the motion surface.');
|
|
158
|
+
if (['transform', 'opacity'].some((p) => target.style.getPropertyPriority(p)))
|
|
159
|
+
throw new TypeError('Important inline motion styles are unsupported.');
|
|
160
|
+
this.baseline = baseline.toString();
|
|
161
|
+
this.origin = css.transformOrigin;
|
|
162
|
+
this.className = target.className;
|
|
163
|
+
this.original = { transform: target.style.transform, opacity: target.style.opacity };
|
|
164
|
+
this.written = { ...this.original };
|
|
165
|
+
this.state = {
|
|
166
|
+
bindings: new Map(),
|
|
167
|
+
entries: new Map(),
|
|
168
|
+
rest: new Map(transformProperties.map((property) => [
|
|
169
|
+
keyOf(property),
|
|
170
|
+
{
|
|
171
|
+
property,
|
|
172
|
+
value: property === 'opacity' ? Number(css.opacity) : identity(property),
|
|
173
|
+
},
|
|
174
|
+
])),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
assertDrag() {
|
|
178
|
+
this.assert();
|
|
179
|
+
assertDragSpace(this.target, new this.runtime.view.DOMMatrix(this.baseline).isIdentity);
|
|
180
|
+
}
|
|
181
|
+
layoutBasis() {
|
|
182
|
+
const view = this.runtime.view;
|
|
183
|
+
let matrix = new view.DOMMatrix();
|
|
184
|
+
for (const parent of renderedAncestors(this.target)) {
|
|
185
|
+
if (parent === this.target)
|
|
186
|
+
continue;
|
|
187
|
+
const css = view.getComputedStyle(parent);
|
|
188
|
+
const transform = new view.DOMMatrix(css.transform === 'none' ? undefined : css.transform);
|
|
189
|
+
if (!transform.is2D || css.perspective !== 'none')
|
|
190
|
+
throw new Error('A projective ancestor does not have a 2D FLIP inverse.');
|
|
191
|
+
const zoom = parseFloat(css.zoom) || 1;
|
|
192
|
+
const scale = css.scale === 'none' ? [1, 1] : css.scale.split(' ').map(Number);
|
|
193
|
+
const rotation = css.rotate === 'none'
|
|
194
|
+
? 0
|
|
195
|
+
: parseFloat(css.rotate.replace(/^z\s+/, '')) *
|
|
196
|
+
(css.rotate.endsWith('rad')
|
|
197
|
+
? 180 / Math.PI
|
|
198
|
+
: css.rotate.endsWith('turn')
|
|
199
|
+
? 360
|
|
200
|
+
: 1);
|
|
201
|
+
const individual = new view.DOMMatrix()
|
|
202
|
+
.rotate(rotation)
|
|
203
|
+
.scale(scale[0], scale[1] ?? scale[0]);
|
|
204
|
+
matrix = individual.multiply(transform).scale(zoom).multiply(matrix);
|
|
205
|
+
}
|
|
206
|
+
return matrix
|
|
207
|
+
.scale(parseFloat(view.getComputedStyle(this.target).zoom) || 1)
|
|
208
|
+
.multiply(new view.DOMMatrix(this.baseline));
|
|
209
|
+
}
|
|
210
|
+
assert(allowGeometry = false) {
|
|
211
|
+
const { target, runtime } = this;
|
|
212
|
+
if (this.disposed || !target.isConnected || target.ownerDocument !== runtime.document)
|
|
213
|
+
throw new Error('The motion surface is unavailable.');
|
|
214
|
+
const css = runtime.view.getComputedStyle(target);
|
|
215
|
+
// Border-width motion changes a content-box surface's used size and pivot.
|
|
216
|
+
// That is our own geometry change, not an external transform mutation.
|
|
217
|
+
const ownsGeometry = this.geometryLeases.size > 0 ||
|
|
218
|
+
[...this.paint.keys()].some((name) => name.endsWith('-width'));
|
|
219
|
+
if (target.className !== this.className ||
|
|
220
|
+
(!allowGeometry && !ownsGeometry && css.transformOrigin !== this.origin) ||
|
|
221
|
+
[css.translate, css.rotate, css.scale].some((v) => v !== 'none') ||
|
|
222
|
+
target.getAnimations().some((a) => a !== this.effect) ||
|
|
223
|
+
['transform', 'opacity'].some((p) => target.style[p] !== this.written[p] || target.style.getPropertyPriority(p)) ||
|
|
224
|
+
[...this.paint].some(([name, held]) => target.style.getPropertyValue(name) !== held.written ||
|
|
225
|
+
target.style.getPropertyPriority(name)))
|
|
226
|
+
throw new Error('External style changes require releasing and recreating the motion surface.');
|
|
227
|
+
if (ownsGeometry) {
|
|
228
|
+
this.validateGeometry(css);
|
|
229
|
+
// A live frame can run before ResizeObserver delivery. Accept only the
|
|
230
|
+
// declared geometry change here; the other ownership guards still apply.
|
|
231
|
+
this.origin = css.transformOrigin;
|
|
232
|
+
}
|
|
233
|
+
return css;
|
|
234
|
+
}
|
|
235
|
+
validateGeometry(css) {
|
|
236
|
+
if (['inline', 'none', 'contents'].includes(css.display) ||
|
|
237
|
+
css.transitionDuration.split(',').some((v) => parseFloat(v) > 0) ||
|
|
238
|
+
parseFloat(css.transformOrigin.split(' ')[2] ?? '0') !== 0)
|
|
239
|
+
throw new TypeError('Geometry refresh needs a transformable 2D box without CSS transitions.');
|
|
240
|
+
}
|
|
241
|
+
refreshGeometry() {
|
|
242
|
+
const css = this.assert(true);
|
|
243
|
+
this.validateGeometry(css);
|
|
244
|
+
// The browser applies the new pivot to the existing transform effect. Its
|
|
245
|
+
// keyframes, logical values, velocity and animation clock need no rebuild.
|
|
246
|
+
this.origin = css.transformOrigin;
|
|
247
|
+
}
|
|
248
|
+
observeGeometry() {
|
|
249
|
+
this.refreshGeometry();
|
|
250
|
+
const token = {};
|
|
251
|
+
this.geometryLeases.add(token);
|
|
252
|
+
if (!this.geometryObserver) {
|
|
253
|
+
this.geometryObserver = new this.runtime.view.ResizeObserver(() => {
|
|
254
|
+
if (this.disposed)
|
|
255
|
+
return;
|
|
256
|
+
try {
|
|
257
|
+
this.refreshGeometry();
|
|
258
|
+
}
|
|
259
|
+
catch (error) {
|
|
260
|
+
this.runtime.release(this.target);
|
|
261
|
+
this.runtime.view.reportError(error);
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
this.geometryObserver.observe(this.target, { box: 'border-box' });
|
|
265
|
+
}
|
|
266
|
+
return {
|
|
267
|
+
dispose: () => {
|
|
268
|
+
if (this.geometryLeases.has(token) && !this.disposed && this.target.isConnected)
|
|
269
|
+
this.origin = this.runtime.view.getComputedStyle(this.target).transformOrigin;
|
|
270
|
+
if (!this.geometryLeases.delete(token))
|
|
271
|
+
return;
|
|
272
|
+
if (!this.geometryLeases.size) {
|
|
273
|
+
this.geometryObserver?.disconnect();
|
|
274
|
+
this.geometryObserver = undefined;
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
snapshot(state, at, controls = new Map()) {
|
|
280
|
+
return [...state.entries.values()].map((entry) => {
|
|
281
|
+
const control = controls.get(entry.owner);
|
|
282
|
+
return {
|
|
283
|
+
property: entry.property,
|
|
284
|
+
points: entry.points,
|
|
285
|
+
time: control?.time ?? entry.owner.time(at),
|
|
286
|
+
paused: control
|
|
287
|
+
? control.paused || !!control.pending
|
|
288
|
+
: entry.owner.paused || entry.owner.pending,
|
|
289
|
+
};
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
prepare(state, at, controls) {
|
|
293
|
+
this.assert();
|
|
294
|
+
if (state.bindings.size) {
|
|
295
|
+
const current = formatPose(poseAt(this.snapshot(state, at, controls), this.rest(state)), this.baseline);
|
|
296
|
+
const nodes = [...state.bindings.values()].map((e) => e.source);
|
|
297
|
+
const first = nodes[0];
|
|
298
|
+
const Timeline = this.runtime.view.ScrollTimeline;
|
|
299
|
+
if (Timeline &&
|
|
300
|
+
this.runtime.view.CSS.supports('animation-range-start', '1px') &&
|
|
301
|
+
first instanceof ScrollLinkedNode &&
|
|
302
|
+
first.native &&
|
|
303
|
+
nodes.every((n) => n instanceof ScrollLinkedNode &&
|
|
304
|
+
n.native &&
|
|
305
|
+
n.scroll === first.scroll &&
|
|
306
|
+
n.range[0] === first.range[0] &&
|
|
307
|
+
n.range[1] === first.range[1]) &&
|
|
308
|
+
[...state.entries.values()].every((e) => {
|
|
309
|
+
const c = controls.get(e.owner);
|
|
310
|
+
return c ? c.paused || c.pending : e.owner.paused || e.owner.pending;
|
|
311
|
+
})) {
|
|
312
|
+
const values = nodes;
|
|
313
|
+
const rests = [
|
|
314
|
+
...state.rest.values(),
|
|
315
|
+
...values
|
|
316
|
+
.filter((n) => n.spatiallyReduced)
|
|
317
|
+
.map((n) => ({ property: n.property, value: n.get() })),
|
|
318
|
+
];
|
|
319
|
+
const entries = [
|
|
320
|
+
...this.snapshot(state, at, controls),
|
|
321
|
+
...values
|
|
322
|
+
.filter((n) => !n.spatiallyReduced)
|
|
323
|
+
.map((n) => ({
|
|
324
|
+
property: n.property,
|
|
325
|
+
points: n.points,
|
|
326
|
+
time: 0,
|
|
327
|
+
paused: false,
|
|
328
|
+
})),
|
|
329
|
+
];
|
|
330
|
+
const compiled = compose(entries, rests, this.baseline, this.runtime.maxKeyframes);
|
|
331
|
+
let animation;
|
|
332
|
+
try {
|
|
333
|
+
if (compiled.frames.length) {
|
|
334
|
+
animation = new this.runtime.view.Animation(new this.runtime.view.KeyframeEffect(this.target, compiled.frames, {
|
|
335
|
+
duration: 'auto',
|
|
336
|
+
fill: 'both',
|
|
337
|
+
easing: 'linear',
|
|
338
|
+
}), new Timeline({ source: first.scroll.element, axis: first.scroll.axis }));
|
|
339
|
+
const ranged = animation;
|
|
340
|
+
if (!('rangeStart' in animation))
|
|
341
|
+
throw new Error('Animation ranges are unsupported.');
|
|
342
|
+
ranged.rangeStart = `${first.range[0]}px`;
|
|
343
|
+
ranged.rangeEnd = `${first.range[1]}px`;
|
|
344
|
+
void animation.finished.catch(() => { });
|
|
345
|
+
}
|
|
346
|
+
return { ...compiled, ...current, animation, path: 'scroll-timeline' };
|
|
347
|
+
}
|
|
348
|
+
catch {
|
|
349
|
+
animation?.cancel();
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return {
|
|
353
|
+
...current,
|
|
354
|
+
duration: 0,
|
|
355
|
+
frames: [],
|
|
356
|
+
animation: undefined,
|
|
357
|
+
path: 'scheduler',
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
const result = compose(this.snapshot(state, at, controls), [...state.rest.values()], this.baseline, this.runtime.maxKeyframes);
|
|
361
|
+
const animation = result.duration > 0
|
|
362
|
+
? new this.runtime.view.Animation(new this.runtime.view.KeyframeEffect(this.target, result.frames, {
|
|
363
|
+
duration: result.duration,
|
|
364
|
+
fill: 'both',
|
|
365
|
+
easing: 'linear',
|
|
366
|
+
}), this.runtime.document.timeline)
|
|
367
|
+
: undefined;
|
|
368
|
+
if (animation)
|
|
369
|
+
void animation.finished.catch(() => { });
|
|
370
|
+
return { ...result, animation, path: 'finite' };
|
|
371
|
+
}
|
|
372
|
+
commit(state, prepared) {
|
|
373
|
+
const previous = this.effect;
|
|
374
|
+
this.write(prepared);
|
|
375
|
+
this.state = state;
|
|
376
|
+
this.effect = prepared.animation;
|
|
377
|
+
this.path = prepared.path;
|
|
378
|
+
this.frameCount = prepared.frames.length;
|
|
379
|
+
this.rebuilds++;
|
|
380
|
+
owners.set(this.target, this);
|
|
381
|
+
previous?.cancel();
|
|
382
|
+
if (this.effect && this.path !== 'scroll-timeline') {
|
|
383
|
+
const animation = this.effect;
|
|
384
|
+
void animation.finished.then(() => {
|
|
385
|
+
if (this.effect !== animation || this.disposed)
|
|
386
|
+
return;
|
|
387
|
+
this.effect = undefined;
|
|
388
|
+
animation.cancel();
|
|
389
|
+
}, () => { });
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
restore() {
|
|
393
|
+
this.disposed = true;
|
|
394
|
+
this.geometryObserver?.disconnect();
|
|
395
|
+
this.geometryObserver = undefined;
|
|
396
|
+
this.geometryLeases.clear();
|
|
397
|
+
this.effect?.cancel();
|
|
398
|
+
this.effect = undefined;
|
|
399
|
+
for (const property of ['transform', 'opacity'])
|
|
400
|
+
if (this.target.style[property] === this.written[property] &&
|
|
401
|
+
!this.target.style.getPropertyPriority(property))
|
|
402
|
+
this.target.style[property] = this.original[property];
|
|
403
|
+
for (const [name, held] of this.paint)
|
|
404
|
+
if (this.target.style.getPropertyValue(name) === held.written &&
|
|
405
|
+
!this.target.style.getPropertyPriority(name)) {
|
|
406
|
+
if (held.original)
|
|
407
|
+
this.target.style.setProperty(name, held.original, held.priority);
|
|
408
|
+
else
|
|
409
|
+
this.target.style.removeProperty(name);
|
|
410
|
+
}
|
|
411
|
+
this.paint.clear();
|
|
412
|
+
this.runtime.scheduler.remove(this.task);
|
|
413
|
+
for (const entry of this.state.bindings.values())
|
|
414
|
+
entry.cleanup?.();
|
|
415
|
+
this.state.bindings.clear();
|
|
416
|
+
this.state.entries.clear();
|
|
417
|
+
this.state.rest.clear();
|
|
418
|
+
if (owners.get(this.target) === this)
|
|
419
|
+
owners.delete(this.target);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
class Owner {
|
|
423
|
+
runtime;
|
|
424
|
+
duration;
|
|
425
|
+
diagnosticReason;
|
|
426
|
+
finished;
|
|
427
|
+
ready;
|
|
428
|
+
entries = new Set();
|
|
429
|
+
clock;
|
|
430
|
+
pending;
|
|
431
|
+
paused = false;
|
|
432
|
+
settled = false;
|
|
433
|
+
complete = true;
|
|
434
|
+
held = 0;
|
|
435
|
+
anchor;
|
|
436
|
+
end;
|
|
437
|
+
resolve;
|
|
438
|
+
resolveReady;
|
|
439
|
+
notify;
|
|
440
|
+
arrive;
|
|
441
|
+
arrived = false;
|
|
442
|
+
cancelArrival;
|
|
443
|
+
feedback;
|
|
444
|
+
constructor(runtime, duration, at) {
|
|
445
|
+
this.runtime = runtime;
|
|
446
|
+
this.duration = duration;
|
|
447
|
+
this.anchor = at;
|
|
448
|
+
this.end = duration;
|
|
449
|
+
this.pending = runtime.document.timeline.currentTime === null;
|
|
450
|
+
this.finished = new Promise((resolve) => {
|
|
451
|
+
this.resolve = resolve;
|
|
452
|
+
});
|
|
453
|
+
this.ready = new Promise((resolve) => {
|
|
454
|
+
this.resolveReady = resolve;
|
|
455
|
+
});
|
|
456
|
+
this.notify = registerPlayback(this, () => ({
|
|
457
|
+
time: this.time(),
|
|
458
|
+
duration: this.duration,
|
|
459
|
+
paused: this.paused,
|
|
460
|
+
ready: !this.pending,
|
|
461
|
+
settled: this.settled,
|
|
462
|
+
completed: this.complete && this.settled,
|
|
463
|
+
}));
|
|
464
|
+
setArrival(this, new Promise((resolve) => {
|
|
465
|
+
this.arrive = resolve;
|
|
466
|
+
}));
|
|
467
|
+
setArrivalTiming(this, {
|
|
468
|
+
read: () => ({
|
|
469
|
+
remaining: this.pending
|
|
470
|
+
? undefined
|
|
471
|
+
: Math.max(0, this.arrivalTime() - this.time()),
|
|
472
|
+
paused: this.paused,
|
|
473
|
+
arrived: this.arrived,
|
|
474
|
+
}),
|
|
475
|
+
subscribe: (callback) => playbackSource(this).subscribe(callback),
|
|
476
|
+
});
|
|
477
|
+
runtime.rememberPlayback(this);
|
|
478
|
+
}
|
|
479
|
+
time(at) {
|
|
480
|
+
if (this.settled || this.pending || this.paused)
|
|
481
|
+
return this.held;
|
|
482
|
+
at ??= this.runtime.now();
|
|
483
|
+
// The default DocumentTimeline and performance clock share the document's
|
|
484
|
+
// origin. Project its resolved start time to this command, rather than using
|
|
485
|
+
// the previous rendering tick during a long input task (notably WebKit).
|
|
486
|
+
const start = typeof this.clock?.startTime === 'number'
|
|
487
|
+
? this.clock.startTime
|
|
488
|
+
: this.anchor - this.held;
|
|
489
|
+
return Math.max(0, Math.min(this.duration, at - start));
|
|
490
|
+
}
|
|
491
|
+
get progress() {
|
|
492
|
+
if (!Number.isFinite(this.duration))
|
|
493
|
+
throw new RangeError('Progress requires a finite animation.');
|
|
494
|
+
return this.settled && this.complete
|
|
495
|
+
? 1
|
|
496
|
+
: this.duration
|
|
497
|
+
? this.time() / this.duration
|
|
498
|
+
: this.settled
|
|
499
|
+
? 1
|
|
500
|
+
: 0;
|
|
501
|
+
}
|
|
502
|
+
set progress(value) {
|
|
503
|
+
validateProgress(value, this.duration);
|
|
504
|
+
this.feedback?.seek(this.duration * value);
|
|
505
|
+
if (!this.settled)
|
|
506
|
+
this.runtime.control(this, {
|
|
507
|
+
time: this.duration * value,
|
|
508
|
+
paused: this.paused,
|
|
509
|
+
pending: this.pending,
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
pause() {
|
|
513
|
+
if (!this.settled && !this.paused)
|
|
514
|
+
this.runtime.control(this, {
|
|
515
|
+
time: this.time(),
|
|
516
|
+
paused: true,
|
|
517
|
+
pending: this.pending,
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
play() {
|
|
521
|
+
if (!this.settled && this.paused)
|
|
522
|
+
this.runtime.control(this, {
|
|
523
|
+
time: this.held,
|
|
524
|
+
paused: false,
|
|
525
|
+
pending: this.pending,
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
stop(properties, options) {
|
|
529
|
+
if (!this.settled)
|
|
530
|
+
this.runtime.stopOwner(this, properties, options);
|
|
531
|
+
}
|
|
532
|
+
then(onfulfilled, onrejected) {
|
|
533
|
+
return this.finished.then(onfulfilled, onrejected);
|
|
534
|
+
}
|
|
535
|
+
prepare(control, at) {
|
|
536
|
+
if (!this.duration)
|
|
537
|
+
return undefined;
|
|
538
|
+
const clock = new this.runtime.view.Animation(new this.runtime.view.KeyframeEffect(null, [], {
|
|
539
|
+
duration: this.end,
|
|
540
|
+
fill: 'both',
|
|
541
|
+
}), this.runtime.document.timeline);
|
|
542
|
+
void clock.finished.catch(() => { });
|
|
543
|
+
try {
|
|
544
|
+
if (control.paused || control.pending) {
|
|
545
|
+
clock.pause();
|
|
546
|
+
clock.currentTime = control.time;
|
|
547
|
+
}
|
|
548
|
+
else {
|
|
549
|
+
clock.play();
|
|
550
|
+
clock.startTime = at - control.time;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
catch (error) {
|
|
554
|
+
clock.cancel();
|
|
555
|
+
throw error;
|
|
556
|
+
}
|
|
557
|
+
return clock;
|
|
558
|
+
}
|
|
559
|
+
apply(control, at, clock) {
|
|
560
|
+
const previous = this.clock;
|
|
561
|
+
this.held = control.time;
|
|
562
|
+
this.anchor = at;
|
|
563
|
+
this.paused = control.paused;
|
|
564
|
+
this.pending = !!control.pending;
|
|
565
|
+
this.clock = clock;
|
|
566
|
+
previous?.cancel();
|
|
567
|
+
this.watch();
|
|
568
|
+
if (!this.pending)
|
|
569
|
+
this.resolveReady();
|
|
570
|
+
this.notify();
|
|
571
|
+
}
|
|
572
|
+
arrivalTime() {
|
|
573
|
+
return Math.max(0, ...[...this.entries].map((e) => e.track.arrival));
|
|
574
|
+
}
|
|
575
|
+
scheduleArrival() {
|
|
576
|
+
this.cancelArrival?.();
|
|
577
|
+
this.cancelArrival = undefined;
|
|
578
|
+
if (this.arrived || this.settled || this.paused || this.pending)
|
|
579
|
+
return;
|
|
580
|
+
const remaining = this.arrivalTime() - this.time();
|
|
581
|
+
if (remaining <= 0) {
|
|
582
|
+
this.arrived = true;
|
|
583
|
+
this.arrive();
|
|
584
|
+
this.notify();
|
|
585
|
+
}
|
|
586
|
+
else if (Number.isFinite(remaining)) {
|
|
587
|
+
const id = this.runtime.view.setTimeout(() => this.scheduleArrival(), Math.min(remaining, 2_147_483_647));
|
|
588
|
+
this.cancelArrival = () => this.runtime.view.clearTimeout(id);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
watch() {
|
|
592
|
+
if (this.clock)
|
|
593
|
+
void this.clock.finished.then(() => {
|
|
594
|
+
if (!this.settled &&
|
|
595
|
+
!this.paused &&
|
|
596
|
+
!this.pending &&
|
|
597
|
+
this.clock?.playState === 'finished')
|
|
598
|
+
this.runtime.completeOwner(this);
|
|
599
|
+
}, () => { });
|
|
600
|
+
}
|
|
601
|
+
refresh(at) {
|
|
602
|
+
if (this.settled)
|
|
603
|
+
return;
|
|
604
|
+
this.end = Math.max(0, ...[...this.entries].map((e) => e.track.end));
|
|
605
|
+
this.notify();
|
|
606
|
+
this.scheduleArrival();
|
|
607
|
+
if (!this.entries.size)
|
|
608
|
+
this.settle(this.complete, at);
|
|
609
|
+
else {
|
|
610
|
+
this.clock?.effect?.updateTiming({ duration: this.end });
|
|
611
|
+
this.watch();
|
|
612
|
+
if (!this.paused && !this.pending && this.time(at) >= this.end)
|
|
613
|
+
queueMicrotask(() => {
|
|
614
|
+
if (!this.settled && !this.paused && !this.pending && this.time() >= this.end)
|
|
615
|
+
this.runtime.completeOwner(this);
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
settle(completed, at) {
|
|
620
|
+
if (this.settled)
|
|
621
|
+
return;
|
|
622
|
+
this.held = this.time(at);
|
|
623
|
+
this.settled = true;
|
|
624
|
+
this.complete = completed;
|
|
625
|
+
this.clock?.cancel();
|
|
626
|
+
this.clock = undefined;
|
|
627
|
+
this.entries.clear();
|
|
628
|
+
this.cancelArrival?.();
|
|
629
|
+
this.cancelArrival = undefined;
|
|
630
|
+
this.arrived = true;
|
|
631
|
+
this.arrive();
|
|
632
|
+
this.notify();
|
|
633
|
+
this.feedback = undefined;
|
|
634
|
+
this.resolveReady();
|
|
635
|
+
this.resolve(completed);
|
|
636
|
+
this.runtime.forget(this);
|
|
637
|
+
// A retained terminal handle must not keep the document/context alive.
|
|
638
|
+
this.runtime = undefined;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
/** Internal implementation. Package exports and framework adapters are separate work. */
|
|
642
|
+
export class WebRuntime {
|
|
643
|
+
document;
|
|
644
|
+
sharedLayouts = new Map();
|
|
645
|
+
nextShared = 0;
|
|
646
|
+
diagnostic;
|
|
647
|
+
scopes = new Set();
|
|
648
|
+
resourceOwners = new WeakMap();
|
|
649
|
+
pointerFollowers = new Set();
|
|
650
|
+
viewportEntrances = new Set();
|
|
651
|
+
preferenceListeners = new Set();
|
|
652
|
+
view;
|
|
653
|
+
maxKeyframes;
|
|
654
|
+
settings;
|
|
655
|
+
presets = new Map();
|
|
656
|
+
surfaces = new Map();
|
|
657
|
+
animations = new Set();
|
|
658
|
+
ownership = createOwnership();
|
|
659
|
+
observers = new Map();
|
|
660
|
+
presses = new Map();
|
|
661
|
+
interactions = new Map();
|
|
662
|
+
gestureInputs = new WeakMap();
|
|
663
|
+
zoomInputs = new WeakMap();
|
|
664
|
+
headerInputs = new WeakMap();
|
|
665
|
+
reorderInputs = new WeakMap();
|
|
666
|
+
drags = new Map();
|
|
667
|
+
sizes = new Map();
|
|
668
|
+
layouts = new Map();
|
|
669
|
+
nextLayout = 0;
|
|
670
|
+
nextPress = 0;
|
|
671
|
+
nextInteraction = 0;
|
|
672
|
+
preference;
|
|
673
|
+
reported;
|
|
674
|
+
disposed = false;
|
|
675
|
+
pendingFrame;
|
|
676
|
+
scheduler;
|
|
677
|
+
values = new Set();
|
|
678
|
+
playbacks = new WeakSet();
|
|
679
|
+
paths = new Map();
|
|
680
|
+
itemAnimations = new Set();
|
|
681
|
+
stateControllers = new Set();
|
|
682
|
+
groups = new Set();
|
|
683
|
+
groupVisibility = new Set();
|
|
684
|
+
timers;
|
|
685
|
+
valueTracks = new Set();
|
|
686
|
+
valueStates = new Map();
|
|
687
|
+
valueTask = {
|
|
688
|
+
update: () => {
|
|
689
|
+
this.sampleValues();
|
|
690
|
+
return [...this.valueTracks.values()].some((e) => e.source.observed && !e.owner.paused && !e.owner.pending && !e.owner.settled);
|
|
691
|
+
},
|
|
692
|
+
};
|
|
693
|
+
scrollSources = new Set();
|
|
694
|
+
scrollLinks = new Map();
|
|
695
|
+
nodes = new WeakMap();
|
|
696
|
+
visibility = () => {
|
|
697
|
+
this.scheduler.hidden(this.document.hidden);
|
|
698
|
+
this.timers.visibilityChanged();
|
|
699
|
+
for (const change of this.groupVisibility)
|
|
700
|
+
change();
|
|
701
|
+
};
|
|
702
|
+
report = (error) => this.view.reportError(error);
|
|
703
|
+
constructor(document, options = {}) {
|
|
704
|
+
this.document = document;
|
|
705
|
+
const view = document?.defaultView;
|
|
706
|
+
if (!view)
|
|
707
|
+
throw new TypeError('A live document is required to create the Web runtime.');
|
|
708
|
+
this.view = view;
|
|
709
|
+
this.scheduler = new FrameScheduler({
|
|
710
|
+
now: () => this.now(),
|
|
711
|
+
request: (callback) => this.view.requestAnimationFrame(callback),
|
|
712
|
+
cancel: (id) => this.view.cancelAnimationFrame(id),
|
|
713
|
+
error: this.report,
|
|
714
|
+
});
|
|
715
|
+
this.timers = new ContextTimers(this.view, () => this.scheduler.now(), () => this.document.hidden);
|
|
716
|
+
if (!this.view.Animation || !this.view.KeyframeEffect || !document.timeline)
|
|
717
|
+
throw new Error('Web Animations API is required.');
|
|
718
|
+
this.settings = this.validate(options, { timeScale: 1, reducedMotion: 'user' });
|
|
719
|
+
this.maxKeyframes = options.maxKeyframes ?? 6001;
|
|
720
|
+
if (!Number.isSafeInteger(this.maxKeyframes) ||
|
|
721
|
+
this.maxKeyframes < 2 ||
|
|
722
|
+
this.maxKeyframes > 60001)
|
|
723
|
+
throw new RangeError('maxKeyframes must be an integer from 2 to 60001.');
|
|
724
|
+
this.preference = this.view.matchMedia('(prefers-reduced-motion: reduce)');
|
|
725
|
+
this.reported = this.reduced();
|
|
726
|
+
this.preference.addEventListener('change', this.preferenceChanged);
|
|
727
|
+
this.document.addEventListener('visibilitychange', this.visibility);
|
|
728
|
+
this.visibility();
|
|
729
|
+
for (const [name, preset] of Object.entries(builtins)) {
|
|
730
|
+
if (Object.keys(preset.keyframes).every((p) => p === 'scale' || properties.includes(p)))
|
|
731
|
+
this.presets.set(name, this.copyPreset(preset));
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
now() {
|
|
735
|
+
return this.view.performance.now();
|
|
736
|
+
}
|
|
737
|
+
assert() {
|
|
738
|
+
if (this.disposed)
|
|
739
|
+
throw new Error('The Web runtime is disposed.');
|
|
740
|
+
}
|
|
741
|
+
reduced() {
|
|
742
|
+
return (this.settings.reducedMotion === 'always' ||
|
|
743
|
+
(this.settings.reducedMotion === 'user' && this.preference.matches));
|
|
744
|
+
}
|
|
745
|
+
validate(options, current) {
|
|
746
|
+
if (!options || typeof options !== 'object')
|
|
747
|
+
throw new TypeError('Expected runtime options.');
|
|
748
|
+
const timeScale = options.timeScale ?? current.timeScale, reducedMotion = options.reducedMotion ?? current.reducedMotion;
|
|
749
|
+
if (!Number.isFinite(timeScale) || timeScale <= 0)
|
|
750
|
+
throw new RangeError('timeScale must be positive and finite.');
|
|
751
|
+
if (!['user', 'always', 'never'].includes(reducedMotion))
|
|
752
|
+
throw new TypeError('Invalid reduced-motion policy.');
|
|
753
|
+
return { timeScale, reducedMotion };
|
|
754
|
+
}
|
|
755
|
+
configure(options) {
|
|
756
|
+
this.assert();
|
|
757
|
+
this.settings = this.validate(options, this.settings);
|
|
758
|
+
this.preferenceChanged();
|
|
759
|
+
}
|
|
760
|
+
scope(setup) {
|
|
761
|
+
this.assert();
|
|
762
|
+
if (setup !== undefined && typeof setup !== 'function')
|
|
763
|
+
throw new TypeError('Expected scope setup.');
|
|
764
|
+
const scope = createWebScope(this, this.resourceOwners, () => this.scopes.delete(scope), (reason, resource) => {
|
|
765
|
+
this.diagnostic?.record({
|
|
766
|
+
reason,
|
|
767
|
+
time: this.now(),
|
|
768
|
+
scope: this.diagnostic.id(scope),
|
|
769
|
+
owner: resource && this.diagnostic.id(resource),
|
|
770
|
+
});
|
|
771
|
+
});
|
|
772
|
+
this.scopes.add(scope);
|
|
773
|
+
try {
|
|
774
|
+
const result = setup?.(scope);
|
|
775
|
+
if (result && typeof result.then === 'function')
|
|
776
|
+
throw new TypeError('Web motion setup must be synchronous.');
|
|
777
|
+
}
|
|
778
|
+
catch (error) {
|
|
779
|
+
try {
|
|
780
|
+
scope.dispose();
|
|
781
|
+
}
|
|
782
|
+
catch (cleanup) {
|
|
783
|
+
throw new AggregateError([error, cleanup], 'Web scope setup and cleanup failed.');
|
|
784
|
+
}
|
|
785
|
+
throw error;
|
|
786
|
+
}
|
|
787
|
+
return scope;
|
|
788
|
+
}
|
|
789
|
+
diagnostics(options) {
|
|
790
|
+
this.assert();
|
|
791
|
+
if (this.diagnostic)
|
|
792
|
+
throw new Error('This runtime already has a diagnostics owner.');
|
|
793
|
+
const collector = new DiagnosticCollector(options, () => this.diagnosticSnapshot(collector), () => {
|
|
794
|
+
if (this.diagnostic === collector)
|
|
795
|
+
this.diagnostic = undefined;
|
|
796
|
+
});
|
|
797
|
+
this.diagnostic = collector;
|
|
798
|
+
return collector.handle();
|
|
799
|
+
}
|
|
800
|
+
sharedLayout(container, options = {}) {
|
|
801
|
+
this.assert();
|
|
802
|
+
this.targets(container);
|
|
803
|
+
if (this.sharedLayouts.has(container))
|
|
804
|
+
throw new Error('The container already has a shared layout owner.');
|
|
805
|
+
const layer = `jolt:shared:${++this.nextShared}`;
|
|
806
|
+
const control = createSharedLayout(container, options, {
|
|
807
|
+
scheduler: this.scheduler,
|
|
808
|
+
reduced: () => this.reduced(),
|
|
809
|
+
preference: this.watchPreference,
|
|
810
|
+
animate: (target, frames, transition) => this.animate(target, frames, transition),
|
|
811
|
+
hide: (target) => {
|
|
812
|
+
this.play(target, { opacity: 0 }, { duration: 0 }, layer);
|
|
813
|
+
},
|
|
814
|
+
reveal: (target) => {
|
|
815
|
+
const surface = this.surfaces.get(target);
|
|
816
|
+
if (!surface || surface.disposed || !target.isConnected)
|
|
817
|
+
return;
|
|
818
|
+
const state = clone(surface.state);
|
|
819
|
+
state.rest.delete(keyOf('opacity', layer));
|
|
820
|
+
state.entries.delete(keyOf('opacity', layer));
|
|
821
|
+
try {
|
|
822
|
+
this.transaction(new Map([[surface, state]]), this.now());
|
|
823
|
+
}
|
|
824
|
+
catch {
|
|
825
|
+
this.release(target);
|
|
826
|
+
}
|
|
827
|
+
},
|
|
828
|
+
release: (target) => this.release(target),
|
|
829
|
+
forget: () => {
|
|
830
|
+
this.sharedLayouts.delete(container);
|
|
831
|
+
this.observe();
|
|
832
|
+
},
|
|
833
|
+
});
|
|
834
|
+
this.sharedLayouts.set(container, control);
|
|
835
|
+
this.observe();
|
|
836
|
+
return control;
|
|
837
|
+
}
|
|
838
|
+
diagnosticSnapshot(collector) {
|
|
839
|
+
return {
|
|
840
|
+
disposed: this.disposed,
|
|
841
|
+
resources: {
|
|
842
|
+
surfaces: this.surfaces.size,
|
|
843
|
+
animations: this.animations.size,
|
|
844
|
+
values: this.values.size,
|
|
845
|
+
paths: this.paths.size,
|
|
846
|
+
itemAnimations: this.itemAnimations.size,
|
|
847
|
+
stateControllers: this.stateControllers.size,
|
|
848
|
+
groups: this.groups.size,
|
|
849
|
+
timers: this.timers.size,
|
|
850
|
+
scopes: this.scopes.size,
|
|
851
|
+
pointerFollowers: this.pointerFollowers.size,
|
|
852
|
+
viewportEntrances: this.viewportEntrances.size,
|
|
853
|
+
presses: this.presses.size,
|
|
854
|
+
drags: this.drags.size,
|
|
855
|
+
interactions: [...this.interactions.values()].reduce((sum, entries) => sum + entries.size, 0),
|
|
856
|
+
sizes: this.sizes.size,
|
|
857
|
+
layouts: this.layouts.size,
|
|
858
|
+
sharedLayouts: this.sharedLayouts.size,
|
|
859
|
+
scrollSources: this.scrollSources.size,
|
|
860
|
+
observers: this.observers.size,
|
|
861
|
+
geometryObservers: [...this.surfaces.values()].reduce((sum, surface) => sum + surface.geometryObservers, 0),
|
|
862
|
+
frameTasks: this.scheduler.size,
|
|
863
|
+
framePending: this.scheduler.pending,
|
|
864
|
+
preferenceListeners: this.preferenceListeners.size,
|
|
865
|
+
},
|
|
866
|
+
targets: [...this.surfaces.values()].map((surface) => ({
|
|
867
|
+
id: collector.id(surface.target),
|
|
868
|
+
execution: surface.path,
|
|
869
|
+
channels: [
|
|
870
|
+
...[...surface.state.entries.values()].map((entry) => ({
|
|
871
|
+
property: entry.property,
|
|
872
|
+
layer: entry.layer,
|
|
873
|
+
kind: 'animation',
|
|
874
|
+
owner: collector.id(entry.owner),
|
|
875
|
+
paused: entry.owner.paused,
|
|
876
|
+
})),
|
|
877
|
+
...[...surface.state.bindings.values()].map((entry) => ({
|
|
878
|
+
property: entry.property,
|
|
879
|
+
kind: 'value',
|
|
880
|
+
owner: collector.id(entry.source),
|
|
881
|
+
})),
|
|
882
|
+
...[...surface.state.rest].map(([key, rest]) => ({
|
|
883
|
+
property: rest.property,
|
|
884
|
+
layer: JSON.parse(key)[1] ?? undefined,
|
|
885
|
+
kind: 'rest',
|
|
886
|
+
})),
|
|
887
|
+
],
|
|
888
|
+
})),
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
diagnosticEvent(reason, owner, target, property, layer) {
|
|
892
|
+
const diagnostic = this.diagnostic;
|
|
893
|
+
if (diagnostic)
|
|
894
|
+
diagnostic.record({
|
|
895
|
+
reason,
|
|
896
|
+
time: this.now(),
|
|
897
|
+
owner: owner && diagnostic.id(owner),
|
|
898
|
+
target: target && diagnostic.id(target),
|
|
899
|
+
property,
|
|
900
|
+
layer,
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
watchPreference = (listener) => {
|
|
904
|
+
this.preferenceListeners.add(listener);
|
|
905
|
+
return () => {
|
|
906
|
+
this.preferenceListeners.delete(listener);
|
|
907
|
+
};
|
|
908
|
+
};
|
|
909
|
+
pointerFollow(region, options = {}) {
|
|
910
|
+
this.assert();
|
|
911
|
+
this.targets(region);
|
|
912
|
+
let controller;
|
|
913
|
+
controller = createPointerFollow(region, options, {
|
|
914
|
+
runtime: this,
|
|
915
|
+
scheduler: this.scheduler,
|
|
916
|
+
reduced: () => this.reduced(),
|
|
917
|
+
preference: this.watchPreference,
|
|
918
|
+
forget: () => {
|
|
919
|
+
if (controller)
|
|
920
|
+
this.pointerFollowers.delete(controller);
|
|
921
|
+
},
|
|
922
|
+
});
|
|
923
|
+
this.pointerFollowers.add(controller);
|
|
924
|
+
return controller;
|
|
925
|
+
}
|
|
926
|
+
viewportEnter(target, options = {}) {
|
|
927
|
+
this.assert();
|
|
928
|
+
if (!options || typeof options !== 'object')
|
|
929
|
+
throw new TypeError('Expected viewport options.');
|
|
930
|
+
const targets = this.targets(target);
|
|
931
|
+
const frames = options.keyframes ?? 'fadeInUp';
|
|
932
|
+
const plans = prepare(frames, options.transition, this.presets, targets.length);
|
|
933
|
+
let controller;
|
|
934
|
+
controller = createViewportEntrance(targets, options, {
|
|
935
|
+
document: this.document,
|
|
936
|
+
alive: () => !this.disposed,
|
|
937
|
+
reduced: () => this.reduced(),
|
|
938
|
+
preference: this.watchPreference,
|
|
939
|
+
play: (index) => this.play(targets[index], frames, undefined, undefined, [plans[index]]),
|
|
940
|
+
forget: () => {
|
|
941
|
+
if (controller)
|
|
942
|
+
this.viewportEntrances.delete(controller);
|
|
943
|
+
},
|
|
944
|
+
});
|
|
945
|
+
this.viewportEntrances.add(controller);
|
|
946
|
+
return controller;
|
|
947
|
+
}
|
|
948
|
+
animateItems(items, animation = 'fadeInUp', options = {}) {
|
|
949
|
+
this.assert();
|
|
950
|
+
let controller;
|
|
951
|
+
controller = createItemsAnimation(items, animation, options, {
|
|
952
|
+
document: this.document,
|
|
953
|
+
assert: () => this.assert(),
|
|
954
|
+
alive: () => !this.disposed,
|
|
955
|
+
reduced: () => this.reduced(),
|
|
956
|
+
preference: this.watchPreference,
|
|
957
|
+
prepare: (input, frames, transition) => {
|
|
958
|
+
const targets = this.targets(input);
|
|
959
|
+
const plans = prepare(frames, transition, this.presets, targets.length);
|
|
960
|
+
const compiled = this.compileElements(targets, plans, this.now());
|
|
961
|
+
if (compiled.some((surface) => surface.plans.some(({ track }) => !Number.isFinite(track.end))))
|
|
962
|
+
throw new RangeError('Item entrances must have finite duration.');
|
|
963
|
+
return (index, settle) => {
|
|
964
|
+
const tracks = plans[index];
|
|
965
|
+
const instant = settle
|
|
966
|
+
? tracks.map((plan) => ({
|
|
967
|
+
...plan,
|
|
968
|
+
transition: {
|
|
969
|
+
...plan.transition,
|
|
970
|
+
curve: {
|
|
971
|
+
type: 'tween',
|
|
972
|
+
duration: 0,
|
|
973
|
+
ease: [(t) => t],
|
|
974
|
+
times: undefined,
|
|
975
|
+
},
|
|
976
|
+
delay: 0,
|
|
977
|
+
},
|
|
978
|
+
}))
|
|
979
|
+
: tracks;
|
|
980
|
+
return this.play(targets[index], frames, undefined, undefined, [instant]);
|
|
981
|
+
};
|
|
982
|
+
},
|
|
983
|
+
forget: () => {
|
|
984
|
+
if (controller)
|
|
985
|
+
this.itemAnimations.delete(controller);
|
|
986
|
+
},
|
|
987
|
+
});
|
|
988
|
+
this.itemAnimations.add(controller);
|
|
989
|
+
return controller;
|
|
990
|
+
}
|
|
991
|
+
copyPreset(preset) {
|
|
992
|
+
const copy = (v) => Array.isArray(v)
|
|
993
|
+
? v.map(copy)
|
|
994
|
+
: v && typeof v === 'object'
|
|
995
|
+
? Object.fromEntries(Object.entries(v).map(([k, x]) => [k, copy(x)]))
|
|
996
|
+
: v;
|
|
997
|
+
return copy(preset);
|
|
998
|
+
}
|
|
999
|
+
definePreset(name, preset) {
|
|
1000
|
+
this.assert();
|
|
1001
|
+
if (!name || Object.hasOwn(builtins, name))
|
|
1002
|
+
throw new TypeError('A custom preset needs a new nonempty name.');
|
|
1003
|
+
const copied = this.copyPreset(preset);
|
|
1004
|
+
prepare(copied.keyframes, copied.transition, this.presets, 1);
|
|
1005
|
+
this.presets.set(name, copied);
|
|
1006
|
+
}
|
|
1007
|
+
targets(target) {
|
|
1008
|
+
const result = Array.isArray(target) ? [...target] : [target];
|
|
1009
|
+
if (new Set(result).size !== result.length)
|
|
1010
|
+
throw new TypeError('Duplicate animation targets are unsupported.');
|
|
1011
|
+
for (const element of result)
|
|
1012
|
+
if (!(element instanceof this.view.HTMLElement) ||
|
|
1013
|
+
element.ownerDocument !== this.document ||
|
|
1014
|
+
!element.isConnected)
|
|
1015
|
+
throw new TypeError('Targets must be mounted HTML elements in this runtime document.');
|
|
1016
|
+
return result;
|
|
1017
|
+
}
|
|
1018
|
+
refresh(target) {
|
|
1019
|
+
this.assert();
|
|
1020
|
+
this.targets(target);
|
|
1021
|
+
const surface = this.surfaces.get(target);
|
|
1022
|
+
if (!surface)
|
|
1023
|
+
throw new Error('Claim the motion surface before refreshing its geometry.');
|
|
1024
|
+
surface.refreshGeometry();
|
|
1025
|
+
}
|
|
1026
|
+
observeGeometry(target) {
|
|
1027
|
+
this.assert();
|
|
1028
|
+
this.targets(target);
|
|
1029
|
+
const surface = this.surfaces.get(target);
|
|
1030
|
+
if (!surface)
|
|
1031
|
+
throw new Error('Claim the motion surface before observing its geometry.');
|
|
1032
|
+
return surface.observeGeometry();
|
|
1033
|
+
}
|
|
1034
|
+
animateSize(target, values, changeOrOptions, options) {
|
|
1035
|
+
this.assert();
|
|
1036
|
+
this.targets(target);
|
|
1037
|
+
const change = typeof changeOrOptions === 'function' ? changeOrOptions : undefined;
|
|
1038
|
+
const config = change
|
|
1039
|
+
? options
|
|
1040
|
+
: changeOrOptions;
|
|
1041
|
+
validateSize(values, change, config);
|
|
1042
|
+
let operation;
|
|
1043
|
+
operation = new SizeOperation(target, { ...values }, change, config, {
|
|
1044
|
+
scheduler: this.scheduler,
|
|
1045
|
+
settings: () => ({
|
|
1046
|
+
timeScale: this.settings.timeScale,
|
|
1047
|
+
reducedMotion: this.reduced(),
|
|
1048
|
+
}),
|
|
1049
|
+
geometry: (target) => this.geometryLease(target),
|
|
1050
|
+
forget: () => {
|
|
1051
|
+
if (this.sizes.get(target) === operation)
|
|
1052
|
+
this.sizes.delete(target);
|
|
1053
|
+
},
|
|
1054
|
+
}, this.sizes.get(target));
|
|
1055
|
+
this.sizes.set(target, operation);
|
|
1056
|
+
return operation;
|
|
1057
|
+
}
|
|
1058
|
+
geometryLease(target) {
|
|
1059
|
+
let surface = this.surfaces.get(target);
|
|
1060
|
+
if (!surface) {
|
|
1061
|
+
surface = new Surface(this, target);
|
|
1062
|
+
this.transaction(new Map([[surface, clone(surface.state)]]), this.now());
|
|
1063
|
+
}
|
|
1064
|
+
return surface.observeGeometry();
|
|
1065
|
+
}
|
|
1066
|
+
animateLayout(container, changeOrOptions, options) {
|
|
1067
|
+
this.assert();
|
|
1068
|
+
this.targets(container);
|
|
1069
|
+
const change = typeof changeOrOptions === 'function' ? changeOrOptions : undefined;
|
|
1070
|
+
const config = change
|
|
1071
|
+
? options
|
|
1072
|
+
: changeOrOptions;
|
|
1073
|
+
validateLayout(change, config);
|
|
1074
|
+
const layer = `jolt:layout:${++this.nextLayout}`;
|
|
1075
|
+
let operation;
|
|
1076
|
+
operation = new LayoutOperation(container, change, config, {
|
|
1077
|
+
scheduler: this.scheduler,
|
|
1078
|
+
geometry: (target) => this.geometryLease(target),
|
|
1079
|
+
basis: (target) => this.surfaces.get(target).layoutBasis(),
|
|
1080
|
+
scale: (target) => {
|
|
1081
|
+
const surface = this.surfaces.get(target);
|
|
1082
|
+
const at = this.document.timeline.currentTime;
|
|
1083
|
+
const value = (property) => {
|
|
1084
|
+
const key = keyOf(property, layer), entry = surface?.state.entries.get(key);
|
|
1085
|
+
// Match the presented document tick used by getBoundingClientRect.
|
|
1086
|
+
return entry
|
|
1087
|
+
? sampled(entry.points, entry.owner.time(typeof at === 'number' ? at : undefined))
|
|
1088
|
+
: (surface?.state.rest.get(key)?.value ?? 1);
|
|
1089
|
+
};
|
|
1090
|
+
return { x: value('scaleX'), y: value('scaleY') };
|
|
1091
|
+
},
|
|
1092
|
+
set: (target, values) => {
|
|
1093
|
+
this.play(target, values, { duration: 0 }, layer);
|
|
1094
|
+
},
|
|
1095
|
+
animate: (target, values, options) => this.play(target, values, options, layer),
|
|
1096
|
+
clear: (target) => {
|
|
1097
|
+
const surface = this.surfaces.get(target);
|
|
1098
|
+
if (!surface || surface.disposed || !target.isConnected)
|
|
1099
|
+
return;
|
|
1100
|
+
const state = clone(surface.state);
|
|
1101
|
+
for (const property of properties) {
|
|
1102
|
+
state.entries.delete(keyOf(property, layer));
|
|
1103
|
+
state.rest.delete(keyOf(property, layer));
|
|
1104
|
+
}
|
|
1105
|
+
try {
|
|
1106
|
+
this.transaction(new Map([[surface, state]]), this.now());
|
|
1107
|
+
}
|
|
1108
|
+
catch {
|
|
1109
|
+
this.release(target);
|
|
1110
|
+
}
|
|
1111
|
+
},
|
|
1112
|
+
forget: () => {
|
|
1113
|
+
if (this.layouts.get(container) === operation) {
|
|
1114
|
+
this.layouts.delete(container);
|
|
1115
|
+
this.observe();
|
|
1116
|
+
}
|
|
1117
|
+
},
|
|
1118
|
+
}, this.layouts.get(container));
|
|
1119
|
+
this.layouts.set(container, operation);
|
|
1120
|
+
this.observe();
|
|
1121
|
+
return operation;
|
|
1122
|
+
}
|
|
1123
|
+
rememberPlayback(animation) {
|
|
1124
|
+
this.playbacks.add(animation);
|
|
1125
|
+
}
|
|
1126
|
+
playbackProgress(animation) {
|
|
1127
|
+
this.assert();
|
|
1128
|
+
if (!this.playbacks.has(animation))
|
|
1129
|
+
throw new TypeError('Expected a playback handle from this runtime.');
|
|
1130
|
+
const node = new ProgressNode(animation, this.scheduler, this.report, () => this.values.delete(node));
|
|
1131
|
+
return this.valueHandle(node, node.readableHandle());
|
|
1132
|
+
}
|
|
1133
|
+
motionValue(initial) {
|
|
1134
|
+
this.assert();
|
|
1135
|
+
const node = new MotionInputNode(this.scheduler, initial, this.report, () => this.values.delete(node));
|
|
1136
|
+
return this.valueHandle(node, node.handle());
|
|
1137
|
+
}
|
|
1138
|
+
valueHandle(node, handle) {
|
|
1139
|
+
const result = Object.assign(handle, {
|
|
1140
|
+
to: ((input, output, options) => {
|
|
1141
|
+
this.assert();
|
|
1142
|
+
if (output.some((v) => typeof v === 'string')) {
|
|
1143
|
+
if (!output.every((v) => typeof v === 'string'))
|
|
1144
|
+
throw new TypeError('A color mapping requires color strings for every stop.');
|
|
1145
|
+
const colors = output.map((value) => parseColor(this.document, value));
|
|
1146
|
+
const mapped = new ColorMappedNode(node, input, colors, options, this.report, () => this.values.delete(mapped));
|
|
1147
|
+
const result = mapped.colorHandle();
|
|
1148
|
+
this.values.add(mapped);
|
|
1149
|
+
this.nodes.set(result, mapped);
|
|
1150
|
+
return result;
|
|
1151
|
+
}
|
|
1152
|
+
const mapped = new DerivedValueNode(node, numericMap(input, output, options), this.report, () => this.values.delete(mapped));
|
|
1153
|
+
return this.valueHandle(mapped, mapped.readableHandle());
|
|
1154
|
+
}),
|
|
1155
|
+
});
|
|
1156
|
+
this.values.add(node);
|
|
1157
|
+
this.nodes.set(result, node);
|
|
1158
|
+
return result;
|
|
1159
|
+
}
|
|
1160
|
+
scrollNode(source, axis = 'y') {
|
|
1161
|
+
const node = new ScrollValueNode(this.document, source, axis, this.scheduler, this.report, () => {
|
|
1162
|
+
this.values.delete(node);
|
|
1163
|
+
this.scrollSources.delete(node);
|
|
1164
|
+
this.observe();
|
|
1165
|
+
});
|
|
1166
|
+
this.scrollSources.add(node);
|
|
1167
|
+
this.values.add(node);
|
|
1168
|
+
this.observe();
|
|
1169
|
+
return node;
|
|
1170
|
+
}
|
|
1171
|
+
scrollValue(source = this.document, options) {
|
|
1172
|
+
this.assert();
|
|
1173
|
+
const node = this.scrollNode(source, scrollAxis(options));
|
|
1174
|
+
return this.valueHandle(node, Object.assign(node.readableHandle(), { refresh: () => node.refresh() }));
|
|
1175
|
+
}
|
|
1176
|
+
scrollLinked(source, target, frames, options) {
|
|
1177
|
+
this.assert();
|
|
1178
|
+
this.targets(target);
|
|
1179
|
+
const plan = scrollPlan(frames, options);
|
|
1180
|
+
const scroll = this.scrollNode(source, plan.axis);
|
|
1181
|
+
const nodes = new Set();
|
|
1182
|
+
let binding;
|
|
1183
|
+
try {
|
|
1184
|
+
const values = {};
|
|
1185
|
+
for (const [property, entry] of plan.plans) {
|
|
1186
|
+
const node = new ScrollLinkedNode(scroll, property, plan.range, entry.points, plan.native, entry.input, entry.output, () => this.reduced(), this.report, () => this.values.delete(node));
|
|
1187
|
+
nodes.add(node);
|
|
1188
|
+
values[property] = this.valueHandle(node, node.readableHandle());
|
|
1189
|
+
}
|
|
1190
|
+
binding = this.bind(target, values);
|
|
1191
|
+
}
|
|
1192
|
+
catch (error) {
|
|
1193
|
+
for (const node of nodes)
|
|
1194
|
+
node.dispose();
|
|
1195
|
+
scroll.dispose();
|
|
1196
|
+
throw error;
|
|
1197
|
+
}
|
|
1198
|
+
const surface = this.surfaces.get(target);
|
|
1199
|
+
let ended = false;
|
|
1200
|
+
const link = {
|
|
1201
|
+
owns: () => !ended &&
|
|
1202
|
+
!surface.disposed &&
|
|
1203
|
+
[...surface.state.bindings.values()].some((b) => nodes.has(b.source)),
|
|
1204
|
+
get execution() {
|
|
1205
|
+
return link.owns()
|
|
1206
|
+
? surface.path === 'scroll-timeline'
|
|
1207
|
+
? 'scroll-timeline'
|
|
1208
|
+
: 'scheduler'
|
|
1209
|
+
: 'released';
|
|
1210
|
+
},
|
|
1211
|
+
refresh: () => {
|
|
1212
|
+
if (ended)
|
|
1213
|
+
return;
|
|
1214
|
+
scroll.refresh();
|
|
1215
|
+
if (ended || scroll.disposed)
|
|
1216
|
+
return;
|
|
1217
|
+
surface.refreshGeometry();
|
|
1218
|
+
this.transaction(new Map([[surface, clone(surface.state)]]), this.now());
|
|
1219
|
+
},
|
|
1220
|
+
dispose: () => {
|
|
1221
|
+
if (ended)
|
|
1222
|
+
return;
|
|
1223
|
+
ended = true;
|
|
1224
|
+
const links = this.scrollLinks.get(target);
|
|
1225
|
+
links?.delete(link);
|
|
1226
|
+
if (!links?.size)
|
|
1227
|
+
this.scrollLinks.delete(target);
|
|
1228
|
+
binding?.dispose();
|
|
1229
|
+
for (const node of nodes)
|
|
1230
|
+
node.dispose();
|
|
1231
|
+
scroll.dispose();
|
|
1232
|
+
},
|
|
1233
|
+
};
|
|
1234
|
+
const links = this.scrollLinks.get(target) ?? new Set();
|
|
1235
|
+
links.add(link);
|
|
1236
|
+
this.scrollLinks.set(target, links);
|
|
1237
|
+
scroll.onDispose(link.dispose);
|
|
1238
|
+
return link;
|
|
1239
|
+
}
|
|
1240
|
+
springValue(source, options = {}) {
|
|
1241
|
+
this.assert();
|
|
1242
|
+
const input = this.nodes.get(source);
|
|
1243
|
+
if (!input || input.disposed || input.kind !== 'number')
|
|
1244
|
+
throw new TypeError('A continuous spring requires a live input motion value from this runtime.');
|
|
1245
|
+
const node = new SpringValueNode(this.scheduler, input, options, () => ({ reduced: this.reduced(), timeScale: this.settings.timeScale }), this.report, () => this.values.delete(node));
|
|
1246
|
+
return this.valueHandle(node, node.springHandle());
|
|
1247
|
+
}
|
|
1248
|
+
bind(target, values) {
|
|
1249
|
+
const binding = this.bindInLayer(target, values);
|
|
1250
|
+
return { dispose: binding.dispose };
|
|
1251
|
+
}
|
|
1252
|
+
bindInLayer(target, values, layer) {
|
|
1253
|
+
this.assert();
|
|
1254
|
+
this.targets(target);
|
|
1255
|
+
if (!values || typeof values !== 'object' || !Object.keys(values).length)
|
|
1256
|
+
throw new TypeError('bind() requires numeric motion values.');
|
|
1257
|
+
const surface = this.surfaces.get(target) ?? new Surface(this, target);
|
|
1258
|
+
const state = clone(surface.state);
|
|
1259
|
+
const added = new Map();
|
|
1260
|
+
for (const [name, value] of Object.entries(values)) {
|
|
1261
|
+
if (!keyframeProperties.includes(name))
|
|
1262
|
+
throw new TypeError('Unsupported binding property.');
|
|
1263
|
+
const source = this.nodes.get(value);
|
|
1264
|
+
if (!source || source.disposed)
|
|
1265
|
+
throw new TypeError('Bindings require a live value from this runtime.');
|
|
1266
|
+
for (const property of expand(name)) {
|
|
1267
|
+
if (name !== property && values[property])
|
|
1268
|
+
continue;
|
|
1269
|
+
if (name === 'borderRadius' && values[property.slice(0, -1)])
|
|
1270
|
+
continue;
|
|
1271
|
+
if (isColor(property) !== (source.kind === 'color'))
|
|
1272
|
+
throw new TypeError('Color channels require a color mapping; numeric channels require numeric values.');
|
|
1273
|
+
this.ensureRadius(state, surface, property);
|
|
1274
|
+
if (layer && !isTransform(property))
|
|
1275
|
+
throw new TypeError('Interaction layers require transform or opacity channels.');
|
|
1276
|
+
const key = keyOf(property, layer), entry = { property, source, layer };
|
|
1277
|
+
state.entries.delete(key);
|
|
1278
|
+
state.rest.delete(key);
|
|
1279
|
+
state.bindings.set(key, entry);
|
|
1280
|
+
added.set(key, entry);
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
this.transaction(new Map([[surface, state]]), this.now());
|
|
1284
|
+
// Interaction consumers explicitly track changing image, row and header geometry.
|
|
1285
|
+
// Keep that lease active until their private contribution has been removed.
|
|
1286
|
+
const geometry = layer ? surface.observeGeometry() : undefined;
|
|
1287
|
+
return {
|
|
1288
|
+
dispose: () => {
|
|
1289
|
+
try {
|
|
1290
|
+
this.unbind(surface, added);
|
|
1291
|
+
}
|
|
1292
|
+
finally {
|
|
1293
|
+
geometry?.dispose();
|
|
1294
|
+
}
|
|
1295
|
+
},
|
|
1296
|
+
owns: () => !surface.disposed &&
|
|
1297
|
+
[...added].every(([key, entry]) => surface.state.bindings.get(key) === entry),
|
|
1298
|
+
};
|
|
1299
|
+
}
|
|
1300
|
+
unbind(surface, selected) {
|
|
1301
|
+
if (surface.disposed)
|
|
1302
|
+
return;
|
|
1303
|
+
if (!surface.target.isConnected ||
|
|
1304
|
+
surface.target.ownerDocument !== this.document ||
|
|
1305
|
+
!surface.target.getClientRects().length) {
|
|
1306
|
+
this.release(surface.target);
|
|
1307
|
+
return;
|
|
1308
|
+
}
|
|
1309
|
+
const state = clone(surface.state);
|
|
1310
|
+
for (const [key, entry] of selected)
|
|
1311
|
+
if (state.bindings.get(key) === entry) {
|
|
1312
|
+
state.bindings.delete(key);
|
|
1313
|
+
if (entry.layer)
|
|
1314
|
+
state.rest.delete(key);
|
|
1315
|
+
else
|
|
1316
|
+
this.rest(state, key, entry.property, entry.source.get());
|
|
1317
|
+
}
|
|
1318
|
+
if (state.bindings.size !== surface.state.bindings.size) {
|
|
1319
|
+
try {
|
|
1320
|
+
this.transaction(new Map([[surface, state]]), this.now());
|
|
1321
|
+
}
|
|
1322
|
+
catch (error) {
|
|
1323
|
+
this.release(surface.target);
|
|
1324
|
+
throw error;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
animate(target, animation, options) {
|
|
1329
|
+
if (typeof animation === 'number' ||
|
|
1330
|
+
Array.isArray(animation) ||
|
|
1331
|
+
this.nodes.has(target))
|
|
1332
|
+
return this.animateValue(target, animation, options);
|
|
1333
|
+
return this.play(target, animation, options);
|
|
1334
|
+
}
|
|
1335
|
+
drawPath(target, options = {}) {
|
|
1336
|
+
this.assert();
|
|
1337
|
+
let drawing;
|
|
1338
|
+
drawing = new StrokeSurface(target, options, {
|
|
1339
|
+
document: this.document,
|
|
1340
|
+
now: () => this.now(),
|
|
1341
|
+
settings: () => ({
|
|
1342
|
+
timeScale: this.settings.timeScale,
|
|
1343
|
+
reducedMotion: this.reduced(),
|
|
1344
|
+
}),
|
|
1345
|
+
maxKeyframes: this.maxKeyframes,
|
|
1346
|
+
after: (ms, callback) => this.timers.after(ms, callback),
|
|
1347
|
+
remember: (animation) => this.rememberPlayback(animation),
|
|
1348
|
+
preference: (callback) => {
|
|
1349
|
+
this.preferenceListeners.add(callback);
|
|
1350
|
+
return () => this.preferenceListeners.delete(callback);
|
|
1351
|
+
},
|
|
1352
|
+
assert: () => this.assert(),
|
|
1353
|
+
forget: () => {
|
|
1354
|
+
if (this.paths.get(target) === drawing) {
|
|
1355
|
+
this.paths.delete(target);
|
|
1356
|
+
this.observe();
|
|
1357
|
+
}
|
|
1358
|
+
},
|
|
1359
|
+
}, this.paths.get(target));
|
|
1360
|
+
this.paths.set(target, drawing);
|
|
1361
|
+
this.observe();
|
|
1362
|
+
return drawing;
|
|
1363
|
+
}
|
|
1364
|
+
motionStates(targets, definitions, options = {}) {
|
|
1365
|
+
this.assert();
|
|
1366
|
+
let controller;
|
|
1367
|
+
const result = createMotionStates(targets, definitions, options, {
|
|
1368
|
+
assert: () => this.assert(),
|
|
1369
|
+
validateTarget: (target) => {
|
|
1370
|
+
this.targets(target);
|
|
1371
|
+
},
|
|
1372
|
+
prepare: (target, frames, transition) => {
|
|
1373
|
+
const plans = prepare(frames, transition, this.presets, 1);
|
|
1374
|
+
if (target)
|
|
1375
|
+
this.compileElements([target], plans, this.now());
|
|
1376
|
+
else
|
|
1377
|
+
for (const plan of plans[0])
|
|
1378
|
+
for (const value of plan.frames) {
|
|
1379
|
+
if (value === null || typeof value === 'number')
|
|
1380
|
+
continue;
|
|
1381
|
+
const property = plan.source.endsWith('RadiusX') || plan.source.endsWith('RadiusY')
|
|
1382
|
+
? plan.source.slice(0, -1)
|
|
1383
|
+
: plan.source;
|
|
1384
|
+
if (!this.view.CSS.supports(cssName(property), value))
|
|
1385
|
+
throw new TypeError(`Invalid ${property}: ${value}`);
|
|
1386
|
+
}
|
|
1387
|
+
return () => {
|
|
1388
|
+
if (!target)
|
|
1389
|
+
throw new Error('Attach a target before playing.');
|
|
1390
|
+
return this.play(target, {}, undefined, undefined, plans);
|
|
1391
|
+
};
|
|
1392
|
+
},
|
|
1393
|
+
set: (target, frames) => {
|
|
1394
|
+
this.set(target, frames);
|
|
1395
|
+
},
|
|
1396
|
+
forget: () => {
|
|
1397
|
+
if (controller)
|
|
1398
|
+
this.stateControllers.delete(controller);
|
|
1399
|
+
},
|
|
1400
|
+
});
|
|
1401
|
+
controller = result;
|
|
1402
|
+
this.stateControllers.add(result);
|
|
1403
|
+
return result;
|
|
1404
|
+
}
|
|
1405
|
+
sequence(steps) {
|
|
1406
|
+
return this.group(steps, false);
|
|
1407
|
+
}
|
|
1408
|
+
timeline(steps) {
|
|
1409
|
+
return this.group(steps, true);
|
|
1410
|
+
}
|
|
1411
|
+
group(steps, controlled) {
|
|
1412
|
+
this.assert();
|
|
1413
|
+
const seeds = new Map(), claimed = new Map();
|
|
1414
|
+
const prepared = sequenceSteps(steps, controlled, (input, animation, options) => {
|
|
1415
|
+
if (typeof animation === 'number' ||
|
|
1416
|
+
Array.isArray(animation) ||
|
|
1417
|
+
this.nodes.has(input)) {
|
|
1418
|
+
if (!controlled)
|
|
1419
|
+
throw new TypeError('Numeric tuple steps belong to timeline(); sequence can use a value factory.');
|
|
1420
|
+
const value = this.mutable(input), plan = valuePlan(options);
|
|
1421
|
+
valueTrack(animation, plan, value.get(), 0, { timeScale: this.settings.timeScale, reducedMotion: this.reduced() });
|
|
1422
|
+
return () => this.animateValue(input, animation, plan);
|
|
1423
|
+
}
|
|
1424
|
+
const targets = this.targets(input), plans = prepare(animation, options, this.presets, targets.length);
|
|
1425
|
+
this.compileElements(targets, plans, this.now());
|
|
1426
|
+
for (let index = 0; index < targets.length; index++) {
|
|
1427
|
+
const target = targets[index], used = claimed.get(target) ?? new Set(), initial = seeds.get(target) ?? [];
|
|
1428
|
+
for (const plan of plans[index]) {
|
|
1429
|
+
const first = plan.frames[0];
|
|
1430
|
+
if (!used.has(plan.property) &&
|
|
1431
|
+
first !== null &&
|
|
1432
|
+
first !== undefined &&
|
|
1433
|
+
!plan.relative &&
|
|
1434
|
+
plan.layer === undefined)
|
|
1435
|
+
initial.push({
|
|
1436
|
+
...plan,
|
|
1437
|
+
frames: [first, first],
|
|
1438
|
+
transition: {
|
|
1439
|
+
curve: {
|
|
1440
|
+
type: 'tween',
|
|
1441
|
+
duration: 0,
|
|
1442
|
+
ease: [(t) => t],
|
|
1443
|
+
times: undefined,
|
|
1444
|
+
},
|
|
1445
|
+
delay: 0,
|
|
1446
|
+
repeat: 0,
|
|
1447
|
+
reverse: false,
|
|
1448
|
+
},
|
|
1449
|
+
});
|
|
1450
|
+
used.add(plan.property);
|
|
1451
|
+
}
|
|
1452
|
+
claimed.set(target, used);
|
|
1453
|
+
seeds.set(target, initial);
|
|
1454
|
+
}
|
|
1455
|
+
return () => this.play(targets, {}, undefined, undefined, plans);
|
|
1456
|
+
});
|
|
1457
|
+
// Every descriptor is checked before applying any hidden starting state.
|
|
1458
|
+
for (const [target, plans] of seeds)
|
|
1459
|
+
if (plans.length)
|
|
1460
|
+
this.play(target, {}, undefined, undefined, [plans]);
|
|
1461
|
+
const animation = composePrepared(prepared, controlled, {
|
|
1462
|
+
driver: {
|
|
1463
|
+
now: () => this.scheduler.now(),
|
|
1464
|
+
after: (ms, callback) => this.timers.after(ms, callback),
|
|
1465
|
+
},
|
|
1466
|
+
slowdown: 1 / this.settings.timeScale,
|
|
1467
|
+
active: () => !this.document.hidden,
|
|
1468
|
+
cancelled: () => this.disposed,
|
|
1469
|
+
});
|
|
1470
|
+
if (this.disposed) {
|
|
1471
|
+
animation.stop();
|
|
1472
|
+
return animation;
|
|
1473
|
+
}
|
|
1474
|
+
this.groups.add(animation);
|
|
1475
|
+
this.rememberPlayback(animation);
|
|
1476
|
+
let held = false;
|
|
1477
|
+
const visibility = () => {
|
|
1478
|
+
if (!controlled)
|
|
1479
|
+
return;
|
|
1480
|
+
const handle = animation;
|
|
1481
|
+
if (this.document.hidden && !handle.paused) {
|
|
1482
|
+
held = true;
|
|
1483
|
+
handle.pause();
|
|
1484
|
+
}
|
|
1485
|
+
else if (!this.document.hidden && held) {
|
|
1486
|
+
held = false;
|
|
1487
|
+
handle.play();
|
|
1488
|
+
}
|
|
1489
|
+
};
|
|
1490
|
+
this.groupVisibility.add(visibility);
|
|
1491
|
+
visibility();
|
|
1492
|
+
const done = () => {
|
|
1493
|
+
this.groups.delete(animation);
|
|
1494
|
+
this.groupVisibility.delete(visibility);
|
|
1495
|
+
};
|
|
1496
|
+
void animation.finished.then(done, done);
|
|
1497
|
+
return animation;
|
|
1498
|
+
}
|
|
1499
|
+
decay(target, velocity, options) {
|
|
1500
|
+
this.assert();
|
|
1501
|
+
const targets = this.targets(target), plans = decayPlans(velocity, options);
|
|
1502
|
+
return this.play(targets, {}, undefined, undefined, targets.map(() => plans));
|
|
1503
|
+
}
|
|
1504
|
+
seekableTimeline(steps, options = {}) {
|
|
1505
|
+
this.assert();
|
|
1506
|
+
const leaves = sceneSteps(steps, options);
|
|
1507
|
+
const prepared = [];
|
|
1508
|
+
const surfaces = new Map();
|
|
1509
|
+
const claimed = new Map();
|
|
1510
|
+
for (const leaf of leaves) {
|
|
1511
|
+
const source = 'value' in leaf ? this.nodes.get(leaf.value) : undefined;
|
|
1512
|
+
let surface;
|
|
1513
|
+
if ('value' in leaf) {
|
|
1514
|
+
if (!source || source.disposed || !(source instanceof MotionInputNode))
|
|
1515
|
+
throw new TypeError('Scene values must be mutable numeric inputs owned by this runtime.');
|
|
1516
|
+
}
|
|
1517
|
+
else {
|
|
1518
|
+
this.targets(leaf.target);
|
|
1519
|
+
surface =
|
|
1520
|
+
surfaces.get(leaf.target) ??
|
|
1521
|
+
this.surfaces.get(leaf.target) ??
|
|
1522
|
+
new Surface(this, leaf.target);
|
|
1523
|
+
surface.assert();
|
|
1524
|
+
surfaces.set(leaf.target, surface);
|
|
1525
|
+
}
|
|
1526
|
+
const transition = typeof leaf.transition === 'string'
|
|
1527
|
+
? { ...springDefinitions[leaf.transition], layer: leaf.layer }
|
|
1528
|
+
: { ...(leaf.transition ?? { duration: 300 }), layer: leaf.layer };
|
|
1529
|
+
if (typeof leaf.transition === 'string' &&
|
|
1530
|
+
!Object.hasOwn(springDefinitions, leaf.transition))
|
|
1531
|
+
throw new TypeError('Unknown scene spring.');
|
|
1532
|
+
const frames = 'value' in leaf ? { opacity: leaf.keyframes } : leaf.keyframes;
|
|
1533
|
+
const plans = prepare(frames, transition, this.presets, 1)[0];
|
|
1534
|
+
const target = surface?.target ?? source;
|
|
1535
|
+
let keys = claimed.get(target);
|
|
1536
|
+
if (!keys)
|
|
1537
|
+
claimed.set(target, (keys = new Set()));
|
|
1538
|
+
for (const plan of plans) {
|
|
1539
|
+
const key = keyOf(plan.property, plan.layer);
|
|
1540
|
+
if (keys.has(key))
|
|
1541
|
+
throw new TypeError('Each scene channel has one descriptor; combine its movements into keyframes.');
|
|
1542
|
+
keys.add(key);
|
|
1543
|
+
plan.transition = { ...plan.transition, delay: plan.transition.delay + leaf.at };
|
|
1544
|
+
const values = plan.frames.map((v) => {
|
|
1545
|
+
if (v === null)
|
|
1546
|
+
throw new TypeError('Scene keyframes must be explicit.');
|
|
1547
|
+
if (surface)
|
|
1548
|
+
return resolveProperty(surface.target, plan.property, plan.source, v);
|
|
1549
|
+
if (typeof v !== 'number' || !Number.isFinite(v))
|
|
1550
|
+
throw new TypeError('Scene value tracks require finite numbers.');
|
|
1551
|
+
return v;
|
|
1552
|
+
});
|
|
1553
|
+
const track = createTrack(coreProperty(plan.property), values, plan.transition, 0, { timeScale: this.settings.timeScale, reducedMotion: this.reduced() });
|
|
1554
|
+
prepared.push({
|
|
1555
|
+
surface,
|
|
1556
|
+
source,
|
|
1557
|
+
plan,
|
|
1558
|
+
track,
|
|
1559
|
+
points: flatten(track, this.maxKeyframes),
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
const at = this.now(), owner = new Owner(this, Math.max(0, ...prepared.map((p) => p.track.end)), at);
|
|
1564
|
+
const proposals = new Map(), valueEntries = [];
|
|
1565
|
+
for (const item of prepared) {
|
|
1566
|
+
const { surface, source, plan, track, points } = item;
|
|
1567
|
+
const entry = {
|
|
1568
|
+
property: plan.property,
|
|
1569
|
+
layer: plan.layer,
|
|
1570
|
+
track,
|
|
1571
|
+
points,
|
|
1572
|
+
owner,
|
|
1573
|
+
};
|
|
1574
|
+
if (surface) {
|
|
1575
|
+
const state = proposals.get(surface) ?? clone(surface.state);
|
|
1576
|
+
this.ensureRadius(state, surface, plan.property);
|
|
1577
|
+
const key = keyOf(plan.property, plan.layer);
|
|
1578
|
+
state.rest.delete(key);
|
|
1579
|
+
state.bindings.delete(key);
|
|
1580
|
+
state.entries.set(key, entry);
|
|
1581
|
+
proposals.set(surface, state);
|
|
1582
|
+
}
|
|
1583
|
+
else {
|
|
1584
|
+
const value = {
|
|
1585
|
+
...entry,
|
|
1586
|
+
source: source,
|
|
1587
|
+
};
|
|
1588
|
+
valueEntries.push(value);
|
|
1589
|
+
owner.entries.add(value);
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
this.transaction(proposals, at, new Map([
|
|
1593
|
+
[
|
|
1594
|
+
owner,
|
|
1595
|
+
{
|
|
1596
|
+
time: 0,
|
|
1597
|
+
paused: options.paused ?? false,
|
|
1598
|
+
pending: this.document.timeline.currentTime === null,
|
|
1599
|
+
},
|
|
1600
|
+
],
|
|
1601
|
+
]));
|
|
1602
|
+
for (const entry of valueEntries) {
|
|
1603
|
+
this.claimValue(entry);
|
|
1604
|
+
}
|
|
1605
|
+
this.sampleValues();
|
|
1606
|
+
this.scheduleValues();
|
|
1607
|
+
owner.refresh(at);
|
|
1608
|
+
return owner;
|
|
1609
|
+
}
|
|
1610
|
+
readValue(state, at = this.now()) {
|
|
1611
|
+
let value = 0, velocity = 0, moving = false;
|
|
1612
|
+
for (const [key, rest] of state.rests)
|
|
1613
|
+
if (!state.entries.has(key))
|
|
1614
|
+
value += rest;
|
|
1615
|
+
for (const entry of state.entries.values()) {
|
|
1616
|
+
const time = entry.owner.time(at);
|
|
1617
|
+
value += entry.track.valueAt(time);
|
|
1618
|
+
const running = !entry.owner.paused && !entry.owner.pending && !entry.owner.settled;
|
|
1619
|
+
if (running)
|
|
1620
|
+
velocity += entry.track.velocityAt(time);
|
|
1621
|
+
moving ||= running;
|
|
1622
|
+
}
|
|
1623
|
+
return { value, velocity, moving };
|
|
1624
|
+
}
|
|
1625
|
+
valueState(source) {
|
|
1626
|
+
let state = this.valueStates.get(source);
|
|
1627
|
+
if (!state) {
|
|
1628
|
+
state = {
|
|
1629
|
+
source,
|
|
1630
|
+
entries: new Map(),
|
|
1631
|
+
rests: new Map([['', source.get()]]),
|
|
1632
|
+
cancel: () => this.resetValue(source),
|
|
1633
|
+
};
|
|
1634
|
+
this.valueStates.set(source, state);
|
|
1635
|
+
source.claimWriter(state.cancel);
|
|
1636
|
+
source.playback(() => this.readValue(state), () => this.scheduleValues());
|
|
1637
|
+
}
|
|
1638
|
+
return state;
|
|
1639
|
+
}
|
|
1640
|
+
claimValue(entry) {
|
|
1641
|
+
const state = this.valueState(entry.source), key = entry.layer ?? '';
|
|
1642
|
+
const old = state.entries.get(key);
|
|
1643
|
+
if (old)
|
|
1644
|
+
this.removeValue(old, false);
|
|
1645
|
+
state.rests.delete(key);
|
|
1646
|
+
state.entries.set(key, entry);
|
|
1647
|
+
entry.owner.entries.add(entry);
|
|
1648
|
+
this.valueTracks.add(entry);
|
|
1649
|
+
}
|
|
1650
|
+
scheduleValues() {
|
|
1651
|
+
if ([...this.valueTracks].some((e) => e.source.observed && !e.owner.paused && !e.owner.pending && !e.owner.settled))
|
|
1652
|
+
this.scheduler.add(this.valueTask);
|
|
1653
|
+
else
|
|
1654
|
+
this.scheduler.remove(this.valueTask);
|
|
1655
|
+
}
|
|
1656
|
+
sampleValues() {
|
|
1657
|
+
const at = this.now();
|
|
1658
|
+
for (const state of this.valueStates.values()) {
|
|
1659
|
+
const sample = this.readValue(state, at);
|
|
1660
|
+
state.source.writeSample(sample.value, sample.velocity);
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
removeValue(entry, completed) {
|
|
1664
|
+
if (!this.valueTracks.has(entry))
|
|
1665
|
+
return;
|
|
1666
|
+
const state = this.valueStates.get(entry.source), key = entry.layer ?? '';
|
|
1667
|
+
const value = completed ? entry.track.to : entry.track.valueAt(entry.owner.time());
|
|
1668
|
+
this.valueTracks.delete(entry);
|
|
1669
|
+
state.entries.delete(key);
|
|
1670
|
+
if (completed || !key)
|
|
1671
|
+
state.rests.set(key, value);
|
|
1672
|
+
else
|
|
1673
|
+
state.rests.delete(key);
|
|
1674
|
+
entry.owner.entries.delete(entry);
|
|
1675
|
+
entry.owner.complete &&= completed;
|
|
1676
|
+
const sample = this.readValue(state);
|
|
1677
|
+
entry.source.writeSample(sample.value, sample.velocity);
|
|
1678
|
+
entry.owner.refresh(this.now());
|
|
1679
|
+
this.scheduleValues();
|
|
1680
|
+
}
|
|
1681
|
+
resetValue(source, layer) {
|
|
1682
|
+
const state = this.valueStates.get(source);
|
|
1683
|
+
if (!state)
|
|
1684
|
+
return;
|
|
1685
|
+
const sample = this.readValue(state);
|
|
1686
|
+
if (layer !== undefined) {
|
|
1687
|
+
if (!layer)
|
|
1688
|
+
throw new TypeError('A layer needs a nonempty name.');
|
|
1689
|
+
const entry = state.entries.get(layer);
|
|
1690
|
+
if (entry)
|
|
1691
|
+
this.removeValue(entry, false);
|
|
1692
|
+
state.rests.delete(layer);
|
|
1693
|
+
const next = this.readValue(state);
|
|
1694
|
+
source.writeSample(next.value, next.velocity);
|
|
1695
|
+
}
|
|
1696
|
+
else {
|
|
1697
|
+
for (const entry of [...state.entries.values()])
|
|
1698
|
+
this.removeValue(entry, false);
|
|
1699
|
+
this.valueStates.delete(source);
|
|
1700
|
+
source.releaseWriter(state.cancel);
|
|
1701
|
+
source.playback();
|
|
1702
|
+
source.writeSample(sample.value, 0);
|
|
1703
|
+
}
|
|
1704
|
+
this.scheduleValues();
|
|
1705
|
+
}
|
|
1706
|
+
mutable(target) {
|
|
1707
|
+
const node = this.nodes.get(target);
|
|
1708
|
+
if (!(node instanceof MotionInputNode) || node.disposed)
|
|
1709
|
+
throw new TypeError('Expected a live mutable motion value owned by this runtime.');
|
|
1710
|
+
return node;
|
|
1711
|
+
}
|
|
1712
|
+
animateValue(target, frames, options) {
|
|
1713
|
+
this.assert();
|
|
1714
|
+
const source = this.mutable(target), plan = valuePlan(options);
|
|
1715
|
+
const at = this.now(), state = this.valueStates.get(source), key = plan.layer ?? '', old = state?.entries.get(key);
|
|
1716
|
+
const from = old
|
|
1717
|
+
? old.track.valueAt(old.owner.time(at))
|
|
1718
|
+
: (state?.rests.get(key) ?? (key ? 0 : source.get()));
|
|
1719
|
+
const velocity = old && !old.owner.paused && !old.owner.pending
|
|
1720
|
+
? old.track.velocityAt(old.owner.time(at))
|
|
1721
|
+
: 0;
|
|
1722
|
+
const track = valueTrack(frames, plan, from, velocity, {
|
|
1723
|
+
timeScale: this.settings.timeScale,
|
|
1724
|
+
reducedMotion: this.reduced(),
|
|
1725
|
+
});
|
|
1726
|
+
return this.playValueTrack(source, track, plan.layer);
|
|
1727
|
+
}
|
|
1728
|
+
playValueTrack(source, track, layer) {
|
|
1729
|
+
const at = this.now();
|
|
1730
|
+
const points = []; // Numeric readers use the analytical curve, not WAAPI keyframe expansion.
|
|
1731
|
+
const owner = new Owner(this, track.end, at);
|
|
1732
|
+
const entry = {
|
|
1733
|
+
source,
|
|
1734
|
+
property: 'opacity',
|
|
1735
|
+
layer,
|
|
1736
|
+
track,
|
|
1737
|
+
points,
|
|
1738
|
+
owner,
|
|
1739
|
+
};
|
|
1740
|
+
// Keep the owner alive while preparing its clock, before replacing the old writer.
|
|
1741
|
+
owner.entries.add(entry);
|
|
1742
|
+
this.transaction(new Map(), at, new Map([
|
|
1743
|
+
[
|
|
1744
|
+
owner,
|
|
1745
|
+
{
|
|
1746
|
+
time: 0,
|
|
1747
|
+
paused: false,
|
|
1748
|
+
pending: this.document.timeline.currentTime === null,
|
|
1749
|
+
},
|
|
1750
|
+
],
|
|
1751
|
+
]));
|
|
1752
|
+
this.claimValue(entry);
|
|
1753
|
+
this.sampleValues();
|
|
1754
|
+
this.scheduleValues();
|
|
1755
|
+
owner.refresh(at);
|
|
1756
|
+
return owner;
|
|
1757
|
+
}
|
|
1758
|
+
compileElements(targets, plans, at) {
|
|
1759
|
+
const compiled = [];
|
|
1760
|
+
for (let i = 0; i < targets.length; i++) {
|
|
1761
|
+
const element = targets[i];
|
|
1762
|
+
const surface = this.surfaces.get(element) ?? new Surface(this, element);
|
|
1763
|
+
surface.assert();
|
|
1764
|
+
const tracks = plans[i].map((plan) => {
|
|
1765
|
+
const key = keyOf(plan.property, plan.layer), old = surface.state.entries.get(key);
|
|
1766
|
+
const time = old?.owner.time(at) ?? 0;
|
|
1767
|
+
const from = old
|
|
1768
|
+
? old.track.valueAt(time)
|
|
1769
|
+
: (surface.state.bindings.get(key)?.source.get() ??
|
|
1770
|
+
surface.state.rest.get(key)?.value ??
|
|
1771
|
+
(plan.layer === undefined
|
|
1772
|
+
? readProperty(element, plan.property)
|
|
1773
|
+
: identity(plan.property)));
|
|
1774
|
+
const velocity = old
|
|
1775
|
+
? !old.owner.paused && !old.owner.pending
|
|
1776
|
+
? old.track.velocityAt(time)
|
|
1777
|
+
: 0
|
|
1778
|
+
: (surface.state.bindings.get(key)?.source.getVelocity() ?? 0);
|
|
1779
|
+
const values = plan.frames.map((input) => {
|
|
1780
|
+
const value = input === null
|
|
1781
|
+
? null
|
|
1782
|
+
: resolveProperty(element, plan.property, plan.source, input);
|
|
1783
|
+
return value === null
|
|
1784
|
+
? from
|
|
1785
|
+
: plan.relative && !isColor(plan.property)
|
|
1786
|
+
? multiplicative(plan.property)
|
|
1787
|
+
? from * value
|
|
1788
|
+
: from + value
|
|
1789
|
+
: value;
|
|
1790
|
+
});
|
|
1791
|
+
const track = createTrack(coreProperty(plan.property), values, plan.transition, velocity, {
|
|
1792
|
+
timeScale: this.settings.timeScale,
|
|
1793
|
+
reducedMotion: this.reduced(),
|
|
1794
|
+
});
|
|
1795
|
+
return { plan, track, points: flatten(track, this.maxKeyframes) };
|
|
1796
|
+
});
|
|
1797
|
+
compiled.push({ surface, plans: tracks });
|
|
1798
|
+
}
|
|
1799
|
+
return compiled;
|
|
1800
|
+
}
|
|
1801
|
+
play(target, animation, options, privateLayer, prepared) {
|
|
1802
|
+
this.assert();
|
|
1803
|
+
const targets = this.targets(target);
|
|
1804
|
+
const plans = prepared ?? prepare(animation, options, this.presets, targets.length);
|
|
1805
|
+
if (privateLayer !== undefined)
|
|
1806
|
+
for (const tracks of plans)
|
|
1807
|
+
for (const plan of tracks)
|
|
1808
|
+
plan.layer = privateLayer;
|
|
1809
|
+
const feedback = resolveHaptic(typeof options === 'object' && options.haptic !== undefined
|
|
1810
|
+
? options.haptic
|
|
1811
|
+
: typeof animation === 'string'
|
|
1812
|
+
? this.presets.get(animation)?.transition?.haptic
|
|
1813
|
+
: undefined);
|
|
1814
|
+
const at = this.now(), pending = this.document.timeline.currentTime === null;
|
|
1815
|
+
const compiled = this.compileElements(targets, plans, at);
|
|
1816
|
+
const owner = new Owner(this, Math.max(0, ...compiled.flatMap((c) => c.plans.map((p) => p.track.end))), at);
|
|
1817
|
+
const proposals = new Map();
|
|
1818
|
+
for (const { surface, plans: tracks } of compiled) {
|
|
1819
|
+
if (!tracks.length)
|
|
1820
|
+
continue;
|
|
1821
|
+
const state = clone(surface.state);
|
|
1822
|
+
for (const { plan, track, points } of tracks) {
|
|
1823
|
+
this.ensureRadius(state, surface, plan.property);
|
|
1824
|
+
const key = keyOf(plan.property, plan.layer);
|
|
1825
|
+
state.entries.delete(key);
|
|
1826
|
+
state.bindings.delete(key);
|
|
1827
|
+
if (track.end === 0)
|
|
1828
|
+
this.rest(state, key, plan.property, track.to, plan.layer);
|
|
1829
|
+
else {
|
|
1830
|
+
state.rest.delete(key);
|
|
1831
|
+
state.entries.set(key, {
|
|
1832
|
+
owner,
|
|
1833
|
+
property: plan.property,
|
|
1834
|
+
layer: plan.layer,
|
|
1835
|
+
track,
|
|
1836
|
+
points,
|
|
1837
|
+
});
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
proposals.set(surface, state);
|
|
1841
|
+
}
|
|
1842
|
+
this.transaction(proposals, at, new Map([[owner, { time: 0, paused: false, pending }]]));
|
|
1843
|
+
owner.refresh(at);
|
|
1844
|
+
if (feedback && !privateLayer)
|
|
1845
|
+
owner.feedback = animationHaptics(owner, compiled.flatMap((c) => c.plans.map((p) => p.track)), feedback, this.effectHost(), () => owner.complete &&
|
|
1846
|
+
targets.every((t) => t.isConnected &&
|
|
1847
|
+
t.ownerDocument === this.document &&
|
|
1848
|
+
t.getClientRects().length > 0 &&
|
|
1849
|
+
!t.closest('[inert],[hidden]') &&
|
|
1850
|
+
this.view.getComputedStyle(t).visibility === 'visible'));
|
|
1851
|
+
return owner;
|
|
1852
|
+
}
|
|
1853
|
+
set(target, values) {
|
|
1854
|
+
if (typeof values === 'number' || this.nodes.has(target)) {
|
|
1855
|
+
const source = this.mutable(target);
|
|
1856
|
+
if (typeof values !== 'number')
|
|
1857
|
+
throw new TypeError('Expected a finite numeric value.');
|
|
1858
|
+
source.set(values);
|
|
1859
|
+
return;
|
|
1860
|
+
}
|
|
1861
|
+
if (!values ||
|
|
1862
|
+
typeof values !== 'object' ||
|
|
1863
|
+
Object.values(values).some((v) => typeof v !== 'number' && typeof v !== 'string'))
|
|
1864
|
+
throw new TypeError('set() requires one value per property.');
|
|
1865
|
+
return this.animate(target, values, { duration: 0 });
|
|
1866
|
+
}
|
|
1867
|
+
press(target, values = { scale: 0.96 }, options = {}) {
|
|
1868
|
+
this.assert();
|
|
1869
|
+
this.targets(target);
|
|
1870
|
+
if (this.presses.has(target))
|
|
1871
|
+
throw new Error('The surface already has press feedback.');
|
|
1872
|
+
validatePressState(options);
|
|
1873
|
+
resolveHaptic(options.haptic);
|
|
1874
|
+
if (options.haptic && typeof options.haptic !== 'string')
|
|
1875
|
+
throw new TypeError('Press haptic must be light, medium, heavy or false.');
|
|
1876
|
+
if (!values ||
|
|
1877
|
+
!Object.keys(values).length ||
|
|
1878
|
+
Object.values(values).some((v) => typeof v !== 'number'))
|
|
1879
|
+
throw new TypeError('Press requires numeric contributions.');
|
|
1880
|
+
const copied = { ...values };
|
|
1881
|
+
const transition = typeof options.transition === 'object'
|
|
1882
|
+
? { ...options.transition }
|
|
1883
|
+
: (options.transition ?? 'snappy');
|
|
1884
|
+
prepare(copied, transition, this.presets, 1);
|
|
1885
|
+
const layer = `jolt:press:${++this.nextPress}`;
|
|
1886
|
+
const neutral = Object.fromEntries(Object.keys(copied).map((p) => [
|
|
1887
|
+
p,
|
|
1888
|
+
p === 'opacity' || p.startsWith('scale') ? 1 : 0,
|
|
1889
|
+
]));
|
|
1890
|
+
this.play(target, neutral, { duration: 0 }, layer);
|
|
1891
|
+
const binding = createPress(target, copied, options, (next) => this.play(target, next, transition, layer), () => {
|
|
1892
|
+
if (!target.isConnected || target.ownerDocument !== this.document) {
|
|
1893
|
+
this.release(target);
|
|
1894
|
+
return;
|
|
1895
|
+
}
|
|
1896
|
+
const surface = this.surfaces.get(target);
|
|
1897
|
+
if (surface) {
|
|
1898
|
+
const state = clone(surface.state);
|
|
1899
|
+
for (const property of properties) {
|
|
1900
|
+
state.entries.delete(keyOf(property, layer));
|
|
1901
|
+
state.rest.delete(keyOf(property, layer));
|
|
1902
|
+
}
|
|
1903
|
+
this.transaction(new Map([[surface, state]]), this.now());
|
|
1904
|
+
}
|
|
1905
|
+
this.presses.delete(target);
|
|
1906
|
+
}, () => {
|
|
1907
|
+
const h = resolveHaptic(options.haptic);
|
|
1908
|
+
if (h)
|
|
1909
|
+
this.haptic(h.style);
|
|
1910
|
+
});
|
|
1911
|
+
this.presses.set(target, binding);
|
|
1912
|
+
return binding.handle;
|
|
1913
|
+
}
|
|
1914
|
+
interactionHost() {
|
|
1915
|
+
return {
|
|
1916
|
+
motionValue: this.motionValue.bind(this),
|
|
1917
|
+
animate: this.animate.bind(this),
|
|
1918
|
+
bindLayer: this.bindInLayer.bind(this),
|
|
1919
|
+
layer: (name) => `jolt:interaction:${name}:${++this.nextInteraction}`,
|
|
1920
|
+
gestures: this.gestures.bind(this),
|
|
1921
|
+
bind: this.bind.bind(this),
|
|
1922
|
+
set: this.set.bind(this),
|
|
1923
|
+
stop: this.stop.bind(this),
|
|
1924
|
+
refresh: this.refresh.bind(this),
|
|
1925
|
+
scrollValue: this.scrollValue.bind(this),
|
|
1926
|
+
animateLayout: this.animateLayout.bind(this),
|
|
1927
|
+
scope: this.scope.bind(this),
|
|
1928
|
+
scheduler: this.scheduler,
|
|
1929
|
+
error: this.report,
|
|
1930
|
+
after: (ms, action) => this.timers.after(ms, action),
|
|
1931
|
+
reduced: () => this.reduced(),
|
|
1932
|
+
onReduced: (callback) => {
|
|
1933
|
+
this.preferenceListeners.add(callback);
|
|
1934
|
+
return () => this.preferenceListeners.delete(callback);
|
|
1935
|
+
},
|
|
1936
|
+
register: (target, resource, refresh) => {
|
|
1937
|
+
const entries = this.interactions.get(target) ?? new Map();
|
|
1938
|
+
entries.set(resource, refresh);
|
|
1939
|
+
this.interactions.set(target, entries);
|
|
1940
|
+
this.observe();
|
|
1941
|
+
return () => {
|
|
1942
|
+
entries.delete(resource);
|
|
1943
|
+
if (!entries.size)
|
|
1944
|
+
this.interactions.delete(target);
|
|
1945
|
+
this.observe();
|
|
1946
|
+
};
|
|
1947
|
+
},
|
|
1948
|
+
};
|
|
1949
|
+
}
|
|
1950
|
+
effectHost() {
|
|
1951
|
+
return {
|
|
1952
|
+
...this.interactionHost(),
|
|
1953
|
+
identity: this,
|
|
1954
|
+
document: this.document,
|
|
1955
|
+
settings: () => ({
|
|
1956
|
+
timeScale: this.settings.timeScale,
|
|
1957
|
+
reducedMotion: this.reduced(),
|
|
1958
|
+
}),
|
|
1959
|
+
maxKeyframes: this.maxKeyframes,
|
|
1960
|
+
remember: (animation) => this.rememberPlayback(animation),
|
|
1961
|
+
value: (source, color) => {
|
|
1962
|
+
const node = this.nodes.get(source);
|
|
1963
|
+
if (!node || node.disposed || node.kind !== (color ? 'color' : 'number'))
|
|
1964
|
+
throw new TypeError('Gradient bindings need live values of the correct kind from this runtime.');
|
|
1965
|
+
return node;
|
|
1966
|
+
},
|
|
1967
|
+
visibility: (callback) => {
|
|
1968
|
+
this.groupVisibility.add(callback);
|
|
1969
|
+
return () => this.groupVisibility.delete(callback);
|
|
1970
|
+
},
|
|
1971
|
+
};
|
|
1972
|
+
}
|
|
1973
|
+
platformHost() {
|
|
1974
|
+
return {
|
|
1975
|
+
...this.interactionHost(),
|
|
1976
|
+
...this.effectHost(),
|
|
1977
|
+
sharedLayout: this.sharedLayout.bind(this),
|
|
1978
|
+
};
|
|
1979
|
+
}
|
|
1980
|
+
glass(target, options = {}) {
|
|
1981
|
+
this.assert();
|
|
1982
|
+
return createGlass(target, options, this.effectHost());
|
|
1983
|
+
}
|
|
1984
|
+
sensor(kind, options = {}) {
|
|
1985
|
+
this.assert();
|
|
1986
|
+
return createSensor(kind, options, this.platformHost(), (initial) => {
|
|
1987
|
+
const node = new SensorValueNode(this.scheduler, initial, this.report, () => this.values.delete(node));
|
|
1988
|
+
return { node, value: this.valueHandle(node, node.readableHandle()) };
|
|
1989
|
+
});
|
|
1990
|
+
}
|
|
1991
|
+
interactiveNavigation(target, options) {
|
|
1992
|
+
this.assert();
|
|
1993
|
+
return createInteractiveNavigation(target, options, this.platformHost());
|
|
1994
|
+
}
|
|
1995
|
+
sharedNavigationEntry(container, options) {
|
|
1996
|
+
this.assert();
|
|
1997
|
+
return createNavigationEntry(container, options, this.platformHost());
|
|
1998
|
+
}
|
|
1999
|
+
haptic(style) {
|
|
2000
|
+
this.assert();
|
|
2001
|
+
return requestHaptic(style, this.effectHost());
|
|
2002
|
+
}
|
|
2003
|
+
onKeyboard(callback) {
|
|
2004
|
+
this.assert();
|
|
2005
|
+
return createKeyboardSubscription(callback, this.platformHost());
|
|
2006
|
+
}
|
|
2007
|
+
followKeyboard(target, options = {}) {
|
|
2008
|
+
this.assert();
|
|
2009
|
+
return createKeyboardFollower(target, options, this.platformHost());
|
|
2010
|
+
}
|
|
2011
|
+
bottomSheet(target, options) {
|
|
2012
|
+
this.assert();
|
|
2013
|
+
return createBottomSheet(target, options, this.platformHost());
|
|
2014
|
+
}
|
|
2015
|
+
interactiveModal(target, options = {}) {
|
|
2016
|
+
this.assert();
|
|
2017
|
+
return createInteractiveModal(target, options, this.platformHost());
|
|
2018
|
+
}
|
|
2019
|
+
sharedNavigation(container, options = {}) {
|
|
2020
|
+
this.assert();
|
|
2021
|
+
return createSharedNavigation(container, options, this.platformHost());
|
|
2022
|
+
}
|
|
2023
|
+
physicsWorld(container, bodies, options = {}) {
|
|
2024
|
+
this.assert();
|
|
2025
|
+
return createPhysicsWorld(container, bodies, options, this.platformHost());
|
|
2026
|
+
}
|
|
2027
|
+
symbolEffect(target, effect, options = {}) {
|
|
2028
|
+
this.assert();
|
|
2029
|
+
return createSymbolEffect(target, effect, options, this.platformHost());
|
|
2030
|
+
}
|
|
2031
|
+
particles(target, options = {}) {
|
|
2032
|
+
this.assert();
|
|
2033
|
+
return createParticles(target, options, this.effectHost());
|
|
2034
|
+
}
|
|
2035
|
+
confetti(target, options = {}) {
|
|
2036
|
+
this.assert();
|
|
2037
|
+
return createConfetti(target, options, this.effectHost());
|
|
2038
|
+
}
|
|
2039
|
+
blur(target, options = {}) {
|
|
2040
|
+
this.assert();
|
|
2041
|
+
return createBlur(target, options, this.effectHost());
|
|
2042
|
+
}
|
|
2043
|
+
shape(target, options) {
|
|
2044
|
+
this.assert();
|
|
2045
|
+
return createShape(target, options, this.effectHost());
|
|
2046
|
+
}
|
|
2047
|
+
liquid(target, options = {}) {
|
|
2048
|
+
this.assert();
|
|
2049
|
+
return createLiquid(target, options, this.effectHost());
|
|
2050
|
+
}
|
|
2051
|
+
imageEffect(target, effect, options = {}) {
|
|
2052
|
+
this.assert();
|
|
2053
|
+
return createImageEffect(target, effect, options, this.effectHost());
|
|
2054
|
+
}
|
|
2055
|
+
gradient(target, options) {
|
|
2056
|
+
this.assert();
|
|
2057
|
+
return createGradient(target, options, this.effectHost());
|
|
2058
|
+
}
|
|
2059
|
+
reveal(target, options = {}) {
|
|
2060
|
+
this.assert();
|
|
2061
|
+
return createReveal(target, true, options, this.effectHost());
|
|
2062
|
+
}
|
|
2063
|
+
conceal(target, options = {}) {
|
|
2064
|
+
this.assert();
|
|
2065
|
+
return createReveal(target, false, options, this.effectHost());
|
|
2066
|
+
}
|
|
2067
|
+
animateText(target, options = {}) {
|
|
2068
|
+
this.assert();
|
|
2069
|
+
return createTextAnimation(target, options, this.effectHost());
|
|
2070
|
+
}
|
|
2071
|
+
rollTo(target, value, options = {}) {
|
|
2072
|
+
this.assert();
|
|
2073
|
+
return createRoll(target, value, options, this.effectHost());
|
|
2074
|
+
}
|
|
2075
|
+
shimmer(target, options = {}) {
|
|
2076
|
+
this.assert();
|
|
2077
|
+
return createShimmer(target, options, this.effectHost());
|
|
2078
|
+
}
|
|
2079
|
+
loader(target, options = {}) {
|
|
2080
|
+
this.assert();
|
|
2081
|
+
return createLoader(target, options, this.effectHost());
|
|
2082
|
+
}
|
|
2083
|
+
zoomable(image, options = {}) {
|
|
2084
|
+
this.assert();
|
|
2085
|
+
this.targets(image);
|
|
2086
|
+
if (this.zoomInputs.has(image) && !this.zoomInputs.get(image).disposed)
|
|
2087
|
+
throw new Error('The image already has zoom input.');
|
|
2088
|
+
const handle = createZoomable(image, options, this.interactionHost());
|
|
2089
|
+
this.zoomInputs.set(image, handle);
|
|
2090
|
+
return handle;
|
|
2091
|
+
}
|
|
2092
|
+
scrollHeader(source, options) {
|
|
2093
|
+
this.assert();
|
|
2094
|
+
this.targets(source);
|
|
2095
|
+
if (this.headerInputs.has(source) && !this.headerInputs.get(source).disposed)
|
|
2096
|
+
throw new Error('The scroll source already has a header controller.');
|
|
2097
|
+
const handle = createScrollHeader(source, options, this.interactionHost());
|
|
2098
|
+
this.headerInputs.set(source, handle);
|
|
2099
|
+
return handle;
|
|
2100
|
+
}
|
|
2101
|
+
reorder(container, options) {
|
|
2102
|
+
this.assert();
|
|
2103
|
+
this.targets(container);
|
|
2104
|
+
if (this.reorderInputs.has(container) && !this.reorderInputs.get(container).disposed)
|
|
2105
|
+
throw new Error('The list already has reorder input.');
|
|
2106
|
+
const handle = createReorder(container, options, this.interactionHost());
|
|
2107
|
+
this.reorderInputs.set(container, handle);
|
|
2108
|
+
return handle;
|
|
2109
|
+
}
|
|
2110
|
+
gestures(target, options = {}) {
|
|
2111
|
+
this.assert();
|
|
2112
|
+
this.targets(target);
|
|
2113
|
+
if (this.drags.has(target) ||
|
|
2114
|
+
(!this.gestureInputs.get(target)?.disposed && this.gestureInputs.has(target)))
|
|
2115
|
+
throw new Error('The surface already has gesture input.');
|
|
2116
|
+
const handle = createGestures(target, options, this.interactionHost());
|
|
2117
|
+
this.gestureInputs.set(target, handle);
|
|
2118
|
+
return handle;
|
|
2119
|
+
}
|
|
2120
|
+
drag(target, options = {}) {
|
|
2121
|
+
this.assert();
|
|
2122
|
+
this.targets(target);
|
|
2123
|
+
if (this.drags.has(target) ||
|
|
2124
|
+
(this.gestureInputs.has(target) && !this.gestureInputs.get(target).disposed))
|
|
2125
|
+
throw new Error('The surface already has drag input.');
|
|
2126
|
+
const config = dragOptions(options);
|
|
2127
|
+
if (config.value)
|
|
2128
|
+
return this.dragValue(target, config);
|
|
2129
|
+
// Validate spring compilation before claiming a surface or changing input styles.
|
|
2130
|
+
prepare({ x: 1 }, { type: 'spring', ...config.spring }, this.presets, 1);
|
|
2131
|
+
const surface = this.surfaces.get(target) ?? new Surface(this, target);
|
|
2132
|
+
surface.assertDrag();
|
|
2133
|
+
if (!this.surfaces.has(target))
|
|
2134
|
+
this.transaction(new Map([[surface, clone(surface.state)]]), this.now());
|
|
2135
|
+
const axes = config.axis === 'both' ? ['x', 'y'] : [config.axis];
|
|
2136
|
+
let binding;
|
|
2137
|
+
const inputs = new Map();
|
|
2138
|
+
const read = () => {
|
|
2139
|
+
const at = this.now();
|
|
2140
|
+
const channel = (property) => {
|
|
2141
|
+
const key = keyOf(property), entry = surface.state.entries.get(key);
|
|
2142
|
+
return (surface.state.bindings.get(key)?.source.get() ??
|
|
2143
|
+
(entry
|
|
2144
|
+
? sampled(entry.points, entry.owner.time(at))
|
|
2145
|
+
: (surface.state.rest.get(key)?.value ?? 0)));
|
|
2146
|
+
};
|
|
2147
|
+
return { x: channel('x'), y: channel('y') };
|
|
2148
|
+
};
|
|
2149
|
+
const cleanup = () => {
|
|
2150
|
+
const current = binding;
|
|
2151
|
+
binding = undefined;
|
|
2152
|
+
const values = [...inputs.values()];
|
|
2153
|
+
inputs.clear();
|
|
2154
|
+
try {
|
|
2155
|
+
current?.dispose();
|
|
2156
|
+
}
|
|
2157
|
+
finally {
|
|
2158
|
+
for (const value of values)
|
|
2159
|
+
value.dispose();
|
|
2160
|
+
}
|
|
2161
|
+
};
|
|
2162
|
+
const drag = createDrag(target, config, {
|
|
2163
|
+
scheduler: this.scheduler,
|
|
2164
|
+
error: this.report,
|
|
2165
|
+
read,
|
|
2166
|
+
validate: () => surface.assertDrag(),
|
|
2167
|
+
begin: () => {
|
|
2168
|
+
const current = read();
|
|
2169
|
+
try {
|
|
2170
|
+
for (const axis of axes)
|
|
2171
|
+
inputs.set(axis, this.motionValue(current[axis]));
|
|
2172
|
+
binding = this.bind(target, Object.fromEntries(inputs));
|
|
2173
|
+
}
|
|
2174
|
+
catch (error) {
|
|
2175
|
+
cleanup();
|
|
2176
|
+
throw error;
|
|
2177
|
+
}
|
|
2178
|
+
},
|
|
2179
|
+
owns: () => [...inputs].every(([axis, value]) => surface.state.bindings.get(keyOf(axis))?.source === this.nodes.get(value)),
|
|
2180
|
+
write: (point) => {
|
|
2181
|
+
for (const [axis, value] of inputs)
|
|
2182
|
+
value.set(point[axis]);
|
|
2183
|
+
},
|
|
2184
|
+
cancel: cleanup,
|
|
2185
|
+
release: (point, velocity) => {
|
|
2186
|
+
try {
|
|
2187
|
+
if (config.release === 'decay')
|
|
2188
|
+
return this.play(target, {}, undefined, undefined, [
|
|
2189
|
+
dragPlans(config, velocity),
|
|
2190
|
+
]);
|
|
2191
|
+
return this.animate(target, Object.fromEntries(axes.map((axis) => [axis, point[axis]])), {
|
|
2192
|
+
type: 'spring',
|
|
2193
|
+
...config.spring,
|
|
2194
|
+
...Object.fromEntries(axes.map((axis) => [
|
|
2195
|
+
axis,
|
|
2196
|
+
{ type: 'spring', ...config.spring, velocity: velocity[axis] },
|
|
2197
|
+
])),
|
|
2198
|
+
});
|
|
2199
|
+
}
|
|
2200
|
+
finally {
|
|
2201
|
+
cleanup();
|
|
2202
|
+
}
|
|
2203
|
+
},
|
|
2204
|
+
dispose: () => {
|
|
2205
|
+
cleanup();
|
|
2206
|
+
this.drags.delete(target);
|
|
2207
|
+
if (!target.isConnected || target.ownerDocument !== this.document)
|
|
2208
|
+
this.release(target);
|
|
2209
|
+
},
|
|
2210
|
+
});
|
|
2211
|
+
this.drags.set(target, drag);
|
|
2212
|
+
return drag.handle;
|
|
2213
|
+
}
|
|
2214
|
+
dragValue(target, config) {
|
|
2215
|
+
const source = this.mutable(config.value);
|
|
2216
|
+
const axis = config.axis;
|
|
2217
|
+
assertDragSpace(target, true);
|
|
2218
|
+
let owns = false;
|
|
2219
|
+
const cancelled = () => {
|
|
2220
|
+
owns = false;
|
|
2221
|
+
drag.handle.cancel();
|
|
2222
|
+
};
|
|
2223
|
+
const cleanup = () => {
|
|
2224
|
+
owns = false;
|
|
2225
|
+
source.releaseWriter(cancelled);
|
|
2226
|
+
};
|
|
2227
|
+
const read = () => ({
|
|
2228
|
+
x: axis === 'x' ? source.get() : 0,
|
|
2229
|
+
y: axis === 'y' ? source.get() : 0,
|
|
2230
|
+
});
|
|
2231
|
+
const drag = createDrag(target, config, {
|
|
2232
|
+
scheduler: this.scheduler,
|
|
2233
|
+
error: this.report,
|
|
2234
|
+
read,
|
|
2235
|
+
validate: () => {
|
|
2236
|
+
assertDragSpace(target, true);
|
|
2237
|
+
this.mutable(config.value);
|
|
2238
|
+
},
|
|
2239
|
+
begin: () => {
|
|
2240
|
+
source.claimWriter(cancelled);
|
|
2241
|
+
owns = true;
|
|
2242
|
+
},
|
|
2243
|
+
owns: () => owns && !source.disposed,
|
|
2244
|
+
write: (point, speed) => source.writeSample(point[axis], speed[axis]),
|
|
2245
|
+
cancel: cleanup,
|
|
2246
|
+
release: (point, velocity) => {
|
|
2247
|
+
cleanup();
|
|
2248
|
+
if (config.release !== 'decay')
|
|
2249
|
+
return this.playValueTrack(source, createTrack(axis, [source.get(), point[axis]], resolveTransition({ type: 'spring', ...config.spring, velocity: velocity[axis] }, axis, 2), velocity[axis], { timeScale: this.settings.timeScale, reducedMotion: this.reduced() }));
|
|
2250
|
+
const track = createTrack(axis, [source.get(), source.get()], {
|
|
2251
|
+
curve: dragCurve(config, axis, velocity[axis]),
|
|
2252
|
+
delay: 0,
|
|
2253
|
+
repeat: 0,
|
|
2254
|
+
reverse: false,
|
|
2255
|
+
}, velocity[axis], { timeScale: this.settings.timeScale, reducedMotion: this.reduced() });
|
|
2256
|
+
return this.playValueTrack(source, track);
|
|
2257
|
+
},
|
|
2258
|
+
dispose: () => {
|
|
2259
|
+
cleanup();
|
|
2260
|
+
unlisten();
|
|
2261
|
+
this.drags.delete(target);
|
|
2262
|
+
this.observe();
|
|
2263
|
+
},
|
|
2264
|
+
});
|
|
2265
|
+
const unlisten = source.onDispose(() => drag.handle.dispose());
|
|
2266
|
+
this.drags.set(target, drag);
|
|
2267
|
+
this.observe();
|
|
2268
|
+
return drag.handle;
|
|
2269
|
+
}
|
|
2270
|
+
rest(state, key, property, value, layer) {
|
|
2271
|
+
if (layer !== undefined && value === identity(property))
|
|
2272
|
+
state.rest.delete(key);
|
|
2273
|
+
else
|
|
2274
|
+
state.rest.set(key, { property, value });
|
|
2275
|
+
}
|
|
2276
|
+
ensureRadius(state, surface, property) {
|
|
2277
|
+
if (!isRadius(property))
|
|
2278
|
+
return;
|
|
2279
|
+
const sibling = `${property.slice(0, -1)}${property.endsWith('X') ? 'Y' : 'X'}`;
|
|
2280
|
+
const key = keyOf(sibling);
|
|
2281
|
+
if (!state.rest.has(key) && !state.entries.has(key) && !state.bindings.has(key))
|
|
2282
|
+
state.rest.set(key, {
|
|
2283
|
+
property: sibling,
|
|
2284
|
+
value: readProperty(surface.target, sibling),
|
|
2285
|
+
});
|
|
2286
|
+
}
|
|
2287
|
+
transaction(proposals, at, controls = new Map(), removed = 'cancel') {
|
|
2288
|
+
const prepared = new Map();
|
|
2289
|
+
const clocks = new Map();
|
|
2290
|
+
try {
|
|
2291
|
+
for (const [surface, state] of proposals)
|
|
2292
|
+
prepared.set(surface, surface.prepare(state, at, controls));
|
|
2293
|
+
// Construct and validate every effect before changing ownership or old playback.
|
|
2294
|
+
for (const data of prepared.values())
|
|
2295
|
+
if (data.animation) {
|
|
2296
|
+
data.animation.play();
|
|
2297
|
+
if (data.path !== 'scroll-timeline')
|
|
2298
|
+
data.animation.startTime = at;
|
|
2299
|
+
}
|
|
2300
|
+
for (const [owner, control] of controls)
|
|
2301
|
+
clocks.set(owner, owner.prepare(control, at));
|
|
2302
|
+
}
|
|
2303
|
+
catch (error) {
|
|
2304
|
+
for (const data of prepared.values())
|
|
2305
|
+
data.animation?.cancel();
|
|
2306
|
+
for (const clock of clocks.values())
|
|
2307
|
+
clock?.cancel();
|
|
2308
|
+
for (const owner of controls.keys())
|
|
2309
|
+
if (!this.animations.has(owner))
|
|
2310
|
+
owner.settle(false, at);
|
|
2311
|
+
throw error;
|
|
2312
|
+
}
|
|
2313
|
+
for (const [owner, control] of controls)
|
|
2314
|
+
owner.apply(control, at, clocks.get(owner));
|
|
2315
|
+
const affected = new Set(controls.keys());
|
|
2316
|
+
for (const [surface, state] of proposals) {
|
|
2317
|
+
for (const [key, previous] of surface.state.entries)
|
|
2318
|
+
if (state.entries.get(key) !== previous) {
|
|
2319
|
+
if (removed !== 'finish')
|
|
2320
|
+
previous.owner.diagnosticReason =
|
|
2321
|
+
state.entries.has(key) || state.bindings.has(key)
|
|
2322
|
+
? 'interrupted'
|
|
2323
|
+
: 'stopped';
|
|
2324
|
+
this.diagnosticEvent(state.entries.has(key) || state.bindings.has(key)
|
|
2325
|
+
? 'interrupted'
|
|
2326
|
+
: removed === 'finish'
|
|
2327
|
+
? 'completed'
|
|
2328
|
+
: 'stopped', previous.owner, surface.target, previous.property, previous.layer);
|
|
2329
|
+
previous.owner.entries.delete(previous);
|
|
2330
|
+
previous.owner.complete &&= removed === 'finish';
|
|
2331
|
+
affected.add(previous.owner);
|
|
2332
|
+
this.ownership.invalidate(surface.target, [key]);
|
|
2333
|
+
}
|
|
2334
|
+
for (const [key, entry] of state.entries)
|
|
2335
|
+
if (surface.state.entries.get(key) !== entry) {
|
|
2336
|
+
this.diagnosticEvent('claimed', entry.owner, surface.target, entry.property, entry.layer);
|
|
2337
|
+
entry.token = this.ownership.claim(surface.target, key);
|
|
2338
|
+
entry.owner.entries.add(entry);
|
|
2339
|
+
affected.add(entry.owner);
|
|
2340
|
+
}
|
|
2341
|
+
for (const [key, previous] of surface.state.bindings)
|
|
2342
|
+
if (state.bindings.get(key) !== previous ||
|
|
2343
|
+
surface.path !== prepared.get(surface).path) {
|
|
2344
|
+
previous.cleanup?.();
|
|
2345
|
+
if (state.bindings.get(key) !== previous)
|
|
2346
|
+
this.diagnosticEvent(state.entries.has(key) || state.bindings.has(key)
|
|
2347
|
+
? 'interrupted'
|
|
2348
|
+
: 'released', previous.source, surface.target, previous.property);
|
|
2349
|
+
if (!state.entries.has(key) && !state.bindings.has(key))
|
|
2350
|
+
this.ownership.invalidate(surface.target, [key]);
|
|
2351
|
+
}
|
|
2352
|
+
for (const [key, entry] of state.bindings)
|
|
2353
|
+
if (surface.state.bindings.get(key) !== entry ||
|
|
2354
|
+
surface.path !== prepared.get(surface).path) {
|
|
2355
|
+
if (surface.state.bindings.get(key) !== entry)
|
|
2356
|
+
this.ownership.claim(surface.target, key);
|
|
2357
|
+
if (surface.state.bindings.get(key) !== entry)
|
|
2358
|
+
this.diagnosticEvent('claimed', entry.source, surface.target, entry.property);
|
|
2359
|
+
const ending = () => this.unbind(surface, new Map([[key, entry]]));
|
|
2360
|
+
entry.cleanup =
|
|
2361
|
+
prepared.get(surface).path === 'scroll-timeline'
|
|
2362
|
+
? entry.source.onDispose(ending)
|
|
2363
|
+
: entry.source.listen(() => this.scheduler.add(surface.task), ending);
|
|
2364
|
+
}
|
|
2365
|
+
surface.commit(state, prepared.get(surface));
|
|
2366
|
+
if (state.bindings.size && surface.path !== 'scroll-timeline')
|
|
2367
|
+
this.scheduler.add(surface.task);
|
|
2368
|
+
else
|
|
2369
|
+
this.scheduler.remove(surface.task);
|
|
2370
|
+
this.surfaces.set(surface.target, surface);
|
|
2371
|
+
}
|
|
2372
|
+
for (const owner of affected) {
|
|
2373
|
+
if (!owner.settled)
|
|
2374
|
+
this.animations.add(owner);
|
|
2375
|
+
owner.refresh(at);
|
|
2376
|
+
}
|
|
2377
|
+
this.observe();
|
|
2378
|
+
this.schedulePending();
|
|
2379
|
+
for (const drag of this.drags.values())
|
|
2380
|
+
drag.refresh();
|
|
2381
|
+
for (const links of [...this.scrollLinks.values()])
|
|
2382
|
+
for (const link of [...links])
|
|
2383
|
+
if (!link.owns())
|
|
2384
|
+
link.dispose();
|
|
2385
|
+
}
|
|
2386
|
+
control(owner, control) {
|
|
2387
|
+
this.assert();
|
|
2388
|
+
const proposals = new Map();
|
|
2389
|
+
for (const surface of this.surfaces.values())
|
|
2390
|
+
if ([...surface.state.entries.values()].some((e) => e.owner === owner))
|
|
2391
|
+
proposals.set(surface, clone(surface.state));
|
|
2392
|
+
this.transaction(proposals, this.now(), new Map([[owner, control]]));
|
|
2393
|
+
this.sampleValues();
|
|
2394
|
+
this.scheduleValues();
|
|
2395
|
+
}
|
|
2396
|
+
stopOwner(owner, selected, options) {
|
|
2397
|
+
owner.diagnosticReason = 'stopped';
|
|
2398
|
+
if (selected?.some((name) => !keyframeProperties.includes(name)))
|
|
2399
|
+
throw new TypeError('Unsupported property to stop.');
|
|
2400
|
+
const names = selected?.flatMap(expand);
|
|
2401
|
+
const matches = (entry) => entry.owner === owner &&
|
|
2402
|
+
(!names || names.includes(entry.property)) &&
|
|
2403
|
+
(options?.layer === undefined || entry.layer === options.layer);
|
|
2404
|
+
for (const [target, surface] of this.surfaces)
|
|
2405
|
+
if ([...surface.state.entries.values()].some(matches) &&
|
|
2406
|
+
(!target.isConnected || !target.getClientRects().length))
|
|
2407
|
+
this.release(target);
|
|
2408
|
+
for (const entry of [...this.valueTracks.values()])
|
|
2409
|
+
if (matches(entry))
|
|
2410
|
+
this.removeValue(entry, false);
|
|
2411
|
+
this.remove(matches, false);
|
|
2412
|
+
}
|
|
2413
|
+
completeOwner(owner) {
|
|
2414
|
+
if (owner.settled || owner.paused || owner.pending)
|
|
2415
|
+
return;
|
|
2416
|
+
try {
|
|
2417
|
+
for (const entry of [...this.valueTracks.values()])
|
|
2418
|
+
if (entry.owner === owner)
|
|
2419
|
+
this.removeValue(entry, true);
|
|
2420
|
+
this.remove((entry) => entry.owner === owner, true);
|
|
2421
|
+
}
|
|
2422
|
+
catch {
|
|
2423
|
+
for (const [target, surface] of this.surfaces)
|
|
2424
|
+
if ([...surface.state.entries.values()].some((e) => e.owner === owner))
|
|
2425
|
+
this.release(target);
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
stop(target, selected, options) {
|
|
2429
|
+
this.assert();
|
|
2430
|
+
if (this.nodes.has(target) ||
|
|
2431
|
+
(!Array.isArray(target) && !(target instanceof this.view.HTMLElement))) {
|
|
2432
|
+
const source = this.mutable(target);
|
|
2433
|
+
if (Array.isArray(selected))
|
|
2434
|
+
throw new TypeError('Numeric values have named layers, not property keys.');
|
|
2435
|
+
this.resetValue(source, selected?.layer);
|
|
2436
|
+
return;
|
|
2437
|
+
}
|
|
2438
|
+
if (selected !== undefined && !Array.isArray(selected))
|
|
2439
|
+
throw new TypeError('Expected property keys.');
|
|
2440
|
+
const targets = new Set(this.targets(target));
|
|
2441
|
+
const names = selected?.flatMap(expand);
|
|
2442
|
+
if (names?.some((p) => !properties.includes(p)))
|
|
2443
|
+
throw new TypeError('Unsupported property to stop.');
|
|
2444
|
+
for (const surface of this.surfaces.values())
|
|
2445
|
+
if (targets.has(surface.target) && options?.layer === undefined)
|
|
2446
|
+
this.unbind(surface, new Map([...surface.state.bindings].filter(([, entry]) => !names || names.includes(entry.property))));
|
|
2447
|
+
this.remove((entry) => (!names || names.includes(entry.property)) &&
|
|
2448
|
+
(options?.layer === undefined || entry.layer === options.layer), false, (surface) => targets.has(surface.target));
|
|
2449
|
+
}
|
|
2450
|
+
remove(matches, completed, includes = (_surface) => true) {
|
|
2451
|
+
const at = this.now(), proposals = new Map();
|
|
2452
|
+
for (const surface of this.surfaces.values()) {
|
|
2453
|
+
if (!includes(surface))
|
|
2454
|
+
continue;
|
|
2455
|
+
const state = clone(surface.state);
|
|
2456
|
+
for (const [key, entry] of state.entries)
|
|
2457
|
+
if (matches(entry) && this.ownership.get(surface.target, key) === entry.token) {
|
|
2458
|
+
state.entries.delete(key);
|
|
2459
|
+
this.rest(state, key, entry.property, completed
|
|
2460
|
+
? entry.track.to
|
|
2461
|
+
: sampled(entry.points, entry.owner.time(at), 'right', entry.property), entry.layer);
|
|
2462
|
+
proposals.set(surface, state);
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
this.transaction(proposals, at, new Map(), completed ? 'finish' : 'cancel');
|
|
2466
|
+
}
|
|
2467
|
+
preferenceChanged = () => {
|
|
2468
|
+
if (this.disposed)
|
|
2469
|
+
return;
|
|
2470
|
+
const reduced = this.reduced();
|
|
2471
|
+
if (reduced === this.reported)
|
|
2472
|
+
return;
|
|
2473
|
+
this.reported = reduced;
|
|
2474
|
+
if (reduced)
|
|
2475
|
+
this.diagnosticEvent('reduced-motion');
|
|
2476
|
+
for (const listener of [...this.preferenceListeners])
|
|
2477
|
+
listener();
|
|
2478
|
+
for (const value of this.values)
|
|
2479
|
+
if (value instanceof SpringValueNode)
|
|
2480
|
+
value.preferenceChanged();
|
|
2481
|
+
for (const size of this.sizes.values())
|
|
2482
|
+
size.reduced();
|
|
2483
|
+
if (reduced) {
|
|
2484
|
+
try {
|
|
2485
|
+
this.remove((entry) => entry.property !== 'opacity' && !isColor(entry.property), true);
|
|
2486
|
+
}
|
|
2487
|
+
catch {
|
|
2488
|
+
for (const target of [...this.surfaces.keys()])
|
|
2489
|
+
this.release(target);
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
const scroll = new Map();
|
|
2493
|
+
for (const surface of this.surfaces.values())
|
|
2494
|
+
if ([...surface.state.bindings.values()].some((e) => e.source instanceof ScrollLinkedNode))
|
|
2495
|
+
scroll.set(surface, clone(surface.state));
|
|
2496
|
+
if (scroll.size)
|
|
2497
|
+
this.transaction(scroll, this.now());
|
|
2498
|
+
};
|
|
2499
|
+
schedulePending() {
|
|
2500
|
+
if (this.pendingFrame !== undefined || ![...this.animations].some((a) => a.pending))
|
|
2501
|
+
return;
|
|
2502
|
+
const task = {
|
|
2503
|
+
update: () => {
|
|
2504
|
+
this.pendingFrame = undefined;
|
|
2505
|
+
if (this.disposed)
|
|
2506
|
+
return;
|
|
2507
|
+
if (this.document.timeline.currentTime === null) {
|
|
2508
|
+
this.schedulePending();
|
|
2509
|
+
return;
|
|
2510
|
+
}
|
|
2511
|
+
const at = this.now(), controls = new Map();
|
|
2512
|
+
for (const owner of this.animations)
|
|
2513
|
+
if (owner.pending)
|
|
2514
|
+
controls.set(owner, {
|
|
2515
|
+
time: owner.time(at),
|
|
2516
|
+
paused: owner.paused,
|
|
2517
|
+
pending: false,
|
|
2518
|
+
});
|
|
2519
|
+
const proposals = new Map();
|
|
2520
|
+
for (const surface of this.surfaces.values())
|
|
2521
|
+
if ([...surface.state.entries.values()].some((e) => controls.has(e.owner)))
|
|
2522
|
+
proposals.set(surface, clone(surface.state));
|
|
2523
|
+
try {
|
|
2524
|
+
this.transaction(proposals, at, controls);
|
|
2525
|
+
}
|
|
2526
|
+
catch {
|
|
2527
|
+
for (const surface of proposals.keys())
|
|
2528
|
+
this.release(surface.target);
|
|
2529
|
+
}
|
|
2530
|
+
},
|
|
2531
|
+
};
|
|
2532
|
+
this.pendingFrame = task;
|
|
2533
|
+
this.scheduler.add(task);
|
|
2534
|
+
}
|
|
2535
|
+
observe() {
|
|
2536
|
+
const roots = new Set();
|
|
2537
|
+
if (this.paths.size ||
|
|
2538
|
+
this.drags.size ||
|
|
2539
|
+
this.interactions.size ||
|
|
2540
|
+
this.surfaces.size ||
|
|
2541
|
+
this.scrollSources.size ||
|
|
2542
|
+
this.layouts.size ||
|
|
2543
|
+
this.sharedLayouts.size)
|
|
2544
|
+
roots.add(this.document);
|
|
2545
|
+
for (const target of this.interactions.keys())
|
|
2546
|
+
roots.add(target.getRootNode());
|
|
2547
|
+
for (const target of this.drags.keys())
|
|
2548
|
+
roots.add(target.getRootNode());
|
|
2549
|
+
for (const target of this.paths.keys())
|
|
2550
|
+
roots.add(target.getRootNode());
|
|
2551
|
+
for (const source of this.scrollSources)
|
|
2552
|
+
roots.add(source.element.getRootNode());
|
|
2553
|
+
for (const surface of this.surfaces.values())
|
|
2554
|
+
roots.add(surface.target.getRootNode());
|
|
2555
|
+
for (const [root, observer] of this.observers)
|
|
2556
|
+
if (!roots.has(root)) {
|
|
2557
|
+
observer.disconnect();
|
|
2558
|
+
this.observers.delete(root);
|
|
2559
|
+
}
|
|
2560
|
+
for (const root of roots)
|
|
2561
|
+
if (!this.observers.has(root)) {
|
|
2562
|
+
const observer = new this.view.MutationObserver(() => {
|
|
2563
|
+
for (const [target, drawing] of this.paths)
|
|
2564
|
+
if (!target.isConnected || target.ownerDocument !== this.document)
|
|
2565
|
+
drawing.dispose();
|
|
2566
|
+
for (const [container, shared] of this.sharedLayouts)
|
|
2567
|
+
if (!container.isConnected || container.ownerDocument !== this.document)
|
|
2568
|
+
shared.dispose();
|
|
2569
|
+
for (const [target, layout] of this.layouts)
|
|
2570
|
+
if (!target.isConnected ||
|
|
2571
|
+
target.ownerDocument !== this.document ||
|
|
2572
|
+
!target.getClientRects().length)
|
|
2573
|
+
layout.stop();
|
|
2574
|
+
for (const source of [...this.scrollSources])
|
|
2575
|
+
if (!source.element.isConnected ||
|
|
2576
|
+
source.element.ownerDocument !== this.document)
|
|
2577
|
+
source.dispose();
|
|
2578
|
+
for (const target of [...this.surfaces.keys()])
|
|
2579
|
+
if (!target.isConnected ||
|
|
2580
|
+
target.ownerDocument !== this.document ||
|
|
2581
|
+
!target.getClientRects().length)
|
|
2582
|
+
this.release(target);
|
|
2583
|
+
for (const entries of [...this.interactions.values()])
|
|
2584
|
+
for (const refresh of [...entries.values()])
|
|
2585
|
+
refresh();
|
|
2586
|
+
for (const press of this.presses.values())
|
|
2587
|
+
press.refresh();
|
|
2588
|
+
for (const drag of this.drags.values())
|
|
2589
|
+
drag.refresh();
|
|
2590
|
+
this.observe();
|
|
2591
|
+
});
|
|
2592
|
+
observer.observe(root, {
|
|
2593
|
+
childList: true,
|
|
2594
|
+
subtree: true,
|
|
2595
|
+
attributes: true,
|
|
2596
|
+
attributeFilter: [
|
|
2597
|
+
'disabled',
|
|
2598
|
+
'aria-disabled',
|
|
2599
|
+
'aria-busy',
|
|
2600
|
+
'inert',
|
|
2601
|
+
'open',
|
|
2602
|
+
'hidden',
|
|
2603
|
+
],
|
|
2604
|
+
});
|
|
2605
|
+
this.observers.set(root, observer);
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
release(target) {
|
|
2609
|
+
const surface = this.surfaces.get(target);
|
|
2610
|
+
// Mark first: controller cleanup can dispose bound values and re-enter unbind.
|
|
2611
|
+
if (surface)
|
|
2612
|
+
surface.disposed = true;
|
|
2613
|
+
for (const resource of [...(this.interactions.get(target)?.keys() ?? [])])
|
|
2614
|
+
resource.dispose();
|
|
2615
|
+
if (this.surfaces.has(target))
|
|
2616
|
+
this.diagnosticEvent('released', undefined, target);
|
|
2617
|
+
this.layouts.get(target)?.stop();
|
|
2618
|
+
this.layouts.delete(target);
|
|
2619
|
+
this.sizes.get(target)?.detach();
|
|
2620
|
+
this.sizes.delete(target);
|
|
2621
|
+
for (const link of [...(this.scrollLinks.get(target) ?? [])])
|
|
2622
|
+
link.dispose();
|
|
2623
|
+
this.drags.get(target)?.detach();
|
|
2624
|
+
this.drags.delete(target);
|
|
2625
|
+
this.presses.get(target)?.detach();
|
|
2626
|
+
this.presses.delete(target);
|
|
2627
|
+
if (!surface)
|
|
2628
|
+
return;
|
|
2629
|
+
const at = this.now(), affected = new Set();
|
|
2630
|
+
for (const entry of surface.state.entries.values()) {
|
|
2631
|
+
entry.owner.diagnosticReason = 'released';
|
|
2632
|
+
entry.owner.entries.delete(entry);
|
|
2633
|
+
entry.owner.complete = false;
|
|
2634
|
+
affected.add(entry.owner);
|
|
2635
|
+
}
|
|
2636
|
+
this.ownership.invalidate(target);
|
|
2637
|
+
surface.restore();
|
|
2638
|
+
this.surfaces.delete(target);
|
|
2639
|
+
for (const owner of affected)
|
|
2640
|
+
owner.refresh(at);
|
|
2641
|
+
this.observe();
|
|
2642
|
+
}
|
|
2643
|
+
forget(owner) {
|
|
2644
|
+
this.diagnosticEvent(owner.complete ? 'completed' : (owner.diagnosticReason ?? 'interrupted'), owner);
|
|
2645
|
+
this.animations.delete(owner);
|
|
2646
|
+
if (this.pendingFrame !== undefined && ![...this.animations].some((a) => a.pending)) {
|
|
2647
|
+
this.scheduler.remove(this.pendingFrame);
|
|
2648
|
+
this.pendingFrame = undefined;
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
/** Internal diagnostics for conformance fixtures, not a frame subscription. */
|
|
2652
|
+
inspect(target) {
|
|
2653
|
+
const surface = this.surfaces.get(target), at = this.now();
|
|
2654
|
+
return {
|
|
2655
|
+
scopes: this.scopes.size,
|
|
2656
|
+
paths: this.paths.size,
|
|
2657
|
+
itemAnimations: this.itemAnimations.size,
|
|
2658
|
+
groups: this.groups.size,
|
|
2659
|
+
timers: this.timers.size,
|
|
2660
|
+
sharedLayouts: this.sharedLayouts.size,
|
|
2661
|
+
pointerFollowers: this.pointerFollowers.size,
|
|
2662
|
+
viewportEntrances: this.viewportEntrances.size,
|
|
2663
|
+
preferenceListeners: this.preferenceListeners.size,
|
|
2664
|
+
drags: this.drags.size,
|
|
2665
|
+
targets: this.surfaces.size,
|
|
2666
|
+
values: this.values.size,
|
|
2667
|
+
interactions: [...this.interactions.values()].reduce((sum, entries) => sum + entries.size, 0),
|
|
2668
|
+
valueAnimations: this.valueTracks.size,
|
|
2669
|
+
valueTracks: [...this.valueTracks].map((e) => ({
|
|
2670
|
+
layer: e.layer,
|
|
2671
|
+
from: e.track.valueAt(0),
|
|
2672
|
+
initialVelocity: e.track.velocityAt(0),
|
|
2673
|
+
time: e.owner.time(at),
|
|
2674
|
+
duration: e.track.end,
|
|
2675
|
+
})),
|
|
2676
|
+
sizes: this.sizes.size,
|
|
2677
|
+
layouts: this.layouts.size,
|
|
2678
|
+
scrollSources: this.scrollSources.size,
|
|
2679
|
+
scheduler: {
|
|
2680
|
+
tasks: this.scheduler.size,
|
|
2681
|
+
pending: this.scheduler.pending,
|
|
2682
|
+
frames: this.scheduler.frames,
|
|
2683
|
+
},
|
|
2684
|
+
animations: this.animations.size,
|
|
2685
|
+
observers: this.observers.size,
|
|
2686
|
+
geometryObservers: [...this.surfaces.values()].reduce((sum, s) => sum + s.geometryObservers, 0),
|
|
2687
|
+
pendingFrame: this.pendingFrame !== undefined,
|
|
2688
|
+
...(surface && {
|
|
2689
|
+
pose: poseAt(surface.snapshot(surface.state, at), surface.rest()),
|
|
2690
|
+
bindings: surface.state.bindings.size,
|
|
2691
|
+
execution: surface.path,
|
|
2692
|
+
effects: surface.target.getAnimations().length,
|
|
2693
|
+
keyframes: surface.frameCount,
|
|
2694
|
+
rebuilds: surface.rebuilds,
|
|
2695
|
+
tracks: [...surface.state.entries.values()].map((e) => ({
|
|
2696
|
+
property: e.property,
|
|
2697
|
+
layer: e.layer,
|
|
2698
|
+
time: e.owner.time(at),
|
|
2699
|
+
clockTime: e.owner.clock?.currentTime,
|
|
2700
|
+
startTime: e.owner.clock?.startTime,
|
|
2701
|
+
initialVelocity: e.track.velocityAt(0),
|
|
2702
|
+
from: e.track.values[0],
|
|
2703
|
+
position: e.track.valueAt(e.owner.time(at)),
|
|
2704
|
+
velocity: e.owner.paused || e.owner.pending ? 0 : e.track.velocityAt(e.owner.time(at)),
|
|
2705
|
+
duration: e.track.end,
|
|
2706
|
+
paused: e.owner.paused,
|
|
2707
|
+
pending: e.owner.pending,
|
|
2708
|
+
})),
|
|
2709
|
+
}),
|
|
2710
|
+
};
|
|
2711
|
+
}
|
|
2712
|
+
dispose() {
|
|
2713
|
+
if (this.disposed)
|
|
2714
|
+
return;
|
|
2715
|
+
this.disposed = true;
|
|
2716
|
+
const errors = [];
|
|
2717
|
+
for (const resource of [
|
|
2718
|
+
...this.scopes,
|
|
2719
|
+
...[...this.interactions.values()].flatMap((entries) => [...entries.keys()]),
|
|
2720
|
+
...[...this.drags.values()].map((drag) => drag.handle),
|
|
2721
|
+
...this.stateControllers,
|
|
2722
|
+
...this.itemAnimations,
|
|
2723
|
+
...this.paths.values(),
|
|
2724
|
+
...this.pointerFollowers,
|
|
2725
|
+
...this.viewportEntrances,
|
|
2726
|
+
...this.sharedLayouts.values(),
|
|
2727
|
+
]) {
|
|
2728
|
+
try {
|
|
2729
|
+
resource.dispose();
|
|
2730
|
+
}
|
|
2731
|
+
catch (error) {
|
|
2732
|
+
errors.push(error);
|
|
2733
|
+
}
|
|
2734
|
+
}
|
|
2735
|
+
this.paths.clear();
|
|
2736
|
+
this.stateControllers.clear();
|
|
2737
|
+
this.itemAnimations.clear();
|
|
2738
|
+
this.scopes.clear();
|
|
2739
|
+
this.pointerFollowers.clear();
|
|
2740
|
+
this.viewportEntrances.clear();
|
|
2741
|
+
this.preferenceListeners.clear();
|
|
2742
|
+
this.preference.removeEventListener('change', this.preferenceChanged);
|
|
2743
|
+
this.document.removeEventListener('visibilitychange', this.visibility);
|
|
2744
|
+
for (const group of [...this.groups])
|
|
2745
|
+
group.stop();
|
|
2746
|
+
this.groups.clear();
|
|
2747
|
+
this.groupVisibility.clear();
|
|
2748
|
+
this.timers.dispose();
|
|
2749
|
+
for (const layout of this.layouts.values())
|
|
2750
|
+
layout.stop();
|
|
2751
|
+
for (const target of [...this.surfaces.keys()])
|
|
2752
|
+
this.release(target);
|
|
2753
|
+
for (const observer of this.observers.values())
|
|
2754
|
+
observer.disconnect();
|
|
2755
|
+
this.observers.clear();
|
|
2756
|
+
for (const value of [...this.values])
|
|
2757
|
+
value.dispose();
|
|
2758
|
+
this.scheduler.dispose();
|
|
2759
|
+
this.pendingFrame = undefined;
|
|
2760
|
+
this.presets.clear();
|
|
2761
|
+
this.diagnosticEvent('disposed');
|
|
2762
|
+
this.diagnostic?.end();
|
|
2763
|
+
if (errors.length)
|
|
2764
|
+
throw new AggregateError(errors, 'Web runtime cleanup failed.');
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
export const createWebRuntime = (document, options) => new WebRuntime(document, options);
|
|
2768
|
+
//# sourceMappingURL=runtime.js.map
|