react-native-reanimated 3.0.0-rc.6 → 3.0.0-rc.8

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 (183) hide show
  1. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +32 -37
  2. package/Common/cpp/AnimatedSensor/AnimatedSensorModule.h +4 -3
  3. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +76 -0
  4. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +41 -0
  5. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +161 -165
  6. package/Common/cpp/NativeModules/NativeReanimatedModule.h +36 -34
  7. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +22 -34
  8. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +13 -14
  9. package/Common/cpp/SharedItems/RuntimeManager.h +1 -34
  10. package/Common/cpp/SharedItems/Shareables.cpp +142 -0
  11. package/Common/cpp/SharedItems/Shareables.h +455 -0
  12. package/Common/cpp/Tools/PlatformDepMethodsHolder.h +6 -0
  13. package/Common/cpp/Tools/RuntimeDecorator.cpp +54 -26
  14. package/Common/cpp/Tools/RuntimeDecorator.h +11 -2
  15. package/Common/cpp/Tools/Scheduler.cpp +10 -0
  16. package/Common/cpp/Tools/SingleInstanceChecker.h +1 -1
  17. package/RNReanimated.podspec +2 -1
  18. package/android/CMakeLists.txt +1 -1
  19. package/android/build.gradle +9 -4
  20. package/android/src/main/cpp/LayoutAnimations.cpp +6 -16
  21. package/android/src/main/cpp/LayoutAnimations.h +4 -4
  22. package/android/src/main/cpp/NativeProxy.cpp +60 -63
  23. package/ios/REAModule.mm +11 -5
  24. package/ios/native/NativeProxy.mm +26 -42
  25. package/ios/native/REAInitializer.mm +9 -0
  26. package/lib/commonjs/createAnimatedComponent.js +7 -11
  27. package/lib/commonjs/createAnimatedComponent.js.map +1 -1
  28. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +51 -25
  29. package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  30. package/lib/commonjs/reanimated2/ViewDescriptorsSet.js +27 -55
  31. package/lib/commonjs/reanimated2/ViewDescriptorsSet.js.map +1 -1
  32. package/lib/commonjs/reanimated2/WorkletEventHandler.js +5 -3
  33. package/lib/commonjs/reanimated2/WorkletEventHandler.js.map +1 -1
  34. package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
  35. package/lib/commonjs/reanimated2/commonTypes.js +7 -0
  36. package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
  37. package/lib/commonjs/reanimated2/core.js +111 -209
  38. package/lib/commonjs/reanimated2/core.js.map +1 -1
  39. package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
  40. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +15 -9
  41. package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  42. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +18 -8
  43. package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
  44. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +27 -36
  45. package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  46. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +24 -50
  47. package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  48. package/lib/commonjs/reanimated2/hook/useSharedValue.js +3 -2
  49. package/lib/commonjs/reanimated2/hook/useSharedValue.js.map +1 -1
  50. package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
  51. package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
  52. package/lib/commonjs/reanimated2/jestUtils.js +8 -33
  53. package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
  54. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +16 -100
  55. package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  56. package/lib/commonjs/reanimated2/js-reanimated/index.js +5 -0
  57. package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
  58. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  59. package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  60. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +91 -0
  61. package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -0
  62. package/lib/commonjs/reanimated2/layoutReanimation/index.js +1 -1
  63. package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
  64. package/lib/commonjs/reanimated2/mappers.js +186 -0
  65. package/lib/commonjs/reanimated2/mappers.js.map +1 -0
  66. package/lib/commonjs/reanimated2/mutables.js +173 -0
  67. package/lib/commonjs/reanimated2/mutables.js.map +1 -0
  68. package/lib/commonjs/reanimated2/shareables.js +153 -0
  69. package/lib/commonjs/reanimated2/shareables.js.map +1 -0
  70. package/lib/commonjs/reanimated2/threads.js +58 -0
  71. package/lib/commonjs/reanimated2/threads.js.map +1 -0
  72. package/lib/commonjs/reanimated2/time.js +55 -0
  73. package/lib/commonjs/reanimated2/time.js.map +1 -0
  74. package/lib/commonjs/reanimated2/valueSetter.js +81 -0
  75. package/lib/commonjs/reanimated2/valueSetter.js.map +1 -0
  76. package/lib/module/createAnimatedComponent.js +7 -12
  77. package/lib/module/createAnimatedComponent.js.map +1 -1
  78. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +49 -25
  79. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  80. package/lib/module/reanimated2/ViewDescriptorsSet.js +27 -53
  81. package/lib/module/reanimated2/ViewDescriptorsSet.js.map +1 -1
  82. package/lib/module/reanimated2/WorkletEventHandler.js +4 -3
  83. package/lib/module/reanimated2/WorkletEventHandler.js.map +1 -1
  84. package/lib/module/reanimated2/animation/util.js.map +1 -1
  85. package/lib/module/reanimated2/commonTypes.js +7 -0
  86. package/lib/module/reanimated2/commonTypes.js.map +1 -1
  87. package/lib/module/reanimated2/core.js +66 -188
  88. package/lib/module/reanimated2/core.js.map +1 -1
  89. package/lib/module/reanimated2/globals.d.js.map +1 -1
  90. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +16 -6
  91. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  92. package/lib/module/reanimated2/hook/useAnimatedRef.js +17 -8
  93. package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
  94. package/lib/module/reanimated2/hook/useAnimatedSensor.js +29 -34
  95. package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  96. package/lib/module/reanimated2/hook/useAnimatedStyle.js +26 -52
  97. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  98. package/lib/module/reanimated2/hook/useSharedValue.js +3 -2
  99. package/lib/module/reanimated2/hook/useSharedValue.js.map +1 -1
  100. package/lib/module/reanimated2/hook/utils.js.map +1 -1
  101. package/lib/module/reanimated2/interpolateColor.js.map +1 -1
  102. package/lib/module/reanimated2/jestUtils.js +8 -31
  103. package/lib/module/reanimated2/jestUtils.js.map +1 -1
  104. package/lib/module/reanimated2/js-reanimated/JSReanimated.js +16 -95
  105. package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  106. package/lib/module/reanimated2/js-reanimated/index.js +5 -0
  107. package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
  108. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  109. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  110. package/lib/module/reanimated2/layoutReanimation/animationsManager.js +84 -0
  111. package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -0
  112. package/lib/module/reanimated2/layoutReanimation/index.js +1 -1
  113. package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
  114. package/lib/module/reanimated2/mappers.js +173 -0
  115. package/lib/module/reanimated2/mappers.js.map +1 -0
  116. package/lib/module/reanimated2/mutables.js +149 -0
  117. package/lib/module/reanimated2/mutables.js.map +1 -0
  118. package/lib/module/reanimated2/shareables.js +133 -0
  119. package/lib/module/reanimated2/shareables.js.map +1 -0
  120. package/lib/module/reanimated2/threads.js +45 -0
  121. package/lib/module/reanimated2/threads.js.map +1 -0
  122. package/lib/module/reanimated2/time.js +37 -0
  123. package/lib/module/reanimated2/time.js.map +1 -0
  124. package/lib/module/reanimated2/valueSetter.js +66 -0
  125. package/lib/module/reanimated2/valueSetter.js.map +1 -0
  126. package/package.json +2 -2
  127. package/plugin.js +31 -15
  128. package/scripts/reanimated_utils.rb +3 -2
  129. package/src/createAnimatedComponent.tsx +8 -24
  130. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +62 -53
  131. package/src/reanimated2/ViewDescriptorsSet.ts +30 -69
  132. package/src/reanimated2/WorkletEventHandler.ts +4 -11
  133. package/src/reanimated2/animation/util.ts +1 -0
  134. package/src/reanimated2/commonTypes.ts +29 -4
  135. package/src/reanimated2/core.ts +103 -230
  136. package/src/reanimated2/globals.d.ts +28 -26
  137. package/src/reanimated2/hook/useAnimatedKeyboard.ts +18 -9
  138. package/src/reanimated2/hook/useAnimatedRef.ts +27 -9
  139. package/src/reanimated2/hook/useAnimatedSensor.ts +33 -31
  140. package/src/reanimated2/hook/useAnimatedStyle.ts +26 -64
  141. package/src/reanimated2/hook/useSharedValue.ts +6 -3
  142. package/src/reanimated2/hook/utils.ts +1 -1
  143. package/src/reanimated2/interpolateColor.ts +2 -2
  144. package/src/reanimated2/jestUtils.ts +14 -29
  145. package/src/reanimated2/js-reanimated/JSReanimated.ts +19 -93
  146. package/src/reanimated2/js-reanimated/index.ts +4 -0
  147. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +7 -0
  148. package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
  149. package/src/reanimated2/layoutReanimation/animationsManager.ts +94 -0
  150. package/src/reanimated2/layoutReanimation/index.ts +1 -1
  151. package/src/reanimated2/mappers.ts +179 -0
  152. package/src/reanimated2/mutables.ts +151 -0
  153. package/src/reanimated2/shareables.ts +121 -0
  154. package/src/reanimated2/threads.ts +46 -0
  155. package/src/reanimated2/time.ts +30 -0
  156. package/src/reanimated2/valueSetter.ts +64 -0
  157. package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp +0 -127
  158. package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.h +0 -56
  159. package/Common/cpp/Registries/MapperRegistry.cpp +0 -147
  160. package/Common/cpp/Registries/MapperRegistry.h +0 -29
  161. package/Common/cpp/Registries/WorkletsCache.cpp +0 -45
  162. package/Common/cpp/Registries/WorkletsCache.h +0 -24
  163. package/Common/cpp/SharedItems/FrozenObject.cpp +0 -35
  164. package/Common/cpp/SharedItems/FrozenObject.h +0 -36
  165. package/Common/cpp/SharedItems/HostFunctionHandler.h +0 -28
  166. package/Common/cpp/SharedItems/MutableValue.cpp +0 -134
  167. package/Common/cpp/SharedItems/MutableValue.h +0 -54
  168. package/Common/cpp/SharedItems/MutableValueSetterProxy.cpp +0 -47
  169. package/Common/cpp/SharedItems/MutableValueSetterProxy.h +0 -25
  170. package/Common/cpp/SharedItems/RemoteObject.cpp +0 -45
  171. package/Common/cpp/SharedItems/RemoteObject.h +0 -35
  172. package/Common/cpp/SharedItems/ShareableValue.cpp +0 -529
  173. package/Common/cpp/SharedItems/ShareableValue.h +0 -63
  174. package/Common/cpp/SharedItems/ValueWrapper.h +0 -183
  175. package/Common/cpp/Tools/JSIStoreValueUser.cpp +0 -55
  176. package/Common/cpp/Tools/JSIStoreValueUser.h +0 -37
  177. package/Common/cpp/Tools/Mapper.cpp +0 -86
  178. package/Common/cpp/Tools/Mapper.h +0 -51
  179. package/lib/commonjs/reanimated2/layoutReanimation/LayoutAnimationRepository.js +0 -58
  180. package/lib/commonjs/reanimated2/layoutReanimation/LayoutAnimationRepository.js.map +0 -1
  181. package/lib/module/reanimated2/layoutReanimation/LayoutAnimationRepository.js +0 -52
  182. package/lib/module/reanimated2/layoutReanimation/LayoutAnimationRepository.js.map +0 -1
  183. package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +0 -49
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.8)
3
3
 
