react-native-reanimated 2.4.0 → 2.6.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 (437) hide show
  1. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +72 -0
  2. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +30 -1
  3. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +64 -39
  4. package/Common/cpp/Tools/RuntimeDecorator.cpp +2 -0
  5. package/Common/cpp/headers/AnimatedSensor/AnimatedSensorModule.h +41 -0
  6. package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +14 -0
  7. package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +14 -0
  8. package/Common/cpp/headers/SharedItems/MutableValue.h +4 -1
  9. package/Common/cpp/headers/SharedItems/ShareableValue.h +3 -0
  10. package/Common/cpp/headers/SharedItems/ValueWrapper.h +3 -0
  11. package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +11 -0
  12. package/Common/cpp/headers/Tools/RuntimeDecorator.h +2 -0
  13. package/LICENSE +1 -1
  14. package/README.md +2 -2
  15. package/RNReanimated.podspec +15 -6
  16. package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  17. package/android/.gradle/7.2/dependencies-accessors/gc.properties +0 -0
  18. package/android/.gradle/7.2/executionHistory/executionHistory.bin +0 -0
  19. package/android/.gradle/7.2/executionHistory/executionHistory.lock +0 -0
  20. package/android/.gradle/7.2/fileChanges/last-build.bin +0 -0
  21. package/android/.gradle/7.2/fileHashes/fileHashes.bin +0 -0
  22. package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
  23. package/android/.gradle/7.2/fileHashes/resourceHashesCache.bin +0 -0
  24. package/android/.gradle/7.2/gc.properties +0 -0
  25. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  26. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  27. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  28. package/android/.gradle/checksums/checksums.lock +0 -0
  29. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  30. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  31. package/android/.gradle/vcs-1/gc.properties +0 -0
  32. package/android/CMakeLists.txt +198 -0
  33. package/android/README.md +15 -0
  34. package/android/build.gradle +676 -73
  35. package/android/empty.cpp +1 -0
  36. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  37. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  38. package/android/gradle.properties +25 -0
  39. package/android/gradlew +234 -0
  40. package/android/gradlew.bat +89 -0
  41. package/android/react-native-reanimated-64-hermes.aar +0 -0
  42. package/android/react-native-reanimated-64-jsc.aar +0 -0
  43. package/android/react-native-reanimated-65-hermes.aar +0 -0
  44. package/android/react-native-reanimated-65-jsc.aar +0 -0
  45. package/android/react-native-reanimated-66-hermes.aar +0 -0
  46. package/android/react-native-reanimated-66-jsc.aar +0 -0
  47. package/android/react-native-reanimated-67-hermes.aar +0 -0
  48. package/android/react-native-reanimated-67-jsc.aar +0 -0
  49. package/android/react-native-reanimated-68-hermes.aar +0 -0
  50. package/android/react-native-reanimated-68-jsc.aar +0 -0
  51. package/android/rnVersionPatch/62/layoutReanimation/ReanimatedNativeHierarchyManager.java +412 -0
  52. package/android/rnVersionPatch/62/layoutReanimation/ReanimatedUIImplementation.java +68 -0
  53. package/android/rnVersionPatch/63/layoutReanimation/ReanimatedUIImplementation.java +68 -0
  54. package/android/rnVersionPatch/64/layoutReanimation/ReanimatedUIImplementation.java +68 -0
  55. package/android/rnVersionPatch/65/.gitkeep +0 -0
  56. package/android/rnVersionPatch/66/.gitkeep +0 -0
  57. package/android/rnVersionPatch/67/.gitkeep +0 -0
  58. package/android/rnVersionPatch/68/.gitkeep +0 -0
  59. package/android/rnVersionPatch/backup/.gitkeep +0 -0
  60. package/android/settings.gradle +1 -0
  61. package/android/spotless.gradle +9 -0
  62. package/android/src/{AndroidManifest.xml → main/AndroidManifest.xml} +0 -0
  63. package/android/src/main/cpp/AndroidErrorHandler.cpp +42 -0
  64. package/android/src/main/cpp/AndroidLogger.cpp +27 -0
  65. package/android/src/main/cpp/AndroidScheduler.cpp +59 -0
  66. package/android/src/main/cpp/JNIHelper.cpp +59 -0
  67. package/android/src/main/cpp/LayoutAnimations.cpp +103 -0
  68. package/android/src/main/cpp/NativeProxy.cpp +327 -0
  69. package/android/src/main/cpp/OnLoad.cpp +17 -0
  70. package/android/src/main/cpp/TurboModule.cpp +44 -0
  71. package/android/src/main/cpp/headers/AndroidErrorHandler.h +30 -0
  72. package/android/src/main/cpp/headers/AndroidLogger.h +16 -0
  73. package/android/src/main/cpp/headers/AndroidScheduler.h +41 -0
  74. package/android/src/main/cpp/headers/JNIHelper.h +30 -0
  75. package/android/src/main/cpp/headers/LayoutAnimations.h +42 -0
  76. package/android/src/main/cpp/headers/NativeProxy.h +170 -0
  77. package/android/src/main/cpp/headers/TurboModule.h +70 -0
  78. package/android/src/main/java/com/facebook/react/uimanager/UIManagerReanimatedHelper.java +15 -0
  79. package/android/src/main/java/com/swmansion/common/GestureHandlerStateManager.java +5 -0
  80. package/android/src/main/java/com/swmansion/reanimated/AndroidErrorHandler.java +8 -0
  81. package/android/src/main/java/com/swmansion/reanimated/CopiedEvent.java +43 -0
  82. package/android/src/main/java/com/swmansion/reanimated/MapUtils.java +26 -0
  83. package/android/src/main/java/com/swmansion/reanimated/NativeMethodsHelper.java +117 -0
  84. package/android/src/main/java/com/swmansion/reanimated/NativeProxy.java +285 -0
  85. package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +682 -0
  86. package/android/src/main/java/com/swmansion/reanimated/ReanimatedJSIModulePackage.java +29 -0
  87. package/android/src/main/java/com/swmansion/reanimated/ReanimatedModule.java +251 -0
  88. package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +96 -0
  89. package/android/src/main/java/com/swmansion/reanimated/Scheduler.java +51 -0
  90. package/android/src/main/java/com/swmansion/reanimated/UpdateContext.java +11 -0
  91. package/android/src/main/java/com/swmansion/reanimated/Utils.java +32 -0
  92. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +517 -0
  93. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +56 -0
  94. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +11 -0
  95. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +410 -0
  96. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIImplementation.java +68 -0
  97. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +292 -0
  98. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +121 -0
  99. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ViewHierarchyObserver.java +12 -0
  100. package/android/src/main/java/com/swmansion/reanimated/nodes/AlwaysNode.java +29 -0
  101. package/android/src/main/java/com/swmansion/reanimated/nodes/BezierNode.java +87 -0
  102. package/android/src/main/java/com/swmansion/reanimated/nodes/BlockNode.java +24 -0
  103. package/android/src/main/java/com/swmansion/reanimated/nodes/CallFuncNode.java +49 -0
  104. package/android/src/main/java/com/swmansion/reanimated/nodes/ClockNode.java +38 -0
  105. package/android/src/main/java/com/swmansion/reanimated/nodes/ClockOpNode.java +73 -0
  106. package/android/src/main/java/com/swmansion/reanimated/nodes/ConcatNode.java +36 -0
  107. package/android/src/main/java/com/swmansion/reanimated/nodes/CondNode.java +41 -0
  108. package/android/src/main/java/com/swmansion/reanimated/nodes/DebugNode.java +33 -0
  109. package/android/src/main/java/com/swmansion/reanimated/nodes/EventNode.java +83 -0
  110. package/android/src/main/java/com/swmansion/reanimated/nodes/FinalNode.java +5 -0
  111. package/android/src/main/java/com/swmansion/reanimated/nodes/FunctionNode.java +20 -0
  112. package/android/src/main/java/com/swmansion/reanimated/nodes/JSCallNode.java +41 -0
  113. package/android/src/main/java/com/swmansion/reanimated/nodes/Node.java +139 -0
  114. package/android/src/main/java/com/swmansion/reanimated/nodes/NoopNode.java +37 -0
  115. package/android/src/main/java/com/swmansion/reanimated/nodes/OperatorNode.java +377 -0
  116. package/android/src/main/java/com/swmansion/reanimated/nodes/ParamNode.java +71 -0
  117. package/android/src/main/java/com/swmansion/reanimated/nodes/PropsNode.java +153 -0
  118. package/android/src/main/java/com/swmansion/reanimated/nodes/SetNode.java +32 -0
  119. package/android/src/main/java/com/swmansion/reanimated/nodes/StyleNode.java +40 -0
  120. package/android/src/main/java/com/swmansion/reanimated/nodes/TransformNode.java +84 -0
  121. package/android/src/main/java/com/swmansion/reanimated/nodes/ValueNode.java +40 -0
  122. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +41 -0
  123. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +40 -0
  124. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -0
  125. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorType.java +35 -0
  126. package/android/src/main/java/com/swmansion/reanimated/transitions/ChangeTransition.java +84 -0
  127. package/android/src/main/java/com/swmansion/reanimated/transitions/SaneSidePropagation.java +25 -0
  128. package/android/src/main/java/com/swmansion/reanimated/transitions/Scale.java +86 -0
  129. package/android/src/main/java/com/swmansion/reanimated/transitions/TransitionModule.java +41 -0
  130. package/android/src/main/java/com/swmansion/reanimated/transitions/TransitionUtils.java +161 -0
  131. package/ios/LayoutReanimation/REAAnimationsManager.m +14 -4
  132. package/ios/REAModule.m +8 -9
  133. package/ios/REANodesManager.h +4 -1
  134. package/ios/REANodesManager.m +76 -4
  135. package/ios/native/NativeProxy.mm +76 -4
  136. package/ios/sensor/ReanimatedSensor.h +25 -0
  137. package/ios/sensor/ReanimatedSensor.m +217 -0
  138. package/ios/sensor/ReanimatedSensorContainer.h +12 -0
  139. package/ios/sensor/ReanimatedSensorContainer.m +40 -0
  140. package/ios/sensor/ReanimatedSensorType.h +7 -0
  141. package/lib/{src/Animated.js → Animated.js} +0 -0
  142. package/lib/{src/ConfigHelper.js → ConfigHelper.js} +2 -2
  143. package/lib/{src/ReanimatedEventEmitter.js → ReanimatedEventEmitter.js} +0 -0
  144. package/lib/{src/ReanimatedModule.js → ReanimatedModule.js} +0 -0
  145. package/lib/{src/ReanimatedModule.macos.js → ReanimatedModule.macos.js} +0 -0
  146. package/lib/{src/ReanimatedModule.native.js → ReanimatedModule.native.js} +0 -0
  147. package/lib/{src/ReanimatedModule.windows.js → ReanimatedModule.windows.js} +0 -0
  148. package/lib/{src/ReanimatedModuleCompat.js → ReanimatedModuleCompat.js} +0 -0
  149. package/lib/{src/__mocks__ → __mocks__}/ReanimatedEventEmitter.js +0 -0
  150. package/lib/{src/__mocks__ → __mocks__}/ReanimatedModule.native.js +0 -0
  151. package/lib/{src/createAnimatedComponent.js → createAnimatedComponent.js} +3 -4
  152. package/lib/{src/index.js → index.js} +0 -0
  153. package/lib/{src/reanimated1 → reanimated1}/Easing.js +0 -0
  154. package/lib/{src/reanimated1 → reanimated1}/SpringConfig.js +0 -0
  155. package/lib/{src/reanimated1 → reanimated1}/Transitioning.js +0 -0
  156. package/lib/{src/reanimated1 → reanimated1}/animations/Animation.js +0 -0
  157. package/lib/{src/reanimated1 → reanimated1}/animations/SpringUtils.js +0 -0
  158. package/lib/{src/reanimated1 → reanimated1}/animations/backwardCompatibleAnimWrapper.js +0 -0
  159. package/lib/{src/reanimated1 → reanimated1}/animations/decay.js +0 -0
  160. package/lib/{src/reanimated1 → reanimated1}/animations/spring.js +0 -0
  161. package/lib/{src/reanimated1 → reanimated1}/animations/timing.js +0 -0
  162. package/lib/{src/reanimated1 → reanimated1}/base.js +0 -0
  163. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedAlways.js +0 -0
  164. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedBezier.js +0 -0
  165. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedBlock.js +0 -0
  166. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedCall.js +0 -0
  167. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedCallFunc.js +0 -0
  168. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedClock.js +0 -0
  169. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedClockTest.js +0 -0
  170. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedCode.js +0 -0
  171. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedConcat.js +0 -0
  172. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedCond.js +0 -0
  173. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedDebug.js +0 -0
  174. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedEvent.js +0 -0
  175. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedFunction.js +1 -1
  176. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedNode.js +0 -0
  177. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedOperator.js +0 -0
  178. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedParam.js +0 -0
  179. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedProps.js +0 -0
  180. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedSet.js +0 -0
  181. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedStartClock.js +0 -0
  182. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedStopClock.js +0 -0
  183. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedStyle.js +0 -0
  184. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedTransform.js +0 -0
  185. package/lib/{src/reanimated1 → reanimated1}/core/AnimatedValue.js +0 -0
  186. package/lib/{src/reanimated1 → reanimated1}/core/Core.test.js +0 -0
  187. package/lib/{src/reanimated1 → reanimated1}/core/InternalAnimatedValue.js +0 -0
  188. package/lib/{src/reanimated1 → reanimated1}/core/__mocks__/AnimatedProps.js +0 -0
  189. package/lib/{src/reanimated1 → reanimated1}/core/createEventObjectProxyPolyfill.js +0 -0
  190. package/lib/{src/reanimated1 → reanimated1}/derived/__mocks__/evaluateOnce.js +0 -0
  191. package/lib/{src/reanimated1 → reanimated1}/derived/acc.js +0 -0
  192. package/lib/{src/reanimated1 → reanimated1}/derived/color.js +0 -0
  193. package/lib/{src/reanimated1 → reanimated1}/derived/diff.js +0 -0
  194. package/lib/{src/reanimated1 → reanimated1}/derived/diffClamp.js +0 -0
  195. package/lib/{src/reanimated1 → reanimated1}/derived/evaluateOnce.js +0 -0
  196. package/lib/{src/reanimated1 → reanimated1}/derived/index.js +0 -0
  197. package/lib/{src/reanimated1 → reanimated1}/derived/interpolate.js +2 -4
  198. package/lib/{src/reanimated1 → reanimated1}/derived/interpolateColors.js +0 -0
  199. package/lib/{src/reanimated1 → reanimated1}/derived/onChange.js +0 -0
  200. package/lib/{src/reanimated1 → reanimated1}/derived/useCode.js +0 -0
  201. package/lib/{src/reanimated1 → reanimated1}/index.js +0 -0
  202. package/lib/{src/reanimated1 → reanimated1}/operators.js +0 -0
  203. package/lib/{src/reanimated1 → reanimated1}/useValue.js +0 -0
  204. package/lib/{src/reanimated1 → reanimated1}/val.js +0 -0
  205. package/lib/{src/reanimated2 → reanimated2}/Bezier.js +0 -0
  206. package/lib/{src/reanimated2 → reanimated2}/Colors.js +2 -1
  207. package/lib/{src/reanimated2 → reanimated2}/Easing.js +0 -0
  208. package/lib/{src/reanimated2 → reanimated2}/NativeMethods.js +0 -0
  209. package/lib/reanimated2/NativeReanimated/NativeReanimated.js +50 -0
  210. package/lib/{src/reanimated2 → reanimated2}/NativeReanimated/index.js +0 -4
  211. package/lib/{src/reanimated2 → reanimated2}/PlatformChecker.js +0 -0
  212. package/lib/{src/reanimated2 → reanimated2}/PropAdapters.js +0 -0
  213. package/lib/{src/reanimated2 → reanimated2}/UpdateProps.js +0 -0
  214. package/lib/{src/reanimated2 → reanimated2}/ViewDescriptorsSet.js +2 -2
  215. package/lib/{src/reanimated2 → reanimated2}/WorkletEventHandler.js +0 -0
  216. package/lib/{src/reanimated2 → reanimated2}/__mocks__/MutableValue.js +0 -0
  217. package/lib/{src/reanimated2 → reanimated2}/__mocks__/NativeReanimated.js +0 -0
  218. package/lib/{src/reanimated2 → reanimated2}/__mocks__/NativeReanimated.native.js +0 -0
  219. package/lib/{src/reanimated2 → reanimated2}/animation/commonTypes.js +0 -0
  220. package/lib/{src/reanimated2 → reanimated2}/animation/decay.js +0 -0
  221. package/lib/{src/reanimated2 → reanimated2}/animation/delay.js +0 -0
  222. package/lib/{src/reanimated2 → reanimated2}/animation/index.js +0 -0
  223. package/lib/{src/reanimated2 → reanimated2}/animation/repeat.js +0 -0
  224. package/lib/{src/reanimated2 → reanimated2}/animation/sequence.js +0 -0
  225. package/lib/{src/reanimated2 → reanimated2}/animation/spring.js +0 -0
  226. package/lib/{src/reanimated2 → reanimated2}/animation/styleAnimation.js +2 -1
  227. package/lib/{src/reanimated2 → reanimated2}/animation/timing.js +0 -0
  228. package/lib/{src/reanimated2 → reanimated2}/animation/util.js +0 -0
  229. package/lib/{src/reanimated2 → reanimated2}/commonTypes.js +0 -0
  230. package/lib/{src/reanimated2 → reanimated2}/component/FlatList.js +0 -0
  231. package/lib/{src/reanimated2 → reanimated2}/component/WrappedComponents.js +0 -0
  232. package/lib/{src/reanimated2 → reanimated2}/component/index.js +0 -0
  233. package/lib/{src/reanimated2 → reanimated2}/core.js +30 -24
  234. package/lib/{src/reanimated2 → reanimated2}/globals.d.ts +6 -0
  235. package/lib/{src/reanimated2 → reanimated2}/hook/Hooks.js +0 -0
  236. package/lib/{src/reanimated2 → reanimated2}/hook/commonTypes.js +0 -0
  237. package/lib/{src/reanimated2 → reanimated2}/hook/index.js +1 -0
  238. package/lib/{src/reanimated2 → reanimated2}/hook/useAnimatedGestureHandler.js +0 -0
  239. package/lib/{src/reanimated2 → reanimated2}/hook/useAnimatedReaction.js +0 -0
  240. package/lib/{src/reanimated2 → reanimated2}/hook/useAnimatedRef.js +0 -0
  241. package/lib/{src/reanimated2 → reanimated2}/hook/useAnimatedScrollHandler.js +0 -0
  242. package/lib/reanimated2/hook/useAnimatedSensor.js +66 -0
  243. package/lib/{src/reanimated2 → reanimated2}/hook/useAnimatedStyle.js +0 -0
  244. package/lib/{src/reanimated2 → reanimated2}/hook/useDerivedValue.js +0 -0
  245. package/lib/{src/reanimated2 → reanimated2}/hook/useSharedValue.js +0 -0
  246. package/lib/{src/reanimated2 → reanimated2}/hook/utils.js +0 -0
  247. package/lib/{src/reanimated2 → reanimated2}/index.js +0 -0
  248. package/lib/{src/reanimated2 → reanimated2}/interpolateColor.js +11 -11
  249. package/lib/{src/reanimated2 → reanimated2}/interpolation.js +1 -1
  250. package/lib/{src/reanimated2 → reanimated2}/jestUtils.js +9 -4
  251. package/lib/{src/reanimated2 → reanimated2}/js-reanimated/JSReanimated.js +23 -2
  252. package/lib/{src/reanimated2 → reanimated2}/js-reanimated/Mapper.js +0 -0
  253. package/lib/{src/reanimated2 → reanimated2}/js-reanimated/MapperRegistry.js +0 -0
  254. package/lib/{src/reanimated2 → reanimated2}/js-reanimated/MutableValue.js +0 -0
  255. package/lib/{src/reanimated2 → reanimated2}/js-reanimated/commonTypes.js +0 -0
  256. package/lib/{src/reanimated2 → reanimated2}/js-reanimated/index.js +3 -3
  257. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/LayoutAnimationRepository.js +0 -0
  258. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +0 -0
  259. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +8 -0
  260. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/Keyframe.js +2 -1
  261. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/commonTypes.js +0 -0
  262. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/index.js +0 -0
  263. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Bounce.js +32 -42
  264. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Default.js +0 -0
  265. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Fade.js +20 -38
  266. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Flip.js +32 -44
  267. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Lightspeed.js +8 -16
  268. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Pinwheel.js +6 -10
  269. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Roll.js +8 -12
  270. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Rotate.js +20 -36
  271. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Slide.js +16 -20
  272. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Stretch.js +8 -12
  273. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Zoom.js +32 -48
  274. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/index.js +0 -0
  275. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/CurvedTransition.js +0 -0
  276. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/EntryExitTransition.js +22 -18
  277. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/FadingTransition.js +0 -0
  278. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/JumpingTransition.js +0 -0
  279. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/LinearTransition.js +0 -0
  280. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/SequencedTransition.js +0 -0
  281. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/index.js +0 -0
  282. package/lib/{src/reanimated2 → reanimated2}/layoutReanimation/index.js +0 -0
  283. package/lib/{src/reanimated2 → reanimated2}/mock.js +3 -2
  284. package/lib/{src/reanimated2 → reanimated2}/platform-specific/RNRenderer.js +0 -0
  285. package/lib/{src/reanimated2 → reanimated2}/platform-specific/RNRenderer.web.js +0 -0
  286. package/lib/{src/reanimated2 → reanimated2}/utils.js +0 -0
  287. package/lib/{src/setAndForwardRef.js → setAndForwardRef.js} +0 -0
  288. package/lib/types/lib/ConfigHelper.d.ts +12 -0
  289. package/lib/types/lib/ReanimatedEventEmitter.d.ts +3 -0
  290. package/lib/types/lib/ReanimatedModule.d.ts +2 -0
  291. package/lib/types/lib/ReanimatedModule.macos.d.ts +2 -0
  292. package/lib/types/lib/ReanimatedModule.native.d.ts +2 -0
  293. package/lib/types/lib/ReanimatedModule.windows.d.ts +2 -0
  294. package/lib/types/lib/ReanimatedModuleCompat.d.ts +14 -0
  295. package/lib/types/lib/createAnimatedComponent.d.ts +33 -0
  296. package/lib/types/lib/reanimated2/Bezier.d.ts +6 -0
  297. package/lib/types/lib/reanimated2/Colors.d.ts +31 -0
  298. package/lib/types/lib/reanimated2/Easing.d.ts +172 -0
  299. package/lib/types/lib/reanimated2/NativeMethods.d.ts +14 -0
  300. package/lib/types/lib/reanimated2/NativeReanimated/NativeReanimated.d.ts +20 -0
  301. package/lib/types/lib/reanimated2/NativeReanimated/index.d.ts +3 -0
  302. package/lib/types/lib/reanimated2/PlatformChecker.d.ts +5 -0
  303. package/lib/types/lib/reanimated2/PropAdapters.d.ts +4 -0
  304. package/lib/types/lib/reanimated2/UpdateProps.d.ts +9 -0
  305. package/lib/types/lib/reanimated2/ViewDescriptorsSet.d.ts +20 -0
  306. package/lib/types/lib/reanimated2/WorkletEventHandler.d.ts +13 -0
  307. package/lib/types/lib/reanimated2/__mocks__/MutableValue.d.ts +5 -0
  308. package/lib/types/lib/reanimated2/__mocks__/NativeReanimated.d.ts +13 -0
  309. package/lib/types/lib/reanimated2/__mocks__/NativeReanimated.native.d.ts +13 -0
  310. package/lib/types/lib/reanimated2/animation/commonTypes.d.ts +27 -0
  311. package/lib/types/lib/reanimated2/animation/decay.d.ts +19 -0
  312. package/lib/types/lib/reanimated2/animation/delay.d.ts +7 -0
  313. package/lib/types/lib/reanimated2/animation/index.d.ts +9 -0
  314. package/lib/types/lib/reanimated2/animation/repeat.d.ts +12 -0
  315. package/lib/types/lib/reanimated2/animation/sequence.d.ts +7 -0
  316. package/lib/types/lib/reanimated2/animation/spring.d.ts +22 -0
  317. package/lib/types/lib/reanimated2/animation/styleAnimation.d.ts +7 -0
  318. package/lib/types/lib/reanimated2/animation/timing.d.ts +21 -0
  319. package/lib/types/lib/reanimated2/animation/util.d.ts +9 -0
  320. package/lib/types/lib/reanimated2/commonTypes.d.ts +80 -0
  321. package/lib/types/lib/reanimated2/component/FlatList.d.ts +9 -0
  322. package/lib/types/lib/reanimated2/component/WrappedComponents.d.ts +8 -0
  323. package/lib/types/lib/reanimated2/component/index.d.ts +9 -0
  324. package/lib/types/lib/reanimated2/core.d.ts +24 -0
  325. package/lib/types/lib/reanimated2/hook/Hooks.d.ts +5 -0
  326. package/lib/types/lib/reanimated2/hook/commonTypes.d.ts +14 -0
  327. package/lib/types/lib/reanimated2/hook/index.d.ts +10 -0
  328. package/lib/types/lib/reanimated2/hook/useAnimatedGestureHandler.d.ts +35 -0
  329. package/lib/types/lib/reanimated2/hook/useAnimatedReaction.d.ts +12 -0
  330. package/lib/types/lib/reanimated2/hook/useAnimatedRef.d.ts +3 -0
  331. package/lib/types/lib/reanimated2/hook/useAnimatedScrollHandler.d.ts +21 -0
  332. package/lib/types/lib/reanimated2/hook/useAnimatedSensor.d.ts +20 -0
  333. package/lib/types/lib/reanimated2/hook/useAnimatedStyle.d.ts +11 -0
  334. package/lib/types/lib/reanimated2/hook/useDerivedValue.d.ts +4 -0
  335. package/lib/types/lib/reanimated2/hook/useSharedValue.d.ts +2 -0
  336. package/lib/types/lib/reanimated2/hook/utils.d.ts +28 -0
  337. package/lib/types/lib/reanimated2/index.d.ts +12 -0
  338. package/lib/types/lib/reanimated2/interpolateColor.d.ts +26 -0
  339. package/lib/types/lib/reanimated2/interpolation.d.ts +14 -0
  340. package/lib/types/lib/reanimated2/jestUtils.d.ts +12 -0
  341. package/lib/types/lib/reanimated2/js-reanimated/JSReanimated.d.ts +30 -0
  342. package/lib/types/lib/reanimated2/js-reanimated/Mapper.d.ts +14 -0
  343. package/lib/types/lib/reanimated2/js-reanimated/MapperRegistry.d.ts +14 -0
  344. package/lib/types/lib/reanimated2/js-reanimated/MutableValue.d.ts +14 -0
  345. package/lib/types/lib/reanimated2/js-reanimated/commonTypes.d.ts +44 -0
  346. package/lib/types/lib/reanimated2/js-reanimated/index.d.ts +15 -0
  347. package/lib/types/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.d.ts +1 -0
  348. package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.d.ts +22 -0
  349. package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +38 -0
  350. package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/Keyframe.d.ts +25 -0
  351. package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/commonTypes.d.ts +77 -0
  352. package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/index.d.ts +4 -0
  353. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Bounce.d.ts +62 -0
  354. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Default.d.ts +4 -0
  355. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Fade.d.ts +42 -0
  356. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.d.ts +50 -0
  357. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.d.ts +18 -0
  358. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.d.ts +10 -0
  359. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Roll.d.ts +18 -0
  360. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.d.ts +34 -0
  361. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.d.ts +34 -0
  362. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Stretch.d.ts +18 -0
  363. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.d.ts +66 -0
  364. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/index.d.ts +10 -0
  365. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +19 -0
  366. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +13 -0
  367. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.d.ts +6 -0
  368. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +6 -0
  369. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.d.ts +7 -0
  370. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +9 -0
  371. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/index.d.ts +6 -0
  372. package/lib/types/lib/reanimated2/layoutReanimation/index.d.ts +4 -0
  373. package/lib/types/lib/reanimated2/mock.d.ts +55 -0
  374. package/lib/types/lib/reanimated2/platform-specific/RNRenderer.d.ts +1 -0
  375. package/lib/types/lib/reanimated2/platform-specific/RNRenderer.web.d.ts +0 -0
  376. package/lib/types/lib/reanimated2/utils.d.ts +7 -0
  377. package/lib/types/lib/setAndForwardRef.d.ts +40 -0
  378. package/lib/types/react-native-reanimated-tests.d.ts +1 -0
  379. package/mock.js +5 -4
  380. package/package.json +44 -38
  381. package/plugin.js +3 -0
  382. package/react-native-reanimated.d.ts +64 -34
  383. package/src/ConfigHelper.ts +4 -4
  384. package/src/createAnimatedComponent.tsx +4 -4
  385. package/src/reanimated1/core/AnimatedFunction.js +1 -1
  386. package/src/reanimated1/derived/interpolate.js +2 -4
  387. package/src/reanimated2/Colors.ts +2 -1
  388. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +42 -15
  389. package/src/reanimated2/NativeReanimated/index.ts +0 -6
  390. package/src/reanimated2/ViewDescriptorsSet.ts +2 -3
  391. package/src/reanimated2/animation/index.ts +1 -0
  392. package/src/reanimated2/animation/styleAnimation.ts +10 -7
  393. package/src/reanimated2/animation/timing.ts +3 -1
  394. package/src/reanimated2/animation/util.ts +10 -11
  395. package/src/reanimated2/commonTypes.ts +20 -0
  396. package/src/reanimated2/component/FlatList.tsx +3 -2
  397. package/src/reanimated2/core.ts +34 -26
  398. package/src/reanimated2/globals.d.ts +6 -0
  399. package/src/reanimated2/hook/index.ts +1 -0
  400. package/src/reanimated2/hook/useAnimatedSensor.ts +91 -0
  401. package/src/reanimated2/hook/utils.ts +2 -1
  402. package/src/reanimated2/interpolateColor.ts +11 -11
  403. package/src/reanimated2/interpolation.ts +2 -6
  404. package/src/reanimated2/jestUtils.ts +20 -4
  405. package/src/reanimated2/js-reanimated/JSReanimated.ts +25 -2
  406. package/src/reanimated2/js-reanimated/index.ts +3 -3
  407. package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +13 -0
  408. package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +2 -3
  409. package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +51 -21
  410. package/src/reanimated2/layoutReanimation/defaultAnimations/Fade.ts +40 -10
  411. package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +48 -12
  412. package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +16 -4
  413. package/src/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.ts +8 -2
  414. package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +16 -4
  415. package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +32 -8
  416. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -10
  417. package/src/reanimated2/layoutReanimation/defaultAnimations/Stretch.ts +16 -4
  418. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +64 -16
  419. package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +2 -1
  420. package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +26 -19
  421. package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +2 -1
  422. package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +2 -1
  423. package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +2 -1
  424. package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +2 -1
  425. package/src/reanimated2/mock.ts +3 -2
  426. package/android/expo/linking.gradle +0 -46
  427. package/android/expo/src/main/java/com/swmansion/reanimated/EXReanimatedAdapter.java +0 -12
  428. package/android/expo/src/main/java/expo/modules/adapters/reanimated/EXReanimatedPackage.java +0 -26
  429. package/android/react-native-reanimated-63-hermes.aar +0 -0
  430. package/android/react-native-reanimated-63-jsc.aar +0 -0
  431. package/android/src/main/java/com/swmansion/reanimated/ReanimatedProxyPackage.java +0 -15
  432. package/expo-module.config.json +0 -3
  433. package/lib/src/reanimated2/NativeReanimated/NativeReanimated.js +0 -37
  434. package/libSo/fbjni/jni/arm64-v8a/libfbjni.so +0 -0
  435. package/libSo/fbjni/jni/armeabi-v7a/libfbjni.so +0 -0
  436. package/libSo/fbjni/jni/x86/libfbjni.so +0 -0
  437. package/libSo/fbjni/jni/x86_64/libfbjni.so +0 -0
