react-native-reanimated 2.8.0 → 2.10.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 (224) hide show
  1. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +4 -4
  2. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +38 -0
  3. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +23 -0
  4. package/Common/cpp/Tools/RuntimeDecorator.cpp +17 -11
  5. package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +8 -0
  6. package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +8 -0
  7. package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +5 -0
  8. package/RNReanimated.podspec +22 -3
  9. package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  10. package/android/.gradle/7.2/executionHistory/executionHistory.bin +0 -0
  11. package/android/.gradle/7.2/executionHistory/executionHistory.lock +0 -0
  12. package/android/.gradle/7.2/fileHashes/fileHashes.bin +0 -0
  13. package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
  14. package/android/.gradle/7.2/fileHashes/resourceHashesCache.bin +0 -0
  15. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  16. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  17. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  18. package/android/.gradle/checksums/checksums.lock +0 -0
  19. package/android/.gradle/checksums/md5-checksums.bin +0 -0
  20. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  21. package/android/CMakeLists.txt +216 -84
  22. package/android/build.gradle +255 -229
  23. package/android/react-native-reanimated-66-hermes.aar +0 -0
  24. package/android/react-native-reanimated-66-jsc.aar +0 -0
  25. package/android/react-native-reanimated-67-hermes.aar +0 -0
  26. package/android/react-native-reanimated-67-jsc.aar +0 -0
  27. package/android/react-native-reanimated-68-hermes.aar +0 -0
  28. package/android/react-native-reanimated-68-jsc.aar +0 -0
  29. package/android/react-native-reanimated-69-hermes.aar +0 -0
  30. package/android/react-native-reanimated-69-jsc.aar +0 -0
  31. package/android/react-native-reanimated-70-hermes.aar +0 -0
  32. package/android/react-native-reanimated-70-jsc.aar +0 -0
  33. package/{lib/types/lib/reanimated2/platform-specific/RNRenderer.web.d.ts → android/rnVersionPatch/69/.gitkeep} +0 -0
  34. package/android/rnVersionPatch/70/.gitkeep +0 -0
  35. package/android/src/main/cpp/NativeProxy.cpp +56 -11
  36. package/android/src/main/cpp/OnLoad.cpp +1 -0
  37. package/android/src/main/cpp/headers/NativeProxy.h +29 -0
  38. package/android/src/main/java/com/swmansion/reanimated/NativeProxy.java +25 -0
  39. package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +3 -1
  40. package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +165 -0
  41. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +19 -16
  42. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +5 -1
  43. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +24 -1
  44. package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorType.java +7 -5
  45. package/ios/REANodesManager.m +31 -8
  46. package/ios/keyboardObserver/REAKeyboardEventObserver.h +17 -0
  47. package/ios/keyboardObserver/REAKeyboardEventObserver.m +198 -0
  48. package/ios/native/NativeProxy.mm +20 -1
  49. package/ios/native/REAInitializer.mm +10 -4
  50. package/ios/sensor/ReanimatedSensor.m +27 -18
  51. package/lib/Animated.js +8 -21
  52. package/lib/index.js +12 -20
  53. package/lib/index.web.js +4 -0
  54. package/lib/reanimated2/Colors.js +1 -1
  55. package/lib/reanimated2/NativeMethods.js +3 -0
  56. package/lib/reanimated2/NativeReanimated/NativeReanimated.js +7 -1
  57. package/lib/reanimated2/animation/sequence.js +0 -3
  58. package/lib/reanimated2/animation/util.js +4 -1
  59. package/lib/reanimated2/commonTypes.js +8 -1
  60. package/lib/reanimated2/component/FlatList.js +8 -8
  61. package/lib/reanimated2/component/Image.js +4 -0
  62. package/lib/reanimated2/component/ScrollView.js +4 -0
  63. package/lib/reanimated2/component/Text.js +4 -0
  64. package/lib/reanimated2/component/View.js +4 -0
  65. package/lib/reanimated2/core.js +5 -9
  66. package/lib/reanimated2/frameCallback/FrameCallbackRegistryJS.js +32 -0
  67. package/lib/reanimated2/frameCallback/FrameCallbackRegistryUI.js +47 -0
  68. package/lib/reanimated2/globals.d.ts +3 -0
  69. package/lib/reanimated2/hook/index.js +2 -0
  70. package/lib/reanimated2/hook/useAnimatedKeyboard.js +31 -0
  71. package/lib/reanimated2/hook/useAnimatedSensor.js +3 -3
  72. package/lib/reanimated2/hook/useFrameCallback.js +23 -0
  73. package/lib/reanimated2/hook/utils.js +0 -5
  74. package/lib/reanimated2/jestUtils.js +11 -3
  75. package/lib/reanimated2/js-reanimated/JSReanimated.js +7 -0
  76. package/lib/reanimated2/js-reanimated/global.js +36 -0
  77. package/lib/reanimated2/js-reanimated/index.js +0 -24
  78. package/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.js +1 -1
  79. package/lib/reanimated2/mock.js +6 -0
  80. package/lib/types/Animated.d.ts +8 -0
  81. package/lib/types/{lib/ConfigHelper.d.ts → ConfigHelper.d.ts} +0 -0
  82. package/lib/types/{lib/ReanimatedEventEmitter.d.ts → ReanimatedEventEmitter.d.ts} +0 -0
  83. package/lib/types/{lib/ReanimatedModule.d.ts → ReanimatedModule.d.ts} +0 -0
  84. package/lib/types/{lib/ReanimatedModule.macos.d.ts → ReanimatedModule.macos.d.ts} +0 -0
  85. package/lib/types/{lib/ReanimatedModule.native.d.ts → ReanimatedModule.native.d.ts} +0 -0
  86. package/lib/types/{lib/ReanimatedModule.windows.d.ts → ReanimatedModule.windows.d.ts} +0 -0
  87. package/lib/types/{lib/ReanimatedModuleCompat.d.ts → ReanimatedModuleCompat.d.ts} +0 -0
  88. package/lib/types/{lib/createAnimatedComponent.d.ts → createAnimatedComponent.d.ts} +0 -0
  89. package/lib/types/index.d.ts +4 -0
  90. package/lib/types/index.web.d.ts +3 -0
  91. package/lib/types/{lib/reanimated2 → reanimated2}/Bezier.d.ts +0 -0
  92. package/lib/types/{lib/reanimated2 → reanimated2}/Colors.d.ts +0 -0
  93. package/lib/types/{lib/reanimated2 → reanimated2}/Easing.d.ts +0 -0
  94. package/lib/types/{lib/reanimated2 → reanimated2}/NativeMethods.d.ts +0 -0
  95. package/lib/types/{lib/reanimated2 → reanimated2}/NativeReanimated/NativeReanimated.d.ts +3 -1
  96. package/lib/types/{lib/reanimated2 → reanimated2}/NativeReanimated/index.d.ts +0 -0
  97. package/lib/types/{lib/reanimated2 → reanimated2}/PlatformChecker.d.ts +0 -0
  98. package/lib/types/{lib/reanimated2 → reanimated2}/PropAdapters.d.ts +0 -0
  99. package/lib/types/{lib/reanimated2 → reanimated2}/UpdateProps.d.ts +0 -0
  100. package/lib/types/{lib/reanimated2 → reanimated2}/ViewDescriptorsSet.d.ts +0 -0
  101. package/lib/types/{lib/reanimated2 → reanimated2}/WorkletEventHandler.d.ts +0 -0
  102. package/lib/types/{lib/reanimated2 → reanimated2}/__mocks__/MutableValue.d.ts +0 -0
  103. package/lib/types/{lib/reanimated2 → reanimated2}/__mocks__/NativeReanimated.d.ts +0 -0
  104. package/lib/types/{lib/reanimated2 → reanimated2}/__mocks__/NativeReanimated.native.d.ts +0 -0
  105. package/lib/types/{lib/reanimated2 → reanimated2}/animation/commonTypes.d.ts +0 -0
  106. package/lib/types/{lib/reanimated2 → reanimated2}/animation/decay.d.ts +0 -0
  107. package/lib/types/{lib/reanimated2 → reanimated2}/animation/delay.d.ts +0 -0
  108. package/lib/types/{lib/reanimated2 → reanimated2}/animation/index.d.ts +0 -0
  109. package/lib/types/{lib/reanimated2 → reanimated2}/animation/repeat.d.ts +0 -0
  110. package/lib/types/{lib/reanimated2 → reanimated2}/animation/sequence.d.ts +0 -0
  111. package/lib/types/{lib/reanimated2 → reanimated2}/animation/spring.d.ts +0 -0
  112. package/lib/types/{lib/reanimated2 → reanimated2}/animation/styleAnimation.d.ts +0 -0
  113. package/lib/types/{lib/reanimated2 → reanimated2}/animation/timing.d.ts +0 -0
  114. package/lib/types/{lib/reanimated2 → reanimated2}/animation/util.d.ts +0 -0
  115. package/lib/types/{lib/reanimated2 → reanimated2}/commonTypes.d.ts +12 -0
  116. package/lib/types/{lib/reanimated2 → reanimated2}/component/FlatList.d.ts +2 -2
  117. package/lib/types/reanimated2/component/Image.d.ts +3 -0
  118. package/lib/types/reanimated2/component/ScrollView.d.ts +3 -0
  119. package/lib/types/reanimated2/component/Text.d.ts +3 -0
  120. package/lib/types/reanimated2/component/View.d.ts +3 -0
  121. package/lib/types/{lib/reanimated2 → reanimated2}/core.d.ts +0 -0
  122. package/lib/types/reanimated2/frameCallback/FrameCallbackRegistryJS.d.ts +7 -0
  123. package/lib/types/reanimated2/frameCallback/FrameCallbackRegistryUI.d.ts +10 -0
  124. package/lib/types/{lib/reanimated2 → reanimated2}/hook/Hooks.d.ts +0 -0
  125. package/lib/types/{lib/reanimated2 → reanimated2}/hook/commonTypes.d.ts +0 -0
  126. package/lib/types/{lib/reanimated2 → reanimated2}/hook/index.d.ts +3 -0
  127. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedGestureHandler.d.ts +0 -0
  128. package/lib/types/reanimated2/hook/useAnimatedKeyboard.d.ts +2 -0
  129. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedReaction.d.ts +0 -0
  130. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedRef.d.ts +0 -0
  131. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedScrollHandler.d.ts +0 -0
  132. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedSensor.d.ts +1 -1
  133. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useAnimatedStyle.d.ts +0 -0
  134. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useDerivedValue.d.ts +0 -0
  135. package/lib/types/reanimated2/hook/useFrameCallback.d.ts +6 -0
  136. package/lib/types/{lib/reanimated2 → reanimated2}/hook/useSharedValue.d.ts +0 -0
  137. package/lib/types/{lib/reanimated2 → reanimated2}/hook/utils.d.ts +0 -0
  138. package/lib/types/{lib/reanimated2 → reanimated2}/index.d.ts +0 -0
  139. package/lib/types/{lib/reanimated2 → reanimated2}/interpolateColor.d.ts +0 -0
  140. package/lib/types/{lib/reanimated2 → reanimated2}/interpolation.d.ts +0 -0
  141. package/lib/types/{lib/reanimated2 → reanimated2}/jestUtils.d.ts +1 -1
  142. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/JSReanimated.d.ts +3 -1
  143. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/Mapper.d.ts +0 -0
  144. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/MapperRegistry.d.ts +0 -0
  145. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/MutableValue.d.ts +0 -0
  146. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/commonTypes.d.ts +0 -0
  147. package/lib/types/reanimated2/js-reanimated/global.d.ts +2 -0
  148. package/lib/types/{lib/reanimated2 → reanimated2}/js-reanimated/index.d.ts +0 -0
  149. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/LayoutAnimationRepository.d.ts +0 -0
  150. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/BaseAnimationBuilder.d.ts +0 -0
  151. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +0 -0
  152. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/Keyframe.d.ts +0 -0
  153. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/commonTypes.d.ts +0 -0
  154. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/animationBuilder/index.d.ts +0 -0
  155. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Bounce.d.ts +0 -0
  156. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Default.d.ts +0 -0
  157. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Fade.d.ts +0 -0
  158. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Flip.d.ts +0 -0
  159. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Lightspeed.d.ts +0 -0
  160. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Pinwheel.d.ts +0 -0
  161. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Roll.d.ts +0 -0
  162. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Rotate.d.ts +0 -0
  163. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Slide.d.ts +0 -0
  164. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Stretch.d.ts +0 -0
  165. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/Zoom.d.ts +0 -0
  166. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultAnimations/index.d.ts +0 -0
  167. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +0 -0
  168. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +0 -0
  169. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/FadingTransition.d.ts +0 -0
  170. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +0 -0
  171. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/LinearTransition.d.ts +0 -0
  172. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +0 -0
  173. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/defaultTransitions/index.d.ts +0 -0
  174. package/lib/types/{lib/reanimated2 → reanimated2}/layoutReanimation/index.d.ts +0 -0
  175. package/lib/types/{lib/reanimated2 → reanimated2}/mock.d.ts +6 -0
  176. package/lib/types/{lib/reanimated2 → reanimated2}/platform-specific/RNRenderer.d.ts +0 -0
  177. package/lib/types/reanimated2/platform-specific/RNRenderer.web.d.ts +0 -0
  178. package/lib/types/{lib/reanimated2 → reanimated2}/utils.d.ts +0 -0
  179. package/lib/types/{lib/setAndForwardRef.d.ts → setAndForwardRef.d.ts} +0 -0
  180. package/mock.js +1 -0
  181. package/package.json +15 -10
  182. package/plugin.js +7 -6
  183. package/react-native-reanimated.d.ts +56 -8
  184. package/src/Animated.ts +13 -0
  185. package/src/index.ts +15 -0
  186. package/src/index.web.ts +5 -0
  187. package/src/reanimated2/Colors.ts +1 -1
  188. package/src/reanimated2/NativeMethods.ts +5 -0
  189. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +10 -1
  190. package/src/reanimated2/animation/sequence.ts +0 -5
  191. package/src/reanimated2/animation/util.ts +8 -1
  192. package/src/reanimated2/commonTypes.ts +15 -0
  193. package/src/reanimated2/component/FlatList.tsx +32 -25
  194. package/src/reanimated2/component/Image.ts +6 -0
  195. package/src/reanimated2/component/ScrollView.ts +6 -0
  196. package/src/reanimated2/component/Text.ts +6 -0
  197. package/src/reanimated2/component/View.ts +6 -0
  198. package/src/reanimated2/core.ts +8 -13
  199. package/src/reanimated2/frameCallback/FrameCallbackRegistryJS.ts +43 -0
  200. package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +64 -0
  201. package/src/reanimated2/globals.d.ts +3 -0
  202. package/src/reanimated2/hook/index.ts +3 -0
  203. package/src/reanimated2/hook/useAnimatedKeyboard.ts +35 -0
  204. package/src/reanimated2/hook/useAnimatedSensor.ts +5 -5
  205. package/src/reanimated2/hook/useFrameCallback.ts +39 -0
  206. package/src/reanimated2/hook/utils.ts +0 -6
  207. package/src/reanimated2/jestUtils.ts +11 -3
  208. package/src/reanimated2/js-reanimated/JSReanimated.ts +16 -1
  209. package/src/reanimated2/js-reanimated/global.ts +45 -0
  210. package/src/reanimated2/js-reanimated/index.ts +0 -31
  211. package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +1 -1
  212. package/src/reanimated2/mock.ts +6 -0
  213. package/android/react-native-reanimated-64-hermes.aar +0 -0
  214. package/android/react-native-reanimated-64-jsc.aar +0 -0
  215. package/android/react-native-reanimated-65-hermes.aar +0 -0
  216. package/android/react-native-reanimated-65-jsc.aar +0 -0
  217. package/lib/reanimated2/component/WrappedComponents.js +0 -9
  218. package/lib/reanimated2/component/index.js +0 -4
  219. package/lib/types/lib/reanimated2/component/WrappedComponents.d.ts +0 -8
  220. package/lib/types/lib/reanimated2/component/index.d.ts +0 -9
  221. package/lib/types/react-native-reanimated-tests.d.ts +0 -1
  222. package/src/Animated.js +0 -22
  223. package/src/reanimated2/component/WrappedComponents.ts +0 -11
  224. package/src/reanimated2/component/index.ts +0 -9
