react-native-reanimated 2.12.0 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +1 -0
  2. package/Common/cpp/Tools/ReanimatedVersion.cpp +17 -0
  3. package/Common/cpp/Tools/ReanimatedVersion.h +11 -0
  4. package/RNReanimated.podspec +2 -1
  5. package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
  6. package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
  7. package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
  8. package/android/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  9. package/android/.gradle/7.5.1/executionHistory/executionHistory.bin +0 -0
  10. package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
  11. package/android/.gradle/7.5.1/fileHashes/fileHashes.bin +0 -0
  12. package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
  13. package/android/.gradle/7.5.1/fileHashes/resourceHashesCache.bin +0 -0
  14. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  15. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  16. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  17. package/android/.gradle/file-system.probe +0 -0
  18. package/android/CMakeLists.txt +192 -189
  19. package/android/build.gradle +395 -317
  20. package/android/react-native-reanimated-67-hermes.aar +0 -0
  21. package/android/react-native-reanimated-67-jsc.aar +0 -0
  22. package/android/react-native-reanimated-68-hermes.aar +0 -0
  23. package/android/react-native-reanimated-68-jsc.aar +0 -0
  24. package/android/react-native-reanimated-69-hermes.aar +0 -0
  25. package/android/react-native-reanimated-69-jsc.aar +0 -0
  26. package/android/react-native-reanimated-70-hermes.aar +0 -0
  27. package/android/react-native-reanimated-70-jsc.aar +0 -0
  28. package/android/react-native-reanimated-71-hermes.aar +0 -0
  29. package/android/react-native-reanimated-71-jsc.aar +0 -0
  30. package/android/src/main/cpp/NativeProxy.cpp +8 -0
  31. package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +5 -4
  32. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +1 -1
  33. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +16 -0
  34. package/android/src/{main/java → reactNativeVersionPatch/ReanimatedUIManager/70}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -0
  35. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +63 -0
  36. package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +271 -0
  37. package/android/src/reactNativeVersionPatch/nativeHierarchyManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +3 -30
  38. package/ios/REAModule.mm +11 -7
  39. package/ios/native/REAInitializer.mm +4 -0
  40. package/lib/createAnimatedComponent.js +5 -0
  41. package/lib/reanimated2/Colors.js +27 -11
  42. package/lib/reanimated2/NativeReanimated/NativeReanimated.js +4 -0
  43. package/lib/reanimated2/animation/util.js +15 -15
  44. package/lib/reanimated2/globals.d.ts +2 -0
  45. package/lib/reanimated2/interpolateColor.js +79 -20
  46. package/lib/reanimated2/jestUtils.js +14 -7
  47. package/lib/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -18
  48. package/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -10
  49. package/lib/reanimated2/layoutReanimation/defaultAnimations/Roll.js +15 -10
  50. package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -10
  51. package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +24 -18
  52. package/lib/reanimated2/platform-specific/checkVersion.js +24 -0
  53. package/lib/reanimated2/platform-specific/checkVersion.web.js +6 -0
  54. package/lib/types/{Animated.d.ts → lib/Animated.d.ts} +0 -0
  55. package/lib/types/{ConfigHelper.d.ts → lib/ConfigHelper.d.ts} +0 -0
  56. package/lib/types/{ReanimatedEventEmitter.d.ts → lib/ReanimatedEventEmitter.d.ts} +0 -0
  57. package/lib/types/{ReanimatedModule.d.ts → lib/ReanimatedModule.d.ts} +0 -0
  58. package/lib/types/{ReanimatedModule.macos.d.ts → lib/ReanimatedModule.macos.d.ts} +0 -0
  59. package/lib/types/{ReanimatedModule.native.d.ts → lib/ReanimatedModule.native.d.ts} +0 -0
  60. package/lib/types/{ReanimatedModule.windows.d.ts → lib/ReanimatedModule.windows.d.ts} +0 -0
  61. package/lib/types/{ReanimatedModuleCompat.d.ts → lib/ReanimatedModuleCompat.d.ts} +0 -0
  62. package/lib/types/{createAnimatedComponent.d.ts → lib/createAnimatedComponent.d.ts} +0 -0
  63. package/lib/types/{index.d.ts → lib/index.d.ts} +0 -0
  64. package/lib/types/{index.web.d.ts → lib/index.web.d.ts} +0 -0
  65. package/lib/types/{reanimated2 → lib/reanimated2}/Bezier.d.ts +0 -0
  66. package/lib/types/{reanimated2 → lib/reanimated2}/Colors.d.ts +5 -3
  67. package/lib/types/{reanimated2 → lib/reanimated2}/Easing.d.ts +0 -0
  68. package/lib/types/{reanimated2 → lib/reanimated2}/NativeMethods.d.ts +0 -0
  69. package/lib/types/{reanimated2 → lib/reanimated2}/NativeReanimated/NativeReanimated.d.ts +0 -0
  70. package/lib/types/{reanimated2 → lib/reanimated2}/NativeReanimated/index.d.ts +0 -0
  71. package/lib/types/{reanimated2 → lib/reanimated2}/PlatformChecker.d.ts +0 -0
  72. package/lib/types/{reanimated2 → lib/reanimated2}/PropAdapters.d.ts +0 -0
  73. package/lib/types/{reanimated2 → lib/reanimated2}/UpdateProps.d.ts +0 -0
  74. package/lib/types/{reanimated2 → lib/reanimated2}/ViewDescriptorsSet.d.ts +0 -0
  75. package/lib/types/{reanimated2 → lib/reanimated2}/WorkletEventHandler.d.ts +0 -0
  76. package/lib/types/{reanimated2 → lib/reanimated2}/__mocks__/MutableValue.d.ts +0 -0
  77. package/lib/types/{reanimated2 → lib/reanimated2}/__mocks__/NativeReanimated.d.ts +0 -0
  78. package/lib/types/{reanimated2 → lib/reanimated2}/animation/commonTypes.d.ts +0 -0
  79. package/lib/types/{reanimated2 → lib/reanimated2}/animation/decay.d.ts +0 -0
  80. package/lib/types/{reanimated2 → lib/reanimated2}/animation/delay.d.ts +0 -0
  81. package/lib/types/{reanimated2 → lib/reanimated2}/animation/index.d.ts +0 -0
  82. package/lib/types/{reanimated2 → lib/reanimated2}/animation/repeat.d.ts +0 -0
  83. package/lib/types/{reanimated2 → lib/reanimated2}/animation/sequence.d.ts +0 -0
  84. package/lib/types/{reanimated2 → lib/reanimated2}/animation/spring.d.ts +0 -0
  85. package/lib/types/{reanimated2 → lib/reanimated2}/animation/styleAnimation.d.ts +0 -0
  86. package/lib/types/{reanimated2 → lib/reanimated2}/animation/timing.d.ts +0 -0
  87. package/lib/types/{reanimated2 → lib/reanimated2}/animation/util.d.ts +0 -0
  88. package/lib/types/{reanimated2 → lib/reanimated2}/commonTypes.d.ts +0 -0
  89. package/lib/types/{reanimated2 → lib/reanimated2}/component/FlatList.d.ts +0 -0
  90. package/lib/types/{reanimated2 → lib/reanimated2}/component/Image.d.ts +0 -0
  91. package/lib/types/{reanimated2 → lib/reanimated2}/component/ScrollView.d.ts +0 -0
  92. package/lib/types/{reanimated2 → lib/reanimated2}/component/Text.d.ts +0 -0
  93. package/lib/types/{reanimated2 → lib/reanimated2}/component/View.d.ts +0 -0
  94. package/lib/types/{reanimated2 → lib/reanimated2}/core.d.ts +0 -0
  95. package/lib/types/{reanimated2 → lib/reanimated2}/frameCallback/FrameCallbackRegistryJS.d.ts +0 -0
  96. package/lib/types/{reanimated2 → lib/reanimated2}/frameCallback/FrameCallbackRegistryUI.d.ts +0 -0
  97. package/lib/types/{reanimated2 → lib/reanimated2}/hook/Hooks.d.ts +0 -0
  98. package/lib/types/{reanimated2 → lib/reanimated2}/hook/commonTypes.d.ts +0 -0
  99. package/lib/types/{reanimated2 → lib/reanimated2}/hook/index.d.ts +0 -0
  100. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useAnimatedGestureHandler.d.ts +0 -0
  101. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useAnimatedKeyboard.d.ts +0 -0
  102. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useAnimatedReaction.d.ts +0 -0
  103. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useAnimatedRef.d.ts +0 -0
  104. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useAnimatedScrollHandler.d.ts +0 -0
  105. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useAnimatedSensor.d.ts +0 -0
  106. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useAnimatedStyle.d.ts +0 -0
  107. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useDerivedValue.d.ts +0 -0
  108. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useFrameCallback.d.ts +0 -0
  109. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useScrollViewOffset.d.ts +0 -0
  110. package/lib/types/{reanimated2 → lib/reanimated2}/hook/useSharedValue.d.ts +0 -0
  111. package/lib/types/{reanimated2 → lib/reanimated2}/hook/utils.d.ts +0 -0
  112. package/lib/types/{reanimated2 → lib/reanimated2}/index.d.ts +0 -0
  113. package/lib/types/{reanimated2 → lib/reanimated2}/interpolateColor.d.ts +8 -2
  114. package/lib/types/{reanimated2 → lib/reanimated2}/interpolation.d.ts +0 -0
  115. package/lib/types/{reanimated2 → lib/reanimated2}/jestUtils.d.ts +0 -0
  116. package/lib/types/{reanimated2 → lib/reanimated2}/js-reanimated/JSReanimated.d.ts +0 -0
  117. package/lib/types/{reanimated2 → lib/reanimated2}/js-reanimated/Mapper.d.ts +0 -0
  118. package/lib/types/{reanimated2 → lib/reanimated2}/js-reanimated/MapperRegistry.d.ts +0 -0
  119. package/lib/types/{reanimated2 → lib/reanimated2}/js-reanimated/MutableValue.d.ts +0 -0
  120. package/lib/types/{reanimated2 → lib/reanimated2}/js-reanimated/commonTypes.d.ts +0 -0
  121. package/lib/types/{reanimated2 → lib/reanimated2}/js-reanimated/global.d.ts +0 -0
  122. package/lib/types/{reanimated2 → lib/reanimated2}/js-reanimated/index.d.ts +0 -0
  123. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/LayoutAnimationRepository.d.ts +0 -0
  124. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/animationBuilder/BaseAnimationBuilder.d.ts +0 -0
  125. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +0 -0
  126. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/animationBuilder/Keyframe.d.ts +0 -0
  127. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/animationBuilder/commonTypes.d.ts +4 -0
  128. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/animationBuilder/index.d.ts +0 -0
  129. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Bounce.d.ts +0 -0
  130. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Default.d.ts +0 -0
  131. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Fade.d.ts +0 -0
  132. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Flip.d.ts +0 -0
  133. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Lightspeed.d.ts +0 -0
  134. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Pinwheel.d.ts +0 -0
  135. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Roll.d.ts +0 -0
  136. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Rotate.d.ts +0 -0
  137. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Slide.d.ts +0 -0
  138. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Stretch.d.ts +0 -0
  139. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/Zoom.d.ts +0 -0
  140. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultAnimations/index.d.ts +0 -0
  141. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +0 -0
  142. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +0 -0
  143. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultTransitions/FadingTransition.d.ts +0 -0
  144. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +0 -0
  145. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultTransitions/LinearTransition.d.ts +0 -0
  146. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +0 -0
  147. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/defaultTransitions/index.d.ts +0 -0
  148. package/lib/types/{reanimated2 → lib/reanimated2}/layoutReanimation/index.d.ts +0 -0
  149. package/lib/types/{reanimated2 → lib/reanimated2}/mock.d.ts +0 -0
  150. package/lib/types/{reanimated2 → lib/reanimated2}/platform-specific/RNRenderer.d.ts +0 -0
  151. package/lib/types/{reanimated2 → lib/reanimated2}/platform-specific/RNRenderer.web.d.ts +0 -0
  152. package/lib/types/lib/reanimated2/platform-specific/checkVersion.d.ts +4 -0
  153. package/lib/types/lib/reanimated2/platform-specific/checkVersion.web.d.ts +5 -0
  154. package/lib/types/{reanimated2 → lib/reanimated2}/utils.d.ts +0 -0
  155. package/lib/types/{setAndForwardRef.d.ts → lib/setAndForwardRef.d.ts} +0 -0
  156. package/package.json +8 -8
  157. package/plugin.js +7 -3
  158. package/react-native-reanimated.d.ts +11 -2
  159. package/scripts/reanimated_utils.rb +7 -3
  160. package/src/createAnimatedComponent.tsx +7 -0
  161. package/src/reanimated2/Colors.ts +38 -11
  162. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +4 -0
  163. package/src/reanimated2/animation/util.ts +26 -15
  164. package/src/reanimated2/globals.d.ts +2 -0
  165. package/src/reanimated2/interpolateColor.ts +105 -21
  166. package/src/reanimated2/jestUtils.ts +14 -6
  167. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +4 -0
  168. package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +16 -19
  169. package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +14 -11
  170. package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +21 -11
  171. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -11
  172. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +36 -19
  173. package/src/reanimated2/platform-specific/checkVersion.ts +28 -0
  174. package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
  175. package/android/react-native-reanimated-66-hermes.aar +0 -0
  176. package/android/react-native-reanimated-66-jsc.aar +0 -0