@@ -1,26 +1,128 @@
1
- import groovy.json.JsonSlurper
1
+ import java.nio.file.Paths
2
+ import org.apache.tools.ant.filters.ReplaceTokens
3
+
2
4
  import java.util.regex.Matcher
3
5
  import java.util.regex.Pattern
4
- configurations.maybeCreate("default")
6
+ import groovy.json.JsonSlurper
7
+ import java.util.zip.ZipFile
5
8
 
6
- def inputFile = new File(projectDir, '../../react-native/package.json')
7
- def json = new JsonSlurper().parseText(inputFile.text)
8
- def reactNativeVersion = json.version as String
9
- def (major, minor, patch) = reactNativeVersion.tokenize('.')
9
+ /**
10
+ * Finds the path of the installed npm package with the given name using Node's
11
+ * module resolution algorithm, which searches "node_modules" directories up to
12
+ * the file system root. This handles various cases, including:
13
+ *
14
+ * - Working in the open-source RN repo:
15
+ * Gradle: /path/to/react-native/ReactAndroid
16
+ * Node module: /path/to/react-native/node_modules/[package]
17
+ *
18
+ * - Installing RN as a dependency of an app and searching for hoisted
19
+ * dependencies:
20
+ * Gradle: /path/to/app/node_modules/react-native/ReactAndroid
21
+ * Node module: /path/to/app/node_modules/[package]
22
+ *
23
+ * - Working in a larger repo (e.g., Facebook) that contains RN:
24
+ * Gradle: /path/to/repo/path/to/react-native/ReactAndroid
25
+ * Node module: /path/to/repo/node_modules/[package]
26
+ *
27
+ * The search begins at the given base directory (a File object). The returned
28
+ * path is a string.
29
+ */
30
+ static def findNodeModulePath(baseDir, packageName) {
31
+ def basePath = baseDir.toPath().normalize()
32
+ // Node's module resolution algorithm searches up to the root directory,
33
+ // after which the base path will be null
34
+ while (basePath) {
35
+ def candidatePath = Paths.get(basePath.toString(), "node_modules", packageName)
36
+ if (candidatePath.toFile().exists()) {
37
+ return candidatePath.toString()
38
+ }
39
+ basePath = basePath.getParent()
40
+ }
41
+ return null
42
+ }
43
+
44
+ def safeExtGet(prop, fallback) {
45
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
46
+ }
47
+
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"
58
+ }
59
+
60
+ def resolveBuildType() {
61
+ def buildType = System.getenv("CLIENT_SIDE_BUILD")
62
+ if (buildType != null) {
63
+ return buildType == "True"
64
+ }
65
+
66
+ if (hasProperty("clientSideBuild")) {
67
+ return property("clientSideBuild") == "true"
68
+ }
69
+
70
+ if (isDeveloperMode()) {
71
+ return false
72
+ }
73
+
74
+ return true
75
+ }
10
76
 
