diff --git a/android/vendored/unversioned/react-native-reanimated/android/build.gradle b/android/vendored/unversioned/react-native-reanimated/android/build.gradle index 9450c632ee29c3..be9f3ab4d025a5 100644 --- a/android/vendored/unversioned/react-native-reanimated/android/build.gradle +++ b/android/vendored/unversioned/react-native-reanimated/android/build.gradle @@ -2,6 +2,9 @@ import com.android.Version import org.apache.tools.ant.filters.ReplaceTokens import org.apache.tools.ant.taskdefs.condition.Os import groovy.json.JsonSlurper + +import javax.inject.Inject +import java.nio.file.Files import java.nio.file.Paths /** @@ -141,41 +144,6 @@ def shouldAssertNoMultipleInstances() { } } -def findReanimatedInstancesForPath(String path) { - return fileTree(path) { - include "**/react-native-reanimated/package.json" - exclude "**/.yarn/**" - exclude {{ file, attr -> attr.isSymbolicLink() }} - }.files -} - -def checkNoMultipleInstances() { - // 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 = "\n[react-native-reanimated] Multiple 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 GradleException(exceptionMessage) - } -} - def getReanimatedVersion() { def inputFile = file(projectDir.path + '/../package.json') def json = new JsonSlurper().parseText(inputFile.text) @@ -207,7 +175,7 @@ file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { rea def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME") def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.startsWith("0.0.0-") ? 1000 : REACT_NATIVE_VERSION.split("\\.")[1].toInteger() def REANIMATED_PACKAGE_BUILD = System.getenv("REANIMATED_PACKAGE_BUILD") -def REANIMATED_VERSION = "3.1.0" +def REANIMATED_VERSION = "3.3.0" def REANIMATED_MAJOR_VERSION = 3 // for React Native <= 0.70 @@ -586,15 +554,64 @@ android { } } -def assertNoMultipleInstances = task assertNoMultipleInstancesTask { - onlyIf { shouldAssertNoMultipleInstances() && CLIENT_SIDE_BUILD } - doFirst { - checkNoMultipleInstances() +abstract class NoMultipleInstancesAssertionTask extends DefaultTask { + @Inject abstract ObjectFactory getObjectFactory() + + @Input abstract Property getProjectDirFile() + @Input abstract Property getRootDirFile() + @Input abstract Property getShouldCheck() + + def findReanimatedInstancesForPath(String path) { + return objectFactory.fileTree().from(path) + .include("**/react-native-reanimated/package.json") + .exclude("**/.yarn/**") + .exclude({ Files.isSymbolicLink(it.getFile().toPath()) }) + .findAll() + } + + @TaskAction + def check() { + if (shouldCheck.get()) { + // Assert there are no multiple installations of Reanimated + Set files + + if (projectDirFile.get().parent.contains(rootDirFile.get().parent)) { + // standard app + files = findReanimatedInstancesForPath(rootDirFile.get().parent + "/node_modules") + } else { + // monorepo + files = findReanimatedInstancesForPath(rootDirFile.get().parent + "/node_modules") + files.addAll( + findReanimatedInstancesForPath(projectDirFile.get().parentFile.parent) + ) + } + + if (files.size() > 1) { + String parsedLocation = files.stream().map({ + File file -> "- " + file.toString().replace("/package.json", "") + }).collect().join("\n") + String exceptionMessage = "\n[react-native-reanimated] Multiple 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 GradleException(exceptionMessage) + } + } } } +tasks.register('assertNoMultipleInstances', NoMultipleInstancesAssertionTask) { + shouldCheck = shouldAssertNoMultipleInstances() + rootDirFile = rootDir + projectDirFile = projectDir +} + +def NEW_ARCH_ENABLED = isNewArchitectureEnabled() + def assertNoReanimated2WithNewArchitecture = task assertNoReanimated2WithNewArchitectureTask { - onlyIf { isNewArchitectureEnabled() && REANIMATED_MAJOR_VERSION == 2 } + onlyIf { NEW_ARCH_ENABLED && REANIMATED_MAJOR_VERSION == 2 } doFirst { throw new GradleException( "\n[react-native-reanimated] Reanimated 2.x does not support Fabric. " + @@ -605,7 +622,7 @@ def assertNoReanimated2WithNewArchitecture = task assertNoReanimated2WithNewArch } def assertLatestReactNativeWithNewArchitecture = task assertLatestReactNativeWithNewArchitectureTask { - onlyIf { isNewArchitectureEnabled() && REANIMATED_MAJOR_VERSION == 3 && REACT_NATIVE_MINOR_VERSION < 72 } + onlyIf { NEW_ARCH_ENABLED && REANIMATED_MAJOR_VERSION == 3 && REACT_NATIVE_MINOR_VERSION < 72 } doFirst { throw new GradleException( "\n[react-native-reanimated] Reanimated " + REANIMATED_VERSION + " supports the New Architecture " + @@ -736,7 +753,7 @@ if (REACT_NATIVE_MINOR_VERSION < 71) { Task resolveGlog = resolveTaskFactory("resolveGlog", "glog-${GLOG_VERSION}.tar.gz", reactNativeAndroidDownloadDir, downloadsDir) if (isNewArchitectureEnabled()) { - def reactNativeAndroidProject = findProject(":packages:react-native:ReactAndroid") + def reactNativeAndroidProject = findProject(":packages:react-native::ReactAndroid") if (reactNativeAndroidProject != null) { reactNativeAndroidProject.afterEvaluate { def resolveTasks = [resolveBoost, resolveGlog, resolveDoubleConversion, resolveFolly] @@ -746,13 +763,13 @@ if (REACT_NATIVE_MINOR_VERSION < 71) { if (reactAndroidDownloadTask != null) { task.dependsOn(reactAndroidDownloadTask) } else { - logger.warn("[Reanimated] Failed to find task named `$reactAndroidDownloadTaskName` in `:packages:react-native:ReactAndroid` project." + + logger.warn("[Reanimated] Failed to find task named `$reactAndroidDownloadTaskName` in `:packages:react-native::ReactAndroid` project." + " Explicit dependency between it and $task.name task can not be set.") } }) } } else { - throw new GradleException("[Reanimated] Failed to find `:packages:react-native:ReactAndroid` project. Explicit dependency between download tasks can not be set.") + throw new GradleException("[Reanimated] Failed to find `:packages:react-native::ReactAndroid` project. Explicit dependency between download tasks can not be set.") } } diff --git a/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/NativeProxy.cpp b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/NativeProxy.cpp index 96c80221880a3f..1386d81187e276 100644 --- a/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/NativeProxy.cpp +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/cpp/NativeProxy.cpp @@ -474,6 +474,8 @@ void NativeProxy::setGlobalProperties( jsRuntime.global().setProperty( jsRuntime, "_WORKLET_RUNTIME", workletRuntimeValue); + jsRuntime.global().setProperty(jsRuntime, "_WORKLET", false); + #ifdef RCT_NEW_ARCH_ENABLED jsRuntime.global().setProperty(jsRuntime, "_IS_FABRIC", true); #else 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 index c60199c8486b57..d359217cd23bb1 100644 --- 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 @@ -145,7 +145,7 @@ public int subscribeForKeyboardEvents( private void bringBackWindowInsets() { WindowCompat.setDecorFitsSystemWindows( - reactContext.get().getCurrentActivity().getWindow(), true); + reactContext.get().getCurrentActivity().getWindow(), !isStatusBarTranslucent); ViewCompat.setOnApplyWindowInsetsListener(getRootView(), null); ViewCompat.setWindowInsetsAnimationCallback(getRootView(), null); View content = diff --git a/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java index 3cffc762a3b27b..9e54a86e0d6135 100644 --- a/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java @@ -84,7 +84,7 @@ public void onViewRemoval(View view, ViewGroup parent, Runnable callback) { Integer tag = view.getId(); mCallbacks.put(tag, callback); - if (!removeOrAnimateExitRecursive(view, parent, true)) { + if (!removeOrAnimateExitRecursive(view, true)) { removeView(view, parent); } } @@ -473,7 +473,7 @@ public boolean isLayoutAnimationEnabled() { return mNativeMethodsHolder != null && mNativeMethodsHolder.isLayoutAnimationEnabled(); } - private boolean removeOrAnimateExitRecursive(View view, ViewGroup parent, boolean shouldRemove) { + private boolean removeOrAnimateExitRecursive(View view, boolean shouldRemove) { int tag = view.getId(); ViewManager viewManager = resolveViewManager(tag); @@ -501,7 +501,7 @@ private boolean removeOrAnimateExitRecursive(View view, ViewGroup parent, boolea ViewGroup viewGroup = (ViewGroup) view; for (int i = viewGroup.getChildCount() - 1; i >= 0; i--) { View child = viewGroup.getChildAt(i); - if (removeOrAnimateExitRecursive(child, viewGroup, shouldRemove)) { + if (removeOrAnimateExitRecursive(child, shouldRemove)) { hasAnimatedChildren = true; } else if (shouldRemove) { toBeRemoved.add(child); diff --git a/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java index 0c536e9d0e9ae5..97280c2c5da2ed 100644 --- a/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +++ b/android/vendored/unversioned/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java @@ -69,7 +69,9 @@ public void onSensorChanged(SensorEvent event) { }; setter.sensorSetter(data, orientationDegrees); } else { - setter.sensorSetter(event.values, orientationDegrees); + // Set the opposite values to be consistent with iOS + float[] data = new float[] {-event.values[0], -event.values[1], -event.values[2]}; + setter.sensorSetter(data, orientationDegrees); } } diff --git a/apps/bare-expo/ios/Podfile.lock b/apps/bare-expo/ios/Podfile.lock index dec248b5166b11..eeebda93d622e3 100644 --- a/apps/bare-expo/ios/Podfile.lock +++ b/apps/bare-expo/ios/Podfile.lock @@ -808,10 +808,11 @@ PODS: - React-Core - RNGestureHandler (2.12.0): - React-Core - - RNReanimated (3.1.0): + - RNReanimated (3.3.0): - DoubleConversion - FBLazyVector - glog + - hermes-engine - RCT-Folly - RCTRequired - RCTTypeSafety @@ -821,11 +822,13 @@ PODS: - React-Core/RCTWebSocket - React-CoreModules - React-cxxreact + - React-hermes - React-jsi - React-jsiexecutor - React-jsinspector - React-RCTActionSheet - React-RCTAnimation + - React-RCTAppDelegate - React-RCTBlob - React-RCTImage - React-RCTLinking @@ -1500,7 +1503,7 @@ SPEC CHECKSUMS: RNDateTimePicker: 7ecd54a97fc3749f38c3c89a171f6cbd52f3c142 RNFlashList: ade81b4e928ebd585dd492014d40fb8d0e848aab RNGestureHandler: dec4645026e7401a0899f2846d864403478ff6a5 - RNReanimated: b4f101902606e60b4b045e813e47204c2d7b38a7 + RNReanimated: 11ef210bd11e80668ed3708f7a9dd846ae29e99c RNScreens: 218801c16a2782546d30bd2026bb625c0302d70f RNSharedElement: 504fa28a235b12505b6daedbb452a9ec96809bd0 RNSVG: 53c661b76829783cdaf9b7a57258f3d3b4c28315 diff --git a/apps/bare-expo/package.json b/apps/bare-expo/package.json index 5a55dfe94d270b..843086c7eee68b 100644 --- a/apps/bare-expo/package.json +++ b/apps/bare-expo/package.json @@ -83,7 +83,7 @@ "react-native": "0.72.0-rc.6", "react-native-gesture-handler": "~2.12.0", "react-native-pager-view": "6.2.0", - "react-native-reanimated": "~3.1.0", + "react-native-reanimated": "~3.3.0", "react-native-safe-area-context": "4.5.3", "react-native-screens": "~3.20.0", "react-native-shared-element": "0.8.8", diff --git a/apps/native-component-list/package.json b/apps/native-component-list/package.json index 11aec0570d33ed..fc743232a49a10 100644 --- a/apps/native-component-list/package.json +++ b/apps/native-component-list/package.json @@ -147,7 +147,7 @@ "react-native-maps": "1.7.1", "react-native-pager-view": "6.2.0", "react-native-paper": "^4.0.1", - "react-native-reanimated": "~3.1.0", + "react-native-reanimated": "~3.3.0", "react-native-safe-area-context": "4.5.3", "react-native-screens": "~3.20.0", "react-native-shared-element": "0.8.8", diff --git a/dev-home-config.json b/dev-home-config.json index 40a84851f78841..01125e940bdfa6 100644 --- a/dev-home-config.json +++ b/dev-home-config.json @@ -1,3 +1,3 @@ { - "url": "exp://exp.host/@expo-home-dev/expo-home-dev-5461ebcc6f68405d3adf445d1ef5ace732a40b33" + "url": "exp://exp.host/@expo-home-dev/expo-home-dev-ff46e842d64e42d9abacf0e3d5830d23616dfbeb" } diff --git a/home/package.json b/home/package.json index b44f63b0c1e457..ad9c2b1762b104 100644 --- a/home/package.json +++ b/home/package.json @@ -63,7 +63,7 @@ "react-native-keyboard-aware-scroll-view": "^0.9.5", "react-native-maps": "1.7.1", "react-native-paper": "^4.0.1", - "react-native-reanimated": "~3.1.0", + "react-native-reanimated": "~3.3.0", "react-native-safe-area-context": "4.5.3", "react-native-screens": "~3.20.0", "react-redux": "^7.2.0", diff --git a/ios/Podfile.lock b/ios/Podfile.lock index ef9a598aa31b80..1667648e49d3ef 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -2213,11 +2213,11 @@ PODS: - React-Core - RNGestureHandler (2.12.0): - React-Core - - RNReanimated (3.1.0): + - RNReanimated (3.3.0): - DoubleConversion - FBLazyVector - - FBReactNativeSpec - glog + - hermes-engine - RCT-Folly - RCTRequired - RCTTypeSafety @@ -2227,11 +2227,13 @@ PODS: - React-Core/RCTWebSocket - React-CoreModules - React-cxxreact + - React-hermes - React-jsi - React-jsiexecutor - React-jsinspector - React-RCTActionSheet - React-RCTAnimation + - React-RCTAppDelegate - React-RCTBlob - React-RCTImage - React-RCTLinking @@ -3776,7 +3778,7 @@ SPEC CHECKSUMS: RNCAsyncStorage: ddc4ee162bfd41b0d2c68bf2d95acd81dd7f1f93 RNFlashList: ade81b4e928ebd585dd492014d40fb8d0e848aab RNGestureHandler: dec4645026e7401a0899f2846d864403478ff6a5 - RNReanimated: 48794d0f278349ecb6d94490e7bb184c9cdcd86f + RNReanimated: c540188fb085b7bf60678f5f5ca3ced906faaab7 RNScreens: 218801c16a2782546d30bd2026bb625c0302d70f RNSVG: 53c661b76829783cdaf9b7a57258f3d3b4c28315 SDWebImage: cb032eba469c54e0000e78bcb0a13cdde0a52798 diff --git a/ios/vendored/unversioned/react-native-reanimated/RNReanimated.podspec.json b/ios/vendored/unversioned/react-native-reanimated/RNReanimated.podspec.json index dc07e22e9dcded..38ea9d2a15ca5a 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": "3.1.0", + "version": "3.3.0", "summary": "More powerful alternative to Animated library for React Native.", "description": "RNReanimated", "homepage": "https://github.com/software-mansion/react-native-reanimated", @@ -14,7 +14,7 @@ }, "source": { "git": "https://github.com/software-mansion/react-native-reanimated.git", - "tag": "3.1.0" + "tag": "3.3.0" }, "source_files": [ "ios/**/*.{mm,h,m}", @@ -29,10 +29,10 @@ "FRAMEWORK_SEARCH_PATHS": "\"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes\"", "CLANG_CXX_LANGUAGE_STANDARD": "c++17" }, - "compiler_flags": "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32 -DREACT_NATIVE_MINOR_VERSION=71 -Wno-comma -Wno-shorten-64-to-32 -Wno-documentation -DHERMES_ENABLE_DEBUGGER", + "compiler_flags": "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32 -DREACT_NATIVE_MINOR_VERSION=72 -Wno-comma -Wno-shorten-64-to-32 -Wno-documentation -DHERMES_ENABLE_DEBUGGER", "xcconfig": { - "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\" \"$(PODS_ROOT)/../../../../../../../../..${PODS_ROOT}/../../react-native-lab/react-native/packages/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=71 -DREANIMATED_VERSION=3.1.0" + "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\" \"${PODS_ROOT}/../../react-native-lab/react-native/packages/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=72 -DREANIMATED_VERSION=3.3.0" }, "requires_arc": true, "dependencies": { @@ -42,7 +42,6 @@ "RCTTypeSafety": [], "ReactCommon/turbomodule/core": [], "FBLazyVector": [], - "FBReactNativeSpec": [], "React-CoreModules": [], "React-Core/DevSupport": [], "React-RCTActionSheet": [], @@ -61,6 +60,9 @@ "Yoga": [], "DoubleConversion": [], "glog": [], - "React-callinvoker": [] + "React-hermes": [], + "hermes-engine": [], + "React-callinvoker": [], + "React-RCTAppDelegate": [] } } diff --git a/ios/vendored/unversioned/react-native-reanimated/ios/LayoutReanimation/REAAnimationsManager.m b/ios/vendored/unversioned/react-native-reanimated/ios/LayoutReanimation/REAAnimationsManager.m index 365ae4f9e53584..cd1a311ee843e8 100644 --- a/ios/vendored/unversioned/react-native-reanimated/ios/LayoutReanimation/REAAnimationsManager.m +++ b/ios/vendored/unversioned/react-native-reanimated/ios/LayoutReanimation/REAAnimationsManager.m @@ -396,7 +396,8 @@ - (BOOL)startAnimationsRecursive:(UIView *)view return NO; } - BOOL hasExitAnimation = _hasAnimationForTag(view.reactTag, EXITING) || [_exitingViews objectForKey:view.reactTag]; + BOOL hasExitAnimation = + [self hasAnimationForTag:view.reactTag type:EXITING] || [_exitingViews objectForKey:view.reactTag]; BOOL hasAnimatedChildren = NO; shouldRemoveSubviewsWithoutAnimations = shouldRemoveSubviewsWithoutAnimations && !hasExitAnimation; NSMutableArray *toBeRemoved = [[NSMutableArray alloc] init]; diff --git a/ios/vendored/unversioned/react-native-reanimated/ios/REAModule.mm b/ios/vendored/unversioned/react-native-reanimated/ios/REAModule.mm index 3cb75a0b8cf0a3..fc5a4998ee2b57 100644 --- a/ios/vendored/unversioned/react-native-reanimated/ios/REAModule.mm +++ b/ios/vendored/unversioned/react-native-reanimated/ios/REAModule.mm @@ -2,6 +2,7 @@ #ifdef RCT_NEW_ARCH_ENABLED #import +#import #import #import #import @@ -192,54 +193,8 @@ - (void)setBridge:(RCTBridge *)bridge _nodesManager = [[REANodesManager alloc] initWithModule:self bridge:self.bridge surfacePresenter:_surfacePresenter]; } -RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(installTurboModule) -{ - facebook::jsi::Runtime *jsiRuntime = [self.bridge respondsToSelector:@selector(runtime)] - ? reinterpret_cast(self.bridge.runtime) - : nullptr; - - if (jsiRuntime) { - // Reanimated - jsi::Runtime &runtime = *jsiRuntime; - - auto reanimatedModule = reanimated::createReanimatedModule(self.bridge, self.bridge.jsCallInvoker); - - 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, "_IS_FABRIC", true); - - auto version = getReanimatedVersionString(runtime); - runtime.global().setProperty(runtime, "_REANIMATED_VERSION_CPP", version); - - runtime.global().setProperty( - runtime, - jsi::PropNameID::forAscii(runtime, "__reanimatedModuleProxy"), - jsi::Object::createFromHostObject(runtime, reanimatedModule)); - reanimatedModule_ = reanimatedModule; - if (_surfacePresenter != nil) { - // reload, uiManager is null right now, we need to wait for `installReanimatedUIManagerBindingAfterReload` - [self injectDependencies:runtime]; - } - } - return nil; -} - #else -RCT_EXPORT_METHOD(installTurboModule) -{ - // TODO: Move initialization from UIResponder+Reanimated to here -} - - (void)setBridge:(RCTBridge *)bridge { [super setBridge:bridge]; @@ -311,4 +266,54 @@ - (void)sendEventWithName:(NSString *)eventName body:(id)body } } +RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(installTurboModule) +{ + facebook::jsi::Runtime *jsiRuntime = [self.bridge respondsToSelector:@selector(runtime)] + ? reinterpret_cast(self.bridge.runtime) + : nullptr; + + if (jsiRuntime) { + jsi::Runtime &runtime = *jsiRuntime; + + auto reanimatedModule = reanimated::createReanimatedModule(self.bridge, self.bridge.jsCallInvoker); + + 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", false); + +#ifdef RCT_NEW_ARCH_ENABLED + runtime.global().setProperty(runtime, "_IS_FABRIC", true); +#else + runtime.global().setProperty(runtime, "_IS_FABRIC", false); +#endif // RCT_NEW_ARCH_ENABLED + + auto version = getReanimatedVersionString(runtime); + runtime.global().setProperty(runtime, "_REANIMATED_VERSION_CPP", version); + + runtime.global().setProperty( + runtime, + jsi::PropNameID::forAscii(runtime, "__reanimatedModuleProxy"), + jsi::Object::createFromHostObject(runtime, reanimatedModule)); + +#ifdef RCT_NEW_ARCH_ENABLED + reanimatedModule_ = reanimatedModule; + if (_surfacePresenter != nil) { + // reload, uiManager is null right now, we need to wait for `installReanimatedUIManagerBindingAfterReload` + [self injectDependencies:runtime]; + } +#endif // RCT_NEW_ARCH_ENABLED + } + + return nil; +} + @end diff --git a/ios/vendored/unversioned/react-native-reanimated/ios/REANodesManager.mm b/ios/vendored/unversioned/react-native-reanimated/ios/REANodesManager.mm index 26bb25365856d9..4670a7075a0b06 100644 --- a/ios/vendored/unversioned/react-native-reanimated/ios/REANodesManager.mm +++ b/ios/vendored/unversioned/react-native-reanimated/ios/REANodesManager.mm @@ -12,6 +12,10 @@ #import #endif +#if __has_include() +#import +#endif + #ifdef RCT_NEW_ARCH_ENABLED using namespace facebook::react; #endif @@ -85,19 +89,77 @@ - (void)runSyncUIUpdatesWithObserver:(id)observer @end -@interface REANodesManager () +#ifndef RCT_NEW_ARCH_ENABLED +@interface REASyncUpdateObserver : NSObject @end +@implementation REASyncUpdateObserver { + volatile void (^_mounting)(void); + volatile BOOL _waitTimedOut; + dispatch_semaphore_t _semaphore; +} + +- (instancetype)init +{ + self = [super init]; + if (self) { + _mounting = nil; + _waitTimedOut = NO; + _semaphore = dispatch_semaphore_create(0); + } + return self; +} + +- (void)dealloc +{ + RCTAssert(_mounting == nil, @"Mouting block was set but never executed. This may lead to UI inconsistencies"); +} + +- (void)unblockUIThread +{ + RCTAssertUIManagerQueue(); + dispatch_semaphore_signal(_semaphore); +} + +- (void)waitAndMountWithTimeout:(NSTimeInterval)timeout +{ + RCTAssertMainQueue(); + long result = dispatch_semaphore_wait(_semaphore, dispatch_time(DISPATCH_TIME_NOW, timeout * NSEC_PER_SEC)); + if (result != 0) { + @synchronized(self) { + _waitTimedOut = YES; + } + } + if (_mounting) { + _mounting(); + _mounting = nil; + } +} + +- (BOOL)uiManager:(RCTUIManager *)manager performMountingWithBlock:(RCTUIManagerMountingBlock)block +{ + RCTAssertUIManagerQueue(); + @synchronized(self) { + if (_waitTimedOut) { + return NO; + } else { + _mounting = block; + return YES; + } + } +} + +@end + +#endif + @implementation REANodesManager { CADisplayLink *_displayLink; BOOL _wantRunUpdates; NSMutableArray *_onAnimationCallbacks; BOOL _tryRunBatchUpdatesSynchronously; REAEventHandler _eventHandler; - volatile void (^_mounting)(void); - NSObject *_syncLayoutUpdatesWaitLock; - volatile BOOL _syncLayoutUpdatesWaitTimedOut; NSMutableDictionary *_componentUpdateBuffer; NSMutableDictionary *_viewRegistry; #ifdef RCT_NEW_ARCH_ENABLED @@ -125,7 +187,6 @@ - (nonnull instancetype)initWithModule:(REAModule *)reanimatedModule _operationsInBatch = [NSMutableDictionary new]; _componentUpdateBuffer = [NSMutableDictionary new]; _viewRegistry = [_uiManager valueForKey:@"_viewRegistry"]; - _syncLayoutUpdatesWaitLock = [NSObject new]; } _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(onAnimationFrame:)]; @@ -241,19 +302,6 @@ - (void)onAnimationFrame:(CADisplayLink *)displayLink } } -- (BOOL)uiManager:(RCTUIManager *)manager performMountingWithBlock:(RCTUIManagerMountingBlock)block -{ - RCTAssert(_mounting == nil, @"Mouting block is expected to not be set"); - @synchronized(_syncLayoutUpdatesWaitLock) { - if (_syncLayoutUpdatesWaitTimedOut) { - return NO; - } else { - _mounting = block; - return YES; - } - } -} - - (void)performOperations { #ifdef RCT_NEW_ARCH_ENABLED @@ -268,8 +316,7 @@ - (void)performOperations _tryRunBatchUpdatesSynchronously = NO; __weak __typeof__(self) weakSelf = self; - dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); - _syncLayoutUpdatesWaitTimedOut = NO; + REASyncUpdateObserver *syncUpdateObserver = [REASyncUpdateObserver new]; RCTExecuteOnUIManagerQueue(^{ __typeof__(self) strongSelf = weakSelf; if (strongSelf == nil) { @@ -278,7 +325,7 @@ - (void)performOperations BOOL canUpdateSynchronously = trySynchronously && ![strongSelf.uiManager hasEnqueuedUICommands]; if (!canUpdateSynchronously) { - dispatch_semaphore_signal(semaphore); + [syncUpdateObserver unblockUIThread]; } for (int i = 0; i < copiedOperationsQueue.count; i++) { @@ -286,8 +333,8 @@ - (void)performOperations } if (canUpdateSynchronously) { - [strongSelf.uiManager runSyncUIUpdatesWithObserver:strongSelf]; - dispatch_semaphore_signal(semaphore); + [strongSelf.uiManager runSyncUIUpdatesWithObserver:syncUpdateObserver]; + [syncUpdateObserver unblockUIThread]; } // In case canUpdateSynchronously=true we still have to send uiManagerWillPerformMounting event // to observers because some components (e.g. TextInput) update their UIViews only on that event. @@ -298,17 +345,7 @@ - (void)performOperations // from CADisplayLink but it is easier to hardcode it for the time being. // The reason why we use frame duration here is that if takes longer than one frame to complete layout tasks // there is no point of synchronizing layout with the UI interaction as we get that one frame delay anyways. - long result = dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, 16 * NSEC_PER_MSEC)); - if (result != 0) { - @synchronized(_syncLayoutUpdatesWaitLock) { - _syncLayoutUpdatesWaitTimedOut = YES; - } - } - } - - if (_mounting) { - _mounting(); - _mounting = nil; + [syncUpdateObserver waitAndMountWithTimeout:0.016]; } } _wantRunUpdates = NO; @@ -368,7 +405,16 @@ - (void)configureUiProps:(nonnull NSSet *)uiPropsSet - (BOOL)isNativeViewMounted:(NSNumber *)viewTag { - return _viewRegistry[viewTag].superview != nil; + UIView *view = _viewRegistry[viewTag]; + if (view.superview != nil) { + return YES; + } +#if __has_include() + if ([view isKindOfClass:[RNSScreenStackHeaderConfig class]]) { + return ((RNSScreenStackHeaderConfig *)view).screenView != nil; + } +#endif + return NO; } #ifdef RCT_NEW_ARCH_ENABLED diff --git a/ios/vendored/unversioned/react-native-reanimated/ios/keyboardObserver/REAKeyboardEventObserver.h b/ios/vendored/unversioned/react-native-reanimated/ios/keyboardObserver/REAKeyboardEventObserver.h index 37600c010dbcae..982bd1f08f70dc 100644 --- a/ios/vendored/unversioned/react-native-reanimated/ios/keyboardObserver/REAKeyboardEventObserver.h +++ b/ios/vendored/unversioned/react-native-reanimated/ios/keyboardObserver/REAKeyboardEventObserver.h @@ -1,7 +1,6 @@ #ifndef REAKeyboardEventManager_h #define REAKeyboardEventManager_h -#import #import typedef void (^KeyboardEventListenerBlock)(int keyboardState, int height); diff --git a/ios/vendored/unversioned/react-native-reanimated/ios/native/RCTAppDelegate+Reanimated.h b/ios/vendored/unversioned/react-native-reanimated/ios/native/RCTAppDelegate+Reanimated.h new file mode 100644 index 00000000000000..1886195564f1bd --- /dev/null +++ b/ios/vendored/unversioned/react-native-reanimated/ios/native/RCTAppDelegate+Reanimated.h @@ -0,0 +1,25 @@ +#if REACT_NATIVE_MINOR_VERSION >= 72 && !defined(RCT_NEW_ARCH_ENABLED) && !defined(DONT_AUTOINSTALL_REANIMATED) + +#import + +#if __has_include() +#import +#elif __has_include() +// for importing the header from framework, the dash will be transformed to underscore +#import +#endif + +#if __has_include() +#import +#elif __has_include() +// for importing the header from framework, "React-cxxreact" will be omitted +#import +#endif + +@interface RCTAppDelegate (Reanimated) + +- (std::unique_ptr)reanimated_jsExecutorFactoryForBridge:(RCTBridge *)bridge; + +@end + +#endif diff --git a/ios/vendored/unversioned/react-native-reanimated/ios/native/RCTAppDelegate+Reanimated.mm b/ios/vendored/unversioned/react-native-reanimated/ios/native/RCTAppDelegate+Reanimated.mm new file mode 100644 index 00000000000000..7647df5d8421d0 --- /dev/null +++ b/ios/vendored/unversioned/react-native-reanimated/ios/native/RCTAppDelegate+Reanimated.mm @@ -0,0 +1,28 @@ +#if REACT_NATIVE_MINOR_VERSION >= 72 && !defined(RCT_NEW_ARCH_ENABLED) && !defined(DONT_AUTOINSTALL_REANIMATED) + +#import +#import +#import + +@implementation RCTAppDelegate (Reanimated) + +- (std::unique_ptr)reanimated_jsExecutorFactoryForBridge:(RCTBridge *)bridge +{ + reanimated::REAInitializer(bridge); + return [self reanimated_jsExecutorFactoryForBridge:bridge]; // call the original method +} + ++ (void)load +{ + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + Class cls = [self class]; + Method originalMethod = class_getInstanceMethod(cls, @selector(jsExecutorFactoryForBridge:)); + Method swizzledMethod = class_getInstanceMethod(cls, @selector(reanimated_jsExecutorFactoryForBridge:)); + method_exchangeImplementations(originalMethod, swizzledMethod); + }); +} + +@end + +#endif 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 94c548b3a6acca..b3cf5fbffc76f3 100644 --- a/ios/vendored/unversioned/react-native-reanimated/ios/native/REAInitializer.h +++ b/ios/vendored/unversioned/react-native-reanimated/ios/native/REAInitializer.h @@ -1,30 +1,27 @@ +#ifndef RCT_NEW_ARCH_ENABLED + #import -#import -#import -#import -#import -#import -#import -#import - -#if REACT_NATIVE_MINOR_VERSION >= 64 -#import -#endif +#import -#if REACT_NATIVE_MINOR_VERSION < 63 -#import -#endif +#if REACT_NATIVE_MINOR_VERSION <= 71 +#import +using namespace facebook::react; +#endif // REACT_NATIVE_MINOR_VERSION <= 71 NS_ASSUME_NONNULL_BEGIN namespace reanimated { -using namespace facebook; -using namespace react; +void REAInitializer(RCTBridge *bridge); +#if REACT_NATIVE_MINOR_VERSION <= 71 JSIExecutor::RuntimeInstaller REAJSIExecutorRuntimeInstaller( RCTBridge *bridge, JSIExecutor::RuntimeInstaller runtimeInstallerToWrap); +#endif // REACT_NATIVE_MINOR_VERSION <= 71 } // namespace reanimated + NS_ASSUME_NONNULL_END + +#endif // RCT_NEW_ARCH_ENABLED 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 60ee16df3da166..401b1026da4844 100644 --- a/ios/vendored/unversioned/react-native-reanimated/ios/native/REAInitializer.mm +++ b/ios/vendored/unversioned/react-native-reanimated/ios/native/REAInitializer.mm @@ -1,21 +1,12 @@ +#ifndef RCT_NEW_ARCH_ENABLED + +#import #import #import -#import - -@interface RCTEventDispatcher (Reanimated) - -- (void)setBridge:(RCTBridge *)bridge; - -@end namespace reanimated { -using namespace facebook; -using namespace react; - -JSIExecutor::RuntimeInstaller REAJSIExecutorRuntimeInstaller( - RCTBridge *bridge, - JSIExecutor::RuntimeInstaller runtimeInstallerToWrap) +void REAInitializer(RCTBridge *bridge) { [bridge moduleForClass:[RCTUIManager class]]; REAUIManager *reaUiManager = [REAUIManager new]; @@ -36,37 +27,17 @@ - (void)setBridge:(RCTBridge *)bridge; [eventDispatcher setBridge:bridge]; #endif [bridge updateModuleWithInstance:eventDispatcher]; - const auto runtimeInstaller = [bridge, runtimeInstallerToWrap](facebook::jsi::Runtime &runtime) { - if (!bridge) { - return; - } -#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)); - workletRuntimeData[0] = reinterpret_cast(reanimatedModule->runtime.get()); - - runtime.global().setProperty(runtime, "_WORKLET_RUNTIME", workletRuntimeValue); - - runtime.global().setProperty(runtime, "_IS_FABRIC", false); +} - auto version = getReanimatedVersionString(runtime); - runtime.global().setProperty(runtime, "_REANIMATED_VERSION_CPP", version); +#if REACT_NATIVE_MINOR_VERSION <= 71 - runtime.global().setProperty( - runtime, - jsi::PropNameID::forAscii(runtime, "__reanimatedModuleProxy"), - jsi::Object::createFromHostObject(runtime, reanimatedModule)); +JSIExecutor::RuntimeInstaller REAJSIExecutorRuntimeInstaller( + RCTBridge *bridge, + JSIExecutor::RuntimeInstaller runtimeInstallerToWrap) +{ + REAInitializer(bridge); + const auto runtimeInstaller = [runtimeInstallerToWrap](facebook::jsi::Runtime &runtime) { if (runtimeInstallerToWrap) { runtimeInstallerToWrap(runtime); } @@ -74,4 +45,8 @@ - (void)setBridge:(RCTBridge *)bridge; return runtimeInstaller; } +#endif // REACT_NATIVE_MINOR_VERSION <= 71 + } // namespace reanimated + +#endif // RCT_NEW_ARCH_ENABLED diff --git a/ios/vendored/unversioned/react-native-reanimated/ios/native/UIResponder+Reanimated.h b/ios/vendored/unversioned/react-native-reanimated/ios/native/UIResponder+Reanimated.h index 782eb2ab4df717..d245c5a64c23f6 100644 --- a/ios/vendored/unversioned/react-native-reanimated/ios/native/UIResponder+Reanimated.h +++ b/ios/vendored/unversioned/react-native-reanimated/ios/native/UIResponder+Reanimated.h @@ -1,12 +1,10 @@ +#if REACT_NATIVE_MINOR_VERSION <= 71 && !defined(RCT_NEW_ARCH_ENABLED) && !defined(DONT_AUTOINSTALL_REANIMATED) + #import #import -#ifndef RCT_NEW_ARCH_ENABLED -#ifndef DONT_AUTOINSTALL_REANIMATED - @interface UIResponder (Reanimated) @end -#endif // DONT_AUTOINSTALL_REANIMATED -#endif // RCT_NEW_ARCH_ENABLED +#endif \ No newline at end of file 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 76526d81c4ae7c..4ca12f0acf5d42 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 @@ -1,5 +1,6 @@ +#if REACT_NATIVE_MINOR_VERSION <= 71 && !defined(RCT_NEW_ARCH_ENABLED) && !defined(DONT_AUTOINSTALL_REANIMATED) + #import -#import #import #if __has_include() @@ -13,9 +14,6 @@ typedef JSCExecutorFactory ExecutorFactory; #endif -#ifndef RCT_NEW_ARCH_ENABLED -#ifndef DONT_AUTOINSTALL_REANIMATED - @implementation UIResponder (Reanimated) - (std::unique_ptr)jsExecutorFactoryForBridge:(RCTBridge *)bridge { @@ -31,5 +29,4 @@ @implementation UIResponder (Reanimated) @end -#endif // DONT_AUTOINSTALL_REANIMATED -#endif // RCT_NEW_ARCH_ENABLED +#endif diff --git a/packages/expo/bundledNativeModules.json b/packages/expo/bundledNativeModules.json index f9c1c37efac2cf..2eb842ef12aae5 100644 --- a/packages/expo/bundledNativeModules.json +++ b/packages/expo/bundledNativeModules.json @@ -89,7 +89,7 @@ "react-native-get-random-values": "~1.8.0", "react-native-maps": "1.7.1", "react-native-pager-view": "6.2.0", - "react-native-reanimated": "~3.1.0", + "react-native-reanimated": "~3.3.0", "react-native-screens": "~3.20.0", "react-native-safe-area-context": "4.5.3", "react-native-shared-element": "0.8.8", diff --git a/tools/src/vendoring/config/expoGoConfig.ts b/tools/src/vendoring/config/expoGoConfig.ts index 8e90d63000a30c..3ebc2b4dd0301e 100644 --- a/tools/src/vendoring/config/expoGoConfig.ts +++ b/tools/src/vendoring/config/expoGoConfig.ts @@ -98,11 +98,14 @@ const config: VendoringTargetConfig = { return podspecPath; }, async mutatePodspec(podspec: Podspec) { - const rnForkPath = path.join(REACT_NATIVE_SUBMODULE_DIR, '..'); - const relativeForkPath = path.relative(path.join(EXPO_DIR, 'ios'), rnForkPath); + const reactCommonDir = path.relative( + EXPO_DIR, + path.join(REACT_NATIVE_SUBMODULE_DIR, 'packages', 'react-native', 'ReactCommon') + ); + // `reanimated_utils.rb` generates wrong and confusing paths to ReactCommon headers, so we need to fix them. podspec.xcconfig['HEADER_SEARCH_PATHS'] = podspec.xcconfig[ 'HEADER_SEARCH_PATHS' - ]?.replace(rnForkPath, '${PODS_ROOT}/../' + relativeForkPath); + ]?.replace(/"\$\(PODS_ROOT\)\/\.\.\/.+?"/g, `"\${PODS_ROOT}/../../${reactCommonDir}"`); }, transforms: { content: [ diff --git a/yarn.lock b/yarn.lock index ef8a29076bc4a1..273a2b7ca56b53 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15879,10 +15879,10 @@ react-native-paper@^4.0.1: color "^3.1.2" react-native-iphone-x-helper "^1.3.1" -react-native-reanimated@~3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-3.1.0.tgz#6fe757dadf06a59b365c1c0339e992751ab03792" - integrity sha512-8YJR7yHnrqK6yKWzkGLVEawi1WZqJ9bGIehKEnE8zG58yLrSwUZe1T220XTbftpkA3r37Sy0kJJ/HOOiaIU+HQ== +react-native-reanimated@~3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-3.3.0.tgz#80f9d58e28fddf62fe4c1bc792337b8ab57936ab" + integrity sha512-LzfpPZ1qXBGy5BcUHqw3pBC0qSd22qXS3t8hWSbozXNrBkzMhhOrcILE/nEg/PHpNNp1xvGOW8NwpAMF006roQ== dependencies: "@babel/plugin-transform-object-assign" "^7.16.7" "@babel/preset-typescript" "^7.16.7"