react-native-reanimated 2.4.1 → 2.7.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 (387) hide show
  1. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +72 -0
  2. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +30 -1
  3. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +64 -39
  4. package/Common/cpp/SharedItems/ShareableValue.cpp +2 -2
  5. package/Common/cpp/Tools/RuntimeDecorator.cpp +2 -14
  6. package/Common/cpp/headers/AnimatedSensor/AnimatedSensorModule.h +41 -0
  7. package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +14 -0
  8. package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +14 -0
  9. package/Common/cpp/headers/SharedItems/MutableValue.h +4 -1
  10. package/Common/cpp/headers/SharedItems/ShareableValue.h +3 -0
  11. package/Common/cpp/headers/SharedItems/ValueWrapper.h +3 -0
  12. package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +11 -0
  13. package/Common/cpp/headers/Tools/RuntimeDecorator.h +2 -0
  14. package/README.md +2 -2
  15. package/RNReanimated.podspec +15 -6
  16. package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  17. package/android/.gradle/7.2/dependencies-accessors/gc.properties +0 -0
  18. package/android/.gradle/7.2/executionHistory/executionHistory.bin +0 -0
  19. package/android/.gradle/7.2/executionHistory/executionHistory.lock +0 -0
  20. package/android/.gradle/7.2/fileChanges/last-build.bin +0 -0
  21. package/android/.gradle/7.2/fileHashes/fileHashes.bin +0 -0
  22. package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
  23. package/android/.gradle/7.2/fileHashes/resourceHashesCache.bin +0 -0
  24. package/android/.gradle/7.2/gc.properties +0 -0
  25. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  26. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  27. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  28. package/android/.gradle/checksums/checksums.lock +0 -0
  29. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  30. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  31. package/android/.gradle/vcs-1/gc.properties +0 -0
  32. package/android/CMakeLists.txt +198 -0
  33. package/android/README.md +15 -0
  34. package/android/build.gradle +676 -73
  35. package/android/empty.cpp +1 -0
  36. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  37. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  38. package/android/gradle.properties +25 -0
  39. package/android/gradlew +234 -0
  40. package/android/gradlew.bat +89 -0
  41. package/android/react-native-reanimated-64-hermes.aar +0 -0
  42. package/android/react-native-reanimated-64-jsc.aar +0 -0
  43. package/android/react-native-reanimated-65-hermes.aar +0 -0
  44. package/android/react-native-reanimated-65-jsc.aar +0 -0
  45. package/android/react-native-reanimated-66-hermes.aar +0 -0
  46. package/android/react-native-reanimated-66-jsc.aar +0 -0
  47. package/android/react-native-reanimated-67-hermes.aar +0 -0
  48. package/android/react-native-reanimated-67-jsc.aar +0 -0
  49. package/android/react-native-reanimated-68-hermes.aar +0 -0
  50. package/android/react-native-reanimated-68-jsc.aar +0 -0
  51. package/android/rnVersionPatch/62/layoutReanimation/ReanimatedNativeHierarchyManager.java +412 -0
  52. package/android/rnVersionPatch/62/layoutReanimation/ReanimatedUIImplementation.java +68 -0
  53. package/android/rnVersionPatch/63/layoutReanimation/ReanimatedUIImplementation.java +68 -0
  54. package/android/rnVersionPatch/64/layoutReanimation/ReanimatedUIImplementation.java +68 -0
  55. package/android/rnVersionPatch/65/.gitkeep +0 -0
  56. package/android/rnVersionPatch/66/.gitkeep +0 -0
  57. package/android/rnVersionPatch/67/.gitkeep +0 -0
  58. package/android/rnVersionPatch/68/.gitkeep +0 -0
  59. package/android/rnVersionPatch/backup/.gitkeep +0 -0
  60. package/android/settings.gradle +1 -0
  61. package/android/spotless.gradle +9 -0
  62. package/android/src/{AndroidManifest.xml → main/AndroidManifest.xml} +0 -0
  63. package/android/src/main/cpp/AndroidErrorHandler.cpp +42 -0
  64. package/android/src/main/cpp/AndroidLogger.cpp +27 -0
  65. package/android/src/main/cpp/AndroidScheduler.cpp +59 -0
  66. package/android/src/main/cpp/JNIHelper.cpp +59 -0
  67. package/android/src/main/cpp/LayoutAnimations.cpp +103 -0
  68. package/android/src/main/cpp/NativeProxy.cpp +327 -0
  69. package/android/src/main/cpp/OnLoad.cpp +17 -0
  70. package/android/src/main/cpp/TurboModule.cpp +44 -0
  71. package/android/src/main/cpp/headers/AndroidErrorHandler.h +30 -0
  72. package/android/src/main/cpp/headers/AndroidLogger.h +16 -0
  73. package/android/src/main/cpp/headers/AndroidScheduler.h +41 -0
  74. package/android/src/main/cpp/headers/JNIHelper.h +30 -0
  75. package/android/src/main/cpp/headers/LayoutAnimations.h +42 -0
  76. package/android/src/main/cpp/headers/NativeProxy.h +170 -0
  77. package/android/src/main/cpp/headers/TurboModule.h +70 -0
  78. package/android/src/main/java/com/facebook/react/uimanager/UIManagerReanimatedHelper.java +15 -0
  79. package/android/src/main/java/com/swmansion/common/GestureHandlerStateManager.java +5 -0
  80. package/android/src/main/java/com/swmansion/reanimated/AndroidErrorHandler.java +8 -0
  81. package/android/src/main/java/com/swmansion/reanimated/CopiedEvent.java +43 -0
  82. package/android/src/main/java/com/swmansion/reanimated/MapUtils.java +26 -0
  83. package/android/src/main/java/com/swmansion/reanimated/NativeMethodsHelper.java +117 -0
  84. package/android/src/main/java/com/swmansion/reanimated/NativeProxy.java +288 -0
  85. package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +682 -0
  86. package/android/src/main/java/com/swmansion/reanimated/ReanimatedJSIModulePackage.java +29 -0
  87. package/android/src/main/java/com/swmansion/reanimated/ReanimatedModule.java +251 -0
  88. package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +96 -0
  89. package/android/src/main/java/com/swmansion/reanimated/Scheduler.java +51 -0
  90. package/android/src/main/java/com/swmansion/reanimated/UpdateContext.java +11 -0
  91. package/android/src/main/java/com/swmansion/reanimated/Utils.java +32 -0
  92. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +524 -0
  93. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +56 -0
  94. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +11 -0
  95. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +410 -0
  96. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIImplementation.java +68 -0
  97. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +292 -0
  98. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +121 -0
  99. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ViewHierarchyObserver.java +12 -0
  100. package/android/src/main/java/com/swmansion/reanimated/nodes/AlwaysNode.java +29 -0
  101. package/android/src/main/java/com/swmansion/reanimated/nodes/BezierNode.java +87 -0
  102. package/android/src/main/java/com/swmansion/reanimated/nodes/BlockNode.java +24 -0
  103. package/android/src/main/java/com/swmansion/reanimated/nodes/CallFuncNode.java +49 -0
  104. package/android/src/main/java/com/swmansion/reanimated/nodes/ClockNode.java +38 -0
  105. package/android/src/main/java/com/swmansion/reanimated/nodes/ClockOpNode.java +73 -0
  106. package/android/src/main/java/com/swmansion/reanimated/nodes/ConcatNode.java +36 -0
  107. package/android/src/main/java/com/swmansion/reanimated/nodes/CondNode.java +41 -0
  108. package/android/src/main/java/com/swmansion/reanimated/nodes/DebugNode.java +33 -0
  109. package/android/src/main/java/com/swmansion/reanimated/nodes/EventNode.java +83 -0
  110. package/android/src/main/java/com/swmansion/reanimated/nodes/FinalNode.java +5 -0
  111. package/android/src/main/java/com/swmansion/reanimated/nodes/FunctionNode.java +20 -0
  112. package/android/src/main/java/com/swmansion/reanimated/nodes/JSCallNode.java +41 -0
  113. package/android/src/main/java/com/swmansion/reanimated/nodes/Node.java +139 -0
  114. package/android/src/main/java/com/swmansion/reanimated/nodes/NoopNode.java +37 -0
  115. package/android/src/main/java/com/swmansion/reanimated/nodes/OperatorNode.java +377 -0
  116. package/android/src/main/java/com/swmansion/reanimated/nodes/ParamNode.java +71 -0
  117. package/android/src/main/java/com/swmansion/reanimated/nodes/PropsNode.java +153 -0
  118. package/android/src/main/java/com/swmansion/reanimated/nodes/SetNode.java +32 -0
  119. package/android/src/main/java/com/swmansion/reanimated/nodes/StyleNode.java +40 -0
  120. package/android/src/main/java/com/swmansion/reanimated/nodes/TransformNode.java +84 -0
  121. package/android/src/main/java/com/swmansion/reanimated/nodes/ValueNode.java +40 -0
  122. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +41 -0
  123. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +40 -0
  124. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -0
  125. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorType.java +35 -0
  126. package/android/src/main/java/com/swmansion/reanimated/transitions/ChangeTransition.java +84 -0
  127. package/android/src/main/java/com/swmansion/reanimated/transitions/SaneSidePropagation.java +25 -0
  128. package/android/src/main/java/com/swmansion/reanimated/transitions/Scale.java +86 -0
  129. package/android/src/main/java/com/swmansion/reanimated/transitions/TransitionModule.java +41 -0
  130. package/android/src/main/java/com/swmansion/reanimated/transitions/TransitionUtils.java +161 -0
  131. package/ios/LayoutReanimation/REAAnimationsManager.h +1 -1
  132. package/ios/LayoutReanimation/REAAnimationsManager.m +16 -6
  133. package/ios/LayoutReanimation/REASnapshot.m +1 -1
  134. package/ios/LayoutReanimation/REAUIManager.h +1 -1
  135. package/ios/LayoutReanimation/REAUIManager.mm +4 -5
  136. package/ios/Nodes/REAAlwaysNode.h +1 -1
  137. package/ios/Nodes/REAAlwaysNode.m +5 -5
  138. package/ios/Nodes/REABezierNode.h +1 -1
  139. package/ios/Nodes/REABezierNode.m +4 -5
  140. package/ios/Nodes/REABlockNode.h +1 -1
  141. package/ios/Nodes/REABlockNode.m +2 -2
  142. package/ios/Nodes/REACallFuncNode.h +1 -1
  143. package/ios/Nodes/REACallFuncNode.m +5 -5
  144. package/ios/Nodes/REAClockNodes.h +1 -1
  145. package/ios/Nodes/REAClockNodes.m +4 -4
  146. package/ios/Nodes/REAConcatNode.h +1 -1
  147. package/ios/Nodes/REAConcatNode.m +3 -3
  148. package/ios/Nodes/REACondNode.h +1 -1
  149. package/ios/Nodes/REACondNode.m +3 -3
  150. package/ios/Nodes/READebugNode.h +1 -1
  151. package/ios/Nodes/READebugNode.m +3 -3
  152. package/ios/Nodes/REAEventNode.h +1 -2
  153. package/ios/Nodes/REAEventNode.m +3 -3
  154. package/ios/Nodes/REAFunctionNode.h +1 -1
  155. package/ios/Nodes/REAFunctionNode.m +3 -3
  156. package/ios/Nodes/REAJSCallNode.h +1 -1
  157. package/ios/Nodes/REAJSCallNode.m +3 -3
  158. package/ios/Nodes/REANode.m +2 -2
  159. package/ios/Nodes/REAOperatorNode.h +1 -1
  160. package/ios/Nodes/REAOperatorNode.m +2 -3
  161. package/ios/Nodes/REAParamNode.h +1 -1
  162. package/ios/Nodes/REAParamNode.m +4 -4
  163. package/ios/Nodes/REAPropsNode.h +1 -1
  164. package/ios/Nodes/REAPropsNode.m +4 -6
  165. package/ios/Nodes/REASetNode.h +1 -1
  166. package/ios/Nodes/REASetNode.m +4 -4
  167. package/ios/Nodes/REAStyleNode.h +1 -1
  168. package/ios/Nodes/REAStyleNode.m +2 -3
  169. package/ios/Nodes/REATransformNode.h +1 -1
  170. package/ios/Nodes/REATransformNode.m +2 -2
  171. package/ios/Nodes/REAValueNode.h +1 -3
  172. package/ios/Nodes/REAValueNode.m +1 -1
  173. package/ios/REAEventDispatcher.m +1 -1
  174. package/ios/REAModule.h +1 -1
  175. package/ios/REAModule.m +12 -14
  176. package/ios/REANodesManager.h +5 -3
  177. package/ios/REANodesManager.m +97 -27
  178. package/ios/Transitioning/RCTConvert+REATransition.h +1 -2
  179. package/ios/Transitioning/RCTConvert+REATransition.m +1 -1
  180. package/ios/Transitioning/REAAllTransitions.h +1 -1
  181. package/ios/Transitioning/REAAllTransitions.m +2 -3
  182. package/ios/Transitioning/REATransition.h +2 -3
  183. package/ios/Transitioning/REATransition.m +3 -4
  184. package/ios/Transitioning/REATransitionAnimation.m +1 -2
  185. package/ios/Transitioning/REATransitionManager.m +2 -4
  186. package/ios/Transitioning/REATransitionValues.m +2 -3
  187. package/ios/native/NativeMethods.h +1 -3
  188. package/ios/native/NativeMethods.mm +1 -1
  189. package/ios/native/NativeProxy.h +2 -2
  190. package/ios/native/NativeProxy.mm +86 -15
  191. package/ios/native/REAIOSErrorHandler.h +2 -4
  192. package/ios/native/REAIOSErrorHandler.mm +1 -1
  193. package/ios/native/REAIOSLogger.h +1 -3
  194. package/ios/native/REAIOSLogger.mm +1 -1
  195. package/ios/native/REAIOSScheduler.h +1 -3
  196. package/ios/native/REAIOSScheduler.mm +2 -2
  197. package/ios/native/REAInitializer.h +0 -7
  198. package/ios/native/REAInitializer.mm +2 -2
  199. package/ios/native/UIResponder+Reanimated.mm +3 -3
  200. package/ios/sensor/ReanimatedSensor.h +25 -0
  201. package/ios/sensor/ReanimatedSensor.m +217 -0
  202. package/ios/sensor/ReanimatedSensorContainer.h +12 -0
  203. package/ios/sensor/ReanimatedSensorContainer.m +40 -0
  204. package/ios/sensor/ReanimatedSensorType.h +7 -0
  205. package/lib/ConfigHelper.js +2 -3
  206. package/lib/createAnimatedComponent.js +3 -4
  207. package/lib/reanimated1/core/AnimatedFunction.js +1 -1
  208. package/lib/reanimated1/derived/interpolate.js +2 -4
  209. package/lib/reanimated2/Colors.js +2 -1
  210. package/lib/reanimated2/Easing.js +9 -3
  211. package/lib/reanimated2/NativeReanimated/NativeReanimated.js +25 -12
  212. package/lib/reanimated2/NativeReanimated/index.js +0 -4
  213. package/lib/reanimated2/ViewDescriptorsSet.js +2 -2
  214. package/lib/reanimated2/animation/styleAnimation.js +2 -1
  215. package/lib/reanimated2/core.js +30 -60
  216. package/lib/reanimated2/globals.d.ts +7 -2
  217. package/lib/reanimated2/hook/index.js +1 -0
  218. package/lib/reanimated2/hook/useAnimatedSensor.js +66 -0
  219. package/lib/reanimated2/interpolateColor.js +11 -11
  220. package/lib/reanimated2/interpolation.js +1 -1
  221. package/lib/reanimated2/jestUtils.js +9 -4
  222. package/lib/reanimated2/js-reanimated/JSReanimated.js +23 -2
  223. package/lib/reanimated2/js-reanimated/index.js +3 -3
  224. package/lib/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +8 -0
  225. package/lib/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +2 -1
  226. package/lib/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +32 -42
  227. package/lib/reanimated2/layoutReanimation/defaultAnimations/Fade.js +20 -38
  228. package/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.js +32 -44
  229. package/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -16
  230. package/lib/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +6 -10
  231. package/lib/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
  232. package/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +20 -36
  233. package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +16 -20
  234. package/lib/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +8 -12
  235. package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +32 -48
  236. package/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +22 -18
  237. package/lib/reanimated2/mock.js +3 -2
  238. package/lib/types/lib/ConfigHelper.d.ts +12 -0
  239. package/lib/types/lib/ReanimatedEventEmitter.d.ts +3 -0
  240. package/lib/types/lib/ReanimatedModule.d.ts +2 -0
  241. package/lib/types/lib/ReanimatedModule.macos.d.ts +2 -0
  242. package/lib/types/lib/ReanimatedModule.native.d.ts +2 -0
  243. package/lib/types/lib/ReanimatedModule.windows.d.ts +2 -0
  244. package/lib/types/lib/ReanimatedModuleCompat.d.ts +14 -0
  245. package/lib/types/lib/createAnimatedComponent.d.ts +33 -0
  246. package/lib/types/lib/reanimated2/Bezier.d.ts +6 -0
  247. package/lib/types/lib/reanimated2/Colors.d.ts +31 -0
  248. package/lib/types/lib/reanimated2/Easing.d.ts +172 -0
  249. package/lib/types/lib/reanimated2/NativeMethods.d.ts +14 -0
  250. package/lib/types/lib/reanimated2/NativeReanimated/NativeReanimated.d.ts +20 -0
  251. package/lib/types/lib/reanimated2/NativeReanimated/index.d.ts +3 -0
  252. package/lib/types/lib/reanimated2/PlatformChecker.d.ts +5 -0
  253. package/lib/types/lib/reanimated2/PropAdapters.d.ts +4 -0
  254. package/lib/types/lib/reanimated2/UpdateProps.d.ts +9 -0
  255. package/lib/types/lib/reanimated2/ViewDescriptorsSet.d.ts +20 -0
  256. package/lib/types/lib/reanimated2/WorkletEventHandler.d.ts +13 -0
  257. package/lib/types/lib/reanimated2/__mocks__/MutableValue.d.ts +5 -0
  258. package/lib/types/lib/reanimated2/__mocks__/NativeReanimated.d.ts +13 -0
  259. package/lib/types/lib/reanimated2/__mocks__/NativeReanimated.native.d.ts +13 -0
  260. package/lib/types/lib/reanimated2/animation/commonTypes.d.ts +27 -0
  261. package/lib/types/lib/reanimated2/animation/decay.d.ts +19 -0
  262. package/lib/types/lib/reanimated2/animation/delay.d.ts +7 -0
  263. package/lib/types/lib/reanimated2/animation/index.d.ts +9 -0
  264. package/lib/types/lib/reanimated2/animation/repeat.d.ts +12 -0
  265. package/lib/types/lib/reanimated2/animation/sequence.d.ts +7 -0
  266. package/lib/types/lib/reanimated2/animation/spring.d.ts +22 -0
  267. package/lib/types/lib/reanimated2/animation/styleAnimation.d.ts +7 -0
  268. package/lib/types/lib/reanimated2/animation/timing.d.ts +21 -0
  269. package/lib/types/lib/reanimated2/animation/util.d.ts +9 -0
  270. package/lib/types/lib/reanimated2/commonTypes.d.ts +79 -0
  271. package/lib/types/lib/reanimated2/component/FlatList.d.ts +9 -0
  272. package/lib/types/lib/reanimated2/component/WrappedComponents.d.ts +8 -0
  273. package/lib/types/lib/reanimated2/component/index.d.ts +9 -0
  274. package/lib/types/lib/reanimated2/core.d.ts +24 -0
  275. package/lib/types/lib/reanimated2/hook/Hooks.d.ts +5 -0
  276. package/lib/types/lib/reanimated2/hook/commonTypes.d.ts +14 -0
  277. package/lib/types/lib/reanimated2/hook/index.d.ts +10 -0
  278. package/lib/types/lib/reanimated2/hook/useAnimatedGestureHandler.d.ts +35 -0
  279. package/lib/types/lib/reanimated2/hook/useAnimatedReaction.d.ts +12 -0
  280. package/lib/types/lib/reanimated2/hook/useAnimatedRef.d.ts +3 -0
  281. package/lib/types/lib/reanimated2/hook/useAnimatedScrollHandler.d.ts +21 -0
  282. package/lib/types/lib/reanimated2/hook/useAnimatedSensor.d.ts +20 -0
  283. package/lib/types/lib/reanimated2/hook/useAnimatedStyle.d.ts +11 -0
  284. package/lib/types/lib/reanimated2/hook/useDerivedValue.d.ts +4 -0
  285. package/lib/types/lib/reanimated2/hook/useSharedValue.d.ts +2 -0
  286. package/lib/types/lib/reanimated2/hook/utils.d.ts +28 -0
  287. package/lib/types/lib/reanimated2/index.d.ts +12 -0
  288. package/lib/types/lib/reanimated2/interpolateColor.d.ts +26 -0
  289. package/lib/types/lib/reanimated2/interpolation.d.ts +14 -0
  290. package/lib/types/lib/reanimated2/jestUtils.d.ts +12 -0
  291. package/lib/types/lib/reanimated2/js-reanimated/JSReanimated.d.ts +30 -0
  292. package/lib/types/lib/reanimated2/js-reanimated/Mapper.d.ts +14 -0
  293. package/lib/types/lib/reanimated2/js-reanimated/MapperRegistry.d.ts +14 -0
  294. package/lib/types/lib/reanimated2/js-reanimated/MutableValue.d.ts +14 -0
  295. package/lib/types/lib/reanimated2/js-reanimated/commonTypes.d.ts +44 -0
  296. package/lib/types/lib/reanimated2/js-reanimated/index.d.ts +15 -0
  297. package/lib/types/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.d.ts +1 -0
  298. package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.d.ts +22 -0
  299. package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +38 -0
  300. package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/Keyframe.d.ts +25 -0
  301. package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/commonTypes.d.ts +77 -0
  302. package/lib/types/lib/reanimated2/layoutReanimation/animationBuilder/index.d.ts +4 -0
  303. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Bounce.d.ts +62 -0
  304. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Default.d.ts +4 -0
  305. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Fade.d.ts +42 -0
  306. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.d.ts +50 -0
  307. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.d.ts +18 -0
  308. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.d.ts +10 -0
  309. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Roll.d.ts +18 -0
  310. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.d.ts +34 -0
  311. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.d.ts +34 -0
  312. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Stretch.d.ts +18 -0
  313. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.d.ts +66 -0
  314. package/lib/types/lib/reanimated2/layoutReanimation/defaultAnimations/index.d.ts +10 -0
  315. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +19 -0
  316. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +13 -0
  317. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.d.ts +6 -0
  318. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +6 -0
  319. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.d.ts +7 -0
  320. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +9 -0
  321. package/lib/types/lib/reanimated2/layoutReanimation/defaultTransitions/index.d.ts +6 -0
  322. package/lib/types/lib/reanimated2/layoutReanimation/index.d.ts +4 -0
  323. package/lib/types/lib/reanimated2/mock.d.ts +55 -0
  324. package/lib/types/lib/reanimated2/platform-specific/RNRenderer.d.ts +1 -0
  325. package/lib/types/lib/reanimated2/platform-specific/RNRenderer.web.d.ts +0 -0
  326. package/lib/types/lib/reanimated2/utils.d.ts +7 -0
  327. package/lib/types/lib/setAndForwardRef.d.ts +40 -0
  328. package/lib/types/react-native-reanimated-tests.d.ts +1 -0
  329. package/mock.js +4 -4
  330. package/package.json +43 -39
  331. package/plugin.js +3 -12
  332. package/react-native-reanimated.d.ts +58 -32
  333. package/src/ConfigHelper.ts +4 -5
  334. package/src/createAnimatedComponent.tsx +4 -4
  335. package/src/reanimated1/core/AnimatedFunction.js +1 -1
  336. package/src/reanimated1/derived/interpolate.js +2 -4
  337. package/src/reanimated2/Colors.ts +2 -1
  338. package/src/reanimated2/Easing.ts +9 -3
  339. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +42 -15
  340. package/src/reanimated2/NativeReanimated/index.ts +0 -6
  341. package/src/reanimated2/ViewDescriptorsSet.ts +2 -3
  342. package/src/reanimated2/animation/index.ts +1 -0
  343. package/src/reanimated2/animation/styleAnimation.ts +10 -7
  344. package/src/reanimated2/animation/timing.ts +3 -1
  345. package/src/reanimated2/animation/util.ts +10 -11
  346. package/src/reanimated2/commonTypes.ts +20 -1
  347. package/src/reanimated2/component/FlatList.tsx +3 -2
  348. package/src/reanimated2/core.ts +34 -73
  349. package/src/reanimated2/globals.d.ts +7 -2
  350. package/src/reanimated2/hook/index.ts +1 -0
  351. package/src/reanimated2/hook/useAnimatedSensor.ts +91 -0
  352. package/src/reanimated2/hook/utils.ts +2 -1
  353. package/src/reanimated2/interpolateColor.ts +11 -11
  354. package/src/reanimated2/interpolation.ts +2 -6
  355. package/src/reanimated2/jestUtils.ts +20 -4
  356. package/src/reanimated2/js-reanimated/JSReanimated.ts +25 -2
  357. package/src/reanimated2/js-reanimated/index.ts +3 -3
  358. package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +13 -0
  359. package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +2 -3
  360. package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +51 -21
  361. package/src/reanimated2/layoutReanimation/defaultAnimations/Fade.ts +40 -10
  362. package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +48 -12
  363. package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +16 -4
  364. package/src/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.ts +8 -2
  365. package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +16 -4
  366. package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +32 -8
  367. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -10
  368. package/src/reanimated2/layoutReanimation/defaultAnimations/Stretch.ts +16 -4
  369. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +64 -16
  370. package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +2 -1
  371. package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +26 -19
  372. package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +2 -1
  373. package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +2 -1
  374. package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +2 -1
  375. package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +2 -1
  376. package/src/reanimated2/mock.ts +3 -2
  377. package/android/expo/linking.gradle +0 -46
  378. package/android/expo/src/main/java/com/swmansion/reanimated/EXReanimatedAdapter.java +0 -12
  379. package/android/expo/src/main/java/expo/modules/adapters/reanimated/EXReanimatedPackage.java +0 -26
  380. package/android/react-native-reanimated-63-hermes.aar +0 -0
  381. package/android/react-native-reanimated-63-jsc.aar +0 -0
  382. package/android/src/main/java/com/swmansion/reanimated/ReanimatedProxyPackage.java +0 -15
  383. package/expo-module.config.json +0 -3
  384. package/libSo/fbjni/jni/arm64-v8a/libfbjni.so +0 -0
  385. package/libSo/fbjni/jni/armeabi-v7a/libfbjni.so +0 -0
  386. package/libSo/fbjni/jni/x86/libfbjni.so +0 -0
  387. package/libSo/fbjni/jni/x86_64/libfbjni.so +0 -0