11
- def engine = "jsc"
77
+ def isDeveloperMode() {
78
+ // developer mode, to run Example app
79
+ return file("$projectDir/../node_modules/react-native/package.json").exists()
80
+ }
81
+
82
+ def resolveReactNativeDirectory() {
83
+ if (isDeveloperMode()) {
84
+ return file("$projectDir/../node_modules/react-native")
85
+ }
86
+ return file("$projectDir/../../react-native")
87
+ }
12
88
 
13
89
  abstract class replaceSoTask extends DefaultTask {
14
90
  public static String appName = ":app"
15
91
  public static String buildDir = "../../../android/app/build"
92
+ public static String fbjniVersion = "0.3.0"
16
93
 
17
94
  @TaskAction
18
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
+ }
19
121
  for(def abiVersion in ["x86", "x86_64", "armeabi-v7a", "arm64-v8a"]) {
20
122
  ant.sequential {
21
123
  copy(
22
124
  tofile: "${buildDir}/intermediates/merged_native_libs/debug/out/lib/${abiVersion}/libfbjni.so",
23
- file: "../libSo/fbjni/jni/${abiVersion}/libfbjni.so",
125
+ file: "${buildDir}/tmp/libSo/jni/${abiVersion}/libfbjni.so",
24
126
  overwrite: true
25
127
  )
26
128
  }
@@ -28,84 +130,585 @@ abstract class replaceSoTask extends DefaultTask {
28
130
  }
29
131
  }
