From a9f847e17069c8206f6a24ed93ef457cbf4ba2a3 Mon Sep 17 00:00:00 2001 From: lukmccall Date: Tue, 18 Oct 2022 16:55:03 +0200 Subject: [PATCH 1/4] [iOS][Android] Update reanimated to `2.11.0` --- CHANGELOG.md | 1 + android/expoview/CMakeLists.txt | 184 --- android/expoview/build.gradle | 467 -------- .../uimanager/UIManagerReanimatedHelper.java | 14 - .../java/host/exp/exponent/kernel/Kernel.kt | 7 - .../host/exp/exponent/ExpoTurboPackage.kt | 2 +- .../host/exp/exponent/VersionedUtils.kt | 17 - .../api/reanimated/AndroidErrorHandler.java | 8 - .../api/reanimated/nodes/FinalNode.java | 5 - .../android/build.gradle | 6 +- .../AnimatedSensor/AnimatedSensorModule.cpp | 11 +- .../AnimatedSensor/AnimatedSensorModule.h | 0 .../LayoutAnimationsProxy.cpp | 2 + .../LayoutAnimations/LayoutAnimationsProxy.h | 0 .../NativeModules/NativeReanimatedModule.cpp | 40 + .../NativeModules/NativeReanimatedModule.h | 13 + .../NativeReanimatedModuleSpec.cpp | 25 + .../NativeReanimatedModuleSpec.h | 10 +- .../cpp/Registries/EventHandlerRegistry.cpp | 0 .../cpp}/Registries/EventHandlerRegistry.h | 0 .../Common/cpp/Registries/MapperRegistry.cpp | 4 +- .../Common/cpp}/Registries/MapperRegistry.h | 0 .../Common/cpp/Registries/WorkletsCache.cpp | 3 + .../Common/cpp}/Registries/WorkletsCache.h | 0 .../Common/cpp/SharedItems/FrozenObject.cpp | 0 .../Common/cpp}/SharedItems/FrozenObject.h | 0 .../cpp}/SharedItems/HostFunctionHandler.h | 0 .../Common/cpp/SharedItems/MutableValue.cpp | 2 + .../Common/cpp}/SharedItems/MutableValue.h | 0 .../SharedItems/MutableValueSetterProxy.cpp | 0 .../SharedItems/MutableValueSetterProxy.h | 0 .../Common/cpp/SharedItems/RemoteObject.cpp | 0 .../Common/cpp}/SharedItems/RemoteObject.h | 0 .../Common/cpp}/SharedItems/RuntimeManager.h | 0 .../Common/cpp/SharedItems/ShareableValue.cpp | 9 +- .../Common/cpp}/SharedItems/ShareableValue.h | 0 .../Common/cpp}/SharedItems/SharedParent.h | 0 .../Common/cpp}/SharedItems/ValueWrapper.h | 0 .../Common/cpp}/SpecTools/ErrorHandler.h | 0 .../Common/cpp/Tools/FeaturesConfig.cpp | 0 .../Common/cpp}/Tools/FeaturesConfig.h | 0 .../Common/cpp/Tools/JSIStoreValueUser.cpp | 4 +- .../Common/cpp}/Tools/JSIStoreValueUser.h | 0 .../Common/cpp/Tools/Mapper.cpp | 0 .../Common/cpp}/Tools/Mapper.h | 0 .../cpp}/Tools/PlatformDepMethodsHolder.h | 5 + .../cpp}/Tools/ReanimatedHiddenHeaders.h | 2 +- .../Common/cpp/Tools/RuntimeDecorator.cpp | 0 .../Common/cpp}/Tools/RuntimeDecorator.h | 0 .../Common/cpp/Tools/Scheduler.cpp | 0 .../Common/cpp}/Tools/Scheduler.h | 0 .../Common/cpp/Tools/SingleInstanceChecker.h | 58 + .../Common/cpp/Tools/WorkletEventHandler.cpp | 0 .../Common/cpp}/Tools/WorkletEventHandler.h | 0 .../Common/cpp/hidden_headers/Logger.h | 0 .../cpp/hidden_headers/LoggerInterface.h | 0 .../Common/cpp/hidden_headers/SpeedChecker.h | 0 .../android/CMakeLists.txt | 321 ++++++ .../react-native-reanimated/android/README.md | 15 + .../android/build.gradle | 1016 +++++++++++++++++ .../react-native-reanimated/android/empty.cpp | 1 + .../ReanimatedNativeHierarchyManager.java | 412 +++++++ .../ReanimatedUIImplementation.java | 68 ++ .../ReanimatedUIImplementation.java | 68 ++ .../ReanimatedUIImplementation.java | 68 ++ .../android/src/main/AndroidManifest.xml | 5 + .../src/main/cpp/AndroidErrorHandler.cpp | 7 +- .../src/main/cpp}/AndroidErrorHandler.h | 5 +- .../android}/src/main/cpp/AndroidLogger.cpp | 5 +- .../android/src/main/cpp}/AndroidLogger.h | 0 .../src/main/cpp/AndroidScheduler.cpp | 0 .../android/src/main/cpp}/AndroidScheduler.h | 2 +- .../android}/src/main/cpp/JNIHelper.cpp | 0 .../android/src/main/cpp}/JNIHelper.h | 0 .../src/main/cpp/LayoutAnimations.cpp | 0 .../android/src/main/cpp}/LayoutAnimations.h | 2 +- .../android}/src/main/cpp/NativeProxy.cpp | 88 +- .../android/src/main/cpp}/NativeProxy.h | 37 +- .../android}/src/main/cpp/OnLoad.cpp | 1 + .../android}/src/main/cpp/TurboModule.cpp | 0 .../android/src/main/cpp}/TurboModule.h | 0 .../uimanager/UIManagerReanimatedHelper.java | 15 + .../common/GestureHandlerStateManager.java | 5 + .../swmansion}/reanimated/CopiedEvent.java | 2 +- .../com/swmansion}/reanimated/MapUtils.java | 2 +- .../reanimated/NativeMethodsHelper.java | 2 +- .../swmansion}/reanimated/NativeProxy.java | 47 +- .../swmansion}/reanimated/NodesManager.java | 50 +- .../ReanimatedJSIModulePackage.java | 2 +- .../reanimated/ReanimatedModule.java | 4 +- .../reanimated/ReanimatedPackage.java | 2 +- .../com/swmansion}/reanimated/Scheduler.java | 2 +- .../swmansion}/reanimated/UpdateContext.java | 4 +- .../java/com/swmansion}/reanimated/Utils.java | 2 +- .../ReanimatedKeyboardEventListener.java | 166 +++ .../layoutReanimation/AnimationsManager.java | 39 +- .../layoutReanimation/LayoutAnimations.java | 4 +- .../NativeMethodsHolder.java | 2 +- .../ReanimatedNativeHierarchyManager.java | 4 +- .../ReanimatedUIImplementation.java | 2 +- .../ReanimatedUIManager.java | 0 .../layoutReanimation/Snapshot.java | 2 +- .../ViewHierarchyObserver.java | 2 +- .../reanimated/nodes/AlwaysNode.java | 6 +- .../reanimated/nodes/BezierNode.java | 6 +- .../reanimated/nodes/BlockNode.java | 6 +- .../reanimated/nodes/CallFuncNode.java | 6 +- .../reanimated/nodes/ClockNode.java | 4 +- .../reanimated/nodes/ClockOpNode.java | 6 +- .../reanimated/nodes/ConcatNode.java | 6 +- .../swmansion}/reanimated/nodes/CondNode.java | 6 +- .../reanimated/nodes/DebugNode.java | 6 +- .../reanimated/nodes/EventNode.java | 4 +- .../swmansion/reanimated/nodes/FinalNode.java | 5 + .../reanimated/nodes/FunctionNode.java | 4 +- .../reanimated/nodes/JSCallNode.java | 6 +- .../com/swmansion}/reanimated/nodes/Node.java | 6 +- .../swmansion}/reanimated/nodes/NoopNode.java | 4 +- .../reanimated/nodes/OperatorNode.java | 6 +- .../reanimated/nodes/ParamNode.java | 4 +- .../reanimated/nodes/PropsNode.java | 6 +- .../swmansion}/reanimated/nodes/SetNode.java | 6 +- .../reanimated/nodes/StyleNode.java | 6 +- .../reanimated/nodes/TransformNode.java | 4 +- .../reanimated/nodes/ValueNode.java | 4 +- .../reanimated/sensor/ReanimatedSensor.java | 10 +- .../sensor/ReanimatedSensorContainer.java | 4 +- .../sensor/ReanimatedSensorListener.java | 4 +- .../sensor/ReanimatedSensorType.java | 4 +- .../transitions/ChangeTransition.java | 2 +- .../transitions/SaneSidePropagation.java | 2 +- .../reanimated/transitions/Scale.java | 2 +- .../transitions/TransitionModule.java | 2 +- .../transitions/TransitionUtils.java | 2 +- apps/bare-expo/package.json | 2 +- apps/native-component-list/package.json | 2 +- home/package.json | 2 +- ios/Podfile.lock | 4 +- .../AnimatedSensor/AnimatedSensorModule.cpp | 11 +- .../AnimatedSensor/AnimatedSensorModule.h | 0 .../LayoutAnimationsProxy.cpp | 2 + .../LayoutAnimations/LayoutAnimationsProxy.h | 0 .../NativeModules/NativeReanimatedModule.cpp | 40 + .../NativeModules/NativeReanimatedModule.h | 13 + .../NativeReanimatedModuleSpec.cpp | 25 + .../NativeReanimatedModuleSpec.h | 10 +- .../Registries/EventHandlerRegistry.h | 0 .../Common/cpp/Registries/MapperRegistry.cpp | 4 +- .../{headers => }/Registries/MapperRegistry.h | 0 .../Common/cpp/Registries/WorkletsCache.cpp | 3 + .../{headers => }/Registries/WorkletsCache.h | 0 .../{headers => }/SharedItems/FrozenObject.h | 0 .../SharedItems/HostFunctionHandler.h | 0 .../Common/cpp/SharedItems/MutableValue.cpp | 2 + .../{headers => }/SharedItems/MutableValue.h | 0 .../SharedItems/MutableValueSetterProxy.h | 0 .../{headers => }/SharedItems/RemoteObject.h | 0 .../SharedItems/RuntimeManager.h | 0 .../Common/cpp/SharedItems/ShareableValue.cpp | 9 +- .../SharedItems/ShareableValue.h | 0 .../{headers => }/SharedItems/SharedParent.h | 0 .../{headers => }/SharedItems/ValueWrapper.h | 0 .../{headers => }/SpecTools/ErrorHandler.h | 0 .../cpp/{headers => }/Tools/FeaturesConfig.h | 0 .../Common/cpp/Tools/JSIStoreValueUser.cpp | 4 +- .../{headers => }/Tools/JSIStoreValueUser.h | 0 .../Common/cpp/{headers => }/Tools/Mapper.h | 0 .../cpp}/Tools/PlatformDepMethodsHolder.h | 5 + .../Tools/ReanimatedHiddenHeaders.h | 2 +- .../{headers => }/Tools/RuntimeDecorator.h | 0 .../cpp/{headers => }/Tools/Scheduler.h | 0 .../Common/cpp/Tools/SingleInstanceChecker.h | 58 + .../{headers => }/Tools/WorkletEventHandler.h | 0 .../RNReanimated.podspec.json | 24 +- .../ios/{REAModule.m => REAModule.mm} | 12 + .../ios/REANodesManager.m | 39 +- .../REAKeyboardEventObserver.h | 17 + .../REAKeyboardEventObserver.m | 198 ++++ .../ios/native/NativeProxy.mm | 27 +- .../ios/native/REAInitializer.h | 4 +- .../ios/native/REAInitializer.mm | 24 +- .../ios/native/UIResponder+Reanimated.mm | 2 +- .../ios/sensor/ReanimatedSensor.m | 43 +- packages/expo/bundledNativeModules.json | 2 +- tools/src/vendoring/config/expoGoConfig.ts | 66 +- 185 files changed, 3193 insertions(+), 992 deletions(-) delete mode 100644 android/expoview/CMakeLists.txt delete mode 100644 android/expoview/src/main/java/com/facebook/react/uimanager/UIManagerReanimatedHelper.java delete mode 100644 android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/AndroidErrorHandler.java delete mode 100644 android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/FinalNode.java rename android/{expoview/src/main => vendored/unversioned/react-native-reanimated}/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp (90%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/AnimatedSensor/AnimatedSensorModule.h (100%) rename android/{expoview/src/main => vendored/unversioned/react-native-reanimated}/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp (98%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/LayoutAnimations/LayoutAnimationsProxy.h (100%) rename android/{expoview/src/main => vendored/unversioned/react-native-reanimated}/Common/cpp/NativeModules/NativeReanimatedModule.cpp (86%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/NativeModules/NativeReanimatedModule.h (87%) rename android/{expoview/src/main => vendored/unversioned/react-native-reanimated}/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp (86%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/NativeModules/NativeReanimatedModuleSpec.h (88%) rename android/{expoview/src/main => vendored/unversioned/react-native-reanimated}/Common/cpp/Registries/EventHandlerRegistry.cpp (100%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/Registries/EventHandlerRegistry.h (100%) rename android/{expoview/src/main => vendored/unversioned/react-native-reanimated}/Common/cpp/Registries/MapperRegistry.cpp (99%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/Registries/MapperRegistry.h (100%) rename android/{expoview/src/main => vendored/unversioned/react-native-reanimated}/Common/cpp/Registries/WorkletsCache.cpp (97%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/Registries/WorkletsCache.h (100%) rename android/{expoview/src/main => vendored/unversioned/react-native-reanimated}/Common/cpp/SharedItems/FrozenObject.cpp (100%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/SharedItems/FrozenObject.h (100%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/SharedItems/HostFunctionHandler.h (100%) rename android/{expoview/src/main => vendored/unversioned/react-native-reanimated}/Common/cpp/SharedItems/MutableValue.cpp (99%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/SharedItems/MutableValue.h (100%) rename android/{expoview/src/main => vendored/unversioned/react-native-reanimated}/Common/cpp/SharedItems/MutableValueSetterProxy.cpp (100%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/SharedItems/MutableValueSetterProxy.h (100%) rename android/{expoview/src/main => vendored/unversioned/react-native-reanimated}/Common/cpp/SharedItems/RemoteObject.cpp (100%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/SharedItems/RemoteObject.h (100%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/SharedItems/RuntimeManager.h (100%) rename android/{expoview/src/main => vendored/unversioned/react-native-reanimated}/Common/cpp/SharedItems/ShareableValue.cpp (98%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/SharedItems/ShareableValue.h (100%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/SharedItems/SharedParent.h (100%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/SharedItems/ValueWrapper.h (100%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/SpecTools/ErrorHandler.h (100%) rename android/{expoview/src/main => vendored/unversioned/react-native-reanimated}/Common/cpp/Tools/FeaturesConfig.cpp (100%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/Tools/FeaturesConfig.h (100%) rename android/{expoview/src/main => vendored/unversioned/react-native-reanimated}/Common/cpp/Tools/JSIStoreValueUser.cpp (97%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/Tools/JSIStoreValueUser.h (100%) rename android/{expoview/src/main => vendored/unversioned/react-native-reanimated}/Common/cpp/Tools/Mapper.cpp (100%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/Tools/Mapper.h (100%) rename {ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers => android/vendored/unversioned/react-native-reanimated/Common/cpp}/Tools/PlatformDepMethodsHolder.h (83%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/Tools/ReanimatedHiddenHeaders.h (91%) rename android/{expoview/src/main => vendored/unversioned/react-native-reanimated}/Common/cpp/Tools/RuntimeDecorator.cpp (100%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/Tools/RuntimeDecorator.h (100%) rename android/{expoview/src/main => vendored/unversioned/react-native-reanimated}/Common/cpp/Tools/Scheduler.cpp (100%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/Tools/Scheduler.h (100%) create mode 100644 android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/SingleInstanceChecker.h rename android/{expoview/src/main => vendored/unversioned/react-native-reanimated}/Common/cpp/Tools/WorkletEventHandler.cpp (100%) rename android/{expoview/src/main/Common/cpp/headers => vendored/unversioned/react-native-reanimated/Common/cpp}/Tools/WorkletEventHandler.h (100%) rename android/{expoview/src/main => vendored/unversioned/react-native-reanimated}/Common/cpp/hidden_headers/Logger.h (100%) rename android/{expoview/src/main => vendored/unversioned/react-native-reanimated}/Common/cpp/hidden_headers/LoggerInterface.h (100%) rename android/{expoview/src/main => vendored/unversioned/react-native-reanimated}/Common/cpp/hidden_headers/SpeedChecker.h (100%) create mode 100644 android/vendored/unversioned/react-native-reanimated/android/CMakeLists.txt create mode 100644 android/vendored/unversioned/react-native-reanimated/android/README.md create mode 100644 android/vendored/unversioned/react-native-reanimated/android/build.gradle create mode 100644 android/vendored/unversioned/react-native-reanimated/android/empty.cpp create mode 100644 android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/62/layoutReanimation/ReanimatedNativeHierarchyManager.java create mode 100644 android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/62/layoutReanimation/ReanimatedUIImplementation.java create mode 100644 android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/63/layoutReanimation/ReanimatedUIImplementation.java create mode 100644 android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/64/layoutReanimation/ReanimatedUIImplementation.java create mode 100644 android/vendored/unversioned/react-native-reanimated/android/src/main/AndroidManifest.xml rename android/{expoview => vendored/unversioned/react-native-reanimated/android}/src/main/cpp/AndroidErrorHandler.cpp (84%) rename android/{expoview/src/main/cpp/headers => vendored/unversioned/react-native-reanimated/android/src/main/cpp}/AndroidErrorHandler.h (72%) rename android/{expoview => vendored/unversioned/react-native-reanimated/android}/src/main/cpp/AndroidLogger.cpp (97%) rename android/{expoview/src/main/cpp/headers => vendored/unversioned/react-native-reanimated/android/src/main/cpp}/AndroidLogger.h (100%) rename android/{expoview => vendored/unversioned/react-native-reanimated/android}/src/main/cpp/AndroidScheduler.cpp (100%) rename android/{expoview/src/main/cpp/headers => vendored/unversioned/react-native-reanimated/android/src/main/cpp}/AndroidScheduler.h (92%) rename android/{expoview => vendored/unversioned/react-native-reanimated/android}/src/main/cpp/JNIHelper.cpp (100%) rename android/{expoview/src/main/cpp/headers => vendored/unversioned/react-native-reanimated/android/src/main/cpp}/JNIHelper.h (100%) rename android/{expoview => vendored/unversioned/react-native-reanimated/android}/src/main/cpp/LayoutAnimations.cpp (100%) rename android/{expoview/src/main/cpp/headers => vendored/unversioned/react-native-reanimated/android/src/main/cpp}/LayoutAnimations.h (91%) rename android/{expoview => vendored/unversioned/react-native-reanimated/android}/src/main/cpp/NativeProxy.cpp (81%) rename android/{expoview/src/main/cpp/headers => vendored/unversioned/react-native-reanimated/android/src/main/cpp}/NativeProxy.h (81%) rename android/{expoview => vendored/unversioned/react-native-reanimated/android}/src/main/cpp/OnLoad.cpp (90%) rename android/{expoview => vendored/unversioned/react-native-reanimated/android}/src/main/cpp/TurboModule.cpp (100%) rename android/{expoview/src/main/cpp/headers => vendored/unversioned/react-native-reanimated/android/src/main/cpp}/TurboModule.h (100%) create mode 100644 android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/facebook/react/uimanager/UIManagerReanimatedHelper.java create mode 100644 android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/common/GestureHandlerStateManager.java rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/CopiedEvent.java (94%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/MapUtils.java (92%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/NativeMethodsHelper.java (98%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/NativeProxy.java (86%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/NodesManager.java (92%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/ReanimatedJSIModulePackage.java (94%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/ReanimatedModule.java (97%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/ReanimatedPackage.java (98%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/Scheduler.java (95%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/UpdateContext.java (59%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/Utils.java (93%) create mode 100644 android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/layoutReanimation/AnimationsManager.java (95%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/layoutReanimation/LayoutAnimations.java (90%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/layoutReanimation/NativeMethodsHolder.java (76%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java (99%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/layoutReanimation/ReanimatedUIImplementation.java (95%) rename android/{expoview/src/main/java/com/facebook/react/uimanager => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation}/ReanimatedUIManager.java (100%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/layoutReanimation/Snapshot.java (98%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/layoutReanimation/ViewHierarchyObserver.java (80%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/nodes/AlwaysNode.java (76%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/nodes/BezierNode.java (92%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/nodes/BlockNode.java (71%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/nodes/CallFuncNode.java (87%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/nodes/ClockNode.java (83%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/nodes/ClockOpNode.java (90%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/nodes/ConcatNode.java (82%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/nodes/CondNode.java (86%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/nodes/DebugNode.java (81%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/nodes/EventNode.java (94%) create mode 100644 android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/FinalNode.java rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/nodes/FunctionNode.java (76%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/nodes/JSCallNode.java (85%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/nodes/Node.java (95%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/nodes/NoopNode.java (86%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/nodes/OperatorNode.java (98%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/nodes/ParamNode.java (93%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/nodes/PropsNode.java (96%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/nodes/SetNode.java (80%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/nodes/StyleNode.java (85%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/nodes/TransformNode.java (95%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/nodes/ValueNode.java (87%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/sensor/ReanimatedSensor.java (82%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/sensor/ReanimatedSensorContainer.java (89%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/sensor/ReanimatedSensorListener.java (92%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/sensor/ReanimatedSensorType.java (88%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/transitions/ChangeTransition.java (97%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/transitions/SaneSidePropagation.java (90%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/transitions/Scale.java (97%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/transitions/TransitionModule.java (95%) rename android/{expoview/src/main/java/versioned/host/exp/exponent/modules/api => vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion}/reanimated/transitions/TransitionUtils.java (98%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/AnimatedSensor/AnimatedSensorModule.h (100%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/LayoutAnimations/LayoutAnimationsProxy.h (100%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/NativeModules/NativeReanimatedModule.h (87%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/NativeModules/NativeReanimatedModuleSpec.h (88%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/Registries/EventHandlerRegistry.h (100%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/Registries/MapperRegistry.h (100%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/Registries/WorkletsCache.h (100%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/SharedItems/FrozenObject.h (100%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/SharedItems/HostFunctionHandler.h (100%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/SharedItems/MutableValue.h (100%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/SharedItems/MutableValueSetterProxy.h (100%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/SharedItems/RemoteObject.h (100%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/SharedItems/RuntimeManager.h (100%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/SharedItems/ShareableValue.h (100%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/SharedItems/SharedParent.h (100%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/SharedItems/ValueWrapper.h (100%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/SpecTools/ErrorHandler.h (100%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/Tools/FeaturesConfig.h (100%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/Tools/JSIStoreValueUser.h (100%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/Tools/Mapper.h (100%) rename {android/expoview/src/main/Common/cpp/headers => ios/vendored/unversioned/react-native-reanimated/Common/cpp}/Tools/PlatformDepMethodsHolder.h (83%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/Tools/ReanimatedHiddenHeaders.h (91%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/Tools/RuntimeDecorator.h (100%) rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/Tools/Scheduler.h (100%) create mode 100644 ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/SingleInstanceChecker.h rename ios/vendored/unversioned/react-native-reanimated/Common/cpp/{headers => }/Tools/WorkletEventHandler.h (100%) rename ios/vendored/unversioned/react-native-reanimated/ios/{REAModule.m => REAModule.mm} (96%) create mode 100644 ios/vendored/unversioned/react-native-reanimated/ios/keyboardObserver/REAKeyboardEventObserver.h create mode 100644 ios/vendored/unversioned/react-native-reanimated/ios/keyboardObserver/REAKeyboardEventObserver.m diff --git a/CHANGELOG.md b/CHANGELOG.md index dcdc2e724a136..5e266a58f8c93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ Package-specific changes not released in any SDK will be added here just before - Updated `lottie-react-native` from `5.1.3` to `5.1.4`. ([#19433](https://github.com/expo/expo/pull/19433) by [@kudo](https://github.com/kudo)) - Updated `@react-native-community/slider` from `4.2.3` to `4.2.4`. ([#19424](https://github.com/expo/expo/pull/19424)) by [@kudo](https://github.com/kudo)) - Updated `react-native-svg` from `12.3.0` to `13.4.0`. ([#19434](https://github.com/expo/expo/pull/19434) by [@lukmccall](https://github.com/lukmccall)) +- Updated `react-native-reanimated` from `2.10.0` to `2.11.0`. ### 🛠 Breaking changes diff --git a/android/expoview/CMakeLists.txt b/android/expoview/CMakeLists.txt deleted file mode 100644 index 6f666fb470497..0000000000000 --- a/android/expoview/CMakeLists.txt +++ /dev/null @@ -1,184 +0,0 @@ -cmake_minimum_required(VERSION 3.5.1) - -set (CMAKE_VERBOSE_MAKEFILE ON) -set (CMAKE_CXX_STANDARD 14) -set (CMAKE_CXX_FLAGS "-DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_HAVE_MEMRCHR=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DON_ANDROID -DONANDROID -DFOR_HERMES=${FOR_HERMES} -fexceptions -fno-omit-frame-pointer -frtti -Wno-sign-compare") - -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "") - -set (PACKAGE_NAME "reanimated") -set (BUILD_DIR ${CMAKE_SOURCE_DIR}/build) -set (NODE_MODULES_DIR "../node_modules") - -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_OUTPUT_DIR}/${ANDROID_ABI}) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_OUTPUT_DIR}/${ANDROID_ABI}) - -# reanimated shared - -file(GLOB sources_tools "./src/main/Common/cpp/Tools/*.cpp") -file(GLOB sources_native_modules "./src/main/Common/cpp/NativeModules/*.cpp") -file(GLOB sources_shared_items "./src/main/Common/cpp/SharedItems/*.cpp") -file(GLOB sources_registries "./src/main/Common/cpp/Registries/*.cpp") -file(GLOB sources_android "./src/main/cpp/*.cpp") - -if(${REACT_NATIVE_TARGET_VERSION} LESS 66) - set ( - INCLUDE_JSI_CPP - "${REACT_NATIVE_PATH}/ReactCommon/jsi/jsi/jsi.cpp" - ) - set ( - INCLUDE_JSIDYNAMIC_CPP - "${REACT_NATIVE_PATH}/ReactCommon/jsi/jsi/JSIDynamic.cpp" - ) -endif() - -add_library( - ${PACKAGE_NAME} - SHARED - ${sources_native_modules} - ${sources_shared_items} - ${sources_registries} - ${sources_android} - ${source_tools} - ${INCLUDE_JSI_CPP} - ${INCLUDE_JSIDYNAMIC_CPP} - "./src/main/Common/cpp/Tools/JSIStoreValueUser.cpp" - "./src/main/Common/cpp/Tools/Mapper.cpp" - "./src/main/Common/cpp/Tools/RuntimeDecorator.cpp" - "./src/main/Common/cpp/Tools/Scheduler.cpp" - "./src/main/Common/cpp/Tools/WorkletEventHandler.cpp" - "./src/main/Common/cpp/Tools/FeaturesConfig.cpp" - "./src/main/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp" - "./src/main/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp" -) - -# includes - -file (GLOB LIBFBJNI_INCLUDE_DIR ${FBJNI_HEADERS_DIR}) - -target_include_directories( - ${PACKAGE_NAME} - PRIVATE - "${LIBFBJNI_INCLUDE_DIR}" - "${REACT_NATIVE_PATH}/ReactAndroid/build/third-party-ndk/boost/boost_${BOOST_VERSION}" - "${REACT_NATIVE_PATH}/ReactAndroid/build/third-party-ndk/double-conversion" - "${REACT_NATIVE_PATH}/ReactAndroid/build/third-party-ndk/folly" - "${REACT_NATIVE_PATH}/ReactAndroid/build/third-party-ndk/glog/exported" - "${REACT_NATIVE_PATH}/React" - "${REACT_NATIVE_PATH}/React/Base" - "${REACT_NATIVE_PATH}/ReactAndroid/src/main/jni" - "${REACT_NATIVE_PATH}/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni" - "${REACT_NATIVE_PATH}/ReactCommon" - "${REACT_NATIVE_PATH}/ReactCommon/callinvoker" - "${REACT_NATIVE_PATH}/ReactCommon/jsi" - "${REACT_NATIVE_PATH}/ReactCommon/turbomodule/core" - "${REACT_NATIVE_PATH}/ReactCommon/turbomodule" - "./src/main/Common/cpp/headers/Tools" - "./src/main/Common/cpp/headers/SpecTools" - "./src/main/Common/cpp/headers/NativeModules" - "./src/main/Common/cpp/headers/SharedItems" - "./src/main/Common/cpp/headers/Registries" - "./src/main/Common/cpp/headers/AnimatedSensor" - "./src/main/Common/cpp/headers/LayoutAnimations" - "./src/main/Common/cpp/hidden_headers" - "./src/main/cpp/headers" -) - -# find libraries - -file (GLOB LIBRN_DIR "${RN_SO_DIR}/${ANDROID_ABI}") - -find_library( - LOG_LIB - log -) -find_library( - FBJNI_LIB - fbjni - PATHS ${LIBRN_DIR} - NO_CMAKE_FIND_ROOT_PATH -) -find_package(hermes-engine REQUIRED CONFIG) -find_library( - JSEXECUTOR_LIB - jscexecutor - PATHS ${LIBRN_DIR} - NO_CMAKE_FIND_ROOT_PATH -) -find_library( - FOLLY_LIB - folly_runtime - PATHS ${LIBRN_DIR} - NO_CMAKE_FIND_ROOT_PATH -) -find_library( - REACT_NATIVE_JNI_LIB - reactnativejni - PATHS ${LIBRN_DIR} - NO_CMAKE_FIND_ROOT_PATH -) -find_library( - FBJNI_LIBRARY fbjni - PATHS ${libfbjni_link_DIRS} - NO_CMAKE_FIND_ROOT_PATH -) -find_library( - GLOG_LIB - glog - PATHS ${LIBRN_DIR} - NO_CMAKE_FIND_ROOT_PATH -) - -if(${REACT_NATIVE_TARGET_VERSION} LESS 66) - set (JSI_LIB "") -else() - find_library( - JSI_LIB - jsi - PATHS ${LIBRN_DIR} - NO_CMAKE_FIND_ROOT_PATH - ) -endif() - -# build shared lib - -set_target_properties(${PACKAGE_NAME} PROPERTIES LINKER_LANGUAGE CXX) - -message(STATUS "CMakeLists.txt FOR_HERMES=${FOR_HERMES}") - -if(${FOR_HERMES}) - target_link_libraries( - ${PACKAGE_NAME} - ${LOG_LIB} - ${JSI_LIB} - hermes-engine::libhermes - ${GLOG_LIB} - ${FBJNI_LIB} - ${FOLLY_LIB} - ${REACT_NATIVE_JNI_LIB} - android - ) -else() - target_link_libraries( - ${PACKAGE_NAME} - ${LOG_LIB} - ${JSI_LIB} - ${JSEXECUTOR_LIB} - ${GLOG_LIB} - ${FBJNI_LIB} - ${FOLLY_LIB} - ${REACT_NATIVE_JNI_LIB} - android - ) -endif() - -if(${REACT_NATIVE_TARGET_VERSION} LESS 64) - add_library( - turbomodulejsijni - # Sets the library as a shared library. - SHARED - # Provides a relative path to your source file(s). - ./empty.cpp - ) -endif() diff --git a/android/expoview/build.gradle b/android/expoview/build.gradle index 4081647078c9d..85c5710656770 100644 --- a/android/expoview/build.gradle +++ b/android/expoview/build.gradle @@ -40,49 +40,12 @@ afterEvaluate { } // WHEN_VERSIONING_REMOVE_TO_HERE -// WHEN_PREPARING_REANIMATED_REMOVE_FROM_HERE - -// reanimated - -def debugNativeLibraries = false - -import java.nio.file.Paths - -import de.undercouch.gradle.tasks.download.Download -import org.apache.tools.ant.taskdefs.condition.Os -import org.apache.tools.ant.filters.ReplaceTokens - -def reactNative = new File("$projectDir/../../versioned-react-native") - -// WHEN_VERSIONING_REMOVE_FROM_HERE -reactNative = new File("$projectDir/../../react-native-lab/react-native") -// WHEN_VERSIONING_REMOVE_TO_HERE - - -def BOOST_VERSION = reactProperties.getProperty("BOOST_VERSION") -def DOUBLE_CONVERSION_VERSION = reactProperties.getProperty("DOUBLE_CONVERSION_VERSION") -def FOLLY_VERSION = reactProperties.getProperty("FOLLY_VERSION") -def GLOG_VERSION = reactProperties.getProperty("GLOG_VERSION") -def REACT_VERSION = reactProperties.getProperty("VERSION_NAME").split("\\.")[1].toInteger() -def REACT_NATIVE_PATH = reactNative.absolutePath -def CMAKE_OUTPUT_DIR = "$buildDir/reanimated-ndk/all" -def RN_SO_DIR = "$reactNative/ReactAndroid/build/intermediates/library_*/*/jni" -def FBJNI_HEADERS_DIR = "$reactNative/ReactAndroid/src/main/jni/first-party/fbjni/headers" -def FOR_HERMES = true -def reactNativeArchitectures() { - def value = project.getProperties().get("reactNativeArchitectures") - return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] -} - def prebuiltHermesDir = findProperty("expo.prebuiltHermesDir") ?: file("${rootDir}/prebuiltHermes") def prebuiltHermesVersion = file("${prebuiltHermesDir}/.hermesversion").exists() ? file("${prebuiltHermesDir}/.hermesversion").text : null def currentHermesVersion = file("${project(':ReactAndroid').projectDir}/../sdks/.hermesversion").exists() ? file("${project(':ReactAndroid').projectDir}/../sdks/.hermesversion").text : null def buildHermesSource = currentHermesVersion != prebuiltHermesVersion logger.info(":expoview - buildHermesSource[${buildHermesSource}]") -// WHEN_PREPARING_REANIMATED_REMOVE_TO_HERE - - buildscript { // Simple helper that allows the root project to override versions declared by this library. ext.safeExtGet = { prop, fallback -> @@ -149,66 +112,8 @@ android { 'appAuthRedirectScheme': 'host.exp.exponent' ] // WHEN_VERSIONING_REMOVE_TO_HERE - - // WHEN_PREPARING_REANIMATED_REMOVE_FROM_HERE - externalNativeBuild { - cmake { - arguments "-DANDROID_STL=c++_shared", - "-DREACT_NATIVE_TARGET_VERSION=${REACT_VERSION}", - "-DANDROID_TOOLCHAIN=clang", - "${getCmakeToolchainFile()}", - "-DBOOST_VERSION=${BOOST_VERSION}", - "-DFOR_HERMES=${FOR_HERMES}", - "-DREACT_NATIVE_PATH=${REACT_NATIVE_PATH}", - "-DRN_SO_DIR=${RN_SO_DIR}", - "-DFBJNI_HEADERS_DIR=${FBJNI_HEADERS_DIR}", - "-DCMAKE_OUTPUT_DIR=${CMAKE_OUTPUT_DIR}" - abiFilters (*reactNativeArchitectures()) - } - } - - buildConfigField("boolean", "IS_INTERNAL_BUILD", "false") - buildConfigField("int", "EXOPACKAGE_FLAGS", "0") - buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", "false") - // WHEN_PREPARING_REANIMATED_REMOVE_TO_HERE - } - - // WHEN_PREPARING_REANIMATED_REMOVE_FROM_HERE - externalNativeBuild { - cmake { - path "CMakeLists.txt" - } - } - - packagingOptions { - println "Native libs debug enabled: ${debugNativeLibraries}" - doNotStrip debugNativeLibraries ? "**/**/*.so" : '' - - // Gradle will add cmake target dependencies into packaging. - // Theses files are intermediated linking files to build reanimated and should not be in final package. - excludes = [ - "**/libc++_shared.so", - "**/libreactnativejni.so", - "**/libglog.so", - "**/libjscexecutor.so", - "**/libfbjni.so", - "**/libfolly_runtime.so", - "**/libhermes.so", - "**/libjsi.so", - ] } - configurations { - extractHeaders - extractSO - } - - buildFeatures { - prefab true - } - - // WHEN_PREPARING_REANIMATED_REMOVE_TO_HERE - buildTypes { release { consumerProguardFiles('proguard-rules.pro') @@ -269,13 +174,6 @@ dependencies { api("com.facebook.fbjni:fbjni-java-only:0.2.2") - // WHEN_PREPARING_REANIMATED_REMOVE_FROM_HERE - - extractHeaders("com.facebook.fbjni:fbjni:0.2.2:headers") - extractSO("com.facebook.fbjni:fbjni:0.2.2") - - // WHEN_PREPARING_REANIMATED_REMOVE_TO_HERE - // WHEN_VERSIONING_REPLACE_WITH_DEPENDENCIES // WHEN_VERSIONING_REMOVE_FROM_HERE @@ -434,368 +332,3 @@ dependencies { } useVendoredModulesForExpoView('unversioned') - -// WHEN_PREPARING_REANIMATED_REMOVE_FROM_HERE - -// reanimated - -// We download various C++ open-source dependencies into downloads. -// We then copy both the downloaded code and our custom makefiles and headers into third-party-ndk. -// After that we build native code from src/main/jni with module path pointing at third-party-ndk. - -def customDownloadsDir = System.getenv("REACT_NATIVE_DOWNLOADS_DIR") -def downloadsDir = customDownloadsDir ? new File(customDownloadsDir) : new File("$buildDir/downloads") -def thirdPartyNdkDir = new File("$buildDir/third-party-ndk") - -def reactNativeThirdParty = new File("$reactNative/ReactAndroid/src/main/jni/third-party") - -// You need to have following folders in this directory: -// - boost_1_63_0 -// - double-conversion-1.1.6 -// - folly-deprecate-dynamic-initializer -// - glog-0.3.5 -def dependenciesPath = System.getenv("REACT_NATIVE_DEPENDENCIES") - -// The Boost library is a very large download (>100MB). -// If Boost is already present on your system, define the REACT_NATIVE_BOOST_PATH env variable -// and the build will use that. -def boostPath = dependenciesPath ?: System.getenv("REACT_NATIVE_BOOST_PATH") - -def follyReplaceContent = ''' - ssize_t r; - do { - r = open(name, flags, mode); - } while (r == -1 && errno == EINTR); - return r; -''' - -task createNativeDepsDirectories { - downloadsDir.mkdirs() - thirdPartyNdkDir.mkdirs() -} - -task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) { - src("https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION.replace("_", ".")}/source/boost_${BOOST_VERSION}.tar.gz") - onlyIfNewer(true) - overwrite(false) - dest(new File(downloadsDir, "boost_${BOOST_VERSION}.tar.gz")) -} - -task prepareBoost(dependsOn: boostPath ? [] : [downloadBoost], type: Copy) { - from(boostPath ?: tarTree(resources.gzip(downloadBoost.dest))) - from("$reactNativeThirdParty/boost/Android.mk") - include("Android.mk", "boost_${BOOST_VERSION}/boost/**/*.hpp", "boost/boost/**/*.hpp") - includeEmptyDirs = false - into("$thirdPartyNdkDir/boost") - doLast { - file("$thirdPartyNdkDir/boost/boost").renameTo("$thirdPartyNdkDir/boost/boost_${BOOST_VERSION}") - } -} - -task downloadDoubleConversion(dependsOn: createNativeDepsDirectories, type: Download) { - src("https://github.com/google/double-conversion/archive/v${DOUBLE_CONVERSION_VERSION}.tar.gz") - onlyIfNewer(true) - overwrite(false) - dest(new File(downloadsDir, "double-conversion-${DOUBLE_CONVERSION_VERSION}.tar.gz")) -} - -task prepareDoubleConversion(dependsOn: dependenciesPath ? [] : [downloadDoubleConversion], type: Copy) { - from(dependenciesPath ?: tarTree(downloadDoubleConversion.dest)) - from("$reactNativeThirdParty/double-conversion/Android.mk") - include("double-conversion-${DOUBLE_CONVERSION_VERSION}/src/**/*", "Android.mk") - filesMatching("*/src/**/*", { fname -> fname.path = "double-conversion/${fname.name}" }) - includeEmptyDirs = false - into("$thirdPartyNdkDir/double-conversion") -} - -task downloadFolly(dependsOn: createNativeDepsDirectories, type: Download) { - src("https://github.com/facebook/folly/archive/v${FOLLY_VERSION}.tar.gz") - onlyIfNewer(true) - overwrite(false) - dest(new File(downloadsDir, "folly-${FOLLY_VERSION}.tar.gz")) -} - -task prepareFolly(dependsOn: dependenciesPath ? [] : [downloadFolly], type: Copy) { - from(dependenciesPath ?: tarTree(downloadFolly.dest)) - from("$reactNativeThirdParty/folly/Android.mk") - include("folly-${FOLLY_VERSION}/folly/**/*", "Android.mk") - eachFile { fname -> fname.path = (fname.path - "folly-${FOLLY_VERSION}/") } - // Fixes problem with Folly failing to build on certain systems. See - // https://github.com/software-mansion/react-native-reanimated/issues/1024 - filter { line -> line.replaceAll('return int\\(wrapNoInt\\(open, name, flags, mode\\)\\);', follyReplaceContent) } - includeEmptyDirs = false - into("$thirdPartyNdkDir/folly") -} - -task downloadGlog(dependsOn: createNativeDepsDirectories, type: Download) { - src("https://github.com/google/glog/archive/v${GLOG_VERSION}.tar.gz") - onlyIfNewer(true) - overwrite(false) - dest(new File(downloadsDir, "glog-${GLOG_VERSION}.tar.gz")) -} - -// Prepare glog sources to be compiled, this task will perform steps that normally should've been -// executed by automake. This way we can avoid dependencies on make/automake -task prepareGlog(dependsOn: dependenciesPath ? [] : [downloadGlog], type: Copy) { - duplicatesStrategy("warn") - from(dependenciesPath ?: tarTree(downloadGlog.dest)) - from("$reactNativeThirdParty/glog/") - include("glog-${GLOG_VERSION}/src/**/*", "Android.mk", "config.h") - includeEmptyDirs = false - filesMatching("**/*.h.in") { - filter(ReplaceTokens, tokens: [ - ac_cv_have_unistd_h : "1", - ac_cv_have_stdint_h : "1", - ac_cv_have_systypes_h : "1", - ac_cv_have_inttypes_h : "1", - ac_cv_have_libgflags : "0", - ac_google_start_namespace : "namespace google {", - ac_cv_have_uint16_t : "1", - ac_cv_have_u_int16_t : "1", - ac_cv_have___uint16 : "0", - ac_google_end_namespace : "}", - ac_cv_have___builtin_expect : "1", - ac_google_namespace : "google", - ac_cv___attribute___noinline : "__attribute__ ((noinline))", - ac_cv___attribute___noreturn : "__attribute__ ((noreturn))", - ac_cv___attribute___printf_4_5: "__attribute__((__format__ (__printf__, 4, 5)))" - ]) - it.path = (it.name - ".in") - } - into("$thirdPartyNdkDir/glog") - - doLast { - copy { - from(fileTree(dir: "$thirdPartyNdkDir/glog", includes: ["stl_logging.h", "logging.h", "raw_logging.h", "vlog_is_on.h", "**/src/glog/log_severity.h"]).files) - includeEmptyDirs = false - into("$thirdPartyNdkDir/glog/exported/glog") - } - } -} - -task downloadNdkBuildDependencies { - if (!boostPath) { - dependsOn(downloadBoost) - } - dependsOn(downloadDoubleConversion) - dependsOn(downloadFolly) - dependsOn(downloadGlog) -} - -/** - * Finds the path of the installed npm package with the given name using Node's - * module resolution algorithm, which searches "node_modules" directories up to - * the file system root. This handles various cases, including: - * - * - Working in the open-source RN repo: - * Gradle: /path/to/react-native/ReactAndroid - * Node module: /path/to/react-native/node_modules/[package] - * - * - Installing RN as a dependency of an app and searching for hoisted - * dependencies: - * Gradle: /path/to/app/node_modules/react-native/ReactAndroid - * Node module: /path/to/app/node_modules/[package] - * - * - Working in a larger repo (e.g., Facebook) that contains RN: - * Gradle: /path/to/repo/path/to/react-native/ReactAndroid - * Node module: /path/to/repo/node_modules/[package] - * - * The search begins at the given base directory (a File object). The returned - * path is a string. - */ -def findNodeModulePath(baseDir, packageName) { - def basePath = baseDir.toPath().normalize() - // Node's module resolution algorithm searches up to the root directory, - // after which the base path will be null - while (basePath) { - def candidatePath = Paths.get(basePath.toString(), "node_modules", packageName) - if (candidatePath.toFile().exists()) { - return candidatePath.toString() - } - basePath = basePath.getParent() - } - return null -} - -def getNdkBuildName() { - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - return "ndk-build.cmd" - } else { - return "ndk-build" - } -} - -def findNdkBuildFullPath() { - // android.ndkDirectory should return project.android.ndkVersion ndkDirectory - def ndkDir = android.ndkDirectory ? android.ndkDirectory.absolutePath : null - if (ndkDir) { - return new File(ndkDir, getNdkBuildName()).getAbsolutePath() - } - - // we allow to provide full path to ndk-build tool - if (hasProperty("ndk.command")) { - return property("ndk.command") - } - // or just a path to the containing directory - if (hasProperty("ndk.path")) { - ndkDir = property("ndk.path") - return new File(ndkDir, getNdkBuildName()).getAbsolutePath() - } - - // @TODO ANDROID_NDK && ndk.dir is deprecated and will be removed in the future. - if (System.getenv("ANDROID_NDK_HOME") != null) { - ndkDir = System.getenv("ANDROID_NDK_HOME") - return new File(ndkDir, getNdkBuildName()).getAbsolutePath() - } - - // Left for the legacy reasons, use the previous one. - if (System.getenv("ANDROID_NDK") != null) { - ndkDir = System.getenv("ANDROID_NDK") - return new File(ndkDir, getNdkBuildName()).getAbsolutePath() - } - - return null -} - -def getNdkBuildFullPath() { - def ndkBuildFullPath = findNdkBuildFullPath() - if (ndkBuildFullPath == null) { - throw new GradleScriptException( - "ndk-build binary cannot be found, check if you've set " + - "\$ANDROID_NDK_HOME environment variable correctly or if ndk.dir is " + - "setup in local.properties", - null) - } - if (!new File(ndkBuildFullPath).canExecute()) { - throw new GradleScriptException( - "ndk-build binary " + ndkBuildFullPath + " doesn't exist or isn't executable.\n" + - "Check that the \$ANDROID_NDK_HOME environment variable, or ndk.dir in local.properties, is set correctly.\n" + - "(On Windows, make sure you escape backslashes in local.properties or use forward slashes, e.g. C:\\\\ndk or C:/ndk rather than C:\\ndk)", - null) - } - return ndkBuildFullPath -} - -def getCmakeToolchainFile() { - return "-DCMAKE_TOOLCHAIN_FILE=${getNdkBuildFullPath()}/../build/cmake/android.toolchain.cmake" -} - -// Create Android.mk library module based on jsc from npm -task prepareJSC { - doLast { - def jscPackagePath = findNodeModulePath(projectDir, "jsc-android") - if (!jscPackagePath) { - throw new GradleScriptException("Could not find the jsc-android npm package", null) - } - - def jscDist = file("$jscPackagePath/dist") - if (!jscDist.exists()) { - throw new GradleScriptException("The jsc-android npm package is missing its \"dist\" directory", null) - } - - def jscAAR = fileTree(jscDist).matching({ it.include "**/android-jsc/**/*.aar" }).singleFile - def soFiles = zipTree(jscAAR).matching({ it.include "**/*.so" }) - - def headerFiles = fileTree(jscDist).matching({ it.include "**/include/*.h" }) - - copy { - from(soFiles) - from(headerFiles) - from("$reactNative/ReactAndroid/src/main/jni/third-party/jsc/Android.mk") - - filesMatching("**/*.h", { it.path = "JavaScriptCore/${it.name}" }) - - includeEmptyDirs(false) - into("$thirdPartyNdkDir/jsc") - } - } -} - -task extractAARHeaders { - doLast { - configurations.extractHeaders.files.each { - def file = it.absoluteFile - def packageName = file.name.tokenize('-')[0] - copy { - from zipTree(file) - into "$reactNative/ReactAndroid/src/main/jni/first-party/$packageName/headers" - include "**/*.h" - } - } - } -} - -task extractSOFiles { - doLast { - println "extractSOFiles" - configurations.extractSO.files.each { - def file = it.absoluteFile - println file - def packageName = file.name.tokenize('-')[0] - copy { - from zipTree(file) - into "$reactNative/ReactAndroid/src/main/jni/first-party/$packageName/" - include "jni/**/*.so" - } - } - } -} - -project.afterEvaluate { - def nativeBuildTask = tasks.findByName("copyUnversionedReleaseJniLibsProjectAndLocalJars") // for expoview - ?: tasks.findByName("copyReleaseJniLibsProjectAndLocalJars") // for expoview-${abiName} - if (nativeBuildTask) { - packageNdkLibs.dependsOn nativeBuildTask - } - - // Workaround for AGP 7 local lint aar task with errors from a library project owning other aars. - // In our case, it's the expoview (library project) owning hermes aar - // ``` - // Error while evaluating property 'hasLocalAarDeps' of task ':expoview:bundleVersionedReleaseLocalLintAar' - // > Direct local .aar file dependencies are not supported when building an AAR. - // The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. - // Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). - // The following direct local .aar file dependencies of the :expoview project caused this error: - // /home/runner/work/expo/expo/node_modules/hermes-engine/android/hermes-release.aar - // ``` - // For the workaround, we just pretend we don't have local aar dependencies. - tasks.findByName("bundleVersionedReleaseLocalLintAar")?.localAarDeps?.setFrom([]) - tasks.findByName("bundleUnversionedReleaseLocalLintAar")?.localAarDeps?.setFrom([]) -} - -task packageNdkLibs(type: Copy) { - from("$buildDir/intermediates/stripped_native_libs/unversionedRelease/out/lib") // for expoview - from("$buildDir/intermediates/stripped_native_libs/release/out/lib") // for expoview-${abiName} - include("**/libreanimated*.so") - into("$projectDir/src/main/jniLibs") -} - -task prepareThirdPartyNdkHeaders(dependsOn: [downloadNdkBuildDependencies, prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog]) { -} - - -// pre-native build pipeline - -tasks.whenTaskAdded { task -> - if (!task.name.contains("Clean") && (task.name.contains('externalNativeBuild') || task.name.startsWith('configureCMake'))) { - def buildType = task.name.endsWith('Debug') ? 'Debug' : 'Release' - task.dependsOn(prepareThirdPartyNdkHeaders) - extractAARHeaders.dependsOn(prepareThirdPartyNdkHeaders) - extractSOFiles.dependsOn(prepareThirdPartyNdkHeaders) - task.dependsOn(extractAARHeaders) - task.dependsOn(extractSOFiles) - task.dependsOn(":ReactAndroid:copy${buildType}JniLibsProjectOnly") - } else if (task.name.startsWith('generateJsonModel')) { - def buildType = task.name.endsWith('Debug') ? 'Debug' : 'Release' - task.dependsOn(":ReactAndroid:copy${buildType}JniLibsProjectOnly") - } -} - -def hermesAAR = new File("${reactNative}/ReactAndroid/hermes-engine/build/outputs/aar/hermes-engine-release.aar") -if (hermesAAR.exists() && !hasHermesEngineDeps) { - dependencies { - compileOnly(files(hermesAAR)) - } -} - -// WHEN_PREPARING_REANIMATED_REMOVE_TO_HERE diff --git a/android/expoview/src/main/java/com/facebook/react/uimanager/UIManagerReanimatedHelper.java b/android/expoview/src/main/java/com/facebook/react/uimanager/UIManagerReanimatedHelper.java deleted file mode 100644 index da7dab48864e7..0000000000000 --- a/android/expoview/src/main/java/com/facebook/react/uimanager/UIManagerReanimatedHelper.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.facebook.react.uimanager; - -/** - * This class provides a way to workaround limited visibility of UIViewOperationQueue#getUIViewOperationQueue. - * We rely on accessing that method to check if operation queue is empty or not. This in turn indicates if - * we are in a middle of processing batch of operations from JS. In such a case we can rely on the enqueued update - * operations to be flushed onto the shadow view hierarchy. Otherwise we want to trigger "dispatchViewUpdates" and - * enforce flush immediately. - */ -public class UIManagerReanimatedHelper { - public static boolean isOperationQueueEmpty(UIImplementation uiImplementation) { - return uiImplementation.getUIViewOperationQueue().isEmpty(); - } -} diff --git a/android/expoview/src/main/java/host/exp/exponent/kernel/Kernel.kt b/android/expoview/src/main/java/host/exp/exponent/kernel/Kernel.kt index 885ea00ce4c20..fab2dd660c75f 100644 --- a/android/expoview/src/main/java/host/exp/exponent/kernel/Kernel.kt +++ b/android/expoview/src/main/java/host/exp/exponent/kernel/Kernel.kt @@ -67,7 +67,6 @@ import org.json.JSONObject import versioned.host.exp.exponent.ExpoTurboPackage import versioned.host.exp.exponent.ExponentPackage import versioned.host.exp.exponent.ReactUnthemedRootView -import versioned.host.exp.exponent.modules.api.reanimated.ReanimatedJSIModulePackage import java.lang.ref.WeakReference import java.util.* import java.util.concurrent.TimeUnit @@ -275,12 +274,6 @@ class Kernel : KernelInterface() { exponentManifest.getKernelManifest(), initialURL ) ) - .setJSIModulesPackage { reactApplicationContext: ReactApplicationContext?, jsContext: JavaScriptContextHolder? -> - ReanimatedJSIModulePackage().getJSIModules( - reactApplicationContext, - jsContext - ) - } .setInitialLifecycleState(LifecycleState.RESUMED) if (!KernelConfig.FORCE_NO_KERNEL_DEBUG_MODE && exponentManifest.getKernelManifest().isDevelopmentMode()) { Exponent.enableDeveloperSupport( diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/ExpoTurboPackage.kt b/android/expoview/src/main/java/versioned/host/exp/exponent/ExpoTurboPackage.kt index 9fd2fa954cd85..dee8f82b260f1 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/ExpoTurboPackage.kt +++ b/android/expoview/src/main/java/versioned/host/exp/exponent/ExpoTurboPackage.kt @@ -20,11 +20,11 @@ import com.facebook.react.uimanager.ReanimatedUIManager import com.facebook.react.uimanager.UIManagerModule import com.facebook.react.uimanager.ViewManager import com.facebook.systrace.Systrace +import com.swmansion.reanimated.ReanimatedModule import expo.modules.manifests.core.Manifest import host.exp.exponent.experience.ReactNativeActivity import host.exp.exponent.kernel.KernelConstants import host.exp.expoview.Exponent -import versioned.host.exp.exponent.modules.api.reanimated.ReanimatedModule import versioned.host.exp.exponent.modules.internal.ExponentAsyncStorageModule import versioned.host.exp.exponent.modules.internal.ExponentIntentModule import versioned.host.exp.exponent.modules.internal.ExponentUnsignedAsyncStorageModule diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/VersionedUtils.kt b/android/expoview/src/main/java/versioned/host/exp/exponent/VersionedUtils.kt index 82570fb074e63..7ecbfb2739171 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/VersionedUtils.kt +++ b/android/expoview/src/main/java/versioned/host/exp/exponent/VersionedUtils.kt @@ -28,7 +28,6 @@ import host.exp.exponent.experience.ReactNativeActivity import host.exp.expoview.Exponent import host.exp.expoview.Exponent.InstanceManagerBuilderProperties import org.json.JSONObject -import versioned.host.exp.exponent.modules.api.reanimated.ReanimatedJSIModulePackage import java.util.* object VersionedUtils { @@ -194,22 +193,6 @@ object VersionedUtils { var builder = ReactInstanceManager.builder() .setApplication(instanceManagerBuilderProperties.application) .setJSIModulesPackage { reactApplicationContext: ReactApplicationContext, jsContext: JavaScriptContextHolder? -> - val devSupportManager = getDevSupportManager(reactApplicationContext) - if (devSupportManager == null) { - Log.e( - "Exponent", - "Couldn't get the `DevSupportManager`. JSI modules won't be initialized." - ) - return@setJSIModulesPackage emptyList() - } - val devSettings = devSupportManager.callRecursive("getDevSettings") - val isRemoteJSDebugEnabled = devSettings != null && devSettings.call("isRemoteJSDebugEnabled") as Boolean - if (!isRemoteJSDebugEnabled) { - return@setJSIModulesPackage ReanimatedJSIModulePackage().getJSIModules( - reactApplicationContext, - jsContext - ) - } emptyList() } .addPackage(MainReactPackage()) diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/AndroidErrorHandler.java b/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/AndroidErrorHandler.java deleted file mode 100644 index 55c276c2b877b..0000000000000 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/AndroidErrorHandler.java +++ /dev/null @@ -1,8 +0,0 @@ -package versioned.host.exp.exponent.modules.api.reanimated; - -public class AndroidErrorHandler { - - public static void raise(String message) { - throw new RuntimeException(message); - } -} diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/FinalNode.java b/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/FinalNode.java deleted file mode 100644 index dff7bcdbeed34..0000000000000 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/FinalNode.java +++ /dev/null @@ -1,5 +0,0 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; - -public interface FinalNode { - void update(); -} diff --git a/android/vendored/unversioned/react-native-gesture-handler/android/build.gradle b/android/vendored/unversioned/react-native-gesture-handler/android/build.gradle index 59e09d694a166..f0e3e1708ebf5 100644 --- a/android/vendored/unversioned/react-native-gesture-handler/android/build.gradle +++ b/android/vendored/unversioned/react-native-gesture-handler/android/build.gradle @@ -54,7 +54,9 @@ def safeExtGet(prop, fallback) { // Check whether Reanimated 2.3 or higher is installed alongside Gesture Handler def shouldUseCommonInterfaceFromReanimated() { - def reanimated = rootProject.subprojects.find { it.name == 'react-native-reanimated' } + return true + + def reanimated = rootProject.subprojects.find { it.name == 'vendored_unversioned_react-native-reanimated' } if (reanimated != null) { def inputFile = new File(reanimated.projectDir, '../package.json') def json = new JsonSlurper().parseText(inputFile.text) @@ -201,7 +203,7 @@ dependencies { if (shouldUseCommonInterfaceFromReanimated()) { // Include Reanimated as dependency to load the common interface - implementation (rootProject.subprojects.find { it.name == 'react-native-reanimated' }) { + implementation (rootProject.subprojects.find { it.name == 'vendored_unversioned_react-native-reanimated' }) { exclude group:'com.facebook.fbjni' // resolves "Duplicate class com.facebook.jni.CppException" } } diff --git a/android/expoview/src/main/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp b/android/vendored/unversioned/react-native-reanimated/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp similarity index 90% rename from android/expoview/src/main/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp index 89d212db8cd91..83948c91314fb 100644 --- a/android/expoview/src/main/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +++ b/android/vendored/unversioned/react-native-reanimated/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp @@ -2,6 +2,9 @@ #include "MutableValue.h" #include "ValueWrapper.h" +#include +#include + namespace reanimated { AnimatedSensorModule::AnimatedSensorModule( @@ -35,10 +38,10 @@ jsi::Value AnimatedSensorModule::registerSensor( setter = [&, mutableObject](double newValues[]) { jsi::Runtime &runtime = *runtimeManager_->runtime.get(); jsi::Object value(runtime); - value.setProperty(runtime, "qw", newValues[0]); - value.setProperty(runtime, "qx", newValues[1]); - value.setProperty(runtime, "qy", newValues[2]); - value.setProperty(runtime, "qz", newValues[3]); + value.setProperty(runtime, "qx", newValues[0]); + value.setProperty(runtime, "qy", newValues[1]); + value.setProperty(runtime, "qz", newValues[2]); + value.setProperty(runtime, "qw", newValues[3]); value.setProperty(runtime, "yaw", newValues[4]); value.setProperty(runtime, "pitch", newValues[5]); value.setProperty(runtime, "roll", newValues[6]); diff --git a/android/expoview/src/main/Common/cpp/headers/AnimatedSensor/AnimatedSensorModule.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/AnimatedSensor/AnimatedSensorModule.h similarity index 100% rename from android/expoview/src/main/Common/cpp/headers/AnimatedSensor/AnimatedSensorModule.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/AnimatedSensor/AnimatedSensorModule.h diff --git a/android/expoview/src/main/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp b/android/vendored/unversioned/react-native-reanimated/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp similarity index 98% rename from android/expoview/src/main/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp index 96bd26c17fdf4..bbfaacf5d159c 100644 --- a/android/expoview/src/main/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp +++ b/android/vendored/unversioned/react-native-reanimated/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp @@ -4,6 +4,8 @@ #include "ShareableValue.h" #include "ValueWrapper.h" +#include + namespace reanimated { const long long idOffset = 1e9; diff --git a/android/expoview/src/main/Common/cpp/headers/LayoutAnimations/LayoutAnimationsProxy.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.h similarity index 100% rename from android/expoview/src/main/Common/cpp/headers/LayoutAnimations/LayoutAnimationsProxy.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.h diff --git a/android/expoview/src/main/Common/cpp/NativeModules/NativeReanimatedModule.cpp b/android/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModule.cpp similarity index 86% rename from android/expoview/src/main/Common/cpp/NativeModules/NativeReanimatedModule.cpp rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModule.cpp index 50584dd761118..8f8de85a495e1 100644 --- a/android/expoview/src/main/Common/cpp/NativeModules/NativeReanimatedModule.cpp +++ b/android/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModule.cpp @@ -2,6 +2,8 @@ #include #include #include +#include + #include "EventHandlerRegistry.h" #include "FeaturesConfig.h" #include "FrozenObject.h" @@ -98,6 +100,10 @@ NativeReanimatedModule::NativeReanimatedModule( this->onRender(timestampMs); }; updaterFunction = platformDepMethodsHolder.updaterFunction; + subscribeForKeyboardEventsFunction = + platformDepMethodsHolder.subscribeForKeyboardEvents; + unsubscribeFromKeyboardEventsFunction = + platformDepMethodsHolder.unsubscribeFromKeyboardEvents; } void NativeReanimatedModule::installCoreFunctions( @@ -327,4 +333,38 @@ void NativeReanimatedModule::unregisterSensor( animatedSensorModule.unregisterSensor(sensorId); } +jsi::Value NativeReanimatedModule::subscribeForKeyboardEvents( + jsi::Runtime &rt, + const jsi::Value &keyboardEventContainer) { + jsi::Object keyboardEventObj = keyboardEventContainer.getObject(rt); + std::unordered_map> + sharedProperties; + std::shared_ptr keyboardStateShared = ShareableValue::adapt( + rt, keyboardEventObj.getProperty(rt, "state"), this); + std::shared_ptr heightShared = ShareableValue::adapt( + rt, keyboardEventObj.getProperty(rt, "height"), this); + + auto keyboardEventDataUpdater = + [this, &rt, keyboardStateShared, heightShared]( + int keyboardState, int height) { + auto &keyboardStateValue = + ValueWrapper::asMutableValue(keyboardStateShared->valueContainer); + keyboardStateValue->setValue(rt, jsi::Value(keyboardState)); + + auto &heightMutableValue = + ValueWrapper::asMutableValue(heightShared->valueContainer); + heightMutableValue->setValue(rt, jsi::Value(height)); + + this->mapperRegistry->execute(*this->runtime); + }; + + return subscribeForKeyboardEventsFunction(keyboardEventDataUpdater); +} + +void NativeReanimatedModule::unsubscribeFromKeyboardEvents( + jsi::Runtime &rt, + const jsi::Value &listenerId) { + unsubscribeFromKeyboardEventsFunction(listenerId.asNumber()); +} + } // namespace reanimated diff --git a/android/expoview/src/main/Common/cpp/headers/NativeModules/NativeReanimatedModule.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModule.h similarity index 87% rename from android/expoview/src/main/Common/cpp/headers/NativeModules/NativeReanimatedModule.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModule.h index fdcea13424d23..ec06185a2fd48 100644 --- a/android/expoview/src/main/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +++ b/android/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModule.h @@ -13,6 +13,7 @@ #include "RuntimeDecorator.h" #include "RuntimeManager.h" #include "Scheduler.h" +#include "SingleInstanceChecker.h" namespace reanimated { @@ -89,6 +90,12 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec, const jsi::Value &interval, const jsi::Value &sensorDataContainer) override; void unregisterSensor(jsi::Runtime &rt, const jsi::Value &sensorId) override; + jsi::Value subscribeForKeyboardEvents( + jsi::Runtime &rt, + const jsi::Value &keyboardEventContainer) override; + void unsubscribeFromKeyboardEvents( + jsi::Runtime &rt, + const jsi::Value &listenerId) override; private: std::shared_ptr mapperRegistry; @@ -103,6 +110,12 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec, std::shared_ptr layoutAnimationsProxy; AnimatedSensorModule animatedSensorModule; ConfigurePropsFunction configurePropsPlatformFunction; + KeyboardEventSubscribeFunction subscribeForKeyboardEventsFunction; + KeyboardEventUnsubscribeFunction unsubscribeFromKeyboardEventsFunction; + +#ifdef DEBUG + SingleInstanceChecker singleInstanceChecker_; +#endif }; } // namespace reanimated diff --git a/android/expoview/src/main/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp b/android/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp similarity index 86% rename from android/expoview/src/main/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp index 14819e06ff1cb..eb49f1c61dab2 100644 --- a/android/expoview/src/main/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +++ b/android/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp @@ -1,5 +1,7 @@ #include "NativeReanimatedModuleSpec.h" +#include + #define SPEC_PREFIX(FN_NAME) __hostFunction_NativeReanimatedModuleSpec_##FN_NAME namespace reanimated { @@ -138,6 +140,25 @@ static jsi::Value SPEC_PREFIX(configureProps)( return jsi::Value::undefined(); } +static jsi::Value SPEC_PREFIX(subscribeForKeyboardEvents)( + jsi::Runtime &rt, + TurboModule &turboModule, + const jsi::Value *args, + size_t count) { + return static_cast(&turboModule) + ->subscribeForKeyboardEvents(rt, std::move(args[0])); +} + +static jsi::Value SPEC_PREFIX(unsubscribeFromKeyboardEvents)( + jsi::Runtime &rt, + TurboModule &turboModule, + const jsi::Value *args, + size_t count) { + static_cast(&turboModule) + ->unsubscribeFromKeyboardEvents(rt, std::move(args[0])); + return jsi::Value::undefined(); +} + NativeReanimatedModuleSpec::NativeReanimatedModuleSpec( std::shared_ptr jsInvoker) : TurboModule("NativeReanimated", jsInvoker) { @@ -163,5 +184,9 @@ NativeReanimatedModuleSpec::NativeReanimatedModuleSpec( methodMap_["unregisterSensor"] = MethodMetadata{1, SPEC_PREFIX(unregisterSensor)}; methodMap_["configureProps"] = MethodMetadata{2, SPEC_PREFIX(configureProps)}; + methodMap_["subscribeForKeyboardEvents"] = + MethodMetadata{1, SPEC_PREFIX(subscribeForKeyboardEvents)}; + methodMap_["unsubscribeFromKeyboardEvents"] = + MethodMetadata{1, SPEC_PREFIX(unsubscribeFromKeyboardEvents)}; } } // namespace reanimated diff --git a/android/expoview/src/main/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h similarity index 88% rename from android/expoview/src/main/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h index eae4509f0eb13..30d74cbb9961f 100644 --- a/android/expoview/src/main/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +++ b/android/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h @@ -4,7 +4,7 @@ #include #include -#ifdef ONANDROID +#ifdef ANDROID #include "TurboModule.h" #else #include @@ -69,6 +69,14 @@ class JSI_EXPORT NativeReanimatedModuleSpec : public TurboModule { jsi::Runtime &rt, const jsi::Value &sensorId) = 0; + // keyboard + virtual jsi::Value subscribeForKeyboardEvents( + jsi::Runtime &rt, + const jsi::Value &keyboardEventContainer) = 0; + virtual void unsubscribeFromKeyboardEvents( + jsi::Runtime &rt, + const jsi::Value &listenerId) = 0; + // other virtual jsi::Value enableLayoutAnimations( jsi::Runtime &rt, diff --git a/android/expoview/src/main/Common/cpp/Registries/EventHandlerRegistry.cpp b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/EventHandlerRegistry.cpp similarity index 100% rename from android/expoview/src/main/Common/cpp/Registries/EventHandlerRegistry.cpp rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/EventHandlerRegistry.cpp diff --git a/android/expoview/src/main/Common/cpp/headers/Registries/EventHandlerRegistry.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/EventHandlerRegistry.h similarity index 100% rename from android/expoview/src/main/Common/cpp/headers/Registries/EventHandlerRegistry.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/EventHandlerRegistry.h diff --git a/android/expoview/src/main/Common/cpp/Registries/MapperRegistry.cpp b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/MapperRegistry.cpp similarity index 99% rename from android/expoview/src/main/Common/cpp/Registries/MapperRegistry.cpp rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/MapperRegistry.cpp index dac74fb085da8..3d764d78499bf 100644 --- a/android/expoview/src/main/Common/cpp/Registries/MapperRegistry.cpp +++ b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/MapperRegistry.cpp @@ -1,8 +1,10 @@ #include "MapperRegistry.h" +#include "Mapper.h" + #include #include #include -#include "Mapper.h" +#include namespace reanimated { diff --git a/android/expoview/src/main/Common/cpp/headers/Registries/MapperRegistry.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/MapperRegistry.h similarity index 100% rename from android/expoview/src/main/Common/cpp/headers/Registries/MapperRegistry.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/MapperRegistry.h diff --git a/android/expoview/src/main/Common/cpp/Registries/WorkletsCache.cpp b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/WorkletsCache.cpp similarity index 97% rename from android/expoview/src/main/Common/cpp/Registries/WorkletsCache.cpp rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/WorkletsCache.cpp index c72e62b12d485..66409d36be938 100644 --- a/android/expoview/src/main/Common/cpp/Registries/WorkletsCache.cpp +++ b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/WorkletsCache.cpp @@ -2,6 +2,9 @@ #include "FrozenObject.h" #include "ShareableValue.h" +#include +#include + using namespace facebook; namespace reanimated { diff --git a/android/expoview/src/main/Common/cpp/headers/Registries/WorkletsCache.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/WorkletsCache.h similarity index 100% rename from android/expoview/src/main/Common/cpp/headers/Registries/WorkletsCache.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/WorkletsCache.h diff --git a/android/expoview/src/main/Common/cpp/SharedItems/FrozenObject.cpp b/android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/FrozenObject.cpp similarity index 100% rename from android/expoview/src/main/Common/cpp/SharedItems/FrozenObject.cpp rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/FrozenObject.cpp diff --git a/android/expoview/src/main/Common/cpp/headers/SharedItems/FrozenObject.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/FrozenObject.h similarity index 100% rename from android/expoview/src/main/Common/cpp/headers/SharedItems/FrozenObject.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/FrozenObject.h diff --git a/android/expoview/src/main/Common/cpp/headers/SharedItems/HostFunctionHandler.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/HostFunctionHandler.h similarity index 100% rename from android/expoview/src/main/Common/cpp/headers/SharedItems/HostFunctionHandler.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/HostFunctionHandler.h diff --git a/android/expoview/src/main/Common/cpp/SharedItems/MutableValue.cpp b/android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/MutableValue.cpp similarity index 99% rename from android/expoview/src/main/Common/cpp/SharedItems/MutableValue.cpp rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/MutableValue.cpp index 4fbf9c4a7d048..eebbb7753e0de 100644 --- a/android/expoview/src/main/Common/cpp/SharedItems/MutableValue.cpp +++ b/android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/MutableValue.cpp @@ -4,6 +4,8 @@ #include "ShareableValue.h" #include "SharedParent.h" +#include + namespace reanimated { void MutableValue::setValue(jsi::Runtime &rt, const jsi::Value &newValue) { diff --git a/android/expoview/src/main/Common/cpp/headers/SharedItems/MutableValue.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/MutableValue.h similarity index 100% rename from android/expoview/src/main/Common/cpp/headers/SharedItems/MutableValue.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/MutableValue.h diff --git a/android/expoview/src/main/Common/cpp/SharedItems/MutableValueSetterProxy.cpp b/android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/MutableValueSetterProxy.cpp similarity index 100% rename from android/expoview/src/main/Common/cpp/SharedItems/MutableValueSetterProxy.cpp rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/MutableValueSetterProxy.cpp diff --git a/android/expoview/src/main/Common/cpp/headers/SharedItems/MutableValueSetterProxy.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/MutableValueSetterProxy.h similarity index 100% rename from android/expoview/src/main/Common/cpp/headers/SharedItems/MutableValueSetterProxy.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/MutableValueSetterProxy.h diff --git a/android/expoview/src/main/Common/cpp/SharedItems/RemoteObject.cpp b/android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/RemoteObject.cpp similarity index 100% rename from android/expoview/src/main/Common/cpp/SharedItems/RemoteObject.cpp rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/RemoteObject.cpp diff --git a/android/expoview/src/main/Common/cpp/headers/SharedItems/RemoteObject.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/RemoteObject.h similarity index 100% rename from android/expoview/src/main/Common/cpp/headers/SharedItems/RemoteObject.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/RemoteObject.h diff --git a/android/expoview/src/main/Common/cpp/headers/SharedItems/RuntimeManager.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/RuntimeManager.h similarity index 100% rename from android/expoview/src/main/Common/cpp/headers/SharedItems/RuntimeManager.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/RuntimeManager.h diff --git a/android/expoview/src/main/Common/cpp/SharedItems/ShareableValue.cpp b/android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/ShareableValue.cpp similarity index 98% rename from android/expoview/src/main/Common/cpp/SharedItems/ShareableValue.cpp rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/ShareableValue.cpp index d65b2a16bc4ea..ef6c82466802f 100644 --- a/android/expoview/src/main/Common/cpp/SharedItems/ShareableValue.cpp +++ b/android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/ShareableValue.cpp @@ -1,10 +1,13 @@ #include +#include + #include "FrozenObject.h" #include "MutableValue.h" #include "MutableValueSetterProxy.h" #include "RemoteObject.h" #include "RuntimeDecorator.h" #include "RuntimeManager.h" +#include "ShareableValue.h" #include "SharedParent.h" namespace reanimated { @@ -394,8 +397,10 @@ jsi::Value ShareableValue::toJSValue(jsi::Runtime &rt) { } else { res = funPtr->call(rt, args, count); } - } catch (jsi::JSError &e) { - throw e; + } catch (std::exception &e) { + std::string str = e.what(); + runtimeManager->errorHandler->setError(str); + runtimeManager->errorHandler->raise(); } catch (...) { if (demangleExceptionName( abi::__cxa_current_exception_type()->name()) == diff --git a/android/expoview/src/main/Common/cpp/headers/SharedItems/ShareableValue.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/ShareableValue.h similarity index 100% rename from android/expoview/src/main/Common/cpp/headers/SharedItems/ShareableValue.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/ShareableValue.h diff --git a/android/expoview/src/main/Common/cpp/headers/SharedItems/SharedParent.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/SharedParent.h similarity index 100% rename from android/expoview/src/main/Common/cpp/headers/SharedItems/SharedParent.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/SharedParent.h diff --git a/android/expoview/src/main/Common/cpp/headers/SharedItems/ValueWrapper.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/ValueWrapper.h similarity index 100% rename from android/expoview/src/main/Common/cpp/headers/SharedItems/ValueWrapper.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/ValueWrapper.h diff --git a/android/expoview/src/main/Common/cpp/headers/SpecTools/ErrorHandler.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/SpecTools/ErrorHandler.h similarity index 100% rename from android/expoview/src/main/Common/cpp/headers/SpecTools/ErrorHandler.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/SpecTools/ErrorHandler.h diff --git a/android/expoview/src/main/Common/cpp/Tools/FeaturesConfig.cpp b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/FeaturesConfig.cpp similarity index 100% rename from android/expoview/src/main/Common/cpp/Tools/FeaturesConfig.cpp rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/FeaturesConfig.cpp diff --git a/android/expoview/src/main/Common/cpp/headers/Tools/FeaturesConfig.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/FeaturesConfig.h similarity index 100% rename from android/expoview/src/main/Common/cpp/headers/Tools/FeaturesConfig.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/FeaturesConfig.h diff --git a/android/expoview/src/main/Common/cpp/Tools/JSIStoreValueUser.cpp b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/JSIStoreValueUser.cpp similarity index 97% rename from android/expoview/src/main/Common/cpp/Tools/JSIStoreValueUser.cpp rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/JSIStoreValueUser.cpp index 08427be5f6d98..546a85f8cdb5d 100644 --- a/android/expoview/src/main/Common/cpp/Tools/JSIStoreValueUser.cpp +++ b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/JSIStoreValueUser.cpp @@ -1,6 +1,6 @@ #include "JSIStoreValueUser.h" #include "RuntimeManager.h" -#ifdef ONANDROID +#ifdef ANDROID #include #endif @@ -32,7 +32,7 @@ StoreUser::~StoreUser() { std::shared_ptr strongScheduler = scheduler.lock(); if (strongScheduler != nullptr) { std::shared_ptr sud = storeUserData; -#ifdef ONANDROID +#ifdef ANDROID jni::ThreadScope::WithClassLoader([&] { strongScheduler->scheduleOnUI([id, sud]() { const std::lock_guard lock(sud->storeMutex); diff --git a/android/expoview/src/main/Common/cpp/headers/Tools/JSIStoreValueUser.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/JSIStoreValueUser.h similarity index 100% rename from android/expoview/src/main/Common/cpp/headers/Tools/JSIStoreValueUser.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/JSIStoreValueUser.h diff --git a/android/expoview/src/main/Common/cpp/Tools/Mapper.cpp b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/Mapper.cpp similarity index 100% rename from android/expoview/src/main/Common/cpp/Tools/Mapper.cpp rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/Mapper.cpp diff --git a/android/expoview/src/main/Common/cpp/headers/Tools/Mapper.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/Mapper.h similarity index 100% rename from android/expoview/src/main/Common/cpp/headers/Tools/Mapper.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/Mapper.h diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/PlatformDepMethodsHolder.h similarity index 83% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/PlatformDepMethodsHolder.h index 2c6558556eba7..d7dcb48793219 100644 --- a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +++ b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/PlatformDepMethodsHolder.h @@ -30,6 +30,9 @@ using ConfigurePropsFunction = std::function; +using KeyboardEventSubscribeFunction = + std::function)>; +using KeyboardEventUnsubscribeFunction = std::function; struct PlatformDepMethodsHolder { RequestRender requestRender; @@ -41,6 +44,8 @@ struct PlatformDepMethodsHolder { UnregisterSensorFunction unregisterSensor; SetGestureStateFunction setGestureStateFunction; ConfigurePropsFunction configurePropsFunction; + KeyboardEventSubscribeFunction subscribeForKeyboardEvents; + KeyboardEventUnsubscribeFunction unsubscribeFromKeyboardEvents; }; } // namespace reanimated diff --git a/android/expoview/src/main/Common/cpp/headers/Tools/ReanimatedHiddenHeaders.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/ReanimatedHiddenHeaders.h similarity index 91% rename from android/expoview/src/main/Common/cpp/headers/Tools/ReanimatedHiddenHeaders.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/ReanimatedHiddenHeaders.h index e5f9c0844c6ba..c1a05456d8c78 100644 --- a/android/expoview/src/main/Common/cpp/headers/Tools/ReanimatedHiddenHeaders.h +++ b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/ReanimatedHiddenHeaders.h @@ -1,6 +1,6 @@ #pragma once -#if defined(ONANDROID) +#ifdef ANDROID #include "Logger.h" #include "LoggerInterface.h" #include "SpeedChecker.h" diff --git a/android/expoview/src/main/Common/cpp/Tools/RuntimeDecorator.cpp b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/RuntimeDecorator.cpp similarity index 100% rename from android/expoview/src/main/Common/cpp/Tools/RuntimeDecorator.cpp rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/RuntimeDecorator.cpp diff --git a/android/expoview/src/main/Common/cpp/headers/Tools/RuntimeDecorator.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/RuntimeDecorator.h similarity index 100% rename from android/expoview/src/main/Common/cpp/headers/Tools/RuntimeDecorator.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/RuntimeDecorator.h diff --git a/android/expoview/src/main/Common/cpp/Tools/Scheduler.cpp b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/Scheduler.cpp similarity index 100% rename from android/expoview/src/main/Common/cpp/Tools/Scheduler.cpp rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/Scheduler.cpp diff --git a/android/expoview/src/main/Common/cpp/headers/Tools/Scheduler.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/Scheduler.h similarity index 100% rename from android/expoview/src/main/Common/cpp/headers/Tools/Scheduler.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/Scheduler.h diff --git a/android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/SingleInstanceChecker.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/SingleInstanceChecker.h new file mode 100644 index 0000000000000..797afd829caaf --- /dev/null +++ b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/SingleInstanceChecker.h @@ -0,0 +1,58 @@ +#pragma once + +#ifdef DEBUG + +#include + +#include +#include + +namespace reanimated { + +// This is a class that counts how many instances of a different class there +// are. It is meant only to be used with classes that should only have one +// instance. + +template +class SingleInstanceChecker { + public: + SingleInstanceChecker(); + ~SingleInstanceChecker(); + + private: + void assertWithMessage(bool condition, std::string message) { + if (!condition) { + std::cerr << message << std::endl; + assert(condition); + } + } + + // A static field will exist separately for every class template. + // This has to be inline for automatic initialization. + inline static int instanceCount_; +}; + +template +SingleInstanceChecker::SingleInstanceChecker() { + int status = 0; + std::string className = + __cxxabiv1::__cxa_demangle(typeid(T).name(), nullptr, nullptr, &status); + + // Only one instance should exist, but it is possible for two instances + // to co-exist during a reload. + assertWithMessage( + instanceCount_ <= 1, + "More than one instance of " + className + + " present. This may indicate a memory leak due to a retain cycle."); + + instanceCount_++; +} + +template +SingleInstanceChecker::~SingleInstanceChecker() { + instanceCount_--; +} + +} // namespace reanimated + +#endif // DEBUG diff --git a/android/expoview/src/main/Common/cpp/Tools/WorkletEventHandler.cpp b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/WorkletEventHandler.cpp similarity index 100% rename from android/expoview/src/main/Common/cpp/Tools/WorkletEventHandler.cpp rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/WorkletEventHandler.cpp diff --git a/android/expoview/src/main/Common/cpp/headers/Tools/WorkletEventHandler.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/WorkletEventHandler.h similarity index 100% rename from android/expoview/src/main/Common/cpp/headers/Tools/WorkletEventHandler.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/WorkletEventHandler.h diff --git a/android/expoview/src/main/Common/cpp/hidden_headers/Logger.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/hidden_headers/Logger.h similarity index 100% rename from android/expoview/src/main/Common/cpp/hidden_headers/Logger.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/hidden_headers/Logger.h diff --git a/android/expoview/src/main/Common/cpp/hidden_headers/LoggerInterface.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/hidden_headers/LoggerInterface.h similarity index 100% rename from android/expoview/src/main/Common/cpp/hidden_headers/LoggerInterface.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/hidden_headers/LoggerInterface.h diff --git a/android/expoview/src/main/Common/cpp/hidden_headers/SpeedChecker.h b/android/vendored/unversioned/react-native-reanimated/Common/cpp/hidden_headers/SpeedChecker.h similarity index 100% rename from android/expoview/src/main/Common/cpp/hidden_headers/SpeedChecker.h rename to android/vendored/unversioned/react-native-reanimated/Common/cpp/hidden_headers/SpeedChecker.h diff --git a/android/vendored/unversioned/react-native-reanimated/android/CMakeLists.txt b/android/vendored/unversioned/react-native-reanimated/android/CMakeLists.txt new file mode 100644 index 0000000000000..65c8c1d38137e --- /dev/null +++ b/android/vendored/unversioned/react-native-reanimated/android/CMakeLists.txt @@ -0,0 +1,321 @@ +project(Reanimated) +cmake_minimum_required(VERSION 3.8) + +set (CMAKE_VERBOSE_MAKEFILE ON) +set (CMAKE_CXX_STANDARD 17) +set (DEFAULT_FLAGS "-DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_HAVE_MEMRCHR=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DFOLLY_HAVE_RECVMMSG=1 -DFOLLY_HAVE_PTHREAD=1 -DANDROID -DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION} -fexceptions -fno-omit-frame-pointer -frtti -Wno-sign-compare -std=c++17 -Wall -Werror") +if(${IS_NEW_ARCHITECTURE_ENABLED}) + set (ALL_FLAGS "${DEFAULT_FLAGS} -DRCT_NEW_ARCH_ENABLED") +else() + set (ALL_FLAGS ${DEFAULT_FLAGS}) +endif() +if(${CMAKE_BUILD_TYPE} STREQUAL "Debug" AND NOT ${REANIMATED_PACKAGE_BUILD} STREQUAL "1") + set (ALL_FLAGS "${ALL_FLAGS} -DDEBUG") +endif() +set (CMAKE_CXX_FLAGS ${ALL_FLAGS}) + +if(${CMAKE_BUILD_TYPE} STREQUAL "Debug" AND NOT ${REANIMATED_PACKAGE_BUILD} STREQUAL "1") + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g") +endif() + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "") + +set (PACKAGE_NAME "reanimated") +set (BUILD_DIR ${CMAKE_SOURCE_DIR}/build) +set (SRC_DIR ${CMAKE_SOURCE_DIR}/src) + +set (COMMON_SRC_DIR "${CMAKE_SOURCE_DIR}/../Common") +if(${IS_NEW_ARCHITECTURE_ENABLED}) + if(${CLIENT_SIDE_BUILD}) + set (RN_SO_DIR "${CMAKE_SOURCE_DIR}/../../../android/app/build/react-ndk/exported") + set (FBJNI_HEADERS_DIR "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/first-party/fbjni/headers") + else() + # Reanimated Playground app + set (RN_SO_DIR "${CMAKE_SOURCE_DIR}/../${PLAYGROUND_APP_NAME}/android/app/build/react-ndk/exported") + set (FBJNI_HEADERS_DIR "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/first-party/fbjni/headers") + + endif() +else() + set (RN_SO_DIR ${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/first-party/react/jni) + set (FBJNI_HEADERS_DIR "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/first-party/fbjni/headers") +endif() + +file (GLOB LIBRN_DIR "${RN_SO_DIR}/${ANDROID_ABI}") + +file(GLOB_RECURSE SOURCES_COMMON CONFIGURE_DEPENDS "${COMMON_SRC_DIR}/cpp/**.cpp") +file(GLOB_RECURSE SOURCES_ANDROID CONFIGURE_DEPENDS "${SRC_DIR}/main/cpp/**.cpp") + +if(${REACT_NATIVE_MINOR_VERSION} LESS 66) + set ( + INCLUDE_JSI_CPP + "${REACT_NATIVE_DIR}/ReactCommon/jsi/jsi/jsi.cpp" + ) + set ( + INCLUDE_JSIDYNAMIC_CPP + "${REACT_NATIVE_DIR}/ReactCommon/jsi/jsi/JSIDynamic.cpp" + ) +endif() + +add_library( + ${PACKAGE_NAME} + SHARED + ${SOURCES_COMMON} + ${SOURCES_ANDROID} + ${INCLUDE_JSI_CPP} + ${INCLUDE_JSIDYNAMIC_CPP} +) + +# includes + +file (GLOB LIBFBJNI_INCLUDE_DIR ${FBJNI_HEADERS_DIR}) + +target_include_directories( + ${PACKAGE_NAME} + PRIVATE + "${LIBFBJNI_INCLUDE_DIR}" + "${BUILD_DIR}/third-party-ndk/boost/boost_${BOOST_VERSION}" + "${BUILD_DIR}/third-party-ndk/double-conversion" + "${BUILD_DIR}/third-party-ndk/folly" + "${BUILD_DIR}/third-party-ndk/glog/exported" + "${REACT_NATIVE_DIR}/React" + "${REACT_NATIVE_DIR}/React/Base" + "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni" + "${REACT_NATIVE_DIR}/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni" + "${REACT_NATIVE_DIR}/ReactAndroid/src/main/java/com/facebook/react/fabric/jni" + "${REACT_NATIVE_DIR}/ReactCommon" + "${REACT_NATIVE_DIR}/ReactCommon/callinvoker" + "${REACT_NATIVE_DIR}/ReactCommon/jsi" + "${REACT_NATIVE_DIR}/ReactCommon/react/renderer/graphics/platform/cxx" + "${REACT_NATIVE_DIR}/ReactCommon/runtimeexecutor" + "${REACT_NATIVE_DIR}/ReactCommon/turbomodule/core" + "${REACT_NATIVE_DIR}/ReactCommon/turbomodule" + "${REACT_NATIVE_DIR}/ReactCommon/yoga" + "${COMMON_SRC_DIR}/cpp/Tools" + "${COMMON_SRC_DIR}/cpp/SpecTools" + "${COMMON_SRC_DIR}/cpp/NativeModules" + "${COMMON_SRC_DIR}/cpp/SharedItems" + "${COMMON_SRC_DIR}/cpp/Registries" + "${COMMON_SRC_DIR}/cpp/LayoutAnimations" + "${COMMON_SRC_DIR}/cpp/AnimatedSensor" + "${COMMON_SRC_DIR}/cpp/Fabric" + "${COMMON_SRC_DIR}/cpp/hidden_headers" + "${SRC_DIR}/main/cpp" +) + +find_library( + LOG_LIB + log +) +find_library( + REACT_NATIVE_JNI_LIB + reactnativejni + PATHS ${LIBRN_DIR} + NO_CMAKE_FIND_ROOT_PATH +) +find_library( + GLOG_LIB + glog + PATHS ${LIBRN_DIR} + NO_CMAKE_FIND_ROOT_PATH +) +find_library( + FBJNI_LIB + fbjni + PATHS ${LIBRN_DIR} + NO_CMAKE_FIND_ROOT_PATH +) + +if(${REACT_NATIVE_MINOR_VERSION} LESS 69) + find_library( + FOLLY_LIB + folly_json + PATHS ${LIBRN_DIR} + NO_CMAKE_FIND_ROOT_PATH + ) +else() + find_library( + FOLLY_LIB + folly_runtime + PATHS ${LIBRN_DIR} + NO_CMAKE_FIND_ROOT_PATH + ) +endif() + +if(${REACT_NATIVE_MINOR_VERSION} LESS 66) + set (JSI_LIB "") +else() + find_library( + JSI_LIB + jsi + PATHS ${LIBRN_DIR} + NO_CMAKE_FIND_ROOT_PATH + ) +endif() + +if(${IS_NEW_ARCHITECTURE_ENABLED}) + find_library( + REACT_RENDER_UIMANAGER + react_render_uimanager + PATHS ${LIBRN_DIR} + NO_CMAKE_FIND_ROOT_PATH + ) + find_library( + REACT_RENDER_MOUNTING + react_render_mounting + PATHS ${LIBRN_DIR} + NO_CMAKE_FIND_ROOT_PATH + ) + find_library( + REACT_RENDER_COMPONENTREGISTRY + react_render_componentregistry + PATHS ${LIBRN_DIR} + NO_CMAKE_FIND_ROOT_PATH + ) + find_library( + REACT_RENDER_CORE + react_render_core + PATHS ${LIBRN_DIR} + NO_CMAKE_FIND_ROOT_PATH + ) + find_library( + REACT_DEBUG + react_debug + PATHS ${LIBRN_DIR} + NO_CMAKE_FIND_ROOT_PATH + ) + find_library( + REACT_RENDER_DEBUG + react_render_debug + PATHS ${LIBRN_DIR} + NO_CMAKE_FIND_ROOT_PATH + ) + find_library( + RRC_ROOT + rrc_root + PATHS ${LIBRN_DIR} + NO_CMAKE_FIND_ROOT_PATH + ) + find_library( + RRC_VIEW + rrc_view + PATHS ${LIBRN_DIR} + NO_CMAKE_FIND_ROOT_PATH + ) + find_library( + REACT_RENDER_SCHEDULER + react_render_scheduler + PATHS ${LIBRN_DIR} + NO_CMAKE_FIND_ROOT_PATH + ) + find_library( + FABRICJNI + fabricjni + PATHS ${LIBRN_DIR} + NO_CMAKE_FIND_ROOT_PATH + ) +endif() + +# build shared lib + +set_target_properties(${PACKAGE_NAME} PROPERTIES LINKER_LANGUAGE CXX) + + +target_link_libraries( + ${PACKAGE_NAME} + ${LOG_LIB} + ${JSI_LIB} + ${GLOG_LIB} + ${FBJNI_LIB} + ${FOLLY_LIB} + ${REACT_NATIVE_JNI_LIB} + android +) + +if(${JS_RUNTIME} STREQUAL "hermes") + string(APPEND CMAKE_CXX_FLAGS " -DJS_RUNTIME_HERMES=1") + if(${REACT_NATIVE_MINOR_VERSION} LESS 69) + # From `hermes-engine` npm package + target_include_directories( + ${PACKAGE_NAME} + PRIVATE + "${JS_RUNTIME_DIR}/android/include" + ) + else() + # Bundled Hermes from module `com.facebook.react:hermes-engine` or project `:ReactAndroid:hermes-engine` + target_include_directories( + ${PACKAGE_NAME} + PRIVATE + "${JS_RUNTIME_DIR}/API" + "${JS_RUNTIME_DIR}/public" + ) + endif() + target_link_libraries( + ${PACKAGE_NAME} + "${BUILD_DIR}/third-party-ndk/hermes/jni/${ANDROID_ABI}/libhermes.so" + ) +elseif(${JS_RUNTIME} STREQUAL "v8") + string(APPEND CMAKE_CXX_FLAGS " -DJS_RUNTIME_V8=1") + target_include_directories( + ${PACKAGE_NAME} + PRIVATE + "${JS_RUNTIME_DIR}/src" + ) + file (GLOB V8_SO_DIR "${JS_RUNTIME_DIR}/android/build/intermediates/library_jni/*/jni/${ANDROID_ABI}") + find_library( + V8EXECUTOR_LIB + v8executor + PATHS ${V8_SO_DIR} + NO_CMAKE_FIND_ROOT_PATH + ) + target_link_libraries( + ${PACKAGE_NAME} + ${V8EXECUTOR_LIB} + ) +else() + string(APPEND CMAKE_CXX_FLAGS " -DJS_RUNTIME_JSC=1") + find_library( + JSEXECUTOR_LIB + jscexecutor + PATHS ${LIBRN_DIR} + NO_CMAKE_FIND_ROOT_PATH + ) + target_link_libraries( + ${PACKAGE_NAME} + ${JSEXECUTOR_LIB} + ) +endif() + +if(${IS_NEW_ARCHITECTURE_ENABLED}) + target_link_libraries( + ${PACKAGE_NAME} + ${REACT_RENDER_UIMANAGER} + ${REACT_RENDER_MOUNTING} + ${REACT_RENDER_COMPONENTREGISTRY} + ${REACT_RENDER_CORE} + ${REACT_DEBUG} + ${REACT_RENDER_DEBUG} + ${RRC_ROOT} + ${RRC_VIEW} + ${FABRICJNI} + ${REACT_RENDER_SCHEDULER} + ) +endif() + +if(${REACT_NATIVE_MINOR_VERSION} LESS 64) + add_library( + turbomodulejsijni + # Sets the library as a shared library. + SHARED + # Provides a relative path to your source file(s). + ./empty.cpp + ) +endif() + +# Resolves "CMake Warning: Manually-specified variables were not used by the project" +# when any of the following variables is not used in some build configuration. +set (ignoreMe "${CLIENT_SIDE_BUILD}") +set (ignoreMe "${JS_RUNTIME_DIR}") +set (ignoreMe "${PLAYGROUND_APP_NAME}") +set (ignoreMe "${HERMES_ENABLE_DEBUGGER}") diff --git a/android/vendored/unversioned/react-native-reanimated/android/README.md b/android/vendored/unversioned/react-native-reanimated/android/README.md new file mode 100644 index 0000000000000..b8a0f807bdac5 --- /dev/null +++ b/android/vendored/unversioned/react-native-reanimated/android/README.md @@ -0,0 +1,15 @@ + +README +====== + +If you want to publish the lib as a maven dependency, follow these steps before publishing a new version to npm: + +1. Be sure to have the Android [SDK](https://developer.android.com/studio/index.html) and [NDK](https://developer.android.com/ndk/guides/index.html) installed +2. Be sure to have a `local.properties` file in this folder that points to the Android SDK and NDK +``` +ndk.dir=/Users/{username}/Library/Android/sdk/ndk-bundle +sdk.dir=/Users/{username}/Library/Android/sdk +``` +3. Delete the `maven` folder +4. Run `sudo ./gradlew installArchives` +5. Verify that latest set of generated files is in the maven folder with the correct version number diff --git a/android/vendored/unversioned/react-native-reanimated/android/build.gradle b/android/vendored/unversioned/react-native-reanimated/android/build.gradle new file mode 100644 index 0000000000000..fe523cfa55145 --- /dev/null +++ b/android/vendored/unversioned/react-native-reanimated/android/build.gradle @@ -0,0 +1,1016 @@ +import com.android.Version +import org.apache.tools.ant.filters.ReplaceTokens + +import java.nio.file.Paths + +/** + * Finds the path of the installed npm package with the given name using Node's + * module resolution algorithm, which searches "node_modules" directories up to + * the file system root. This handles various cases, including: + * + * - Working in the open-source RN repo: + * Gradle: /path/to/react-native/ReactAndroid + * Node module: /path/to/react-native/node_modules/[package] + * + * - Installing RN as a dependency of an app and searching for hoisted + * dependencies: + * Gradle: /path/to/app/node_modules/react-native/ReactAndroid + * Node module: /path/to/app/node_modules/[package] + * + * - Working in a larger repo (e.g., Facebook) that contains RN: + * Gradle: /path/to/repo/path/to/react-native/ReactAndroid + * Node module: /path/to/repo/node_modules/[package] + * + * The search begins at the given base directory (a File object). The returned + * path is a string. + */ +static def findNodeModulePath(baseDir, packageName) { + def basePath = baseDir.toPath().normalize() + // Node's module resolution algorithm searches up to the root directory, + // after which the base path will be null + while (basePath) { + def candidatePath = Paths.get(basePath.toString(), "node_modules", packageName) + if (candidatePath.toFile().exists()) { + return candidatePath.toString() + } + basePath = basePath.getParent() + } + return null +} + +def safeExtGet(prop, fallback) { + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback +} + +def safeAppExtGet(prop, fallback) { + def appProject = null + try { + appProject = project(":app") + } catch(Exception e) { + return fallback + } + appProject?.ext?.has(prop) ? appProject.ext.get(prop) : fallback +} + +def resolveBuildType() { + Gradle gradle = getGradle() + String tskReqStr = gradle.getStartParameter().getTaskRequests()['args'].toString() + + return tskReqStr.contains('Release') ? 'release' : 'debug' +} + +def resolveClientSideBuild() { + def clientSideBuild = System.getenv("CLIENT_SIDE_BUILD") + if (clientSideBuild != null) { + return clientSideBuild == "True" + } + + if (hasProperty("clientSideBuild")) { + return property("clientSideBuild") == "true" + } + + if (isDeveloperMode()) { + return false + } + + return true +} + +def isDeveloperMode() { + // developer mode, to run Example app + return safeAppExtGet("isReanimatedExampleApp", false) || System.getenv("REANIMATED_PACKAGE_BUILD") == "1" +} + +def isNewArchitectureEnabled() { + // To opt-in for the New Architecture, you can either: + // - Set `newArchEnabled` to true inside the `gradle.properties` file + // - Invoke gradle with `-newArchEnabled=true` + // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true` + return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true" +} + +def resolveReactNativeDirectory() { + def reactNativeLocation = safeAppExtGet("REACT_NATIVE_NODE_MODULES_DIR", null) + if (reactNativeLocation != null) { + return file(reactNativeLocation) + } + + if (isDeveloperMode()) { + return file("$projectDir/../${getPlaygroundAppName()}/node_modules/react-native") + } + + // monorepo workaround + // react-native can be hoisted or in project's own node_modules + def reactNativeFromProjectNodeModules = file("${rootProject.projectDir}/../node_modules/react-native") + if (reactNativeFromProjectNodeModules.exists()) { + return reactNativeFromProjectNodeModules + } + + def reactNativeFromNodeModulesWithReanimated = file("${projectDir}/../../react-native") + if (reactNativeFromNodeModulesWithReanimated.exists()) { + return reactNativeFromNodeModulesWithReanimated + } + + throw new Exception( + "[Reanimated] Unable to resolve react-native location in " + + "node_modules. You should project extension property (in app/build.gradle) " + + "`REACT_NATIVE_NODE_MODULES_DIR` with path to react-native." + ) +} + +def getPlaygroundAppName() { // only for the development + String playgroundAppName = "" + try { + rootProject.getSubprojects().forEach({project -> + if (project.plugins.hasPlugin("com.android.application")) { + var projectCatalogAbsolutePath = project.projectDir.toString().replace("/android/app", "") + var slashPosition = projectCatalogAbsolutePath.lastIndexOf("/") + playgroundAppName = projectCatalogAbsolutePath.substring(slashPosition + 1) + } + }) + } catch(_) { + return "NOT_FOUND" + } + return playgroundAppName +} + +def shouldAssertNoMultipleInstances() { + if (rootProject.hasProperty("disableMultipleInstancesCheck")) { + return rootProject.property("disableMultipleInstancesCheck") != "true" + } else { + return true + } +} + +def findReanimatedInstancesForPath(String path) { + return fileTree(path) { + include "**/react-native-reanimated/package.json" + exclude "**/.yarn/**" + exclude {{ file, attr -> attr.isSymbolicLink() }} + }.files +} + +def assertNoMultipleInstances() { + // Assert there are no multiple installations of Reanimated + Set files + if (projectDir.path.contains(rootDir.parent)) { + // standard app + files = findReanimatedInstancesForPath(rootDir.parent + "/node_modules") + } else { + // monorepo + files = findReanimatedInstancesForPath(rootDir.parent + "/node_modules") + files.addAll( + findReanimatedInstancesForPath(file(projectDir.parent).parent) + ) + } + if (files.size() > 1) { + String parsedLocation = files.stream().map({ + File file -> "- " + file.toString().replace("/package.json", "") + }).collect().join("\n") + String exceptionMessage = "\nMultiple versions of Reanimated were detected. Only one " + + "instance of react-native-reanimated can be installed in a project. You need to " + + "resolve the conflict manually. Check out the documentation: " + + "https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/" + + "troubleshooting#multiple-versions-of-reanimated-were-detected \n\nConflict " + + "between: \n" + parsedLocation + "\n"; + throw new Exception(exceptionMessage) + } +} + +boolean CLIENT_SIDE_BUILD = resolveClientSideBuild() +if (CLIENT_SIDE_BUILD) { + configurations.maybeCreate("default") +} + +def reactNativeRootDir = resolveReactNativeDirectory() + +def reactProperties = new Properties() +file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) } + +def BOOST_VERSION = reactProperties.getProperty("BOOST_VERSION") +def DOUBLE_CONVERSION_VERSION = reactProperties.getProperty("DOUBLE_CONVERSION_VERSION") +def FOLLY_VERSION = reactProperties.getProperty("FOLLY_VERSION") +def GLOG_VERSION = reactProperties.getProperty("GLOG_VERSION") +def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME") +def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.split("\\.")[1].toInteger() +def FBJNI_VERSION = "0.3.0" +def REANIMATED_PACKAGE_BUILD = System.getenv("REANIMATED_PACKAGE_BUILD") + +// We download various C++ open-source dependencies into downloads. +// We then copy both the downloaded code and our custom makefiles and headers into third-party-ndk. +// After that we build native code from src/main/jni with module path pointing at third-party-ndk. + +def customDownloadsDir = System.getenv("REACT_NATIVE_DOWNLOADS_DIR") +def downloadsDir = customDownloadsDir ? new File(customDownloadsDir) : new File("$buildDir/downloads") +def thirdPartyNdkDir = new File("$buildDir/third-party-ndk") + +def reactNativeThirdParty = new File("$reactNativeRootDir/ReactAndroid/src/main/jni/third-party") +def reactNativeAndroidDownloadDir = new File("$reactNativeRootDir/ReactAndroid/build/downloads") + +def _stackProtectorFlag = true + +def JS_RUNTIME = { + return "hermes" // Expo Go always uses hermes + + // Returns the js runtime explicitly requested in the environment variable + if (System.getenv("JS_RUNTIME")) { + return System.getenv("JS_RUNTIME") + } + + // Detect js runtime from project setup + def defaultRuntimeType = "jsc"; + def v8Project = rootProject.getSubprojects().find { project -> project.name == "react-native-v8" } + if (v8Project != null) { + return "v8" + } + def appProject = findProject(":app") ? project(":app") : null + return appProject?.ext?.react?.enableHermes ? "hermes" : defaultRuntimeType +}.call() + +def jsRuntimeDir = { + if (JS_RUNTIME == "hermes") { + if (REACT_NATIVE_MINOR_VERSION >= 69) { + return Paths.get(reactNativeRootDir.path, "sdks", "hermes") + } else { + return Paths.get(reactNativeRootDir.path, "..", "hermes-engine") + } + } else if (JS_RUNTIME == "v8") { + return findProject(":react-native-v8").getProjectDir().getParent() + } else { + return Paths.get(reactNativeRootDir.path, "ReactCommon", "jsi") + } +}.call() + +def reactNativeArchitectures() { + def value = project.getProperties().get("reactNativeArchitectures") + return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] +} + +def detectAAR(Integer rnMinorVersion, String engine) { // Reanimated2 only + def rnMinorVersionCopy = rnMinorVersion + def aar = file("react-native-reanimated-${rnMinorVersionCopy}-${engine}.aar") + + if (aar.exists()) { + println "AAR for react-native-reanimated has been found\n$aar" + return aar + } else { + while (!aar.exists() && rnMinorVersionCopy >= 63) { + rnMinorVersionCopy -= 1 + aar = file("react-native-reanimated-${rnMinorVersionCopy}-${engine}.aar") + } + + if (rnMinorVersionCopy < 63) { + println "No AAR for react-native-reanimated found. Attempting to build from source." + } else { // aar exists, but was build for lower react-native version + println "\n\n\n" + println "****************************************************************************************" + println "\n\n\n" + println "WARNING reanimated - no version-specific reanimated AAR for react-native version $minor found." + println "Falling back to AAR for react-native version $rnMinorVersionCopy." + println "The react-native JSI interface is not ABI-safe yet, this may result in crashes." + println "Please post a pull request to implement support for react-native version $minor to the reanimated repo." + println "Thanks!" + println "\n\n\n" + println "****************************************************************************************" + + return aar + } + } + return null +} + +def isUserDemandToBuildFromSource() { // Reanimated2 only + def buildFromSourceConf = false + rootProject.getSubprojects().forEach({project -> + if (project.plugins.hasPlugin("com.android.application")) { + if ( + project.ext.has("reanimated") + && project.ext.reanimated.buildFromSource + ) { + buildFromSourceConf = true + } + } + }) + return buildFromSourceConf +} + +def shouldBuildFromSource(aar, jsRuntimeName) { // Reanimated2 only + if (jsRuntimeName == "v8") { + return true + } + else if (isDeveloperMode()) { + // Example app + return true + } + else if (isUserDemandToBuildFromSource()) { + // on user demand + return true + } + else if (aar != null) { + // when binary exist + return false + } + // when binary is not found + return true +} + +def getTaskByPath( + project, + String appName, + String secondPart, + String flavorString, + String lastPart +) { // Reanimated2 only + String pathName = "${appName}:${secondPart}${flavorString}${lastPart}" + Task task = project.getTasks().findByPath(pathName) + if (task != null) { + return task + } + pathName = "${appName}:${secondPart}${flavorString.capitalize()}${lastPart}" + return project.getTasks().findByPath(pathName) +} + +def aar = detectAAR(REACT_NATIVE_MINOR_VERSION, JS_RUNTIME) +boolean BUILD_FROM_SOURCE = shouldBuildFromSource(aar, JS_RUNTIME) + +if (!BUILD_FROM_SOURCE && !isNewArchitectureEnabled()) { // Reanimated2 only + if (REACT_NATIVE_MINOR_VERSION < 65) { + tasks.register("replaceSoTaskDebug", replaceSoTask) + tasks.register("replaceSoTaskRelease", replaceSoTask) + Task replaceSoTaskDebug = project.getTasks().findByPath(":react-native-reanimated:replaceSoTaskDebug") + Task replaceSoTaskRelease = project.getTasks().findByPath(":react-native-reanimated:replaceSoTaskRelease") + + if (replaceSoTaskDebug != null && replaceSoTaskRelease != null) { + rootProject.getSubprojects().forEach({project -> + if (project.plugins.hasPlugin("com.android.application") && project.getProperties().get("android")) { + def projectProperties = project.getProperties() + def flavorString = getCurrentFlavor() + def reanimatedConf = projectProperties.get("reanimated") + + if ( + flavorString != "NOT-FOUND" + && (!reanimatedConf || (reanimatedConf && !reanimatedConf.get("enablePackagingOptions"))) + ) { + replaceSoTask.appName = projectProperties.path + replaceSoTask.buildDir = projectProperties.buildDir + def appName = projectProperties.path + + Task debugNativeLibsTask = getTaskByPath(project, appName, "merge", flavorString, "DebugNativeLibs") + Task debugDebugSymbolsTask = getTaskByPath(project, appName, "strip", flavorString, "DebugDebugSymbols") + Task releaseNativeLibsTask = getTaskByPath(project, appName, "merge", flavorString, "ReleaseNativeLibs") + Task releaseDebugSymbolsTask = getTaskByPath(project, appName, "strip", flavorString, "ReleaseDebugSymbols") + Task debugTask = getTaskByPath(project, appName, "package", flavorString, "Debug") + Task releaseTask = getTaskByPath(project, appName, "package", flavorString, "Release") + + if ( + debugNativeLibsTask != null && debugDebugSymbolsTask != null + && releaseNativeLibsTask != null && releaseDebugSymbolsTask != null + && debugTask != null && releaseTask != null + ) { + replaceSoTaskDebug.dependsOn(debugNativeLibsTask, debugDebugSymbolsTask) + debugTask.dependsOn(replaceSoTaskDebug) + replaceSoTaskRelease.dependsOn(releaseNativeLibsTask, releaseDebugSymbolsTask) + releaseTask.dependsOn(replaceSoTaskRelease) + } + } + } + }) + } + } + + artifacts.add("default", aar) +} + +// end if already loaded aar +if (!BUILD_FROM_SOURCE) { + return +} +// You need to have following folders in this directory: +// - boost_1_63_0 +// - double-conversion-1.1.6 +// - folly-deprecate-dynamic-initializer +// - glog-0.3.5 +def dependenciesPath = System.getenv("REACT_NATIVE_DEPENDENCIES") + +// The Boost library is a very large download (>100MB). +// If Boost is already present on your system, define the REACT_NATIVE_BOOST_PATH env variable +// and the build will use that. +def boostPath = dependenciesPath ?: System.getenv("REACT_NATIVE_BOOST_PATH") + +def follyReplaceContent = ''' + ssize_t r; + do { + r = open(name, flags, mode); + } while (r == -1 && errno == EINTR); + return r; +''' + +buildscript { + repositories { + google() + mavenCentral() + maven { + url "https://plugins.gradle.org/m2/" + } + } + dependencies { + classpath "com.android.tools.build:gradle:7.3.0" + classpath "de.undercouch:gradle-download-task:5.0.1" + classpath "com.diffplug.spotless:spotless-plugin-gradle:6.11.0" + } +} + +if (project == rootProject) { + apply from: "spotless.gradle" +} + +apply plugin: "com.android.library" +apply plugin: "maven-publish" +apply plugin: "de.undercouch.download" + +android { + compileSdkVersion safeExtGet("compileSdkVersion", 30) + defaultConfig { + minSdkVersion safeExtGet("minSdkVersion", 16) + targetSdkVersion safeExtGet("targetSdkVersion", 30) + versionCode 1 + versionName "1.0" + buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() + externalNativeBuild { + cmake { + arguments "-DANDROID_STL=c++_shared", + "-DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION}", + "-DANDROID_TOOLCHAIN=clang", + "-DBOOST_VERSION=${BOOST_VERSION}", + "-DREACT_NATIVE_DIR=${reactNativeRootDir.path}", + "-DJS_RUNTIME=${JS_RUNTIME}", + "-DJS_RUNTIME_DIR=${jsRuntimeDir}", + "-DCLIENT_SIDE_BUILD=${CLIENT_SIDE_BUILD}", + "-DIS_NEW_ARCHITECTURE_ENABLED=${isNewArchitectureEnabled()}", + "-DPLAYGROUND_APP_NAME=${getPlaygroundAppName()}", + "-DREANIMATED_PACKAGE_BUILD=${REANIMATED_PACKAGE_BUILD}" + abiFilters (*reactNativeArchitectures()) + _stackProtectorFlag ? (cppFlags("-fstack-protector-all")) : null + } + } + + buildConfigField("boolean", "IS_INTERNAL_BUILD", "false") + buildConfigField("int", "EXOPACKAGE_FLAGS", "0") + buildConfigField("int", "REACT_NATIVE_MINOR_VERSION", REACT_NATIVE_MINOR_VERSION.toString()) + } + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } + buildTypes { + debug { + externalNativeBuild { + cmake { + if (JS_RUNTIME == "hermes") { + arguments "-DHERMES_ENABLE_DEBUGGER=1" + } else { + arguments "-DHERMES_ENABLE_DEBUGGER=0" + } + } + } + } + release { + externalNativeBuild { + cmake { + arguments "-DHERMES_ENABLE_DEBUGGER=0" + } + } + } + } + lintOptions { + abortOnError false + } + packagingOptions { + doNotStrip resolveBuildType() == 'debug' ? "**/**/*.so" : '' + excludes = [ + "META-INF", + "META-INF/**", + "**/libc++_shared.so", + "**/libfbjni.so", + "**/libjsi.so", + "**/libfolly_json.so", + "**/libfolly_runtime.so", + "**/libglog.so", + "**/libhermes.so", + "**/libhermes-executor-debug.so", + "**/libreactnativejni.so", + "**/libjscexecutor.so", + "**/libv8executor.so", + ] + } + tasks.withType(JavaCompile) { + compileTask -> + compileTask.dependsOn(packageNdkLibs) + } + configurations { + extractHeaders + extractSO + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + packagingOptions { + // For some reason gradle only complains about the duplicated version of librrc_root and libreact_render libraries + // while there are more libraries copied in intermediates folder of the lib build directory, we exclude + // only the ones that make the build fail (ideally we should only include libreanimated but we + // are only allowed to specify exlude patterns) + exclude "**/libreact_render*.so" + exclude "**/librrc_root.so" + } + sourceSets.main { + java { + if (isNewArchitectureEnabled()) { + srcDirs += [ + "src/fabric/java", + ] + } else { + srcDirs += [ + "src/paper/java", + ] + } + } + } +} + +def assertionTask = task assertNoMultipleInstancesTask { + onlyIf { shouldAssertNoMultipleInstances() && CLIENT_SIDE_BUILD } + doFirst { + assertNoMultipleInstances() + } +} + +tasks.preBuild { + dependsOn assertionTask +} + +task cleanCmakeCache() { + tasks.getByName("clean").dependsOn(cleanCmakeCache) + doFirst { + delete "${projectDir}/.cxx" + } +} + +task printVersions { + println "Android gradle plugin: ${Version.ANDROID_GRADLE_PLUGIN_VERSION}" + println "Gradle: ${project.gradle.gradleVersion}" +} + +task Log { + println("building Reanimated2") +} + +task applyJavaPatches(type: Copy) { + def patchDirectory = file("${projectDir}/rnVersionPatch/${REACT_NATIVE_MINOR_VERSION}") + if (patchDirectory.exists()) { + from ("${patchDirectory}") { + include "**/*.java" + } + into ("${projectDir}/src/main/java/com/swmansion/reanimated") + } +} + +task createNativeDepsDirectories(dependsOn: applyJavaPatches) { + downloadsDir.mkdirs() + thirdPartyNdkDir.mkdirs() +} + +def resolveTaskFactory(String taskName, String artifactLocalName, File reactNativeAndroidDownloadDir, File reanimatedDownloadDir) { + return tasks.create(name: taskName, dependsOn: createNativeDepsDirectories, type: Copy) { + from reactNativeAndroidDownloadDir + include artifactLocalName + into reanimatedDownloadDir + + onlyIf { + // First we check whether the file is already in our download directory + if (file("$reanimatedDownloadDir/$artifactLocalName").isFile()) { + return false + } + + // If it is not the case we check whether it was downloaded by ReactAndroid project + if (file("$reactNativeAndroidDownloadDir/$artifactLocalName").isFile()) { + return true + } + + return false + } + } +} + +Task resolveBoost = resolveTaskFactory("resolveBoost", "boost_${BOOST_VERSION}.tar.gz", reactNativeAndroidDownloadDir, downloadsDir) +Task resolveDoubleConversion = resolveTaskFactory( + "resolveDoubleConversion", + "double-conversion-${DOUBLE_CONVERSION_VERSION}.tar.gz", + reactNativeAndroidDownloadDir, + downloadsDir +) +Task resolveFolly = resolveTaskFactory("resolveFolly", "folly-${FOLLY_VERSION}.tar.gz", reactNativeAndroidDownloadDir, downloadsDir) +Task resolveGlog = resolveTaskFactory("resolveGlog", "glog-${GLOG_VERSION}.tar.gz", reactNativeAndroidDownloadDir, downloadsDir) + +if (isNewArchitectureEnabled()) { + def reactNativeAndroidProject = findProject(":ReactAndroid") + if (reactNativeAndroidProject != null) { + reactNativeAndroidProject.afterEvaluate { + def resolveTasks = [resolveBoost, resolveGlog, resolveDoubleConversion, resolveFolly] + resolveTasks.forEach({ task -> + String reactAndroidDownloadTaskName = "download" + task.name.replace("resolve", "") + def reactAndroidDownloadTask = reactNativeAndroidProject.getTasks().findByName(reactAndroidDownloadTaskName) + if (reactAndroidDownloadTask != null) { + task.dependsOn(reactAndroidDownloadTask) + } else { + logger.warn("[Reanimated] Failed to find task named `$reactAndroidDownloadTaskName` in `:ReactAndroid` project." + + " Explicit dependency between it and $task.name task can not be set.") + } + }) + } + } else { + throw new GradleScriptException("[Reanimated] Failed to find `:ReactAndroid` project. Explicit dependency between download tasks can not be set.") + } +} + +task downloadBoost(dependsOn: resolveBoost, type: Download) { + def transformedVersion = BOOST_VERSION.replace("_", ".") + def artifactLocalName = "boost_${BOOST_VERSION}.tar.gz" + def srcUrl = "https://boostorg.jfrog.io/artifactory/main/release/${transformedVersion}/source/boost_${BOOST_VERSION}.tar.gz" + if (REACT_NATIVE_MINOR_VERSION < 69) { + srcUrl = "https://github.com/react-native-community/boost-for-react-native/releases/download/v${transformedVersion}-0/boost_${BOOST_VERSION}.tar.gz" + } + src(srcUrl) + onlyIfNewer(true) + overwrite(false) + dest(new File(downloadsDir, artifactLocalName)) +} + +task prepareBoost(dependsOn: boostPath ? [] : [downloadBoost], type: Copy) { + from(boostPath ?: tarTree(resources.gzip(downloadBoost.dest))) + from("$reactNativeThirdParty/boost/Android.mk") + include("Android.mk", "boost_${BOOST_VERSION}/boost/**/*.hpp", "boost/boost/**/*.hpp") + includeEmptyDirs = false + into("$thirdPartyNdkDir/boost") + doLast { + file("$thirdPartyNdkDir/boost/boost").renameTo("$thirdPartyNdkDir/boost/boost_${BOOST_VERSION}") + } +} + +task downloadDoubleConversion(dependsOn: resolveDoubleConversion, type: Download) { + src("https://github.com/google/double-conversion/archive/v${DOUBLE_CONVERSION_VERSION}.tar.gz") + onlyIfNewer(true) + overwrite(false) + dest(new File(downloadsDir, "double-conversion-${DOUBLE_CONVERSION_VERSION}.tar.gz")) +} + +task prepareDoubleConversion(dependsOn: dependenciesPath ? [] : [downloadDoubleConversion], type: Copy) { + from(dependenciesPath ?: tarTree(downloadDoubleConversion.dest)) + from("$reactNativeThirdParty/double-conversion/Android.mk") + include("double-conversion-${DOUBLE_CONVERSION_VERSION}/src/**/*", "Android.mk") + filesMatching("*/src/**/*", { fname -> fname.path = "double-conversion/${fname.name}" }) + includeEmptyDirs = false + into("$thirdPartyNdkDir/double-conversion") +} + +task downloadFolly(dependsOn: resolveFolly, type: Download) { + src("https://github.com/facebook/folly/archive/v${FOLLY_VERSION}.tar.gz") + onlyIfNewer(true) + overwrite(false) + dest(new File(downloadsDir, "folly-${FOLLY_VERSION}.tar.gz")) +} + +task prepareFolly(dependsOn: dependenciesPath ? [] : [downloadFolly], type: Copy) { + from(dependenciesPath ?: tarTree(downloadFolly.dest)) + from("$reactNativeThirdParty/folly/Android.mk") + include("folly-${FOLLY_VERSION}/folly/**/*", "Android.mk") + eachFile { fname -> fname.path = (fname.path - "folly-${FOLLY_VERSION}/") } + // Fixes problem with Folly failing to build on certain systems. See + // https://github.com/software-mansion/react-native-reanimated/issues/1024 + filter { line -> line.replaceAll("return int\\(wrapNoInt\\(open, name, flags, mode\\)\\);", follyReplaceContent) } + includeEmptyDirs = false + into("$thirdPartyNdkDir/folly") +} + +task downloadGlog(dependsOn: resolveGlog, type: Download) { + src("https://github.com/google/glog/archive/v${GLOG_VERSION}.tar.gz") + onlyIfNewer(true) + overwrite(false) + dest(new File(downloadsDir, "glog-${GLOG_VERSION}.tar.gz")) +} + +// Prepare glog sources to be compiled, this task will perform steps that normally should've been +// executed by automake. This way we can avoid dependencies on make/automake +task prepareGlog(dependsOn: dependenciesPath ? [] : [downloadGlog], type: Copy) { + duplicatesStrategy = "include" + from(dependenciesPath ?: tarTree(downloadGlog.dest)) + from("$reactNativeThirdParty/glog/") + include("glog-${GLOG_VERSION}/src/**/*", "Android.mk", "config.h") + includeEmptyDirs = false + filesMatching("**/*.h.in") { + filter(ReplaceTokens, tokens: [ + ac_cv_have_unistd_h : "1", + ac_cv_have_stdint_h : "1", + ac_cv_have_systypes_h : "1", + ac_cv_have_inttypes_h : "1", + ac_cv_have_libgflags : "0", + ac_google_start_namespace : "namespace google {", + ac_cv_have_uint16_t : "1", + ac_cv_have_u_int16_t : "1", + ac_cv_have___uint16 : "0", + ac_google_end_namespace : "}", + ac_cv_have___builtin_expect : "1", + ac_google_namespace : "google", + ac_cv___attribute___noinline : "__attribute__ ((noinline))", + ac_cv___attribute___noreturn : "__attribute__ ((noreturn))", + ac_cv___attribute___printf_4_5: "__attribute__((__format__ (__printf__, 4, 5)))" + ]) + it.path = (it.name - ".in") + } + into("$thirdPartyNdkDir/glog") + + doLast { + copy { + from(fileTree(dir: "$thirdPartyNdkDir/glog", includes: ["stl_logging.h", "logging.h", "raw_logging.h", "vlog_is_on.h", "**/src/glog/log_severity.h"]).files) + includeEmptyDirs = false + into("$thirdPartyNdkDir/glog/exported/glog") + } + } +} + +/* +Reanimated includes "hermes/hermes.h" header file in `NativeProxy.cpp`. +Previously, we used header files from `hermes-engine` package in `node_modules`. +Starting from React Native 0.69, Hermes is no longer distributed as package on NPM. +On the new architecture, Hermes is downloaded from GitHub and then compiled from sources. +However, on the old architecture, we need to download Hermes header files on our own +as well as unzip Hermes AAR in order to obtain `libhermes.so` shared library. +For more details, see https://reactnative.dev/architecture/bundled-hermes +or https://github.com/reactwg/react-native-new-architecture/discussions/4 +*/ +if (REACT_NATIVE_MINOR_VERSION >= 69 && !isNewArchitectureEnabled()) { + // copied from `react-native/ReactAndroid/hermes-engine/build.gradle` + + def downloadDir = customDownloadsDir ? new File(customDownloadsDir) : new File(reactNativeRootDir, "sdks/download") + + // By default we are going to download and unzip hermes inside the /sdks/hermes folder + // but you can provide an override for where the hermes source code is located. + def hermesDir = System.getenv("REACT_NATIVE_OVERRIDE_HERMES_DIR") ?: new File(reactNativeRootDir, "sdks/hermes") + + def hermesVersion = "main" + def hermesVersionFile = new File(reactNativeRootDir, "sdks/.hermesversion") + if (hermesVersionFile.exists()) { + hermesVersion = hermesVersionFile.text + } + + task downloadHermes(type: Download) { + src("https://github.com/facebook/hermes/tarball/${hermesVersion}") + onlyIfNewer(true) + overwrite(false) + dest(new File(downloadDir, "hermes.tar.gz")) + } + + task unzipHermes(dependsOn: downloadHermes, type: Copy) { + from(tarTree(downloadHermes.dest)) { + eachFile { file -> + // We flatten the unzip as the tarball contains a `facebook-hermes-` + // folder at the top level. + if (file.relativePath.segments.size() > 1) { + file.relativePath = new RelativePath(!file.isDirectory(), file.relativePath.segments.drop(1)) + } + } + } + into(hermesDir) + } +} + +task prepareHermes() { + if (REACT_NATIVE_MINOR_VERSION >= 69) { + if (!isNewArchitectureEnabled()) { + dependsOn(unzipHermes) + } + + doLast { + // e.g. hermes-engine-0.70.0-rc.1-debug.aar + def hermesAAR = file( + "$reactNativeRootDir/android/com/facebook/react/hermes-engine/" + + "${REACT_NATIVE_VERSION}/hermes-engine-${REACT_NATIVE_VERSION}-" + + "${resolveBuildType()}.aar" + ) + if (!hermesAAR.exists()) { + throw new GradleScriptException("Could not find hermes-engine AAR", null) + } + + def soFiles = zipTree(hermesAAR).matching({ it.include "**/*.so" }) + + copy { + from soFiles + from "$reactNativeRootDir/ReactAndroid/src/main/jni/first-party/hermes/Android.mk" + into "$thirdPartyNdkDir/hermes" + } + } + } else { + doLast { + def hermesPackagePath = findNodeModulePath(projectDir, "hermes-engine") + if (!hermesPackagePath) { + throw new GradleScriptException("Could not find the hermes-engine npm package", null) + } + + def hermesAAR = file("$hermesPackagePath/android/hermes-${resolveBuildType()}.aar") // e.g. hermes-debug.aar + if (!hermesAAR.exists()) { + throw new GradleScriptException("The hermes-engine npm package is missing \"android/hermes-${resolveBuildType()}.aar\"", null) + } + + def soFiles = zipTree(hermesAAR).matching({ it.include "**/*.so" }) + + copy { + from soFiles + from "$reactNativeRootDir/ReactAndroid/src/main/jni/first-party/hermes/Android.mk" + into "$thirdPartyNdkDir/hermes" + } + } + } +} + +task prepareJSC { + doLast { + def jscPackagePath = findNodeModulePath(projectDir, "jsc-android") + if (!jscPackagePath) { + throw new GradleScriptException("Could not find the jsc-android npm package", null) + } + + def jscDist = file("$jscPackagePath/dist") + if (!jscDist.exists()) { + throw new GradleScriptException("The jsc-android npm package is missing its \"dist\" directory", null) + } + + def jscAAR = fileTree(jscDist).matching({ it.include "**/android-jsc/**/*.aar" }).singleFile + def soFiles = zipTree(jscAAR).matching({ it.include "**/*.so" }) + + def headerFiles = fileTree(jscDist).matching({ it.include "**/include/*.h" }) + + copy { + from(soFiles) + from(headerFiles) + from("$reactNativeRootDir/ReactAndroid/src/main/jni/third-party/jsc/Android.mk") + + filesMatching("**/*.h", { it.path = "JavaScriptCore/${it.name}" }) + + includeEmptyDirs(false) + into("$thirdPartyNdkDir/jsc") + } + } +} + +task extractAARHeaders { + doLast { + configurations.extractHeaders.files.each { + def file = it.absoluteFile + def packageName = file.name.tokenize('-')[0] + copy { + from zipTree(file) + into "$reactNativeRootDir/ReactAndroid/src/main/jni/first-party/$packageName/headers" + include "**/*.h" + } + } + } +} + +task extractSOFiles { + doLast { + configurations.extractSO.files.each { + def file = it.absoluteFile + def packageName = file.name.tokenize('-')[0] + copy { + from zipTree(file) + into "$reactNativeRootDir/ReactAndroid/src/main/jni/first-party/$packageName/" + include "jni/**/*.so" + } + } + } +} + +task packageNdkLibs(type: Copy) { + from("$buildDir/reanimated-ndk/all") + include("**/libreanimated.so") + if(REACT_NATIVE_MINOR_VERSION < 64) { + include("**/libturbomodulejsijni.so") + } + into("$projectDir/src/main/jniLibs") +} + +repositories { + mavenCentral() + mavenLocal() + maven { + // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm + url "$reactNativeRootDir/android" + } + maven { + // Android JSC is installed from npm + url "$reactNativeRootDir/../jsc-android/dist" + } + google() +} + +dependencies { + // noinspection GradleDynamicVersion + implementation "com.facebook.yoga:proguard-annotations:1.19.0" + if (isDeveloperMode() && !isNewArchitectureEnabled()) { + implementation "com.facebook.fbjni:fbjni:" + FBJNI_VERSION + } + else { + implementation "com.facebook.fbjni:fbjni-java-only:" + FBJNI_VERSION + } + implementation "com.facebook.react:react-native:+" // From node_modules + implementation "androidx.transition:transition:1.1.0" + implementation "androidx.core:core:1.6.0" + + extractHeaders("com.facebook.fbjni:fbjni:" + FBJNI_VERSION + ":headers") + extractSO("com.facebook.fbjni:fbjni:" + FBJNI_VERSION) + + def jscAAR = fileTree("$reactNativeRootDir/../jsc-android/dist/org/webkit/android-jsc").matching({ it.include "**/**/*.aar" }).singleFile + extractSO(files(jscAAR)) +} + +task unpackReactNativeAAR { + def buildType = resolveBuildType() + def rnAarMatcher = "**/react-native/**/*${buildType}.aar" + if (REACT_NATIVE_MINOR_VERSION < 69) { + rnAarMatcher = "**/**/*.aar" + } + def rnAAR = fileTree("$reactNativeRootDir/android").matching({ it.include rnAarMatcher }).singleFile + def file = rnAAR.absoluteFile + def packageName = file.name.tokenize('-')[0] + copy { + from zipTree(file) + into "$reactNativeRootDir/ReactAndroid/src/main/jni/first-party/$packageName/" + include "jni/**/*.so" + } +} + +task downloadNdkBuildDependencies { + if (!boostPath) { + dependsOn(downloadBoost) + } + dependsOn(downloadDoubleConversion) + dependsOn(downloadFolly) + dependsOn(downloadGlog) +} + +task prepareThirdPartyNdkHeaders(dependsOn:[ + downloadNdkBuildDependencies, + prepareBoost, + prepareDoubleConversion, + prepareFolly, + prepareGlog, + unpackReactNativeAAR] +) {} + +def nativeBuildDependsOn(dependsOnTask) { + def buildTasks = tasks.findAll({ task -> + !task.name.contains("Clean") && (task.name.contains("externalNative") || task.name.contains("CMake")) }) + buildTasks.forEach { task -> task.dependsOn(dependsOnTask) } +} + +afterEvaluate { + extractAARHeaders.dependsOn(prepareThirdPartyNdkHeaders) + extractSOFiles.dependsOn(prepareThirdPartyNdkHeaders) + + nativeBuildDependsOn(prepareThirdPartyNdkHeaders) + nativeBuildDependsOn(extractAARHeaders) + nativeBuildDependsOn(extractSOFiles) + + tasks.forEach({ task -> + if (task.name.contains("JniLibFolders")) { + task.dependsOn(packageNdkLibs) + } + }) + + if (JS_RUNTIME == "hermes") { + extractAARHeaders.dependsOn(prepareHermes) + extractSOFiles.dependsOn(prepareHermes) + } else if (JS_RUNTIME == "v8") { + def buildTasks = tasks.findAll({ task -> + !task.name.contains("Clean") && (task.name.contains("externalNative") || task.name.contains("CMake") || task.name.startsWith("generateJsonModel")) }) + buildTasks.forEach { task -> + def buildType = task.name.endsWith('Debug') ? 'Debug' : 'Release' + task.dependsOn(":react-native-v8:copy${buildType}JniLibsProjectOnly") + } + } else if (JS_RUNTIME == "jsc") { + extractAARHeaders.dependsOn(prepareJSC) + extractSOFiles.dependsOn(prepareJSC) + } else { + throw GradleScriptException("Unknown JS runtime ${JS_RUNTIME}.") + } +} + +if (CLIENT_SIDE_BUILD) { + def aarDir = "${buildDir}/outputs" + aar = file("${aarDir}/android-${resolveBuildType()}.aar") // e.g. android-debug.aar + if (aar == null) { + throw GradleScriptException("AAR build failed. No AAR found in ${aarDir}.") + } + artifacts.add("default", aar) +} \ No newline at end of file diff --git a/android/vendored/unversioned/react-native-reanimated/android/empty.cpp b/android/vendored/unversioned/react-native-reanimated/android/empty.cpp new file mode 100644 index 0000000000000..8d50bb2809009 --- /dev/null +++ b/android/vendored/unversioned/react-native-reanimated/android/empty.cpp @@ -0,0 +1 @@ +// required for compilation purpose diff --git a/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/62/layoutReanimation/ReanimatedNativeHierarchyManager.java b/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/62/layoutReanimation/ReanimatedNativeHierarchyManager.java new file mode 100644 index 0000000000000..c781f682a44c3 --- /dev/null +++ b/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/62/layoutReanimation/ReanimatedNativeHierarchyManager.java @@ -0,0 +1,412 @@ +package com.swmansion.reanimated.layoutReanimation; + +import android.os.Build; +import android.util.Log; +import android.view.View; +import android.view.ViewGroup; +import androidx.annotation.Nullable; +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.bridge.UiThreadUtil; +import com.facebook.react.uimanager.IllegalViewOperationException; +import com.facebook.react.uimanager.NativeViewHierarchyManager; +import com.facebook.react.uimanager.RootViewManager; +import com.facebook.react.uimanager.ViewAtIndex; +import com.facebook.react.uimanager.ViewGroupManager; +import com.facebook.react.uimanager.ViewManager; +import com.facebook.react.uimanager.ViewManagerRegistry; +import com.facebook.react.uimanager.layoutanimation.LayoutAnimationController; +import com.facebook.react.uimanager.layoutanimation.LayoutAnimationListener; +import com.swmansion.reanimated.ReanimatedModule; +import java.lang.ref.WeakReference; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; + +class ReaLayoutAnimator extends LayoutAnimationController { + private AnimationsManager mAnimationsManager = null; + private volatile boolean mInitialized = false; + private ReactApplicationContext mContext; + private WeakReference mWeakNativeViewHierarchyManage = + new WeakReference<>(null); + + ReaLayoutAnimator( + ReactApplicationContext context, NativeViewHierarchyManager nativeViewHierarchyManager) { + mContext = context; + mWeakNativeViewHierarchyManage = new WeakReference<>(nativeViewHierarchyManager); + } + + public void maybeInit() { + if (!mInitialized) { + mInitialized = true; + ReanimatedModule reanimatedModule = mContext.getNativeModule(ReanimatedModule.class); + mAnimationsManager = reanimatedModule.getNodesManager().getAnimationsManager(); + mAnimationsManager.setReanimatedNativeHierarchyManager( + (ReanimatedNativeHierarchyManager) mWeakNativeViewHierarchyManage.get()); + } + } + + public boolean shouldAnimateLayout(View viewToAnimate) { + if (!isLayoutAnimationEnabled()) { + return super.shouldAnimateLayout(viewToAnimate); + } + // if view parent is null, skip animation: view have been clipped, we don't want animation to + // resume when view is re-attached to parent, which is the standard android animation behavior. + // If there's a layout handling animation going on, it should be animated nonetheless since the + // ongoing animation needs to be updated. + if (viewToAnimate == null) { + return false; + } + return (viewToAnimate.getParent() != null); + } + + /** + * Update layout of given view, via immediate update or animation depending on the current batch + * layout animation configuration supplied during initialization. Handles create and update + * animations. + * + * @param view the view to update layout of + * @param x the new X position for the view + * @param y the new Y position for the view + * @param width the new width value for the view + * @param height the new height value for the view + */ + public void applyLayoutUpdate(View view, int x, int y, int width, int height) { + if (!isLayoutAnimationEnabled()) { + super.applyLayoutUpdate(view, x, y, width, height); + return; + } + UiThreadUtil.assertOnUiThread(); + maybeInit(); + // Determine which animation to use : if view is initially invisible, use create animation, + // otherwise use update animation. This approach is easier than maintaining a list of tags + // for recently created views. + if (view.getWidth() == 0 || view.getHeight() == 0) { + view.layout(x, y, x + width, y + height); + if (view.getId() != -1) { + mAnimationsManager.onViewCreate( + view, + (ViewGroup) view.getParent(), + new Snapshot(view, mWeakNativeViewHierarchyManage.get())); + } + } else { + Snapshot before = new Snapshot(view, mWeakNativeViewHierarchyManage.get()); + view.layout(x, y, x + width, y + height); + Snapshot after = new Snapshot(view, mWeakNativeViewHierarchyManage.get()); + mAnimationsManager.onViewUpdate(view, before, after); + } + } + + /** + * Animate a view deletion using the layout animation configuration supplied during + * initialization. + * + * @param view The view to animate. + * @param listener Called once the animation is finished, should be used to completely remove the + * view. + */ + public void deleteView(final View view, final LayoutAnimationListener listener) { + if (!isLayoutAnimationEnabled()) { + super.deleteView(view, listener); + return; + } + UiThreadUtil.assertOnUiThread(); + NativeViewHierarchyManager nativeViewHierarchyManager = mWeakNativeViewHierarchyManage.get(); + ViewManager viewManager; + try { + viewManager = nativeViewHierarchyManager.resolveViewManager(view.getId()); + } catch (IllegalViewOperationException e) { + // (IllegalViewOperationException) == (vm == null) + e.printStackTrace(); + super.deleteView(view, listener); + return; + } + // we don't want layout animations in native-stack since it is currently buggy there + // so we check if it is a (grand)child of ScreenStack + if (viewManager.getName().equals("RNSScreen") + && view.getParent() != null + && view.getParent().getParent() instanceof View) { + // we check grandparent of Screen since the parent is a ScreenStackFragment + View screenParentView = (View) view.getParent().getParent(); + ViewManager screenParentViewManager; + try { + screenParentViewManager = + nativeViewHierarchyManager.resolveViewManager(screenParentView.getId()); + } catch (IllegalViewOperationException e) { + // (IllegalViewOperationException) == (vm == null) + e.printStackTrace(); + super.deleteView(view, listener); + return; + } + String parentName = screenParentViewManager.getName(); + if (parentName.equals("RNSScreenStack")) { + super.deleteView(view, listener); + return; + } + } + maybeInit(); + Snapshot before = new Snapshot(view, mWeakNativeViewHierarchyManage.get()); + mAnimationsManager.onViewRemoval( + view, (ViewGroup) view.getParent(), before, () -> listener.onAnimationEnd()); + if (viewManager instanceof ViewGroupManager) { + ViewGroupManager vgm = (ViewGroupManager) viewManager; + for (int i = 0; i < vgm.getChildCount((ViewGroup) view); ++i) { + dfs(vgm.getChildAt((ViewGroup) view, i), nativeViewHierarchyManager); + } + } + } + + private void dfs(View view, NativeViewHierarchyManager nativeViewHierarchyManager) { + int tag = view.getId(); + if (tag == -1) { + return; + } + ViewManager vm = null; + try { + vm = nativeViewHierarchyManager.resolveViewManager(tag); + Snapshot before = new Snapshot(view, mWeakNativeViewHierarchyManage.get()); + mAnimationsManager.onViewRemoval( + view, + (ViewGroup) view.getParent(), + before, + () -> { + ReanimatedNativeHierarchyManager reanimatedNativeHierarchyManager = + (ReanimatedNativeHierarchyManager) nativeViewHierarchyManager; + reanimatedNativeHierarchyManager.publicDropView(view); + }); + } catch (IllegalViewOperationException e) { + // (IllegalViewOperationException) == (vm == null) + e.printStackTrace(); + } + if (vm instanceof ViewGroupManager) { + ViewGroupManager vgm = (ViewGroupManager) vm; + for (int i = 0; i < vgm.getChildCount((ViewGroup) view); ++i) { + dfs(vgm.getChildAt((ViewGroup) view, i), nativeViewHierarchyManager); + } + } + } + + public boolean isLayoutAnimationEnabled() { + maybeInit(); + return mAnimationsManager.isLayoutAnimationEnabled(); + } +} + +public class ReanimatedNativeHierarchyManager extends NativeViewHierarchyManager { + private final HashMap> toBeRemoved = new HashMap<>(); + private final HashMap cleanerCallback = new HashMap<>(); + private LayoutAnimationController mReaLayoutAnimator = null; + private HashMap> mPendingDeletionsForTag = new HashMap<>(); + private boolean initOk = true; + + public ReanimatedNativeHierarchyManager( + ViewManagerRegistry viewManagers, ReactApplicationContext reactContext) { + super(viewManagers); + + mReaLayoutAnimator = new ReaLayoutAnimator(reactContext, this); + + Class clazz = this.getClass().getSuperclass(); + if (clazz == null) { + Log.e("reanimated", "unable to resolve super class of ReanimatedNativeHierarchyManager"); + return; + } + + try { + Field layoutAnimatorField = clazz.getDeclaredField("mLayoutAnimator"); + layoutAnimatorField.setAccessible(true); + + if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + try { + // accessFlags is supported only by API >=23 + Field modifiersField = Field.class.getDeclaredField("accessFlags"); + modifiersField.setAccessible(true); + modifiersField.setInt( + layoutAnimatorField, layoutAnimatorField.getModifiers() & ~Modifier.FINAL); + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + } + layoutAnimatorField.set(this, mReaLayoutAnimator); + } catch (NoSuchFieldException | IllegalAccessException e) { + initOk = false; + e.printStackTrace(); + } + + try { + Field pendingTagsField = clazz.getDeclaredField("mPendingDeletionsForTag"); + pendingTagsField.setAccessible(true); + + if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + try { + // accessFlags is supported only by API >=23 + Field pendingTagsFieldModifiers = Field.class.getDeclaredField("accessFlags"); + pendingTagsFieldModifiers.setAccessible(true); + pendingTagsFieldModifiers.setInt( + pendingTagsField, pendingTagsField.getModifiers() & ~Modifier.FINAL); + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + } + pendingTagsField.set(this, mPendingDeletionsForTag); + } catch (NoSuchFieldException | IllegalAccessException e) { + initOk = false; + e.printStackTrace(); + } + + if (initOk) { + setLayoutAnimationEnabled(true); + } + } + + public ReanimatedNativeHierarchyManager( + ViewManagerRegistry viewManagers, RootViewManager manager) { + super(viewManagers, manager); + } + + private boolean isLayoutAnimationDisabled() { + return !initOk || !((ReaLayoutAnimator) mReaLayoutAnimator).isLayoutAnimationEnabled(); + } + + public synchronized void updateLayout( + int parentTag, int tag, int x, int y, int width, int height) { + super.updateLayout(parentTag, tag, x, y, width, height); + if (isLayoutAnimationDisabled()) { + return; + } + try { + View viewToUpdate = this.resolveView(tag); + ViewManager viewManager = this.resolveViewManager(tag); + String viewManagerName = viewManager.getName(); + View container = resolveView(parentTag); + if (container != null + && viewManagerName.equals("RNSScreen") + && this.mReaLayoutAnimator != null) { + this.mReaLayoutAnimator.applyLayoutUpdate( + viewToUpdate, + (int) container.getX(), + (int) container.getY(), + container.getWidth(), + container.getHeight()); + } + } catch (IllegalViewOperationException e) { + // (IllegalViewOperationException) == (vm == null) + e.printStackTrace(); + } + } + + // @Override + public synchronized void manageChildren( + int tag, + @Nullable int[] indicesToRemove, + @Nullable ViewAtIndex[] viewsToAdd, + @Nullable int[] tagsToDelete) { + int[] mock = new int[] {}; + if (isLayoutAnimationDisabled()) { + super.manageChildren(tag, indicesToRemove, viewsToAdd, tagsToDelete, mock); + return; + } + ViewGroup viewGroup; + ViewGroupManager viewGroupManager; + try { + viewGroup = (ViewGroup) resolveView(tag); + viewGroupManager = (ViewGroupManager) resolveViewManager(tag); + } catch (IllegalViewOperationException e) { + // (IllegalViewOperationException) == (vm == null) + e.printStackTrace(); + super.manageChildren(tag, indicesToRemove, viewsToAdd, tagsToDelete, mock); + return; + } + + // we don't want layout animations in native-stack since it is currently buggy there + if (viewGroupManager.getName().equals("RNSScreenStack")) { + super.manageChildren(tag, indicesToRemove, viewsToAdd, tagsToDelete, mock); + return; + } + + if (toBeRemoved.containsKey(tag)) { + ArrayList childrenToBeRemoved = toBeRemoved.get(tag); + HashSet tagsToRemove = new HashSet(); + for (View childToRemove : childrenToBeRemoved) { + tagsToRemove.add(childToRemove.getId()); + } + while (viewGroupManager.getChildCount(viewGroup) != 0) { + View child = + viewGroupManager.getChildAt(viewGroup, viewGroupManager.getChildCount(viewGroup) - 1); + if (tagsToRemove.contains(child.getId())) { + viewGroupManager.removeViewAt(viewGroup, viewGroupManager.getChildCount(viewGroup) - 1); + } else { + break; + } + } + } + if (tagsToDelete != null) { + if (!toBeRemoved.containsKey(tag)) { + toBeRemoved.put(tag, new ArrayList<>()); + } + ArrayList toBeRemovedChildren = toBeRemoved.get(tag); + for (Integer childtag : tagsToDelete) { + View view; + try { + view = resolveView(childtag); + } catch (IllegalViewOperationException e) { + // (IllegalViewOperationException) == (vm == null) + e.printStackTrace(); + continue; + } + toBeRemovedChildren.add(view); + cleanerCallback.put( + view.getId(), + new Runnable() { + @Override + public void run() { + toBeRemovedChildren.remove(view); + viewGroupManager.removeView(viewGroup, view); + } // It's far from optimal but let's leave it as it is for now + }); + } + } + + // mPendingDeletionsForTag is modify by React + if (mPendingDeletionsForTag != null) { + Set pendingTags = mPendingDeletionsForTag.get(tag); + if (pendingTags != null) { + pendingTags.clear(); + } + } + + super.manageChildren(tag, indicesToRemove, viewsToAdd, mock, mock); + if (toBeRemoved.containsKey(tag)) { + ArrayList childrenToBeRemoved = toBeRemoved.get(tag); + for (View child : childrenToBeRemoved) { + viewGroupManager.addView(viewGroup, child, viewGroupManager.getChildCount(viewGroup)); + } + } + ViewAtIndex[] mock2 = new ViewAtIndex[] {}; + super.manageChildren(tag, mock, mock2, tagsToDelete, mock); + } + + public void publicDropView(View view) { + dropView(view); + } + + @Override + protected synchronized void dropView(View view) { + if (isLayoutAnimationDisabled()) { + super.dropView(view); + return; + } + if (toBeRemoved.containsKey(view.getId())) { + toBeRemoved.remove(view.getId()); + } + if (cleanerCallback.containsKey(view.getId())) { + Runnable runnable = cleanerCallback.get(view.getId()); + cleanerCallback.remove(view.getId()); + runnable.run(); + } + // childrens' callbacks should be cleaned by former publicDropView calls as Animation Manager + // stripes views from bottom to top + super.dropView(view); + } +} diff --git a/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/62/layoutReanimation/ReanimatedUIImplementation.java b/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/62/layoutReanimation/ReanimatedUIImplementation.java new file mode 100644 index 0000000000000..372dac9c987c5 --- /dev/null +++ b/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/62/layoutReanimation/ReanimatedUIImplementation.java @@ -0,0 +1,68 @@ +package com.facebook.react.uimanager; + +import androidx.annotation.Nullable; +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.bridge.ReadableArray; +import com.facebook.react.uimanager.events.EventDispatcher; +import com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager; +import java.util.List; + +public class ReanimatedUIImplementation extends UIImplementation { + public ReanimatedUIImplementation( + ReactApplicationContext reactContext, + UIManagerModule.ViewManagerResolver viewManagerResolver, + EventDispatcher eventDispatcher, + int minTimeLeftInFrameForNonBatchedOperationMs) { + this( + reactContext, + new ViewManagerRegistry(viewManagerResolver), + eventDispatcher, + minTimeLeftInFrameForNonBatchedOperationMs); + } + + public ReanimatedUIImplementation( + ReactApplicationContext reactContext, + List viewManagerList, + EventDispatcher eventDispatcher, + int minTimeLeftInFrameForNonBatchedOperationMs) { + this( + reactContext, + new ViewManagerRegistry(viewManagerList), + eventDispatcher, + minTimeLeftInFrameForNonBatchedOperationMs); + } + + public ReanimatedUIImplementation( + ReactApplicationContext reactContext, + ViewManagerRegistry viewManagerRegistry, + EventDispatcher eventDispatcher, + int minTimeLeftInFrameForNonBatchedOperationMs) { + super( + reactContext, + viewManagerRegistry, + new UIViewOperationQueue( + reactContext, + new ReanimatedNativeHierarchyManager(viewManagerRegistry, reactContext), + minTimeLeftInFrameForNonBatchedOperationMs), + eventDispatcher); + } + + /** + * Invoked when there is a mutation in a node tree. + * + * @param tag react tag of the node we want to manage + * @param indicesToRemove ordered (asc) list of indicies at which view should be removed + * @param viewsToAdd ordered (asc based on mIndex property) list of tag-index pairs that represent + * a view which should be added at the specified index + * @param tagsToDelete list of tags corresponding to views that should be removed + */ + public void manageChildren( + int viewTag, + @Nullable ReadableArray moveFrom, + @Nullable ReadableArray moveTo, + @Nullable ReadableArray addChildTags, + @Nullable ReadableArray addAtIndices, + @Nullable ReadableArray removeFrom) { + super.manageChildren(viewTag, moveFrom, moveTo, addChildTags, addAtIndices, removeFrom); + } +} diff --git a/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/63/layoutReanimation/ReanimatedUIImplementation.java b/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/63/layoutReanimation/ReanimatedUIImplementation.java new file mode 100644 index 0000000000000..372dac9c987c5 --- /dev/null +++ b/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/63/layoutReanimation/ReanimatedUIImplementation.java @@ -0,0 +1,68 @@ +package com.facebook.react.uimanager; + +import androidx.annotation.Nullable; +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.bridge.ReadableArray; +import com.facebook.react.uimanager.events.EventDispatcher; +import com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager; +import java.util.List; + +public class ReanimatedUIImplementation extends UIImplementation { + public ReanimatedUIImplementation( + ReactApplicationContext reactContext, + UIManagerModule.ViewManagerResolver viewManagerResolver, + EventDispatcher eventDispatcher, + int minTimeLeftInFrameForNonBatchedOperationMs) { + this( + reactContext, + new ViewManagerRegistry(viewManagerResolver), + eventDispatcher, + minTimeLeftInFrameForNonBatchedOperationMs); + } + + public ReanimatedUIImplementation( + ReactApplicationContext reactContext, + List viewManagerList, + EventDispatcher eventDispatcher, + int minTimeLeftInFrameForNonBatchedOperationMs) { + this( + reactContext, + new ViewManagerRegistry(viewManagerList), + eventDispatcher, + minTimeLeftInFrameForNonBatchedOperationMs); + } + + public ReanimatedUIImplementation( + ReactApplicationContext reactContext, + ViewManagerRegistry viewManagerRegistry, + EventDispatcher eventDispatcher, + int minTimeLeftInFrameForNonBatchedOperationMs) { + super( + reactContext, + viewManagerRegistry, + new UIViewOperationQueue( + reactContext, + new ReanimatedNativeHierarchyManager(viewManagerRegistry, reactContext), + minTimeLeftInFrameForNonBatchedOperationMs), + eventDispatcher); + } + + /** + * Invoked when there is a mutation in a node tree. + * + * @param tag react tag of the node we want to manage + * @param indicesToRemove ordered (asc) list of indicies at which view should be removed + * @param viewsToAdd ordered (asc based on mIndex property) list of tag-index pairs that represent + * a view which should be added at the specified index + * @param tagsToDelete list of tags corresponding to views that should be removed + */ + public void manageChildren( + int viewTag, + @Nullable ReadableArray moveFrom, + @Nullable ReadableArray moveTo, + @Nullable ReadableArray addChildTags, + @Nullable ReadableArray addAtIndices, + @Nullable ReadableArray removeFrom) { + super.manageChildren(viewTag, moveFrom, moveTo, addChildTags, addAtIndices, removeFrom); + } +} diff --git a/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/64/layoutReanimation/ReanimatedUIImplementation.java b/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/64/layoutReanimation/ReanimatedUIImplementation.java new file mode 100644 index 0000000000000..372dac9c987c5 --- /dev/null +++ b/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/64/layoutReanimation/ReanimatedUIImplementation.java @@ -0,0 +1,68 @@ +package com.facebook.react.uimanager; + +import androidx.annotation.Nullable; +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.bridge.ReadableArray; +import com.facebook.react.uimanager.events.EventDispatcher; +import com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager; +import java.util.List; + +public class ReanimatedUIImplementation extends UIImplementation { + public ReanimatedUIImplementation( + ReactApplicationContext reactContext, + UIManagerModule.ViewManagerResolver viewManagerResolver, + EventDispatcher eventDispatcher, + int minTimeLeftInFrameForNonBatchedOperationMs) { + this( + reactContext, + new ViewManagerRegistry(viewManagerResolver), + eventDispatcher, + minTimeLeftInFrameForNonBatchedOperationMs); + } + + public ReanimatedUIImplementation( + ReactApplicationContext reactContext, + List viewManagerList, + EventDispatcher eventDispatcher, + int minTimeLeftInFrameForNonBatchedOperationMs) { + this( + reactContext, + new ViewManagerRegistry(viewManagerList), + eventDispatcher, + minTimeLeftInFrameForNonBatchedOperationMs); + } + + public ReanimatedUIImplementation( + ReactApplicationContext reactContext, + ViewManagerRegistry viewManagerRegistry, + EventDispatcher eventDispatcher, + int minTimeLeftInFrameForNonBatchedOperationMs) { + super( + reactContext, + viewManagerRegistry, + new UIViewOperationQueue( + reactContext, + new ReanimatedNativeHierarchyManager(viewManagerRegistry, reactContext), + minTimeLeftInFrameForNonBatchedOperationMs), + eventDispatcher); + } + + /** + * Invoked when there is a mutation in a node tree. + * + * @param tag react tag of the node we want to manage + * @param indicesToRemove ordered (asc) list of indicies at which view should be removed + * @param viewsToAdd ordered (asc based on mIndex property) list of tag-index pairs that represent + * a view which should be added at the specified index + * @param tagsToDelete list of tags corresponding to views that should be removed + */ + public void manageChildren( + int viewTag, + @Nullable ReadableArray moveFrom, + @Nullable ReadableArray moveTo, + @Nullable ReadableArray addChildTags, + @Nullable ReadableArray addAtIndices, + @Nullable ReadableArray removeFrom) { + super.manageChildren(viewTag, moveFrom, moveTo, addChildTags, addAtIndices, removeFrom); + } +} diff --git a/android/vendored/unversioned/react-native-reanimated/android/src/main/AndroidManifest.xml b/android/vendored/unversioned/react-native-reanimated/android/src/main/AndroidManifest.xml new file mode 100644 index 0000000000000..586ffb9741e39 --- /dev/null +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + diff --git a/android/expoview/src/main/cpp/AndroidErrorHandler.cpp b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/AndroidErrorHandler.cpp similarity index 84% rename from android/expoview/src/main/cpp/AndroidErrorHandler.cpp rename to android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/AndroidErrorHandler.cpp index 91af18c0c9020..fb1386fcadfaf 100644 --- a/android/expoview/src/main/cpp/AndroidErrorHandler.cpp +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/AndroidErrorHandler.cpp @@ -1,5 +1,6 @@ #include "AndroidErrorHandler.h" #include +#include #include #include "Logger.h" @@ -17,11 +18,9 @@ void AndroidErrorHandler::raiseSpec() { return; } - static const auto cls = javaClassStatic(); - static auto method = cls->getStaticMethod("raise"); - method(cls, error->message); - + // mark error as handled before this method throws exception this->error->handled = true; + throw std::runtime_error(this->error->message); } std::shared_ptr AndroidErrorHandler::getScheduler() { diff --git a/android/expoview/src/main/cpp/headers/AndroidErrorHandler.h b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/AndroidErrorHandler.h similarity index 72% rename from android/expoview/src/main/cpp/headers/AndroidErrorHandler.h rename to android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/AndroidErrorHandler.h index 4f40eeee0e49c..5db1439350773 100644 --- a/android/expoview/src/main/cpp/headers/AndroidErrorHandler.h +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/AndroidErrorHandler.h @@ -11,15 +11,12 @@ namespace reanimated { -class AndroidErrorHandler : public JavaClass, - public ErrorHandler { +class AndroidErrorHandler : public ErrorHandler { std::shared_ptr error; std::shared_ptr scheduler; void raiseSpec() override; public: - static auto constexpr kJavaDescriptor = - "Lversioned/host/exp/exponent/modules/api/reanimated/AndroidErrorHandler;"; explicit AndroidErrorHandler(std::shared_ptr scheduler); std::shared_ptr getScheduler() override; std::shared_ptr getError() override; diff --git a/android/expoview/src/main/cpp/AndroidLogger.cpp b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/AndroidLogger.cpp similarity index 97% rename from android/expoview/src/main/cpp/AndroidLogger.cpp rename to android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/AndroidLogger.cpp index 1fc4d2d98a3ec..767ce6f43f2ab 100644 --- a/android/expoview/src/main/cpp/AndroidLogger.cpp +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/AndroidLogger.cpp @@ -1,6 +1,9 @@ -#include "AndroidLogger.h" #include +#include + +#include "AndroidLogger.h" #include "Logger.h" + #define APPNAME "NATIVE_REANIMATED" namespace reanimated { diff --git a/android/expoview/src/main/cpp/headers/AndroidLogger.h b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/AndroidLogger.h similarity index 100% rename from android/expoview/src/main/cpp/headers/AndroidLogger.h rename to android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/AndroidLogger.h diff --git a/android/expoview/src/main/cpp/AndroidScheduler.cpp b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/AndroidScheduler.cpp similarity index 100% rename from android/expoview/src/main/cpp/AndroidScheduler.cpp rename to android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/AndroidScheduler.cpp diff --git a/android/expoview/src/main/cpp/headers/AndroidScheduler.h b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/AndroidScheduler.h similarity index 92% rename from android/expoview/src/main/cpp/headers/AndroidScheduler.h rename to android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/AndroidScheduler.h index e61e01f66750a..262c78370173e 100644 --- a/android/expoview/src/main/cpp/headers/AndroidScheduler.h +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/AndroidScheduler.h @@ -15,7 +15,7 @@ using namespace facebook; class AndroidScheduler : public jni::HybridClass { public: static auto constexpr kJavaDescriptor = - "Lversioned/host/exp/exponent/modules/api/reanimated/Scheduler;"; + "Lcom/swmansion/reanimated/Scheduler;"; static jni::local_ref initHybrid( jni::alias_ref jThis); static void registerNatives(); diff --git a/android/expoview/src/main/cpp/JNIHelper.cpp b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/JNIHelper.cpp similarity index 100% rename from android/expoview/src/main/cpp/JNIHelper.cpp rename to android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/JNIHelper.cpp diff --git a/android/expoview/src/main/cpp/headers/JNIHelper.h b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/JNIHelper.h similarity index 100% rename from android/expoview/src/main/cpp/headers/JNIHelper.h rename to android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/JNIHelper.h diff --git a/android/expoview/src/main/cpp/LayoutAnimations.cpp b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/LayoutAnimations.cpp similarity index 100% rename from android/expoview/src/main/cpp/LayoutAnimations.cpp rename to android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/LayoutAnimations.cpp diff --git a/android/expoview/src/main/cpp/headers/LayoutAnimations.h b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/LayoutAnimations.h similarity index 91% rename from android/expoview/src/main/cpp/headers/LayoutAnimations.h rename to android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/LayoutAnimations.h index 63cedb8dd6e50..62e7b170cd187 100644 --- a/android/expoview/src/main/cpp/headers/LayoutAnimations.h +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/LayoutAnimations.h @@ -13,7 +13,7 @@ using namespace facebook; class LayoutAnimations : public jni::HybridClass { public: static auto constexpr kJavaDescriptor = - "Lversioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/LayoutAnimations;"; + "Lcom/swmansion/reanimated/layoutReanimation/LayoutAnimations;"; static jni::local_ref initHybrid( jni::alias_ref jThis); static void registerNatives(); diff --git a/android/expoview/src/main/cpp/NativeProxy.cpp b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/NativeProxy.cpp similarity index 81% rename from android/expoview/src/main/cpp/NativeProxy.cpp rename to android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/NativeProxy.cpp index 0e4014c680737..62b7ced1efb13 100644 --- a/android/expoview/src/main/cpp/NativeProxy.cpp +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/NativeProxy.cpp @@ -7,8 +7,10 @@ #include #include -#if FOR_HERMES +#if JS_RUNTIME_HERMES #include +#elif JS_RUNTIME_V8 +#include #else #include #endif @@ -38,10 +40,8 @@ NativeProxy::NativeProxy( layoutAnimations(std::move(_layoutAnimations)) {} NativeProxy::~NativeProxy() { - runtime_->global().setProperty( - *runtime_, - jsi::PropNameID::forAscii(*runtime_, "__reanimatedModuleProxy"), - jsi::Value::undefined()); + // removed temporary, new event listener mechanism need fix on the RN side + // reactScheduler_->removeEventListener(eventListener_); } jni::local_ref NativeProxy::initHybrid( @@ -73,11 +73,10 @@ void NativeProxy::installJSIBindings() { }; auto getCurrentTime = [this]() { - auto method = - javaPart_->getClass()->getMethod()>("getUptime"); - local_ref output = method(javaPart_.get()); - return static_cast( - std::strtoll(output->toStdString().c_str(), NULL, 10)); + static const auto method = + javaPart_->getClass()->getMethod("getCurrentTime"); + jlong output = method(javaPart_.get()); + return static_cast(output); }; auto requestRender = [this, getCurrentTime]( @@ -136,31 +135,44 @@ void NativeProxy::installJSIBindings() { auto setGestureStateFunction = [this](int handlerTag, int newState) -> void { setGestureState(handlerTag, newState); }; -#if FOR_HERMES + + auto subscribeForKeyboardEventsFunction = + [this](std::function keyboardEventDataUpdater) -> int { + return subscribeForKeyboardEvents(std::move(keyboardEventDataUpdater)); + }; + + auto unsubscribeFromKeyboardEventsFunction = [this](int listenerId) -> void { + unsubscribeFromKeyboardEvents(listenerId); + }; + +#if JS_RUNTIME_HERMES auto config = ::hermes::vm::RuntimeConfig::Builder().withEnableSampleProfiling(false); std::shared_ptr animatedRuntime = facebook::hermes::makeHermesRuntime(config.build()); +#elif JS_RUNTIME_V8 + auto config = std::make_unique(); + config->enableInspector = false; + config->appName = "reanimated"; + std::shared_ptr animatedRuntime = + rnv8::createSharedV8Runtime(runtime_, std::move(config)); #else std::shared_ptr animatedRuntime = facebook::jsc::makeJSCRuntime(); #endif - auto workletRuntimeValue = runtime_->global() - .getProperty(*runtime_, "ArrayBuffer") - .asObject(*runtime_) - .asFunction(*runtime_) - .callAsConstructor(*runtime_, {static_cast(sizeof(void*))}); - uintptr_t* workletRuntimeData = reinterpret_cast( - workletRuntimeValue - .getObject(*runtime_) - .getArrayBuffer(*runtime_) - .data(*runtime_)); + auto workletRuntimeValue = + runtime_->global() + .getProperty(*runtime_, "ArrayBuffer") + .asObject(*runtime_) + .asFunction(*runtime_) + .callAsConstructor(*runtime_, {static_cast(sizeof(void *))}); + uintptr_t *workletRuntimeData = reinterpret_cast( + workletRuntimeValue.getObject(*runtime_).getArrayBuffer(*runtime_).data( + *runtime_)); workletRuntimeData[0] = reinterpret_cast(animatedRuntime.get()); runtime_->global().setProperty( - *runtime_, - "_WORKLET_RUNTIME", - workletRuntimeValue); + *runtime_, "_WORKLET_RUNTIME", workletRuntimeValue); std::shared_ptr errorHandler = std::make_shared(scheduler_); @@ -198,7 +210,10 @@ void NativeProxy::installJSIBindings() { registerSensorFunction, unregisterSensorFunction, setGestureStateFunction, - configurePropsFunction}; + configurePropsFunction, + subscribeForKeyboardEventsFunction, + unsubscribeFromKeyboardEventsFunction, + }; auto module = std::make_shared( jsCallInvoker_, @@ -337,12 +352,29 @@ void NativeProxy::configureProps( ReadableNativeArray::javaobject)>("configureProps"); method( javaPart_.get(), - ReadableNativeArray::newObjectCxxArgs( - std::move(jsi::dynamicFromValue(rt, uiProps))) + ReadableNativeArray::newObjectCxxArgs(jsi::dynamicFromValue(rt, uiProps)) .get(), ReadableNativeArray::newObjectCxxArgs( - std::move(jsi::dynamicFromValue(rt, nativeProps))) + jsi::dynamicFromValue(rt, nativeProps)) + .get()); +} + +int NativeProxy::subscribeForKeyboardEvents( + std::function keyboardEventDataUpdater) { + auto method = javaPart_->getClass() + ->getMethod( + "subscribeForKeyboardEvents"); + return method( + javaPart_.get(), + KeyboardEventDataUpdater::newObjectCxxArgs( + std::move(keyboardEventDataUpdater)) .get()); } +void NativeProxy::unsubscribeFromKeyboardEvents(int listenerId) { + auto method = javaPart_->getClass()->getMethod( + "unsubscribeFromKeyboardEvents"); + method(javaPart_.get(), listenerId); +} + } // namespace reanimated diff --git a/android/expoview/src/main/cpp/headers/NativeProxy.h b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/NativeProxy.h similarity index 81% rename from android/expoview/src/main/cpp/headers/NativeProxy.h rename to android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/NativeProxy.h index d72f6be4cab33..a5629f8096df9 100644 --- a/android/expoview/src/main/cpp/headers/NativeProxy.h +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/NativeProxy.h @@ -28,7 +28,7 @@ using namespace facebook::jni; class AnimationFrameCallback : public HybridClass { public: static auto constexpr kJavaDescriptor = - "Lversioned/host/exp/exponent/modules/api/reanimated/NativeProxy$AnimationFrameCallback;"; + "Lcom/swmansion/reanimated/NativeProxy$AnimationFrameCallback;"; void onAnimationFrame(double timestampMs) { callback_(timestampMs); @@ -53,7 +53,7 @@ class AnimationFrameCallback : public HybridClass { class EventHandler : public HybridClass { public: static auto constexpr kJavaDescriptor = - "Lversioned/host/exp/exponent/modules/api/reanimated/NativeProxy$EventHandler;"; + "Lcom/swmansion/reanimated/NativeProxy$EventHandler;"; void receiveEvent( jni::alias_ref eventKey, @@ -91,7 +91,7 @@ class EventHandler : public HybridClass { class SensorSetter : public HybridClass { public: static auto constexpr kJavaDescriptor = - "Lversioned/host/exp/exponent/modules/api/reanimated/NativeProxy$SensorSetter;"; + "Lcom/swmansion/reanimated/NativeProxy$SensorSetter;"; void sensorSetter(jni::alias_ref value) { size_t size = value->size(); @@ -118,10 +118,36 @@ class SensorSetter : public HybridClass { std::function callback_; }; +class KeyboardEventDataUpdater : public HybridClass { + public: + static auto constexpr kJavaDescriptor = + "Lcom/swmansion/reanimated/NativeProxy$KeyboardEventDataUpdater;"; + + void keyboardEventDataUpdater(int keyboardState, int height) { + callback_(keyboardState, height); + } + + static void registerNatives() { + javaClassStatic()->registerNatives({ + makeNativeMethod( + "keyboardEventDataUpdater", + KeyboardEventDataUpdater::keyboardEventDataUpdater), + }); + } + + private: + friend HybridBase; + + explicit KeyboardEventDataUpdater(std::function callback) + : callback_(std::move(callback)) {} + + std::function callback_; +}; + class NativeProxy : public jni::HybridClass { public: static auto constexpr kJavaDescriptor = - "Lversioned/host/exp/exponent/modules/api/reanimated/NativeProxy;"; + "Lcom/swmansion/reanimated/NativeProxy;"; static jni::local_ref initHybrid( jni::alias_ref jThis, jlong jsContext, @@ -160,6 +186,9 @@ class NativeProxy : public jni::HybridClass { jsi::Runtime &rt, const jsi::Value &uiProps, const jsi::Value &nativeProps); + int subscribeForKeyboardEvents( + std::function keyboardEventDataUpdater); + void unsubscribeFromKeyboardEvents(int listenerId); explicit NativeProxy( jni::alias_ref jThis, diff --git a/android/expoview/src/main/cpp/OnLoad.cpp b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/OnLoad.cpp similarity index 90% rename from android/expoview/src/main/cpp/OnLoad.cpp rename to android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/OnLoad.cpp index d3e3a55b70e41..644f222a3a3c7 100644 --- a/android/expoview/src/main/cpp/OnLoad.cpp +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/OnLoad.cpp @@ -13,5 +13,6 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) { reanimated::AndroidScheduler::registerNatives(); reanimated::LayoutAnimations::registerNatives(); reanimated::SensorSetter::registerNatives(); + reanimated::KeyboardEventDataUpdater::registerNatives(); }); } diff --git a/android/expoview/src/main/cpp/TurboModule.cpp b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/TurboModule.cpp similarity index 100% rename from android/expoview/src/main/cpp/TurboModule.cpp rename to android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/TurboModule.cpp diff --git a/android/expoview/src/main/cpp/headers/TurboModule.h b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/TurboModule.h similarity index 100% rename from android/expoview/src/main/cpp/headers/TurboModule.h rename to android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/TurboModule.h diff --git a/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/facebook/react/uimanager/UIManagerReanimatedHelper.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/facebook/react/uimanager/UIManagerReanimatedHelper.java new file mode 100644 index 0000000000000..2798cd6dbee0c --- /dev/null +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/facebook/react/uimanager/UIManagerReanimatedHelper.java @@ -0,0 +1,15 @@ +package com.facebook.react.uimanager; + +/** + * This class provides a way to workaround limited visibility of + * UIViewOperationQueue#getUIViewOperationQueue. We rely on accessing that method to check if + * operation queue is empty or not. This in turn indicates if we are in a middle of processing batch + * of operations from JS. In such a case we can rely on the enqueued update operations to be flushed + * onto the shadow view hierarchy. Otherwise we want to trigger "dispatchViewUpdates" and enforce + * flush immediately. + */ +public class UIManagerReanimatedHelper { + public static boolean isOperationQueueEmpty(UIImplementation uiImplementation) { + return uiImplementation.getUIViewOperationQueue().isEmpty(); + } +} diff --git a/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/common/GestureHandlerStateManager.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/common/GestureHandlerStateManager.java new file mode 100644 index 0000000000000..e34e90697e2da --- /dev/null +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/common/GestureHandlerStateManager.java @@ -0,0 +1,5 @@ +package com.swmansion.common; + +public interface GestureHandlerStateManager { + void setGestureHandlerState(int handlerTag, int newState); +} diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/CopiedEvent.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/CopiedEvent.java similarity index 94% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/CopiedEvent.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/CopiedEvent.java index ac0886d2529e9..290d9c4f29b0c 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/CopiedEvent.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/CopiedEvent.java @@ -1,4 +1,4 @@ -package versioned.host.exp.exponent.modules.api.reanimated; +package com.swmansion.reanimated; import androidx.annotation.Nullable; import com.facebook.react.bridge.WritableArray; diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/MapUtils.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/MapUtils.java similarity index 92% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/MapUtils.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/MapUtils.java index 34e62e2207003..276419e94400f 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/MapUtils.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/MapUtils.java @@ -1,4 +1,4 @@ -package versioned.host.exp.exponent.modules.api.reanimated; +package com.swmansion.reanimated; import com.facebook.react.bridge.JSApplicationCausedNativeException; import com.facebook.react.bridge.NoSuchKeyException; diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/NativeMethodsHelper.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NativeMethodsHelper.java similarity index 98% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/NativeMethodsHelper.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NativeMethodsHelper.java index f496b22f4e434..b8e8ba26013dc 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/NativeMethodsHelper.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NativeMethodsHelper.java @@ -1,4 +1,4 @@ -package versioned.host.exp.exponent.modules.api.reanimated; +package com.swmansion.reanimated; import android.graphics.Matrix; import android.graphics.RectF; diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/NativeProxy.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NativeProxy.java similarity index 86% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/NativeProxy.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NativeProxy.java index 02fd6797927a9..f1af5ba2e5d29 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/NativeProxy.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NativeProxy.java @@ -1,4 +1,4 @@ -package versioned.host.exp.exponent.modules.api.reanimated; +package com.swmansion.reanimated; import android.os.SystemClock; import android.util.Log; @@ -16,12 +16,12 @@ import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.events.RCTEventEmitter; import com.swmansion.common.GestureHandlerStateManager; - -import versioned.host.exp.exponent.modules.api.reanimated.layoutReanimation.AnimationsManager; -import versioned.host.exp.exponent.modules.api.reanimated.layoutReanimation.LayoutAnimations; -import versioned.host.exp.exponent.modules.api.reanimated.layoutReanimation.NativeMethodsHolder; -import versioned.host.exp.exponent.modules.api.reanimated.sensor.ReanimatedSensorContainer; -import versioned.host.exp.exponent.modules.api.reanimated.sensor.ReanimatedSensorType; +import com.swmansion.reanimated.keyboardObserver.ReanimatedKeyboardEventListener; +import com.swmansion.reanimated.layoutReanimation.AnimationsManager; +import com.swmansion.reanimated.layoutReanimation.LayoutAnimations; +import com.swmansion.reanimated.layoutReanimation.NativeMethodsHolder; +import com.swmansion.reanimated.sensor.ReanimatedSensorContainer; +import com.swmansion.reanimated.sensor.ReanimatedSensorType; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.HashMap; @@ -88,6 +88,18 @@ private SensorSetter(HybridData hybridData) { public native void sensorSetter(float[] value); } + @DoNotStrip + public static class KeyboardEventDataUpdater { + @DoNotStrip private final HybridData mHybridData; + + @DoNotStrip + private KeyboardEventDataUpdater(HybridData hybridData) { + mHybridData = hybridData; + } + + public native void keyboardEventDataUpdater(int keyboardState, int height); + } + @DoNotStrip @SuppressWarnings("unused") private final HybridData mHybridData; @@ -97,6 +109,7 @@ private SensorSetter(HybridData hybridData) { private Scheduler mScheduler = null; private ReanimatedSensorContainer reanimatedSensorContainer; private final GestureHandlerStateManager gestureHandlerStateManager; + private ReanimatedKeyboardEventListener reanimatedKeyboardEventListener; private Long firstUptime = SystemClock.uptimeMillis(); private boolean slowAnimationsEnabled = false; @@ -111,6 +124,7 @@ public NativeProxy(ReactApplicationContext context) { mContext = new WeakReference<>(context); prepare(LayoutAnimations); reanimatedSensorContainer = new ReanimatedSensorContainer(mContext); + reanimatedKeyboardEventListener = new ReanimatedKeyboardEventListener(mContext); addDevMenuOption(); GestureHandlerStateManager tempHandlerStateManager; @@ -189,14 +203,13 @@ private void setGestureState(int handlerTag, int newState) { } @DoNotStrip - private String getUptime() { + private long getCurrentTime() { if (slowAnimationsEnabled) { final long ANIMATIONS_DRAG_FACTOR = 10; - return Long.toString( - this.firstUptime - + (SystemClock.uptimeMillis() - this.firstUptime) / ANIMATIONS_DRAG_FACTOR); + return this.firstUptime + + (SystemClock.uptimeMillis() - this.firstUptime) / ANIMATIONS_DRAG_FACTOR; } else { - return Long.toString(SystemClock.uptimeMillis()); + return SystemClock.uptimeMillis(); } } @@ -238,6 +251,16 @@ private void unregisterSensor(int sensorId) { reanimatedSensorContainer.unregisterSensor(sensorId); } + @DoNotStrip + private int subscribeForKeyboardEvents(KeyboardEventDataUpdater keyboardEventDataUpdater) { + return reanimatedKeyboardEventListener.subscribeForKeyboardEvents(keyboardEventDataUpdater); + } + + @DoNotStrip + private void unsubscribeFromKeyboardEvents(int listenerId) { + reanimatedKeyboardEventListener.unsubscribeFromKeyboardEvents(listenerId); + } + public void onCatalystInstanceDestroy() { mScheduler.deactivate(); mHybridData.resetNative(); diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/NodesManager.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java similarity index 92% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/NodesManager.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java index adb7f1b209597..2f3230985a40a 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/NodesManager.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java @@ -1,4 +1,6 @@ -package versioned.host.exp.exponent.modules.api.reanimated; +package com.swmansion.reanimated; + +import static java.lang.Float.NaN; import android.util.SparseArray; import android.view.View; @@ -27,28 +29,28 @@ import com.facebook.react.uimanager.events.Event; import com.facebook.react.uimanager.events.EventDispatcherListener; import com.facebook.react.uimanager.events.RCTEventEmitter; -import versioned.host.exp.exponent.modules.api.reanimated.layoutReanimation.AnimationsManager; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.AlwaysNode; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.BezierNode; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.BlockNode; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.CallFuncNode; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.ClockNode; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.ClockOpNode; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.ConcatNode; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.CondNode; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.DebugNode; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.EventNode; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.FunctionNode; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.JSCallNode; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.Node; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.NoopNode; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.OperatorNode; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.ParamNode; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.PropsNode; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.SetNode; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.StyleNode; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.TransformNode; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.ValueNode; +import com.swmansion.reanimated.layoutReanimation.AnimationsManager; +import com.swmansion.reanimated.nodes.AlwaysNode; +import com.swmansion.reanimated.nodes.BezierNode; +import com.swmansion.reanimated.nodes.BlockNode; +import com.swmansion.reanimated.nodes.CallFuncNode; +import com.swmansion.reanimated.nodes.ClockNode; +import com.swmansion.reanimated.nodes.ClockOpNode; +import com.swmansion.reanimated.nodes.ConcatNode; +import com.swmansion.reanimated.nodes.CondNode; +import com.swmansion.reanimated.nodes.DebugNode; +import com.swmansion.reanimated.nodes.EventNode; +import com.swmansion.reanimated.nodes.FunctionNode; +import com.swmansion.reanimated.nodes.JSCallNode; +import com.swmansion.reanimated.nodes.Node; +import com.swmansion.reanimated.nodes.NoopNode; +import com.swmansion.reanimated.nodes.OperatorNode; +import com.swmansion.reanimated.nodes.ParamNode; +import com.swmansion.reanimated.nodes.PropsNode; +import com.swmansion.reanimated.nodes.SetNode; +import com.swmansion.reanimated.nodes.StyleNode; +import com.swmansion.reanimated.nodes.TransformNode; +import com.swmansion.reanimated.nodes.ValueNode; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -83,7 +85,7 @@ public float[] measure(int viewTag) { view = mUIManager.resolveView(viewTag); } catch (IllegalViewOperationException e) { e.printStackTrace(); - return (new float[] {}); + return (new float[] {NaN, NaN, NaN, NaN, NaN, NaN}); } return NativeMethodsHelper.measure(view); } diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/ReanimatedJSIModulePackage.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/ReanimatedJSIModulePackage.java similarity index 94% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/ReanimatedJSIModulePackage.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/ReanimatedJSIModulePackage.java index cabe2e3c75f36..7d1a1652b011a 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/ReanimatedJSIModulePackage.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/ReanimatedJSIModulePackage.java @@ -1,4 +1,4 @@ -package versioned.host.exp.exponent.modules.api.reanimated; +package com.swmansion.reanimated; import android.util.Log; import com.facebook.react.bridge.JSIModulePackage; diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/ReanimatedModule.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/ReanimatedModule.java similarity index 97% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/ReanimatedModule.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/ReanimatedModule.java index 62affff921490..76d7863323d1c 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/ReanimatedModule.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/ReanimatedModule.java @@ -1,4 +1,4 @@ -package versioned.host.exp.exponent.modules.api.reanimated; +package com.swmansion.reanimated; import android.util.Log; import com.facebook.react.bridge.Callback; @@ -12,7 +12,7 @@ import com.facebook.react.uimanager.UIBlock; import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.UIManagerModuleListener; -import versioned.host.exp.exponent.modules.api.reanimated.transitions.TransitionModule; +import com.swmansion.reanimated.transitions.TransitionModule; import java.util.ArrayList; import javax.annotation.Nullable; diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/ReanimatedPackage.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java similarity index 98% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/ReanimatedPackage.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java index c9e7bc7b500ee..e426da6309149 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/ReanimatedPackage.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java @@ -1,4 +1,4 @@ -package versioned.host.exp.exponent.modules.api.reanimated; +package com.swmansion.reanimated; import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_END; import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_START; diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/Scheduler.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/Scheduler.java similarity index 95% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/Scheduler.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/Scheduler.java index bda6fe3732107..3f92ebec9909c 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/Scheduler.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/Scheduler.java @@ -1,4 +1,4 @@ -package versioned.host.exp.exponent.modules.api.reanimated; +package com.swmansion.reanimated; import com.facebook.jni.HybridData; import com.facebook.proguard.annotations.DoNotStrip; diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/UpdateContext.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/UpdateContext.java similarity index 59% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/UpdateContext.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/UpdateContext.java index 561df2a19dd27..01c805fedcc46 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/UpdateContext.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/UpdateContext.java @@ -1,6 +1,6 @@ -package versioned.host.exp.exponent.modules.api.reanimated; +package com.swmansion.reanimated; -import versioned.host.exp.exponent.modules.api.reanimated.nodes.Node; +import com.swmansion.reanimated.nodes.Node; import java.util.ArrayList; public class UpdateContext { diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/Utils.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/Utils.java similarity index 93% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/Utils.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/Utils.java index 7874c833b7e66..f54c0373fed6f 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/Utils.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/Utils.java @@ -1,4 +1,4 @@ -package versioned.host.exp.exponent.modules.api.reanimated; +package com.swmansion.reanimated; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; diff --git a/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java new file mode 100644 index 0000000000000..511293fecaf3b --- /dev/null +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java @@ -0,0 +1,166 @@ +package com.swmansion.reanimated.keyboardObserver; + +import android.os.Handler; +import android.os.Looper; +import android.view.View; +import android.widget.FrameLayout; +import androidx.annotation.NonNull; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowCompat; +import androidx.core.view.WindowInsetsAnimationCompat; +import androidx.core.view.WindowInsetsCompat; +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.uimanager.PixelUtil; +import com.swmansion.reanimated.BuildConfig; +import com.swmansion.reanimated.NativeProxy.KeyboardEventDataUpdater; +import java.lang.ref.WeakReference; +import java.util.HashMap; +import java.util.List; + +public class ReanimatedKeyboardEventListener { + enum KeyboardState { + UNKNOWN(0), + OPENING(1), + OPEN(2), + CLOSING(3), + CLOSED(4); + + private final int value; + + KeyboardState(int value) { + this.value = value; + } + + public int asInt() { + return value; + } + } + + private final WeakReference reactContext; + private int nextListenerId = 0; + private KeyboardState state; + private final HashMap listeners = new HashMap<>(); + + public ReanimatedKeyboardEventListener(WeakReference reactContext) { + this.reactContext = reactContext; + } + + private View getRootView() { + return reactContext.get().getCurrentActivity().getWindow().getDecorView(); + } + + private void setupWindowInsets() { + View rootView = getRootView(); + WindowCompat.setDecorFitsSystemWindows( + reactContext.get().getCurrentActivity().getWindow(), false); + ViewCompat.setOnApplyWindowInsetsListener( + rootView, + (v, insets) -> { + int paddingBottom = 0; + if (!BuildConfig.IS_NEW_ARCHITECTURE_ENABLED + && BuildConfig.REACT_NATIVE_MINOR_VERSION < 70) { + paddingBottom = insets.getInsets(WindowInsetsCompat.Type.navigationBars()).bottom; + } + int paddingTop = insets.getInsets(WindowInsetsCompat.Type.systemBars()).top; + View content = + rootView.getRootView().findViewById(com.swmansion.reanimated.R.id.action_bar_root); + + FrameLayout.LayoutParams params = + new FrameLayout.LayoutParams( + FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); + params.setMargins(0, paddingTop, 0, paddingBottom); + content.setLayoutParams(params); + return insets; + }); + } + + private void updateKeyboard(int keyboardHeight) { + for (KeyboardEventDataUpdater listener : listeners.values()) { + listener.keyboardEventDataUpdater(state.asInt(), keyboardHeight); + } + } + + private class WindowInsetsCallback extends WindowInsetsAnimationCompat.Callback { + private int keyboardHeight = 0; + + public WindowInsetsCallback() { + super(WindowInsetsAnimationCompat.Callback.DISPATCH_MODE_CONTINUE_ON_SUBTREE); + } + + @NonNull + @Override + public WindowInsetsAnimationCompat.BoundsCompat onStart( + @NonNull WindowInsetsAnimationCompat animation, + @NonNull WindowInsetsAnimationCompat.BoundsCompat bounds) { + state = keyboardHeight == 0 ? KeyboardState.OPENING : KeyboardState.CLOSING; + updateKeyboard(keyboardHeight); + return super.onStart(animation, bounds); + } + + @NonNull + @Override + public WindowInsetsCompat onProgress( + @NonNull WindowInsetsCompat insets, + @NonNull List runningAnimations) { + + keyboardHeight = + (int) + PixelUtil.toDIPFromPixel( + Math.max( + 0, + insets.getInsets(WindowInsetsCompat.Type.ime()).bottom + - insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom)); + updateKeyboard(keyboardHeight); + return insets; + } + + @Override + public void onEnd(@NonNull WindowInsetsAnimationCompat animation) { + state = keyboardHeight == 0 ? KeyboardState.CLOSED : KeyboardState.OPEN; + updateKeyboard(keyboardHeight); + } + } + + private void setUpCallbacks() { + View rootView = getRootView(); + new Handler(Looper.getMainLooper()).post(this::setupWindowInsets); + ViewCompat.setWindowInsetsAnimationCallback(rootView, new WindowInsetsCallback()); + } + + public int subscribeForKeyboardEvents(KeyboardEventDataUpdater updater) { + int listenerId = nextListenerId++; + if (listeners.isEmpty()) { + setUpCallbacks(); + } + listeners.put(listenerId, updater); + return listenerId; + } + + private void bringBackWindowInsets() { + WindowCompat.setDecorFitsSystemWindows( + reactContext.get().getCurrentActivity().getWindow(), true); + ViewCompat.setOnApplyWindowInsetsListener(getRootView(), null); + ViewCompat.setWindowInsetsAnimationCallback(getRootView(), null); + View content = + getRootView().getRootView().findViewById(com.swmansion.reanimated.R.id.action_bar_root); + + FrameLayout.LayoutParams params = + new FrameLayout.LayoutParams( + FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); + params.setMargins(0, 0, 0, 0); + content.setLayoutParams(params); + } + + private void removeCallbacks() { + View rootView = getRootView(); + new Handler(Looper.getMainLooper()).post(this::bringBackWindowInsets); + ViewCompat.setWindowInsetsAnimationCallback(rootView, null); + } + + public void unsubscribeFromKeyboardEvents(int listenerId) { + listeners.remove(listenerId); + if (listeners.isEmpty()) { + removeCallbacks(); + } + } +} diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/AnimationsManager.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java similarity index 95% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/AnimationsManager.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java index 7c6d3b8bef965..444bb0dc79712 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/AnimationsManager.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java @@ -1,4 +1,4 @@ -package versioned.host.exp.exponent.modules.api.reanimated.layoutReanimation; +package com.swmansion.reanimated.layoutReanimation; import android.app.Activity; import android.util.DisplayMetrics; @@ -20,7 +20,7 @@ import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.ViewGroupManager; import com.facebook.react.uimanager.ViewManager; -import versioned.host.exp.exponent.modules.api.reanimated.Scheduler; +import com.swmansion.reanimated.Scheduler; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.HashMap; @@ -229,24 +229,27 @@ public void notifyAboutEnd(int tag, boolean cancelled) { } private void removeLeftovers() { - HashSet roots = new HashSet<>(); - // go through ready to remove from bottom to top - for (int tag : mToRemove) { - View view = mViewForTag.get(tag); - if (view == null) { - try { - view = mUIManager.resolveView(tag); - mViewForTag.put(tag, view); - } catch (IllegalViewOperationException ignored) { - continue; + // mToRemove may be null if onCatalystInstanceDestroy was called first + if (mToRemove != null) { + HashSet roots = new HashSet<>(); + // go through ready to remove from bottom to top + for (int tag : mToRemove) { + View view = mViewForTag.get(tag); + if (view == null) { + try { + view = mUIManager.resolveView(tag); + mViewForTag.put(tag, view); + } catch (IllegalViewOperationException ignored) { + continue; + } } + findRoot(view, roots); } - findRoot(view, roots); - } - for (int tag : roots) { - View view = mViewForTag.get(tag); - if (view != null) { - dfs(view, view, mToRemove); + for (int tag : roots) { + View view = mViewForTag.get(tag); + if (view != null) { + dfs(view, view, mToRemove); + } } } } diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/LayoutAnimations.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java similarity index 90% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/LayoutAnimations.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java index 64e5bef060508..1443516577010 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/LayoutAnimations.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java @@ -1,9 +1,9 @@ -package versioned.host.exp.exponent.modules.api.reanimated.layoutReanimation; +package com.swmansion.reanimated.layoutReanimation; import com.facebook.jni.HybridData; import com.facebook.proguard.annotations.DoNotStrip; import com.facebook.react.bridge.ReactApplicationContext; -import versioned.host.exp.exponent.modules.api.reanimated.ReanimatedModule; +import com.swmansion.reanimated.ReanimatedModule; import java.lang.ref.WeakReference; import java.util.Map; diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/NativeMethodsHolder.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java similarity index 76% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/NativeMethodsHolder.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java index 878e1deae110f..45564bfb2b740 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/NativeMethodsHolder.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java @@ -1,4 +1,4 @@ -package versioned.host.exp.exponent.modules.api.reanimated.layoutReanimation; +package com.swmansion.reanimated.layoutReanimation; import java.util.HashMap; diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java similarity index 99% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java index fa08638611006..b0e33b0f9faa1 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java @@ -1,4 +1,4 @@ -package versioned.host.exp.exponent.modules.api.reanimated.layoutReanimation; +package com.swmansion.reanimated.layoutReanimation; import android.os.Build; import android.util.Log; @@ -16,7 +16,7 @@ import com.facebook.react.uimanager.ViewManagerRegistry; import com.facebook.react.uimanager.layoutanimation.LayoutAnimationController; import com.facebook.react.uimanager.layoutanimation.LayoutAnimationListener; -import versioned.host.exp.exponent.modules.api.reanimated.ReanimatedModule; +import com.swmansion.reanimated.ReanimatedModule; import java.lang.ref.WeakReference; import java.lang.reflect.Field; import java.lang.reflect.Modifier; diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/ReanimatedUIImplementation.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIImplementation.java similarity index 95% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/ReanimatedUIImplementation.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIImplementation.java index cfae16c65a539..36d6a4af1d31a 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/ReanimatedUIImplementation.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIImplementation.java @@ -4,7 +4,7 @@ import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.uimanager.events.EventDispatcher; -import versioned.host.exp.exponent.modules.api.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager; +import com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager; import java.util.List; public class ReanimatedUIImplementation extends UIImplementation { diff --git a/android/expoview/src/main/java/com/facebook/react/uimanager/ReanimatedUIManager.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java similarity index 100% rename from android/expoview/src/main/java/com/facebook/react/uimanager/ReanimatedUIManager.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/Snapshot.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java similarity index 98% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/Snapshot.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java index 6682bf5f4383e..bfff89d92d657 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/Snapshot.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java @@ -1,4 +1,4 @@ -package versioned.host.exp.exponent.modules.api.reanimated.layoutReanimation; +package com.swmansion.reanimated.layoutReanimation; import android.view.View; import android.view.ViewGroup; diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/ViewHierarchyObserver.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ViewHierarchyObserver.java similarity index 80% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/ViewHierarchyObserver.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ViewHierarchyObserver.java index 8abf243478de3..ca4a47f3a4c11 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/layoutReanimation/ViewHierarchyObserver.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ViewHierarchyObserver.java @@ -1,4 +1,4 @@ -package versioned.host.exp.exponent.modules.api.reanimated.layoutReanimation; +package com.swmansion.reanimated.layoutReanimation; import android.view.View; import android.view.ViewGroup; diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/AlwaysNode.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/AlwaysNode.java similarity index 76% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/AlwaysNode.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/AlwaysNode.java index 3c96253a04742..79c8bf76f59a8 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/AlwaysNode.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/AlwaysNode.java @@ -1,8 +1,8 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; +package com.swmansion.reanimated.nodes; import com.facebook.react.bridge.ReadableMap; -import versioned.host.exp.exponent.modules.api.reanimated.MapUtils; -import versioned.host.exp.exponent.modules.api.reanimated.NodesManager; +import com.swmansion.reanimated.MapUtils; +import com.swmansion.reanimated.NodesManager; public class AlwaysNode extends Node implements FinalNode { public AlwaysNode(int nodeID, ReadableMap config, NodesManager nodesManager) { diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/BezierNode.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/BezierNode.java similarity index 92% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/BezierNode.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/BezierNode.java index 745f023887d8e..f7fa8a9be934d 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/BezierNode.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/BezierNode.java @@ -1,9 +1,9 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; +package com.swmansion.reanimated.nodes; import android.graphics.PointF; import com.facebook.react.bridge.ReadableMap; -import versioned.host.exp.exponent.modules.api.reanimated.MapUtils; -import versioned.host.exp.exponent.modules.api.reanimated.NodesManager; +import com.swmansion.reanimated.MapUtils; +import com.swmansion.reanimated.NodesManager; public class BezierNode extends Node { diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/BlockNode.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/BlockNode.java similarity index 71% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/BlockNode.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/BlockNode.java index c680d4738a86e..dd3785d2ffd85 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/BlockNode.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/BlockNode.java @@ -1,8 +1,8 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; +package com.swmansion.reanimated.nodes; import com.facebook.react.bridge.ReadableMap; -import versioned.host.exp.exponent.modules.api.reanimated.NodesManager; -import versioned.host.exp.exponent.modules.api.reanimated.Utils; +import com.swmansion.reanimated.NodesManager; +import com.swmansion.reanimated.Utils; public class BlockNode extends Node { diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/CallFuncNode.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/CallFuncNode.java similarity index 87% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/CallFuncNode.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/CallFuncNode.java index f8a4fcf0ff9f0..7134b9378b136 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/CallFuncNode.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/CallFuncNode.java @@ -1,8 +1,8 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; +package com.swmansion.reanimated.nodes; import com.facebook.react.bridge.ReadableMap; -import versioned.host.exp.exponent.modules.api.reanimated.NodesManager; -import versioned.host.exp.exponent.modules.api.reanimated.Utils; +import com.swmansion.reanimated.NodesManager; +import com.swmansion.reanimated.Utils; public class CallFuncNode extends Node { diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/ClockNode.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/ClockNode.java similarity index 83% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/ClockNode.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/ClockNode.java index 227269ac2130d..35f335c9710b6 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/ClockNode.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/ClockNode.java @@ -1,7 +1,7 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; +package com.swmansion.reanimated.nodes; import com.facebook.react.bridge.ReadableMap; -import versioned.host.exp.exponent.modules.api.reanimated.NodesManager; +import com.swmansion.reanimated.NodesManager; public class ClockNode extends Node implements NodesManager.OnAnimationFrame { diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/ClockOpNode.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/ClockOpNode.java similarity index 90% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/ClockOpNode.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/ClockOpNode.java index ef4744782b07c..5e6ffe963da01 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/ClockOpNode.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/ClockOpNode.java @@ -1,8 +1,8 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; +package com.swmansion.reanimated.nodes; import com.facebook.react.bridge.ReadableMap; -import versioned.host.exp.exponent.modules.api.reanimated.MapUtils; -import versioned.host.exp.exponent.modules.api.reanimated.NodesManager; +import com.swmansion.reanimated.MapUtils; +import com.swmansion.reanimated.NodesManager; public abstract class ClockOpNode extends Node { diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/ConcatNode.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/ConcatNode.java similarity index 82% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/ConcatNode.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/ConcatNode.java index 23482d1bfe4ac..5be15115fa8cb 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/ConcatNode.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/ConcatNode.java @@ -1,8 +1,8 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; +package com.swmansion.reanimated.nodes; import com.facebook.react.bridge.ReadableMap; -import versioned.host.exp.exponent.modules.api.reanimated.NodesManager; -import versioned.host.exp.exponent.modules.api.reanimated.Utils; +import com.swmansion.reanimated.NodesManager; +import com.swmansion.reanimated.Utils; import java.text.NumberFormat; import java.util.Locale; diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/CondNode.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/CondNode.java similarity index 86% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/CondNode.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/CondNode.java index b3c5014d063c7..e1863d0d82be7 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/CondNode.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/CondNode.java @@ -1,8 +1,8 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; +package com.swmansion.reanimated.nodes; import com.facebook.react.bridge.ReadableMap; -import versioned.host.exp.exponent.modules.api.reanimated.MapUtils; -import versioned.host.exp.exponent.modules.api.reanimated.NodesManager; +import com.swmansion.reanimated.MapUtils; +import com.swmansion.reanimated.NodesManager; public class CondNode extends Node { diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/DebugNode.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/DebugNode.java similarity index 81% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/DebugNode.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/DebugNode.java index 99be536fb5917..df017f739b2e1 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/DebugNode.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/DebugNode.java @@ -1,9 +1,9 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; +package com.swmansion.reanimated.nodes; import android.util.Log; import com.facebook.react.bridge.ReadableMap; -import versioned.host.exp.exponent.modules.api.reanimated.MapUtils; -import versioned.host.exp.exponent.modules.api.reanimated.NodesManager; +import com.swmansion.reanimated.MapUtils; +import com.swmansion.reanimated.NodesManager; public class DebugNode extends Node { diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/EventNode.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/EventNode.java similarity index 94% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/EventNode.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/EventNode.java index 8ceaaea1cc590..5eac1b2477b2d 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/EventNode.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/EventNode.java @@ -1,11 +1,11 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; +package com.swmansion.reanimated.nodes; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.WritableArray; import com.facebook.react.bridge.WritableMap; import com.facebook.react.uimanager.events.RCTEventEmitter; -import versioned.host.exp.exponent.modules.api.reanimated.NodesManager; +import com.swmansion.reanimated.NodesManager; import java.util.ArrayList; import java.util.List; import javax.annotation.Nullable; diff --git a/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/FinalNode.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/FinalNode.java new file mode 100644 index 0000000000000..9b2822bde9a74 --- /dev/null +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/FinalNode.java @@ -0,0 +1,5 @@ +package com.swmansion.reanimated.nodes; + +public interface FinalNode { + void update(); +} diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/FunctionNode.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/FunctionNode.java similarity index 76% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/FunctionNode.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/FunctionNode.java index a2a4ff52bf3e1..9970a94d78bb4 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/FunctionNode.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/FunctionNode.java @@ -1,7 +1,7 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; +package com.swmansion.reanimated.nodes; import com.facebook.react.bridge.ReadableMap; -import versioned.host.exp.exponent.modules.api.reanimated.NodesManager; +import com.swmansion.reanimated.NodesManager; public class FunctionNode extends Node { diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/JSCallNode.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/JSCallNode.java similarity index 85% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/JSCallNode.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/JSCallNode.java index cc631818a2cc0..60a4b386511f5 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/JSCallNode.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/JSCallNode.java @@ -1,11 +1,11 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; +package com.swmansion.reanimated.nodes; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.WritableArray; import com.facebook.react.bridge.WritableMap; -import versioned.host.exp.exponent.modules.api.reanimated.NodesManager; -import versioned.host.exp.exponent.modules.api.reanimated.Utils; +import com.swmansion.reanimated.NodesManager; +import com.swmansion.reanimated.Utils; public class JSCallNode extends Node { diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/Node.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/Node.java similarity index 95% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/Node.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/Node.java index e69d1b2f64df2..031015983c0da 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/Node.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/Node.java @@ -1,9 +1,9 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; +package com.swmansion.reanimated.nodes; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.UiThreadUtil; -import versioned.host.exp.exponent.modules.api.reanimated.NodesManager; -import versioned.host.exp.exponent.modules.api.reanimated.UpdateContext; +import com.swmansion.reanimated.NodesManager; +import com.swmansion.reanimated.UpdateContext; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/NoopNode.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/NoopNode.java similarity index 86% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/NoopNode.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/NoopNode.java index 8198b797b06e5..776cba003cfda 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/NoopNode.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/NoopNode.java @@ -1,6 +1,6 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; +package com.swmansion.reanimated.nodes; -import versioned.host.exp.exponent.modules.api.reanimated.NodesManager; +import com.swmansion.reanimated.NodesManager; /** * This node is used by {@link NodesManager} to return in place of a missing node that might have diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/OperatorNode.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/OperatorNode.java similarity index 98% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/OperatorNode.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/OperatorNode.java index d4dc6d25bac13..7740c2c982a9f 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/OperatorNode.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/OperatorNode.java @@ -1,9 +1,9 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; +package com.swmansion.reanimated.nodes; import com.facebook.react.bridge.JSApplicationIllegalArgumentException; import com.facebook.react.bridge.ReadableMap; -import versioned.host.exp.exponent.modules.api.reanimated.NodesManager; -import versioned.host.exp.exponent.modules.api.reanimated.Utils; +import com.swmansion.reanimated.NodesManager; +import com.swmansion.reanimated.Utils; public class OperatorNode extends Node { diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/ParamNode.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/ParamNode.java similarity index 93% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/ParamNode.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/ParamNode.java index 04694cbf64c16..53393d40900e6 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/ParamNode.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/ParamNode.java @@ -1,7 +1,7 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; +package com.swmansion.reanimated.nodes; import com.facebook.react.bridge.ReadableMap; -import versioned.host.exp.exponent.modules.api.reanimated.NodesManager; +import com.swmansion.reanimated.NodesManager; import java.util.Stack; public class ParamNode extends ValueNode { diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/PropsNode.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/PropsNode.java similarity index 96% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/PropsNode.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/PropsNode.java index 8ee0c63954140..effb2e2c7275f 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/PropsNode.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/PropsNode.java @@ -1,4 +1,4 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; +package com.swmansion.reanimated.nodes; import android.view.View; import com.facebook.react.bridge.Arguments; @@ -10,8 +10,8 @@ import com.facebook.react.bridge.WritableMap; import com.facebook.react.uimanager.ReactStylesDiffMap; import com.facebook.react.uimanager.UIImplementation; -import versioned.host.exp.exponent.modules.api.reanimated.NodesManager; -import versioned.host.exp.exponent.modules.api.reanimated.Utils; +import com.swmansion.reanimated.NodesManager; +import com.swmansion.reanimated.Utils; import java.util.Map; public class PropsNode extends Node implements FinalNode { diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/SetNode.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/SetNode.java similarity index 80% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/SetNode.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/SetNode.java index 21102954661b6..22d2e368b1643 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/SetNode.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/SetNode.java @@ -1,8 +1,8 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; +package com.swmansion.reanimated.nodes; import com.facebook.react.bridge.ReadableMap; -import versioned.host.exp.exponent.modules.api.reanimated.MapUtils; -import versioned.host.exp.exponent.modules.api.reanimated.NodesManager; +import com.swmansion.reanimated.MapUtils; +import com.swmansion.reanimated.NodesManager; public class SetNode extends Node { diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/StyleNode.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/StyleNode.java similarity index 85% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/StyleNode.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/StyleNode.java index d048087fd8ab3..9917e85bce966 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/StyleNode.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/StyleNode.java @@ -1,11 +1,11 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; +package com.swmansion.reanimated.nodes; import com.facebook.react.bridge.JavaOnlyMap; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.WritableArray; import com.facebook.react.bridge.WritableMap; -import versioned.host.exp.exponent.modules.api.reanimated.NodesManager; -import versioned.host.exp.exponent.modules.api.reanimated.Utils; +import com.swmansion.reanimated.NodesManager; +import com.swmansion.reanimated.Utils; import java.util.Map; public class StyleNode extends Node { diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/TransformNode.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/TransformNode.java similarity index 95% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/TransformNode.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/TransformNode.java index a0af4038c4826..520320b22419c 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/TransformNode.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/TransformNode.java @@ -1,4 +1,4 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; +package com.swmansion.reanimated.nodes; import com.facebook.react.bridge.JavaOnlyArray; import com.facebook.react.bridge.JavaOnlyMap; @@ -6,7 +6,7 @@ import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableType; import com.facebook.react.bridge.WritableArray; -import versioned.host.exp.exponent.modules.api.reanimated.NodesManager; +import com.swmansion.reanimated.NodesManager; import java.util.ArrayList; import java.util.List; diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/ValueNode.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/ValueNode.java similarity index 87% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/ValueNode.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/ValueNode.java index f9e952051b23e..0fe5439bf793f 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/nodes/ValueNode.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/nodes/ValueNode.java @@ -1,8 +1,8 @@ -package versioned.host.exp.exponent.modules.api.reanimated.nodes; +package com.swmansion.reanimated.nodes; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.ReadableType; -import versioned.host.exp.exponent.modules.api.reanimated.NodesManager; +import com.swmansion.reanimated.NodesManager; import javax.annotation.Nullable; public class ValueNode extends Node { diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/sensor/ReanimatedSensor.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java similarity index 82% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/sensor/ReanimatedSensor.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java index b40cd99b0b125..6134a802873f9 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/sensor/ReanimatedSensor.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java @@ -1,9 +1,9 @@ -package versioned.host.exp.exponent.modules.api.reanimated.sensor; +package com.swmansion.reanimated.sensor; import android.hardware.Sensor; import android.hardware.SensorManager; import com.facebook.react.bridge.ReactApplicationContext; -import versioned.host.exp.exponent.modules.api.reanimated.NativeProxy; +import com.swmansion.reanimated.NativeProxy; import java.lang.ref.WeakReference; public class ReanimatedSensor { @@ -23,7 +23,11 @@ public class ReanimatedSensor { sensorManager = (SensorManager) reactContext.get().getSystemService(reactContext.get().SENSOR_SERVICE); this.sensorType = sensorType; - this.interval = interval; + if (interval == -1) { + this.interval = SensorManager.SENSOR_DELAY_UI; + } else { + this.interval = interval; + } } boolean initialize() { diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/sensor/ReanimatedSensorContainer.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java similarity index 89% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/sensor/ReanimatedSensorContainer.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java index 9b4dba721f910..ab7b322272792 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/sensor/ReanimatedSensorContainer.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java @@ -1,8 +1,8 @@ -package versioned.host.exp.exponent.modules.api.reanimated.sensor; +package com.swmansion.reanimated.sensor; import android.util.Log; import com.facebook.react.bridge.ReactApplicationContext; -import versioned.host.exp.exponent.modules.api.reanimated.NativeProxy; +import com.swmansion.reanimated.NativeProxy; import java.lang.ref.WeakReference; import java.util.HashMap; diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/sensor/ReanimatedSensorListener.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java similarity index 92% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/sensor/ReanimatedSensorListener.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java index 7f36538e64773..704553711264b 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/sensor/ReanimatedSensorListener.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java @@ -1,10 +1,10 @@ -package versioned.host.exp.exponent.modules.api.reanimated.sensor; +package com.swmansion.reanimated.sensor; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; -import versioned.host.exp.exponent.modules.api.reanimated.NativeProxy; +import com.swmansion.reanimated.NativeProxy; public class ReanimatedSensorListener implements SensorEventListener { diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/sensor/ReanimatedSensorType.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorType.java similarity index 88% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/sensor/ReanimatedSensorType.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorType.java index 1f4582c053201..90e85fb1f907d 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/sensor/ReanimatedSensorType.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorType.java @@ -1,9 +1,9 @@ -package versioned.host.exp.exponent.modules.api.reanimated.sensor; +package com.swmansion.reanimated.sensor; import android.hardware.Sensor; public enum ReanimatedSensorType { - ACCELEROMETER(Sensor.TYPE_ACCELEROMETER), + ACCELEROMETER(Sensor.TYPE_LINEAR_ACCELERATION), GYROSCOPE(Sensor.TYPE_GYROSCOPE), GRAVITY(Sensor.TYPE_GRAVITY), MAGNETIC_FIELD(Sensor.TYPE_MAGNETIC_FIELD), diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/transitions/ChangeTransition.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/transitions/ChangeTransition.java similarity index 97% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/transitions/ChangeTransition.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/transitions/ChangeTransition.java index fea038d2ebd3f..485e7e41f2665 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/transitions/ChangeTransition.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/transitions/ChangeTransition.java @@ -1,4 +1,4 @@ -package versioned.host.exp.exponent.modules.api.reanimated.transitions; +package com.swmansion.reanimated.transitions; import android.animation.Animator; import android.animation.AnimatorSet; diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/transitions/SaneSidePropagation.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/transitions/SaneSidePropagation.java similarity index 90% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/transitions/SaneSidePropagation.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/transitions/SaneSidePropagation.java index b5fb4140026c1..7898fbc2ad8fb 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/transitions/SaneSidePropagation.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/transitions/SaneSidePropagation.java @@ -1,4 +1,4 @@ -package versioned.host.exp.exponent.modules.api.reanimated.transitions; +package com.swmansion.reanimated.transitions; import android.view.View; import android.view.ViewGroup; diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/transitions/Scale.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/transitions/Scale.java similarity index 97% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/transitions/Scale.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/transitions/Scale.java index 653b59de5f0fa..38ca3b78b68ba 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/transitions/Scale.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/transitions/Scale.java @@ -1,4 +1,4 @@ -package versioned.host.exp.exponent.modules.api.reanimated.transitions; +package com.swmansion.reanimated.transitions; import android.animation.Animator; import android.animation.AnimatorSet; diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/transitions/TransitionModule.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/transitions/TransitionModule.java similarity index 95% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/transitions/TransitionModule.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/transitions/TransitionModule.java index bbaf56a70d606..306662c5e382c 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/transitions/TransitionModule.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/transitions/TransitionModule.java @@ -1,4 +1,4 @@ -package versioned.host.exp.exponent.modules.api.reanimated.transitions; +package com.swmansion.reanimated.transitions; import android.view.View; import android.view.ViewGroup; diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/transitions/TransitionUtils.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/transitions/TransitionUtils.java similarity index 98% rename from android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/transitions/TransitionUtils.java rename to android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/transitions/TransitionUtils.java index 00ca5680815d7..be79f17f9110b 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/reanimated/transitions/TransitionUtils.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/transitions/TransitionUtils.java @@ -1,4 +1,4 @@ -package versioned.host.exp.exponent.modules.api.reanimated.transitions; +package com.swmansion.reanimated.transitions; import android.view.Gravity; import android.view.animation.AccelerateDecelerateInterpolator; diff --git a/apps/bare-expo/package.json b/apps/bare-expo/package.json index 2247b6876878c..294193861fb25 100644 --- a/apps/bare-expo/package.json +++ b/apps/bare-expo/package.json @@ -113,7 +113,7 @@ "react-dom": "18.0.0", "react-native": "0.70.3", "react-native-gesture-handler": "~2.7.0", - "react-native-reanimated": "~2.10.0", + "react-native-reanimated": "~2.11.0", "react-native-safe-area-context": "4.4.1", "react-native-screens": "~3.18.0", "react-native-shared-element": "0.8.4", diff --git a/apps/native-component-list/package.json b/apps/native-component-list/package.json index 44161c23b4134..9e7541a3107ed 100644 --- a/apps/native-component-list/package.json +++ b/apps/native-component-list/package.json @@ -150,7 +150,7 @@ "react-native-maps": "1.3.2", "react-native-pager-view": "6.0.1", "react-native-paper": "^4.0.1", - "react-native-reanimated": "~2.10.0", + "react-native-reanimated": "~2.11.0", "react-native-safe-area-context": "4.4.1", "react-native-safe-area-view": "^0.14.8", "react-native-screens": "~3.18.0", diff --git a/home/package.json b/home/package.json index 7d1edb54d1270..bcdc6670c67a6 100644 --- a/home/package.json +++ b/home/package.json @@ -61,7 +61,7 @@ "react-native-keyboard-aware-scroll-view": "^0.9.5", "react-native-maps": "1.3.2", "react-native-paper": "^4.0.1", - "react-native-reanimated": "~2.10.0", + "react-native-reanimated": "~2.11.0", "react-native-safe-area-context": "4.4.1", "react-native-screens": "~3.18.0", "react-redux": "^7.2.0", diff --git a/ios/Podfile.lock b/ios/Podfile.lock index b939e9d431c27..5172b5028e17b 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -2021,7 +2021,7 @@ PODS: - React-Core - RNGestureHandler (2.7.0): - React-Core - - RNReanimated (2.9.1): + - RNReanimated (2.11.0): - DoubleConversion - FBLazyVector - FBReactNativeSpec @@ -3524,7 +3524,7 @@ SPEC CHECKSUMS: ReactCommon: 01064177e66d652192c661de899b1076da962fd9 RNFlashList: 5116f2de2f543f01bfc30b22d5942d5af84b43df RNGestureHandler: 7673697e7c0e9391adefae4faa087442bc04af33 - RNReanimated: 5c8c17e26787fd8984cd5accdc70fef2ca70aafd + RNReanimated: 590d19d77725fa713c2a0f7f656f6ac41b9ab3e8 RNScreens: f3230dd008a7d0ce5c0a8bc78ff12cf2315bda24 RNSVG: 07dbd870b0dcdecc99b3a202fa37c8ca163caec2 Stripe: 90c12b350ae9e8a262efa87d230c00110c741f88 diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp index 89d212db8cd91..83948c91314fb 100644 --- a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +++ b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp @@ -2,6 +2,9 @@ #include "MutableValue.h" #include "ValueWrapper.h" +#include +#include + namespace reanimated { AnimatedSensorModule::AnimatedSensorModule( @@ -35,10 +38,10 @@ jsi::Value AnimatedSensorModule::registerSensor( setter = [&, mutableObject](double newValues[]) { jsi::Runtime &runtime = *runtimeManager_->runtime.get(); jsi::Object value(runtime); - value.setProperty(runtime, "qw", newValues[0]); - value.setProperty(runtime, "qx", newValues[1]); - value.setProperty(runtime, "qy", newValues[2]); - value.setProperty(runtime, "qz", newValues[3]); + value.setProperty(runtime, "qx", newValues[0]); + value.setProperty(runtime, "qy", newValues[1]); + value.setProperty(runtime, "qz", newValues[2]); + value.setProperty(runtime, "qw", newValues[3]); value.setProperty(runtime, "yaw", newValues[4]); value.setProperty(runtime, "pitch", newValues[5]); value.setProperty(runtime, "roll", newValues[6]); diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/AnimatedSensor/AnimatedSensorModule.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/AnimatedSensor/AnimatedSensorModule.h similarity index 100% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/AnimatedSensor/AnimatedSensorModule.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/AnimatedSensor/AnimatedSensorModule.h diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp index 96bd26c17fdf4..bbfaacf5d159c 100644 --- a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp +++ b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp @@ -4,6 +4,8 @@ #include "ShareableValue.h" #include "ValueWrapper.h" +#include + namespace reanimated { const long long idOffset = 1e9; diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/LayoutAnimations/LayoutAnimationsProxy.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.h similarity index 100% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/LayoutAnimations/LayoutAnimationsProxy.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.h diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModule.cpp b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModule.cpp index 50584dd761118..8f8de85a495e1 100644 --- a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModule.cpp +++ b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModule.cpp @@ -2,6 +2,8 @@ #include #include #include +#include + #include "EventHandlerRegistry.h" #include "FeaturesConfig.h" #include "FrozenObject.h" @@ -98,6 +100,10 @@ NativeReanimatedModule::NativeReanimatedModule( this->onRender(timestampMs); }; updaterFunction = platformDepMethodsHolder.updaterFunction; + subscribeForKeyboardEventsFunction = + platformDepMethodsHolder.subscribeForKeyboardEvents; + unsubscribeFromKeyboardEventsFunction = + platformDepMethodsHolder.unsubscribeFromKeyboardEvents; } void NativeReanimatedModule::installCoreFunctions( @@ -327,4 +333,38 @@ void NativeReanimatedModule::unregisterSensor( animatedSensorModule.unregisterSensor(sensorId); } +jsi::Value NativeReanimatedModule::subscribeForKeyboardEvents( + jsi::Runtime &rt, + const jsi::Value &keyboardEventContainer) { + jsi::Object keyboardEventObj = keyboardEventContainer.getObject(rt); + std::unordered_map> + sharedProperties; + std::shared_ptr keyboardStateShared = ShareableValue::adapt( + rt, keyboardEventObj.getProperty(rt, "state"), this); + std::shared_ptr heightShared = ShareableValue::adapt( + rt, keyboardEventObj.getProperty(rt, "height"), this); + + auto keyboardEventDataUpdater = + [this, &rt, keyboardStateShared, heightShared]( + int keyboardState, int height) { + auto &keyboardStateValue = + ValueWrapper::asMutableValue(keyboardStateShared->valueContainer); + keyboardStateValue->setValue(rt, jsi::Value(keyboardState)); + + auto &heightMutableValue = + ValueWrapper::asMutableValue(heightShared->valueContainer); + heightMutableValue->setValue(rt, jsi::Value(height)); + + this->mapperRegistry->execute(*this->runtime); + }; + + return subscribeForKeyboardEventsFunction(keyboardEventDataUpdater); +} + +void NativeReanimatedModule::unsubscribeFromKeyboardEvents( + jsi::Runtime &rt, + const jsi::Value &listenerId) { + unsubscribeFromKeyboardEventsFunction(listenerId.asNumber()); +} + } // namespace reanimated diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/NativeModules/NativeReanimatedModule.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModule.h similarity index 87% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/NativeModules/NativeReanimatedModule.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModule.h index fdcea13424d23..ec06185a2fd48 100644 --- a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +++ b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModule.h @@ -13,6 +13,7 @@ #include "RuntimeDecorator.h" #include "RuntimeManager.h" #include "Scheduler.h" +#include "SingleInstanceChecker.h" namespace reanimated { @@ -89,6 +90,12 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec, const jsi::Value &interval, const jsi::Value &sensorDataContainer) override; void unregisterSensor(jsi::Runtime &rt, const jsi::Value &sensorId) override; + jsi::Value subscribeForKeyboardEvents( + jsi::Runtime &rt, + const jsi::Value &keyboardEventContainer) override; + void unsubscribeFromKeyboardEvents( + jsi::Runtime &rt, + const jsi::Value &listenerId) override; private: std::shared_ptr mapperRegistry; @@ -103,6 +110,12 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec, std::shared_ptr layoutAnimationsProxy; AnimatedSensorModule animatedSensorModule; ConfigurePropsFunction configurePropsPlatformFunction; + KeyboardEventSubscribeFunction subscribeForKeyboardEventsFunction; + KeyboardEventUnsubscribeFunction unsubscribeFromKeyboardEventsFunction; + +#ifdef DEBUG + SingleInstanceChecker singleInstanceChecker_; +#endif }; } // namespace reanimated diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp index 14819e06ff1cb..eb49f1c61dab2 100644 --- a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +++ b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp @@ -1,5 +1,7 @@ #include "NativeReanimatedModuleSpec.h" +#include + #define SPEC_PREFIX(FN_NAME) __hostFunction_NativeReanimatedModuleSpec_##FN_NAME namespace reanimated { @@ -138,6 +140,25 @@ static jsi::Value SPEC_PREFIX(configureProps)( return jsi::Value::undefined(); } +static jsi::Value SPEC_PREFIX(subscribeForKeyboardEvents)( + jsi::Runtime &rt, + TurboModule &turboModule, + const jsi::Value *args, + size_t count) { + return static_cast(&turboModule) + ->subscribeForKeyboardEvents(rt, std::move(args[0])); +} + +static jsi::Value SPEC_PREFIX(unsubscribeFromKeyboardEvents)( + jsi::Runtime &rt, + TurboModule &turboModule, + const jsi::Value *args, + size_t count) { + static_cast(&turboModule) + ->unsubscribeFromKeyboardEvents(rt, std::move(args[0])); + return jsi::Value::undefined(); +} + NativeReanimatedModuleSpec::NativeReanimatedModuleSpec( std::shared_ptr jsInvoker) : TurboModule("NativeReanimated", jsInvoker) { @@ -163,5 +184,9 @@ NativeReanimatedModuleSpec::NativeReanimatedModuleSpec( methodMap_["unregisterSensor"] = MethodMetadata{1, SPEC_PREFIX(unregisterSensor)}; methodMap_["configureProps"] = MethodMetadata{2, SPEC_PREFIX(configureProps)}; + methodMap_["subscribeForKeyboardEvents"] = + MethodMetadata{1, SPEC_PREFIX(subscribeForKeyboardEvents)}; + methodMap_["unsubscribeFromKeyboardEvents"] = + MethodMetadata{1, SPEC_PREFIX(unsubscribeFromKeyboardEvents)}; } } // namespace reanimated diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h similarity index 88% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h index eae4509f0eb13..30d74cbb9961f 100644 --- a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +++ b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h @@ -4,7 +4,7 @@ #include #include -#ifdef ONANDROID +#ifdef ANDROID #include "TurboModule.h" #else #include @@ -69,6 +69,14 @@ class JSI_EXPORT NativeReanimatedModuleSpec : public TurboModule { jsi::Runtime &rt, const jsi::Value &sensorId) = 0; + // keyboard + virtual jsi::Value subscribeForKeyboardEvents( + jsi::Runtime &rt, + const jsi::Value &keyboardEventContainer) = 0; + virtual void unsubscribeFromKeyboardEvents( + jsi::Runtime &rt, + const jsi::Value &listenerId) = 0; + // other virtual jsi::Value enableLayoutAnimations( jsi::Runtime &rt, diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Registries/EventHandlerRegistry.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/EventHandlerRegistry.h similarity index 100% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Registries/EventHandlerRegistry.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/EventHandlerRegistry.h diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/MapperRegistry.cpp b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/MapperRegistry.cpp index dac74fb085da8..3d764d78499bf 100644 --- a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/MapperRegistry.cpp +++ b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/MapperRegistry.cpp @@ -1,8 +1,10 @@ #include "MapperRegistry.h" +#include "Mapper.h" + #include #include #include -#include "Mapper.h" +#include namespace reanimated { diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Registries/MapperRegistry.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/MapperRegistry.h similarity index 100% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Registries/MapperRegistry.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/MapperRegistry.h diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/WorkletsCache.cpp b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/WorkletsCache.cpp index c72e62b12d485..66409d36be938 100644 --- a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/WorkletsCache.cpp +++ b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/WorkletsCache.cpp @@ -2,6 +2,9 @@ #include "FrozenObject.h" #include "ShareableValue.h" +#include +#include + using namespace facebook; namespace reanimated { diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Registries/WorkletsCache.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/WorkletsCache.h similarity index 100% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Registries/WorkletsCache.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/Registries/WorkletsCache.h diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/SharedItems/FrozenObject.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/FrozenObject.h similarity index 100% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/SharedItems/FrozenObject.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/FrozenObject.h diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/SharedItems/HostFunctionHandler.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/HostFunctionHandler.h similarity index 100% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/SharedItems/HostFunctionHandler.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/HostFunctionHandler.h diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/MutableValue.cpp b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/MutableValue.cpp index 4fbf9c4a7d048..eebbb7753e0de 100644 --- a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/MutableValue.cpp +++ b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/MutableValue.cpp @@ -4,6 +4,8 @@ #include "ShareableValue.h" #include "SharedParent.h" +#include + namespace reanimated { void MutableValue::setValue(jsi::Runtime &rt, const jsi::Value &newValue) { diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/SharedItems/MutableValue.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/MutableValue.h similarity index 100% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/SharedItems/MutableValue.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/MutableValue.h diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/SharedItems/MutableValueSetterProxy.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/MutableValueSetterProxy.h similarity index 100% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/SharedItems/MutableValueSetterProxy.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/MutableValueSetterProxy.h diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/SharedItems/RemoteObject.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/RemoteObject.h similarity index 100% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/SharedItems/RemoteObject.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/RemoteObject.h diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/SharedItems/RuntimeManager.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/RuntimeManager.h similarity index 100% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/SharedItems/RuntimeManager.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/RuntimeManager.h diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/ShareableValue.cpp b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/ShareableValue.cpp index d65b2a16bc4ea..ef6c82466802f 100644 --- a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/ShareableValue.cpp +++ b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/ShareableValue.cpp @@ -1,10 +1,13 @@ #include +#include + #include "FrozenObject.h" #include "MutableValue.h" #include "MutableValueSetterProxy.h" #include "RemoteObject.h" #include "RuntimeDecorator.h" #include "RuntimeManager.h" +#include "ShareableValue.h" #include "SharedParent.h" namespace reanimated { @@ -394,8 +397,10 @@ jsi::Value ShareableValue::toJSValue(jsi::Runtime &rt) { } else { res = funPtr->call(rt, args, count); } - } catch (jsi::JSError &e) { - throw e; + } catch (std::exception &e) { + std::string str = e.what(); + runtimeManager->errorHandler->setError(str); + runtimeManager->errorHandler->raise(); } catch (...) { if (demangleExceptionName( abi::__cxa_current_exception_type()->name()) == diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/SharedItems/ShareableValue.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/ShareableValue.h similarity index 100% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/SharedItems/ShareableValue.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/ShareableValue.h diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/SharedItems/SharedParent.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/SharedParent.h similarity index 100% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/SharedItems/SharedParent.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/SharedParent.h diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/SharedItems/ValueWrapper.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/ValueWrapper.h similarity index 100% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/SharedItems/ValueWrapper.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/SharedItems/ValueWrapper.h diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/SpecTools/ErrorHandler.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/SpecTools/ErrorHandler.h similarity index 100% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/SpecTools/ErrorHandler.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/SpecTools/ErrorHandler.h diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Tools/FeaturesConfig.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/FeaturesConfig.h similarity index 100% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Tools/FeaturesConfig.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/FeaturesConfig.h diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/JSIStoreValueUser.cpp b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/JSIStoreValueUser.cpp index 08427be5f6d98..546a85f8cdb5d 100644 --- a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/JSIStoreValueUser.cpp +++ b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/JSIStoreValueUser.cpp @@ -1,6 +1,6 @@ #include "JSIStoreValueUser.h" #include "RuntimeManager.h" -#ifdef ONANDROID +#ifdef ANDROID #include #endif @@ -32,7 +32,7 @@ StoreUser::~StoreUser() { std::shared_ptr strongScheduler = scheduler.lock(); if (strongScheduler != nullptr) { std::shared_ptr sud = storeUserData; -#ifdef ONANDROID +#ifdef ANDROID jni::ThreadScope::WithClassLoader([&] { strongScheduler->scheduleOnUI([id, sud]() { const std::lock_guard lock(sud->storeMutex); diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Tools/JSIStoreValueUser.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/JSIStoreValueUser.h similarity index 100% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Tools/JSIStoreValueUser.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/JSIStoreValueUser.h diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Tools/Mapper.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/Mapper.h similarity index 100% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Tools/Mapper.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/Mapper.h diff --git a/android/expoview/src/main/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/PlatformDepMethodsHolder.h similarity index 83% rename from android/expoview/src/main/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/PlatformDepMethodsHolder.h index 2c6558556eba7..d7dcb48793219 100644 --- a/android/expoview/src/main/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +++ b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/PlatformDepMethodsHolder.h @@ -30,6 +30,9 @@ using ConfigurePropsFunction = std::function; +using KeyboardEventSubscribeFunction = + std::function)>; +using KeyboardEventUnsubscribeFunction = std::function; struct PlatformDepMethodsHolder { RequestRender requestRender; @@ -41,6 +44,8 @@ struct PlatformDepMethodsHolder { UnregisterSensorFunction unregisterSensor; SetGestureStateFunction setGestureStateFunction; ConfigurePropsFunction configurePropsFunction; + KeyboardEventSubscribeFunction subscribeForKeyboardEvents; + KeyboardEventUnsubscribeFunction unsubscribeFromKeyboardEvents; }; } // namespace reanimated diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Tools/ReanimatedHiddenHeaders.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/ReanimatedHiddenHeaders.h similarity index 91% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Tools/ReanimatedHiddenHeaders.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/ReanimatedHiddenHeaders.h index e5f9c0844c6ba..c1a05456d8c78 100644 --- a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Tools/ReanimatedHiddenHeaders.h +++ b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/ReanimatedHiddenHeaders.h @@ -1,6 +1,6 @@ #pragma once -#if defined(ONANDROID) +#ifdef ANDROID #include "Logger.h" #include "LoggerInterface.h" #include "SpeedChecker.h" diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Tools/RuntimeDecorator.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/RuntimeDecorator.h similarity index 100% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Tools/RuntimeDecorator.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/RuntimeDecorator.h diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Tools/Scheduler.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/Scheduler.h similarity index 100% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Tools/Scheduler.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/Scheduler.h diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/SingleInstanceChecker.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/SingleInstanceChecker.h new file mode 100644 index 0000000000000..797afd829caaf --- /dev/null +++ b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/SingleInstanceChecker.h @@ -0,0 +1,58 @@ +#pragma once + +#ifdef DEBUG + +#include + +#include +#include + +namespace reanimated { + +// This is a class that counts how many instances of a different class there +// are. It is meant only to be used with classes that should only have one +// instance. + +template +class SingleInstanceChecker { + public: + SingleInstanceChecker(); + ~SingleInstanceChecker(); + + private: + void assertWithMessage(bool condition, std::string message) { + if (!condition) { + std::cerr << message << std::endl; + assert(condition); + } + } + + // A static field will exist separately for every class template. + // This has to be inline for automatic initialization. + inline static int instanceCount_; +}; + +template +SingleInstanceChecker::SingleInstanceChecker() { + int status = 0; + std::string className = + __cxxabiv1::__cxa_demangle(typeid(T).name(), nullptr, nullptr, &status); + + // Only one instance should exist, but it is possible for two instances + // to co-exist during a reload. + assertWithMessage( + instanceCount_ <= 1, + "More than one instance of " + className + + " present. This may indicate a memory leak due to a retain cycle."); + + instanceCount_++; +} + +template +SingleInstanceChecker::~SingleInstanceChecker() { + instanceCount_--; +} + +} // namespace reanimated + +#endif // DEBUG diff --git a/ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Tools/WorkletEventHandler.h b/ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/WorkletEventHandler.h similarity index 100% rename from ios/vendored/unversioned/react-native-reanimated/Common/cpp/headers/Tools/WorkletEventHandler.h rename to ios/vendored/unversioned/react-native-reanimated/Common/cpp/Tools/WorkletEventHandler.h diff --git a/ios/vendored/unversioned/react-native-reanimated/RNReanimated.podspec.json b/ios/vendored/unversioned/react-native-reanimated/RNReanimated.podspec.json index 07c7b7c8244bd..f925c1eeb4540 100644 --- a/ios/vendored/unversioned/react-native-reanimated/RNReanimated.podspec.json +++ b/ios/vendored/unversioned/react-native-reanimated/RNReanimated.podspec.json @@ -1,6 +1,6 @@ { "name": "RNReanimated", - "version": "2.9.1", + "version": "2.11.0", "summary": "More powerful alternative to Animated library for React Native.", "description": "RNReanimated", "homepage": "https://github.com/software-mansion/react-native-reanimated", @@ -14,12 +14,11 @@ }, "source": { "git": "https://github.com/software-mansion/react-native-reanimated.git", - "tag": "2.9.1" + "tag": "2.11.0" }, "source_files": [ "ios/**/*.{mm,h,m}", - "Common/cpp/**/*.cpp", - "Common/cpp/headers/**/*.h" + "Common/cpp/**/*.{cpp,h}" ], "preserve_paths": [ "Common/cpp/hidden_headers/**" @@ -28,19 +27,20 @@ "USE_HEADERMAP": "YES", "HEADER_SEARCH_PATHS": "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Headers/Private/React-Core\" " }, - "compiler_flags": "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DRNVERSION=68 -Wno-comma -Wno-shorten-64-to-32 -Wno-documentation", + "compiler_flags": "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32 -DREACT_NATIVE_MINOR_VERSION=70 -Wno-comma -Wno-shorten-64-to-32 -Wno-documentation", "xcconfig": { - "CLANG_CXX_LANGUAGE_STANDARD": "c++14", - "HEADER_SEARCH_PATHS": "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/RCT-Folly\" \"${PODS_ROOT}/Headers/Public/React-hermes\" \"${PODS_ROOT}/Headers/Public/hermes-engine\"", - "OTHER_CFLAGS": "$(inherited) -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DRNVERSION=68" + "HEADER_SEARCH_PATHS": "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/RCT-Folly\" \"${PODS_ROOT}/Headers/Public/React-hermes\" \"${PODS_ROOT}/Headers/Public/hermes-engine\" \"${PODS_ROOT}/../../react-native-lab/react-native/ReactCommon\"", + "OTHER_CFLAGS": "$(inherited) -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32 -DREACT_NATIVE_MINOR_VERSION=70" }, "requires_arc": true, "dependencies": { "React-Core": [], - "FBLazyVector": [], - "FBReactNativeSpec": [], + "RCT-Folly": [], "RCTRequired": [], "RCTTypeSafety": [], + "ReactCommon/turbomodule/core": [], + "FBLazyVector": [], + "FBReactNativeSpec": [], "React-CoreModules": [], "React-Core/DevSupport": [], "React-RCTActionSheet": [], @@ -56,11 +56,9 @@ "React-jsi": [], "React-jsiexecutor": [], "React-jsinspector": [], - "ReactCommon/turbomodule/core": [], "Yoga": [], "DoubleConversion": [], "glog": [], - "React-callinvoker": [], - "RCT-Folly": [] + "React-callinvoker": [] } } diff --git a/ios/vendored/unversioned/react-native-reanimated/ios/REAModule.m b/ios/vendored/unversioned/react-native-reanimated/ios/REAModule.mm similarity index 96% rename from ios/vendored/unversioned/react-native-reanimated/ios/REAModule.m rename to ios/vendored/unversioned/react-native-reanimated/ios/REAModule.mm index 960e3611e6c8d..69ea03aa041db 100644 --- a/ios/vendored/unversioned/react-native-reanimated/ios/REAModule.m +++ b/ios/vendored/unversioned/react-native-reanimated/ios/REAModule.mm @@ -3,15 +3,27 @@ #import #import +#import "SingleInstanceChecker.h" + +using namespace reanimated; + typedef void (^AnimatedOperation)(REANodesManager *nodesManager); @implementation REAModule { NSMutableArray *_operations; REATransitionManager *_transitionManager; +#ifdef DEBUG + SingleInstanceChecker singleInstanceChecker_; +#endif } RCT_EXPORT_MODULE(ReanimatedModule); ++ (BOOL)requiresMainQueueSetup +{ + return YES; +} + - (void)invalidate { _transitionManager = nil; diff --git a/ios/vendored/unversioned/react-native-reanimated/ios/REANodesManager.m b/ios/vendored/unversioned/react-native-reanimated/ios/REANodesManager.m index f40467d16e616..675f4842d4afb 100644 --- a/ios/vendored/unversioned/react-native-reanimated/ios/REANodesManager.m +++ b/ios/vendored/unversioned/react-native-reanimated/ios/REANodesManager.m @@ -509,9 +509,9 @@ - (void)configureUiProps:(nonnull NSSet *)uiPropsSet _nativeProps = nativePropsSet; } -- (BOOL)isNotNativeViewFullyMounted:(NSNumber *)viewTag +- (BOOL)isNativeViewMounted:(NSNumber *)viewTag { - return _viewRegistry[viewTag].superview == nil; + return _viewRegistry[viewTag].superview != nil; } - (void)setValueForNodeID:(nonnull NSNumber *)nodeID value:(nonnull NSNumber *)newValue @@ -529,7 +529,17 @@ - (void)updateProps:(nonnull NSDictionary *)props withName:(nonnull NSString *)viewName { ComponentUpdate *lastSnapshot = _componentUpdateBuffer[viewTag]; - if ([self isNotNativeViewFullyMounted:viewTag] || lastSnapshot != nil) { + BOOL isNativeViewMounted = [self isNativeViewMounted:viewTag]; + + if (lastSnapshot != nil) { + NSMutableDictionary *lastProps = lastSnapshot.props; + for (NSString *key in props) { + [lastProps setValue:props[key] forKey:key]; + } + } + + // If the component isn't mounted, we will bail early with a scheduled update + if (!isNativeViewMounted) { if (lastSnapshot == nil) { ComponentUpdate *propsSnapshot = [ComponentUpdate new]; propsSnapshot.props = [props mutableCopy]; @@ -537,15 +547,28 @@ - (void)updateProps:(nonnull NSDictionary *)props propsSnapshot.viewName = viewName; _componentUpdateBuffer[viewTag] = propsSnapshot; atomic_store(&_shouldFlushUpdateBuffer, true); - } else { - NSMutableDictionary *lastProps = lastSnapshot.props; - for (NSString *key in props) { - [lastProps setValue:props[key] forKey:key]; - } } + return; } + // The component may have been mounted with a pending snapshot (due to a race condition), + // so we should attempt run the update. Otherwise, the next call to -maybeFlushUpdateBuffer + // will only arrive when a new component is mounted (which might be never!) + // + // If there are 0 remaining items in the buffer, we can skip the run in -maybeFlushUpdateBuffer. + if (lastSnapshot != nil && isNativeViewMounted) { + props = lastSnapshot.props; + viewTag = lastSnapshot.viewTag; + viewName = lastSnapshot.viewName; + + [_componentUpdateBuffer removeObjectForKey:viewTag]; + + if (_componentUpdateBuffer.count == 0) { + atomic_store(&_shouldFlushUpdateBuffer, false); + } + } + // TODO: refactor PropsNode to also use this function NSMutableDictionary *uiProps = [NSMutableDictionary new]; NSMutableDictionary *nativeProps = [NSMutableDictionary new]; diff --git a/ios/vendored/unversioned/react-native-reanimated/ios/keyboardObserver/REAKeyboardEventObserver.h b/ios/vendored/unversioned/react-native-reanimated/ios/keyboardObserver/REAKeyboardEventObserver.h new file mode 100644 index 0000000000000..37600c010dbca --- /dev/null +++ b/ios/vendored/unversioned/react-native-reanimated/ios/keyboardObserver/REAKeyboardEventObserver.h @@ -0,0 +1,17 @@ +#ifndef REAKeyboardEventManager_h +#define REAKeyboardEventManager_h + +#import +#import + +typedef void (^KeyboardEventListenerBlock)(int keyboardState, int height); + +@interface REAKeyboardEventObserver : NSObject + +- (instancetype)init; +- (int)subscribeForKeyboardEvents:(KeyboardEventListenerBlock)listener; +- (void)unsubscribeFromKeyboardEvents:(int)listenerId; + +@end + +#endif /* REAKeyboardEventManager_h */ diff --git a/ios/vendored/unversioned/react-native-reanimated/ios/keyboardObserver/REAKeyboardEventObserver.m b/ios/vendored/unversioned/react-native-reanimated/ios/keyboardObserver/REAKeyboardEventObserver.m new file mode 100644 index 0000000000000..4c5e123f38d15 --- /dev/null +++ b/ios/vendored/unversioned/react-native-reanimated/ios/keyboardObserver/REAKeyboardEventObserver.m @@ -0,0 +1,198 @@ +#import "REAKeyboardEventObserver.h" +#import +#import +#import + +typedef NS_ENUM(NSUInteger, KeyboardState) { + UNKNOWN = 0, + OPENING = 1, + OPEN = 2, + CLOSING = 3, + CLOSED = 4, +}; + +@implementation REAKeyboardEventObserver { + NSNumber *_nextListenerId; + NSMutableDictionary *_listeners; + CADisplayLink *displayLink; + int _windowsCount; + UIView *_keyboardView; + KeyboardState _state; +} + +- (instancetype)init +{ + self = [super init]; + _listeners = [[NSMutableDictionary alloc] init]; + _nextListenerId = @0; + _state = UNKNOWN; + return self; +} + +// copied from +// https://github.com/tonlabs/UIKit/blob/bd5651e4723d547bde0cb86ca1c27813cedab4a9/casts/keyboard/ios/UIKitKeyboardIosFrameListener.m +- (UIView *)findKeyboardView +{ + for (UIWindow *window in [UIApplication.sharedApplication.windows objectEnumerator]) { + if ([window isKindOfClass:NSClassFromString(@"UITextEffectsWindow")]) { + for (UIView *containerView in window.subviews) { + if ([containerView isKindOfClass:NSClassFromString(@"UIInputSetContainerView")]) { + for (UIView *hostView in containerView.subviews) { + if ([hostView isKindOfClass:NSClassFromString(@"UIInputSetHostView")]) { + return hostView; + } + } + } + } + } + } + return nil; +} + +- (UIView *)getKeyboardView +{ + /** + * If the count of windows has changed it means there might be a new UITextEffectsWindow, + * thus we have to obtain a new `keyboardView` + */ + int windowsCount = [UIApplication.sharedApplication.windows count]; + + if (_keyboardView == nil || windowsCount != _windowsCount) { + _keyboardView = [self findKeyboardView]; + _windowsCount = windowsCount; + } + return _keyboardView; +} + +#if TARGET_OS_TV +- (int)subscribeForKeyboardEvents:(KeyboardEventListenerBlock)listener +{ + NSLog(@"Keyboard handling is not supported on tvOS"); + return 0; +} + +- (void)unsubscribeFromKeyboardEvents:(int)listenerId +{ + NSLog(@"Keyboard handling is not supported on tvOS"); +} +#else + +- (void)runAnimation +{ + displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(updateKeyboardFrame)]; + [displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; +} + +- (void)stopAnimation +{ + [displayLink invalidate]; + displayLink = nil; + [self updateKeyboardFrame]; +} + +- (void)updateKeyboardFrame +{ + UIView *keyboardView = [self getKeyboardView]; + if (keyboardView == nil) { + return; + } + + CGFloat keyboardHeight = [self computeKeyboardHeight:keyboardView]; + for (NSString *key in _listeners.allKeys) { + ((KeyboardEventListenerBlock)_listeners[key])(_state, keyboardHeight); + } +} + +- (CGFloat)computeKeyboardHeight:(UIView *)keyboardView +{ + CGFloat keyboardFrameY = [keyboardView.layer presentationLayer].frame.origin.y; + CGFloat keyboardWindowH = keyboardView.window.bounds.size.height; + CGFloat keyboardHeight = keyboardWindowH - keyboardFrameY; + return keyboardHeight; +} + +- (void)keyboardWillShow:(NSNotification *)notification +{ + _state = OPENING; + [self runAnimation]; +} + +- (void)keyboardDidShow:(NSNotification *)notification +{ + _state = OPEN; + [self stopAnimation]; +} + +- (void)keyboardWillHide:(NSNotification *)notification +{ + _state = CLOSING; + [self runAnimation]; +} + +- (void)keyboardDidHide:(NSNotification *)notification +{ + _state = CLOSED; + [self stopAnimation]; +} + +- (int)subscribeForKeyboardEvents:(KeyboardEventListenerBlock)listener +{ + NSNumber *listenerId = [_nextListenerId copy]; + _nextListenerId = [NSNumber numberWithInt:[_nextListenerId intValue] + 1]; + if ([_listeners count] == 0) { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter addObserver:self + selector:@selector(keyboardWillHide:) + name:UIKeyboardWillHideNotification + object:nil]; + + [notificationCenter addObserver:self + selector:@selector(keyboardWillShow:) + name:UIKeyboardWillShowNotification + object:nil]; + + [notificationCenter addObserver:self + selector:@selector(keyboardDidHide:) + name:UIKeyboardDidHideNotification + object:nil]; + + [notificationCenter addObserver:self + selector:@selector(keyboardDidShow:) + name:UIKeyboardDidShowNotification + object:nil]; + } + + [_listeners setObject:listener forKey:listenerId]; + if (_state == UNKNOWN) { + [self recognizeInitialKeyboardState]; + } + return [listenerId intValue]; +} + +- (void)unsubscribeFromKeyboardEvents:(int)listenerId +{ + NSNumber *_listenerId = [NSNumber numberWithInt:listenerId]; + [_listeners removeObjectForKey:_listenerId]; + if ([_listeners count] == 0) { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + } +} + +- (void)recognizeInitialKeyboardState +{ + RCTExecuteOnMainQueue(^() { + UIView *keyboardView = [self getKeyboardView]; + if (keyboardView == nil) { + self->_state = CLOSED; + } else { + CGFloat keyboardHeight = [self computeKeyboardHeight:keyboardView]; + self->_state = keyboardHeight == 0 ? CLOSED : OPEN; + } + [self updateKeyboardFrame]; + }); +} + +#endif + +@end diff --git a/ios/vendored/unversioned/react-native-reanimated/ios/native/NativeProxy.mm b/ios/vendored/unversioned/react-native-reanimated/ios/native/NativeProxy.mm index 46ab01d508473..e595d9d985633 100644 --- a/ios/vendored/unversioned/react-native-reanimated/ios/native/NativeProxy.mm +++ b/ios/vendored/unversioned/react-native-reanimated/ios/native/NativeProxy.mm @@ -4,6 +4,7 @@ #import #import #import +#import #import #import #import @@ -196,8 +197,10 @@ static id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &v } }; - auto requestRender = [reanimatedModule, &module](std::function onRender, jsi::Runtime &rt) { - [reanimatedModule.nodesManager postOnAnimation:^(CADisplayLink *displayLink) { + auto nodesManager = reanimatedModule.nodesManager; + + auto requestRender = [nodesManager, &module](std::function onRender, jsi::Runtime &rt) { + [nodesManager postOnAnimation:^(CADisplayLink *displayLink) { double frameTimestamp = calculateTimestampWithSlowAnimations(displayLink.targetTimestamp) * 1000; jsi::Object global = rt.global(); jsi::String frameTimestampName = jsi::String::createFromAscii(rt, "_frameTimestamp"); @@ -293,6 +296,21 @@ static id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &v auto unregisterSensorFunction = [=](int sensorId) { [reanimatedSensorContainer unregisterSensor:sensorId]; }; // end sensors + // keyboard events + + static REAKeyboardEventObserver *keyboardObserver = [[REAKeyboardEventObserver alloc] init]; + auto subscribeForKeyboardEventsFunction = + [](std::function keyboardEventDataUpdater) { + return [keyboardObserver subscribeForKeyboardEvents:^(int keyboardState, int height) { + keyboardEventDataUpdater(keyboardState, height); + }]; + }; + + auto unsubscribeFromKeyboardEventsFunction = [](int listenerId) { + [keyboardObserver unsubscribeFromKeyboardEvents:listenerId]; + }; + // end keyboard events + PlatformDepMethodsHolder platformDepMethodsHolder = { requestRender, propUpdater, @@ -302,7 +320,10 @@ static id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &v registerSensorFunction, unregisterSensorFunction, setGestureStateFunction, - configurePropsFunction}; + configurePropsFunction, + subscribeForKeyboardEventsFunction, + unsubscribeFromKeyboardEventsFunction, + }; module = std::make_shared( jsInvoker, diff --git a/ios/vendored/unversioned/react-native-reanimated/ios/native/REAInitializer.h b/ios/vendored/unversioned/react-native-reanimated/ios/native/REAInitializer.h index e1c3627789b92..94c548b3a6acc 100644 --- a/ios/vendored/unversioned/react-native-reanimated/ios/native/REAInitializer.h +++ b/ios/vendored/unversioned/react-native-reanimated/ios/native/REAInitializer.h @@ -7,11 +7,11 @@ #import #import -#if RNVERSION >= 64 +#if REACT_NATIVE_MINOR_VERSION >= 64 #import #endif -#if RNVERSION < 63 +#if REACT_NATIVE_MINOR_VERSION < 63 #import #endif diff --git a/ios/vendored/unversioned/react-native-reanimated/ios/native/REAInitializer.mm b/ios/vendored/unversioned/react-native-reanimated/ios/native/REAInitializer.mm index 1c86929842432..a8b56cdff0fca 100644 --- a/ios/vendored/unversioned/react-native-reanimated/ios/native/REAInitializer.mm +++ b/ios/vendored/unversioned/react-native-reanimated/ios/native/REAInitializer.mm @@ -24,7 +24,7 @@ - (void)setBridge:(RCTBridge *)bridge; [bridge moduleForClass:[RCTEventDispatcher class]]; RCTEventDispatcher *eventDispatcher = [REAEventDispatcher new]; -#if RNVERSION >= 66 +#if REACT_NATIVE_MINOR_VERSION >= 66 RCTCallableJSModules *callableJSModules = [RCTCallableJSModules new]; [bridge setValue:callableJSModules forKey:@"_callableJSModules"]; [callableJSModules setBridge:bridge]; @@ -39,26 +39,22 @@ - (void)setBridge:(RCTBridge *)bridge; if (!bridge) { return; } -#if RNVERSION >= 63 +#if REACT_NATIVE_MINOR_VERSION >= 63 auto reanimatedModule = reanimated::createReanimatedModule(bridge, bridge.jsCallInvoker); #else auto callInvoker = std::make_shared(bridge.reactInstance); auto reanimatedModule = reanimated::createReanimatedModule(bridge, callInvoker); #endif - auto workletRuntimeValue = runtime - .global() - .getProperty(runtime, "ArrayBuffer") - .asObject(runtime) - .asFunction(runtime) - .callAsConstructor(runtime, {static_cast(sizeof(void*))}); - uintptr_t* workletRuntimeData = reinterpret_cast( - workletRuntimeValue.getObject(runtime).getArrayBuffer(runtime).data(runtime)); + auto workletRuntimeValue = runtime.global() + .getProperty(runtime, "ArrayBuffer") + .asObject(runtime) + .asFunction(runtime) + .callAsConstructor(runtime, {static_cast(sizeof(void *))}); + uintptr_t *workletRuntimeData = + reinterpret_cast(workletRuntimeValue.getObject(runtime).getArrayBuffer(runtime).data(runtime)); workletRuntimeData[0] = reinterpret_cast(reanimatedModule->runtime.get()); - runtime.global().setProperty( - runtime, - "_WORKLET_RUNTIME", - workletRuntimeValue); + runtime.global().setProperty(runtime, "_WORKLET_RUNTIME", workletRuntimeValue); runtime.global().setProperty( runtime, diff --git a/ios/vendored/unversioned/react-native-reanimated/ios/native/UIResponder+Reanimated.mm b/ios/vendored/unversioned/react-native-reanimated/ios/native/UIResponder+Reanimated.mm index daf4e10893906..f7dcf88c93b4a 100644 --- a/ios/vendored/unversioned/react-native-reanimated/ios/native/UIResponder+Reanimated.mm +++ b/ios/vendored/unversioned/react-native-reanimated/ios/native/UIResponder+Reanimated.mm @@ -20,7 +20,7 @@ @implementation UIResponder (Reanimated) { const auto installer = reanimated::REAJSIExecutorRuntimeInstaller(bridge, NULL); -#if RNVERSION >= 64 +#if REACT_NATIVE_MINOR_VERSION >= 64 // installs globals such as console, nativePerformanceNow, etc. return std::make_unique(RCTJSIExecutorRuntimeInstaller(installer)); #else diff --git a/ios/vendored/unversioned/react-native-reanimated/ios/sensor/ReanimatedSensor.m b/ios/vendored/unversioned/react-native-reanimated/ios/sensor/ReanimatedSensor.m index aec8f52574128..dc3dfeab8148d 100644 --- a/ios/vendored/unversioned/react-native-reanimated/ios/sensor/ReanimatedSensor.m +++ b/ios/vendored/unversioned/react-native-reanimated/ios/sensor/ReanimatedSensor.m @@ -7,7 +7,11 @@ - (instancetype)init:(ReanimatedSensorType)sensorType interval:(int)interval set { self = [super init]; _sensorType = sensorType; - _interval = interval / 1000; // in seconds + if (interval == -1) { + _interval = 1.0 / UIScreen.mainScreen.maximumFramesPerSecond; + } else { + _interval = interval / 1000.0; // in seconds + } _setter = setter; _motionManager = [[CMMotionManager alloc] init]; return self; @@ -59,18 +63,21 @@ - (bool)initializeAccelerometer } [_motionManager setAccelerometerUpdateInterval:_interval]; [_motionManager startAccelerometerUpdates]; - [_motionManager - startAccelerometerUpdatesToQueue:[NSOperationQueue mainQueue] - withHandler:^(CMAccelerometerData *sensorData, NSError *error) { - double currentTime = [[NSProcessInfo processInfo] systemUptime]; - if (currentTime - self->_lastTimestamp < self->_interval) { - return; - } - double data[] = { - sensorData.acceleration.x, sensorData.acceleration.y, sensorData.acceleration.z}; - self->_setter(data); - self->_lastTimestamp = currentTime; - }]; + [_motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue mainQueue] + withHandler:^(CMAccelerometerData *sensorData, NSError *error) { + double currentTime = [[NSProcessInfo processInfo] systemUptime]; + if (currentTime - self->_lastTimestamp < self->_interval) { + return; + } + double G = 9.81; + // convert G to m/s^2 + double data[] = { + sensorData.acceleration.x * G, + sensorData.acceleration.y * G, + sensorData.acceleration.z * G}; + self->_setter(data); + self->_lastTimestamp = currentTime; + }]; return true; } @@ -89,7 +96,10 @@ - (bool)initializeGravity if (currentTime - self->_lastTimestamp < self->_interval) { return; } - double data[] = {sensorData.gravity.x, sensorData.gravity.y, sensorData.gravity.z}; + double G = 9.81; + // convert G to m/s^2 + double data[] = { + sensorData.gravity.x * G, sensorData.gravity.y * G, sensorData.gravity.z * G}; self->_setter(data); self->_lastTimestamp = currentTime; }]; @@ -128,7 +138,7 @@ - (bool)initializeOrientation [_motionManager setDeviceMotionUpdateInterval:_interval]; [_motionManager setShowsDeviceMovementDisplay:YES]; - [_motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXTrueNorthZVertical + [_motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXArbitraryZVertical toQueue:[NSOperationQueue mainQueue] withHandler:^(CMDeviceMotion *sensorData, NSError *error) { double currentTime = [[NSProcessInfo processInfo] systemUptime]; @@ -143,8 +153,7 @@ - (bool)initializeOrientation attitude.quaternion.w, attitude.yaw, attitude.pitch, - attitude.roll - }; + attitude.roll}; self->_setter(data); self->_lastTimestamp = currentTime; }]; diff --git a/packages/expo/bundledNativeModules.json b/packages/expo/bundledNativeModules.json index a81783361cc2b..c032fe9aec478 100644 --- a/packages/expo/bundledNativeModules.json +++ b/packages/expo/bundledNativeModules.json @@ -94,7 +94,7 @@ "react-native-get-random-values": "~1.8.0", "react-native-maps": "1.3.2", "react-native-pager-view": "6.0.1", - "react-native-reanimated": "~2.10.0", + "react-native-reanimated": "~2.11.0", "react-native-screens": "~3.18.0", "react-native-safe-area-context": "4.4.1", "react-native-shared-element": "0.8.4", diff --git a/tools/src/vendoring/config/expoGoConfig.ts b/tools/src/vendoring/config/expoGoConfig.ts index 1081cb1871b2c..34cbd4678908a 100644 --- a/tools/src/vendoring/config/expoGoConfig.ts +++ b/tools/src/vendoring/config/expoGoConfig.ts @@ -4,6 +4,7 @@ import path from 'path'; import { Podspec } from '../../CocoaPods'; import { EXPO_DIR, EXPOTOOLS_DIR } from '../../Constants'; +import { getExpoRepositoryRootDir, getReactNativeSubmoduleDir } from '../../Directories'; import logger from '../../Logger'; import { applyPatchAsync } from '../../Utils'; import { VendoringTargetConfig } from '../types'; @@ -58,30 +59,47 @@ const config: VendoringTargetConfig = { source: 'https://github.com/software-mansion/react-native-gesture-handler.git', semverPrefix: '~', ios: {}, - android: {}, + android: { + async postCopyFilesHookAsync(sourceDirectory: string, targetDirectory: string) { + const buildGradlePath = path.join(targetDirectory, 'android', 'build.gradle'); + let buildGradle = await fs.readFile(buildGradlePath, 'utf-8'); + buildGradle = buildGradle.replace( + 'def shouldUseCommonInterfaceFromReanimated() {', + 'def shouldUseCommonInterfaceFromReanimated() {\n return true\n' + ); + buildGradle = buildGradle.replace( + 'react-native-reanimated', + 'vendored_unversioned_react-native-reanimated' + ); + await fs.writeFile(buildGradlePath, buildGradle); + }, + }, }, 'react-native-reanimated': { source: 'https://github.com/software-mansion/react-native-reanimated.git', semverPrefix: '~', ios: { async preReadPodspecHookAsync(podspecPath: string): Promise { - let content = await fs.readFile(podspecPath, 'utf-8'); - content = content.replace("reactVersion = '0.66.0'", "reactVersion = '0.67.2'"); - content = content.replace(/(puts "\[RNReanimated\].*$)/gm, '# $1'); - await fs.writeFile(podspecPath, content); + const reaUtilsPath = path.join(podspecPath, '..', 'scripts', 'reanimated_utils.rb'); + assert(fs.existsSync(reaUtilsPath), 'Cannot find `reanimated_utils`.'); + const rnForkPath = path.join(getReactNativeSubmoduleDir(), '..'); + let content = await fs.readFile(reaUtilsPath, 'utf-8'); + content = content.replace( + 'react_native_node_modules_dir = ', + `react_native_node_modules_dir = "${rnForkPath}" #` + ); + await fs.writeFile(reaUtilsPath, content); return podspecPath; }, async mutatePodspec(podspec: Podspec) { - // TODO: The podspec checks RN version from package.json. - // however we don't have RN's package.json in the place where it looks for and the fallback - // is set to `0.66.0`. - // currently we change the version in `preReadPodspecHookAsync`, once reanimated removed the `puts` in error message. - // we should use the json based transformation here. that's why we keep the referenced code and comment out. - // podspec.compiler_flags = podspec.compiler_flags.replace('RNVERSION=64', 'RNVERSION=63'); - // podspec.xcconfig.OTHER_CFLAGS = podspec.xcconfig.OTHER_CFLAGS.replace( - // 'RNVERSION=64', - // 'RNVERSION=63' - // ); + const rnForkPath = path.join(getReactNativeSubmoduleDir(), '..'); + const relativeForkPath = path.relative( + path.join(getExpoRepositoryRootDir(), 'ios'), + rnForkPath + ); + podspec.xcconfig['HEADER_SEARCH_PATHS'] = podspec.xcconfig[ + 'HEADER_SEARCH_PATHS' + ]?.replace(rnForkPath, '${PODS_ROOT}/../' + relativeForkPath); }, transforms: { content: [ @@ -104,6 +122,24 @@ const config: VendoringTargetConfig = { ], }, }, + android: { + excludeFiles: [ + 'android/gradle{/**,**}', + 'android/settings.gradle', + 'android/spotless.gradle', + ], + async postCopyFilesHookAsync(sourceDirectory: string, targetDirectory: string) { + await fs.copy(path.join(sourceDirectory, 'Common'), path.join(targetDirectory, 'Common')); + + const buildGradlePath = path.join(targetDirectory, 'android', 'build.gradle'); + let buildGradle = await fs.readFile(buildGradlePath, 'utf-8'); + buildGradle = buildGradle.replace( + 'def JS_RUNTIME = {', + 'def JS_RUNTIME = {\n return "hermes" // Expo Go always uses hermes\n' + ); + await fs.writeFile(buildGradlePath, buildGradle); + }, + }, }, 'react-native-screens': { source: 'https://github.com/software-mansion/react-native-screens.git', From 3eb0eafbe542b7d5d68809e05e67c76cd302adf8 Mon Sep 17 00:00:00 2001 From: lukmccall Date: Wed, 19 Oct 2022 10:12:20 +0200 Subject: [PATCH 2/4] Apply requested changes --- .../ReanimatedNativeHierarchyManager.java | 412 ------------------ .../ReanimatedUIImplementation.java | 68 --- .../ReanimatedUIImplementation.java | 68 --- .../ReanimatedUIImplementation.java | 68 --- tools/src/vendoring/config/expoGoConfig.ts | 14 +- 5 files changed, 6 insertions(+), 624 deletions(-) delete mode 100644 android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/62/layoutReanimation/ReanimatedNativeHierarchyManager.java delete mode 100644 android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/62/layoutReanimation/ReanimatedUIImplementation.java delete mode 100644 android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/63/layoutReanimation/ReanimatedUIImplementation.java delete mode 100644 android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/64/layoutReanimation/ReanimatedUIImplementation.java diff --git a/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/62/layoutReanimation/ReanimatedNativeHierarchyManager.java b/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/62/layoutReanimation/ReanimatedNativeHierarchyManager.java deleted file mode 100644 index c781f682a44c3..0000000000000 --- a/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/62/layoutReanimation/ReanimatedNativeHierarchyManager.java +++ /dev/null @@ -1,412 +0,0 @@ -package com.swmansion.reanimated.layoutReanimation; - -import android.os.Build; -import android.util.Log; -import android.view.View; -import android.view.ViewGroup; -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.bridge.UiThreadUtil; -import com.facebook.react.uimanager.IllegalViewOperationException; -import com.facebook.react.uimanager.NativeViewHierarchyManager; -import com.facebook.react.uimanager.RootViewManager; -import com.facebook.react.uimanager.ViewAtIndex; -import com.facebook.react.uimanager.ViewGroupManager; -import com.facebook.react.uimanager.ViewManager; -import com.facebook.react.uimanager.ViewManagerRegistry; -import com.facebook.react.uimanager.layoutanimation.LayoutAnimationController; -import com.facebook.react.uimanager.layoutanimation.LayoutAnimationListener; -import com.swmansion.reanimated.ReanimatedModule; -import java.lang.ref.WeakReference; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; - -class ReaLayoutAnimator extends LayoutAnimationController { - private AnimationsManager mAnimationsManager = null; - private volatile boolean mInitialized = false; - private ReactApplicationContext mContext; - private WeakReference mWeakNativeViewHierarchyManage = - new WeakReference<>(null); - - ReaLayoutAnimator( - ReactApplicationContext context, NativeViewHierarchyManager nativeViewHierarchyManager) { - mContext = context; - mWeakNativeViewHierarchyManage = new WeakReference<>(nativeViewHierarchyManager); - } - - public void maybeInit() { - if (!mInitialized) { - mInitialized = true; - ReanimatedModule reanimatedModule = mContext.getNativeModule(ReanimatedModule.class); - mAnimationsManager = reanimatedModule.getNodesManager().getAnimationsManager(); - mAnimationsManager.setReanimatedNativeHierarchyManager( - (ReanimatedNativeHierarchyManager) mWeakNativeViewHierarchyManage.get()); - } - } - - public boolean shouldAnimateLayout(View viewToAnimate) { - if (!isLayoutAnimationEnabled()) { - return super.shouldAnimateLayout(viewToAnimate); - } - // if view parent is null, skip animation: view have been clipped, we don't want animation to - // resume when view is re-attached to parent, which is the standard android animation behavior. - // If there's a layout handling animation going on, it should be animated nonetheless since the - // ongoing animation needs to be updated. - if (viewToAnimate == null) { - return false; - } - return (viewToAnimate.getParent() != null); - } - - /** - * Update layout of given view, via immediate update or animation depending on the current batch - * layout animation configuration supplied during initialization. Handles create and update - * animations. - * - * @param view the view to update layout of - * @param x the new X position for the view - * @param y the new Y position for the view - * @param width the new width value for the view - * @param height the new height value for the view - */ - public void applyLayoutUpdate(View view, int x, int y, int width, int height) { - if (!isLayoutAnimationEnabled()) { - super.applyLayoutUpdate(view, x, y, width, height); - return; - } - UiThreadUtil.assertOnUiThread(); - maybeInit(); - // Determine which animation to use : if view is initially invisible, use create animation, - // otherwise use update animation. This approach is easier than maintaining a list of tags - // for recently created views. - if (view.getWidth() == 0 || view.getHeight() == 0) { - view.layout(x, y, x + width, y + height); - if (view.getId() != -1) { - mAnimationsManager.onViewCreate( - view, - (ViewGroup) view.getParent(), - new Snapshot(view, mWeakNativeViewHierarchyManage.get())); - } - } else { - Snapshot before = new Snapshot(view, mWeakNativeViewHierarchyManage.get()); - view.layout(x, y, x + width, y + height); - Snapshot after = new Snapshot(view, mWeakNativeViewHierarchyManage.get()); - mAnimationsManager.onViewUpdate(view, before, after); - } - } - - /** - * Animate a view deletion using the layout animation configuration supplied during - * initialization. - * - * @param view The view to animate. - * @param listener Called once the animation is finished, should be used to completely remove the - * view. - */ - public void deleteView(final View view, final LayoutAnimationListener listener) { - if (!isLayoutAnimationEnabled()) { - super.deleteView(view, listener); - return; - } - UiThreadUtil.assertOnUiThread(); - NativeViewHierarchyManager nativeViewHierarchyManager = mWeakNativeViewHierarchyManage.get(); - ViewManager viewManager; - try { - viewManager = nativeViewHierarchyManager.resolveViewManager(view.getId()); - } catch (IllegalViewOperationException e) { - // (IllegalViewOperationException) == (vm == null) - e.printStackTrace(); - super.deleteView(view, listener); - return; - } - // we don't want layout animations in native-stack since it is currently buggy there - // so we check if it is a (grand)child of ScreenStack - if (viewManager.getName().equals("RNSScreen") - && view.getParent() != null - && view.getParent().getParent() instanceof View) { - // we check grandparent of Screen since the parent is a ScreenStackFragment - View screenParentView = (View) view.getParent().getParent(); - ViewManager screenParentViewManager; - try { - screenParentViewManager = - nativeViewHierarchyManager.resolveViewManager(screenParentView.getId()); - } catch (IllegalViewOperationException e) { - // (IllegalViewOperationException) == (vm == null) - e.printStackTrace(); - super.deleteView(view, listener); - return; - } - String parentName = screenParentViewManager.getName(); - if (parentName.equals("RNSScreenStack")) { - super.deleteView(view, listener); - return; - } - } - maybeInit(); - Snapshot before = new Snapshot(view, mWeakNativeViewHierarchyManage.get()); - mAnimationsManager.onViewRemoval( - view, (ViewGroup) view.getParent(), before, () -> listener.onAnimationEnd()); - if (viewManager instanceof ViewGroupManager) { - ViewGroupManager vgm = (ViewGroupManager) viewManager; - for (int i = 0; i < vgm.getChildCount((ViewGroup) view); ++i) { - dfs(vgm.getChildAt((ViewGroup) view, i), nativeViewHierarchyManager); - } - } - } - - private void dfs(View view, NativeViewHierarchyManager nativeViewHierarchyManager) { - int tag = view.getId(); - if (tag == -1) { - return; - } - ViewManager vm = null; - try { - vm = nativeViewHierarchyManager.resolveViewManager(tag); - Snapshot before = new Snapshot(view, mWeakNativeViewHierarchyManage.get()); - mAnimationsManager.onViewRemoval( - view, - (ViewGroup) view.getParent(), - before, - () -> { - ReanimatedNativeHierarchyManager reanimatedNativeHierarchyManager = - (ReanimatedNativeHierarchyManager) nativeViewHierarchyManager; - reanimatedNativeHierarchyManager.publicDropView(view); - }); - } catch (IllegalViewOperationException e) { - // (IllegalViewOperationException) == (vm == null) - e.printStackTrace(); - } - if (vm instanceof ViewGroupManager) { - ViewGroupManager vgm = (ViewGroupManager) vm; - for (int i = 0; i < vgm.getChildCount((ViewGroup) view); ++i) { - dfs(vgm.getChildAt((ViewGroup) view, i), nativeViewHierarchyManager); - } - } - } - - public boolean isLayoutAnimationEnabled() { - maybeInit(); - return mAnimationsManager.isLayoutAnimationEnabled(); - } -} - -public class ReanimatedNativeHierarchyManager extends NativeViewHierarchyManager { - private final HashMap> toBeRemoved = new HashMap<>(); - private final HashMap cleanerCallback = new HashMap<>(); - private LayoutAnimationController mReaLayoutAnimator = null; - private HashMap> mPendingDeletionsForTag = new HashMap<>(); - private boolean initOk = true; - - public ReanimatedNativeHierarchyManager( - ViewManagerRegistry viewManagers, ReactApplicationContext reactContext) { - super(viewManagers); - - mReaLayoutAnimator = new ReaLayoutAnimator(reactContext, this); - - Class clazz = this.getClass().getSuperclass(); - if (clazz == null) { - Log.e("reanimated", "unable to resolve super class of ReanimatedNativeHierarchyManager"); - return; - } - - try { - Field layoutAnimatorField = clazz.getDeclaredField("mLayoutAnimator"); - layoutAnimatorField.setAccessible(true); - - if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - try { - // accessFlags is supported only by API >=23 - Field modifiersField = Field.class.getDeclaredField("accessFlags"); - modifiersField.setAccessible(true); - modifiersField.setInt( - layoutAnimatorField, layoutAnimatorField.getModifiers() & ~Modifier.FINAL); - } catch (NoSuchFieldException | IllegalAccessException e) { - e.printStackTrace(); - } - } - layoutAnimatorField.set(this, mReaLayoutAnimator); - } catch (NoSuchFieldException | IllegalAccessException e) { - initOk = false; - e.printStackTrace(); - } - - try { - Field pendingTagsField = clazz.getDeclaredField("mPendingDeletionsForTag"); - pendingTagsField.setAccessible(true); - - if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - try { - // accessFlags is supported only by API >=23 - Field pendingTagsFieldModifiers = Field.class.getDeclaredField("accessFlags"); - pendingTagsFieldModifiers.setAccessible(true); - pendingTagsFieldModifiers.setInt( - pendingTagsField, pendingTagsField.getModifiers() & ~Modifier.FINAL); - } catch (NoSuchFieldException | IllegalAccessException e) { - e.printStackTrace(); - } - } - pendingTagsField.set(this, mPendingDeletionsForTag); - } catch (NoSuchFieldException | IllegalAccessException e) { - initOk = false; - e.printStackTrace(); - } - - if (initOk) { - setLayoutAnimationEnabled(true); - } - } - - public ReanimatedNativeHierarchyManager( - ViewManagerRegistry viewManagers, RootViewManager manager) { - super(viewManagers, manager); - } - - private boolean isLayoutAnimationDisabled() { - return !initOk || !((ReaLayoutAnimator) mReaLayoutAnimator).isLayoutAnimationEnabled(); - } - - public synchronized void updateLayout( - int parentTag, int tag, int x, int y, int width, int height) { - super.updateLayout(parentTag, tag, x, y, width, height); - if (isLayoutAnimationDisabled()) { - return; - } - try { - View viewToUpdate = this.resolveView(tag); - ViewManager viewManager = this.resolveViewManager(tag); - String viewManagerName = viewManager.getName(); - View container = resolveView(parentTag); - if (container != null - && viewManagerName.equals("RNSScreen") - && this.mReaLayoutAnimator != null) { - this.mReaLayoutAnimator.applyLayoutUpdate( - viewToUpdate, - (int) container.getX(), - (int) container.getY(), - container.getWidth(), - container.getHeight()); - } - } catch (IllegalViewOperationException e) { - // (IllegalViewOperationException) == (vm == null) - e.printStackTrace(); - } - } - - // @Override - public synchronized void manageChildren( - int tag, - @Nullable int[] indicesToRemove, - @Nullable ViewAtIndex[] viewsToAdd, - @Nullable int[] tagsToDelete) { - int[] mock = new int[] {}; - if (isLayoutAnimationDisabled()) { - super.manageChildren(tag, indicesToRemove, viewsToAdd, tagsToDelete, mock); - return; - } - ViewGroup viewGroup; - ViewGroupManager viewGroupManager; - try { - viewGroup = (ViewGroup) resolveView(tag); - viewGroupManager = (ViewGroupManager) resolveViewManager(tag); - } catch (IllegalViewOperationException e) { - // (IllegalViewOperationException) == (vm == null) - e.printStackTrace(); - super.manageChildren(tag, indicesToRemove, viewsToAdd, tagsToDelete, mock); - return; - } - - // we don't want layout animations in native-stack since it is currently buggy there - if (viewGroupManager.getName().equals("RNSScreenStack")) { - super.manageChildren(tag, indicesToRemove, viewsToAdd, tagsToDelete, mock); - return; - } - - if (toBeRemoved.containsKey(tag)) { - ArrayList childrenToBeRemoved = toBeRemoved.get(tag); - HashSet tagsToRemove = new HashSet(); - for (View childToRemove : childrenToBeRemoved) { - tagsToRemove.add(childToRemove.getId()); - } - while (viewGroupManager.getChildCount(viewGroup) != 0) { - View child = - viewGroupManager.getChildAt(viewGroup, viewGroupManager.getChildCount(viewGroup) - 1); - if (tagsToRemove.contains(child.getId())) { - viewGroupManager.removeViewAt(viewGroup, viewGroupManager.getChildCount(viewGroup) - 1); - } else { - break; - } - } - } - if (tagsToDelete != null) { - if (!toBeRemoved.containsKey(tag)) { - toBeRemoved.put(tag, new ArrayList<>()); - } - ArrayList toBeRemovedChildren = toBeRemoved.get(tag); - for (Integer childtag : tagsToDelete) { - View view; - try { - view = resolveView(childtag); - } catch (IllegalViewOperationException e) { - // (IllegalViewOperationException) == (vm == null) - e.printStackTrace(); - continue; - } - toBeRemovedChildren.add(view); - cleanerCallback.put( - view.getId(), - new Runnable() { - @Override - public void run() { - toBeRemovedChildren.remove(view); - viewGroupManager.removeView(viewGroup, view); - } // It's far from optimal but let's leave it as it is for now - }); - } - } - - // mPendingDeletionsForTag is modify by React - if (mPendingDeletionsForTag != null) { - Set pendingTags = mPendingDeletionsForTag.get(tag); - if (pendingTags != null) { - pendingTags.clear(); - } - } - - super.manageChildren(tag, indicesToRemove, viewsToAdd, mock, mock); - if (toBeRemoved.containsKey(tag)) { - ArrayList childrenToBeRemoved = toBeRemoved.get(tag); - for (View child : childrenToBeRemoved) { - viewGroupManager.addView(viewGroup, child, viewGroupManager.getChildCount(viewGroup)); - } - } - ViewAtIndex[] mock2 = new ViewAtIndex[] {}; - super.manageChildren(tag, mock, mock2, tagsToDelete, mock); - } - - public void publicDropView(View view) { - dropView(view); - } - - @Override - protected synchronized void dropView(View view) { - if (isLayoutAnimationDisabled()) { - super.dropView(view); - return; - } - if (toBeRemoved.containsKey(view.getId())) { - toBeRemoved.remove(view.getId()); - } - if (cleanerCallback.containsKey(view.getId())) { - Runnable runnable = cleanerCallback.get(view.getId()); - cleanerCallback.remove(view.getId()); - runnable.run(); - } - // childrens' callbacks should be cleaned by former publicDropView calls as Animation Manager - // stripes views from bottom to top - super.dropView(view); - } -} diff --git a/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/62/layoutReanimation/ReanimatedUIImplementation.java b/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/62/layoutReanimation/ReanimatedUIImplementation.java deleted file mode 100644 index 372dac9c987c5..0000000000000 --- a/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/62/layoutReanimation/ReanimatedUIImplementation.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.facebook.react.uimanager; - -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.bridge.ReadableArray; -import com.facebook.react.uimanager.events.EventDispatcher; -import com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager; -import java.util.List; - -public class ReanimatedUIImplementation extends UIImplementation { - public ReanimatedUIImplementation( - ReactApplicationContext reactContext, - UIManagerModule.ViewManagerResolver viewManagerResolver, - EventDispatcher eventDispatcher, - int minTimeLeftInFrameForNonBatchedOperationMs) { - this( - reactContext, - new ViewManagerRegistry(viewManagerResolver), - eventDispatcher, - minTimeLeftInFrameForNonBatchedOperationMs); - } - - public ReanimatedUIImplementation( - ReactApplicationContext reactContext, - List viewManagerList, - EventDispatcher eventDispatcher, - int minTimeLeftInFrameForNonBatchedOperationMs) { - this( - reactContext, - new ViewManagerRegistry(viewManagerList), - eventDispatcher, - minTimeLeftInFrameForNonBatchedOperationMs); - } - - public ReanimatedUIImplementation( - ReactApplicationContext reactContext, - ViewManagerRegistry viewManagerRegistry, - EventDispatcher eventDispatcher, - int minTimeLeftInFrameForNonBatchedOperationMs) { - super( - reactContext, - viewManagerRegistry, - new UIViewOperationQueue( - reactContext, - new ReanimatedNativeHierarchyManager(viewManagerRegistry, reactContext), - minTimeLeftInFrameForNonBatchedOperationMs), - eventDispatcher); - } - - /** - * Invoked when there is a mutation in a node tree. - * - * @param tag react tag of the node we want to manage - * @param indicesToRemove ordered (asc) list of indicies at which view should be removed - * @param viewsToAdd ordered (asc based on mIndex property) list of tag-index pairs that represent - * a view which should be added at the specified index - * @param tagsToDelete list of tags corresponding to views that should be removed - */ - public void manageChildren( - int viewTag, - @Nullable ReadableArray moveFrom, - @Nullable ReadableArray moveTo, - @Nullable ReadableArray addChildTags, - @Nullable ReadableArray addAtIndices, - @Nullable ReadableArray removeFrom) { - super.manageChildren(viewTag, moveFrom, moveTo, addChildTags, addAtIndices, removeFrom); - } -} diff --git a/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/63/layoutReanimation/ReanimatedUIImplementation.java b/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/63/layoutReanimation/ReanimatedUIImplementation.java deleted file mode 100644 index 372dac9c987c5..0000000000000 --- a/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/63/layoutReanimation/ReanimatedUIImplementation.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.facebook.react.uimanager; - -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.bridge.ReadableArray; -import com.facebook.react.uimanager.events.EventDispatcher; -import com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager; -import java.util.List; - -public class ReanimatedUIImplementation extends UIImplementation { - public ReanimatedUIImplementation( - ReactApplicationContext reactContext, - UIManagerModule.ViewManagerResolver viewManagerResolver, - EventDispatcher eventDispatcher, - int minTimeLeftInFrameForNonBatchedOperationMs) { - this( - reactContext, - new ViewManagerRegistry(viewManagerResolver), - eventDispatcher, - minTimeLeftInFrameForNonBatchedOperationMs); - } - - public ReanimatedUIImplementation( - ReactApplicationContext reactContext, - List viewManagerList, - EventDispatcher eventDispatcher, - int minTimeLeftInFrameForNonBatchedOperationMs) { - this( - reactContext, - new ViewManagerRegistry(viewManagerList), - eventDispatcher, - minTimeLeftInFrameForNonBatchedOperationMs); - } - - public ReanimatedUIImplementation( - ReactApplicationContext reactContext, - ViewManagerRegistry viewManagerRegistry, - EventDispatcher eventDispatcher, - int minTimeLeftInFrameForNonBatchedOperationMs) { - super( - reactContext, - viewManagerRegistry, - new UIViewOperationQueue( - reactContext, - new ReanimatedNativeHierarchyManager(viewManagerRegistry, reactContext), - minTimeLeftInFrameForNonBatchedOperationMs), - eventDispatcher); - } - - /** - * Invoked when there is a mutation in a node tree. - * - * @param tag react tag of the node we want to manage - * @param indicesToRemove ordered (asc) list of indicies at which view should be removed - * @param viewsToAdd ordered (asc based on mIndex property) list of tag-index pairs that represent - * a view which should be added at the specified index - * @param tagsToDelete list of tags corresponding to views that should be removed - */ - public void manageChildren( - int viewTag, - @Nullable ReadableArray moveFrom, - @Nullable ReadableArray moveTo, - @Nullable ReadableArray addChildTags, - @Nullable ReadableArray addAtIndices, - @Nullable ReadableArray removeFrom) { - super.manageChildren(viewTag, moveFrom, moveTo, addChildTags, addAtIndices, removeFrom); - } -} diff --git a/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/64/layoutReanimation/ReanimatedUIImplementation.java b/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/64/layoutReanimation/ReanimatedUIImplementation.java deleted file mode 100644 index 372dac9c987c5..0000000000000 --- a/android/vendored/unversioned/react-native-reanimated/android/rnVersionPatch/64/layoutReanimation/ReanimatedUIImplementation.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.facebook.react.uimanager; - -import androidx.annotation.Nullable; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.bridge.ReadableArray; -import com.facebook.react.uimanager.events.EventDispatcher; -import com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager; -import java.util.List; - -public class ReanimatedUIImplementation extends UIImplementation { - public ReanimatedUIImplementation( - ReactApplicationContext reactContext, - UIManagerModule.ViewManagerResolver viewManagerResolver, - EventDispatcher eventDispatcher, - int minTimeLeftInFrameForNonBatchedOperationMs) { - this( - reactContext, - new ViewManagerRegistry(viewManagerResolver), - eventDispatcher, - minTimeLeftInFrameForNonBatchedOperationMs); - } - - public ReanimatedUIImplementation( - ReactApplicationContext reactContext, - List viewManagerList, - EventDispatcher eventDispatcher, - int minTimeLeftInFrameForNonBatchedOperationMs) { - this( - reactContext, - new ViewManagerRegistry(viewManagerList), - eventDispatcher, - minTimeLeftInFrameForNonBatchedOperationMs); - } - - public ReanimatedUIImplementation( - ReactApplicationContext reactContext, - ViewManagerRegistry viewManagerRegistry, - EventDispatcher eventDispatcher, - int minTimeLeftInFrameForNonBatchedOperationMs) { - super( - reactContext, - viewManagerRegistry, - new UIViewOperationQueue( - reactContext, - new ReanimatedNativeHierarchyManager(viewManagerRegistry, reactContext), - minTimeLeftInFrameForNonBatchedOperationMs), - eventDispatcher); - } - - /** - * Invoked when there is a mutation in a node tree. - * - * @param tag react tag of the node we want to manage - * @param indicesToRemove ordered (asc) list of indicies at which view should be removed - * @param viewsToAdd ordered (asc based on mIndex property) list of tag-index pairs that represent - * a view which should be added at the specified index - * @param tagsToDelete list of tags corresponding to views that should be removed - */ - public void manageChildren( - int viewTag, - @Nullable ReadableArray moveFrom, - @Nullable ReadableArray moveTo, - @Nullable ReadableArray addChildTags, - @Nullable ReadableArray addAtIndices, - @Nullable ReadableArray removeFrom) { - super.manageChildren(viewTag, moveFrom, moveTo, addChildTags, addAtIndices, removeFrom); - } -} diff --git a/tools/src/vendoring/config/expoGoConfig.ts b/tools/src/vendoring/config/expoGoConfig.ts index 34cbd4678908a..8d2ac95eff22d 100644 --- a/tools/src/vendoring/config/expoGoConfig.ts +++ b/tools/src/vendoring/config/expoGoConfig.ts @@ -3,8 +3,7 @@ import fs from 'fs-extra'; import path from 'path'; import { Podspec } from '../../CocoaPods'; -import { EXPO_DIR, EXPOTOOLS_DIR } from '../../Constants'; -import { getExpoRepositoryRootDir, getReactNativeSubmoduleDir } from '../../Directories'; +import { EXPO_DIR, EXPOTOOLS_DIR, REACT_NATIVE_SUBMODULE_DIR } from '../../Constants'; import logger from '../../Logger'; import { applyPatchAsync } from '../../Utils'; import { VendoringTargetConfig } from '../types'; @@ -82,7 +81,7 @@ const config: VendoringTargetConfig = { async preReadPodspecHookAsync(podspecPath: string): Promise { const reaUtilsPath = path.join(podspecPath, '..', 'scripts', 'reanimated_utils.rb'); assert(fs.existsSync(reaUtilsPath), 'Cannot find `reanimated_utils`.'); - const rnForkPath = path.join(getReactNativeSubmoduleDir(), '..'); + const rnForkPath = path.join(REACT_NATIVE_SUBMODULE_DIR, '..'); let content = await fs.readFile(reaUtilsPath, 'utf-8'); content = content.replace( 'react_native_node_modules_dir = ', @@ -92,11 +91,8 @@ const config: VendoringTargetConfig = { return podspecPath; }, async mutatePodspec(podspec: Podspec) { - const rnForkPath = path.join(getReactNativeSubmoduleDir(), '..'); - const relativeForkPath = path.relative( - path.join(getExpoRepositoryRootDir(), 'ios'), - rnForkPath - ); + const rnForkPath = path.join(REACT_NATIVE_SUBMODULE_DIR, '..'); + const relativeForkPath = path.relative(path.join(EXPO_DIR, 'ios'), rnForkPath); podspec.xcconfig['HEADER_SEARCH_PATHS'] = podspec.xcconfig[ 'HEADER_SEARCH_PATHS' ]?.replace(rnForkPath, '${PODS_ROOT}/../' + relativeForkPath); @@ -127,6 +123,8 @@ const config: VendoringTargetConfig = { 'android/gradle{/**,**}', 'android/settings.gradle', 'android/spotless.gradle', + 'android/README.md', + 'android/rnVersionPatch/**', ], async postCopyFilesHookAsync(sourceDirectory: string, targetDirectory: string) { await fs.copy(path.join(sourceDirectory, 'Common'), path.join(targetDirectory, 'Common')); From 2b5858f45c0bbff843864b77569fbf7be567a72f Mon Sep 17 00:00:00 2001 From: lukmccall Date: Wed, 19 Oct 2022 10:33:35 +0200 Subject: [PATCH 3/4] run pod install --- apps/bare-expo/ios/Podfile.lock | 4 ++-- yarn.lock | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/bare-expo/ios/Podfile.lock b/apps/bare-expo/ios/Podfile.lock index fca4bbe1b9a88..0f9392aff9e5b 100644 --- a/apps/bare-expo/ios/Podfile.lock +++ b/apps/bare-expo/ios/Podfile.lock @@ -707,7 +707,7 @@ PODS: - React-Core - RNGestureHandler (2.7.0): - React-Core - - RNReanimated (2.10.0): + - RNReanimated (2.11.0): - DoubleConversion - FBLazyVector - FBReactNativeSpec @@ -1360,7 +1360,7 @@ SPEC CHECKSUMS: RNCPicker: 2f71e09c52ab6327e2c393213368ea0e5bfbcb65 RNDateTimePicker: 154f8246e9c32fd663995647a7f9f667a8c6b258 RNGestureHandler: 7673697e7c0e9391adefae4faa087442bc04af33 - RNReanimated: 60e291d42c77752a0f6d6f358387bdf225a87c6e + RNReanimated: 2e463924d627f7dc857eeecbfef25c4894978cd6 RNScreens: f3230dd008a7d0ce5c0a8bc78ff12cf2315bda24 RNSharedElement: eb7d506733952d58634f34c82ec17e82f557e377 RNSVG: 07dbd870b0dcdecc99b3a202fa37c8ca163caec2 diff --git a/yarn.lock b/yarn.lock index 8984821ccd5a2..e8d4482c06556 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17244,10 +17244,10 @@ react-native-paper@^4.0.1: color "^3.1.2" react-native-iphone-x-helper "^1.3.1" -react-native-reanimated@~2.10.0: - version "2.10.0" - resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-2.10.0.tgz#ed53be66bbb553b5b5e93e93ef4217c87b8c73db" - integrity sha512-jKm3xz5nX7ABtHzzuuLmawP0pFWP77lXNdIC6AWOceBs23OHUaJ29p4prxr/7Sb588GwTbkPsYkDqVFaE3ezNQ== +react-native-reanimated@~2.11.0: + version "2.11.0" + resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-2.11.0.tgz#415ef668440d1b7d8b2b36a20342b1035432dd80" + integrity sha512-/QnujrXSNyXasv7v8K3eu5Z4XGRYMPRa0+x0RjNr6Z5/KEuPHwrg1Xm7UZ2YSm6jCF2b1BW6ceqP/1d626gvhQ== dependencies: "@babel/plugin-transform-object-assign" "^7.16.7" "@babel/preset-typescript" "^7.16.7" From e37708c2416d04d76040f1aad33c77da9034d802 Mon Sep 17 00:00:00 2001 From: lukmccall Date: Wed, 19 Oct 2022 11:25:28 +0200 Subject: [PATCH 4/4] Fix CI and add missing build configs --- CHANGELOG.md | 2 +- android/expoview/build.gradle | 4 ++++ .../main/java/host/exp/exponent/kernel/Kernel.kt | 2 -- .../versioned/host/exp/exponent/VersionedUtils.kt | 1 - .../react-native-reanimated/android/README.md | 15 --------------- 5 files changed, 5 insertions(+), 19 deletions(-) delete mode 100644 android/vendored/unversioned/react-native-reanimated/android/README.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e266a58f8c93..ec1e9f34de39c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,7 @@ Package-specific changes not released in any SDK will be added here just before - Updated `lottie-react-native` from `5.1.3` to `5.1.4`. ([#19433](https://github.com/expo/expo/pull/19433) by [@kudo](https://github.com/kudo)) - Updated `@react-native-community/slider` from `4.2.3` to `4.2.4`. ([#19424](https://github.com/expo/expo/pull/19424)) by [@kudo](https://github.com/kudo)) - Updated `react-native-svg` from `12.3.0` to `13.4.0`. ([#19434](https://github.com/expo/expo/pull/19434) by [@lukmccall](https://github.com/lukmccall)) -- Updated `react-native-reanimated` from `2.10.0` to `2.11.0`. +- Updated `react-native-reanimated` from `2.10.0` to `2.11.0`. ([#19602](https://github.com/expo/expo/pull/19602) by [@lukmccall](https://github.com/lukmccall)) ### 🛠 Breaking changes diff --git a/android/expoview/build.gradle b/android/expoview/build.gradle index 85c5710656770..73953012210e9 100644 --- a/android/expoview/build.gradle +++ b/android/expoview/build.gradle @@ -111,6 +111,10 @@ android { manifestPlaceholders = [ 'appAuthRedirectScheme': 'host.exp.exponent' ] + + buildConfigField("boolean", "IS_INTERNAL_BUILD", "false") + buildConfigField("int", "EXOPACKAGE_FLAGS", "0") + buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", "false") // WHEN_VERSIONING_REMOVE_TO_HERE } diff --git a/android/expoview/src/main/java/host/exp/exponent/kernel/Kernel.kt b/android/expoview/src/main/java/host/exp/exponent/kernel/Kernel.kt index fab2dd660c75f..955e415d75976 100644 --- a/android/expoview/src/main/java/host/exp/exponent/kernel/Kernel.kt +++ b/android/expoview/src/main/java/host/exp/exponent/kernel/Kernel.kt @@ -20,8 +20,6 @@ import com.facebook.proguard.annotations.DoNotStrip import com.facebook.react.ReactInstanceManager import com.facebook.react.ReactRootView import com.facebook.react.bridge.Arguments -import com.facebook.react.bridge.JavaScriptContextHolder -import com.facebook.react.bridge.ReactApplicationContext import com.facebook.react.bridge.ReadableMap import com.facebook.react.common.LifecycleState import com.facebook.react.modules.network.ReactCookieJarContainer diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/VersionedUtils.kt b/android/expoview/src/main/java/versioned/host/exp/exponent/VersionedUtils.kt index 7ecbfb2739171..d2c267c9a022f 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/VersionedUtils.kt +++ b/android/expoview/src/main/java/versioned/host/exp/exponent/VersionedUtils.kt @@ -6,7 +6,6 @@ import android.content.Intent import android.net.Uri import android.os.Build import android.provider.Settings -import android.util.Log import com.facebook.common.logging.FLog import com.facebook.hermes.reactexecutor.HermesExecutorFactory import com.facebook.react.ReactInstanceManager diff --git a/android/vendored/unversioned/react-native-reanimated/android/README.md b/android/vendored/unversioned/react-native-reanimated/android/README.md deleted file mode 100644 index b8a0f807bdac5..0000000000000 --- a/android/vendored/unversioned/react-native-reanimated/android/README.md +++ /dev/null @@ -1,15 +0,0 @@ - -README -====== - -If you want to publish the lib as a maven dependency, follow these steps before publishing a new version to npm: - -1. Be sure to have the Android [SDK](https://developer.android.com/studio/index.html) and [NDK](https://developer.android.com/ndk/guides/index.html) installed -2. Be sure to have a `local.properties` file in this folder that points to the Android SDK and NDK -``` -ndk.dir=/Users/{username}/Library/Android/sdk/ndk-bundle -sdk.dir=/Users/{username}/Library/Android/sdk -``` -3. Delete the `maven` folder -4. Run `sudo ./gradlew installArchives` -5. Verify that latest set of generated files is in the maven folder with the correct version number