react-native-reanimated 2.13.0 → 2.14.1

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