30
132
 
31
- def getCurrentFlavor() {
32
- Gradle gradle = getGradle()
33
- String taskRequestName = gradle.getStartParameter().getTaskRequests().toString()
34
- Pattern pattern = Pattern.compile("(assemble|bundle|install|generate)(\\w*)(Release|Debug)")
35
- Matcher matcher = pattern.matcher(taskRequestName)
133
+ def detectAAR(minor, engine) {
134
+ def rnMinorVersionCopy = Integer.parseInt(minor)
135
+ def aar = file("react-native-reanimated-${rnMinorVersionCopy}-${engine}.aar")
36
136
 
37
- if(matcher.find()) {
38
- return matcher.group(2)
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
+ }
39
162
  }
163
+ return null
164
+ }
40
165
 
41
- return "NOT-FOUND"
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
42
176
  }
43
177
 
44
- def replaceSoTaskDebug
45
- def replaceSoTaskRelease
46
- if(Integer.parseInt(minor) < 65) {
47
- tasks.register("replaceSoTaskDebug", replaceSoTask)
48
- tasks.register("replaceSoTaskRelease", replaceSoTask)
49
- replaceSoTaskDebug = project.getTasks().getByPath(":react-native-reanimated:replaceSoTaskDebug")
50
- replaceSoTaskRelease = project.getTasks().getByPath(":react-native-reanimated:replaceSoTaskRelease")
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
+ }
192
+
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
201
+ }
202
+ else if (aar != null) {
203
+ // when binary exist
204
+ return false
205
+ }
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
+ }
214
+ def reactNative = resolveReactNativeDirectory()
215
+ def reactNativeManifest = file("$reactNative/package.json")
216
+ def reactNativeManifestAsJson = new JsonSlurper().parseText(reactNativeManifest.text)
217
+ def reactNativeVersion = reactNativeManifestAsJson.version as String
218
+ def (major, minor, patch) = reactNativeVersion.tokenize('.')
219
+ 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)
51
232
  }
