react-native-reanimated 2.3.0-alpha.1 → 2.3.0-beta.2

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 (328) hide show
  1. package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp +15 -8
  2. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +170 -166
  3. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +36 -34
  4. package/Common/cpp/Registries/EventHandlerRegistry.cpp +13 -6
  5. package/Common/cpp/Registries/MapperRegistry.cpp +19 -15
  6. package/Common/cpp/Registries/WorkletsCache.cpp +19 -9
  7. package/Common/cpp/SharedItems/FrozenObject.cpp +19 -8
  8. package/Common/cpp/SharedItems/MutableValue.cpp +38 -25
  9. package/Common/cpp/SharedItems/MutableValueSetterProxy.cpp +11 -7
  10. package/Common/cpp/SharedItems/RemoteObject.cpp +9 -5
  11. package/Common/cpp/SharedItems/ShareableValue.cpp +216 -143
  12. package/Common/cpp/Tools/JSIStoreValueUser.cpp +36 -24
  13. package/Common/cpp/Tools/Mapper.cpp +41 -29
  14. package/Common/cpp/Tools/RuntimeDecorator.cpp +103 -84
  15. package/Common/cpp/Tools/Scheduler.cpp +14 -6
  16. package/Common/cpp/Tools/WorkletEventHandler.cpp +1 -1
  17. package/Common/cpp/headers/LayoutAnimations/LayoutAnimationsProxy.h +12 -11
  18. package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +45 -34
  19. package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +28 -16
  20. package/Common/cpp/headers/Registries/EventHandlerRegistry.h +14 -8
  21. package/Common/cpp/headers/Registries/MapperRegistry.h +4 -4
  22. package/Common/cpp/headers/Registries/WorkletsCache.h +9 -7
  23. package/Common/cpp/headers/SharedItems/FrozenObject.h +15 -11
  24. package/Common/cpp/headers/SharedItems/HostFunctionHandler.h +6 -4
  25. package/Common/cpp/headers/SharedItems/MutableValue.h +21 -12
  26. package/Common/cpp/headers/SharedItems/MutableValueSetterProxy.h +10 -7
  27. package/Common/cpp/headers/SharedItems/RemoteObject.h +16 -8
  28. package/Common/cpp/headers/SharedItems/RuntimeManager.h +39 -21
  29. package/Common/cpp/headers/SharedItems/ShareableValue.h +31 -27
  30. package/Common/cpp/headers/SharedItems/SharedParent.h +7 -4
  31. package/Common/cpp/headers/SharedItems/ValueWrapper.h +80 -61
  32. package/Common/cpp/headers/SpecTools/ErrorHandler.h +17 -19
  33. package/Common/cpp/headers/Tools/JSIStoreValueUser.h +18 -13
  34. package/Common/cpp/headers/Tools/Mapper.h +24 -18
  35. package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +12 -7
  36. package/Common/cpp/headers/Tools/ReanimatedHiddenHeaders.h +7 -7
  37. package/Common/cpp/headers/Tools/RuntimeDecorator.h +29 -23
  38. package/Common/cpp/headers/Tools/Scheduler.h +28 -33
  39. package/Common/cpp/headers/Tools/WorkletEventHandler.h +9 -7
  40. package/Common/cpp/hidden_headers/Logger.h +14 -14
  41. package/Common/cpp/hidden_headers/LoggerInterface.h +8 -9
  42. package/Common/cpp/hidden_headers/SpeedChecker.h +7 -8
  43. package/README.md +1 -1
  44. package/RNReanimated.podspec +4 -4
  45. package/android/build.gradle +80 -3
  46. package/android/react-native-reanimated-63-hermes.aar +0 -0
  47. package/android/react-native-reanimated-63-jsc.aar +0 -0
  48. package/android/react-native-reanimated-64-hermes.aar +0 -0
  49. package/android/react-native-reanimated-64-jsc.aar +0 -0
  50. package/android/react-native-reanimated-65-hermes.aar +0 -0
  51. package/android/react-native-reanimated-65-jsc.aar +0 -0
  52. package/android/react-native-reanimated-66-hermes.aar +0 -0
  53. package/android/react-native-reanimated-66-jsc.aar +0 -0
  54. package/ios/LayoutReanimation/REAAnimationsManager.h +19 -10
  55. package/ios/LayoutReanimation/REAAnimationsManager.m +195 -200
  56. package/ios/LayoutReanimation/REASnapshot.h +13 -0
  57. package/ios/LayoutReanimation/REASnapshot.m +29 -0
  58. package/ios/LayoutReanimation/REAUIManager.h +16 -0
  59. package/ios/LayoutReanimation/REAUIManager.mm +348 -0
  60. package/ios/Nodes/REAAlwaysNode.m +14 -15
  61. package/ios/Nodes/REABezierNode.m +8 -7
  62. package/ios/Nodes/REABlockNode.m +1 -1
  63. package/ios/Nodes/REACallFuncNode.h +0 -1
  64. package/ios/Nodes/REACallFuncNode.m +10 -8
  65. package/ios/Nodes/REAClockNodes.m +22 -20
  66. package/ios/Nodes/REAConcatNode.h +0 -1
  67. package/ios/Nodes/REAConcatNode.m +2 -2
  68. package/ios/Nodes/REACondNode.m +7 -5
  69. package/ios/Nodes/READebugNode.m +5 -4
  70. package/ios/Nodes/REAEventNode.m +1 -1
  71. package/ios/Nodes/REAFunctionNode.h +0 -1
  72. package/ios/Nodes/REAFunctionNode.m +2 -2
  73. package/ios/Nodes/REAJSCallNode.m +4 -5
  74. package/ios/Nodes/REANode.h +3 -4
  75. package/ios/Nodes/REANode.m +9 -11
  76. package/ios/Nodes/REAOperatorNode.m +68 -67
  77. package/ios/Nodes/REAParamNode.h +1 -3
  78. package/ios/Nodes/REAParamNode.m +15 -17
  79. package/ios/Nodes/REAPropsNode.h +1 -3
  80. package/ios/Nodes/REAPropsNode.m +19 -22
  81. package/ios/Nodes/REASetNode.h +0 -1
  82. package/ios/Nodes/REASetNode.m +7 -5
  83. package/ios/Nodes/REAStyleNode.h +0 -1
  84. package/ios/Nodes/REAStyleNode.m +2 -4
  85. package/ios/Nodes/REATransformNode.h +0 -1
  86. package/ios/Nodes/REATransformNode.m +3 -5
  87. package/ios/Nodes/REAValueNode.m +5 -7
  88. package/ios/REAEventDispatcher.m +3 -3
  89. package/ios/REAModule.h +0 -2
  90. package/ios/REAModule.m +29 -40
  91. package/ios/REANodesManager.h +11 -19
  92. package/ios/REANodesManager.m +105 -130
  93. package/ios/REAUtils.h +5 -3
  94. package/ios/Transitioning/RCTConvert+REATransition.m +45 -29
  95. package/ios/Transitioning/REAAllTransitions.h +2 -2
  96. package/ios/Transitioning/REAAllTransitions.m +14 -25
  97. package/ios/Transitioning/REATransition.h +8 -7
  98. package/ios/Transitioning/REATransition.m +19 -16
  99. package/ios/Transitioning/REATransitionAnimation.h +1 -1
  100. package/ios/Transitioning/REATransitionAnimation.m +2 -3
  101. package/ios/Transitioning/REATransitionManager.m +3 -3
  102. package/ios/native/NativeMethods.h +15 -5
  103. package/ios/native/NativeProxy.h +4 -3
  104. package/ios/native/NativeProxy.mm +19 -5
  105. package/ios/native/REAIOSErrorHandler.h +13 -10
  106. package/ios/native/REAIOSLogger.h +8 -8
  107. package/ios/native/REAIOSScheduler.h +5 -5
  108. package/ios/native/REAIOSScheduler.mm +7 -5
  109. package/ios/native/REAInitializer.h +37 -0
  110. package/ios/native/REAInitializer.mm +63 -0
  111. package/ios/native/UIResponder+Reanimated.mm +9 -48
  112. package/lib/ConfigHelper.js +1 -0
  113. package/lib/ReanimatedModule.native.js +10 -2
  114. package/lib/createAnimatedComponent.js +64 -30
  115. package/lib/reanimated1/core/AnimatedAlways.js +1 -1
  116. package/lib/reanimated1/core/AnimatedBezier.js +1 -1
  117. package/lib/reanimated1/core/AnimatedBlock.js +1 -1
  118. package/lib/reanimated1/core/AnimatedCall.js +1 -1
  119. package/lib/reanimated1/core/AnimatedCallFunc.js +1 -1
  120. package/lib/reanimated1/core/AnimatedConcat.js +1 -1
  121. package/lib/reanimated1/core/AnimatedCond.js +1 -1
  122. package/lib/reanimated1/core/AnimatedDebug.js +1 -1
  123. package/lib/reanimated1/core/AnimatedEvent.js +1 -1
  124. package/lib/reanimated1/core/AnimatedFunction.js +1 -1
  125. package/lib/reanimated1/core/AnimatedOperator.js +1 -1
  126. package/lib/reanimated1/core/AnimatedParam.js +1 -1
  127. package/lib/reanimated1/core/AnimatedProps.js +2 -2
  128. package/lib/reanimated1/core/AnimatedSet.js +1 -1
  129. package/lib/reanimated1/core/AnimatedStartClock.js +1 -1
  130. package/lib/reanimated1/core/AnimatedStopClock.js +1 -1
  131. package/lib/reanimated1/core/AnimatedStyle.js +1 -1
  132. package/lib/reanimated1/core/AnimatedTransform.js +1 -1
  133. package/lib/reanimated1/core/Core.test.js +30 -0
  134. package/lib/reanimated1/core/InternalAnimatedValue.js +1 -1
  135. package/lib/reanimated1/core/__mocks__/AnimatedProps.js +1 -1
  136. package/lib/reanimated1/derived/interpolate.js +1 -1
  137. package/lib/reanimated2/Colors.js +16 -12
  138. package/lib/reanimated2/NativeMethods.js +3 -14
  139. package/lib/reanimated2/{NativeReanimated.native.js → NativeReanimated/NativeReanimated.js} +19 -24
  140. package/lib/reanimated2/NativeReanimated/index.js +15 -0
  141. package/lib/reanimated2/PlatformChecker.js +16 -0
  142. package/lib/reanimated2/PropAdapters.js +14 -4
  143. package/lib/reanimated2/UpdateProps.js +14 -11
  144. package/lib/reanimated2/ViewDescriptorsSet.js +73 -0
  145. package/lib/reanimated2/WorkletEventHandler.js +15 -13
  146. package/lib/reanimated2/animation/commonTypes.js +1 -0
  147. package/lib/reanimated2/animation/decay.js +71 -0
  148. package/lib/reanimated2/animation/delay.js +64 -0
  149. package/lib/reanimated2/animation/index.js +8 -0
  150. package/lib/reanimated2/animation/repeat.js +69 -0
  151. package/lib/reanimated2/animation/sequence.js +72 -0
  152. package/lib/reanimated2/animation/spring.js +101 -0
  153. package/lib/reanimated2/animation/styleAnimation.js +166 -0
  154. package/lib/reanimated2/animation/timing.js +64 -0
  155. package/lib/reanimated2/animation/util.js +157 -0
  156. package/lib/reanimated2/commonTypes.js +1 -0
  157. package/lib/reanimated2/core.js +35 -39
  158. package/lib/reanimated2/globals.d.ts +47 -1
  159. package/lib/reanimated2/hook/Hooks.js +9 -0
  160. package/lib/reanimated2/hook/commonTypes.js +1 -0
  161. package/lib/reanimated2/hook/index.js +8 -0
  162. package/lib/reanimated2/hook/useAnimatedGestureHandler.js +50 -0
  163. package/lib/reanimated2/hook/useAnimatedReaction.js +37 -0
  164. package/lib/reanimated2/hook/useAnimatedRef.js +25 -0
  165. package/lib/reanimated2/hook/useAnimatedScrollHandler.js +41 -0
  166. package/lib/reanimated2/hook/useAnimatedStyle.js +376 -0
  167. package/lib/reanimated2/hook/useDerivedValue.js +36 -0
  168. package/lib/reanimated2/hook/useSharedValue.js +17 -0
  169. package/lib/reanimated2/hook/utils.js +175 -0
  170. package/lib/reanimated2/index.js +3 -2
  171. package/lib/reanimated2/interpolation.js +95 -86
  172. package/lib/reanimated2/jestUtils.js +0 -12
  173. package/lib/reanimated2/js-reanimated/JSReanimated.js +9 -10
  174. package/lib/reanimated2/js-reanimated/index.js +57 -1
  175. package/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.js +58 -0
  176. package/lib/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +69 -0
  177. package/lib/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +125 -0
  178. package/lib/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +193 -0
  179. package/lib/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +1 -0
  180. package/lib/reanimated2/layoutReanimation/animationBuilder/index.js +3 -0
  181. package/lib/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +325 -207
  182. package/lib/reanimated2/layoutReanimation/defaultAnimations/Default.js +36 -0
  183. package/lib/reanimated2/layoutReanimation/defaultAnimations/Fade.js +235 -187
  184. package/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.js +327 -269
  185. package/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +146 -0
  186. package/lib/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +85 -0
  187. package/lib/reanimated2/layoutReanimation/defaultAnimations/Roll.js +119 -0
  188. package/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +289 -0
  189. package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +159 -121
  190. package/lib/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +83 -65
  191. package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +371 -277
  192. package/lib/reanimated2/layoutReanimation/defaultAnimations/index.js +4 -0
  193. package/lib/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +78 -0
  194. package/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +128 -0
  195. package/lib/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +37 -0
  196. package/lib/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +41 -0
  197. package/lib/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +34 -0
  198. package/lib/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +46 -0
  199. package/lib/reanimated2/layoutReanimation/defaultTransitions/index.js +6 -0
  200. package/lib/reanimated2/layoutReanimation/index.js +3 -2
  201. package/lib/reanimated2/platform-specific/RNRenderer.web.js +2 -0
  202. package/lib/reanimated2/utils.js +9 -0
  203. package/libSo/fbjni/jni/arm64-v8a/libfbjni.so +0 -0
  204. package/libSo/fbjni/jni/armeabi-v7a/libfbjni.so +0 -0
  205. package/libSo/fbjni/jni/x86/libfbjni.so +0 -0
  206. package/libSo/fbjni/jni/x86_64/libfbjni.so +0 -0
  207. package/package.json +21 -10
  208. package/plugin.js +244 -85
  209. package/react-native-reanimated.d.ts +531 -453
  210. package/src/ConfigHelper.js +1 -0
  211. package/src/ReanimatedModule.native.js +10 -2
  212. package/src/createAnimatedComponent.js +64 -30
  213. package/src/reanimated1/core/AnimatedAlways.js +1 -1
  214. package/src/reanimated1/core/AnimatedBezier.js +1 -1
  215. package/src/reanimated1/core/AnimatedBlock.js +1 -1
  216. package/src/reanimated1/core/AnimatedCall.js +1 -1
  217. package/src/reanimated1/core/AnimatedCallFunc.js +1 -1
  218. package/src/reanimated1/core/AnimatedConcat.js +1 -1
  219. package/src/reanimated1/core/AnimatedCond.js +1 -1
  220. package/src/reanimated1/core/AnimatedDebug.js +1 -1
  221. package/src/reanimated1/core/AnimatedEvent.js +1 -1
  222. package/src/reanimated1/core/AnimatedFunction.js +1 -1
  223. package/src/reanimated1/core/AnimatedOperator.js +1 -1
  224. package/src/reanimated1/core/AnimatedParam.js +1 -1
  225. package/src/reanimated1/core/AnimatedProps.js +2 -2
  226. package/src/reanimated1/core/AnimatedSet.js +1 -1
  227. package/src/reanimated1/core/AnimatedStartClock.js +1 -1
  228. package/src/reanimated1/core/AnimatedStopClock.js +1 -1
  229. package/src/reanimated1/core/AnimatedStyle.js +1 -1
  230. package/src/reanimated1/core/AnimatedTransform.js +1 -1
  231. package/src/reanimated1/core/Core.test.js +30 -0
  232. package/src/reanimated1/core/InternalAnimatedValue.js +1 -1
  233. package/src/reanimated1/core/__mocks__/AnimatedProps.js +1 -1
  234. package/src/reanimated1/derived/interpolate.js +1 -1
  235. package/src/reanimated2/Colors.ts +30 -27
  236. package/src/reanimated2/Easing.ts +3 -1
  237. package/src/reanimated2/NativeMethods.ts +26 -16
  238. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +78 -0
  239. package/src/reanimated2/NativeReanimated/index.ts +18 -0
  240. package/src/reanimated2/PlatformChecker.ts +21 -0
  241. package/src/reanimated2/PropAdapters.ts +52 -34
  242. package/src/reanimated2/UpdateProps.ts +40 -20
  243. package/src/reanimated2/ViewDescriptorsSet.ts +108 -0
  244. package/src/reanimated2/WorkletEventHandler.ts +41 -23
  245. package/src/reanimated2/animation/commonTypes.ts +48 -0
  246. package/src/reanimated2/animation/decay.ts +141 -0
  247. package/src/reanimated2/animation/delay.ts +103 -0
  248. package/src/reanimated2/animation/index.ts +16 -0
  249. package/src/reanimated2/animation/repeat.ts +128 -0
  250. package/src/reanimated2/animation/sequence.ts +110 -0
  251. package/src/reanimated2/animation/spring.ts +165 -0
  252. package/src/reanimated2/animation/styleAnimation.ts +253 -0
  253. package/src/reanimated2/animation/timing.ts +109 -0
  254. package/src/reanimated2/animation/util.ts +242 -0
  255. package/src/reanimated2/commonTypes.ts +81 -0
  256. package/src/reanimated2/core.ts +128 -82
  257. package/src/reanimated2/globals.d.ts +47 -1
  258. package/src/reanimated2/hook/Hooks.ts +16 -0
  259. package/src/reanimated2/hook/commonTypes.ts +12 -0
  260. package/src/reanimated2/hook/index.ts +25 -0
  261. package/src/reanimated2/hook/useAnimatedGestureHandler.ts +110 -0
  262. package/src/reanimated2/hook/useAnimatedReaction.ts +49 -0
  263. package/src/reanimated2/hook/useAnimatedRef.ts +34 -0
  264. package/src/reanimated2/hook/useAnimatedScrollHandler.ts +83 -0
  265. package/src/reanimated2/hook/useAnimatedStyle.ts +538 -0
  266. package/src/reanimated2/hook/useDerivedValue.ts +48 -0
  267. package/src/reanimated2/hook/useSharedValue.ts +22 -0
  268. package/src/reanimated2/hook/utils.ts +259 -0
  269. package/src/reanimated2/index.ts +3 -2
  270. package/src/reanimated2/interpolation.ts +170 -101
  271. package/src/reanimated2/jestUtils.ts +0 -12
  272. package/src/reanimated2/js-reanimated/JSReanimated.ts +47 -22
  273. package/src/reanimated2/js-reanimated/Mapper.ts +1 -1
  274. package/src/reanimated2/js-reanimated/index.ts +71 -0
  275. package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.tsx +62 -0
  276. package/src/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.ts +91 -0
  277. package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +169 -0
  278. package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +263 -0
  279. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +78 -0
  280. package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +16 -0
  281. package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +243 -121
  282. package/src/reanimated2/layoutReanimation/defaultAnimations/Default.ts +43 -0
  283. package/src/reanimated2/layoutReanimation/defaultAnimations/Fade.ts +95 -53
  284. package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +114 -64
  285. package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +179 -0
  286. package/src/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.ts +93 -0
  287. package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +132 -0
  288. package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +333 -0
  289. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +84 -50
  290. package/src/reanimated2/layoutReanimation/defaultAnimations/Stretch.ts +41 -23
  291. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +234 -154
  292. package/src/reanimated2/layoutReanimation/defaultAnimations/index.ts +4 -0
  293. package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +104 -0
  294. package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +213 -0
  295. package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +60 -0
  296. package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +58 -0
  297. package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +41 -0
  298. package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +78 -0
  299. package/src/reanimated2/layoutReanimation/defaultTransitions/index.ts +6 -0
  300. package/src/reanimated2/layoutReanimation/index.ts +3 -2
  301. package/src/reanimated2/platform-specific/RNRenderer.web.ts +2 -0
  302. package/src/reanimated2/utils.ts +21 -0
  303. package/android/react-native-reanimated-62-hermes.aar +0 -0
  304. package/android/react-native-reanimated-62-jsc.aar +0 -0
  305. package/ios/LayoutReanimation/REAAnimationRootView.h +0 -12
  306. package/ios/LayoutReanimation/REAAnimationRootView.m +0 -16
  307. package/ios/LayoutReanimation/REAAnimationRootViewManager.h +0 -9
  308. package/ios/LayoutReanimation/REAAnimationRootViewManager.m +0 -49
  309. package/ios/LayoutReanimation/REAReactBatchObserver.h +0 -20
  310. package/ios/LayoutReanimation/REAReactBatchObserver.m +0 -125
  311. package/ios/LayoutReanimation/REASnapshooter.h +0 -19
  312. package/ios/LayoutReanimation/REASnapshooter.m +0 -64
  313. package/ios/LayoutReanimation/REAViewTraverser.h +0 -13
  314. package/ios/LayoutReanimation/REAViewTraverser.m +0 -40
  315. package/lib/reanimated2/Hooks.js +0 -732
  316. package/lib/reanimated2/NativeReanimated.js +0 -4
  317. package/lib/reanimated2/animations.js +0 -713
  318. package/lib/reanimated2/js-reanimated/index.web.js +0 -20
  319. package/lib/reanimated2/layoutReanimation/AnimatedRoot.js +0 -55
  320. package/lib/reanimated2/layoutReanimation/defaultAnimationsBuilder.js +0 -374
  321. package/src/reanimated2/Hooks.ts +0 -918
  322. package/src/reanimated2/NativeReanimated.native.ts +0 -61
  323. package/src/reanimated2/NativeReanimated.ts +0 -5
  324. package/src/reanimated2/animations.ts +0 -868
  325. package/src/reanimated2/js-reanimated/index.js +0 -0
  326. package/src/reanimated2/js-reanimated/index.web.ts +0 -29
  327. package/src/reanimated2/layoutReanimation/AnimatedRoot.tsx +0 -68
  328. package/src/reanimated2/layoutReanimation/defaultAnimationsBuilder.ts +0 -440
