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,18 +1,19 @@
1
1
  #pragma once
2
2
 
3
- #include "NativeReanimatedModuleSpec.h"
4
- #include "Scheduler.h"
5
- #include "ErrorHandler.h"
6
- #include "RuntimeDecorator.h"
7
- #include "PlatformDepMethodsHolder.h"
8
3
  #include <unistd.h>
9
4
  #include <memory>
5
+ #include <string>
10
6
  #include <vector>
11
- #include "RuntimeManager.h"
7
+
8
+ #include "ErrorHandler.h"
12
9
  #include "LayoutAnimationsProxy.h"
10
+ #include "NativeReanimatedModuleSpec.h"
11
+ #include "PlatformDepMethodsHolder.h"
12
+ #include "RuntimeDecorator.h"
13
+ #include "RuntimeManager.h"
14
+ #include "Scheduler.h"
13
15
 
14
- namespace reanimated
15
- {
16
+ namespace reanimated {
16
17
 
17
18
  using FrameCallback = std::function<void(double)>;
18
19
 
@@ -21,38 +22,54 @@ class MutableValue;
21
22
  class MapperRegistry;
22
23
  class EventHandlerRegistry;
23
24
 
24
- class NativeReanimatedModule : public NativeReanimatedModuleSpec, public RuntimeManager
25
- {
25
+ class NativeReanimatedModule : public NativeReanimatedModuleSpec,
26
+ public RuntimeManager {
26
27
  friend ShareableValue;
27
28
  friend MutableValue;
28
29
 
29
- public:
30
- NativeReanimatedModule(std::shared_ptr<CallInvoker> jsInvoker,
31
- std::shared_ptr<Scheduler> scheduler,
32
- std::shared_ptr<jsi::Runtime> rt,
33
- std::shared_ptr<ErrorHandler> errorHandler,
34
- std::function<jsi::Value(jsi::Runtime &, const int, const jsi::String &)> propObtainer,
35
- std::shared_ptr<LayoutAnimationsProxy> layoutAnimationsProxy,
36
- PlatformDepMethodsHolder platformDepMethodsHolder);
30
+ public:
31
+ NativeReanimatedModule(
32
+ std::shared_ptr<CallInvoker> jsInvoker,
33
+ std::shared_ptr<Scheduler> scheduler,
34
+ std::shared_ptr<jsi::Runtime> rt,
35
+ std::shared_ptr<ErrorHandler> errorHandler,
36
+ std::function<jsi::Value(jsi::Runtime &, const int, const jsi::String &)>
37
+ propObtainer,
38
+ std::shared_ptr<LayoutAnimationsProxy> layoutAnimationsProxy,
39
+ PlatformDepMethodsHolder platformDepMethodsHolder);
37
40
 
38
- void installCoreFunctions(jsi::Runtime &rt, const jsi::Value &valueSetter) override;
41
+ void installCoreFunctions(jsi::Runtime &rt, const jsi::Value &valueSetter)
42
+ override;
39
43
 
40
44
  jsi::Value makeShareable(jsi::Runtime &rt, const jsi::Value &value) override;
41
45
  jsi::Value makeMutable(jsi::Runtime &rt, const jsi::Value &value) override;
42
46
  jsi::Value makeRemote(jsi::Runtime &rt, const jsi::Value &value) override;
43
47
 
44
- jsi::Value startMapper(jsi::Runtime &rt,
45
- const jsi::Value &worklet,
46
- const jsi::Value &inputs,
47
- const jsi::Value &outputs,
48
- const jsi::Value &updater,
49
- const jsi::Value &viewDescriptors) override;
48
+ jsi::Value startMapper(
49
+ jsi::Runtime &rt,
50
+ const jsi::Value &worklet,
51
+ const jsi::Value &inputs,
52
+ const jsi::Value &outputs,
53
+ const jsi::Value &updater,
54
+ const jsi::Value &viewDescriptors) override;
50
55
  void stopMapper(jsi::Runtime &rt, const jsi::Value &mapperId) override;
51
56
 
52
- jsi::Value registerEventHandler(jsi::Runtime &rt, const jsi::Value &eventHash, const jsi::Value &worklet) override;
53
- void unregisterEventHandler(jsi::Runtime &rt, const jsi::Value &registrationId) override;
57
+ jsi::Value registerEventHandler(
58
+ jsi::Runtime &rt,
59
+ const jsi::Value &eventHash,
60
+ const jsi::Value &worklet) override;
61
+ void unregisterEventHandler(
62
+ jsi::Runtime &rt,
63
+ const jsi::Value &registrationId) override;
64
+
65
+ jsi::Value getViewProp(
66
+ jsi::Runtime &rt,
67
+ const jsi::Value &viewTag,
68
+ const jsi::Value &propName,
69
+ const jsi::Value &callback) override;
54
70
 
55
- jsi::Value getViewProp(jsi::Runtime &rt, const jsi::Value &viewTag, const jsi::Value &propName, const jsi::Value &callback) override;
71
+ jsi::Value enableLayoutAnimations(jsi::Runtime &rt, const jsi::Value &config)
72
+ override;
56
73
 
57
74
  void onRender(double timestampMs);
58
75
  void onEvent(std::string eventName, std::string eventAsString);
@@ -60,14 +77,16 @@ public:
60
77
 
61
78
  void maybeRequestRender();
62
79
  UpdaterFunction updaterFunction;
63
- private:
80
+
81
+ private:
64
82
  std::shared_ptr<MapperRegistry> mapperRegistry;
65
83
  std::shared_ptr<EventHandlerRegistry> eventHandlerRegistry;
66
- std::function<void(FrameCallback&, jsi::Runtime&)> requestRender;
84
+ std::function<void(FrameCallback &, jsi::Runtime &)> requestRender;
67
85
  std::shared_ptr<jsi::Value> dummyEvent;
68
86
  std::vector<FrameCallback> frameCallbacks;
69
87
  bool renderRequested = false;
70
- std::function<jsi::Value(jsi::Runtime &, const int, const jsi::String &)> propObtainer;
88
+ std::function<jsi::Value(jsi::Runtime &, const int, const jsi::String &)>
89
+ propObtainer;
71
90
  std::function<void(double)> onRenderCallback;
72
91
  std::shared_ptr<LayoutAnimationsProxy> layoutAnimationsProxy;
73
92
  };
@@ -5,9 +5,9 @@
5
5
  #include <vector>
6
6
 
7
7
  #ifdef ONANDROID
8
- #include "TurboModule.h"
8
+ #include "TurboModule.h"
9
9
  #else
10
- #include <ReactCommon/TurboModule.h>
10
+ #include <ReactCommon/TurboModule.h>
11
11
  #endif
12
12
 
13
13
  #include <ReactCommon/CallInvoker.h>
@@ -15,36 +15,54 @@
15
15
  using namespace facebook;
16
16
  using namespace react;
17
17
 
18
- namespace reanimated
19
- {
18
+ namespace reanimated {
20
19
 
21
20
  class JSI_EXPORT NativeReanimatedModuleSpec : public TurboModule {
22
21
  protected:
23
- NativeReanimatedModuleSpec(std::shared_ptr<CallInvoker> jsInvoker);
22
+ explicit NativeReanimatedModuleSpec(std::shared_ptr<CallInvoker> jsInvoker);
24
23
 
25
24
  public:
26
- virtual void installCoreFunctions(jsi::Runtime &rt, const jsi::Value &valueSetter) = 0;
25
+ virtual void installCoreFunctions(
26
+ jsi::Runtime &rt,
27
+ const jsi::Value &valueSetter) = 0;
27
28
 
28
29
  // SharedValue
29
- virtual jsi::Value makeShareable(jsi::Runtime &rt, const jsi::Value &value) = 0;
30
+ virtual jsi::Value makeShareable(
31
+ jsi::Runtime &rt,
32
+ const jsi::Value &value) = 0;
30
33
  virtual jsi::Value makeMutable(jsi::Runtime &rt, const jsi::Value &value) = 0;
31
34
  virtual jsi::Value makeRemote(jsi::Runtime &rt, const jsi::Value &value) = 0;
32
35
 
33
36
  // mappers
34
- virtual jsi::Value startMapper(jsi::Runtime &rt,
35
- const jsi::Value &worklet,
36
- const jsi::Value &inputs,
37
- const jsi::Value &outputs,
38
- const jsi::Value &updater,
39
- const jsi::Value &viewDescriptors) = 0;
37
+ virtual jsi::Value startMapper(
38
+ jsi::Runtime &rt,
39
+ const jsi::Value &worklet,
40
+ const jsi::Value &inputs,
41
+ const jsi::Value &outputs,
42
+ const jsi::Value &updater,
43
+ const jsi::Value &viewDescriptors) = 0;
40
44
  virtual void stopMapper(jsi::Runtime &rt, const jsi::Value &mapperId) = 0;
41
45
 
42
46
  // events
43
- virtual jsi::Value registerEventHandler(jsi::Runtime &rt, const jsi::Value &eventHash, const jsi::Value &worklet) = 0;
44
- virtual void unregisterEventHandler(jsi::Runtime &rt, const jsi::Value &registrationId) = 0;
47
+ virtual jsi::Value registerEventHandler(
48
+ jsi::Runtime &rt,
49
+ const jsi::Value &eventHash,
50
+ const jsi::Value &worklet) = 0;
51
+ virtual void unregisterEventHandler(
52
+ jsi::Runtime &rt,
53
+ const jsi::Value &registrationId) = 0;
45
54
 
46
55
  // views
47
- virtual jsi::Value getViewProp(jsi::Runtime &rt, const jsi::Value &viewTag, const jsi::Value &propName, const jsi::Value &callback) = 0;
56
+ virtual jsi::Value getViewProp(
57
+ jsi::Runtime &rt,
58
+ const jsi::Value &viewTag,
59
+ const jsi::Value &propName,
60
+ const jsi::Value &callback) = 0;
61
+
62
+ // other
63
+ virtual jsi::Value enableLayoutAnimations(
64
+ jsi::Runtime &rt,
65
+ const jsi::Value &config) = 0;
48
66
  };
49
67
 
50
68
  } // namespace reanimated
@@ -1,12 +1,13 @@
1
1
  #pragma once
2
2
 
3
- #include <vector>
3
+ #include <jsi/jsi.h>
4
4
  #include <map>
5
+ #include <memory>
6
+ #include <mutex>
5
7
  #include <set>
6
- #include <unordered_map>
7
8
  #include <string>
8
- #include <jsi/jsi.h>
9
- #include <mutex>
9
+ #include <unordered_map>
10
+ #include <vector>
10
11
 
11
12
  using namespace facebook;
12
13
 
@@ -15,16 +16,22 @@ namespace reanimated {
15
16
  class WorkletEventHandler;
16
17
 
17
18
  class EventHandlerRegistry {
18
- std::map<std::string, std::unordered_map<unsigned long, std::shared_ptr<WorkletEventHandler>>> eventMappings;
19
+ std::map<
20
+ std::string,
21
+ std::unordered_map<unsigned long, std::shared_ptr<WorkletEventHandler>>>
22
+ eventMappings;
19
23
  std::map<unsigned long, std::shared_ptr<WorkletEventHandler>> eventHandlers;
20
24
  std::mutex instanceMutex;
21
25
 
22
- public:
26
+ public:
23
27
  void registerEventHandler(std::shared_ptr<WorkletEventHandler> eventHandler);
24
28
  void unregisterEventHandler(unsigned long id);
25
29
 
26
- void processEvent(jsi::Runtime &rt, std::string eventName, std::string eventPayload);
30
+ void processEvent(
31
+ jsi::Runtime &rt,
32
+ std::string eventName,
33
+ std::string eventPayload);
27
34
  bool isAnyHandlerWaitingForEvent(std::string eventName);
28
35
  };
29
36
 
30
- }
37
+ } // namespace reanimated
@@ -1,8 +1,9 @@
1
1
  #pragma once
2
2
 
3
- #include <vector>
4
- #include <unordered_map>
5
3
  #include <jsi/jsi.h>
4
+ #include <memory>
5
+ #include <unordered_map>
6
+ #include <vector>
6
7
 
7
8
  using namespace facebook;
8
9
 
@@ -16,7 +17,7 @@ class MapperRegistry {
16
17
  void updateOrder();
17
18
  bool updatedSinceLastExecute = false;
18
19
 
19
- public:
20
+ public:
20
21
  void startMapper(std::shared_ptr<Mapper> mapper);
21
22
  void stopMapper(unsigned long id);
22
23
 
@@ -25,4 +26,4 @@ public:
25
26
  bool needRunOnRender();
26
27
  };
27
28
 
28
- }
29
+ } // namespace reanimated
@@ -1,22 +1,24 @@
1
1
  #pragma once
2
2
 
3
- #include <stdio.h>
4
- #include <unordered_map>
5
3
  #include <jsi/jsi.h>
4
+ #include <stdio.h>
6
5
  #include <memory>
6
+ #include <unordered_map>
7
7
 
8
- namespace reanimated
9
- {
8
+ namespace reanimated {
10
9
 
11
10
  using namespace facebook;
12
11
 
13
12
  class FrozenObject;
14
13
 
15
14
  class WorkletsCache {
16
- private:
15
+ private:
17
16
  std::unordered_map<long long, std::shared_ptr<jsi::Function>> worklets;
18
- public:
19
- std::shared_ptr<jsi::Function> getFunction(jsi::Runtime & rt, std::shared_ptr<reanimated::FrozenObject> frozenObj);
17
+
18
+ public:
19
+ std::shared_ptr<jsi::Function> getFunction(
20
+ jsi::Runtime &rt,
21
+ std::shared_ptr<reanimated::FrozenObject> frozenObj);
20
22
  };
21
23
 
22
24
  } // namespace reanimated
@@ -1,9 +1,13 @@
1
1
  #pragma once
2
2
 
3
- #include "WorkletsCache.h"
4
- #include "SharedParent.h"
5
- #include "RuntimeManager.h"
6
3
  #include <jsi/jsi.h>
4
+ #include <memory>
5
+ #include <string>
6
+ #include <unordered_map>
7
+ #include <vector>
8
+ #include "RuntimeManager.h"
9
+ #include "SharedParent.h"
10
+ #include "WorkletsCache.h"
7
11
 
8
12
  using namespace facebook;
9
13
 
@@ -11,18 +15,22 @@ namespace reanimated {
11
15
 
12
16
  class FrozenObject : public jsi::HostObject {
13
17
  friend WorkletsCache;
14
- friend void extractMutables(jsi::Runtime &rt,
15
- std::shared_ptr<ShareableValue> sv,
16
- std::vector<std::shared_ptr<MutableValue>> &res);
18
+ friend void extractMutables(
19
+ jsi::Runtime &rt,
20
+ std::shared_ptr<ShareableValue> sv,
21
+ std::vector<std::shared_ptr<MutableValue>> &res);
17
22
 
18
- private:
23
+ private:
19
24
  std::unordered_map<std::string, std::shared_ptr<ShareableValue>> map;
25
+ std::vector<std::string> namesOrder;
20
26
 
21
- public:
22
-
23
- FrozenObject(jsi::Runtime &rt, const jsi::Object &object, RuntimeManager *runtimeManager);
27
+ public:
28
+ FrozenObject(
29
+ jsi::Runtime &rt,
30
+ const jsi::Object &object,
31
+ RuntimeManager *runtimeManager);
24
32
  jsi::Object shallowClone(jsi::Runtime &rt);
25
33
  bool containsHostFunction = false;
26
34
  };
27
35
 
28
- }
36
+ } // namespace reanimated
@@ -1,6 +1,10 @@
1
1
  #pragma once
2
2
 
3
3
  #include <jsi/jsi.h>
4
+ #include <memory>
5
+ #include <string>
6
+
7
+ using namespace facebook;
4
8
 
5
9
  namespace reanimated {
6
10
 
@@ -8,17 +12,17 @@ struct HostFunctionHandler : jsi::HostObject {
8
12
  std::shared_ptr<jsi::Function> pureFunction;
9
13
  std::string functionName;
10
14
  jsi::Runtime *hostRuntime;
11
- jsi::HostObject a;
12
-
15
+ jsi::HostObject a;
16
+
13
17
  HostFunctionHandler(std::shared_ptr<jsi::Function> f, jsi::Runtime &rt) {
14
18
  pureFunction = f;
15
19
  functionName = f->getProperty(rt, "name").asString(rt).utf8(rt);
16
20
  hostRuntime = &rt;
17
21
  }
18
-
22
+
19
23
  std::shared_ptr<jsi::Function> getPureFunction() {
20
24
  return pureFunction;
21
25
  }
22
26
  };
23
27
 
24
- }
28
+ } // namespace reanimated
@@ -1,20 +1,24 @@
1
1
  #pragma once
