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
@@ -5,20 +5,24 @@ namespace reanimated {
5
5
 
6
6
  std::unique_ptr<LoggerInterface> Logger::instance = std::make_unique<REAIOSLogger>();
7
7
 
8
- void REAIOSLogger::log(const char* str) {
8
+ void REAIOSLogger::log(const char *str)
9
+ {
9
10
  NSLog(@"%@", [NSString stringWithCString:str encoding:[NSString defaultCStringEncoding]]);
10
11
  }
11
12
 
12
- void REAIOSLogger::log(double d) {
13
+ void REAIOSLogger::log(double d)
14
+ {
13
15
  NSLog(@"%lf", d);
14
16
  }
15
17
 
16
- void REAIOSLogger::log(int i) {
17
- NSLog(@"%i", i);
18
+ void REAIOSLogger::log(int i)
19
+ {
20
+ NSLog(@"%i", i);
18
21
  }
19
22
 
20
- void REAIOSLogger::log(bool b) {
21
- const char* str = (b)? "true" : "false";
23
+ void REAIOSLogger::log(bool b)
24
+ {
25
+ const char *str = (b) ? "true" : "false";
22
26
  NSLog(@"%@", [NSString stringWithCString:str encoding:[NSString defaultCStringEncoding]]);
23
27
  }
24
28
 
@@ -1,18 +1,18 @@
1
1
  #pragma once
2
2
 
3
+ #import <React/RCTUIManager.h>
4
+ #import <ReactCommon/CallInvoker.h>
3
5
  #include <stdio.h>
6
+ #include <memory>
4
7
  #include "Scheduler.h"
5
- #import <ReactCommon/CallInvoker.h>
6
- #import <React/RCTUIManager.h>
7
8
 
8
- namespace reanimated
9
- {
9
+ namespace reanimated {
10
10
 
11
11
  using namespace facebook;
12
12
  using namespace react;
13
13
 
14
14
  class REAIOSScheduler : public Scheduler {
15
- public:
15
+ public:
16
16
  REAIOSScheduler(std::shared_ptr<CallInvoker> jsInvoker);
17
17
  void scheduleOnUI(std::function<void()> job) override;
18
18
  virtual ~REAIOSScheduler();
@@ -6,36 +6,43 @@ namespace reanimated {
6
6
  using namespace facebook;
7
7
  using namespace react;
8
8
 
9
- REAIOSScheduler::REAIOSScheduler(std::shared_ptr<CallInvoker> jsInvoker) {
9
+ REAIOSScheduler::REAIOSScheduler(std::shared_ptr<CallInvoker> jsInvoker)
10
+ {
10
11
  this->jsCallInvoker_ = jsInvoker;
11
12
  }
12
13
 
13
- void REAIOSScheduler::scheduleOnUI(std::function<void()> job) {
14
+ void REAIOSScheduler::scheduleOnUI(std::function<void()> job)
15
+ {
14
16
  if (runtimeManager.lock() == nullptr) {
15
17
  return;
16
18
  }
17
19
 
18
- if([NSThread isMainThread]) {
19
- if (runtimeManager.lock()) job();
20
+ if ([NSThread isMainThread]) {
21
+ if (runtimeManager.lock()) {
22
+ job();
23
+ }
20
24
  return;
21
25
  }
22
26
 
23
27
  Scheduler::scheduleOnUI(job);
24
- if([NSThread isMainThread]) {
25
- if (runtimeManager.lock()) triggerUI();
28
+ if ([NSThread isMainThread]) {
29
+ if (runtimeManager.lock()) {
30
+ triggerUI();
31
+ }
26
32
  return;
27
33
  }
28
-
34
+
29
35
  if (!this->scheduledOnUI) {
30
36
  __block std::weak_ptr<RuntimeManager> blockRuntimeManager = runtimeManager;
31
37
 
32
38
  dispatch_async(dispatch_get_main_queue(), ^{
33
- if (blockRuntimeManager.lock()) triggerUI();
39
+ if (blockRuntimeManager.lock()) {
40
+ triggerUI();
41
+ }
34
42
  });
35
43
  }
36
44
  }
37
45
 
38
- REAIOSScheduler::~REAIOSScheduler(){
39
- }
46
+ REAIOSScheduler::~REAIOSScheduler() {}
40
47
 
41
48
  }
@@ -6,13 +6,12 @@
6
6
  //
7
7
 
8
8
  #import <Foundation/Foundation.h>
9
- #import <React/RCTCxxBridgeDelegate.h>
10
9
  #import <RNReanimated/NativeProxy.h>
10
+ #import <RNReanimated/REAEventDispatcher.h>
11
11
  #import <RNReanimated/REAModule.h>
12
- #import <ReactCommon/RCTTurboModuleManager.h>
13
12
  #import <React/RCTBridge+Private.h>
14
13
  #import <React/RCTCxxBridgeDelegate.h>
15
- #import <RNReanimated/REAEventDispatcher.h>
14
+ #import <ReactCommon/RCTTurboModuleManager.h>
16
15
  #import <jsireact/JSIExecutor.h>
17
16
 
18
17
  #if RNVERSION >= 64
@@ -31,9 +30,8 @@ using namespace facebook;
31
30
  using namespace react;
32
31
 
33
32
  JSIExecutor::RuntimeInstaller REAJSIExecutorRuntimeInstaller(
34
- RCTBridge* bridge,
35
- JSIExecutor::RuntimeInstaller runtimeInstallerToWrap
36
- );
33
+ RCTBridge *bridge,
34
+ JSIExecutor::RuntimeInstaller runtimeInstallerToWrap);
37
35
 
38
- }
36
+ } // namespace reanimated
39
37
  NS_ASSUME_NONNULL_END
@@ -1,9 +1,9 @@
1
1
  #import "REAInitializer.h"
2
2
  #import "REAUIManager.h"
3
3
 
4
- @interface RCTEventDispatcher(Reanimated)
4
+ @interface RCTEventDispatcher (Reanimated)
5
5
 
6
- - (void)setBridge:(RCTBridge*)bridge;
6
+ - (void)setBridge:(RCTBridge *)bridge;
7
7
 
8
8
  @end
9
9
 
@@ -13,42 +13,54 @@ using namespace facebook;
13
13
  using namespace react;
14
14
 
15
15
  JSIExecutor::RuntimeInstaller REAJSIExecutorRuntimeInstaller(
16
- RCTBridge* bridge,
16
+ RCTBridge *bridge,
17
17
  JSIExecutor::RuntimeInstaller runtimeInstallerToWrap)
18
18
  {
19
- [bridge moduleForClass:[RCTUIManager class]];
20
- REAUIManager* reaUiManager = [REAUIManager new];
21
- [reaUiManager setBridge:bridge];
22
- RCTUIManager* uiManager = reaUiManager;
23
- [bridge updateModuleWithInstance:uiManager];
24
-
25
- [bridge moduleForClass:[RCTEventDispatcher class]];
26
- RCTEventDispatcher *eventDispatcher = [REAEventDispatcher new];
27
- [eventDispatcher setBridge:bridge];
28
- [bridge updateModuleWithInstance:eventDispatcher];
29
- _bridge_reanimated = bridge;
30
- const auto runtimeInstaller = [bridge, runtimeInstallerToWrap](facebook::jsi::Runtime &runtime) {
31
- if (!bridge) {
32
- return;
33
- }
19
+ [bridge moduleForClass:[RCTUIManager class]];
20
+ REAUIManager *reaUiManager = [REAUIManager new];
21
+ [reaUiManager setBridge:bridge];
22
+ RCTUIManager *uiManager = reaUiManager;
23
+ [bridge updateModuleWithInstance:uiManager];
24
+
25
+ [bridge moduleForClass:[RCTEventDispatcher class]];
26
+ RCTEventDispatcher *eventDispatcher = [REAEventDispatcher new];
27
+ #if RNVERSION >= 66
28
+ RCTCallableJSModules *callableJSModules = [RCTCallableJSModules new];
29
+ [bridge setValue:callableJSModules forKey:@"_callableJSModules"];
30
+ [callableJSModules setBridge:bridge];
31
+ [eventDispatcher setValue:callableJSModules forKey:@"_callableJSModules"];
32
+ [eventDispatcher setValue:bridge forKey:@"_bridge"];
33
+ [eventDispatcher initialize];
34
+ #else
35
+ [eventDispatcher setBridge:bridge];
36
+ #endif
37
+ [bridge updateModuleWithInstance:eventDispatcher];
38
+ const auto runtimeInstaller = [bridge, runtimeInstallerToWrap](facebook::jsi::Runtime &runtime) {
39
+ if (!bridge) {
40
+ return;
41
+ }
34
42
  #if RNVERSION >= 63
35
- auto reanimatedModule = reanimated::createReanimatedModule(bridge.jsCallInvoker);
43
+ auto reanimatedModule = reanimated::createReanimatedModule(bridge, bridge.jsCallInvoker);
36
44
  #else
37
45
  auto callInvoker = std::make_shared<react::BridgeJSCallInvoker>(bridge.reactInstance);
38
- auto reanimatedModule = reanimated::createReanimatedModule(callInvoker);
46
+ auto reanimatedModule = reanimated::createReanimatedModule(bridge, callInvoker);
39
47
  #endif
40
- runtime.global().setProperty(runtime,
41
- jsi::PropNameID::forAscii(runtime, "__reanimatedModuleProxy"),
42
- jsi::Object::createFromHostObject(runtime, reanimatedModule));
43
-
44
- if (runtimeInstallerToWrap) {
45
- runtimeInstallerToWrap(runtime);
46
- }
47
- };
48
- return runtimeInstaller;
49
- }
48
+ runtime.global().setProperty(
49
+ runtime,
50
+ "_WORKLET_RUNTIME",
51
+ static_cast<double>(
52
+ reinterpret_cast<std::uintptr_t>(reanimatedModule->runtime.get())));
50
53
 
54
+ runtime.global().setProperty(
55
+ runtime,
56
+ jsi::PropNameID::forAscii(runtime, "__reanimatedModuleProxy"),
57
+ jsi::Object::createFromHostObject(runtime, reanimatedModule));
51
58
 
59
+ if (runtimeInstallerToWrap) {
60
+ runtimeInstallerToWrap(runtime);
61
+ }
62
+ };
63
+ return runtimeInstaller;
52
64
  }
53
65
 
54
-
66
+ }
@@ -1,6 +1,6 @@
1
- #import "UIResponder+Reanimated.h"
2
- #import "REAUIManager.h"
3
1
  #import "REAInitializer.h"
2
+ #import "REAUIManager.h"
3
+ #import "UIResponder+Reanimated.h"
4
4
 
5
5
  #if __has_include(<reacthermes/HermesExecutorFactory.h>)
6
6
  #import <reacthermes/HermesExecutorFactory.h>
package/lib/Animated.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Image, ScrollView, Text, View } from 'react-native';
1
+ import { Image, ScrollView, Text, View, LogBox } from 'react-native';
2
2
  import createAnimatedComponent from './createAnimatedComponent';
3
3
  import {
4
4
  addWhitelistedNativeProps,
@@ -23,3 +23,11 @@ const Animated = {
23
23
  export * from './reanimated2';
24
24
  export * from './reanimated1';
25
25
  export default Animated;
26
+
27
+ // I think we can ignore this message as long as Gesture Handler doesn't
28
+ // try to load the Reanimated module. I figured it should be here instead of
29
+ // RNGH because this prevents the message from being displayed for all
30
+ // versions of RNGH.
31
+ LogBox.ignoreLogs([
32
+ 'RCTBridge required dispatch_sync to load RNGestureHandlerModule. This may lead to deadlocks',
33
+ ]);
@@ -1,163 +1,146 @@
1
1
  import ReanimatedModule from './ReanimatedModule';
2
-
3
2
  /**
4
3
  * Styles allowed to be direcly updated in UI thread
5
4
  */
6
5
  let UI_THREAD_PROPS_WHITELIST = {
7
- opacity: true,
8
- transform: true,
9
- /* colors */
10
- backgroundColor: true,
11
- borderRightColor: true,
12
- borderBottomColor: true,
13
- borderColor: true,
14
- borderEndColor: true,
15
- borderLeftColor: true,
16
- borderStartColor: true,
17
- borderTopColor: true,
18
- /* ios styles */
19
- shadowOpacity: true,
20
- shadowRadius: true,
21
- /* legacy android transform properties */
22
- scaleX: true,
23
- scaleY: true,
24
- translateX: true,
25
- translateY: true,
6
+ opacity: true,
7
+ transform: true,
8
+ /* colors */
9
+ backgroundColor: true,
10
+ borderRightColor: true,
11
+ borderBottomColor: true,
12
+ borderColor: true,
13
+ borderEndColor: true,
14
+ borderLeftColor: true,
15
+ borderStartColor: true,
16
+ borderTopColor: true,
17
+ /* ios styles */
18
+ shadowOpacity: true,
19
+ shadowRadius: true,
20
+ /* legacy android transform properties */
21
+ scaleX: true,
22
+ scaleY: true,
23
+ translateX: true,
24
+ translateY: true,
26
25
  };
27
-
28
26
  /**
29
27
  * Whitelist of view props that can be updated in native thread via UIManagerModule
30
28
  */
31
29
  let NATIVE_THREAD_PROPS_WHITELIST = {
32
- borderBottomWidth: true,
33
- borderEndWidth: true,
34
- borderLeftWidth: true,
35
- borderRightWidth: true,
36
- borderStartWidth: true,
37
- borderTopWidth: true,
38
- borderWidth: true,
39
- bottom: true,
40
- flex: true,
41
- flexGrow: true,
42
- flexShrink: true,
43
- height: true,
44
- left: true,
45
- margin: true,
46
- marginBottom: true,
47
- marginEnd: true,
48
- marginHorizontal: true,
49
- marginLeft: true,
50
- marginRight: true,
51
- marginStart: true,
52
- marginTop: true,
53
- marginVertical: true,
54
- maxHeight: true,
55
- maxWidth: true,
56
- minHeight: true,
57
- minWidth: true,
58
- padding: true,
59
- paddingBottom: true,
60
- paddingEnd: true,
61
- paddingHorizontal: true,
62
- paddingLeft: true,
63
- paddingRight: true,
64
- paddingStart: true,
65
- paddingTop: true,
66
- paddingVertical: true,
67
- right: true,
68
- start: true,
69
- top: true,
70
- width: true,
71
- zIndex: true,
72
- borderBottomEndRadius: true,
73
- borderBottomLeftRadius: true,
74
- borderBottomRightRadius: true,
75
- borderBottomStartRadius: true,
76
- borderRadius: true,
77
- borderTopEndRadius: true,
78
- borderTopLeftRadius: true,
79
- borderTopRightRadius: true,
80
- borderTopStartRadius: true,
81
- opacity: true,
82
- elevation: true,
83
- fontSize: true,
84
- lineHeight: true,
85
- textShadowRadius: true,
86
- letterSpacing: true,
87
- /* strings */
88
- display: true,
89
- backfaceVisibility: true,
90
- overflow: true,
91
- resizeMode: true,
92
- fontStyle: true,
93
- fontWeight: true,
94
- textAlign: true,
95
- textDecorationLine: true,
96
- fontFamily: true,
97
- textAlignVertical: true,
98
- fontVariant: true,
99
- textDecorationStyle: true,
100
- textTransform: true,
101
- writingDirection: true,
102
- /* text color */
103
- color: true,
104
- tintColor: true,
105
- shadowColor: true,
106
- placeholderTextColor: true,
30
+ borderBottomWidth: true,
31
+ borderEndWidth: true,
32
+ borderLeftWidth: true,
33
+ borderRightWidth: true,
34
+ borderStartWidth: true,
35
+ borderTopWidth: true,
36
+ borderWidth: true,
37
+ bottom: true,
38
+ flex: true,
39
+ flexGrow: true,
40
+ flexShrink: true,
41
+ height: true,
42
+ left: true,
43
+ margin: true,
44
+ marginBottom: true,
45
+ marginEnd: true,
46
+ marginHorizontal: true,
47
+ marginLeft: true,
48
+ marginRight: true,
49
+ marginStart: true,
50
+ marginTop: true,
51
+ marginVertical: true,
52
+ maxHeight: true,
53
+ maxWidth: true,
54
+ minHeight: true,
55
+ minWidth: true,
56
+ padding: true,
57
+ paddingBottom: true,
58
+ paddingEnd: true,
59
+ paddingHorizontal: true,
60
+ paddingLeft: true,
61
+ paddingRight: true,
62
+ paddingStart: true,
63
+ paddingTop: true,
64
+ paddingVertical: true,
65
+ right: true,
66
+ start: true,
67
+ top: true,
68
+ width: true,
69
+ zIndex: true,
70
+ borderBottomEndRadius: true,
71
+ borderBottomLeftRadius: true,
72
+ borderBottomRightRadius: true,
73
+ borderBottomStartRadius: true,
74
+ borderRadius: true,
75
+ borderTopEndRadius: true,
76
+ borderTopLeftRadius: true,
77
+ borderTopRightRadius: true,
78
+ borderTopStartRadius: true,
79
+ opacity: true,
80
+ elevation: true,
81
+ fontSize: true,
82
+ lineHeight: true,
83
+ textShadowRadius: true,
84
+ letterSpacing: true,
85
+ /* strings */
86
+ display: true,
87
+ backfaceVisibility: true,
88
+ overflow: true,
89
+ resizeMode: true,
90
+ fontStyle: true,
91
+ fontWeight: true,
92
+ textAlign: true,
93
+ textDecorationLine: true,
94
+ fontFamily: true,
95
+ textAlignVertical: true,
96
+ fontVariant: true,
97
+ textDecorationStyle: true,
98
+ textTransform: true,
99
+ writingDirection: true,
100
+ /* text color */
101
+ color: true,
102
+ tintColor: true,
103
+ shadowColor: true,
104
+ placeholderTextColor: true,
107
105
  };
108
-
109
106
  function configureProps() {
110
- ReanimatedModule.configureProps(
111
- Object.keys(NATIVE_THREAD_PROPS_WHITELIST),
112
- Object.keys(UI_THREAD_PROPS_WHITELIST)
113
- );
107
+ ReanimatedModule.configureProps(Object.keys(NATIVE_THREAD_PROPS_WHITELIST), Object.keys(UI_THREAD_PROPS_WHITELIST));
114
108
  }
115
-
116
109
  export function addWhitelistedNativeProps(props) {
117
- const oldSize = Object.keys(NATIVE_THREAD_PROPS_WHITELIST).length;
118
- NATIVE_THREAD_PROPS_WHITELIST = {
119
- ...NATIVE_THREAD_PROPS_WHITELIST,
120
- ...props,
121
- };
122
- if (oldSize !== Object.keys(NATIVE_THREAD_PROPS_WHITELIST).length) {
123
- configureProps();
124
- }
110
+ const oldSize = Object.keys(NATIVE_THREAD_PROPS_WHITELIST).length;
111
+ NATIVE_THREAD_PROPS_WHITELIST = Object.assign(Object.assign({}, NATIVE_THREAD_PROPS_WHITELIST), props);
112
+ if (oldSize !== Object.keys(NATIVE_THREAD_PROPS_WHITELIST).length) {
113
+ configureProps();
114
+ }
125
115
  }
126
-
127
116
  export function addWhitelistedUIProps(props) {
128
- const oldSize = Object.keys(UI_THREAD_PROPS_WHITELIST).length;
129
- UI_THREAD_PROPS_WHITELIST = { ...UI_THREAD_PROPS_WHITELIST, ...props };
130
- if (oldSize !== Object.keys(UI_THREAD_PROPS_WHITELIST).length) {
131
- configureProps();
132
- }
117
+ const oldSize = Object.keys(UI_THREAD_PROPS_WHITELIST).length;
118
+ UI_THREAD_PROPS_WHITELIST = Object.assign(Object.assign({}, UI_THREAD_PROPS_WHITELIST), props);
119
+ if (oldSize !== Object.keys(UI_THREAD_PROPS_WHITELIST).length) {
120
+ configureProps();
121
+ }
133
122
  }
134
-
135
123
  const PROCESSED_VIEW_NAMES = new Set();
136
124
  /**
137
125
  * updates UI props whitelist for given view host instance
138
126
  * this will work just once for every view name
139
127
  */
140
128
  export function adaptViewConfig(viewConfig) {
141
- const viewName = viewConfig.uiViewClassName;
142
- const props = viewConfig.validAttributes;
143
-
144
- // update whitelist of UI props for this view name only once
145
- if (!PROCESSED_VIEW_NAMES.has(viewName)) {
146
- const propsToAdd = {};
147
- Object.keys(props).forEach((key) => {
148
- // we don't want to add native props as they affect layout
149
- // we also skip props which repeat here
150
- if (
151
- !(key in NATIVE_THREAD_PROPS_WHITELIST) &&
152
- !(key in UI_THREAD_PROPS_WHITELIST)
153
- ) {
154
- propsToAdd[key] = true;
155
- }
156
- });
157
- addWhitelistedUIProps(propsToAdd);
158
-
159
- PROCESSED_VIEW_NAMES.add(viewName);
160
- }
129
+ const viewName = viewConfig.uiViewClassName;
130
+ const props = viewConfig.validAttributes;
131
+ // update whitelist of UI props for this view name only once
132
+ if (!PROCESSED_VIEW_NAMES.has(viewName)) {
133
+ const propsToAdd = {};
134
+ Object.keys(props).forEach((key) => {
135
+ // we don't want to add native props as they affect layout
136
+ // we also skip props which repeat here
137
+ if (!(key in NATIVE_THREAD_PROPS_WHITELIST) &&
138
+ !(key in UI_THREAD_PROPS_WHITELIST)) {
139
+ propsToAdd[key] = true;
140
+ }
141
+ });
142
+ addWhitelistedUIProps(propsToAdd);
143
+ PROCESSED_VIEW_NAMES.add(viewName);
144
+ }
161
145
  }
162
-
163
146
  configureProps();
@@ -1,4 +1,3 @@
1
1
  import ReanimatedModule from './ReanimatedModule';
2
2
  import { NativeEventEmitter } from 'react-native';
3
-
4
3
  export default new NativeEventEmitter(ReanimatedModule);
@@ -1,3 +1,2 @@
1
1
  import ReanimatedModuleCompat from './ReanimatedModuleCompat';
2
-
3
2
  export default ReanimatedModuleCompat;
@@ -1,3 +1,2 @@
1
1
  import ReanimatedModuleCompat from './ReanimatedModuleCompat';
2
-
3
2
  export default ReanimatedModuleCompat;
@@ -1,13 +1,12 @@
1
1
  import { NativeModules } from 'react-native';
2
2
  import ReanimatedModuleCompat from './ReanimatedModuleCompat';
3
3
  import { nativeShouldBeMock } from './reanimated2/PlatformChecker';
4
-
5
4
  let exportedModule;
6
5
  if (nativeShouldBeMock()) {
7
- exportedModule = ReanimatedModuleCompat;
8
- } else {
9
- const { ReanimatedModule } = NativeModules;
10
- exportedModule = ReanimatedModule;
6
+ exportedModule = ReanimatedModuleCompat;
7
+ }
8
+ else {
9
+ const { ReanimatedModule } = NativeModules;
10
+ exportedModule = ReanimatedModule;
11
11
  }
12
-
13
12
  export default exportedModule;
@@ -1,3 +1,2 @@
1
1
  import ReanimatedModuleCompat from './ReanimatedModuleCompat';
2
-
3
2
  export default ReanimatedModuleCompat;