react-native-reanimated 2.6.0 → 3.0.0-rc.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 (405) hide show
  1. package/Common/cpp/Fabric/FabricUtils.cpp +128 -0
  2. package/Common/cpp/Fabric/ReanimatedUIManagerBinding.cpp +197 -0
  3. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +311 -6
  4. package/Common/cpp/Registries/EventHandlerRegistry.cpp +14 -1
  5. package/Common/cpp/Registries/NewestShadowNodesRegistry.cpp +68 -0
  6. package/Common/cpp/SharedItems/ShareableValue.cpp +20 -2
  7. package/Common/cpp/Tools/Mapper.cpp +23 -4
  8. package/Common/cpp/Tools/RuntimeDecorator.cpp +92 -46
  9. package/Common/cpp/Tools/Scheduler.cpp +4 -0
  10. package/Common/cpp/headers/Fabric/FabricUtils.h +78 -0
  11. package/Common/cpp/headers/Fabric/ReanimatedUIManagerBinding.h +46 -0
  12. package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +72 -2
  13. package/Common/cpp/headers/Registries/EventHandlerRegistry.h +8 -0
  14. package/Common/cpp/headers/Registries/NewestShadowNodesRegistry.h +41 -0
  15. package/Common/cpp/headers/SharedItems/SharedParent.h +3 -0
  16. package/Common/cpp/headers/SharedItems/ValueWrapper.h +25 -0
  17. package/Common/cpp/headers/SpecTools/ErrorHandler.h +5 -0
  18. package/Common/cpp/headers/Tools/Mapper.h +1 -1
  19. package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +43 -8
  20. package/Common/cpp/headers/Tools/RuntimeDecorator.h +8 -3
  21. package/README.md +4 -0
  22. package/RNReanimated.podspec +22 -11
  23. package/android/CMakeLists.txt +139 -27
  24. package/android/build.gradle +86 -209
  25. package/android/local.properties +1 -0
  26. package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +310 -0
  27. package/android/src/fabric/java/com/swmansion/reanimated/ReaCompatibility.java +25 -0
  28. package/android/src/main/cpp/NativeProxy.cpp +196 -41
  29. package/android/src/main/cpp/headers/NativeProxy.h +45 -7
  30. package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +13 -245
  31. package/android/src/main/java/com/swmansion/reanimated/ReanimatedModule.java +0 -125
  32. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +13 -6
  33. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +2 -1
  34. package/android/src/{main → paper}/java/com/swmansion/reanimated/NativeProxy.java +26 -10
  35. package/android/src/paper/java/com/swmansion/reanimated/ReaCompatibility.java +17 -0
  36. package/ios/Fabric/REAInitializerRCTFabricSurface.h +12 -0
  37. package/ios/Fabric/REAInitializerRCTFabricSurface.mm +73 -0
  38. package/ios/LayoutReanimation/REAAnimationsManager.h +1 -1
  39. package/ios/LayoutReanimation/REAAnimationsManager.m +2 -2
  40. package/ios/LayoutReanimation/REASnapshot.m +1 -1
  41. package/ios/LayoutReanimation/REAUIManager.h +1 -1
  42. package/ios/LayoutReanimation/REAUIManager.mm +4 -5
  43. package/ios/REAEventDispatcher.m +1 -2
  44. package/ios/REAModule.h +10 -1
  45. package/ios/REAModule.mm +284 -0
  46. package/ios/REANodesManager.h +27 -52
  47. package/ios/{REANodesManager.m → REANodesManager.mm} +92 -226
  48. package/ios/native/NativeMethods.h +1 -3
  49. package/ios/native/NativeMethods.mm +1 -1
  50. package/ios/native/NativeProxy.h +2 -2
  51. package/ios/native/NativeProxy.mm +162 -32
  52. package/ios/native/REAIOSErrorHandler.h +2 -4
  53. package/ios/native/REAIOSErrorHandler.mm +1 -1
  54. package/ios/native/REAIOSLogger.h +1 -3
  55. package/ios/native/REAIOSLogger.mm +1 -1
  56. package/ios/native/REAIOSScheduler.h +1 -3
  57. package/ios/native/REAIOSScheduler.mm +2 -2
  58. package/ios/native/REAInitializer.h +0 -7
  59. package/ios/native/REAInitializer.mm +14 -6
  60. package/ios/native/UIResponder+Reanimated.h +3 -1
  61. package/ios/native/UIResponder+Reanimated.mm +6 -4
  62. package/ios/sensor/ReanimatedSensor.h +1 -1
  63. package/ios/sensor/ReanimatedSensor.m +1 -1
  64. package/ios/sensor/ReanimatedSensorContainer.h +1 -1
  65. package/ios/sensor/ReanimatedSensorContainer.m +2 -2
  66. package/lib/Animated.js +0 -13
  67. package/lib/ConfigHelper.js +0 -1
  68. package/lib/createAnimatedComponent.js +30 -169
  69. package/lib/index.js +0 -13
  70. package/lib/reanimated2/Easing.js +8 -44
  71. package/lib/reanimated2/NativeMethods.js +20 -3
  72. package/lib/reanimated2/UpdateProps.js +25 -10
  73. package/lib/reanimated2/core.js +4 -37
  74. package/lib/reanimated2/fabricUtils.js +18 -0
  75. package/lib/reanimated2/globals.d.ts +18 -3
  76. package/lib/reanimated2/hook/useAnimatedRef.js +6 -2
  77. package/lib/reanimated2/hook/utils.js +0 -5
  78. package/lib/reanimated2/interpolateColor.js +5 -2
  79. package/lib/reanimated2/interpolation.js +0 -15
  80. package/lib/reanimated2/js-reanimated/index.js +3 -0
  81. package/lib/types/{lib/ConfigHelper.d.ts → ConfigHelper.d.ts} +0 -0
  82. package/lib/types/{lib/ReanimatedEventEmitter.d.ts → ReanimatedEventEmitter.d.ts} +0 -0
  83. package/lib/types/{lib/ReanimatedModule.d.ts → ReanimatedModule.d.ts} +0 -0
  84. package/lib/types/{lib/ReanimatedModule.macos.d.ts → ReanimatedModule.macos.d.ts} +0 -0
  85. package/lib/types/{lib/ReanimatedModule.native.d.ts → ReanimatedModule.native.d.ts} +0 -0
  86. package/lib/types/{lib/ReanimatedModule.windows.d.ts → ReanimatedModule.windows.d.ts} +0 -0
  87. package/lib/types/{lib/ReanimatedModuleCompat.d.ts → ReanimatedModuleCompat.d.ts} +0 -0
  88. package/lib/types/{lib/createAnimatedComponent.d.ts → createAnimatedComponent.d.ts} +0 -0
  89. package/lib/types/{lib/reanimated2 → reanimated2}/Bezier.d.ts +0 -0
  90. package/lib/types/{lib/reanimated2 → reanimated2}/Colors.d.ts +0 -0
  91. package/lib/types/{lib/reanimated2 → reanimated2}/Easing.d.ts +0 -0
  92. package/lib/types/{lib/reanimated2 → reanimated2}/NativeMethods.d.ts +2 -1
  93. package/lib/types/{lib/reanimated2 → reanimated2}/NativeReanimated/NativeReanimated.d.ts +0 -0
  94. package/lib/types/{lib/reanimated2 → reanimated2}/NativeReanimated/index.d.ts +0 -0
  95. package/lib/types/{lib/reanimated2 → reanimated2}/PlatformChecker.d.ts +0 -0
  96. package/lib/types/{lib/reanimated2 → reanimated2}/PropAdapters.d.ts +0 -0
  97. package/lib/types/{lib/reanimated2 → reanimated2}/UpdateProps.d.ts +0 -0
  98. package/lib/types/{lib/reanimated2 → reanimated2}/ViewDescriptorsSet.d.ts +0 -0
  99. package/lib/types/{lib/reanimated2 → reanimated2}/WorkletEventHandler.d.ts +0 -0
  100. package/lib/types/{lib/reanimated2 → reanimated2}/__mocks__/MutableValue.d.ts +0 -0
  101. package/lib/types/{lib/reanimated2 → reanimated2}/__mocks__/NativeReanimated.d.ts +0 -0
  102. package/lib/types/{lib/reanimated2 → reanimated2}/__mocks__/NativeReanimated.native.d.ts +0 -0
  103. package/lib/types/{lib/reanimated2 → reanimated2}/animation/commonTypes.d.ts +0 -0
  104. package/lib/types/{lib/reanimated2 → reanimated2}/animation/decay.d.ts +0 -0
  105. package/lib/types/{lib/reanimated2 → reanimated2}/animation/delay.d.ts +0 -0
  106. package/lib/types/{lib/reanimated2 → reanimated2}/animation/index.d.ts +0 -0
  107. package/lib/types/{lib/reanimated2 → reanimated2}/animation/repeat.d.ts +0 -0
  108. package/lib/types/{lib/reanimated2 → reanimated2}/animation/sequence.d.ts +0 -0
  109. package/lib/types/{lib/reanimated2 → reanimated2}/animation/spring.d.ts +0 -0
  110. package/lib/types/{lib/reanimated2 → reanimated2}/animation/styleAnimation.d.ts +0 -0
  111. package/lib/types/{lib/reanimated2 → reanimated2}/animation/timing.d.ts +0 -0
  112. package/lib/types/{lib/reanimated2 → reanimated2}/animation/util.d.ts +0 -0
  113. package/lib/types/{lib/reanimated2 → reanimated2}/commonTypes.d.ts +2 -2
  114. package/lib/types/{lib/reanimated2 → reanimated2}/component/FlatList.d.ts +0 -0
  115. package/lib/types/{lib/reanimated2 → reanimated2}/component/WrappedComponents.d.ts +0 -0
  116. package/lib/types/{lib/reanimated2 → reanimated2}/component/index.d.ts +0 -0
  117. package/lib/types/{lib/reanimated2 → reanimated2}/core.d.ts +0 -0
  118. package/lib/types/reanimated2/fabricUtils.d.ts +4 -0
  119. package/lib/types/{lib/reanimated2 → reanimated2}/hook/Hooks.d.ts +0 -0
  120. package/lib/types/{lib/reanimated2 → reanimated2}/hook/commonTypes.d.ts +2 -1
  121. package/lib/types/{lib/reanimated2 → reanimated2}/hook/index.d.ts +1 -1
  122. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedGestureHandler.d.ts +2 -2
  123. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedReaction.d.ts +0 -0
  124. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedRef.d.ts +0 -0
  125. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedScrollHandler.d.ts +2 -2
  126. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedSensor.d.ts +1 -3
  127. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedStyle.d.ts +0 -0
  128. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useDerivedValue.d.ts +0 -0
  129. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useSharedValue.d.ts +0 -0
  130. package/lib/types/{lib/reanimated2 → reanimated2}/hook/utils.d.ts +2 -2
  131. package/lib/types/{lib/reanimated2 → reanimated2}/index.d.ts +0 -0
  132. package/lib/types/{lib/reanimated2 → reanimated2}/interpolateColor.d.ts +5 -0
  133. package/lib/types/{lib/reanimated2 → reanimated2}/interpolation.d.ts +1 -4
  134. package/lib/types/{lib/reanimated2 → reanimated2}/jestUtils.d.ts +0 -0
  135. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/JSReanimated.d.ts +0 -0
  136. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/Mapper.d.ts +0 -0
  137. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/MapperRegistry.d.ts +0 -0
  138. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/MutableValue.d.ts +0 -0
  139. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/commonTypes.d.ts +0 -0
  140. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/index.d.ts +0 -0
  141. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/LayoutAnimationRepository.d.ts +0 -0
  142. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/BaseAnimationBuilder.d.ts +0 -0
  143. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +0 -0
  144. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/Keyframe.d.ts +0 -0
  145. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/commonTypes.d.ts +0 -0
  146. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/index.d.ts +0 -0
  147. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Bounce.d.ts +0 -0
  148. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Default.d.ts +0 -0
  149. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Fade.d.ts +0 -0
  150. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Flip.d.ts +0 -0
  151. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Lightspeed.d.ts +0 -0
  152. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Pinwheel.d.ts +0 -0
  153. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Roll.d.ts +0 -0
  154. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Rotate.d.ts +0 -0
  155. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Slide.d.ts +0 -0
  156. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Stretch.d.ts +0 -0
  157. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Zoom.d.ts +0 -0
  158. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/index.d.ts +0 -0
  159. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +0 -0
  160. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +0 -0
  161. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/FadingTransition.d.ts +0 -0
  162. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +0 -0
  163. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/LinearTransition.d.ts +0 -0
  164. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +0 -0
  165. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/index.d.ts +0 -0
  166. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/index.d.ts +0 -0
  167. package/lib/types/{lib/reanimated2 → reanimated2}/mock.d.ts +0 -0
  168. package/lib/types/{lib/reanimated2 → reanimated2}/platform-specific/RNRenderer.d.ts +0 -0
  169. package/lib/types/{lib/reanimated2 → reanimated2}/platform-specific/RNRenderer.web.d.ts +0 -0
  170. package/lib/types/{lib/reanimated2 → reanimated2}/utils.d.ts +0 -0
  171. package/lib/types/{lib/setAndForwardRef.d.ts → setAndForwardRef.d.ts} +0 -0
  172. package/package.json +10 -10
  173. package/plugin.js +29 -33
  174. package/react-native-reanimated.d.ts +15 -3
  175. package/src/Animated.js +0 -13
  176. package/src/ConfigHelper.ts +0 -1
  177. package/src/createAnimatedComponent.tsx +37 -197
  178. package/src/reanimated2/Easing.ts +8 -55
  179. package/src/reanimated2/NativeMethods.ts +39 -7
  180. package/src/reanimated2/UpdateProps.ts +38 -19
  181. package/src/reanimated2/commonTypes.ts +4 -2
  182. package/src/reanimated2/component/FlatList.tsx +8 -5
  183. package/src/reanimated2/core.ts +7 -48
  184. package/src/reanimated2/fabricUtils.ts +27 -0
  185. package/src/reanimated2/globals.d.ts +18 -3
  186. package/src/reanimated2/hook/commonTypes.ts +4 -2
  187. package/src/reanimated2/hook/index.ts +1 -1
  188. package/src/reanimated2/hook/useAnimatedGestureHandler.ts +2 -2
  189. package/src/reanimated2/hook/useAnimatedRef.ts +8 -3
  190. package/src/reanimated2/hook/useAnimatedScrollHandler.ts +2 -2
  191. package/src/reanimated2/hook/useAnimatedSensor.ts +1 -3
  192. package/src/reanimated2/hook/utils.ts +2 -11
  193. package/src/reanimated2/interpolateColor.ts +6 -2
  194. package/src/reanimated2/interpolation.ts +1 -26
  195. package/src/reanimated2/js-reanimated/index.ts +5 -0
  196. package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  197. package/android/.gradle/7.2/dependencies-accessors/gc.properties +0 -0
  198. package/android/.gradle/7.2/executionHistory/executionHistory.bin +0 -0
  199. package/android/.gradle/7.2/executionHistory/executionHistory.lock +0 -0
  200. package/android/.gradle/7.2/fileChanges/last-build.bin +0 -0
  201. package/android/.gradle/7.2/fileHashes/fileHashes.bin +0 -0
  202. package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
  203. package/android/.gradle/7.2/fileHashes/resourceHashesCache.bin +0 -0
  204. package/android/.gradle/7.2/gc.properties +0 -0
  205. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  206. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  207. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  208. package/android/.gradle/checksums/checksums.lock +0 -0
  209. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  210. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  211. package/android/.gradle/vcs-1/gc.properties +0 -0
  212. package/android/react-native-reanimated-64-hermes.aar +0 -0
  213. package/android/react-native-reanimated-64-jsc.aar +0 -0
  214. package/android/react-native-reanimated-65-hermes.aar +0 -0
  215. package/android/react-native-reanimated-65-jsc.aar +0 -0
  216. package/android/react-native-reanimated-66-hermes.aar +0 -0
  217. package/android/react-native-reanimated-66-jsc.aar +0 -0
  218. package/android/react-native-reanimated-67-hermes.aar +0 -0
  219. package/android/react-native-reanimated-67-jsc.aar +0 -0
  220. package/android/react-native-reanimated-68-hermes.aar +0 -0
  221. package/android/react-native-reanimated-68-jsc.aar +0 -0
  222. package/android/src/main/java/com/swmansion/reanimated/UpdateContext.java +0 -11
  223. package/android/src/main/java/com/swmansion/reanimated/nodes/AlwaysNode.java +0 -29
  224. package/android/src/main/java/com/swmansion/reanimated/nodes/BezierNode.java +0 -87
  225. package/android/src/main/java/com/swmansion/reanimated/nodes/BlockNode.java +0 -24
  226. package/android/src/main/java/com/swmansion/reanimated/nodes/CallFuncNode.java +0 -49
  227. package/android/src/main/java/com/swmansion/reanimated/nodes/ClockNode.java +0 -38
  228. package/android/src/main/java/com/swmansion/reanimated/nodes/ClockOpNode.java +0 -73
  229. package/android/src/main/java/com/swmansion/reanimated/nodes/ConcatNode.java +0 -36
  230. package/android/src/main/java/com/swmansion/reanimated/nodes/CondNode.java +0 -41
  231. package/android/src/main/java/com/swmansion/reanimated/nodes/DebugNode.java +0 -33
  232. package/android/src/main/java/com/swmansion/reanimated/nodes/EventNode.java +0 -83
  233. package/android/src/main/java/com/swmansion/reanimated/nodes/FinalNode.java +0 -5
  234. package/android/src/main/java/com/swmansion/reanimated/nodes/FunctionNode.java +0 -20
  235. package/android/src/main/java/com/swmansion/reanimated/nodes/JSCallNode.java +0 -41
  236. package/android/src/main/java/com/swmansion/reanimated/nodes/Node.java +0 -139
  237. package/android/src/main/java/com/swmansion/reanimated/nodes/NoopNode.java +0 -37
  238. package/android/src/main/java/com/swmansion/reanimated/nodes/OperatorNode.java +0 -377
  239. package/android/src/main/java/com/swmansion/reanimated/nodes/ParamNode.java +0 -71
  240. package/android/src/main/java/com/swmansion/reanimated/nodes/PropsNode.java +0 -153
  241. package/android/src/main/java/com/swmansion/reanimated/nodes/SetNode.java +0 -32
  242. package/android/src/main/java/com/swmansion/reanimated/nodes/StyleNode.java +0 -40
  243. package/android/src/main/java/com/swmansion/reanimated/nodes/TransformNode.java +0 -84
  244. package/android/src/main/java/com/swmansion/reanimated/nodes/ValueNode.java +0 -40
  245. package/android/src/main/java/com/swmansion/reanimated/transitions/ChangeTransition.java +0 -84
  246. package/android/src/main/java/com/swmansion/reanimated/transitions/SaneSidePropagation.java +0 -25
  247. package/android/src/main/java/com/swmansion/reanimated/transitions/Scale.java +0 -86
  248. package/android/src/main/java/com/swmansion/reanimated/transitions/TransitionModule.java +0 -41
  249. package/android/src/main/java/com/swmansion/reanimated/transitions/TransitionUtils.java +0 -161
  250. package/ios/Nodes/REAAlwaysNode.h +0 -4
  251. package/ios/Nodes/REAAlwaysNode.m +0 -35
  252. package/ios/Nodes/REABezierNode.h +0 -5
  253. package/ios/Nodes/REABezierNode.m +0 -104
  254. package/ios/Nodes/REABlockNode.h +0 -5
  255. package/ios/Nodes/REABlockNode.m +0 -25
  256. package/ios/Nodes/REACallFuncNode.h +0 -6
  257. package/ios/Nodes/REACallFuncNode.m +0 -69
  258. package/ios/Nodes/REAClockNodes.h +0 -19
  259. package/ios/Nodes/REAClockNodes.m +0 -118
  260. package/ios/Nodes/REAConcatNode.h +0 -5
  261. package/ios/Nodes/REAConcatNode.m +0 -32
  262. package/ios/Nodes/REACondNode.h +0 -5
  263. package/ios/Nodes/REACondNode.m +0 -36
  264. package/ios/Nodes/READebugNode.h +0 -5
  265. package/ios/Nodes/READebugNode.m +0 -30
  266. package/ios/Nodes/REAEventNode.h +0 -9
  267. package/ios/Nodes/REAEventNode.m +0 -35
  268. package/ios/Nodes/REAFunctionNode.h +0 -6
  269. package/ios/Nodes/REAFunctionNode.m +0 -24
  270. package/ios/Nodes/REAJSCallNode.h +0 -5
  271. package/ios/Nodes/REAJSCallNode.m +0 -30
  272. package/ios/Nodes/REANode.h +0 -40
  273. package/ios/Nodes/REANode.m +0 -155
  274. package/ios/Nodes/REAOperatorNode.h +0 -5
  275. package/ios/Nodes/REAOperatorNode.m +0 -115
  276. package/ios/Nodes/REAParamNode.h +0 -10
  277. package/ios/Nodes/REAParamNode.m +0 -79
  278. package/ios/Nodes/REAPropsNode.h +0 -9
  279. package/ios/Nodes/REAPropsNode.m +0 -98
  280. package/ios/Nodes/REASetNode.h +0 -5
  281. package/ios/Nodes/REASetNode.m +0 -34
  282. package/ios/Nodes/REAStyleNode.h +0 -5
  283. package/ios/Nodes/REAStyleNode.m +0 -28
  284. package/ios/Nodes/REATransformNode.h +0 -5
  285. package/ios/Nodes/REATransformNode.m +0 -36
  286. package/ios/Nodes/REAValueNode.h +0 -11
  287. package/ios/Nodes/REAValueNode.m +0 -26
  288. package/ios/REAModule.m +0 -185
  289. package/ios/Transitioning/RCTConvert+REATransition.h +0 -12
  290. package/ios/Transitioning/RCTConvert+REATransition.m +0 -53
  291. package/ios/Transitioning/REAAllTransitions.h +0 -26
  292. package/ios/Transitioning/REAAllTransitions.m +0 -297
  293. package/ios/Transitioning/REATransition.h +0 -65
  294. package/ios/Transitioning/REATransition.m +0 -211
  295. package/ios/Transitioning/REATransitionAnimation.h +0 -17
  296. package/ios/Transitioning/REATransitionAnimation.m +0 -80
  297. package/ios/Transitioning/REATransitionManager.h +0 -9
  298. package/ios/Transitioning/REATransitionManager.m +0 -62
  299. package/ios/Transitioning/REATransitionValues.h +0 -15
  300. package/ios/Transitioning/REATransitionValues.m +0 -26
  301. package/lib/reanimated1/Easing.js +0 -231
  302. package/lib/reanimated1/SpringConfig.js +0 -79
  303. package/lib/reanimated1/Transitioning.js +0 -158
  304. package/lib/reanimated1/animations/Animation.js +0 -32
  305. package/lib/reanimated1/animations/SpringUtils.js +0 -199
  306. package/lib/reanimated1/animations/backwardCompatibleAnimWrapper.js +0 -117
  307. package/lib/reanimated1/animations/decay.js +0 -54
  308. package/lib/reanimated1/animations/spring.js +0 -198
  309. package/lib/reanimated1/animations/timing.js +0 -74
  310. package/lib/reanimated1/base.js +0 -13
  311. package/lib/reanimated1/core/AnimatedAlways.js +0 -33
  312. package/lib/reanimated1/core/AnimatedBezier.js +0 -150
  313. package/lib/reanimated1/core/AnimatedBlock.js +0 -52
  314. package/lib/reanimated1/core/AnimatedCall.js +0 -55
  315. package/lib/reanimated1/core/AnimatedCallFunc.js +0 -72
  316. package/lib/reanimated1/core/AnimatedClock.js +0 -90
  317. package/lib/reanimated1/core/AnimatedClockTest.js +0 -22
  318. package/lib/reanimated1/core/AnimatedCode.js +0 -32
  319. package/lib/reanimated1/core/AnimatedConcat.js +0 -32
  320. package/lib/reanimated1/core/AnimatedCond.js +0 -57
  321. package/lib/reanimated1/core/AnimatedDebug.js +0 -62
  322. package/lib/reanimated1/core/AnimatedEvent.js +0 -126
  323. package/lib/reanimated1/core/AnimatedFunction.js +0 -55
  324. package/lib/reanimated1/core/AnimatedNode.js +0 -223
  325. package/lib/reanimated1/core/AnimatedOperator.js +0 -103
  326. package/lib/reanimated1/core/AnimatedParam.js +0 -88
  327. package/lib/reanimated1/core/AnimatedProps.js +0 -108
  328. package/lib/reanimated1/core/AnimatedSet.js +0 -38
  329. package/lib/reanimated1/core/AnimatedStartClock.js +0 -30
  330. package/lib/reanimated1/core/AnimatedStopClock.js +0 -30
  331. package/lib/reanimated1/core/AnimatedStyle.js +0 -78
  332. package/lib/reanimated1/core/AnimatedTransform.js +0 -78
  333. package/lib/reanimated1/core/AnimatedValue.js +0 -38
  334. package/lib/reanimated1/core/Core.test.js +0 -30
  335. package/lib/reanimated1/core/InternalAnimatedValue.js +0 -87
  336. package/lib/reanimated1/core/__mocks__/AnimatedProps.js +0 -86
  337. package/lib/reanimated1/core/createEventObjectProxyPolyfill.js +0 -44
  338. package/lib/reanimated1/derived/__mocks__/evaluateOnce.js +0 -14
  339. package/lib/reanimated1/derived/acc.js +0 -11
  340. package/lib/reanimated1/derived/color.js +0 -47
  341. package/lib/reanimated1/derived/diff.js +0 -16
  342. package/lib/reanimated1/derived/diffClamp.js +0 -11
  343. package/lib/reanimated1/derived/evaluateOnce.js +0 -35
  344. package/lib/reanimated1/derived/index.js +0 -8
  345. package/lib/reanimated1/derived/interpolate.js +0 -152
  346. package/lib/reanimated1/derived/interpolateColors.js +0 -62
  347. package/lib/reanimated1/derived/onChange.js +0 -14
  348. package/lib/reanimated1/derived/useCode.js +0 -41
  349. package/lib/reanimated1/index.js +0 -53
  350. package/lib/reanimated1/operators.js +0 -35
  351. package/lib/reanimated1/useValue.js +0 -10
  352. package/lib/reanimated1/val.js +0 -3
  353. package/lib/types/react-native-reanimated-tests.d.ts +0 -1
  354. package/src/reanimated1/Easing.js +0 -231
  355. package/src/reanimated1/SpringConfig.js +0 -79
  356. package/src/reanimated1/Transitioning.js +0 -158
  357. package/src/reanimated1/animations/Animation.js +0 -32
  358. package/src/reanimated1/animations/SpringUtils.js +0 -199
  359. package/src/reanimated1/animations/backwardCompatibleAnimWrapper.js +0 -117
  360. package/src/reanimated1/animations/decay.js +0 -54
  361. package/src/reanimated1/animations/spring.js +0 -198
  362. package/src/reanimated1/animations/timing.js +0 -74
  363. package/src/reanimated1/base.js +0 -13
  364. package/src/reanimated1/core/AnimatedAlways.js +0 -33
  365. package/src/reanimated1/core/AnimatedBezier.js +0 -150
  366. package/src/reanimated1/core/AnimatedBlock.js +0 -52
  367. package/src/reanimated1/core/AnimatedCall.js +0 -55
  368. package/src/reanimated1/core/AnimatedCallFunc.js +0 -72
  369. package/src/reanimated1/core/AnimatedClock.js +0 -90
  370. package/src/reanimated1/core/AnimatedClockTest.js +0 -22
  371. package/src/reanimated1/core/AnimatedCode.js +0 -32
  372. package/src/reanimated1/core/AnimatedConcat.js +0 -32
  373. package/src/reanimated1/core/AnimatedCond.js +0 -57
  374. package/src/reanimated1/core/AnimatedDebug.js +0 -62
  375. package/src/reanimated1/core/AnimatedEvent.js +0 -126
  376. package/src/reanimated1/core/AnimatedFunction.js +0 -55
  377. package/src/reanimated1/core/AnimatedNode.js +0 -223
  378. package/src/reanimated1/core/AnimatedOperator.js +0 -103
  379. package/src/reanimated1/core/AnimatedParam.js +0 -88
  380. package/src/reanimated1/core/AnimatedProps.js +0 -108
  381. package/src/reanimated1/core/AnimatedSet.js +0 -38
  382. package/src/reanimated1/core/AnimatedStartClock.js +0 -30
  383. package/src/reanimated1/core/AnimatedStopClock.js +0 -30
  384. package/src/reanimated1/core/AnimatedStyle.js +0 -78
  385. package/src/reanimated1/core/AnimatedTransform.js +0 -78
  386. package/src/reanimated1/core/AnimatedValue.js +0 -38
  387. package/src/reanimated1/core/Core.test.js +0 -30
  388. package/src/reanimated1/core/InternalAnimatedValue.js +0 -87
  389. package/src/reanimated1/core/__mocks__/AnimatedProps.js +0 -86
  390. package/src/reanimated1/core/createEventObjectProxyPolyfill.js +0 -44
  391. package/src/reanimated1/derived/__mocks__/evaluateOnce.js +0 -14
  392. package/src/reanimated1/derived/acc.js +0 -11
  393. package/src/reanimated1/derived/color.js +0 -47
  394. package/src/reanimated1/derived/diff.js +0 -16
  395. package/src/reanimated1/derived/diffClamp.js +0 -11
  396. package/src/reanimated1/derived/evaluateOnce.js +0 -35
  397. package/src/reanimated1/derived/index.js +0 -8
  398. package/src/reanimated1/derived/interpolate.js +0 -152
  399. package/src/reanimated1/derived/interpolateColors.js +0 -62
  400. package/src/reanimated1/derived/onChange.js +0 -14
  401. package/src/reanimated1/derived/useCode.js +0 -41
  402. package/src/reanimated1/index.js +0 -53
  403. package/src/reanimated1/operators.js +0 -35
  404. package/src/reanimated1/useValue.js +0 -10
  405. package/src/reanimated1/val.js +0 -3
