react-native-reanimated 2.8.0 → 2.10.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 (224) hide show
  1. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +4 -4
  2. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +38 -0
  3. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +23 -0
  4. package/Common/cpp/Tools/RuntimeDecorator.cpp +17 -11
  5. package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +8 -0
  6. package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +8 -0
  7. package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +5 -0
  8. package/RNReanimated.podspec +22 -3
  9. package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  10. package/android/.gradle/7.2/executionHistory/executionHistory.bin +0 -0
  11. package/android/.gradle/7.2/executionHistory/executionHistory.lock +0 -0
  12. package/android/.gradle/7.2/fileHashes/fileHashes.bin +0 -0
  13. package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
  14. package/android/.gradle/7.2/fileHashes/resourceHashesCache.bin +0 -0
  15. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  16. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  17. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  18. package/android/.gradle/checksums/checksums.lock +0 -0
  19. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  20. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  21. package/android/CMakeLists.txt +216 -84
  22. package/android/build.gradle +255 -229
  23. package/android/react-native-reanimated-66-hermes.aar +0 -0
  24. package/android/react-native-reanimated-66-jsc.aar +0 -0
  25. package/android/react-native-reanimated-67-hermes.aar +0 -0
  26. package/android/react-native-reanimated-67-jsc.aar +0 -0
  27. package/android/react-native-reanimated-68-hermes.aar +0 -0
  28. package/android/react-native-reanimated-68-jsc.aar +0 -0
  29. package/android/react-native-reanimated-69-hermes.aar +0 -0
  30. package/android/react-native-reanimated-69-jsc.aar +0 -0
  31. package/android/react-native-reanimated-70-hermes.aar +0 -0
  32. package/android/react-native-reanimated-70-jsc.aar +0 -0
  33. package/{lib/types/lib/reanimated2/platform-specific/RNRenderer.web.d.ts → android/rnVersionPatch/69/.gitkeep} +0 -0
  34. package/android/rnVersionPatch/70/.gitkeep +0 -0
  35. package/android/src/main/cpp/NativeProxy.cpp +56 -11
  36. package/android/src/main/cpp/OnLoad.cpp +1 -0
  37. package/android/src/main/cpp/headers/NativeProxy.h +29 -0
  38. package/android/src/main/java/com/swmansion/reanimated/NativeProxy.java +25 -0
  39. package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +3 -1
  40. package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +165 -0
  41. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +19 -16
  42. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +5 -1
  43. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +24 -1
  44. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorType.java +7 -5
  45. package/ios/REANodesManager.m +31 -8
  46. package/ios/keyboardObserver/REAKeyboardEventObserver.h +17 -0
  47. package/ios/keyboardObserver/REAKeyboardEventObserver.m +198 -0
  48. package/ios/native/NativeProxy.mm +20 -1
  49. package/ios/native/REAInitializer.mm +10 -4
  50. package/ios/sensor/ReanimatedSensor.m +27 -18
  51. package/lib/Animated.js +8 -21
  52. package/lib/index.js +12 -20
  53. package/lib/index.web.js +4 -0
  54. package/lib/reanimated2/Colors.js +1 -1
  55. package/lib/reanimated2/NativeMethods.js +3 -0
  56. package/lib/reanimated2/NativeReanimated/NativeReanimated.js +7 -1
  57. package/lib/reanimated2/animation/sequence.js +0 -3
  58. package/lib/reanimated2/animation/util.js +4 -1
  59. package/lib/reanimated2/commonTypes.js +8 -1
  60. package/lib/reanimated2/component/FlatList.js +8 -8
  61. package/lib/reanimated2/component/Image.js +4 -0
  62. package/lib/reanimated2/component/ScrollView.js +4 -0
  63. package/lib/reanimated2/component/Text.js +4 -0
  64. package/lib/reanimated2/component/View.js +4 -0
  65. package/lib/reanimated2/core.js +5 -9
  66. package/lib/reanimated2/frameCallback/FrameCallbackRegistryJS.js +32 -0
  67. package/lib/reanimated2/frameCallback/FrameCallbackRegistryUI.js +47 -0
  68. package/lib/reanimated2/globals.d.ts +3 -0
  69. package/lib/reanimated2/hook/index.js +2 -0
  70. package/lib/reanimated2/hook/useAnimatedKeyboard.js +31 -0
  71. package/lib/reanimated2/hook/useAnimatedSensor.js +3 -3
  72. package/lib/reanimated2/hook/useFrameCallback.js +23 -0
  73. package/lib/reanimated2/hook/utils.js +0 -5
  74. package/lib/reanimated2/jestUtils.js +11 -3
  75. package/lib/reanimated2/js-reanimated/JSReanimated.js +7 -0
  76. package/lib/reanimated2/js-reanimated/global.js +36 -0
  77. package/lib/reanimated2/js-reanimated/index.js +0 -24
  78. package/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.js +1 -1
  79. package/lib/reanimated2/mock.js +6 -0
  80. package/lib/types/Animated.d.ts +8 -0
  81. package/lib/types/{lib/ConfigHelper.d.ts → ConfigHelper.d.ts} +0 -0
  82. package/lib/types/{lib/ReanimatedEventEmitter.d.ts → ReanimatedEventEmitter.d.ts} +0 -0
  83. package/lib/types/{lib/ReanimatedModule.d.ts → ReanimatedModule.d.ts} +0 -0
  84. package/lib/types/{lib/ReanimatedModule.macos.d.ts → ReanimatedModule.macos.d.ts} +0 -0
  85. package/lib/types/{lib/ReanimatedModule.native.d.ts → ReanimatedModule.native.d.ts} +0 -0
  86. package/lib/types/{lib/ReanimatedModule.windows.d.ts → ReanimatedModule.windows.d.ts} +0 -0
  87. package/lib/types/{lib/ReanimatedModuleCompat.d.ts → ReanimatedModuleCompat.d.ts} +0 -0
  88. package/lib/types/{lib/createAnimatedComponent.d.ts → createAnimatedComponent.d.ts} +0 -0
  89. package/lib/types/index.d.ts +4 -0
  90. package/lib/types/index.web.d.ts +3 -0
  91. package/lib/types/{lib/reanimated2 → reanimated2}/Bezier.d.ts +0 -0
  92. package/lib/types/{lib/reanimated2 → reanimated2}/Colors.d.ts +0 -0
  93. package/lib/types/{lib/reanimated2 → reanimated2}/Easing.d.ts +0 -0
  94. package/lib/types/{lib/reanimated2 → reanimated2}/NativeMethods.d.ts +0 -0
  95. package/lib/types/{lib/reanimated2 → reanimated2}/NativeReanimated/NativeReanimated.d.ts +3 -1
  96. package/lib/types/{lib/reanimated2 → reanimated2}/NativeReanimated/index.d.ts +0 -0
  97. package/lib/types/{lib/reanimated2 → reanimated2}/PlatformChecker.d.ts +0 -0
  98. package/lib/types/{lib/reanimated2 → reanimated2}/PropAdapters.d.ts +0 -0
  99. package/lib/types/{lib/reanimated2 → reanimated2}/UpdateProps.d.ts +0 -0
  100. package/lib/types/{lib/reanimated2 → reanimated2}/ViewDescriptorsSet.d.ts +0 -0
  101. package/lib/types/{lib/reanimated2 → reanimated2}/WorkletEventHandler.d.ts +0 -0
  102. package/lib/types/{lib/reanimated2 → reanimated2}/__mocks__/MutableValue.d.ts +0 -0
  103. package/lib/types/{lib/reanimated2 → reanimated2}/__mocks__/NativeReanimated.d.ts +0 -0
  104. package/lib/types/{lib/reanimated2 → reanimated2}/__mocks__/NativeReanimated.native.d.ts +0 -0
  105. package/lib/types/{lib/reanimated2 → reanimated2}/animation/commonTypes.d.ts +0 -0
  106. package/lib/types/{lib/reanimated2 → reanimated2}/animation/decay.d.ts +0 -0
  107. package/lib/types/{lib/reanimated2 → reanimated2}/animation/delay.d.ts +0 -0
  108. package/lib/types/{lib/reanimated2 → reanimated2}/animation/index.d.ts +0 -0
  109. package/lib/types/{lib/reanimated2 → reanimated2}/animation/repeat.d.ts +0 -0
  110. package/lib/types/{lib/reanimated2 → reanimated2}/animation/sequence.d.ts +0 -0
  111. package/lib/types/{lib/reanimated2 → reanimated2}/animation/spring.d.ts +0 -0
  112. package/lib/types/{lib/reanimated2 → reanimated2}/animation/styleAnimation.d.ts +0 -0
  113. package/lib/types/{lib/reanimated2 → reanimated2}/animation/timing.d.ts +0 -0
  114. package/lib/types/{lib/reanimated2 → reanimated2}/animation/util.d.ts +0 -0
  115. package/lib/types/{lib/reanimated2 → reanimated2}/commonTypes.d.ts +12 -0
  116. package/lib/types/{lib/reanimated2 → reanimated2}/component/FlatList.d.ts +2 -2
  117. package/lib/types/reanimated2/component/Image.d.ts +3 -0
  118. package/lib/types/reanimated2/component/ScrollView.d.ts +3 -0
  119. package/lib/types/reanimated2/component/Text.d.ts +3 -0
  120. package/lib/types/reanimated2/component/View.d.ts +3 -0
  121. package/lib/types/{lib/reanimated2 → reanimated2}/core.d.ts +0 -0
  122. package/lib/types/reanimated2/frameCallback/FrameCallbackRegistryJS.d.ts +7 -0
  123. package/lib/types/reanimated2/frameCallback/FrameCallbackRegistryUI.d.ts +10 -0
  124. package/lib/types/{lib/reanimated2 → reanimated2}/hook/Hooks.d.ts +0 -0
  125. package/lib/types/{lib/reanimated2 → reanimated2}/hook/commonTypes.d.ts +0 -0
  126. package/lib/types/{lib/reanimated2 → reanimated2}/hook/index.d.ts +3 -0
  127. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedGestureHandler.d.ts +0 -0
  128. package/lib/types/reanimated2/hook/useAnimatedKeyboard.d.ts +2 -0
  129. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedReaction.d.ts +0 -0
  130. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedRef.d.ts +0 -0
  131. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedScrollHandler.d.ts +0 -0
  132. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedSensor.d.ts +1 -1
  133. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedStyle.d.ts +0 -0
  134. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useDerivedValue.d.ts +0 -0
  135. package/lib/types/reanimated2/hook/useFrameCallback.d.ts +6 -0
  136. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useSharedValue.d.ts +0 -0
  137. package/lib/types/{lib/reanimated2 → reanimated2}/hook/utils.d.ts +0 -0
  138. package/lib/types/{lib/reanimated2 → reanimated2}/index.d.ts +0 -0
  139. package/lib/types/{lib/reanimated2 → reanimated2}/interpolateColor.d.ts +0 -0
  140. package/lib/types/{lib/reanimated2 → reanimated2}/interpolation.d.ts +0 -0
  141. package/lib/types/{lib/reanimated2 → reanimated2}/jestUtils.d.ts +1 -1
  142. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/JSReanimated.d.ts +3 -1
  143. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/Mapper.d.ts +0 -0
  144. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/MapperRegistry.d.ts +0 -0
  145. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/MutableValue.d.ts +0 -0
  146. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/commonTypes.d.ts +0 -0
  147. package/lib/types/reanimated2/js-reanimated/global.d.ts +2 -0
  148. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/index.d.ts +0 -0
  149. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/LayoutAnimationRepository.d.ts +0 -0
  150. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/BaseAnimationBuilder.d.ts +0 -0
  151. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +0 -0
  152. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/Keyframe.d.ts +0 -0
  153. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/commonTypes.d.ts +0 -0
  154. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/index.d.ts +0 -0
  155. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Bounce.d.ts +0 -0
  156. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Default.d.ts +0 -0
  157. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Fade.d.ts +0 -0
  158. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Flip.d.ts +0 -0
  159. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Lightspeed.d.ts +0 -0
  160. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Pinwheel.d.ts +0 -0
  161. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Roll.d.ts +0 -0
  162. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Rotate.d.ts +0 -0
  163. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Slide.d.ts +0 -0
  164. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Stretch.d.ts +0 -0
  165. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Zoom.d.ts +0 -0
  166. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/index.d.ts +0 -0
  167. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +0 -0
  168. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +0 -0
  169. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/FadingTransition.d.ts +0 -0
  170. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +0 -0
  171. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/LinearTransition.d.ts +0 -0
  172. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +0 -0
  173. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/index.d.ts +0 -0
  174. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/index.d.ts +0 -0
  175. package/lib/types/{lib/reanimated2 → reanimated2}/mock.d.ts +6 -0
  176. package/lib/types/{lib/reanimated2 → reanimated2}/platform-specific/RNRenderer.d.ts +0 -0
  177. package/lib/types/reanimated2/platform-specific/RNRenderer.web.d.ts +0 -0
  178. package/lib/types/{lib/reanimated2 → reanimated2}/utils.d.ts +0 -0
  179. package/lib/types/{lib/setAndForwardRef.d.ts → setAndForwardRef.d.ts} +0 -0
  180. package/mock.js +1 -0
  181. package/package.json +15 -10
  182. package/plugin.js +7 -6
  183. package/react-native-reanimated.d.ts +56 -8
  184. package/src/Animated.ts +13 -0
  185. package/src/index.ts +15 -0
  186. package/src/index.web.ts +5 -0
  187. package/src/reanimated2/Colors.ts +1 -1
  188. package/src/reanimated2/NativeMethods.ts +5 -0
  189. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +10 -1
  190. package/src/reanimated2/animation/sequence.ts +0 -5
  191. package/src/reanimated2/animation/util.ts +8 -1
  192. package/src/reanimated2/commonTypes.ts +15 -0
  193. package/src/reanimated2/component/FlatList.tsx +32 -25
  194. package/src/reanimated2/component/Image.ts +6 -0
  195. package/src/reanimated2/component/ScrollView.ts +6 -0
  196. package/src/reanimated2/component/Text.ts +6 -0
  197. package/src/reanimated2/component/View.ts +6 -0
  198. package/src/reanimated2/core.ts +8 -13
  199. package/src/reanimated2/frameCallback/FrameCallbackRegistryJS.ts +43 -0
  200. package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +64 -0
  201. package/src/reanimated2/globals.d.ts +3 -0
  202. package/src/reanimated2/hook/index.ts +3 -0
  203. package/src/reanimated2/hook/useAnimatedKeyboard.ts +35 -0
  204. package/src/reanimated2/hook/useAnimatedSensor.ts +5 -5
  205. package/src/reanimated2/hook/useFrameCallback.ts +39 -0
  206. package/src/reanimated2/hook/utils.ts +0 -6
  207. package/src/reanimated2/jestUtils.ts +11 -3
  208. package/src/reanimated2/js-reanimated/JSReanimated.ts +16 -1
  209. package/src/reanimated2/js-reanimated/global.ts +45 -0
  210. package/src/reanimated2/js-reanimated/index.ts +0 -31
  211. package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +1 -1
  212. package/src/reanimated2/mock.ts +6 -0
  213. package/android/react-native-reanimated-64-hermes.aar +0 -0
  214. package/android/react-native-reanimated-64-jsc.aar +0 -0
  215. package/android/react-native-reanimated-65-hermes.aar +0 -0
  216. package/android/react-native-reanimated-65-jsc.aar +0 -0
  217. package/lib/reanimated2/component/WrappedComponents.js +0 -9
  218. package/lib/reanimated2/component/index.js +0 -4
  219. package/lib/types/lib/reanimated2/component/WrappedComponents.d.ts +0 -8
  220. package/lib/types/lib/reanimated2/component/index.d.ts +0 -9
  221. package/lib/types/react-native-reanimated-tests.d.ts +0 -1
  222. package/src/Animated.js +0 -22
  223. package/src/reanimated2/component/WrappedComponents.ts +0 -11
  224. package/src/reanimated2/component/index.ts +0 -9