2
2
 
3
- #include "SharedParent.h"
4
- #include "MutableValueSetterProxy.h"
5
- #include <mutex>
6
3
  #include <jsi/jsi.h>
7
4
  #include <map>
5
+ #include <memory>
6
+ #include <mutex>
7
+ #include <vector>
8
8
  #include "JSIStoreValueUser.h"
9
- #include "RuntimeManager.h"
10
9
  #include "LayoutAnimationsProxy.h"
10
+ #include "MutableValueSetterProxy.h"
11
+ #include "RuntimeManager.h"
12
+ #include "SharedParent.h"
11
13
 
12
14
  using namespace facebook;
13
15
 
14
16
  namespace reanimated {
15
17
 
16
- class MutableValue : public jsi::HostObject, public std::enable_shared_from_this<MutableValue>, public StoreUser {
17
- private:
18
+ class MutableValue : public jsi::HostObject,
19
+ public std::enable_shared_from_this<MutableValue>,
20
+ public StoreUser {
21
+ private:
18
22
  friend MutableValueSetterProxy;
19
23
  RuntimeManager *runtimeManager;
20
24
  friend LayoutAnimationsProxy;
@@ -26,15 +30,22 @@ private:
26
30
  void setValue(jsi::Runtime &rt, const jsi::Value &newValue);
27
31
  jsi::Value getValue(jsi::Runtime &rt);
28
32
 
29
- public:
30
- MutableValue(jsi::Runtime &rt, const jsi::Value &initial, RuntimeManager *runtimeManager, std::shared_ptr<Scheduler> s);
33
+ public:
34
+ MutableValue(
35
+ jsi::Runtime &rt,
36
+ const jsi::Value &initial,
37
+ RuntimeManager *runtimeManager,
38
+ std::shared_ptr<Scheduler> s);
31
39
 
32
- public:
33
- void set(jsi::Runtime &rt, const jsi::PropNameID &name, const jsi::Value &value);
40
+ public:
41
+ void
42
+ set(jsi::Runtime &rt, const jsi::PropNameID &name, const jsi::Value &value);
34
43
  jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &name);
35
44
  std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt);
36
- unsigned long addListener(unsigned long listenerId, std::function<void()> listener);
45
+ unsigned long addListener(
46
+ unsigned long listenerId,
47
+ std::function<void()> listener);
37
48
  void removeListener(unsigned long listenerId);
38
49
  };
