react-native-reanimated 2.9.1 → 2.11.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 (257) hide show
  1. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +7 -4
  2. package/Common/cpp/{headers/AnimatedSensor → AnimatedSensor}/AnimatedSensorModule.h +0 -0
  3. package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp +2 -0
  4. package/Common/cpp/{headers/LayoutAnimations → LayoutAnimations}/LayoutAnimationsProxy.h +0 -0
  5. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +40 -0
  6. package/Common/cpp/{headers/NativeModules → NativeModules}/NativeReanimatedModule.h +13 -0
  7. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +25 -0
  8. package/Common/cpp/{headers/NativeModules → NativeModules}/NativeReanimatedModuleSpec.h +9 -1
  9. package/Common/cpp/{headers/Registries → Registries}/EventHandlerRegistry.h +0 -0
  10. package/Common/cpp/Registries/MapperRegistry.cpp +3 -1
  11. package/Common/cpp/{headers/Registries → Registries}/MapperRegistry.h +0 -0
  12. package/Common/cpp/Registries/WorkletsCache.cpp +3 -0
  13. package/Common/cpp/{headers/Registries → Registries}/WorkletsCache.h +0 -0
  14. package/Common/cpp/{headers/SharedItems → SharedItems}/FrozenObject.h +0 -0
  15. package/Common/cpp/{headers/SharedItems → SharedItems}/HostFunctionHandler.h +0 -0
  16. package/Common/cpp/SharedItems/MutableValue.cpp +2 -0
  17. package/Common/cpp/{headers/SharedItems → SharedItems}/MutableValue.h +0 -0
  18. package/Common/cpp/{headers/SharedItems → SharedItems}/MutableValueSetterProxy.h +0 -0
  19. package/Common/cpp/{headers/SharedItems → SharedItems}/RemoteObject.h +0 -0
  20. package/Common/cpp/{headers/SharedItems → SharedItems}/RuntimeManager.h +0 -0
  21. package/Common/cpp/SharedItems/ShareableValue.cpp +7 -2
  22. package/Common/cpp/{headers/SharedItems → SharedItems}/ShareableValue.h +0 -0
  23. package/Common/cpp/{headers/SharedItems → SharedItems}/SharedParent.h +0 -0
  24. package/Common/cpp/{headers/SharedItems → SharedItems}/ValueWrapper.h +0 -0
  25. package/Common/cpp/{headers/SpecTools → SpecTools}/ErrorHandler.h +0 -0
  26. package/Common/cpp/{headers/Tools → Tools}/FeaturesConfig.h +0 -0
  27. package/Common/cpp/Tools/JSIStoreValueUser.cpp +2 -2
  28. package/Common/cpp/{headers/Tools → Tools}/JSIStoreValueUser.h +0 -0
  29. package/Common/cpp/{headers/Tools → Tools}/Mapper.h +0 -0
  30. package/Common/cpp/{headers/Tools → Tools}/PlatformDepMethodsHolder.h +5 -0
  31. package/Common/cpp/{headers/Tools → Tools}/ReanimatedHiddenHeaders.h +1 -1
  32. package/Common/cpp/{headers/Tools → Tools}/RuntimeDecorator.h +0 -0
  33. package/Common/cpp/{headers/Tools → Tools}/Scheduler.h +0 -0
  34. package/Common/cpp/Tools/SingleInstanceChecker.h +58 -0
  35. package/Common/cpp/{headers/Tools → Tools}/WorkletEventHandler.h +0 -0
  36. package/RNReanimated.podspec +18 -58
  37. package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
  38. package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
  39. package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
  40. package/android/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  41. package/android/.gradle/{7.2 → 7.5.1}/dependencies-accessors/gc.properties +0 -0
  42. package/android/.gradle/7.5.1/executionHistory/executionHistory.bin +0 -0
  43. package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
  44. package/android/.gradle/{7.2 → 7.5.1}/fileChanges/last-build.bin +0 -0
  45. package/android/.gradle/7.5.1/fileHashes/fileHashes.bin +0 -0
  46. package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
  47. package/android/.gradle/{7.2 → 7.5.1}/fileHashes/resourceHashesCache.bin +0 -0
  48. package/android/.gradle/{7.2 → 7.5.1}/gc.properties +0 -0
  49. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  50. package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
  51. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  52. package/android/.gradle/file-system.probe +0 -0
  53. package/android/CMakeLists.txt +223 -113
  54. package/android/build.gradle +480 -195
  55. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  56. package/android/react-native-reanimated-66-hermes.aar +0 -0
  57. package/android/react-native-reanimated-66-jsc.aar +0 -0
  58. package/android/react-native-reanimated-67-hermes.aar +0 -0
  59. package/android/react-native-reanimated-67-jsc.aar +0 -0
  60. package/android/react-native-reanimated-68-hermes.aar +0 -0
  61. package/android/react-native-reanimated-68-jsc.aar +0 -0
  62. package/android/react-native-reanimated-69-hermes.aar +0 -0
  63. package/android/react-native-reanimated-69-jsc.aar +0 -0
  64. package/android/react-native-reanimated-70-hermes.aar +0 -0
  65. package/android/react-native-reanimated-70-jsc.aar +0 -0
  66. package/{lib/types/lib/reanimated2/platform-specific/RNRenderer.web.d.ts → android/rnVersionPatch/70/.gitkeep} +0 -0
  67. package/android/src/main/cpp/AndroidErrorHandler.cpp +3 -4
  68. package/android/src/main/cpp/{headers/AndroidErrorHandler.h → AndroidErrorHandler.h} +1 -4
  69. package/android/src/main/cpp/AndroidLogger.cpp +4 -1
  70. package/android/src/main/cpp/{headers/AndroidLogger.h → AndroidLogger.h} +0 -0
  71. package/android/src/main/cpp/{headers/AndroidScheduler.h → AndroidScheduler.h} +0 -0
  72. package/android/src/main/cpp/{headers/JNIHelper.h → JNIHelper.h} +0 -0
  73. package/android/src/main/cpp/{headers/LayoutAnimations.h → LayoutAnimations.h} +0 -0
  74. package/android/src/main/cpp/NativeProxy.cpp +60 -28
  75. package/android/src/main/cpp/{headers/NativeProxy.h → NativeProxy.h} +29 -0
  76. package/android/src/main/cpp/OnLoad.cpp +1 -0
  77. package/android/src/main/cpp/{headers/TurboModule.h → TurboModule.h} +0 -0
  78. package/android/src/main/java/com/swmansion/reanimated/NativeProxy.java +29 -5
  79. package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +3 -1
  80. package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +166 -0
  81. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +19 -16
  82. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +5 -1
  83. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorType.java +1 -1
  84. package/ios/{REAModule.m → REAModule.mm} +12 -0
  85. package/ios/REANodesManager.m +31 -8
  86. package/ios/keyboardObserver/REAKeyboardEventObserver.h +17 -0
  87. package/ios/keyboardObserver/REAKeyboardEventObserver.m +198 -0
  88. package/ios/native/NativeProxy.mm +24 -3
  89. package/ios/native/REAInitializer.h +2 -2
  90. package/ios/native/REAInitializer.mm +10 -14
  91. package/ios/native/UIResponder+Reanimated.mm +1 -1
  92. package/ios/sensor/ReanimatedSensor.m +26 -17
  93. package/lib/index.js +11 -3
  94. package/lib/index.web.js +6 -0
  95. package/lib/reanimated2/Colors.js +1 -1
  96. package/lib/reanimated2/NativeMethods.js +34 -17
  97. package/lib/reanimated2/NativeReanimated/NativeReanimated.js +6 -0
  98. package/lib/reanimated2/animation/util.js +4 -1
  99. package/lib/reanimated2/commonTypes.js +8 -1
  100. package/lib/reanimated2/component/FlatList.js +5 -5
  101. package/lib/reanimated2/core.js +5 -4
  102. package/lib/reanimated2/frameCallback/FrameCallbackRegistryJS.js +32 -0
  103. package/lib/reanimated2/frameCallback/FrameCallbackRegistryUI.js +76 -0
  104. package/lib/reanimated2/globals.d.ts +5 -2
  105. package/lib/reanimated2/hook/index.js +3 -0
  106. package/lib/reanimated2/hook/useAnimatedKeyboard.js +31 -0
  107. package/lib/reanimated2/hook/useAnimatedSensor.js +3 -3
  108. package/lib/reanimated2/hook/useFrameCallback.js +23 -0
  109. package/lib/reanimated2/hook/useScrollViewOffset.js +26 -0
  110. package/lib/reanimated2/jestUtils.js +11 -3
  111. package/lib/reanimated2/js-reanimated/JSReanimated.js +7 -0
  112. package/lib/reanimated2/js-reanimated/global.js +33 -22
  113. package/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.js +1 -1
  114. package/lib/reanimated2/utils.js +10 -3
  115. package/lib/types/{lib/Animated.d.ts → Animated.d.ts} +0 -0
  116. package/lib/types/{lib/ConfigHelper.d.ts → ConfigHelper.d.ts} +0 -0
  117. package/lib/types/{lib/ReanimatedEventEmitter.d.ts → ReanimatedEventEmitter.d.ts} +0 -0
  118. package/lib/types/{lib/ReanimatedModule.d.ts → ReanimatedModule.d.ts} +0 -0
  119. package/lib/types/{lib/ReanimatedModule.macos.d.ts → ReanimatedModule.macos.d.ts} +0 -0
  120. package/lib/types/{lib/ReanimatedModule.native.d.ts → ReanimatedModule.native.d.ts} +0 -0
  121. package/lib/types/{lib/ReanimatedModule.windows.d.ts → ReanimatedModule.windows.d.ts} +0 -0
  122. package/lib/types/{lib/ReanimatedModuleCompat.d.ts → ReanimatedModuleCompat.d.ts} +0 -0
  123. package/lib/types/{lib/createAnimatedComponent.d.ts → createAnimatedComponent.d.ts} +0 -0
  124. package/lib/types/index.d.ts +4 -0
  125. package/lib/types/{lib/index.d.ts → index.web.d.ts} +0 -0
  126. package/lib/types/{lib/reanimated2 → reanimated2}/Bezier.d.ts +0 -0
  127. package/lib/types/{lib/reanimated2 → reanimated2}/Colors.d.ts +0 -0
  128. package/lib/types/{lib/reanimated2 → reanimated2}/Easing.d.ts +0 -0
  129. package/lib/types/{lib/reanimated2 → reanimated2}/NativeMethods.d.ts +3 -10
  130. package/lib/types/{lib/reanimated2 → reanimated2}/NativeReanimated/NativeReanimated.d.ts +3 -1
  131. package/lib/types/{lib/reanimated2 → reanimated2}/NativeReanimated/index.d.ts +0 -0
  132. package/lib/types/{lib/reanimated2 → reanimated2}/PlatformChecker.d.ts +0 -0
  133. package/lib/types/{lib/reanimated2 → reanimated2}/PropAdapters.d.ts +0 -0
  134. package/lib/types/{lib/reanimated2 → reanimated2}/UpdateProps.d.ts +0 -0
  135. package/lib/types/{lib/reanimated2 → reanimated2}/ViewDescriptorsSet.d.ts +0 -0
  136. package/lib/types/{lib/reanimated2 → reanimated2}/WorkletEventHandler.d.ts +0 -0
  137. package/lib/types/{lib/reanimated2 → reanimated2}/__mocks__/MutableValue.d.ts +0 -0
  138. package/lib/types/{lib/reanimated2 → reanimated2}/__mocks__/NativeReanimated.d.ts +0 -0
  139. package/lib/types/{lib/reanimated2 → reanimated2}/animation/commonTypes.d.ts +0 -0
  140. package/lib/types/{lib/reanimated2 → reanimated2}/animation/decay.d.ts +0 -0
  141. package/lib/types/{lib/reanimated2 → reanimated2}/animation/delay.d.ts +0 -0
  142. package/lib/types/{lib/reanimated2 → reanimated2}/animation/index.d.ts +0 -0
  143. package/lib/types/{lib/reanimated2 → reanimated2}/animation/repeat.d.ts +0 -0
  144. package/lib/types/{lib/reanimated2 → reanimated2}/animation/sequence.d.ts +0 -0
  145. package/lib/types/{lib/reanimated2 → reanimated2}/animation/spring.d.ts +0 -0
  146. package/lib/types/{lib/reanimated2 → reanimated2}/animation/styleAnimation.d.ts +0 -0
  147. package/lib/types/{lib/reanimated2 → reanimated2}/animation/timing.d.ts +0 -0
  148. package/lib/types/{lib/reanimated2 → reanimated2}/animation/util.d.ts +0 -0
  149. package/lib/types/{lib/reanimated2 → reanimated2}/commonTypes.d.ts +20 -0
  150. package/lib/types/{lib/reanimated2 → reanimated2}/component/FlatList.d.ts +2 -2
  151. package/lib/types/{lib/reanimated2 → reanimated2}/component/Image.d.ts +0 -0
  152. package/lib/types/{lib/reanimated2 → reanimated2}/component/ScrollView.d.ts +0 -0
  153. package/lib/types/{lib/reanimated2 → reanimated2}/component/Text.d.ts +0 -0
  154. package/lib/types/{lib/reanimated2 → reanimated2}/component/View.d.ts +0 -0
  155. package/lib/types/{lib/reanimated2 → reanimated2}/core.d.ts +0 -0
  156. package/lib/types/reanimated2/frameCallback/FrameCallbackRegistryJS.d.ts +8 -0
  157. package/lib/types/reanimated2/frameCallback/FrameCallbackRegistryUI.d.ts +6 -0
  158. package/lib/types/{lib/reanimated2 → reanimated2}/hook/Hooks.d.ts +0 -0
  159. package/lib/types/{lib/reanimated2 → reanimated2}/hook/commonTypes.d.ts +0 -0
  160. package/lib/types/{lib/reanimated2 → reanimated2}/hook/index.d.ts +4 -0
  161. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedGestureHandler.d.ts +0 -0
  162. package/lib/types/reanimated2/hook/useAnimatedKeyboard.d.ts +2 -0
  163. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedReaction.d.ts +0 -0
  164. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedRef.d.ts +0 -0
  165. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedScrollHandler.d.ts +1 -2
  166. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedSensor.d.ts +1 -1
  167. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedStyle.d.ts +0 -0
  168. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useDerivedValue.d.ts +0 -0
  169. package/lib/types/reanimated2/hook/useFrameCallback.d.ts +7 -0
  170. package/lib/types/reanimated2/hook/useScrollViewOffset.d.ts +4 -0
  171. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useSharedValue.d.ts +0 -0
  172. package/lib/types/{lib/reanimated2 → reanimated2}/hook/utils.d.ts +0 -0
  173. package/lib/types/{lib/reanimated2 → reanimated2}/index.d.ts +0 -0
  174. package/lib/types/{lib/reanimated2 → reanimated2}/interpolateColor.d.ts +0 -0
  175. package/lib/types/{lib/reanimated2 → reanimated2}/interpolation.d.ts +0 -0
  176. package/lib/types/{lib/reanimated2 → reanimated2}/jestUtils.d.ts +1 -1
  177. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/JSReanimated.d.ts +3 -1
  178. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/Mapper.d.ts +0 -0
  179. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/MapperRegistry.d.ts +0 -0
  180. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/MutableValue.d.ts +0 -0
  181. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/commonTypes.d.ts +0 -0
  182. package/lib/types/reanimated2/js-reanimated/global.d.ts +2 -0
  183. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/index.d.ts +0 -0
  184. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/LayoutAnimationRepository.d.ts +0 -0
  185. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/BaseAnimationBuilder.d.ts +0 -0
  186. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +0 -0
  187. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/Keyframe.d.ts +0 -0
  188. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/commonTypes.d.ts +0 -0
  189. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/index.d.ts +0 -0
  190. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Bounce.d.ts +0 -0
  191. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Default.d.ts +0 -0
  192. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Fade.d.ts +0 -0
  193. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Flip.d.ts +0 -0
  194. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Lightspeed.d.ts +0 -0
  195. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Pinwheel.d.ts +0 -0
  196. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Roll.d.ts +0 -0
  197. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Rotate.d.ts +0 -0
  198. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Slide.d.ts +0 -0
  199. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Stretch.d.ts +0 -0
  200. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Zoom.d.ts +0 -0
  201. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/index.d.ts +0 -0
  202. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +0 -0
  203. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +0 -0
  204. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/FadingTransition.d.ts +0 -0
  205. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +0 -0
  206. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/LinearTransition.d.ts +0 -0
  207. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +0 -0
  208. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/index.d.ts +0 -0
  209. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/index.d.ts +0 -0
  210. package/lib/types/{lib/reanimated2 → reanimated2}/mock.d.ts +0 -0
  211. package/lib/types/{lib/reanimated2 → reanimated2}/platform-specific/RNRenderer.d.ts +0 -0
  212. package/lib/types/reanimated2/platform-specific/RNRenderer.web.d.ts +0 -0
  213. package/lib/types/{lib/reanimated2 → reanimated2}/utils.d.ts +5 -1
  214. package/lib/types/{lib/setAndForwardRef.d.ts → setAndForwardRef.d.ts} +0 -0
  215. package/mock.js +1 -0
  216. package/package.json +8 -8
  217. package/plugin.js +8 -17
  218. package/react-native-reanimated.d.ts +67 -12
  219. package/scripts/reanimated_utils.rb +65 -0
  220. package/src/index.ts +11 -3
  221. package/src/index.web.ts +7 -0
  222. package/src/reanimated2/Colors.ts +1 -1
  223. package/src/reanimated2/NativeMethods.ts +47 -30
  224. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +9 -0
  225. package/src/reanimated2/animation/util.ts +8 -1
  226. package/src/reanimated2/commonTypes.ts +24 -0
  227. package/src/reanimated2/component/FlatList.tsx +29 -19
  228. package/src/reanimated2/core.ts +8 -8
  229. package/src/reanimated2/frameCallback/FrameCallbackRegistryJS.ts +40 -0
  230. package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +115 -0
  231. package/src/reanimated2/globals.d.ts +5 -2
  232. package/src/reanimated2/hook/index.ts +4 -0
  233. package/src/reanimated2/hook/useAnimatedKeyboard.ts +35 -0
  234. package/src/reanimated2/hook/useAnimatedScrollHandler.ts +3 -1
  235. package/src/reanimated2/hook/useAnimatedSensor.ts +5 -5
  236. package/src/reanimated2/hook/useFrameCallback.ts +40 -0
  237. package/src/reanimated2/hook/useScrollViewOffset.ts +36 -0
  238. package/src/reanimated2/jestUtils.ts +11 -3
  239. package/src/reanimated2/js-reanimated/JSReanimated.ts +16 -1
  240. package/src/reanimated2/js-reanimated/global.ts +41 -29
  241. package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +1 -1
  242. package/src/reanimated2/utils.ts +12 -5
  243. package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  244. package/android/.gradle/7.2/executionHistory/executionHistory.bin +0 -0
  245. package/android/.gradle/7.2/executionHistory/executionHistory.lock +0 -0
  246. package/android/.gradle/7.2/fileHashes/fileHashes.bin +0 -0
  247. package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
  248. package/android/.gradle/checksums/checksums.lock +0 -0
  249. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  250. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  251. package/android/react-native-reanimated-65-hermes.aar +0 -0
  252. package/android/react-native-reanimated-65-jsc.aar +0 -0
  253. package/android/src/main/java/com/swmansion/reanimated/AndroidErrorHandler.java +0 -8
  254. package/lib/reanimated2/__mocks__/NativeReanimated.native.js +0 -20
  255. package/lib/types/lib/reanimated2/__mocks__/NativeReanimated.native.d.ts +0 -13
  256. package/lib/types/lib/reanimated2/js-reanimated/global.d.ts +0 -1
  257. package/lib/types/react-native-reanimated-tests.d.ts +0 -1