@@ -1,10 +1,11 @@
1
+ import com.android.Version
2
+
3
+ import java.nio.file.Files
1
4
  import java.nio.file.Paths
5
+ import java.nio.file.Path
2
6
  import org.apache.tools.ant.filters.ReplaceTokens
3
-
4
- import java.util.regex.Matcher
5
- import java.util.regex.Pattern
6
7
  import groovy.json.JsonSlurper
7
- import java.util.zip.ZipFile
8
+ import java.util.stream.Stream
8
9
 
9
10
  /**
10
11
  * Finds the path of the installed npm package with the given name using Node's
@@ -45,22 +46,20 @@ def safeExtGet(prop, fallback) {
45
46
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
46
47
  }
47
48
 
48
- def getCurrentFlavor() {
49
- String taskRequestName = getGradle().getStartParameter().getTaskRequests().toString()
50
- Pattern pattern = Pattern.compile("(assemble|bundle|install|generate)(\\w*)(Release|Debug)")
51
- Matcher matcher = pattern.matcher(taskRequestName)
52
-
53
- if (matcher.find()) {
54
- return matcher.group(2)
55
- }
56
-
57
- return "NOT-FOUND"
49
+ def resolveBuildType() {
50
+ def buildType = "debug"
51
+ tasks.all({ task ->
52
+ if (task.name == "buildCMakeRelease") {
53
+ buildType = "release"
54
+ }
55
+ })
56
+ return buildType
58
57
  }
59
58
 
60
- def resolveBuildType() {
61
- def buildType = System.getenv("CLIENT_SIDE_BUILD")
62
- if (buildType != null) {
63
- return buildType == "True"
59
+ def resolveClientSideBuild() {
60
+ def clientSideBuild = System.getenv("CLIENT_SIDE_BUILD")
61
+ if (clientSideBuild != null) {
62
+ return clientSideBuild == "True"
64
63
  }
65
64
 
66
65
  if (hasProperty("clientSideBuild")) {
@@ -79,137 +78,57 @@ def isDeveloperMode() {
79
78
  return file("$projectDir/../node_modules/react-native/package.json").exists()
80
79
  }
81
80
 
81
+ def isNewArchitectureEnabled() {
82
+ // To opt-in for the New Architecture, you can either:
83
+ // - Set `newArchEnabled` to true inside the `gradle.properties` file
84
+ // - Invoke gradle with `-newArchEnabled=true`
85
+ // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
86
+ return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
87
+ }
88
+
82
89
  def resolveReactNativeDirectory() {
83
90
  if (isDeveloperMode()) {
84
- return file("$projectDir/../node_modules/react-native")
91
+ return file("$projectDir/../${getPlaygroundAppName()}/node_modules/react-native")
85
92
  }
86
93
  return file("$projectDir/../../react-native")
87
94
  }
88
95
 
89
- abstract class replaceSoTask extends DefaultTask {
90
- public static String appName = ":app"
91
- public static String buildDir = "../../../android/app/build"
92
- public static String fbjniVersion = "0.3.0"
93
-
94
- @TaskAction
95
- def run() {
96
- def libSoDir = new File("${buildDir}/tmp/libSo")
97
- if (!libSoDir.exists()) {
98
- libSoDir.mkdirs()
99
- def fbjniUrl = "https://repo1.maven.org/maven2/com/facebook/fbjni/fbjni/${fbjniVersion}/fbjni-${fbjniVersion}.aar"
100
- def aarFile = new File("${libSoDir.path}/fbjni-${fbjniVersion}.aar")
101
- aarFile.createNewFile()
102
- aarFile.withOutputStream { out ->
103
- def url = new URL(fbjniUrl).openConnection()
104
- out << url.inputStream
105
- }
106
- if (!aarFile.exists()) {
107
- println("Unable to find ${libSoDir.path}/fbjni-${fbjniVersion}.aar")
108
- return
109
- }
110
- def zipFile = new ZipFile(new File("${libSoDir.path}/fbjni-${fbjniVersion}.aar"))
111
- zipFile.entries().each {
112
- def zipIt = it
113
- if (zipIt.name.contains("libfbjni.so")) {
114
- new File("${libSoDir.path}/" + zipIt.name.replace("/libfbjni.so", "")).mkdirs()
115
- new File("${libSoDir.path}/" + zipIt.name).withOutputStream{
116
- it << zipFile.getInputStream(zipIt)
117
- }
118
- }
119
- }
120
- }
121
- for(def abiVersion in ["x86", "x86_64", "armeabi-v7a", "arm64-v8a"]) {
122
- ant.sequential {
123
- copy(
124
- tofile: "${buildDir}/intermediates/merged_native_libs/debug/out/lib/${abiVersion}/libfbjni.so",
125
- file: "${buildDir}/tmp/libSo/jni/${abiVersion}/libfbjni.so",
126
- overwrite: true
127
- )
96
+ def getPlaygroundAppName() { // only for the development
97
+ String playgroundAppName = ""
98
+ try {
99
+ rootProject.getSubprojects().forEach({project ->
100
+ if (project.plugins.hasPlugin("com.android.application")) {
101
+ var projectCatalogAbsolutePath = project.projectDir.toString().replace("/android/app", "")
102
+ var slashPosition = projectCatalogAbsolutePath.lastIndexOf("/")
103
+ playgroundAppName = projectCatalogAbsolutePath.substring(slashPosition + 1)
128
104
  }
129
- }
105
+ })
106
+ } catch(_) {
107
+ return "NOT_FOUND"
130
108
  }
109
+ return playgroundAppName
131
110
  }
132
111
 
133
- def detectAAR(minor, engine) {
134
- def rnMinorVersionCopy = Integer.parseInt(minor)
135
- def aar = file("react-native-reanimated-${rnMinorVersionCopy}-${engine}.aar")
136
-
137
- if (aar.exists()) {
138
- println "AAR for react-native-reanimated has been found\n$aar"
139
- return aar
140
- } else {
141
- while (!aar.exists() && rnMinorVersionCopy >= 63) {
142
- rnMinorVersionCopy -= 1
143
- aar = file("react-native-reanimated-${rnMinorVersionCopy}-${engine}.aar")
144
- }
145
-
146
- if (rnMinorVersionCopy < 63) {
147
- println "No AAR for react-native-reanimated found. Attempting to build from source."
148
- } else { // aar exists, but was build for lower react-native version
149
- println "\n\n\n"
150
- println "****************************************************************************************"
151
- println "\n\n\n"
152
- println "WARNING reanimated - no version-specific reanimated AAR for react-native version $rnMinorVersion found."
153
- println "Falling back to AAR for react-native version $rnMinorVersionCopy."
154
- println "The react-native JSI interface is not ABI-safe yet, this may result in crashes."
155
- println "Please post a pull request to implement support for react-native version $rnMinorVersion to the reanimated repo."
156
- println "Thanks!"
157
- println "\n\n\n"
158
- println "****************************************************************************************"
159
-
160
- return aar
161
- }
162
- }
163
- return null
164
- }
112
+ boolean CLIENT_SIDE_BUILD = resolveClientSideBuild()
113
+ if (CLIENT_SIDE_BUILD) {
114
+ configurations.maybeCreate("default")
165
115
 
166
- def detectJsRuntime() {
167
- def runtimeType = "jsc"
168
- rootProject.getSubprojects().forEach({project ->
169
- if (project.plugins.hasPlugin("com.android.application")) {
170
- if (project.ext.react.enableHermes) {
171
- runtimeType = "hermes"
172
- }
173
- }
174
- })
175
- return runtimeType
176
- }
177
-
178
- def detectReanimatedConfig() {
179
- def buildFromSourceConf = false
180
- rootProject.getSubprojects().forEach({project ->
181
- if (project.plugins.hasPlugin("com.android.application")) {
182
- if (
183
- project.ext.has("reanimated")
184
- && project.ext.reanimated.buildFromSource
185
- ) {
186
- buildFromSourceConf = true
187
- }
188
- }
189
- })
190
- return buildFromSourceConf
191
- }
116
+ List<Path> paths = Files.find(
117
+ Paths.get(rootDir.parent),
118
+ Integer.MAX_VALUE,
119
+ {path, fileAttributes -> path.toString().endsWith("/react-native-reanimated/package.json") }
120
+ ).toArray()
192
121
 
193
- def shouldBuildFromSource(aar) {
194
- if (isDeveloperMode()) {
195
- // Example app
196
- return true
197
- }
198
- else if (detectReanimatedConfig()) {
199
- // on user demand
200
- return true
122
+ String parsedLocation = ""
123
+ def libInstancesCount = 0
124
+ for (def path in paths) {
125
+ parsedLocation += "- " + path.toString().replace("/package.json", "\n")
126
+ libInstancesCount++
201
127
  }
202
- else if (aar != null) {
203
- // when binary exist
204
- return false
128
+ if (libInstancesCount > 1) {
129
+ String exceptionMessage = "\nMultiple versions of Reanimated were detected. Only one instance of react-native-reanimated can be installed in a project. You need to resolve the conflict manually. Check out the documentation: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/troubleshooting#multiple-versions-of-reanimated-were-detected \n\nConflict between: \n" + parsedLocation + "\n";
130
+ throw new Exception(exceptionMessage)
205
131
  }
206
- // when binary is not found
207
- return true
208
- }
209
-
210
- boolean CLIENT_SIDE_BUILD = resolveBuildType()
211
- if (CLIENT_SIDE_BUILD) {
212
- configurations.maybeCreate("default")
213
132
  }
214
133
  def reactNative = resolveReactNativeDirectory()
215
134
  def reactNativeManifest = file("$reactNative/package.json")
@@ -217,70 +136,6 @@ def reactNativeManifestAsJson = new JsonSlurper().parseText(reactNativeManifest.
217
136
  def reactNativeVersion = reactNativeManifestAsJson.version as String
218
137
  def (major, minor, patch) = reactNativeVersion.tokenize('.')
219
138
  def rnMinorVersion = Integer.parseInt(minor)
220
- def engine = detectJsRuntime()
221
- def aar = detectAAR(minor, engine)
222
- boolean BUILD_FROM_SOURCE = shouldBuildFromSource(aar)
223
-
224
- def getTaskByPath(project, String appName, String secondPart, String flavorString, String lastPart) {
225
- String pathName = "${appName}:${secondPart}${flavorString}${lastPart}"
226
- Task task = project.getTasks().findByPath(pathName)
227
- if (task != null) {
228
- return task
229
- }
230
- pathName = "${appName}:${secondPart}${flavorString.capitalize()}${lastPart}"
231
- return project.getTasks().findByPath(pathName)
232
- }
233
-
234
- if (!BUILD_FROM_SOURCE) {
235
- if (rnMinorVersion < 65) {
236
- tasks.register("replaceSoTaskDebug", replaceSoTask)
237
- tasks.register("replaceSoTaskRelease", replaceSoTask)
238
- Task replaceSoTaskDebug = project.getTasks().findByPath(":react-native-reanimated:replaceSoTaskDebug")
239
- Task replaceSoTaskRelease = project.getTasks().findByPath(":react-native-reanimated:replaceSoTaskRelease")
240
-
241
- if (replaceSoTaskDebug != null && replaceSoTaskRelease != null) {
242
- rootProject.getSubprojects().forEach({project ->
243
- if (project.plugins.hasPlugin("com.android.application") && project.getProperties().get("android")) {
244
- def projectProperties = project.getProperties()
245
- def flavorString = getCurrentFlavor()
246
- def reanimatedConf = projectProperties.get("reanimated")
247
-
248
- if (
249
- flavorString != "NOT-FOUND"
250
- && (!reanimatedConf || (reanimatedConf && !reanimatedConf.get("enablePackagingOptions")))
251
- ) {
252
- replaceSoTask.appName = projectProperties.path
253
- replaceSoTask.buildDir = projectProperties.buildDir
254
- def appName = projectProperties.path
255
-
256
- Task debugNativeLibsTask = getTaskByPath(project, appName, "merge", flavorString, "DebugNativeLibs")
257
- Task debugDebugSymbolsTask = getTaskByPath(project, appName, "strip", flavorString, "DebugDebugSymbols")
258
- Task releaseNativeLibsTask = getTaskByPath(project, appName, "merge", flavorString, "ReleaseNativeLibs")
259
- Task releaseDebugSymbolsTask = getTaskByPath(project, appName, "strip", flavorString, "ReleaseDebugSymbols")
260
- Task debugTask = getTaskByPath(project, appName, "package", flavorString, "Debug")
261
- Task releaseTask = getTaskByPath(project, appName, "package", flavorString, "Release")
262
-
263
- if (
264
- debugNativeLibsTask != null && debugDebugSymbolsTask != null
265
- && releaseNativeLibsTask != null && releaseDebugSymbolsTask != null
266
- && debugTask != null && releaseTask != null
267
- ) {
268
- replaceSoTaskDebug.dependsOn(debugNativeLibsTask, debugDebugSymbolsTask)
269
- debugTask.dependsOn(replaceSoTaskDebug)
270
- replaceSoTaskRelease.dependsOn(releaseNativeLibsTask, releaseDebugSymbolsTask)
271
- releaseTask.dependsOn(replaceSoTaskRelease)
272
- }
273
- }
274
- }
275
- })
276
- }
277
- }
278
-
279
- artifacts.add("default", aar)
280
- }
281
-
282
- // end if already loaded aar
283
- if (!BUILD_FROM_SOURCE) return
284
139
 
285
140
  def localProps = new Properties()
286
141
  def localPropertiesFile = file("local.properties")
@@ -309,13 +164,40 @@ def thirdPartyNdkDir = new File("$buildDir/third-party-ndk")
309
164
  def reactNativeThirdParty = new File("$reactNative/ReactAndroid/src/main/jni/third-party")
310
165
 
311
166
  def _stackProtectorFlag = true
312
- def FOR_HERMES = ""
313
167
 
314
- if (findProject(":app")) {
315
- FOR_HERMES = project(":app").ext.react.enableHermes;
316
- } else {
317
- FOR_HERMES = System.getenv("FOR_HERMES") == "True";
318
- }
168
+ def CMAKE_NODE_MODULES_DIR = CLIENT_SIDE_BUILD
169
+ ? project.getProjectDir().getParentFile().getParent()
170
+ : Paths.get(project.getProjectDir().getParent(), getPlaygroundAppName(), "node_modules").toString()
171
+
172
+ def JS_RUNTIME = {
173
+ // Returns the js runtime explicitly requested in the environment variable
174
+ if (System.getenv("JS_RUNTIME")) {
175
+ return System.getenv("JS_RUNTIME")
176
+ }
177
+
178
+ // Detect js runtime from project setup
179
+ def defaultRuntimeType = "jsc";
180
+ def v8Project = rootProject.getSubprojects().find { project -> project.name == "react-native-v8" }
181
+ if (v8Project != null) {
182
+ return "v8"
183
+ }
184
+ def appProject = findProject(":app") ? project(":app") : null
185
+ return appProject?.ext?.react?.enableHermes ? "hermes" : defaultRuntimeType
186
+ }.call()
187
+
188
+ def jsRuntimeDir = {
189
+ if (JS_RUNTIME == "hermes") {
190
+ if (rnMinorVersion >= 69) {
191
+ return Paths.get(CMAKE_NODE_MODULES_DIR, "react-native", "sdks", "hermes")
192
+ } else {
193
+ return Paths.get(CMAKE_NODE_MODULES_DIR, "hermes-engine")
194
+ }
195
+ } else if (JS_RUNTIME == "v8") {
196
+ return findProject(":react-native-v8").getProjectDir().getParent()
197
+ } else {
198
+ return Paths.get(CMAKE_NODE_MODULES_DIR, "react-native", "ReactCommon", "jsi")
199
+ }
200
+ }.call()
319
201
 
320
202
  def reactNativeArchitectures() {
321
203
  def value = project.getProperties().get("reactNativeArchitectures")
@@ -372,6 +254,7 @@ android {
372
254
  targetSdkVersion safeExtGet("targetSdkVersion", 30)
373
255
  versionCode 1
374
256
  versionName "1.0"
257
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
375
258
  externalNativeBuild {
376
259
  cmake {
377
260
  arguments "-DANDROID_STL=c++_shared",
@@ -379,10 +262,13 @@ android {
379
262
  "-DREACT_NATIVE_TARGET_VERSION=${REACT_VERSION}",
380
263
  "-DANDROID_TOOLCHAIN=clang",
381
264
  "-DBOOST_VERSION=${BOOST_VERSION}",
382
- "-DBUILD_DIR=${buildDir}",
383
- "-DFOR_HERMES=${FOR_HERMES}",
265
+ "-DNODE_MODULES_DIR=${CMAKE_NODE_MODULES_DIR}",
266
+ "-DJS_RUNTIME=${JS_RUNTIME}",
267
+ "-DJS_RUNTIME_DIR=${jsRuntimeDir}",
384
268
  "-DCLIENT_SIDE_BUILD=${CLIENT_SIDE_BUILD}",
385
- "--clean-first"
269
+ "-DIS_NEW_ARCHITECTURE_ENABLED=${isNewArchitectureEnabled()}",
270
+ "-DPLAYGROUND_APP_NAME=${getPlaygroundAppName()}",
271
+ "-DRNVERSION=${rnMinorVersion}"
386
272
  abiFilters (*reactNativeArchitectures())
387
273
  _stackProtectorFlag ? (cppFlags("-fstack-protector-all")) : null
388
274
  }
@@ -390,10 +276,12 @@ android {
390
276
 
391
277
  buildConfigField("boolean", "IS_INTERNAL_BUILD", "false")
392
278
  buildConfigField("int", "EXOPACKAGE_FLAGS", "0")
279
+ buildConfigField("int", "REACT_NATIVE_VERSION", rnMinorVersion.toString())
393
280
  }
394
281
  externalNativeBuild {
395
282
  cmake {
396
283
  path "CMakeLists.txt"
284
+ version "3.18.1"
397
285
  }
398
286
  }
399
287
  lintOptions {
@@ -407,10 +295,12 @@ android {
407
295
  "**/libfbjni.so",