39
50
 
40
- }
51
+ } // namespace reanimated
@@ -1,20 +1,25 @@
1
1
  #pragma once
2
2
 
3
- #include "SharedParent.h"
4
3
  #include <jsi/jsi.h>
4
+ #include <memory>
5
+ #include <utility>
6
+ #include "SharedParent.h"
5
7
 
6
8
  using namespace facebook;
7
9
 
8
10
  namespace reanimated {
9
11
 
10
- class MutableValueSetterProxy: public jsi::HostObject {
11
- private:
12
+ class MutableValueSetterProxy : public jsi::HostObject {
13
+ private:
12
14
  friend MutableValue;
13
15
  std::shared_ptr<MutableValue> mutableValue;
14
- public:
15
- MutableValueSetterProxy(std::shared_ptr<MutableValue> mutableValue): mutableValue(std::move(mutableValue)) {}
16
- void set(jsi::Runtime &rt, const jsi::PropNameID &name, const jsi::Value &value);
16
+
17
+ public:
18
+ explicit MutableValueSetterProxy(std::shared_ptr<MutableValue> mutableValue)
19
+ : mutableValue(std::move(mutableValue)) {}
20
+ void
21
+ set(jsi::Runtime &rt, const jsi::PropNameID &name, const jsi::Value &value);
17
22
  jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &name);
18
23
  };
19
24
 
20
- }
25
+ } // namespace reanimated
@@ -1,24 +1,35 @@
1
1
  #pragma once