@@ -0,0 +1,310 @@
1
+ package com.swmansion.reanimated;
2
+
3
+ import android.os.SystemClock;
4
+ import android.util.Log;
5
+ import androidx.annotation.Nullable;
6
+ import com.facebook.jni.HybridData;
7
+ import com.facebook.proguard.annotations.DoNotStrip;
8
+ import com.facebook.react.ReactApplication;
9
+ import com.facebook.react.bridge.NativeModule;
10
+ import com.facebook.react.bridge.ReactApplicationContext;
11
+ import com.facebook.react.bridge.ReadableMap;
12
+ import com.facebook.react.bridge.ReadableNativeArray;
13
+ import com.facebook.react.bridge.WritableArray;
14
+ import com.facebook.react.bridge.WritableMap;
15
+ import com.facebook.react.devsupport.interfaces.DevSupportManager;
16
+ import com.facebook.react.fabric.FabricUIManager;
17
+ import com.facebook.react.turbomodule.core.CallInvokerHolderImpl;
18
+ import com.facebook.react.uimanager.UIManagerHelper;
19
+ import com.facebook.react.uimanager.UIManagerModule;
20
+ import com.facebook.react.uimanager.common.UIManagerType;
21
+ import com.facebook.react.uimanager.events.RCTEventEmitter;
22
+ import com.facebook.soloader.SoLoader;
23
+ import com.swmansion.common.GestureHandlerStateManager;
24
+ import com.swmansion.reanimated.layoutReanimation.AnimationsManager;
25
+ import com.swmansion.reanimated.layoutReanimation.LayoutAnimations;
26
+ import com.swmansion.reanimated.layoutReanimation.NativeMethodsHolder;
27
+ import com.swmansion.reanimated.sensor.ReanimatedSensorContainer;
28
+ import com.swmansion.reanimated.sensor.ReanimatedSensorType;
29
+ import java.lang.ref.WeakReference;
30
+ import java.util.ArrayList;
31
+ import java.util.HashMap;
32
+ import java.util.HashSet;
33
+ import java.util.Map;
34
+ import java.util.Set;
35
+
36
+ public class NativeProxy {
37
+
38
+ static {
39
+ SoLoader.loadLibrary("reanimated");
40
+ }
41
+
42
+ @DoNotStrip
43
+ public static class AnimationFrameCallback implements NodesManager.OnAnimationFrame {
44
+
45
+ @DoNotStrip private final HybridData mHybridData;
46
+
47
+ @DoNotStrip
48
+ private AnimationFrameCallback(HybridData hybridData) {
49
+ mHybridData = hybridData;
50
+ }
51
+
52
+ @Override
53
+ public native void onAnimationFrame(double timestampMs);
54
+ }
55
+
56
+ @DoNotStrip
57
+ public static class EventHandler implements RCTEventEmitter {
58
+
59
+ @DoNotStrip private final HybridData mHybridData;
60
+ private UIManagerModule.CustomEventNamesResolver mCustomEventNamesResolver;
61
+
62
+ @DoNotStrip
63
+ private EventHandler(HybridData hybridData) {
64
+ mHybridData = hybridData;
65
+ }
66
+
67
+ @Override
68
+ public void receiveEvent(int targetTag, String eventName, @Nullable WritableMap event) {
69
+ String resolvedEventName = mCustomEventNamesResolver.resolveCustomEventName(eventName);
70
+ receiveEvent(targetTag + resolvedEventName, event);
71
+ }
72
+
73
+ public native void receiveEvent(String eventKey, @Nullable WritableMap event);
74
+
75
+ @Override
76
+ public void receiveTouches(
77
+ String eventName, WritableArray touches, WritableArray changedIndices) {
78
+ // not interested in processing touch events this way, we process raw events only
79
+ }
80
+ }
81
+
82
+ @DoNotStrip
83
+ public static class SensorSetter {
84
+
85
+ @DoNotStrip private final HybridData mHybridData;
86
+
87
+ @DoNotStrip
88
+ private SensorSetter(HybridData hybridData) {
89
+ mHybridData = hybridData;
90
+ }
91
+
92
+ public native void sensorSetter(float[] value);
93
+ }
94
+
95
+ @DoNotStrip
96
+ @SuppressWarnings("unused")
97
+ private final HybridData mHybridData;
98
+
99
+ private NodesManager mNodesManager;
100
+ private final WeakReference<ReactApplicationContext> mContext;
101
+ private Scheduler mScheduler = null;
102
+ private ReanimatedSensorContainer reanimatedSensorContainer;
103
+ private final GestureHandlerStateManager gestureHandlerStateManager;
104
+ private Long firstUptime = SystemClock.uptimeMillis();
105
+ private boolean slowAnimationsEnabled = false;
106
+
107
+ public NativeProxy(ReactApplicationContext context) {
108
+ CallInvokerHolderImpl holder =
109
+ (CallInvokerHolderImpl) context.getCatalystInstance().getJSCallInvokerHolder();
110
+ LayoutAnimations LayoutAnimations = new LayoutAnimations(context);
111
+ mScheduler = new Scheduler(context);
112
+ FabricUIManager fabricUIManager =
113
+ (FabricUIManager) UIManagerHelper.getUIManager(context, UIManagerType.FABRIC);
114
+
115
+ mHybridData =
116
+ initHybrid(
117
+ context.getJavaScriptContextHolder().get(),
118
+ holder,
119
+ mScheduler,
120
+ LayoutAnimations,
121
+ fabricUIManager);
122
+ mContext = new WeakReference<>(context);
123
+ prepare(LayoutAnimations);
124
+ reanimatedSensorContainer = new ReanimatedSensorContainer(mContext);
125
+ addDevMenuOption();
126
+
127
+ GestureHandlerStateManager tempHandlerStateManager;
128
+ try {
129
+ Class<NativeModule> gestureHandlerModuleClass =
130
+ (Class<NativeModule>)
131
+ Class.forName("com.swmansion.gesturehandler.react.RNGestureHandlerModule");
132
+ tempHandlerStateManager =
133
+ (GestureHandlerStateManager) context.getNativeModule(gestureHandlerModuleClass);
134
+ } catch (ClassCastException | ClassNotFoundException e) {
135
+ tempHandlerStateManager = null;
136
+ }
137
+ gestureHandlerStateManager = tempHandlerStateManager;
138
+ }
139
+
140
+ private native HybridData initHybrid(
141
+ long jsContext,
142
+ CallInvokerHolderImpl jsCallInvokerHolder,
143
+ Scheduler scheduler,
144
+ LayoutAnimations LayoutAnimations,
145
+ FabricUIManager fabricUIManager);
146
+
147
+ private native void installJSIBindings(FabricUIManager fabricUIManager);
148
+
149
+ public native boolean isAnyHandlerWaitingForEvent(String eventName);
150
+
151
+ public native void performOperations();
152
+
153
+ public Scheduler getScheduler() {
154
+ return mScheduler;
155
+ }
156
+
157
+ private void toggleSlowAnimations() {
158
+ slowAnimationsEnabled = !slowAnimationsEnabled;
159
+ if (slowAnimationsEnabled) {
160
+ firstUptime = SystemClock.uptimeMillis();
161
+ }
162
+ }
163
+
164
+ private void addDevMenuOption() {
165
+ // In Expo, `ApplicationContext` is not an instance of `ReactApplication`
166
+ if (mContext.get().getApplicationContext() instanceof ReactApplication) {
167
+ final DevSupportManager devSupportManager =
168
+ ((ReactApplication) mContext.get().getApplicationContext())
169
+ .getReactNativeHost()
170
+ .getReactInstanceManager()
171
+ .getDevSupportManager();
172
+
173
+ devSupportManager.addCustomDevOption(
174
+ "Toggle slow animations (Reanimated)", this::toggleSlowAnimations);
175
+ }
176
+ }
177
+
178
+ @DoNotStrip
179
+ private void requestRender(AnimationFrameCallback callback) {
180
+ mNodesManager.postOnAnimation(callback);
181
+ }
182
+
183
+ @DoNotStrip
184
+ private void updateProps(int viewTag, Map<String, Object> props) {
185
+ mNodesManager.updateProps(viewTag, props);
186
+ }
187
+
188
+ @DoNotStrip
189
+ private void synchronouslyUpdateUIProps(int viewTag, ReadableMap uiProps) {
190
+ mNodesManager.synchronouslyUpdateUIProps(viewTag, uiProps);
191
+ }
192
+
193
+ @DoNotStrip
194
+ private String obtainProp(int viewTag, String propName) {
195
+ return mNodesManager.obtainProp(viewTag, propName);
196
+ }
197
+
198
+ @DoNotStrip
199
+ private void scrollTo(int viewTag, double x, double y, boolean animated) {
200
+ mNodesManager.scrollTo(viewTag, x, y, animated);
201
+ }
202
+
203
+ @DoNotStrip
204
+ private void setGestureState(int handlerTag, int newState) {
205
+ if (gestureHandlerStateManager != null) {
206
+ gestureHandlerStateManager.setGestureHandlerState(handlerTag, newState);
207
+ }
208
+ }
209
+
210
+ @DoNotStrip
211
+ private String getUptime() {
212
+ if (slowAnimationsEnabled) {
213
+ final long ANIMATIONS_DRAG_FACTOR = 10;
214
+ return Long.toString(
215
+ this.firstUptime
216
+ + (SystemClock.uptimeMillis() - this.firstUptime) / ANIMATIONS_DRAG_FACTOR);
217
+ } else {
218
+ return Long.toString(SystemClock.uptimeMillis());
219
+ }
220
+ }
221
+
222
+ @DoNotStrip
223
+ private float[] measure(int viewTag) {
224
+ return mNodesManager.measure(viewTag);
225
+ }
226
+
227
+ @DoNotStrip
228
+ private void configureProps(ReadableNativeArray uiProps, ReadableNativeArray nativeProps) {
229
+ Set<String> uiPropsSet = convertProps(uiProps);
230
+ Set<String> nativePropsSet = convertProps(nativeProps);
231
+ mNodesManager.configureProps(uiPropsSet, nativePropsSet);
232
+ }
233
+
234
+ private Set<String> convertProps(ReadableNativeArray props) {
235
+ Set<String> propsSet = new HashSet<>();
236
+ ArrayList<Object> propsList = props.toArrayList();
237
+ for (int i = 0; i < propsList.size(); i++) {
238
+ propsSet.add((String) propsList.get(i));
239
+ }
240
+ return propsSet;
241
+ }
242
+
243
+ @DoNotStrip
244
+ private void registerEventHandler(EventHandler handler) {
245
+ handler.mCustomEventNamesResolver = mNodesManager.getEventNameResolver();
246
+ mNodesManager.registerEventHandler(handler);
247
+ }
248
+
249
+ @DoNotStrip
250
+ private int registerSensor(int sensorType, int interval, SensorSetter setter) {
251
+ return reanimatedSensorContainer.registerSensor(
252
+ ReanimatedSensorType.getInstanceById(sensorType), interval, setter);
253
+ }
254
+
255
+ @DoNotStrip
256
+ private void unregisterSensor(int sensorId) {
257
+ reanimatedSensorContainer.unregisterSensor(sensorId);
258
+ }
259
+
260
+ public void onCatalystInstanceDestroy() {
261
+ mScheduler.deactivate();
262
+ mHybridData.resetNative();
263
+ }
264
+
265
+ public void prepare(LayoutAnimations LayoutAnimations) {
266
+ if (Utils.isChromeDebugger) {
267
+ Log.w("[REANIMATED]", "You can not use LayoutAnimation with enabled Chrome Debugger");
268
+ return;
269
+ }
270
+ mNodesManager = mContext.get().getNativeModule(ReanimatedModule.class).getNodesManager();
271
+ FabricUIManager fabricUIManager =
272
+ (FabricUIManager) UIManagerHelper.getUIManager(mContext.get(), UIManagerType.FABRIC);
273
+ installJSIBindings(fabricUIManager);
274
+ AnimationsManager animationsManager =
275
+ mContext
276
+ .get()
277
+ .getNativeModule(ReanimatedModule.class)
278
+ .getNodesManager()
279
+ .getAnimationsManager();
280
+
281
+ WeakReference<LayoutAnimations> weakLayoutAnimations = new WeakReference<>(LayoutAnimations);
282
+ animationsManager.setNativeMethods(
283
+ new NativeMethodsHolder() {
284
+ @Override
285
+ public void startAnimationForTag(int tag, String type, HashMap<String, Float> values) {
286
+ LayoutAnimations LayoutAnimations = weakLayoutAnimations.get();
287
+ if (LayoutAnimations != null) {
288
+ HashMap<String, String> preparedValues = new HashMap<>();
289
+ for (String key : values.keySet()) {
290
+ preparedValues.put(key, values.get(key).toString());
291
+ }
292
+ LayoutAnimations.startAnimationForTag(tag, type, preparedValues);
293
+ }
294
+ }
295
+
296
+ @Override
297
+ public void removeConfigForTag(int tag) {
298
+ LayoutAnimations LayoutAnimations = weakLayoutAnimations.get();
299
+ if (LayoutAnimations != null) {
300
+ LayoutAnimations.removeConfigForTag(tag);
301
+ }
302
+ }
303
+
304
+ @Override
305
+ public boolean isLayoutAnimationEnabled() {
306
+ return LayoutAnimations.isLayoutAnimationEnabled();
307
+ }
308
+ });
309
+ }
310
+ }
@@ -0,0 +1,25 @@
1
+ package com.swmansion.reanimated;
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext;
4
+ import com.facebook.react.bridge.ReadableMap;
5
+ import com.facebook.react.uimanager.UIManagerHelper;
6
+ import com.facebook.react.uimanager.common.UIManagerType;
7
+ import com.facebook.react.fabric.FabricUIManager;
8
+
9
+ class ReaCompatibility {
10
+ private FabricUIManager fabricUIManager;
11
+
12
+ public ReaCompatibility(ReactApplicationContext reactApplicationContext) {
13
+ fabricUIManager = (FabricUIManager) UIManagerHelper.getUIManager(reactApplicationContext, UIManagerType.FABRIC);
14
+ }
15
+
16
+ public void registerFabricEventListener(NodesManager nodeManager) {
17
+ if (fabricUIManager != null) {
18
+ fabricUIManager.getEventDispatcher().addListener(nodeManager);
19
+ }
20
+ }
21
+
22
+ public void synchronouslyUpdateUIProps(int viewTag, ReadableMap uiProps) {
23
+ fabricUIManager.synchronouslyUpdateViewOnUIThread(viewTag, uiProps);
24
+ }
25
+ }
@@ -20,6 +20,13 @@
20
20
  #include "NativeProxy.h"
