react-native-reanimated 2.3.0-alpha.3 → 2.3.0-beta.4

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 (264) hide show
  1. package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp +15 -8
  2. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +176 -154
  3. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +49 -33
  4. package/Common/cpp/Registries/EventHandlerRegistry.cpp +14 -7
  5. package/Common/cpp/Registries/MapperRegistry.cpp +24 -20
  6. package/Common/cpp/Registries/WorkletsCache.cpp +19 -9
  7. package/Common/cpp/SharedItems/FrozenObject.cpp +17 -8
  8. package/Common/cpp/SharedItems/MutableValue.cpp +38 -25
  9. package/Common/cpp/SharedItems/MutableValueSetterProxy.cpp +11 -7
  10. package/Common/cpp/SharedItems/RemoteObject.cpp +9 -5
  11. package/Common/cpp/SharedItems/ShareableValue.cpp +211 -160
  12. package/Common/cpp/Tools/FeaturesConfig.cpp +5 -0
  13. package/Common/cpp/Tools/JSIStoreValueUser.cpp +25 -6
  14. package/Common/cpp/Tools/Mapper.cpp +30 -30
  15. package/Common/cpp/Tools/RuntimeDecorator.cpp +124 -86
  16. package/Common/cpp/Tools/Scheduler.cpp +6 -5
  17. package/Common/cpp/Tools/WorkletEventHandler.cpp +4 -2
  18. package/Common/cpp/headers/LayoutAnimations/LayoutAnimationsProxy.h +12 -11
  19. package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +50 -31
  20. package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +34 -16
  21. package/Common/cpp/headers/Registries/EventHandlerRegistry.h +15 -8
  22. package/Common/cpp/headers/Registries/MapperRegistry.h +5 -4
  23. package/Common/cpp/headers/Registries/WorkletsCache.h +9 -7
  24. package/Common/cpp/headers/SharedItems/FrozenObject.h +19 -11
  25. package/Common/cpp/headers/SharedItems/HostFunctionHandler.h +8 -4
  26. package/Common/cpp/headers/SharedItems/MutableValue.h +23 -12
  27. package/Common/cpp/headers/SharedItems/MutableValueSetterProxy.h +12 -7
  28. package/Common/cpp/headers/SharedItems/RemoteObject.h +19 -8
  29. package/Common/cpp/headers/SharedItems/RuntimeManager.h +26 -25
  30. package/Common/cpp/headers/SharedItems/ShareableValue.h +32 -27
  31. package/Common/cpp/headers/SharedItems/SharedParent.h +10 -7
  32. package/Common/cpp/headers/SharedItems/ValueWrapper.h +95 -72
  33. package/Common/cpp/headers/SpecTools/ErrorHandler.h +18 -19
  34. package/Common/cpp/headers/Tools/FeaturesConfig.h +19 -0
  35. package/Common/cpp/headers/Tools/JSIStoreValueUser.h +13 -16
  36. package/Common/cpp/headers/Tools/Mapper.h +19 -16
  37. package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +17 -7
  38. package/Common/cpp/headers/Tools/ReanimatedHiddenHeaders.h +7 -11
  39. package/Common/cpp/headers/Tools/RuntimeDecorator.h +36 -27
  40. package/Common/cpp/headers/Tools/Scheduler.h +30 -35
  41. package/Common/cpp/headers/Tools/WorkletEventHandler.h +11 -8
  42. package/Common/cpp/hidden_headers/Logger.h +14 -14
  43. package/Common/cpp/hidden_headers/LoggerInterface.h +8 -9
  44. package/Common/cpp/hidden_headers/SpeedChecker.h +7 -8
  45. package/README.md +1 -1
  46. package/RNReanimated.podspec +24 -6
  47. package/android/build.gradle +38 -29
  48. package/android/react-native-reanimated-63-hermes.aar +0 -0
  49. package/android/react-native-reanimated-63-jsc.aar +0 -0
  50. package/android/react-native-reanimated-64-hermes.aar +0 -0
  51. package/android/react-native-reanimated-64-jsc.aar +0 -0
  52. package/android/react-native-reanimated-65-hermes.aar +0 -0
  53. package/android/react-native-reanimated-65-jsc.aar +0 -0
  54. package/android/react-native-reanimated-66-hermes.aar +0 -0
  55. package/android/react-native-reanimated-66-jsc.aar +0 -0
  56. package/android/react-native-reanimated-67-hermes.aar +0 -0
  57. package/android/react-native-reanimated-67-jsc.aar +0 -0
  58. package/ios/LayoutReanimation/REAAnimationsManager.h +10 -8
  59. package/ios/LayoutReanimation/REAAnimationsManager.m +91 -87
  60. package/ios/LayoutReanimation/REASnapshot.h +2 -2
  61. package/ios/LayoutReanimation/REASnapshot.m +8 -7
  62. package/ios/LayoutReanimation/REAUIManager.h +4 -4
  63. package/ios/LayoutReanimation/REAUIManager.mm +116 -70
  64. package/ios/Nodes/REAAlwaysNode.m +14 -15
  65. package/ios/Nodes/REABezierNode.m +8 -7
  66. package/ios/Nodes/REABlockNode.m +1 -1
  67. package/ios/Nodes/REACallFuncNode.h +0 -1
  68. package/ios/Nodes/REACallFuncNode.m +10 -8
  69. package/ios/Nodes/REAClockNodes.m +22 -20
  70. package/ios/Nodes/REAConcatNode.h +0 -1
  71. package/ios/Nodes/REAConcatNode.m +2 -2
  72. package/ios/Nodes/REACondNode.m +7 -5
  73. package/ios/Nodes/READebugNode.m +5 -4
  74. package/ios/Nodes/REAEventNode.m +1 -1
  75. package/ios/Nodes/REAFunctionNode.h +0 -1
  76. package/ios/Nodes/REAFunctionNode.m +2 -2
  77. package/ios/Nodes/REAJSCallNode.m +4 -5
  78. package/ios/Nodes/REANode.h +3 -4
  79. package/ios/Nodes/REANode.m +9 -11
  80. package/ios/Nodes/REAOperatorNode.m +68 -67
  81. package/ios/Nodes/REAParamNode.h +1 -3
  82. package/ios/Nodes/REAParamNode.m +15 -17
  83. package/ios/Nodes/REAPropsNode.h +1 -3
  84. package/ios/Nodes/REAPropsNode.m +19 -22
  85. package/ios/Nodes/REASetNode.h +0 -1
  86. package/ios/Nodes/REASetNode.m +7 -5
  87. package/ios/Nodes/REAStyleNode.h +0 -1
  88. package/ios/Nodes/REAStyleNode.m +2 -4
  89. package/ios/Nodes/REATransformNode.h +0 -1
  90. package/ios/Nodes/REATransformNode.m +3 -5
  91. package/ios/Nodes/REAValueNode.m +5 -7
  92. package/ios/REAEventDispatcher.m +4 -4
  93. package/ios/REAModule.h +0 -2
  94. package/ios/REAModule.m +29 -38
  95. package/ios/REANodesManager.h +11 -19
  96. package/ios/REANodesManager.m +106 -130
  97. package/ios/REAUtils.h +5 -3
  98. package/ios/RNGestureHandlerStateManager.h +5 -0
  99. package/ios/Transitioning/RCTConvert+REATransition.m +45 -29
  100. package/ios/Transitioning/REAAllTransitions.h +2 -2
  101. package/ios/Transitioning/REAAllTransitions.m +14 -25
  102. package/ios/Transitioning/REATransition.h +8 -7
  103. package/ios/Transitioning/REATransition.m +19 -16
  104. package/ios/Transitioning/REATransitionAnimation.h +1 -1
  105. package/ios/Transitioning/REATransitionAnimation.m +2 -3
  106. package/ios/Transitioning/REATransitionManager.m +3 -3
  107. package/ios/native/NativeMethods.h +20 -5
  108. package/ios/native/NativeMethods.mm +14 -6
  109. package/ios/native/NativeProxy.h +4 -2
  110. package/ios/native/NativeProxy.mm +84 -63
  111. package/ios/native/REAIOSErrorHandler.h +13 -10
  112. package/ios/native/REAIOSErrorHandler.mm +19 -15
  113. package/ios/native/REAIOSLogger.h +8 -8
  114. package/ios/native/REAIOSLogger.mm +10 -6
  115. package/ios/native/REAIOSScheduler.h +5 -5
  116. package/ios/native/REAIOSScheduler.mm +17 -10
  117. package/ios/native/REAInitializer.h +5 -7
  118. package/ios/native/REAInitializer.mm +43 -31
  119. package/ios/native/UIResponder+Reanimated.mm +2 -2
  120. package/lib/Animated.js +9 -1
  121. package/lib/ConfigHelper.js +121 -138
  122. package/lib/ReanimatedEventEmitter.js +0 -1
  123. package/lib/ReanimatedModule.js +0 -1
  124. package/lib/ReanimatedModule.macos.js +0 -1
  125. package/lib/ReanimatedModule.native.js +5 -6
  126. package/lib/ReanimatedModule.windows.js +0 -1
  127. package/lib/ReanimatedModuleCompat.js +64 -35
  128. package/lib/createAnimatedComponent.js +468 -487
  129. package/lib/index.js +9 -1
  130. package/lib/reanimated2/NativeMethods.js +7 -12
  131. package/lib/reanimated2/NativeReanimated/NativeReanimated.js +37 -0
  132. package/lib/reanimated2/NativeReanimated/index.js +15 -0
  133. package/lib/reanimated2/PropAdapters.js +0 -1
  134. package/lib/reanimated2/UpdateProps.js +6 -7
  135. package/lib/reanimated2/ViewDescriptorsSet.js +4 -4
  136. package/lib/reanimated2/WorkletEventHandler.js +15 -13
  137. package/lib/reanimated2/animation/delay.js +8 -2
  138. package/lib/reanimated2/animation/spring.js +2 -0
  139. package/lib/reanimated2/animation/styleAnimation.js +7 -3
  140. package/lib/reanimated2/animation/util.js +25 -2
  141. package/lib/reanimated2/core.js +41 -17
  142. package/lib/reanimated2/globals.d.ts +21 -1
  143. package/lib/reanimated2/hook/useAnimatedRef.js +1 -1
  144. package/lib/reanimated2/hook/useAnimatedStyle.js +3 -3
  145. package/lib/reanimated2/index.js +1 -0
  146. package/lib/reanimated2/interpolation.js +95 -87
  147. package/lib/reanimated2/js-reanimated/JSReanimated.js +13 -10
  148. package/lib/reanimated2/js-reanimated/Mapper.js +4 -3
  149. package/lib/reanimated2/js-reanimated/MapperRegistry.js +3 -6
  150. package/lib/reanimated2/js-reanimated/MutableValue.js +0 -2
  151. package/lib/reanimated2/js-reanimated/index.js +10 -8
  152. package/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.js +33 -2
  153. package/lib/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +27 -124
  154. package/lib/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +125 -0
  155. package/lib/reanimated2/layoutReanimation/animationBuilder/index.js +1 -2
  156. package/lib/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +115 -45
  157. package/lib/reanimated2/layoutReanimation/defaultAnimations/Default.js +7 -2
  158. package/lib/reanimated2/layoutReanimation/defaultAnimations/Fade.js +21 -21
  159. package/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.js +25 -25
  160. package/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +19 -17
  161. package/lib/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +5 -5
  162. package/lib/reanimated2/layoutReanimation/defaultAnimations/Roll.js +9 -9
  163. package/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +17 -17
  164. package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +19 -19
  165. package/lib/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +9 -9
  166. package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +33 -33
  167. package/lib/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +78 -0
  168. package/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +128 -0
  169. package/lib/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +37 -0
  170. package/lib/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +41 -0
  171. package/lib/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +34 -0
  172. package/lib/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +46 -0
  173. package/lib/reanimated2/layoutReanimation/defaultTransitions/index.js +6 -0
  174. package/lib/reanimated2/layoutReanimation/index.js +1 -0
  175. package/lib/reanimated2/mock.js +3 -1
  176. package/lib/reanimated2/utils.js +9 -0
  177. package/lib/setAndForwardRef.js +14 -48
  178. package/libSo/fbjni/jni/arm64-v8a/libfbjni.so +0 -0
  179. package/libSo/fbjni/jni/armeabi-v7a/libfbjni.so +0 -0
  180. package/libSo/fbjni/jni/x86/libfbjni.so +0 -0
  181. package/libSo/fbjni/jni/x86_64/libfbjni.so +0 -0
  182. package/mock.js +1 -1
  183. package/package.json +28 -17
  184. package/plugin.js +220 -39
  185. package/react-native-reanimated.d.ts +542 -547
  186. package/src/Animated.js +9 -1
  187. package/src/{ConfigHelper.js → ConfigHelper.ts} +15 -7
  188. package/src/{ReanimatedEventEmitter.js → ReanimatedEventEmitter.ts} +0 -0
  189. package/src/{ReanimatedModule.js → ReanimatedModule.macos.ts} +0 -0
  190. package/src/{ReanimatedModule.native.js → ReanimatedModule.native.ts} +0 -0
  191. package/src/{ReanimatedModule.macos.js → ReanimatedModule.ts} +0 -0
  192. package/src/{ReanimatedModule.windows.js → ReanimatedModule.windows.ts} +0 -0
  193. package/src/ReanimatedModuleCompat.ts +51 -0
  194. package/src/{createAnimatedComponent.js → createAnimatedComponent.tsx} +285 -126
  195. package/src/reanimated2/NativeMethods.ts +34 -13
  196. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +72 -0
  197. package/src/reanimated2/NativeReanimated/index.ts +18 -0
  198. package/src/reanimated2/PropAdapters.ts +0 -1
  199. package/src/reanimated2/UpdateProps.ts +31 -15
  200. package/src/reanimated2/ViewDescriptorsSet.ts +15 -12
  201. package/src/reanimated2/WorkletEventHandler.ts +41 -23
  202. package/src/reanimated2/animation/commonTypes.ts +4 -4
  203. package/src/reanimated2/animation/decay.ts +2 -2
  204. package/src/reanimated2/animation/delay.ts +11 -5
  205. package/src/reanimated2/animation/index.ts +7 -7
  206. package/src/reanimated2/animation/repeat.ts +4 -4
  207. package/src/reanimated2/animation/sequence.ts +2 -2
  208. package/src/reanimated2/animation/spring.ts +6 -5
  209. package/src/reanimated2/animation/styleAnimation.ts +27 -15
  210. package/src/reanimated2/animation/timing.ts +5 -5
  211. package/src/reanimated2/animation/util.ts +47 -8
  212. package/src/reanimated2/commonTypes.ts +3 -0
  213. package/src/reanimated2/core.ts +80 -34
  214. package/src/reanimated2/globals.d.ts +21 -1
  215. package/src/reanimated2/hook/useAnimatedGestureHandler.ts +1 -1
  216. package/src/reanimated2/hook/useAnimatedRef.ts +13 -15
  217. package/src/reanimated2/hook/useAnimatedScrollHandler.ts +3 -3
  218. package/src/reanimated2/hook/useAnimatedStyle.ts +7 -7
  219. package/src/reanimated2/hook/utils.ts +4 -3
  220. package/src/reanimated2/index.ts +1 -0
  221. package/src/reanimated2/interpolation.ts +170 -103
  222. package/src/reanimated2/js-reanimated/JSReanimated.ts +37 -23
  223. package/src/reanimated2/js-reanimated/Mapper.ts +22 -9
  224. package/src/reanimated2/js-reanimated/MapperRegistry.ts +22 -19
  225. package/src/reanimated2/js-reanimated/MutableValue.ts +11 -11
  226. package/src/reanimated2/js-reanimated/index.ts +31 -14
  227. package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +75 -0
  228. package/src/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.ts +29 -159
  229. package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +169 -0
  230. package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +2 -2
  231. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +3 -9
  232. package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -5
  233. package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +162 -82
  234. package/src/reanimated2/layoutReanimation/defaultAnimations/Default.ts +7 -2
  235. package/src/reanimated2/layoutReanimation/defaultAnimations/Fade.ts +32 -32
  236. package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +38 -38
  237. package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +34 -32
  238. package/src/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.ts +8 -8
  239. package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +14 -14
  240. package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +26 -26
  241. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +28 -28
  242. package/src/reanimated2/layoutReanimation/defaultAnimations/Stretch.ts +14 -14
  243. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +50 -50
  244. package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +104 -0
  245. package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +213 -0
  246. package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +60 -0
  247. package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +58 -0
  248. package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +41 -0
  249. package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +78 -0
  250. package/src/reanimated2/layoutReanimation/defaultTransitions/index.ts +6 -0
  251. package/src/reanimated2/layoutReanimation/index.ts +1 -0
  252. package/src/reanimated2/mock.ts +3 -1
  253. package/src/reanimated2/utils.ts +21 -0
  254. package/src/{setAndForwardRef.js → setAndForwardRef.ts} +12 -2
  255. package/android/react-native-reanimated-62-hermes.aar +0 -0
  256. package/android/react-native-reanimated-62-jsc.aar +0 -0
  257. package/lib/reanimated2/NativeReanimated.js +0 -48
  258. package/lib/reanimated2/layoutReanimation/animationBuilder/BaseBounceAnimationBuilder.js +0 -55
  259. package/lib/reanimated2/layoutReanimation/animationBuilder/LayoutAnimationBuilder.js +0 -165
  260. package/src/ReanimatedModuleCompat.js +0 -37
  261. package/src/reanimated2/NativeReanimated.ts +0 -70
  262. package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.tsx +0 -41
  263. package/src/reanimated2/layoutReanimation/animationBuilder/BaseBounceAnimationBuilder.ts +0 -82
  264. package/src/reanimated2/layoutReanimation/animationBuilder/LayoutAnimationBuilder.ts +0 -217