@@ -1,10 +1,7 @@
1
- import java.nio.file.Paths
1
+ import com.android.Version
2
2
  import org.apache.tools.ant.filters.ReplaceTokens
3
3
 
4
- import java.util.regex.Matcher
5
- import java.util.regex.Pattern
6
- import groovy.json.JsonSlurper
7
- import java.util.zip.ZipFile
4
+ import java.nio.file.Paths
8
5
 
9
6
  /**
10
7
  * Finds the path of the installed npm package with the given name using Node's
@@ -45,22 +42,27 @@ def safeExtGet(prop, fallback) {
45
42
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
46
43
  }
47
44
 
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)
45
+ def safeAppExtGet(prop, fallback) {
46
+ def appProject = null
47
+ try {
48
+ appProject = project(":app")
49
+ } catch(Exception e) {
50
+ return fallback
55
51
  }
56
-
57
- return "NOT-FOUND"
52
+ appProject?.ext?.has(prop) ? appProject.ext.get(prop) : fallback
58
53
  }
59
54
 
60
55
  def resolveBuildType() {
61
- def buildType = System.getenv("CLIENT_SIDE_BUILD")
62
- if (buildType != null) {
63
- return buildType == "True"
56
+ Gradle gradle = getGradle()
57
+ String tskReqStr = gradle.getStartParameter().getTaskRequests()['args'].toString()
58
+
59
+ return tskReqStr.contains('Release') ? 'release' : 'debug'
60
+ }
61
+
62
+ def resolveClientSideBuild() {
63
+ def clientSideBuild = System.getenv("CLIENT_SIDE_BUILD")
64
+ if (clientSideBuild != null) {
65
+ return clientSideBuild == "True"
64
66
  }
65
67
 
66
68
  if (hasProperty("clientSideBuild")) {
@@ -76,62 +78,174 @@ def resolveBuildType() {
76
78
 
77
79
  def isDeveloperMode() {
78
80
  // developer mode, to run Example app
79
- return file("$projectDir/../node_modules/react-native/package.json").exists()
81
+ return safeAppExtGet("isReanimatedExampleApp", false) || System.getenv("REANIMATED_PACKAGE_BUILD") == "1"
82
+ }
83
+
84
+ def isNewArchitectureEnabled() {
85
+ // To opt-in for the New Architecture, you can either:
86
+ // - Set `newArchEnabled` to true inside the `gradle.properties` file
87
+ // - Invoke gradle with `-newArchEnabled=true`
88
+ // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
89
+ return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
80
90
  }
81
91
 
82
92
  def resolveReactNativeDirectory() {
93
+ def reactNativeLocation = safeAppExtGet("REACT_NATIVE_NODE_MODULES_DIR", null)
94
+ if (reactNativeLocation != null) {
95
+ return file(reactNativeLocation)
96
+ }
97
+
83
98
  if (isDeveloperMode()) {
84
- return file("$projectDir/../node_modules/react-native")
85
- }
86
- return file("$projectDir/../../react-native")
87
- }
88
-
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
- )
99
+ return file("$projectDir/../${getPlaygroundAppName()}/node_modules/react-native")
100
+ }
101
+
102
+ // monorepo workaround
103
+ // react-native can be hoisted or in project's own node_modules
104
+ def reactNativeFromProjectNodeModules = file("${rootProject.projectDir}/../node_modules/react-native")
105
+ if (reactNativeFromProjectNodeModules.exists()) {
106
+ return reactNativeFromProjectNodeModules
107
+ }
108
+
109
+ def reactNativeFromNodeModulesWithReanimated = file("${projectDir}/../../react-native")
110
+ if (reactNativeFromNodeModulesWithReanimated.exists()) {
111
+ return reactNativeFromNodeModulesWithReanimated
112
+ }
113
+
114
+ throw new Exception(
115
+ "[Reanimated] Unable to resolve react-native location in " +
116
+ "node_modules. You should project extension property (in app/build.gradle) " +
117
+ "`REACT_NATIVE_NODE_MODULES_DIR` with path to react-native."
118
+ )
119
+ }
120
+
121
+ def getPlaygroundAppName() { // only for the development
122
+ String playgroundAppName = ""
123
+ try {
124
+ rootProject.getSubprojects().forEach({project ->
125
+ if (project.plugins.hasPlugin("com.android.application")) {
126
+ var projectCatalogAbsolutePath = project.projectDir.toString().replace("/android/app", "")
127
+ var slashPosition = projectCatalogAbsolutePath.lastIndexOf("/")
128
+ playgroundAppName = projectCatalogAbsolutePath.substring(slashPosition + 1)
128
129
  }
130
+ })
131
+ } catch(_) {
132
+ return "NOT_FOUND"
133
+ }
134
+ return playgroundAppName
135
+ }
136
+
137
+ def shouldAssertNoMultipleInstances() {
138
+ if (rootProject.hasProperty("disableMultipleInstancesCheck")) {
139
+ return rootProject.property("disableMultipleInstancesCheck") != "true"
140
+ } else {
141
+ return true
142
+ }
143
+ }
144
+
145
+ def findReanimatedInstancesForPath(String path) {
146
+ return fileTree(path) {
147
+ include "**/react-native-reanimated/package.json"
148
+ exclude "**/.yarn/**"
149
+ exclude {{ file, attr -> attr.isSymbolicLink() }}
150
+ }.files
151
+ }
152
+
153
+ def assertNoMultipleInstances() {
154
+ // Assert there are no multiple installations of Reanimated
155
+ Set<File> files
156
+ if (projectDir.path.contains(rootDir.parent)) {
157
+ // standard app
158
+ files = findReanimatedInstancesForPath(rootDir.parent + "/node_modules")
159
+ } else {
160
+ // monorepo
161
+ files = findReanimatedInstancesForPath(rootDir.parent + "/node_modules")
162
+ files.addAll(
163
+ findReanimatedInstancesForPath(file(projectDir.parent).parent)
164
+ )
165
+ }
166
+ if (files.size() > 1) {
167
+ String parsedLocation = files.stream().map({
168
+ File file -> "- " + file.toString().replace("/package.json", "")
169
+ }).collect().join("\n")
170
+ String exceptionMessage = "\nMultiple versions of Reanimated were detected. Only one " +
171
+ "instance of react-native-reanimated can be installed in a project. You need to " +
172
+ "resolve the conflict manually. Check out the documentation: " +
173
+ "https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/" +
174
+ "troubleshooting#multiple-versions-of-reanimated-were-detected \n\nConflict " +
175
+ "between: \n" + parsedLocation + "\n";
176
+ throw new Exception(exceptionMessage)
177
+ }
178
+ }
179
+
180
+ boolean CLIENT_SIDE_BUILD = resolveClientSideBuild()
181
+ if (CLIENT_SIDE_BUILD) {
182
+ configurations.maybeCreate("default")
183
+ }
184
+
185
+ def reactNativeRootDir = resolveReactNativeDirectory()
186
+
187
+ def reactProperties = new Properties()
188
+ file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
189
+
190
+ def BOOST_VERSION = reactProperties.getProperty("BOOST_VERSION")
191
+ def DOUBLE_CONVERSION_VERSION = reactProperties.getProperty("DOUBLE_CONVERSION_VERSION")
192
+ def FOLLY_VERSION = reactProperties.getProperty("FOLLY_VERSION")
193
+ def GLOG_VERSION = reactProperties.getProperty("GLOG_VERSION")
194
+ def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME")
195
+ def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.split("\\.")[1].toInteger()
196
+ def FBJNI_VERSION = "0.3.0"
197
+ def REANIMATED_PACKAGE_BUILD = System.getenv("REANIMATED_PACKAGE_BUILD")
198
+
199
+ // We download various C++ open-source dependencies into downloads.
200
+ // We then copy both the downloaded code and our custom makefiles and headers into third-party-ndk.
201
+ // After that we build native code from src/main/jni with module path pointing at third-party-ndk.
202
+
203
+ def customDownloadsDir = System.getenv("REACT_NATIVE_DOWNLOADS_DIR")
204
+ def downloadsDir = customDownloadsDir ? new File(customDownloadsDir) : new File("$buildDir/downloads")
205
+ def thirdPartyNdkDir = new File("$buildDir/third-party-ndk")
206
+
207
+ def reactNativeThirdParty = new File("$reactNativeRootDir/ReactAndroid/src/main/jni/third-party")
208
+ def reactNativeAndroidDownloadDir = new File("$reactNativeRootDir/ReactAndroid/build/downloads")
209
+
210
+ def _stackProtectorFlag = true
211
+
212
+ def JS_RUNTIME = {
213
+ // Returns the js runtime explicitly requested in the environment variable
214
+ if (System.getenv("JS_RUNTIME")) {
215
+ return System.getenv("JS_RUNTIME")
216
+ }
217
+
218
+ // Detect js runtime from project setup
219
+ def defaultRuntimeType = "jsc";
220
+ def v8Project = rootProject.getSubprojects().find { project -> project.name == "react-native-v8" }
221
+ if (v8Project != null) {
222
+ return "v8"
223
+ }
224
+ def appProject = findProject(":app") ? project(":app") : null
225
+ return appProject?.ext?.react?.enableHermes ? "hermes" : defaultRuntimeType
226
+ }.call()
227
+
228
+ def jsRuntimeDir = {
229
+ if (JS_RUNTIME == "hermes") {
230
+ if (REACT_NATIVE_MINOR_VERSION >= 69) {
231
+ return Paths.get(reactNativeRootDir.path, "sdks", "hermes")
232
+ } else {
233
+ return Paths.get(reactNativeRootDir.path, "..", "hermes-engine")
129
234
  }
235
+ } else if (JS_RUNTIME == "v8") {
236
+ return findProject(":react-native-v8").getProjectDir().getParent()
237
+ } else {
238
+ return Paths.get(reactNativeRootDir.path, "ReactCommon", "jsi")
130
239
  }
240
+ }.call()
241
+
242
+ def reactNativeArchitectures() {
243
+ def value = project.getProperties().get("reactNativeArchitectures")
244
+ return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
131
245
  }