21
21
  #include "PlatformDepMethodsHolder.h"
22
22
 
23
+ #ifdef RCT_NEW_ARCH_ENABLED
24
+ #include <JFabricUIManager.h>
25
+ #include "FabricUtils.h"
26
+ #include "NewestShadowNodesRegistry.h"
27
+ #include "ReanimatedUIManagerBinding.h"
28
+ #endif
29
+
23
30
  namespace reanimated {
24
31
 
25
32
  using namespace facebook;
@@ -30,12 +37,41 @@ NativeProxy::NativeProxy(
30
37
  jsi::Runtime *rt,
31
38
  std::shared_ptr<facebook::react::CallInvoker> jsCallInvoker,
32
39
  std::shared_ptr<Scheduler> scheduler,
33
- jni::global_ref<LayoutAnimations::javaobject> _layoutAnimations)
40
+ jni::global_ref<LayoutAnimations::javaobject> _layoutAnimations
41
+ #ifdef RCT_NEW_ARCH_ENABLED
42
+ ,
43
+ jni::alias_ref<facebook::react::JFabricUIManager::javaobject>
44
+ fabricUIManager
45
+ #endif
46
+ )
34
47
  : javaPart_(jni::make_global(jThis)),
35
48
  runtime_(rt),
36
49
  jsCallInvoker_(jsCallInvoker),
