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,55 +1,60 @@
1
1
  #pragma once
2
2
 
3
- #include "WorkletsCache.h"
4
- #include "SharedParent.h"
5
- #include "ValueWrapper.h"
3
+ #include <jsi/jsi.h>
4
+ #include <memory>
5
+ #include <mutex>
6
+ #include <string>
7
+ #include <unordered_map>
8
+ #include <vector>
6
9
  #include "HostFunctionHandler.h"
7
10
  #include "JSIStoreValueUser.h"
11
+ #include "LayoutAnimationsProxy.h"
8
12
  #include "RuntimeManager.h"
9
13
  #include "Scheduler.h"
10
- #include <string>
11
- #include <mutex>
12
- #include <unordered_map>
13
- #include <jsi/jsi.h>
14
- #include "LayoutAnimationsProxy.h"
14
+ #include "SharedParent.h"
15
+ #include "ValueWrapper.h"
16
+ #include "WorkletsCache.h"
15
17
 
16
18
  using namespace facebook;
17
19
 
18
20
  namespace reanimated {
19
21
 
20
- class ShareableValue: public std::enable_shared_from_this<ShareableValue>, public StoreUser {
21
- friend WorkletsCache;
22
- friend FrozenObject;
23
- friend LayoutAnimationsProxy;
24
- friend void extractMutables(jsi::Runtime &rt,
25
- std::shared_ptr<ShareableValue> sv,
26
- std::vector<std::shared_ptr<MutableValue>> &res);
27
-
28
- private:
22
+ class ShareableValue : public std::enable_shared_from_this<ShareableValue>,
23
+ public StoreUser {
24
+ friend WorkletsCache;
25
+ friend FrozenObject;
26
+ friend LayoutAnimationsProxy;
27
+ friend void extractMutables(
28
+ jsi::Runtime &rt,
29
+ std::shared_ptr<ShareableValue> sv,
30
+ std::vector<std::shared_ptr<MutableValue>> &res);
31
+
32
+ private:
29
33
  RuntimeManager *runtimeManager;
30
34
  std::unique_ptr<ValueWrapper> valueContainer;
31
35
  std::unique_ptr<jsi::Value> hostValue;
32
36
  std::weak_ptr<jsi::Value> remoteValue;
33
37
  bool containsHostFunction = false;
34
38
 
35
- ShareableValue(RuntimeManager *runtimeManager, std::shared_ptr<Scheduler> s): StoreUser(s, *runtimeManager), runtimeManager(runtimeManager) {}
39
+ ShareableValue(RuntimeManager *runtimeManager, std::shared_ptr<Scheduler> s)
40
+ : StoreUser(s, *runtimeManager), runtimeManager(runtimeManager) {}
36
41
 
37
42
  jsi::Value toJSValue(jsi::Runtime &rt);
38
- jsi::Object createHost(jsi::Runtime &rt, std::shared_ptr<jsi::HostObject> host);
43
+ jsi::Object createHost(
44
+ jsi::Runtime &rt,
45
+ std::shared_ptr<jsi::HostObject> host);
39
46
  void adapt(jsi::Runtime &rt, const jsi::Value &value, ValueType objectType);
40
47
  void adaptCache(jsi::Runtime &rt, const jsi::Value &value);
41
48
  std::string demangleExceptionName(std::string toDemangle);
42
49
 
43
- public:
50
+ public:
44
51
  ValueType type = ValueType::UndefinedType;
45
52
  static std::shared_ptr<ShareableValue> adapt(
46
- jsi::Runtime &rt,
47
- const jsi::Value &value,
48
- RuntimeManager *runtimeManager,
49
- ValueType objectType = ValueType::UndefinedType
50
- );
53
+ jsi::Runtime &rt,
54
+ const jsi::Value &value,
55
+ RuntimeManager *runtimeManager,
56
+ ValueType objectType = ValueType::UndefinedType);
51
57
  jsi::Value getValue(jsi::Runtime &rt);
52
-
53
58
  };
54
59
 
55
- }
60
+ } // namespace reanimated
@@ -8,12 +8,15 @@ enum class ValueType {
8
8
  BoolType,
9
9
  NumberType,
10
10
  StringType,
11
- RemoteObjectType, /* object that can be instantiated on host side and modified on the remote (worklet) side */
12
- MutableValueType, /* object with 'value' property that can be updated and read from any thread */
13
- HostFunctionType, /* function that will be executed asynchronously on the host runtime */
14
- WorkletFunctionType, /* function that gets run on the UI thread */
15
- FrozenObjectType, /* frozen object, can only be set and never modified */
16
- FrozenArrayType, /* frozen array, can only be set and never modified */
11
+ RemoteObjectType, // object that can be instantiated on host side and modified
12
+ // on the remote (worklet) side
13
+ MutableValueType, // object with 'value' property that can be updated and read
14
+ // from any thread
15
+ HostFunctionType, // function that will be executed asynchronously on the host
16
+ // runtime
17
+ WorkletFunctionType, // function that gets run on the UI thread
18
+ FrozenObjectType, // frozen object, can only be set and never modified
19
+ FrozenArrayType, // frozen array, can only be set and never modified
17
20
  };
