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,217 @@
1
+ #import <RNReanimated/ReanimatedSensor.h>
2
+
3
+ #if __has_include(<CoreMotion/CoreMotion.h>)
4
+ @implementation ReanimatedSensor
5
+
6
+ - (instancetype)init:(ReanimatedSensorType)sensorType interval:(int)interval setter:(void (^)(double[]))setter
7
+ {
8
+ self = [super init];
9
+ _sensorType = sensorType;
10
+ _interval = interval / 1000; // in seconds
11
+ _setter = setter;
12
+ _motionManager = [[CMMotionManager alloc] init];
13
+ return self;
14
+ }
15
+
16
+ - (bool)initialize
17
+ {
18
+ if (_sensorType == ACCELEROMETER) {
19
+ return [self initializeAccelerometer];
20
+ } else if (_sensorType == GYROSCOPE) {
21
+ return [self initializeGyroscope];
22
+ } else if (_sensorType == GRAVITY) {
23
+ return [self initializeGravity];
24
+ } else if (_sensorType == MAGNETIC_FIELD) {
25
+ return [self initializeMagnetometer];
26
+ } else if (_sensorType == ROTATION_VECTOR) {
27
+ return [self initializeOrientation];
28
+ }
29
+
30
+ return false;
31
+ }
32
+
33
+ - (bool)initializeGyroscope
34
+ {
35
+ if (![_motionManager isGyroAvailable]) {
36
+ return false;
37
+ }
38
+ [_motionManager setGyroUpdateInterval:_interval];
39
+ [_motionManager startGyroUpdates];
40
+ [_motionManager
41
+ startGyroUpdatesToQueue:[NSOperationQueue mainQueue]
42
+ withHandler:^(CMGyroData *sensorData, NSError *error) {
43
+ double currentTime = [[NSProcessInfo processInfo] systemUptime];
44
+ if (currentTime - self->_lastTimestamp < self->_interval) {
45
+ return;
46
+ }
47
+ double data[] = {sensorData.rotationRate.x, sensorData.rotationRate.y, sensorData.rotationRate.z};
48
+ self->_setter(data);
49
+ self->_lastTimestamp = currentTime;
50
+ }];
51
+
52
+ return true;
53
+ }
54
+
55
+ - (bool)initializeAccelerometer
56
+ {
57
+ if (![_motionManager isAccelerometerAvailable]) {
58
+ return false;
59
+ }
60
+ [_motionManager setAccelerometerUpdateInterval:_interval];
61
+ [_motionManager startAccelerometerUpdates];
62
+ [_motionManager
63
+ startAccelerometerUpdatesToQueue:[NSOperationQueue mainQueue]
64
+ withHandler:^(CMAccelerometerData *sensorData, NSError *error) {
65
+ double currentTime = [[NSProcessInfo processInfo] systemUptime];
66
+ if (currentTime - self->_lastTimestamp < self->_interval) {
67
+ return;
68
+ }
69
+ double data[] = {
70
+ sensorData.acceleration.x, sensorData.acceleration.y, sensorData.acceleration.z};
71
+ self->_setter(data);
72
+ self->_lastTimestamp = currentTime;
73
+ }];
74
+
75
+ return true;
76
+ }
77
+
78
+ - (bool)initializeGravity
79
+ {
80
+ if (![_motionManager isDeviceMotionAvailable]) {
81
+ return false;
82
+ }
83
+ [_motionManager setDeviceMotionUpdateInterval:_interval];
84
+ [_motionManager setShowsDeviceMovementDisplay:YES];
85
+ [_motionManager
86
+ startDeviceMotionUpdatesToQueue:[NSOperationQueue mainQueue]
87
+ withHandler:^(CMDeviceMotion *sensorData, NSError *error) {
88
+ double currentTime = [[NSProcessInfo processInfo] systemUptime];
89
+ if (currentTime - self->_lastTimestamp < self->_interval) {
90
+ return;
91
+ }
92
+ double data[] = {sensorData.gravity.x, sensorData.gravity.y, sensorData.gravity.z};
93
+ self->_setter(data);
94
+ self->_lastTimestamp = currentTime;
95
+ }];
96
+
97
+ return true;
98
+ }
99
+
100
+ - (bool)initializeMagnetometer
101
+ {
102
+ if (![_motionManager isMagnetometerAvailable]) {
103
+ return false;
104
+ }
105
+ [_motionManager setMagnetometerUpdateInterval:_interval];
106
+ [_motionManager startMagnetometerUpdates];
107
+ [_motionManager
108
+ startMagnetometerUpdatesToQueue:[NSOperationQueue mainQueue]
109
+ withHandler:^(CMMagnetometerData *sensorData, NSError *error) {
110
+ double currentTime = [[NSProcessInfo processInfo] systemUptime];
111
+ if (currentTime - self->_lastTimestamp < self->_interval) {
112
+ return;
113
+ }
114
+ double data[] = {
115
+ sensorData.magneticField.x, sensorData.magneticField.y, sensorData.magneticField.z};
116
+ self->_setter(data);
117
+ self->_lastTimestamp = currentTime;
118
+ }];
119
+
120
+ return true;
121
+ }
122
+
123
+ - (bool)initializeOrientation
124
+ {
125
+ if (![_motionManager isDeviceMotionAvailable]) {
126
+ return false;
127
+ }
128
+ [_motionManager setDeviceMotionUpdateInterval:_interval];
129
+
130
+ [_motionManager setShowsDeviceMovementDisplay:YES];
131
+ [_motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXTrueNorthZVertical
132
+ toQueue:[NSOperationQueue mainQueue]
133
+ withHandler:^(CMDeviceMotion *sensorData, NSError *error) {
134
+ double currentTime = [[NSProcessInfo processInfo] systemUptime];
135
+ if (currentTime - self->_lastTimestamp < self->_interval) {
136
+ return;
137
+ }
138
+ CMAttitude *attitude = sensorData.attitude;
139
+ double data[] = {
140
+ attitude.quaternion.x,
141
+ attitude.quaternion.y,
142
+ attitude.quaternion.z,
143
+ attitude.quaternion.w,
144
+ attitude.pitch,
145
+ attitude.roll,
146
+ attitude.yaw,
147
+ };
148
+ self->_setter(data);
149
+ self->_lastTimestamp = currentTime;
150
+ }];
151
+
152
+ return true;
153
+ }
154
+
155
+ - (void)cancel
156
+ {
157
+ if (_sensorType == ACCELEROMETER) {
158
+ [_motionManager stopAccelerometerUpdates];
159
+ } else if (_sensorType == GYROSCOPE) {
160
+ [_motionManager stopGyroUpdates];
161
+ } else if (_sensorType == GRAVITY) {
162
+ [_motionManager stopDeviceMotionUpdates];
163
+ } else if (_sensorType == MAGNETIC_FIELD) {
164
+ [_motionManager stopMagnetometerUpdates];
165
+ } else if (_sensorType == ROTATION_VECTOR) {
166
+ [_motionManager stopDeviceMotionUpdates];
167
+ }
168
+ }
169
+
170
+ @end
171
+
172
+ #else
173
+
174
+ @implementation ReanimatedSensor
175
+
176
+ - (instancetype)init:(ReanimatedSensorType)sensorType interval:(int)interval setter:(void (^)(double[]))setter
177
+ {
178
+ self = [super init];
179
+ return self;
180
+ }
181
+
182
+ - (bool)initialize
183
+ {
184
+ return false;
185
+ }
186
+
187
+ - (bool)initializeGyroscope
188
+ {
189
+ return false;
190
+ }
191
+
192
+ - (bool)initializeAccelerometer
193
+ {
194
+ return false;
195
+ }
196
+
197
+ - (bool)initializeGravity
198
+ {
199
+ return false;
200
+ }
201
+
202
+ - (bool)initializeMagnetometer
203
+ {
204
+ return false;
205
+ }
206
+
207
+ - (bool)initializeOrientation
208
+ {
209
+ return false;
210
+ }
211
+
212
+ - (void)cancel
213
+ {
214
+ }
215
+
216
+ @end
217
+ #endif
@@ -0,0 +1,12 @@
1
+ #import <RNReanimated/ReanimatedSensorType.h>
2
+
3
+ @interface ReanimatedSensorContainer : NSObject {
4
+ NSNumber *_nextSensorId;
5
+ NSMutableDictionary *_sensors;
6
+ }
7
+
8
+ - (instancetype)init;
9
+ - (int)registerSensor:(ReanimatedSensorType)sensorType interval:(int)interval setter:(void (^)(double[]))setter;
10
+ - (void)unregisterSensor:(int)sensorId;
11
+
12
+ @end
@@ -0,0 +1,40 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <RNReanimated/ReanimatedSensor.h>
3
+ #import <RNReanimated/ReanimatedSensorContainer.h>
4
+
5
+ static NSNumber *_nextSensorId = nil;
6
+
7
+ @implementation ReanimatedSensorContainer
8
+
9
+ - (instancetype)init
10
+ {
11
+ self = [super init];
12
+ _sensors = [[NSMutableDictionary alloc] init];
13
+ _nextSensorId = @0;
14
+ return self;
15
+ }
16
+
17
+ - (int)registerSensor:(ReanimatedSensorType)sensorType interval:(int)interval setter:(void (^)(double[]))setter
18
+ {
19
+ ReanimatedSensor *sensor = [[ReanimatedSensor alloc] init:sensorType interval:interval setter:setter];
20
+ if ([sensor initialize]) {
21
+ NSNumber *sensorId = [_nextSensorId copy];
22
+ _nextSensorId = [NSNumber numberWithInt:[_nextSensorId intValue] + 1];
23
+ [_sensors setObject:sensor forKey:sensorId];
24
+ return [sensorId intValue];
25
+ } else {
26
+ return -1;
27
+ }
28
+ }
29
+
30
+ - (void)unregisterSensor:(int)sensorId
31
+ {
32
+ NSNumber *_sensorId = [NSNumber numberWithInt:sensorId];
33
+ if (_sensors[_sensorId] == nil) {
34
+ return;
35
+ }
36
+ [_sensors[_sensorId] cancel];
37
+ [_sensors removeObjectForKey:_sensorId];
38
+ }
39
+
40
+ @end
@@ -0,0 +1,7 @@
1
+ typedef NS_ENUM(NSUInteger, ReanimatedSensorType) {
2
+ ACCELEROMETER = 1,
3
+ GYROSCOPE = 2,
4
+ GRAVITY = 3,
5
+ MAGNETIC_FIELD = 4,
6
+ ROTATION_VECTOR = 5,
7
+ };
@@ -1,4 +1,4 @@
1
- import ReanimatedModule from './ReanimatedModule';
1
+ import { configureProps as jsiConfigureProps } from './reanimated2/core';
2
2
  /**
3
3
  * Styles allowed to be direcly updated in UI thread
4
4
  */