52
233
 
53
- rootProject.getSubprojects().forEach({project ->
54
- if (project.plugins.hasPlugin("com.android.application")) {
55
- if(project.ext.react.enableHermes) {
56
- engine = "hermes"
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
+ })
57
276
  }
277
+ }
58
278
 
59
- if(project.getProperties().get("android") && Integer.parseInt(minor) < 65) {
60
- def projectProperties = project.getProperties()
61
- final NOTFOUND = "NOT-FOUND"
62
- if(!NOTFOUND.equals(getCurrentFlavor()) && (!projectProperties.get("reanimated")
63
- || (projectProperties.get("reanimated") && projectProperties.get("reanimated").get("enablePackagingOptions")))
64
- ) {
65
- def flavorString = getCurrentFlavor()
66
- replaceSoTask.appName = project.getProperties().path
67
- replaceSoTask.buildDir = project.getProperties().buildDir
68
- def appName = project.getProperties().path
69
-
70
- replaceSoTaskDebug.dependsOn(
71
- project.getTasks().getByPath("${appName}:merge${flavorString}DebugNativeLibs"),
72
- project.getTasks().getByPath("${appName}:strip${flavorString}DebugDebugSymbols")
73
- )
74
- project.getTasks().getByPath("${appName}:package${flavorString}Debug").dependsOn(replaceSoTaskDebug)
279
+ artifacts.add("default", aar)
280
+ }
75
281
 
76
- replaceSoTaskRelease.dependsOn(
77
- project.getTasks().getByPath("${appName}:merge${flavorString}ReleaseNativeLibs"),
78
- project.getTasks().getByPath("${appName}:strip${flavorString}ReleaseDebugSymbols")
79
- )
80
- project.getTasks().getByPath("${appName}:package${flavorString}Release").dependsOn(replaceSoTaskRelease)
282
+ // end if already loaded aar
283
+ if (!BUILD_FROM_SOURCE) return
284
+
285
+ def localProps = new Properties()
286
+ def localPropertiesFile = file("local.properties")
287
+ if (localPropertiesFile.exists()) {
288
+ localProps.load(new InputStreamReader(new FileInputStream(localPropertiesFile), "UTF-8"))
289
+ }
290
+
291
+ def debugNativeLibraries = localProps.getProperty('NATIVE_DEBUG_ON', 'FALSE').toBoolean()
292
+ def reactProperties = new Properties()
293
+ file("$reactNative/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
294
+
295
+ def BOOST_VERSION = reactProperties.getProperty("BOOST_VERSION")
296
+ def DOUBLE_CONVERSION_VERSION = reactProperties.getProperty("DOUBLE_CONVERSION_VERSION")
297
+ def FOLLY_VERSION = reactProperties.getProperty("FOLLY_VERSION")
298
+ def GLOG_VERSION = reactProperties.getProperty("GLOG_VERSION")
299
+ def REACT_VERSION = reactProperties.getProperty("VERSION_NAME").split("\\.")[1].toInteger()
300
+ def FBJNI_VERSION = "0.3.0"
301
+
302
+ // We download various C++ open-source dependencies into downloads.
303
+ // We then copy both the downloaded code and our custom makefiles and headers into third-party-ndk.
304
+ // After that we build native code from src/main/jni with module path pointing at third-party-ndk.
305
+
306
+ def downloadsDir = new File("$buildDir/downloads")
307
+ def thirdPartyNdkDir = new File("$buildDir/third-party-ndk")
308
+
309
+ def reactNativeThirdParty = new File("$reactNative/ReactAndroid/src/main/jni/third-party")
310
+
311
+ def _stackProtectorFlag = true
312
+ def FOR_HERMES = ""
313
+
314
+ if (findProject(":app")) {
315
+ FOR_HERMES = project(":app").ext.react.enableHermes;
316
+ } else {
317
+ FOR_HERMES = System.getenv("FOR_HERMES") == "True";
318
+ }
319
+
320
+ def reactNativeArchitectures() {
321
+ def value = project.getProperties().get("reactNativeArchitectures")
322
+ return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
323
+ }
324
+
325
+ // You need to have following folders in this directory:
326
+ // - boost_1_63_0
327
+ // - double-conversion-1.1.6
328
+ // - folly-deprecate-dynamic-initializer
329
+ // - glog-0.3.5
330
+ def dependenciesPath = System.getenv("REACT_NATIVE_DEPENDENCIES")
331
+
332
+ // The Boost library is a very large download (>100MB).
333
+ // If Boost is already present on your system, define the REACT_NATIVE_BOOST_PATH env variable
334
+ // and the build will use that.
335
+ def boostPath = dependenciesPath ?: System.getenv("REACT_NATIVE_BOOST_PATH")
336
+
337
+ def follyReplaceContent = '''
338
+ ssize_t r;
339
+ do {
340
+ r = open(name, flags, mode);
341
+ } while (r == -1 && errno == EINTR);
342
+ return r;
343
+ '''
344
+
345
+ buildscript {
346
+ repositories {
347
+ google()
348
+ mavenCentral()
349
+ maven {
350
+ url "https://plugins.gradle.org/m2/"
351
+ }
352
+ }
353
+ dependencies {
354
+ classpath "com.android.tools.build:gradle:4.2.2"
355
+ classpath "de.undercouch:gradle-download-task:4.1.2"
356
+ classpath "com.diffplug.spotless:spotless-plugin-gradle:5.15.0"
357
+ }
358
+ }
359
+
360
+ if (project == rootProject) {
361
+ apply from: "spotless.gradle"
362
+ }
363
+
364
+ apply plugin: "com.android.library"
365
+ apply plugin: "maven-publish"
366
+ apply plugin: "de.undercouch.download"
367
+
368
+ android {
369
+ compileSdkVersion safeExtGet("compileSdkVersion", 30)
370
+ defaultConfig {
371
+ minSdkVersion safeExtGet("minSdkVersion", 16)
372
+ targetSdkVersion safeExtGet("targetSdkVersion", 30)
373
+ versionCode 1
374
+ versionName "1.0"
375
+ externalNativeBuild {
376
+ cmake {
377
+ arguments "-DANDROID_STL=c++_shared",
378
+ "-DNATIVE_DEBUG=${debugNativeLibraries}",
379
+ "-DREACT_NATIVE_TARGET_VERSION=${REACT_VERSION}",
380
+ "-DANDROID_TOOLCHAIN=clang",
381
+ "-DBOOST_VERSION=${BOOST_VERSION}",
382
+ "-DBUILD_DIR=${buildDir}",
383
+ "-DFOR_HERMES=${FOR_HERMES}",
384
+ "-DCLIENT_SIDE_BUILD=${CLIENT_SIDE_BUILD}",
385
+ "--clean-first"
386
+ abiFilters (*reactNativeArchitectures())
387
+ _stackProtectorFlag ? (cppFlags("-fstack-protector-all")) : null
81
388
  }
82
389
  }
390
+
391
+ buildConfigField("boolean", "IS_INTERNAL_BUILD", "false")
392
+ buildConfigField("int", "EXOPACKAGE_FLAGS", "0")
83
393
  }
84
- })
394
+ externalNativeBuild {
395
+ cmake {
396
+ path "CMakeLists.txt"
397
+ }
398
+ }
399
+ lintOptions {
400
+ abortOnError false
401
+ }
402
+ packagingOptions {
403
+ println "Native libs debug enabled: ${debugNativeLibraries}"
404
+ doNotStrip debugNativeLibraries ? "**/**/*.so" : ''
405
+ excludes = [
406
+ "**/libc++_shared.so",
407
+ "**/libfbjni.so",
408
+ "**/libjsi.so",
409
+ "**/libfolly_json.so",
410
+ "**/libglog.so",
411
+ "**/libhermes.so",
412
+ "**/libreactnativejni.so",
413
+ "**/libjscexecutor.so",
414
+ ]
415
+ }
416
+ tasks.withType(JavaCompile) {
417
+ compileTask ->
418
+ compileTask.dependsOn(packageNdkLibs)
419
+ }
420
+ configurations {
421
+ extractHeaders
422
+ extractSO
423
+ }
424
+ compileOptions {
425
+ sourceCompatibility JavaVersion.VERSION_1_8
426
+ targetCompatibility JavaVersion.VERSION_1_8
427
+ }
428
+ }
429
+
430
+ task cleanCmakeCache() {
431
+ tasks.getByName("clean").dependsOn(cleanCmakeCache)
432
+ doFirst {
433
+ delete "${projectDir}/.cxx"
434
+ }
435
+ }
436
+
437
+ task printVersions {
438
+ println "Android gradle plugin: ${com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION}"
439
+ println "Gradle: ${project.gradle.gradleVersion}"
440
+ }
85
441
 