@@ -1,10 +1,12 @@
1
1
  #pragma once
2
2
 
3
- #include "PlatformDepMethodsHolder.h"
3
+ #include <jsi/jsi.h>
4
4
  #include <stdio.h>
5
+ #include <memory>
6
+ #include <string>
5
7
  #include <unordered_map>
6
- #include <jsi/jsi.h>
7
8
  #include "LayoutAnimationsProxy.h"
9
+ #include "PlatformDepMethodsHolder.h"
8
10
 
9
11
  using namespace facebook;
10
12
 
@@ -22,25 +24,28 @@ enum RuntimeType {
22
24
  */
23
25
  UI
24
26
  };
25
- typedef jsi::Runtime* RuntimePointer;
27
+ typedef jsi::Runtime *RuntimePointer;
26
28
 
27
29
  class RuntimeDecorator {
28
- public:
30
+ public:
29
31
  static void decorateRuntime(jsi::Runtime &rt, const std::string &label);
30
- static void decorateUIRuntime(jsi::Runtime &rt,
31
- const UpdaterFunction updater,
32
- const RequestFrameFunction requestFrame,
33
- const ScrollToFunction scrollTo,
34
- const MeasuringFunction measure,
35
- const TimeProviderFunction getCurrentTime,
36
- std::shared_ptr<LayoutAnimationsProxy> layoutAnimationsProxy);
37
-
32
+ static void decorateUIRuntime(
33
+ jsi::Runtime &rt,
34
+ const UpdaterFunction updater,
35
+ const RequestFrameFunction requestFrame,
36
+ const ScrollToFunction scrollTo,
37
+ const MeasuringFunction measure,
38
+ const TimeProviderFunction getCurrentTime,
39
+ const SetGestureStateFunction setGestureState,
40
+ std::shared_ptr<LayoutAnimationsProxy> layoutAnimationsProxy);
41
+
38
42
  /**
39
43
  Returns true if the given Runtime is the Reanimated UI-Thread Runtime.
40
44
  */
41
45
  inline static bool isUIRuntime(jsi::Runtime &rt);
42
46
  /**
43
- Returns true if the given Runtime is a Runtime that supports the concept of Workletization. (REA, Vision, ...)
47
+ Returns true if the given Runtime is a Runtime that supports the concept of
48
+ Workletization. (REA, Vision, ...)
44
49
  */
45
50
  inline static bool isWorkletRuntime(jsi::Runtime &rt);
46
51
  /**
@@ -48,31 +53,35 @@ public:
48
53
  */
49
54
  inline static bool isReactRuntime(jsi::Runtime &rt);
50
55
  /**
51
- Register the given Runtime. This function is required for every RuntimeManager, otherwise future runtime checks will fail.
56
+ Register the given Runtime. This function is required for every
57
+ RuntimeManager, otherwise future runtime checks will fail.
52
58
  */
53
- static void registerRuntime(jsi::Runtime* runtime, RuntimeType runtimeType);
59
+ static void registerRuntime(jsi::Runtime *runtime, RuntimeType runtimeType);
54
60
 
55
- private:
56
- static std::unordered_map<RuntimePointer, RuntimeType> runtimeRegistry;
61
+ private:
62
+ static std::unordered_map<RuntimePointer, RuntimeType> &runtimeRegistry();
57
63
  };