@@ -76,7 +76,6 @@ let NATIVE_THREAD_PROPS_WHITELIST = {
76
76
  borderTopLeftRadius: true,
77
77
  borderTopRightRadius: true,
78
78
  borderTopStartRadius: true,
79
- opacity: true,
80
79
  elevation: true,
81
80
  fontSize: true,
82
81
  lineHeight: true,
@@ -104,7 +103,7 @@ let NATIVE_THREAD_PROPS_WHITELIST = {
104
103
  placeholderTextColor: true,
105
104
  };
106
105
  function configureProps() {
107
- ReanimatedModule.configureProps(Object.keys(NATIVE_THREAD_PROPS_WHITELIST), Object.keys(UI_THREAD_PROPS_WHITELIST));
106
+ jsiConfigureProps(Object.keys(UI_THREAD_PROPS_WHITELIST), Object.keys(NATIVE_THREAD_PROPS_WHITELIST));
108
107
  }
109
108
  export function addWhitelistedNativeProps(props) {
110
109
  const oldSize = Object.keys(NATIVE_THREAD_PROPS_WHITELIST).length;
@@ -90,6 +90,7 @@ export default function createAnimatedComponent(Component, options) {
90
90
  this._viewTag = -1;
91
91
  this._isFirstRender = true;
92
92
  this.animatedStyle = { value: {} };
93
+ this.initialStyle = {};
93
94
  this._component = null;
94
95
  // The system is best designed when setNativeProps is implemented. It is
95
96
  // able to avoid re-rendering and directly set the attributes that changed.
@@ -438,11 +439,9 @@ export default function createAnimatedComponent(Component, options) {
438
439
  // this is how we recognize styles returned by useAnimatedStyle
439
440
  style.viewsRef.add(this);
440
441
  if (this._isFirstRender) {
441
- return Object.assign(Object.assign({}, style.initial.value), initialUpdaterRun(style.initial.updater));
442
- }
443
- else {
444
- return style.initial.value;
442
+ this.initialStyle = Object.assign(Object.assign({}, style.initial.value), initialUpdaterRun(style.initial.updater));
445
443
  }
444
+ return this.initialStyle;
446
445
  }
447
446
  else {
448
447
  return style;
@@ -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],
@@ -31,7 +31,8 @@ function getMatchers() {
31
31
  cachedMatchers.hsl = new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE));
32
32
  cachedMatchers.hsla = new RegExp('hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER));
33
33
  cachedMatchers.hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
34
- cachedMatchers.hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
34
+ cachedMatchers.hex4 =
35
+ /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
35
36
  cachedMatchers.hex6 = /^#([0-9a-fA-F]{6})$/;
36
37
  cachedMatchers.hex8 = /^#([0-9a-fA-F]{8})$/;
37
38
  }
@@ -53,7 +53,10 @@ function cubic(t) {
53
53
  */
54
54
  function poly(n) {
55
55
  'worklet';
56
- return (t) => Math.pow(t, n);
56
+ return (t) => {
57
+ 'worklet';
58
+ return Math.pow(t, n);
59
+ };
57
60
  }
58
61
  /**
59
62
  * A sinusoidal function.
@@ -110,7 +113,10 @@ function elastic(bounciness = 1) {
110
113
  */
111
114
  function back(s = 1.70158) {
112
115
  'worklet';
113
- return (t) => t * t * ((s + 1) * t - s);
116
+ return (t) => {
117
+ 'worklet';
118
+ return t * t * ((s + 1) * t - s);
119
+ };
114
120
  }
115
121
  /**
116
122
  * Provides a simple bouncing effect.
@@ -224,7 +230,7 @@ function createChecker(worklet, workletName, prevArgs) {
224
230
  }
225
231
  // @ts-ignore this is implicitly any - TODO
226
232
  const res = worklet.apply(this, arguments);
227
- if (!_WORKLET && res && typeof res === 'function' && res.__worklet) {
233
+ if (!_WORKLET && res && typeof res === 'function' && res.__workletHash) {
228
234
  return createChecker(res, workletName, arguments);
229
235
  }
230
236
  return res;
@@ -1,37 +1,50 @@
1
- const InnerNativeModule = global.__reanimatedModuleProxy;
1
+ import { NativeModules } from 'react-native';
2
2
  export class NativeReanimated {
3
3
  constructor(native = true) {
4
+ if (global.__reanimatedModuleProxy === undefined) {
5
+ const { ReanimatedModule } = NativeModules;
6
+ ReanimatedModule === null || ReanimatedModule === void 0 ? void 0 : ReanimatedModule.installTurboModule();
7
+ }
8
+ this.InnerNativeModule = global.__reanimatedModuleProxy;
4
9
  this.native = native;
5
- this.useOnlyV1 = InnerNativeModule === null;
6
10
  }
7
11
  installCoreFunctions(valueSetter) {
8
- return InnerNativeModule.installCoreFunctions(valueSetter);
12
+ return this.InnerNativeModule.installCoreFunctions(valueSetter);
9
13
  }
10
14
  makeShareable(value) {
11
- return InnerNativeModule.makeShareable(value);
15
+ return this.InnerNativeModule.makeShareable(value);
12
16
  }
13
17
  makeMutable(value) {
14
- return InnerNativeModule.makeMutable(value);
18
+ return this.InnerNativeModule.makeMutable(value);
15
19
  }
16
20
  makeRemote(object = {}) {
17
- return InnerNativeModule.makeRemote(object);
21
+ return this.InnerNativeModule.makeRemote(object);
22
+ }
23
+ registerSensor(sensorType, interval, sensorData) {
24
+ return this.InnerNativeModule.registerSensor(sensorType, interval, sensorData);
25
+ }
26
+ unregisterSensor(sensorId) {
27
+ return this.InnerNativeModule.unregisterSensor(sensorId);
18
28
  }
19
29
  startMapper(mapper, inputs = [], outputs = [], updater, viewDescriptors) {
20
- return InnerNativeModule.startMapper(mapper, inputs, outputs, updater, viewDescriptors);
30
+ return this.InnerNativeModule.startMapper(mapper, inputs, outputs, updater, viewDescriptors);
21
31
  }
22
32
  stopMapper(mapperId) {
23
- return InnerNativeModule.stopMapper(mapperId);
33
+ return this.InnerNativeModule.stopMapper(mapperId);
24
34
  }
25
35
  registerEventHandler(eventHash, eventHandler) {
26
- return InnerNativeModule.registerEventHandler(eventHash, eventHandler);
36
+ return this.InnerNativeModule.registerEventHandler(eventHash, eventHandler);
27
37
  }
28
38
  unregisterEventHandler(id) {
29
- return InnerNativeModule.unregisterEventHandler(id);
39
+ return this.InnerNativeModule.unregisterEventHandler(id);
30
40
  }
31
41
  getViewProp(viewTag, propName, callback) {
32
- return InnerNativeModule.getViewProp(viewTag, propName, callback);
42
+ return this.InnerNativeModule.getViewProp(viewTag, propName, callback);
33
43
  }
34
44
  enableLayoutAnimations(flag) {
35
- InnerNativeModule.enableLayoutAnimations(flag);
45
+ this.InnerNativeModule.enableLayoutAnimations(flag);
46
+ }
47
+ configureProps(uiProps, nativeProps) {
48
+ this.InnerNativeModule.configureProps(uiProps, nativeProps);
36
49
  }
37
50
  }
@@ -1,6 +1,5 @@
1
1
  import reanimatedJS from '../js-reanimated';
2
2
  import { shouldBeUseWeb } from '../PlatformChecker';
3
- import { Platform } from 'react-native';
4
3
  import { NativeReanimated } from './NativeReanimated';
5
4
  let exportedModule;
6
5
  if (shouldBeUseWeb()) {
@@ -8,8 +7,5 @@ if (shouldBeUseWeb()) {
8
7
  }
9
8
  else {
10
9
  exportedModule = new NativeReanimated();
11
- if (exportedModule.useOnlyV1 && Platform.OS === 'android') {
12
- console.warn(`If you want to use Reanimated 2 then go through our installation steps https://docs.swmansion.com/react-native-reanimated/docs/installation`);
13
- }
14
10
  }
15
11
  export default exportedModule;
@@ -1,7 +1,7 @@
1
1
  import { useRef } from 'react';
2
2
  import { makeMutable } from './core';
3
- import { Platform } from 'react-native';
4
- const scheduleUpdates = Platform.OS === 'web' ? requestAnimationFrame : setImmediate;
3
+ import { shouldBeUseWeb } from './PlatformChecker';
4
+ const scheduleUpdates = shouldBeUseWeb() ? requestAnimationFrame : setImmediate;
5
5
  export function makeViewDescriptorsSet() {
6
6
  const ref = useRef(null);
7
7
  if (ref.current === null) {
@@ -35,7 +35,8 @@ export function setPath(obj, path, value) {
35
35
  }
36
36
  currObj = currObj[keys[i]];
37
37
  }
38
- currObj[keys[keys.length - 1]] = value;
38
+ currObj[keys[keys.length - 1]] =
39
+ value;
39
40
  }
40
41
  export function withStyleAnimation(styleAnimations) {
41
42
  'worklet';
@@ -2,9 +2,6 @@
2
2
  import NativeReanimatedModule from './NativeReanimated';
3
3
  import { Platform } from 'react-native';
4
4
  import { nativeShouldBeMock, shouldBeUseWeb, isWeb } from './PlatformChecker';
5
- global.__reanimatedWorkletInit = function (worklet) {
6
- worklet.__worklet = true;
7
- };
8
5
  if (global._setGlobalConsole === undefined) {
9
6
  // it can happen when Reanimated plugin wasn't added, but the user uses the only API from version 1
10
7
  global._setGlobalConsole = () => {
@@ -24,46 +21,13 @@ export const checkPluginState = (throwError = true) => {
24
21
  return true;
25
22
  };
26
23
  export const isConfigured = (throwError = false) => {
27
- return checkPluginState(throwError) && !NativeReanimatedModule.useOnlyV1;
24
+ return checkPluginState(throwError);
28
25
  };
29
26
  export const isConfiguredCheck = () => {
30
27
  if (!isConfigured(true)) {
31
28
  throw new Error('If you want to use Reanimated 2 then go through our installation steps https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation');
32
29
  }
33
30
  };
34
- function _toArrayReanimated(object) {
35
- 'worklet';
36
- if (Array.isArray(object)) {
37
- return object;
38
- }
39
- if (typeof Symbol !== 'undefined' &&
40
- (typeof Symbol === 'function' ? Symbol.iterator : '@@iterator') in
41
- Object(object)) {
42
- return Array.from(object);
43
- }
44
- throw new Error('Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.');
45
- }
46
- function _mergeObjectsReanimated() {
47
- 'worklet';
48
- // we can't use rest parameters in worklets at the moment
49
- // eslint-disable-next-line prefer-rest-params
50
- const arr = Array.from(arguments);
51
- return Object.assign.apply(null, [arr[0], ...arr.slice(1)]);
52
- }
53
- global.__reanimatedWorkletInit = function (worklet) {
54
- worklet.__worklet = true;
55
- if (worklet._closure) {
56
- const closure = worklet._closure;
57
- Object.keys(closure).forEach((key) => {
58
- if (key === '_toConsumableArray') {
59
- closure[key] = _toArrayReanimated;
60
- }
61
- if (key === '_objectSpread') {
62
- closure[key] = _mergeObjectsReanimated;
63
- }
64
- });
65
- }
66
- };
67
31
  function pushFrame(frame) {
68
32
  NativeReanimatedModule.pushFrame(frame);
69
33
  }
@@ -259,29 +223,27 @@ export function runOnJS(fun) {
259
223
  return fun.__callAsync;
260
224
  }
261
225
  }
262
- if (!NativeReanimatedModule.useOnlyV1) {
263
- NativeReanimatedModule.installCoreFunctions(NativeReanimatedModule.native
264
- ? workletValueSetter
265
- : workletValueSetterJS);
266
- if (!isWeb() && isConfigured()) {
267
- const capturableConsole = console;
268
- runOnUI(() => {
269
- 'worklet';
270
- const console = {
271
- debug: runOnJS(capturableConsole.debug),
272
- log: runOnJS(capturableConsole.log),
273
- warn: runOnJS(capturableConsole.warn),
274
- error: runOnJS(capturableConsole.error),
275
- info: runOnJS(capturableConsole.info),
276
- };
277
- _setGlobalConsole(console);
278
- if (global.performance == null) {
279
- global.performance = {
280
- now: global._chronoNow,
281
- };
282
- }
283
- })();
284
- }
226
+ NativeReanimatedModule.installCoreFunctions(NativeReanimatedModule.native
227
+ ? workletValueSetter
228
+ : workletValueSetterJS);
229
+ if (!isWeb() && isConfigured()) {
230
+ const capturableConsole = console;
231
+ runOnUI(() => {
232
+ 'worklet';
233
+ const console = {
234
+ debug: runOnJS(capturableConsole.debug),
235
+ log: runOnJS(capturableConsole.log),
236
+ warn: runOnJS(capturableConsole.warn),
237
+ error: runOnJS(capturableConsole.error),
238
+ info: runOnJS(capturableConsole.info),
239
+ };
240
+ _setGlobalConsole(console);
241
+ if (global.performance == null) {
242
+ global.performance = {
243
+ now: global._chronoNow,
244
+ }; // due to conflict with lib.dom.d.ts -> Performance
245
+ }
246
+ })();
285
247
  }
286
248
  let featuresConfig = {
287
249
  enableLayoutAnimations: false,
@@ -301,3 +263,11 @@ export function enableLayoutAnimations(flag, isCallByUser = true) {
301
263
  NativeReanimatedModule.enableLayoutAnimations(flag);
302
264
  }
303
265
  }
266
+ export function configureProps(uiProps, nativeProps) {
267
+ if (!nativeShouldBeMock()) {
268
+ NativeReanimatedModule.configureProps(uiProps, nativeProps);
269
+ }
270
+ }
271
+ export function jestResetJsReanimatedModule() {
272
+ NativeReanimatedModule.jestResetModule();
273
+ }
@@ -1,4 +1,4 @@
1
- import { AnimatedStyle, StyleProps, WorkletFunction } from './commonTypes';
1
+ import { AnimatedStyle, StyleProps } from './commonTypes';
2
2
  import { ReanimatedConsole } from './core';
3
3
  import { MeasuredDimensions } from './NativeMethods';
4
4
  import { NativeReanimated } from './NativeReanimated/NativeReanimated';
@@ -27,9 +27,11 @@ declare global {
27
27
  animated: boolean
28
28
  ) => void;
29
29
  const _chronoNow: () => number;
30
+ const ReanimatedDataMock: {
31
+ now: () => number;
32
+ };
30
33
  namespace NodeJS {
31
34
  interface Global {
32
- __reanimatedWorkletInit: (worklet: WorkletFunction) => void;
33
35
  _setGlobalConsole: (console?: ReanimatedConsole) => void;
34
36
  _log: (s: string) => void;
35
37
  _setGestureState: () => void;
@@ -50,6 +52,9 @@ declare global {
50
52
  yogaValues: unknown
51
53
  ): void;
52
54
  };
55
+ ReanimatedDataMock: {
56
+ now: () => number;
57
+ };
53
58
  }
54
59
  }
55
60
  }
@@ -6,3 +6,4 @@ export { useAnimatedReaction, } from './useAnimatedReaction';
6
6
  export { useAnimatedRef } from './useAnimatedRef';
7
7
  export { useAnimatedScrollHandler, } from './useAnimatedScrollHandler';
8
8
  export { useDerivedValue } from './useDerivedValue';
9
+ export { useAnimatedSensor, SensorType } from './useAnimatedSensor';