react-native-reanimated 3.0.0-rc.8 → 3.0.0
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 +122 -121
- package/Common/cpp/NativeModules/NativeReanimatedModule.h +21 -14
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +15 -7
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +8 -4
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +50 -1
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +10 -1
- 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 +11 -63
- package/Common/cpp/SharedItems/Shareables.h +113 -93
- 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 +67 -247
- package/Common/cpp/Tools/RuntimeDecorator.h +2 -3
- package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -2
- package/Common/cpp/Tools/WorkletEventHandler.h +14 -6
- 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 +31 -5
- package/ios/LayoutReanimation/REAAnimationsManager.m +265 -77
- 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 +67 -60
- 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 +232 -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 +18 -35
- 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/component/FlatList.js +19 -3
- package/lib/commonjs/reanimated2/component/FlatList.js.map +1 -1
- package/lib/commonjs/reanimated2/core.js +34 -83
- package/lib/commonjs/reanimated2/core.js.map +1 -1
- package/lib/commonjs/reanimated2/errors.js +66 -0
- package/lib/commonjs/reanimated2/errors.js.map +1 -0
- 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 +89 -16
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +43 -50
- 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 +196 -0
- package/lib/commonjs/reanimated2/initializers.js.map +1 -0
- 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 +101 -16
- 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 +4 -9
- 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 +16 -12
- 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 +45 -0
- 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 +38 -11
- package/lib/commonjs/reanimated2/shareables.js.map +1 -1
- package/lib/commonjs/reanimated2/threads.js +114 -4
- 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 +229 -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 +18 -34
- 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/component/FlatList.js +18 -4
- package/lib/module/reanimated2/component/FlatList.js.map +1 -1
- package/lib/module/reanimated2/core.js +30 -76
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/errors.js +58 -0
- package/lib/module/reanimated2/errors.js.map +1 -0
- 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 +88 -13
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +45 -52
- 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 +182 -0
- package/lib/module/reanimated2/initializers.js.map +1 -0
- 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 +101 -16
- 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 +4 -9
- 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 +15 -10
- 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 +45 -0
- 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 +38 -9
- package/lib/module/reanimated2/shareables.js.map +1 -1
- package/lib/module/reanimated2/threads.js +105 -4
- 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/package.json +9 -8
- package/{plugin.js → plugin/index.js} +173 -228
- package/react-native-reanimated.d.ts +57 -10
- package/scripts/reanimated_utils.rb +15 -2
- package/src/createAnimatedComponent.tsx +238 -28
- package/src/reanimated2/Colors.ts +38 -11
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +63 -41
- 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/component/FlatList.tsx +30 -5
- package/src/reanimated2/core.ts +45 -75
- package/src/reanimated2/errors.ts +57 -0
- package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +2 -2
- package/src/reanimated2/globals.d.ts +34 -18
- 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 +88 -11
- package/src/reanimated2/hook/useAnimatedStyle.ts +43 -45
- 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 +184 -0
- package/src/reanimated2/interpolateColor.ts +104 -20
- package/src/reanimated2/jestUtils.ts +1 -1
- package/src/reanimated2/js-reanimated/JSReanimated.ts +105 -18
- 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 +4 -8
- 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 +17 -12
- 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 +128 -0
- 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 +47 -11
- package/src/reanimated2/threads.ts +103 -1
- 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,7 @@
|
|
|
1
1
|
import NativeReanimatedModule from './NativeReanimated';
|
|
2
2
|
import { ShareableRef } from './commonTypes';
|
|
3
3
|
import { shouldBeUseWeb } from './PlatformChecker';
|
|
4
|
+
import { registerWorkletStackDetails } from './errors';
|
|
4
5
|
|
|
5
6
|
// for web/chrome debugger/jest environments this file provides a stub implementation
|
|
6
7
|
// where no shareable references are used. Instead, the objects themselves are used
|
|
@@ -16,6 +17,16 @@ const _shareableCache = new WeakMap<
|
|
|
16
17
|
// this is used to allow for a converted shareable to be passed to makeShareableClone
|
|
17
18
|
const _shareableFlag = Symbol('shareable flag');
|
|
18
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
|
+
|
|
19
30
|
export function registerShareableMapping(
|
|
20
31
|
shareable: any,
|
|
21
32
|
shareableRef?: ShareableRef<any>
|
|
@@ -26,14 +37,10 @@ export function registerShareableMapping(
|
|
|
26
37
|
_shareableCache.set(shareable, shareableRef || _shareableFlag);
|
|
27
38
|
}
|
|
28
39
|
|
|
29
|
-
export function
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return shadowNodeWrapper;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function makeShareableCloneRecursive<T>(value: any): ShareableRef<T> {
|
|
40
|
+
export function makeShareableCloneRecursive<T>(
|
|
41
|
+
value: any,
|
|
42
|
+
shouldPersistRemote = false
|
|
43
|
+
): ShareableRef<T> {
|
|
37
44
|
if (USE_STUB_IMPLEMENTATION) {
|
|
38
45
|
return value;
|
|
39
46
|
}
|
|
@@ -52,8 +59,34 @@ export function makeShareableCloneRecursive<T>(value: any): ShareableRef<T> {
|
|
|
52
59
|
} else if (type === 'function' && value.__workletHash === undefined) {
|
|
53
60
|
// this is a remote function
|
|
54
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;
|
|
55
67
|
} else {
|
|
56
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
|
|
86
|
+
);
|
|
87
|
+
delete value.__initData;
|
|
88
|
+
}
|
|
89
|
+
|
|
57
90
|
for (const [key, element] of Object.entries(value)) {
|
|
58
91
|
toAdapt[key] = makeShareableCloneRecursive(element);
|
|
59
92
|
}
|
|
@@ -64,16 +97,19 @@ export function makeShareableCloneRecursive<T>(value: any): ShareableRef<T> {
|
|
|
64
97
|
// shareable. Meaning that they may be doing a faulty assumption in their
|
|
65
98
|
// code expecting that the updates are going to automatically populate to
|
|
66
99
|
// the object sent to the UI thread. If the user really wants some objects
|
|
67
|
-
// to be mutable they should use
|
|
100
|
+
// to be mutable they should use shared values instead.
|
|
68
101
|
Object.freeze(value);
|
|
69
102
|
}
|
|
70
|
-
const adopted = NativeReanimatedModule.makeShareableClone(
|
|
103
|
+
const adopted = NativeReanimatedModule.makeShareableClone(
|
|
104
|
+
toAdapt,
|
|
105
|
+
shouldPersistRemote
|
|
106
|
+
);
|
|
71
107
|
_shareableCache.set(value, adopted);
|
|
72
108
|
_shareableCache.set(adopted, _shareableFlag);
|
|
73
109
|
return adopted;
|
|
74
110
|
}
|
|
75
111
|
}
|
|
76
|
-
return NativeReanimatedModule.makeShareableClone(value);
|
|
112
|
+
return NativeReanimatedModule.makeShareableClone(value, shouldPersistRemote);
|
|
77
113
|
}
|
|
78
114
|
|
|
79
115
|
export function makeShareableCloneOnUIRecursive<T>(value: T): ShareableRef<T> {
|
|
@@ -1,12 +1,102 @@
|
|
|
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
|
+
|
|
11
|
+
let _runOnUIQueue: Array<[ComplexWorkletFunction<any[], any>, any[]]> = [];
|
|
12
|
+
|
|
13
|
+
export function setupSetImmediate() {
|
|
14
|
+
'worklet';
|
|
15
|
+
|
|
16
|
+
let immediateCalbacks: Array<() => void> = [];
|
|
17
|
+
|
|
18
|
+
// @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
|
|
19
|
+
global.setImmediate = (callback: () => void): number => {
|
|
20
|
+
immediateCalbacks.push(callback);
|
|
21
|
+
return -1;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
global.__flushImmediates = () => {
|
|
25
|
+
for (let index = 0; index < immediateCalbacks.length; index += 1) {
|
|
26
|
+
// we use classic 'for' loop because the size of the currentTasks array may change while executing some of the callbacks due to setImmediate calls
|
|
27
|
+
immediateCalbacks[index]();
|
|
28
|
+
}
|
|
29
|
+
immediateCalbacks = [];
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function flushImmediatesOnUIThread() {
|
|
34
|
+
'worklet';
|
|
35
|
+
global.__flushImmediates();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const flushImmediates = shouldBeUseWeb()
|
|
39
|
+
? () => {
|
|
40
|
+
// on web flushing is a noop as immediates are handled by the browser
|
|
41
|
+
}
|
|
42
|
+
: flushImmediatesOnUIThread;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Schedule a worklet to execute on the UI runtime. This method does not schedule the work immediately but instead
|
|
46
|
+
* waits for other worklets to be scheduled within the same JS loop. It uses setImmediate to schedule all the worklets
|
|
47
|
+
* at once making sure they will run within the same frame boundaries on the UI thread.
|
|
48
|
+
*/
|
|
8
49
|
export function runOnUI<A extends any[], R>(
|
|
9
50
|
worklet: ComplexWorkletFunction<A, R>
|
|
51
|
+
): (...args: A) => void {
|
|
52
|
+
if (__DEV__ && !shouldBeUseWeb()) {
|
|
53
|
+
if (worklet.__workletHash === undefined) {
|
|
54
|
+
throw new Error('runOnUI() can only be used on worklets');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return (...args) => {
|
|
58
|
+
if (IS_JEST) {
|
|
59
|
+
// Mocking time in Jest is tricky as both requestAnimationFrame and setImmediate
|
|
60
|
+
// callbacks run on the same queue and can be interleaved. There is no way
|
|
61
|
+
// to flush particular queue in Jest and the only control over mocked timers
|
|
62
|
+
// is by using jest.advanceTimersByTime() method which advances all types
|
|
63
|
+
// of timers including immediate and animation callbacks. Ideally we'd like
|
|
64
|
+
// to have some way here to schedule work along with React updates, but
|
|
65
|
+
// that's not possible, and hence in Jest environment instead of using scheduling
|
|
66
|
+
// mechanism we just schedule the work ommiting the queue. This is ok for the
|
|
67
|
+
// uses that we currently have but may not be ok for future tests that we write.
|
|
68
|
+
NativeReanimatedModule.scheduleOnUI(
|
|
69
|
+
makeShareableCloneRecursive(() => {
|
|
70
|
+
'worklet';
|
|
71
|
+
worklet(...args);
|
|
72
|
+
})
|
|
73
|
+
);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
_runOnUIQueue.push([worklet, args]);
|
|
77
|
+
if (_runOnUIQueue.length === 1) {
|
|
78
|
+
setImmediate(() => {
|
|
79
|
+
const queue = _runOnUIQueue;
|
|
80
|
+
_runOnUIQueue = [];
|
|
81
|
+
NativeReanimatedModule.scheduleOnUI(
|
|
82
|
+
makeShareableCloneRecursive(() => {
|
|
83
|
+
'worklet';
|
|
84
|
+
queue.forEach(([worklet, args]) => {
|
|
85
|
+
worklet(...args);
|
|
86
|
+
});
|
|
87
|
+
flushImmediates();
|
|
88
|
+
})
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Schedule a worklet to execute on the UI runtime skipping batching mechanism.
|
|
97
|
+
*/
|
|
98
|
+
export function runOnUIImmediately<A extends any[], R>(
|
|
99
|
+
worklet: ComplexWorkletFunction<A, R>
|
|
10
100
|
): (...args: A) => void {
|
|
11
101
|
if (__DEV__) {
|
|
12
102
|
if (worklet.__workletHash === undefined) {
|
|
@@ -17,12 +107,24 @@ export function runOnUI<A extends any[], R>(
|
|
|
17
107
|
NativeReanimatedModule.scheduleOnUI(
|
|
18
108
|
makeShareableCloneRecursive(() => {
|
|
19
109
|
'worklet';
|
|
20
|
-
|
|
110
|
+
worklet(...args);
|
|
21
111
|
})
|
|
22
112
|
);
|
|
23
113
|
};
|
|
24
114
|
}
|
|
25
115
|
|
|
116
|
+
if (__DEV__) {
|
|
117
|
+
try {
|
|
118
|
+
runOnUI(() => {
|
|
119
|
+
'worklet';
|
|
120
|
+
});
|
|
121
|
+
} catch (e) {
|
|
122
|
+
throw new Error(
|
|
123
|
+
'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.'
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
26
128
|
export function runOnJS<A extends any[], R>(
|
|
27
129
|
fun: ComplexWorkletFunction<A, R>
|
|
28
130
|
): (...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 typeof value === 'object' && 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
|
-
}
|