@@ -1,5 +1,6 @@
1
1
  import com.android.Version
2
2
  import org.apache.tools.ant.filters.ReplaceTokens
3
+ import org.apache.tools.ant.taskdefs.condition.Os
3
4
  import groovy.json.JsonSlurper
4
5
  import java.nio.file.Paths
5
6
 
@@ -43,10 +44,7 @@ def safeExtGet(prop, fallback) {
43
44
  }
44
45
 
45
46
  def safeAppExtGet(prop, fallback) {
46
- if (findProject(':app') == null) {
47
- return fallback
48
- }
49
- def appProject = project(':app')
47
+ def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
50
48
  appProject?.ext?.has(prop) ? appProject.ext.get(prop) : fallback
51
49
  }
52
50
 
@@ -67,16 +65,20 @@ def resolveClientSideBuild() {
67
65
  return property("clientSideBuild") == "true"
68
66
  }
69
67
 
70
- if (isDeveloperMode()) {
68
+ if (isDeveloperMode() || isPackageBuild()) {
71
69
  return false
72
70
  }
73
71
 
74
72
  return true
75
73
  }
76
74
 
75
+ def isPackageBuild() {
76
+ return System.getenv("REANIMATED_PACKAGE_BUILD") == "1"
77
+ }
78
+
77
79
  def isDeveloperMode() {
78
80
  // developer mode, to run Example app
79
- return safeAppExtGet("isReanimatedExampleApp", false) || System.getenv("REANIMATED_PACKAGE_BUILD") == "1"
81
+ return safeAppExtGet("isReanimatedExampleApp", false)
80
82
  }
81
83
 