408
296
  "**/libjsi.so",
409
297
  "**/libfolly_json.so",
298
+ "**/libfolly_runtime.so",
410
299
  "**/libglog.so",
411
300
  "**/libhermes.so",
412
301
  "**/libreactnativejni.so",
413
302
  "**/libjscexecutor.so",
303
+ "**/libv8executor.so",
414
304
  ]
415
305
  }
416
306
  tasks.withType(JavaCompile) {
@@ -425,6 +315,27 @@ android {
425
315
  sourceCompatibility JavaVersion.VERSION_1_8
426
316
  targetCompatibility JavaVersion.VERSION_1_8
427
317
  }
318
+ packagingOptions {
319
+ // For some reason gradle only complains about the duplicated version of librrc_root and libreact_render libraries
320
+ // while there are more libraries copied in intermediates folder of the lib build directory, we exclude
321
+ // only the ones that make the build fail (ideally we should only include libreanimated but we
322
+ // are only allowed to specify exlude patterns)
323
+ exclude "**/libreact_render*.so"
324
+ exclude "**/librrc_root.so"
325
+ }
326
+ sourceSets.main {
327
+ java {
328
+ if (isNewArchitectureEnabled()) {
329
+ srcDirs += [
330
+ "src/fabric/java",
331
+ ]
332
+ } else {
333
+ srcDirs += [
334
+ "src/paper/java",
335
+ ]
336
+ }
337
+ }
338
+ }
428
339
  }