37
- scheduler_(scheduler),
38
- layoutAnimations(std::move(_layoutAnimations)) {}
50
+ layoutAnimations(std::move(_layoutAnimations)),
51
+ scheduler_(scheduler)
52
+ #ifdef RCT_NEW_ARCH_ENABLED
53
+ ,
54
+ newestShadowNodesRegistry_(std::make_shared<NewestShadowNodesRegistry>())
55
+ #endif
56
+ {
57
+ #ifdef RCT_NEW_ARCH_ENABLED
58
+ Binding *binding = fabricUIManager->getBinding();
59
+ RuntimeExecutor runtimeExecutor = getRuntimeExecutorFromBinding(binding);
60
+ std::shared_ptr<UIManager> uiManager =
61
+ binding->getScheduler()->getUIManager();
62
+ ReanimatedUIManagerBinding::createAndInstallIfNeeded(
63
+ *rt, runtimeExecutor, uiManager, newestShadowNodesRegistry_);
64
+ #endif
65
+ }
66
+
67
+ NativeProxy::~NativeProxy() {
68
+ runtime_->global().setProperty(
69
+ *runtime_,
70
+ jsi::PropNameID::forAscii(*runtime_, "__reanimatedModuleProxy"),
71
+ jsi::Value::undefined());
72
+ // removed temporary, new event listener mechanism need fix on the RN side
73
+ // reactScheduler_->removeEventListener(eventListener_);
74
+ }
39
75
 