2
2
 
3
- #include "SharedParent.h"
3
+ #include <memory>
4
+ #include <vector>
5
+
4
6
  #include "FrozenObject.h"
5
7
  #include "JSIStoreValueUser.h"
8
+ #include "SharedParent.h"
6
9
 
7
10
  using namespace facebook;
8
11
 
9
12
  namespace reanimated {
10
13
 
11
- class RemoteObject: public jsi::HostObject, public StoreUser {
12
- private:
14
+ class RemoteObject : public jsi::HostObject, public StoreUser {
15
+ private:
13
16
  std::weak_ptr<jsi::Value> backing;
14
17
  std::unique_ptr<FrozenObject> initializer;
15
- public:
18
+
19
+ public:
16
20
  void maybeInitializeOnWorkletRuntime(jsi::Runtime &rt);
17
- RemoteObject(jsi::Runtime &rt, jsi::Object &object, RuntimeManager *runtimeManager, std::shared_ptr<Scheduler> s):
18
- StoreUser(s, *runtimeManager), initializer(std::make_unique<FrozenObject>(rt, object, runtimeManager)) {}
19
- void set(jsi::Runtime &rt, const jsi::PropNameID &name, const jsi::Value &value);
21
+ RemoteObject(
22
+ jsi::Runtime &rt,
23
+ const jsi::Object &object,
24
+ RuntimeManager *runtimeManager,
25
+ std::shared_ptr<Scheduler> s)
26
+ : StoreUser(s, *runtimeManager),
27
+ initializer(
28
+ std::make_unique<FrozenObject>(rt, object, runtimeManager)) {}
29
+ void
30
+ set(jsi::Runtime &rt, const jsi::PropNameID &name, const jsi::Value &value);
20
31
  jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &name);
21
32
  std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt);
22
33
  };