429
340
 
430
341
  task cleanCmakeCache() {
@@ -435,7 +346,7 @@ task cleanCmakeCache() {
435
346
  }
436
347
 
437
348
  task printVersions {
438
- println "Android gradle plugin: ${com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION}"
349
+ println "Android gradle plugin: ${Version.ANDROID_GRADLE_PLUGIN_VERSION}"
439
350
  println "Gradle: ${project.gradle.gradleVersion}"
440
351
  }
441
352
 
@@ -459,7 +370,12 @@ task createNativeDepsDirectories(dependsOn: applyJavaPatches) {
459
370
  }
460
371
 
461
372
  task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) {
462
- src("https://github.com/react-native-community/boost-for-react-native/releases/download/v${BOOST_VERSION.replace("_", ".")}-0/boost_${BOOST_VERSION}.tar.gz")
373
+ def transformedVersion = BOOST_VERSION.replace("_", ".")
374
+ def srcUrl = "https://boostorg.jfrog.io/artifactory/main/release/${transformedVersion}/source/boost_${BOOST_VERSION}.tar.gz"
375
+ if (rnMinorVersion < 69) {
376
+ srcUrl = "https://github.com/react-native-community/boost-for-react-native/releases/download/v${transformedVersion}-0/boost_${BOOST_VERSION}.tar.gz"
377
+ }
378
+ src(srcUrl)
463
379
  onlyIfNewer(true)
464
380
  overwrite(false)
465
381
  dest(new File(downloadsDir, "boost_${BOOST_VERSION}.tar.gz"))
@@ -557,23 +473,94 @@ task prepareGlog(dependsOn: dependenciesPath ? [] : [downloadGlog], type: Copy)
557
473
  }