40
76
  jni::local_ref<NativeProxy::jhybriddata> NativeProxy::initHybrid(
41
77
  jni::alias_ref<jhybridobject> jThis,
@@ -43,7 +79,13 @@ jni::local_ref<NativeProxy::jhybriddata> NativeProxy::initHybrid(
43
79
  jni::alias_ref<facebook::react::CallInvokerHolder::javaobject>
44
80
  jsCallInvokerHolder,
45
81
  jni::alias_ref<AndroidScheduler::javaobject> androidScheduler,
46
- jni::alias_ref<LayoutAnimations::javaobject> layoutAnimations) {
82
+ jni::alias_ref<LayoutAnimations::javaobject> layoutAnimations
83
+ #ifdef RCT_NEW_ARCH_ENABLED
84
+ ,
85
+ jni::alias_ref<facebook::react::JFabricUIManager::javaobject>
86
+ fabricUIManager
87
+ #endif
88
+ ) {
47
89
  auto jsCallInvoker = jsCallInvokerHolder->cthis()->getCallInvoker();
48
90
  auto scheduler = androidScheduler->cthis()->getScheduler();
49
91
  scheduler->setJSCallInvoker(jsCallInvoker);
@@ -52,19 +94,43 @@ jni::local_ref<NativeProxy::jhybriddata> NativeProxy::initHybrid(
52
94
  (jsi::Runtime *)jsContext,
53
95
  jsCallInvoker,
54
96
  scheduler,
55
- make_global(layoutAnimations));
97
+ make_global(layoutAnimations)
98
+ #ifdef RCT_NEW_ARCH_ENABLED
99
+ ,
100
+ fabricUIManager
101
+ #endif
102
+ /**/);
56
103
  }
