Skip to content

Commit

Permalink
[go] update react-native-reanimated to 3.3.0 (expo#22907)
Browse files Browse the repository at this point in the history
# Why

update vendoring modules for sdk 49

# How

- `et uvm -m react-native-reanimated -c 3.3.0`
- publish dev home because prebuilt home still uses reanimated 3.1.0

# Test Plan

unversioned expo go + ncl reanimated
  • Loading branch information
Kudo authored Jun 19, 2023
1 parent 2ad44b9 commit c3bb8da
Show file tree
Hide file tree
Showing 25 changed files with 327 additions and 225 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down Expand Up @@ -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<File> 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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<File> getProjectDirFile()
@Input abstract Property<File> getRootDirFile()
@Input abstract Property<Boolean> 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<File> 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. " +
Expand All @@ -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 " +
Expand Down Expand Up @@ -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]
Expand All @@ -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.")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
7 changes: 5 additions & 2 deletions apps/bare-expo/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -1500,7 +1503,7 @@ SPEC CHECKSUMS:
RNDateTimePicker: 7ecd54a97fc3749f38c3c89a171f6cbd52f3c142
RNFlashList: ade81b4e928ebd585dd492014d40fb8d0e848aab
RNGestureHandler: dec4645026e7401a0899f2846d864403478ff6a5
RNReanimated: b4f101902606e60b4b045e813e47204c2d7b38a7
RNReanimated: 11ef210bd11e80668ed3708f7a9dd846ae29e99c
RNScreens: 218801c16a2782546d30bd2026bb625c0302d70f
RNSharedElement: 504fa28a235b12505b6daedbb452a9ec96809bd0
RNSVG: 53c661b76829783cdaf9b7a57258f3d3b4c28315
Expand Down
2 changes: 1 addition & 1 deletion apps/bare-expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion apps/native-component-list/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion dev-home-config.json
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 1 addition & 1 deletion home/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 5 additions & 3 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -3776,7 +3778,7 @@ SPEC CHECKSUMS:
RNCAsyncStorage: ddc4ee162bfd41b0d2c68bf2d95acd81dd7f1f93
RNFlashList: ade81b4e928ebd585dd492014d40fb8d0e848aab
RNGestureHandler: dec4645026e7401a0899f2846d864403478ff6a5
RNReanimated: 48794d0f278349ecb6d94490e7bb184c9cdcd86f
RNReanimated: c540188fb085b7bf60678f5f5ca3ced906faaab7
RNScreens: 218801c16a2782546d30bd2026bb625c0302d70f
RNSVG: 53c661b76829783cdaf9b7a57258f3d3b4c28315
SDWebImage: cb032eba469c54e0000e78bcb0a13cdde0a52798
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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}",
Expand All @@ -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": {
Expand All @@ -42,7 +42,6 @@
"RCTTypeSafety": [],
"ReactCommon/turbomodule/core": [],
"FBLazyVector": [],
"FBReactNativeSpec": [],
"React-CoreModules": [],
"React-Core/DevSupport": [],
"React-RCTActionSheet": [],
Expand All @@ -61,6 +60,9 @@
"Yoga": [],
"DoubleConversion": [],
"glog": [],
"React-callinvoker": []
"React-hermes": [],
"hermes-engine": [],
"React-callinvoker": [],
"React-RCTAppDelegate": []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Loading

0 comments on commit c3bb8da

Please sign in to comment.