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,40 @@
1
+ /**
2
+ * imported from react-native
3
+ */
4
+ import { MutableRefObject } from 'react';
5
+ /**
6
+ * This is a helper function for when a component needs to be able to forward a ref
7
+ * to a child component, but still needs to have access to that component as part of
8
+ * its implementation.
9
+ *
10
+ * Its main use case is in wrappers for native components.
11
+ *
12
+ * Usage:
13
+ *
14
+ * class MyView extends React.Component {
15
+ * _nativeRef = null;
16
+ *
17
+ * _setNativeRef = setAndForwardRef({
18
+ * getForwardedRef: () => this.props.forwardedRef,
19
+ * setLocalRef: ref => {
20
+ * this._nativeRef = ref;
21
+ * },
22
+ * });
23
+ *
24
+ * render() {
25
+ * return <View ref={this._setNativeRef} />;
26
+ * }
27
+ * }
28
+ *
29
+ * const MyViewWithRef = React.forwardRef((props, ref) => (
30
+ * <MyView {...props} forwardedRef={ref} />
31
+ * ));
32
+ *
33
+ * module.exports = MyViewWithRef;
34
+ */
35
+ export declare type ForwardedRef<T> = () => MutableRefObject<T> | ((ref: T) => void);
36
+ declare function setAndForwardRef<T>({ getForwardedRef, setLocalRef, }: {
37
+ getForwardedRef: ForwardedRef<T>;
38
+ setLocalRef: (ref: T) => void;
39
+ }): (ref: T) => void;
40
+ export default setAndForwardRef;
@@ -0,0 +1 @@
1
+ export {};
package/mock.js CHANGED
@@ -28,7 +28,7 @@ function simulateCallbackFactory(...params) {
28
28
  callback &&
29
29
  setTimeout(() => {
30
30
  // user defined callback
31
- // eslint-disable-next-line standard/no-callback-literal
31
+ // eslint-disable-next-line node/no-callback-literal
32
32
  callback(...params);
33
33
  }, 0);
34
34
  };
