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
@@ -51,5 +51,11 @@ declare const ReanimatedV2: {
51
51
  out: (t: any) => any;
52
52
  inOut: (t: any) => any;
53
53
  };
54
+ Extrapolation: {
55
+ EXTEND: string;
56
+ CLAMP: string;
57
+ IDENTITY: string;
58
+ };
54
59
  runOnJS: (fn: any) => any;
60
+ runOnUI: (fn: any) => any;
55
61
  };
package/mock.js CHANGED
@@ -102,6 +102,7 @@ const Reanimated = {
102
102
  Text,
103
103
  Image,
104
104
  ScrollView: Animated.ScrollView,
105
+ FlatList: Animated.FlatList,
105
106
  Code,
106
107
 
107
108
  Clock: NOOP,
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
2
  "name": "react-native-reanimated",
3
- "version": "2.8.0",
3
+ "version": "2.10.0",
4
4
  "description": "More powerful alternative to Animated library for React Native.",
5
5
  "scripts": {
6
- "start": "node node_modules/react-native/local-cli/cli.js start",
7
6
  "test": "yarn run format:js && yarn run lint:js && yarn run test:unit",
8
7
  "test:unit": "jest",
9
8
  "lint": "yarn lint:js && yarn lint:cpp && yarn lint:java",
@@ -34,10 +33,10 @@
34
33
  "clean:deep": "cd android && rm -rf .cxx .gradle build && cd ../Example/android && rm -rf .gradle build app/build && cd ../.. && yarn clean",
35
34
  "reset:deep": "yarn clean:deep && yarn setup"
36
35
  },
37
- "main": "lib/Animated.js",
38
- "module": "lib/Animated",
39
- "react-native": "src/Animated",
40
- "source": "src/Animated",
36
+ "main": "lib/index.js",
37
+ "module": "lib/index",
38
+ "react-native": "src/index",
39
+ "source": "src/index",
41
40
  "types": "react-native-reanimated.d.ts",
42
41
  "files": [
43
42
  "Common/",
@@ -101,7 +100,7 @@
101
100
  "@types/babel__generator": "^7.6.4",
102
101
  "@types/babel__traverse": "^7.14.2",
103
102
  "@types/jest": "^27.4.0",
104
- "@types/react-native": "^0.66.15",
103
+ "@types/react-native": "^0.69.5",
105
104
  "@typescript-eslint/eslint-plugin": "^5.11.0",
106
105
  "@typescript-eslint/parser": "^5.11.0",
107
106
  "babel-eslint": "^10.1.0",
@@ -122,10 +121,11 @@
122
121
  "madge": "^5.0.1",
123
122
  "prettier": "^2.5.1",
124
123
  "react": "17.0.2",
125
- "react-native": "0.68.0",
124
+ "react-native": "0.70.0-rc.3",
125
+ "react-native-builder-bob": "^0.18.3",
126
126
  "react-native-codegen": "^0.0.7",
127
127
  "react-native-gesture-handler": "^1.6.1",
128
- "react-test-renderer": "17.0.2",
128
+ "react-test-renderer": "18.0.0",
129
129
  "release-it": "^13.7.2",
130
130
  "typescript": "^4.1.3"
131
131
  },
@@ -154,5 +154,10 @@
154
154
  "commonjs",
155
155
  "module"
156
156
  ]
157
- }
157
+ },
158
+ "sideEffects": [
159
+ "./lib/reanimated2/core",
160
+ "./lib/reanimated2/js-reanimated/global",
161
+ "./lib/index"
162
+ ]
158
163
  }
package/plugin.js CHANGED
@@ -7,6 +7,7 @@ const { transformSync } = require('@babel/core');
7
7
  * holds a map of function names as keys and array of argument indexes as values which should be automatically workletized(they have to be functions)(starting from 0)
8
8
  */