@@ -0,0 +1,47 @@
1
+ import { runOnUI } from '../core';
2
+ export const prepareUIRegistry = runOnUI(() => {
3
+ 'worklet';
4
+ const frameCallbackRegistry = {
5
+ frameCallbackRegistry: new Map(),
6
+ frameCallbackActive: new Set(),
7
+ isFrameCallbackRunning: false,
8
+ runCallbacks() {
9
+ const loop = () => {
10
+ this.frameCallbackActive.forEach((key) => {
11
+ const callback = this.frameCallbackRegistry.get(key);
12
+ callback();
13
+ });
14
+ if (this.frameCallbackActive.size > 0) {
15
+ requestAnimationFrame(loop);
16
+ }
17
+ else {
18
+ this.isFrameCallbackRunning = false;
19
+ }
20
+ };
21
+ if (!this.isFrameCallbackRunning) {
22
+ requestAnimationFrame(loop);
23
+ this.isFrameCallbackRunning = true;
24
+ }
25
+ },
26
+ registerFrameCallback(callback, callbackId) {
27
+ this.frameCallbackRegistry.set(callbackId, callback);
28
+ },
29
+ unregisterFrameCallback(frameCallbackId) {
30
+ this.manageStateFrameCallback(frameCallbackId, false);
31
+ this.frameCallbackRegistry.delete(frameCallbackId);
32
+ },
33
+ manageStateFrameCallback(frameCallbackId, state) {
34
+ if (frameCallbackId === -1) {
35
+ return;
36
+ }
37
+ if (state) {
38
+ this.frameCallbackActive.add(frameCallbackId);
39
+ this.runCallbacks();
40
+ }
41
+ else {
42
+ this.frameCallbackActive.delete(frameCallbackId);
43
+ }
44
+ },
45
+ };
46
+ global._frameCallbackRegistry = frameCallbackRegistry;
47
+ });
@@ -1,5 +1,6 @@
1
1
  import { AnimatedStyle, StyleProps } from './commonTypes';