132
246
 
133
- def detectAAR(minor, engine) {
134
- def rnMinorVersionCopy = Integer.parseInt(minor)
247
+ def detectAAR(Integer rnMinorVersion, String engine) { // Reanimated2 only
248
+ def rnMinorVersionCopy = rnMinorVersion
135
249
  def aar = file("react-native-reanimated-${rnMinorVersionCopy}-${engine}.aar")
136
250
 
137
251
  if (aar.exists()) {
@@ -163,25 +277,13 @@ def detectAAR(minor, engine) {
163
277
  return null
164
278
  }
165
279
 
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() {
280
+ def isUserDemandToBuildFromSource() { // Reanimated2 only
179
281
  def buildFromSourceConf = false
180
282
  rootProject.getSubprojects().forEach({project ->
181
283
  if (project.plugins.hasPlugin("com.android.application")) {
182
284
  if (
183
- project.ext.has("reanimated")
184
- && project.ext.reanimated.buildFromSource
285
+ project.ext.has("reanimated")
286
+ && project.ext.reanimated.buildFromSource
185
287
  ) {
186
288
  buildFromSourceConf = true
187
289
  }
@@ -190,12 +292,15 @@ def detectReanimatedConfig() {
190
292
  return buildFromSourceConf
191
293
  }
192
294
 
193
- def shouldBuildFromSource(aar) {
194
- if (isDeveloperMode()) {
295
+ def shouldBuildFromSource(aar, jsRuntimeName) { // Reanimated2 only
296
+ if (jsRuntimeName == "v8") {
297
+ return true
298
+ }
299
+ else if (isDeveloperMode()) {
195
300
  // Example app
196
301
  return true
197
302
  }
198
- else if (detectReanimatedConfig()) {
303
+ else if (isUserDemandToBuildFromSource()) {
199
304
  // on user demand
200
305
  return true
201
306
  }
@@ -207,21 +312,13 @@ def shouldBuildFromSource(aar) {
207
312
  return true
208
313
  }
209
314
 
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) {
315
+ def getTaskByPath(
316
+ project,
317
+ String appName,
318
+ String secondPart,
319
+ String flavorString,
320
+ String lastPart
321
+ ) { // Reanimated2 only
225
322
  String pathName = "${appName}:${secondPart}${flavorString}${lastPart}"
226
323
  Task task = project.getTasks().findByPath(pathName)
227
324
  if (task != null) {
@@ -231,8 +328,11 @@ def getTaskByPath(project, String appName, String secondPart, String flavorStrin
231
328
  return project.getTasks().findByPath(pathName)
232
329
  }
233
330
 
234
- if (!BUILD_FROM_SOURCE) {
235
- if (rnMinorVersion < 65) {
331
+ def aar = detectAAR(REACT_NATIVE_MINOR_VERSION, JS_RUNTIME)
332
+ boolean BUILD_FROM_SOURCE = shouldBuildFromSource(aar, JS_RUNTIME)
333
+
334
+ if (!BUILD_FROM_SOURCE && !isNewArchitectureEnabled()) { // Reanimated2 only
335
+ if (REACT_NATIVE_MINOR_VERSION < 65) {
236
336
  tasks.register("replaceSoTaskDebug", replaceSoTask)
237
337
  tasks.register("replaceSoTaskRelease", replaceSoTask)
238
338
  Task replaceSoTaskDebug = project.getTasks().findByPath(":react-native-reanimated:replaceSoTaskDebug")
@@ -246,8 +346,8 @@ if (!BUILD_FROM_SOURCE) {
246
346
  def reanimatedConf = projectProperties.get("reanimated")
247
347
 
248
348
  if (
249
- flavorString != "NOT-FOUND"
250
- && (!reanimatedConf || (reanimatedConf && !reanimatedConf.get("enablePackagingOptions")))
349
+ flavorString != "NOT-FOUND"
350
+ && (!reanimatedConf || (reanimatedConf && !reanimatedConf.get("enablePackagingOptions")))
251
351
  ) {
252
352
  replaceSoTask.appName = projectProperties.path
253
353
  replaceSoTask.buildDir = projectProperties.buildDir
@@ -261,9 +361,9 @@ if (!BUILD_FROM_SOURCE) {
261
361
  Task releaseTask = getTaskByPath(project, appName, "package", flavorString, "Release")
262
362
 
263
363
  if (
264
- debugNativeLibsTask != null && debugDebugSymbolsTask != null
265
- && releaseNativeLibsTask != null && releaseDebugSymbolsTask != null
266
- && debugTask != null && releaseTask != null
364
+ debugNativeLibsTask != null && debugDebugSymbolsTask != null
365
+ && releaseNativeLibsTask != null && releaseDebugSymbolsTask != null
366
+ && debugTask != null && releaseTask != null
267
367
  ) {
268
368
  replaceSoTaskDebug.dependsOn(debugNativeLibsTask, debugDebugSymbolsTask)
269
369
  debugTask.dependsOn(replaceSoTaskDebug)
@@ -280,48 +380,9 @@ if (!BUILD_FROM_SOURCE) {
280
380
  }
281
381
 
282
382
  // 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"]
383
+ if (!BUILD_FROM_SOURCE) {
384
+ return
323
385
  }
324
-
325
386
  // You need to have following folders in this directory:
326
387
  // - boost_1_63_0
327
388
  // - double-conversion-1.1.6
@@ -351,9 +412,9 @@ buildscript {
351
412
  }
352
413
  }
353
414
  dependencies {
354
- classpath "com.android.tools.build:gradle:7.1.1"
415
+ classpath "com.android.tools.build:gradle:7.3.0"
355
416
  classpath "de.undercouch:gradle-download-task:5.0.1"
356
- classpath "com.diffplug.spotless:spotless-plugin-gradle:5.15.0"
417
+ classpath "com.diffplug.spotless:spotless-plugin-gradle:6.11.0"
357
418
  }
358
419
  }
359
420
 
@@ -372,16 +433,20 @@ android {
372
433
  targetSdkVersion safeExtGet("targetSdkVersion", 30)
373
434
  versionCode 1
374
435
  versionName "1.0"
436
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
375
437
  externalNativeBuild {
376
438
  cmake {
377
439
  arguments "-DANDROID_STL=c++_shared",
378
- "-DNATIVE_DEBUG=${debugNativeLibraries}",
379
- "-DREACT_NATIVE_TARGET_VERSION=${REACT_VERSION}",
440
+ "-DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION}",
380
441
  "-DANDROID_TOOLCHAIN=clang",
381
442
  "-DBOOST_VERSION=${BOOST_VERSION}",
382
- "-DBUILD_DIR=${buildDir}",
383
- "-DFOR_HERMES=${FOR_HERMES}",
384
- "-DCLIENT_SIDE_BUILD=${CLIENT_SIDE_BUILD}"
443
+ "-DREACT_NATIVE_DIR=${reactNativeRootDir.path}",
444
+ "-DJS_RUNTIME=${JS_RUNTIME}",
445
+ "-DJS_RUNTIME_DIR=${jsRuntimeDir}",
446
+ "-DCLIENT_SIDE_BUILD=${CLIENT_SIDE_BUILD}",
447
+ "-DIS_NEW_ARCHITECTURE_ENABLED=${isNewArchitectureEnabled()}",
448
+ "-DPLAYGROUND_APP_NAME=${getPlaygroundAppName()}",
449
+ "-DREANIMATED_PACKAGE_BUILD=${REANIMATED_PACKAGE_BUILD}"
385
450
  abiFilters (*reactNativeArchitectures())
386
451
  _stackProtectorFlag ? (cppFlags("-fstack-protector-all")) : null
387
452
  }
@@ -389,19 +454,41 @@ android {
389
454
 
390
455
  buildConfigField("boolean", "IS_INTERNAL_BUILD", "false")
391
456
  buildConfigField("int", "EXOPACKAGE_FLAGS", "0")
457
+ buildConfigField("int", "REACT_NATIVE_MINOR_VERSION", REACT_NATIVE_MINOR_VERSION.toString())
392
458
  }
393
459
  externalNativeBuild {
394
460
  cmake {
395
461
  path "CMakeLists.txt"
396
462
  }
397
463
  }
464
+ buildTypes {
465
+ debug {
466
+ externalNativeBuild {
467
+ cmake {
468
+ if (JS_RUNTIME == "hermes") {
469
+ arguments "-DHERMES_ENABLE_DEBUGGER=1"
470
+ } else {
471
+ arguments "-DHERMES_ENABLE_DEBUGGER=0"
472
+ }
473
+ }
474
+ }
475
+ }
476
+ release {
477
+ externalNativeBuild {
478
+ cmake {
479
+ arguments "-DHERMES_ENABLE_DEBUGGER=0"
480
+ }
481
+ }
482
+ }
483
+ }
398
484
  lintOptions {
399
485
  abortOnError false
400
486
  }
401
487
  packagingOptions {
402
- println "Native libs debug enabled: ${debugNativeLibraries}"
403
- doNotStrip debugNativeLibraries ? "**/**/*.so" : ''
488
+ doNotStrip resolveBuildType() == 'debug' ? "**/**/*.so" : ''
404
489
  excludes = [
490
+ "META-INF",
491
+ "META-INF/**",
405
492
  "**/libc++_shared.so",
406
493
  "**/libfbjni.so",
407
494
  "**/libjsi.so",
@@ -409,8 +496,10 @@ android {
409
496
  "**/libfolly_runtime.so",
410
497
  "**/libglog.so",
411
498
  "**/libhermes.so",
499
+ "**/libhermes-executor-debug.so",
412
500
  "**/libreactnativejni.so",
413
501
  "**/libjscexecutor.so",
502
+ "**/libv8executor.so",
414
503
  ]
415
504
  }
416
505
  tasks.withType(JavaCompile) {
@@ -425,6 +514,38 @@ android {
425
514
  sourceCompatibility JavaVersion.VERSION_1_8
426
515
  targetCompatibility JavaVersion.VERSION_1_8
427
516
  }
517
+ packagingOptions {
518
+ // For some reason gradle only complains about the duplicated version of librrc_root and libreact_render libraries
519
+ // while there are more libraries copied in intermediates folder of the lib build directory, we exclude
520
+ // only the ones that make the build fail (ideally we should only include libreanimated but we
521
+ // are only allowed to specify exlude patterns)
522
+ exclude "**/libreact_render*.so"
523
+ exclude "**/librrc_root.so"
524
+ }
525
+ sourceSets.main {
526
+ java {
527
+ if (isNewArchitectureEnabled()) {
528
+ srcDirs += [
529
+ "src/fabric/java",
530
+ ]
531
+ } else {
532
+ srcDirs += [
533
+ "src/paper/java",
534
+ ]
535
+ }
536
+ }
537
+ }
538
+ }
539
+
540
+ def assertionTask = task assertNoMultipleInstancesTask {
541
+ onlyIf { shouldAssertNoMultipleInstances() && CLIENT_SIDE_BUILD }
542
+ doFirst {
543
+ assertNoMultipleInstances()
544
+ }
545
+ }
546
+
547
+ tasks.preBuild {
548
+ dependsOn assertionTask
428
549
  }
429
550
 
430
551
  task cleanCmakeCache() {
@@ -435,7 +556,7 @@ task cleanCmakeCache() {
435
556
  }
436
557
 
437
558
  task printVersions {
438
- println "Android gradle plugin: ${com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION}"
559
+ println "Android gradle plugin: ${Version.ANDROID_GRADLE_PLUGIN_VERSION}"
439
560
  println "Gradle: ${project.gradle.gradleVersion}"
440
561
  }
441
562
 
@@ -444,7 +565,7 @@ task Log {
444
565
  }
445
566
 
446
567
  task applyJavaPatches(type: Copy) {
447
- def patchDirectory = file("${projectDir}/rnVersionPatch/${rnMinorVersion}")
568
+ def patchDirectory = file("${projectDir}/rnVersionPatch/${REACT_NATIVE_MINOR_VERSION}")
448
569
  if (patchDirectory.exists()) {
449
570
  from ("${patchDirectory}") {
450
571
  include "**/*.java"
@@ -458,16 +579,70 @@ task createNativeDepsDirectories(dependsOn: applyJavaPatches) {
458
579
  thirdPartyNdkDir.mkdirs()
459
580
  }
460
581
 
461
- task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) {
582
+ def resolveTaskFactory(String taskName, String artifactLocalName, File reactNativeAndroidDownloadDir, File reanimatedDownloadDir) {
583
+ return tasks.create(name: taskName, dependsOn: createNativeDepsDirectories, type: Copy) {
584
+ from reactNativeAndroidDownloadDir
585
+ include artifactLocalName
586
+ into reanimatedDownloadDir
587
+
588
+ onlyIf {
589
+ // First we check whether the file is already in our download directory
590
+ if (file("$reanimatedDownloadDir/$artifactLocalName").isFile()) {
591
+ return false
592
+ }
593
+
594
+ // If it is not the case we check whether it was downloaded by ReactAndroid project
595
+ if (file("$reactNativeAndroidDownloadDir/$artifactLocalName").isFile()) {
596
+ return true
597
+ }
598
+
599
+ return false
600
+ }
601
+ }
602
+ }
603
+
604
+ Task resolveBoost = resolveTaskFactory("resolveBoost", "boost_${BOOST_VERSION}.tar.gz", reactNativeAndroidDownloadDir, downloadsDir)
605
+ Task resolveDoubleConversion = resolveTaskFactory(
606
+ "resolveDoubleConversion",
607
+ "double-conversion-${DOUBLE_CONVERSION_VERSION}.tar.gz",
608
+ reactNativeAndroidDownloadDir,
609
+ downloadsDir
610
+ )
611
+ Task resolveFolly = resolveTaskFactory("resolveFolly", "folly-${FOLLY_VERSION}.tar.gz", reactNativeAndroidDownloadDir, downloadsDir)
612
+ Task resolveGlog = resolveTaskFactory("resolveGlog", "glog-${GLOG_VERSION}.tar.gz", reactNativeAndroidDownloadDir, downloadsDir)
613
+
614
+ if (isNewArchitectureEnabled()) {
615
+ def reactNativeAndroidProject = findProject(":ReactAndroid")
616
+ if (reactNativeAndroidProject != null) {
617
+ reactNativeAndroidProject.afterEvaluate {
618
+ def resolveTasks = [resolveBoost, resolveGlog, resolveDoubleConversion, resolveFolly]
619
+ resolveTasks.forEach({ task ->
620
+ String reactAndroidDownloadTaskName = "download" + task.name.replace("resolve", "")
621
+ def reactAndroidDownloadTask = reactNativeAndroidProject.getTasks().findByName(reactAndroidDownloadTaskName)
622
+ if (reactAndroidDownloadTask != null) {
623
+ task.dependsOn(reactAndroidDownloadTask)
624
+ } else {
625
+ logger.warn("[Reanimated] Failed to find task named `$reactAndroidDownloadTaskName` in `:ReactAndroid` project." +
626
+ " Explicit dependency between it and $task.name task can not be set.")
627
+ }
628
+ })
629
+ }
630
+ } else {
631
+ throw new GradleScriptException("[Reanimated] Failed to find `:ReactAndroid` project. Explicit dependency between download tasks can not be set.")
632
+ }
633
+ }
634
+
635
+ task downloadBoost(dependsOn: resolveBoost, type: Download) {
462
636
  def transformedVersion = BOOST_VERSION.replace("_", ".")
637
+ def artifactLocalName = "boost_${BOOST_VERSION}.tar.gz"
463
638
  def srcUrl = "https://boostorg.jfrog.io/artifactory/main/release/${transformedVersion}/source/boost_${BOOST_VERSION}.tar.gz"
464
- if (rnMinorVersion < 69) {
639
+ if (REACT_NATIVE_MINOR_VERSION < 69) {
465
640
  srcUrl = "https://github.com/react-native-community/boost-for-react-native/releases/download/v${transformedVersion}-0/boost_${BOOST_VERSION}.tar.gz"
466
641
  }
467
642
  src(srcUrl)
468
643
  onlyIfNewer(true)
469
644
  overwrite(false)
470
- dest(new File(downloadsDir, "boost_${BOOST_VERSION}.tar.gz"))
645
+ dest(new File(downloadsDir, artifactLocalName))
471
646
  }
472
647
 
473
648
  task prepareBoost(dependsOn: boostPath ? [] : [downloadBoost], type: Copy) {
@@ -481,7 +656,7 @@ task prepareBoost(dependsOn: boostPath ? [] : [downloadBoost], type: Copy) {
481
656
  }
482
657
  }
483
658
 
484
- task downloadDoubleConversion(dependsOn: createNativeDepsDirectories, type: Download) {
659
+ task downloadDoubleConversion(dependsOn: resolveDoubleConversion, type: Download) {
485
660
  src("https://github.com/google/double-conversion/archive/v${DOUBLE_CONVERSION_VERSION}.tar.gz")
486
661
  onlyIfNewer(true)
487
662
  overwrite(false)
@@ -497,7 +672,7 @@ task prepareDoubleConversion(dependsOn: dependenciesPath ? [] : [downloadDoubleC
497
672
  into("$thirdPartyNdkDir/double-conversion")
498
673
  }
499
674
 
500
- task downloadFolly(dependsOn: createNativeDepsDirectories, type: Download) {
675
+ task downloadFolly(dependsOn: resolveFolly, type: Download) {
501
676
  src("https://github.com/facebook/folly/archive/v${FOLLY_VERSION}.tar.gz")
502
677
  onlyIfNewer(true)
503
678
  overwrite(false)
@@ -516,7 +691,7 @@ task prepareFolly(dependsOn: dependenciesPath ? [] : [downloadFolly], type: Copy
516
691
  into("$thirdPartyNdkDir/folly")
517
692
  }
518
693
 
519
- task downloadGlog(dependsOn: createNativeDepsDirectories, type: Download) {
694
+ task downloadGlog(dependsOn: resolveGlog, type: Download) {
520
695
  src("https://github.com/google/glog/archive/v${GLOG_VERSION}.tar.gz")
521
696
  onlyIfNewer(true)
522
697
  overwrite(false)
@@ -562,23 +737,97 @@ task prepareGlog(dependsOn: dependenciesPath ? [] : [downloadGlog], type: Copy)
562
737
  }
563
738
  }
564
739
 
565
- task prepareHermes() {
566
- def hermesPackagePath = findNodeModulePath(projectDir, "hermes-engine")
567
- if (!hermesPackagePath) {
568
- throw new GradleScriptException("Could not find the hermes-engine npm package", null)
740
+ /*
741
+ Reanimated includes "hermes/hermes.h" header file in `NativeProxy.cpp`.
742
+ Previously, we used header files from `hermes-engine` package in `node_modules`.
743
+ Starting from React Native 0.69, Hermes is no longer distributed as package on NPM.
744
+ On the new architecture, Hermes is downloaded from GitHub and then compiled from sources.
745
+ However, on the old architecture, we need to download Hermes header files on our own
746
+ as well as unzip Hermes AAR in order to obtain `libhermes.so` shared library.
747
+ For more details, see https://reactnative.dev/architecture/bundled-hermes
748
+ or https://github.com/reactwg/react-native-new-architecture/discussions/4
749
+ */
750
+ if (REACT_NATIVE_MINOR_VERSION >= 69 && !isNewArchitectureEnabled()) {
751
+ // copied from `react-native/ReactAndroid/hermes-engine/build.gradle`
752
+
753
+ def downloadDir = customDownloadsDir ? new File(customDownloadsDir) : new File(reactNativeRootDir, "sdks/download")
754
+
755
+ // By default we are going to download and unzip hermes inside the /sdks/hermes folder
756
+ // but you can provide an override for where the hermes source code is located.
757
+ def hermesDir = System.getenv("REACT_NATIVE_OVERRIDE_HERMES_DIR") ?: new File(reactNativeRootDir, "sdks/hermes")
758
+
759
+ def hermesVersion = "main"
760
+ def hermesVersionFile = new File(reactNativeRootDir, "sdks/.hermesversion")
761
+ if (hermesVersionFile.exists()) {
762
+ hermesVersion = hermesVersionFile.text
569
763
  }
570
764
 
571
- def hermesAAR = file("$hermesPackagePath/android/hermes-debug.aar")
572
- if (!hermesAAR.exists()) {
573
- throw new GradleScriptException("The hermes-engine npm package is missing \"android/hermes-debug.aar\"", null)
765
+ task downloadHermes(type: Download) {
766
+ src("https://github.com/facebook/hermes/tarball/${hermesVersion}")
767
+ onlyIfNewer(true)
768
+ overwrite(false)
769
+ dest(new File(downloadDir, "hermes.tar.gz"))
574
770
  }
575
771
 
576
- def soFiles = zipTree(hermesAAR).matching({ it.include "**/*.so" })
772
+ task unzipHermes(dependsOn: downloadHermes, type: Copy) {
773
+ from(tarTree(downloadHermes.dest)) {
774
+ eachFile { file ->
775
+ // We flatten the unzip as the tarball contains a `facebook-hermes-<SHA>`
776
+ // folder at the top level.
777
+ if (file.relativePath.segments.size() > 1) {
778
+ file.relativePath = new RelativePath(!file.isDirectory(), file.relativePath.segments.drop(1))
779
+ }
780
+ }
781
+ }
782
+ into(hermesDir)
783
+ }
784
+ }
577
785
 
578
- copy {
579
- from soFiles
580
- from "$reactNative/ReactAndroid/src/main/jni/first-party/hermes/Android.mk"
581
- into "$thirdPartyNdkDir/hermes"
786
+ task prepareHermes() {
787
+ if (REACT_NATIVE_MINOR_VERSION >= 69) {
788
+ if (!isNewArchitectureEnabled()) {
789
+ dependsOn(unzipHermes)
790
+ }
791
+
792
+ doLast {
793
+ // e.g. hermes-engine-0.70.0-rc.1-debug.aar
794
+ def hermesAAR = file(
795
+ "$reactNativeRootDir/android/com/facebook/react/hermes-engine/" +
796
+ "${REACT_NATIVE_VERSION}/hermes-engine-${REACT_NATIVE_VERSION}-" +
797
+ "${resolveBuildType()}.aar"
798
+ )
799
+ if (!hermesAAR.exists()) {
800
+ throw new GradleScriptException("Could not find hermes-engine AAR", null)
801
+ }
802
+
803
+ def soFiles = zipTree(hermesAAR).matching({ it.include "**/*.so" })
804
+
805
+ copy {
806
+ from soFiles
807
+ from "$reactNativeRootDir/ReactAndroid/src/main/jni/first-party/hermes/Android.mk"
808
+ into "$thirdPartyNdkDir/hermes"
809
+ }
810
+ }
811
+ } else {
812
+ doLast {
813
+ def hermesPackagePath = findNodeModulePath(projectDir, "hermes-engine")
814
+ if (!hermesPackagePath) {
815
+ throw new GradleScriptException("Could not find the hermes-engine npm package", null)
816
+ }
817
+
818
+ def hermesAAR = file("$hermesPackagePath/android/hermes-${resolveBuildType()}.aar") // e.g. hermes-debug.aar
819
+ if (!hermesAAR.exists()) {
820
+ throw new GradleScriptException("The hermes-engine npm package is missing \"android/hermes-${resolveBuildType()}.aar\"", null)
821
+ }
822
+
823
+ def soFiles = zipTree(hermesAAR).matching({ it.include "**/*.so" })
824
+
825
+ copy {
826
+ from soFiles
827
+ from "$reactNativeRootDir/ReactAndroid/src/main/jni/first-party/hermes/Android.mk"
828
+ into "$thirdPartyNdkDir/hermes"
829
+ }
830
+ }
582
831
  }
583
832
  }
584
833
 
@@ -602,7 +851,7 @@ task prepareJSC {
602
851
  copy {
603
852
  from(soFiles)
604
853
  from(headerFiles)
605
- from("$reactNative/ReactAndroid/src/main/jni/third-party/jsc/Android.mk")
854
+ from("$reactNativeRootDir/ReactAndroid/src/main/jni/third-party/jsc/Android.mk")
606
855
 
607
856
  filesMatching("**/*.h", { it.path = "JavaScriptCore/${it.name}" })
608
857
 
@@ -619,7 +868,7 @@ task extractAARHeaders {
619
868
  def packageName = file.name.tokenize('-')[0]
620
869
  copy {
621
870
  from zipTree(file)
622
- into "$reactNative/ReactAndroid/src/main/jni/first-party/$packageName/headers"
871
+ into "$reactNativeRootDir/ReactAndroid/src/main/jni/first-party/$packageName/headers"
623
872
  include "**/*.h"
624
873
  }
625
874
  }
@@ -633,7 +882,7 @@ task extractSOFiles {
633
882
  def packageName = file.name.tokenize('-')[0]
634
883
  copy {
635
884
  from zipTree(file)
636
- into "$reactNative/ReactAndroid/src/main/jni/first-party/$packageName/"
885
+ into "$reactNativeRootDir/ReactAndroid/src/main/jni/first-party/$packageName/"
637
886
  include "jni/**/*.so"
638
887
  }
639
888
  }
@@ -643,7 +892,7 @@ task extractSOFiles {
643
892
  task packageNdkLibs(type: Copy) {
644
893
  from("$buildDir/reanimated-ndk/all")
645
894
  include("**/libreanimated.so")
646
- if(REACT_VERSION < 64) {
895
+ if(REACT_NATIVE_MINOR_VERSION < 64) {
647
896
  include("**/libturbomodulejsijni.so")
648
897
  }
649
898
  into("$projectDir/src/main/jniLibs")
@@ -654,11 +903,11 @@ repositories {
654
903
  mavenLocal()
655
904
  maven {
656
905
  // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
657
- url "$reactNative/android"
906
+ url "$reactNativeRootDir/android"
658
907
  }
659
908
  maven {
660
909
  // Android JSC is installed from npm
661
- url "$reactNative/../jsc-android/dist"
910
+ url "$reactNativeRootDir/../jsc-android/dist"
662
911
  }
663
912
  google()
664
913
  }
@@ -666,7 +915,7 @@ repositories {
666
915
  dependencies {
667
916
  // noinspection GradleDynamicVersion
668
917
  implementation "com.facebook.yoga:proguard-annotations:1.19.0"
669
- if (isDeveloperMode()) {
918
+ if (isDeveloperMode() && !isNewArchitectureEnabled()) {
670
919
  implementation "com.facebook.fbjni:fbjni:" + FBJNI_VERSION
671
920
  }
672
921
  else {
@@ -674,22 +923,29 @@ dependencies {
674
923
  }
675
924
  implementation "com.facebook.react:react-native:+" // From node_modules
676
925
  implementation "androidx.transition:transition:1.1.0"
926
+ implementation "androidx.core:core:1.6.0"
927
+
677
928
  extractHeaders("com.facebook.fbjni:fbjni:" + FBJNI_VERSION + ":headers")
678
929
  extractSO("com.facebook.fbjni:fbjni:" + FBJNI_VERSION)
679
930
 
680
- def buildType = "debug"
681
- tasks.all({ task ->
682
- if (task.name == "buildCMakeRelease") {
683
- buildType = "release"
684
- }
685
- })
931
+ def jscAAR = fileTree("$reactNativeRootDir/../jsc-android/dist/org/webkit/android-jsc").matching({ it.include "**/**/*.aar" }).singleFile
932
+ extractSO(files(jscAAR))
933
+ }
934
+
935
+ task unpackReactNativeAAR {
936
+ def buildType = resolveBuildType()
686
937
  def rnAarMatcher = "**/react-native/**/*${buildType}.aar"
687
- if (rnMinorVersion < 69) {
938
+ if (REACT_NATIVE_MINOR_VERSION < 69) {
688
939
  rnAarMatcher = "**/**/*.aar"
689
940
  }
690
- def rnAAR = fileTree("$reactNative/android").matching({ it.include rnAarMatcher }).singleFile
691
- def jscAAR = fileTree("$reactNative/../jsc-android/dist/org/webkit/android-jsc").matching({ it.include "**/**/*.aar" }).singleFile
692
- extractSO(files(rnAAR, jscAAR))
941
+ def rnAAR = fileTree("$reactNativeRootDir/android").matching({ it.include rnAarMatcher }).singleFile
942
+ def file = rnAAR.absoluteFile
943
+ def packageName = file.name.tokenize('-')[0]
944
+ copy {
945
+ from zipTree(file)
946
+ into "$reactNativeRootDir/ReactAndroid/src/main/jni/first-party/$packageName/"
947
+ include "jni/**/*.so"
948
+ }
693
949
  }
694
950
 
695
951
  task downloadNdkBuildDependencies {
@@ -701,8 +957,14 @@ task downloadNdkBuildDependencies {
701
957
  dependsOn(downloadGlog)
702
958
  }
703
959
 
704
- task prepareThirdPartyNdkHeaders(dependsOn:[downloadNdkBuildDependencies, prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog]) {
705
- }
960
+ task prepareThirdPartyNdkHeaders(dependsOn:[
961
+ downloadNdkBuildDependencies,
962
+ prepareBoost,
963
+ prepareDoubleConversion,
964
+ prepareFolly,
965
+ prepareGlog,
966
+ unpackReactNativeAAR]
967
+ ) {}
706
968
 
707
969
  def nativeBuildDependsOn(dependsOnTask) {
708
970
  def buildTasks = tasks.findAll({ task ->
@@ -717,13 +979,36 @@ afterEvaluate {
717
979
  nativeBuildDependsOn(prepareThirdPartyNdkHeaders)
718
980
  nativeBuildDependsOn(extractAARHeaders)
719
981
  nativeBuildDependsOn(extractSOFiles)
982
+
983
+ tasks.forEach({ task ->
984
+ if (task.name.contains("JniLibFolders")) {
985
+ task.dependsOn(packageNdkLibs)
986
+ }
987
+ })
988
+
989
+ if (JS_RUNTIME == "hermes") {
990
+ extractAARHeaders.dependsOn(prepareHermes)
991
+ extractSOFiles.dependsOn(prepareHermes)
992
+ } else if (JS_RUNTIME == "v8") {
993
+ def buildTasks = tasks.findAll({ task ->
994
+ !task.name.contains("Clean") && (task.name.contains("externalNative") || task.name.contains("CMake") || task.name.startsWith("generateJsonModel")) })
995
+ buildTasks.forEach { task ->
996
+ def buildType = task.name.endsWith('Debug') ? 'Debug' : 'Release'
997
+ task.dependsOn(":react-native-v8:copy${buildType}JniLibsProjectOnly")
998
+ }
999
+ } else if (JS_RUNTIME == "jsc") {
1000
+ extractAARHeaders.dependsOn(prepareJSC)
1001
+ extractSOFiles.dependsOn(prepareJSC)
1002
+ } else {
1003
+ throw GradleScriptException("Unknown JS runtime ${JS_RUNTIME}.")
1004
+ }
720
1005
  }
721
1006
 
722
1007
  if (CLIENT_SIDE_BUILD) {
723
1008
  def aarDir = "${buildDir}/outputs"
724
- aar = file("${aarDir}/android-debug.aar")
1009
+ aar = file("${aarDir}/android-${resolveBuildType()}.aar") // e.g. android-debug.aar
725
1010
  if (aar == null) {
726
1011
  throw GradleScriptException("AAR build failed. No AAR found in ${aarDir}.")
727
1012
  }
728
1013
  artifacts.add("default", aar)
729
- }
1014
+ }