9
9
  const functionArgsToWorkletize = new Map([
10
+ ['useFrameCallback', [0]],
10
11
  ['useAnimatedStyle', [0]],
11
12
  ['useAnimatedProps', [0]],
12
13
  ['createAnimatedPropAdapter', [0]],
@@ -14,7 +15,6 @@ const functionArgsToWorkletize = new Map([
14
15
  ['useAnimatedScrollHandler', [0]],
15
16
  ['useAnimatedReaction', [0, 1]],
16
17
  ['useWorkletCallback', [0]],
17
- ['createWorklet', [0]],
18
18
  // animations' callbacks
19
19
  ['withTiming', [2]],
20
20
  ['withSpring', [2]],
@@ -306,13 +306,14 @@ function buildWorkletString(t, fun, closureVariables, name) {
306
306
  },
307
307
  });
308
308
 
309
+ const expression = fun.program.body.find(
310
+ ({ type }) => type === 'ExpressionStatement'
311
+ ).expression;
312
+
309
313
  const workletFunction = t.functionExpression(
310
314
  t.identifier(name),
311
- fun.program.body[0].expression.params,
312
- prependClosureVariablesIfNecessary(
313
- closureVariables,
314
- fun.program.body[0].expression.body
315
- )
315
+ expression.params,
316
+ prependClosureVariablesIfNecessary(closureVariables, expression.body)
316
317
  );
317
318
 
318
319
  return generate(workletFunction, { compact: true }).code;
@@ -156,7 +156,7 @@ declare module 'react-native-reanimated' {
156
156
  : Record<string, unknown>;
157
157
 
158
158
  export type AnimateProps<P extends object> = {
159
- [K in keyof P]: P[K] | AnimatedNode<P[K]>;
159
+ [K in keyof Omit<P, 'style'>]: P[K] | AnimatedNode<P[K]>;
160
160
  } & {
161
161
  style?: StyleProp<AnimateStyle<StylesOrDefault<P>>>;
162
162
  } & {
@@ -495,20 +495,71 @@ declare module 'react-native-reanimated' {
495
495
  }
496
496
 
497
497
  export type SensorConfig = {
498
- interval: number;
498
+ interval: number | 'auto';
499
499
  };
500
500
 
501
- export type AnimatedSensor = {
502
- sensor: SensorValue3D | SensorValueRotation | null;
501
+ export type Value3D = {
502
+ x: number;
503
+ y: number;
504
+ z: number;
505
+ };
506
+
507
+ export type SensorValue3D = SharedValue<Value3D>;
508
+
509
+ export type ValueRotation = {
510
+ qw: number;
511
+ qx: number;
512
+ qy: number;
513
+ qz: number;
514
+ yaw: number;
515
+ pitch: number;
516
+ roll: number;
517
+ };
518
+
519
+ export type SensorValueRotation = SharedValue<ValueRotation>;
520
+
521
+ export type AnimatedSensor<SensorValueType> = {
522
+ sensor: SensorValueType;
503
523
  unregister: () => void;
504
524
  isAvailable: boolean;
505
525
  config: SensorConfig;
506
526
  };
507
527
 
528
+ export function useAnimatedSensor(
529
+ sensorType: SensorType.ROTATION,
530
+ userConfig?: SensorConfig
531
+ ): AnimatedSensor<SensorValueRotation>;
532
+ export function useAnimatedSensor(
533
+ sensorType: Exclude<SensorType, SensorType.ROTATION>,
534
+ userConfig?: SensorConfig
535
+ ): AnimatedSensor<SensorValue3D>;
508
536
  export function useAnimatedSensor(
509
537
  sensorType: SensorType,
510
538
  userConfig?: SensorConfig
511
- ): AnimatedSensor;
539
+ ): AnimatedSensor<any>;
540
+
541
+ export type FrameCallback = {
542
+ setActive: (isActive: boolean) => void;
543
+ isActive: boolean;
544
+ callbackId: number;
545
+ };
546
+ export function useFrameCallback(
547
+ callback: () => void,
548
+ autostart?: boolean
549
+ ): FrameCallback;
550
+
551
+ export enum KeyboardState {
552
+ UNKNOWN = 0,
553
+ OPENING = 1,
554
+ OPEN = 2,
555
+ CLOSING = 3,
556
+ CLOSED = 4,
557
+ }
558
+ export type AnimatedKeyboardInfo = {
559
+ height: SharedValue<number>;
560
+ state: SharedValue<KeyboardState>;
561
+ };
562
+ export function useAnimatedKeyboard(): AnimatedKeyboardInfo;
512
563
 
513
564
  export interface ExitAnimationsValues {
514
565
  currentOriginX: number;
@@ -650,9 +701,6 @@ declare module 'react-native-reanimated' {
650
701
  ): PropsAdapterFunction;
651
702
 
652
703
  export function processColor(color: number | string): number;
653
- export function createWorklet<A extends any[], R>(
654
- fn: (...args: A) => R
655
- ): (...args: Parameters<typeof fn>) => R;
656
704
 
657
705
  export function interpolateColor<T extends string | number>(
658
706
  value: number,
@@ -0,0 +1,13 @@
1
+ export { default as createAnimatedComponent } from './createAnimatedComponent';
2
+ export {
3
+ addWhitelistedNativeProps,
4
+ addWhitelistedUIProps,
5
+ } from './ConfigHelper';
6
+
7
+ export { default as Text } from './reanimated2/component/Text';
8
+ export { default as View } from './reanimated2/component/View';
9
+ export { default as ScrollView } from './reanimated2/component/ScrollView';
10
+ export { default as Image } from './reanimated2/component/Image';
11
+ export { default as FlatList } from './reanimated2/component/FlatList';
12
+ // @ts-ignore backward compatibility with treeshaking
13
+ export * from './reanimated1';
package/src/index.ts ADDED
@@ -0,0 +1,15 @@
1
+ import * as Animated from './Animated';
2
+ import webGlobalIsInitialized from './reanimated2/js-reanimated/global';
3
+ if (!webGlobalIsInitialized) {
4
+ /*
5
+ `webGlobalIsInitialized` should always be `true`,
6
+ but we need to use `webGlobalIsInitialized` somewhere to ensure function execution,
7
+ in another way, the bundler can remove unused variables.
8
+ */
9
+ console.error('[Reanimated] Unable to initialize global objects for web.');
10
+ }
11
+
12
+ // @ts-ignore backward compatibility with treeshaking
13
+ export * from './reanimated1';
14
+ export * from './reanimated2';
15
+ export default Animated;
@@ -0,0 +1,5 @@
1
+ // tree-shaken side effects
2
+ import './reanimated2/js-reanimated/global';
3
+
4
+ export * from './reanimated2';
5
+ export * as default from './Animated'; // If this line fails, you probably forgot some installation steps. Check out the installation guide here: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/ 1) Make sure reanimated's babel plugin is installed in your babel.config.js (you should have 'react-native-reanimated/plugin' listed there - also see the above link for details) 2) Make sure you reset build cache after updating the config, run: yarn start --reset-cache
@@ -23,7 +23,7 @@ interface HSV {
23
23
  }
24
24
 
25
25
  // var INTEGER = '[-+]?\\d+';
26
- const NUMBER = '[-+]?\\d*\\.?\\d+';
26
+ const NUMBER = '[-+]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)';
27
27
  const PERCENTAGE = NUMBER + '%';
28
28
 
29
29
  function call(...args: unknown[]): string {
@@ -45,6 +45,11 @@ export function measure(
45
45
  if (result.x === -1234567) {
46
46
  throw new Error(`The view with tag ${viewTag} could not be measured`);
47
47
  }
48
+ if (isNaN(result.x)) {
49
+ console.warn(
50
+ 'Trying to measure a component which gets view-flattened on Android. To disable view-flattening, set `collapsable={false}` on this component.'
51
+ );
52
+ }
48
53
  return result;
49
54
  }
50
55
 
@@ -3,6 +3,7 @@ import {
3
3
  SharedValue,
4
4
  SensorValue3D,
5
5
  SensorValueRotation,
6
+ AnimatedKeyboardInfo,
6
7
  } from '../commonTypes';
7
8
  import { Descriptor } from '../hook/commonTypes';
8
9
 
@@ -11,7 +12,7 @@ export class NativeReanimated {
11
12
  private InnerNativeModule: any;
12
13
 
13
14
  constructor(native = true) {
14
- if (global.__reanimatedModuleProxy === undefined) {
15
+ if (global.__reanimatedModuleProxy === undefined && native) {
15
16
  const { ReanimatedModule } = NativeModules;
16
17
  ReanimatedModule?.installTurboModule();
17
18
  }
@@ -97,4 +98,12 @@ export class NativeReanimated {
97
98
  configureProps(uiProps: string[], nativeProps: string[]): void {
98
99
  this.InnerNativeModule.configureProps(uiProps, nativeProps);
99
100
  }
101
+
102
+ subscribeForKeyboardEvents(keyboardEventData: AnimatedKeyboardInfo): number {
103
+ return this.InnerNativeModule.subscribeForKeyboardEvents(keyboardEventData);
104
+ }
105
+
106
+ unsubscribeFromKeyboardEvents(listenerId: number): void {
107
+ this.InnerNativeModule.unsubscribeFromKeyboardEvents(listenerId);
108
+ }
100
109
  }
@@ -63,11 +63,6 @@ export function withSequence(
63
63
  now: Timestamp,
64
64
  previousAnimation: SequenceAnimation
65
65
  ): void {
66
- if (animations.length === 1) {
67
- throw Error(
68
- 'withSequence() animation require more than one animation as argument'
69
- );
70
- }
71
66
  animation.animationIndex = 0;
72
67
  if (previousAnimation === undefined) {
73
68
  previousAnimation = animations[
@@ -87,7 +87,14 @@ function decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(
87
87
  animation.startValue = strippedValue;
88
88
  animation.toValue = strippedToValue;
89
89
  if (previousAnimation && previousAnimation !== animation) {
90
- previousAnimation.current = previousAnimation.strippedCurrent;
90
+ const {
91
+ prefix: paPrefix,
92
+ suffix: paSuffix,
93
+ strippedValue: paStrippedValue,
94
+ } = recognizePrefixSuffix(previousAnimation.current as string | number);
95
+ previousAnimation.current = paStrippedValue;
96
+ previousAnimation.__prefix = paPrefix;
97
+ previousAnimation.__suffix = paSuffix;
91
98
  }
92
99
 
93
100
  baseOnStart(animation, strippedValue, timestamp, previousAnimation);
@@ -145,3 +145,18 @@ export type ValueRotation = {
145
145
  };
146
146
 
147
147
  export type SensorValueRotation = SharedValue<ValueRotation>;
148
+
149
+ export type ShadowNodeWrapper = object;
150
+
151
+ export enum KeyboardState {
152
+ UNKNOWN = 0,
153
+ OPENING = 1,
154
+ OPEN = 2,
155
+ CLOSING = 3,
156
+ CLOSED = 4,
157
+ }
158
+
159
+ export type AnimatedKeyboardInfo = {
160
+ height: SharedValue<number>;
161
+ state: SharedValue<KeyboardState>;
162
+ };
@@ -1,45 +1,52 @@
1
- import React from 'react';
1
+ import React, { ForwardedRef, forwardRef } from 'react';
2
2
  import { FlatList, FlatListProps, LayoutChangeEvent } from 'react-native';
3
- import WrappedComponents from './WrappedComponents';
3
+ import ReanimatedView from './View';
4
4
  import createAnimatedComponent from '../../createAnimatedComponent';
5
5
  import { ILayoutAnimationBuilder } from '../layoutReanimation/animationBuilder/commonTypes';
6
6
 
7
7
  const AnimatedFlatList = createAnimatedComponent(FlatList as any) as any;
8
8
 
9
+ interface AnimatedFlatListProps {
10
+ onLayout: (event: LayoutChangeEvent) => void;
11
+ // implicit `children` prop has been removed in @types/react^18.0.0
12
+ children: React.ReactNode;
13
+ }
14
+
9
15
  const createCellRenderer = (itemLayoutAnimation?: ILayoutAnimationBuilder) => {
10
- const cellRenderer: React.FC<{
11
- onLayout: (event: LayoutChangeEvent) => void;
12
- }> = (props) => {
16
+ const cellRenderer = (props: AnimatedFlatListProps) => {
13
17
  return (
14
- <WrappedComponents.View
15
- layout={itemLayoutAnimation}
16
- onLayout={props.onLayout}
17
- >
18
+ <ReanimatedView layout={itemLayoutAnimation} onLayout={props.onLayout}>
18
19
  {props.children}
19
- </WrappedComponents.View>
20
+ </ReanimatedView>
20
21
  );
21
22
  };
22
23
 
23
24
  return cellRenderer;
24
25
  };
25
26
 
26
- export interface ReanimatedFlatlistProps<ItemT> extends FlatListProps<ItemT> {
27
+ export interface ReanimatedFlatListProps<ItemT> extends FlatListProps<ItemT> {
27
28
  itemLayoutAnimation?: ILayoutAnimationBuilder;
28
29
  }
29
30
 
30
- type ReanimatedFlatListFC<T = any> = React.FC<ReanimatedFlatlistProps<T>>;
31
-
32
- const ReanimatedFlatlist: ReanimatedFlatListFC = ({
33
- itemLayoutAnimation,
34
- ...restProps
35
- }) => {
36
- const cellRenderer = React.useMemo(
37
- () => createCellRenderer(itemLayoutAnimation),
38
- []
39
- );
40
- return (
41
- <AnimatedFlatList {...restProps} CellRendererComponent={cellRenderer} />
42
- );
43
- };
31
+ type ReanimatedFlatListFC<T = any> = React.FC<ReanimatedFlatListProps<T>>;
32
+
33
+ const ReanimatedFlatlist: ReanimatedFlatListFC = forwardRef(
34
+ (props: ReanimatedFlatListProps<any>, ref: ForwardedRef<FlatList>) => {
35
+ const { itemLayoutAnimation, ...restProps } = props;
36
+
37
+ const cellRenderer = React.useMemo(
38
+ () => createCellRenderer(itemLayoutAnimation),
39
+ []
40
+ );
41
+
42
+ return (
43
+ <AnimatedFlatList
44
+ ref={ref}
45
+ {...restProps}
46
+ CellRendererComponent={cellRenderer}
47
+ />
48
+ );
49
+ }
50
+ );
44
51
 
45
52
  export default ReanimatedFlatlist;
@@ -0,0 +1,6 @@
1
+ import { Image } from 'react-native';
2
+ import createAnimatedComponent from '../../createAnimatedComponent';
3
+
4
+ const AnimatedImage = createAnimatedComponent(Image as any);
5
+
6
+ export default AnimatedImage;
@@ -0,0 +1,6 @@
1
+ import { ScrollView } from 'react-native';
2
+ import createAnimatedComponent from '../../createAnimatedComponent';
3
+
4
+ const AnimatedScrollView = createAnimatedComponent(ScrollView);
5
+
6
+ export default AnimatedScrollView;
@@ -0,0 +1,6 @@
1
+ import { Text } from 'react-native';
2
+ import createAnimatedComponent from '../../createAnimatedComponent';
3
+
4
+ const AnimatedText = createAnimatedComponent(Text as any);
5
+
6
+ export default AnimatedText;
@@ -0,0 +1,6 @@
1
+ import { View } from 'react-native';
2
+ import createAnimatedComponent from '../../createAnimatedComponent';
3
+
4
+ const AnimatedView = createAnimatedComponent(View);
5
+
6
+ export default AnimatedView;
@@ -41,14 +41,18 @@ const testWorklet: BasicWorkletFunction<void> = () => {
41
41
  'worklet';
42
42
  };
43
43
 
44
+ const throwUninitializedReanimatedException = () => {
45
+ throw new Error(
46
+ "Failed to initialize react-native-reanimated library, make sure you followed installation steps here: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/ \n1) Make sure reanimated's babel plugin is installed in your babel.config.js (you should have 'react-native-reanimated/plugin' listed there - also see the above link for details) \n2) Make sure you reset build cache after updating the config, run: yarn start --reset-cache"
47
+ );
48
+ };
49
+
44
50
  export const checkPluginState: (throwError: boolean) => boolean = (
45
51
  throwError = true
46
52
  ) => {
47
53
  if (!testWorklet.__workletHash && !shouldBeUseWeb()) {
48
54
  if (throwError) {
49
- throw new Error(
50
- "Reanimated 2 failed to create a worklet, maybe you forgot to add Reanimated's babel plugin?"
51
- );
55
+ throwUninitializedReanimatedException();
52
56
  }
53
57
  return false;
54
58
  }
@@ -62,11 +66,7 @@ export const isConfigured: (throwError?: boolean) => boolean = (
62
66
  };
63
67
 
64
68
  export const isConfiguredCheck: () => void = () => {
65
- if (!isConfigured(true)) {
66
- throw new Error(
67
- 'If you want to use Reanimated 2 then go through our installation steps https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation'
68
- );
69
- }
69
+ checkPluginState(true);
70
70
  };
71
71
 
72
72
  function pushFrame(frame: (timestamp: Timestamp) => void): void {
@@ -333,11 +333,6 @@ if (!isWeb() && isConfigured()) {
333
333
  info: runOnJS(capturableConsole.info),
334
334
  };
335
335
  _setGlobalConsole(console);
336
- if (global.performance == null) {
337
- global.performance = {
338
- now: global._chronoNow,
339
- } as any; // due to conflict with lib.dom.d.ts -> Performance
340
- }
341
336
  })();
342
337
  }
343
338
 
@@ -0,0 +1,43 @@
1
+ import { runOnUI } from '../core';
2
+ import { prepareUIRegistry } from './FrameCallbackRegistryUI';
3
+
4
+ export default class FrameCallbackRegistryJS {
5
+ private nextCallbackId = 0;
6
+
7
+ constructor() {
8
+ prepareUIRegistry();
9
+ }
10
+
11
+ registerFrameCallback(callback: () => void): number {
12
+ if (!callback) {
13
+ return -1;
14
+ }
15
+
16
+ const callbackId = this.nextCallbackId;
17
+ this.nextCallbackId++;
18
+
19
+ runOnUI(() => {
20
+ 'worklet';
21
+ global._frameCallbackRegistry.registerFrameCallback(callback, callbackId);
22
+ })();
23
+
24
+ return callbackId;
25
+ }
26
+
27
+ unregisterFrameCallback(frameCallbackId: number): void {
28
+ runOnUI(() => {
29
+ 'worklet';
30
+ global._frameCallbackRegistry.unregisterFrameCallback(frameCallbackId);
31
+ })();
32
+ }
33
+
34
+ manageStateFrameCallback(frameCallbackId: number, state: boolean): void {
35
+ runOnUI(() => {
36
+ 'worklet';
37
+ global._frameCallbackRegistry.manageStateFrameCallback(
38
+ frameCallbackId,
39
+ state
40
+ );
41
+ })();
42
+ }
43
+ }