@rafaelaugusto/jolt 0.1.0-beta.8 → 0.1.0-rc.1
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 +136 -15
- package/dist/animate.d.ts +25 -4
- package/dist/animate.d.ts.map +1 -1
- package/dist/animate.js +67 -26
- 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 +18 -0
- package/dist/bottom-sheet/geometry.d.ts.map +1 -0
- package/dist/bottom-sheet/geometry.js +51 -0
- package/dist/bottom-sheet/geometry.js.map +1 -0
- package/dist/bottom-sheet/index.d.ts +56 -0
- package/dist/bottom-sheet/index.d.ts.map +1 -0
- package/dist/bottom-sheet/index.js +462 -0
- package/dist/bottom-sheet/index.js.map +1 -0
- package/dist/bottom-sheet/native.d.ts +11 -0
- package/dist/bottom-sheet/native.d.ts.map +1 -0
- package/dist/bottom-sheet/native.js +173 -0
- package/dist/bottom-sheet/native.js.map +1 -0
- 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/decay.d.ts +1 -0
- package/dist/decay.d.ts.map +1 -1
- package/dist/decay.js +7 -0
- package/dist/decay.js.map +1 -1
- package/dist/drag-physics.d.ts +6 -1
- package/dist/drag-physics.d.ts.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 +67 -1
- 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 +14 -0
- 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-layout.d.ts +9 -0
- package/dist/driver/ios-layout.d.ts.map +1 -0
- package/dist/driver/ios-layout.js +52 -0
- package/dist/driver/ios-layout.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 +57 -1
- package/dist/driver/ios.js.map +1 -1
- package/dist/easing.d.ts +3 -1
- package/dist/easing.d.ts.map +1 -1
- package/dist/easing.js +18 -1
- package/dist/easing.js.map +1 -1
- package/dist/engine.d.ts +35 -2
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +211 -42
- 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 +38 -0
- package/dist/gradient-binding.d.ts.map +1 -0
- package/dist/gradient-binding.js +128 -0
- package/dist/gradient-binding.js.map +1 -0
- package/dist/gradient.d.ts +105 -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 +13 -0
- package/dist/gravity.d.ts.map +1 -0
- package/dist/gravity.js +84 -0
- package/dist/gravity.js.map +1 -0
- package/dist/haptics.d.ts.map +1 -1
- package/dist/haptics.js +101 -28
- 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 +21 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -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 +44 -0
- package/dist/interactive-navigation/index.d.ts.map +1 -0
- package/dist/interactive-navigation/index.js +314 -0
- package/dist/interactive-navigation/index.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/layout.d.ts +13 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +348 -0
- package/dist/layout.js.map +1 -0
- package/dist/live-spring-driver.d.ts +52 -0
- package/dist/live-spring-driver.d.ts.map +1 -0
- package/dist/live-spring-driver.js +104 -0
- package/dist/live-spring-driver.js.map +1 -0
- package/dist/mixer.d.ts +55 -0
- package/dist/mixer.d.ts.map +1 -0
- package/dist/mixer.js +278 -0
- package/dist/mixer.js.map +1 -0
- package/dist/motion-scope.d.ts +10 -2
- package/dist/motion-scope.d.ts.map +1 -1
- package/dist/motion-scope.js +30 -3
- package/dist/motion-scope.js.map +1 -1
- package/dist/motion-states.d.ts +19 -7
- package/dist/motion-states.d.ts.map +1 -1
- package/dist/motion-states.js +116 -26
- package/dist/motion-states.js.map +1 -1
- package/dist/motion-value.d.ts +227 -0
- package/dist/motion-value.d.ts.map +1 -0
- package/dist/motion-value.js +1074 -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 +116 -0
- package/dist/physics/index.d.ts.map +1 -0
- package/dist/physics/index.js +306 -0
- package/dist/physics/index.js.map +1 -0
- package/dist/physics/native.d.ts +53 -0
- package/dist/physics/native.d.ts.map +1 -0
- package/dist/physics/native.js +58 -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 +15 -0
- package/dist/playback.d.ts.map +1 -1
- package/dist/playback.js +23 -0
- 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/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 +10 -0
- package/dist/reorder/index.d.ts.map +1 -0
- package/dist/reorder/index.js +233 -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 +6 -0
- package/dist/reorder/model.d.ts.map +1 -0
- package/dist/reorder/model.js +30 -0
- package/dist/reorder/model.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 +92 -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/sampling.d.ts +35 -0
- package/dist/sampling.d.ts.map +1 -0
- package/dist/sampling.js +123 -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 +18 -0
- package/dist/scroll-header/geometry.d.ts.map +1 -0
- package/dist/scroll-header/geometry.js +46 -0
- package/dist/scroll-header/geometry.js.map +1 -0
- package/dist/scroll-header/index.d.ts +48 -0
- package/dist/scroll-header/index.d.ts.map +1 -0
- package/dist/scroll-header/index.js +373 -0
- package/dist/scroll-header/index.js.map +1 -0
- package/dist/scroll-header/native.d.ts +28 -0
- package/dist/scroll-header/native.d.ts.map +1 -0
- package/dist/scroll-header/native.js +43 -0
- package/dist/scroll-header/native.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 +181 -19
- 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 +238 -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 +10 -0
- package/dist/shapes/path.d.ts.map +1 -0
- package/dist/shapes/path.js +106 -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 +318 -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 +32 -0
- package/dist/shared-navigation/return-target.d.ts.map +1 -0
- package/dist/shared-navigation/return-target.js +168 -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 +216 -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 +251 -0
- package/dist/size.js.map +1 -0
- package/dist/spring.d.ts +2 -0
- package/dist/spring.d.ts.map +1 -1
- package/dist/spring.js +11 -0
- package/dist/spring.js.map +1 -1
- package/dist/svg-path.d.ts +18 -0
- package/dist/svg-path.d.ts.map +1 -1
- package/dist/svg-path.js +3 -2
- 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 +3 -0
- package/dist/track.d.ts.map +1 -1
- package/dist/track.js +281 -40
- package/dist/track.js.map +1 -1
- package/dist/transition.d.ts +54 -2
- package/dist/transition.d.ts.map +1 -1
- package/dist/transition.js +128 -8
- package/dist/transition.js.map +1 -1
- package/dist/types.d.ts +10 -1
- 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 +13 -0
- package/dist/value-track.d.ts.map +1 -0
- package/dist/value-track.js +59 -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/zoomable.d.ts +1 -1
- package/dist/zoomable.d.ts.map +1 -1
- package/package.json +68 -3
- package/platforms/android/include.gradle +10 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/BlurEffect.java +89 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/CircleMath.java +151 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/CircleWorld.java +210 -0
- 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 +224 -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/LiveSpring.java +277 -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/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 +84 -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 +120 -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 +20 -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 +183 -0
- package/platforms/ios/src/JoltCircleWorld.h +17 -0
- package/platforms/ios/src/JoltCircleWorld.m +203 -0
- package/platforms/ios/src/JoltGestureSession.h +23 -0
- package/platforms/ios/src/JoltGestureSession.m +251 -0
- package/platforms/ios/src/JoltInteractiveNavigation.h +23 -0
- package/platforms/ios/src/JoltInteractiveNavigation.m +255 -0
- package/platforms/ios/src/JoltLiveSpring.h +29 -0
- package/platforms/ios/src/JoltLiveSpring.m +243 -0
- package/platforms/ios/src/JoltMotionProbe.h +9 -0
- package/platforms/ios/src/JoltMotionProbe.m +72 -0
- package/platforms/ios/src/JoltReorderSession.h +15 -0
- package/platforms/ios/src/JoltReorderSession.m +205 -0
- package/platforms/ios/src/JoltScrollHeader.h +13 -0
- package/platforms/ios/src/JoltScrollHeader.m +93 -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 +10 -0
- package/src/android-plugin.d.ts +463 -0
- package/src/animate.ts +129 -15
- 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 +84 -0
- package/src/bottom-sheet/index.ts +536 -0
- package/src/bottom-sheet/native.ts +214 -0
- package/src/config.ts +39 -1
- package/src/decay.ts +9 -0
- 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 +69 -1
- package/src/driver/frame.ts +10 -0
- package/src/driver/index.ts +15 -0
- package/src/driver/ios-gradient.ts +136 -0
- package/src/driver/ios-layout.ts +63 -0
- package/src/driver/ios-scroll-delegate.ts +23 -0
- package/src/driver/ios.ts +70 -17
- package/src/easing.ts +21 -1
- package/src/engine.ts +226 -59
- 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 +158 -0
- package/src/gradient.ts +663 -0
- package/src/gravity.ts +107 -0
- package/src/haptics.ts +106 -28
- package/src/image-effect.ts +10 -2
- package/src/index.ts +59 -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 +398 -0
- package/src/ios-plugin.d.ts +279 -0
- package/src/keyboard.ts +231 -7
- package/src/layout.ts +408 -0
- package/src/live-spring-driver.ts +181 -0
- package/src/mixer.ts +306 -0
- package/src/motion-scope.ts +53 -6
- package/src/motion-states.ts +149 -42
- package/src/motion-value.ts +1289 -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 +443 -0
- package/src/physics/native.ts +110 -0
- package/src/playback-group.ts +17 -1
- package/src/playback.ts +41 -0
- package/src/predictive-back/index.ts +280 -0
- package/src/predictive-back/presentation.ts +6 -0
- package/src/reorder/handle.ts +9 -0
- package/src/reorder/index.ts +243 -0
- package/src/reorder/list-view.ts +262 -0
- package/src/reorder/model.ts +47 -0
- package/src/reorder/surface.ts +10 -0
- package/src/reorder/types.ts +87 -0
- package/src/sampling.ts +173 -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 +88 -0
- package/src/scroll-header/index.ts +504 -0
- package/src/scroll-header/native.ts +89 -0
- package/src/sensors/index.ts +246 -0
- package/src/sensors/native.ts +72 -0
- package/src/sequence.ts +209 -20
- package/src/shapes/android.ts +63 -0
- package/src/shapes/index.ts +267 -0
- package/src/shapes/ios.ts +194 -0
- package/src/shapes/native.ts +27 -0
- package/src/shapes/path.ts +127 -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 +414 -0
- package/src/shared-navigation/return-signal.ts +41 -0
- package/src/shared-navigation/return-target.ts +197 -0
- package/src/shared-navigation/scope.ts +3 -0
- package/src/shared-navigation/targets.ts +38 -0
- package/src/size-layout.ts +237 -0
- package/src/size.ts +302 -0
- package/src/spring.ts +18 -0
- package/src/svg-path.ts +8 -3
- 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 +334 -38
- package/src/transition.ts +197 -9
- package/src/types.ts +11 -1
- package/src/value-observers.ts +147 -0
- package/src/value-track.ts +71 -0
- package/src/vue/index.ts +147 -1
- package/src/zoomable.ts +1 -1
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { Application, Trace } from '@nativescript/core'
|
|
2
|
+
import { onReducedMotion, reducedMotion } from '../config.js'
|
|
3
|
+
import {
|
|
4
|
+
motionValue,
|
|
5
|
+
springValue,
|
|
6
|
+
liveValueInput,
|
|
7
|
+
type DerivedValue,
|
|
8
|
+
type SpringValue,
|
|
9
|
+
} from '../motion-value.js'
|
|
10
|
+
import type { MotionScope } from '../motion-scope.js'
|
|
11
|
+
import { createSensorDriver, rememberSensorDriver, type SensorDriver } from './native.js'
|
|
12
|
+
|
|
13
|
+
export type SensorKind = 'rotation' | 'gravity'
|
|
14
|
+
export type SensorStatus =
|
|
15
|
+
| 'idle'
|
|
16
|
+
| 'starting'
|
|
17
|
+
| 'active'
|
|
18
|
+
| 'paused'
|
|
19
|
+
| 'unavailable'
|
|
20
|
+
| 'error'
|
|
21
|
+
| 'replaying'
|
|
22
|
+
| 'disposed'
|
|
23
|
+
export interface SensorOptions {
|
|
24
|
+
/** Milliseconds; 'auto' requests the display interval. Hardware may deliver less often. Minimum 5 ms. */
|
|
25
|
+
interval?: number | 'auto'
|
|
26
|
+
/** Right-handed x right, y up, z out of the screen. Defaults to interface coordinates. */
|
|
27
|
+
coordinates?: 'device' | 'interface'
|
|
28
|
+
/** Decorative motion stops sampling under Reduce Motion by default. */
|
|
29
|
+
reducedMotion?: 'pause' | 'continue'
|
|
30
|
+
scope?: MotionScope
|
|
31
|
+
/** Availability/lifecycle boundaries only. Never a callback for every reading. */
|
|
32
|
+
onStatus?: (status: SensorStatus) => void
|
|
33
|
+
}
|
|
34
|
+
export interface SensorSnapshot {
|
|
35
|
+
status: SensorStatus
|
|
36
|
+
available: boolean
|
|
37
|
+
error: string | null
|
|
38
|
+
/** Monotonic hardware timestamp, milliseconds since boot; not a wall-clock date. */
|
|
39
|
+
timestamp: number | null
|
|
40
|
+
samples: number
|
|
41
|
+
frames: number
|
|
42
|
+
callbacks: number
|
|
43
|
+
processingMs: number
|
|
44
|
+
interval: number
|
|
45
|
+
values: number[]
|
|
46
|
+
}
|
|
47
|
+
interface SensorBase {
|
|
48
|
+
readonly kind: SensorKind
|
|
49
|
+
readonly status: SensorStatus
|
|
50
|
+
readonly available: boolean
|
|
51
|
+
readonly paused: boolean
|
|
52
|
+
readonly disposed: boolean
|
|
53
|
+
/** Read on demand; installs no JS polling. Rotation values are radians, then quaternion xyzw. */
|
|
54
|
+
snapshot(): SensorSnapshot
|
|
55
|
+
pause(): void
|
|
56
|
+
play(): void
|
|
57
|
+
dispose(): void
|
|
58
|
+
}
|
|
59
|
+
export interface RotationSensor extends SensorBase {
|
|
60
|
+
readonly kind: 'rotation'
|
|
61
|
+
/** Relative extrinsic XYZ angles (equivalently intrinsic ZYX), radians. Map to degrees for Jolt rotation. */
|
|
62
|
+
readonly x: DerivedValue
|
|
63
|
+
readonly y: DerivedValue
|
|
64
|
+
readonly z: DerivedValue
|
|
65
|
+
/** Unit quaternion xyzw; prefer quaternion interpolation for full rotations. */
|
|
66
|
+
readonly quaternion: Readonly<{
|
|
67
|
+
x: DerivedValue
|
|
68
|
+
y: DerivedValue
|
|
69
|
+
z: DerivedValue
|
|
70
|
+
w: DerivedValue
|
|
71
|
+
}>
|
|
72
|
+
/** Set the current device pose as the identity rotation at the next reading. */
|
|
73
|
+
recenter(): void
|
|
74
|
+
}
|
|
75
|
+
export interface GravitySensor extends SensorBase {
|
|
76
|
+
readonly kind: 'gravity'
|
|
77
|
+
/** Downward gravitational acceleration in m/s²; a flat, face-up phone reports z ≈ -9.80665. */
|
|
78
|
+
readonly x: DerivedValue
|
|
79
|
+
readonly y: DerivedValue
|
|
80
|
+
readonly z: DerivedValue
|
|
81
|
+
}
|
|
82
|
+
export type Sensor = RotationSensor | GravitySensor
|
|
83
|
+
export function sensor(kind: 'rotation', options?: SensorOptions): RotationSensor
|
|
84
|
+
export function sensor(kind: 'gravity', options?: SensorOptions): GravitySensor
|
|
85
|
+
export function sensor(kind: SensorKind, options?: SensorOptions): Sensor
|
|
86
|
+
export function sensor(kind: SensorKind, options: SensorOptions = {}): Sensor {
|
|
87
|
+
if (kind !== 'rotation' && kind !== 'gravity')
|
|
88
|
+
throw new TypeError('sensor() supports rotation and gravity.')
|
|
89
|
+
if (!options || typeof options !== 'object')
|
|
90
|
+
throw new TypeError('Expected sensor options.')
|
|
91
|
+
const interval = options.interval ?? 'auto'
|
|
92
|
+
if (
|
|
93
|
+
interval !== 'auto' &&
|
|
94
|
+
(!Number.isFinite(interval) || interval < 5 || interval > 1000)
|
|
95
|
+
)
|
|
96
|
+
throw new RangeError('Sensor interval must be auto or 5–1000 milliseconds.')
|
|
97
|
+
const coordinates = options.coordinates ?? 'interface'
|
|
98
|
+
if (!['device', 'interface'].includes(coordinates))
|
|
99
|
+
throw new TypeError('Invalid sensor coordinates.')
|
|
100
|
+
if (
|
|
101
|
+
options.reducedMotion !== undefined &&
|
|
102
|
+
!['pause', 'continue'].includes(options.reducedMotion)
|
|
103
|
+
)
|
|
104
|
+
throw new TypeError('Invalid reduced-motion sensor policy.')
|
|
105
|
+
if (options.onStatus !== undefined && typeof options.onStatus !== 'function')
|
|
106
|
+
throw new TypeError('onStatus must be a function.')
|
|
107
|
+
if (options.scope?.disposed || options.scope?.suspended)
|
|
108
|
+
throw new Error('Sensor scope must be active.')
|
|
109
|
+
const nodes: SpringValue[] = []
|
|
110
|
+
const releases: (() => void)[] = []
|
|
111
|
+
let native: SensorDriver | undefined,
|
|
112
|
+
ended = false,
|
|
113
|
+
held = false,
|
|
114
|
+
background = false
|
|
115
|
+
let lastStatus: SensorStatus | undefined
|
|
116
|
+
const demand = new Set<number>()
|
|
117
|
+
const blocked = () =>
|
|
118
|
+
held || background || (options.reducedMotion !== 'continue' && reducedMotion())
|
|
119
|
+
const changed = () => {
|
|
120
|
+
if (!native || ended) return
|
|
121
|
+
const status = native.snapshot().status
|
|
122
|
+
for (const value of nodes)
|
|
123
|
+
liveValueInput(value).active(
|
|
124
|
+
status === 'active' || status === 'replaying' || status === 'starting',
|
|
125
|
+
)
|
|
126
|
+
if (status !== lastStatus) {
|
|
127
|
+
lastStatus = status
|
|
128
|
+
try {
|
|
129
|
+
options.onStatus?.(status)
|
|
130
|
+
} catch (error) {
|
|
131
|
+
Trace.write(
|
|
132
|
+
`Jolt sensor status listener failed: ${String(error)}`,
|
|
133
|
+
Trace.categories.Error,
|
|
134
|
+
Trace.messageType.error,
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const update = () => {
|
|
140
|
+
native?.enabled(demand.size > 0 && !blocked(), blocked())
|
|
141
|
+
changed()
|
|
142
|
+
}
|
|
143
|
+
const suspend = () => {
|
|
144
|
+
background = true
|
|
145
|
+
update()
|
|
146
|
+
}
|
|
147
|
+
const resume = () => {
|
|
148
|
+
background = false
|
|
149
|
+
update()
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
for (let i = 0; i < (kind === 'rotation' ? 7 : 3); i++)
|
|
153
|
+
nodes.push(
|
|
154
|
+
springValue(motionValue(kind === 'rotation' && i === 6 ? 1 : 0), { duration: 0 }),
|
|
155
|
+
)
|
|
156
|
+
native = createSensorDriver(
|
|
157
|
+
kind,
|
|
158
|
+
{ interval: interval === 'auto' ? 0 : interval, coordinates },
|
|
159
|
+
nodes,
|
|
160
|
+
changed,
|
|
161
|
+
)
|
|
162
|
+
nodes.forEach((value, i) =>
|
|
163
|
+
releases.push(
|
|
164
|
+
liveValueInput(value).demand((active) => {
|
|
165
|
+
if (active) demand.add(i)
|
|
166
|
+
else demand.delete(i)
|
|
167
|
+
update()
|
|
168
|
+
}),
|
|
169
|
+
),
|
|
170
|
+
)
|
|
171
|
+
releases.push(onReducedMotion(update))
|
|
172
|
+
Application.on(Application.suspendEvent, suspend)
|
|
173
|
+
Application.on(Application.resumeEvent, resume)
|
|
174
|
+
releases.push(() => {
|
|
175
|
+
Application.off(Application.suspendEvent, suspend)
|
|
176
|
+
Application.off(Application.resumeEvent, resume)
|
|
177
|
+
})
|
|
178
|
+
const source = {
|
|
179
|
+
kind,
|
|
180
|
+
x: nodes[0]!,
|
|
181
|
+
y: nodes[1]!,
|
|
182
|
+
z: nodes[2]!,
|
|
183
|
+
...(kind === 'rotation'
|
|
184
|
+
? {
|
|
185
|
+
quaternion: Object.freeze({
|
|
186
|
+
x: nodes[3]!,
|
|
187
|
+
y: nodes[4]!,
|
|
188
|
+
z: nodes[5]!,
|
|
189
|
+
w: nodes[6]!,
|
|
190
|
+
}),
|
|
191
|
+
recenter: () => {
|
|
192
|
+
if (!ended) native!.recenter()
|
|
193
|
+
},
|
|
194
|
+
}
|
|
195
|
+
: {}),
|
|
196
|
+
get status() {
|
|
197
|
+
return ended ? ('disposed' as const) : native!.snapshot().status
|
|
198
|
+
},
|
|
199
|
+
get available() {
|
|
200
|
+
return native!.snapshot().available
|
|
201
|
+
},
|
|
202
|
+
get paused() {
|
|
203
|
+
return held
|
|
204
|
+
},
|
|
205
|
+
get disposed() {
|
|
206
|
+
return ended
|
|
207
|
+
},
|
|
208
|
+
snapshot() {
|
|
209
|
+
return {
|
|
210
|
+
...native!.snapshot(),
|
|
211
|
+
...(ended ? { status: 'disposed' as const } : {}),
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
pause() {
|
|
215
|
+
if (!ended) {
|
|
216
|
+
held = true
|
|
217
|
+
update()
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
play() {
|
|
221
|
+
if (!ended) {
|
|
222
|
+
if (native!.snapshot().status === 'error') native!.enabled(false, true)
|
|
223
|
+
held = false
|
|
224
|
+
update()
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
dispose() {
|
|
228
|
+
if (ended) return
|
|
229
|
+
ended = true
|
|
230
|
+
native!.dispose()
|
|
231
|
+
releases.splice(0).forEach((release) => release())
|
|
232
|
+
nodes.forEach((value) => value.dispose())
|
|
233
|
+
},
|
|
234
|
+
} as Sensor
|
|
235
|
+
rememberSensorDriver(source, native)
|
|
236
|
+
options.scope?.add(source)
|
|
237
|
+
changed()
|
|
238
|
+
return source
|
|
239
|
+
} catch (error) {
|
|
240
|
+
ended = true
|
|
241
|
+
native?.dispose()
|
|
242
|
+
releases.forEach((release) => release())
|
|
243
|
+
nodes.forEach((value) => value.dispose())
|
|
244
|
+
throw error
|
|
245
|
+
}
|
|
246
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Application, isIOS } from '@nativescript/core'
|
|
2
|
+
import { nativeLiveNode } from '../live-spring-driver.js'
|
|
3
|
+
import { liveValueInput, type SpringValue } from '../motion-value.js'
|
|
4
|
+
import type { SensorKind, SensorSnapshot } from './index.js'
|
|
5
|
+
export interface SensorDriver {
|
|
6
|
+
enabled(active: boolean, paused: boolean): void
|
|
7
|
+
snapshot(): SensorSnapshot
|
|
8
|
+
recenter(): void
|
|
9
|
+
replay(trace: string): void
|
|
10
|
+
dispose(): void
|
|
11
|
+
}
|
|
12
|
+
const drivers = new WeakMap<object, SensorDriver>()
|
|
13
|
+
export function rememberSensorDriver(source: object, driver: SensorDriver) {
|
|
14
|
+
drivers.set(source, driver)
|
|
15
|
+
}
|
|
16
|
+
export function sensorDriver(source: { disposed: boolean }): SensorDriver {
|
|
17
|
+
const driver = drivers.get(source)
|
|
18
|
+
if (!driver || source.disposed) throw new Error('Expected a live Jolt sensor.')
|
|
19
|
+
return driver
|
|
20
|
+
}
|
|
21
|
+
export type SensorFactory = (
|
|
22
|
+
kind: SensorKind,
|
|
23
|
+
options: { interval: number; coordinates: string },
|
|
24
|
+
nodes: readonly SpringValue[],
|
|
25
|
+
changed: () => void,
|
|
26
|
+
) => SensorDriver
|
|
27
|
+
let override: SensorFactory | undefined
|
|
28
|
+
export function setSensorFactory(factory: SensorFactory | undefined) {
|
|
29
|
+
override = factory
|
|
30
|
+
}
|
|
31
|
+
export const createSensorDriver: SensorFactory = (kind, options, values, changed) => {
|
|
32
|
+
if (override) return override(kind, options, values, changed)
|
|
33
|
+
const nodes = values.map((value) => nativeLiveNode(liveValueInput(value).node))
|
|
34
|
+
if (isIOS) {
|
|
35
|
+
if (typeof JoltSensorSource === 'undefined')
|
|
36
|
+
throw new Error('Rebuild the native app to use sensor().')
|
|
37
|
+
const native = JoltSensorSource.createOptionsOnState(
|
|
38
|
+
kind,
|
|
39
|
+
JSON.stringify(options),
|
|
40
|
+
changed,
|
|
41
|
+
)
|
|
42
|
+
nodes.forEach((node, index) => native.connectIndex(node as JoltLiveSpring, index))
|
|
43
|
+
return {
|
|
44
|
+
enabled: (active, paused) => native.setEnabledPaused(active, paused),
|
|
45
|
+
snapshot: () => JSON.parse(native.snapshot()),
|
|
46
|
+
recenter: () => native.recenter(),
|
|
47
|
+
replay: (trace) => native.replay(trace),
|
|
48
|
+
dispose: () => native.dispose(),
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (
|
|
52
|
+
typeof org === 'undefined' ||
|
|
53
|
+
typeof org.rafaelaugusto.jolt.SensorSource !== 'function'
|
|
54
|
+
)
|
|
55
|
+
throw new Error('Rebuild the native app to use sensor().')
|
|
56
|
+
const native = new org.rafaelaugusto.jolt.SensorSource(
|
|
57
|
+
Application.android.context,
|
|
58
|
+
kind,
|
|
59
|
+
JSON.stringify(options),
|
|
60
|
+
new org.rafaelaugusto.jolt.SensorSource.Listener({ changed }),
|
|
61
|
+
)
|
|
62
|
+
nodes.forEach((node, index) =>
|
|
63
|
+
native.connect(node as org.rafaelaugusto.jolt.LiveSpring, index),
|
|
64
|
+
)
|
|
65
|
+
return {
|
|
66
|
+
enabled: (active, paused) => native.setEnabled(active, paused),
|
|
67
|
+
snapshot: () => JSON.parse(native.snapshot()),
|
|
68
|
+
recenter: () => native.recenter(),
|
|
69
|
+
replay: (trace) => native.replay(trace),
|
|
70
|
+
dispose: () => native.dispose(),
|
|
71
|
+
}
|
|
72
|
+
}
|
package/src/sequence.ts
CHANGED
|
@@ -10,7 +10,12 @@ import {
|
|
|
10
10
|
stopView,
|
|
11
11
|
type Animation,
|
|
12
12
|
} from './engine.js'
|
|
13
|
-
import { createClock } from './playback.js'
|
|
13
|
+
import { createClock, registerPlayback, playbackSource } from './playback.js'
|
|
14
|
+
import {
|
|
15
|
+
isMotionValue,
|
|
16
|
+
type MotionValue,
|
|
17
|
+
type ValueAnimationOptions,
|
|
18
|
+
} from './motion-value.js'
|
|
14
19
|
import type { PresetName } from './presets.js'
|
|
15
20
|
import { writeValue, type Property } from './properties.js'
|
|
16
21
|
import type { SpringName } from './transition.js'
|
|
@@ -28,6 +33,34 @@ export type Step =
|
|
|
28
33
|
]
|
|
29
34
|
| (() => Animation)
|
|
30
35
|
|
|
36
|
+
/** A participant that can genuinely freeze and continue, rather than restart. */
|
|
37
|
+
export interface PlayableAnimation extends Animation {
|
|
38
|
+
pause(): void
|
|
39
|
+
play(): void
|
|
40
|
+
readonly paused: boolean
|
|
41
|
+
readonly duration?: number
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type TimelineStep =
|
|
45
|
+
| Exclude<Step, () => Animation>
|
|
46
|
+
| readonly [
|
|
47
|
+
MotionValue,
|
|
48
|
+
number | readonly (number | null)[],
|
|
49
|
+
((ValueAnimationOptions & { at?: SequencePosition }) | SpringName)?,
|
|
50
|
+
]
|
|
51
|
+
| { readonly at?: SequencePosition; readonly run: () => PlayableAnimation }
|
|
52
|
+
| (() => PlayableAnimation)
|
|
53
|
+
|
|
54
|
+
export interface TimelineAnimation extends PlayableAnimation {
|
|
55
|
+
/** Unknown until every step has activated and every participant reports a duration. */
|
|
56
|
+
readonly duration: number | undefined
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Overlapping steps with a shared pause/resume control, including pending launches. */
|
|
60
|
+
export function timeline(steps: readonly TimelineStep[]): TimelineAnimation {
|
|
61
|
+
return compose(steps, true) as TimelineAnimation
|
|
62
|
+
}
|
|
63
|
+
|
|
31
64
|
/**
|
|
32
65
|
* By default a step starts once the previous one looks done. `at` can overlap
|
|
33
66
|
* that arrival, share the previous start, or select an absolute timeline time.
|
|
@@ -44,26 +77,54 @@ export type Step =
|
|
|
44
77
|
* ```
|
|
45
78
|
*/
|
|
46
79
|
export function sequence(steps: readonly Step[]): Animation {
|
|
80
|
+
return compose(steps, false)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function compose(
|
|
84
|
+
steps: readonly TimelineStep[] | readonly Step[],
|
|
85
|
+
controlled: boolean,
|
|
86
|
+
): Animation {
|
|
47
87
|
const prepared = steps.map((step) => {
|
|
48
88
|
if (typeof step === 'function') return { step, position: undefined }
|
|
49
|
-
|
|
89
|
+
if (!Array.isArray(step)) {
|
|
90
|
+
const descriptor = step as { at?: SequencePosition; run: () => PlayableAnimation }
|
|
91
|
+
if (typeof descriptor.run !== 'function')
|
|
92
|
+
throw new TypeError('A timeline step needs a run() factory.')
|
|
93
|
+
return { step: descriptor.run, position: parsePosition(descriptor.at) }
|
|
94
|
+
}
|
|
95
|
+
const [target, animation, options] = step as Exclude<
|
|
96
|
+
TimelineStep,
|
|
97
|
+
Function | { run: () => PlayableAnimation }
|
|
98
|
+
>
|
|
50
99
|
if (typeof options !== 'object' || options === null)
|
|
51
100
|
return { step, position: undefined }
|
|
52
101
|
const { at, ...transition } = options
|
|
53
102
|
const position = parsePosition(at)
|
|
54
103
|
return { step: [target, animation, transition] as Step, position }
|
|
55
104
|
})
|
|
56
|
-
applyStartingValues(
|
|
105
|
+
applyStartingValues(
|
|
106
|
+
prepared
|
|
107
|
+
.map(({ step }) => step as Step)
|
|
108
|
+
.filter((step) => typeof step === 'function' || !isMotionValue(step[0])),
|
|
109
|
+
)
|
|
57
110
|
|
|
58
111
|
const driver = getDriver()
|
|
59
112
|
const slowdown = 1 / timeScale()
|
|
60
113
|
// Absolute positions share the platform clock, including Android duration scale.
|
|
61
|
-
const clock =
|
|
62
|
-
|
|
63
|
-
|
|
114
|
+
const clock =
|
|
115
|
+
controlled || prepared.some(({ position }) => typeof position === 'number')
|
|
116
|
+
? (driver.clock?.(Infinity) ?? createClock(() => driver.now()))
|
|
117
|
+
: undefined
|
|
64
118
|
const started: Animation[] = []
|
|
65
119
|
const cancellations = new Set<() => void>()
|
|
66
120
|
let stopped = false
|
|
121
|
+
let paused = false
|
|
122
|
+
let settled = false
|
|
123
|
+
let completed = false
|
|
124
|
+
let changed = () => {}
|
|
125
|
+
const resumeChildren = new Set<PlayableAnimation>()
|
|
126
|
+
const waits = new Set<{ at: number; fire(): void; cancel(): void; schedule(): void }>()
|
|
127
|
+
const time = () => clock?.time() ?? 0
|
|
67
128
|
let resolveScheduled!: () => void
|
|
68
129
|
let rejectScheduled!: (reason: unknown) => void
|
|
69
130
|
const scheduled = new Promise<void>((resolve, reject) => {
|
|
@@ -77,28 +138,55 @@ export function sequence(steps: readonly Step[]): Animation {
|
|
|
77
138
|
position,
|
|
78
139
|
onStart: new Set<() => void>(),
|
|
79
140
|
animation: undefined as Animation | undefined,
|
|
141
|
+
start: undefined as number | undefined,
|
|
80
142
|
}
|
|
81
143
|
})
|
|
82
144
|
const cancelSchedule = () => {
|
|
83
145
|
for (const cancel of cancellations) cancel()
|
|
84
146
|
cancellations.clear()
|
|
85
|
-
|
|
147
|
+
for (const wait of waits) wait.cancel()
|
|
148
|
+
waits.clear()
|
|
149
|
+
if (!controlled || stopped || settled) clock?.cancel()
|
|
86
150
|
}
|
|
87
151
|
const fail = (error: unknown) => {
|
|
88
152
|
if (stopped) return
|
|
89
153
|
stopped = true
|
|
154
|
+
settled = true
|
|
90
155
|
cancelSchedule()
|
|
91
156
|
states.forEach((state) => state.onStart.clear())
|
|
92
157
|
started.forEach((child) => child.stop())
|
|
158
|
+
changed()
|
|
93
159
|
rejectScheduled(error)
|
|
94
160
|
}
|
|
95
161
|
const launch = (index: number) => {
|
|
96
162
|
const state = states[index]!
|
|
97
163
|
if (stopped || state.animation) return
|
|
164
|
+
if (paused) {
|
|
165
|
+
wait(0, () => launch(index))
|
|
166
|
+
return
|
|
167
|
+
}
|
|
98
168
|
try {
|
|
99
169
|
const step = state.step
|
|
100
|
-
const child =
|
|
170
|
+
const child =
|
|
171
|
+
typeof step === 'function'
|
|
172
|
+
? step()
|
|
173
|
+
: (animate as (...args: any[]) => Animation)(...(step as any[]))
|
|
174
|
+
if (controlled && !isPlayable(child)) {
|
|
175
|
+
child?.stop?.()
|
|
176
|
+
throw new TypeError(
|
|
177
|
+
'A timeline participant must expose pause(), play() and paused; use sequence() for non-playable effects.',
|
|
178
|
+
)
|
|
179
|
+
}
|
|
101
180
|
state.animation = child
|
|
181
|
+
state.start = time()
|
|
182
|
+
if (controlled) {
|
|
183
|
+
try {
|
|
184
|
+
const playback = playbackSource(child).read()
|
|
185
|
+
if (playback.ready) state.start = Math.max(0, time() - playback.time)
|
|
186
|
+
} catch {
|
|
187
|
+
/* A custom playable participant can omit a clock. */
|
|
188
|
+
}
|
|
189
|
+
}
|
|
102
190
|
started.push(child)
|
|
103
191
|
// Observe setup failures immediately, even while other steps are still
|
|
104
192
|
// scheduled. Nested sequences can reject before this one reaches arrival.
|
|
@@ -110,25 +198,51 @@ export function sequence(steps: readonly Step[]): Animation {
|
|
|
110
198
|
cancelSchedule()
|
|
111
199
|
resolveScheduled()
|
|
112
200
|
}
|
|
201
|
+
changed()
|
|
113
202
|
} catch (error) {
|
|
114
203
|
fail(error)
|
|
115
204
|
}
|
|
116
205
|
}
|
|
117
206
|
const wait = (ms: number, callback: () => void) => {
|
|
118
207
|
if (stopped) return
|
|
119
|
-
if (
|
|
120
|
-
|
|
208
|
+
if (!controlled) {
|
|
209
|
+
if (ms <= 0) {
|
|
210
|
+
callback()
|
|
211
|
+
return
|
|
212
|
+
}
|
|
213
|
+
let cancel = () => {}
|
|
214
|
+
let fired = false
|
|
215
|
+
const off = driver.after(ms, () => {
|
|
216
|
+
fired = true
|
|
217
|
+
cancellations.delete(cancel)
|
|
218
|
+
if (!stopped) callback()
|
|
219
|
+
})
|
|
220
|
+
cancel = off
|
|
221
|
+
if (!fired) cancellations.add(cancel)
|
|
121
222
|
return
|
|
122
223
|
}
|
|
123
|
-
let
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
224
|
+
let off = () => {}
|
|
225
|
+
const waiting = {
|
|
226
|
+
at: time() + Math.max(0, ms),
|
|
227
|
+
fire() {
|
|
228
|
+
off()
|
|
229
|
+
waits.delete(waiting)
|
|
230
|
+
if (!stopped) callback()
|
|
231
|
+
},
|
|
232
|
+
cancel() {
|
|
233
|
+
off()
|
|
234
|
+
off = () => {}
|
|
235
|
+
},
|
|
236
|
+
schedule() {
|
|
237
|
+
waiting.cancel()
|
|
238
|
+
if (paused || stopped) return
|
|
239
|
+
const remaining = waiting.at - time()
|
|
240
|
+
if (remaining <= 0) waiting.fire()
|
|
241
|
+
else off = driver.after(remaining, waiting.fire)
|
|
242
|
+
},
|
|
243
|
+
}
|
|
244
|
+
waits.add(waiting)
|
|
245
|
+
waiting.schedule()
|
|
132
246
|
}
|
|
133
247
|
|
|
134
248
|
for (let index = 0; index < states.length; index++) {
|
|
@@ -214,7 +328,11 @@ export function sequence(steps: readonly Step[]): Animation {
|
|
|
214
328
|
const arrived = scheduled.then(() => Promise.all(started.map(arrivalOf)))
|
|
215
329
|
const finished = arrived.then(async () => {
|
|
216
330
|
const results = await Promise.all(started.map((animation) => animation.finished))
|
|
217
|
-
|
|
331
|
+
completed = !stopped && results.length === steps.length && results.every(Boolean)
|
|
332
|
+
settled = true
|
|
333
|
+
clock?.cancel()
|
|
334
|
+
changed()
|
|
335
|
+
return completed
|
|
218
336
|
})
|
|
219
337
|
|
|
220
338
|
const animation: Animation = {
|
|
@@ -222,13 +340,69 @@ export function sequence(steps: readonly Step[]): Animation {
|
|
|
222
340
|
stop() {
|
|
223
341
|
if (stopped) return
|
|
224
342
|
stopped = true
|
|
343
|
+
settled = true
|
|
225
344
|
cancelSchedule()
|
|
226
345
|
states.forEach((state) => state.onStart.clear())
|
|
227
346
|
resolveScheduled()
|
|
228
347
|
started.forEach((animation) => animation.stop())
|
|
348
|
+
resumeChildren.clear()
|
|
349
|
+
changed()
|
|
229
350
|
},
|
|
230
351
|
then: (onfulfilled, onrejected) => finished.then(onfulfilled, onrejected),
|
|
231
352
|
}
|
|
353
|
+
if (controlled) {
|
|
354
|
+
const duration = () => {
|
|
355
|
+
if (pending) return undefined
|
|
356
|
+
let total = 0
|
|
357
|
+
for (const state of states) {
|
|
358
|
+
const child = state.animation as PlayableAnimation | undefined
|
|
359
|
+
if (!child || child.duration === undefined) return undefined
|
|
360
|
+
try {
|
|
361
|
+
if (!playbackSource(child).read().ready) return undefined
|
|
362
|
+
} catch {
|
|
363
|
+
/* custom playable */
|
|
364
|
+
}
|
|
365
|
+
total = Math.max(total, (state.start ?? 0) + child.duration)
|
|
366
|
+
}
|
|
367
|
+
return total
|
|
368
|
+
}
|
|
369
|
+
Object.defineProperties(animation, {
|
|
370
|
+
paused: { get: () => paused },
|
|
371
|
+
duration: { get: duration },
|
|
372
|
+
})
|
|
373
|
+
Object.assign(animation, {
|
|
374
|
+
pause() {
|
|
375
|
+
if (paused || settled) return
|
|
376
|
+
paused = true
|
|
377
|
+
clock?.pause()
|
|
378
|
+
for (const wait of waits) wait.cancel()
|
|
379
|
+
for (const child of started as PlayableAnimation[]) {
|
|
380
|
+
if (!child.paused) {
|
|
381
|
+
resumeChildren.add(child)
|
|
382
|
+
child.pause()
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
changed()
|
|
386
|
+
},
|
|
387
|
+
play() {
|
|
388
|
+
if (!paused || settled) return
|
|
389
|
+
paused = false
|
|
390
|
+
clock?.play()
|
|
391
|
+
for (const child of resumeChildren) child.play()
|
|
392
|
+
resumeChildren.clear()
|
|
393
|
+
for (const wait of [...waits]) wait.schedule()
|
|
394
|
+
changed()
|
|
395
|
+
},
|
|
396
|
+
})
|
|
397
|
+
changed = registerPlayback(animation, () => ({
|
|
398
|
+
time: time(),
|
|
399
|
+
duration: duration() ?? Infinity,
|
|
400
|
+
paused,
|
|
401
|
+
ready: duration() !== undefined,
|
|
402
|
+
settled,
|
|
403
|
+
completed,
|
|
404
|
+
}))
|
|
405
|
+
}
|
|
232
406
|
setArrival(animation, arrived)
|
|
233
407
|
return animation
|
|
234
408
|
}
|
|
@@ -276,3 +450,18 @@ function applyStartingValues(steps: readonly Step[]) {
|
|
|
276
450
|
}
|
|
277
451
|
}
|
|
278
452
|
}
|
|
453
|
+
|
|
454
|
+
function isPlayable(animation: Animation): animation is PlayableAnimation {
|
|
455
|
+
const handle = animation as PlayableAnimation | undefined
|
|
456
|
+
return (
|
|
457
|
+
!!handle &&
|
|
458
|
+
typeof handle.pause === 'function' &&
|
|
459
|
+
typeof handle.play === 'function' &&
|
|
460
|
+
typeof handle.paused === 'boolean' &&
|
|
461
|
+
typeof handle.stop === 'function' &&
|
|
462
|
+
typeof handle.finished?.then === 'function' &&
|
|
463
|
+
typeof handle.finished?.catch === 'function' &&
|
|
464
|
+
(handle.duration === undefined ||
|
|
465
|
+
(typeof handle.duration === 'number' && handle.duration >= 0))
|
|
466
|
+
)
|
|
467
|
+
}
|