4
4
  set (CMAKE_VERBOSE_MAKEFILE ON)
5
5
  set (CMAKE_CXX_STANDARD 17)
6
- set (DEFAULT_FLAGS "-DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_HAVE_MEMRCHR=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DFOLLY_HAVE_RECVMMSG=1 -DFOLLY_HAVE_PTHREAD=1 -DANDROID -DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION} -DHERMES_ENABLE_DEBUGGER=${HERMES_ENABLE_DEBUGGER} -fexceptions -fno-omit-frame-pointer -frtti -Wno-sign-compare -std=c++17 -Wall -Werror")
6
+ set (DEFAULT_FLAGS "-DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_HAVE_MEMRCHR=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DFOLLY_HAVE_RECVMMSG=1 -DFOLLY_HAVE_PTHREAD=1 -DANDROID -DREACT_NATIVE_MINOR_VERSION=${REACT_NATIVE_MINOR_VERSION} -DREANIMATED_VERSION=${REANIMATED_VERSION} -DHERMES_ENABLE_DEBUGGER=${HERMES_ENABLE_DEBUGGER} -fexceptions -fno-omit-frame-pointer -frtti -Wno-sign-compare -std=c++17 -Wall -Werror")
7
7
  if(${IS_NEW_ARCHITECTURE_ENABLED})