82
84
  def isNewArchitectureEnabled() {
@@ -93,7 +95,7 @@ def resolveReactNativeDirectory() {
93
95
  return file(reactNativeLocation)
94
96
  }
95
97
 
96
- if (isDeveloperMode()) {
98
+ if (isDeveloperMode() || isPackageBuild()) {
97
99
  return file("$projectDir/../${getPlaygroundAppName()}/node_modules/react-native")
98
100
  }
99
101
 
@@ -109,7 +111,7 @@ def resolveReactNativeDirectory() {
109
111
  return reactNativeFromNodeModulesWithReanimated
110
112
  }
111
113
 
112
- throw new Exception(
114
+ throw new GradleException(
113
115
  "[Reanimated] Unable to resolve react-native location in " +
114
116
  "node_modules. You should project extension property (in app/build.gradle) " +
115
117
  "`REACT_NATIVE_NODE_MODULES_DIR` with path to react-native."
@@ -171,18 +173,28 @@ def checkNoMultipleInstances() {
171
173
  "https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/" +
172
174
  "troubleshooting#multiple-versions-of-reanimated-were-detected \n\nConflict " +
173
175
  "between: \n" + parsedLocation + "\n";
174
- throw new Exception(exceptionMessage)
176
+ throw new GradleException(exceptionMessage)
175
177
  }
176
178
  }
177
179
 
178
180
  def getReanimatedVersion() {
179
181
  def inputFile = file(projectDir.path + '/../package.json')
180
182
  def json = new JsonSlurper().parseText(inputFile.text)
181
- String reanimatedVersion = json.version
182
- def (major, minor, patch) = reanimatedVersion.tokenize('.')
183
+ return json.version
184
+ }
185
+
186
+ def getReanimatedMajorVersion() {
187
+ def (major, minor, patch) = getReanimatedVersion().tokenize('.')
183
188
  return major.toInteger()
184
189
  }
185
190
 
191
+ def toPlatformFileString(String path) {
192
+ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
193
+ path = path.replace(File.separatorChar, '/' as char)
194
+ }
195
+ return path
196
+ }
197
+
186
198
  boolean CLIENT_SIDE_BUILD = resolveClientSideBuild()
187
199
  if (CLIENT_SIDE_BUILD) {
188
200
  configurations.maybeCreate("default")
@@ -193,15 +205,18 @@ def reactNativeRootDir = resolveReactNativeDirectory()
193
205
  def reactProperties = new Properties()
194
206
  file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
195
207
 
208
+ def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME")
209
+ def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.startsWith("0.0.0-") ? 1000 : REACT_NATIVE_VERSION.split("\\.")[1].toInteger()
210
+ def REANIMATED_PACKAGE_BUILD = System.getenv("REANIMATED_PACKAGE_BUILD")
211
+ def REANIMATED_VERSION = getReanimatedVersion()
212
+ def REANIMATED_MAJOR_VERSION = getReanimatedMajorVersion()
213
+
214
+ // for React Native <= 0.70
196
215
  def BOOST_VERSION = reactProperties.getProperty("BOOST_VERSION")
197
216
  def DOUBLE_CONVERSION_VERSION = reactProperties.getProperty("DOUBLE_CONVERSION_VERSION")
198
217
  def FOLLY_VERSION = reactProperties.getProperty("FOLLY_VERSION")
199
218
  def GLOG_VERSION = reactProperties.getProperty("GLOG_VERSION")
200
- def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME")
201
- def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.split("\\.")[1].toInteger()
202
219
  def FBJNI_VERSION = "0.3.0"
203
- def REANIMATED_PACKAGE_BUILD = System.getenv("REANIMATED_PACKAGE_BUILD")
204
- def REANIMATED_MAJOR_VERSION = getReanimatedVersion()
205
220
 
206
221
  // We download various C++ open-source dependencies into downloads.
207
222
  // We then copy both the downloaded code and our custom makefiles and headers into third-party-ndk.
@@ -214,22 +229,26 @@ def thirdPartyNdkDir = new File("$buildDir/third-party-ndk")
214
229
  def reactNativeThirdParty = new File("$reactNativeRootDir/ReactAndroid/src/main/jni/third-party")
215
230
  def reactNativeAndroidDownloadDir = new File("$reactNativeRootDir/ReactAndroid/build/downloads")
216
231
 
217
- def _stackProtectorFlag = true
218
-
219
232
  def JS_RUNTIME = {
220
- // Returns the js runtime explicitly requested in the environment variable
233
+ // Override JS runtime with environment variable
221
234
  if (System.getenv("JS_RUNTIME")) {
222
235
  return System.getenv("JS_RUNTIME")
223
236
  }
224
237
 
225
- // Detect js runtime from project setup
226
- def defaultRuntimeType = "jsc";
238
+ // Enable V8 runtime if react-native-v8 is installed
227
239
  def v8Project = rootProject.getSubprojects().find { project -> project.name == "react-native-v8" }
228
240
  if (v8Project != null) {
229
241
  return "v8"
230
242
  }
231
- def appProject = findProject(":app") ? project(":app") : null
232
- return appProject?.ext?.react?.enableHermes ? "hermes" : defaultRuntimeType
243
+
244
+ // Check if Hermes is enabled in app setup
245
+ def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
246
+ if ((REACT_NATIVE_MINOR_VERSION >= 71 && appProject?.hermesEnabled?.toBoolean()) || appProject?.ext?.react?.enableHermes?.toBoolean()) {
247
+ return "hermes"
248
+ }
249
+
250
+ // Use JavaScriptCore (JSC) by default
251
+ return "jsc"
233
252
  }.call()
234
253
 
235
254
  def jsRuntimeDir = {
@@ -303,7 +322,7 @@ def shouldBuildFromSource(aar, jsRuntimeName) { // Reanimated2 only
303
322
  if (jsRuntimeName == "v8") {
304
323
  return true
305
324
  }
306
- else if (isDeveloperMode()) {
325
+ else if (isDeveloperMode() || isPackageBuild()) {
307
326
  // Example app
308
327
  return true
309
328
  }
@@ -390,25 +409,6 @@ if (!BUILD_FROM_SOURCE && !isNewArchitectureEnabled()) { // Reanimated2 only
390
409
  if (!BUILD_FROM_SOURCE) {
391
410
  return
392
411
  }
393
- // You need to have following folders in this directory:
394
- // - boost_1_63_0
395
- // - double-conversion-1.1.6
396
- // - folly-deprecate-dynamic-initializer
397
- // - glog-0.3.5
398
- def dependenciesPath = System.getenv("REACT_NATIVE_DEPENDENCIES")
399
-
400
- // The Boost library is a very large download (>100MB).
401
- // If Boost is already present on your system, define the REACT_NATIVE_BOOST_PATH env variable
402
- // and the build will use that.
403
- def boostPath = dependenciesPath ?: System.getenv("REACT_NATIVE_BOOST_PATH")
404
-
405
- def follyReplaceContent = '''
406
- ssize_t r;
407
- do {
408
- r = open(name, flags, mode);
409
- } while (r == -1 && errno == EINTR);
410
- return r;
411
- '''
412
412
 
413
413
  buildscript {
414
414
  repositories {
@@ -419,7 +419,7 @@ buildscript {
419
419
  }
420
420
  }
421
421
  dependencies {
422
- classpath "com.android.tools.build:gradle:7.3.0"
422
+ classpath "com.android.tools.build:gradle:7.3.1"
423
423
  classpath "de.undercouch:gradle-download-task:5.0.1"
424
424
  classpath "com.diffplug.spotless:spotless-plugin-gradle:6.11.0"
425
425
  }
@@ -435,8 +435,17 @@ apply plugin: "de.undercouch.download"
435
435
 
436
436
  android {
437
437
  compileSdkVersion safeExtGet("compileSdkVersion", 30)
438
+ if (REACT_NATIVE_MINOR_VERSION >= 71) {
439
+ buildFeatures {
440
+ prefab true
441
+ }
442
+ }
438
443
  defaultConfig {
439
- minSdkVersion safeExtGet("minSdkVersion", 16)
444
+ if (REACT_NATIVE_MINOR_VERSION >= 71 && isPackageBuild()) {
445
+ minSdkVersion safeExtGet("minSdkVersion", 21)
446
+ } else {
447
+ minSdkVersion safeExtGet("minSdkVersion", 16)
448
+ }
440
449
  targetSdkVersion safeExtGet("targetSdkVersion", 30)
441
450
  versionCode 1
442
451
  versionName "1.0"
@@ -446,16 +455,16 @@ android {
446
455
  arguments "-DANDROID_STL=c++_shared",
447
456
  "-DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION}",
448
457
  "-DANDROID_TOOLCHAIN=clang",
449
- "-DBOOST_VERSION=${BOOST_VERSION}",
450
- "-DREACT_NATIVE_DIR=${reactNativeRootDir.path}",
458
+ REACT_NATIVE_MINOR_VERSION < 71 ? "-DBOOST_VERSION=${BOOST_VERSION}" : "-DBOOST_VERSION=",
459
+ "-DREACT_NATIVE_DIR=${toPlatformFileString(reactNativeRootDir.path)}",
451
460
  "-DJS_RUNTIME=${JS_RUNTIME}",
452
461
  "-DJS_RUNTIME_DIR=${jsRuntimeDir}",
453
462
  "-DCLIENT_SIDE_BUILD=${CLIENT_SIDE_BUILD}",
454
463
  "-DIS_NEW_ARCHITECTURE_ENABLED=${isNewArchitectureEnabled()}",
455
464
  "-DPLAYGROUND_APP_NAME=${getPlaygroundAppName()}",
456
- "-DREANIMATED_PACKAGE_BUILD=${REANIMATED_PACKAGE_BUILD}"
465
+ "-DREANIMATED_PACKAGE_BUILD=${REANIMATED_PACKAGE_BUILD}",
466
+ "-DREANIMATED_VERSION=${REANIMATED_VERSION}"
457
467
  abiFilters (*reactNativeArchitectures())
458
- _stackProtectorFlag ? (cppFlags("-fstack-protector-all")) : null
459
468
  }
460
469
  }
461
470
 
@@ -504,7 +513,10 @@ android {
504
513
  "**/libglog.so",
505
514
  "**/libhermes.so",
506
515
  "**/libhermes-executor-debug.so",
516
+ "**/libhermes_executor.so",
507
517
  "**/libreactnativejni.so",
518
+ "**/libturbomodulejsijni.so",
519
+ "**/libreact_nativemodule_core.so",
508
520
  "**/libjscexecutor.so",
509
521
  "**/libv8executor.so",
510
522
  ]
@@ -553,6 +565,13 @@ android {
553
565
  srcDirs += "src/reactNativeVersionPatch/UIImplementation/latest"
554
566
  }
555
567
 
568
+ // ReanimatedUIManager & ReanimatedUIImplementation
569
+ if (REACT_NATIVE_MINOR_VERSION <= 70) {
570
+ srcDirs += "src/reactNativeVersionPatch/ReanimatedUIManager/70"
571
+ } else {
572
+ srcDirs += "src/reactNativeVersionPatch/ReanimatedUIManager/latest"
573
+ }
574
+
556
575
  // nativeHierarchyManager
557
576
  if (REACT_NATIVE_MINOR_VERSION <= 62) {
558
577
  srcDirs += "src/reactNativeVersionPatch/nativeHierarchyManager/62"
@@ -573,7 +592,7 @@ def assertNoMultipleInstances = task assertNoMultipleInstancesTask {
573
592
  def assertNoReanimated2WithNewArchitecture = task assertNoReanimated2WithNewArchitectureTask {
574
593
  onlyIf { isNewArchitectureEnabled() && REANIMATED_MAJOR_VERSION == 2 }
575
594
  doFirst {
576
- throw new Exception(
595
+ throw new GradleException(
577
596
  "\n[react-native-reanimated] Reanimated 2.x does not support Fabric. " +
578
597
  "Please upgrade to 3.x to use Reanimated with the New Architecture. " +
579
598
  "For details, see https://blog.swmansion.com/announcing-reanimated-3-16167428c5f7"
@@ -581,8 +600,19 @@ def assertNoReanimated2WithNewArchitecture = task assertNoReanimated2WithNewArch
581
600
  }
582
601
  }
583
602
 
603
+ def assertLatestReactNativeWithNewArchitecture = task assertLatestReactNativeWithNewArchitectureTask {
604
+ onlyIf { isNewArchitectureEnabled() && REANIMATED_MAJOR_VERSION == 3 && REACT_NATIVE_MINOR_VERSION < 71 }
605
+ doFirst {
606
+ throw new GradleException(
607
+ "\n[react-native-reanimated] Reanimated " + REANIMATED_VERSION + " supports the New Architecture " +
608
+ "only on the latest minor release of React Native. Please upgrade to React Native 0.71.0+ " +
609
+ "or downgrade to an older version of Reanimated v3."
610
+ )
611
+ }
612
+ }
613
+
584
614
  tasks.preBuild {
585
- dependsOn assertNoMultipleInstances, assertNoReanimated2WithNewArchitecture
615
+ dependsOn assertNoMultipleInstances, assertNoReanimated2WithNewArchitecture, assertLatestReactNativeWithNewArchitecture
586
616
  }
587
617
 
588
618
  task cleanCmakeCache() {
@@ -624,153 +654,17 @@ def resolveTaskFactory(String taskName, String artifactLocalName, File reactNati
624
654
  }
625
655
  }
626
656
 
627
- Task resolveBoost = resolveTaskFactory("resolveBoost", "boost_${BOOST_VERSION}.tar.gz", reactNativeAndroidDownloadDir, downloadsDir)
628
- Task resolveDoubleConversion = resolveTaskFactory(
629
- "resolveDoubleConversion",
630
- "double-conversion-${DOUBLE_CONVERSION_VERSION}.tar.gz",
631
- reactNativeAndroidDownloadDir,
632
- downloadsDir
633
- )
634
- Task resolveFolly = resolveTaskFactory("resolveFolly", "folly-${FOLLY_VERSION}.tar.gz", reactNativeAndroidDownloadDir, downloadsDir)
635
- Task resolveGlog = resolveTaskFactory("resolveGlog", "glog-${GLOG_VERSION}.tar.gz", reactNativeAndroidDownloadDir, downloadsDir)
636
-
637
- if (isNewArchitectureEnabled()) {
638
- def reactNativeAndroidProject = findProject(":ReactAndroid")
639
- if (reactNativeAndroidProject != null) {
640
- reactNativeAndroidProject.afterEvaluate {
641
- def resolveTasks = [resolveBoost, resolveGlog, resolveDoubleConversion, resolveFolly]
642
- resolveTasks.forEach({ task ->
643
- String reactAndroidDownloadTaskName = "download" + task.name.replace("resolve", "")
644
- def reactAndroidDownloadTask = reactNativeAndroidProject.getTasks().findByName(reactAndroidDownloadTaskName)
645
- if (reactAndroidDownloadTask != null) {
646
- task.dependsOn(reactAndroidDownloadTask)
647
- } else {
648
- logger.warn("[Reanimated] Failed to find task named `$reactAndroidDownloadTaskName` in `:ReactAndroid` project." +
649
- " Explicit dependency between it and $task.name task can not be set.")
650
- }
651
- })
652
- }
653
- } else {
654
- throw new GradleScriptException("[Reanimated] Failed to find `:ReactAndroid` project. Explicit dependency between download tasks can not be set.")
655
- }
656
- }
657
-
658
- task downloadBoost(dependsOn: resolveBoost, type: Download) {
659
- def transformedVersion = BOOST_VERSION.replace("_", ".")
660
- def artifactLocalName = "boost_${BOOST_VERSION}.tar.gz"
661
- def srcUrl = "https://boostorg.jfrog.io/artifactory/main/release/${transformedVersion}/source/boost_${BOOST_VERSION}.tar.gz"
662
- if (REACT_NATIVE_MINOR_VERSION < 69) {
663
- srcUrl = "https://github.com/react-native-community/boost-for-react-native/releases/download/v${transformedVersion}-0/boost_${BOOST_VERSION}.tar.gz"
664
- }
665
- src(srcUrl)
666
- onlyIfNewer(true)
667
- overwrite(false)
668
- dest(new File(downloadsDir, artifactLocalName))
669
- }
670
-
671
- task prepareBoost(dependsOn: boostPath ? [] : [downloadBoost], type: Copy) {
672
- from(boostPath ?: tarTree(resources.gzip(downloadBoost.dest)))
673
- from("$reactNativeThirdParty/boost/Android.mk")
674
- include("Android.mk", "boost_${BOOST_VERSION}/boost/**/*.hpp", "boost/boost/**/*.hpp")
675
- includeEmptyDirs = false
676
- into("$thirdPartyNdkDir/boost")
677
- doLast {
678
- file("$thirdPartyNdkDir/boost/boost").renameTo("$thirdPartyNdkDir/boost/boost_${BOOST_VERSION}")
679
- }
680
- }
681
-
682
- task downloadDoubleConversion(dependsOn: resolveDoubleConversion, type: Download) {
683
- src("https://github.com/google/double-conversion/archive/v${DOUBLE_CONVERSION_VERSION}.tar.gz")
684
- onlyIfNewer(true)
685
- overwrite(false)
686
- dest(new File(downloadsDir, "double-conversion-${DOUBLE_CONVERSION_VERSION}.tar.gz"))
687
- }
688
-
689
- task prepareDoubleConversion(dependsOn: dependenciesPath ? [] : [downloadDoubleConversion], type: Copy) {
690
- from(dependenciesPath ?: tarTree(downloadDoubleConversion.dest))
691
- from("$reactNativeThirdParty/double-conversion/Android.mk")
692
- include("double-conversion-${DOUBLE_CONVERSION_VERSION}/src/**/*", "Android.mk")
693
- filesMatching("*/src/**/*", { fname -> fname.path = "double-conversion/${fname.name}" })
694
- includeEmptyDirs = false
695
- into("$thirdPartyNdkDir/double-conversion")
696
- }
697
-
698
- task downloadFolly(dependsOn: resolveFolly, type: Download) {
699
- src("https://github.com/facebook/folly/archive/v${FOLLY_VERSION}.tar.gz")
700
- onlyIfNewer(true)
701
- overwrite(false)
702
- dest(new File(downloadsDir, "folly-${FOLLY_VERSION}.tar.gz"))
703
- }
704
-
705
- task prepareFolly(dependsOn: dependenciesPath ? [] : [downloadFolly], type: Copy) {
706
- from(dependenciesPath ?: tarTree(downloadFolly.dest))
707
- from("$reactNativeThirdParty/folly/Android.mk")
708
- include("folly-${FOLLY_VERSION}/folly/**/*", "Android.mk")
709
- eachFile { fname -> fname.path = (fname.path - "folly-${FOLLY_VERSION}/") }
710
- // Fixes problem with Folly failing to build on certain systems. See
711
- // https://github.com/software-mansion/react-native-reanimated/issues/1024
712
- filter { line -> line.replaceAll("return int\\(wrapNoInt\\(open, name, flags, mode\\)\\);", follyReplaceContent) }
713
- includeEmptyDirs = false
714
- into("$thirdPartyNdkDir/folly")
715
- }
716
-
717
- task downloadGlog(dependsOn: resolveGlog, type: Download) {
718
- src("https://github.com/google/glog/archive/v${GLOG_VERSION}.tar.gz")
719
- onlyIfNewer(true)
720
- overwrite(false)
721
- dest(new File(downloadsDir, "glog-${GLOG_VERSION}.tar.gz"))
722
- }
723
-
724
- // Prepare glog sources to be compiled, this task will perform steps that normally should've been
725
- // executed by automake. This way we can avoid dependencies on make/automake
726
- task prepareGlog(dependsOn: dependenciesPath ? [] : [downloadGlog], type: Copy) {
727
- duplicatesStrategy = "include"
728
- from(dependenciesPath ?: tarTree(downloadGlog.dest))
729
- from("$reactNativeThirdParty/glog/")
730
- include("glog-${GLOG_VERSION}/src/**/*", "Android.mk", "config.h")
731
- includeEmptyDirs = false
732
- filesMatching("**/*.h.in") {
733
- filter(ReplaceTokens, tokens: [
734
- ac_cv_have_unistd_h : "1",
735
- ac_cv_have_stdint_h : "1",
736
- ac_cv_have_systypes_h : "1",
737
- ac_cv_have_inttypes_h : "1",
738
- ac_cv_have_libgflags : "0",
739
- ac_google_start_namespace : "namespace google {",
740
- ac_cv_have_uint16_t : "1",
741
- ac_cv_have_u_int16_t : "1",
742
- ac_cv_have___uint16 : "0",
743
- ac_google_end_namespace : "}",
744
- ac_cv_have___builtin_expect : "1",
745
- ac_google_namespace : "google",
746
- ac_cv___attribute___noinline : "__attribute__ ((noinline))",
747
- ac_cv___attribute___noreturn : "__attribute__ ((noreturn))",
748
- ac_cv___attribute___printf_4_5: "__attribute__((__format__ (__printf__, 4, 5)))"
749
- ])
750
- it.path = (it.name - ".in")
751
- }
752
- into("$thirdPartyNdkDir/glog")
753
-
754
- doLast {
755
- copy {
756
- from(fileTree(dir: "$thirdPartyNdkDir/glog", includes: ["stl_logging.h", "logging.h", "raw_logging.h", "vlog_is_on.h", "**/src/glog/log_severity.h"]).files)
757
- includeEmptyDirs = false
758
- into("$thirdPartyNdkDir/glog/exported/glog")
759
- }
760
- }
761
- }
762
-
763
657
  /*
764
658
  Reanimated includes "hermes/hermes.h" header file in `NativeProxy.cpp`.
765
659
  Previously, we used header files from `hermes-engine` package in `node_modules`.
766
- Starting from React Native 0.69, Hermes is no longer distributed as package on NPM.
660
+ In React Native 0.69 and 0.70, Hermes is no longer distributed as package on NPM.
767
661
  On the new architecture, Hermes is downloaded from GitHub and then compiled from sources.
768
662
  However, on the old architecture, we need to download Hermes header files on our own
769
663
  as well as unzip Hermes AAR in order to obtain `libhermes.so` shared library.
770
664
  For more details, see https://reactnative.dev/architecture/bundled-hermes
771
665
  or https://github.com/reactwg/react-native-new-architecture/discussions/4
772
666
  */
773
- if (REACT_NATIVE_MINOR_VERSION >= 69 && !isNewArchitectureEnabled()) {
667
+ if (REACT_NATIVE_MINOR_VERSION in [69, 70] && !isNewArchitectureEnabled()) {
774
668
  // copied from `react-native/ReactAndroid/hermes-engine/build.gradle`
775
669
 
776
670
  def downloadDir = customDownloadsDir ? new File(customDownloadsDir) : new File(reactNativeRootDir, "sdks/download")
@@ -806,110 +700,306 @@ if (REACT_NATIVE_MINOR_VERSION >= 69 && !isNewArchitectureEnabled()) {
806
700
  }
807
701
  }
808
702
 
809
- task prepareHermes() {
810
- if (REACT_NATIVE_MINOR_VERSION >= 69) {
811
- if (!isNewArchitectureEnabled()) {
812
- dependsOn(unzipHermes)
703
+ if (REACT_NATIVE_MINOR_VERSION < 71) {
704
+ // You need to have following folders in this directory:
705
+ // - boost_1_63_0
706
+ // - double-conversion-1.1.6
707
+ // - folly-deprecate-dynamic-initializer
708
+ // - glog-0.3.5
709
+ def dependenciesPath = System.getenv("REACT_NATIVE_DEPENDENCIES")
710
+
711
+ // The Boost library is a very large download (>100MB).
712
+ // If Boost is already present on your system, define the REACT_NATIVE_BOOST_PATH env variable
713
+ // and the build will use that.
714
+ def boostPath = dependenciesPath ?: System.getenv("REACT_NATIVE_BOOST_PATH")
715
+
716
+ def follyReplaceContent = '''
717
+ ssize_t r;
718
+ do {
719
+ r = open(name, flags, mode);
720
+ } while (r == -1 && errno == EINTR);
721
+ return r;
722
+ '''
723
+
724
+ Task resolveBoost = resolveTaskFactory("resolveBoost", "boost_${BOOST_VERSION}.tar.gz", reactNativeAndroidDownloadDir, downloadsDir)
725
+ Task resolveDoubleConversion = resolveTaskFactory(
726
+ "resolveDoubleConversion",
727
+ "double-conversion-${DOUBLE_CONVERSION_VERSION}.tar.gz",
728
+ reactNativeAndroidDownloadDir,
729
+ downloadsDir
730
+ )
731
+ Task resolveFolly = resolveTaskFactory("resolveFolly", "folly-${FOLLY_VERSION}.tar.gz", reactNativeAndroidDownloadDir, downloadsDir)
732
+ Task resolveGlog = resolveTaskFactory("resolveGlog", "glog-${GLOG_VERSION}.tar.gz", reactNativeAndroidDownloadDir, downloadsDir)
733
+
734
+ if (isNewArchitectureEnabled()) {
735
+ def reactNativeAndroidProject = findProject(":ReactAndroid")
736
+ if (reactNativeAndroidProject != null) {
737
+ reactNativeAndroidProject.afterEvaluate {
738
+ def resolveTasks = [resolveBoost, resolveGlog, resolveDoubleConversion, resolveFolly]
739
+ resolveTasks.forEach({ task ->
740
+ String reactAndroidDownloadTaskName = "download" + task.name.replace("resolve", "")
741
+ def reactAndroidDownloadTask = reactNativeAndroidProject.getTasks().findByName(reactAndroidDownloadTaskName)
742
+ if (reactAndroidDownloadTask != null) {
743
+ task.dependsOn(reactAndroidDownloadTask)
744
+ } else {
745
+ logger.warn("[Reanimated] Failed to find task named `$reactAndroidDownloadTaskName` in `:ReactAndroid` project." +
746
+ " Explicit dependency between it and $task.name task can not be set.")
747
+ }
748
+ })
749
+ }
750
+ } else {
751
+ throw new GradleException("[Reanimated] Failed to find `:ReactAndroid` project. Explicit dependency between download tasks can not be set.")
752
+ }
753
+ }
754
+
755
+ task downloadBoost(dependsOn: resolveBoost, type: Download) {
756
+ def transformedVersion = BOOST_VERSION.replace("_", ".")
757
+ def artifactLocalName = "boost_${BOOST_VERSION}.tar.gz"
758
+ def srcUrl = "https://boostorg.jfrog.io/artifactory/main/release/${transformedVersion}/source/boost_${BOOST_VERSION}.tar.gz"
759
+ if (REACT_NATIVE_MINOR_VERSION < 69) {
760
+ srcUrl = "https://github.com/react-native-community/boost-for-react-native/releases/download/v${transformedVersion}-0/boost_${BOOST_VERSION}.tar.gz"
813
761
  }
762
+ src(srcUrl)
763
+ onlyIfNewer(true)
764
+ overwrite(false)
765
+ dest(new File(downloadsDir, artifactLocalName))
766
+ }
814
767
 
768
+ task prepareBoost(dependsOn: boostPath ? [] : [downloadBoost], type: Copy) {
769
+ from(boostPath ?: tarTree(resources.gzip(downloadBoost.dest)))
770
+ from("$reactNativeThirdParty/boost/Android.mk")
771
+ include("Android.mk", "boost_${BOOST_VERSION}/boost/**/*.hpp", "boost/boost/**/*.hpp")
772
+ includeEmptyDirs = false
773
+ into("$thirdPartyNdkDir/boost")
815
774
  doLast {
816
- // e.g. hermes-engine-0.70.0-rc.1-debug.aar
817
- def hermesAAR = file(
818
- "$reactNativeRootDir/android/com/facebook/react/hermes-engine/" +
819
- "${REACT_NATIVE_VERSION}/hermes-engine-${REACT_NATIVE_VERSION}-" +
820
- "${resolveBuildType()}.aar"
821
- )
822
- if (!hermesAAR.exists()) {
823
- throw new GradleScriptException("Could not find hermes-engine AAR", null)
824
- }
775
+ file("$thirdPartyNdkDir/boost/boost").renameTo("$thirdPartyNdkDir/boost/boost_${BOOST_VERSION}")
776
+ }
777
+ }
778
+
779
+ task downloadDoubleConversion(dependsOn: resolveDoubleConversion, type: Download) {
780
+ src("https://github.com/google/double-conversion/archive/v${DOUBLE_CONVERSION_VERSION}.tar.gz")
781
+ onlyIfNewer(true)
782
+ overwrite(false)
783
+ dest(new File(downloadsDir, "double-conversion-${DOUBLE_CONVERSION_VERSION}.tar.gz"))
784
+ }
785
+
786
+ task prepareDoubleConversion(dependsOn: dependenciesPath ? [] : [downloadDoubleConversion], type: Copy) {
787
+ from(dependenciesPath ?: tarTree(downloadDoubleConversion.dest))
788
+ from("$reactNativeThirdParty/double-conversion/Android.mk")
789
+ include("double-conversion-${DOUBLE_CONVERSION_VERSION}/src/**/*", "Android.mk")
790
+ filesMatching("*/src/**/*", { fname -> fname.path = "double-conversion/${fname.name}" })
791
+ includeEmptyDirs = false
792
+ into("$thirdPartyNdkDir/double-conversion")
793
+ }
825
794
 
826
- def soFiles = zipTree(hermesAAR).matching({ it.include "**/*.so" })
795
+ task downloadFolly(dependsOn: resolveFolly, type: Download) {
796
+ src("https://github.com/facebook/folly/archive/v${FOLLY_VERSION}.tar.gz")
797
+ onlyIfNewer(true)
798
+ overwrite(false)
799
+ dest(new File(downloadsDir, "folly-${FOLLY_VERSION}.tar.gz"))
800
+ }
801
+
802
+ task prepareFolly(dependsOn: dependenciesPath ? [] : [downloadFolly], type: Copy) {
803
+ from(dependenciesPath ?: tarTree(downloadFolly.dest))
804
+ from("$reactNativeThirdParty/folly/Android.mk")
805
+ include("folly-${FOLLY_VERSION}/folly/**/*", "Android.mk")
806
+ eachFile { fname -> fname.path = (fname.path - "folly-${FOLLY_VERSION}/") }
807
+ // Fixes problem with Folly failing to build on certain systems. See
808
+ // https://github.com/software-mansion/react-native-reanimated/issues/1024
809
+ filter { line -> line.replaceAll("return int\\(wrapNoInt\\(open, name, flags, mode\\)\\);", follyReplaceContent) }
810
+ includeEmptyDirs = false
811
+ into("$thirdPartyNdkDir/folly")
812
+ }
813
+
814
+ task downloadGlog(dependsOn: resolveGlog, type: Download) {
815
+ src("https://github.com/google/glog/archive/v${GLOG_VERSION}.tar.gz")
816
+ onlyIfNewer(true)
817
+ overwrite(false)
818
+ dest(new File(downloadsDir, "glog-${GLOG_VERSION}.tar.gz"))
819
+ }
820
+
821
+ // Prepare glog sources to be compiled, this task will perform steps that normally should've been
822
+ // executed by automake. This way we can avoid dependencies on make/automake
823
+ task prepareGlog(dependsOn: dependenciesPath ? [] : [downloadGlog], type: Copy) {
824
+ duplicatesStrategy = "include"
825
+ from(dependenciesPath ?: tarTree(downloadGlog.dest))
826
+ from("$reactNativeThirdParty/glog/")
827
+ include("glog-${GLOG_VERSION}/src/**/*", "Android.mk", "config.h")
828
+ includeEmptyDirs = false
829
+ filesMatching("**/*.h.in") {
830
+ filter(ReplaceTokens, tokens: [
831
+ ac_cv_have_unistd_h : "1",
832
+ ac_cv_have_stdint_h : "1",
833
+ ac_cv_have_systypes_h : "1",
834
+ ac_cv_have_inttypes_h : "1",
835
+ ac_cv_have_libgflags : "0",
836
+ ac_google_start_namespace : "namespace google {",
837
+ ac_cv_have_uint16_t : "1",
838
+ ac_cv_have_u_int16_t : "1",
839
+ ac_cv_have___uint16 : "0",
840
+ ac_google_end_namespace : "}",
841
+ ac_cv_have___builtin_expect : "1",
842
+ ac_google_namespace : "google",
843
+ ac_cv___attribute___noinline : "__attribute__ ((noinline))",
844
+ ac_cv___attribute___noreturn : "__attribute__ ((noreturn))",
845
+ ac_cv___attribute___printf_4_5: "__attribute__((__format__ (__printf__, 4, 5)))"
846
+ ])
847
+ it.path = (it.name - ".in")
848
+ }
849
+ into("$thirdPartyNdkDir/glog")
827
850
 
851
+ doLast {
828
852
  copy {
829
- from soFiles
830
- from "$reactNativeRootDir/ReactAndroid/src/main/jni/first-party/hermes/Android.mk"
831
- into "$thirdPartyNdkDir/hermes"
853
+ from(fileTree(dir: "$thirdPartyNdkDir/glog", includes: ["stl_logging.h", "logging.h", "raw_logging.h", "vlog_is_on.h", "**/src/glog/log_severity.h"]).files)
854
+ includeEmptyDirs = false
855
+ into("$thirdPartyNdkDir/glog/exported/glog")
832
856
  }
833
857
  }
834
- } else {
835
- doLast {
836
- def hermesPackagePath = findNodeModulePath(projectDir, "hermes-engine")
837
- if (!hermesPackagePath) {
838
- throw new GradleScriptException("Could not find the hermes-engine npm package", null)
858
+ }
859
+
860
+ task prepareHermes {
861
+ if (REACT_NATIVE_MINOR_VERSION >= 69) {
862
+ if (!isNewArchitectureEnabled()) {
863
+ dependsOn(unzipHermes)
839
864
  }
840
865
 
841
- def hermesAAR = file("$hermesPackagePath/android/hermes-${resolveBuildType()}.aar") // e.g. hermes-debug.aar
842
- if (!hermesAAR.exists()) {
843
- throw new GradleScriptException("The hermes-engine npm package is missing \"android/hermes-${resolveBuildType()}.aar\"", null)
866
+ doLast {
867
+ // e.g. hermes-engine-0.70.0-rc.1-debug.aar
868
+ def hermesAAR = file(
869
+ "$reactNativeRootDir/android/com/facebook/react/hermes-engine/" +
870
+ "${REACT_NATIVE_VERSION}/hermes-engine-${REACT_NATIVE_VERSION}-" +
871
+ "${resolveBuildType()}.aar"
872
+ )
873
+ if (!hermesAAR.exists()) {
874
+ throw new GradleException("Could not find hermes-engine AAR", null)
875
+ }
876
+
877
+ def soFiles = zipTree(hermesAAR).matching({ it.include "**/*.so" })
878
+
879
+ copy {
880
+ from soFiles
881
+ from "$reactNativeRootDir/ReactAndroid/src/main/jni/first-party/hermes/Android.mk"
882
+ into "$thirdPartyNdkDir/hermes"
883
+ }
844
884
  }
885
+ } else {
886
+ doLast {
887
+ def hermesPackagePath = findNodeModulePath(projectDir, "hermes-engine")
888
+ if (!hermesPackagePath) {
889
+ throw new GradleException("Could not find the hermes-engine npm package", null)
890
+ }
845
891
 
846
- def soFiles = zipTree(hermesAAR).matching({ it.include "**/*.so" })
892
+ def hermesAAR = file("$hermesPackagePath/android/hermes-${resolveBuildType()}.aar") // e.g. hermes-debug.aar
893
+ if (!hermesAAR.exists()) {
894
+ throw new GradleException("The hermes-engine npm package is missing \"android/hermes-${resolveBuildType()}.aar\"", null)
895
+ }
847
896
 
848
- copy {
849
- from soFiles
850
- from "$reactNativeRootDir/ReactAndroid/src/main/jni/first-party/hermes/Android.mk"
851
- into "$thirdPartyNdkDir/hermes"
897
+ def soFiles = zipTree(hermesAAR).matching({ it.include "**/*.so" })
898
+
899
+ copy {
900
+ from soFiles
901
+ from "$reactNativeRootDir/ReactAndroid/src/main/jni/first-party/hermes/Android.mk"
902
+ into "$thirdPartyNdkDir/hermes"
903
+ }
852
904
  }
853
905
  }
854
906
  }
855
- }
856
907
 
857
- task prepareJSC {
858
- doLast {
859
- def jscPackagePath = findNodeModulePath(projectDir, "jsc-android")
860
- if (!jscPackagePath) {
861
- throw new GradleScriptException("Could not find the jsc-android npm package", null)
862
- }
908
+ task prepareJSC {
909
+ if (REACT_NATIVE_MINOR_VERSION >= 71) {
910
+ // do nothing
911
+ } else {
912
+ doLast {
913
+ def jscPackagePath = findNodeModulePath(projectDir, "jsc-android")
914
+ if (!jscPackagePath) {
915
+ throw new GradleException("Could not find the jsc-android npm package", null)
916
+ }
863
917
 
864
- def jscDist = file("$jscPackagePath/dist")
865
- if (!jscDist.exists()) {
866
- throw new GradleScriptException("The jsc-android npm package is missing its \"dist\" directory", null)
867
- }
918
+ def jscDist = file("$jscPackagePath/dist")
919
+ if (!jscDist.exists()) {
920
+ throw new GradleException("The jsc-android npm package is missing its \"dist\" directory", null)
921
+ }
868
922
 
869
- def jscAAR = fileTree(jscDist).matching({ it.include "**/android-jsc/**/*.aar" }).singleFile
870
- def soFiles = zipTree(jscAAR).matching({ it.include "**/*.so" })
923
+ def jscAAR = fileTree(jscDist).matching({ it.include "**/android-jsc/**/*.aar" }).singleFile
924
+ def soFiles = zipTree(jscAAR).matching({ it.include "**/*.so" })
871
925
 
872
- def headerFiles = fileTree(jscDist).matching({ it.include "**/include/*.h" })
926
+ def headerFiles = fileTree(jscDist).matching({ it.include "**/include/*.h" })
873
927
 
874
- copy {
875
- from(soFiles)
876
- from(headerFiles)
877
- from("$reactNativeRootDir/ReactAndroid/src/main/jni/third-party/jsc/Android.mk")
928
+ copy {
929
+ from(soFiles)
930
+ from(headerFiles)
931
+ from("$reactNativeRootDir/ReactAndroid/src/main/jni/third-party/jsc/Android.mk")
878
932
 
879
- filesMatching("**/*.h", { it.path = "JavaScriptCore/${it.name}" })
933
+ filesMatching("**/*.h", { it.path = "JavaScriptCore/${it.name}" })
880
934
 
881
- includeEmptyDirs(false)
882
- into("$thirdPartyNdkDir/jsc")
935
+ includeEmptyDirs(false)
936
+ into("$thirdPartyNdkDir/jsc")
937
+ }
938
+ }
883
939
  }
884
940
  }
885
- }
886
941
 
887
- task extractAARHeaders {
888
- doLast {
889
- configurations.extractHeaders.files.each {
890
- def file = it.absoluteFile
891
- def packageName = file.name.tokenize('-')[0]
892
- copy {
893
- from zipTree(file)
894
- into "$reactNativeRootDir/ReactAndroid/src/main/jni/first-party/$packageName/headers"
895
- include "**/*.h"
942
+ task extractAARHeaders {
943
+ doLast {
944
+ configurations.extractHeaders.files.each {
945
+ def file = it.absoluteFile
946
+ def packageName = file.name.tokenize('-')[0]
947
+ copy {
948
+ from zipTree(file)
949
+ into "$reactNativeRootDir/ReactAndroid/src/main/jni/first-party/$packageName/headers"
950
+ include "**/*.h"
951
+ }
896
952
  }
897
953
  }
898
954
  }
899
- }
900
955
 
901
- task extractSOFiles {
902
- doLast {
903
- configurations.extractSO.files.each {
904
- def file = it.absoluteFile
905
- def packageName = file.name.tokenize('-')[0]
906
- copy {
907
- from zipTree(file)
908
- into "$reactNativeRootDir/ReactAndroid/src/main/jni/first-party/$packageName/"
909
- include "jni/**/*.so"
956
+ task extractSOFiles {
957
+ doLast {
958
+ configurations.extractSO.files.each {
959
+ def file = it.absoluteFile
960
+ def packageName = file.name.tokenize('-')[0]
961
+ copy {
962
+ from zipTree(file)
963
+ into "$reactNativeRootDir/ReactAndroid/src/main/jni/first-party/$packageName/"
964
+ include "jni/**/*.so"
965
+ }
910
966
  }
911
967
  }
912
968
  }
969
+
970
+ task unpackReactNativeAAR {
971
+ def buildType = resolveBuildType()
972
+ def rnAarMatcher = "**/react-native/**/*${buildType}.aar"
973
+ if (REACT_NATIVE_MINOR_VERSION < 69) {
974
+ rnAarMatcher = "**/**/*.aar"
975
+ }
976
+ def rnAAR = fileTree("$reactNativeRootDir/android").matching({ it.include rnAarMatcher }).singleFile
977
+ def file = rnAAR.absoluteFile
978
+ def packageName = file.name.tokenize('-')[0]
979
+ copy {
980
+ from zipTree(file)
981
+ into "$reactNativeRootDir/ReactAndroid/src/main/jni/first-party/$packageName/"
982
+ include "jni/**/*.so"
983
+ }
984
+ }
985
+
986
+ task downloadNdkBuildDependencies {
987
+ if (!boostPath) {
988
+ dependsOn(downloadBoost)
989
+ }
990
+ dependsOn(downloadDoubleConversion)
991
+ dependsOn(downloadFolly)
992
+ dependsOn(downloadGlog)
993
+ }
994
+
995
+ task prepareThirdPartyNdkHeaders(dependsOn:[
996
+ downloadNdkBuildDependencies,
997
+ prepareBoost,
998
+ prepareDoubleConversion,
999
+ prepareFolly,
1000
+ prepareGlog,
1001
+ unpackReactNativeAAR]
1002
+ ) {}
913
1003
  }
914
1004
 
915
1005
  task packageNdkLibs(type: Copy) {
@@ -938,57 +1028,39 @@ repositories {
938
1028
  dependencies {
939
1029
  // noinspection GradleDynamicVersion
940
1030
  implementation "com.facebook.yoga:proguard-annotations:1.19.0"
941
- if (isDeveloperMode() && !isNewArchitectureEnabled()) {
942
- implementation "com.facebook.fbjni:fbjni:" + FBJNI_VERSION
943
- }
944
- else {
945
- implementation "com.facebook.fbjni:fbjni-java-only:" + FBJNI_VERSION
946
- }
947
- implementation "com.facebook.react:react-native:+" // From node_modules
948
1031
  implementation "androidx.transition:transition:1.1.0"
949
1032
  implementation "androidx.core:core:1.6.0"
950
-
951
- extractHeaders("com.facebook.fbjni:fbjni:" + FBJNI_VERSION + ":headers")
952
- extractSO("com.facebook.fbjni:fbjni:" + FBJNI_VERSION)
953
1033
 
954
- def jscAAR = fileTree("$reactNativeRootDir/../jsc-android/dist/org/webkit/android-jsc").matching({ it.include "**/**/*.aar" }).singleFile
955
- extractSO(files(jscAAR))
956
- }
1034
+ if (REACT_NATIVE_MINOR_VERSION >= 71) {
1035
+ if (isPackageBuild()) {
1036
+ implementation "com.facebook.react:react-android:+"
1037
+ } else {
1038
+ implementation "com.facebook.react:react-android:" // version substituted by RNGP
1039
+ }
1040
+ if (JS_RUNTIME == "hermes") {
1041
+ if (isPackageBuild()) {
1042
+ implementation "com.facebook.react:hermes-android:+"
1043
+ } else {
1044
+ implementation "com.facebook.react:hermes-android:" // version substituted by RNGP
1045
+ }
1046
+ }
1047
+ } else {
1048
+ implementation "com.facebook.react:react-native:+" // From node_modules
1049
+ if ((isDeveloperMode() || isPackageBuild()) && !isNewArchitectureEnabled()) {
1050
+ implementation "com.facebook.fbjni:fbjni:" + FBJNI_VERSION
1051
+ }
1052
+ else {
1053
+ implementation "com.facebook.fbjni:fbjni-java-only:" + FBJNI_VERSION
1054
+ }
957
1055
 
958
- task unpackReactNativeAAR {
959
- def buildType = resolveBuildType()
960
- def rnAarMatcher = "**/react-native/**/*${buildType}.aar"
961
- if (REACT_NATIVE_MINOR_VERSION < 69) {
962
- rnAarMatcher = "**/**/*.aar"
963
- }
964
- def rnAAR = fileTree("$reactNativeRootDir/android").matching({ it.include rnAarMatcher }).singleFile
965
- def file = rnAAR.absoluteFile
966
- def packageName = file.name.tokenize('-')[0]
967
- copy {
968
- from zipTree(file)
969
- into "$reactNativeRootDir/ReactAndroid/src/main/jni/first-party/$packageName/"
970
- include "jni/**/*.so"
971
- }
972
- }
1056
+ extractHeaders("com.facebook.fbjni:fbjni:" + FBJNI_VERSION + ":headers")
1057
+ extractSO("com.facebook.fbjni:fbjni:" + FBJNI_VERSION)
973
1058
 
974
- task downloadNdkBuildDependencies {
975
- if (!boostPath) {
976
- dependsOn(downloadBoost)
1059
+ def jscAAR = fileTree("$reactNativeRootDir/../jsc-android/dist/org/webkit/android-jsc").matching({ it.include "**/**/*.aar" }).singleFile
1060
+ extractSO(files(jscAAR))
977
1061
  }
978
- dependsOn(downloadDoubleConversion)
979
- dependsOn(downloadFolly)
980
- dependsOn(downloadGlog)
981
1062
  }
982
1063
 
983
- task prepareThirdPartyNdkHeaders(dependsOn:[
984
- downloadNdkBuildDependencies,
985
- prepareBoost,
986
- prepareDoubleConversion,
987
- prepareFolly,
988
- prepareGlog,
989
- unpackReactNativeAAR]
990
- ) {}
991
-
992
1064
  def nativeBuildDependsOn(dependsOnTask) {
993
1065
  def buildTasks = tasks.findAll({ task -> (
994
1066
  !task.name.contains("Clean")
@@ -1001,22 +1073,26 @@ def nativeBuildDependsOn(dependsOnTask) {
1001
1073
  }
1002
1074
 
1003
1075
  afterEvaluate {
1004
- extractAARHeaders.dependsOn(prepareThirdPartyNdkHeaders)
1005
- extractSOFiles.dependsOn(prepareThirdPartyNdkHeaders)
1076
+ if (REACT_NATIVE_MINOR_VERSION < 71) {
1077
+ extractAARHeaders.dependsOn(prepareThirdPartyNdkHeaders)
1078
+ extractSOFiles.dependsOn(prepareThirdPartyNdkHeaders)
1006
1079
 
1007
- nativeBuildDependsOn(prepareThirdPartyNdkHeaders)
1008
- nativeBuildDependsOn(extractAARHeaders)
1009
- nativeBuildDependsOn(extractSOFiles)
1080
+ nativeBuildDependsOn(prepareThirdPartyNdkHeaders)
1081
+ nativeBuildDependsOn(extractAARHeaders)
1082
+ nativeBuildDependsOn(extractSOFiles)
1010
1083
 
1011
- tasks.forEach({ task ->
1012
- if (task.name.contains("JniLibFolders")) {
1013
- task.dependsOn(packageNdkLibs)
1014
- }
1015
- })
1084
+ tasks.forEach({ task ->
1085
+ if (task.name.contains("JniLibFolders")) {
1086
+ task.dependsOn(packageNdkLibs)
1087
+ }
1088
+ })
1089
+ }
1016
1090
 
1017
1091
  if (JS_RUNTIME == "hermes") {
1018
- extractAARHeaders.dependsOn(prepareHermes)
1019
- extractSOFiles.dependsOn(prepareHermes)
1092
+ if (REACT_NATIVE_MINOR_VERSION < 71) {
1093
+ extractAARHeaders.dependsOn(prepareHermes)
1094
+ extractSOFiles.dependsOn(prepareHermes)
1095
+ }
1020
1096
  } else if (JS_RUNTIME == "v8") {
1021
1097
  def buildTasks = tasks.findAll({ task ->
1022
1098
  !task.name.contains("Clean") && (task.name.contains("externalNative") || task.name.contains("CMake") || task.name.startsWith("generateJsonModel")) })
@@ -1025,8 +1101,10 @@ afterEvaluate {
1025
1101
  task.dependsOn(":react-native-v8:copy${buildType}JniLibsProjectOnly")
1026
1102
  }
1027
1103
  } else if (JS_RUNTIME == "jsc") {
1028
- extractAARHeaders.dependsOn(prepareJSC)
1029
- extractSOFiles.dependsOn(prepareJSC)
1104
+ if (REACT_NATIVE_MINOR_VERSION < 71) {
1105
+ extractAARHeaders.dependsOn(prepareJSC)
1106
+ extractSOFiles.dependsOn(prepareJSC)
1107
+ }
1030
1108
  } else {
1031
1109
  throw GradleScriptException("Unknown JS runtime ${JS_RUNTIME}.")
1032
1110
  }
@@ -1039,4 +1117,4 @@ if (CLIENT_SIDE_BUILD) {
1039
1117
  throw GradleScriptException("AAR build failed. No AAR found in ${aarDir}.")
1040
1118
  }
1041
1119
  artifacts.add("default", aar)
1042
- }
1120
+ }