2
2
  import { ReanimatedConsole } from './core';
3
+ import FrameCallbackRegistryUI from './frameCallback/FrameCallbackRegistryUI';
3
4
  import { MeasuredDimensions } from './NativeMethods';
4
5
  import { NativeReanimated } from './NativeReanimated/NativeReanimated';
5
6
  declare global {
@@ -30,6 +31,7 @@ declare global {
30
31
  const ReanimatedDataMock: {
31
32
  now: () => number;
32
33
  };
34
+ const _frameCallbackRegistry: FrameCallbackRegistryUI;
33
35
  namespace NodeJS {
34
36
  interface Global {
35
37
  _setGlobalConsole: (console?: ReanimatedConsole) => void;
@@ -55,6 +57,7 @@ declare global {
55
57
  ReanimatedDataMock: {
56
58
  now: () => number;
57
59
  };
60
+ _frameCallbackRegistry: FrameCallbackRegistryUI;
58
61
  }
59
62
  }
60
63
  }
@@ -7,3 +7,5 @@ export { useAnimatedRef } from './useAnimatedRef';
7
7
  export { useAnimatedScrollHandler, } from './useAnimatedScrollHandler';
8
8
  export { useDerivedValue } from './useDerivedValue';
9
9
  export { useAnimatedSensor, SensorType } from './useAnimatedSensor';
10
+ export { useFrameCallback } from './useFrameCallback';
11
+ export { useAnimatedKeyboard } from './useAnimatedKeyboard';
@@ -0,0 +1,31 @@
1
+ import { useEffect, useRef } from 'react';
2
+ import NativeReanimated from '../NativeReanimated';
3
+ import { makeMutable } from '../core';
4
+ import { KeyboardState } from '../commonTypes';
5
+ export function useAnimatedKeyboard() {
6
+ const ref = useRef(null);
7
+ const listenerId = useRef(-1);
8
+ const isSubscribed = useRef(false);
9
+ if (ref.current === null) {
10
+ const keyboardEventData = {
11
+ state: makeMutable(KeyboardState.UNKNOWN),
12
+ height: makeMutable(0),
13
+ };
14
+ listenerId.current =
15
+ NativeReanimated.subscribeForKeyboardEvents(keyboardEventData);
16
+ ref.current = keyboardEventData;
17
+ isSubscribed.current = true;
18
+ }
19
+ useEffect(() => {
20
+ if (isSubscribed.current === false && ref.current !== null) {
21
+ // subscribe again after Fast Refresh
22
+ listenerId.current = NativeReanimated.subscribeForKeyboardEvents(ref.current);
23
+ isSubscribed.current = true;
24
+ }
25
+ return () => {
26
+ NativeReanimated.unsubscribeFromKeyboardEvents(listenerId.current);
27
+ isSubscribed.current = false;
28
+ };
29
+ }, []);
30
+ return ref.current;
31
+ }
@@ -21,7 +21,7 @@ export function useAnimatedSensor(sensorType, userConfig) {
21
21
  },
22
22
  });
