@rafaelaugusto/jolt 0.1.0-beta.9 → 0.1.0-rc.2
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 +167 -21
- 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 +27 -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 +4 -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-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 +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 +31 -2
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +194 -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 +19 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -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 +350 -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/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 +286 -0
- package/dist/mixer.js.map +1 -0
- package/dist/motion-scope.d.ts +8 -2
- package/dist/motion-scope.d.ts.map +1 -1
- package/dist/motion-scope.js +24 -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 +139 -0
- package/dist/physics/index.d.ts.map +1 -0
- package/dist/physics/index.js +316 -0
- package/dist/physics/index.js.map +1 -0
- package/dist/physics/native.d.ts +54 -0
- package/dist/physics/native.d.ts.map +1 -0
- package/dist/physics/native.js +64 -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/press.d.ts.map +1 -1
- package/dist/press.js +11 -2
- package/dist/press.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 +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 +399 -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 +158 -0
- package/platforms/android/java/org/rafaelaugusto/jolt/CircleWorld.java +221 -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 +191 -0
- package/platforms/ios/src/JoltCircleWorld.h +18 -0
- package/platforms/ios/src/JoltCircleWorld.m +218 -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 +101 -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 +464 -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 +31 -1
- package/src/driver/frame.ts +10 -0
- package/src/driver/index.ts +4 -0
- 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 +21 -1
- package/src/engine.ts +209 -60
- 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 +56 -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 +427 -0
- package/src/ios-plugin.d.ts +280 -0
- package/src/keyboard.ts +231 -7
- package/src/live-spring-driver.ts +181 -0
- package/src/mixer.ts +312 -0
- package/src/motion-scope.ts +39 -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 +476 -0
- package/src/physics/native.ts +121 -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/press.ts +10 -2
- 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 +530 -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,63 @@
|
|
|
1
|
+
import type { ShapeFactory } from './native.js'
|
|
2
|
+
const floats = (values: readonly number[]) => {
|
|
3
|
+
const a = Array.create('float', values.length)
|
|
4
|
+
values.forEach((v, i) => (a[i] = v))
|
|
5
|
+
return a
|
|
6
|
+
}
|
|
7
|
+
export const androidShape: ShapeFactory = (view, style, initial) => {
|
|
8
|
+
if (
|
|
9
|
+
typeof org === 'undefined' ||
|
|
10
|
+
typeof org.rafaelaugusto.jolt.ShapeLayer !== 'function'
|
|
11
|
+
)
|
|
12
|
+
throw new Error('Rebuild the Android app to install native shapes.')
|
|
13
|
+
const native = view.nativeViewProtected as android.view.View
|
|
14
|
+
const layer = new org.rafaelaugusto.jolt.ShapeLayer(JSON.stringify(style))
|
|
15
|
+
native.getOverlay().add(layer)
|
|
16
|
+
let path = initial.path
|
|
17
|
+
const paint = (frame: typeof initial) => {
|
|
18
|
+
path = frame.path
|
|
19
|
+
layer.paint(path.commands, floats(path.points), frame.start, frame.end)
|
|
20
|
+
}
|
|
21
|
+
const resize = () => layer.setBounds(0, 0, native.getWidth(), native.getHeight())
|
|
22
|
+
resize()
|
|
23
|
+
paint(initial)
|
|
24
|
+
return {
|
|
25
|
+
paint,
|
|
26
|
+
resize,
|
|
27
|
+
read() {
|
|
28
|
+
const v = layer.values()
|
|
29
|
+
return {
|
|
30
|
+
path: {
|
|
31
|
+
...path,
|
|
32
|
+
points: Array.from({ length: v.length - 2 }, (_, i) => v[i + 2]!),
|
|
33
|
+
},
|
|
34
|
+
start: v[0]!,
|
|
35
|
+
end: v[1]!,
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
play(from, to, track) {
|
|
39
|
+
path = from.path
|
|
40
|
+
layer.play(
|
|
41
|
+
path.commands,
|
|
42
|
+
floats([from.start, from.end, ...from.path.points]),
|
|
43
|
+
floats([to.start, to.end, ...to.path.points]),
|
|
44
|
+
floats(track.times),
|
|
45
|
+
floats(track.values),
|
|
46
|
+
track.duration,
|
|
47
|
+
track.delay,
|
|
48
|
+
track.repeat === Infinity ? -1 : track.repeat,
|
|
49
|
+
track.reverse,
|
|
50
|
+
)
|
|
51
|
+
},
|
|
52
|
+
control: (time, paused) => layer.control(time, paused),
|
|
53
|
+
animations: () => (layer.isPlaying() ? 1 : 0),
|
|
54
|
+
bounds() {
|
|
55
|
+
const b = layer.geometryBounds()
|
|
56
|
+
return Array.from({ length: b.length }, (_, i) => b[i]!)
|
|
57
|
+
},
|
|
58
|
+
dispose() {
|
|
59
|
+
layer.dispose()
|
|
60
|
+
native.getOverlay().remove(layer)
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { Application, type View } from '@nativescript/core'
|
|
2
|
+
import { toView } from '../animate.js'
|
|
3
|
+
import { parseColor } from '../color.js'
|
|
4
|
+
import { onReducedMotion, reducedMotion } from '../config.js'
|
|
5
|
+
import { TimedAnimation } from '../timed-animation.js'
|
|
6
|
+
import { createTrack, instantTrack, type Track } from '../track.js'
|
|
7
|
+
import {
|
|
8
|
+
resolveTransition,
|
|
9
|
+
springs,
|
|
10
|
+
type Transition,
|
|
11
|
+
type SpringName,
|
|
12
|
+
} from '../transition.js'
|
|
13
|
+
import type { Target } from '../types.js'
|
|
14
|
+
import { compatible, pathString, shapePath } from './path.js'
|
|
15
|
+
import { createShape, type ShapePainter } from './native.js'
|
|
16
|
+
import {
|
|
17
|
+
mixFrame,
|
|
18
|
+
type Shape,
|
|
19
|
+
type ShapeValues,
|
|
20
|
+
type ShapeOptions,
|
|
21
|
+
type ShapeFrame,
|
|
22
|
+
type ShapeStyle,
|
|
23
|
+
} from './types.js'
|
|
24
|
+
export type { Shape, ShapeValues, ShapeOptions } from './types.js'
|
|
25
|
+
const owners = new WeakMap<View, ShapeOwner>()
|
|
26
|
+
function number(n: number, name: string, min: number, max: number) {
|
|
27
|
+
if (!Number.isFinite(n) || n < min || n > max)
|
|
28
|
+
throw new RangeError(`${name} must be within ${min}..${max}.`)
|
|
29
|
+
return n
|
|
30
|
+
}
|
|
31
|
+
function resolve(base: ShapeFrame, values: ShapeValues): ShapeFrame {
|
|
32
|
+
if (
|
|
33
|
+
!values ||
|
|
34
|
+
typeof values !== 'object' ||
|
|
35
|
+
Object.keys(values).some((k) => !['d', 'strokeStart', 'strokeEnd'].includes(k))
|
|
36
|
+
)
|
|
37
|
+
throw new TypeError('Shape values accept d, strokeStart and strokeEnd.')
|
|
38
|
+
const path = values.d === undefined ? base.path : shapePath(values.d)
|
|
39
|
+
const start = number(values.strokeStart ?? base.start, 'strokeStart', 0, 1),
|
|
40
|
+
end = number(values.strokeEnd ?? base.end, 'strokeEnd', 0, 1)
|
|
41
|
+
if (path.contours > 1 && (start !== 0 || end !== 1))
|
|
42
|
+
throw new RangeError(
|
|
43
|
+
'Partial stroke drawing requires one continuous subpath. Compound paths can morph or draw their complete stroke.',
|
|
44
|
+
)
|
|
45
|
+
return { path, start, end }
|
|
46
|
+
}
|
|
47
|
+
/** Draw an owned native vector surface over a view. Create after native layout. */
|
|
48
|
+
export function shape(target: Target, options: ShapeOptions): Shape {
|
|
49
|
+
if (!options || typeof options !== 'object')
|
|
50
|
+
throw new TypeError('Shape options are required.')
|
|
51
|
+
const frame = resolve(
|
|
52
|
+
{ path: shapePath(options.d), start: 0, end: 1 },
|
|
53
|
+
{ strokeStart: options.strokeStart, strokeEnd: options.strokeEnd },
|
|
54
|
+
)
|
|
55
|
+
const box = options.viewBox
|
|
56
|
+
if (!Array.isArray(box) || box.length !== 4)
|
|
57
|
+
throw new TypeError('viewBox needs [minX, minY, width, height].')
|
|
58
|
+
const viewBox: [number, number, number, number] = [
|
|
59
|
+
number(box[0]!, 'viewBox x', -1000000, 1000000),
|
|
60
|
+
number(box[1]!, 'viewBox y', -1000000, 1000000),
|
|
61
|
+
number(box[2]!, 'viewBox width', 0.001, 1000000),
|
|
62
|
+
number(box[3]!, 'viewBox height', 0.001, 1000000),
|
|
63
|
+
]
|
|
64
|
+
const style: ShapeStyle = {
|
|
65
|
+
viewBox,
|
|
66
|
+
stroke: parseColor(options.stroke ?? '#202630'),
|
|
67
|
+
fill: parseColor(options.fill ?? '#00000000'),
|
|
68
|
+
width: number(options.strokeWidth ?? 2, 'strokeWidth', 0, 1000),
|
|
69
|
+
cap: options.lineCap ?? 'round',
|
|
70
|
+
join: options.lineJoin ?? 'round',
|
|
71
|
+
rule: options.fillRule ?? 'nonzero',
|
|
72
|
+
}
|
|
73
|
+
if (
|
|
74
|
+
!['butt', 'round', 'square'].includes(style.cap) ||
|
|
75
|
+
!['miter', 'round', 'bevel'].includes(style.join) ||
|
|
76
|
+
!['nonzero', 'evenodd'].includes(style.rule)
|
|
77
|
+
)
|
|
78
|
+
throw new TypeError('Invalid shape cap, join or fill rule.')
|
|
79
|
+
const view = toView(target)
|
|
80
|
+
if (!view.isLoaded || !view.nativeViewProtected)
|
|
81
|
+
throw new Error('Create shapes after native layout.')
|
|
82
|
+
if (owners.has(view))
|
|
83
|
+
throw new Error('This view already owns a shape. Dispose it first.')
|
|
84
|
+
return new ShapeOwner(view, style, frame)
|
|
85
|
+
}
|
|
86
|
+
class ShapeOwner implements Shape {
|
|
87
|
+
disposed = false
|
|
88
|
+
private painter?: ShapePainter
|
|
89
|
+
private native?: object
|
|
90
|
+
private active?: {
|
|
91
|
+
animation: TimedAnimation
|
|
92
|
+
track: Track
|
|
93
|
+
from: ShapeFrame
|
|
94
|
+
to: ShapeFrame
|
|
95
|
+
}
|
|
96
|
+
private suspended = false
|
|
97
|
+
private backgrounded = false
|
|
98
|
+
private offReduced: () => void
|
|
99
|
+
constructor(
|
|
100
|
+
private readonly view: View,
|
|
101
|
+
private readonly style: ShapeStyle,
|
|
102
|
+
private frame: ShapeFrame,
|
|
103
|
+
) {
|
|
104
|
+
this.attach()
|
|
105
|
+
owners.set(view, this)
|
|
106
|
+
view.on('loaded', this.layout)
|
|
107
|
+
view.on('layoutChanged', this.layout)
|
|
108
|
+
view.on('unloaded', this.unload)
|
|
109
|
+
Application.on(Application.suspendEvent, this.background)
|
|
110
|
+
Application.on(Application.resumeEvent, this.foreground)
|
|
111
|
+
this.offReduced = onReducedMotion((value) => {
|
|
112
|
+
if (!value || !this.active) return
|
|
113
|
+
const destination = this.active.to
|
|
114
|
+
this.stop()
|
|
115
|
+
this.frame = destination
|
|
116
|
+
this.painter?.paint(destination)
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
private alive() {
|
|
120
|
+
if (this.disposed) throw new Error('Shape has been disposed.')
|
|
121
|
+
}
|
|
122
|
+
private attach() {
|
|
123
|
+
this.native = this.view.nativeViewProtected
|
|
124
|
+
this.painter = createShape(this.view, this.style, this.frame)
|
|
125
|
+
}
|
|
126
|
+
private layout = () => {
|
|
127
|
+
if (this.disposed || !this.view.isLoaded || !this.view.nativeViewProtected) return
|
|
128
|
+
if (this.native && this.native !== this.view.nativeViewProtected) this.unload()
|
|
129
|
+
if (!this.painter) {
|
|
130
|
+
this.attach()
|
|
131
|
+
if (this.active) {
|
|
132
|
+
const { from, to, track, animation } = this.active
|
|
133
|
+
this.painter!.play(from, to, track)
|
|
134
|
+
this.painter!.control(animation.time, true)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
this.painter!.resize()
|
|
138
|
+
if (!this.backgrounded && this.suspended) {
|
|
139
|
+
this.active?.animation.play()
|
|
140
|
+
this.suspended = false
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
private unload = () => {
|
|
144
|
+
if (this.backgrounded && this.active) this.frame = this.painter?.read() ?? this.frame
|
|
145
|
+
else this.stop()
|
|
146
|
+
this.painter?.dispose()
|
|
147
|
+
this.painter = undefined
|
|
148
|
+
this.native = undefined
|
|
149
|
+
}
|
|
150
|
+
private background = () => {
|
|
151
|
+
if (this.backgrounded) return
|
|
152
|
+
this.backgrounded = true
|
|
153
|
+
this.suspended = !!this.active && !this.active.animation.paused
|
|
154
|
+
if (this.suspended) this.active!.animation.pause()
|
|
155
|
+
}
|
|
156
|
+
private foreground = () => {
|
|
157
|
+
this.backgrounded = false
|
|
158
|
+
if (this.painter) {
|
|
159
|
+
if (this.suspended) this.active?.animation.play()
|
|
160
|
+
this.suspended = false
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
snapshot() {
|
|
164
|
+
this.frame = this.painter?.read() ?? this.frame
|
|
165
|
+
return {
|
|
166
|
+
d: pathString(this.frame.path),
|
|
167
|
+
strokeStart: this.frame.start,
|
|
168
|
+
strokeEnd: this.frame.end,
|
|
169
|
+
attached: !!this.painter,
|
|
170
|
+
nativeAnimations: this.painter?.animations() ?? 0,
|
|
171
|
+
bounds: this.painter?.bounds() ?? null,
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
set(values: ShapeValues) {
|
|
175
|
+
this.alive()
|
|
176
|
+
const frame = resolve(this.painter?.read() ?? this.frame, values)
|
|
177
|
+
this.stop()
|
|
178
|
+
this.frame = frame
|
|
179
|
+
this.painter?.paint(frame)
|
|
180
|
+
}
|
|
181
|
+
animate(values: ShapeValues, options: Transition | SpringName = {}) {
|
|
182
|
+
this.alive()
|
|
183
|
+
if (!this.painter || !this.view.isLoaded)
|
|
184
|
+
throw new Error('Load the shape before animating.')
|
|
185
|
+
const from = this.painter.read(),
|
|
186
|
+
to = resolve(from, values)
|
|
187
|
+
compatible(from.path, to.path)
|
|
188
|
+
if (typeof options === 'string' && !Object.hasOwn(springs, options))
|
|
189
|
+
throw new TypeError('Unknown shape spring.')
|
|
190
|
+
const settings = typeof options === 'string' ? springs[options] : options
|
|
191
|
+
if ('layer' in settings)
|
|
192
|
+
throw new TypeError(
|
|
193
|
+
'Shapes own one geometry/trim animation; named layers are not supported.',
|
|
194
|
+
)
|
|
195
|
+
const transition = resolveTransition(settings, 'opacity', 2)
|
|
196
|
+
const vector = (f: ShapeFrame) => [f.start, f.end, ...f.path.points]
|
|
197
|
+
const a = vector(from),
|
|
198
|
+
b = vector(to),
|
|
199
|
+
delta = b.map((p, i) => p - a[i]!),
|
|
200
|
+
squared = delta.reduce((s, v) => s + v * v, 0)
|
|
201
|
+
let velocity = 0
|
|
202
|
+
if (this.active && !this.active.animation.paused && squared) {
|
|
203
|
+
const old = this.active,
|
|
204
|
+
speed = old.track.velocityAt(old.animation.time),
|
|
205
|
+
x = vector(old.from),
|
|
206
|
+
y = vector(old.to)
|
|
207
|
+
velocity =
|
|
208
|
+
delta.reduce((s, v, i) => s + v * ((y[i] ?? 0) - (x[i] ?? 0)) * speed, 0) /
|
|
209
|
+
squared
|
|
210
|
+
}
|
|
211
|
+
const track = reducedMotion()
|
|
212
|
+
? instantTrack('opacity', 1)
|
|
213
|
+
: createTrack('opacity', [0, 1], transition, velocity)
|
|
214
|
+
if (track.times.length * (a.length + 1) > 262144)
|
|
215
|
+
throw new RangeError(
|
|
216
|
+
'Shape animation exceeds the sampled geometry budget. Simplify the path or curve.',
|
|
217
|
+
)
|
|
218
|
+
this.stop()
|
|
219
|
+
let animation: TimedAnimation
|
|
220
|
+
animation = new TimedAnimation(
|
|
221
|
+
track.end,
|
|
222
|
+
track.arrival,
|
|
223
|
+
(time, paused) => this.painter?.control(time, paused),
|
|
224
|
+
(completed) => {
|
|
225
|
+
this.frame = completed
|
|
226
|
+
? mixFrame(from, to, track.to)
|
|
227
|
+
: (this.painter?.read() ?? this.frame)
|
|
228
|
+
this.painter?.paint(this.frame)
|
|
229
|
+
if (this.active?.animation === animation) this.active = undefined
|
|
230
|
+
},
|
|
231
|
+
)
|
|
232
|
+
this.active = { animation, track, from, to }
|
|
233
|
+
try {
|
|
234
|
+
if (track.end > 0) this.painter.play(from, to, track)
|
|
235
|
+
else {
|
|
236
|
+
this.frame = to
|
|
237
|
+
this.painter.paint(to)
|
|
238
|
+
}
|
|
239
|
+
animation.start()
|
|
240
|
+
if (this.backgrounded && this.active) {
|
|
241
|
+
this.suspended = true
|
|
242
|
+
animation.pause()
|
|
243
|
+
}
|
|
244
|
+
} catch (e) {
|
|
245
|
+
animation.stop()
|
|
246
|
+
throw e
|
|
247
|
+
}
|
|
248
|
+
return animation
|
|
249
|
+
}
|
|
250
|
+
stop() {
|
|
251
|
+
this.active?.animation.stop()
|
|
252
|
+
this.suspended = false
|
|
253
|
+
}
|
|
254
|
+
dispose() {
|
|
255
|
+
if (this.disposed) return
|
|
256
|
+
this.stop()
|
|
257
|
+
this.unload()
|
|
258
|
+
this.disposed = true
|
|
259
|
+
this.offReduced()
|
|
260
|
+
this.view.off('loaded', this.layout)
|
|
261
|
+
this.view.off('layoutChanged', this.layout)
|
|
262
|
+
this.view.off('unloaded', this.unload)
|
|
263
|
+
Application.off(Application.suspendEvent, this.background)
|
|
264
|
+
Application.off(Application.resumeEvent, this.foreground)
|
|
265
|
+
owners.delete(this.view)
|
|
266
|
+
}
|
|
267
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { Color, type View } from '@nativescript/core'
|
|
2
|
+
import { getDriver } from '../driver/index.js'
|
|
3
|
+
import type { Track } from '../track.js'
|
|
4
|
+
import type { ShapeFactory } from './native.js'
|
|
5
|
+
import { mixFrame, type ShapeFrame } from './types.js'
|
|
6
|
+
|
|
7
|
+
export const iosShape: ShapeFactory = (view: View, style, initial) => {
|
|
8
|
+
const native = view.nativeViewProtected as UIView
|
|
9
|
+
const root = CALayer.new(),
|
|
10
|
+
layer = CAShapeLayer.new()
|
|
11
|
+
let marker = CALayer.new()
|
|
12
|
+
root.name = 'jolt:shape'
|
|
13
|
+
root.masksToBounds = true
|
|
14
|
+
layer.name = 'jolt:shape:path'
|
|
15
|
+
marker.name = 'jolt:shape:progress'
|
|
16
|
+
layer.fillColor = new Color(style.fill).ios.CGColor
|
|
17
|
+
layer.strokeColor = new Color(style.stroke).ios.CGColor
|
|
18
|
+
layer.lineWidth = style.width
|
|
19
|
+
layer.lineCap = style.cap
|
|
20
|
+
layer.lineJoin = style.join
|
|
21
|
+
layer.fillRule = style.rule === 'evenodd' ? kCAFillRuleEvenOdd : kCAFillRuleNonZero
|
|
22
|
+
layer.contentsScale = UIScreen.mainScreen.scale
|
|
23
|
+
root.addSublayer(layer)
|
|
24
|
+
root.addSublayer(marker)
|
|
25
|
+
native.layer.addSublayer(root)
|
|
26
|
+
let current = initial,
|
|
27
|
+
program:
|
|
28
|
+
| {
|
|
29
|
+
from: ShapeFrame
|
|
30
|
+
to: ShapeFrame
|
|
31
|
+
track: Track
|
|
32
|
+
start: number
|
|
33
|
+
offset: number
|
|
34
|
+
paused: boolean
|
|
35
|
+
}
|
|
36
|
+
| undefined
|
|
37
|
+
const transaction = (fn: () => void) => {
|
|
38
|
+
CATransaction.begin()
|
|
39
|
+
CATransaction.setDisableActions(true)
|
|
40
|
+
try {
|
|
41
|
+
fn()
|
|
42
|
+
} finally {
|
|
43
|
+
CATransaction.commit()
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const path = (frame: ShapeFrame) => {
|
|
47
|
+
const p = UIBezierPath.bezierPath(),
|
|
48
|
+
v = frame.path.points
|
|
49
|
+
let i = 0
|
|
50
|
+
for (const op of frame.path.commands) {
|
|
51
|
+
if (op === 'M') {
|
|
52
|
+
p.moveToPoint(CGPointMake(v[i]!, v[i + 1]!))
|
|
53
|
+
i += 2
|
|
54
|
+
}
|
|
55
|
+
if (op === 'L') {
|
|
56
|
+
p.addLineToPoint(CGPointMake(v[i]!, v[i + 1]!))
|
|
57
|
+
i += 2
|
|
58
|
+
}
|
|
59
|
+
if (op === 'C') {
|
|
60
|
+
p.addCurveToPointControlPoint1ControlPoint2(
|
|
61
|
+
CGPointMake(v[i + 4]!, v[i + 5]!),
|
|
62
|
+
CGPointMake(v[i]!, v[i + 1]!),
|
|
63
|
+
CGPointMake(v[i + 2]!, v[i + 3]!),
|
|
64
|
+
)
|
|
65
|
+
i += 6
|
|
66
|
+
}
|
|
67
|
+
if (op === 'Q') {
|
|
68
|
+
p.addQuadCurveToPointControlPoint(
|
|
69
|
+
CGPointMake(v[i + 2]!, v[i + 3]!),
|
|
70
|
+
CGPointMake(v[i]!, v[i + 1]!),
|
|
71
|
+
)
|
|
72
|
+
i += 4
|
|
73
|
+
}
|
|
74
|
+
if (op === 'Z') p.closePath()
|
|
75
|
+
}
|
|
76
|
+
return p.CGPath
|
|
77
|
+
}
|
|
78
|
+
const resize = () =>
|
|
79
|
+
transaction(() => {
|
|
80
|
+
const { width, height } = view.getActualSize(),
|
|
81
|
+
[x, y, w, h] = style.viewBox
|
|
82
|
+
root.frame = CGRectMake(0, 0, Math.max(0, width), Math.max(0, height))
|
|
83
|
+
layer.bounds = CGRectMake(x, y, w, h)
|
|
84
|
+
layer.position = CGPointMake(width / 2, height / 2)
|
|
85
|
+
const scale = Math.max(0, Math.min(width / w, height / h))
|
|
86
|
+
layer.transform = CATransform3DMakeScale(scale, scale, 1)
|
|
87
|
+
})
|
|
88
|
+
const paint = (frame: ShapeFrame) =>
|
|
89
|
+
transaction(() => {
|
|
90
|
+
program = undefined
|
|
91
|
+
current = frame
|
|
92
|
+
root.speed = 1
|
|
93
|
+
root.beginTime = 0
|
|
94
|
+
root.timeOffset = 0
|
|
95
|
+
layer.removeAllAnimations()
|
|
96
|
+
marker.removeAllAnimations()
|
|
97
|
+
layer.path = path(frame)
|
|
98
|
+
layer.strokeStart = frame.start
|
|
99
|
+
layer.strokeEnd = frame.end
|
|
100
|
+
})
|
|
101
|
+
resize()
|
|
102
|
+
paint(initial)
|
|
103
|
+
return {
|
|
104
|
+
paint,
|
|
105
|
+
resize,
|
|
106
|
+
read() {
|
|
107
|
+
if (!program) return current
|
|
108
|
+
const { from, to, track, paused, offset, start } = program
|
|
109
|
+
const presented = marker.presentationLayer()
|
|
110
|
+
const progress =
|
|
111
|
+
!paused && presented
|
|
112
|
+
? Number(presented.valueForKeyPath('transform.translation.x'))
|
|
113
|
+
: track.valueAt(offset + (paused ? 0 : getDriver().now() - start))
|
|
114
|
+
const frame = mixFrame(from, to, progress)
|
|
115
|
+
// Trim diagnostics read the actual shape layer, except before a pending pause transaction is drawn.
|
|
116
|
+
const shown = layer.presentationLayer() as CAShapeLayer | null
|
|
117
|
+
if (shown && !paused) {
|
|
118
|
+
frame.start = shown.strokeStart
|
|
119
|
+
frame.end = shown.strokeEnd
|
|
120
|
+
}
|
|
121
|
+
return frame
|
|
122
|
+
},
|
|
123
|
+
play(from, to, track) {
|
|
124
|
+
paint(mixFrame(from, to, track.to))
|
|
125
|
+
// A new marker cannot expose the previous program's cached presentation
|
|
126
|
+
// when several retargets happen before the next render transaction.
|
|
127
|
+
marker.removeFromSuperlayer()
|
|
128
|
+
marker = CALayer.new()
|
|
129
|
+
marker.name = 'jolt:shape:progress'
|
|
130
|
+
root.addSublayer(marker)
|
|
131
|
+
program = { from, to, track, paused: false, offset: 0, start: getDriver().now() }
|
|
132
|
+
transaction(() => {
|
|
133
|
+
root.beginTime = native.layer.convertTimeFromLayer(CACurrentMediaTime(), null)
|
|
134
|
+
const frames = track.values.map((t) => mixFrame(from, to, t))
|
|
135
|
+
const add = (target: CALayer, key: string, values: unknown[]) => {
|
|
136
|
+
const a = CAKeyframeAnimation.animationWithKeyPath(key)
|
|
137
|
+
a.values = NSArray.arrayWithArray(values)
|
|
138
|
+
a.keyTimes = NSArray.arrayWithArray([...track.times])
|
|
139
|
+
a.duration = track.duration / 1000
|
|
140
|
+
a.beginTime = Math.max(0.000001, track.delay / 1000)
|
|
141
|
+
a.fillMode = kCAFillModeBoth
|
|
142
|
+
a.removedOnCompletion = false
|
|
143
|
+
a.autoreverses = track.reverse
|
|
144
|
+
a.repeatCount =
|
|
145
|
+
track.repeat === Infinity
|
|
146
|
+
? Infinity
|
|
147
|
+
: track.reverse
|
|
148
|
+
? (track.repeat + 1) / 2
|
|
149
|
+
: track.repeat + 1
|
|
150
|
+
target.addAnimationForKey(a, 'jolt:shape:' + key)
|
|
151
|
+
}
|
|
152
|
+
marker.setValueForKeyPath(track.to, 'transform.translation.x')
|
|
153
|
+
add(layer, 'path', frames.map(path))
|
|
154
|
+
add(
|
|
155
|
+
layer,
|
|
156
|
+
'strokeStart',
|
|
157
|
+
frames.map((f) => f.start),
|
|
158
|
+
)
|
|
159
|
+
add(
|
|
160
|
+
layer,
|
|
161
|
+
'strokeEnd',
|
|
162
|
+
frames.map((f) => f.end),
|
|
163
|
+
)
|
|
164
|
+
add(marker, 'transform.translation.x', [...track.values])
|
|
165
|
+
})
|
|
166
|
+
},
|
|
167
|
+
control(time, paused) {
|
|
168
|
+
if (!program) return
|
|
169
|
+
program.offset = time
|
|
170
|
+
program.start = getDriver().now()
|
|
171
|
+
program.paused = paused
|
|
172
|
+
transaction(() => {
|
|
173
|
+
root.speed = paused ? 0 : 1
|
|
174
|
+
root.timeOffset = paused ? time / 1000 : 0
|
|
175
|
+
root.beginTime = paused
|
|
176
|
+
? 0
|
|
177
|
+
: native.layer.convertTimeFromLayer(CACurrentMediaTime(), null) - time / 1000
|
|
178
|
+
})
|
|
179
|
+
},
|
|
180
|
+
animations: () =>
|
|
181
|
+
(layer.animationKeys()?.count ?? 0) + (marker.animationKeys()?.count ?? 0),
|
|
182
|
+
bounds() {
|
|
183
|
+
const shown = (layer.presentationLayer() as CAShapeLayer | null) ?? layer
|
|
184
|
+
const b = CGPathGetBoundingBox(shown.path)
|
|
185
|
+
return [b.origin.x, b.origin.y, b.size.width, b.size.height]
|
|
186
|
+
},
|
|
187
|
+
dispose() {
|
|
188
|
+
program = undefined
|
|
189
|
+
layer.removeAllAnimations()
|
|
190
|
+
marker.removeAllAnimations()
|
|
191
|
+
root.removeFromSuperlayer()
|
|
192
|
+
},
|
|
193
|
+
}
|
|
194
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { isAndroid, type View } from '@nativescript/core'
|
|
2
|
+
import type { Track } from '../track.js'
|
|
3
|
+
import type { ShapeFrame, ShapeStyle } from './types.js'
|
|
4
|
+
import { iosShape } from './ios.js'
|
|
5
|
+
import { androidShape } from './android.js'
|
|
6
|
+
export interface ShapePainter {
|
|
7
|
+
paint(frame: ShapeFrame): void
|
|
8
|
+
read(): ShapeFrame
|
|
9
|
+
play(from: ShapeFrame, to: ShapeFrame, track: Track): void
|
|
10
|
+
control(time: number, paused: boolean): void
|
|
11
|
+
resize(): void
|
|
12
|
+
animations(): number
|
|
13
|
+
bounds(): number[]
|
|
14
|
+
dispose(): void
|
|
15
|
+
}
|
|
16
|
+
export type ShapeFactory = (
|
|
17
|
+
view: View,
|
|
18
|
+
style: ShapeStyle,
|
|
19
|
+
frame: ShapeFrame,
|
|
20
|
+
) => ShapePainter
|
|
21
|
+
let override: ShapeFactory | undefined
|
|
22
|
+
/** Internal injection for lifecycle tests. */
|
|
23
|
+
export function setShapeFactory(value: ShapeFactory | undefined) {
|
|
24
|
+
override = value
|
|
25
|
+
}
|
|
26
|
+
export const createShape: ShapeFactory = (view, style, frame) =>
|
|
27
|
+
(override ?? (isAndroid ? androidShape : iosShape))(view, style, frame)
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Scanner, arc, type PathPoint } from '../svg-path.js'
|
|
2
|
+
|
|
3
|
+
/** Absolute M/L/C/Q/Z commands, shared by both native renderers. */
|
|
4
|
+
export interface ShapePath {
|
|
5
|
+
commands: string
|
|
6
|
+
points: number[]
|
|
7
|
+
contours: number
|
|
8
|
+
}
|
|
9
|
+
export function shapePath(d: string): ShapePath {
|
|
10
|
+
if (typeof d !== 'string' || !d.trim())
|
|
11
|
+
throw new TypeError('Shape d must be a nonempty SVG path.')
|
|
12
|
+
if (d.length > 20000) throw new RangeError('Shape path exceeds 20000 characters.')
|
|
13
|
+
const scanner = new Scanner(d),
|
|
14
|
+
result: ShapePath = { commands: '', points: [], contours: 0 }
|
|
15
|
+
let current = { x: 0, y: 0 },
|
|
16
|
+
first: PathPoint | undefined,
|
|
17
|
+
control = current
|
|
18
|
+
let command = '',
|
|
19
|
+
previous = ''
|
|
20
|
+
const add = (op: string, ...points: PathPoint[]) => {
|
|
21
|
+
if (result.commands.length >= 256)
|
|
22
|
+
throw new RangeError('Shapes support at most 256 normalized commands.')
|
|
23
|
+
result.commands += op
|
|
24
|
+
for (const p of points) {
|
|
25
|
+
if (![p.x, p.y].every((n) => Number.isFinite(n) && Math.abs(n) <= 1000000))
|
|
26
|
+
throw new RangeError('Shape coordinates must stay within ±1000000.')
|
|
27
|
+
result.points.push(p.x, p.y)
|
|
28
|
+
}
|
|
29
|
+
if (points.length) current = points.at(-1)!
|
|
30
|
+
}
|
|
31
|
+
while (scanner.peek() !== undefined) {
|
|
32
|
+
if (/[a-z]/i.test(scanner.peek()!)) command = scanner.command()
|
|
33
|
+
else if (!command) scanner.error()
|
|
34
|
+
const upper = command.toUpperCase(),
|
|
35
|
+
relative = command !== upper,
|
|
36
|
+
origin = current
|
|
37
|
+
const point = () => ({
|
|
38
|
+
x: scanner.number() + (relative ? origin.x : 0),
|
|
39
|
+
y: scanner.number() + (relative ? origin.y : 0),
|
|
40
|
+
})
|
|
41
|
+
if (!first && upper !== 'M')
|
|
42
|
+
throw new SyntaxError('Shape path must start with M or m.')
|
|
43
|
+
if (upper === 'M') {
|
|
44
|
+
first = point()
|
|
45
|
+
add('M', first)
|
|
46
|
+
result.contours++
|
|
47
|
+
command = relative ? 'l' : 'L'
|
|
48
|
+
} else if (upper === 'L') add('L', point())
|
|
49
|
+
else if (upper === 'H' || upper === 'V') {
|
|
50
|
+
const n = scanner.number()
|
|
51
|
+
add(
|
|
52
|
+
'L',
|
|
53
|
+
upper === 'H'
|
|
54
|
+
? { x: n + (relative ? origin.x : 0), y: current.y }
|
|
55
|
+
: { x: current.x, y: n + (relative ? origin.y : 0) },
|
|
56
|
+
)
|
|
57
|
+
} else if (upper === 'C' || upper === 'S') {
|
|
58
|
+
const c1 =
|
|
59
|
+
upper === 'C'
|
|
60
|
+
? point()
|
|
61
|
+
: /[CS]/.test(previous)
|
|
62
|
+
? { x: 2 * current.x - control.x, y: 2 * current.y - control.y }
|
|
63
|
+
: current
|
|
64
|
+
const c2 = point(),
|
|
65
|
+
end = point()
|
|
66
|
+
add('C', c1, c2, end)
|
|
67
|
+
control = c2
|
|
68
|
+
} else if (upper === 'Q' || upper === 'T') {
|
|
69
|
+
const c =
|
|
70
|
+
upper === 'Q'
|
|
71
|
+
? point()
|
|
72
|
+
: /[QT]/.test(previous)
|
|
73
|
+
? { x: 2 * current.x - control.x, y: 2 * current.y - control.y }
|
|
74
|
+
: current
|
|
75
|
+
add('Q', c, point())
|
|
76
|
+
control = c
|
|
77
|
+
} else if (upper === 'A') {
|
|
78
|
+
const rx = scanner.number(),
|
|
79
|
+
ry = scanner.number(),
|
|
80
|
+
rotation = scanner.number(),
|
|
81
|
+
large = scanner.number(true),
|
|
82
|
+
sweep = scanner.number(true),
|
|
83
|
+
end = point()
|
|
84
|
+
const segment = arc(current, end, rx, ry, rotation, !!large, !!sweep)
|
|
85
|
+
if (!segment.angle) add('L', end)
|
|
86
|
+
else {
|
|
87
|
+
const count = Math.ceil(Math.abs(segment.angle) / (Math.PI / 2)),
|
|
88
|
+
factor = ((4 / 3) * Math.tan(segment.angle / count / 4)) / segment.angle
|
|
89
|
+
for (let i = 0; i < count; i++) {
|
|
90
|
+
const a = segment.point(i / count),
|
|
91
|
+
b = segment.point((i + 1) / count),
|
|
92
|
+
da = segment.tangent(i / count),
|
|
93
|
+
db = segment.tangent((i + 1) / count)
|
|
94
|
+
add(
|
|
95
|
+
'C',
|
|
96
|
+
{ x: a.x + da.x * factor, y: a.y + da.y * factor },
|
|
97
|
+
{ x: b.x - db.x * factor, y: b.y - db.y * factor },
|
|
98
|
+
b,
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
} else if (upper === 'Z') {
|
|
103
|
+
add('Z')
|
|
104
|
+
current = first!
|
|
105
|
+
command = ''
|
|
106
|
+
} else scanner.error()
|
|
107
|
+
previous = upper
|
|
108
|
+
}
|
|
109
|
+
if (!/[LCQ]/.test(result.commands))
|
|
110
|
+
throw new SyntaxError('Shape needs at least one drawing segment.')
|
|
111
|
+
return result
|
|
112
|
+
}
|
|
113
|
+
export function compatible(a: ShapePath, b: ShapePath) {
|
|
114
|
+
if (a.commands !== b.commands)
|
|
115
|
+
throw new TypeError(
|
|
116
|
+
'Morph paths need matching normalized commands and subpaths. Use set() for a topology change.',
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
export function pathString(path: ShapePath) {
|
|
120
|
+
let i = 0
|
|
121
|
+
return [...path.commands]
|
|
122
|
+
.map((op) => {
|
|
123
|
+
const count = op === 'C' ? 6 : op === 'Q' ? 4 : op === 'Z' ? 0 : 2
|
|
124
|
+
return op + path.points.slice(i, (i += count)).join(' ')
|
|
125
|
+
})
|
|
126
|
+
.join(' ')
|
|
127
|
+
}
|