18
21
 
19
22
  class ShareableValue;
@@ -21,4 +24,4 @@ class MutableValue;
21
24
  class RemoteObject;
22
25
  class NativeReanimatedModule;
23
26
 
24
- }
27
+ } // namespace reanimated
@@ -1,132 +1,155 @@
1
1
  #pragma once
2
2
 
3
- #include "WorkletsCache.h"
4
- #include "SharedParent.h"
5
3
  #include <jsi/jsi.h>
4
+ #include <memory>
6
5
  #include <string>
7
- #include "JSIStoreValueUser.h"
6
+ #include <vector>
8
7
  #include "HostFunctionHandler.h"
8
+ #include "JSIStoreValueUser.h"
9
+ #include "SharedParent.h"
10
+ #include "WorkletsCache.h"
9
11
 
10
12
  namespace reanimated {
11
13
 
12
14
  class HostFunctionWrapper;
13
15
 
14
16
  class ValueWrapper {
15
- public:
16
- ValueWrapper() {};
17
- ValueWrapper(ValueType _type) : type(_type) {};
17
+ public:
18
+ ValueWrapper() {}
19
+ explicit ValueWrapper(ValueType _type) : type(_type) {}
18
20
  ValueType getType() const {
19
21
  return type;
20
22
  }
21
23
 
22
24
  virtual ~ValueWrapper() {}
23
25
 
24
- static inline bool asBoolean(const std::unique_ptr<ValueWrapper>& valueContainer);
25
- static inline double asNumber(const std::unique_ptr<ValueWrapper>& valueContainer);
26
- static inline const std::string& asString(const std::unique_ptr<ValueWrapper>& valueContainer);
27
- static inline const std::shared_ptr<HostFunctionHandler>& asHostFunction(const std::unique_ptr<ValueWrapper>& valueContainer);
28
- static inline const std::shared_ptr<FrozenObject>& asFrozenObject(const std::unique_ptr<ValueWrapper>& valueContainer);
29
- static inline const std::shared_ptr<RemoteObject>& asRemoteObject(const std::unique_ptr<ValueWrapper>& valueContainer);
30
- static inline std::vector<std::shared_ptr<ShareableValue>>& asFrozenArray(const std::unique_ptr<ValueWrapper>& valueContainer);
31
- static inline const std::shared_ptr<MutableValue>& asMutableValue(const std::unique_ptr<ValueWrapper>& valueContainer);
32
-
33
- static const HostFunctionWrapper* asHostFunctionWrapper(const std::unique_ptr<ValueWrapper>& valueContainer);
34
-
35
- protected:
36
- ValueType type;
26
+ static inline bool asBoolean(
27
+ const std::unique_ptr<ValueWrapper> &valueContainer);
28
+ static inline double asNumber(
29
+ const std::unique_ptr<ValueWrapper> &valueContainer);
30
+ static inline const std::string &asString(
31
+ const std::unique_ptr<ValueWrapper> &valueContainer);
32
+ static inline const std::shared_ptr<HostFunctionHandler> &asHostFunction(
33
+ const std::unique_ptr<ValueWrapper> &valueContainer);
34
+ static inline const std::shared_ptr<FrozenObject> &asFrozenObject(
35
+ const std::unique_ptr<ValueWrapper> &valueContainer);
36
+ static inline const std::shared_ptr<RemoteObject> &asRemoteObject(
37
+ const std::unique_ptr<ValueWrapper> &valueContainer);
38
+ static inline std::vector<std::shared_ptr<ShareableValue>> &asFrozenArray(
39
+ const std::unique_ptr<ValueWrapper> &valueContainer);
40
+ static inline const std::shared_ptr<MutableValue> &asMutableValue(
41
+ const std::unique_ptr<ValueWrapper> &valueContainer);
42
+
43
+ static const HostFunctionWrapper *asHostFunctionWrapper(
44
+ const std::unique_ptr<ValueWrapper> &valueContainer);
45
+
46
+ protected:
47
+ ValueType type;
37
48
  };
38
49
 
39
50
  class BooleanValueWrapper : public ValueWrapper {
40
- public:
41
- BooleanValueWrapper(const bool _value)
42
- : ValueWrapper(ValueType::BoolType), value(_value) {};
51
+ public:
52
+ explicit BooleanValueWrapper(const bool _value)
53
+ : ValueWrapper(ValueType::BoolType), value(_value) {}
43
54
  bool value;
44
55
  };
45
56
 
46
57
  class NumberValueWrapper : public ValueWrapper {
47
- public:
48
- NumberValueWrapper(const double _value)
49
- : ValueWrapper(ValueType::NumberType), value(_value) {};
58
+ public:
59
+ explicit NumberValueWrapper(const double _value)
60
+ : ValueWrapper(ValueType::NumberType), value(_value) {}
50
61
  double value;
51
62
  };
52
63
 
53
64
  class StringValueWrapper : public ValueWrapper {
54
- public:
55
- StringValueWrapper(const std::string & _value)
56
- : ValueWrapper(ValueType::StringType), value(_value) {};
65
+ public:
66
+ explicit StringValueWrapper(const std::string &_value)
67
+ : ValueWrapper(ValueType::StringType), value(_value) {}
57
68
  std::string value;
58
69
  };
59
70
 
60
71
  class HostFunctionWrapper : public ValueWrapper {
61
- public:
62
- HostFunctionWrapper(const std::shared_ptr<HostFunctionHandler> & _value)
63
- : ValueWrapper(ValueType::HostFunctionType), value(_value) {};
72
+ public:
73
+ explicit HostFunctionWrapper(
74
+ const std::shared_ptr<HostFunctionHandler> &_value)
75
+ : ValueWrapper(ValueType::HostFunctionType), value(_value) {}
64
76
  std::shared_ptr<HostFunctionHandler> value;
65
77
  };
66
78
 
67
79
  class FrozenObjectWrapper : public ValueWrapper {
68
- public:
69
- FrozenObjectWrapper(const std::shared_ptr<FrozenObject> & _value)
70
- : ValueWrapper(ValueType::FrozenObjectType), value(_value) {};
80
+ public:
81
+ explicit FrozenObjectWrapper(const std::shared_ptr<FrozenObject> &_value)
82
+ : ValueWrapper(ValueType::FrozenObjectType), value(_value) {}
71
83
  std::shared_ptr<FrozenObject> value;
72
84
  };
73
85
 
74
86
  class RemoteObjectWrapper : public ValueWrapper {
75
- public:
76
- RemoteObjectWrapper(const std::shared_ptr<RemoteObject> & _value)
77
- : ValueWrapper(ValueType::RemoteObjectType), value(_value) {};
87
+ public:
88
+ explicit RemoteObjectWrapper(const std::shared_ptr<RemoteObject> &_value)
89
+ : ValueWrapper(ValueType::RemoteObjectType), value(_value) {}
78
90
  std::shared_ptr<RemoteObject> value;
79
91
  };
80
92
 
81
93
  class FrozenArrayWrapper : public ValueWrapper {
82
- public:
83
- FrozenArrayWrapper() : ValueWrapper(ValueType::FrozenArrayType) {};
84
- FrozenArrayWrapper(const std::vector<std::shared_ptr<ShareableValue>> & _value)
85
- : ValueWrapper(ValueType::FrozenArrayType), value(_value) {};
94
+ public:
95
+ FrozenArrayWrapper() : ValueWrapper(ValueType::FrozenArrayType) {}
96
+ explicit FrozenArrayWrapper(
97
+ const std::vector<std::shared_ptr<ShareableValue>> &_value)
98
+ : ValueWrapper(ValueType::FrozenArrayType), value(_value) {}
86
99
  std::vector<std::shared_ptr<ShareableValue>> value;
87
100
  };
88
101
 
89
102
  class MutableValueWrapper : public ValueWrapper {
90
- public:
91
- MutableValueWrapper(const std::shared_ptr<MutableValue> & _value)
92
- : ValueWrapper(ValueType::MutableValueType), value(_value) {};
103
+ public:
104
+ explicit MutableValueWrapper(const std::shared_ptr<MutableValue> &_value)
105
+ : ValueWrapper(ValueType::MutableValueType), value(_value) {}
93
106
  std::shared_ptr<MutableValue> value;
94
107
  };
95
108
 
96
- inline bool ValueWrapper::asBoolean(const std::unique_ptr<ValueWrapper>& valueContainer) {
97
- return static_cast<BooleanValueWrapper*>(valueContainer.get())->value;
98
- };
99
-
100
- inline double ValueWrapper::asNumber(const std::unique_ptr<ValueWrapper>& valueContainer) {
101
- return static_cast<NumberValueWrapper*>(valueContainer.get())->value;
102
- };
109
+ inline bool ValueWrapper::asBoolean(
110
+ const std::unique_ptr<ValueWrapper> &valueContainer) {
111
+ return static_cast<BooleanValueWrapper *>(valueContainer.get())->value;
112
+ }
103
113
 
104
- inline const std::string& ValueWrapper::asString(const std::unique_ptr<ValueWrapper>& valueContainer) {
105
- return static_cast<StringValueWrapper*>(valueContainer.get())->value;
106
- };
114
+ inline double ValueWrapper::asNumber(
115
+ const std::unique_ptr<ValueWrapper> &valueContainer) {
116
+ return static_cast<NumberValueWrapper *>(valueContainer.get())->value;
117
+ }
107
118
 
108
- inline const std::shared_ptr<HostFunctionHandler>& ValueWrapper::asHostFunction(const std::unique_ptr<ValueWrapper>& valueContainer) {
109
- return static_cast<HostFunctionWrapper*>(valueContainer.get())->value;
110
- };
119
+ inline const std::string &ValueWrapper::asString(
120
+ const std::unique_ptr<ValueWrapper> &valueContainer) {
121
+ return static_cast<StringValueWrapper *>(valueContainer.get())->value;
122
+ }
111
123
 
112
- inline const std::shared_ptr<FrozenObject>& ValueWrapper::asFrozenObject(const std::unique_ptr<ValueWrapper>& valueContainer) {
113
- return static_cast<FrozenObjectWrapper*>(valueContainer.get())->value;
114
- };
124
+ inline const std::shared_ptr<HostFunctionHandler> &ValueWrapper::asHostFunction(
125
+ const std::unique_ptr<ValueWrapper> &valueContainer) {
126
+ return static_cast<HostFunctionWrapper *>(valueContainer.get())->value;
127
+ }
115
128
 
116
- inline const std::shared_ptr<RemoteObject>& ValueWrapper::asRemoteObject(const std::unique_ptr<ValueWrapper>& valueContainer) {
117
- return static_cast<RemoteObjectWrapper*>(valueContainer.get())->value;
118
- };
129
+ inline const std::shared_ptr<FrozenObject> &ValueWrapper::asFrozenObject(
130
+ const std::unique_ptr<ValueWrapper> &valueContainer) {
131
+ return static_cast<FrozenObjectWrapper *>(valueContainer.get())->value;
132
+ }
119
133
 
120
- inline std::vector<std::shared_ptr<ShareableValue>>& ValueWrapper::asFrozenArray(const std::unique_ptr<ValueWrapper>& valueContainer) {
121
- return static_cast<FrozenArrayWrapper*>(valueContainer.get())->value;
122
- };
134
+ inline const std::shared_ptr<RemoteObject> &ValueWrapper::asRemoteObject(
135
+ const std::unique_ptr<ValueWrapper> &valueContainer) {
136
+ return static_cast<RemoteObjectWrapper *>(valueContainer.get())->value;
137
+ }
123
138
 
124
- inline const std::shared_ptr<MutableValue>& ValueWrapper::asMutableValue(const std::unique_ptr<ValueWrapper>& valueContainer) {
125
- return static_cast<MutableValueWrapper*>(valueContainer.get())->value;
126
- };
139
+ inline std::vector<std::shared_ptr<ShareableValue>>
140
+ &ValueWrapper::asFrozenArray(
141
+ const std::unique_ptr<ValueWrapper> &valueContainer) {
142
+ return static_cast<FrozenArrayWrapper *>(valueContainer.get())->value;
143
+ }
127
144
 
128
- inline const HostFunctionWrapper* ValueWrapper::asHostFunctionWrapper(const std::unique_ptr<ValueWrapper>& valueContainer) {
129
- return static_cast<HostFunctionWrapper*>(valueContainer.get());
130
- };
145
+ inline const std::shared_ptr<MutableValue> &ValueWrapper::asMutableValue(
146
+ const std::unique_ptr<ValueWrapper> &valueContainer) {
147
+ return static_cast<MutableValueWrapper *>(valueContainer.get())->value;
148
+ }
131
149
 
150
+ inline const HostFunctionWrapper *ValueWrapper::asHostFunctionWrapper(
151
+ const std::unique_ptr<ValueWrapper> &valueContainer) {
152
+ return static_cast<HostFunctionWrapper *>(valueContainer.get());
132
153
  }
154
+
155
+ } // namespace reanimated
@@ -1,10 +1,10 @@
1
1
  #pragma once
