react-native-reanimated 2.8.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 (381) 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 +18 -0
  7. package/Common/cpp/Tools/Mapper.cpp +23 -4
  8. package/Common/cpp/Tools/RuntimeDecorator.cpp +92 -32
  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 +178 -33
  29. package/android/src/main/cpp/headers/NativeProxy.h +43 -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/LayoutAnimations.java +2 -1
  33. package/android/src/{main → paper}/java/com/swmansion/reanimated/NativeProxy.java +15 -2
  34. package/android/src/paper/java/com/swmansion/reanimated/ReaCompatibility.java +17 -0
  35. package/ios/Fabric/REAInitializerRCTFabricSurface.h +12 -0
  36. package/ios/Fabric/REAInitializerRCTFabricSurface.mm +73 -0
  37. package/ios/REAEventDispatcher.m +0 -1
  38. package/ios/REAModule.h +10 -1
  39. package/ios/REAModule.mm +284 -0
  40. package/ios/REANodesManager.h +27 -51
  41. package/ios/{REANodesManager.m → REANodesManager.mm} +91 -223
  42. package/ios/native/NativeProxy.mm +144 -17
  43. package/ios/native/REAInitializer.mm +12 -4
  44. package/ios/native/UIResponder+Reanimated.h +3 -1
  45. package/ios/native/UIResponder+Reanimated.mm +3 -1
  46. package/lib/Animated.js +0 -4
  47. package/lib/createAnimatedComponent.js +30 -169
  48. package/lib/index.js +0 -4
  49. package/lib/reanimated2/Easing.js +0 -42
  50. package/lib/reanimated2/NativeMethods.js +20 -3
  51. package/lib/reanimated2/UpdateProps.js +25 -10
  52. package/lib/reanimated2/core.js +4 -1
  53. package/lib/reanimated2/fabricUtils.js +18 -0
  54. package/lib/reanimated2/globals.d.ts +17 -1
  55. package/lib/reanimated2/hook/useAnimatedRef.js +6 -2
  56. package/lib/reanimated2/hook/utils.js +0 -5
  57. package/lib/reanimated2/interpolateColor.js +5 -2
  58. package/lib/reanimated2/interpolation.js +0 -15
  59. package/lib/reanimated2/js-reanimated/index.js +3 -0
  60. package/lib/types/{lib/ConfigHelper.d.ts → ConfigHelper.d.ts} +0 -0
  61. package/lib/types/{lib/ReanimatedEventEmitter.d.ts → ReanimatedEventEmitter.d.ts} +0 -0
  62. package/lib/types/{lib/ReanimatedModule.d.ts → ReanimatedModule.d.ts} +0 -0
  63. package/lib/types/{lib/ReanimatedModule.macos.d.ts → ReanimatedModule.macos.d.ts} +0 -0
  64. package/lib/types/{lib/ReanimatedModule.native.d.ts → ReanimatedModule.native.d.ts} +0 -0
  65. package/lib/types/{lib/ReanimatedModule.windows.d.ts → ReanimatedModule.windows.d.ts} +0 -0
  66. package/lib/types/{lib/ReanimatedModuleCompat.d.ts → ReanimatedModuleCompat.d.ts} +0 -0
  67. package/lib/types/{lib/createAnimatedComponent.d.ts → createAnimatedComponent.d.ts} +0 -0
  68. package/lib/types/{lib/reanimated2 → reanimated2}/Bezier.d.ts +0 -0
  69. package/lib/types/{lib/reanimated2 → reanimated2}/Colors.d.ts +0 -0
  70. package/lib/types/{lib/reanimated2 → reanimated2}/Easing.d.ts +0 -0
  71. package/lib/types/{lib/reanimated2 → reanimated2}/NativeMethods.d.ts +2 -1
  72. package/lib/types/{lib/reanimated2 → reanimated2}/NativeReanimated/NativeReanimated.d.ts +0 -0
  73. package/lib/types/{lib/reanimated2 → reanimated2}/NativeReanimated/index.d.ts +0 -0
  74. package/lib/types/{lib/reanimated2 → reanimated2}/PlatformChecker.d.ts +0 -0
  75. package/lib/types/{lib/reanimated2 → reanimated2}/PropAdapters.d.ts +0 -0
  76. package/lib/types/{lib/reanimated2 → reanimated2}/UpdateProps.d.ts +0 -0
  77. package/lib/types/{lib/reanimated2 → reanimated2}/ViewDescriptorsSet.d.ts +0 -0
  78. package/lib/types/{lib/reanimated2 → reanimated2}/WorkletEventHandler.d.ts +0 -0
  79. package/lib/types/{lib/reanimated2 → reanimated2}/__mocks__/MutableValue.d.ts +0 -0
  80. package/lib/types/{lib/reanimated2 → reanimated2}/__mocks__/NativeReanimated.d.ts +0 -0
  81. package/lib/types/{lib/reanimated2 → reanimated2}/__mocks__/NativeReanimated.native.d.ts +0 -0
  82. package/lib/types/{lib/reanimated2 → reanimated2}/animation/commonTypes.d.ts +0 -0
  83. package/lib/types/{lib/reanimated2 → reanimated2}/animation/decay.d.ts +0 -0
  84. package/lib/types/{lib/reanimated2 → reanimated2}/animation/delay.d.ts +0 -0
  85. package/lib/types/{lib/reanimated2 → reanimated2}/animation/index.d.ts +0 -0
  86. package/lib/types/{lib/reanimated2 → reanimated2}/animation/repeat.d.ts +0 -0
  87. package/lib/types/{lib/reanimated2 → reanimated2}/animation/sequence.d.ts +0 -0
  88. package/lib/types/{lib/reanimated2 → reanimated2}/animation/spring.d.ts +0 -0
  89. package/lib/types/{lib/reanimated2 → reanimated2}/animation/styleAnimation.d.ts +0 -0
  90. package/lib/types/{lib/reanimated2 → reanimated2}/animation/timing.d.ts +0 -0
  91. package/lib/types/{lib/reanimated2 → reanimated2}/animation/util.d.ts +0 -0
  92. package/lib/types/{lib/reanimated2 → reanimated2}/commonTypes.d.ts +2 -1
  93. package/lib/types/{lib/reanimated2 → reanimated2}/component/FlatList.d.ts +0 -0
  94. package/lib/types/{lib/reanimated2 → reanimated2}/component/WrappedComponents.d.ts +0 -0
  95. package/lib/types/{lib/reanimated2 → reanimated2}/component/index.d.ts +0 -0
  96. package/lib/types/{lib/reanimated2 → reanimated2}/core.d.ts +0 -0
  97. package/lib/types/reanimated2/fabricUtils.d.ts +4 -0
  98. package/lib/types/{lib/reanimated2 → reanimated2}/hook/Hooks.d.ts +0 -0
  99. package/lib/types/{lib/reanimated2 → reanimated2}/hook/commonTypes.d.ts +2 -1
  100. package/lib/types/{lib/reanimated2 → reanimated2}/hook/index.d.ts +1 -1
  101. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedGestureHandler.d.ts +2 -2
  102. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedReaction.d.ts +0 -0
  103. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedRef.d.ts +0 -0
  104. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedScrollHandler.d.ts +2 -2
  105. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedSensor.d.ts +0 -0
  106. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedStyle.d.ts +0 -0
  107. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useDerivedValue.d.ts +0 -0
  108. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useSharedValue.d.ts +0 -0
  109. package/lib/types/{lib/reanimated2 → reanimated2}/hook/utils.d.ts +2 -2
  110. package/lib/types/{lib/reanimated2 → reanimated2}/index.d.ts +0 -0
  111. package/lib/types/{lib/reanimated2 → reanimated2}/interpolateColor.d.ts +5 -0
  112. package/lib/types/{lib/reanimated2 → reanimated2}/interpolation.d.ts +1 -4
  113. package/lib/types/{lib/reanimated2 → reanimated2}/jestUtils.d.ts +0 -0
  114. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/JSReanimated.d.ts +0 -0
  115. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/Mapper.d.ts +0 -0
  116. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/MapperRegistry.d.ts +0 -0
  117. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/MutableValue.d.ts +0 -0
  118. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/commonTypes.d.ts +0 -0
  119. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/index.d.ts +0 -0
  120. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/LayoutAnimationRepository.d.ts +0 -0
  121. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/BaseAnimationBuilder.d.ts +0 -0
  122. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +0 -0
  123. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/Keyframe.d.ts +0 -0
  124. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/commonTypes.d.ts +0 -0
  125. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/index.d.ts +0 -0
  126. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Bounce.d.ts +0 -0
  127. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Default.d.ts +0 -0
  128. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Fade.d.ts +0 -0
  129. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Flip.d.ts +0 -0
  130. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Lightspeed.d.ts +0 -0
  131. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Pinwheel.d.ts +0 -0
  132. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Roll.d.ts +0 -0
  133. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Rotate.d.ts +0 -0
  134. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Slide.d.ts +0 -0
  135. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Stretch.d.ts +0 -0
  136. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Zoom.d.ts +0 -0
  137. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/index.d.ts +0 -0
  138. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +0 -0
  139. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +0 -0
  140. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/FadingTransition.d.ts +0 -0
  141. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +0 -0
  142. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/LinearTransition.d.ts +0 -0
  143. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +0 -0
  144. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/index.d.ts +0 -0
  145. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/index.d.ts +0 -0
  146. package/lib/types/{lib/reanimated2 → reanimated2}/mock.d.ts +0 -0
  147. package/lib/types/{lib/reanimated2 → reanimated2}/platform-specific/RNRenderer.d.ts +0 -0
  148. package/lib/types/{lib/reanimated2 → reanimated2}/platform-specific/RNRenderer.web.d.ts +0 -0
  149. package/lib/types/{lib/reanimated2 → reanimated2}/utils.d.ts +0 -0
  150. package/lib/types/{lib/setAndForwardRef.d.ts → setAndForwardRef.d.ts} +0 -0
  151. package/package.json +7 -5
  152. package/plugin.js +4 -1
  153. package/src/Animated.js +0 -4
  154. package/src/createAnimatedComponent.tsx +37 -197
  155. package/src/reanimated2/Easing.ts +0 -53
  156. package/src/reanimated2/NativeMethods.ts +39 -7
  157. package/src/reanimated2/UpdateProps.ts +38 -19
  158. package/src/reanimated2/commonTypes.ts +4 -1
  159. package/src/reanimated2/component/FlatList.tsx +8 -5
  160. package/src/reanimated2/core.ts +7 -1
  161. package/src/reanimated2/fabricUtils.ts +27 -0
  162. package/src/reanimated2/globals.d.ts +17 -1
  163. package/src/reanimated2/hook/commonTypes.ts +4 -2
  164. package/src/reanimated2/hook/index.ts +1 -1
  165. package/src/reanimated2/hook/useAnimatedGestureHandler.ts +2 -2
  166. package/src/reanimated2/hook/useAnimatedRef.ts +8 -3
  167. package/src/reanimated2/hook/useAnimatedScrollHandler.ts +2 -2
  168. package/src/reanimated2/hook/utils.ts +2 -11
  169. package/src/reanimated2/interpolateColor.ts +6 -2
  170. package/src/reanimated2/interpolation.ts +1 -26
  171. package/src/reanimated2/js-reanimated/index.ts +5 -0
  172. package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  173. package/android/.gradle/7.2/dependencies-accessors/gc.properties +0 -0
  174. package/android/.gradle/7.2/executionHistory/executionHistory.bin +0 -0
  175. package/android/.gradle/7.2/executionHistory/executionHistory.lock +0 -0
  176. package/android/.gradle/7.2/fileChanges/last-build.bin +0 -0
  177. package/android/.gradle/7.2/fileHashes/fileHashes.bin +0 -0
  178. package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
  179. package/android/.gradle/7.2/fileHashes/resourceHashesCache.bin +0 -0
  180. package/android/.gradle/7.2/gc.properties +0 -0
  181. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  182. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  183. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  184. package/android/.gradle/checksums/checksums.lock +0 -0
  185. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  186. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  187. package/android/.gradle/vcs-1/gc.properties +0 -0
  188. package/android/react-native-reanimated-64-hermes.aar +0 -0
  189. package/android/react-native-reanimated-64-jsc.aar +0 -0
  190. package/android/react-native-reanimated-65-hermes.aar +0 -0
  191. package/android/react-native-reanimated-65-jsc.aar +0 -0
  192. package/android/react-native-reanimated-66-hermes.aar +0 -0
  193. package/android/react-native-reanimated-66-jsc.aar +0 -0
  194. package/android/react-native-reanimated-67-hermes.aar +0 -0
  195. package/android/react-native-reanimated-67-jsc.aar +0 -0
  196. package/android/react-native-reanimated-68-hermes.aar +0 -0
  197. package/android/react-native-reanimated-68-jsc.aar +0 -0
  198. package/android/src/main/java/com/swmansion/reanimated/UpdateContext.java +0 -11
  199. package/android/src/main/java/com/swmansion/reanimated/nodes/AlwaysNode.java +0 -29
  200. package/android/src/main/java/com/swmansion/reanimated/nodes/BezierNode.java +0 -87
  201. package/android/src/main/java/com/swmansion/reanimated/nodes/BlockNode.java +0 -24
  202. package/android/src/main/java/com/swmansion/reanimated/nodes/CallFuncNode.java +0 -49
  203. package/android/src/main/java/com/swmansion/reanimated/nodes/ClockNode.java +0 -38
  204. package/android/src/main/java/com/swmansion/reanimated/nodes/ClockOpNode.java +0 -73
  205. package/android/src/main/java/com/swmansion/reanimated/nodes/ConcatNode.java +0 -36
  206. package/android/src/main/java/com/swmansion/reanimated/nodes/CondNode.java +0 -41
  207. package/android/src/main/java/com/swmansion/reanimated/nodes/DebugNode.java +0 -33
  208. package/android/src/main/java/com/swmansion/reanimated/nodes/EventNode.java +0 -83
  209. package/android/src/main/java/com/swmansion/reanimated/nodes/FinalNode.java +0 -5
  210. package/android/src/main/java/com/swmansion/reanimated/nodes/FunctionNode.java +0 -20
  211. package/android/src/main/java/com/swmansion/reanimated/nodes/JSCallNode.java +0 -41
  212. package/android/src/main/java/com/swmansion/reanimated/nodes/Node.java +0 -139
  213. package/android/src/main/java/com/swmansion/reanimated/nodes/NoopNode.java +0 -37
  214. package/android/src/main/java/com/swmansion/reanimated/nodes/OperatorNode.java +0 -377
  215. package/android/src/main/java/com/swmansion/reanimated/nodes/ParamNode.java +0 -71
  216. package/android/src/main/java/com/swmansion/reanimated/nodes/PropsNode.java +0 -153
  217. package/android/src/main/java/com/swmansion/reanimated/nodes/SetNode.java +0 -32
  218. package/android/src/main/java/com/swmansion/reanimated/nodes/StyleNode.java +0 -40
  219. package/android/src/main/java/com/swmansion/reanimated/nodes/TransformNode.java +0 -84
  220. package/android/src/main/java/com/swmansion/reanimated/nodes/ValueNode.java +0 -40
  221. package/android/src/main/java/com/swmansion/reanimated/transitions/ChangeTransition.java +0 -84
  222. package/android/src/main/java/com/swmansion/reanimated/transitions/SaneSidePropagation.java +0 -25
  223. package/android/src/main/java/com/swmansion/reanimated/transitions/Scale.java +0 -86
  224. package/android/src/main/java/com/swmansion/reanimated/transitions/TransitionModule.java +0 -41
  225. package/android/src/main/java/com/swmansion/reanimated/transitions/TransitionUtils.java +0 -161
  226. package/ios/Nodes/REAAlwaysNode.h +0 -4
  227. package/ios/Nodes/REAAlwaysNode.m +0 -35
  228. package/ios/Nodes/REABezierNode.h +0 -5
  229. package/ios/Nodes/REABezierNode.m +0 -103
  230. package/ios/Nodes/REABlockNode.h +0 -5
  231. package/ios/Nodes/REABlockNode.m +0 -25
  232. package/ios/Nodes/REACallFuncNode.h +0 -6
  233. package/ios/Nodes/REACallFuncNode.m +0 -69
  234. package/ios/Nodes/REAClockNodes.h +0 -19
  235. package/ios/Nodes/REAClockNodes.m +0 -118
  236. package/ios/Nodes/REAConcatNode.h +0 -5
  237. package/ios/Nodes/REAConcatNode.m +0 -32
  238. package/ios/Nodes/REACondNode.h +0 -5
  239. package/ios/Nodes/REACondNode.m +0 -36
  240. package/ios/Nodes/READebugNode.h +0 -5
  241. package/ios/Nodes/READebugNode.m +0 -30
  242. package/ios/Nodes/REAEventNode.h +0 -8
  243. package/ios/Nodes/REAEventNode.m +0 -35
  244. package/ios/Nodes/REAFunctionNode.h +0 -6
  245. package/ios/Nodes/REAFunctionNode.m +0 -24
  246. package/ios/Nodes/REAJSCallNode.h +0 -5
  247. package/ios/Nodes/REAJSCallNode.m +0 -30
  248. package/ios/Nodes/REANode.h +0 -40
  249. package/ios/Nodes/REANode.m +0 -155
  250. package/ios/Nodes/REAOperatorNode.h +0 -5
  251. package/ios/Nodes/REAOperatorNode.m +0 -114
  252. package/ios/Nodes/REAParamNode.h +0 -10
  253. package/ios/Nodes/REAParamNode.m +0 -79
  254. package/ios/Nodes/REAPropsNode.h +0 -9
  255. package/ios/Nodes/REAPropsNode.m +0 -96
  256. package/ios/Nodes/REASetNode.h +0 -5
  257. package/ios/Nodes/REASetNode.m +0 -34
  258. package/ios/Nodes/REAStyleNode.h +0 -5
  259. package/ios/Nodes/REAStyleNode.m +0 -27
  260. package/ios/Nodes/REATransformNode.h +0 -5
  261. package/ios/Nodes/REATransformNode.m +0 -36
  262. package/ios/Nodes/REAValueNode.h +0 -9
  263. package/ios/Nodes/REAValueNode.m +0 -26
  264. package/ios/REAModule.m +0 -184
  265. package/ios/Transitioning/RCTConvert+REATransition.h +0 -11
  266. package/ios/Transitioning/RCTConvert+REATransition.m +0 -53
  267. package/ios/Transitioning/REAAllTransitions.h +0 -26
  268. package/ios/Transitioning/REAAllTransitions.m +0 -296
  269. package/ios/Transitioning/REATransition.h +0 -64
  270. package/ios/Transitioning/REATransition.m +0 -210
  271. package/ios/Transitioning/REATransitionAnimation.h +0 -17
  272. package/ios/Transitioning/REATransitionAnimation.m +0 -79
  273. package/ios/Transitioning/REATransitionManager.h +0 -9
  274. package/ios/Transitioning/REATransitionManager.m +0 -60
  275. package/ios/Transitioning/REATransitionValues.h +0 -15
  276. package/ios/Transitioning/REATransitionValues.m +0 -25
  277. package/lib/reanimated1/Easing.js +0 -231
  278. package/lib/reanimated1/SpringConfig.js +0 -79
  279. package/lib/reanimated1/Transitioning.js +0 -158
  280. package/lib/reanimated1/animations/Animation.js +0 -32
  281. package/lib/reanimated1/animations/SpringUtils.js +0 -199
  282. package/lib/reanimated1/animations/backwardCompatibleAnimWrapper.js +0 -117
  283. package/lib/reanimated1/animations/decay.js +0 -54
  284. package/lib/reanimated1/animations/spring.js +0 -198
  285. package/lib/reanimated1/animations/timing.js +0 -74
  286. package/lib/reanimated1/base.js +0 -13
  287. package/lib/reanimated1/core/AnimatedAlways.js +0 -33
  288. package/lib/reanimated1/core/AnimatedBezier.js +0 -150
  289. package/lib/reanimated1/core/AnimatedBlock.js +0 -52
  290. package/lib/reanimated1/core/AnimatedCall.js +0 -55
  291. package/lib/reanimated1/core/AnimatedCallFunc.js +0 -72
  292. package/lib/reanimated1/core/AnimatedClock.js +0 -90
  293. package/lib/reanimated1/core/AnimatedClockTest.js +0 -22
  294. package/lib/reanimated1/core/AnimatedCode.js +0 -32
  295. package/lib/reanimated1/core/AnimatedConcat.js +0 -32
  296. package/lib/reanimated1/core/AnimatedCond.js +0 -57
  297. package/lib/reanimated1/core/AnimatedDebug.js +0 -62
  298. package/lib/reanimated1/core/AnimatedEvent.js +0 -126
  299. package/lib/reanimated1/core/AnimatedFunction.js +0 -55
  300. package/lib/reanimated1/core/AnimatedNode.js +0 -223
  301. package/lib/reanimated1/core/AnimatedOperator.js +0 -103
  302. package/lib/reanimated1/core/AnimatedParam.js +0 -88
  303. package/lib/reanimated1/core/AnimatedProps.js +0 -108
  304. package/lib/reanimated1/core/AnimatedSet.js +0 -38
  305. package/lib/reanimated1/core/AnimatedStartClock.js +0 -30
  306. package/lib/reanimated1/core/AnimatedStopClock.js +0 -30
  307. package/lib/reanimated1/core/AnimatedStyle.js +0 -78
  308. package/lib/reanimated1/core/AnimatedTransform.js +0 -78
  309. package/lib/reanimated1/core/AnimatedValue.js +0 -38
  310. package/lib/reanimated1/core/Core.test.js +0 -30
  311. package/lib/reanimated1/core/InternalAnimatedValue.js +0 -87
  312. package/lib/reanimated1/core/__mocks__/AnimatedProps.js +0 -86
  313. package/lib/reanimated1/core/createEventObjectProxyPolyfill.js +0 -44
  314. package/lib/reanimated1/derived/__mocks__/evaluateOnce.js +0 -14
  315. package/lib/reanimated1/derived/acc.js +0 -11
  316. package/lib/reanimated1/derived/color.js +0 -47
  317. package/lib/reanimated1/derived/diff.js +0 -16
  318. package/lib/reanimated1/derived/diffClamp.js +0 -11
  319. package/lib/reanimated1/derived/evaluateOnce.js +0 -35
  320. package/lib/reanimated1/derived/index.js +0 -8
  321. package/lib/reanimated1/derived/interpolate.js +0 -152
  322. package/lib/reanimated1/derived/interpolateColors.js +0 -62
  323. package/lib/reanimated1/derived/onChange.js +0 -14
  324. package/lib/reanimated1/derived/useCode.js +0 -41
  325. package/lib/reanimated1/index.js +0 -53
  326. package/lib/reanimated1/operators.js +0 -35
  327. package/lib/reanimated1/useValue.js +0 -10
  328. package/lib/reanimated1/val.js +0 -3
  329. package/lib/types/react-native-reanimated-tests.d.ts +0 -1
  330. package/src/reanimated1/Easing.js +0 -231
  331. package/src/reanimated1/SpringConfig.js +0 -79
  332. package/src/reanimated1/Transitioning.js +0 -158
  333. package/src/reanimated1/animations/Animation.js +0 -32
  334. package/src/reanimated1/animations/SpringUtils.js +0 -199
  335. package/src/reanimated1/animations/backwardCompatibleAnimWrapper.js +0 -117
  336. package/src/reanimated1/animations/decay.js +0 -54
  337. package/src/reanimated1/animations/spring.js +0 -198
  338. package/src/reanimated1/animations/timing.js +0 -74
  339. package/src/reanimated1/base.js +0 -13
  340. package/src/reanimated1/core/AnimatedAlways.js +0 -33
  341. package/src/reanimated1/core/AnimatedBezier.js +0 -150
  342. package/src/reanimated1/core/AnimatedBlock.js +0 -52
  343. package/src/reanimated1/core/AnimatedCall.js +0 -55
  344. package/src/reanimated1/core/AnimatedCallFunc.js +0 -72
  345. package/src/reanimated1/core/AnimatedClock.js +0 -90
  346. package/src/reanimated1/core/AnimatedClockTest.js +0 -22
  347. package/src/reanimated1/core/AnimatedCode.js +0 -32
  348. package/src/reanimated1/core/AnimatedConcat.js +0 -32
  349. package/src/reanimated1/core/AnimatedCond.js +0 -57
  350. package/src/reanimated1/core/AnimatedDebug.js +0 -62
  351. package/src/reanimated1/core/AnimatedEvent.js +0 -126
  352. package/src/reanimated1/core/AnimatedFunction.js +0 -55
  353. package/src/reanimated1/core/AnimatedNode.js +0 -223
  354. package/src/reanimated1/core/AnimatedOperator.js +0 -103
  355. package/src/reanimated1/core/AnimatedParam.js +0 -88
  356. package/src/reanimated1/core/AnimatedProps.js +0 -108
  357. package/src/reanimated1/core/AnimatedSet.js +0 -38
  358. package/src/reanimated1/core/AnimatedStartClock.js +0 -30
  359. package/src/reanimated1/core/AnimatedStopClock.js +0 -30
  360. package/src/reanimated1/core/AnimatedStyle.js +0 -78
  361. package/src/reanimated1/core/AnimatedTransform.js +0 -78
  362. package/src/reanimated1/core/AnimatedValue.js +0 -38
  363. package/src/reanimated1/core/Core.test.js +0 -30
  364. package/src/reanimated1/core/InternalAnimatedValue.js +0 -87
  365. package/src/reanimated1/core/__mocks__/AnimatedProps.js +0 -86
  366. package/src/reanimated1/core/createEventObjectProxyPolyfill.js +0 -44
  367. package/src/reanimated1/derived/__mocks__/evaluateOnce.js +0 -14
  368. package/src/reanimated1/derived/acc.js +0 -11
  369. package/src/reanimated1/derived/color.js +0 -47
  370. package/src/reanimated1/derived/diff.js +0 -16
  371. package/src/reanimated1/derived/diffClamp.js +0 -11
  372. package/src/reanimated1/derived/evaluateOnce.js +0 -35
  373. package/src/reanimated1/derived/index.js +0 -8
  374. package/src/reanimated1/derived/interpolate.js +0 -152
  375. package/src/reanimated1/derived/interpolateColors.js +0 -62
  376. package/src/reanimated1/derived/onChange.js +0 -14
  377. package/src/reanimated1/derived/useCode.js +0 -41
  378. package/src/reanimated1/index.js +0 -53
  379. package/src/reanimated1/operators.js +0 -35
  380. package/src/reanimated1/useValue.js +0 -10
  381. 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,18 +37,40 @@ 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
