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,14 +1,14 @@
1
1
  #import "REAAnimationsManager.h"
2
2
  #import <React/RCTComponentData.h>
3
- #import <React/UIView+React.h>
3
+ #import <React/RCTTextView.h>
4
4
  #import <React/UIView+Private.h>
5
+ #import <React/UIView+React.h>
5
6
  #import "REAUIManager.h"
6
- #import <React/RCTTextView.h>
7
7
 
8
8
  @interface REAAnimationsManager ()
9
9
 
10
- @property (atomic, nullable) void(^startAnimationForTag)(NSNumber *, NSString *, NSDictionary *, NSNumber*);
11
- @property (atomic, nullable) void(^removeConfigForTag)(NSNumber *);
10
+ @property (atomic, nullable) void (^startAnimationForTag)(NSNumber *, NSString *, NSDictionary *, NSNumber *);
11
+ @property (atomic, nullable) void (^removeConfigForTag)(NSNumber *);
12
12
 
13
13
  - (void)removeLeftovers;
14
14
  - (void)scheduleCleaning;
@@ -16,29 +16,29 @@
16
16
  @end
17
17
 
18
18
  @implementation REAAnimationsManager {
19
- RCTUIManager* _uiManager;
20
- REAUIManager* _reaUiManager;
21
- NSMutableDictionary<NSNumber*, NSNumber *>* _states;
22
- NSMutableDictionary<NSNumber*, UIView *>* _viewForTag;
23
- NSMutableSet<NSNumber*>* _toRemove;
19
+ RCTUIManager *_uiManager;
20
+ REAUIManager *_reaUiManager;
21
+ NSMutableDictionary<NSNumber *, NSNumber *> *_states;
22
+ NSMutableDictionary<NSNumber *, UIView *> *_viewForTag;
23
+ NSMutableSet<NSNumber *> *_toRemove;
24
24
  BOOL _cleaningScheduled;
25
25
  }
26
26
 
27
27
  + (NSArray *)layoutKeys
28
28
  {
29
- static NSArray *_array;
30
- static dispatch_once_t onceToken;
31
- dispatch_once(&onceToken, ^{
32
- _array = @[@"originX", @"originY", @"width", @"height"];
33
- });
34
- return _array;
29
+ static NSArray *_array;
30
+ static dispatch_once_t onceToken;
31
+ dispatch_once(&onceToken, ^{
32
+ _array = @[ @"originX", @"originY", @"width", @"height" ];
33
+ });
34
+ return _array;
35
35
  }
36
36
 
37
37
  - (instancetype)initWithUIManager:(RCTUIManager *)uiManager