2
2
 
3
- #include "Scheduler.h"
3
+ #include <memory>
4
4
  #include <string>
5
+ #include "Scheduler.h"
5
6
 
6
- namespace reanimated
7
- {
7
+ namespace reanimated {
8
8
 
9
9
  struct ErrorWrapper {
10
10
  std::string message = "";
@@ -12,22 +12,21 @@ struct ErrorWrapper {
12
12
  };
13
13
 
14
14
  class ErrorHandler {
15
- public:
16
- bool raise() {
17
- if (getError()->handled) {
18
- return false;
19
- }
20
- this->getScheduler()->scheduleOnUI([this]() mutable {
21
- this->raiseSpec();
22
- });
23
- return true;
15
+ public:
16
+ bool raise() {
17
+ if (getError()->handled) {
18
+ return false;
24
19
  }
25
- virtual std::shared_ptr<Scheduler> getScheduler() = 0;
26
- virtual std::shared_ptr<ErrorWrapper> getError() = 0;
27
- virtual void setError(std::string message) = 0;
28
- virtual ~ErrorHandler() {}
29
- protected:
30
- virtual void raiseSpec() = 0;
20
+ this->getScheduler()->scheduleOnUI([this]() mutable { this->raiseSpec(); });
21
+ return true;
22
+ }
23
+ virtual std::shared_ptr<Scheduler> getScheduler() = 0;
24
+ virtual std::shared_ptr<ErrorWrapper> getError() = 0;
25
+ virtual void setError(std::string message) = 0;
26
+ virtual ~ErrorHandler() {}
27
+
28
+ protected:
29
+ virtual void raiseSpec() = 0;
31
30
  };
32
31
 
33
- }
32
+ } // namespace reanimated
@@ -0,0 +1,19 @@
1
+ #pragma once
2
+ #include <string>
3
+
4
+ namespace reanimated {
5
+
6
+ class FeaturesConfig {
7
+ public:
8
+ static inline bool isLayoutAnimationEnabled() {
9
+ return _isLayoutAnimationEnabled;
10
+ }
11
+ static inline void setLayoutAnimationEnabled(bool isLayoutAnimationEnabled) {
12
+ _isLayoutAnimationEnabled = isLayoutAnimationEnabled;
13
+ }
14
+
15
+ private:
16
+ static bool _isLayoutAnimationEnabled;
17
+ };
18
+
19
+ } // namespace reanimated
@@ -1,12 +1,11 @@
1
- #ifndef JSIStoreValueUser_h
2
- #define JSIStoreValueUser_h
1
+ #pragma once
3
2
 
3
+ #include <jsi/jsi.h>
4
4
  #include <stdio.h>
5
5
  #include <memory>
6
- #include <vector>
7
- #include <unordered_map>
8
- #include <jsi/jsi.h>
9
6
  #include <mutex>
7
+ #include <unordered_map>
8
+ #include <vector>
10
9
  #include "Scheduler.h"
11
10
 
12
11
  using namespace facebook;
@@ -16,25 +15,23 @@ namespace reanimated {
16
15
  class RuntimeManager;
17
16
 
18
17
  struct StaticStoreUser {
19
- std::atomic<int> ctr;
20
- std::unordered_map<int, std::vector<std::shared_ptr<jsi::Value>>> store;
21
- std::recursive_mutex storeMutex;
18
+ std::atomic<int> ctr;
19
+ std::unordered_map<int, std::vector<std::shared_ptr<jsi::Value>>> store;
20
+ std::recursive_mutex storeMutex;
22
21
  };
23
22
 
24
23
  class StoreUser {
25
24
  int identifier = 0;
26
25
  std::weak_ptr<Scheduler> scheduler;
27
26
  std::shared_ptr<StaticStoreUser> storeUserData;
28
-
29
- public:
30
- StoreUser(std::shared_ptr<Scheduler> s, RuntimeManager &runtimeManager);
31
-
27
+
28
+ public:
29
+ StoreUser(std::shared_ptr<Scheduler> s, const RuntimeManager &runtimeManager);
30
+
32
31
  std::weak_ptr<jsi::Value> getWeakRef(jsi::Runtime &rt);
33
32
  void removeRefs();
34
-
33
+
35
34
  virtual ~StoreUser();
36
35
  };
37
36
 
38
- }
39
-
40
- #endif /* JSIStoreValueUser_h */
37
+ } // namespace reanimated
@@ -1,9 +1,11 @@
1
1
  #pragma once
2
2
 
3
- #include "ShareableValue.h"
4
- #include "NativeReanimatedModule.h"
5
- #include <stdio.h>
6
3
  #include <jsi/jsi.h>
4
+ #include <stdio.h>
5
+ #include <memory>
6
+ #include <vector>
7
+ #include "NativeReanimatedModule.h"
8
+ #include "ShareableValue.h"
7
9
 
8
10
  using namespace facebook;
9
11
 
@@ -18,7 +20,8 @@ struct ViewDescriptor {
18
20
 
19
21
  class Mapper : public std::enable_shared_from_this<Mapper> {
20
22
  friend MapperRegistry;
21
- private:
23
+
24
+ private:
22
25
  unsigned long id;
23
26
  NativeReanimatedModule *module;
24
27
  std::shared_ptr<jsi::Function> mapper;
@@ -26,23 +29,23 @@ private:
26
29
  std::vector<std::shared_ptr<MutableValue>> outputs;
27
30
  bool dirty = true;
28
31
  std::shared_ptr<jsi::Function> userUpdater;
29
- UpdaterFunction* updateProps;
32
+ UpdaterFunction *updateProps;
30
33
  int optimalizationLvl = 0;
31
34
  std::shared_ptr<ShareableValue> viewDescriptors;
32
35
 
33
- public:
34
- Mapper(NativeReanimatedModule *module,
35
- unsigned long id,
36
- std::shared_ptr<jsi::Function> mapper,
37
- std::vector<std::shared_ptr<MutableValue>> inputs,
38
- std::vector<std::shared_ptr<MutableValue>> outputs);
36
+ public:
37
+ Mapper(
38
+ NativeReanimatedModule *module,
39
+ unsigned long id,
40
+ std::shared_ptr<jsi::Function> mapper,
41
+ std::vector<std::shared_ptr<MutableValue>> inputs,
42
+ std::vector<std::shared_ptr<MutableValue>> outputs);
39
43
  void execute(jsi::Runtime &rt);
40
44
  void enableFastMode(
41
- const int optimalizationLvl,
42
- const std::shared_ptr<ShareableValue>& updater,
43
- const std::shared_ptr<ShareableValue>&jsViewDescriptors
44
- );
45
+ const int optimalizationLvl,
46
+ const std::shared_ptr<ShareableValue> &updater,
47
+ const std::shared_ptr<ShareableValue> &jsViewDescriptors);
45
48
  virtual ~Mapper();
46
49
  };
47
50
 
48
- }
51
+ } // namespace reanimated
@@ -1,18 +1,27 @@
1
1
  #pragma once