58
64
 
59
- inline bool RuntimeDecorator::isUIRuntime(jsi::Runtime& rt) {
60
- auto iterator = runtimeRegistry.find(&rt);
61
- if (iterator == runtimeRegistry.end()) return false;
65
+ inline bool RuntimeDecorator::isUIRuntime(jsi::Runtime &rt) {
66
+ auto iterator = runtimeRegistry().find(&rt);
67
+ if (iterator == runtimeRegistry().end())
68
+ return false;
62
69
  return iterator->second == RuntimeType::UI;
63
70
  }
64
71
 
65
- inline bool RuntimeDecorator::isWorkletRuntime(jsi::Runtime& rt) {
66
- auto iterator = runtimeRegistry.find(&rt);
67
- if (iterator == runtimeRegistry.end()) return false;
72
+ inline bool RuntimeDecorator::isWorkletRuntime(jsi::Runtime &rt) {
73
+ auto iterator = runtimeRegistry().find(&rt);
74
+ if (iterator == runtimeRegistry().end())
75
+ return false;
68
76
  auto type = iterator->second;
69
77
  return type == RuntimeType::UI || type == RuntimeType::Worklet;
70
78
  }
71
79
 
72
- inline bool RuntimeDecorator::isReactRuntime(jsi::Runtime& rt) {
73
- auto iterator = runtimeRegistry.find(&rt);
74
- if (iterator == runtimeRegistry.end()) return true;
80
+ inline bool RuntimeDecorator::isReactRuntime(jsi::Runtime &rt) {
81
+ auto iterator = runtimeRegistry().find(&rt);
82
+ if (iterator == runtimeRegistry().end())
83
+ return true;
75
84
  return false;
76
85
  }
77
86
 
78
- }
87
+ } // namespace reanimated
@@ -1,14 +1,15 @@
1
1
  #pragma once
2
2
 
3
- #include <queue>
4
- #include <thread>
5
- #include <mutex>
3
+ #include <ReactCommon/CallInvoker.h>
6
4
  #include <condition_variable>
7
5
  #include <functional>
8
- #include <ReactCommon/CallInvoker.h>
6
+ #include <memory>
7
+ #include <mutex>
8
+ #include <queue>
9
+ #include <thread>
10
+ #include <utility>
9
11
 
10
- namespace reanimated
11
- {
12
+ namespace reanimated {
12
13
 
13
14
  //
14
15
  // Copyright (c) 2013 Juan Palacios juan.palacios.puyana@gmail.com
@@ -16,15 +17,11 @@ namespace reanimated
16
17
  // - see < http://opensource.org/licenses/BSD-2-Clause>
17
18
  //
18
19
  template <typename T>
19
- class Queue
20
- {
20
+ class Queue {
21
21
  public:
22
-
23
- T pop()
24
- {
22
+ T pop() {
25
23
  std::unique_lock<std::mutex> mlock(mutex_);
26
- while (queue_.empty())
27
- {
24
+ while (queue_.empty()) {
28
25
  cond_.wait(mlock);
29
26
  }
30
27
  auto item = queue_.front();
@@ -32,27 +29,23 @@ class Queue
32
29
  return item;
33
30
  }
34
31
 
35
- void pop(T& item)
36
- {
32
+ void pop(T &item) {
37
33
  std::unique_lock<std::mutex> mlock(mutex_);
38
- while (queue_.empty())
39
- {
34
+ while (queue_.empty()) {
40
35
  cond_.wait(mlock);
41
36
  }
42
37
  item = queue_.front();
43
38
  queue_.pop();
44
39
  }
45
40
 
46
- void push(const T& item)
47
- {
41
+ void push(const T &item) {
48
42
  std::unique_lock<std::mutex> mlock(mutex_);
49
43
  queue_.push(item);
50
44
  mlock.unlock();
51
45
  cond_.notify_one();
52
46
  }
53
47
 
54
- void push(T&& item)
55
- {
48
+ void push(T &&item) {
56
49
  std::unique_lock<std::mutex> mlock(mutex_);
57
50
  queue_.push(std::move(item));
58
51
  mlock.unlock();
@@ -76,19 +69,21 @@ class Queue
76
69
  class RuntimeManager;
77
70
 
78
71
  class Scheduler {
79
- public:
80
- Scheduler();
81
- void scheduleOnJS(std::function<void()> job);
82
- void setJSCallInvoker(std::shared_ptr<facebook::react::CallInvoker> jsCallInvoker);
83
- void setRuntimeManager(std::shared_ptr<RuntimeManager> runtimeManager);
84
- virtual void scheduleOnUI(std::function<void()> job);
85
- virtual void triggerUI();
86
- virtual ~Scheduler();
87
- protected:
88
- std::atomic<bool> scheduledOnUI{};
89
- Queue<std::function<void()>> uiJobs;
90
- std::shared_ptr<facebook::react::CallInvoker> jsCallInvoker_;
91
- std::weak_ptr<RuntimeManager> runtimeManager;
72
+ public:
73
+ Scheduler();
74
+ void scheduleOnJS(std::function<void()> job);
75
+ void setJSCallInvoker(
76
+ std::shared_ptr<facebook::react::CallInvoker> jsCallInvoker);
77
+ void setRuntimeManager(std::shared_ptr<RuntimeManager> runtimeManager);
78
+ virtual void scheduleOnUI(std::function<void()> job);
79
+ virtual void triggerUI();
80
+ virtual ~Scheduler();
81
+
82
+ protected:
83
+ std::atomic<bool> scheduledOnUI{};
84
+ Queue<std::function<void()>> uiJobs;
85
+ std::shared_ptr<facebook::react::CallInvoker> jsCallInvoker_;
86
+ std::weak_ptr<RuntimeManager> runtimeManager;
92
87
  };
93
88
 
94
- }
89
+ } // namespace reanimated
@@ -1,7 +1,8 @@
1
1
  #pragma once
2
2
 
3
- #include <string>
4
3
  #include <jsi/jsi.h>
4
+ #include <string>
5
+ #include <utility>
5
6
 
6
7
  using namespace facebook;
7
8
 
@@ -12,16 +13,18 @@ class EventHandlerRegistry;
12
13
  class WorkletEventHandler {
13
14
  friend EventHandlerRegistry;
14
15
 
15
- private:
16
+ private:
16
17
  unsigned long id;
17
18
  std::string eventName;
18
19
  jsi::Function handler;
19
20
 
20
- public:
21
- WorkletEventHandler(unsigned long id,
22
- std::string eventName,
23
- jsi::Function &&handler): id(id), eventName(eventName), handler(std::move(handler)) {}
24
- void process(jsi::Runtime &rt, jsi::Value &eventValue);
21
+ public:
22
+ WorkletEventHandler(
23
+ unsigned long id,
24
+ std::string eventName,
25
+ jsi::Function &&handler)
26
+ : id(id), eventName(eventName), handler(std::move(handler)) {}
27
+ void process(jsi::Runtime &rt, const jsi::Value &eventValue);
25
28
  };
26
29
 
27
- }
30
+ } // namespace reanimated
@@ -1,22 +1,22 @@
1
1
  #pragma once
2
2
 
3
- #include "./LoggerInterface.h"
4
3
  #include <memory>
4
+ #include "./LoggerInterface.h"
5
5
 
6
- namespace reanimated
7
- {
6
+ namespace reanimated {
8
7
 
9
8
  class Logger {
10
- public:
11
- template<typename T>
12
- static void log(T value) {
13
- if (instance == nullptr) {
14
- throw std::runtime_error("no logger specified");
15
- }
16
- instance->log(value);
17
- };
18
- private:
19
- static std::unique_ptr<LoggerInterface> instance;
9
+ public:
10
+ template <typename T>
11
+ static void log(T value) {
12
+ if (instance == nullptr) {
13
+ throw std::runtime_error("no logger specified");
14
+ }
15
+ instance->log(value);
16
+ }
17
+
18
+ private:
19
+ static std::unique_ptr<LoggerInterface> instance;
20
20
  };
21
21
 
22
- }
22
+ } // namespace reanimated
@@ -1,15 +1,14 @@
1
1
  #pragma once
2
2
 
3
- namespace reanimated
4
- {
3
+ namespace reanimated {
5
4
 
6
5
  class LoggerInterface {
7
- public:
8
- virtual void log(const char* str) = 0;
9
- virtual void log(double d) = 0;
10
- virtual void log(int i) = 0;
11
- virtual void log(bool b) = 0;
12
- virtual ~LoggerInterface() {}
6
+ public:
7
+ virtual void log(const char *str) = 0;
8
+ virtual void log(double d) = 0;
9
+ virtual void log(int i) = 0;
10
+ virtual void log(bool b) = 0;
11
+ virtual ~LoggerInterface() {}
13
12
  };
14
13
 
15
- }
14
+ } // namespace reanimated
@@ -2,17 +2,16 @@
2
2
 
3
3
  #define CHECK_SPEED 1
4
4
 
5
- #include "./Logger.h"
6
- #include <memory>
5
+ #include <chrono>
7
6
  #include <functional>
7
+ #include <memory>
8
8
  #include <string>
9
- #include <chrono>
9
+ #include "./Logger.h"
10
10
 
11
- namespace reanimated
12
- {
11
+ namespace reanimated {
13
12
 
14
13
  class SpeedChecker {
15
- public:
14
+ public:
16
15
  static void checkSpeed(std::string tag, std::function<void()> fun) {
17
16
  #if CHECK_SPEED
18
17
  auto start = std::chrono::system_clock::now();
@@ -20,11 +19,11 @@ public:
20
19
  fun();
21
20
  #if CHECK_SPEED
22
21
  auto end = std::chrono::system_clock::now();
23
- std::chrono::duration<double> elapsed_seconds = end-start;
22
+ std::chrono::duration<double> elapsed_seconds = end - start;
24
23
  tag += " " + std::to_string(elapsed_seconds.count()) + "s";
25
24
  Logger::log(tag.c_str());
26
25
  #endif
27
26
  }
28
27
  };
29
28
 
30
- }
29
+ } // namespace reanimated
package/README.md CHANGED
@@ -11,7 +11,7 @@ comes to gesture based interactions.
11
11
 
12
12
  ## Installation
13
13
 
14
- Check out [installation](https://docs.swmansion.com/react-native-reanimated/docs/installation) section of our docs for the detailed installation instructions.
14
+ Check out [installation](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation) section of our docs for the detailed installation instructions.
15
15
 
16
16
  ## Documentation
17
17
 
@@ -5,9 +5,28 @@ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
5
5
  reactVersion = '0.0.0'
6
6
 
7
7
  begin
8
- reactVersion = JSON.parse(File.read(File.join(__dir__, "..", "react-native", "package.json")))["version"]
8
+ # standard app
9
+ # /appName/node_modules/react-native-reanimated/RNReanimated.podspec
10
+ # /appName/node_modules/react-native/package.json
11
+ reactVersion = JSON.parse(File.read(File.join(__dir__, "..", "..", "node_modules", "react-native", "package.json")))["version"]
9
12
  rescue
10
- reactVersion = '0.64.0'
13
+ begin
14
+ # monorepo
15
+ # /monorepo/packages/appName/node_modules/react-native-reanimated/RNReanimated.podspec
16
+ # /monorepo/node_modules/react-native/package.json
17
+ reactVersion = JSON.parse(File.read(File.join(__dir__, "..", "..", "..", "..", "node_modules", "react-native", "package.json")))["version"]
18
+ rescue
19
+ begin
20
+ # Example app in reanimated repo
21
+ # /react-native-reanimated/RNReanimated.podspec
22
+ # /react-native-reanimated/node_modules/react-native/package.json
23
+ reactVersion = JSON.parse(File.read(File.join(__dir__, "node_modules", "react-native", "package.json")))["version"]
24
+ rescue
25
+ # should never happen
26
+ reactVersion = '0.66.0'
27
+ puts "[RNReanimated] Unable to recognized your `react-native` version! Default `react-native` version: " + reactVersion
28
+ end
29
+ end
11
30
  end
12
31
 
13
32
  rnVersion = reactVersion.split('.')[1]
@@ -20,7 +39,7 @@ end
20
39
 
21
40
  folly_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DRNVERSION=' + rnVersion
22
41
  folly_compiler_flags = folly_flags + ' ' + '-Wno-comma -Wno-shorten-64-to-32'
23
- folly_version = '2020.01.13.00'
42
+ folly_version = '2021.04.26.00'
24
43
  boost_compiler_flags = '-Wno-documentation'
25
44
 
26
45
  Pod::Spec.new do |s|
@@ -49,12 +68,12 @@ Pod::Spec.new do |s|
49
68
 
50
69
  s.pod_target_xcconfig = {
51
70
  "USE_HEADERMAP" => "YES",
52
- "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Headers/Private/React-Core\" "
71
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Headers/Private/React-Core\" "
53
72
  }
54
73
  s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
55
74
  s.xcconfig = {
56
75
  "CLANG_CXX_LANGUAGE_STANDARD" => "c++14",
57
- "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"${PODS_ROOT}/Headers/Public/React-hermes\" \"${PODS_ROOT}/Headers/Public/hermes-engine\"",
76
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"${PODS_ROOT}/Headers/Public/React-hermes\" \"${PODS_ROOT}/Headers/Public/hermes-engine\"",
58
77
  "OTHER_CFLAGS" => "$(inherited)" + " " + folly_flags }
59
78
 
60
79
  s.requires_arc = true
@@ -74,7 +93,6 @@ Pod::Spec.new do |s|
74
93
  s.dependency 'React-RCTBlob'
75
94
  s.dependency 'React-RCTSettings'
76
95
  s.dependency 'React-RCTText'
77
- s.dependency 'React-RCTVibration'
78
96
  s.dependency 'React-RCTImage'
79
97
  s.dependency 'React-Core/RCTWebSocket'
80
98
  s.dependency 'React-cxxreact'
@@ -13,21 +13,15 @@ def engine = "jsc"
13
13
  abstract class replaceSoTask extends DefaultTask {
14
14
  public static String appName = ":app"
15
15
  public static String buildDir = "../../../android/app/build"
16
- public static String engine = "jsc"
17
- public static String reactVersion = "64"
18
16
 
19
17
  @TaskAction
20
18
  def run() {
21
- ant.unzip(
22
- src: "./react-native-reanimated-${reactVersion}-${engine}.aar",
23
- dest: "./tmp"
24
- )
25
19
  for(def abiVersion in ["x86", "x86_64", "armeabi-v7a", "arm64-v8a"]) {
26
20
  ant.sequential {
27
21
  copy(
28
- tofile: "${buildDir}/intermediates/merged_native_libs/debug/out/lib/${abiVersion}/libfbjni.so",
29
- file: "./tmp/jni/${abiVersion}/libfbjni.so",
30
- overwrite: true
22
+ tofile: "${buildDir}/intermediates/merged_native_libs/debug/out/lib/${abiVersion}/libfbjni.so",
23
+ file: "../libSo/fbjni/jni/${abiVersion}/libfbjni.so",
24
+ overwrite: true
31
25
  )
32
26
  }
33
27
  }
@@ -37,20 +31,14 @@ abstract class replaceSoTask extends DefaultTask {
37
31
  def getCurrentFlavor() {
38
32
  Gradle gradle = getGradle()
39
33
  String taskRequestName = gradle.getStartParameter().getTaskRequests().toString()
40
- Pattern pattern
41
-
42
- if(taskRequestName.contains("assemble")) {
43
- pattern = Pattern.compile("assemble(\\w+)(Release|Debug)")
44
- }
45
- else {
46
- pattern = Pattern.compile("generate(\\w+)(Release|Debug)")
47
- }
34
+ Pattern pattern = Pattern.compile("(assemble|bundle|install|generate)(\\w*)(Release|Debug)")
48
35
  Matcher matcher = pattern.matcher(taskRequestName)
49
36
 
50
37
  if(matcher.find()) {
51
- return matcher.group(1).toLowerCase()
38
+ return matcher.group(2)
52
39
  }
53
- return ""
40
+
41
+ return "NOT-FOUND"
54
42
  }
55
43
 
56
44
  def replaceSoTaskDebug
@@ -70,26 +58,24 @@ rootProject.getSubprojects().forEach({project ->
70
58
 
71
59
  if(project.getProperties().get("android") && Integer.parseInt(minor) < 65) {
72
60
  def projectProperties = project.getProperties()
73
- if(!projectProperties.get("reanimated")
74
- || (projectProperties.get("reanimated") && projectProperties.get("reanimated").get("enablePackagingOptions"))
61
+ final NOTFOUND = "NOT-FOUND"
62
+ if(!NOTFOUND.equals(getCurrentFlavor()) && (!projectProperties.get("reanimated")
63
+ || (projectProperties.get("reanimated") && projectProperties.get("reanimated").get("enablePackagingOptions")))
75
64
  ) {
76
65
  def flavorString = getCurrentFlavor()
77
66
  replaceSoTask.appName = project.getProperties().path
78
67
  replaceSoTask.buildDir = project.getProperties().buildDir
79
- replaceSoTask.engine = engine
80
- replaceSoTask.reactVersion = minor
81
68
  def appName = project.getProperties().path
82
- project.getProperties().android.packagingOptions.pickFirst("lib/**/libfbjni.so")
83
69
 
84
70
  replaceSoTaskDebug.dependsOn(
85
- project.getTasks().getByPath("${appName}:merge${flavorString}DebugNativeLibs"),
86
- project.getTasks().getByPath("${appName}:strip${flavorString}DebugDebugSymbols")
71
+ project.getTasks().getByPath("${appName}:merge${flavorString}DebugNativeLibs"),
72
+ project.getTasks().getByPath("${appName}:strip${flavorString}DebugDebugSymbols")
87
73
  )
88
74
  project.getTasks().getByPath("${appName}:package${flavorString}Debug").dependsOn(replaceSoTaskDebug)
89
75
 
90
76
  replaceSoTaskRelease.dependsOn(
91
- project.getTasks().getByPath("${appName}:merge${flavorString}ReleaseNativeLibs"),
92
- project.getTasks().getByPath("${appName}:strip${flavorString}ReleaseDebugSymbols")
77
+ project.getTasks().getByPath("${appName}:merge${flavorString}ReleaseNativeLibs"),
78
+ project.getTasks().getByPath("${appName}:strip${flavorString}ReleaseDebugSymbols")
93
79
  )
94
80
  project.getTasks().getByPath("${appName}:package${flavorString}Release").dependsOn(replaceSoTaskRelease)
95
81
  }
@@ -97,4 +83,27 @@ rootProject.getSubprojects().forEach({project ->
97
83
  }
98
84
  })
99
85
 
100
- artifacts.add("default", file("react-native-reanimated-${minor}-${engine}.aar"))
86
+ def minorCopy = Integer.parseInt(minor)
87
+ def aar = file("react-native-reanimated-${minorCopy}-${engine}.aar")
88
+
89
+ while (!aar.exists()) {
90
+ minorCopy -= 1
91
+ aar = file("react-native-reanimated-${minorCopy}-${engine}.aar")
92
+ if (minorCopy < 63) {
93
+ throw new GradleException('No aar for react-native-reanimated found.')
94
+ }
95
+ if (aar.exists()) {
96
+ println "\n\n\n"
97
+ println "****************************************************************************************"
98
+ println "\n\n\n"
99
+ println "WARNING reanimated - no version-specific reanimated AAR for react-native version " . minor . " found."
100
+ println "Falling back to AAR for react-native version " . minorCopy
101
+ println "The react-native JSI interface is not ABI-safe yet, this may result in crashes."
102
+ println "Please post a pull request to implement support for react-native version " . minor . " to the reanimated repo."
103
+ println "Thanks!"
104
+ println "\n\n\n"
105
+ println "****************************************************************************************"
106
+ }
107
+ }
108
+
109
+ artifacts.add("default", aar)
@@ -14,16 +14,18 @@ typedef NS_ENUM(NSInteger, ViewState) {
14
14
 
15
15
  @interface REAAnimationsManager : NSObject
16
16
 
17
- - (instancetype)initWithUIManager:(RCTUIManager*)uiManager;
17
+ - (instancetype)initWithUIManager:(RCTUIManager *)uiManager;
18
18
  - (void)setRemovingConfigBlock:(void (^)(NSNumber *tag))block;
19
- - (void)setAnimationStartingBlock:(void (^)(NSNumber *tag, NSString *type, NSDictionary* target, NSNumber* depth))startAnimation;
20
- - (void)notifyAboutProgress:(NSDictionary *)newStyle tag:(NSNumber*)tag;
21
- - (void)notifyAboutEnd:(NSNumber*)tag cancelled:(BOOL)cancelled;
19
+ - (void)setAnimationStartingBlock:
20
+ (void (^)(NSNumber *tag, NSString *type, NSDictionary *target, NSNumber *depth))startAnimation;
21
+ - (void)notifyAboutProgress:(NSDictionary *)newStyle tag:(NSNumber *)tag;
22
+ - (void)notifyAboutEnd:(NSNumber *)tag cancelled:(BOOL)cancelled;
22
23
  - (void)invalidate;
23
- - (void) onViewRemoval:(UIView*)view before:(REASnapshot*)before;
24
- - (void) onViewCreate:(UIView*)view after:(REASnapshot*)after;
25
- - (void) onViewUpdate:(UIView*)view before:(REASnapshot*)before after:(REASnapshot*)after;
26
- - (void) setToBeRemovedRegistry:(NSMutableDictionary<NSNumber*, NSMutableSet<id<RCTComponent>>*>*) toBeRemovedRegister;
24
+ - (void)onViewRemoval:(UIView *)view before:(REASnapshot *)before;
25
+ - (void)onViewCreate:(UIView *)view after:(REASnapshot *)after;
26
+ - (void)onViewUpdate:(UIView *)view before:(REASnapshot *)before after:(REASnapshot *)after;
27
+ - (void)setToBeRemovedRegistry:(NSMutableDictionary<NSNumber *, NSMutableSet<id<RCTComponent>> *> *)toBeRemovedRegister;
28
+ - (void)removeLeftovers;
27
29
 
28
30
  @end
29
31