23
34
 
24
- }
35
+ } // namespace reanimated
@@ -1,13 +1,13 @@
1
1
  #pragma once
2
2
 
3
- #include "ShareableValue.h"
3
+ #include <jsi/jsi.h>
4
+ #include <memory>
4
5
  #include "ErrorHandler.h"
6
+ #include "JSIStoreValueUser.h"
7
+ #include "RuntimeDecorator.h"
5
8
  #include "Scheduler.h"
9
+ #include "ShareableValue.h"
6
10
  #include "WorkletsCache.h"
7
- #include "RuntimeDecorator.h"
8
- #include "JSIStoreValueUser.h"
9
- #include <jsi/jsi.h>
10
- #include <memory>
11
11
 
12
12
  namespace reanimated {
13
13
 
@@ -17,19 +17,17 @@ using namespace facebook;
17
17
  A class that manages a jsi::Runtime apart from the React-JS runtime.
18
18
  */
19
19
  class RuntimeManager {
20
- public:
20
+ public:
21
21
  RuntimeManager(
22
- std::shared_ptr<jsi::Runtime> runtime,
23
- std::shared_ptr<ErrorHandler> errorHandler,
24
- std::shared_ptr<Scheduler> scheduler,
25
- RuntimeType runtimeType = RuntimeType::Worklet
26
- ) :
27
- runtime(runtime),
28
- errorHandler(errorHandler),
29
- scheduler(scheduler),
30
- workletsCache(std::make_unique<WorkletsCache>()),
31
- storeUserData(std::make_shared<StaticStoreUser>())
32
- {
22
+ std::shared_ptr<jsi::Runtime> runtime,
23
+ std::shared_ptr<ErrorHandler> errorHandler,
24
+ std::shared_ptr<Scheduler> scheduler,
25
+ RuntimeType runtimeType = RuntimeType::Worklet)
26
+ : runtime(runtime),
27
+ errorHandler(errorHandler),
28
+ scheduler(scheduler),
29
+ workletsCache(std::make_unique<WorkletsCache>()),
30
+ storeUserData(std::make_shared<StaticStoreUser>()) {
33
31
  RuntimeDecorator::registerRuntime(this->runtime.get(), runtimeType);
34
32
  }
35
33
 
@@ -37,10 +35,10 @@ public:
37
35
  clearStore();
38
36
  }
39
37
 
40
- public:
38
+ public:
41
39
  /**
42
- Holds the jsi::Function worklet that is responsible for updating values in JS.
43
- Can be null.
40
+ Holds the jsi::Function worklet that is responsible for updating values in
41
+ JS. Can be null.
44
42
  */
45
43
  std::shared_ptr<ShareableValue> valueSetter;
46
44
  /**
@@ -52,23 +50,26 @@ public:
52
50
  */
53
51
  std::shared_ptr<ErrorHandler> errorHandler;
54
52
  /**
55
- Holds the Scheduler that is responsible for scheduling work on the UI- or React-JS Thread.
53
+ Holds the Scheduler that is responsible for scheduling work on the UI- or
54
+ React-JS Thread.
56
55
  */
57
56
  std::shared_ptr<Scheduler> scheduler;
58
57
  /**
59
- Holds a list of adapted Worklets which are cached to avoid unneccessary recreation.
58
+ Holds a list of adapted Worklets which are cached to avoid unneccessary
59
+ recreation.
60
60
  */
61
61
  std::unique_ptr<WorkletsCache> workletsCache;
62
62
  /**
63
- Holds the JSI-Value Store where JSI::Values are cached on a per-RuntimeManager basis.
63
+ Holds the JSI-Value Store where JSI::Values are cached on a
64
+ per-RuntimeManager basis.
64
65
  */
65
66
  std::shared_ptr<StaticStoreUser> storeUserData;
66
67
 
67
- private:
68
+ private:
68
69
  void clearStore() {
69
70
  const std::lock_guard<std::recursive_mutex> lock(storeUserData->storeMutex);
70
71
  storeUserData->store.clear();
71
72
  }
72
73
  };
73
74
 
74
- }
75
+ } // namespace reanimated