react-native-reanimated 3.0.0-rc.9 → 3.0.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/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +30 -12
- package/Common/cpp/AnimatedSensor/AnimatedSensorModule.h +2 -0
- package/Common/cpp/Fabric/FabricUtils.cpp +3 -107
- package/Common/cpp/Fabric/FabricUtils.h +3 -24
- package/Common/cpp/Fabric/ReanimatedUIManagerBinding.cpp +54 -37
- package/Common/cpp/LayoutAnimations/LayoutAnimationType.h +8 -0
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +81 -26
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +20 -3
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +105 -109
- package/Common/cpp/NativeModules/NativeReanimatedModule.h +19 -12
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +15 -7
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +6 -2
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +20 -1
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +9 -0
- package/Common/cpp/ReanimatedRuntime/ReanimatedRuntime.cpp +5 -1
- package/Common/cpp/Registries/EventHandlerRegistry.cpp +8 -34
- package/Common/cpp/Registries/EventHandlerRegistry.h +7 -13
- package/Common/cpp/SharedItems/Shareables.cpp +9 -63
- package/Common/cpp/SharedItems/Shareables.h +77 -72
- package/Common/cpp/Tools/CollectionUtils.h +14 -0
- package/Common/cpp/Tools/JsiUtils.cpp +26 -0
- package/Common/cpp/Tools/JsiUtils.h +176 -0
- package/Common/cpp/Tools/PlatformDepMethodsHolder.h +5 -5
- package/Common/cpp/Tools/ReanimatedVersion.cpp +17 -0
- package/Common/cpp/Tools/ReanimatedVersion.h +11 -0
- package/Common/cpp/Tools/RuntimeDecorator.cpp +49 -230
- package/Common/cpp/Tools/RuntimeDecorator.h +0 -2
- package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -2
- package/Common/cpp/Tools/WorkletEventHandler.h +14 -6
- package/README.md +1 -1
- package/RNReanimated.podspec +2 -1
- package/android/CMakeLists.txt +188 -181
- package/android/build.gradle +362 -311
- package/android/proguard-rules.pro +2 -0
- package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +63 -295
- package/android/src/main/cpp/LayoutAnimations.cpp +35 -5
- package/android/src/main/cpp/LayoutAnimations.h +23 -6
- package/android/src/main/cpp/NativeProxy.cpp +143 -98
- package/android/src/main/cpp/NativeProxy.h +22 -28
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +5 -4
- package/android/src/main/java/com/swmansion/reanimated/Utils.java +7 -1
- package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +10 -3
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +218 -35
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +43 -17
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +6 -2
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedElement.java +19 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +610 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +93 -23
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/AnimationFrameCallback.java +19 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/EventHandler.java +35 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/KeyboardEventDataUpdater.java +16 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +206 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/SensorSetter.java +17 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +9 -3
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +3 -4
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -7
- package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +90 -307
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +16 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +63 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +271 -0
- package/android/src/reactNativeVersionPatch/nativeHierarchyManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +76 -20
- package/ios/LayoutReanimation/REAAnimationsManager.h +28 -4
- package/ios/LayoutReanimation/REAAnimationsManager.m +216 -61
- package/ios/LayoutReanimation/REAFrame.h +10 -0
- package/ios/LayoutReanimation/REAFrame.m +15 -0
- package/ios/LayoutReanimation/REAScreensHelper.h +19 -0
- package/ios/LayoutReanimation/REAScreensHelper.m +106 -0
- package/ios/LayoutReanimation/REASharedElement.h +15 -0
- package/ios/LayoutReanimation/REASharedElement.m +16 -0
- package/ios/LayoutReanimation/REASharedTransitionManager.h +17 -0
- package/ios/LayoutReanimation/REASharedTransitionManager.m +632 -0
- package/ios/LayoutReanimation/REASnapshot.h +1 -0
- package/ios/LayoutReanimation/REASnapshot.m +96 -11
- package/ios/LayoutReanimation/REAUIManager.mm +64 -17
- package/ios/REAModule.mm +2 -7
- package/ios/REANodesManager.mm +1 -21
- package/ios/keyboardObserver/REAKeyboardEventObserver.m +72 -36
- package/ios/native/NativeProxy.mm +75 -114
- package/ios/native/REAInitializer.mm +2 -7
- package/ios/native/REAJSIUtils.h +60 -2
- package/ios/sensor/ReanimatedSensor.h +6 -2
- package/ios/sensor/ReanimatedSensor.m +43 -7
- package/ios/sensor/ReanimatedSensorContainer.h +4 -1
- package/ios/sensor/ReanimatedSensorContainer.m +8 -2
- package/lib/commonjs/createAnimatedComponent.js +244 -28
- package/lib/commonjs/createAnimatedComponent.js.map +1 -1
- package/lib/commonjs/reanimated2/Colors.js +43 -22
- package/lib/commonjs/reanimated2/Colors.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +16 -33
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/util.js +17 -15
- package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
- package/lib/commonjs/reanimated2/commonTypes.js +33 -1
- package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/core.js +33 -14
- package/lib/commonjs/reanimated2/core.js.map +1 -1
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/index.js +0 -6
- package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +5 -2
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +13 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +91 -15
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +43 -40
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js +13 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +2 -2
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/utils.js +18 -65
- package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/index.js +13 -0
- package/lib/commonjs/reanimated2/index.js.map +1 -1
- package/lib/commonjs/reanimated2/initializers.js +71 -32
- package/lib/commonjs/reanimated2/initializers.js.map +1 -1
- package/lib/commonjs/reanimated2/interpolateColor.js +96 -19
- package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +103 -13
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +22 -0
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js +2 -0
- package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js.map +1 -0
- package/lib/commonjs/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/global.js +0 -2
- package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js +0 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +11 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +8 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +22 -9
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -14
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -14
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -15
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/index.js +13 -0
- package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +94 -0
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
- package/lib/commonjs/reanimated2/mappers.js +18 -6
- package/lib/commonjs/reanimated2/mappers.js.map +1 -1
- package/lib/commonjs/reanimated2/mock.js +20 -1
- package/lib/commonjs/reanimated2/mock.js.map +1 -1
- package/lib/commonjs/reanimated2/mutables.js +4 -2
- package/lib/commonjs/reanimated2/mutables.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +42 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +1 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +15 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
- package/lib/commonjs/reanimated2/pluginUtils.js +11 -0
- package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -0
- package/lib/commonjs/reanimated2/shareables.js +36 -15
- package/lib/commonjs/reanimated2/shareables.js.map +1 -1
- package/lib/commonjs/reanimated2/threads.js +114 -7
- package/lib/commonjs/reanimated2/threads.js.map +1 -1
- package/lib/commonjs/reanimated2/utils.js +7 -0
- package/lib/commonjs/reanimated2/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/valueSetter.js +1 -3
- package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
- package/lib/module/createAnimatedComponent.js +241 -29
- package/lib/module/createAnimatedComponent.js.map +1 -1
- package/lib/module/reanimated2/Colors.js +35 -19
- package/lib/module/reanimated2/Colors.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +16 -32
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +17 -16
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +29 -0
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/core.js +32 -7
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/module/reanimated2/globals.d.js.map +1 -1
- package/lib/module/reanimated2/hook/index.js +1 -1
- package/lib/module/reanimated2/hook/index.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +5 -2
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js +12 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js +90 -13
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +46 -43
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js +12 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js +2 -2
- package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js +17 -60
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/index.js +1 -0
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/initializers.js +72 -33
- package/lib/module/reanimated2/initializers.js.map +1 -1
- package/lib/module/reanimated2/interpolateColor.js +96 -19
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.js +1 -1
- package/lib/module/reanimated2/jestUtils.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js +103 -13
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/Mapper.js +21 -0
- package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/WebSensor.js +2 -0
- package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -0
- package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/global.js +0 -2
- package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js +0 -1
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +9 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js +1 -0
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js +20 -8
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -21
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -12
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -13
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -21
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/index.js +1 -0
- package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +82 -0
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
- package/lib/module/reanimated2/mappers.js +16 -6
- package/lib/module/reanimated2/mappers.js.map +1 -1
- package/lib/module/reanimated2/mock.js +20 -1
- package/lib/module/reanimated2/mock.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +4 -2
- package/lib/module/reanimated2/mutables.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/checkVersion.js +35 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.js.map +1 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js +8 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
- package/lib/module/reanimated2/pluginUtils.js +4 -0
- package/lib/module/reanimated2/pluginUtils.js.map +1 -0
- package/lib/module/reanimated2/shareables.js +36 -12
- package/lib/module/reanimated2/shareables.js.map +1 -1
- package/lib/module/reanimated2/threads.js +105 -7
- package/lib/module/reanimated2/threads.js.map +1 -1
- package/lib/module/reanimated2/utils.js +5 -0
- package/lib/module/reanimated2/utils.js.map +1 -1
- package/lib/module/reanimated2/valueSetter.js +1 -2
- package/lib/module/reanimated2/valueSetter.js.map +1 -1
- package/mock.js +1 -211
- package/package.json +10 -10
- package/{plugin.js → plugin/index.js} +128 -249
- package/react-native-reanimated.d.ts +55 -417
- package/scripts/reanimated_utils.rb +15 -2
- package/src/createAnimatedComponent.tsx +247 -28
- package/src/reanimated2/Colors.ts +38 -11
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +52 -39
- package/src/reanimated2/animation/styleAnimation.ts +8 -1
- package/src/reanimated2/animation/util.ts +29 -16
- package/src/reanimated2/commonTypes.ts +28 -1
- package/src/reanimated2/core.ts +42 -9
- package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +2 -2
- package/src/reanimated2/globals.d.ts +12 -15
- package/src/reanimated2/hook/index.ts +1 -1
- package/src/reanimated2/hook/useAnimatedKeyboard.ts +10 -4
- package/src/reanimated2/hook/useAnimatedReaction.ts +12 -5
- package/src/reanimated2/hook/useAnimatedRef.ts +1 -4
- package/src/reanimated2/hook/useAnimatedSensor.ts +90 -11
- package/src/reanimated2/hook/useAnimatedStyle.ts +44 -36
- package/src/reanimated2/hook/useDerivedValue.ts +8 -1
- package/src/reanimated2/hook/useScrollViewOffset.ts +2 -2
- package/src/reanimated2/hook/utils.ts +15 -61
- package/src/reanimated2/index.ts +1 -0
- package/src/reanimated2/initializers.ts +76 -35
- package/src/reanimated2/interpolateColor.ts +104 -20
- package/src/reanimated2/jestUtils.ts +1 -1
- package/src/reanimated2/js-reanimated/JSReanimated.ts +98 -15
- package/src/reanimated2/js-reanimated/Mapper.ts +32 -0
- package/src/reanimated2/js-reanimated/WebSensor.ts +34 -0
- package/src/reanimated2/js-reanimated/commonTypes.ts +0 -1
- package/src/reanimated2/js-reanimated/global.ts +0 -1
- package/src/reanimated2/js-reanimated/index.ts +0 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +13 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/animationsManager.ts +20 -9
- package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +16 -19
- package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +14 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +21 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +36 -19
- package/src/reanimated2/layoutReanimation/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/sharedTransitions/index.ts +87 -0
- package/src/reanimated2/mappers.ts +17 -6
- package/src/reanimated2/mock.ts +25 -2
- package/src/reanimated2/mutables.ts +2 -0
- package/src/reanimated2/platform-specific/checkVersion.ts +39 -0
- package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
- package/src/reanimated2/pluginUtils.ts +8 -0
- package/src/reanimated2/shareables.ts +45 -16
- package/src/reanimated2/threads.ts +103 -4
- package/src/reanimated2/utils.ts +6 -0
- package/src/reanimated2/valueSetter.ts +1 -2
- package/lib/commonjs/reanimated2/time.js +0 -55
- package/lib/commonjs/reanimated2/time.js.map +0 -1
- package/lib/module/reanimated2/time.js +0 -37
- package/lib/module/reanimated2/time.js.map +0 -1
- package/src/reanimated2/time.ts +0 -30
- /package/android/src/{main/java → reactNativeVersionPatch/ReanimatedUIManager/70}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -0
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { SharedValue } from './commonTypes';
|
|
2
|
+
import { isJest } from './PlatformChecker';
|
|
2
3
|
import { runOnUI } from './threads';
|
|
3
4
|
|
|
5
|
+
const IS_JEST = isJest();
|
|
6
|
+
|
|
4
7
|
export type Mapper = {
|
|
5
8
|
id: number;
|
|
6
9
|
dirty: boolean;
|
|
@@ -14,7 +17,7 @@ export function createMapperRegistry() {
|
|
|
14
17
|
const mappers = new Map();
|
|
15
18
|
let sortedMappers: Mapper[] = [];
|
|
16
19
|
|
|
17
|
-
let
|
|
20
|
+
let runRequested = false;
|
|
18
21
|
|
|
19
22
|
function updateMappersOrder() {
|
|
20
23
|
// sort mappers topologically
|
|
@@ -74,8 +77,8 @@ export function createMapperRegistry() {
|
|
|
74
77
|
sortedMappers = newOrder;
|
|
75
78
|
}
|
|
76
79
|
|
|
77
|
-
function
|
|
78
|
-
|
|
80
|
+
function mapperRun() {
|
|
81
|
+
runRequested = false;
|
|
79
82
|
if (mappers.size !== sortedMappers.length) {
|
|
80
83
|
updateMappersOrder();
|
|
81
84
|
}
|
|
@@ -88,9 +91,17 @@ export function createMapperRegistry() {
|
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
function maybeRequestUpdates() {
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
if (IS_JEST) {
|
|
95
|
+
// On Jest environment we avoid using setImmediate as that'd require test
|
|
96
|
+
// to advance the clock manually. This on other hand would require tests
|
|
97
|
+
// to know how many times mappers need to run. As we don't want tests to
|
|
98
|
+
// make any assumptions on that number it is easier to execute mappers
|
|
99
|
+
// immediately for testing purposes and only expect test to advance timers
|
|
100
|
+
// if they want to make any assertions on the effects of animations being run.
|
|
101
|
+
mapperRun();
|
|
102
|
+
} else if (!runRequested) {
|
|
103
|
+
setImmediate(mapperRun);
|
|
104
|
+
runRequested = true;
|
|
94
105
|
}
|
|
95
106
|
}
|
|
96
107
|
|
package/src/reanimated2/mock.ts
CHANGED
|
@@ -16,7 +16,19 @@ class BaseAnimationMock {
|
|
|
16
16
|
return this;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
springify(_: number) {
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
damping(_: number) {
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
stiffness(_: number) {
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
withCallback(_: (finished: boolean) => void) {
|
|
20
32
|
return this;
|
|
21
33
|
}
|
|
22
34
|
|
|
@@ -27,6 +39,10 @@ class BaseAnimationMock {
|
|
|
27
39
|
withInitialValues() {
|
|
28
40
|
return this;
|
|
29
41
|
}
|
|
42
|
+
|
|
43
|
+
build() {
|
|
44
|
+
return () => ({ initialValues: {}, animations: {} });
|
|
45
|
+
}
|
|
30
46
|
}
|
|
31
47
|
|
|
32
48
|
const ReanimatedV2 = {
|
|
@@ -102,7 +118,7 @@ const ReanimatedV2 = {
|
|
|
102
118
|
'FadeInRight',
|
|
103
119
|
'FadeInLeft',
|
|
104
120
|
'FadeInUp',
|
|
105
|
-
'
|
|
121
|
+
'FadeInDown',
|
|
106
122
|
'FadeOut',
|
|
107
123
|
'FadeOutRight',
|
|
108
124
|
'FadeOutLeft',
|
|
@@ -174,6 +190,13 @@ const ReanimatedV2 = {
|
|
|
174
190
|
'RollInRight',
|
|
175
191
|
'RollOutLeft',
|
|
176
192
|
'RollOutRight',
|
|
193
|
+
|
|
194
|
+
'Layout',
|
|
195
|
+
'CurvedTransition',
|
|
196
|
+
'JumpingTransition',
|
|
197
|
+
'SequencedTransition',
|
|
198
|
+
'FadingTransition',
|
|
199
|
+
'EntryExitTransition',
|
|
177
200
|
].forEach((k) =>
|
|
178
201
|
Object.assign(ReanimatedV2, {
|
|
179
202
|
[k]: new BaseAnimationMock(),
|
|
@@ -53,6 +53,7 @@ export function makeUIMutable<T>(
|
|
|
53
53
|
listeners.delete(id);
|
|
54
54
|
},
|
|
55
55
|
_animation: null,
|
|
56
|
+
_isReanimatedSharedValue: true,
|
|
56
57
|
};
|
|
57
58
|
return self;
|
|
58
59
|
}
|
|
@@ -134,6 +135,7 @@ export function makeMutable<T>(
|
|
|
134
135
|
}
|
|
135
136
|
listeners!.delete(id);
|
|
136
137
|
},
|
|
138
|
+
_isReanimatedSharedValue: true,
|
|
137
139
|
};
|
|
138
140
|
registerShareableMapping(mutable, handle);
|
|
139
141
|
return mutable;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We hardcode the version of Reanimated here in order to compare it
|
|
3
|
+
* with the version used to build the native part of the library in runtime.
|
|
4
|
+
* Remember to keep this in sync with the version declared in `package.json`
|
|
5
|
+
*/
|
|
6
|
+
const jsVersion = '3.0.1';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Checks that native and js versions of reanimated match.
|
|
10
|
+
*/
|
|
11
|
+
export function checkVersion(): void {
|
|
12
|
+
const cppVersion = global._REANIMATED_VERSION_CPP;
|
|
13
|
+
if (cppVersion === undefined) {
|
|
14
|
+
console.error(
|
|
15
|
+
`[Reanimated] Couldn't determine the version of the native part of Reanimated. Did you forget to re-build the app after upgrading react-native-reanimated? If you use Expo Go, you must use the exact version which is bundled into Expo SDK.`
|
|
16
|
+
);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const ok = (() => {
|
|
20
|
+
if (
|
|
21
|
+
jsVersion.match(/^\d+\.\d+\.\d+$/) &&
|
|
22
|
+
cppVersion.match(/^\d+\.\d+\.\d+$/)
|
|
23
|
+
) {
|
|
24
|
+
// x.y.z, compare only major and minor, skip patch
|
|
25
|
+
const [jsMajor, jsMinor] = jsVersion.split('.');
|
|
26
|
+
const [cppMajor, cppMinor] = cppVersion.split('.');
|
|
27
|
+
return jsMajor === cppMajor && jsMinor === cppMinor;
|
|
28
|
+
} else {
|
|
29
|
+
// alpha, beta or rc, compare everything
|
|
30
|
+
return jsVersion === cppVersion;
|
|
31
|
+
}
|
|
32
|
+
})();
|
|
33
|
+
if (!ok) {
|
|
34
|
+
console.error(
|
|
35
|
+
`[Reanimated] Mismatch between JavaScript part and native part of Reanimated (${jsVersion} vs. ${cppVersion}). Did you forget to re-build the app after upgrading react-native-reanimated? If you use Expo Go, you must downgrade to ${cppVersion} which is bundled into Expo SDK.`
|
|
36
|
+
);
|
|
37
|
+
// TODO: detect Expo managed workflow
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function getUseOfValueInStyleWarning() {
|
|
2
|
+
return (
|
|
3
|
+
"It looks like you might be using shared value's .value inside reanimated inline style. " +
|
|
4
|
+
'If you want a component to update when shared value changes you should use the shared value' +
|
|
5
|
+
' directly instead of its current state represented by `.value`. See documentation here: ' +
|
|
6
|
+
'https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/animations#animations-in-inline-styles'
|
|
7
|
+
);
|
|
8
|
+
}
|
|
@@ -17,6 +17,16 @@ const _shareableCache = new WeakMap<
|
|
|
17
17
|
// this is used to allow for a converted shareable to be passed to makeShareableClone
|
|
18
18
|
const _shareableFlag = Symbol('shareable flag');
|
|
19
19
|
|
|
20
|
+
const MAGIC_KEY = 'REANIMATED_MAGIC_KEY';
|
|
21
|
+
|
|
22
|
+
function isHostObject(value: any): boolean {
|
|
23
|
+
// We could use JSI to determine whether an object is a host object, however
|
|
24
|
+
// the below workaround works well and is way faster than an additional JSI call.
|
|
25
|
+
// We use the fact that host objects have broken implementation of `hasOwnProperty`
|
|
26
|
+
// and hence return true for all `in` checks regardless of the key we ask for.
|
|
27
|
+
return MAGIC_KEY in value;
|
|
28
|
+
}
|
|
29
|
+
|
|
20
30
|
export function registerShareableMapping(
|
|
21
31
|
shareable: any,
|
|
22
32
|
shareableRef?: ShareableRef<any>
|
|
@@ -27,14 +37,10 @@ export function registerShareableMapping(
|
|
|
27
37
|
_shareableCache.set(shareable, shareableRef || _shareableFlag);
|
|
28
38
|
}
|
|
29
39
|
|
|
30
|
-
export function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return shadowNodeWrapper;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function makeShareableCloneRecursive<T>(value: any): ShareableRef<T> {
|
|
40
|
+
export function makeShareableCloneRecursive<T>(
|
|
41
|
+
value: any,
|
|
42
|
+
shouldPersistRemote = false
|
|
43
|
+
): ShareableRef<T> {
|
|
38
44
|
if (USE_STUB_IMPLEMENTATION) {
|
|
39
45
|
return value;
|
|
40
46
|
}
|
|
@@ -53,14 +59,34 @@ export function makeShareableCloneRecursive<T>(value: any): ShareableRef<T> {
|
|
|
53
59
|
} else if (type === 'function' && value.__workletHash === undefined) {
|
|
54
60
|
// this is a remote function
|
|
55
61
|
toAdapt = value;
|
|
62
|
+
} else if (isHostObject(value)) {
|
|
63
|
+
// for host objects we pass the reference to the object as shareable and
|
|
64
|
+
// then recreate new host object wrapping the same instance on the UI thread.
|
|
65
|
+
// there is no point of iterating over keys as we do for regular objects.
|
|
66
|
+
toAdapt = value;
|
|
56
67
|
} else {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
68
|
+
toAdapt = {};
|
|
69
|
+
if (value.__workletHash !== undefined) {
|
|
70
|
+
// we are converting a worklet
|
|
71
|
+
if (__DEV__) {
|
|
72
|
+
registerWorkletStackDetails(
|
|
73
|
+
value.__workletHash,
|
|
74
|
+
value.__stackDetails
|
|
75
|
+
);
|
|
76
|
+
delete value.__stackDetails;
|
|
77
|
+
}
|
|
78
|
+
// to save on transferring static __initData field of worklet structure
|
|
79
|
+
// we request shareable value to persist its UI counterpart. This means
|
|
80
|
+
// that the __initData field that contains long strings represeting the
|
|
81
|
+
// worklet code, source map, and location, will always be
|
|
82
|
+
// serialized/deserialized once.
|
|
83
|
+
toAdapt.__initData = makeShareableCloneRecursive(
|
|
84
|
+
value.__initData,
|
|
85
|
+
true
|
|
61
86
|
);
|
|
87
|
+
delete value.__initData;
|
|
62
88
|
}
|
|
63
|
-
|
|
89
|
+
|
|
64
90
|
for (const [key, element] of Object.entries(value)) {
|
|
65
91
|
toAdapt[key] = makeShareableCloneRecursive(element);
|
|
66
92
|
}
|
|
@@ -71,16 +97,19 @@ export function makeShareableCloneRecursive<T>(value: any): ShareableRef<T> {
|
|
|
71
97
|
// shareable. Meaning that they may be doing a faulty assumption in their
|
|
72
98
|
// code expecting that the updates are going to automatically populate to
|
|
73
99
|
// the object sent to the UI thread. If the user really wants some objects
|
|
74
|
-
// to be mutable they should use
|
|
100
|
+
// to be mutable they should use shared values instead.
|
|
75
101
|
Object.freeze(value);
|
|
76
102
|
}
|
|
77
|
-
const adopted = NativeReanimatedModule.makeShareableClone(
|
|
103
|
+
const adopted = NativeReanimatedModule.makeShareableClone(
|
|
104
|
+
toAdapt,
|
|
105
|
+
shouldPersistRemote
|
|
106
|
+
);
|
|
78
107
|
_shareableCache.set(value, adopted);
|
|
79
108
|
_shareableCache.set(adopted, _shareableFlag);
|
|
80
109
|
return adopted;
|
|
81
110
|
}
|
|
82
111
|
}
|
|
83
|
-
return NativeReanimatedModule.makeShareableClone(value);
|
|
112
|
+
return NativeReanimatedModule.makeShareableClone(value, shouldPersistRemote);
|
|
84
113
|
}
|
|
85
114
|
|
|
86
115
|
export function makeShareableCloneOnUIRecursive<T>(value: T): ShareableRef<T> {
|
|
@@ -1,28 +1,127 @@
|
|
|
1
1
|
import NativeReanimatedModule from './NativeReanimated';
|
|
2
|
+
import { isJest, shouldBeUseWeb } from './PlatformChecker';
|
|
2
3
|
import { ComplexWorkletFunction } from './commonTypes';
|
|
3
4
|
import {
|
|
4
5
|
makeShareableCloneOnUIRecursive,
|
|
5
6
|
makeShareableCloneRecursive,
|
|
6
7
|
} from './shareables';
|
|
7
8
|
|
|
9
|
+
const IS_JEST = isJest();
|
|
10
|
+
const IS_WEB = shouldBeUseWeb();
|
|
11
|
+
|
|
12
|
+
let _runOnUIQueue: Array<[ComplexWorkletFunction<any[], any>, any[]]> = [];
|
|
13
|
+
|
|
14
|
+
export function setupSetImmediate() {
|
|
15
|
+
'worklet';
|
|
16
|
+
|
|
17
|
+
let immediateCallbacks: Array<() => void> = [];
|
|
18
|
+
|
|
19
|
+
// @ts-ignore – typescript expects this to conform to NodeJS definition and expects the return value to be NodeJS.Immediate which is an object and not a number
|
|
20
|
+
global.setImmediate = (callback: () => void): number => {
|
|
21
|
+
immediateCallbacks.push(callback);
|
|
22
|
+
return -1;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
global.__flushImmediates = () => {
|
|
26
|
+
for (let index = 0; index < immediateCallbacks.length; index += 1) {
|
|
27
|
+
// we use classic 'for' loop because the size of the currentTasks array may change while executing some of the callbacks due to setImmediate calls
|
|
28
|
+
immediateCallbacks[index]();
|
|
29
|
+
}
|
|
30
|
+
immediateCallbacks = [];
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function flushImmediatesOnUIThread() {
|
|
35
|
+
'worklet';
|
|
36
|
+
global.__flushImmediates();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const flushImmediates = shouldBeUseWeb()
|
|
40
|
+
? () => {
|
|
41
|
+
// on web flushing is a noop as immediates are handled by the browser
|
|
42
|
+
}
|
|
43
|
+
: flushImmediatesOnUIThread;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Schedule a worklet to execute on the UI runtime. This method does not schedule the work immediately but instead
|
|
47
|
+
* waits for other worklets to be scheduled within the same JS loop. It uses setImmediate to schedule all the worklets
|
|
48
|
+
* at once making sure they will run within the same frame boundaries on the UI thread.
|
|
49
|
+
*/
|
|
8
50
|
export function runOnUI<A extends any[], R>(
|
|
9
51
|
worklet: ComplexWorkletFunction<A, R>
|
|
10
52
|
): (...args: A) => void {
|
|
11
|
-
if (__DEV__) {
|
|
12
|
-
|
|
13
|
-
|
|
53
|
+
if (__DEV__ && !IS_WEB && worklet.__workletHash === undefined) {
|
|
54
|
+
throw new Error('runOnUI() can only be used on worklets');
|
|
55
|
+
}
|
|
56
|
+
return (...args) => {
|
|
57
|
+
if (IS_JEST) {
|
|
58
|
+
// Mocking time in Jest is tricky as both requestAnimationFrame and setImmediate
|
|
59
|
+
// callbacks run on the same queue and can be interleaved. There is no way
|
|
60
|
+
// to flush particular queue in Jest and the only control over mocked timers
|
|
61
|
+
// is by using jest.advanceTimersByTime() method which advances all types
|
|
62
|
+
// of timers including immediate and animation callbacks. Ideally we'd like
|
|
63
|
+
// to have some way here to schedule work along with React updates, but
|
|
64
|
+
// that's not possible, and hence in Jest environment instead of using scheduling
|
|
65
|
+
// mechanism we just schedule the work ommiting the queue. This is ok for the
|
|
66
|
+
// uses that we currently have but may not be ok for future tests that we write.
|
|
67
|
+
NativeReanimatedModule.scheduleOnUI(
|
|
68
|
+
makeShareableCloneRecursive(() => {
|
|
69
|
+
'worklet';
|
|
70
|
+
worklet(...args);
|
|
71
|
+
})
|
|
72
|
+
);
|
|
73
|
+
return;
|
|
14
74
|
}
|
|
75
|
+
_runOnUIQueue.push([worklet, args]);
|
|
76
|
+
if (_runOnUIQueue.length === 1) {
|
|
77
|
+
setImmediate(() => {
|
|
78
|
+
const queue = _runOnUIQueue;
|
|
79
|
+
_runOnUIQueue = [];
|
|
80
|
+
NativeReanimatedModule.scheduleOnUI(
|
|
81
|
+
makeShareableCloneRecursive(() => {
|
|
82
|
+
'worklet';
|
|
83
|
+
queue.forEach(([worklet, args]) => {
|
|
84
|
+
worklet(...args);
|
|
85
|
+
});
|
|
86
|
+
flushImmediates();
|
|
87
|
+
})
|
|
88
|
+
);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Schedule a worklet to execute on the UI runtime skipping batching mechanism.
|
|
96
|
+
*/
|
|
97
|
+
export function runOnUIImmediately<A extends any[], R>(
|
|
98
|
+
worklet: ComplexWorkletFunction<A, R>
|
|
99
|
+
): (...args: A) => void {
|
|
100
|
+
if (__DEV__ && !IS_WEB && worklet.__workletHash === undefined) {
|
|
101
|
+
throw new Error('runOnUI() can only be used on worklets');
|
|
15
102
|
}
|
|
16
103
|
return (...args) => {
|
|
17
104
|
NativeReanimatedModule.scheduleOnUI(
|
|
18
105
|
makeShareableCloneRecursive(() => {
|
|
19
106
|
'worklet';
|
|
20
|
-
|
|
107
|
+
worklet(...args);
|
|
21
108
|
})
|
|
22
109
|
);
|
|
23
110
|
};
|
|
24
111
|
}
|
|
25
112
|
|
|
113
|
+
if (__DEV__) {
|
|
114
|
+
try {
|
|
115
|
+
runOnUI(() => {
|
|
116
|
+
'worklet';
|
|
117
|
+
});
|
|
118
|
+
} catch (e) {
|
|
119
|
+
throw new Error(
|
|
120
|
+
'Failed to create a worklet. Did you forget to add Reanimated Babel plugin in babel.config.js? See installation docs at https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation#babel-plugin.'
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
26
125
|
export function runOnJS<A extends any[], R>(
|
|
27
126
|
fun: ComplexWorkletFunction<A, R>
|
|
28
127
|
): (...args: A) => void {
|
package/src/reanimated2/utils.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
2
|
import { measure } from './NativeMethods';
|
|
3
3
|
import { RefObjectFunction } from './hook/commonTypes';
|
|
4
|
+
import { SharedValue } from './commonTypes';
|
|
4
5
|
|
|
5
6
|
export interface ComponentCoords {
|
|
6
7
|
x: number;
|
|
@@ -26,3 +27,8 @@ export function getRelativeCoords(
|
|
|
26
27
|
y: absoluteY - parentCoords.y,
|
|
27
28
|
};
|
|
28
29
|
}
|
|
30
|
+
|
|
31
|
+
export function isSharedValue<T>(value: any): value is SharedValue<T> {
|
|
32
|
+
'worklet';
|
|
33
|
+
return value?._isReanimatedSharedValue === true;
|
|
34
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AnimationObject, AnimatableValue } from './commonTypes';
|
|
2
2
|
import { Descriptor } from './hook/commonTypes';
|
|
3
|
-
import { getTimestamp } from './time';
|
|
4
3
|
export { stopMapper } from './mappers';
|
|
5
4
|
|
|
6
5
|
export function valueSetter(sv: any, value: any): void {
|
|
@@ -32,7 +31,7 @@ export function valueSetter(sv: any, value: any): void {
|
|
|
32
31
|
const initializeAnimation = (timestamp: number) => {
|
|
33
32
|
animation.onStart(animation, sv.value, timestamp, previousAnimation);
|
|
34
33
|
};
|
|
35
|
-
const currentTimestamp =
|
|
34
|
+
const currentTimestamp = global.__frameTimestamp || performance.now();
|
|
36
35
|
initializeAnimation(currentTimestamp);
|
|
37
36
|
const step = (timestamp: number) => {
|
|
38
37
|
if (animation.cancelled) {
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getTimestamp = getTimestamp;
|
|
7
|
-
Object.defineProperty(exports, "stopMapper", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _mappers.stopMapper;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
var _NativeReanimated = _interopRequireDefault(require("./NativeReanimated"));
|
|
15
|
-
|
|
16
|
-
var _reactNative = require("react-native");
|
|
17
|
-
|
|
18
|
-
var _PlatformChecker = require("./PlatformChecker");
|
|
19
|
-
|
|
20
|
-
var _mappers = require("./mappers");
|
|
21
|
-
|
|
22
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
24
|
-
let _getTimestamp;
|
|
25
|
-
|
|
26
|
-
if ((0, _PlatformChecker.nativeShouldBeMock)()) {
|
|
27
|
-
_getTimestamp = () => {
|
|
28
|
-
return _NativeReanimated.default.getTimestamp();
|
|
29
|
-
};
|
|
30
|
-
} else {
|
|
31
|
-
_getTimestamp = () => {
|
|
32
|
-
'worklet';
|
|
33
|
-
|
|
34
|
-
if (_frameTimestamp) {
|
|
35
|
-
return _frameTimestamp;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (_eventTimestamp) {
|
|
39
|
-
return _eventTimestamp;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return _getCurrentTime();
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function getTimestamp() {
|
|
47
|
-
'worklet';
|
|
48
|
-
|
|
49
|
-
if (_reactNative.Platform.OS === 'web') {
|
|
50
|
-
return _NativeReanimated.default.getTimestamp();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return _getTimestamp();
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=time.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_getTimestamp","nativeShouldBeMock","NativeReanimatedModule","getTimestamp","_frameTimestamp","_eventTimestamp","_getCurrentTime","Platform","OS"],"sources":["time.ts"],"sourcesContent":["import NativeReanimatedModule from './NativeReanimated';\nimport { Platform } from 'react-native';\nimport { nativeShouldBeMock } from './PlatformChecker';\nexport { stopMapper } from './mappers';\n\nlet _getTimestamp: () => number;\nif (nativeShouldBeMock()) {\n _getTimestamp = () => {\n return NativeReanimatedModule.getTimestamp();\n };\n} else {\n _getTimestamp = () => {\n 'worklet';\n if (_frameTimestamp) {\n return _frameTimestamp;\n }\n if (_eventTimestamp) {\n return _eventTimestamp;\n }\n return _getCurrentTime();\n };\n}\n\nexport function getTimestamp(): number {\n 'worklet';\n if (Platform.OS === 'web') {\n return NativeReanimatedModule.getTimestamp();\n }\n return _getTimestamp();\n}\n"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;AAEA,IAAIA,aAAJ;;AACA,IAAI,IAAAC,mCAAA,GAAJ,EAA0B;EACxBD,aAAa,GAAG,MAAM;IACpB,OAAOE,yBAAA,CAAuBC,YAAvB,EAAP;EACD,CAFD;AAGD,CAJD,MAIO;EACLH,aAAa,GAAG,MAAM;IACpB;;IACA,IAAII,eAAJ,EAAqB;MACnB,OAAOA,eAAP;IACD;;IACD,IAAIC,eAAJ,EAAqB;MACnB,OAAOA,eAAP;IACD;;IACD,OAAOC,eAAe,EAAtB;EACD,CATD;AAUD;;AAEM,SAASH,YAAT,GAAgC;EACrC;;EACA,IAAII,qBAAA,CAASC,EAAT,KAAgB,KAApB,EAA2B;IACzB,OAAON,yBAAA,CAAuBC,YAAvB,EAAP;EACD;;EACD,OAAOH,aAAa,EAApB;AACD"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import NativeReanimatedModule from './NativeReanimated';
|
|
2
|
-
import { Platform } from 'react-native';
|
|
3
|
-
import { nativeShouldBeMock } from './PlatformChecker';
|
|
4
|
-
export { stopMapper } from './mappers';
|
|
5
|
-
|
|
6
|
-
let _getTimestamp;
|
|
7
|
-
|
|
8
|
-
if (nativeShouldBeMock()) {
|
|
9
|
-
_getTimestamp = () => {
|
|
10
|
-
return NativeReanimatedModule.getTimestamp();
|
|
11
|
-
};
|
|
12
|
-
} else {
|
|
13
|
-
_getTimestamp = () => {
|
|
14
|
-
'worklet';
|
|
15
|
-
|
|
16
|
-
if (_frameTimestamp) {
|
|
17
|
-
return _frameTimestamp;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (_eventTimestamp) {
|
|
21
|
-
return _eventTimestamp;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return _getCurrentTime();
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function getTimestamp() {
|
|
29
|
-
'worklet';
|
|
30
|
-
|
|
31
|
-
if (Platform.OS === 'web') {
|
|
32
|
-
return NativeReanimatedModule.getTimestamp();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return _getTimestamp();
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=time.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["NativeReanimatedModule","Platform","nativeShouldBeMock","stopMapper","_getTimestamp","getTimestamp","_frameTimestamp","_eventTimestamp","_getCurrentTime","OS"],"sources":["time.ts"],"sourcesContent":["import NativeReanimatedModule from './NativeReanimated';\nimport { Platform } from 'react-native';\nimport { nativeShouldBeMock } from './PlatformChecker';\nexport { stopMapper } from './mappers';\n\nlet _getTimestamp: () => number;\nif (nativeShouldBeMock()) {\n _getTimestamp = () => {\n return NativeReanimatedModule.getTimestamp();\n };\n} else {\n _getTimestamp = () => {\n 'worklet';\n if (_frameTimestamp) {\n return _frameTimestamp;\n }\n if (_eventTimestamp) {\n return _eventTimestamp;\n }\n return _getCurrentTime();\n };\n}\n\nexport function getTimestamp(): number {\n 'worklet';\n if (Platform.OS === 'web') {\n return NativeReanimatedModule.getTimestamp();\n }\n return _getTimestamp();\n}\n"],"mappings":"AAAA,OAAOA,sBAAP,MAAmC,oBAAnC;AACA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,kBAAT,QAAmC,mBAAnC;AACA,SAASC,UAAT,QAA2B,WAA3B;;AAEA,IAAIC,aAAJ;;AACA,IAAIF,kBAAkB,EAAtB,EAA0B;EACxBE,aAAa,GAAG,MAAM;IACpB,OAAOJ,sBAAsB,CAACK,YAAvB,EAAP;EACD,CAFD;AAGD,CAJD,MAIO;EACLD,aAAa,GAAG,MAAM;IACpB;;IACA,IAAIE,eAAJ,EAAqB;MACnB,OAAOA,eAAP;IACD;;IACD,IAAIC,eAAJ,EAAqB;MACnB,OAAOA,eAAP;IACD;;IACD,OAAOC,eAAe,EAAtB;EACD,CATD;AAUD;;AAED,OAAO,SAASH,YAAT,GAAgC;EACrC;;EACA,IAAIJ,QAAQ,CAACQ,EAAT,KAAgB,KAApB,EAA2B;IACzB,OAAOT,sBAAsB,CAACK,YAAvB,EAAP;EACD;;EACD,OAAOD,aAAa,EAApB;AACD"}
|
package/src/reanimated2/time.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import NativeReanimatedModule from './NativeReanimated';
|
|
2
|
-
import { Platform } from 'react-native';
|
|
3
|
-
import { nativeShouldBeMock } from './PlatformChecker';
|
|
4
|
-
export { stopMapper } from './mappers';
|
|
5
|
-
|
|
6
|
-
let _getTimestamp: () => number;
|
|
7
|
-
if (nativeShouldBeMock()) {
|
|
8
|
-
_getTimestamp = () => {
|
|
9
|
-
return NativeReanimatedModule.getTimestamp();
|
|
10
|
-
};
|
|
11
|
-
} else {
|
|
12
|
-
_getTimestamp = () => {
|
|
13
|
-
'worklet';
|
|
14
|
-
if (_frameTimestamp) {
|
|
15
|
-
return _frameTimestamp;
|
|
16
|
-
}
|
|
17
|
-
if (_eventTimestamp) {
|
|
18
|
-
return _eventTimestamp;
|
|
19
|
-
}
|
|
20
|
-
return _getCurrentTime();
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function getTimestamp(): number {
|
|
25
|
-
'worklet';
|
|
26
|
-
if (Platform.OS === 'web') {
|
|
27
|
-
return NativeReanimatedModule.getTimestamp();
|
|
28
|
-
}
|
|
29
|
-
return _getTimestamp();
|
|
30
|
-
}
|