react-native-reanimated 3.0.2 → 3.1.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/Fabric/FabricUtils.h +1 -1
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +38 -27
- package/Common/cpp/SharedItems/Shareables.h +22 -0
- package/Common/cpp/Tools/PlatformDepMethodsHolder.h +2 -0
- package/Common/cpp/Tools/RuntimeDecorator.cpp +4 -1
- package/Common/cpp/Tools/RuntimeDecorator.h +2 -1
- package/Common/cpp/Tools/SingleInstanceChecker.h +14 -2
- package/RNReanimated.podspec +5 -2
- package/android/CMakeLists.txt +4 -0
- package/android/build.gradle +18 -10
- package/android/src/main/cpp/NativeProxy.cpp +316 -337
- package/android/src/main/cpp/NativeProxy.h +53 -11
- package/android/src/main/java/com/swmansion/reanimated/NativeMethodsHelper.java +7 -12
- package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +11 -8
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +21 -14
- package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +0 -3
- package/ios/Fabric/REAInitializerRCTFabricSurface.mm +1 -0
- package/ios/REANodesManager.h +1 -0
- package/ios/REANodesManager.mm +30 -4
- package/ios/keyboardObserver/REAKeyboardEventObserver.m +51 -130
- package/ios/native/NativeMethods.mm +1 -1
- package/ios/native/NativeProxy.mm +4 -1
- package/ios/native/REAIOSErrorHandler.mm +1 -1
- package/ios/native/REAIOSLogger.mm +1 -1
- package/ios/native/REAIOSScheduler.mm +1 -1
- package/ios/native/REAInitializer.mm +1 -1
- package/ios/native/REAMessageThread.mm +2 -2
- package/lib/commonjs/Animated.js +0 -8
- package/lib/commonjs/Animated.js.map +1 -1
- package/lib/commonjs/ConfigHelper.js +8 -19
- package/lib/commonjs/ConfigHelper.js.map +1 -1
- package/lib/commonjs/createAnimatedComponent.js +20 -158
- package/lib/commonjs/createAnimatedComponent.js.map +1 -1
- package/lib/commonjs/index.js +0 -9
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +0 -7
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/reanimated2/Bezier.js +14 -34
- package/lib/commonjs/reanimated2/Bezier.js.map +1 -1
- package/lib/commonjs/reanimated2/Colors.js +60 -132
- package/lib/commonjs/reanimated2/Colors.js.map +1 -1
- package/lib/commonjs/reanimated2/Easing.js +81 -34
- package/lib/commonjs/reanimated2/Easing.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeMethods.js +8 -20
- package/lib/commonjs/reanimated2/NativeMethods.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +5 -31
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/index.js +0 -7
- package/lib/commonjs/reanimated2/NativeReanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated2/PlatformChecker.js +0 -6
- package/lib/commonjs/reanimated2/PlatformChecker.js.map +1 -1
- package/lib/commonjs/reanimated2/PropAdapters.js +10 -12
- package/lib/commonjs/reanimated2/PropAdapters.js.map +1 -1
- package/lib/commonjs/reanimated2/UpdateProps.js +3 -12
- package/lib/commonjs/reanimated2/UpdateProps.js.map +1 -1
- package/lib/commonjs/reanimated2/ViewDescriptorsSet.js +0 -10
- package/lib/commonjs/reanimated2/ViewDescriptorsSet.js.map +1 -1
- package/lib/commonjs/reanimated2/WorkletEventHandler.js +5 -22
- package/lib/commonjs/reanimated2/WorkletEventHandler.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/decay.js +7 -18
- package/lib/commonjs/reanimated2/animation/decay.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/delay.js +0 -11
- package/lib/commonjs/reanimated2/animation/delay.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/index.js +0 -8
- package/lib/commonjs/reanimated2/animation/index.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/repeat.js +6 -22
- package/lib/commonjs/reanimated2/animation/repeat.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/sequence.js +3 -20
- package/lib/commonjs/reanimated2/animation/sequence.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/spring.js +11 -23
- package/lib/commonjs/reanimated2/animation/spring.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js +3 -35
- package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/timing.js +0 -11
- package/lib/commonjs/reanimated2/animation/timing.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/util.js +11 -41
- package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
- package/lib/commonjs/reanimated2/commonTypes.js +16 -23
- package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/component/FlatList.js +0 -16
- package/lib/commonjs/reanimated2/component/FlatList.js.map +1 -1
- package/lib/commonjs/reanimated2/component/Image.js +0 -4
- package/lib/commonjs/reanimated2/component/Image.js.map +1 -1
- package/lib/commonjs/reanimated2/component/ScrollView.js +0 -4
- package/lib/commonjs/reanimated2/component/ScrollView.js.map +1 -1
- package/lib/commonjs/reanimated2/component/Text.js +0 -4
- package/lib/commonjs/reanimated2/component/Text.js.map +1 -1
- package/lib/commonjs/reanimated2/component/View.js +0 -4
- package/lib/commonjs/reanimated2/component/View.js.map +1 -1
- package/lib/commonjs/reanimated2/core.js +6 -48
- package/lib/commonjs/reanimated2/core.js.map +1 -1
- package/lib/commonjs/reanimated2/errors.js +3 -14
- package/lib/commonjs/reanimated2/errors.js.map +1 -1
- package/lib/commonjs/reanimated2/fabricUtils.js +3 -5
- package/lib/commonjs/reanimated2/fabricUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/fabricUtils.web.js +1 -3
- package/lib/commonjs/reanimated2/fabricUtils.web.js.map +1 -1
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryJS.js +3 -12
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryJS.js.map +1 -1
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +13 -17
- 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/Hooks.js +0 -5
- package/lib/commonjs/reanimated2/hook/Hooks.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/index.js +0 -12
- package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedGestureHandler.js +4 -17
- package/lib/commonjs/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +2 -9
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +1 -11
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +0 -12
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedScrollHandler.js +2 -9
- package/lib/commonjs/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +8 -23
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +13 -71
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js +4 -13
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useFrameCallback.js +0 -5
- package/lib/commonjs/reanimated2/hook/useFrameCallback.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +0 -7
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useSharedValue.js +2 -7
- package/lib/commonjs/reanimated2/hook/useSharedValue.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/utils.js +8 -39
- package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/index.js +0 -26
- package/lib/commonjs/reanimated2/index.js.map +1 -1
- package/lib/commonjs/reanimated2/initializers.js +21 -43
- package/lib/commonjs/reanimated2/initializers.js.map +1 -1
- package/lib/commonjs/reanimated2/interpolateColor.js +6 -43
- package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
- package/lib/commonjs/reanimated2/interpolation.js +14 -29
- package/lib/commonjs/reanimated2/interpolation.js.map +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js +11 -44
- package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +15 -39
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +9 -28
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/MapperRegistry.js +7 -37
- package/lib/commonjs/reanimated2/js-reanimated/MapperRegistry.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/MutableValue.js +5 -18
- package/lib/commonjs/reanimated2/js-reanimated/MutableValue.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/global.js +2 -9
- package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js +3 -14
- package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +7 -26
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +3 -49
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +7 -43
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +4 -5
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +0 -4
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +4 -23
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +3 -74
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Fade.js +3 -53
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Flip.js +3 -63
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +7 -26
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +3 -13
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +3 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +3 -43
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +3 -43
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +3 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +3 -83
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/index.js +0 -20
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +3 -22
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +5 -29
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +3 -9
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +5 -11
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +3 -8
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +3 -12
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/index.js +0 -12
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/index.js +0 -9
- package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +3 -17
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -1
- package/lib/commonjs/reanimated2/mappers.js +26 -32
- package/lib/commonjs/reanimated2/mappers.js.map +1 -1
- package/lib/commonjs/reanimated2/mock.js +5 -15
- package/lib/commonjs/reanimated2/mock.js.map +1 -1
- package/lib/commonjs/reanimated2/mutables.js +2 -28
- package/lib/commonjs/reanimated2/mutables.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/RNRenderer.js +0 -2
- package/lib/commonjs/reanimated2/platform-specific/RNRenderer.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/RNRenderer.web.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/checkCppVersion.js +31 -0
- package/lib/commonjs/reanimated2/platform-specific/checkCppVersion.js.map +1 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +0 -2
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/jsVersion.js +14 -0
- package/lib/commonjs/reanimated2/platform-specific/jsVersion.js.map +1 -0
- package/lib/commonjs/reanimated2/pluginUtils.js +0 -1
- package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/shareables.js +92 -49
- package/lib/commonjs/reanimated2/shareables.js.map +1 -1
- package/lib/commonjs/reanimated2/threads.js +42 -46
- package/lib/commonjs/reanimated2/threads.js.map +1 -1
- package/lib/commonjs/reanimated2/utils.js +0 -5
- package/lib/commonjs/reanimated2/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/valueSetter.js +6 -21
- package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
- package/lib/commonjs/setAndForwardRef.js +3 -3
- package/lib/commonjs/setAndForwardRef.js.map +1 -1
- package/lib/module/Animated.js.map +1 -1
- package/lib/module/ConfigHelper.js +9 -15
- package/lib/module/ConfigHelper.js.map +1 -1
- package/lib/module/createAnimatedComponent.js +20 -139
- package/lib/module/createAnimatedComponent.js.map +1 -1
- package/lib/module/index.js +0 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/reanimated2/Bezier.js +14 -33
- package/lib/module/reanimated2/Bezier.js.map +1 -1
- package/lib/module/reanimated2/Colors.js +59 -109
- package/lib/module/reanimated2/Colors.js.map +1 -1
- package/lib/module/reanimated2/Easing.js +37 -33
- package/lib/module/reanimated2/Easing.js.map +1 -1
- package/lib/module/reanimated2/NativeMethods.js +8 -15
- package/lib/module/reanimated2/NativeMethods.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +5 -27
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/index.js +0 -2
- package/lib/module/reanimated2/NativeReanimated/index.js.map +1 -1
- package/lib/module/reanimated2/PlatformChecker.js.map +1 -1
- package/lib/module/reanimated2/PropAdapters.js +12 -10
- package/lib/module/reanimated2/PropAdapters.js.map +1 -1
- package/lib/module/reanimated2/UpdateProps.js +3 -5
- package/lib/module/reanimated2/UpdateProps.js.map +1 -1
- package/lib/module/reanimated2/ViewDescriptorsSet.js +0 -6
- package/lib/module/reanimated2/ViewDescriptorsSet.js.map +1 -1
- package/lib/module/reanimated2/WorkletEventHandler.js +5 -18
- package/lib/module/reanimated2/WorkletEventHandler.js.map +1 -1
- package/lib/module/reanimated2/animation/decay.js +7 -15
- package/lib/module/reanimated2/animation/decay.js.map +1 -1
- package/lib/module/reanimated2/animation/delay.js +0 -9
- package/lib/module/reanimated2/animation/delay.js.map +1 -1
- package/lib/module/reanimated2/animation/index.js.map +1 -1
- package/lib/module/reanimated2/animation/repeat.js +6 -20
- package/lib/module/reanimated2/animation/repeat.js.map +1 -1
- package/lib/module/reanimated2/animation/sequence.js +3 -18
- package/lib/module/reanimated2/animation/sequence.js.map +1 -1
- package/lib/module/reanimated2/animation/spring.js +11 -21
- package/lib/module/reanimated2/animation/spring.js.map +1 -1
- package/lib/module/reanimated2/animation/styleAnimation.js +7 -31
- package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/module/reanimated2/animation/timing.js +0 -8
- package/lib/module/reanimated2/animation/timing.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +10 -33
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +12 -19
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/component/FlatList.js +0 -4
- package/lib/module/reanimated2/component/FlatList.js.map +1 -1
- package/lib/module/reanimated2/component/Image.js.map +1 -1
- package/lib/module/reanimated2/component/ScrollView.js.map +1 -1
- package/lib/module/reanimated2/component/Text.js.map +1 -1
- package/lib/module/reanimated2/component/View.js.map +1 -1
- package/lib/module/reanimated2/core.js +6 -22
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/errors.js +3 -13
- package/lib/module/reanimated2/errors.js.map +1 -1
- package/lib/module/reanimated2/fabricUtils.js +3 -3
- package/lib/module/reanimated2/fabricUtils.js.map +1 -1
- package/lib/module/reanimated2/fabricUtils.web.js +1 -1
- package/lib/module/reanimated2/fabricUtils.web.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js +3 -8
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +13 -15
- 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/Hooks.js +3 -2
- package/lib/module/reanimated2/hook/Hooks.js.map +1 -1
- package/lib/module/reanimated2/hook/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/hook/index.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js +3 -14
- package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +2 -5
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js +1 -7
- package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +0 -6
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js +2 -7
- package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js +9 -20
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +13 -59
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js +4 -8
- package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useFrameCallback.js.map +1 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js +0 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/module/reanimated2/hook/useSharedValue.js +2 -3
- package/lib/module/reanimated2/hook/useSharedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js +8 -21
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/initializers.js +23 -37
- package/lib/module/reanimated2/initializers.js.map +1 -1
- package/lib/module/reanimated2/interpolateColor.js +5 -34
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/interpolation.js +13 -28
- package/lib/module/reanimated2/interpolation.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.js +11 -35
- package/lib/module/reanimated2/jestUtils.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js +15 -35
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/Mapper.js +9 -23
- package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/MapperRegistry.js +7 -35
- package/lib/module/reanimated2/js-reanimated/MapperRegistry.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/MutableValue.js +5 -16
- package/lib/module/reanimated2/js-reanimated/MutableValue.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/global.js +2 -6
- package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js +3 -9
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +7 -23
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +3 -45
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +7 -39
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +3 -3
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js +4 -19
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +3 -52
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js +3 -32
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js +3 -38
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +7 -16
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +3 -8
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +3 -14
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +3 -26
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +3 -26
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +3 -14
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +3 -50
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +3 -17
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +5 -23
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +3 -5
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +5 -6
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +3 -5
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +3 -8
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +3 -13
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -1
- package/lib/module/reanimated2/mappers.js +26 -25
- package/lib/module/reanimated2/mappers.js.map +1 -1
- package/lib/module/reanimated2/mock.js +5 -15
- package/lib/module/reanimated2/mock.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +2 -19
- package/lib/module/reanimated2/mutables.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/RNRenderer.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/RNRenderer.web.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/checkCppVersion.js +24 -0
- package/lib/module/reanimated2/platform-specific/checkCppVersion.js.map +1 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js +0 -1
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/jsVersion.js +7 -0
- package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -0
- package/lib/module/reanimated2/pluginUtils.js.map +1 -1
- package/lib/module/reanimated2/shareables.js +96 -44
- package/lib/module/reanimated2/shareables.js.map +1 -1
- package/lib/module/reanimated2/threads.js +39 -33
- package/lib/module/reanimated2/threads.js.map +1 -1
- package/lib/module/reanimated2/utils.js +0 -3
- package/lib/module/reanimated2/utils.js.map +1 -1
- package/lib/module/reanimated2/valueSetter.js +6 -19
- package/lib/module/reanimated2/valueSetter.js.map +1 -1
- package/lib/module/setAndForwardRef.js +3 -2
- package/lib/module/setAndForwardRef.js.map +1 -1
- package/package.json +46 -40
- package/plugin/.eslintrc.js +7 -0
- package/plugin/README.md +241 -0
- package/plugin/build/plugin.js +714 -0
- package/plugin/build/plugin.js.map +7 -0
- package/plugin/index.js +1 -807
- package/plugin/package.json +23 -0
- package/plugin/src/buildWorkletString.ts +213 -0
- package/plugin/src/commonObjects.ts +60 -0
- package/plugin/src/injectVersion.ts +37 -0
- package/plugin/src/makeWorklet.ts +375 -0
- package/plugin/src/plugin.ts +49 -0
- package/plugin/src/processForCalleesWorklets.ts +106 -0
- package/plugin/src/processIfGestureHandlerEventCallbackFunctionNode.ts +156 -0
- package/plugin/src/processIfWorkletFunction.ts +55 -0
- package/plugin/src/processIfWorkletNode.ts +44 -0
- package/plugin/src/processInlineStylesWarning.ts +129 -0
- package/plugin/src/processWorkletObjectMethod.ts +31 -0
- package/plugin/src/types.ts +15 -0
- package/plugin/src/utils.ts +6 -0
- package/plugin/tsconfig.json +15 -0
- package/plugin/yarn.lock +2193 -0
- package/react-native-reanimated.d.ts +1 -0
- package/scripts/reanimated_utils.rb +2 -2
- package/src/createAnimatedComponent.tsx +2 -3
- package/src/reanimated2/Easing.ts +19 -0
- package/src/reanimated2/NativeMethods.ts +9 -4
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +2 -2
- package/src/reanimated2/UpdateProps.ts +2 -2
- package/src/reanimated2/animation/decay.ts +7 -1
- package/src/reanimated2/animation/styleAnimation.ts +5 -1
- package/src/reanimated2/core.ts +4 -4
- package/src/reanimated2/errors.ts +1 -0
- package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +12 -4
- package/src/reanimated2/globals.d.ts +71 -112
- package/src/reanimated2/hook/commonTypes.ts +1 -1
- package/src/reanimated2/hook/useAnimatedReaction.ts +2 -2
- package/src/reanimated2/hook/useAnimatedSensor.ts +2 -2
- package/src/reanimated2/initializers.ts +11 -8
- package/src/reanimated2/jestUtils.ts +0 -1
- package/src/reanimated2/js-reanimated/JSReanimated.ts +5 -1
- package/src/reanimated2/js-reanimated/index.ts +1 -1
- package/src/reanimated2/mappers.ts +26 -4
- package/src/reanimated2/mock.ts +1 -0
- package/src/reanimated2/platform-specific/checkCppVersion.ts +29 -0
- package/src/reanimated2/platform-specific/jsVersion.ts +6 -0
- package/src/reanimated2/shareables.ts +107 -8
- package/src/reanimated2/threads.ts +36 -17
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +0 -42
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +0 -1
- package/lib/module/reanimated2/platform-specific/checkVersion.js +0 -35
- package/lib/module/reanimated2/platform-specific/checkVersion.js.map +0 -1
- package/src/reanimated2/platform-specific/checkVersion.ts +0 -39
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SharedValue } from './commonTypes';
|
|
2
2
|
import { isJest } from './PlatformChecker';
|
|
3
3
|
import { runOnUI } from './threads';
|
|
4
|
+
import { isSharedValue } from './utils';
|
|
4
5
|
|
|
5
6
|
const IS_JEST = isJest();
|
|
6
7
|
|
|
@@ -18,6 +19,7 @@ export function createMapperRegistry() {
|
|
|
18
19
|
let sortedMappers: Mapper[] = [];
|
|
19
20
|
|
|
20
21
|
let runRequested = false;
|
|
22
|
+
let processingMappers = false;
|
|
21
23
|
|
|
22
24
|
function updateMappersOrder() {
|
|
23
25
|
// sort mappers topologically
|
|
@@ -78,6 +80,7 @@ export function createMapperRegistry() {
|
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
function mapperRun() {
|
|
83
|
+
processingMappers = true;
|
|
81
84
|
runRequested = false;
|
|
82
85
|
if (mappers.size !== sortedMappers.length) {
|
|
83
86
|
updateMappersOrder();
|
|
@@ -88,11 +91,12 @@ export function createMapperRegistry() {
|
|
|
88
91
|
mapper.worklet();
|
|
89
92
|
}
|
|
90
93
|
}
|
|
94
|
+
processingMappers = false;
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
function maybeRequestUpdates() {
|
|
94
98
|
if (IS_JEST) {
|
|
95
|
-
// On Jest environment we avoid using
|
|
99
|
+
// On Jest environment we avoid using queueMicrotask as that'd require test
|
|
96
100
|
// to advance the clock manually. This on other hand would require tests
|
|
97
101
|
// to know how many times mappers need to run. As we don't want tests to
|
|
98
102
|
// make any assumptions on that number it is easier to execute mappers
|
|
@@ -100,7 +104,22 @@ export function createMapperRegistry() {
|
|
|
100
104
|
// if they want to make any assertions on the effects of animations being run.
|
|
101
105
|
mapperRun();
|
|
102
106
|
} else if (!runRequested) {
|
|
103
|
-
|
|
107
|
+
if (processingMappers) {
|
|
108
|
+
// In general, we should avoid having mappers trigger updates as this may
|
|
109
|
+
// result in unpredictable behavior. Specifically, the updated value can
|
|
110
|
+
// be read by mappers that run later in the same frame but previous mappers
|
|
111
|
+
// would access the old value. Updating mappers during the mapper-run phase
|
|
112
|
+
// breaks the order in which we should execute the mappers. However, doing
|
|
113
|
+
// that is still a possibility and there are some instances where people use
|
|
114
|
+
// the API in that way, hence we need to prevent mapper-run phase falling into
|
|
115
|
+
// an infinite loop. We do that by detecting when mapper-run is requested while
|
|
116
|
+
// we are already in mapper-run phase, and in that case we use `requestAnimationFrame`
|
|
117
|
+
// instead of `queueMicrotask` which will schedule mapper run for the next
|
|
118
|
+
// frame instead of queuing another set of updates in the same frame.
|
|
119
|
+
requestAnimationFrame(mapperRun);
|
|
120
|
+
} else {
|
|
121
|
+
queueMicrotask(mapperRun);
|
|
122
|
+
}
|
|
104
123
|
runRequested = true;
|
|
105
124
|
}
|
|
106
125
|
}
|
|
@@ -113,9 +132,12 @@ export function createMapperRegistry() {
|
|
|
113
132
|
for (const input of inputs) {
|
|
114
133
|
input && extractInputs(input, resultArray);
|
|
115
134
|
}
|
|
116
|
-
} else if (inputs
|
|
135
|
+
} else if (isSharedValue(inputs)) {
|
|
117
136
|
resultArray.push(inputs);
|
|
118
|
-
} else if (
|
|
137
|
+
} else if (Object.getPrototypeOf(inputs) === Object.prototype) {
|
|
138
|
+
// we only extract inputs recursively from "plain" objects here, if object
|
|
139
|
+
// is of a derivative class (e.g. HostObject on web, or Map) we don't scan
|
|
140
|
+
// it recursively
|
|
119
141
|
for (const element of Object.values(inputs)) {
|
|
120
142
|
element && extractInputs(element, resultArray);
|
|
121
143
|
}
|
package/src/reanimated2/mock.ts
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsVersion } from './jsVersion';
|
|
2
|
+
|
|
3
|
+
export function checkCppVersion() {
|
|
4
|
+
const cppVersion = global._REANIMATED_VERSION_CPP;
|
|
5
|
+
if (cppVersion === undefined) {
|
|
6
|
+
console.error(
|
|
7
|
+
`[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.`
|
|
8
|
+
);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const ok = matchVersion(jsVersion, cppVersion);
|
|
12
|
+
if (!ok) {
|
|
13
|
+
console.error(
|
|
14
|
+
`[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.`
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function matchVersion(version1: string, version2: string) {
|
|
20
|
+
if (version1.match(/^\d+\.\d+\.\d+$/) && version2.match(/^\d+\.\d+\.\d+$/)) {
|
|
21
|
+
// x.y.z, compare only major and minor, skip patch
|
|
22
|
+
const [major1, minor1] = version1.split('.');
|
|
23
|
+
const [major2, minor2] = version2.split('.');
|
|
24
|
+
return major1 === major2 && minor1 === minor2;
|
|
25
|
+
} else {
|
|
26
|
+
// alpha, beta or rc, compare everything
|
|
27
|
+
return version1 === version2;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
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
|
+
export const jsVersion = '3.1.0';
|
|
@@ -2,6 +2,7 @@ import NativeReanimatedModule from './NativeReanimated';
|
|
|
2
2
|
import { ShareableRef } from './commonTypes';
|
|
3
3
|
import { shouldBeUseWeb } from './PlatformChecker';
|
|
4
4
|
import { registerWorkletStackDetails } from './errors';
|
|
5
|
+
import { jsVersion } from './platform-specific/jsVersion';
|
|
5
6
|
|
|
6
7
|
// for web/chrome debugger/jest environments this file provides a stub implementation
|
|
7
8
|
// where no shareable references are used. Instead, the objects themselves are used
|
|
@@ -37,16 +38,85 @@ export function registerShareableMapping(
|
|
|
37
38
|
_shareableCache.set(shareable, shareableRef || _shareableFlag);
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
function isPlainJSObject(object: object) {
|
|
42
|
+
return Object.getPrototypeOf(object) === Object.prototype;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// The below object is used as a replacement for objects that cannot be transferred
|
|
46
|
+
// as shareable values. In makeShareableCloneRecursive we detect if an object is of
|
|
47
|
+
// a plain Object.prototype and only allow such objects to be transferred. This lets
|
|
48
|
+
// us avoid all sorts of react internals from leaking into the UI runtime. To make it
|
|
49
|
+
// possible to catch errors when someone actually tries to access such object on the UI
|
|
50
|
+
// runtime, we use the below Proxy object which is instantiated on the UI runtime and
|
|
51
|
+
// throws whenever someone tries to access its fields.
|
|
52
|
+
const INACCESSIBLE_OBJECT = {
|
|
53
|
+
__init: () => {
|
|
54
|
+
'worklet';
|
|
55
|
+
return new Proxy(
|
|
56
|
+
{},
|
|
57
|
+
{
|
|
58
|
+
get: (_: any, prop: string) => {
|
|
59
|
+
if (prop === '_isReanimatedSharedValue') {
|
|
60
|
+
// not very happy about this check here, but we need to allow for
|
|
61
|
+
// "inaccessible" objects to be tested with isSharedValue check
|
|
62
|
+
// as it is being used in the mappers when extracing inputs recursively.
|
|
63
|
+
// Apparently we can't check if a key exists there as HostObjects always
|
|
64
|
+
// return true for such tests, so the only possibility for us is to
|
|
65
|
+
// actually access that key and see if it is set to true. We therefore
|
|
66
|
+
// need to allow for this key to be accessed here.
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
throw new Error(
|
|
70
|
+
`Trying to access property \`${prop}\` of an object which cannot be sent to the UI runtime.`
|
|
71
|
+
);
|
|
72
|
+
},
|
|
73
|
+
set: () => {
|
|
74
|
+
throw new Error(
|
|
75
|
+
'Trying to write to an object which cannot be sent to the UI runtime.'
|
|
76
|
+
);
|
|
77
|
+
},
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const DETECT_CYCLIC_OBJECT_DEPTH_THRESHOLD = 30;
|
|
84
|
+
// Below variable stores object that we process in makeShareableCloneRecursive at the specified depth.
|
|
85
|
+
// We use it to check if later on the function reenters with the same object
|
|
86
|
+
let processedObjectAtThresholdDepth: any;
|
|
87
|
+
|
|
88
|
+
// We only want to show mismatch error once so we use this flag to track it
|
|
89
|
+
let didShowPluginVersionMismatchError = false;
|
|
90
|
+
|
|
40
91
|
export function makeShareableCloneRecursive<T>(
|
|
41
92
|
value: any,
|
|
42
|
-
shouldPersistRemote = false
|
|
93
|
+
shouldPersistRemote = false,
|
|
94
|
+
depth = 0
|
|
43
95
|
): ShareableRef<T> {
|
|
44
96
|
if (USE_STUB_IMPLEMENTATION) {
|
|
45
97
|
return value;
|
|
46
98
|
}
|
|
99
|
+
if (depth >= DETECT_CYCLIC_OBJECT_DEPTH_THRESHOLD) {
|
|
100
|
+
// if we reach certain recursion depth we suspect that we are dealing with a cyclic object.
|
|
101
|
+
// this type of objects are not supported and cannot be trasferred as shareable, so we
|
|
102
|
+
// implement a simple detection mechanism that remembers the value at a given depth and
|
|
103
|
+
// tests whether we try reenter this method later on with the same value. If that happens
|
|
104
|
+
// we throw an appropriate error.
|
|
105
|
+
if (depth === DETECT_CYCLIC_OBJECT_DEPTH_THRESHOLD) {
|
|
106
|
+
processedObjectAtThresholdDepth = value;
|
|
107
|
+
} else if (value === processedObjectAtThresholdDepth) {
|
|
108
|
+
throw new Error(
|
|
109
|
+
'Trying to convert a cyclic object to a shareable. This is not supported.'
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
processedObjectAtThresholdDepth = undefined;
|
|
114
|
+
}
|
|
47
115
|
// This one actually may be worth to be moved to c++, we also need similar logic to run on the UI thread
|
|
48
116
|
const type = typeof value;
|
|
49
|
-
|
|
117
|
+
const isTypeObject = type === 'object';
|
|
118
|
+
const isTypeFunction = type === 'function';
|
|
119
|
+
if ((isTypeObject || isTypeFunction) && value !== null) {
|
|
50
120
|
const cached = _shareableCache.get(value);
|
|
51
121
|
if (cached === _shareableFlag) {
|
|
52
122
|
return value;
|
|
@@ -55,8 +125,10 @@ export function makeShareableCloneRecursive<T>(
|
|
|
55
125
|
} else {
|
|
56
126
|
let toAdapt: any;
|
|
57
127
|
if (Array.isArray(value)) {
|
|
58
|
-
toAdapt = value.map((element) =>
|
|
59
|
-
|
|
128
|
+
toAdapt = value.map((element) =>
|
|
129
|
+
makeShareableCloneRecursive(element, shouldPersistRemote, depth + 1)
|
|
130
|
+
);
|
|
131
|
+
} else if (isTypeFunction && value.__workletHash === undefined) {
|
|
60
132
|
// this is a remote function
|
|
61
133
|
toAdapt = value;
|
|
62
134
|
} else if (isHostObject(value)) {
|
|
@@ -64,11 +136,20 @@ export function makeShareableCloneRecursive<T>(
|
|
|
64
136
|
// then recreate new host object wrapping the same instance on the UI thread.
|
|
65
137
|
// there is no point of iterating over keys as we do for regular objects.
|
|
66
138
|
toAdapt = value;
|
|
67
|
-
} else {
|
|
139
|
+
} else if (isPlainJSObject(value) || isTypeFunction) {
|
|
68
140
|
toAdapt = {};
|
|
69
141
|
if (value.__workletHash !== undefined) {
|
|
70
142
|
// we are converting a worklet
|
|
71
143
|
if (__DEV__) {
|
|
144
|
+
if (
|
|
145
|
+
// We don't want this error to be logged more than once.
|
|
146
|
+
!didShowPluginVersionMismatchError &&
|
|
147
|
+
value.__version !== jsVersion
|
|
148
|
+
) {
|
|
149
|
+
didShowPluginVersionMismatchError = true;
|
|
150
|
+
console.error(`[Reanimated] Mismatch between JavaScript code version and Reanimated Babel plugin version (${jsVersion} vs. ${value.__version}). Please clear your Metro bundler cache with \`yarn start --reset-cache\`,
|
|
151
|
+
\`npm start -- --reset-cache\` or \`expo start -c\` and run the app again.`);
|
|
152
|
+
}
|
|
72
153
|
registerWorkletStackDetails(
|
|
73
154
|
value.__workletHash,
|
|
74
155
|
value.__stackDetails
|
|
@@ -79,7 +160,8 @@ export function makeShareableCloneRecursive<T>(
|
|
|
79
160
|
// we request shareable value to persist its UI counterpart. This means
|
|
80
161
|
// that the __initData field that contains long strings represeting the
|
|
81
162
|
// worklet code, source map, and location, will always be
|
|
82
|
-
// serialized/deserialized once.
|
|
163
|
+
// serialized/deserialized once. We don't increase depth when calling
|
|
164
|
+
// this method as these objects have one level anyways.
|
|
83
165
|
toAdapt.__initData = makeShareableCloneRecursive(
|
|
84
166
|
value.__initData,
|
|
85
167
|
true
|
|
@@ -88,8 +170,25 @@ export function makeShareableCloneRecursive<T>(
|
|
|
88
170
|
}
|
|
89
171
|
|
|
90
172
|
for (const [key, element] of Object.entries(value)) {
|
|
91
|
-
toAdapt[key] = makeShareableCloneRecursive(
|
|
173
|
+
toAdapt[key] = makeShareableCloneRecursive(
|
|
174
|
+
element,
|
|
175
|
+
shouldPersistRemote,
|
|
176
|
+
depth + 1
|
|
177
|
+
);
|
|
92
178
|
}
|
|
179
|
+
} else {
|
|
180
|
+
// This is reached for object types that are not of plain Object.prototype.
|
|
181
|
+
// We don't support such objects from being transferred as shareables to
|
|
182
|
+
// the UI runtime and hence we replace them with "inaccessible object"
|
|
183
|
+
// which is implemented as a Proxy object that throws on any attempt
|
|
184
|
+
// of accessing its fields. We argue that such objects can sometimes leak
|
|
185
|
+
// as attributes of objects being captured by worklets but should never
|
|
186
|
+
// be used on the UI runtime regardless. If they are being accessed, the user
|
|
187
|
+
// will get an appropriate error message.
|
|
188
|
+
const inaccessibleObject =
|
|
189
|
+
makeShareableCloneRecursive<T>(INACCESSIBLE_OBJECT);
|
|
190
|
+
_shareableCache.set(value, inaccessibleObject);
|
|
191
|
+
return inaccessibleObject;
|
|
93
192
|
}
|
|
94
193
|
if (__DEV__) {
|
|
95
194
|
// we freeze objects that are transformed to shareable. This should help
|
|
@@ -125,7 +224,7 @@ export function makeShareableCloneOnUIRecursive<T>(value: T): ShareableRef<T> {
|
|
|
125
224
|
let toAdapt: any;
|
|
126
225
|
if (Array.isArray(value)) {
|
|
127
226
|
toAdapt = value.map((element) => cloneRecursive(element));
|
|
128
|
-
} else {
|
|
227
|
+
} else if (value !== undefined) {
|
|
129
228
|
toAdapt = {};
|
|
130
229
|
for (const [key, element] of Object.entries(value)) {
|
|
131
230
|
toAdapt[key] = cloneRecursive(element);
|
|
@@ -11,40 +11,50 @@ const IS_WEB = shouldBeUseWeb();
|
|
|
11
11
|
|
|
12
12
|
let _runOnUIQueue: Array<[ComplexWorkletFunction<any[], any>, any[]]> = [];
|
|
13
13
|
|
|
14
|
-
export function
|
|
14
|
+
export function setupMicrotasks() {
|
|
15
15
|
'worklet';
|
|
16
16
|
|
|
17
|
-
let
|
|
17
|
+
let microtasksQueue: Array<() => void> = [];
|
|
18
|
+
let isExecutingMicrotasksQueue = false;
|
|
18
19
|
|
|
19
20
|
// @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.
|
|
21
|
-
|
|
21
|
+
global.queueMicrotask = (callback: () => void): number => {
|
|
22
|
+
microtasksQueue.push(callback);
|
|
22
23
|
return -1;
|
|
23
24
|
};
|
|
24
25
|
|
|
25
|
-
global.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
global.__callMicrotasks = () => {
|
|
27
|
+
if (isExecutingMicrotasksQueue) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
isExecutingMicrotasksQueue = true;
|
|
32
|
+
for (let index = 0; index < microtasksQueue.length; index += 1) {
|
|
33
|
+
// we use classic 'for' loop because the size of the currentTasks array may change while executing some of the callbacks due to queueMicrotask calls
|
|
34
|
+
microtasksQueue[index]();
|
|
35
|
+
}
|
|
36
|
+
microtasksQueue = [];
|
|
37
|
+
global._maybeFlushUIUpdatesQueue();
|
|
38
|
+
} finally {
|
|
39
|
+
isExecutingMicrotasksQueue = false;
|
|
29
40
|
}
|
|
30
|
-
immediateCallbacks = [];
|
|
31
41
|
};
|
|
32
42
|
}
|
|
33
43
|
|
|
34
|
-
function
|
|
44
|
+
function callMicrotasksOnUIThread() {
|
|
35
45
|
'worklet';
|
|
36
|
-
global.
|
|
46
|
+
global.__callMicrotasks();
|
|
37
47
|
}
|
|
38
48
|
|
|
39
|
-
export const
|
|
49
|
+
export const callMicrotasks = shouldBeUseWeb()
|
|
40
50
|
? () => {
|
|
41
51
|
// on web flushing is a noop as immediates are handled by the browser
|
|
42
52
|
}
|
|
43
|
-
:
|
|
53
|
+
: callMicrotasksOnUIThread;
|
|
44
54
|
|
|
45
55
|
/**
|
|
46
56
|
* 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
|
|
57
|
+
* waits for other worklets to be scheduled within the same JS loop. It uses queueMicrotask to schedule all the worklets
|
|
48
58
|
* at once making sure they will run within the same frame boundaries on the UI thread.
|
|
49
59
|
*/
|
|
50
60
|
export function runOnUI<A extends any[], R>(
|
|
@@ -55,7 +65,7 @@ export function runOnUI<A extends any[], R>(
|
|
|
55
65
|
}
|
|
56
66
|
return (...args) => {
|
|
57
67
|
if (IS_JEST) {
|
|
58
|
-
// Mocking time in Jest is tricky as both requestAnimationFrame and
|
|
68
|
+
// Mocking time in Jest is tricky as both requestAnimationFrame and queueMicrotask
|
|
59
69
|
// callbacks run on the same queue and can be interleaved. There is no way
|
|
60
70
|
// to flush particular queue in Jest and the only control over mocked timers
|
|
61
71
|
// is by using jest.advanceTimersByTime() method which advances all types
|
|
@@ -72,9 +82,18 @@ export function runOnUI<A extends any[], R>(
|
|
|
72
82
|
);
|
|
73
83
|
return;
|
|
74
84
|
}
|
|
85
|
+
if (__DEV__) {
|
|
86
|
+
// in DEV mode we call shareable conversion here because in case the object
|
|
87
|
+
// can't be converted, we will get a meaningful stack-trace as opposed to the
|
|
88
|
+
// situation when conversion is only done via microtask queue. This does not
|
|
89
|
+
// make the app particularily less efficient as converted objects are cached
|
|
90
|
+
// and for a given worklet the conversion only happens once.
|
|
91
|
+
makeShareableCloneRecursive(worklet);
|
|
92
|
+
makeShareableCloneRecursive(args);
|
|
93
|
+
}
|
|
75
94
|
_runOnUIQueue.push([worklet, args]);
|
|
76
95
|
if (_runOnUIQueue.length === 1) {
|
|
77
|
-
|
|
96
|
+
queueMicrotask(() => {
|
|
78
97
|
const queue = _runOnUIQueue;
|
|
79
98
|
_runOnUIQueue = [];
|
|
80
99
|
NativeReanimatedModule.scheduleOnUI(
|
|
@@ -83,7 +102,7 @@ export function runOnUI<A extends any[], R>(
|
|
|
83
102
|
queue.forEach(([worklet, args]) => {
|
|
84
103
|
worklet(...args);
|
|
85
104
|
});
|
|
86
|
-
|
|
105
|
+
callMicrotasks();
|
|
87
106
|
})
|
|
88
107
|
);
|
|
89
108
|
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.checkVersion = checkVersion;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* We hardcode the version of Reanimated here in order to compare it
|
|
10
|
-
* with the version used to build the native part of the library in runtime.
|
|
11
|
-
* Remember to keep this in sync with the version declared in `package.json`
|
|
12
|
-
*/
|
|
13
|
-
const jsVersion = '3.0.2';
|
|
14
|
-
/**
|
|
15
|
-
* Checks that native and js versions of reanimated match.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
function checkVersion() {
|
|
19
|
-
const cppVersion = global._REANIMATED_VERSION_CPP;
|
|
20
|
-
|
|
21
|
-
if (cppVersion === undefined) {
|
|
22
|
-
console.error(`[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.`);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const ok = (() => {
|
|
27
|
-
if (jsVersion.match(/^\d+\.\d+\.\d+$/) && cppVersion.match(/^\d+\.\d+\.\d+$/)) {
|
|
28
|
-
// x.y.z, compare only major and minor, skip patch
|
|
29
|
-
const [jsMajor, jsMinor] = jsVersion.split('.');
|
|
30
|
-
const [cppMajor, cppMinor] = cppVersion.split('.');
|
|
31
|
-
return jsMajor === cppMajor && jsMinor === cppMinor;
|
|
32
|
-
} else {
|
|
33
|
-
// alpha, beta or rc, compare everything
|
|
34
|
-
return jsVersion === cppVersion;
|
|
35
|
-
}
|
|
36
|
-
})();
|
|
37
|
-
|
|
38
|
-
if (!ok) {
|
|
39
|
-
console.error(`[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.`); // TODO: detect Expo managed workflow
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=checkVersion.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["jsVersion","checkVersion","cppVersion","global","_REANIMATED_VERSION_CPP","undefined","console","error","ok","match","jsMajor","jsMinor","split","cppMajor","cppMinor"],"sources":["checkVersion.ts"],"sourcesContent":["/**\n * We hardcode the version of Reanimated here in order to compare it\n * with the version used to build the native part of the library in runtime.\n * Remember to keep this in sync with the version declared in `package.json`\n */\nconst jsVersion = '3.0.2';\n\n/**\n * Checks that native and js versions of reanimated match.\n */\nexport function checkVersion(): void {\n const cppVersion = global._REANIMATED_VERSION_CPP;\n if (cppVersion === undefined) {\n console.error(\n `[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.`\n );\n return;\n }\n const ok = (() => {\n if (\n jsVersion.match(/^\\d+\\.\\d+\\.\\d+$/) &&\n cppVersion.match(/^\\d+\\.\\d+\\.\\d+$/)\n ) {\n // x.y.z, compare only major and minor, skip patch\n const [jsMajor, jsMinor] = jsVersion.split('.');\n const [cppMajor, cppMinor] = cppVersion.split('.');\n return jsMajor === cppMajor && jsMinor === cppMinor;\n } else {\n // alpha, beta or rc, compare everything\n return jsVersion === cppVersion;\n }\n })();\n if (!ok) {\n console.error(\n `[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.`\n );\n // TODO: detect Expo managed workflow\n }\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA,MAAMA,SAAS,GAAG,OAAlB;AAEA;AACA;AACA;;AACO,SAASC,YAAT,GAA8B;EACnC,MAAMC,UAAU,GAAGC,MAAM,CAACC,uBAA1B;;EACA,IAAIF,UAAU,KAAKG,SAAnB,EAA8B;IAC5BC,OAAO,CAACC,KAAR,CACG,8OADH;IAGA;EACD;;EACD,MAAMC,EAAE,GAAG,CAAC,MAAM;IAChB,IACER,SAAS,CAACS,KAAV,CAAgB,iBAAhB,KACAP,UAAU,CAACO,KAAX,CAAiB,iBAAjB,CAFF,EAGE;MACA;MACA,MAAM,CAACC,OAAD,EAAUC,OAAV,IAAqBX,SAAS,CAACY,KAAV,CAAgB,GAAhB,CAA3B;MACA,MAAM,CAACC,QAAD,EAAWC,QAAX,IAAuBZ,UAAU,CAACU,KAAX,CAAiB,GAAjB,CAA7B;MACA,OAAOF,OAAO,KAAKG,QAAZ,IAAwBF,OAAO,KAAKG,QAA3C;IACD,CARD,MAQO;MACL;MACA,OAAOd,SAAS,KAAKE,UAArB;IACD;EACF,CAbU,GAAX;;EAcA,IAAI,CAACM,EAAL,EAAS;IACPF,OAAO,CAACC,KAAR,CACG,gFAA+EP,SAAU,QAAOE,UAAW,4HAA2HA,UAAW,kCADpP,EADO,CAIP;EACD;AACF"}
|
|
@@ -1,35 +0,0 @@
|
|
|
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.2';
|
|
7
|
-
/**
|
|
8
|
-
* Checks that native and js versions of reanimated match.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export function checkVersion() {
|
|
12
|
-
const cppVersion = global._REANIMATED_VERSION_CPP;
|
|
13
|
-
|
|
14
|
-
if (cppVersion === undefined) {
|
|
15
|
-
console.error(`[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
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const ok = (() => {
|
|
20
|
-
if (jsVersion.match(/^\d+\.\d+\.\d+$/) && cppVersion.match(/^\d+\.\d+\.\d+$/)) {
|
|
21
|
-
// x.y.z, compare only major and minor, skip patch
|
|
22
|
-
const [jsMajor, jsMinor] = jsVersion.split('.');
|
|
23
|
-
const [cppMajor, cppMinor] = cppVersion.split('.');
|
|
24
|
-
return jsMajor === cppMajor && jsMinor === cppMinor;
|
|
25
|
-
} else {
|
|
26
|
-
// alpha, beta or rc, compare everything
|
|
27
|
-
return jsVersion === cppVersion;
|
|
28
|
-
}
|
|
29
|
-
})();
|
|
30
|
-
|
|
31
|
-
if (!ok) {
|
|
32
|
-
console.error(`[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.`); // TODO: detect Expo managed workflow
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=checkVersion.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["jsVersion","checkVersion","cppVersion","global","_REANIMATED_VERSION_CPP","undefined","console","error","ok","match","jsMajor","jsMinor","split","cppMajor","cppMinor"],"sources":["checkVersion.ts"],"sourcesContent":["/**\n * We hardcode the version of Reanimated here in order to compare it\n * with the version used to build the native part of the library in runtime.\n * Remember to keep this in sync with the version declared in `package.json`\n */\nconst jsVersion = '3.0.2';\n\n/**\n * Checks that native and js versions of reanimated match.\n */\nexport function checkVersion(): void {\n const cppVersion = global._REANIMATED_VERSION_CPP;\n if (cppVersion === undefined) {\n console.error(\n `[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.`\n );\n return;\n }\n const ok = (() => {\n if (\n jsVersion.match(/^\\d+\\.\\d+\\.\\d+$/) &&\n cppVersion.match(/^\\d+\\.\\d+\\.\\d+$/)\n ) {\n // x.y.z, compare only major and minor, skip patch\n const [jsMajor, jsMinor] = jsVersion.split('.');\n const [cppMajor, cppMinor] = cppVersion.split('.');\n return jsMajor === cppMajor && jsMinor === cppMinor;\n } else {\n // alpha, beta or rc, compare everything\n return jsVersion === cppVersion;\n }\n })();\n if (!ok) {\n console.error(\n `[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.`\n );\n // TODO: detect Expo managed workflow\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,MAAMA,SAAS,GAAG,OAAlB;AAEA;AACA;AACA;;AACA,OAAO,SAASC,YAAT,GAA8B;EACnC,MAAMC,UAAU,GAAGC,MAAM,CAACC,uBAA1B;;EACA,IAAIF,UAAU,KAAKG,SAAnB,EAA8B;IAC5BC,OAAO,CAACC,KAAR,CACG,8OADH;IAGA;EACD;;EACD,MAAMC,EAAE,GAAG,CAAC,MAAM;IAChB,IACER,SAAS,CAACS,KAAV,CAAgB,iBAAhB,KACAP,UAAU,CAACO,KAAX,CAAiB,iBAAjB,CAFF,EAGE;MACA;MACA,MAAM,CAACC,OAAD,EAAUC,OAAV,IAAqBX,SAAS,CAACY,KAAV,CAAgB,GAAhB,CAA3B;MACA,MAAM,CAACC,QAAD,EAAWC,QAAX,IAAuBZ,UAAU,CAACU,KAAX,CAAiB,GAAjB,CAA7B;MACA,OAAOF,OAAO,KAAKG,QAAZ,IAAwBF,OAAO,KAAKG,QAA3C;IACD,CARD,MAQO;MACL;MACA,OAAOd,SAAS,KAAKE,UAArB;IACD;EACF,CAbU,GAAX;;EAcA,IAAI,CAACM,EAAL,EAAS;IACPF,OAAO,CAACC,KAAR,CACG,gFAA+EP,SAAU,QAAOE,UAAW,4HAA2HA,UAAW,kCADpP,EADO,CAIP;EACD;AACF"}
|
|
@@ -1,39 +0,0 @@
|
|
|
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.2';
|
|
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
|
-
}
|