8
8
  set (ALL_FLAGS "${DEFAULT_FLAGS} -DRCT_NEW_ARCH_ENABLED")
9
9
  else()
@@ -179,8 +179,11 @@ def checkNoMultipleInstances() {
179
179
  def getReanimatedVersion() {
180
180
  def inputFile = file(projectDir.path + '/../package.json')
181
181
  def json = new JsonSlurper().parseText(inputFile.text)
182
- String reanimatedVersion = json.version
183
- def (major, minor, patch) = reanimatedVersion.tokenize('.')
182
+ return json.version
183
+ }
184
+
185
+ def getReanimatedMajorVersion() {
186
+ def (major, minor, patch) = getReanimatedVersion().tokenize('.')
184
187
  return major.toInteger()
185
188
  }
186
189
 
@@ -209,7 +212,8 @@ def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME")
209
212
  def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.split("\\.")[1].toInteger()
210
213
  def FBJNI_VERSION = "0.3.0"
211
214
  def REANIMATED_PACKAGE_BUILD = System.getenv("REANIMATED_PACKAGE_BUILD")
212
- def REANIMATED_MAJOR_VERSION = getReanimatedVersion()
215
+ def REANIMATED_VERSION = getReanimatedVersion()
216
+ def REANIMATED_MAJOR_VERSION = getReanimatedMajorVersion()
213
217
 
214
218
  // We download various C++ open-source dependencies into downloads.
215
219
  // We then copy both the downloaded code and our custom makefiles and headers into third-party-ndk.
@@ -461,7 +465,8 @@ android {
461
465
  "-DCLIENT_SIDE_BUILD=${CLIENT_SIDE_BUILD}",
462
466
  "-DIS_NEW_ARCHITECTURE_ENABLED=${isNewArchitectureEnabled()}",
463
467
  "-DPLAYGROUND_APP_NAME=${getPlaygroundAppName()}",
464
- "-DREANIMATED_PACKAGE_BUILD=${REANIMATED_PACKAGE_BUILD}"
468
+ "-DREANIMATED_PACKAGE_BUILD=${REANIMATED_PACKAGE_BUILD}",
469
+ "-DREANIMATED_VERSION=${REANIMATED_VERSION}"
465
470
  abiFilters (*reactNativeArchitectures())
466
471
  _stackProtectorFlag ? (cppFlags("-fstack-protector-all")) : null
467
472
  }
@@ -13,10 +13,6 @@ jni::local_ref<LayoutAnimations::jhybriddata> LayoutAnimations::initHybrid(
13
13
  return makeCxxInstance(jThis);
14
14
  }
15
15
 
16
- void LayoutAnimations::setWeakUIRuntime(std::weak_ptr<jsi::Runtime> wrt) {
17
- this->weakUIRuntime = wrt;
18
- }
19
-
20
16
  void LayoutAnimations::setAnimationStartingBlock(
21
17
  AnimationStartingBlock animationStartingBlock) {
22
18
  this->animationStartingBlock_ = animationStartingBlock;
@@ -31,17 +27,12 @@ void LayoutAnimations::startAnimationForTag(
31
27
 
32
28
  void LayoutAnimations::progressLayoutAnimation(
33
29
  int tag,
34
- const jsi::Value &progress) {
35
- if (auto rt = this->weakUIRuntime.lock()) {
36
- static const auto method =
37
- javaPart_->getClass()
38
- ->getMethod<void(int, JMap<JString, JObject>::javaobject)>(
39
- "progressLayoutAnimation");
40
- method(
41
- javaPart_.get(),
42
- tag,
43
- JNIHelper::ConvertToPropsMap(*rt, progress.asObject(*rt)).get());
44
- }
30
+ const jni::local_ref<JNIHelper::PropsMap> &updates) {
31
+ static const auto method =
32
+ javaPart_->getClass()
33
+ ->getMethod<void(int, JMap<JString, JObject>::javaobject)>(
34
+ "progressLayoutAnimation");
35
+ method(javaPart_.get(), tag, updates.get());
45
36
  }
46
37
 
47
38
  void LayoutAnimations::endLayoutAnimation(
@@ -91,5 +82,4 @@ void LayoutAnimations::registerNatives() {
91
82
  LayoutAnimations::isLayoutAnimationEnabled),
92
83
  });
93
84
  }
94
-
95
85
  }; // namespace reanimated