@@ -73,9 +73,9 @@ function createMockComponent(name) {
73
73
 
74
74
  function createTransitioningComponent(Component) {
75
75
  return class extends React.Component {
76
- static displayName = `Transitioning.${Component.displayName ||
77
- Component.name ||
78
- 'Component'}`;
76
+ static displayName = `Transitioning.${
77
+ Component.displayName || Component.name || 'Component'
78
+ }`;
79
79
 
80
80
  setNativeProps() {
81
81
  // noop
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-reanimated",
3
- "version": "2.4.1",
3
+ "version": "2.7.0",
4
4
  "description": "More powerful alternative to Animated library for React Native.",
5
5
  "scripts": {
6
6
  "start": "node node_modules/react-native/local-cli/cli.js start",
@@ -18,14 +18,21 @@
18
18
  "format:common": "find Common/ -iname *.h -o -iname *.cpp | xargs clang-format -i",
19
19
  "release": "npm login && release-it",
20
20
  "type:check": "yarn tsc --noEmit",
21
- "type:generate": "yarn type:generate:clean && yarn type:generate:cp-js-src && yarn type:generate:tsc && yarn type:generate:remove.ts && yarn type:generate:remove.tsx",
21
+ "type:generate": "yarn type:generate:clean && yarn type:generate:cp-js-src && yarn type:generate:tsc && yarn type:generate:tsc:declaration && yarn type:generate:remove.ts && yarn type:generate:remove.tsx && yarn type:generate:remove.js:from-src",
22
22
  "type:generate:clean": "rm -rf lib/ && mkdir lib/",
23
23
  "type:generate:cp-js-src": "cp -RL src/* lib/",
24
24
  "type:generate:tsc": "yarn tsc",
25
+ "type:generate:tsc:declaration": "yarn tsc --project tsconfig.json --pretty --declaration --emitDeclarationOnly --outDir lib/types",
25
26
  "type:generate:remove.ts": "find ./lib -type f -name \"*.ts\" -and -not -name \"*.d.ts\" -delete",
26
27
  "type:generate:remove.tsx": "find ./lib -type f -name \"*.tsx\" -and -not -name \"*.d.ts\" -delete",
28
+ "type:generate:remove.js:from-src": "find ./src/reanimated2 -type f -name \"*.js\" -delete",
27
29
  "prepare": "husky install",
28
- "circular_dependency_check": "yarn madge --extensions js,ts,tsx --circular ./src"
30
+ "circular_dependency_check": "yarn madge --extensions js,ts,tsx --circular ./src",
31
+ "setup": "yarn && cd Example && yarn && cd ios && pod install --verbose && cd ../..",
32
+ "clean": "rm -rf node_modules && cd Example && rm -rf node_modules && cd ios && pod deintegrate && cd ../..",
33
+ "reset": "yarn clean && yarn setup",
34
+ "clean:deep": "cd android && rm -rf .cxx .gradle build && cd ../Example/android && rm -rf .gradle build app/build && cd ../.. && yarn clean",
35
+ "reset:deep": "yarn clean:deep && yarn setup"
29
36
  },
30
37
  "main": "lib/Animated.js",
31
38
  "module": "lib/Animated",
@@ -36,7 +43,6 @@
36
43
  "Common/",
37
44
  "src/",
38
45
  "lib/",
39
- "libSo/",
40
46
  "android/src/main/AndroidManifest.xml",
41
47
  "android/src/main/java/",
42
48
  "android/build.gradle",
@@ -49,7 +55,6 @@
49
55
  "react-native-reanimated.d.ts",
50
56
  "mock.js",
51
57
  "plugin.js",
52
- "expo-module.config.json",
53
58
  "!__snapshots__",
54
59
  "!*.test.js",
55
60
  "!*.test.js.map"
@@ -69,56 +74,55 @@
69
74
  },
70
75
  "homepage": "https://github.com/software-mansion/react-native-reanimated#readme",
71
76
  "dependencies": {
72
- "@babel/plugin-transform-object-assign": "^7.10.4",
77
+ "@babel/plugin-transform-object-assign": "^7.16.7",
78
+ "@babel/preset-typescript": "^7.16.7",
73
79
  "@types/invariant": "^2.2.35",
74
80
  "invariant": "^2.2.4",
75
81
  "lodash.isequal": "^4.5.0",
76
- "mockdate": "^3.0.2",
77
- "react-native-screens": "^3.4.0",
82
+ "setimmediate": "^1.0.5",
78
83
  "string-hash-64": "^1.0.3"
79
84
  },
80
85
  "peerDependencies": {
86
+ "@babel/core": "^7.0.0-0",
81
87
  "react": "*",
82
- "react-native": "*",
83
- "react-native-gesture-handler": "*"
88
+ "react-native": "*"
84
89
  },
85
90
  "devDependencies": {
86
- "@babel/core": "^7.7.5",
87
- "@babel/plugin-proposal-class-properties": "^7.7.4",
88
- "@babel/preset-env": "^7.7.6",
89
- "@babel/preset-typescript": "^7.7.4",
90
- "@react-native-community/bob": "^0.14.3",
91
+ "@babel/core": "^7.17.2",
92
+ "@babel/plugin-proposal-class-properties": "^7.16.7",
93
+ "@babel/preset-env": "^7.16.11",
94
+ "@react-native-community/bob": "^0.17.1",
91
95
  "@react-native-community/eslint-config": "^0.0.5",
92
- "@testing-library/jest-native": "^3.4.3",
96
+ "@testing-library/jest-native": "^4.0.4",
93
97
  "@testing-library/react-hooks": "^5.0.3",
94
98
  "@testing-library/react-native": "^7.1.0",
95
- "@types/babel-types": "^7.0.9",
96
- "@types/babel__core": "^7.1.12",
97
- "@types/babel__generator": "^7.6.2",
98
- "@types/babel__traverse": "^7.0.15",
99
- "@types/jest": "^26.0.15",
100
- "@types/react-native": "^0.65.1",
101
- "@typescript-eslint/eslint-plugin": "^4.15.1",
102
- "@typescript-eslint/parser": "^4.15.1",
103
- "babel-eslint": "^10.0.3",
104
- "babel-jest": "^26.6.3",
99
+ "@types/babel-types": "^7.0.11",
100
+ "@types/babel__core": "^7.1.18",
101
+ "@types/babel__generator": "^7.6.4",
102
+ "@types/babel__traverse": "^7.14.2",
103
+ "@types/jest": "^27.4.0",
104
+ "@types/react-native": "^0.66.15",
105
+ "@typescript-eslint/eslint-plugin": "^5.11.0",
106
+ "@typescript-eslint/parser": "^5.11.0",
107
+ "babel-eslint": "^10.1.0",
108
+ "babel-jest": "^27.5.1",
105
109
  "babel-plugin-module-resolver": "^4.1.0",
106
- "clang-format": "^1.5.0",
107
- "eslint": "^7.31.0",
108
- "eslint-config-prettier": "^6.4.0",
109
- "eslint-config-standard": "^14.1.0",
110
- "eslint-import-resolver-babel-module": "^5.2.0",
111
- "eslint-plugin-import": "^2.18.2",
112
- "eslint-plugin-node": "^10.0.0",
113
- "eslint-plugin-promise": "^4.2.1",
114
- "eslint-plugin-standard": "^4.0.1",
115
- "husky": "^7.0.0",
116
- "jest": "^26.6.3",
110
+ "clang-format": "^1.6.0",
111
+ "eslint": "^8.8.0",
112
+ "eslint-config-prettier": "^8.3.0",
113
+ "eslint-config-standard": "^16.0.3",
114
+ "eslint-import-resolver-babel-module": "^5.3.1",
115
+ "eslint-plugin-import": "^2.25.4",
116
+ "eslint-plugin-node": "^11.1.0",
117
+ "eslint-plugin-promise": "^6.0.0",
118
+ "eslint-plugin-standard": "^5.0.0",
119
+ "husky": "^7.0.4",
120
+ "jest": "^27.5.1",
117
121
  "lint-staged": "^11.2.0",
118
122
  "madge": "^5.0.1",
119
- "prettier": "^2.2.1",
123
+ "prettier": "^2.5.1",
120
124
  "react": "17.0.2",
121
- "react-native": "0.67.2",
125
+ "react-native": "0.68.0",
122
126
  "react-native-codegen": "^0.0.7",
123
127
  "react-native-gesture-handler": "^1.6.1",
124
128
  "react-test-renderer": "17.0.2",
package/plugin.js CHANGED
@@ -30,7 +30,9 @@ const objectHooks = new Set([
30
30
  const globals = new Set([
31
31
  'this',
32
32
  'console',
33
+ 'performance',
33
34
  '_setGlobalConsole',
35
+ '_chronoNow',
34
36
  'Date',
35
37
  'Array',
36
38
  'ArrayBuffer',
@@ -85,6 +87,7 @@ const blacklistedFunctions = new Set([
85
87
  'toString',
86
88
  'map',
87
89
  'filter',
90
+ 'findIndex',
88
91
  'forEach',
89
92
  'valueOf',
90
93
  'toPrecision',
@@ -508,18 +511,6 @@ function makeWorklet(t, fun, fileName) {
508
511
  );
509
512
  }
510
513
 
511
- statements.push(
512
- t.expressionStatement(
513
- t.callExpression(
514
- t.memberExpression(
515
- t.identifier('global'),
516
- t.identifier('__reanimatedWorkletInit'),
517
- false
518
- ),
519
- [privateFunctionId]
520
- )
521
- )
522
- );
523
514
  statements.push(t.returnStatement(privateFunctionId));
524
515
 
525
516
  const newFun = t.functionExpression(fun.id, [], t.blockStatement(statements));
@@ -7,8 +7,6 @@ declare module 'react-native-reanimated' {
7
7
  ReactNode,
8
8
  Component,
9
9
  RefObject,
10
- ComponentType,
11
- ComponentProps,
12
10
  FunctionComponent,
13
11
  } from 'react';
14
12
  import {
@@ -31,7 +29,6 @@ declare module 'react-native-reanimated' {
31
29
  NativeScrollEvent,
32
30
  NativeSyntheticEvent,
33
31
  ColorValue,
34
- OpaqueColorValue,
35
32
  EasingFunction,
36
33
  } from 'react-native';
37
34
  import {
@@ -39,16 +36,24 @@ declare module 'react-native-reanimated' {
39
36
  PanGestureHandlerGestureEvent,
40
37
  } from 'react-native-gesture-handler';
41
38
 
42
- export {
43
- Animation,
44
- TimingAnimation,
45
- SpringAnimation,
46
- DecayAnimation,
47
- DelayAnimation,
48
- RepeatAnimation,
49
- SequenceAnimation,
50
- StyleLayoutAnimation,
51
- } from './src/reanimated2/animation/index';
39
+ import('./lib/reanimated2/globals');
40
+
41
+ export type TimingAnimation =
42
+ import('./lib/types/lib/reanimated2/animation/index').TimingAnimation;
43
+ export type SpringAnimation =
44
+ import('./lib/types/lib/reanimated2/animation/index').SpringAnimation;
45
+ export type DecayAnimation =
46
+ import('./lib/types/lib/reanimated2/animation/index').DecayAnimation;
47
+ export type DelayAnimation =
48
+ import('./lib/types/lib/reanimated2/animation/commonTypes').DelayAnimation;
49
+ export type RepeatAnimation =
50
+ import('./lib/types/lib/reanimated2/animation/index').RepeatAnimation;
51
+ export type SequenceAnimation =
52
+ import('./lib/types/lib/reanimated2/animation/index').SequenceAnimation;
53
+ export type StyleLayoutAnimation =
54
+ import('./lib/types/lib/reanimated2/animation/index').StyleLayoutAnimation;
55
+ export type Animation<T> =
56
+ import('./lib/types/lib/reanimated2/commonTypes').Animation<T>;
52
57
 
53
58
  namespace Animated {
54
59
  type Nullable<T> = T | null | undefined;
@@ -150,7 +155,7 @@ declare module 'react-native-reanimated' {
150
155
  ? T['style']
151
156
  : Record<string, unknown>;
152
157
 
153
- export type AnimateProps<P extends Record<string, unknown>> = {
158
+ export type AnimateProps<P extends object> = {
154
159
  [K in keyof P]: P[K] | AnimatedNode<P[K]>;
155
160
  } & {
156
161
  style?: StyleProp<AnimateStyle<StylesOrDefault<P>>>;
@@ -394,16 +399,16 @@ declare module 'react-native-reanimated' {
394
399
  value: Adaptable<number>,
395
400
  config: InterpolationConfig
396
401
  ): AnimatedNode<number>;
397
- export function interpolateColors(
402
+ export function interpolateColors<T extends string | number>(
398
403
  animationValue: Adaptable<number>,
399
404
  {
400
405
  inputRange,
401
406
  outputColorRange,
402
407
  }: {
403
408
  inputRange: ReadonlyArray<Adaptable<number>>;
404
- outputColorRange: ReadonlyArray<Adaptable<number | string>>;
409
+ outputColorRange: ReadonlyArray<Adaptable<T>>;
405
410
  }
406
- ): AnimatedNode<number | string>;
411
+ ): AnimatedNode<T>;
407
412
  export const max: BinaryOperator;
408
413
  export const min: BinaryOperator;
409
414
 
@@ -481,6 +486,23 @@ declare module 'react-native-reanimated' {
481
486
  targetGlobalOriginY: number;
482
487
  }
483
488
 
489
+ export enum SensorType {
490
+ ACCELEROMETER = 1,
491
+ GYROSCOPE = 2,
492
+ GRAVITY = 3,
493
+ MAGNETIC_FIELD = 4,
494
+ ROTATION = 5,
495
+ }
496
+
497
+ export type SensorConfig = {
498
+ interval: number;
499
+ };
500
+
501
+ export function useAnimatedSensor(
502
+ sensorType: SensorType,
503
+ userConfig?: SensorConfig
504
+ );
505
+
484
506
  export interface ExitAnimationsValues {
485
507
  currentOriginX: number;
486
508
  currentOriginY: number;
@@ -557,9 +579,10 @@ declare module 'react-native-reanimated' {
557
579
  finished?: boolean,
558
580
  current?: AnimatableValue
559
581
  ) => void;
582
+ export type EasingFunctionFactory = { factory: () => EasingFunction };
560
583
  export interface WithTimingConfig {
561
584
  duration?: number;
562
- easing?: EasingFunction;
585
+ easing?: EasingFunction | EasingFunctionFactory;
563
586
  }
564
587
  export interface WithDecayConfig {
565
588
  deceleration?: number;
@@ -576,29 +599,29 @@ declare module 'react-native-reanimated' {
576
599
  restDisplacementThreshold?: number;
577
600
  velocity?: number;
578
601
  }
579
- export function withTiming(
580
- toValue: AnimatableValue,
602
+ export function withTiming<T extends AnimatableValue>(
603
+ toValue: T,
581
604
  userConfig?: WithTimingConfig,
582
605
  callback?: AnimationCallback
583
- ): number;
584
- export function withSpring(
585
- toValue: AnimatableValue,
606
+ ): T;
607
+ export function withSpring<T extends AnimatableValue>(
608
+ toValue: T,
586
609
  userConfig?: WithSpringConfig,
587
610
  callback?: AnimationCallback
588
- ): number;
611
+ ): T;
589
612
  export function withDecay(
590
613
  userConfig: WithDecayConfig,
591
614
  callback?: AnimationCallback
592
615
  ): number;
593
616
  export function cancelAnimation<T>(sharedValue: SharedValue<T>): void;
594
- export function withDelay(delayMS: number, delayedAnimation: number): number;
595
- export function withRepeat(
596
- animation: number,
617
+ export function withDelay<T extends AnimatableValue>(delayMS: number, delayedAnimation: T): T;
618
+ export function withRepeat<T extends AnimatableValue>(
619
+ animation: T,
597
620
  numberOfReps?: number,
598
621
  reverse?: boolean,
599
622
  callback?: AnimationCallback
600
- ): number;
601
- export function withSequence(...animations: [number, ...number[]]): number;
623
+ ): T;
624
+ export function withSequence<T extends AnimatableValue>(...animations: [T, ...T[]]): T;
602
625
 
603
626
  // reanimated2 functions
604
627
  export function runOnUI<A extends any[], R>(
@@ -619,12 +642,12 @@ declare module 'react-native-reanimated' {
619
642
  fn: (...args: A) => R
620
643
  ): (...args: Parameters<typeof fn>) => R;
621
644
 
622
- export function interpolateColor(
645
+ export function interpolateColor<T extends string | number>(
623
646
  value: number,
624
647
  inputRange: readonly number[],
625
- outputRange: readonly (string | number)[],
648
+ outputRange: readonly T[],
626
649
  colorSpace?: 'RGB' | 'HSV'
627
- ): string | number;
650
+ ): T;
628
651
 
629
652
  export enum ColorSpace {
630
653
  RGB = 0,
@@ -829,6 +852,9 @@ declare module 'react-native-reanimated' {
829
852
  callback: (finished: boolean) => void
830
853
  ): ComplexAnimationBuilder;
831
854
 
855
+ static withInitialValues(values: StyleProps): BaseAnimationBuilder;
856
+ withInitialValues(values: StyleProps): BaseAnimationBuilder;
857
+
832
858
  static easing(easingFunction: EasingFunction): ComplexAnimationBuilder;
833
859
  easing(easingFunction: EasingFunction): ComplexAnimationBuilder;
834
860
  static springify(): ComplexAnimationBuilder;
@@ -1,4 +1,4 @@
1
- import ReanimatedModule from './ReanimatedModule';
1
+ import { configureProps as jsiConfigureProps } from './reanimated2/core';
2
2
 
3
3
  /**
4
4
  * Styles allowed to be direcly updated in UI thread
@@ -78,7 +78,6 @@ let NATIVE_THREAD_PROPS_WHITELIST: Record<string, boolean> = {
78
78
  borderTopLeftRadius: true,
79
79
  borderTopRightRadius: true,
80
80
  borderTopStartRadius: true,
81
- opacity: true,
82
81
  elevation: true,
83
82
  fontSize: true,
84
83
  lineHeight: true,
@@ -107,9 +106,9 @@ let NATIVE_THREAD_PROPS_WHITELIST: Record<string, boolean> = {
107
106
  };
108
107
 
109
108
  function configureProps(): void {
110
- ReanimatedModule.configureProps(
111
- Object.keys(NATIVE_THREAD_PROPS_WHITELIST),
112
- Object.keys(UI_THREAD_PROPS_WHITELIST)
109
+ jsiConfigureProps(
110
+ Object.keys(UI_THREAD_PROPS_WHITELIST),
111
+ Object.keys(NATIVE_THREAD_PROPS_WHITELIST)
113
112
  );
114
113
  }
115
114
 
@@ -161,7 +161,7 @@ interface ComponentRef extends Component {
161
161
  getScrollableNode?: () => ComponentRef;
162
162
  }
163
163
 
164
- interface InitialComponentProps extends Record<string, unknown> {
164
+ export interface InitialComponentProps extends Record<string, unknown> {
165
165
  ref?: Ref<Component>;
166
166
  collapsable?: boolean;
167
167
  }
@@ -194,6 +194,7 @@ export default function createAnimatedComponent(
194
194
  _viewTag = -1;
195
195
  _isFirstRender = true;
196
196
  animatedStyle: { value: StyleProps } = { value: {} };
197
+ initialStyle = {};
197
198
  sv: SharedValue<null | Record<string, unknown>> | null;
198
199
  _propsAnimated?: PropsAnimated;
199
200
  _component: ComponentRef | null = null;
@@ -606,13 +607,12 @@ export default function createAnimatedComponent(
606
607
  // this is how we recognize styles returned by useAnimatedStyle
607
608
  style.viewsRef.add(this);
608
609
  if (this._isFirstRender) {
609
- return {
610
+ this.initialStyle = {
610
611
  ...style.initial.value,
611
612
  ...initialUpdaterRun<StyleProps>(style.initial.updater),
612
613
  };
613
- } else {
614
- return style.initial.value;
615
614
  }
615
+ return this.initialStyle;
616
616
  } else {
617
617
  return style;
618
618
  }
@@ -37,7 +37,7 @@ export function createAnimatedFunction(cb) {
37
37
  for (let i = 0; i < params.length; i++) {
38
38
  params[i] = createAnimatedParam();
39
39
  }
40
- // eslint-disable-next-line standard/no-callback-literal
40
+ // eslint-disable-next-line node/no-callback-literal
41
41
  const what = cb(...params);
42
42
  const func = new AnimatedFunction(what, ...params);
43
43
  return (...args) => {
@@ -128,15 +128,13 @@ export default function interpolate(value, config) {
128
128
  const right = extrapolateRight || extrapolate;
129
129
  let output = interpolateInternal(value, inputRange, outputRange);
130
130
 
131
- if (left === Extrapolate.EXTEND) {
132
- } else if (left === Extrapolate.CLAMP) {
131
+ if (left === Extrapolate.CLAMP) {
133
132
  output = cond(lessThan(value, inputRange[0]), outputRange[0], output);
134
133
  } else if (left === Extrapolate.IDENTITY) {
135
134
  output = cond(lessThan(value, inputRange[0]), value, output);
136
135
  }
137
136
 
138
- if (right === Extrapolate.EXTEND) {
139
- } else if (right === Extrapolate.CLAMP) {
137
+ if (right === Extrapolate.CLAMP) {
140
138
  output = cond(
141
139
  greaterThan(value, inputRange[inputRange.length - 1]),
142
140
  outputRange[outputRange.length - 1],
@@ -64,7 +64,8 @@ function getMatchers(): Matchers {
64
64
  'hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER)
65
65
  );
66
66
  cachedMatchers.hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
67
- cachedMatchers.hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
67
+ cachedMatchers.hex4 =
68
+ /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
68
69
  cachedMatchers.hex6 = /^#([0-9a-fA-F]{6})$/;
69
70
  cachedMatchers.hex8 = /^#([0-9a-fA-F]{8})$/;
70
71
  }
@@ -109,7 +109,10 @@ function cubic(t: number): number {
109
109
  */
110
110
  function poly(n: number): EasingFn {
111
111
  'worklet';
112
- return (t) => Math.pow(t, n);
112
+ return (t) => {
113
+ 'worklet';
114
+ return Math.pow(t, n);
115
+ };
113
116
  }
114
117
 
115
118
  /**
@@ -171,7 +174,10 @@ function elastic(bounciness = 1): EasingFn {
171
174
  */
172
175
  function back(s = 1.70158): (t: number) => number {
173
176
  'worklet';
174
- return (t) => t * t * ((s + 1) * t - s);
177
+ return (t) => {
178
+ 'worklet';
179
+ return t * t * ((s + 1) * t - s);
180
+ };
175
181
  }
176
182
 
177
183
  /**
@@ -312,7 +318,7 @@ function createChecker(
312
318
  }
313
319
  // @ts-ignore this is implicitly any - TODO
314
320
  const res = worklet.apply(this, arguments);
315
- if (!_WORKLET && res && typeof res === 'function' && res.__worklet) {
321
+ if (!_WORKLET && res && typeof res === 'function' && res.__workletHash) {
316
322
  return createChecker(res, workletName, arguments);
317
323
  }
318
324
  return res;
@@ -1,31 +1,54 @@
1
- import { SharedValue } from '../commonTypes';
1
+ import { NativeModules } from 'react-native';
2
+ import {
3
+ SharedValue,
4
+ SensorValue3D,
5
+ SensorValueRotation,
6
+ } from '../commonTypes';
2
7
  import { Descriptor } from '../hook/commonTypes';
3
8
 
4
- const InnerNativeModule = global.__reanimatedModuleProxy;
5
-
6
9
  export class NativeReanimated {
7
10
  native: boolean;
8
- useOnlyV1: boolean;
11
+ private InnerNativeModule: any;
9
12
 
10
13
  constructor(native = true) {
14
+ if (global.__reanimatedModuleProxy === undefined) {
15
+ const { ReanimatedModule } = NativeModules;
16
+ ReanimatedModule?.installTurboModule();
17
+ }
18
+ this.InnerNativeModule = global.__reanimatedModuleProxy;
11
19
  this.native = native;
12
- this.useOnlyV1 = InnerNativeModule === null;
13
20
  }
14
21
 
15
22
  installCoreFunctions(valueSetter: <T>(value: T) => void): void {
16
- return InnerNativeModule.installCoreFunctions(valueSetter);
23
+ return this.InnerNativeModule.installCoreFunctions(valueSetter);
17
24
  }
18
25
 
19
26
  makeShareable<T>(value: T): T {
20
- return InnerNativeModule.makeShareable(value);
27
+ return this.InnerNativeModule.makeShareable(value);
21
28
  }
22
29
 
23
30
  makeMutable<T>(value: T): SharedValue<T> {
24
- return InnerNativeModule.makeMutable(value);
31
+ return this.InnerNativeModule.makeMutable(value);
25
32
  }
26
33
 
27
34
  makeRemote<T>(object = {}): T {
28
- return InnerNativeModule.makeRemote(object);
35
+ return this.InnerNativeModule.makeRemote(object);
36
+ }
37
+
38
+ registerSensor(
39
+ sensorType: number,
40
+ interval: number,
41
+ sensorData: SensorValue3D | SensorValueRotation
42
+ ) {
43
+ return this.InnerNativeModule.registerSensor(
44
+ sensorType,
45
+ interval,
46
+ sensorData
47
+ );
48
+ }
49
+
50
+ unregisterSensor(sensorId: number) {
51
+ return this.InnerNativeModule.unregisterSensor(sensorId);
29
52
  }
30
53
 
31
54
  startMapper(
@@ -35,7 +58,7 @@ export class NativeReanimated {
35
58
  updater: () => void,
36
59
  viewDescriptors: Descriptor[] | SharedValue<Descriptor[]>
37
60
  ): number {
38
- return InnerNativeModule.startMapper(
61
+ return this.InnerNativeModule.startMapper(
39
62
  mapper,
40
63
  inputs,
41
64
  outputs,
@@ -45,18 +68,18 @@ export class NativeReanimated {
45
68
  }
46
69
 
47
70
  stopMapper(mapperId: number): void {
48
- return InnerNativeModule.stopMapper(mapperId);
71
+ return this.InnerNativeModule.stopMapper(mapperId);
49
72
  }
50
73
 
51
74
  registerEventHandler<T>(
52
75
  eventHash: string,
53
76
  eventHandler: (event: T) => void
54
77
  ): string {
55
- return InnerNativeModule.registerEventHandler(eventHash, eventHandler);
78
+ return this.InnerNativeModule.registerEventHandler(eventHash, eventHandler);
56
79
  }
57
80
 
58
81
  unregisterEventHandler(id: string): void {
59
- return InnerNativeModule.unregisterEventHandler(id);
82
+ return this.InnerNativeModule.unregisterEventHandler(id);
60
83
  }
61
84
 
62
85
  getViewProp<T>(
@@ -64,10 +87,14 @@ export class NativeReanimated {
64
87
  propName: string,
65
88
  callback?: (result: T) => void
66
89
  ): Promise<T> {
67
- return InnerNativeModule.getViewProp(viewTag, propName, callback);
90
+ return this.InnerNativeModule.getViewProp(viewTag, propName, callback);
68
91
  }
69
92
 
70
93
  enableLayoutAnimations(flag: boolean): void {
71
- InnerNativeModule.enableLayoutAnimations(flag);
94
+ this.InnerNativeModule.enableLayoutAnimations(flag);
95
+ }
96
+
97
+ configureProps(uiProps: string[], nativeProps: string[]): void {
98
+ this.InnerNativeModule.configureProps(uiProps, nativeProps);
72
99
  }
73
100
  }