23
23
  if (ref.current.sensor === null) {
24
- ref.current.config = Object.assign({ interval: 10 }, userConfig);
24
+ ref.current.config = Object.assign({ interval: 'auto' }, userConfig);
25
25
  let sensorData;
26
26
  if (sensorType === SensorType.ROTATION) {
27
27
  sensorData = {
@@ -44,8 +44,8 @@ export function useAnimatedSensor(sensorType, userConfig) {
44
44
  ref.current.sensor = makeMutable(sensorData);
45
45
  }
46
46
  useEffect(() => {
47
- ref.current.config = Object.assign({ interval: 10 }, userConfig);
48
- const id = NativeReanimated.registerSensor(sensorType, ref.current.config.interval, ref.current.sensor);
47
+ ref.current.config = Object.assign({ interval: 'auto' }, userConfig);
48
+ const id = NativeReanimated.registerSensor(sensorType, ref.current.config.interval === 'auto' ? -1 : ref.current.config.interval, ref.current.sensor);
49
49
  if (id !== -1) {
50
50
  // if sensor is available
51
51
  ref.current.unregister = () => NativeReanimated.unregisterSensor(id);
@@ -0,0 +1,23 @@
1
+ import { useEffect, useRef } from 'react';
2
+ import FrameCallbackRegistryJS from '../frameCallback/FrameCallbackRegistryJS';
3
+ const frameCallbackRegistry = new FrameCallbackRegistryJS();
4
+ export function useFrameCallback(callback, autostart = true) {
5
+ const ref = useRef({
6
+ setActive: (isActive) => {
7
+ frameCallbackRegistry.manageStateFrameCallback(ref.current.callbackId, isActive);
8
+ ref.current.isActive = isActive;
9
+ },
10
+ isActive: autostart,
11
+ callbackId: -1,
12
+ });
13
+ useEffect(() => {
14
+ ref.current.callbackId =
15
+ frameCallbackRegistry.registerFrameCallback(callback);
16
+ ref.current.setActive(ref.current.isActive);
17
+ return () => {
18
+ frameCallbackRegistry.unregisterFrameCallback(ref.current.callbackId);
19
+ ref.current.callbackId = -1;
20
+ };
21
+ }, [callback, autostart]);
22
+ return ref.current;
23
+ }
@@ -12,11 +12,6 @@ export function useEvent(handler, eventNames = [], rebuild = false) {
12
12
  else if (rebuild) {
13
13
  initRef.current.updateWorklet(handler);
14
14
  }
15
- useEffect(() => {
16
- return () => {
17
- initRef.current = null;
18
- };
19
- }, []);
20
15
  return initRef;
21
16
  }
22
17
  export function useHandler(handlers, dependencies) {
@@ -127,9 +127,9 @@ const tickTravel = () => {
127
127
  currentTimestamp += frameTime;
128
128
  jest.advanceTimersByTime(frameTime);
129
129
  };
130
- export const withReanimatedTimer = (animatonTest) => {
130
+ export const withReanimatedTimer = (animationTest) => {
131
131
  beforeTest();
132
- animatonTest();
132
+ animationTest();
133
133
  afterTest();
134
134
  };
135
135
  export const advanceAnimationByTime = (time = frameTime) => {
@@ -145,7 +145,15 @@ export const advanceAnimationByFrame = (count) => {
145
145
  jest.advanceTimersByTime(frameTime);
146
146
  };
147
147
  export const setUpTests = (userConfig = {}) => {
148
- const expect = require('expect');
148
+ let expect;
149
+ try {
150
+ expect = require('expect');
151
+ }
152
+ catch (_) {
153
+ // for Jest in version 28+
154
+ const { expect: expectModule } = require('@jest/globals');
155
+ expect = expectModule;
156
+ }
149
157
  require('setimmediate');
150
158
  frameTime = Math.round(1000 / config.fps);
151
159
  config = Object.assign(Object.assign({}, config), userConfig);
@@ -96,4 +96,11 @@ export default class JSReanimated extends NativeReanimated {
96
96
  throw Error('This method can be only use in Jest testing.');
97
97
  }
98
98
  }
99
+ subscribeForKeyboardEvents(_) {
100
+ console.warn('[Reanimated] useAnimatedKeyboard is not available on web yet.');
101
+ return -1;
102
+ }
103
+ unsubscribeFromKeyboardEvents(_) {
104
+ // noop
105
+ }
99
106
  }
@@ -0,0 +1,36 @@
1
+ // In order to keep bundle size down, we treat this file as a polyfill for Web.
2
+ import { shouldBeUseWeb } from '../PlatformChecker';
3
+ const initializeGlobalsForWeb = () => {
4
+ if (shouldBeUseWeb()) {
5
+ global._frameTimestamp = null;
6
+ global._setGlobalConsole = (_val) => {
7
+ // noop
8
+ };
9
+ global._measure = () => {
10
+ console.warn("[Reanimated] You can't use `measure` with Chrome Debugger or with web version");
11
+ return {
12
+ x: 0,
13
+ y: 0,
14
+ width: 0,
15
+ height: 0,
16
+ pageX: 0,
17
+ pageY: 0,
18
+ };
19
+ };
20
+ global._scrollTo = () => {
21
+ console.warn("[Reanimated] You can't use `scrollTo` with Chrome Debugger or with web version");
22
+ };
23
+ global._setGestureState = () => {
24
+ console.warn("[Reanimated] You can't use `setGestureState` with Chrome Debugger or with web version");
25
+ };
26
+ }
27
+ return true;
28
+ };
29
+ /*
30
+ If a file doesn't export anything, tree shaking doesn't pack
31
+ it into the JS bundle. In effect, the code inside of this file
32
+ will never execute. That is why we wrapped initialization code
33
+ into a function, and we call this one during creating
34
+ the module export object.
35
+ */
36
+ export default initializeGlobalsForWeb();
@@ -1,29 +1,5 @@
1
1
  import JSReanimated from './JSReanimated';
2
- import { shouldBeUseWeb } from '../PlatformChecker';
3
2
  const reanimatedJS = new JSReanimated();
4
- if (shouldBeUseWeb()) {
5
- global._frameTimestamp = null;
6
- global._setGlobalConsole = (_val) => {
7
- // noop
8
- };
9
- global._measure = () => {
10
- console.warn("[Reanimated] You can't use `measure` with Chrome Debugger or with web version");
11
- return {
12
- x: 0,
13
- y: 0,
14
- width: 0,
15
- height: 0,
16
- pageX: 0,
17
- pageY: 0,
18
- };
19
- };
20
- global._scrollTo = () => {
21
- console.warn("[Reanimated] You can't use `scrollTo` with Chrome Debugger or with web version");
22
- };
23
- global._setGestureState = () => {
24
- console.warn("[Reanimated] You can't use `setGestureState` with Chrome Debugger or with web version");
25
- };
26
- }
27
3
  export const _updatePropsJS = (updates, viewRef) => {
28
4
  if (viewRef._component) {
29
5
  const component = viewRef._component;
@@ -5,7 +5,7 @@ import { ColorProperties } from '../UpdateProps';
5
5
  import { processColor } from '../Colors';
6
6
  runOnUI(() => {
7
7
  'worklet';
8
- const configs = {};
8
+ const configs = Object.create(null);
9
9
  const enteringAnimationForTag = {};
10
10
  global.LayoutAnimationRepository = {
11
11
  configs,
@@ -64,6 +64,12 @@ const ReanimatedV2 = {
64
64
  out: ID,
65
65
  inOut: ID,
66
66
  },
67
+ Extrapolation: {
68
+ EXTEND: 'extend',
69
+ CLAMP: 'clamp',
70
+ IDENTITY: 'identity',
71
+ },
67
72
  runOnJS: (fn) => fn,
73
+ runOnUI: (fn) => fn,
68
74
  };
69
75
  module.exports = Object.assign({}, ReanimatedV2);
@@ -0,0 +1,8 @@
1
+ export { default as createAnimatedComponent } from './createAnimatedComponent';
2
+ export { addWhitelistedNativeProps, addWhitelistedUIProps, } from './ConfigHelper';
3
+ export { default as Text } from './reanimated2/component/Text';
4
+ export { default as View } from './reanimated2/component/View';
5
+ export { default as ScrollView } from './reanimated2/component/ScrollView';
6
+ export { default as Image } from './reanimated2/component/Image';
7
+ export { default as FlatList } from './reanimated2/component/FlatList';
8
+ export * from './reanimated1';
@@ -0,0 +1,4 @@
1
+ import * as Animated from './Animated';
2
+ export * from './reanimated1';
3
+ export * from './reanimated2';
4
+ export default Animated;
@@ -0,0 +1,3 @@
1
+ import './reanimated2/js-reanimated/global';
2
+ export * from './reanimated2';
3
+ export * as default from './Animated';
@@ -1,4 +1,4 @@
1
- import { SharedValue, SensorValue3D, SensorValueRotation } from '../commonTypes';
1
+ import { SharedValue, SensorValue3D, SensorValueRotation, AnimatedKeyboardInfo } from '../commonTypes';
2
2
  import { Descriptor } from '../hook/commonTypes';
3
3
  export declare class NativeReanimated {
4
4
  native: boolean;
@@ -17,4 +17,6 @@ export declare class NativeReanimated {
17
17
  getViewProp<T>(viewTag: string, propName: string, callback?: (result: T) => void): Promise<T>;
18
18
  enableLayoutAnimations(flag: boolean): void;
19
19
  configureProps(uiProps: string[], nativeProps: string[]): void;
20
+ subscribeForKeyboardEvents(keyboardEventData: AnimatedKeyboardInfo): number;
21
+ unsubscribeFromKeyboardEvents(listenerId: number): void;
20
22
  }
@@ -77,3 +77,15 @@ export declare type ValueRotation = {
77
77
  roll: number;
78
78
  };
79
79
  export declare type SensorValueRotation = SharedValue<ValueRotation>;
80
+ export declare type ShadowNodeWrapper = object;
81
+ export declare enum KeyboardState {
82
+ UNKNOWN = 0,
83
+ OPENING = 1,
84
+ OPEN = 2,
85
+ CLOSING = 3,
86
+ CLOSED = 4
87
+ }
88
+ export declare type AnimatedKeyboardInfo = {
89
+ height: SharedValue<number>;
90
+ state: SharedValue<KeyboardState>;
91
+ };
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import { FlatListProps } from 'react-native';
3
3
  import { ILayoutAnimationBuilder } from '../layoutReanimation/animationBuilder/commonTypes';
4
- export interface ReanimatedFlatlistProps<ItemT> extends FlatListProps<ItemT> {
4
+ export interface ReanimatedFlatListProps<ItemT> extends FlatListProps<ItemT> {
5
5
  itemLayoutAnimation?: ILayoutAnimationBuilder;
6
6
  }
7
- declare type ReanimatedFlatListFC<T = any> = React.FC<ReanimatedFlatlistProps<T>>;
7
+ declare type ReanimatedFlatListFC<T = any> = React.FC<ReanimatedFlatListProps<T>>;
8
8
  declare const ReanimatedFlatlist: ReanimatedFlatListFC;
9
9
  export default ReanimatedFlatlist;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const AnimatedImage: import("react").ComponentType<import("../../createAnimatedComponent").AnimatedComponentProps<import("../../createAnimatedComponent").InitialComponentProps>>;
3
+ export default AnimatedImage;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const AnimatedScrollView: import("react").ComponentType<import("../../createAnimatedComponent").AnimatedComponentProps<import("../../createAnimatedComponent").InitialComponentProps>>;
3
+ export default AnimatedScrollView;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const AnimatedText: import("react").ComponentType<import("../../createAnimatedComponent").AnimatedComponentProps<import("../../createAnimatedComponent").InitialComponentProps>>;
3
+ export default AnimatedText;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const AnimatedView: import("react").ComponentType<import("../../createAnimatedComponent").AnimatedComponentProps<import("../../createAnimatedComponent").InitialComponentProps>>;
3
+ export default AnimatedView;
@@ -0,0 +1,7 @@
1
+ export default class FrameCallbackRegistryJS {
2
+ private nextCallbackId;
3
+ constructor();
4
+ registerFrameCallback(callback: () => void): number;
5
+ unregisterFrameCallback(frameCallbackId: number): void;
6
+ manageStateFrameCallback(frameCallbackId: number, state: boolean): void;
7
+ }
@@ -0,0 +1,10 @@
1
+ export default interface FrameCallbackRegistryUI {
2
+ frameCallbackRegistry: Map<number, () => void>;
3
+ frameCallbackActive: Set<number>;
4
+ isFrameCallbackRunning: boolean;
5
+ runCallbacks: () => void;
6
+ registerFrameCallback: (callback: () => void, callbackId: number) => void;
7
+ unregisterFrameCallback: (frameCallbackId: number) => void;
8
+ manageStateFrameCallback: (frameCallbackId: number, state: boolean) => void;
9
+ }
10
+ export declare const prepareUIRegistry: () => void;
@@ -8,3 +8,6 @@ export { useAnimatedRef } from './useAnimatedRef';
8
8
  export { useAnimatedScrollHandler, ScrollHandler, ScrollHandlers, } from './useAnimatedScrollHandler';
9
9
  export { useDerivedValue, DerivedValue } from './useDerivedValue';
10
10
  export { useAnimatedSensor, SensorType } from './useAnimatedSensor';
11
+ export { useFrameCallback } from './useFrameCallback';
12
+ export type { FrameCallback } from './useFrameCallback';
13
+ export { useAnimatedKeyboard } from './useAnimatedKeyboard';
@@ -0,0 +1,2 @@
1
+ import { AnimatedKeyboardInfo } from '../commonTypes';
2
+ export declare function useAnimatedKeyboard(): AnimatedKeyboardInfo;
@@ -7,7 +7,7 @@ export declare enum SensorType {
7
7
  ROTATION = 5
8
8
  }
9
9
  export declare type SensorConfig = {
10
- interval: number;
10
+ interval: number | 'auto';
11
11
  };
12
12
  export declare type AnimatedSensor = {
13
13
  sensor: SensorValue3D | SensorValueRotation | null;
@@ -0,0 +1,6 @@
1
+ export declare type FrameCallback = {
2
+ setActive: (isActive: boolean) => void;
3
+ isActive: boolean;
4
+ callbackId: number;
5
+ };
6
+ export declare function useFrameCallback(callback: () => void, autostart?: boolean): FrameCallback;
@@ -5,7 +5,7 @@ declare global {
5
5
  }
6
6
  }
7
7
  }
8
- export declare const withReanimatedTimer: (animatonTest: any) => void;
8
+ export declare const withReanimatedTimer: (animationTest: any) => void;
9
9
  export declare const advanceAnimationByTime: (time?: number) => void;
10
10
  export declare const advanceAnimationByFrame: (count: any) => void;
11
11
  export declare const setUpTests: (userConfig?: {}) => void;
@@ -1,7 +1,7 @@
1
1
  import MapperRegistry from './MapperRegistry';
2
2
  import MutableValue from './MutableValue';
3
3
  import { NativeReanimated } from '../NativeReanimated/NativeReanimated';
4
- import { Timestamp, NestedObjectValues } from '../commonTypes';
4
+ import { Timestamp, NestedObjectValues, AnimatedKeyboardInfo } from '../commonTypes';
5
5
  export default class JSReanimated extends NativeReanimated {
6
6
  _valueSetter?: <T>(value: T) => void;
7
7
  _renderRequested: boolean;
@@ -27,4 +27,6 @@ export default class JSReanimated extends NativeReanimated {
27
27
  registerSensor(): number;
28
28
  unregisterSensor(): void;
29
29
  jestResetModule(): void;
30
+ subscribeForKeyboardEvents(_: AnimatedKeyboardInfo): number;
31
+ unsubscribeFromKeyboardEvents(_: number): void;
30
32
  }
@@ -0,0 +1,2 @@
1
+ declare const _default: boolean;
2
+ export default _default;