@@ -14,7 +14,7 @@ using namespace facebook;
14
14
  class LayoutAnimations : public jni::HybridClass<LayoutAnimations> {
15
15
  using AnimationStartingBlock = std::function<
16
16
  void(int, alias_ref<JString>, alias_ref<JMap<jstring, jstring>>)>;
17
- using HasAnimationBlock = std::function<bool(int, std::string)>;
17
+ using HasAnimationBlock = std::function<bool(int, const std::string &)>;
18
18
  using ClearAnimationConfigBlock = std::function<void(int)>;
19
19
 
20
20
  public:
@@ -31,20 +31,20 @@ class LayoutAnimations : public jni::HybridClass<LayoutAnimations> {
31
31
  bool hasAnimationForTag(int tag, std::string type);
32
32
  bool isLayoutAnimationEnabled();
33
33
 
34
- void setWeakUIRuntime(std::weak_ptr<jsi::Runtime> wrt);
35
34
  void setAnimationStartingBlock(AnimationStartingBlock animationStartingBlock);
36
35
  void setHasAnimationBlock(HasAnimationBlock hasAnimationBlock);
37
36
  void setClearAnimationConfigBlock(
38
37
  ClearAnimationConfigBlock clearAnimationConfigBlock);
39
38
 
40
- void progressLayoutAnimation(int tag, const jsi::Value &progress);
39
+ void progressLayoutAnimation(
40
+ int tag,
41
+ const jni::local_ref<JNIHelper::PropsMap> &updates);
41
42
  void endLayoutAnimation(int tag, bool cancelled, bool removeView);
42
43
  void clearAnimationConfigForTag(int tag);
43
44
 
44
45
  private:
45
46
  friend HybridBase;
46
47
  jni::global_ref<LayoutAnimations::javaobject> javaPart_;
47
- std::weak_ptr<jsi::Runtime> weakUIRuntime;
48
48
  AnimationStartingBlock animationStartingBlock_;
49
49
  HasAnimationBlock hasAnimationBlock_;
50
50
  ClearAnimationConfigBlock clearAnimationConfigBlock_;
@@ -11,7 +11,7 @@
11
11
 
12
12
  #include "AndroidErrorHandler.h"
13
13
  #include "AndroidScheduler.h"
14
- #include "LayoutAnimationsProxy.h"
14
+ #include "LayoutAnimationsManager.h"
15
15
  #include "NativeProxy.h"
16
16
  #include "PlatformDepMethodsHolder.h"
17
17
  #include "ReanimatedRuntime.h"
@@ -23,6 +23,12 @@
23
23
  #include "ReanimatedUIManagerBinding.h"
24
24
  #endif
25
25
 
26
+ #ifdef REANIMATED_VERSION
27
+ #define STRINGIZE(x) #x
28
+ #define STRINGIZE2(x) STRINGIZE(x)
29
+ #define REANIMATED_VERSION_STRING STRINGIZE2(REANIMATED_VERSION)
30
+ #endif // REANIMATED_VERSION
31
+
26
32
  namespace reanimated {
27
33
 
28
34
  using namespace facebook;
@@ -225,13 +231,18 @@ void NativeProxy::installJSIBindings(
225
231
  runtime_->global().setProperty(*runtime_, "_IS_FABRIC", false);
226
232
  #endif
227
233
 
234
+ auto version =
235
+ jsi::String::createFromUtf8(*runtime_, REANIMATED_VERSION_STRING);
236
+ runtime_->global().setProperty(*runtime_, "_REANIMATED_VERSION_CPP", version);
237
+
228
238
  std::shared_ptr<ErrorHandler> errorHandler =
229
239
  std::make_shared<AndroidErrorHandler>(scheduler_);
240
+ std::weak_ptr<jsi::Runtime> wrt = animatedRuntime;
230
241
 
231
- // Layout Animations Start
232
-
233
- auto progressLayoutAnimation = [this](int tag, jsi::Value progress) {
234
- this->layoutAnimations->cthis()->progressLayoutAnimation(tag, progress);
242
+ auto progressLayoutAnimation = [this, wrt](
243
+ int tag, const jsi::Object &newProps) {
244
+ auto newPropsJNI = JNIHelper::ConvertToPropsMap(*wrt.lock(), newProps);
245
+ this->layoutAnimations->cthis()->progressLayoutAnimation(tag, newPropsJNI);
235
246
  };
236
247
 
237
248
  auto endLayoutAnimation = [this](int tag, bool isCancelled, bool removeView) {
@@ -239,62 +250,6 @@ void NativeProxy::installJSIBindings(
239
250
  tag, isCancelled, removeView);
240
251
  };
241
252
 
242
- std::shared_ptr<LayoutAnimationsProxy> layoutAnimationsProxy =
243
- std::make_shared<LayoutAnimationsProxy>(
244
- progressLayoutAnimation, endLayoutAnimation, errorHandler);
245
- std::weak_ptr<jsi::Runtime> wrt = animatedRuntime;
246
- std::weak_ptr<LayoutAnimationsProxy> weakLayoutAnimationsProxy =
247
- layoutAnimationsProxy;
248
- layoutAnimations->cthis()->setWeakUIRuntime(wrt);
249
- std::weak_ptr<ErrorHandler> weakErrorHandler = errorHandler;
250
-
251
- layoutAnimations->cthis()->setAnimationStartingBlock(
252
- [wrt, weakLayoutAnimationsProxy, weakErrorHandler](
253
- int tag,
254
- alias_ref<JString> type,
255
- alias_ref<JMap<jstring, jstring>> values) {
256
- auto runtime = wrt.lock();
257
- auto layoutAnimationsProxy = weakLayoutAnimationsProxy.lock();
258
- if (!runtime || !layoutAnimationsProxy) {
259
- return;
260
- }
261
- auto &rt = *runtime;
262
- jsi::Object yogaValues(rt);
263
- for (const auto &entry : *values) {
264
- try {
265
- auto key =
266
- jsi::String::createFromAscii(rt, entry.first->toStdString());
267
- auto value = stod(entry.second->toStdString());
268
- yogaValues.setProperty(rt, key, value);
269
- } catch (std::invalid_argument e) {
270
- if (auto errorHandler = weakErrorHandler.lock()) {
271
- errorHandler->setError("Failed to convert value to number");
272
- errorHandler->raise();
273
- }
274
- }
275
- }
276
-
277
- layoutAnimationsProxy->startLayoutAnimation(
278
- *runtime, tag, type->toStdString(), yogaValues);
279
- });
280
-
281
- layoutAnimations->cthis()->setHasAnimationBlock(
282
- [weakLayoutAnimationsProxy](int tag, std::string type) {
283
- auto layoutAnimationsProxy = weakLayoutAnimationsProxy.lock();
284
- return layoutAnimationsProxy &&
285
- layoutAnimationsProxy->hasLayoutAnimation(tag, type);
286
- });
287
-
288
- layoutAnimations->cthis()->setClearAnimationConfigBlock(
289
- [weakLayoutAnimationsProxy](int tag) {
290
- auto layoutAnimationsProxy = weakLayoutAnimationsProxy.lock();
291
- if (layoutAnimationsProxy) {
292
- layoutAnimationsProxy->clearLayoutAnimationConfig(tag);
293
- }
294
- });
295
-
296
- // Layout Animations End
297
-
298
253
  PlatformDepMethodsHolder platformDepMethodsHolder = {
299
254
  requestRender,
300
255
  #ifdef RCT_NEW_ARCH_ENABLED
@@ -306,6 +261,8 @@ void NativeProxy::installJSIBindings(
306
261
  configurePropsFunction,
307
262
  #endif
308
263
  getCurrentTime,
264
+ progressLayoutAnimation,
265
+ endLayoutAnimation,
309
266
  registerSensorFunction,
310
267
  unregisterSensorFunction,
311
268
  setGestureStateFunction,
@@ -323,12 +280,13 @@ void NativeProxy::installJSIBindings(
323
280
  #else
324
281
  propObtainer,
325
282
  #endif
326
- layoutAnimationsProxy,
327
283
  platformDepMethodsHolder);
328
284
 
329
- _nativeReanimatedModule = module;
285
+ scheduler_->setRuntimeManager(module);
330
286
 
287
+ _nativeReanimatedModule = module;
331
288
  std::weak_ptr<NativeReanimatedModule> weakModule = module;
289
+
332
290
  #ifdef RCT_NEW_ARCH_ENABLED
333
291
  this->registerEventHandler([weakModule, getCurrentTime](
334
292
  std::string eventName,
@@ -380,6 +338,45 @@ void NativeProxy::installJSIBindings(
380
338
  // reactScheduler_ = binding->getScheduler();
381
339
  // reactScheduler_->addEventListener(eventListener_);
382
340
 
341
+ std::weak_ptr<ErrorHandler> weakErrorHandler = errorHandler;
342
+
343
+ layoutAnimations->cthis()->setAnimationStartingBlock(
344
+ [wrt, weakModule, weakErrorHandler](
345
+ int tag,
346
+ alias_ref<JString> type,
347
+ alias_ref<JMap<jstring, jstring>> values) {
348
+ auto &rt = *wrt.lock();
349
+ jsi::Object yogaValues(rt);
350
+ for (const auto &entry : *values) {
351
+ try {
352
+ auto key =
353
+ jsi::String::createFromAscii(rt, entry.first->toStdString());
354
+ auto value = stod(entry.second->toStdString());
355
+ yogaValues.setProperty(rt, key, value);
356
+ } catch (std::invalid_argument e) {
357
+ if (auto errorHandler = weakErrorHandler.lock()) {
358
+ errorHandler->setError("Failed to convert value to number");
359
+ errorHandler->raise();
360
+ }
361
+ }
362
+ }
363
+
364
+ weakModule.lock()->layoutAnimationsManager().startLayoutAnimation(
365
+ rt, tag, type->toStdString(), yogaValues);
366
+ });
367
+
368
+ layoutAnimations->cthis()->setHasAnimationBlock(
369
+ [weakModule](int tag, const std::string &type) {
370
+ return weakModule.lock()->layoutAnimationsManager().hasLayoutAnimation(
371
+ tag, type);
372
+ });
373
+
374
+ layoutAnimations->cthis()->setClearAnimationConfigBlock(
375
+ [weakModule](int tag) {
376
+ weakModule.lock()->layoutAnimationsManager().clearLayoutAnimationConfig(
377
+ tag);
378
+ });
379
+
383
380
  runtime_->global().setProperty(
384
381
  *runtime_,
385
382
  jsi::PropNameID::forAscii(*runtime_, "__reanimatedModuleProxy"),
package/ios/REAModule.mm CHANGED
@@ -21,6 +21,12 @@
21
21
  #import <RNReanimated/REANodesManager.h>
22
22
  #import <RNReanimated/SingleInstanceChecker.h>
23
23
 
24
+ #ifdef REANIMATED_VERSION
25
+ #define STRINGIZE(x) #x
26
+ #define STRINGIZE2(x) STRINGIZE(x)
27
+ #define REANIMATED_VERSION_STRING STRINGIZE2(REANIMATED_VERSION)
28
+ #endif // REANIMATED_VERSION
29
+
24
30
  using namespace facebook::react;
25
31
  using namespace reanimated;
26
32
 
@@ -44,7 +50,6 @@ typedef void (^AnimatedOperation)(REANodesManager *nodesManager);
44
50
  __weak RCTSurfacePresenter *_surfacePresenter;
45
51
  std::shared_ptr<NewestShadowNodesRegistry> newestShadowNodesRegistry;
46
52
  std::weak_ptr<NativeReanimatedModule> reanimatedModule_;
47
- std::shared_ptr<EventListener> eventListener_;
48
53
  #else
49
54
  NSMutableArray<AnimatedOperation> *_operations;
50
55
  #endif
@@ -66,8 +71,6 @@ RCT_EXPORT_MODULE(ReanimatedModule);
66
71
  - (void)invalidate
67
72
  {
68
73
  #ifdef RCT_NEW_ARCH_ENABLED
69
- RCTScheduler *scheduler = [_surfacePresenter scheduler];
70
- [scheduler removeEventListener:eventListener_];
71
74
  [[NSNotificationCenter defaultCenter] removeObserver:self];
72
75
  #endif
73
76
  [_nodesManager invalidate];
@@ -146,7 +149,7 @@ RCT_EXPORT_MODULE(ReanimatedModule);
146
149
  return;
147
150
  }
148
151
  if (auto reanimatedModule = strongSelf->reanimatedModule_.lock()) {
149
- self->eventListener_ =
152
+ auto eventListener =
150
153
  std::make_shared<facebook::react::EventListener>([reanimatedModule](const RawEvent &rawEvent) {
151
154
  if (!RCTIsMainQueue()) {
152
155
  // event listener called on the JS thread, let's ignore this event
@@ -156,7 +159,7 @@ RCT_EXPORT_MODULE(ReanimatedModule);
156
159
  }
157
160
  return reanimatedModule->handleRawEvent(rawEvent, CACurrentMediaTime() * 1000);
158
161
  });
159
- [scheduler addEventListener:self->eventListener_];
162
+ [scheduler addEventListener:eventListener];
160
163
  }
161
164
  });
162
165
  }
@@ -219,6 +222,9 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(installTurboModule)
219
222
 
220
223
  runtime.global().setProperty(runtime, "_IS_FABRIC", true);
221
224
 
225
+ auto version = jsi::String::createFromUtf8(runtime, REANIMATED_VERSION_STRING);
226
+ runtime.global().setProperty(runtime, "_REANIMATED_VERSION_CPP", version);
227
+
222
228
  runtime.global().setProperty(
223
229
  runtime,
224
230
  jsi::PropNameID::forAscii(runtime, "__reanimatedModuleProxy"),
@@ -1,4 +1,3 @@
1
- #import <RNReanimated/LayoutAnimationsProxy.h>
2
1
  #import <RNReanimated/NativeMethods.h>
3
2
  #import <RNReanimated/NativeProxy.h>
4
3
  #import <RNReanimated/REAAnimationsManager.h>
@@ -229,8 +228,14 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
229
228
  [nodesManager synchronouslyUpdateViewOnUIThread:viewTag props:uiProps];
230
229
  };
231
230
 
232
- auto layoutAnimationsProxy = std::make_shared<LayoutAnimationsProxy>(
233
- [](int tag, jsi::Object newStyle) {}, [](int tag, bool isCancelled, bool removeView) {}, errorHandler);
231
+ auto progressLayoutAnimation = [=](int tag, const jsi::Object &newStyle) {
232
+ // noop
233
+ };
234
+
235
+ auto endLayoutAnimation = [=](int tag, bool isCancelled, bool removeView) {
236
+ // noop
237
+ };
238
+
234
239
  #else
235
240
  // Layout Animations start
236
241
  __block std::weak_ptr<Scheduler> weakScheduler = scheduler;
@@ -247,19 +252,15 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
247
252
  [reaUiManagerNoCast setUp:animationsManager];
248
253
 
249
254
  __weak REAAnimationsManager *weakAnimationsManager = animationsManager;
250
- auto progressLayoutAnimation = [weakAnimationsManager, animatedRuntime](int tag, jsi::Object newStyle) {
251
- REAAnimationsManager *animationsManager = weakAnimationsManager;
252
- if (animationsManager) {
253
- NSDictionary *propsDict = convertJSIObjectToNSDictionary(*animatedRuntime, newStyle);
254
- [animationsManager progressLayoutAnimationWithStyle:propsDict forTag:@(tag)];
255
- }
255
+ std::weak_ptr<jsi::Runtime> wrt = animatedRuntime;
256
+
257
+ auto progressLayoutAnimation = [=](int tag, const jsi::Object &newStyle) {
258
+ NSDictionary *propsDict = convertJSIObjectToNSDictionary(*wrt.lock(), newStyle);
259
+ [weakAnimationsManager progressLayoutAnimationWithStyle:propsDict forTag:@(tag)];
256
260
  };
257
261
 
258
- auto endLayoutAnimation = [weakAnimationsManager](int tag, bool isCancelled, bool removeView) {
259
- REAAnimationsManager *animationsManager = weakAnimationsManager;
260
- if (animationsManager) {
261
- [animationsManager endLayoutAnimationForTag:@(tag) cancelled:isCancelled removeView:removeView];
262
- }
262
+ auto endLayoutAnimation = [=](int tag, bool isCancelled, bool removeView) {
263
+ [weakAnimationsManager endLayoutAnimationForTag:@(tag) cancelled:isCancelled removeView:removeView];
263
264
  };
264
265
 
265
266
  auto configurePropsFunction = [reanimatedModule](
@@ -269,11 +270,6 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
269
270
  [reanimatedModule.nodesManager configureUiProps:uiPropsSet andNativeProps:nativePropsSet];
270
271
  };
271
272
 
272
- auto layoutAnimationsProxy =
273
- std::make_shared<LayoutAnimationsProxy>(progressLayoutAnimation, endLayoutAnimation, errorHandler);
274
- auto weakLayoutAnimationsProxy = std::weak_ptr(layoutAnimationsProxy);
275
- std::weak_ptr<jsi::Runtime> wrt = animatedRuntime;
276
-
277
273
  // Layout Animations end
278
274
  #endif
279
275
 
@@ -318,6 +314,8 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
318
314
  configurePropsFunction,
319
315
  #endif
320
316
  getCurrentTime,
317
+ progressLayoutAnimation,
318
+ endLayoutAnimation,
321
319
  registerSensorFunction,
322
320
  unregisterSensorFunction,
323
321
  setGestureStateFunction,
@@ -335,7 +333,6 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
335
333
  #else
336
334
  propObtainer,
337
335
  #endif
338
- layoutAnimationsProxy,
339
336
  platformDepMethodsHolder);
340
337
 
341
338
  scheduler->setRuntimeManager(module);
@@ -372,8 +369,8 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
372
369
  }];
373
370
  #endif
374
371
 
375
- #ifdef RCT_NEW_ARCH_ENABLED
376
372
  std::weak_ptr<NativeReanimatedModule> weakModule = module; // to avoid retain cycle
373
+ #ifdef RCT_NEW_ARCH_ENABLED
377
374
  [reanimatedModule.nodesManager registerPerformOperations:^() {
378
375
  if (auto module = weakModule.lock()) {
379
376
  module->performOperations();
@@ -383,37 +380,24 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
383
380
  // Layout Animation callbacks setup
384
381
  [animationsManager setAnimationStartingBlock:^(
385
382
  NSNumber *_Nonnull tag, NSString *type, NSDictionary *_Nonnull values, NSNumber *depth) {
386
- std::shared_ptr<jsi::Runtime> runtime = wrt.lock();
387
- if (runtime == nullptr) {
388
- return;
389
- }
390
- auto layoutAnimationsProxy = weakLayoutAnimationsProxy.lock();
391
- if (layoutAnimationsProxy == nullptr) {
392
- return;
393
- }
394
- jsi::Object yogaValues(*runtime);
383
+ jsi::Runtime &rt = *wrt.lock();
384
+ jsi::Object yogaValues(rt);
395
385
  for (NSString *key in values.allKeys) {
396
386
  NSNumber *value = values[key];
397
- yogaValues.setProperty(*runtime, [key UTF8String], [value doubleValue]);
387
+ yogaValues.setProperty(rt, [key UTF8String], [value doubleValue]);
398
388
  }
399
389
 
400
- layoutAnimationsProxy->startLayoutAnimation(*runtime, [tag intValue], std::string([type UTF8String]), yogaValues);
390
+ weakModule.lock()->layoutAnimationsManager().startLayoutAnimation(
391
+ rt, [tag intValue], std::string([type UTF8String]), yogaValues);
401
392
  }];
402
393
 
403
394
  [animationsManager setHasAnimationBlock:^(NSNumber *_Nonnull tag, NSString *_Nonnull type) {
404
- auto layoutAnimationsProxy = weakLayoutAnimationsProxy.lock();
405
- if (layoutAnimationsProxy == nullptr) {
406
- return false;
407
- }
408
- return layoutAnimationsProxy->hasLayoutAnimation([tag intValue], std::string([type UTF8String]));
395
+ return weakModule.lock()->layoutAnimationsManager().hasLayoutAnimation(
396
+ [tag intValue], std::string([type UTF8String]));
409
397
  }];
410
398
 
411
399
  [animationsManager setAnimationRemovingBlock:^(NSNumber *_Nonnull tag) {
412
- auto layoutAnimationsProxy = weakLayoutAnimationsProxy.lock();
413
- if (layoutAnimationsProxy == nullptr) {
414
- return;
415
- }
416
- layoutAnimationsProxy->clearLayoutAnimationConfig([tag intValue]);
400
+ weakModule.lock()->layoutAnimationsManager().clearLayoutAnimationConfig([tag intValue]);
417
401
  }];
418
402
  #endif
419
403
 
@@ -1,6 +1,12 @@
1
1
  #import <RNReanimated/REAInitializer.h>
2
2
  #import <RNReanimated/REAUIManager.h>
3
3
 
4
+ #ifdef REANIMATED_VERSION
5
+ #define STRINGIZE(x) #x
6
+ #define STRINGIZE2(x) STRINGIZE(x)
7
+ #define REANIMATED_VERSION_STRING STRINGIZE2(REANIMATED_VERSION)
8
+ #endif // REANIMATED_VERSION
9
+
4
10
  @interface RCTEventDispatcher (Reanimated)
5
11
 
6
12
  - (void)setBridge:(RCTBridge *)bridge;
@@ -58,6 +64,9 @@ JSIExecutor::RuntimeInstaller REAJSIExecutorRuntimeInstaller(
58
64
 
59
65
  runtime.global().setProperty(runtime, "_IS_FABRIC", false);
60
66
 
67
+ auto version = jsi::String::createFromUtf8(runtime, REANIMATED_VERSION_STRING);
68
+ runtime.global().setProperty(runtime, "_REANIMATED_VERSION_CPP", version);
69
+
61
70
  runtime.global().setProperty(
62
71
  runtime,
63
72
  jsi::PropNameID::forAscii(runtime, "__reanimatedModuleProxy"),
@@ -13,7 +13,7 @@ var _WorkletEventHandler = _interopRequireDefault(require("./reanimated2/Worklet
13
13
 
14
14
  var _setAndForwardRef = _interopRequireDefault(require("./setAndForwardRef"));
15
15
 
16
- require("./reanimated2/layoutReanimation/LayoutAnimationRepository");
16
+ require("./reanimated2/layoutReanimation/animationsManager");
17
17
 
18
18
  var _invariant = _interopRequireDefault(require("invariant"));
19
19
 
@@ -29,6 +29,8 @@ var _animation = require("./reanimated2/animation");
29
29
 
30
30
  var _fabricUtils = require("./reanimated2/fabricUtils");
31
31
 
32
+ var _shareables = require("./reanimated2/shareables");
33
+
32
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
35
 
34
36
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
@@ -116,8 +118,6 @@ function createAnimatedComponent(Component, options) {
116
118
 
117
119
  _defineProperty(this, "initialStyle", {});
118
120
 
119
- _defineProperty(this, "sv", void 0);
120
-
121
121
  _defineProperty(this, "_component", null);
122
122
 
123
123
  _defineProperty(this, "_setComponentRef", (0, _setAndForwardRef.default)({
@@ -137,15 +137,15 @@ function createAnimatedComponent(Component, options) {
137
137
  }
138
138
 
139
139
  if (layout) {
140
- (0, _core.configureLayoutAnimations)(tag, 'layout', maybeBuild(layout), this.sv);
140
+ (0, _core.configureLayoutAnimations)(tag, 'layout', maybeBuild(layout));
141
141
  }
142
142
 
143
143
  if (entering) {
144
- (0, _core.configureLayoutAnimations)(tag, 'entering', maybeBuild(entering), this.sv);
144
+ (0, _core.configureLayoutAnimations)(tag, 'entering', maybeBuild(entering));
145
145
  }
146
146
 
147
147
  if (exiting) {
148
- (0, _core.configureLayoutAnimations)(tag, 'exiting', maybeBuild(exiting), this.sv);
148
+ (0, _core.configureLayoutAnimations)(tag, 'exiting', maybeBuild(exiting));
149
149
  }
150
150
  }
151
151
 
@@ -160,16 +160,12 @@ function createAnimatedComponent(Component, options) {
160
160
  value: {}
161
161
  };
162
162
  }
163
-
164
- this.sv = (0, _core.makeMutable)({});
165
163
  }
166
164
 
167
165
  componentWillUnmount() {
168
166
  this._detachNativeEvents();
169
167
 
170
168
  this._detachStyles();
171
-
172
- this.sv = null;
173
169
  }
174
170
 
175
171
  componentDidMount() {
@@ -315,7 +311,7 @@ function createAnimatedComponent(Component, options) {
315
311
  }
316
312
 
317
313
  if (global._IS_FABRIC) {
318
- shadowNodeWrapper = (0, _fabricUtils.getShadowNodeWrapperFromRef)(this);
314
+ shadowNodeWrapper = (0, _shareables.makeShareableShadowNodeWrapper)((0, _fabricUtils.getShadowNodeWrapperFromRef)(this));
319
315
  }
320
316
  }
321
317