2
2
 
3
- #include <stdio.h>
4
3
  #include <jsi/jsi.h>
4
+ #include <stdio.h>
5
+ #include <string>
6
+ #include <utility>
7
+ #include <vector>
5
8
 
6
9
  using namespace facebook;
7
10
 
8
- namespace reanimated
9
- {
11
+ namespace reanimated {
10
12
 
11
- using UpdaterFunction = std::function<void(jsi::Runtime &rt, int viewTag, const jsi::Value &viewName, const jsi::Object &object)>;
12
- using RequestRender = std::function<void(std::function<void(double)>, jsi::Runtime &rt)>;
13
+ using UpdaterFunction = std::function<void(
14
+ jsi::Runtime &rt,
15
+ int viewTag,
16
+ const jsi::Value &viewName,
17
+ const jsi::Object &object)>;
18
+ using RequestRender =
19
+ std::function<void(std::function<void(double)>, jsi::Runtime &rt)>;
13
20
  using ScrollToFunction = std::function<void(int, double, double, bool)>;
14
- using MeasuringFunction = std::function<std::vector<std::pair<std::string, double>>(int)>;
21
+ using MeasuringFunction =
22
+ std::function<std::vector<std::pair<std::string, double>>(int)>;
15
23
  using TimeProviderFunction = std::function<double(void)>;
24
+ using SetGestureStateFunction = std::function<void(int, int)>;
16
25
 
17
26
  struct PlatformDepMethodsHolder {
18
27
  RequestRender requestRender;
@@ -20,6 +29,7 @@ struct PlatformDepMethodsHolder {
20
29
  ScrollToFunction scrollToFunction;
21
30
  MeasuringFunction measuringFunction;
22
31
  TimeProviderFunction getCurrentTime;
32
+ SetGestureStateFunction setGestureStateFunction;
23
33
  };
24
34
 
25
- }
35
+ } // namespace reanimated
@@ -1,15 +1,11 @@
1
-
2
- #ifndef REANIMATEDEXAMPLE_REANIMATEDHIDDEN_H
3
- #define REANIMATEDEXAMPLE_REANIMATEDHIDDEN_H
1
+ #pragma once
4
2
 
5
3
  #if defined(ONANDROID)
6
- #include "Logger.h"
7
- #include "LoggerInterface.h"
8
- #include "SpeedChecker.h"
4
+ #include "Logger.h"
5
+ #include "LoggerInterface.h"
6
+ #include "SpeedChecker.h"
9
7
  #else
10
- #include "Common/cpp/hidden_headers/Logger.h"
11
- #include "Common/cpp/hidden_headers/LoggerInterface.h"
12
- #include "Common/cpp/hidden_headers/SpeedChecker.h"
8
+ #include "Common/cpp/hidden_headers/Logger.h"
9
+ #include "Common/cpp/hidden_headers/LoggerInterface.h"
10
+ #include "Common/cpp/hidden_headers/SpeedChecker.h"
13
11
  #endif
14
-
15
- #endif //REANIMATEDEXAMPLE_REANIMATEDHIDDEN_H