558
474
  }
559
475
 
560
- task prepareHermes() {
561
- def hermesPackagePath = findNodeModulePath(projectDir, "hermes-engine")
562
- if (!hermesPackagePath) {
563
- throw new GradleScriptException("Could not find the hermes-engine npm package", null)
476
+ /*
477
+ Reanimated includes "hermes/hermes.h" header file in `NativeProxy.cpp`.
478
+ Previously, we used header files from `hermes-engine` package in `node_modules`.
479
+ Starting from React Native 0.69, Hermes is no longer distributed as package on NPM.
480
+ On the new architecture, Hermes is downloaded from GitHub and then compiled from sources.
481
+ However, on the old architecture, we need to download Hermes header files on our own
482
+ as well as unzip Hermes AAR in order to obtain `libhermes.so` shared library.
483
+ For more details, see https://reactnative.dev/architecture/bundled-hermes
484
+ or https://github.com/reactwg/react-native-new-architecture/discussions/4
485
+ */
486
+ if (rnMinorVersion >= 69 && !isNewArchitectureEnabled()) {
487
+ // copied from `react-native/ReactAndroid/hermes-engine/build.gradle`
488
+
489
+ def reactNativeRootDir = resolveReactNativeDirectory()
490
+ def customDownloadDir = System.getenv("REACT_NATIVE_DOWNLOADS_DIR")
491
+ def downloadDir = customDownloadDir ? new File(customDownloadDir) : new File(reactNativeRootDir, "sdks/download")
492
+
493
+ // By default we are going to download and unzip hermes inside the /sdks/hermes folder
494
+ // but you can provide an override for where the hermes source code is located.
495
+ def hermesDir = System.getenv("REACT_NATIVE_OVERRIDE_HERMES_DIR") ?: new File(reactNativeRootDir, "sdks/hermes")
496
+
497
+ def hermesVersion = "main"
498
+ def hermesVersionFile = new File(reactNativeRootDir, "sdks/.hermesversion")
499
+ if (hermesVersionFile.exists()) {
500
+ hermesVersion = hermesVersionFile.text
501
+ }
502
+
503
+ task downloadHermes(type: Download) {
504
+ src("https://github.com/facebook/hermes/tarball/${hermesVersion}")
505
+ onlyIfNewer(true)
506
+ overwrite(false)
507
+ dest(new File(downloadDir, "hermes.tar.gz"))
508
+ }
509
+
510
+ task unzipHermes(dependsOn: downloadHermes, type: Copy) {
511
+ from(tarTree(downloadHermes.dest)) {
512
+ eachFile { file ->
513
+ // We flatten the unzip as the tarball contains a `facebook-hermes-<SHA>`
514
+ // folder at the top level.
515
+ if (file.relativePath.segments.size() > 1) {
516
+ file.relativePath = new org.gradle.api.file.RelativePath(!file.isDirectory(), file.relativePath.segments.drop(1))
517
+ }
518
+ }
519
+ }
520
+ into(hermesDir)
564
521
  }
522
+ }
565
523
 
566
- def hermesAAR = file("$hermesPackagePath/android/hermes-debug.aar")
567
- if (!hermesAAR.exists()) {
568
- throw new GradleScriptException("The hermes-engine npm package is missing \"android/hermes-debug.aar\"", null)
569
- }
524
+ task prepareHermes() {
525
+ if (rnMinorVersion >= 69) {
526
+ if (!isNewArchitectureEnabled()) {
527
+ dependsOn(unzipHermes)
528
+ }
570
529
 
571
- def soFiles = zipTree(hermesAAR).matching({ it.include "**/*.so" })
530
+ doLast {
531
+ def hermesAAR = file("$reactNative/android/com/facebook/react/hermes-engine/$reactNativeVersion/hermes-engine-$reactNativeVersion-${resolveBuildType()}.aar") // e.g. hermes-engine-0.70.0-rc.1-debug.aar
532
+ if (!hermesAAR.exists()) {
533
+ throw new GradleScriptException("Could not find hermes-engine AAR", null)
534
+ }
572
535
 
573
- copy {
574
- from soFiles
575
- from "$reactNative/ReactAndroid/src/main/jni/first-party/hermes/Android.mk"
576
- into "$thirdPartyNdkDir/hermes"
536
+ def soFiles = zipTree(hermesAAR).matching({ it.include "**/*.so" })
537
+
538
+ copy {
539
+ from soFiles
540
+ from "$reactNative/ReactAndroid/src/main/jni/first-party/hermes/Android.mk"
541
+ into "$thirdPartyNdkDir/hermes"
542
+ }
543
+ }
544
+ } else {
545
+ doLast {
546
+ def hermesPackagePath = findNodeModulePath(projectDir, "hermes-engine")
547
+ if (!hermesPackagePath) {
548
+ throw new GradleScriptException("Could not find the hermes-engine npm package", null)
549
+ }
550
+
551
+ def hermesAAR = file("$hermesPackagePath/android/hermes-debug.aar")
552
+ if (!hermesAAR.exists()) {
553
+ throw new GradleScriptException("The hermes-engine npm package is missing \"android/hermes-debug.aar\"", null)
554
+ }
555
+
556
+ def soFiles = zipTree(hermesAAR).matching({ it.include "**/*.so" })
557
+
558
+ copy {
559
+ from soFiles
560
+ from "$reactNative/ReactAndroid/src/main/jni/first-party/hermes/Android.mk"
561
+ into "$thirdPartyNdkDir/hermes"
562
+ }
563
+ }
577
564
  }
578
565
  }
579
566
 
@@ -661,7 +648,7 @@ repositories {
661
648
  dependencies {
662
649
  // noinspection GradleDynamicVersion
663
650
  implementation "com.facebook.yoga:proguard-annotations:1.19.0"
664
- if (isDeveloperMode()) {
651
+ if (isDeveloperMode() && !isNewArchitectureEnabled()) {
665
652
  implementation "com.facebook.fbjni:fbjni:" + FBJNI_VERSION
666
653
  }
667
654
  else {
@@ -669,12 +656,33 @@ dependencies {
669
656
  }
670
657
  implementation "com.facebook.react:react-native:+" // From node_modules
671
658
  implementation "androidx.transition:transition:1.1.0"
659
+ if (rnMinorVersion > 66) {
660
+ implementation "androidx.core:core:1.7.0"
661
+ }
662
+ else {
663
+ implementation "androidx.core:core:1.6.0"
664
+ }
672
665
  extractHeaders("com.facebook.fbjni:fbjni:" + FBJNI_VERSION + ":headers")
673
666
  extractSO("com.facebook.fbjni:fbjni:" + FBJNI_VERSION)
674
667
 
675
- def rnAAR = fileTree("$reactNative/android").matching({ it.include "**/**/*.aar" }).singleFile
676
668
  def jscAAR = fileTree("$reactNative/../jsc-android/dist/org/webkit/android-jsc").matching({ it.include "**/**/*.aar" }).singleFile
677
- extractSO(files(rnAAR, jscAAR))
669
+ extractSO(files(jscAAR))
670
+ }
671
+
672
+ task unpackReactNativeAAR {
673
+ def buildType = resolveBuildType()
674
+ def rnAarMatcher = "**/react-native/**/*${buildType}.aar"
675
+ if (rnMinorVersion < 69) {
676
+ rnAarMatcher = "**/**/*.aar"
677
+ }
678
+ def rnAAR = fileTree("$reactNative/android").matching({ it.include rnAarMatcher }).singleFile
679
+ def file = rnAAR.absoluteFile
680
+ def packageName = file.name.tokenize('-')[0]
681
+ copy {
682
+ from zipTree(file)
683
+ into "$reactNative/ReactAndroid/src/main/jni/first-party/$packageName/"
684
+ include "jni/**/*.so"
685
+ }
678
686
  }
679
687
 
680
688
  task downloadNdkBuildDependencies {
@@ -686,7 +694,7 @@ task downloadNdkBuildDependencies {
686
694
  dependsOn(downloadGlog)
687
695
  }
688
696
 
689
- task prepareThirdPartyNdkHeaders(dependsOn:[downloadNdkBuildDependencies, prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog]) {
697
+ task prepareThirdPartyNdkHeaders(dependsOn:[downloadNdkBuildDependencies, prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog, unpackReactNativeAAR]) {
690
698
  }
691
699
 
692
700
  def nativeBuildDependsOn(dependsOnTask) {
@@ -702,13 +710,31 @@ afterEvaluate {
702
710
  nativeBuildDependsOn(prepareThirdPartyNdkHeaders)
703
711
  nativeBuildDependsOn(extractAARHeaders)
704
712
  nativeBuildDependsOn(extractSOFiles)
713
+
714
+ tasks.forEach({ task ->
715
+ if (task.name.contains("JniLibFolders")) {
716
+ task.dependsOn(packageNdkLibs)
717
+ }
718
+ })
719
+
720
+ if (JS_RUNTIME == "hermes") {
721
+ extractAARHeaders.dependsOn(prepareHermes)
722
+ extractSOFiles.dependsOn(prepareHermes)
723
+ } else if (JS_RUNTIME == "v8") {
724
+ def buildTasks = tasks.findAll({ task ->
725
+ !task.name.contains("Clean") && (task.name.contains("externalNative") || task.name.contains("CMake") || task.name.startsWith("generateJsonModel")) })
726
+ buildTasks.forEach { task ->
727
+ def buildType = task.name.endsWith('Debug') ? 'Debug' : 'Release'
728
+ task.dependsOn(":react-native-v8:copy${buildType}JniLibsProjectOnly")
729
+ }
730
+ }
705
731
  }
706
732
 
707
733
  if (CLIENT_SIDE_BUILD) {
708
734
  def aarDir = "${buildDir}/outputs"
709
- aar = file("${aarDir}/android-debug.aar")
735
+ def aar = file("${aarDir}/android-debug.aar")
710
736
  if (aar == null) {
711
737
  throw GradleScriptException("AAR build failed. No AAR found in ${aarDir}.")
712
738
  }
713
739
  artifacts.add("default", aar)
714
- }
740
+ }
File without changes