+ }
39
66
 
40
67
  NativeProxy::~NativeProxy() {
41
68
  runtime_->global().setProperty(
42
69
  *runtime_,
43
70
  jsi::PropNameID::forAscii(*runtime_, "__reanimatedModuleProxy"),
44
71
  jsi::Value::undefined());
72
+ // removed temporary, new event listener mechanism need fix on the RN side
73
+ // reactScheduler_->removeEventListener(eventListener_);
45
74
  }
46
75
 
47
76
  jni::local_ref<NativeProxy::jhybriddata> NativeProxy::initHybrid(
@@ -50,7 +79,13 @@ jni::local_ref<NativeProxy::jhybriddata> NativeProxy::initHybrid(
50
79
  jni::alias_ref<facebook::react::CallInvokerHolder::javaobject>
51
80
  jsCallInvokerHolder,
52
81
  jni::alias_ref<AndroidScheduler::javaobject> androidScheduler,
53
- 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
+ ) {
54
89
  auto jsCallInvoker = jsCallInvokerHolder->cthis()->getCallInvoker();
55
90
  auto scheduler = androidScheduler->cthis()->getScheduler();
56
91
  scheduler->setJSCallInvoker(jsCallInvoker);
@@ -59,19 +94,43 @@ jni::local_ref<NativeProxy::jhybriddata> NativeProxy::initHybrid(
59
94
  (jsi::Runtime *)jsContext,
60
95
  jsCallInvoker,
61
96
  scheduler,
62
- make_global(layoutAnimations));
97
+ make_global(layoutAnimations)
98
+ #ifdef RCT_NEW_ARCH_ENABLED
99
+ ,
100
+ fabricUIManager
101
+ #endif
102
+ /**/);
63
103
  }