57
104
 
58
- void NativeProxy::installJSIBindings() {
59
- auto propUpdater = [this](
60
- jsi::Runtime &rt,
61
- int viewTag,
62
- const jsi::Value &viewName,
63
- const jsi::Object &props) {
105
+ void NativeProxy::installJSIBindings(
106
+ #ifdef RCT_NEW_ARCH_ENABLED
107
+ jni::alias_ref<facebook::react::JFabricUIManager::javaobject>
108
+ fabricUIManager
109
+ #endif
110
+ /**/) {
111
+ #ifdef RCT_NEW_ARCH_ENABLED
112
+ // nothing
113
+ #else
114
+ auto updatePropsFunction = [this](
115
+ jsi::Runtime &rt,
116
+ int viewTag,
117
+ const jsi::Value &viewName,
118
+ const jsi::Object &props) {
64
119
  // viewName is for iOS only, we skip it here
65
120
  this->updateProps(rt, viewTag, props);
66
121
  };
67
122
 
123
+ auto measureFunction =
124
+ [this](int viewTag) -> std::vector<std::pair<std::string, double>> {
125
+ return measure(viewTag);
126
+ };
127
+
128
+ auto scrollToFunction =
129
+ [this](int viewTag, double x, double y, bool animated) -> void {
130
+ scrollTo(viewTag, x, y, animated);
131
+ };
132
+ #endif
133
+
68
134
  auto getCurrentTime = [this]() {
69
135
  auto method =
70
136
  javaPart_->getClass()->getMethod<local_ref<JString>()>("getUptime");
@@ -92,6 +158,12 @@ void NativeProxy::installJSIBindings() {
92
158
  this->requestRender(std::move(wrappedOnRender));
93
159
  };
94
160
 
161
+ #ifdef RCT_NEW_ARCH_ENABLED
162
+ auto synchronouslyUpdateUIPropsFunction =
163
+ [this](jsi::Runtime &rt, Tag tag, const jsi::Value &props) {
164
+ this->synchronouslyUpdateUIProps(rt, tag, props);
165
+ };
166
+ #else
95
167
  auto propObtainer = [this](
96
168
  jsi::Runtime &rt,
97
169
  const int viewTag,
@@ -106,16 +178,7 @@ void NativeProxy::installJSIBindings() {
106
178
  std::string str = result->toStdString();
107
179
  return jsi::Value(rt, jsi::String::createFromAscii(rt, str.c_str()));
108
180
  };
109
-
110
- auto measuringFunction =
111
- [this](int viewTag) -> std::vector<std::pair<std::string, double>> {
112
- return measure(viewTag);
113
- };
114
-
115
- auto scrollToFunction =
116
- [this](int viewTag, double x, double y, bool animated) -> void {
117
- scrollTo(viewTag, x, y, animated);
118
- };
181
+ #endif
119
182
 
120
183
  auto registerSensorFunction =
121
184
  [this](int sensorType, int interval, std::function<void(double[])> setter)
@@ -138,11 +201,25 @@ void NativeProxy::installJSIBindings() {
138
201
  std::shared_ptr<jsi::Runtime> animatedRuntime =
139
202
  facebook::jsc::makeJSCRuntime();
140
203
  #endif
204
+ auto workletRuntimeValue =
205
+ runtime_->global()
206
+ .getProperty(*runtime_, "ArrayBuffer")
207
+ .asObject(*runtime_)
208
+ .asFunction(*runtime_)
209
+ .callAsConstructor(*runtime_, {static_cast<double>(sizeof(void *))});
210
+ uintptr_t *workletRuntimeData = reinterpret_cast<uintptr_t *>(
211
+ workletRuntimeValue.getObject(*runtime_).getArrayBuffer(*runtime_).data(
212
+ *runtime_));
213
+ workletRuntimeData[0] = reinterpret_cast<uintptr_t>(animatedRuntime.get());
214
+
141
215
  runtime_->global().setProperty(
142
- *runtime_,
143
- "_WORKLET_RUNTIME",
144
- static_cast<double>(
145
- reinterpret_cast<std::uintptr_t>(animatedRuntime.get())));
216
+ *runtime_, "_WORKLET_RUNTIME", workletRuntimeValue);
217
+
218
+ #ifdef RCT_NEW_ARCH_ENABLED
219
+ runtime_->global().setProperty(*runtime_, "_IS_FABRIC", true);
220
+ #else
221
+ runtime_->global().setProperty(*runtime_, "_IS_FABRIC", false);
222
+ #endif
146
223
 
147
224
  std::shared_ptr<ErrorHandler> errorHandler =
148
225
  std::make_shared<AndroidErrorHandler>(scheduler_);
@@ -173,37 +250,85 @@ void NativeProxy::installJSIBindings() {
173
250
 
174
251
  PlatformDepMethodsHolder platformDepMethodsHolder = {
175
252
  requestRender,
176
- propUpdater,
253
+ #ifdef RCT_NEW_ARCH_ENABLED
254
+ synchronouslyUpdateUIPropsFunction,
255
+ #else
256
+ updatePropsFunction,
177
257
  scrollToFunction,
178
- measuringFunction,
258
+ measureFunction,
259
+ configurePropsFunction,
260
+ #endif
179
261
  getCurrentTime,
180
262
  registerSensorFunction,
181
263
  unregisterSensorFunction,
182
- setGestureStateFunction,
183
- configurePropsFunction};
264
+ setGestureStateFunction};
184
265
 
185
266
  auto module = std::make_shared<NativeReanimatedModule>(
186
267
  jsCallInvoker_,
187
268
  scheduler_,
188
269
  animatedRuntime,
189
270
  errorHandler,
271
+ #ifdef RCT_NEW_ARCH_ENABLED
272
+ // nothing
273
+ #else
190
274
  propObtainer,
275
+ #endif
191
276
  layoutAnimationsProxy,
192
277
  platformDepMethodsHolder);
193
278
 
194
279
  _nativeReanimatedModule = module;
195
280
 
196
- this->registerEventHandler([module, getCurrentTime](
281
+ std::weak_ptr<NativeReanimatedModule> weakModule = module;
282
+ #ifdef RCT_NEW_ARCH_ENABLED
283
+ this->registerEventHandler([weakModule, getCurrentTime](
197
284
  std::string eventName,
198
285
  std::string eventAsString) {
199
- jsi::Object global = module->runtime->global();
200
- jsi::String eventTimestampName =
201
- jsi::String::createFromAscii(*module->runtime, "_eventTimestamp");
202
- global.setProperty(*module->runtime, eventTimestampName, getCurrentTime());
203
- module->onEvent(eventName, eventAsString);
204
- global.setProperty(
205
- *module->runtime, eventTimestampName, jsi::Value::undefined());
286
+ if (auto module = weakModule.lock()) {
287
+ // handles RCTEvents from RNGestureHandler
288
+
289
+ std::string eventJSON = eventAsString.substr(
290
+ 13, eventAsString.length() - 15); // removes "{ NativeMap: " and " }"
291
+ jsi::Runtime &rt = *module->runtime;
292
+ jsi::Value payload =
293
+ jsi::valueFromDynamic(rt, folly::parseJson(eventJSON));
294
+ // TODO: support NaN and INF values
295
+ // TODO: convert event directly to jsi::Value without JSON serialization
296
+
297
+ module->handleEvent(eventName, std::move(payload), getCurrentTime());
298
+ }
206
299
  });
300
+ #else
301
+ this->registerEventHandler(
302
+ [weakModule, getCurrentTime](
303
+ std::string eventName, std::string eventAsString) {
304
+ if (auto module = weakModule.lock()) {
305
+ jsi::Object global = module->runtime->global();
306
+ jsi::String eventTimestampName =
307
+ jsi::String::createFromAscii(*module->runtime, "_eventTimestamp");
308
+ global.setProperty(
309
+ *module->runtime, eventTimestampName, getCurrentTime());
310
+ module->onEvent(eventName, eventAsString);
311
+ global.setProperty(
312
+ *module->runtime, eventTimestampName, jsi::Value::undefined());
313
+ }
314
+ });
315
+ #endif
316
+
317
+ #ifdef RCT_NEW_ARCH_ENABLED
318
+ Binding *binding = fabricUIManager->getBinding();
319
+ std::shared_ptr<UIManager> uiManager =
320
+ binding->getScheduler()->getUIManager();
321
+ module->setUIManager(uiManager);
322
+ module->setNewestShadowNodesRegistry(newestShadowNodesRegistry_);
323
+ newestShadowNodesRegistry_ = nullptr;
324
+ #endif
325
+ // removed temporary, new event listener mechanism need fix on the RN side
326
+ // eventListener_ = std::make_shared<EventListener>(
327
+ // [module, getCurrentTime](const RawEvent &rawEvent) {
328
+ // return module->handleRawEvent(rawEvent, getCurrentTime());
329
+ // });
330
+ // reactScheduler_ = binding->getScheduler();
331
+ // reactScheduler_->addEventListener(eventListener_);
207
332
 
208
333
  runtime_->global().setProperty(
209
334
  *runtime_,
@@ -215,13 +340,20 @@ bool NativeProxy::isAnyHandlerWaitingForEvent(std::string s) {
215
340
  return _nativeReanimatedModule->isAnyHandlerWaitingForEvent(s);
216
341
  }
217
342
 
343
+ void NativeProxy::performOperations() {
344
+ #ifdef RCT_NEW_ARCH_ENABLED
345
+ _nativeReanimatedModule->performOperations();
346
+ #endif
347
+ }
348
+
218
349
  void NativeProxy::registerNatives() {
219
350
  registerHybrid(
220
351
  {makeNativeMethod("initHybrid", NativeProxy::initHybrid),
221
352
  makeNativeMethod("installJSIBindings", NativeProxy::installJSIBindings),
222
353
  makeNativeMethod(
223
354
  "isAnyHandlerWaitingForEvent",
224
- NativeProxy::isAnyHandlerWaitingForEvent)});
355
+ NativeProxy::isAnyHandlerWaitingForEvent),
356
+ makeNativeMethod("performOperations", NativeProxy::performOperations)});
225
357
  }
226
358
 
227
359
  void NativeProxy::requestRender(std::function<void(double)> onRender) {
@@ -244,6 +376,9 @@ void NativeProxy::registerEventHandler(
244
376
  EventHandler::newObjectCxxArgs(std::move(handler)).get());
245
377
  }
246
378
 
379
+ #ifdef RCT_NEW_ARCH_ENABLED
380
+ // nothing
381
+ #else
247
382
  void NativeProxy::updateProps(
248
383
  jsi::Runtime &rt,
249
384
  int viewTag,
@@ -281,6 +416,27 @@ std::vector<std::pair<std::string, double>> NativeProxy::measure(int viewTag) {
281
416
 
282
417
  return result;
283
418
  }
419
+ #endif // RCT_NEW_ARCH_ENABLED
420
+
421
+ #ifdef RCT_NEW_ARCH_ENABLED
422
+ inline jni::local_ref<ReadableMap::javaobject> castReadableMap(
423
+ jni::local_ref<ReadableNativeMap::javaobject> const &nativeMap) {
424
+ return make_local(reinterpret_cast<ReadableMap::javaobject>(nativeMap.get()));
425
+ }
426
+
427
+ void NativeProxy::synchronouslyUpdateUIProps(
428
+ jsi::Runtime &rt,
429
+ Tag tag,
430
+ const jsi::Value &props) {
431
+ static const auto method =
432
+ javaPart_->getClass()
433
+ ->getMethod<void(int, jni::local_ref<ReadableMap::javaobject>)>(
434
+ "synchronouslyUpdateUIProps");
435
+ jni::local_ref<ReadableMap::javaobject> uiProps = castReadableMap(
436
+ ReadableNativeMap::newObjectCxxArgs(jsi::dynamicFromValue(rt, props)));
437
+ method(javaPart_.get(), tag, uiProps);
438
+ }
439
+ #endif
284
440
 
285
441
  int NativeProxy::registerSensor(
286
442
  int sensorType,
@@ -316,11 +472,10 @@ void NativeProxy::configureProps(
316
472
  ReadableNativeArray::javaobject)>("configureProps");
317
473
  method(
318
474
  javaPart_.get(),
319
- ReadableNativeArray::newObjectCxxArgs(
320
- std::move(jsi::dynamicFromValue(rt, uiProps)))
475
+ ReadableNativeArray::newObjectCxxArgs(jsi::dynamicFromValue(rt, uiProps))
321
476
  .get(),
322
477
  ReadableNativeArray::newObjectCxxArgs(
323
- std::move(jsi::dynamicFromValue(rt, nativeProps)))
478
+ jsi::dynamicFromValue(rt, nativeProps))
324
479
  .get());
325
480
  }
326
481