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
|
@@ -44,7 +44,7 @@ NativeProxy::NativeProxy(
|
|
|
44
44
|
: javaPart_(jni::make_global(jThis)),
|
|
45
45
|
runtime_(rt),
|
|
46
46
|
jsCallInvoker_(jsCallInvoker),
|
|
47
|
-
|
|
47
|
+
layoutAnimations_(std::move(_layoutAnimations)),
|
|
48
48
|
scheduler_(scheduler)
|
|
49
49
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
50
50
|
,
|
|
@@ -68,7 +68,7 @@ NativeProxy::~NativeProxy() {
|
|
|
68
68
|
// cleanup all animated sensors here, since NativeProxy
|
|
69
69
|
// has already been destroyed when AnimatedSensorModule's
|
|
70
70
|
// destructor is ran
|
|
71
|
-
|
|
71
|
+
nativeReanimatedModule_->cleanupSensors();
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
jni::local_ref<NativeProxy::jhybriddata> NativeProxy::initHybrid(
|
|
@@ -108,158 +108,12 @@ void NativeProxy::installJSIBindings(
|
|
|
108
108
|
fabricUIManager
|
|
109
109
|
#endif
|
|
110
110
|
/**/) {
|
|
111
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
112
|
-
// nothing
|
|
113
|
-
#else
|
|
114
|
-
auto updatePropsFunction = [this](
|
|
115
|
-
jsi::Runtime &rt,
|
|
116
|
-
int viewTag,
|
|
117
|
-
const jsi::Value &viewName,
|
|
118
|
-
const jsi::Object &props) {
|
|
119
|
-
// viewName is for iOS only, we skip it here
|
|
120
|
-
this->updateProps(rt, viewTag, props);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
auto measureFunction =
|
|
124
|
-
[this](int viewTag) -> std::vector<std::pair<std::string, double>> {
|
|
125
|
-
return measure(viewTag);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
auto scrollToFunction =
|
|
129
|
-
[this](int viewTag, double x, double y, bool animated) -> void {
|
|
130
|
-
scrollTo(viewTag, x, y, animated);
|
|
131
|
-
};
|
|
132
|
-
#endif
|
|
133
|
-
|
|
134
|
-
auto getCurrentTime = [this]() {
|
|
135
|
-
static const auto method =
|
|
136
|
-
javaPart_->getClass()->getMethod<jlong()>("getCurrentTime");
|
|
137
|
-
jlong output = method(javaPart_.get());
|
|
138
|
-
return static_cast<double>(output);
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
auto requestRender = [this](
|
|
142
|
-
std::function<void(double)> onRender,
|
|
143
|
-
jsi::Runtime &rt) { this->requestRender(onRender); };
|
|
144
|
-
|
|
145
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
146
|
-
auto synchronouslyUpdateUIPropsFunction =
|
|
147
|
-
[this](jsi::Runtime &rt, Tag tag, const jsi::Value &props) {
|
|
148
|
-
this->synchronouslyUpdateUIProps(rt, tag, props);
|
|
149
|
-
};
|
|
150
|
-
#else
|
|
151
|
-
auto propObtainer = [this](
|
|
152
|
-
jsi::Runtime &rt,
|
|
153
|
-
const int viewTag,
|
|
154
|
-
const jsi::String &propName) -> jsi::Value {
|
|
155
|
-
auto method =
|
|
156
|
-
javaPart_->getClass()
|
|
157
|
-
->getMethod<jni::local_ref<JString>(int, jni::local_ref<JString>)>(
|
|
158
|
-
"obtainProp");
|
|
159
|
-
local_ref<JString> propNameJStr =
|
|
160
|
-
jni::make_jstring(propName.utf8(rt).c_str());
|
|
161
|
-
auto result = method(javaPart_.get(), viewTag, propNameJStr);
|
|
162
|
-
std::string str = result->toStdString();
|
|
163
|
-
return jsi::Value(rt, jsi::String::createFromAscii(rt, str.c_str()));
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
auto configurePropsFunction = [=](jsi::Runtime &rt,
|
|
167
|
-
const jsi::Value &uiProps,
|
|
168
|
-
const jsi::Value &nativeProps) {
|
|
169
|
-
this->configureProps(rt, uiProps, nativeProps);
|
|
170
|
-
};
|
|
171
|
-
#endif
|
|
172
|
-
|
|
173
|
-
auto registerSensorFunction =
|
|
174
|
-
[this](
|
|
175
|
-
int sensorType,
|
|
176
|
-
int interval,
|
|
177
|
-
int iosReferenceFrame,
|
|
178
|
-
std::function<void(double[], int)> setter) -> int {
|
|
179
|
-
return this->registerSensor(sensorType, interval, std::move(setter));
|
|
180
|
-
};
|
|
181
|
-
auto unregisterSensorFunction = [this](int sensorId) {
|
|
182
|
-
unregisterSensor(sensorId);
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
auto setGestureStateFunction = [this](int handlerTag, int newState) -> void {
|
|
186
|
-
setGestureState(handlerTag, newState);
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
auto subscribeForKeyboardEventsFunction =
|
|
190
|
-
[this](
|
|
191
|
-
std::function<void(int, int)> keyboardEventDataUpdater,
|
|
192
|
-
bool isStatusBarTranslucent) -> int {
|
|
193
|
-
return subscribeForKeyboardEvents(
|
|
194
|
-
std::move(keyboardEventDataUpdater), isStatusBarTranslucent);
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
auto unsubscribeFromKeyboardEventsFunction = [this](int listenerId) -> void {
|
|
198
|
-
unsubscribeFromKeyboardEvents(listenerId);
|
|
199
|
-
};
|
|
200
|
-
|
|
201
111
|
auto jsQueue = std::make_shared<JMessageQueueThread>(messageQueueThread);
|
|
202
112
|
std::shared_ptr<jsi::Runtime> animatedRuntime =
|
|
203
113
|
ReanimatedRuntime::make(runtime_, jsQueue);
|
|
204
114
|
|
|
205
|
-
auto &rt = *runtime_;
|
|
206
|
-
|
|
207
|
-
auto workletRuntimeValue =
|
|
208
|
-
rt.global()
|
|
209
|
-
.getPropertyAsObject(rt, "ArrayBuffer")
|
|
210
|
-
.asFunction(rt)
|
|
211
|
-
.callAsConstructor(rt, {static_cast<double>(sizeof(void *))});
|
|
212
|
-
uintptr_t *workletRuntimeData = reinterpret_cast<uintptr_t *>(
|
|
213
|
-
workletRuntimeValue.getObject(rt).getArrayBuffer(rt).data(rt));
|
|
214
|
-
workletRuntimeData[0] = reinterpret_cast<uintptr_t>(animatedRuntime.get());
|
|
215
|
-
|
|
216
|
-
rt.global().setProperty(rt, "_WORKLET_RUNTIME", workletRuntimeValue);
|
|
217
|
-
|
|
218
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
219
|
-
rt.global().setProperty(rt, "_IS_FABRIC", true);
|
|
220
|
-
#else
|
|
221
|
-
rt.global().setProperty(rt, "_IS_FABRIC", false);
|
|
222
|
-
#endif
|
|
223
|
-
|
|
224
|
-
auto version = getReanimatedVersionString(rt);
|
|
225
|
-
rt.global().setProperty(rt, "_REANIMATED_VERSION_CPP", version);
|
|
226
|
-
|
|
227
115
|
std::shared_ptr<ErrorHandler> errorHandler =
|
|
228
116
|
std::make_shared<AndroidErrorHandler>(scheduler_);
|
|
229
|
-
std::weak_ptr<jsi::Runtime> wrt = animatedRuntime;
|
|
230
|
-
|
|
231
|
-
auto progressLayoutAnimation =
|
|
232
|
-
[this, wrt](
|
|
233
|
-
int tag, const jsi::Object &newProps, bool isSharedTransition) {
|
|
234
|
-
auto newPropsJNI = JNIHelper::ConvertToPropsMap(*wrt.lock(), newProps);
|
|
235
|
-
this->layoutAnimations->cthis()->progressLayoutAnimation(
|
|
236
|
-
tag, newPropsJNI, isSharedTransition);
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
auto endLayoutAnimation = [this](int tag, bool isCancelled, bool removeView) {
|
|
240
|
-
this->layoutAnimations->cthis()->endLayoutAnimation(
|
|
241
|
-
tag, isCancelled, removeView);
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
PlatformDepMethodsHolder platformDepMethodsHolder = {
|
|
245
|
-
requestRender,
|
|
246
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
247
|
-
synchronouslyUpdateUIPropsFunction,
|
|
248
|
-
#else
|
|
249
|
-
updatePropsFunction,
|
|
250
|
-
scrollToFunction,
|
|
251
|
-
measureFunction,
|
|
252
|
-
configurePropsFunction,
|
|
253
|
-
#endif
|
|
254
|
-
getCurrentTime,
|
|
255
|
-
progressLayoutAnimation,
|
|
256
|
-
endLayoutAnimation,
|
|
257
|
-
registerSensorFunction,
|
|
258
|
-
unregisterSensorFunction,
|
|
259
|
-
setGestureStateFunction,
|
|
260
|
-
subscribeForKeyboardEventsFunction,
|
|
261
|
-
unsubscribeFromKeyboardEventsFunction,
|
|
262
|
-
};
|
|
263
117
|
|
|
264
118
|
auto module = std::make_shared<NativeReanimatedModule>(
|
|
265
119
|
jsCallInvoker_,
|
|
@@ -269,52 +123,12 @@ void NativeProxy::installJSIBindings(
|
|
|
269
123
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
270
124
|
// nothing
|
|
271
125
|
#else
|
|
272
|
-
|
|
126
|
+
bindThis(&NativeProxy::obtainProp),
|
|
273
127
|
#endif
|
|
274
|
-
|
|
128
|
+
getPlatformDependentMethods());
|
|
275
129
|
|
|
276
130
|
scheduler_->setRuntimeManager(module);
|
|
277
|
-
|
|
278
|
-
_nativeReanimatedModule = module;
|
|
279
|
-
std::weak_ptr<NativeReanimatedModule> weakModule = module;
|
|
280
|
-
|
|
281
|
-
this->registerEventHandler([weakModule, getCurrentTime](
|
|
282
|
-
jni::alias_ref<JString> eventKey,
|
|
283
|
-
jni::alias_ref<react::WritableMap> event) {
|
|
284
|
-
// handles RCTEvents from RNGestureHandler
|
|
285
|
-
if (auto module = weakModule.lock()) {
|
|
286
|
-
auto eventName = eventKey->toString();
|
|
287
|
-
|
|
288
|
-
// TODO: convert event directly to jsi::Value without JSON serialization
|
|
289
|
-
std::string eventAsString;
|
|
290
|
-
try {
|
|
291
|
-
eventAsString = event->toString();
|
|
292
|
-
} catch (std::exception &) {
|
|
293
|
-
// Events from other libraries may contain NaN or INF values which
|
|
294
|
-
// cannot be represented in JSON. See
|
|
295
|
-
// https://github.com/software-mansion/react-native-reanimated/issues/1776
|
|
296
|
-
// for details.
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
std::string eventJSON = eventAsString.substr(
|
|
300
|
-
13, eventAsString.length() - 15); // removes "{ NativeMap: " and " }"
|
|
301
|
-
if (eventJSON == "null") {
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
jsi::Runtime &rt = *module->runtime;
|
|
306
|
-
jsi::Value payload;
|
|
307
|
-
try {
|
|
308
|
-
payload = jsi::Value::createFromJsonUtf8(
|
|
309
|
-
rt, reinterpret_cast<uint8_t *>(&eventJSON[0]), eventJSON.size());
|
|
310
|
-
} catch (std::exception &) {
|
|
311
|
-
// Ignore events with malformed JSON payload.
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
module->handleEvent(eventName, payload, getCurrentTime());
|
|
316
|
-
}
|
|
317
|
-
});
|
|
131
|
+
nativeReanimatedModule_ = module;
|
|
318
132
|
|
|
319
133
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
320
134
|
Binding *binding = fabricUIManager->getBinding();
|
|
@@ -323,99 +137,19 @@ void NativeProxy::installJSIBindings(
|
|
|
323
137
|
module->setUIManager(uiManager);
|
|
324
138
|
module->setNewestShadowNodesRegistry(newestShadowNodesRegistry_);
|
|
325
139
|
newestShadowNodesRegistry_ = nullptr;
|
|
140
|
+
// removed temporary, new event listener mechanism need fix on the RN side
|
|
141
|
+
// eventListener_ = std::make_shared<EventListener>(
|
|
142
|
+
// [module, getCurrentTime](const RawEvent &rawEvent) {
|
|
143
|
+
// return module->handleRawEvent(rawEvent, getCurrentTime());
|
|
144
|
+
// });
|
|
145
|
+
// reactScheduler_ = binding->getScheduler();
|
|
146
|
+
// reactScheduler_->addEventListener(eventListener_);
|
|
326
147
|
#endif
|
|
327
|
-
// removed temporary, new event listener mechanism need fix on the RN side
|
|
328
|
-
// eventListener_ = std::make_shared<EventListener>(
|
|
329
|
-
// [module, getCurrentTime](const RawEvent &rawEvent) {
|
|
330
|
-
// return module->handleRawEvent(rawEvent, getCurrentTime());
|
|
331
|
-
// });
|
|
332
|
-
// reactScheduler_ = binding->getScheduler();
|
|
333
|
-
// reactScheduler_->addEventListener(eventListener_);
|
|
334
|
-
|
|
335
|
-
std::weak_ptr<ErrorHandler> weakErrorHandler = errorHandler;
|
|
336
|
-
|
|
337
|
-
layoutAnimations->cthis()->setAnimationStartingBlock(
|
|
338
|
-
[wrt, weakModule, weakErrorHandler](
|
|
339
|
-
int tag, int type, alias_ref<JMap<jstring, jstring>> values) {
|
|
340
|
-
auto &rt = *wrt.lock();
|
|
341
|
-
jsi::Object yogaValues(rt);
|
|
342
|
-
for (const auto &entry : *values) {
|
|
343
|
-
try {
|
|
344
|
-
std::string keyString = entry.first->toStdString();
|
|
345
|
-
std::string valueString = entry.second->toStdString();
|
|
346
|
-
auto key = jsi::String::createFromAscii(rt, keyString);
|
|
347
|
-
if (keyString == "currentTransformMatrix" ||
|
|
348
|
-
keyString == "targetTransformMatrix") {
|
|
349
|
-
jsi::Array matrix =
|
|
350
|
-
jsi_utils::convertStringToArray(rt, valueString, 9);
|
|
351
|
-
yogaValues.setProperty(rt, key, matrix);
|
|
352
|
-
} else {
|
|
353
|
-
auto value = stod(valueString);
|
|
354
|
-
yogaValues.setProperty(rt, key, value);
|
|
355
|
-
}
|
|
356
|
-
} catch (std::invalid_argument e) {
|
|
357
|
-
if (auto errorHandler = weakErrorHandler.lock()) {
|
|
358
|
-
errorHandler->setError("Failed to convert value to number");
|
|
359
|
-
errorHandler->raise();
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
auto reaModule = weakModule.lock();
|
|
365
|
-
if (reaModule == nullptr) {
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
reaModule->layoutAnimationsManager().startLayoutAnimation(
|
|
370
|
-
rt, tag, static_cast<LayoutAnimationType>(type), yogaValues);
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
layoutAnimations->cthis()->setHasAnimationBlock(
|
|
374
|
-
[weakModule](int tag, int type) {
|
|
375
|
-
auto reaModule = weakModule.lock();
|
|
376
|
-
if (reaModule == nullptr) {
|
|
377
|
-
return false;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
return reaModule->layoutAnimationsManager().hasLayoutAnimation(
|
|
381
|
-
tag, static_cast<LayoutAnimationType>(type));
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
layoutAnimations->cthis()->setClearAnimationConfigBlock(
|
|
385
|
-
[weakModule](int tag) {
|
|
386
|
-
auto reaModule = weakModule.lock();
|
|
387
|
-
if (reaModule == nullptr) {
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
148
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
[wrt, weakModule](
|
|
396
|
-
int tag, int type, jboolean cancelled, jboolean removeView) {
|
|
397
|
-
if (auto reaModule = weakModule.lock()) {
|
|
398
|
-
if (auto runtime = wrt.lock()) {
|
|
399
|
-
jsi::Runtime &rt = *runtime;
|
|
400
|
-
reaModule->layoutAnimationsManager().cancelLayoutAnimation(
|
|
401
|
-
rt,
|
|
402
|
-
tag,
|
|
403
|
-
static_cast<LayoutAnimationType>(type),
|
|
404
|
-
cancelled,
|
|
405
|
-
removeView);
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
|
-
|
|
410
|
-
layoutAnimations->cthis()->setFindPrecedingViewTagForTransition(
|
|
411
|
-
[weakModule](int tag) {
|
|
412
|
-
if (auto module = weakModule.lock()) {
|
|
413
|
-
return module->layoutAnimationsManager()
|
|
414
|
-
.findPrecedingViewTagForTransition(tag);
|
|
415
|
-
} else {
|
|
416
|
-
return -1;
|
|
417
|
-
}
|
|
418
|
-
});
|
|
149
|
+
auto &rt = *runtime_;
|
|
150
|
+
setGlobalProperties(rt, animatedRuntime);
|
|
151
|
+
registerEventHandler();
|
|
152
|
+
setupLayoutAnimations();
|
|
419
153
|
|
|
420
154
|
rt.global().setProperty(
|
|
421
155
|
rt,
|
|
@@ -424,12 +158,12 @@ void NativeProxy::installJSIBindings(
|
|
|
424
158
|
}
|
|
425
159
|
|
|
426
160
|
bool NativeProxy::isAnyHandlerWaitingForEvent(std::string s) {
|
|
427
|
-
return
|
|
161
|
+
return nativeReanimatedModule_->isAnyHandlerWaitingForEvent(s);
|
|
428
162
|
}
|
|
429
163
|
|
|
430
164
|
void NativeProxy::performOperations() {
|
|
431
165
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
432
|
-
|
|
166
|
+
nativeReanimatedModule_->performOperations();
|
|
433
167
|
#endif
|
|
434
168
|
}
|
|
435
169
|
|
|
@@ -443,52 +177,84 @@ void NativeProxy::registerNatives() {
|
|
|
443
177
|
makeNativeMethod("performOperations", NativeProxy::performOperations)});
|
|
444
178
|
}
|
|
445
179
|
|
|
446
|
-
void NativeProxy::requestRender(
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
180
|
+
void NativeProxy::requestRender(
|
|
181
|
+
std::function<void(double)> onRender,
|
|
182
|
+
jsi::Runtime &rt) {
|
|
183
|
+
static const auto method =
|
|
184
|
+
getJniMethod<void(AnimationFrameCallback::javaobject)>("requestRender");
|
|
451
185
|
method(
|
|
452
186
|
javaPart_.get(),
|
|
453
187
|
AnimationFrameCallback::newObjectCxxArgs(std::move(onRender)).get());
|
|
454
188
|
}
|
|
455
189
|
|
|
456
|
-
void NativeProxy::registerEventHandler(
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
static auto method =
|
|
461
|
-
javaPart_->getClass()->getMethod<void(EventHandler::javaobject)>(
|
|
462
|
-
"registerEventHandler");
|
|
190
|
+
void NativeProxy::registerEventHandler() {
|
|
191
|
+
auto eventHandler = bindThis(&NativeProxy::handleEvent);
|
|
192
|
+
static const auto method =
|
|
193
|
+
getJniMethod<void(EventHandler::javaobject)>("registerEventHandler");
|
|
463
194
|
method(
|
|
464
195
|
javaPart_.get(),
|
|
465
|
-
EventHandler::newObjectCxxArgs(std::move(
|
|
196
|
+
EventHandler::newObjectCxxArgs(std::move(eventHandler)).get());
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
void NativeProxy::maybeFlushUIUpdatesQueue() {
|
|
200
|
+
static const auto method = getJniMethod<void()>("maybeFlushUIUpdatesQueue");
|
|
201
|
+
method(javaPart_.get());
|
|
466
202
|
}
|
|
467
203
|
|
|
468
204
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
469
205
|
// nothing
|
|
470
206
|
#else
|
|
207
|
+
jsi::Value NativeProxy::obtainProp(
|
|
208
|
+
jsi::Runtime &rt,
|
|
209
|
+
const int viewTag,
|
|
210
|
+
const jsi::String &propName) {
|
|
211
|
+
static const auto method =
|
|
212
|
+
getJniMethod<jni::local_ref<JString>(int, jni::local_ref<JString>)>(
|
|
213
|
+
"obtainProp");
|
|
214
|
+
local_ref<JString> propNameJStr =
|
|
215
|
+
jni::make_jstring(propName.utf8(rt).c_str());
|
|
216
|
+
auto result = method(javaPart_.get(), viewTag, propNameJStr);
|
|
217
|
+
std::string str = result->toStdString();
|
|
218
|
+
return jsi::Value(rt, jsi::String::createFromAscii(rt, str));
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
void NativeProxy::configureProps(
|
|
222
|
+
jsi::Runtime &rt,
|
|
223
|
+
const jsi::Value &uiProps,
|
|
224
|
+
const jsi::Value &nativeProps) {
|
|
225
|
+
static const auto method = getJniMethod<void(
|
|
226
|
+
ReadableNativeArray::javaobject, ReadableNativeArray::javaobject)>(
|
|
227
|
+
"configureProps");
|
|
228
|
+
method(
|
|
229
|
+
javaPart_.get(),
|
|
230
|
+
ReadableNativeArray::newObjectCxxArgs(jsi::dynamicFromValue(rt, uiProps))
|
|
231
|
+
.get(),
|
|
232
|
+
ReadableNativeArray::newObjectCxxArgs(
|
|
233
|
+
jsi::dynamicFromValue(rt, nativeProps))
|
|
234
|
+
.get());
|
|
235
|
+
}
|
|
236
|
+
|
|
471
237
|
void NativeProxy::updateProps(
|
|
472
238
|
jsi::Runtime &rt,
|
|
473
239
|
int viewTag,
|
|
240
|
+
const jsi::Value &viewName,
|
|
474
241
|
const jsi::Object &props) {
|
|
475
|
-
auto method =
|
|
476
|
-
|
|
477
|
-
|
|
242
|
+
static const auto method =
|
|
243
|
+
getJniMethod<void(int, JMap<JString, JObject>::javaobject)>(
|
|
244
|
+
"updateProps");
|
|
478
245
|
method(
|
|
479
246
|
javaPart_.get(), viewTag, JNIHelper::ConvertToPropsMap(rt, props).get());
|
|
480
247
|
}
|
|
481
248
|
|
|
482
249
|
void NativeProxy::scrollTo(int viewTag, double x, double y, bool animated) {
|
|
483
|
-
auto method =
|
|
484
|
-
|
|
485
|
-
"scrollTo");
|
|
250
|
+
static const auto method =
|
|
251
|
+
getJniMethod<void(int, double, double, bool)>("scrollTo");
|
|
486
252
|
method(javaPart_.get(), viewTag, x, y, animated);
|
|
487
253
|
}
|
|
488
254
|
|
|
489
255
|
std::vector<std::pair<std::string, double>> NativeProxy::measure(int viewTag) {
|
|
490
|
-
auto method =
|
|
491
|
-
|
|
256
|
+
static const auto method =
|
|
257
|
+
getJniMethod<local_ref<JArrayFloat>(int)>("measure");
|
|
492
258
|
local_ref<JArrayFloat> output = method(javaPart_.get(), viewTag);
|
|
493
259
|
size_t size = output->size();
|
|
494
260
|
auto elements = output->getRegion(0, size);
|
|
@@ -518,9 +284,8 @@ void NativeProxy::synchronouslyUpdateUIProps(
|
|
|
518
284
|
Tag tag,
|
|
519
285
|
const jsi::Value &props) {
|
|
520
286
|
static const auto method =
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
"synchronouslyUpdateUIProps");
|
|
287
|
+
getJniMethod<void(int, jni::local_ref<ReadableMap::javaobject>)>(
|
|
288
|
+
"synchronouslyUpdateUIProps");
|
|
524
289
|
jni::local_ref<ReadableMap::javaobject> uiProps = castReadableMap(
|
|
525
290
|
ReadableNativeMap::newObjectCxxArgs(jsi::dynamicFromValue(rt, props)));
|
|
526
291
|
method(javaPart_.get(), tag, uiProps);
|
|
@@ -530,10 +295,10 @@ void NativeProxy::synchronouslyUpdateUIProps(
|
|
|
530
295
|
int NativeProxy::registerSensor(
|
|
531
296
|
int sensorType,
|
|
532
297
|
int interval,
|
|
298
|
+
int iosReferenceFrame,
|
|
533
299
|
std::function<void(double[], int)> setter) {
|
|
534
|
-
static auto method =
|
|
535
|
-
|
|
536
|
-
"registerSensor");
|
|
300
|
+
static const auto method =
|
|
301
|
+
getJniMethod<int(int, int, SensorSetter::javaobject)>("registerSensor");
|
|
537
302
|
return method(
|
|
538
303
|
javaPart_.get(),
|
|
539
304
|
sensorType,
|
|
@@ -541,40 +306,21 @@ int NativeProxy::registerSensor(
|
|
|
541
306
|
SensorSetter::newObjectCxxArgs(std::move(setter)).get());
|
|
542
307
|
}
|
|
543
308
|
void NativeProxy::unregisterSensor(int sensorId) {
|
|
544
|
-
auto method =
|
|
309
|
+
static const auto method = getJniMethod<void(int)>("unregisterSensor");
|
|
545
310
|
method(javaPart_.get(), sensorId);
|
|
546
311
|
}
|
|
547
312
|
|
|
548
313
|
void NativeProxy::setGestureState(int handlerTag, int newState) {
|
|
549
|
-
auto method =
|
|
550
|
-
javaPart_->getClass()->getMethod<void(int, int)>("setGestureState");
|
|
314
|
+
static const auto method = getJniMethod<void(int, int)>("setGestureState");
|
|
551
315
|
method(javaPart_.get(), handlerTag, newState);
|
|
552
316
|
}
|
|
553
317
|
|
|
554
|
-
void NativeProxy::configureProps(
|
|
555
|
-
jsi::Runtime &rt,
|
|
556
|
-
const jsi::Value &uiProps,
|
|
557
|
-
const jsi::Value &nativeProps) {
|
|
558
|
-
auto method = javaPart_->getClass()
|
|
559
|
-
->getMethod<void(
|
|
560
|
-
ReadableNativeArray::javaobject,
|
|
561
|
-
ReadableNativeArray::javaobject)>("configureProps");
|
|
562
|
-
method(
|
|
563
|
-
javaPart_.get(),
|
|
564
|
-
ReadableNativeArray::newObjectCxxArgs(jsi::dynamicFromValue(rt, uiProps))
|
|
565
|
-
.get(),
|
|
566
|
-
ReadableNativeArray::newObjectCxxArgs(
|
|
567
|
-
jsi::dynamicFromValue(rt, nativeProps))
|
|
568
|
-
.get());
|
|
569
|
-
}
|
|
570
|
-
|
|
571
318
|
int NativeProxy::subscribeForKeyboardEvents(
|
|
572
319
|
std::function<void(int, int)> keyboardEventDataUpdater,
|
|
573
320
|
bool isStatusBarTranslucent) {
|
|
574
|
-
auto method =
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
"subscribeForKeyboardEvents");
|
|
321
|
+
static const auto method =
|
|
322
|
+
getJniMethod<int(KeyboardEventDataUpdater::javaobject, bool)>(
|
|
323
|
+
"subscribeForKeyboardEvents");
|
|
578
324
|
return method(
|
|
579
325
|
javaPart_.get(),
|
|
580
326
|
KeyboardEventDataUpdater::newObjectCxxArgs(
|
|
@@ -584,9 +330,242 @@ int NativeProxy::subscribeForKeyboardEvents(
|
|
|
584
330
|
}
|
|
585
331
|
|
|
586
332
|
void NativeProxy::unsubscribeFromKeyboardEvents(int listenerId) {
|
|
587
|
-
auto method =
|
|
588
|
-
"unsubscribeFromKeyboardEvents");
|
|
333
|
+
static const auto method =
|
|
334
|
+
getJniMethod<void(int)>("unsubscribeFromKeyboardEvents");
|
|
589
335
|
method(javaPart_.get(), listenerId);
|
|
590
336
|
}
|
|
591
337
|
|
|
338
|
+
double NativeProxy::getCurrentTime() {
|
|
339
|
+
static const auto method = getJniMethod<jlong()>("getCurrentTime");
|
|
340
|
+
jlong output = method(javaPart_.get());
|
|
341
|
+
return static_cast<double>(output);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
void NativeProxy::handleEvent(
|
|
345
|
+
jni::alias_ref<JString> eventKey,
|
|
346
|
+
jni::alias_ref<react::WritableMap> event) {
|
|
347
|
+
// handles RCTEvents from RNGestureHandler
|
|
348
|
+
auto eventName = eventKey->toString();
|
|
349
|
+
|
|
350
|
+
// TODO: convert event directly to jsi::Value without JSON serialization
|
|
351
|
+
std::string eventAsString;
|
|
352
|
+
try {
|
|
353
|
+
eventAsString = event->toString();
|
|
354
|
+
} catch (std::exception &) {
|
|
355
|
+
// Events from other libraries may contain NaN or INF values which
|
|
356
|
+
// cannot be represented in JSON. See
|
|
357
|
+
// https://github.com/software-mansion/react-native-reanimated/issues/1776
|
|
358
|
+
// for details.
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
#if REACT_NATIVE_MINOR_VERSION >= 72
|
|
362
|
+
std::string eventJSON = eventAsString;
|
|
363
|
+
#else
|
|
364
|
+
// remove "{ NativeMap: " and " }"
|
|
365
|
+
std::string eventJSON = eventAsString.substr(13, eventAsString.length() - 15);
|
|
366
|
+
#endif
|
|
367
|
+
if (eventJSON == "null") {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
jsi::Runtime &rt = *nativeReanimatedModule_->runtime;
|
|
372
|
+
jsi::Value payload;
|
|
373
|
+
try {
|
|
374
|
+
payload = jsi::Value::createFromJsonUtf8(
|
|
375
|
+
rt, reinterpret_cast<uint8_t *>(&eventJSON[0]), eventJSON.size());
|
|
376
|
+
} catch (std::exception &) {
|
|
377
|
+
// Ignore events with malformed JSON payload.
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
nativeReanimatedModule_->handleEvent(
|
|
382
|
+
eventName, payload, this->getCurrentTime());
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
void NativeProxy::progressLayoutAnimation(
|
|
386
|
+
int tag,
|
|
387
|
+
const jsi::Object &newProps,
|
|
388
|
+
bool isSharedTransition) {
|
|
389
|
+
auto &rt = *nativeReanimatedModule_->runtime;
|
|
390
|
+
auto newPropsJNI = JNIHelper::ConvertToPropsMap(rt, newProps);
|
|
391
|
+
layoutAnimations_->cthis()->progressLayoutAnimation(
|
|
392
|
+
tag, newPropsJNI, isSharedTransition);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
PlatformDepMethodsHolder NativeProxy::getPlatformDependentMethods() {
|
|
396
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
397
|
+
// nothing
|
|
398
|
+
#else
|
|
399
|
+
auto updatePropsFunction = bindThis(&NativeProxy::updateProps);
|
|
400
|
+
|
|
401
|
+
auto measureFunction = bindThis(&NativeProxy::measure);
|
|
402
|
+
|
|
403
|
+
auto scrollToFunction = bindThis(&NativeProxy::scrollTo);
|
|
404
|
+
#endif
|
|
405
|
+
|
|
406
|
+
auto getCurrentTime = bindThis(&NativeProxy::getCurrentTime);
|
|
407
|
+
|
|
408
|
+
auto requestRender = bindThis(&NativeProxy::requestRender);
|
|
409
|
+
|
|
410
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
411
|
+
auto synchronouslyUpdateUIPropsFunction =
|
|
412
|
+
bindThis(&NativeProxy::synchronouslyUpdateUIProps);
|
|
413
|
+
#else
|
|
414
|
+
auto configurePropsFunction = bindThis(&NativeProxy::configureProps);
|
|
415
|
+
#endif
|
|
416
|
+
|
|
417
|
+
auto registerSensorFunction = bindThis(&NativeProxy::registerSensor);
|
|
418
|
+
auto unregisterSensorFunction = bindThis(&NativeProxy::unregisterSensor);
|
|
419
|
+
|
|
420
|
+
auto setGestureStateFunction = bindThis(&NativeProxy::setGestureState);
|
|
421
|
+
|
|
422
|
+
auto subscribeForKeyboardEventsFunction =
|
|
423
|
+
bindThis(&NativeProxy::subscribeForKeyboardEvents);
|
|
424
|
+
|
|
425
|
+
auto unsubscribeFromKeyboardEventsFunction =
|
|
426
|
+
bindThis(&NativeProxy::unsubscribeFromKeyboardEvents);
|
|
427
|
+
|
|
428
|
+
auto progressLayoutAnimation =
|
|
429
|
+
bindThis(&NativeProxy::progressLayoutAnimation);
|
|
430
|
+
|
|
431
|
+
auto endLayoutAnimation = [this](int tag, bool isCancelled, bool removeView) {
|
|
432
|
+
this->layoutAnimations_->cthis()->endLayoutAnimation(
|
|
433
|
+
tag, isCancelled, removeView);
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
auto maybeFlushUiUpdatesQueueFunction =
|
|
437
|
+
bindThis(&NativeProxy::maybeFlushUIUpdatesQueue);
|
|
438
|
+
|
|
439
|
+
return {
|
|
440
|
+
requestRender,
|
|
441
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
442
|
+
synchronouslyUpdateUIPropsFunction,
|
|
443
|
+
#else
|
|
444
|
+
updatePropsFunction,
|
|
445
|
+
scrollToFunction,
|
|
446
|
+
measureFunction,
|
|
447
|
+
configurePropsFunction,
|
|
448
|
+
#endif
|
|
449
|
+
getCurrentTime,
|
|
450
|
+
progressLayoutAnimation,
|
|
451
|
+
endLayoutAnimation,
|
|
452
|
+
registerSensorFunction,
|
|
453
|
+
unregisterSensorFunction,
|
|
454
|
+
setGestureStateFunction,
|
|
455
|
+
subscribeForKeyboardEventsFunction,
|
|
456
|
+
unsubscribeFromKeyboardEventsFunction,
|
|
457
|
+
maybeFlushUiUpdatesQueueFunction,
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
void NativeProxy::setGlobalProperties(
|
|
462
|
+
jsi::Runtime &jsRuntime,
|
|
463
|
+
const std::shared_ptr<jsi::Runtime> &reanimatedRuntime) {
|
|
464
|
+
auto workletRuntimeValue =
|
|
465
|
+
jsRuntime.global()
|
|
466
|
+
.getPropertyAsObject(jsRuntime, "ArrayBuffer")
|
|
467
|
+
.asFunction(jsRuntime)
|
|
468
|
+
.callAsConstructor(jsRuntime, {static_cast<double>(sizeof(void *))});
|
|
469
|
+
uintptr_t *workletRuntimeData = reinterpret_cast<uintptr_t *>(
|
|
470
|
+
workletRuntimeValue.getObject(jsRuntime).getArrayBuffer(jsRuntime).data(
|
|
471
|
+
jsRuntime));
|
|
472
|
+
workletRuntimeData[0] = reinterpret_cast<uintptr_t>(reanimatedRuntime.get());
|
|
473
|
+
|
|
474
|
+
jsRuntime.global().setProperty(
|
|
475
|
+
jsRuntime, "_WORKLET_RUNTIME", workletRuntimeValue);
|
|
476
|
+
|
|
477
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
478
|
+
jsRuntime.global().setProperty(jsRuntime, "_IS_FABRIC", true);
|
|
479
|
+
#else
|
|
480
|
+
jsRuntime.global().setProperty(jsRuntime, "_IS_FABRIC", false);
|
|
481
|
+
#endif
|
|
482
|
+
|
|
483
|
+
auto version = getReanimatedVersionString(jsRuntime);
|
|
484
|
+
jsRuntime.global().setProperty(jsRuntime, "_REANIMATED_VERSION_CPP", version);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
void NativeProxy::setupLayoutAnimations() {
|
|
488
|
+
auto weakModule =
|
|
489
|
+
std::weak_ptr<NativeReanimatedModule>(nativeReanimatedModule_);
|
|
490
|
+
|
|
491
|
+
layoutAnimations_->cthis()->setAnimationStartingBlock(
|
|
492
|
+
[weakModule](
|
|
493
|
+
int tag, int type, alias_ref<JMap<jstring, jstring>> values) {
|
|
494
|
+
auto module = weakModule.lock();
|
|
495
|
+
if (module == nullptr) {
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
auto &rt = *module->runtime;
|
|
499
|
+
auto errorHandler = module->errorHandler;
|
|
500
|
+
|
|
501
|
+
jsi::Object yogaValues(rt);
|
|
502
|
+
for (const auto &entry : *values) {
|
|
503
|
+
try {
|
|
504
|
+
std::string keyString = entry.first->toStdString();
|
|
505
|
+
std::string valueString = entry.second->toStdString();
|
|
506
|
+
auto key = jsi::String::createFromAscii(rt, keyString);
|
|
507
|
+
if (keyString == "currentTransformMatrix" ||
|
|
508
|
+
keyString == "targetTransformMatrix") {
|
|
509
|
+
jsi::Array matrix =
|
|
510
|
+
jsi_utils::convertStringToArray(rt, valueString, 9);
|
|
511
|
+
yogaValues.setProperty(rt, key, matrix);
|
|
512
|
+
} else {
|
|
513
|
+
auto value = stod(valueString);
|
|
514
|
+
yogaValues.setProperty(rt, key, value);
|
|
515
|
+
}
|
|
516
|
+
} catch (std::invalid_argument e) {
|
|
517
|
+
errorHandler->setError("Failed to convert value to number");
|
|
518
|
+
errorHandler->raise();
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
module->layoutAnimationsManager().startLayoutAnimation(
|
|
523
|
+
rt, tag, static_cast<LayoutAnimationType>(type), yogaValues);
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
layoutAnimations_->cthis()->setHasAnimationBlock(
|
|
527
|
+
[weakModule](int tag, int type) {
|
|
528
|
+
auto module = weakModule.lock();
|
|
529
|
+
if (module == nullptr) {
|
|
530
|
+
return false;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
return module->layoutAnimationsManager().hasLayoutAnimation(
|
|
534
|
+
tag, static_cast<LayoutAnimationType>(type));
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
layoutAnimations_->cthis()->setClearAnimationConfigBlock(
|
|
538
|
+
[weakModule](int tag) {
|
|
539
|
+
auto module = weakModule.lock();
|
|
540
|
+
if (module == nullptr) {
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
module->layoutAnimationsManager().clearLayoutAnimationConfig(tag);
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
layoutAnimations_->cthis()->setCancelAnimationForTag(
|
|
548
|
+
[weakModule](int tag, int type, jboolean cancelled, jboolean removeView) {
|
|
549
|
+
if (auto module = weakModule.lock()) {
|
|
550
|
+
jsi::Runtime &rt = *module->runtime;
|
|
551
|
+
module->layoutAnimationsManager().cancelLayoutAnimation(
|
|
552
|
+
rt,
|
|
553
|
+
tag,
|
|
554
|
+
static_cast<LayoutAnimationType>(type),
|
|
555
|
+
cancelled,
|
|
556
|
+
removeView);
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
layoutAnimations_->cthis()->setFindPrecedingViewTagForTransition(
|
|
561
|
+
[weakModule](int tag) {
|
|
562
|
+
if (auto module = weakModule.lock()) {
|
|
563
|
+
return module->layoutAnimationsManager()
|
|
564
|
+
.findPrecedingViewTagForTransition(tag);
|
|
565
|
+
} else {
|
|
566
|
+
return -1;
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
|
|
592
571
|
} // namespace reanimated
|