@@ -0,0 +1,412 @@
1
+ package com.swmansion.reanimated.layoutReanimation;
2
+
3
+ import android.os.Build;
4
+ import android.util.Log;
5
+ import android.view.View;
6
+ import android.view.ViewGroup;
7
+ import androidx.annotation.Nullable;
8
+ import com.facebook.react.bridge.ReactApplicationContext;
9
+ import com.facebook.react.bridge.UiThreadUtil;
10
+ import com.facebook.react.uimanager.IllegalViewOperationException;
11
+ import com.facebook.react.uimanager.NativeViewHierarchyManager;
12
+ import com.facebook.react.uimanager.RootViewManager;
13
+ import com.facebook.react.uimanager.ViewAtIndex;
14
+ import com.facebook.react.uimanager.ViewGroupManager;
15
+ import com.facebook.react.uimanager.ViewManager;
16
+ import com.facebook.react.uimanager.ViewManagerRegistry;
17
+ import com.facebook.react.uimanager.layoutanimation.LayoutAnimationController;
18
+ import com.facebook.react.uimanager.layoutanimation.LayoutAnimationListener;
19
+ import com.swmansion.reanimated.ReanimatedModule;
20
+ import java.lang.ref.WeakReference;
21
+ import java.lang.reflect.Field;
22
+ import java.lang.reflect.Modifier;
23
+ import java.util.ArrayList;
24
+ import java.util.HashMap;
25
+ import java.util.HashSet;
26
+ import java.util.Set;
27
+
28
+ class ReaLayoutAnimator extends LayoutAnimationController {
29
+ private AnimationsManager mAnimationsManager = null;
30
+ private volatile boolean mInitialized = false;
31
+ private ReactApplicationContext mContext;
32
+ private WeakReference<NativeViewHierarchyManager> mWeakNativeViewHierarchyManage =
33
+ new WeakReference<>(null);
34
+
35
+ ReaLayoutAnimator(
36
+ ReactApplicationContext context, NativeViewHierarchyManager nativeViewHierarchyManager) {
37
+ mContext = context;
38
+ mWeakNativeViewHierarchyManage = new WeakReference<>(nativeViewHierarchyManager);
39
+ }
40
+
41
+ public void maybeInit() {
42
+ if (!mInitialized) {
43
+ mInitialized = true;
44
+ ReanimatedModule reanimatedModule = mContext.getNativeModule(ReanimatedModule.class);
45
+ mAnimationsManager = reanimatedModule.getNodesManager().getAnimationsManager();
46
+ mAnimationsManager.setReanimatedNativeHierarchyManager(
47
+ (ReanimatedNativeHierarchyManager) mWeakNativeViewHierarchyManage.get());
48
+ }
49
+ }
50
+
51
+ public boolean shouldAnimateLayout(View viewToAnimate) {
52
+ if (!isLayoutAnimationEnabled()) {
53
+ return super.shouldAnimateLayout(viewToAnimate);
54
+ }
55
+ // if view parent is null, skip animation: view have been clipped, we don't want animation to
56
+ // resume when view is re-attached to parent, which is the standard android animation behavior.
57
+ // If there's a layout handling animation going on, it should be animated nonetheless since the
58
+ // ongoing animation needs to be updated.
59
+ if (viewToAnimate == null) {
60
+ return false;
61
+ }
62
+ return (viewToAnimate.getParent() != null);
63
+ }
64
+
65
+ /**
66
+ * Update layout of given view, via immediate update or animation depending on the current batch
67
+ * layout animation configuration supplied during initialization. Handles create and update
68
+ * animations.
69
+ *
70
+ * @param view the view to update layout of
71
+ * @param x the new X position for the view
72
+ * @param y the new Y position for the view
73
+ * @param width the new width value for the view
74
+ * @param height the new height value for the view
75
+ */
76
+ public void applyLayoutUpdate(View view, int x, int y, int width, int height) {
77
+ if (!isLayoutAnimationEnabled()) {
78
+ super.applyLayoutUpdate(view, x, y, width, height);
79
+ return;
80
+ }
81
+ UiThreadUtil.assertOnUiThread();
82
+ maybeInit();
83
+ // Determine which animation to use : if view is initially invisible, use create animation,
84
+ // otherwise use update animation. This approach is easier than maintaining a list of tags
85
+ // for recently created views.
86
+ if (view.getWidth() == 0 || view.getHeight() == 0) {
87
+ view.layout(x, y, x + width, y + height);
88
+ if (view.getId() != -1) {
89
+ mAnimationsManager.onViewCreate(
90
+ view,
91
+ (ViewGroup) view.getParent(),
92
+ new Snapshot(view, mWeakNativeViewHierarchyManage.get()));
93
+ }
94
+ } else {
95
+ Snapshot before = new Snapshot(view, mWeakNativeViewHierarchyManage.get());
96
+ view.layout(x, y, x + width, y + height);
97
+ Snapshot after = new Snapshot(view, mWeakNativeViewHierarchyManage.get());
98
+ mAnimationsManager.onViewUpdate(view, before, after);
99
+ }
100
+ }
101
+
102
+ /**
103
+ * Animate a view deletion using the layout animation configuration supplied during
104
+ * initialization.
105
+ *
106
+ * @param view The view to animate.
107
+ * @param listener Called once the animation is finished, should be used to completely remove the
108
+ * view.
109
+ */
110
+ public void deleteView(final View view, final LayoutAnimationListener listener) {
111
+ if (!isLayoutAnimationEnabled()) {
112
+ super.deleteView(view, listener);
113
+ return;
114
+ }
115
+ UiThreadUtil.assertOnUiThread();
116
+ NativeViewHierarchyManager nativeViewHierarchyManager = mWeakNativeViewHierarchyManage.get();
117
+ ViewManager viewManager;
118
+ try {
119
+ viewManager = nativeViewHierarchyManager.resolveViewManager(view.getId());
120
+ } catch (IllegalViewOperationException e) {
121
+ // (IllegalViewOperationException) == (vm == null)
122
+ e.printStackTrace();
123
+ super.deleteView(view, listener);
124
+ return;
125
+ }
126
+ // we don't want layout animations in native-stack since it is currently buggy there
127
+ // so we check if it is a (grand)child of ScreenStack
128
+ if (viewManager.getName().equals("RNSScreen")
129
+ && view.getParent() != null
130
+ && view.getParent().getParent() instanceof View) {
131
+ // we check grandparent of Screen since the parent is a ScreenStackFragment
132
+ View screenParentView = (View) view.getParent().getParent();
133
+ ViewManager screenParentViewManager;
134
+ try {
135
+ screenParentViewManager =
136
+ nativeViewHierarchyManager.resolveViewManager(screenParentView.getId());
137
+ } catch (IllegalViewOperationException e) {
138
+ // (IllegalViewOperationException) == (vm == null)
139
+ e.printStackTrace();
140
+ super.deleteView(view, listener);
141
+ return;
142
+ }
143
+ String parentName = screenParentViewManager.getName();
144
+ if (parentName.equals("RNSScreenStack")) {
145
+ super.deleteView(view, listener);
146
+ return;
147
+ }
148
+ }
149
+ maybeInit();
150
+ Snapshot before = new Snapshot(view, mWeakNativeViewHierarchyManage.get());
151
+ mAnimationsManager.onViewRemoval(
152
+ view, (ViewGroup) view.getParent(), before, () -> listener.onAnimationEnd());
153
+ if (viewManager instanceof ViewGroupManager) {
154
+ ViewGroupManager vgm = (ViewGroupManager) viewManager;
155
+ for (int i = 0; i < vgm.getChildCount((ViewGroup) view); ++i) {
156
+ dfs(vgm.getChildAt((ViewGroup) view, i), nativeViewHierarchyManager);
157
+ }
158
+ }
159
+ }
160
+
161
+ private void dfs(View view, NativeViewHierarchyManager nativeViewHierarchyManager) {
162
+ int tag = view.getId();
163
+ if (tag == -1) {
164
+ return;
165
+ }
166
+ ViewManager vm = null;
167
+ try {
168
+ vm = nativeViewHierarchyManager.resolveViewManager(tag);
169
+ Snapshot before = new Snapshot(view, mWeakNativeViewHierarchyManage.get());
170
+ mAnimationsManager.onViewRemoval(
171
+ view,
172
+ (ViewGroup) view.getParent(),
173
+ before,
174
+ () -> {
175
+ ReanimatedNativeHierarchyManager reanimatedNativeHierarchyManager =
176
+ (ReanimatedNativeHierarchyManager) nativeViewHierarchyManager;
177
+ reanimatedNativeHierarchyManager.publicDropView(view);
178
+ });
179
+ } catch (IllegalViewOperationException e) {
180
+ // (IllegalViewOperationException) == (vm == null)
181
+ e.printStackTrace();
182
+ }
183
+ if (vm instanceof ViewGroupManager) {
184
+ ViewGroupManager vgm = (ViewGroupManager) vm;
185
+ for (int i = 0; i < vgm.getChildCount((ViewGroup) view); ++i) {
186
+ dfs(vgm.getChildAt((ViewGroup) view, i), nativeViewHierarchyManager);
187
+ }
188
+ }
189
+ }
190
+
191
+ public boolean isLayoutAnimationEnabled() {
192
+ maybeInit();
193
+ return mAnimationsManager.isLayoutAnimationEnabled();
194
+ }
195
+ }
196
+
197
+ public class ReanimatedNativeHierarchyManager extends NativeViewHierarchyManager {
198
+ private final HashMap<Integer, ArrayList<View>> toBeRemoved = new HashMap<>();
199
+ private final HashMap<Integer, Runnable> cleanerCallback = new HashMap<>();
200
+ private LayoutAnimationController mReaLayoutAnimator = null;
201
+ private HashMap<Integer, Set<Integer>> mPendingDeletionsForTag = new HashMap<>();
202
+ private boolean initOk = true;
203
+
204
+ public ReanimatedNativeHierarchyManager(
205
+ ViewManagerRegistry viewManagers, ReactApplicationContext reactContext) {
206
+ super(viewManagers);
207
+
208
+ mReaLayoutAnimator = new ReaLayoutAnimator(reactContext, this);
209
+
210
+ Class clazz = this.getClass().getSuperclass();
211
+ if (clazz == null) {
212
+ Log.e("reanimated", "unable to resolve super class of ReanimatedNativeHierarchyManager");
213
+ return;
214
+ }
215
+
216
+ try {
217
+ Field layoutAnimatorField = clazz.getDeclaredField("mLayoutAnimator");
218
+ layoutAnimatorField.setAccessible(true);
219
+
220
+ if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
221
+ try {
222
+ // accessFlags is supported only by API >=23
223
+ Field modifiersField = Field.class.getDeclaredField("accessFlags");
224
+ modifiersField.setAccessible(true);
225
+ modifiersField.setInt(
226
+ layoutAnimatorField, layoutAnimatorField.getModifiers() & ~Modifier.FINAL);
227
+ } catch (NoSuchFieldException | IllegalAccessException e) {
228
+ e.printStackTrace();
229
+ }
230
+ }
231
+ layoutAnimatorField.set(this, mReaLayoutAnimator);
232
+ } catch (NoSuchFieldException | IllegalAccessException e) {
233
+ initOk = false;
234
+ e.printStackTrace();
235
+ }
236
+
237
+ try {
238
+ Field pendingTagsField = clazz.getDeclaredField("mPendingDeletionsForTag");
239
+ pendingTagsField.setAccessible(true);
240
+
241
+ if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
242
+ try {
243
+ // accessFlags is supported only by API >=23
244
+ Field pendingTagsFieldModifiers = Field.class.getDeclaredField("accessFlags");
245
+ pendingTagsFieldModifiers.setAccessible(true);
246
+ pendingTagsFieldModifiers.setInt(
247
+ pendingTagsField, pendingTagsField.getModifiers() & ~Modifier.FINAL);
248
+ } catch (NoSuchFieldException | IllegalAccessException e) {
249
+ e.printStackTrace();
250
+ }
251
+ }
252
+ pendingTagsField.set(this, mPendingDeletionsForTag);
253
+ } catch (NoSuchFieldException | IllegalAccessException e) {
254
+ initOk = false;
255
+ e.printStackTrace();
256
+ }
257
+
258
+ if (initOk) {
259
+ setLayoutAnimationEnabled(true);
260
+ }
261
+ }
262
+
263
+ public ReanimatedNativeHierarchyManager(
264
+ ViewManagerRegistry viewManagers, RootViewManager manager) {
265
+ super(viewManagers, manager);
266
+ }
267
+
268
+ private boolean isLayoutAnimationDisabled() {
269
+ return !initOk || !((ReaLayoutAnimator) mReaLayoutAnimator).isLayoutAnimationEnabled();
270
+ }
271
+
272
+ public synchronized void updateLayout(
273
+ int parentTag, int tag, int x, int y, int width, int height) {
274
+ super.updateLayout(parentTag, tag, x, y, width, height);
275
+ if (isLayoutAnimationDisabled()) {
276
+ return;
277
+ }
278
+ try {
279
+ View viewToUpdate = this.resolveView(tag);
280
+ ViewManager viewManager = this.resolveViewManager(tag);
281
+ String viewManagerName = viewManager.getName();
282
+ View container = resolveView(parentTag);
283
+ if (container != null
284
+ && viewManagerName.equals("RNSScreen")
285
+ && this.mReaLayoutAnimator != null) {
286
+ this.mReaLayoutAnimator.applyLayoutUpdate(
287
+ viewToUpdate,
288
+ (int) container.getX(),
289
+ (int) container.getY(),
290
+ container.getWidth(),
291
+ container.getHeight());
292
+ }
293
+ } catch (IllegalViewOperationException e) {
294
+ // (IllegalViewOperationException) == (vm == null)
295
+ e.printStackTrace();
296
+ }
297
+ }
298
+
299
+ // @Override
300
+ public synchronized void manageChildren(
301
+ int tag,
302
+ @Nullable int[] indicesToRemove,
303
+ @Nullable ViewAtIndex[] viewsToAdd,
304
+ @Nullable int[] tagsToDelete) {
305
+ int[] mock = new int[] {};
306
+ if (isLayoutAnimationDisabled()) {
307
+ super.manageChildren(tag, indicesToRemove, viewsToAdd, tagsToDelete, mock);
308
+ return;
309
+ }
310
+ ViewGroup viewGroup;
311
+ ViewGroupManager viewGroupManager;
312
+ try {
313
+ viewGroup = (ViewGroup) resolveView(tag);
314
+ viewGroupManager = (ViewGroupManager) resolveViewManager(tag);
315
+ } catch (IllegalViewOperationException e) {
316
+ // (IllegalViewOperationException) == (vm == null)
317
+ e.printStackTrace();
318
+ super.manageChildren(tag, indicesToRemove, viewsToAdd, tagsToDelete, mock);
319
+ return;
320
+ }
321
+
322
+ // we don't want layout animations in native-stack since it is currently buggy there
323
+ if (viewGroupManager.getName().equals("RNSScreenStack")) {
324
+ super.manageChildren(tag, indicesToRemove, viewsToAdd, tagsToDelete, mock);
325
+ return;
326
+ }
327
+
328
+ if (toBeRemoved.containsKey(tag)) {
329
+ ArrayList<View> childrenToBeRemoved = toBeRemoved.get(tag);
330
+ HashSet<Integer> tagsToRemove = new HashSet<Integer>();
331
+ for (View childToRemove : childrenToBeRemoved) {
332
+ tagsToRemove.add(childToRemove.getId());
333
+ }
334
+ while (viewGroupManager.getChildCount(viewGroup) != 0) {
335
+ View child =
336
+ viewGroupManager.getChildAt(viewGroup, viewGroupManager.getChildCount(viewGroup) - 1);
337
+ if (tagsToRemove.contains(child.getId())) {
338
+ viewGroupManager.removeViewAt(viewGroup, viewGroupManager.getChildCount(viewGroup) - 1);
339
+ } else {
340
+ break;
341
+ }
342
+ }
343
+ }
344
+ if (tagsToDelete != null) {
345
+ if (!toBeRemoved.containsKey(tag)) {
346
+ toBeRemoved.put(tag, new ArrayList<>());
347
+ }
348
+ ArrayList<View> toBeRemovedChildren = toBeRemoved.get(tag);
349
+ for (Integer childtag : tagsToDelete) {
350
+ View view;
351
+ try {
352
+ view = resolveView(childtag);
353
+ } catch (IllegalViewOperationException e) {
354
+ // (IllegalViewOperationException) == (vm == null)
355
+ e.printStackTrace();
356
+ continue;
357
+ }
358
+ toBeRemovedChildren.add(view);
359
+ cleanerCallback.put(
360
+ view.getId(),
361
+ new Runnable() {
362
+ @Override
363
+ public void run() {
364
+ toBeRemovedChildren.remove(view);
365
+ viewGroupManager.removeView(viewGroup, view);
366
+ } // It's far from optimal but let's leave it as it is for now
367
+ });
368
+ }
369
+ }
370
+
371
+ // mPendingDeletionsForTag is modify by React
372
+ if (mPendingDeletionsForTag != null) {
373
+ Set<Integer> pendingTags = mPendingDeletionsForTag.get(tag);
374
+ if (pendingTags != null) {
375
+ pendingTags.clear();
376
+ }
377
+ }
378
+
379
+ super.manageChildren(tag, indicesToRemove, viewsToAdd, mock, mock);
380
+ if (toBeRemoved.containsKey(tag)) {
381
+ ArrayList<View> childrenToBeRemoved = toBeRemoved.get(tag);
382
+ for (View child : childrenToBeRemoved) {
383
+ viewGroupManager.addView(viewGroup, child, viewGroupManager.getChildCount(viewGroup));
384
+ }
385
+ }
386
+ ViewAtIndex[] mock2 = new ViewAtIndex[] {};
387
+ super.manageChildren(tag, mock, mock2, tagsToDelete, mock);
388
+ }
389
+
390
+ public void publicDropView(View view) {
391
+ dropView(view);
392
+ }
393
+
394
+ @Override
395
+ protected synchronized void dropView(View view) {
396
+ if (isLayoutAnimationDisabled()) {
397
+ super.dropView(view);
398
+ return;
399
+ }
400
+ if (toBeRemoved.containsKey(view.getId())) {
401
+ toBeRemoved.remove(view.getId());
402
+ }
403
+ if (cleanerCallback.containsKey(view.getId())) {
404
+ Runnable runnable = cleanerCallback.get(view.getId());
405
+ cleanerCallback.remove(view.getId());
406
+ runnable.run();
407
+ }
408
+ // childrens' callbacks should be cleaned by former publicDropView calls as Animation Manager
409
+ // stripes views from bottom to top
410
+ super.dropView(view);
411
+ }
412
+ }
@@ -0,0 +1,68 @@
1
+ package com.facebook.react.uimanager;
2
+
3
+ import androidx.annotation.Nullable;
4
+ import com.facebook.react.bridge.ReactApplicationContext;
5
+ import com.facebook.react.bridge.ReadableArray;
6
+ import com.facebook.react.uimanager.events.EventDispatcher;
7
+ import com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager;
8
+ import java.util.List;
9
+
10
+ public class ReanimatedUIImplementation extends UIImplementation {
11
+ public ReanimatedUIImplementation(
12
+ ReactApplicationContext reactContext,
13
+ UIManagerModule.ViewManagerResolver viewManagerResolver,
14
+ EventDispatcher eventDispatcher,
15
+ int minTimeLeftInFrameForNonBatchedOperationMs) {
16
+ this(
17
+ reactContext,
18
+ new ViewManagerRegistry(viewManagerResolver),
19
+ eventDispatcher,
20
+ minTimeLeftInFrameForNonBatchedOperationMs);
21
+ }
22
+
23
+ public ReanimatedUIImplementation(
24
+ ReactApplicationContext reactContext,
25
+ List<ViewManager> viewManagerList,
26
+ EventDispatcher eventDispatcher,
27
+ int minTimeLeftInFrameForNonBatchedOperationMs) {
28
+ this(
29
+ reactContext,
30
+ new ViewManagerRegistry(viewManagerList),
31
+ eventDispatcher,
32
+ minTimeLeftInFrameForNonBatchedOperationMs);
33
+ }
34
+
35
+ public ReanimatedUIImplementation(
36
+ ReactApplicationContext reactContext,
37
+ ViewManagerRegistry viewManagerRegistry,
38
+ EventDispatcher eventDispatcher,
39
+ int minTimeLeftInFrameForNonBatchedOperationMs) {
40
+ super(
41
+ reactContext,
42
+ viewManagerRegistry,
43
+ new UIViewOperationQueue(
44
+ reactContext,
45
+ new ReanimatedNativeHierarchyManager(viewManagerRegistry, reactContext),
46
+ minTimeLeftInFrameForNonBatchedOperationMs),
47
+ eventDispatcher);
48
+ }
49
+
50
+ /**
51
+ * Invoked when there is a mutation in a node tree.
52
+ *
53
+ * @param tag react tag of the node we want to manage
54
+ * @param indicesToRemove ordered (asc) list of indicies at which view should be removed
55
+ * @param viewsToAdd ordered (asc based on mIndex property) list of tag-index pairs that represent
56
+ * a view which should be added at the specified index
57
+ * @param tagsToDelete list of tags corresponding to views that should be removed
58
+ */
59
+ public void manageChildren(
60
+ int viewTag,
61
+ @Nullable ReadableArray moveFrom,
62
+ @Nullable ReadableArray moveTo,
63
+ @Nullable ReadableArray addChildTags,
64
+ @Nullable ReadableArray addAtIndices,
65
+ @Nullable ReadableArray removeFrom) {
66
+ super.manageChildren(viewTag, moveFrom, moveTo, addChildTags, addAtIndices, removeFrom);
67
+ }
68
+ }
@@ -0,0 +1,68 @@
1
+ package com.facebook.react.uimanager;
2
+
3
+ import androidx.annotation.Nullable;
4
+ import com.facebook.react.bridge.ReactApplicationContext;
5
+ import com.facebook.react.bridge.ReadableArray;
6
+ import com.facebook.react.uimanager.events.EventDispatcher;
7
+ import com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager;
8
+ import java.util.List;
9
+
10
+ public class ReanimatedUIImplementation extends UIImplementation {
11
+ public ReanimatedUIImplementation(
12
+ ReactApplicationContext reactContext,
13
+ UIManagerModule.ViewManagerResolver viewManagerResolver,
14
+ EventDispatcher eventDispatcher,
15
+ int minTimeLeftInFrameForNonBatchedOperationMs) {
16
+ this(
17
+ reactContext,
18
+ new ViewManagerRegistry(viewManagerResolver),
19
+ eventDispatcher,
20
+ minTimeLeftInFrameForNonBatchedOperationMs);
21
+ }
22
+
23
+ public ReanimatedUIImplementation(
24
+ ReactApplicationContext reactContext,
25
+ List<ViewManager> viewManagerList,
26
+ EventDispatcher eventDispatcher,
27
+ int minTimeLeftInFrameForNonBatchedOperationMs) {
28
+ this(
29
+ reactContext,
30
+ new ViewManagerRegistry(viewManagerList),
31
+ eventDispatcher,
32
+ minTimeLeftInFrameForNonBatchedOperationMs);
33
+ }
34
+
35
+ public ReanimatedUIImplementation(
36
+ ReactApplicationContext reactContext,
37
+ ViewManagerRegistry viewManagerRegistry,
38
+ EventDispatcher eventDispatcher,
39
+ int minTimeLeftInFrameForNonBatchedOperationMs) {
40
+ super(
41
+ reactContext,
42
+ viewManagerRegistry,
43
+ new UIViewOperationQueue(
44
+ reactContext,
45
+ new ReanimatedNativeHierarchyManager(viewManagerRegistry, reactContext),
46
+ minTimeLeftInFrameForNonBatchedOperationMs),
47
+ eventDispatcher);
48
+ }
49
+
50
+ /**
51
+ * Invoked when there is a mutation in a node tree.
52
+ *
53
+ * @param tag react tag of the node we want to manage
54
+ * @param indicesToRemove ordered (asc) list of indicies at which view should be removed
55
+ * @param viewsToAdd ordered (asc based on mIndex property) list of tag-index pairs that represent
56
+ * a view which should be added at the specified index
57
+ * @param tagsToDelete list of tags corresponding to views that should be removed
58
+ */
59
+ public void manageChildren(
60
+ int viewTag,
61
+ @Nullable ReadableArray moveFrom,
62
+ @Nullable ReadableArray moveTo,
63
+ @Nullable ReadableArray addChildTags,
64
+ @Nullable ReadableArray addAtIndices,
65
+ @Nullable ReadableArray removeFrom) {
66
+ super.manageChildren(viewTag, moveFrom, moveTo, addChildTags, addAtIndices, removeFrom);
67
+ }
68
+ }
@@ -0,0 +1,68 @@
1
+ package com.facebook.react.uimanager;
2
+
3
+ import androidx.annotation.Nullable;
4
+ import com.facebook.react.bridge.ReactApplicationContext;
5
+ import com.facebook.react.bridge.ReadableArray;
6
+ import com.facebook.react.uimanager.events.EventDispatcher;
7
+ import com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager;
8
+ import java.util.List;
9
+
10
+ public class ReanimatedUIImplementation extends UIImplementation {
11
+ public ReanimatedUIImplementation(
12
+ ReactApplicationContext reactContext,
13
+ UIManagerModule.ViewManagerResolver viewManagerResolver,
14
+ EventDispatcher eventDispatcher,
15
+ int minTimeLeftInFrameForNonBatchedOperationMs) {
16
+ this(
17
+ reactContext,
18
+ new ViewManagerRegistry(viewManagerResolver),
19
+ eventDispatcher,
20
+ minTimeLeftInFrameForNonBatchedOperationMs);
21
+ }
22
+
23
+ public ReanimatedUIImplementation(
24
+ ReactApplicationContext reactContext,
25
+ List<ViewManager> viewManagerList,
26
+ EventDispatcher eventDispatcher,
27
+ int minTimeLeftInFrameForNonBatchedOperationMs) {
28
+ this(
29
+ reactContext,
30
+ new ViewManagerRegistry(viewManagerList),
31
+ eventDispatcher,
32
+ minTimeLeftInFrameForNonBatchedOperationMs);
33
+ }
34
+
35
+ public ReanimatedUIImplementation(
36
+ ReactApplicationContext reactContext,
37
+ ViewManagerRegistry viewManagerRegistry,
38
+ EventDispatcher eventDispatcher,
39
+ int minTimeLeftInFrameForNonBatchedOperationMs) {
40
+ super(
41
+ reactContext,
42
+ viewManagerRegistry,
43
+ new UIViewOperationQueue(
44
+ reactContext,
45
+ new ReanimatedNativeHierarchyManager(viewManagerRegistry, reactContext),
46
+ minTimeLeftInFrameForNonBatchedOperationMs),
47
+ eventDispatcher);
48
+ }
49
+
50
+ /**
51
+ * Invoked when there is a mutation in a node tree.
52
+ *
53
+ * @param tag react tag of the node we want to manage
54
+ * @param indicesToRemove ordered (asc) list of indicies at which view should be removed
55
+ * @param viewsToAdd ordered (asc based on mIndex property) list of tag-index pairs that represent
56
+ * a view which should be added at the specified index
57
+ * @param tagsToDelete list of tags corresponding to views that should be removed
58
+ */
59
+ public void manageChildren(
60
+ int viewTag,
61
+ @Nullable ReadableArray moveFrom,
62
+ @Nullable ReadableArray moveTo,
63
+ @Nullable ReadableArray addChildTags,
64
+ @Nullable ReadableArray addAtIndices,
65
+ @Nullable ReadableArray removeFrom) {
66
+ super.manageChildren(viewTag, moveFrom, moveTo, addChildTags, addAtIndices, removeFrom);
67
+ }
68
+ }
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1 @@
1
+ include 'lib'
@@ -0,0 +1,9 @@
1
+ // formatter & linter configuration for java
2
+ apply plugin: 'com.diffplug.spotless'
3
+
4
+ spotless {
5
+ java {
6
+ target 'src/main/java/**/*.java'
7
+ googleJavaFormat()
8
+ }
9
+ }
@@ -0,0 +1,42 @@
1
+ #include "AndroidErrorHandler.h"
2
+ #include <fbjni/fbjni.h>
3
+ #include <string>
4
+ #include "Logger.h"
5
+
6
+ namespace reanimated {
7
+
8
+ using namespace facebook::jni;
9
+
10
+ AndroidErrorHandler::AndroidErrorHandler(std::shared_ptr<Scheduler> scheduler) {
11
+ this->scheduler = scheduler;
12
+ this->error = std::make_shared<ErrorWrapper>();
13
+ }
14
+
15
+ void AndroidErrorHandler::raiseSpec() {
16
+ if (error->handled) {
17
+ return;
18
+ }
19
+
20
+ static const auto cls = javaClassStatic();
21
+ static auto method = cls->getStaticMethod<void(std::string)>("raise");
22
+ method(cls, error->message);
23
+
24
+ this->error->handled = true;
25
+ }
26
+
27
+ std::shared_ptr<Scheduler> AndroidErrorHandler::getScheduler() {
28
+ return this->scheduler;
29
+ }
30
+
31
+ std::shared_ptr<ErrorWrapper> AndroidErrorHandler::getError() {
32
+ return this->error;
33
+ }
34
+
35
+ void AndroidErrorHandler::setError(std::string message) {
36
+ if (error->handled) {
37
+ error->message = message;
38
+ error->handled = false;
39
+ }
40
+ }
41
+
42
+ } // namespace reanimated