38
38
  {
39
39
  if (self = [super init]) {
40
40
  _uiManager = uiManager;
41
- _reaUiManager = (REAUIManager*)uiManager;
41
+ _reaUiManager = (REAUIManager *)uiManager;
42
42
  _states = [NSMutableDictionary new];
43
43
  _viewForTag = [NSMutableDictionary new];
44
44
  _toRemove = [NSMutableSet new];
@@ -58,7 +58,8 @@
58
58
  _cleaningScheduled = false;
59
59
  }
60
60
 
61
- - (void)setAnimationStartingBlock:(void (^)(NSNumber * tag, NSString * type, NSDictionary* yogaValues, NSNumber* depth))startAnimation
61
+ - (void)setAnimationStartingBlock:
62
+ (void (^)(NSNumber *tag, NSString *type, NSDictionary *yogaValues, NSNumber *depth))startAnimation
62
63
  {
63
64
  _startAnimationForTag = startAnimation;
64
65
  }
@@ -70,11 +71,11 @@
70
71
 
71
72
  - (void)scheduleCleaning
72
73
  {
73
- if(_cleaningScheduled) {
74
+ if (_cleaningScheduled) {
74
75
  return;
75
76
  }
76
77
  _cleaningScheduled = true;
77
-
78
+
78
79
  __weak REAAnimationsManager *weakSelf = self;
79
80
  dispatch_async(dispatch_get_main_queue(), ^{
80
81
  self->_cleaningScheduled = false;
@@ -85,44 +86,44 @@
85
86
  });
86
87
  }
87
88
 
88
- - (void) findRoot:(UIView*)view roots:(NSMutableSet<NSNumber*>*)roots
89
+ - (void)findRoot:(UIView *)view roots:(NSMutableSet<NSNumber *> *)roots
89
90
  {
90
- UIView* currentView = view;
91
- NSNumber* lastToRemoveTag = nil;
91
+ UIView *currentView = view;
92
+ NSNumber *lastToRemoveTag = nil;
92
93
  while (currentView != nil) {
93
94
  ViewState state = [_states[currentView.reactTag] intValue];
94
- if(state == Disappearing) {
95
+ if (state == Disappearing) {
95
96
  return;
96
97
  }
97
- if(state == ToRemove) {
98
+ if (state == ToRemove) {
98
99
  lastToRemoveTag = currentView.reactTag;
99
100
  }
100
101
  currentView = currentView.superview;
101
102
  }
102
- if(lastToRemoveTag != nil) {
103
+ if (lastToRemoveTag != nil) {
103
104
  [roots addObject:lastToRemoveTag];
104
105
  }
105
106
  }
106
107
 
107
- - (BOOL) dfs:(UIView*)root view:(UIView*)view cands:(NSMutableSet<NSNumber*>*)cands
108
+ - (BOOL)dfs:(UIView *)root view:(UIView *)view cands:(NSMutableSet<NSNumber *> *)cands
108
109
  {
109
- NSNumber* tag = view.reactTag;
110
+ NSNumber *tag = view.reactTag;
110
111
  if (tag == nil) {
111
112
  return true;
112
113
  }
113
- if(![cands containsObject:tag] && _states[tag] != nil) {
114
+ if (![cands containsObject:tag] && _states[tag] != nil) {
114
115
  return true;
115
116
  }
116
117
  BOOL cannotStripe = false;
117
- NSArray<UIView*>* toRemoveCopy = [view.reactSubviews copy];
118
- for (UIView* child in toRemoveCopy) {
118
+ NSArray<UIView *> *toRemoveCopy = [view.reactSubviews copy];
119
+ for (UIView *child in toRemoveCopy) {
119
120
  if (![view isKindOfClass:[RCTTextView class]]) {
120
121
  cannotStripe |= [self dfs:root view:child cands:cands];
121
122
  }
122
123
  }
123
- if(!cannotStripe) {
124
- if(view.reactSuperview != nil) {
125
- [_reaUiManager unregisterView: view];
124
+ if (!cannotStripe) {
125
+ if (view.reactSuperview != nil) {
126
+ [_reaUiManager unregisterView:view];
126
127
  }
127
128
  [_states removeObjectForKey:tag];
128
129
  [_viewForTag removeObjectForKey:tag];
@@ -133,18 +134,18 @@
133
134
 
134
135
  - (void)removeLeftovers
135
136
  {
136
- NSMutableSet<NSNumber*>* roots = [NSMutableSet new];
137
- for(NSNumber* viewTag in _toRemove) {
138
- UIView* view = _viewForTag[viewTag];
137
+ NSMutableSet<NSNumber *> *roots = [NSMutableSet new];
138
+ for (NSNumber *viewTag in _toRemove) {
139
+ UIView *view = _viewForTag[viewTag];
139
140
  [self findRoot:view roots:roots];
140
141
  }
141
- for(NSNumber* viewTag in roots) {
142
- UIView* view = _viewForTag[viewTag];
142
+ for (NSNumber *viewTag in roots) {
143
+ UIView *view = _viewForTag[viewTag];
143
144
  [self dfs:view view:view cands:_toRemove];
144
145
  }
145
146
  }
146
147
 
147
- - (void)notifyAboutEnd:(NSNumber*)tag cancelled:(BOOL)cancelled
148
+ - (void)notifyAboutEnd:(NSNumber *)tag cancelled:(BOOL)cancelled
148
149
  {
149
150
  if (!cancelled) {
150
151
  ViewState state = [_states[tag] intValue];
@@ -153,7 +154,7 @@
153
154
  }
154
155
  if (state == Disappearing) {
155
156
  _states[tag] = [NSNumber numberWithInt:ToRemove];
156
- if(tag != nil) {
157
+ if (tag != nil) {
157
158
  [_toRemove addObject:tag];
158
159
  }
159
160
  [self scheduleCleaning];
@@ -161,7 +162,7 @@
161
162
  }
162
163
  }
163
164
 
164
- - (void)notifyAboutProgress:(NSDictionary *)newStyle tag:(NSNumber*)tag
165
+ - (void)notifyAboutProgress:(NSDictionary *)newStyle tag:(NSNumber *)tag
165
166
  {
166
167
  if (_states[tag] == nil) {
167
168
  return;
@@ -170,67 +171,69 @@
170
171
  if (state == Inactive) {
171
172
  _states[tag] = [NSNumber numberWithInt:Appearing];
172
173
  }
173
-
174
- NSMutableDictionary* dataComponenetsByName = [_uiManager valueForKey:@"_componentDataByName"];
174
+
175
+ NSMutableDictionary *dataComponenetsByName = [_uiManager valueForKey:@"_componentDataByName"];
175
176
  RCTComponentData *componentData = dataComponenetsByName[@"RCTView"];
176
177
  [self setNewProps:[newStyle mutableCopy] forView:_viewForTag[tag] withComponentData:componentData];
177
178
  }
178
179
 
179
- - (void)setNewProps:(NSMutableDictionary *)newProps forView:(UIView*)view withComponentData:(RCTComponentData*)componentData
180
+ - (void)setNewProps:(NSMutableDictionary *)newProps
181
+ forView:(UIView *)view
182
+ withComponentData:(RCTComponentData *)componentData
180
183
  {
181
184
  if (newProps[@"height"]) {
182
185
  double height = [newProps[@"height"] doubleValue];
183
186
  double oldHeight = view.bounds.size.height;
184
187
  view.bounds = CGRectMake(0, 0, view.bounds.size.width, height);
185
- view.center = CGPointMake(view.center.x, view.center.y - oldHeight/2.0 + view.bounds.size.height/2.0);
188
+ view.center = CGPointMake(view.center.x, view.center.y - oldHeight / 2.0 + view.bounds.size.height / 2.0);
186
189
  [newProps removeObjectForKey:@"height"];
187
190
  }
188
191
  if (newProps[@"width"]) {
189
192
  double width = [newProps[@"width"] doubleValue];
190
193
  double oldWidth = view.bounds.size.width;
191
194
  view.bounds = CGRectMake(0, 0, width, view.bounds.size.height);
192
- view.center = CGPointMake(view.center.x + view.bounds.size.width/2.0 - oldWidth/2.0, view.center.y);
195
+ view.center = CGPointMake(view.center.x + view.bounds.size.width / 2.0 - oldWidth / 2.0, view.center.y);
193
196
  [newProps removeObjectForKey:@"width"];
194
197
  }
195
198
  if (newProps[@"originX"]) {
196
199
  double originX = [newProps[@"originX"] doubleValue];
197
- view.center = CGPointMake(originX + view.bounds.size.width/2.0, view.center.y);
200
+ view.center = CGPointMake(originX + view.bounds.size.width / 2.0, view.center.y);
198
201
  [newProps removeObjectForKey:@"originX"];
199
202
  }
200
203
  if (newProps[@"originY"]) {
201
204
  double originY = [newProps[@"originY"] doubleValue];
202
- view.center = CGPointMake(view.center.x, originY + view.bounds.size.height/2.0);
205
+ view.center = CGPointMake(view.center.x, originY + view.bounds.size.height / 2.0);
203
206
  [newProps removeObjectForKey:@"originY"];
204
207
  }
205
208
  [componentData setProps:newProps forView:view];
206
209
  }
207
210
 
208
- - (NSDictionary*) prepareDataForAnimatingWorklet:(NSMutableDictionary*)values
211
+ - (NSDictionary *)prepareDataForAnimatingWorklet:(NSMutableDictionary *)values
209
212
  {
210
213
  UIView *windowView = UIApplication.sharedApplication.keyWindow;
211
- NSDictionary* preparedData = @{
212
- @"width": values[@"width"],
213
- @"height": values[@"height"],
214
- @"originX": values[@"originX"],
215
- @"originY": values[@"originY"],
216
- @"globalOriginX": values[@"globalOriginX"],
217
- @"globalOriginY": values[@"globalOriginY"],
218
- @"windowWidth": [NSNumber numberWithDouble:windowView.bounds.size.width],
219
- @"windowHeight": [NSNumber numberWithDouble:windowView.bounds.size.height]
214
+ NSDictionary *preparedData = @{
215
+ @"width" : values[@"width"],
216
+ @"height" : values[@"height"],
217
+ @"originX" : values[@"originX"],
218
+ @"originY" : values[@"originY"],
219
+ @"globalOriginX" : values[@"globalOriginX"],
220
+ @"globalOriginY" : values[@"globalOriginY"],
221
+ @"windowWidth" : [NSNumber numberWithDouble:windowView.bounds.size.width],
222
+ @"windowHeight" : [NSNumber numberWithDouble:windowView.bounds.size.height]
220
223
  };
221
224
  return preparedData;
222
225
  }
223
226
 
224
- - (void) onViewRemoval:(UIView*) view before:(REASnapshot*) before
227
+ - (void)onViewRemoval:(UIView *)view before:(REASnapshot *)before
225
228
  {
226
- NSNumber* tag = view.reactTag;
229
+ NSNumber *tag = view.reactTag;
227
230
  ViewState state = [_states[tag] intValue];
228
- if(state == Disappearing || state == ToRemove || tag == nil) {
231
+ if (state == Disappearing || state == ToRemove || tag == nil) {
229
232
  return;
230
233
  }
231
- NSMutableDictionary<NSString*, NSObject*>* startValues = before.values;
232
- if(state == Inactive) {
233
- if(startValues != nil) {
234
+ NSMutableDictionary<NSString *, NSObject *> *startValues = before.values;
235
+ if (state == Inactive) {
236
+ if (startValues != nil) {
234
237
  _states[tag] = [NSNumber numberWithInt:ToRemove];
235
238
  [_toRemove addObject:tag];
236
239
  [self scheduleCleaning];
@@ -238,57 +241,58 @@
238
241
  return;
239
242
  }
240
243
  _states[tag] = [NSNumber numberWithInt:Disappearing];
241
- NSDictionary* preparedValues = [self prepareDataForAnimatingWorklet:startValues];
244
+ NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:startValues];
242
245
  _startAnimationForTag(tag, @"exiting", preparedValues, @(0));
243
246
  }
244
247
 
245
- - (void) onViewCreate:(UIView*) view after:(REASnapshot*) after
248
+ - (void)onViewCreate:(UIView *)view after:(REASnapshot *)after
246
249
  {
247
- NSNumber* tag = view.reactTag;
248
- if(_states[tag] == nil) {
250
+ _reaUiManager.flushUiOperations();
251
+ NSNumber *tag = view.reactTag;
252
+ if (_states[tag] == nil) {
249
253
  _states[tag] = [NSNumber numberWithInt:Inactive];
250
254
  _viewForTag[tag] = view;
251
255
  }
252
- NSMutableDictionary* targetValues = after.values;
256
+ NSMutableDictionary *targetValues = after.values;
253
257
  ViewState state = [_states[tag] intValue];
254
- if(state == Inactive) {
255
- if(targetValues != nil) {
256
- NSDictionary* preparedValues = [self prepareDataForAnimatingWorklet:targetValues];
258
+ if (state == Inactive) {
259
+ if (targetValues != nil) {
260
+ NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:targetValues];
257
261
  _startAnimationForTag(tag, @"entering", preparedValues, @(0));
258
262
  }
259
263
  return;
260
264
  }
261
265
  }
262
266
 
263
- - (void) onViewUpdate: (UIView*) view before:(REASnapshot*) before after:(REASnapshot*) after
267
+ - (void)onViewUpdate:(UIView *)view before:(REASnapshot *)before after:(REASnapshot *)after
264
268
  {
265
- NSNumber* tag = view.reactTag;
266
- NSMutableDictionary* targetValues = after.values;
267
- NSMutableDictionary* startValues = before.values;
269
+ NSNumber *tag = view.reactTag;
270
+ NSMutableDictionary *targetValues = after.values;
271
+ NSMutableDictionary *startValues = before.values;
268
272
  if (_states[tag] == nil) {
269
273
  return;
270
274
  }
271
275
  ViewState state = [_states[tag] intValue];
272
- if(state == Disappearing || state == ToRemove || state == Inactive) {
276
+ if (state == Disappearing || state == ToRemove || state == Inactive) {
273
277
  return;
274
278
  }
275
- if(state == Appearing) {
279
+ if (state == Appearing) {
276
280
  BOOL doNotStartLayout = true;
277
- for (NSString * key in [[self class] layoutKeys]) {
278
- if ([((NSNumber *)startValues[key]) doubleValue] != [((NSNumber *)targetValues[key]) doubleValue]) {
279
- doNotStartLayout = false;
280
- }
281
+ for (NSString *key in [[self class] layoutKeys]) {
282
+ if ([((NSNumber *)startValues[key]) doubleValue] != [((NSNumber *)targetValues[key]) doubleValue]) {
283
+ doNotStartLayout = false;
284
+ }
281
285
  }
282
286
  if (doNotStartLayout) {
283
287
  return;
284
288
  }
285
289
  }
286
- _states[view.reactTag] = [NSNumber numberWithInt: Layout];
287
- NSDictionary* preparedStartValues = [self prepareDataForAnimatingWorklet:startValues];
288
- NSDictionary* preparedTargetValues = [self prepareDataForAnimatingWorklet:targetValues];
289
- NSMutableDictionary * preparedValues = [NSMutableDictionary new];
290
+ _states[view.reactTag] = [NSNumber numberWithInt:Layout];
291
+ NSDictionary *preparedStartValues = [self prepareDataForAnimatingWorklet:startValues];
292
+ NSDictionary *preparedTargetValues = [self prepareDataForAnimatingWorklet:targetValues];
293
+ NSMutableDictionary *preparedValues = [NSMutableDictionary new];
290
294
  [preparedValues addEntriesFromDictionary:preparedTargetValues];
291
- for (NSString* key in preparedStartValues.allKeys) {
295
+ for (NSString *key in preparedStartValues.allKeys) {
292
296
  preparedValues[[NSString stringWithFormat:@"%@%@", @"b", key]] = preparedStartValues[key];
293
297
  }
294
298
  _startAnimationForTag(view.reactTag, @"layout", preparedValues, @(0));
@@ -4,9 +4,9 @@ NS_ASSUME_NONNULL_BEGIN
4
4
 
5
5
  @interface REASnapshot : NSObject
6
6
 
7
- @property NSMutableDictionary* values;
7
+ @property NSMutableDictionary *values;
8
8
 
9
- - (instancetype) init:(UIView*)view;
9
+ - (instancetype)init:(UIView *)view;
10
10
 
11
11
  @end
12
12
 
@@ -4,10 +4,11 @@
4
4
  NS_ASSUME_NONNULL_BEGIN
5
5
 
6
6
  @implementation REASnapshot {
7
- UIView* _view;
7
+ UIView *_view;
8
8
  }
9
9
 
10
- - (instancetype) init:(UIView*)view {
10
+ - (instancetype)init:(UIView *)view
11
+ {
11
12
  self = [super init];
12
13
  _view = view;
13
14
  UIView *windowView = UIApplication.sharedApplication.keyWindow;
@@ -15,11 +16,11 @@ NS_ASSUME_NONNULL_BEGIN
15
16
  _values = [NSMutableDictionary new];
16
17
  _values[@"width"] = [NSNumber numberWithDouble:(double)(view.bounds.size.width)];
17
18
  _values[@"height"] = [NSNumber numberWithDouble:(double)(view.bounds.size.height)];
18
- _values[@"originX"] = [NSNumber numberWithDouble:view.center.x - view.bounds.size.width/2.0];
19
- _values[@"originY"] = [NSNumber numberWithDouble:view.center.y - view.bounds.size.height/2.0];
20
- _values[@"globalOriginX"] = [NSNumber numberWithDouble:originFromRootPerspective.x - view.bounds.size.width/2.0];
21
- _values[@"globalOriginY"] = [NSNumber numberWithDouble:originFromRootPerspective.y - view.bounds.size.height/2.0];
22
-
19
+ _values[@"originX"] = [NSNumber numberWithDouble:view.center.x - view.bounds.size.width / 2.0];
20
+ _values[@"originY"] = [NSNumber numberWithDouble:view.center.y - view.bounds.size.height / 2.0];
21
+ _values[@"globalOriginX"] = [NSNumber numberWithDouble:originFromRootPerspective.x - view.bounds.size.width / 2.0];
22
+ _values[@"globalOriginY"] = [NSNumber numberWithDouble:originFromRootPerspective.y - view.bounds.size.height / 2.0];
23
+
23
24
  return self;
24
25
  }
25
26
 
@@ -1,6 +1,6 @@
1
- #import <React/RCTUIManager.h>
2
- #import <React/RCTDefines.h>
3
1
  #import <React/RCTBridge+Private.h>
2
+ #import <React/RCTDefines.h>
3
+ #import <React/RCTUIManager.h>
4
4
  #import "REAAnimationsManager.h"
5
5
 
6
6
  NS_ASSUME_NONNULL_BEGIN
@@ -8,8 +8,8 @@ NS_ASSUME_NONNULL_BEGIN
8
8
  @interface REAUIManager : RCTUIManager
9
9
  @property BOOL blockSetter;
10
10
  - (void)setBridge:(RCTBridge *)bridge;
11
- - (void)setUp:(REAAnimationsManager*) animationsManager;
12
- - (void)unregisterView:(id<RCTComponent>) view;
11
+ - (void)setUp:(REAAnimationsManager *)animationsManager;
12
+ - (void)unregisterView:(id<RCTComponent>)view;
13
13
  @property (nonatomic, copy) void (^flushUiOperations)();
14
14
  @end
15
15