64
104
 
65
- void NativeProxy::installJSIBindings() {
66
- auto propUpdater = [this](
67
- jsi::Runtime &rt,
68
- int viewTag,
69
- const jsi::Value &viewName,
70
- 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) {
71
119
  // viewName is for iOS only, we skip it here
72
120
  this->updateProps(rt, viewTag, props);
73
121
  };
74
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
+
75
134
  auto getCurrentTime = [this]() {
76
135
  auto method =
77
136
  javaPart_->getClass()->getMethod<local_ref<JString>()>("getUptime");
@@ -99,6 +158,12 @@ void NativeProxy::installJSIBindings() {
99
158
  this->requestRender(std::move(wrappedOnRender));
100
159
  };
101
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
102
167
  auto propObtainer = [this](
103
168
  jsi::Runtime &rt,
104
169
  const int viewTag,
@@ -113,16 +178,7 @@ void NativeProxy::installJSIBindings() {
113
178
  std::string str = result->toStdString();
114
179
  return jsi::Value(rt, jsi::String::createFromAscii(rt, str.c_str()));
115
180
  };
116
-
117
- auto measuringFunction =
118
- [this](int viewTag) -> std::vector<std::pair<std::string, double>> {
119
- return measure(viewTag);
120
- };
121
-
122
- auto scrollToFunction =
123
- [this](int viewTag, double x, double y, bool animated) -> void {
124
- scrollTo(viewTag, x, y, animated);
125
- };
181
+ #endif
126
182
 
127
183
  auto registerSensorFunction =
128
184
  [this](int sensorType, int interval, std::function<void(double[])> setter)
@@ -145,11 +201,25 @@ void NativeProxy::installJSIBindings() {
145
201
  std::shared_ptr<jsi::Runtime> animatedRuntime =
146
202
  facebook::jsc::makeJSCRuntime();
147
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
+
148
215
  runtime_->global().setProperty(
149
- *runtime_,
150
- "_WORKLET_RUNTIME",
151
- static_cast<double>(
152
- 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
153
223
 
154
224
  std::shared_ptr<ErrorHandler> errorHandler =
155
225
  std::make_shared<AndroidErrorHandler>(scheduler_);
@@ -180,26 +250,54 @@ void NativeProxy::installJSIBindings() {
180
250
 
181
251
  PlatformDepMethodsHolder platformDepMethodsHolder = {
182
252
  requestRender,
183
- propUpdater,
253
+ #ifdef RCT_NEW_ARCH_ENABLED
254
+ synchronouslyUpdateUIPropsFunction,
255
+ #else
256
+ updatePropsFunction,
184
257
  scrollToFunction,
185
- measuringFunction,
258
+ measureFunction,
259
+ configurePropsFunction,
260
+ #endif
186
261
  getCurrentTime,
187
262
  registerSensorFunction,
188
263
  unregisterSensorFunction,
189
- setGestureStateFunction,
190
- configurePropsFunction};
264
+ setGestureStateFunction};
191
265
 
192
266
  auto module = std::make_shared<NativeReanimatedModule>(
193
267
  jsCallInvoker_,
194
268
  scheduler_,
195
269
  animatedRuntime,
196
270
  errorHandler,
271
+ #ifdef RCT_NEW_ARCH_ENABLED
272
+ // nothing
273
+ #else
197
274
  propObtainer,
275
+ #endif
198
276
  layoutAnimationsProxy,
199
277
  platformDepMethodsHolder);
200
278
 
201
279
  _nativeReanimatedModule = module;
280
+
202
281
  std::weak_ptr<NativeReanimatedModule> weakModule = module;
282
+ #ifdef RCT_NEW_ARCH_ENABLED
283
+ this->registerEventHandler([weakModule, getCurrentTime](
284
+ std::string eventName,
285
+ std::string eventAsString) {
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
+ }
299
+ });
300
+ #else
203
301
  this->registerEventHandler(
204
302
  [weakModule, getCurrentTime](
205
303
  std::string eventName, std::string eventAsString) {
@@ -214,6 +312,23 @@ void NativeProxy::installJSIBindings() {
214
312
  *module->runtime, eventTimestampName, jsi::Value::undefined());
215
313
  }
216
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_);
217
332
 
218
333
  runtime_->global().setProperty(
219
334
  *runtime_,
@@ -225,13 +340,20 @@ bool NativeProxy::isAnyHandlerWaitingForEvent(std::string s) {
225
340
  return _nativeReanimatedModule->isAnyHandlerWaitingForEvent(s);
226
341
  }
227
342
 
343
+ void NativeProxy::performOperations() {
344
+ #ifdef RCT_NEW_ARCH_ENABLED
345
+ _nativeReanimatedModule->performOperations();
346
+ #endif
347
+ }
348
+
228
349
  void NativeProxy::registerNatives() {
229
350
  registerHybrid(
230
351
  {makeNativeMethod("initHybrid", NativeProxy::initHybrid),
231
352
  makeNativeMethod("installJSIBindings", NativeProxy::installJSIBindings),
232
353
  makeNativeMethod(
233
354
  "isAnyHandlerWaitingForEvent",
234
- NativeProxy::isAnyHandlerWaitingForEvent)});
355
+ NativeProxy::isAnyHandlerWaitingForEvent),
356
+ makeNativeMethod("performOperations", NativeProxy::performOperations)});
235
357
  }
236
358
 
237
359
  void NativeProxy::requestRender(std::function<void(double)> onRender) {
@@ -254,6 +376,9 @@ void NativeProxy::registerEventHandler(
254
376
  EventHandler::newObjectCxxArgs(std::move(handler)).get());
255
377
  }
256
378
 
379
+ #ifdef RCT_NEW_ARCH_ENABLED
380
+ // nothing
381
+ #else
257
382
  void NativeProxy::updateProps(
258
383
  jsi::Runtime &rt,
259
384
  int viewTag,
@@ -291,6 +416,27 @@ std::vector<std::pair<std::string, double>> NativeProxy::measure(int viewTag) {
291
416
 
292
417
  return result;
293
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
294
440
 
295
441
  int NativeProxy::registerSensor(
296
442
  int sensorType,
@@ -326,11 +472,10 @@ void NativeProxy::configureProps(
326
472
  ReadableNativeArray::javaobject)>("configureProps");
327
473
  method(
328
474
  javaPart_.get(),
329
- ReadableNativeArray::newObjectCxxArgs(
330
- std::move(jsi::dynamicFromValue(rt, uiProps)))
475
+ ReadableNativeArray::newObjectCxxArgs(jsi::dynamicFromValue(rt, uiProps))
331
476
  .get(),
332
477
  ReadableNativeArray::newObjectCxxArgs(
333
- std::move(jsi::dynamicFromValue(rt, nativeProps)))
478
+ jsi::dynamicFromValue(rt, nativeProps))
334
479
  .get());
335
480
  }
336
481