diff --git a/Common/cpp/Fabric/ReanimatedCommitHook.cpp b/Common/cpp/Fabric/ReanimatedCommitHook.cpp index f5fef5812d4..dc809e00e6b 100644 --- a/Common/cpp/Fabric/ReanimatedCommitHook.cpp +++ b/Common/cpp/Fabric/ReanimatedCommitHook.cpp @@ -24,7 +24,11 @@ ReanimatedCommitHook::~ReanimatedCommitHook() noexcept { RootShadowNode::Unshared ReanimatedCommitHook::shadowTreeWillCommit( ShadowTree const &, RootShadowNode::Shared const &, +#if REACT_NATIVE_MINOR_VERSION >= 73 + RootShadowNode::Unshared const &newRootShadowNode) noexcept { +#else RootShadowNode::Unshared const &newRootShadowNode) const noexcept { +#endif if (ReanimatedCommitMarker::isReanimatedCommit()) { // ShadowTree commited by Reanimated, no need to apply updates from // PropsRegistry diff --git a/Common/cpp/Fabric/ReanimatedCommitHook.h b/Common/cpp/Fabric/ReanimatedCommitHook.h index d0fe16ec183..22ebd3c612c 100644 --- a/Common/cpp/Fabric/ReanimatedCommitHook.h +++ b/Common/cpp/Fabric/ReanimatedCommitHook.h @@ -19,6 +19,16 @@ class ReanimatedCommitHook : public UIManagerCommitHook { ~ReanimatedCommitHook() noexcept override; +#if REACT_NATIVE_MINOR_VERSION >= 73 + void commitHookWasRegistered(UIManager const &) noexcept override {} + + void commitHookWasUnregistered(UIManager const &) noexcept override {} + + RootShadowNode::Unshared shadowTreeWillCommit( + ShadowTree const &shadowTree, + RootShadowNode::Shared const &oldRootShadowNode, + RootShadowNode::Unshared const &newRootShadowNode) noexcept override; +#else void commitHookWasRegistered(UIManager const &) const noexcept override {} void commitHookWasUnregistered(UIManager const &) const noexcept override {} @@ -28,6 +38,7 @@ class ReanimatedCommitHook : public UIManagerCommitHook { RootShadowNode::Shared const &oldRootShadowNode, RootShadowNode::Unshared const &newRootShadowNode) const noexcept override; +#endif private: std::shared_ptr propsRegistry_; diff --git a/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp b/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp index b3d536b3816..7d6012dfe9e 100644 --- a/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +++ b/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp @@ -4,7 +4,6 @@ #ifndef NDEBUG #include -#include "JSLogger.h" #endif namespace reanimated { diff --git a/Common/cpp/NativeModules/NativeReanimatedModule.cpp b/Common/cpp/NativeModules/NativeReanimatedModule.cpp index 68d32d1ed7e..c2e6df7aace 100644 --- a/Common/cpp/NativeModules/NativeReanimatedModule.cpp +++ b/Common/cpp/NativeModules/NativeReanimatedModule.cpp @@ -6,6 +6,9 @@ #endif #include #include +#if REACT_NATIVE_MINOR_VERSION >= 73 && defined(RCT_NEW_ARCH_ENABLED) +#include +#endif #endif #include @@ -30,12 +33,13 @@ #include #endif -#ifndef NDEBUG -#include "JSLogger.h" -#endif - using namespace facebook; +#if REACT_NATIVE_MINOR_VERSION >= 73 && defined(RCT_NEW_ARCH_ENABLED) +// Android can't find the definition of this static field +bool CoreFeatures::useNativeState; +#endif + namespace reanimated { NativeReanimatedModule::NativeReanimatedModule( @@ -313,7 +317,7 @@ void NativeReanimatedModule::setShouldAnimateExiting( const jsi::Value &viewTag, const jsi::Value &shouldAnimate) { layoutAnimationsManager_.setShouldAnimateExiting( - viewTag.asNumber(), shouldAnimate.asBool()); + viewTag.asNumber(), shouldAnimate.getBool()); } bool NativeReanimatedModule::isAnyHandlerWaitingForEvent( @@ -416,16 +420,20 @@ bool NativeReanimatedModule::handleRawEvent( // just ignore this event, because it's an event on unmounted component return false; } - const std::string &type = rawEvent.type; - const ValueFactory &payloadFactory = rawEvent.payloadFactory; int tag = eventTarget->getTag(); - std::string eventType = type; + auto eventType = rawEvent.type; if (eventType.rfind("top", 0) == 0) { eventType = "on" + eventType.substr(3); } jsi::Runtime &rt = uiWorkletRuntime_->getJSIRuntime(); +#if REACT_NATIVE_MINOR_VERSION >= 73 + const auto &eventPayload = rawEvent.eventPayload; + jsi::Value payload = eventPayload->asJSIValue(rt); +#else + const auto &payloadFactory = rawEvent.payloadFactory; jsi::Value payload = payloadFactory(rt); +#endif auto res = handleEvent(eventType, tag, std::move(payload), currentTime); // TODO: we should call performOperations conditionally if event is handled @@ -638,7 +646,8 @@ void NativeReanimatedModule::initializeFabric( commitHook_ = std::make_shared(propsRegistry_, uiManager_); #if REACT_NATIVE_MINOR_VERSION >= 73 - mountHook_ = std::make_shared(propsRegistry, uiManager_); + mountHook_ = + std::make_shared(propsRegistry_, uiManager_); #endif } #endif // RCT_NEW_ARCH_ENABLED diff --git a/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp b/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp index f02aadad6c2..833d66e0b7a 100644 --- a/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +++ b/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp @@ -18,18 +18,19 @@ #include #endif -#include -#include - namespace reanimated { using namespace facebook; using namespace react; +#if REACT_NATIVE_MINOR_VERSION >= 73 +using namespace facebook::hermes::inspector_modern; +#else +using namespace facebook::hermes::inspector; +#endif #if HERMES_ENABLE_DEBUGGER -class HermesExecutorRuntimeAdapter - : public facebook::hermes::inspector::RuntimeAdapter { +class HermesExecutorRuntimeAdapter : public RuntimeAdapter { public: explicit HermesExecutorRuntimeAdapter( facebook::hermes::HermesRuntime &hermesRuntime, @@ -81,11 +82,9 @@ ReanimatedHermesRuntime::ReanimatedHermesRuntime( auto adapter = std::make_unique(*runtime_, jsQueue); #if REACT_NATIVE_MINOR_VERSION >= 71 - debugToken_ = facebook::hermes::inspector::chrome::enableDebugging( - std::move(adapter), name); + debugToken_ = chrome::enableDebugging(std::move(adapter), name); #else - facebook::hermes::inspector::chrome::enableDebugging( - std::move(adapter), name); + chrome::enableDebugging(std::move(adapter), name); #endif // REACT_NATIVE_MINOR_VERSION #else // This is required by iOS, because there is an assertion in the destructor @@ -127,9 +126,9 @@ ReanimatedHermesRuntime::~ReanimatedHermesRuntime() { #if HERMES_ENABLE_DEBUGGER // We have to disable debugging before the runtime is destroyed. #if REACT_NATIVE_MINOR_VERSION >= 71 - facebook::hermes::inspector::chrome::disableDebugging(debugToken_); + chrome::disableDebugging(debugToken_); #else - facebook::hermes::inspector::chrome::disableDebugging(*runtime_); + chrome::disableDebugging(*runtime_); #endif // REACT_NATIVE_MINOR_VERSION #endif // HERMES_ENABLE_DEBUGGER } diff --git a/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h b/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h index 4ff6db6c686..f6dfbf5e9d8 100644 --- a/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +++ b/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h @@ -27,7 +27,10 @@ #include #endif -#if REACT_NATIVE_MINOR_VERSION >= 71 +#if REACT_NATIVE_MINOR_VERSION >= 73 +#include +#else +#include #include #endif @@ -35,6 +38,11 @@ namespace reanimated { using namespace facebook; using namespace react; +#if REACT_NATIVE_MINOR_VERSION >= 73 +using namespace facebook::hermes::inspector_modern; +#else +using namespace facebook::hermes::inspector; +#endif // ReentrancyCheck is copied from React Native // from ReactCommon/hermes/executor/HermesExecutorFactory.cpp @@ -127,7 +135,7 @@ class ReanimatedHermesRuntime ReanimatedReentrancyCheck reentrancyCheck_; #if HERMES_ENABLE_DEBUGGER #if REACT_NATIVE_MINOR_VERSION >= 71 - facebook::hermes::inspector::chrome::DebugSessionToken debugToken_; + chrome::DebugSessionToken debugToken_; #endif // REACT_NATIVE_MINOR_VERSION >= 71 #endif // HERMES_ENABLE_DEBUGGER }; diff --git a/Common/cpp/Tools/SingleInstanceChecker.h b/Common/cpp/Tools/SingleInstanceChecker.h index 7474a6764f1..2a183e87004 100644 --- a/Common/cpp/Tools/SingleInstanceChecker.h +++ b/Common/cpp/Tools/SingleInstanceChecker.h @@ -4,6 +4,7 @@ #include +#include #include #include @@ -41,7 +42,7 @@ class SingleInstanceChecker { // A static field will exist separately for every class template. // This has to be inline for automatic initialization. - inline static volatile int instanceCount_; + inline static std::atomic instanceCount_; }; template diff --git a/RNReanimated.podspec b/RNReanimated.podspec index e1daa70c60f..dd67526ed15 100644 --- a/RNReanimated.podspec +++ b/RNReanimated.podspec @@ -17,6 +17,7 @@ fabric_flags = fabric_enabled ? '-DRCT_NEW_ARCH_ENABLED' : '' example_flag = config[:is_reanimated_example_app] ? '-DIS_REANIMATED_EXAMPLE_APP' : '' version_flag = '-DREANIMATED_VERSION=' + reanimated_package_json["version"] debug_flag = is_release ? '-DNDEBUG' : '' +ios_min_version = config[:react_native_minor_version] >= 73 ? '10.0' : '9.0' Pod::Spec.new do |s| @@ -30,7 +31,7 @@ Pod::Spec.new do |s| s.license = "MIT" # s.license = { :type => "MIT", :file => "FILE_LICENSE" } s.author = { "author" => "author@domain.cn" } - s.platforms = { :ios => "9.0", :tvos => "9.0", :osx => "10.14" } + s.platforms = { :ios => ios_min_version, :tvos => "9.0", :osx => "10.14" } s.source = { :git => "https://github.com/software-mansion/react-native-reanimated.git", :tag => "#{s.version}" } s.source_files = [ @@ -45,7 +46,7 @@ Pod::Spec.new do |s| s.pod_target_xcconfig = { "USE_HEADERMAP" => "YES", "DEFINES_MODULE" => "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\"", + "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\" \"$(PODS_ROOT)/Headers/Private/Yoga\"", "FRAMEWORK_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes\"", "CLANG_CXX_LANGUAGE_STANDARD" => "c++17", } diff --git a/android/CMakeLists.txt b/android/CMakeLists.txt index 8526cefcee9..8ba41221e81 100644 --- a/android/CMakeLists.txt +++ b/android/CMakeLists.txt @@ -2,7 +2,11 @@ project(Reanimated) cmake_minimum_required(VERSION 3.8) set (CMAKE_VERBOSE_MAKEFILE ON) -set (CMAKE_CXX_STANDARD 17) +if(${REACT_NATIVE_MINOR_VERSION} GREATER_EQUAL 73) + set (CMAKE_CXX_STANDARD 20) +else() + set (CMAKE_CXX_STANDARD 17) +endif() # default CMAKE_CXX_FLAGS: "-g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-protector-all" @@ -16,7 +20,7 @@ endif() string(APPEND CMAKE_CXX_FLAGS " -DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION} -DREANIMATED_VERSION=${REANIMATED_VERSION} -DHERMES_ENABLE_DEBUGGER=${HERMES_ENABLE_DEBUGGER}") -string(APPEND CMAKE_CXX_FLAGS " -fexceptions -fno-omit-frame-pointer -frtti -fstack-protector-all -std=c++17 -Wall -Werror") +string(APPEND CMAKE_CXX_FLAGS " -fexceptions -fno-omit-frame-pointer -frtti -fstack-protector-all -std=c++${CMAKE_CXX_STANDARD} -Wall -Werror") if(${IS_NEW_ARCHITECTURE_ENABLED}) string(APPEND CMAKE_CXX_FLAGS " -DRCT_NEW_ARCH_ENABLED") diff --git a/android/build.gradle b/android/build.gradle index c5be207c0b7..aac382529c3 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -244,6 +244,7 @@ android { if (REACT_NATIVE_MINOR_VERSION > 68) { prefab true prefabPublishing true + buildConfig true } } @@ -363,6 +364,8 @@ android { if (REANIMATED_MAJOR_VERSION > 2) { if (REACT_NATIVE_MINOR_VERSION <= 67) { srcDirs += "src/reactNativeVersionPatch/messageQueueThread/67" + } else if (REACT_NATIVE_MINOR_VERSION <= 72) { + srcDirs += "src/reactNativeVersionPatch/messageQueueThread/72" } else { srcDirs += "src/reactNativeVersionPatch/messageQueueThread/latest" } diff --git a/android/src/main/cpp/NativeProxy.cpp b/android/src/main/cpp/NativeProxy.cpp index ec81c7b9843..16eaefe8a5d 100644 --- a/android/src/main/cpp/NativeProxy.cpp +++ b/android/src/main/cpp/NativeProxy.cpp @@ -5,6 +5,9 @@ #include #include #include +#ifdef RCT_NEW_ARCH_ENABLED +#include +#endif #include #include diff --git a/android/src/main/cpp/NativeProxy.h b/android/src/main/cpp/NativeProxy.h index 929228d7782..8d585dc0549 100644 --- a/android/src/main/cpp/NativeProxy.h +++ b/android/src/main/cpp/NativeProxy.h @@ -2,6 +2,7 @@ #ifdef RCT_NEW_ARCH_ENABLED #include +#include #endif #include diff --git a/android/src/reactNativeVersionPatch/messageQueueThread/72/com/swmansion/reanimated/ReanimatedMessageQueueThread.java b/android/src/reactNativeVersionPatch/messageQueueThread/72/com/swmansion/reanimated/ReanimatedMessageQueueThread.java new file mode 100644 index 00000000000..8cfe53f170f --- /dev/null +++ b/android/src/reactNativeVersionPatch/messageQueueThread/72/com/swmansion/reanimated/ReanimatedMessageQueueThread.java @@ -0,0 +1,12 @@ +package com.swmansion.reanimated; + +import com.facebook.proguard.annotations.DoNotStrip; +import com.swmansion.reanimated.ReanimatedMessageQueueThreadBase; + +@DoNotStrip +public class ReanimatedMessageQueueThread extends ReanimatedMessageQueueThreadBase { + @Override + public boolean runOnQueue(Runnable runnable) { + return messageQueueThread.runOnQueue(runnable); + } +} diff --git a/android/src/reactNativeVersionPatch/messageQueueThread/latest/com/swmansion/reanimated/ReanimatedMessageQueueThread.java b/android/src/reactNativeVersionPatch/messageQueueThread/latest/com/swmansion/reanimated/ReanimatedMessageQueueThread.java index 8cfe53f170f..59598f69499 100644 --- a/android/src/reactNativeVersionPatch/messageQueueThread/latest/com/swmansion/reanimated/ReanimatedMessageQueueThread.java +++ b/android/src/reactNativeVersionPatch/messageQueueThread/latest/com/swmansion/reanimated/ReanimatedMessageQueueThread.java @@ -9,4 +9,9 @@ public class ReanimatedMessageQueueThread extends ReanimatedMessageQueueThreadBa public boolean runOnQueue(Runnable runnable) { return messageQueueThread.runOnQueue(runnable); } + + @Override + public boolean isIdle() { + return messageQueueThread.isIdle(); + } } diff --git a/apple/LayoutReanimation/REASwizzledUIManager.mm b/apple/LayoutReanimation/REASwizzledUIManager.mm index f931505a8aa..3196898536d 100644 --- a/apple/LayoutReanimation/REASwizzledUIManager.mm +++ b/apple/LayoutReanimation/REASwizzledUIManager.mm @@ -159,7 +159,11 @@ - (RCTViewManagerUIBlock)reanimated_uiBlockWithLayoutUpdateForRootView:(RCTRootS } RCTUIManager *originalSelf = (RCTUIManager *)self; +#if REACT_NATIVE_MINOR_VERSION >= 73 + NSPointerArray *affectedShadowViews = [NSPointerArray weakObjectsPointerArray]; +#else NSHashTable *affectedShadowViews = [NSHashTable weakObjectsHashTable]; +#endif [rootShadowView layoutWithAffectedShadowViews:affectedShadowViews]; if (!affectedShadowViews.count) { diff --git a/apple/REAModule.mm b/apple/REAModule.mm index 4d9cb054d34..dc8d6513112 100644 --- a/apple/REAModule.mm +++ b/apple/REAModule.mm @@ -2,12 +2,14 @@ #ifdef RCT_NEW_ARCH_ENABLED #import -#import #import #import #import #import #import +#if REACT_NATIVE_MINOR_VERSION < 73 +#import +#endif #endif #ifdef RCT_NEW_ARCH_ENABLED