@@ -1,24 +1,29 @@
1
1
  /* global _WORKLET _measure _scrollTo */
2
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
- // @ts-nocheck
2
+ import { Component } from 'react';
4
3
  import { findNodeHandle } from 'react-native';
4
+ import { RefObjectFunction } from './hook/useAnimatedRef';
5
+ import { isChromeDebugger } from './PlatformChecker';
5
6
 
6
- export function getTag(view) {
7
+ export function getTag(
8
+ view: null | number | React.Component<any, any> | React.ComponentClass<any>
9
+ ): null | number {
7
10
  return findNodeHandle(view);
8
11
  }
9
12
 
10
- /**
11
- * fields that can be accessed:
12
- * x
13
- * y
14
- * width
15
- * height
16
- * pageX
17
- * pageY
18
- */
19
- export function measure(animatedRef) {
13
+ export interface MeasuredDimensions {
14
+ x: number;
15
+ y: number;
16
+ width: number;
17
+ height: number;
18
+ pageX: number;
19
+ pageY: number;
20
+ }
21
+
22
+ export function measure(
23
+ animatedRef: RefObjectFunction<Component>
24
+ ): MeasuredDimensions {
20
25
  'worklet';
21
- if (!_WORKLET) {
26
+ if (!_WORKLET && !isChromeDebugger()) {
22
27
  throw new Error('(measure) method cannot be used on RN side!');
23
28
  }
24
29
  const viewTag = animatedRef();
@@ -29,9 +34,14 @@ export function measure(animatedRef) {
29
34
  return result;
30
35
  }
31
36
 
32
- export function scrollTo(animatedRef, x, y, animated) {
37
+ export function scrollTo(
38
+ animatedRef: RefObjectFunction<Component>,
39
+ x: number,
40
+ y: number,
41
+ animated: boolean
42
+ ): void {
33
43
  'worklet';
34
- if (!_WORKLET) {
44
+ if (!_WORKLET && !isChromeDebugger()) {
35
45
  return;
36
46
  }
37
47
  const viewTag = animatedRef();
@@ -0,0 +1,78 @@
1
+ import { AnimationObject } from '../animation';
2
+ import { PrimitiveValue } from '../animation/commonTypes';
3
+ import { SharedValue } from '../commonTypes';
4
+ import { Descriptor } from '../hook/commonTypes';
5
+
6
+ const InnerNativeModule = global.__reanimatedModuleProxy;
7
+ export class NativeReanimated {
8
+ native: boolean;
9
+ useOnlyV1: boolean;
10
+
11
+ constructor(native = true) {
12
+ this.native = native;
13
+ this.useOnlyV1 = InnerNativeModule === null;
14
+ }
15
+
16
+ installCoreFunctions(
17
+ valueSetter: (
18
+ value:
19
+ | (() => AnimationObject)
20
+ | AnimationObject
21
+ | PrimitiveValue
22
+ | Descriptor
23
+ ) => void
24
+ ): void {
25
+ return InnerNativeModule.installCoreFunctions(valueSetter);
26
+ }
27
+
28
+ makeShareable<T>(value: T): T {
29
+ return InnerNativeModule.makeShareable(value);
30
+ }
31
+
32
+ makeMutable<T>(value: T): SharedValue<T> {
33
+ return InnerNativeModule.makeMutable(value);
34
+ }
35
+
36
+ makeRemote<T>(object = {}): T {
37
+ return InnerNativeModule.makeRemote(object);
38
+ }
39
+
40
+ startMapper(
41
+ mapper: () => void,
42
+ inputs: any[] = [],
43
+ outputs: any[] = [],
44
+ updater: () => void,
45
+ viewDescriptors: Descriptor[] | SharedValue<Descriptor[]>
46
+ ): number {
47
+ return InnerNativeModule.startMapper(
48
+ mapper,
49
+ inputs,
50
+ outputs,
51
+ updater,
52
+ viewDescriptors
53
+ );
54
+ }
55
+
56
+ stopMapper(mapperId: number): void {
57
+ return InnerNativeModule.stopMapper(mapperId);
58
+ }
59
+
60
+ registerEventHandler<T>(
61
+ eventHash: string,
62
+ eventHandler: (event: T) => void
63
+ ): string {
64
+ return InnerNativeModule.registerEventHandler(eventHash, eventHandler);
65
+ }
66
+
67
+ unregisterEventHandler(id: string): void {
68
+ return InnerNativeModule.unregisterEventHandler(id);
69
+ }
70
+
71
+ getViewProp<T>(
72
+ viewTag: string,
73
+ propName: string,
74
+ callback?: (result: T) => void
75
+ ): Promise<T> {
76
+ return InnerNativeModule.getViewProp(viewTag, propName, callback);
77
+ }
78
+ }
@@ -0,0 +1,18 @@
1
+ import reanimatedJS from '../js-reanimated';
2
+ import { nativeShouldBeMock } from '../PlatformChecker';
3
+ import { Platform } from 'react-native';
4
+ import { NativeReanimated } from './NativeReanimated';
5
+
6
+ let exportedModule;
7
+ if (nativeShouldBeMock()) {
8
+ exportedModule = reanimatedJS;
9
+ } else {
10
+ exportedModule = new NativeReanimated();
11
+ if (exportedModule.useOnlyV1 && Platform.OS === 'android') {
12
+ console.warn(
13
+ `If you want to use Reanimated 2 then go through our installation steps https://docs.swmansion.com/react-native-reanimated/docs/installation`
14
+ );
15
+ }
16
+ }
17
+
18
+ export default exportedModule as NativeReanimated;
@@ -0,0 +1,21 @@
1
+ import { Platform } from 'react-native';
2
+
3
+ export function isJest(): boolean {
4
+ return !!process.env.JEST_WORKER_ID;
5
+ }
6
+
7
+ export function isChromeDebugger(): boolean {
8
+ return !(global as any).nativeCallSyncHook || (global as any).__REMOTEDEV__;
9
+ }
10
+
11
+ export function isWeb(): boolean {
12
+ return Platform.OS === 'web';
13
+ }
14
+
15
+ export function shouldBeUseWeb() {
16
+ return isJest() || isChromeDebugger() || isWeb();
17
+ }
18
+
19
+ export function nativeShouldBeMock() {
20
+ return isJest() || isChromeDebugger();
21
+ }
@@ -1,41 +1,59 @@
1
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
- // @ts-nocheck
3
- import { createAnimatedPropAdapter } from './core';
1
+ // @ts-ignore JS file
2
+ import { addWhitelistedNativeProps } from '../ConfigHelper';
3
+ import { AdapterWorkletFunction } from './commonTypes';
4
4
 
5
- export const SVGAdapter = createAnimatedPropAdapter((props) => {
6
- 'worklet';
7
- const keys = Object.keys(props);
8
- // transform
9
- if (keys.includes('transform')) {
10
- if (Array.isArray(props.transform)) {
11
- // case of array with 6 values => https://github.com/react-native-svg/react-native-svg/blob/b2e2c355204ff4b10973d3afce1495f7e4167ff7/src/elements/Shape.tsx#L200
12
- if (props.transform.length !== 6) {
13
- throw new Error(
14
- `invalid transform length of ${props.transform.length}, should be 6`
15
- );
5
+ export function createAnimatedPropAdapter(
6
+ adapter: AdapterWorkletFunction,
7
+ nativeProps?: string[]
8
+ ): AdapterWorkletFunction {
9
+ const nativePropsToAdd: { [key: string]: boolean } = {};
10
+ // eslint-disable-next-line no-unused-expressions
11
+ nativeProps?.forEach((prop) => {
12
+ nativePropsToAdd[prop] = true;
13
+ });
14
+ addWhitelistedNativeProps(nativePropsToAdd);
15
+ return adapter;
16
+ }
17
+
18
+ // ADAPTERS
19
+
20
+ export const SVGAdapter: AdapterWorkletFunction = createAnimatedPropAdapter(
21
+ (props) => {
22
+ 'worklet';
23
+ const keys = Object.keys(props);
24
+ // transform
25
+ if (keys.includes('transform')) {
26
+ if (Array.isArray(props.transform)) {
27
+ // case of array with 6 values => https://github.com/react-native-svg/react-native-svg/blob/b2e2c355204ff4b10973d3afce1495f7e4167ff7/src/elements/Shape.tsx#L200
28
+ if (props.transform.length !== 6) {
29
+ throw new Error(
30
+ `invalid transform length of ${props.transform.length}, should be 6`
31
+ );
32
+ }
33
+ const transform: number[] = props.transform as number[];
34
+ const x: number = (props.x as number) ?? 0;
35
+ const y: number = (props.y as number) ?? 0;
36
+ props.transform = [
37
+ { translateX: transform[0] * x + transform[2] * y + transform[4] },
38
+ { translateY: transform[1] * x + transform[3] * y + transform[5] },
39
+ ];
40
+ } else if (typeof props.transform === 'string') {
41
+ // case of string 'translate(translateX translateY)'
42
+ // todo: handle other cases of transform string like here https://github.com/react-native-svg/react-native-svg/blob/b2e2c355204ff4b10973d3afce1495f7e4167ff7/src/lib/extract/extractTransform.ts#L184
43
+ const transform: string = props.transform as string;
44
+ const arr = transform
45
+ .replace('translate(', '')
46
+ .replace(')', '')
47
+ .split(' ');
48
+ props.transform = [
49
+ { translateX: parseFloat(arr[0]) },
50
+ { translateY: parseFloat(arr[1]) },
51
+ ];
16
52
  }
17
- const transform = props.transform;
18
- const x = props.x ?? 0;
19
- const y = props.y ?? 0;
20
- props.transform = [
21
- { translateX: transform[0] * x + transform[2] * y + transform[4] },
22
- { translateY: transform[1] * x + transform[3] * y + transform[5] },
23
- ];
24
- } else if (typeof props.transform === 'string') {
25
- // case of string 'translate(translateX translateY)'
26
- // todo: handle other cases of transform string like here https://github.com/react-native-svg/react-native-svg/blob/b2e2c355204ff4b10973d3afce1495f7e4167ff7/src/lib/extract/extractTransform.ts#L184
27
- const arr = props.transform
28
- .replace('translate(', '')
29
- .replace(')', '')
30
- .split(' ');
31
- props.transform = [
32
- { translateX: parseFloat(arr[0]) },
33
- { translateY: parseFloat(arr[1]) },
34
- ];
35
53
  }
54
+ // todo: other props
36
55
  }
37
- // todo: other props
38
- });
56
+ );
39
57
 
40
58
  export const TextInputAdapter = createAnimatedPropAdapter(
41
59
  (props) => {
@@ -1,10 +1,12 @@
1
1
  /* global _updateProps */
2
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
- // @ts-nocheck
2
+ import { MutableRefObject } from 'react';
4
3
  import { processColor } from './Colors';
4
+ import { AnimatedStyle, SharedValue, StyleProps } from './commonTypes';
5
5
  import { makeShareable, isConfigured } from './core';
6
- import { Platform } from 'react-native';
6
+ import { Descriptor } from './hook/commonTypes';
7
7
  import { _updatePropsJS } from './js-reanimated';
8
+ import { shouldBeUseWeb } from './PlatformChecker';
9
+ import { ViewRefSet } from './ViewDescriptorsSet';
8
10
 
9
11
  // copied from react-native/Libraries/Components/View/ReactNativeStyleAttributes
10
12
  export const colorProps = [
@@ -27,13 +29,25 @@ export const colorProps = [
27
29
  const ColorProperties = !isConfigured() ? [] : makeShareable(colorProps);
28
30
 
29
31
  let updatePropsByPlatform;
30
- if (Platform.OS === 'web' || process.env.JEST_WORKER_ID) {
31
- updatePropsByPlatform = (viewDescriptor, updates, maybeViewRef) => {
32
+ if (shouldBeUseWeb()) {
33
+ updatePropsByPlatform = (
34
+ _: SharedValue<Descriptor[]>,
35
+ updates: StyleProps | AnimatedStyle,
36
+ maybeViewRef: ViewRefSet<any> | undefined
37
+ ): void => {
32
38
  'worklet';
33
- _updatePropsJS(viewDescriptor.value.tag, null, updates, maybeViewRef);
39
+ if (maybeViewRef) {
40
+ maybeViewRef.items.forEach((item, _) => {
41
+ _updatePropsJS(updates, item);
42
+ });
43
+ }
34
44
  };
35
45
  } else {
36
- updatePropsByPlatform = (viewDescriptor, updates, _) => {
46
+ updatePropsByPlatform = (
47
+ viewDescriptors: SharedValue<Descriptor[]>,
48
+ updates: StyleProps | AnimatedStyle,
49
+ _: ViewRefSet<any> | undefined
50
+ ): void => {
37
51
  'worklet';
38
52
 
39
53
  for (const key in updates) {
@@ -42,23 +56,29 @@ if (Platform.OS === 'web' || process.env.JEST_WORKER_ID) {
42
56
  }
43
57
  }
44
58
 
45
- _updateProps(
46
- viewDescriptor.value.tag,
47
- viewDescriptor.value.name || 'RCTView',
48
- updates
49
- );
59
+ viewDescriptors.value.forEach((viewDescriptor) => {
60
+ _updateProps(
61
+ viewDescriptor.tag,
62
+ viewDescriptor.name || 'RCTView',
63
+ updates
64
+ );
65
+ });
50
66
  };
51
67
  }
52
68
 
53
- export const updateProps = updatePropsByPlatform;
69
+ export const updateProps: (
70
+ viewDescriptor: SharedValue<Descriptor[]>,
71
+ updates: StyleProps | AnimatedStyle,
72
+ maybeViewRef: ViewRefSet<any> | undefined
73
+ ) => void = updatePropsByPlatform;
54
74
 
55
75
  export const updatePropsJestWrapper = (
56
- viewDescriptor,
57
- updates,
58
- maybeViewRef,
59
- animatedStyle,
60
- adapters
61
- ) => {
76
+ viewDescriptors: SharedValue<Descriptor[]>,
77
+ updates: AnimatedStyle,
78
+ maybeViewRef: ViewRefSet<any> | undefined,
79
+ animatedStyle: MutableRefObject<AnimatedStyle>,
80
+ adapters: ((updates: AnimatedStyle) => void)[]
81
+ ): void => {
62
82
  adapters.forEach((adapter) => {
63
83
  adapter(updates);
64
84
  });
@@ -67,7 +87,7 @@ export const updatePropsJestWrapper = (
67
87
  ...updates,
68
88
  };
69
89
 
70
- updateProps(viewDescriptor, updates, maybeViewRef);
90
+ updateProps(viewDescriptors, updates, maybeViewRef);
71
91
  };
72
92
 
73
93
  export default updateProps;
@@ -0,0 +1,108 @@
1
+ import { useRef } from 'react';
2
+ import { makeMutable } from './core';
3
+ import { SharedValue } from './commonTypes';
4
+ import { Descriptor } from './hook/commonTypes';
5
+
6
+ export interface ViewRefSet<T> {
7
+ items: Set<T>;
8
+ add: (item: T) => void;
9
+ remove: (item: T) => void;
10
+ }
11
+
12
+ export interface ViewDescriptorsSet {
13
+ batchToRemove: Set<number>;
14
+ tags: Set<number>;
15
+ waitForInsertSync: boolean;
16
+ waitForRemoveSync: boolean;
17
+ sharableViewDescriptors: SharedValue<Descriptor[]>;
18
+ items: Descriptor[];
19
+ add: (item: Descriptor) => void;
20
+ remove: (viewTag: number) => void;
21
+ rebuildsharableViewDescriptors: (
22
+ sharableViewDescriptor: SharedValue<Descriptor[]>
23
+ ) => void;
24
+ }
25
+
26
+ export function makeViewDescriptorsSet(): ViewDescriptorsSet {
27
+ const ref = useRef<ViewDescriptorsSet | null>(null);
28
+ if (ref.current === null) {
29
+ const data: ViewDescriptorsSet = {
30
+ batchToRemove: new Set(),
31
+ tags: new Set(),
32
+ waitForInsertSync: false,
33
+ waitForRemoveSync: false,
34
+ sharableViewDescriptors: makeMutable([]),
35
+ items: [],
36
+
37
+ add: (item: Descriptor) => {
38
+ if (data.tags.has(item.tag)) {
39
+ return;
40
+ }
41
+ data.tags.add(item.tag);
42
+ data.items.push(item);
43
+
44
+ if (!data.waitForInsertSync) {
45
+ data.waitForInsertSync = true;
46
+
47
+ setImmediate(() => {
48
+ data.sharableViewDescriptors.value = data.items;
49
+ data.waitForInsertSync = false;
50
+ });
51
+ }
52
+ },
53
+
54
+ remove: (viewTag: number) => {
55
+ data.batchToRemove.add(viewTag);
56
+
57
+ if (!data.waitForRemoveSync) {
58
+ data.waitForRemoveSync = true;
59
+
60
+ setImmediate(() => {
61
+ const items = [];
62
+ for (const item of data.items) {
63
+ if (data.batchToRemove.has(item.tag)) {
64
+ data.tags.delete(item.tag);
65
+ } else {
66
+ items.push(item);
67
+ }
68
+ }
69
+ data.items = items;
70
+ data.sharableViewDescriptors.value = items;
71
+ data.batchToRemove = new Set();
72
+ data.waitForRemoveSync = false;
73
+ });
74
+ }
75
+ },
76
+
77
+ rebuildsharableViewDescriptors: (
78
+ sharableViewDescriptors: SharedValue<Descriptor[]>
79
+ ) => {
80
+ data.sharableViewDescriptors = sharableViewDescriptors;
81
+ },
82
+ };
83
+ ref.current = data;
84
+ }
85
+
86
+ return ref.current;
87
+ }
88
+
89
+ export function makeViewsRefSet<T>(): ViewRefSet<T> {
90
+ const ref = useRef<ViewRefSet<T> | null>(null);
91
+ if (ref.current === null) {
92
+ const data: ViewRefSet<T> = {
93
+ items: new Set(),
94
+
95
+ add: (item: T) => {
96
+ if (data.items.has(item)) return;
97
+ data.items.add(item);
98
+ },
99
+
100
+ remove: (item: T) => {
101
+ data.items.delete(item);
102
+ },
103
+ };
104
+ ref.current = data;
105
+ }
106
+
107
+ return ref.current;
108
+ }
@@ -1,38 +1,57 @@
1
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
- // @ts-nocheck
3
- import NativeModule from './NativeReanimated';
1
+ import { NativeEvent } from './commonTypes';
2
+ import NativeReanimatedModule from './NativeReanimated';
4
3
 
5
- const jsListener = (eventName, handler) => (evt) => {
6
- handler({ ...evt.nativeEvent, eventName });
7
- };
4
+ function jsListener<T extends NativeEvent<T>>(
5
+ eventName: string,
6
+ handler: (event: T) => void
7
+ ) {
8
+ return (evt: T) => {
9
+ handler({ ...evt.nativeEvent, eventName });
10
+ };
11
+ }
8
12
 
9
- export default class WorkletEventHandler {
10
- constructor(worklet, eventNames = []) {
13
+ export default class WorkletEventHandler<T extends NativeEvent<T>> {
14
+ worklet: (event: T) => void;
15
+ eventNames: string[];
16
+ reattachNeeded: boolean;
17
+ listeners: Record<string, (event: T) => void>;
18
+ viewTag: number | undefined;
19
+ registrations: string[];
20
+ constructor(worklet: (event: T) => void, eventNames: string[] = []) {
11
21
  this.worklet = worklet;
12
22
  this.eventNames = eventNames;
13
23
  this.reattachNeeded = false;
24
+ this.listeners = {};
25
+ this.viewTag = undefined;
26
+ this.registrations = [];
14
27
 
15
- if (!NativeModule.native) {
16
- this.listeners = eventNames.reduce((acc, eventName) => {
17
- acc[eventName] = jsListener(eventName, worklet);
18
- return acc;
19
- }, {});
28
+ if (!NativeReanimatedModule.native) {
29
+ this.listeners = eventNames.reduce(
30
+ (acc: Record<string, (event: T) => void>, eventName: string) => {
31
+ acc[eventName] = jsListener(eventName, worklet);
32
+ return acc;
33
+ },
34
+ {}
35
+ );
20
36
  }
21
37
  }
22
38
 
23
- updateWorklet(newWorklet) {
39
+ updateWorklet(newWorklet: (event: T) => void): void {
24
40
  this.worklet = newWorklet;
25
41
  this.reattachNeeded = true;
26
42
  }
27
43
 
28
- registerForEvents(viewTag, fallbackEventName = undefined) {
44
+ registerForEvents(viewTag: number, fallbackEventName?: string): void {
29
45
  this.viewTag = viewTag;
30
46
  this.registrations = this.eventNames.map((eventName) =>
31
- NativeModule.registerEventHandler(viewTag + eventName, this.worklet)
47
+ NativeReanimatedModule.registerEventHandler(
48
+ viewTag + eventName,
49
+ this.worklet
50
+ )
32
51
  );
33
52
  if (this.registrations.length === 0 && fallbackEventName) {
34
53
  this.registrations.push(
35
- NativeModule.registerEventHandler(
54
+ NativeReanimatedModule.registerEventHandler(
36
55
  viewTag + fallbackEventName,
37
56
  this.worklet
38
57
  )
@@ -40,11 +59,10 @@ export default class WorkletEventHandler {
40
59
  }
41
60
  }
42
61
 
43
- unregisterFromEvents() {
44
- this.registrations &&
45
- this.registrations.forEach((id) =>
46
- NativeModule.unregisterEventHandler(id)
47
- );
48
- this.registrations = undefined;
62
+ unregisterFromEvents(): void {
63
+ this.registrations.forEach((id) =>
64
+ NativeReanimatedModule.unregisterEventHandler(id)
65
+ );
66
+ this.registrations = [];
49
67
  }
50
68
  }
@@ -0,0 +1,48 @@
1
+ export type PrimitiveValue = number | string;
2
+
3
+ export interface AnimationObject {
4
+ [key: string]: any;
5
+ callback: AnimationCallback;
6
+ current?: PrimitiveValue;
7
+ toValue?: AnimationObject['current'];
8
+ startValue?: AnimationObject['current'];
9
+ finished?: boolean;
10
+ strippedCurrent?: number;
11
+ cancelled?: boolean;
12
+
13
+ __prefix?: string;
14
+ __suffix?: string;
15
+ onFrame: (animation: any, timestamp: Timestamp) => boolean;
16
+ onStart: (
17
+ nextAnimation: any,
18
+ current: any,
19
+ timestamp: Timestamp,
20
+ previousAnimation: any
21
+ ) => void;
22
+ }
23
+
24
+ export interface Animation<T extends AnimationObject> extends AnimationObject {
25
+ onFrame: (animation: T, timestamp: Timestamp) => boolean;
26
+ onStart: (
27
+ nextAnimation: T,
28
+ current: T extends NumericAnimation ? number : PrimitiveValue,
29
+ timestamp: Timestamp,
30
+ previousAnimation: T
31
+ ) => void;
32
+ }
33
+
34
+ export interface NumericAnimation {
35
+ current?: number;
36
+ }
37
+ export interface HigherOrderAnimation {
38
+ isHigherOrder?: boolean;
39
+ }
40
+
41
+ export type AnimationCallback = (
42
+ finished?: boolean,
43
+ current?: PrimitiveValue
44
+ ) => void;
45
+
46
+ export type NextAnimation<T extends AnimationObject> = T | (() => T);
47
+
48
+ export type Timestamp = number;