From 4f2a40db0d614a63f5cd29d9d69530ddde624e29 Mon Sep 17 00:00:00 2001 From: Wojciech Lewicki Date: Tue, 27 Feb 2024 12:27:26 +0100 Subject: [PATCH 01/25] feat: update codebase --- Common/cpp/Fabric/ShadowTreeCloner.cpp | 2 +- .../NativeModules/NativeReanimatedModule.cpp | 7 +- FabricExample/.gitignore | 12 +- FabricExample/App.tsx | 49 +- FabricExample/Gemfile.lock | 4 +- FabricExample/android/app/build.gradle | 1 - .../java/com/fabricexample/MainApplication.kt | 4 +- FabricExample/android/build.gradle | 6 +- FabricExample/android/gradle-wrapper.jar | Bin 0 -> 43462 bytes .../android/gradle-wrapper.properties | 7 + .../gradle/wrapper/gradle-wrapper.properties | 2 +- .../FabricExample.xcodeproj/project.pbxproj | 29 +- .../ios/FabricExample/AppDelegate.mm | 4 +- FabricExample/ios/FabricExample/Info.plist | 2 +- .../ios/FabricExample/{main.mm => main.m} | 0 FabricExample/ios/Podfile | 19 +- FabricExample/ios/Podfile.lock | 1216 +++++++---------- FabricExample/package.json | 25 +- ...ommunity+cli-platform-android+13.6.0.patch | 12 + .../patches/react-native-box2d+0.2.5.patch | 94 -- FabricExample/yarn.lock | 878 +++++------- apple/REAModule.h | 18 +- apple/REAModule.mm | 100 +- apple/native/NativeProxy.h | 9 +- apple/native/NativeProxy.mm | 125 ++ package.json | 5 + .../NativeReanimated/NativeReanimated.ts | 5 +- src/reanimated2/PlatformChecker.ts | 5 +- src/reanimated2/fabricUtils.ts | 23 +- src/specs/NativeReanimatedModule.ts | 8 + 30 files changed, 1199 insertions(+), 1472 deletions(-) create mode 100644 FabricExample/android/gradle-wrapper.jar create mode 100644 FabricExample/android/gradle-wrapper.properties rename FabricExample/ios/FabricExample/{main.mm => main.m} (100%) create mode 100644 FabricExample/patches/@react-native-community+cli-platform-android+13.6.0.patch delete mode 100644 FabricExample/patches/react-native-box2d+0.2.5.patch create mode 100644 src/specs/NativeReanimatedModule.ts diff --git a/Common/cpp/Fabric/ShadowTreeCloner.cpp b/Common/cpp/Fabric/ShadowTreeCloner.cpp index f913ceba98fe..6d0ccc44ff64 100644 --- a/Common/cpp/Fabric/ShadowTreeCloner.cpp +++ b/Common/cpp/Fabric/ShadowTreeCloner.cpp @@ -22,7 +22,7 @@ ShadowNode::Unshared cloneShadowTreeWithNewProps( PropsParserContext propsParserContext{ source->getSurfaceId(), *source->getContextContainer()}; const auto props = source->getComponentDescriptor().cloneProps( - propsParserContext, source->getProps(), rawProps); + propsParserContext, source->getProps(), std::move(rawProps)); auto newChildNode = source->clone({/* .props = */ props}); diff --git a/Common/cpp/NativeModules/NativeReanimatedModule.cpp b/Common/cpp/NativeModules/NativeReanimatedModule.cpp index b34579deccf6..8de3d0efdee1 100644 --- a/Common/cpp/NativeModules/NativeReanimatedModule.cpp +++ b/Common/cpp/NativeModules/NativeReanimatedModule.cpp @@ -1,9 +1,6 @@ #include "NativeReanimatedModule.h" #ifdef RCT_NEW_ARCH_ENABLED -#if REACT_NATIVE_MINOR_VERSION >= 72 -#include -#endif #include #include #if REACT_NATIVE_MINOR_VERSION >= 73 && defined(RCT_NEW_ARCH_ENABLED) @@ -39,7 +36,7 @@ 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; +//bool CoreFeatures::useNativeState; #endif namespace reanimated { @@ -679,7 +676,7 @@ jsi::Value NativeReanimatedModule::measure( uiManager_->getNewestCloneOfShadowNode(*shadowNode); auto layoutableShadowNode = - traitCast(newestCloneOfShadowNode.get()); + dynamic_cast(newestCloneOfShadowNode.get()); facebook::react::Point originRelativeToParent = layoutableShadowNode != nullptr ? layoutableShadowNode->getLayoutMetrics().frame.origin diff --git a/FabricExample/.gitignore b/FabricExample/.gitignore index 0cab2ac6fc46..d5ae456695e5 100644 --- a/FabricExample/.gitignore +++ b/FabricExample/.gitignore @@ -20,7 +20,7 @@ DerivedData *.hmap *.ipa *.xcuserstate -ios/.xcode.env.local +**/.xcode.env.local # Android/IntelliJ # @@ -56,7 +56,7 @@ yarn-error.log *.jsbundle # Ruby / CocoaPods -/ios/Pods/ +**/Pods/ /vendor/bundle/ # Temporary files created by Metro to check the health of the file watcher @@ -64,3 +64,11 @@ yarn-error.log # testing /coverage + +# Yarn +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions diff --git a/FabricExample/App.tsx b/FabricExample/App.tsx index 6d5397785890..1606027b965c 100644 --- a/FabricExample/App.tsx +++ b/FabricExample/App.tsx @@ -1,3 +1,48 @@ -import App from '../app'; +import Animated, { + useSharedValue, + withTiming, + useAnimatedStyle, + Easing, +} from 'react-native-reanimated'; +import {View, Button, StyleSheet} from 'react-native'; +import React from 'react'; -export default App; +export default function AnimatedStyleUpdateExample() { + const randomWidth = useSharedValue(10); + + const config = { + duration: 500, + easing: Easing.bezierFn(0.5, 0.01, 0, 1), + }; + + const style = useAnimatedStyle(() => { + return { + width: withTiming(randomWidth.value, config), + }; + }); + + return ( + + +