react-native-reanimated 3.0.0-rc.9 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +30 -12
- package/Common/cpp/AnimatedSensor/AnimatedSensorModule.h +2 -0
- package/Common/cpp/Fabric/FabricUtils.cpp +3 -107
- package/Common/cpp/Fabric/FabricUtils.h +3 -24
- package/Common/cpp/Fabric/ReanimatedUIManagerBinding.cpp +54 -37
- package/Common/cpp/LayoutAnimations/LayoutAnimationType.h +8 -0
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +81 -26
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +20 -3
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +105 -109
- package/Common/cpp/NativeModules/NativeReanimatedModule.h +19 -12
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +15 -7
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +6 -2
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +20 -1
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +9 -0
- package/Common/cpp/ReanimatedRuntime/ReanimatedRuntime.cpp +5 -1
- package/Common/cpp/Registries/EventHandlerRegistry.cpp +8 -34
- package/Common/cpp/Registries/EventHandlerRegistry.h +7 -13
- package/Common/cpp/SharedItems/Shareables.cpp +9 -63
- package/Common/cpp/SharedItems/Shareables.h +77 -72
- package/Common/cpp/Tools/CollectionUtils.h +14 -0
- package/Common/cpp/Tools/JsiUtils.cpp +26 -0
- package/Common/cpp/Tools/JsiUtils.h +176 -0
- package/Common/cpp/Tools/PlatformDepMethodsHolder.h +5 -5
- package/Common/cpp/Tools/ReanimatedVersion.cpp +17 -0
- package/Common/cpp/Tools/ReanimatedVersion.h +11 -0
- package/Common/cpp/Tools/RuntimeDecorator.cpp +49 -230
- package/Common/cpp/Tools/RuntimeDecorator.h +0 -2
- package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -2
- package/Common/cpp/Tools/WorkletEventHandler.h +14 -6
- package/RNReanimated.podspec +2 -1
- package/android/CMakeLists.txt +188 -181
- package/android/build.gradle +362 -311
- package/android/proguard-rules.pro +2 -0
- package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +63 -295
- package/android/src/main/cpp/LayoutAnimations.cpp +35 -5
- package/android/src/main/cpp/LayoutAnimations.h +23 -6
- package/android/src/main/cpp/NativeProxy.cpp +143 -98
- package/android/src/main/cpp/NativeProxy.h +22 -28
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +5 -4
- package/android/src/main/java/com/swmansion/reanimated/Utils.java +7 -1
- package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +10 -3
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +218 -35
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +43 -17
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +6 -2
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedElement.java +19 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +610 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +93 -23
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/AnimationFrameCallback.java +19 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/EventHandler.java +35 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/KeyboardEventDataUpdater.java +16 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +206 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/SensorSetter.java +17 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +9 -3
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +3 -4
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -7
- package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +90 -307
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +16 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +63 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +271 -0
- package/android/src/reactNativeVersionPatch/nativeHierarchyManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +76 -20
- package/ios/LayoutReanimation/REAAnimationsManager.h +28 -4
- package/ios/LayoutReanimation/REAAnimationsManager.m +216 -61
- package/ios/LayoutReanimation/REAFrame.h +10 -0
- package/ios/LayoutReanimation/REAFrame.m +15 -0
- package/ios/LayoutReanimation/REAScreensHelper.h +19 -0
- package/ios/LayoutReanimation/REAScreensHelper.m +106 -0
- package/ios/LayoutReanimation/REASharedElement.h +15 -0
- package/ios/LayoutReanimation/REASharedElement.m +16 -0
- package/ios/LayoutReanimation/REASharedTransitionManager.h +17 -0
- package/ios/LayoutReanimation/REASharedTransitionManager.m +632 -0
- package/ios/LayoutReanimation/REASnapshot.h +1 -0
- package/ios/LayoutReanimation/REASnapshot.m +96 -11
- package/ios/LayoutReanimation/REAUIManager.mm +64 -17
- package/ios/REAModule.mm +2 -7
- package/ios/REANodesManager.mm +1 -21
- package/ios/keyboardObserver/REAKeyboardEventObserver.m +72 -36
- package/ios/native/NativeProxy.mm +75 -114
- package/ios/native/REAInitializer.mm +2 -7
- package/ios/native/REAJSIUtils.h +60 -2
- package/ios/sensor/ReanimatedSensor.h +6 -2
- package/ios/sensor/ReanimatedSensor.m +43 -7
- package/ios/sensor/ReanimatedSensorContainer.h +4 -1
- package/ios/sensor/ReanimatedSensorContainer.m +8 -2
- package/lib/commonjs/createAnimatedComponent.js +232 -28
- package/lib/commonjs/createAnimatedComponent.js.map +1 -1
- package/lib/commonjs/reanimated2/Colors.js +43 -22
- package/lib/commonjs/reanimated2/Colors.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +16 -33
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/util.js +17 -15
- package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
- package/lib/commonjs/reanimated2/commonTypes.js +33 -1
- package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/core.js +33 -14
- package/lib/commonjs/reanimated2/core.js.map +1 -1
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/index.js +0 -6
- package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +5 -2
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +13 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +89 -16
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +43 -40
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js +13 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +2 -2
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/utils.js +18 -65
- package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/index.js +13 -0
- package/lib/commonjs/reanimated2/index.js.map +1 -1
- package/lib/commonjs/reanimated2/initializers.js +71 -32
- package/lib/commonjs/reanimated2/initializers.js.map +1 -1
- package/lib/commonjs/reanimated2/interpolateColor.js +96 -19
- package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +103 -13
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +22 -0
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js +2 -0
- package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js.map +1 -0
- package/lib/commonjs/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/global.js +0 -2
- package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js +0 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +11 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +8 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +17 -9
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -14
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -14
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -15
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/index.js +13 -0
- package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +94 -0
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
- package/lib/commonjs/reanimated2/mappers.js +18 -6
- package/lib/commonjs/reanimated2/mappers.js.map +1 -1
- package/lib/commonjs/reanimated2/mock.js +20 -1
- package/lib/commonjs/reanimated2/mock.js.map +1 -1
- package/lib/commonjs/reanimated2/mutables.js +4 -2
- package/lib/commonjs/reanimated2/mutables.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +42 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +1 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +15 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
- package/lib/commonjs/reanimated2/pluginUtils.js +11 -0
- package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -0
- package/lib/commonjs/reanimated2/shareables.js +36 -15
- package/lib/commonjs/reanimated2/shareables.js.map +1 -1
- package/lib/commonjs/reanimated2/threads.js +114 -4
- package/lib/commonjs/reanimated2/threads.js.map +1 -1
- package/lib/commonjs/reanimated2/utils.js +7 -0
- package/lib/commonjs/reanimated2/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/valueSetter.js +1 -3
- package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
- package/lib/module/createAnimatedComponent.js +229 -29
- package/lib/module/createAnimatedComponent.js.map +1 -1
- package/lib/module/reanimated2/Colors.js +35 -19
- package/lib/module/reanimated2/Colors.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +16 -32
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +17 -16
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +29 -0
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/core.js +32 -7
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/module/reanimated2/globals.d.js.map +1 -1
- package/lib/module/reanimated2/hook/index.js +1 -1
- package/lib/module/reanimated2/hook/index.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +5 -2
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js +12 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js +88 -13
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +46 -43
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js +12 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js +2 -2
- package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js +17 -60
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/index.js +1 -0
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/initializers.js +72 -33
- package/lib/module/reanimated2/initializers.js.map +1 -1
- package/lib/module/reanimated2/interpolateColor.js +96 -19
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.js +1 -1
- package/lib/module/reanimated2/jestUtils.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js +103 -13
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/Mapper.js +21 -0
- package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/WebSensor.js +2 -0
- package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -0
- package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/global.js +0 -2
- package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js +0 -1
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +9 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js +1 -0
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js +15 -8
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -21
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -12
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -13
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -21
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/index.js +1 -0
- package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +82 -0
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
- package/lib/module/reanimated2/mappers.js +16 -6
- package/lib/module/reanimated2/mappers.js.map +1 -1
- package/lib/module/reanimated2/mock.js +20 -1
- package/lib/module/reanimated2/mock.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +4 -2
- package/lib/module/reanimated2/mutables.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/checkVersion.js +35 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.js.map +1 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js +8 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
- package/lib/module/reanimated2/pluginUtils.js +4 -0
- package/lib/module/reanimated2/pluginUtils.js.map +1 -0
- package/lib/module/reanimated2/shareables.js +36 -12
- package/lib/module/reanimated2/shareables.js.map +1 -1
- package/lib/module/reanimated2/threads.js +105 -4
- package/lib/module/reanimated2/threads.js.map +1 -1
- package/lib/module/reanimated2/utils.js +5 -0
- package/lib/module/reanimated2/utils.js.map +1 -1
- package/lib/module/reanimated2/valueSetter.js +1 -2
- package/lib/module/reanimated2/valueSetter.js.map +1 -1
- package/package.json +10 -10
- package/{plugin.js → plugin/index.js} +128 -249
- package/react-native-reanimated.d.ts +57 -10
- package/scripts/reanimated_utils.rb +15 -2
- package/src/createAnimatedComponent.tsx +238 -28
- package/src/reanimated2/Colors.ts +38 -11
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +52 -39
- package/src/reanimated2/animation/styleAnimation.ts +8 -1
- package/src/reanimated2/animation/util.ts +29 -16
- package/src/reanimated2/commonTypes.ts +28 -1
- package/src/reanimated2/core.ts +42 -9
- package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +2 -2
- package/src/reanimated2/globals.d.ts +12 -15
- package/src/reanimated2/hook/index.ts +1 -1
- package/src/reanimated2/hook/useAnimatedKeyboard.ts +10 -4
- package/src/reanimated2/hook/useAnimatedReaction.ts +12 -5
- package/src/reanimated2/hook/useAnimatedRef.ts +1 -4
- package/src/reanimated2/hook/useAnimatedSensor.ts +88 -11
- package/src/reanimated2/hook/useAnimatedStyle.ts +44 -36
- package/src/reanimated2/hook/useDerivedValue.ts +8 -1
- package/src/reanimated2/hook/useScrollViewOffset.ts +2 -2
- package/src/reanimated2/hook/utils.ts +15 -61
- package/src/reanimated2/index.ts +1 -0
- package/src/reanimated2/initializers.ts +76 -35
- package/src/reanimated2/interpolateColor.ts +104 -20
- package/src/reanimated2/jestUtils.ts +1 -1
- package/src/reanimated2/js-reanimated/JSReanimated.ts +98 -15
- package/src/reanimated2/js-reanimated/Mapper.ts +32 -0
- package/src/reanimated2/js-reanimated/WebSensor.ts +34 -0
- package/src/reanimated2/js-reanimated/commonTypes.ts +0 -1
- package/src/reanimated2/js-reanimated/global.ts +0 -1
- package/src/reanimated2/js-reanimated/index.ts +0 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +13 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/animationsManager.ts +17 -9
- package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +16 -19
- package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +14 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +21 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +36 -19
- package/src/reanimated2/layoutReanimation/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/sharedTransitions/index.ts +87 -0
- package/src/reanimated2/mappers.ts +17 -6
- package/src/reanimated2/mock.ts +24 -1
- package/src/reanimated2/mutables.ts +2 -0
- package/src/reanimated2/platform-specific/checkVersion.ts +39 -0
- package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
- package/src/reanimated2/pluginUtils.ts +8 -0
- package/src/reanimated2/shareables.ts +45 -16
- package/src/reanimated2/threads.ts +103 -1
- package/src/reanimated2/utils.ts +6 -0
- package/src/reanimated2/valueSetter.ts +1 -2
- package/lib/commonjs/reanimated2/time.js +0 -55
- package/lib/commonjs/reanimated2/time.js.map +0 -1
- package/lib/module/reanimated2/time.js +0 -37
- package/lib/module/reanimated2/time.js.map +0 -1
- package/src/reanimated2/time.ts +0 -30
- /package/android/src/{main/java → reactNativeVersionPatch/ReanimatedUIManager/70}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -0
|
@@ -11,24 +11,19 @@
|
|
|
11
11
|
|
|
12
12
|
#include "AndroidErrorHandler.h"
|
|
13
13
|
#include "AndroidScheduler.h"
|
|
14
|
+
#include "JsiUtils.h"
|
|
14
15
|
#include "LayoutAnimationsManager.h"
|
|
15
16
|
#include "NativeProxy.h"
|
|
16
17
|
#include "PlatformDepMethodsHolder.h"
|
|
17
18
|
#include "ReanimatedRuntime.h"
|
|
19
|
+
#include "ReanimatedVersion.h"
|
|
18
20
|
|
|
19
21
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
20
|
-
#include <JFabricUIManager.h>
|
|
21
22
|
#include "FabricUtils.h"
|
|
22
23
|
#include "NewestShadowNodesRegistry.h"
|
|
23
24
|
#include "ReanimatedUIManagerBinding.h"
|
|
24
25
|
#endif
|
|
25
26
|
|
|
26
|
-
#ifdef REANIMATED_VERSION
|
|
27
|
-
#define STRINGIZE(x) #x
|
|
28
|
-
#define STRINGIZE2(x) STRINGIZE(x)
|
|
29
|
-
#define REANIMATED_VERSION_STRING STRINGIZE2(REANIMATED_VERSION)
|
|
30
|
-
#endif // REANIMATED_VERSION
|
|
31
|
-
|
|
32
27
|
namespace reanimated {
|
|
33
28
|
|
|
34
29
|
using namespace facebook;
|
|
@@ -69,6 +64,11 @@ NativeProxy::NativeProxy(
|
|
|
69
64
|
NativeProxy::~NativeProxy() {
|
|
70
65
|
// removed temporary, new event listener mechanism need fix on the RN side
|
|
71
66
|
// reactScheduler_->removeEventListener(eventListener_);
|
|
67
|
+
|
|
68
|
+
// cleanup all animated sensors here, since NativeProxy
|
|
69
|
+
// has already been destroyed when AnimatedSensorModule's
|
|
70
|
+
// destructor is ran
|
|
71
|
+
_nativeReanimatedModule->cleanupSensors();
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
jni::local_ref<NativeProxy::jhybriddata> NativeProxy::initHybrid(
|
|
@@ -138,24 +138,9 @@ void NativeProxy::installJSIBindings(
|
|
|
138
138
|
return static_cast<double>(output);
|
|
139
139
|
};
|
|
140
140
|
|
|
141
|
-
auto requestRender = [this
|
|
141
|
+
auto requestRender = [this](
|
|
142
142
|
std::function<void(double)> onRender,
|
|
143
|
-
jsi::Runtime &rt) {
|
|
144
|
-
// doNoUse -> NodesManager passes here a timestamp from choreographer which
|
|
145
|
-
// is useless for us as we use diffrent timer to better handle events. The
|
|
146
|
-
// lambda is translated to NodeManager.OnAnimationFrame and treated just
|
|
147
|
-
// like reanimated 1 frame callbacks which make use of the timestamp.
|
|
148
|
-
auto wrappedOnRender = [getCurrentTime, &rt, onRender](double doNotUse) {
|
|
149
|
-
jsi::Object global = rt.global();
|
|
150
|
-
jsi::String frameTimestampName =
|
|
151
|
-
jsi::String::createFromAscii(rt, "_frameTimestamp");
|
|
152
|
-
double frameTimestamp = getCurrentTime();
|
|
153
|
-
global.setProperty(rt, frameTimestampName, frameTimestamp);
|
|
154
|
-
onRender(frameTimestamp);
|
|
155
|
-
global.setProperty(rt, frameTimestampName, jsi::Value::undefined());
|
|
156
|
-
};
|
|
157
|
-
this->requestRender(std::move(wrappedOnRender));
|
|
158
|
-
};
|
|
143
|
+
jsi::Runtime &rt) { this->requestRender(onRender); };
|
|
159
144
|
|
|
160
145
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
161
146
|
auto synchronouslyUpdateUIPropsFunction =
|
|
@@ -186,8 +171,11 @@ void NativeProxy::installJSIBindings(
|
|
|
186
171
|
#endif
|
|
187
172
|
|
|
188
173
|
auto registerSensorFunction =
|
|
189
|
-
[this](
|
|
190
|
-
|
|
174
|
+
[this](
|
|
175
|
+
int sensorType,
|
|
176
|
+
int interval,
|
|
177
|
+
int iosReferenceFrame,
|
|
178
|
+
std::function<void(double[], int)> setter) -> int {
|
|
191
179
|
return this->registerSensor(sensorType, interval, std::move(setter));
|
|
192
180
|
};
|
|
193
181
|
auto unregisterSensorFunction = [this](int sensorId) {
|
|
@@ -199,8 +187,11 @@ void NativeProxy::installJSIBindings(
|
|
|
199
187
|
};
|
|
200
188
|
|
|
201
189
|
auto subscribeForKeyboardEventsFunction =
|
|
202
|
-
[this](
|
|
203
|
-
|
|
190
|
+
[this](
|
|
191
|
+
std::function<void(int, int)> keyboardEventDataUpdater,
|
|
192
|
+
bool isStatusBarTranslucent) -> int {
|
|
193
|
+
return subscribeForKeyboardEvents(
|
|
194
|
+
std::move(keyboardEventDataUpdater), isStatusBarTranslucent);
|
|
204
195
|
};
|
|
205
196
|
|
|
206
197
|
auto unsubscribeFromKeyboardEventsFunction = [this](int listenerId) -> void {
|
|
@@ -211,39 +202,39 @@ void NativeProxy::installJSIBindings(
|
|
|
211
202
|
std::shared_ptr<jsi::Runtime> animatedRuntime =
|
|
212
203
|
ReanimatedRuntime::make(runtime_, jsQueue);
|
|
213
204
|
|
|
205
|
+
auto &rt = *runtime_;
|
|
206
|
+
|
|
214
207
|
auto workletRuntimeValue =
|
|
215
|
-
|
|
216
|
-
.
|
|
217
|
-
.
|
|
218
|
-
.
|
|
219
|
-
.callAsConstructor(*runtime_, {static_cast<double>(sizeof(void *))});
|
|
208
|
+
rt.global()
|
|
209
|
+
.getPropertyAsObject(rt, "ArrayBuffer")
|
|
210
|
+
.asFunction(rt)
|
|
211
|
+
.callAsConstructor(rt, {static_cast<double>(sizeof(void *))});
|
|
220
212
|
uintptr_t *workletRuntimeData = reinterpret_cast<uintptr_t *>(
|
|
221
|
-
workletRuntimeValue.getObject(
|
|
222
|
-
*runtime_));
|
|
213
|
+
workletRuntimeValue.getObject(rt).getArrayBuffer(rt).data(rt));
|
|
223
214
|
workletRuntimeData[0] = reinterpret_cast<uintptr_t>(animatedRuntime.get());
|
|
224
215
|
|
|
225
|
-
|
|
226
|
-
*runtime_, "_WORKLET_RUNTIME", workletRuntimeValue);
|
|
216
|
+
rt.global().setProperty(rt, "_WORKLET_RUNTIME", workletRuntimeValue);
|
|
227
217
|
|
|
228
218
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
229
|
-
|
|
219
|
+
rt.global().setProperty(rt, "_IS_FABRIC", true);
|
|
230
220
|
#else
|
|
231
|
-
|
|
221
|
+
rt.global().setProperty(rt, "_IS_FABRIC", false);
|
|
232
222
|
#endif
|
|
233
223
|
|
|
234
|
-
auto version =
|
|
235
|
-
|
|
236
|
-
runtime_->global().setProperty(*runtime_, "_REANIMATED_VERSION_CPP", version);
|
|
224
|
+
auto version = getReanimatedVersionString(rt);
|
|
225
|
+
rt.global().setProperty(rt, "_REANIMATED_VERSION_CPP", version);
|
|
237
226
|
|
|
238
227
|
std::shared_ptr<ErrorHandler> errorHandler =
|
|
239
228
|
std::make_shared<AndroidErrorHandler>(scheduler_);
|
|
240
229
|
std::weak_ptr<jsi::Runtime> wrt = animatedRuntime;
|
|
241
230
|
|
|
242
|
-
auto progressLayoutAnimation =
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
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
|
+
};
|
|
247
238
|
|
|
248
239
|
auto endLayoutAnimation = [this](int tag, bool isCancelled, bool removeView) {
|
|
249
240
|
this->layoutAnimations->cthis()->endLayoutAnimation(
|
|
@@ -287,40 +278,43 @@ void NativeProxy::installJSIBindings(
|
|
|
287
278
|
_nativeReanimatedModule = module;
|
|
288
279
|
std::weak_ptr<NativeReanimatedModule> weakModule = module;
|
|
289
280
|
|
|
290
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
291
281
|
this->registerEventHandler([weakModule, getCurrentTime](
|
|
292
|
-
|
|
293
|
-
|
|
282
|
+
jni::alias_ref<JString> eventKey,
|
|
283
|
+
jni::alias_ref<react::WritableMap> event) {
|
|
284
|
+
// handles RCTEvents from RNGestureHandler
|
|
294
285
|
if (auto module = weakModule.lock()) {
|
|
295
|
-
|
|
286
|
+
auto eventName = eventKey->toString();
|
|
296
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
|
+
}
|
|
297
299
|
std::string eventJSON = eventAsString.substr(
|
|
298
300
|
13, eventAsString.length() - 15); // removes "{ NativeMap: " and " }"
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
// TODO: support NaN and INF values
|
|
303
|
-
// TODO: convert event directly to jsi::Value without JSON serialization
|
|
301
|
+
if (eventJSON == "null") {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
304
|
|
|
305
|
-
module->
|
|
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());
|
|
306
316
|
}
|
|
307
317
|
});
|
|
308
|
-
#else
|
|
309
|
-
this->registerEventHandler(
|
|
310
|
-
[weakModule, getCurrentTime](
|
|
311
|
-
std::string eventName, std::string eventAsString) {
|
|
312
|
-
if (auto module = weakModule.lock()) {
|
|
313
|
-
jsi::Object global = module->runtime->global();
|
|
314
|
-
jsi::String eventTimestampName =
|
|
315
|
-
jsi::String::createFromAscii(*module->runtime, "_eventTimestamp");
|
|
316
|
-
global.setProperty(
|
|
317
|
-
*module->runtime, eventTimestampName, getCurrentTime());
|
|
318
|
-
module->onEvent(eventName, eventAsString);
|
|
319
|
-
global.setProperty(
|
|
320
|
-
*module->runtime, eventTimestampName, jsi::Value::undefined());
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
#endif
|
|
324
318
|
|
|
325
319
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
326
320
|
Binding *binding = fabricUIManager->getBinding();
|
|
@@ -342,17 +336,23 @@ void NativeProxy::installJSIBindings(
|
|
|
342
336
|
|
|
343
337
|
layoutAnimations->cthis()->setAnimationStartingBlock(
|
|
344
338
|
[wrt, weakModule, weakErrorHandler](
|
|
345
|
-
int tag,
|
|
346
|
-
alias_ref<JString> type,
|
|
347
|
-
alias_ref<JMap<jstring, jstring>> values) {
|
|
339
|
+
int tag, int type, alias_ref<JMap<jstring, jstring>> values) {
|
|
348
340
|
auto &rt = *wrt.lock();
|
|
349
341
|
jsi::Object yogaValues(rt);
|
|
350
342
|
for (const auto &entry : *values) {
|
|
351
343
|
try {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
auto
|
|
355
|
-
|
|
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
356
|
} catch (std::invalid_argument e) {
|
|
357
357
|
if (auto errorHandler = weakErrorHandler.lock()) {
|
|
358
358
|
errorHandler->setError("Failed to convert value to number");
|
|
@@ -361,26 +361,66 @@ void NativeProxy::installJSIBindings(
|
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
-
weakModule.lock()
|
|
365
|
-
|
|
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);
|
|
366
371
|
});
|
|
367
372
|
|
|
368
373
|
layoutAnimations->cthis()->setHasAnimationBlock(
|
|
369
|
-
[weakModule](int tag,
|
|
370
|
-
|
|
371
|
-
|
|
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));
|
|
372
382
|
});
|
|
373
383
|
|
|
374
384
|
layoutAnimations->cthis()->setClearAnimationConfigBlock(
|
|
375
385
|
[weakModule](int tag) {
|
|
376
|
-
weakModule.lock()
|
|
377
|
-
|
|
386
|
+
auto reaModule = weakModule.lock();
|
|
387
|
+
if (reaModule == nullptr) {
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
reaModule->layoutAnimationsManager().clearLayoutAnimationConfig(tag);
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
layoutAnimations->cthis()->setCancelAnimationForTag(
|
|
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
|
+
}
|
|
378
418
|
});
|
|
379
419
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
jsi::PropNameID::forAscii(
|
|
383
|
-
jsi::Object::createFromHostObject(
|
|
420
|
+
rt.global().setProperty(
|
|
421
|
+
rt,
|
|
422
|
+
jsi::PropNameID::forAscii(rt, "__reanimatedModuleProxy"),
|
|
423
|
+
jsi::Object::createFromHostObject(rt, module));
|
|
384
424
|
}
|
|
385
425
|
|
|
386
426
|
bool NativeProxy::isAnyHandlerWaitingForEvent(std::string s) {
|
|
@@ -414,7 +454,9 @@ void NativeProxy::requestRender(std::function<void(double)> onRender) {
|
|
|
414
454
|
}
|
|
415
455
|
|
|
416
456
|
void NativeProxy::registerEventHandler(
|
|
417
|
-
std::function<
|
|
457
|
+
std::function<
|
|
458
|
+
void(jni::alias_ref<JString>, jni::alias_ref<react::WritableMap>)>
|
|
459
|
+
handler) {
|
|
418
460
|
static auto method =
|
|
419
461
|
javaPart_->getClass()->getMethod<void(EventHandler::javaobject)>(
|
|
420
462
|
"registerEventHandler");
|
|
@@ -488,7 +530,7 @@ void NativeProxy::synchronouslyUpdateUIProps(
|
|
|
488
530
|
int NativeProxy::registerSensor(
|
|
489
531
|
int sensorType,
|
|
490
532
|
int interval,
|
|
491
|
-
std::function<void(double[])> setter) {
|
|
533
|
+
std::function<void(double[], int)> setter) {
|
|
492
534
|
static auto method =
|
|
493
535
|
javaPart_->getClass()->getMethod<int(int, int, SensorSetter::javaobject)>(
|
|
494
536
|
"registerSensor");
|
|
@@ -527,15 +569,18 @@ void NativeProxy::configureProps(
|
|
|
527
569
|
}
|
|
528
570
|
|
|
529
571
|
int NativeProxy::subscribeForKeyboardEvents(
|
|
530
|
-
std::function<void(int, int)> keyboardEventDataUpdater
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
572
|
+
std::function<void(int, int)> keyboardEventDataUpdater,
|
|
573
|
+
bool isStatusBarTranslucent) {
|
|
574
|
+
auto method =
|
|
575
|
+
javaPart_->getClass()
|
|
576
|
+
->getMethod<int(KeyboardEventDataUpdater::javaobject, bool)>(
|
|
577
|
+
"subscribeForKeyboardEvents");
|
|
534
578
|
return method(
|
|
535
579
|
javaPart_.get(),
|
|
536
580
|
KeyboardEventDataUpdater::newObjectCxxArgs(
|
|
537
581
|
std::move(keyboardEventDataUpdater))
|
|
538
|
-
.get()
|
|
582
|
+
.get(),
|
|
583
|
+
isStatusBarTranslucent);
|
|
539
584
|
}
|
|
540
585
|
|
|
541
586
|
void NativeProxy::unsubscribeFromKeyboardEvents(int listenerId) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
4
|
-
#include <JFabricUIManager.h>
|
|
4
|
+
#include <react/fabric/JFabricUIManager.h>
|
|
5
5
|
#endif
|
|
6
6
|
|
|
7
7
|
#include <ReactCommon/CallInvokerHolder.h>
|
|
@@ -32,7 +32,7 @@ using namespace facebook::jni;
|
|
|
32
32
|
class AnimationFrameCallback : public HybridClass<AnimationFrameCallback> {
|
|
33
33
|
public:
|
|
34
34
|
static auto constexpr kJavaDescriptor =
|
|
35
|
-
"Lcom/swmansion/reanimated/
|
|
35
|
+
"Lcom/swmansion/reanimated/nativeProxy/AnimationFrameCallback;";
|
|
36
36
|
|
|
37
37
|
void onAnimationFrame(double timestampMs) {
|
|
38
38
|
callback_(timestampMs);
|
|
@@ -57,24 +57,12 @@ class AnimationFrameCallback : public HybridClass<AnimationFrameCallback> {
|
|
|
57
57
|
class EventHandler : public HybridClass<EventHandler> {
|
|
58
58
|
public:
|
|
59
59
|
static auto constexpr kJavaDescriptor =
|
|
60
|
-
"Lcom/swmansion/reanimated/
|
|
60
|
+
"Lcom/swmansion/reanimated/nativeProxy/EventHandler;";
|
|
61
61
|
|
|
62
62
|
void receiveEvent(
|
|
63
63
|
jni::alias_ref<JString> eventKey,
|
|
64
64
|
jni::alias_ref<react::WritableMap> event) {
|
|
65
|
-
|
|
66
|
-
if (event != nullptr) {
|
|
67
|
-
try {
|
|
68
|
-
eventAsString = event->toString();
|
|
69
|
-
} catch (std::exception &) {
|
|
70
|
-
// Events from other libraries may contain NaN or INF values which
|
|
71
|
-
// cannot be represented in JSON. See
|
|
72
|
-
// https://github.com/software-mansion/react-native-reanimated/issues/1776
|
|
73
|
-
// for details.
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
handler_(eventKey->toString(), eventAsString);
|
|
65
|
+
handler_(eventKey, event);
|
|
78
66
|
}
|
|
79
67
|
|
|
80
68
|
static void registerNatives() {
|
|
@@ -86,25 +74,29 @@ class EventHandler : public HybridClass<EventHandler> {
|
|
|
86
74
|
private:
|
|
87
75
|
friend HybridBase;
|
|
88
76
|
|
|
89
|
-
explicit EventHandler(std::function<void(
|
|
77
|
+
explicit EventHandler(std::function<void(
|
|
78
|
+
jni::alias_ref<JString>,
|
|
79
|
+
jni::alias_ref<react::WritableMap>)> handler)
|
|
90
80
|
: handler_(std::move(handler)) {}
|
|
91
81
|
|
|
92
|
-
std::function<
|
|
82
|
+
std::function<
|
|
83
|
+
void(jni::alias_ref<JString>, jni::alias_ref<react::WritableMap>)>
|
|
84
|
+
handler_;
|
|
93
85
|
};
|
|
94
86
|
|
|
95
87
|
class SensorSetter : public HybridClass<SensorSetter> {
|
|
96
88
|
public:
|
|
97
89
|
static auto constexpr kJavaDescriptor =
|
|
98
|
-
"Lcom/swmansion/reanimated/
|
|
90
|
+
"Lcom/swmansion/reanimated/nativeProxy/SensorSetter;";
|
|
99
91
|
|
|
100
|
-
void sensorSetter(jni::alias_ref<JArrayFloat> value) {
|
|
92
|
+
void sensorSetter(jni::alias_ref<JArrayFloat> value, int orientationDegrees) {
|
|
101
93
|
size_t size = value->size();
|
|
102
94
|
auto elements = value->getRegion(0, size);
|
|
103
95
|
double array[7];
|
|
104
96
|
for (int i = 0; i < size; i++) {
|
|
105
97
|
array[i] = elements[i];
|
|
106
98
|
}
|
|
107
|
-
callback_(array);
|
|
99
|
+
callback_(array, orientationDegrees);
|
|
108
100
|
}
|
|
109
101
|
|
|
110
102
|
static void registerNatives() {
|
|
@@ -116,16 +108,16 @@ class SensorSetter : public HybridClass<SensorSetter> {
|
|
|
116
108
|
private:
|
|
117
109
|
friend HybridBase;
|
|
118
110
|
|
|
119
|
-
explicit SensorSetter(std::function<void(double[])> callback)
|
|
111
|
+
explicit SensorSetter(std::function<void(double[], int)> callback)
|
|
120
112
|
: callback_(std::move(callback)) {}
|
|
121
113
|
|
|
122
|
-
std::function<void(double[])> callback_;
|
|
114
|
+
std::function<void(double[], int)> callback_;
|
|
123
115
|
};
|
|
124
116
|
|
|
125
117
|
class KeyboardEventDataUpdater : public HybridClass<KeyboardEventDataUpdater> {
|
|
126
118
|
public:
|
|
127
119
|
static auto constexpr kJavaDescriptor =
|
|
128
|
-
"Lcom/swmansion/reanimated/
|
|
120
|
+
"Lcom/swmansion/reanimated/nativeProxy/KeyboardEventDataUpdater;";
|
|
129
121
|
|
|
130
122
|
void keyboardEventDataUpdater(int keyboardState, int height) {
|
|
131
123
|
callback_(keyboardState, height);
|
|
@@ -199,20 +191,22 @@ class NativeProxy : public jni::HybridClass<NativeProxy> {
|
|
|
199
191
|
bool isAnyHandlerWaitingForEvent(std::string);
|
|
200
192
|
void performOperations();
|
|
201
193
|
void requestRender(std::function<void(double)> onRender);
|
|
202
|
-
void registerEventHandler(
|
|
203
|
-
|
|
194
|
+
void registerEventHandler(std::function<void(
|
|
195
|
+
jni::alias_ref<JString>,
|
|
196
|
+
jni::alias_ref<react::WritableMap>)> handler);
|
|
204
197
|
void setGestureState(int handlerTag, int newState);
|
|
205
198
|
int registerSensor(
|
|
206
199
|
int sensorType,
|
|
207
200
|
int interval,
|
|
208
|
-
std::function<void(double[])> setter);
|
|
201
|
+
std::function<void(double[], int)> setter);
|
|
209
202
|
void unregisterSensor(int sensorId);
|
|
210
203
|
void configureProps(
|
|
211
204
|
jsi::Runtime &rt,
|
|
212
205
|
const jsi::Value &uiProps,
|
|
213
206
|
const jsi::Value &nativeProps);
|
|
214
207
|
int subscribeForKeyboardEvents(
|
|
215
|
-
std::function<void(int, int)> keyboardEventDataUpdater
|
|
208
|
+
std::function<void(int, int)> keyboardEventDataUpdater,
|
|
209
|
+
bool isStatusBarTranslucent);
|
|
216
210
|
void unsubscribeFromKeyboardEvents(int listenerId);
|
|
217
211
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
218
212
|
// nothing
|
|
@@ -16,8 +16,10 @@ import com.facebook.react.module.model.ReactModuleInfoProvider;
|
|
|
16
16
|
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
|
17
17
|
import com.facebook.react.uimanager.ReanimatedUIManager;
|
|
18
18
|
import com.facebook.react.uimanager.UIManagerModule;
|
|
19
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
19
20
|
import com.facebook.systrace.Systrace;
|
|
20
21
|
import java.util.HashMap;
|
|
22
|
+
import java.util.List;
|
|
21
23
|
import java.util.Map;
|
|
22
24
|
|
|
23
25
|
public class ReanimatedPackage extends TurboReactPackage implements ReactPackage {
|
|
@@ -68,12 +70,11 @@ public class ReanimatedPackage extends TurboReactPackage implements ReactPackage
|
|
|
68
70
|
ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_START);
|
|
69
71
|
Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "createUIManagerModule");
|
|
70
72
|
final ReactInstanceManager reactInstanceManager = getReactInstanceManager(reactContext);
|
|
73
|
+
List<ViewManager> viewManagers = reactInstanceManager.getOrCreateViewManagers(reactContext);
|
|
71
74
|
int minTimeLeftInFrameForNonBatchedOperationMs = -1;
|
|
72
75
|
try {
|
|
73
|
-
return
|
|
74
|
-
reactContext,
|
|
75
|
-
reactInstanceManager.getOrCreateViewManagers(reactContext),
|
|
76
|
-
minTimeLeftInFrameForNonBatchedOperationMs);
|
|
76
|
+
return ReanimatedUIManagerFactory.create(
|
|
77
|
+
reactContext, viewManagers, minTimeLeftInFrameForNonBatchedOperationMs);
|
|
77
78
|
} finally {
|
|
78
79
|
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
|
|
79
80
|
ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_END);
|
|
@@ -8,7 +8,7 @@ import java.util.Map;
|
|
|
8
8
|
|
|
9
9
|
public class Utils {
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
public static boolean isChromeDebugger = false;
|
|
12
12
|
|
|
13
13
|
public static Map<String, Integer> processMapping(ReadableMap style) {
|
|
14
14
|
ReadableMapKeySetIterator iter = style.keySetIterator();
|
|
@@ -29,4 +29,10 @@ public class Utils {
|
|
|
29
29
|
}
|
|
30
30
|
return res;
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
public static String simplifyStringNumbersList(String list) {
|
|
34
|
+
// transforms string: '[1, 2, 3]' -> '1 2 3'
|
|
35
|
+
// to make usage of std::istringstream in C++ easier
|
|
36
|
+
return list.replace(",", "").replace("[", "").replace("]", "");
|
|
37
|
+
}
|
|
32
38
|
}
|
|
@@ -12,7 +12,7 @@ import androidx.core.view.WindowInsetsCompat;
|
|
|
12
12
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
13
13
|
import com.facebook.react.uimanager.PixelUtil;
|
|
14
14
|
import com.swmansion.reanimated.BuildConfig;
|
|
15
|
-
import com.swmansion.reanimated.
|
|
15
|
+
import com.swmansion.reanimated.nativeProxy.KeyboardEventDataUpdater;
|
|
16
16
|
import java.lang.ref.WeakReference;
|
|
17
17
|
import java.util.HashMap;
|
|
18
18
|
import java.util.List;
|
|
@@ -40,6 +40,7 @@ public class ReanimatedKeyboardEventListener {
|
|
|
40
40
|
private int nextListenerId = 0;
|
|
41
41
|
private KeyboardState state;
|
|
42
42
|
private final HashMap<Integer, KeyboardEventDataUpdater> listeners = new HashMap<>();
|
|
43
|
+
private boolean isStatusBarTranslucent = false;
|
|
43
44
|
|
|
44
45
|
public ReanimatedKeyboardEventListener(WeakReference<ReactApplicationContext> reactContext) {
|
|
45
46
|
this.reactContext = reactContext;
|
|
@@ -68,7 +69,11 @@ public class ReanimatedKeyboardEventListener {
|
|
|
68
69
|
FrameLayout.LayoutParams params =
|
|
69
70
|
new FrameLayout.LayoutParams(
|
|
70
71
|
FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
|
|
71
|
-
|
|
72
|
+
if (isStatusBarTranslucent) {
|
|
73
|
+
params.setMargins(0, 0, 0, 0);
|
|
74
|
+
} else {
|
|
75
|
+
params.setMargins(0, paddingTop, 0, paddingBottom);
|
|
76
|
+
}
|
|
72
77
|
content.setLayoutParams(params);
|
|
73
78
|
return insets;
|
|
74
79
|
});
|
|
@@ -127,9 +132,11 @@ public class ReanimatedKeyboardEventListener {
|
|
|
127
132
|
ViewCompat.setWindowInsetsAnimationCallback(rootView, new WindowInsetsCallback());
|
|
128
133
|
}
|
|
129
134
|
|
|
130
|
-
public int subscribeForKeyboardEvents(
|
|
135
|
+
public int subscribeForKeyboardEvents(
|
|
136
|
+
KeyboardEventDataUpdater updater, boolean isStatusBarTranslucent) {
|
|
131
137
|
int listenerId = nextListenerId++;
|
|
132
138
|
if (listeners.isEmpty()) {
|
|
139
|
+
this.isStatusBarTranslucent = isStatusBarTranslucent;
|
|
133
140
|
setUpCallbacks();
|
|
134
141
|
}
|
|
135
142
|
listeners.put(listenerId, updater);
|