86
- def minorCopy = Integer.parseInt(minor)
87
- def aar = file("react-native-reanimated-${minorCopy}-${engine}.aar")
442
+ task Log {
443
+ println("building Reanimated2")
444
+ }
88
445
 
89
- while (!aar.exists()) {
90
- minorCopy -= 1
91
- aar = file("react-native-reanimated-${minorCopy}-${engine}.aar")
92
- if (minorCopy < 63) {
93
- throw new GradleException('No aar for react-native-reanimated found.')
446
+ task applyJavaPatches(type: Copy) {
447
+ def patchDirectory = file("${projectDir}/rnVersionPatch/${rnMinorVersion}")
448
+ if (patchDirectory.exists()) {
449
+ from ("${patchDirectory}") {
450
+ include "**/*.java"
451
+ }
452
+ into ("${projectDir}/src/main/java/com/swmansion/reanimated")
94
453
  }
95
- if (aar.exists()) {
96
- println "\n\n\n"
97
- println "****************************************************************************************"
98
- println "\n\n\n"
99
- println "WARNING reanimated - no version-specific reanimated AAR for react-native version " + minor + " found."
100
- println "Falling back to AAR for react-native version " + minorCopy
101
- println "The react-native JSI interface is not ABI-safe yet, this may result in crashes."
102
- println "Please post a pull request to implement support for react-native version " + minor + " to the reanimated repo."
103
- println "Thanks!"
104
- println "\n\n\n"
105
- println "****************************************************************************************"
106
- }
107
- }
108
-
109
- artifacts.add("default", aar)
110
-
111
- apply from: './expo/linking.gradle'
454
+ }
455
+
456
+ task createNativeDepsDirectories(dependsOn: applyJavaPatches) {
457
+ downloadsDir.mkdirs()
458
+ thirdPartyNdkDir.mkdirs()
459
+ }
460
+
461
+ 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")
463
+ onlyIfNewer(true)
464
+ overwrite(false)
465
+ dest(new File(downloadsDir, "boost_${BOOST_VERSION}.tar.gz"))
466
+ }
467
+
468
+ task prepareBoost(dependsOn: boostPath ? [] : [downloadBoost], type: Copy) {
469
+ from(boostPath ?: tarTree(resources.gzip(downloadBoost.dest)))
470
+ from("$reactNativeThirdParty/boost/Android.mk")
471
+ include("Android.mk", "boost_${BOOST_VERSION}/boost/**/*.hpp", "boost/boost/**/*.hpp")
472
+ includeEmptyDirs = false
473
+ into("$thirdPartyNdkDir/boost")
474
+ doLast {
475
+ file("$thirdPartyNdkDir/boost/boost").renameTo("$thirdPartyNdkDir/boost/boost_${BOOST_VERSION}")
476
+ }
477
+ }
478
+
479
+ task downloadDoubleConversion(dependsOn: createNativeDepsDirectories, type: Download) {
480
+ src("https://github.com/google/double-conversion/archive/v${DOUBLE_CONVERSION_VERSION}.tar.gz")
481
+ onlyIfNewer(true)
482
+ overwrite(false)
483
+ dest(new File(downloadsDir, "double-conversion-${DOUBLE_CONVERSION_VERSION}.tar.gz"))
484
+ }
485
+
486
+ task prepareDoubleConversion(dependsOn: dependenciesPath ? [] : [downloadDoubleConversion], type: Copy) {
487
+ from(dependenciesPath ?: tarTree(downloadDoubleConversion.dest))
488
+ from("$reactNativeThirdParty/double-conversion/Android.mk")
489
+ include("double-conversion-${DOUBLE_CONVERSION_VERSION}/src/**/*", "Android.mk")
490
+ filesMatching("*/src/**/*", { fname -> fname.path = "double-conversion/${fname.name}" })
491
+ includeEmptyDirs = false
492
+ into("$thirdPartyNdkDir/double-conversion")
493
+ }
494
+
495
+ task downloadFolly(dependsOn: createNativeDepsDirectories, type: Download) {
496
+ src("https://github.com/facebook/folly/archive/v${FOLLY_VERSION}.tar.gz")
497
+ onlyIfNewer(true)
498
+ overwrite(false)
499
+ dest(new File(downloadsDir, "folly-${FOLLY_VERSION}.tar.gz"))
500
+ }
501
+
502
+ task prepareFolly(dependsOn: dependenciesPath ? [] : [downloadFolly], type: Copy) {
503
+ from(dependenciesPath ?: tarTree(downloadFolly.dest))
504
+ from("$reactNativeThirdParty/folly/Android.mk")
505
+ include("folly-${FOLLY_VERSION}/folly/**/*", "Android.mk")
506
+ eachFile { fname -> fname.path = (fname.path - "folly-${FOLLY_VERSION}/") }
507
+ // Fixes problem with Folly failing to build on certain systems. See
508
+ // https://github.com/software-mansion/react-native-reanimated/issues/1024
509
+ filter { line -> line.replaceAll("return int\\(wrapNoInt\\(open, name, flags, mode\\)\\);", follyReplaceContent) }
510
+ includeEmptyDirs = false
511
+ into("$thirdPartyNdkDir/folly")
512
+ }
513
+
514
+ task downloadGlog(dependsOn: createNativeDepsDirectories, type: Download) {
515
+ src("https://github.com/google/glog/archive/v${GLOG_VERSION}.tar.gz")
516
+ onlyIfNewer(true)
517
+ overwrite(false)
518
+ dest(new File(downloadsDir, "glog-${GLOG_VERSION}.tar.gz"))
519
+ }
520
+
521
+ // Prepare glog sources to be compiled, this task will perform steps that normally should've been
522
+ // executed by automake. This way we can avoid dependencies on make/automake
523
+ task prepareGlog(dependsOn: dependenciesPath ? [] : [downloadGlog], type: Copy) {
524
+ duplicatesStrategy = "include"
525
+ from(dependenciesPath ?: tarTree(downloadGlog.dest))
526
+ from("$reactNativeThirdParty/glog/")
527
+ include("glog-${GLOG_VERSION}/src/**/*", "Android.mk", "config.h")
528
+ includeEmptyDirs = false
529
+ filesMatching("**/*.h.in") {
530
+ filter(ReplaceTokens, tokens: [
531
+ ac_cv_have_unistd_h : "1",
532
+ ac_cv_have_stdint_h : "1",
533
+ ac_cv_have_systypes_h : "1",
534
+ ac_cv_have_inttypes_h : "1",
535
+ ac_cv_have_libgflags : "0",
536
+ ac_google_start_namespace : "namespace google {",
537
+ ac_cv_have_uint16_t : "1",
538
+ ac_cv_have_u_int16_t : "1",
539
+ ac_cv_have___uint16 : "0",
540
+ ac_google_end_namespace : "}",
541
+ ac_cv_have___builtin_expect : "1",
542
+ ac_google_namespace : "google",
543
+ ac_cv___attribute___noinline : "__attribute__ ((noinline))",
544
+ ac_cv___attribute___noreturn : "__attribute__ ((noreturn))",
545
+ ac_cv___attribute___printf_4_5: "__attribute__((__format__ (__printf__, 4, 5)))"
546
+ ])
547
+ it.path = (it.name - ".in")
548
+ }
549
+ into("$thirdPartyNdkDir/glog")
550
+
551
+ doLast {
552
+ copy {
553
+ from(fileTree(dir: "$thirdPartyNdkDir/glog", includes: ["stl_logging.h", "logging.h", "raw_logging.h", "vlog_is_on.h", "**/src/glog/log_severity.h"]).files)
554
+ includeEmptyDirs = false
555
+ into("$thirdPartyNdkDir/glog/exported/glog")
556
+ }
557
+ }
558
+ }
559
+
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)
564
+ }
565
+
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
+ }
570
+
571
+ def soFiles = zipTree(hermesAAR).matching({ it.include "**/*.so" })
572
+
573
+ copy {
574
+ from soFiles
575
+ from "$reactNative/ReactAndroid/src/main/jni/first-party/hermes/Android.mk"
576
+ into "$thirdPartyNdkDir/hermes"
577
+ }
578
+ }
579
+
580
+ task prepareJSC {
581
+ doLast {
582
+ def jscPackagePath = findNodeModulePath(projectDir, "jsc-android")
583
+ if (!jscPackagePath) {
584
+ throw new GradleScriptException("Could not find the jsc-android npm package", null)
585
+ }
586
+
587
+ def jscDist = file("$jscPackagePath/dist")
588
+ if (!jscDist.exists()) {
589
+ throw new GradleScriptException("The jsc-android npm package is missing its \"dist\" directory", null)
590
+ }
591
+
592
+ def jscAAR = fileTree(jscDist).matching({ it.include "**/android-jsc/**/*.aar" }).singleFile
593
+ def soFiles = zipTree(jscAAR).matching({ it.include "**/*.so" })
594
+
595
+ def headerFiles = fileTree(jscDist).matching({ it.include "**/include/*.h" })
596
+
597
+ copy {
598
+ from(soFiles)
599
+ from(headerFiles)
600
+ from("$reactNative/ReactAndroid/src/main/jni/third-party/jsc/Android.mk")
601
+
602
+ filesMatching("**/*.h", { it.path = "JavaScriptCore/${it.name}" })
603
+
604
+ includeEmptyDirs(false)
605
+ into("$thirdPartyNdkDir/jsc")
606
+ }
607
+ }
608
+ }
609
+
610
+ task extractAARHeaders {
611
+ doLast {
612
+ configurations.extractHeaders.files.each {
613
+ def file = it.absoluteFile
614
+ def packageName = file.name.tokenize('-')[0]
615
+ copy {
616
+ from zipTree(file)
617
+ into "$reactNative/ReactAndroid/src/main/jni/first-party/$packageName/headers"
618
+ include "**/*.h"
619
+ }
620
+ }
621
+ }
622
+ }
623
+
624
+ task extractSOFiles {
625
+ doLast {
626
+ configurations.extractSO.files.each {
627
+ def file = it.absoluteFile
628
+ def packageName = file.name.tokenize('-')[0]
629
+ copy {
630
+ from zipTree(file)
631
+ into "$reactNative/ReactAndroid/src/main/jni/first-party/$packageName/"
632
+ include "jni/**/*.so"
633
+ }
634
+ }
635
+ }
636
+ }
637
+
638
+ task packageNdkLibs(type: Copy) {
639
+ from("$buildDir/reanimated-ndk/all")
640
+ include("**/libreanimated.so")
641
+ if(REACT_VERSION < 64) {
642
+ include("**/libturbomodulejsijni.so")
643
+ }
644
+ into("$projectDir/src/main/jniLibs")
645
+ }
646
+
647
+ repositories {
648
+ mavenCentral()
649
+ mavenLocal()
650
+ maven {
651
+ // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
652
+ url "$reactNative/android"
653
+ }
654
+ maven {
655
+ // Android JSC is installed from npm
656
+ url "$reactNative/../jsc-android/dist"
657
+ }
658
+ google()
659
+ }
660
+
661
+ dependencies {
662
+ // noinspection GradleDynamicVersion
663
+ implementation "com.facebook.yoga:proguard-annotations:1.19.0"
664
+ if (isDeveloperMode()) {
665
+ implementation "com.facebook.fbjni:fbjni:" + FBJNI_VERSION
666
+ }
667
+ else {
668
+ implementation "com.facebook.fbjni:fbjni-java-only:" + FBJNI_VERSION
669
+ }
670
+ implementation "com.facebook.react:react-native:+" // From node_modules
671
+ implementation "androidx.transition:transition:1.1.0"
672
+ extractHeaders("com.facebook.fbjni:fbjni:" + FBJNI_VERSION + ":headers")
673
+ extractSO("com.facebook.fbjni:fbjni:" + FBJNI_VERSION)
674
+
675
+ def rnAAR = fileTree("$reactNative/android").matching({ it.include "**/**/*.aar" }).singleFile
676
+ def jscAAR = fileTree("$reactNative/../jsc-android/dist/org/webkit/android-jsc").matching({ it.include "**/**/*.aar" }).singleFile
677
+ extractSO(files(rnAAR, jscAAR))
678
+ }
679
+
680
+ task downloadNdkBuildDependencies {
681
+ if (!boostPath) {
682
+ dependsOn(downloadBoost)
683
+ }
684
+ dependsOn(downloadDoubleConversion)
685
+ dependsOn(downloadFolly)
686
+ dependsOn(downloadGlog)
687
+ }
688
+
689
+ task prepareThirdPartyNdkHeaders(dependsOn:[downloadNdkBuildDependencies, prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog]) {
690
+ }
691
+
692
+ def nativeBuildDependsOn(dependsOnTask) {
693
+ def buildTasks = tasks.findAll({ task ->
694
+ !task.name.contains("Clean") && (task.name.contains("externalNative") || task.name.contains("CMake")) })
695
+ buildTasks.forEach { task -> task.dependsOn(dependsOnTask) }
696
+ }
697
+
698
+ afterEvaluate {
699
+ extractAARHeaders.dependsOn(prepareThirdPartyNdkHeaders)
700
+ extractSOFiles.dependsOn(prepareThirdPartyNdkHeaders)
701
+
702
+ nativeBuildDependsOn(prepareThirdPartyNdkHeaders)
703
+ nativeBuildDependsOn(extractAARHeaders)
704
+ nativeBuildDependsOn(extractSOFiles)
705
+ }
706
+
707
+ if (CLIENT_SIDE_BUILD) {
708
+ def aarDir = "${buildDir}/outputs"
709
+ aar = file("${aarDir}/android-debug.aar")
710
+ if (aar == null) {
711
+ throw GradleScriptException("AAR build failed. No AAR found in ${aarDir}.")
712
+ }
713
+ artifacts.add("default", aar)
714
+ }