react-native-reanimated 4.3.0-rc.0 → 4.3.0

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 (153) hide show
  1. package/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpp +8 -5
  2. package/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.h +3 -5
  3. package/Common/cpp/reanimated/CSS/common/values/CSSValueVariant.cpp +2 -3
  4. package/Common/cpp/reanimated/CSS/interpolation/PropertyInterpolator.cpp +2 -3
  5. package/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.cpp +2 -2
  6. package/Common/cpp/reanimated/CSS/utils/DelayedItemsManager.h +2 -2
  7. package/Common/cpp/reanimated/Compat/WorkletsApi.h +13 -0
  8. package/Common/cpp/reanimated/Events/UIEventHandler.cpp +1 -1
  9. package/Common/cpp/reanimated/Events/UIEventHandler.h +3 -4
  10. package/Common/cpp/reanimated/Events/UIEventHandlerRegistry.cpp +3 -2
  11. package/Common/cpp/reanimated/Events/UIEventHandlerRegistry.h +1 -1
  12. package/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.cpp +2 -8
  13. package/Common/cpp/reanimated/Fabric/ReanimatedCommitHook.h +2 -6
  14. package/Common/cpp/reanimated/Fabric/ReanimatedMountHook.cpp +1 -6
  15. package/Common/cpp/reanimated/Fabric/ReanimatedMountHook.h +1 -8
  16. package/Common/cpp/reanimated/Fabric/updates/AnimatedPropsRegistry.cpp +0 -2
  17. package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsManager.h +1 -2
  18. package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h +1 -1
  19. package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.cpp +9 -9
  20. package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h +2 -3
  21. package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.cpp +21 -21
  22. package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h +3 -3
  23. package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsUtils.h +3 -3
  24. package/Common/cpp/reanimated/LayoutAnimations/SharedTransitions.cpp +24 -20
  25. package/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +25 -25
  26. package/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +1 -2
  27. package/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.cpp +22 -22
  28. package/Common/cpp/reanimated/RuntimeDecorators/UIRuntimeDecorator.h +10 -10
  29. package/Common/cpp/reanimated/Tools/ReaJSIUtils.h +5 -5
  30. package/android/build.gradle +0 -21
  31. package/android/src/main/cpp/reanimated/android/NativeProxy.cpp +6 -10
  32. package/android/src/main/cpp/reanimated/android/NativeProxy.h +1 -2
  33. package/android/src/main/java/com/swmansion/reanimated/CopiedEvent.java +66 -9
  34. package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +16 -11
  35. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/EventHandler.java +34 -8
  36. package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NoopEventHandler.java +27 -6
  37. package/apple/reanimated/apple/REANodesManager.mm +0 -8
  38. package/apple/reanimated/apple/ReanimatedModule.mm +6 -12
  39. package/apple/reanimated/apple/native/NativeProxy.h +1 -2
  40. package/apple/reanimated/apple/native/NativeProxy.mm +1 -1
  41. package/compatibility.json +7 -29
  42. package/lib/module/PropsRegistryGarbageCollector.js +3 -0
  43. package/lib/module/PropsRegistryGarbageCollector.js.map +1 -1
  44. package/lib/module/common/style/processors/colors.js +31 -4
  45. package/lib/module/common/style/processors/colors.js.map +1 -1
  46. package/lib/module/common/style/processors/filter.js +103 -61
  47. package/lib/module/common/style/processors/filter.js.map +1 -1
  48. package/lib/module/common/style/processors/font.js +7 -1
  49. package/lib/module/common/style/processors/font.js.map +1 -1
  50. package/lib/module/common/style/processors/insets.js +26 -14
  51. package/lib/module/common/style/processors/insets.js.map +1 -1
  52. package/lib/module/common/style/processors/others.js +15 -5
  53. package/lib/module/common/style/processors/others.js.map +1 -1
  54. package/lib/module/common/style/processors/shadows.js +14 -3
  55. package/lib/module/common/style/processors/shadows.js.map +1 -1
  56. package/lib/module/common/style/processors/transform.js +30 -1
  57. package/lib/module/common/style/processors/transform.js.map +1 -1
  58. package/lib/module/common/style/processors/transformOrigin.js +20 -3
  59. package/lib/module/common/style/processors/transformOrigin.js.map +1 -1
  60. package/lib/module/common/utils/guards.js +27 -7
  61. package/lib/module/common/utils/guards.js.map +1 -1
  62. package/lib/module/common/utils/parsers.js +2 -1
  63. package/lib/module/common/utils/parsers.js.map +1 -1
  64. package/lib/module/css/native/managers/CSSManager.js +5 -13
  65. package/lib/module/css/native/managers/CSSManager.js.map +1 -1
  66. package/lib/module/css/native/managers/CSSTransitionsManager.js +47 -44
  67. package/lib/module/css/native/managers/CSSTransitionsManager.js.map +1 -1
  68. package/lib/module/css/native/normalization/transition/config.js +35 -17
  69. package/lib/module/css/native/normalization/transition/config.js.map +1 -1
  70. package/lib/module/featureFlags/index.js +1 -1
  71. package/lib/module/featureFlags/staticFlags.json +1 -1
  72. package/lib/module/hook/useAnimatedStyle.js +7 -1
  73. package/lib/module/hook/useAnimatedStyle.js.map +1 -1
  74. package/lib/module/hook/useHandler.js +82 -28
  75. package/lib/module/hook/useHandler.js.map +1 -1
  76. package/lib/module/hook/utils.js +1 -74
  77. package/lib/module/hook/utils.js.map +1 -1
  78. package/lib/module/initializers.js +2 -0
  79. package/lib/module/initializers.js.map +1 -1
  80. package/lib/module/jestUtils/common.js +10 -0
  81. package/lib/module/jestUtils/common.js.map +1 -1
  82. package/lib/module/jestUtils/index.js +2 -5
  83. package/lib/module/jestUtils/index.js.map +1 -1
  84. package/lib/module/jestUtils/index.web.js +1 -1
  85. package/lib/module/jestUtils/index.web.js.map +1 -1
  86. package/lib/module/platform-specific/jsVersion.js +1 -1
  87. package/lib/module/platform-specific/jsVersion.js.map +1 -1
  88. package/lib/typescript/PropsRegistryGarbageCollector.d.ts.map +1 -1
  89. package/lib/typescript/common/style/processors/colors.d.ts +3 -3
  90. package/lib/typescript/common/style/processors/colors.d.ts.map +1 -1
  91. package/lib/typescript/common/style/processors/filter.d.ts +0 -4
  92. package/lib/typescript/common/style/processors/filter.d.ts.map +1 -1
  93. package/lib/typescript/common/style/processors/font.d.ts +1 -1
  94. package/lib/typescript/common/style/processors/font.d.ts.map +1 -1
  95. package/lib/typescript/common/style/processors/insets.d.ts.map +1 -1
  96. package/lib/typescript/common/style/processors/others.d.ts +1 -1
  97. package/lib/typescript/common/style/processors/others.d.ts.map +1 -1
  98. package/lib/typescript/common/style/processors/shadows.d.ts.map +1 -1
  99. package/lib/typescript/common/style/processors/transform.d.ts.map +1 -1
  100. package/lib/typescript/common/style/processors/transformOrigin.d.ts +2 -2
  101. package/lib/typescript/common/style/processors/transformOrigin.d.ts.map +1 -1
  102. package/lib/typescript/common/utils/guards.d.ts +0 -1
  103. package/lib/typescript/common/utils/guards.d.ts.map +1 -1
  104. package/lib/typescript/common/utils/parsers.d.ts.map +1 -1
  105. package/lib/typescript/commonTypes.d.ts +1 -1
  106. package/lib/typescript/commonTypes.d.ts.map +1 -1
  107. package/lib/typescript/css/native/managers/CSSManager.d.ts +0 -1
  108. package/lib/typescript/css/native/managers/CSSManager.d.ts.map +1 -1
  109. package/lib/typescript/css/native/managers/CSSTransitionsManager.d.ts +5 -4
  110. package/lib/typescript/css/native/managers/CSSTransitionsManager.d.ts.map +1 -1
  111. package/lib/typescript/css/native/normalization/transition/config.d.ts.map +1 -1
  112. package/lib/typescript/css/native/types/transition.d.ts +15 -1
  113. package/lib/typescript/css/native/types/transition.d.ts.map +1 -1
  114. package/lib/typescript/featureFlags/index.d.ts +1 -1
  115. package/lib/typescript/hook/useAnimatedStyle.d.ts.map +1 -1
  116. package/lib/typescript/hook/useHandler.d.ts +8 -9
  117. package/lib/typescript/hook/useHandler.d.ts.map +1 -1
  118. package/lib/typescript/hook/utils.d.ts +0 -5
  119. package/lib/typescript/hook/utils.d.ts.map +1 -1
  120. package/lib/typescript/jestUtils/common.d.ts +2 -0
  121. package/lib/typescript/jestUtils/common.d.ts.map +1 -1
  122. package/lib/typescript/jestUtils/index.d.ts +4 -3
  123. package/lib/typescript/jestUtils/index.d.ts.map +1 -1
  124. package/lib/typescript/platform-specific/jsVersion.d.ts +1 -1
  125. package/lib/typescript/platform-specific/jsVersion.d.ts.map +1 -1
  126. package/package.json +10 -9
  127. package/src/PropsRegistryGarbageCollector.ts +3 -0
  128. package/src/common/style/processors/colors.ts +20 -7
  129. package/src/common/style/processors/filter.ts +95 -70
  130. package/src/common/style/processors/font.ts +5 -2
  131. package/src/common/style/processors/insets.ts +23 -14
  132. package/src/common/style/processors/others.ts +12 -6
  133. package/src/common/style/processors/shadows.ts +10 -6
  134. package/src/common/style/processors/transform.ts +15 -1
  135. package/src/common/style/processors/transformOrigin.ts +40 -11
  136. package/src/common/utils/guards.ts +21 -16
  137. package/src/common/utils/parsers.ts +1 -1
  138. package/src/commonTypes.ts +1 -1
  139. package/src/css/native/managers/CSSManager.ts +8 -14
  140. package/src/css/native/managers/CSSTransitionsManager.ts +52 -54
  141. package/src/css/native/normalization/transition/config.ts +35 -27
  142. package/src/css/native/types/transition.ts +15 -1
  143. package/src/featureFlags/index.ts +1 -1
  144. package/src/featureFlags/staticFlags.json +1 -1
  145. package/src/hook/useAnimatedStyle.ts +15 -6
  146. package/src/hook/useHandler.ts +150 -64
  147. package/src/hook/utils.ts +1 -127
  148. package/src/initializers.ts +1 -0
  149. package/src/jestUtils/common.ts +10 -0
  150. package/src/jestUtils/index.ts +5 -8
  151. package/src/jestUtils/index.web.ts +1 -1
  152. package/src/platform-specific/jsVersion.ts +1 -1
  153. package/src/privateGlobals.d.ts +4 -0
@@ -1,5 +1,6 @@
1
1
  #include <react/renderer/components/scrollview/ScrollViewState.h>
2
2
  #include <reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h>
3
+ #include <reanimated/LayoutAnimations/LayoutAnimationsUtils.h>
3
4
  #include <reanimated/Tools/ReanimatedSystraceSection.h>
4
5
  #ifndef ANDROID
5
6
  #if __has_include(<react/renderer/components/rnscreens/Props.h>)
@@ -62,9 +63,11 @@ void LayoutAnimationsProxy_Experimental::findSharedElementsOnScreen(
62
63
  auto newTransform = parseParentTransforms(node, absolutePositions);
63
64
  const auto &parent = node->parent.lock();
64
65
  react_native_assert(parent && "Parent node is nullptr");
65
- transform[index] = std::move(newTransform);
66
- snapshot[index] = copy;
67
- parentTag[index] = parent->current.tag;
66
+
67
+ int indexNum = static_cast<int>(index);
68
+ transform[indexNum] = std::move(newTransform);
69
+ snapshot[indexNum] = copy;
70
+ parentTag[indexNum] = parent->current.tag;
68
71
 
69
72
  if (parentTag[BEFORE] && parentTag[AFTER]) {
70
73
  transitions_.emplace_back(sharedTag, transition);
@@ -88,11 +91,11 @@ void LayoutAnimationsProxy_Experimental::handleProgressTransition(
88
91
  }
89
92
  transitionUpdated_ = false;
90
93
 
91
- if (!mutations.empty() || !transitionState_) {
94
+ if (!mutations.empty() || !static_cast<bool>(transitionState_)) {
92
95
  return;
93
96
  }
94
97
 
95
- if (transitionState_ == START) {
98
+ if (transitionState_ == TransitionState::START) {
96
99
  auto root = lightNodes_[surfaceId];
97
100
  auto beforeTopScreen = topScreen[surfaceId];
98
101
  auto afterTopScreen = lightNodes_[transitionTag_];
@@ -119,7 +122,7 @@ void LayoutAnimationsProxy_Experimental::handleProgressTransition(
119
122
  startProgressTransition(containerTag, before, after, surfaceId);
120
123
  }
121
124
  }
122
- } else if (transitionState_ == ACTIVE) {
125
+ } else if (transitionState_ == TransitionState::ACTIVE) {
123
126
  for (auto tag : activeTransitions_) {
124
127
  auto layoutAnimation = layoutAnimations_[tag];
125
128
  auto &updateMap = surfaceManager.getUpdateMap(layoutAnimation.finalView.surfaceId);
@@ -153,23 +156,23 @@ void LayoutAnimationsProxy_Experimental::handleProgressTransition(
153
156
  }
154
157
  }
155
158
 
156
- if (transitionState_ == START) {
157
- transitionState_ = ACTIVE;
158
- } else if (transitionState_ == END || transitionState_ == CANCELLED) {
159
+ if (transitionState_ == TransitionState::START) {
160
+ transitionState_ = TransitionState::ACTIVE;
161
+ } else if (transitionState_ == TransitionState::END || transitionState_ == TransitionState::CANCELLED) {
159
162
  for (auto tag : activeTransitions_) {
160
163
  sharedContainersToRemove_.push_back(tag);
161
164
  tagsToRestore_.push_back(restoreMap_[tag][AFTER]);
162
- if (transitionState_ == CANCELLED) {
165
+ if (transitionState_ == TransitionState::CANCELLED) {
163
166
  tagsToRestore_.push_back(restoreMap_[tag][BEFORE]);
164
167
  }
165
168
  }
166
- if (transitionState_ == END) {
169
+ if (transitionState_ == TransitionState::END) {
167
170
  topScreen[surfaceId] = lightNodes_[transitionTag_];
168
171
  synchronized_ = false;
169
172
  }
170
173
  sharedTransitionManager_->containerTags_.clear();
171
174
  activeTransitions_.clear();
172
- transitionState_ = NONE;
175
+ transitionState_ = TransitionState::NONE;
173
176
  }
174
177
  }
175
178
 
@@ -278,8 +281,9 @@ void LayoutAnimationsProxy_Experimental::hideTransitioningViews(
278
281
  ShadowViewMutationList &filteredMutations,
279
282
  const PropsParserContext &propsParserContext) const {
280
283
  for (auto &[sharedTag, transition] : transitions_) {
281
- const auto &shadowView = transition.snapshot[index];
282
- const auto &parentTag = transition.parentTag[index];
284
+ int indexNum = static_cast<int>(index);
285
+ const auto &shadowView = transition.snapshot[indexNum];
286
+ const auto &parentTag = transition.parentTag[indexNum];
283
287
  auto m = ShadowViewMutation::UpdateMutation(
284
288
  shadowView, cloneViewWithoutOpacity(shadowView, propsParserContext), parentTag);
285
289
  filteredMutations.push_back(m);
@@ -303,11 +307,11 @@ std::optional<SurfaceId> LayoutAnimationsProxy_Experimental::onTransitionProgres
303
307
  // transitions (maybe that's ok?)
304
308
  if (!isClosing && !isGoingForward && !isAndroid) {
305
309
  transitionProgress_ = progress;
306
- if (transitionState_ == NONE && progress < 1) {
307
- transitionState_ = START;
310
+ if (transitionState_ == TransitionState::NONE && progress < 1) {
311
+ transitionState_ = TransitionState::START;
308
312
  transitionTag_ = tag;
309
- } else if (transitionState_ == ACTIVE && progress == 1) {
310
- transitionState_ = END;
313
+ } else if (transitionState_ == TransitionState::ACTIVE && progress == 1) {
314
+ transitionState_ = TransitionState::END;
311
315
  }
312
316
  const auto &node = lightNodes_[tag];
313
317
  react_native_assert(node && "LightNode is nullptr");
@@ -320,8 +324,8 @@ std::optional<SurfaceId> LayoutAnimationsProxy_Experimental::onTransitionProgres
320
324
 
321
325
  std::optional<SurfaceId> LayoutAnimationsProxy_Experimental::onGestureCancel() {
322
326
  auto lock = std::unique_lock<std::recursive_mutex>(mutex);
323
- if (transitionState_) {
324
- transitionState_ = CANCELLED;
327
+ if (static_cast<bool>(transitionState_)) {
328
+ transitionState_ = TransitionState::CANCELLED;
325
329
  transitionUpdated_ = true;
326
330
  react_native_assert(transitioningSurfaceId_ != -1 && "Cancelling non-observed transition");
327
331
 
@@ -1,5 +1,6 @@
1
1
  #include <react/renderer/scheduler/Scheduler.h>
2
2
  #include <react/renderer/uimanager/UIManagerBinding.h>
3
+ #include <reanimated/Compat/WorkletsApi.h>
3
4
  #include <reanimated/Events/UIEventHandler.h>
4
5
  #include <reanimated/LayoutAnimations/LayoutAnimationsProxy_Experimental.h>
5
6
  #include <reanimated/LayoutAnimations/LayoutAnimationsProxy_Legacy.h>
@@ -8,7 +9,6 @@
8
9
  #include <reanimated/RuntimeDecorators/UIRuntimeDecorator.h>
9
10
  #include <reanimated/Tools/FeatureFlags.h>
10
11
  #include <reanimated/Tools/ReanimatedSystraceSection.h>
11
- #include <worklets/SharedItems/Serializable.h>
12
12
 
13
13
  #ifdef __ANDROID__
14
14
  #include <fbjni/fbjni.h>
@@ -26,13 +26,11 @@ namespace reanimated {
26
26
 
27
27
  using namespace worklets;
28
28
 
29
- #if REACT_NATIVE_MINOR_VERSION >= 81
30
29
  static inline std::shared_ptr<const ShadowNode> shadowNodeFromValue(
31
30
  jsi::Runtime &rt,
32
31
  const jsi::Value &shadowNodeWrapper) {
33
32
  return Bridging<std::shared_ptr<const ShadowNode>>::fromJs(rt, shadowNodeWrapper);
34
33
  }
35
- #endif
36
34
 
37
35
  namespace {
38
36
 
@@ -69,7 +67,7 @@ std::pair<UpdatesBatch, UpdatesBatch> partitionUpdates(
69
67
  const auto keyStr = key.asString();
70
68
  const bool isColorProp = keyStr == "color" || keyStr.find("Color") != std::string::npos;
71
69
  const bool isSynchronous =
72
- synchronousPropNames.contains(keyStr) && (!shouldRequireIntegerColors || !isColorProp || value.isInt());
70
+ synchronousPropNames.contains(keyStr) && (!shouldRequireIntegerColors || !isColorProp || value.isNumber());
73
71
  if (isSynchronous) {
74
72
  synchronousProps[keyStr] = value;
75
73
  } else {
@@ -91,7 +89,7 @@ std::pair<UpdatesBatch, UpdatesBatch> partitionUpdates(
91
89
  const auto keyStr = key.asString();
92
90
  const bool isColorProp = keyStr == "color" || keyStr.find("Color") != std::string::npos;
93
91
  const bool isSynchronous =
94
- synchronousPropNames.contains(keyStr) && (!shouldRequireIntegerColors || !isColorProp || value.isInt());
92
+ synchronousPropNames.contains(keyStr) && (!shouldRequireIntegerColors || !isColorProp || value.isNumber());
95
93
  if (!isSynchronous) {
96
94
  hasOnlySynchronousProps = false;
97
95
  break;
@@ -249,7 +247,7 @@ void ReanimatedModuleProxy::init(const PlatformDepMethodsHolder &platformDepMeth
249
247
  return strongThis->obtainProp(rt, shadowNodeWrapper, propName);
250
248
  };
251
249
 
252
- jsi::Runtime &uiRuntime = uiRuntime_->getJSIRuntime();
250
+ jsi::Runtime &uiRuntime = getJSIRuntimeFromWorkletRuntime(uiRuntime_);
253
251
  UIRuntimeDecorator::decorate(
254
252
  uiRuntime,
255
253
  obtainProp,
@@ -278,11 +276,11 @@ jsi::Value ReanimatedModuleProxy::registerEventHandler(
278
276
 
279
277
  uint64_t newRegistrationId = NEXT_EVENT_HANDLER_ID++;
280
278
  auto eventNameStr = eventName.asString(rt).utf8(rt);
281
- auto handlerSerializable = extractSerializableOrThrow<SerializableWorklet>(
282
- rt, worklet, "[Reanimated] Event handler must be a serializable worklet.");
279
+ auto handlerSerializable = extractSerializable(
280
+ rt, worklet, "[Reanimated] Event handler must be a serializable worklet.", Serializable::ValueType::WorkletType);
283
281
  int emitterReactTagInt = emitterReactTag.asNumber();
284
282
 
285
- uiScheduler_->scheduleOnUI([=, weakThis = weak_from_this()]() {
283
+ scheduleOnUI(uiScheduler_, [=, weakThis = weak_from_this()]() {
286
284
  auto strongThis = weakThis.lock();
287
285
  if (!strongThis) {
288
286
  return;
@@ -297,7 +295,7 @@ jsi::Value ReanimatedModuleProxy::registerEventHandler(
297
295
 
298
296
  void ReanimatedModuleProxy::unregisterEventHandler(jsi::Runtime &, const jsi::Value &registrationId) {
299
297
  uint64_t id = registrationId.asNumber();
300
- uiScheduler_->scheduleOnUI([=, weakThis = weak_from_this()]() {
298
+ scheduleOnUI(uiScheduler_, [=, weakThis = weak_from_this()]() {
301
299
  auto strongThis = weakThis.lock();
302
300
  if (!strongThis) {
303
301
  return;
@@ -323,12 +321,12 @@ jsi::Value ReanimatedModuleProxy::getViewProp(
323
321
  const auto propNameStr = propName.asString(rnRuntime).utf8(rnRuntime);
324
322
  const auto funPtr = std::make_shared<jsi::Function>(callback.getObject(rnRuntime).asFunction(rnRuntime));
325
323
  const auto shadowNode = shadowNodeFromValue(rnRuntime, shadowNodeWrapper);
326
- uiScheduler_->scheduleOnUI([=, weakThis = weak_from_this()]() {
324
+ scheduleOnUI(uiScheduler_, [=, weakThis = weak_from_this()]() {
327
325
  auto strongThis = weakThis.lock();
328
326
  if (!strongThis) {
329
327
  return;
330
328
  }
331
- jsi::Runtime &uiRuntime = strongThis->uiRuntime_->getJSIRuntime();
329
+ jsi::Runtime &uiRuntime = getJSIRuntimeFromWorkletRuntime(strongThis->uiRuntime_);
332
330
  const auto resultStr = strongThis->obtainPropFromShadowNode(uiRuntime, propNameStr, shadowNode);
333
331
 
334
332
  strongThis->jsInvoker_->invokeAsync([=](jsi::Runtime &rnRuntime) {
@@ -364,8 +362,8 @@ jsi::Value ReanimatedModuleProxy::configureLayoutAnimationBatch(
364
362
  if (config.isUndefined()) {
365
363
  batchItem.config = nullptr;
366
364
  } else {
367
- batchItem.config = extractSerializableOrThrow<SerializableObject>(
368
- rt, config, "[Reanimated] Layout animation config must be an object.");
365
+ batchItem.config = extractSerializable(
366
+ rt, config, "[Reanimated] Layout animation config must be an object.", Serializable::ValueType::ObjectType);
369
367
  }
370
368
  auto sharedTag = item.getProperty(rt, "sharedTransitionTag");
371
369
  if (!sharedTag.isUndefined()) {
@@ -583,7 +581,7 @@ bool ReanimatedModuleProxy::handleRawEvent(const RawEvent &rawEvent, double curr
583
581
 
584
582
  if constexpr (StaticFeatureFlags::getFlag("ENABLE_SHARED_ELEMENT_TRANSITIONS")) {
585
583
  if (eventType == "onTransitionProgress") {
586
- jsi::Runtime &uiRuntime = uiRuntime_->getJSIRuntime();
584
+ jsi::Runtime &uiRuntime = getJSIRuntimeFromWorkletRuntime(uiRuntime_);
587
585
  const auto &eventPayload = rawEvent.eventPayload;
588
586
  jsi::Object payload = eventPayload->asJSIValue(uiRuntime).asObject(uiRuntime);
589
587
  auto progress = payload.getProperty(uiRuntime, "progress").asNumber();
@@ -620,7 +618,7 @@ bool ReanimatedModuleProxy::handleRawEvent(const RawEvent &rawEvent, double curr
620
618
  return false;
621
619
  }
622
620
 
623
- jsi::Runtime &uiRuntime = uiRuntime_->getJSIRuntime();
621
+ jsi::Runtime &uiRuntime = getJSIRuntimeFromWorkletRuntime(uiRuntime_);
624
622
  const auto &eventPayload = rawEvent.eventPayload;
625
623
  jsi::Value payload = eventPayload->asJSIValue(uiRuntime);
626
624
 
@@ -657,7 +655,7 @@ void ReanimatedModuleProxy::maybeRunCSSLoop() {
657
655
 
658
656
  cssLoopRunning_ = true;
659
657
 
660
- uiScheduler_->scheduleOnUI([=, weakThis = weak_from_this()]() {
658
+ scheduleOnUI(uiScheduler_, [=, weakThis = weak_from_this()]() {
661
659
  auto strongThis = weakThis.lock();
662
660
  if (!strongThis) {
663
661
  return;
@@ -687,7 +685,7 @@ void ReanimatedModuleProxy::performOperations() {
687
685
  surfaceId, [](const ShadowTree &shadowTree) { shadowTree.notifyDelegatesOfUpdates(); });
688
686
  }
689
687
 
690
- jsi::Runtime &uiRuntime = uiRuntime_->getJSIRuntime();
688
+ jsi::Runtime &uiRuntime = getJSIRuntimeFromWorkletRuntime(uiRuntime_);
691
689
 
692
690
  UpdatesBatch updatesBatch;
693
691
  {
@@ -1198,7 +1196,6 @@ void ReanimatedModuleProxy::commitUpdates(jsi::Runtime &rt, const UpdatesBatch &
1198
1196
  for (auto const &[shadowNode, props] : updatesBatch) {
1199
1197
  SurfaceId surfaceId = shadowNode->getSurfaceId();
1200
1198
  auto family = &shadowNode->getFamily();
1201
- react_native_assert(family->getSurfaceId() == surfaceId);
1202
1199
  propsMapBySurface[surfaceId][family].emplace_back(props);
1203
1200
  }
1204
1201
  }
@@ -1260,7 +1257,7 @@ void ReanimatedModuleProxy::dispatchCommand(
1260
1257
 
1261
1258
  jsi::String
1262
1259
  ReanimatedModuleProxy::obtainProp(jsi::Runtime &rt, const jsi::Value &shadowNodeWrapper, const jsi::Value &propName) {
1263
- jsi::Runtime &uiRuntime = uiRuntime_->getJSIRuntime();
1260
+ jsi::Runtime &uiRuntime = getJSIRuntimeFromWorkletRuntime(uiRuntime_);
1264
1261
  const auto propNameStr = propName.asString(rt).utf8(rt);
1265
1262
  const auto shadowNode = shadowNodeFromValue(rt, shadowNodeWrapper);
1266
1263
  const auto resultStr = obtainPropFromShadowNode(uiRuntime, propNameStr, shadowNode);
@@ -1330,7 +1327,7 @@ void ReanimatedModuleProxy::initializeLayoutAnimationsProxy() {
1330
1327
  layoutAnimationsManager_,
1331
1328
  componentDescriptorRegistry,
1332
1329
  scheduler->getContextContainer(),
1333
- uiRuntime_->getJSIRuntime(),
1330
+ getJSIRuntimeFromWorkletRuntime(uiRuntime_),
1334
1331
  uiScheduler_
1335
1332
  #ifdef ANDROID
1336
1333
  ,
@@ -1348,7 +1345,7 @@ void ReanimatedModuleProxy::initializeLayoutAnimationsProxy() {
1348
1345
  layoutAnimationsManager_,
1349
1346
  componentDescriptorRegistry,
1350
1347
  scheduler->getContextContainer(),
1351
- uiRuntime_->getJSIRuntime(),
1348
+ getJSIRuntimeFromWorkletRuntime(uiRuntime_),
1352
1349
  uiScheduler_
1353
1350
  #ifdef ANDROID
1354
1351
  ,
@@ -1395,15 +1392,18 @@ jsi::Value ReanimatedModuleProxy::subscribeForKeyboardEvents(
1395
1392
  const jsi::Value &handlerWorklet,
1396
1393
  const jsi::Value &isStatusBarTranslucent,
1397
1394
  const jsi::Value &isNavigationBarTranslucent) {
1398
- auto serializableHandler = extractSerializableOrThrow<SerializableWorklet>(
1399
- rt, handlerWorklet, "[Reanimated] Keyboard event handler must be a worklet.");
1395
+ auto serializableHandler = extractSerializable(
1396
+ rt,
1397
+ handlerWorklet,
1398
+ "[Reanimated] Keyboard event handler must be a worklet.",
1399
+ Serializable::ValueType::WorkletType);
1400
1400
  return subscribeForKeyboardEventsFunction_(
1401
1401
  [=, weakThis = weak_from_this()](int keyboardState, int height) {
1402
1402
  auto strongThis = weakThis.lock();
1403
1403
  if (!strongThis) {
1404
1404
  return;
1405
1405
  }
1406
- strongThis->uiRuntime_->runSync(serializableHandler, jsi::Value(keyboardState), jsi::Value(height));
1406
+ runSyncOnRuntime(strongThis->uiRuntime_, serializableHandler, jsi::Value(keyboardState), jsi::Value(height));
1407
1407
  },
1408
1408
  isStatusBarTranslucent.getBool(),
1409
1409
  isNavigationBarTranslucent.getBool());
@@ -11,6 +11,7 @@
11
11
  #include <reanimated/CSS/registries/CSSKeyframesRegistry.h>
12
12
  #include <reanimated/CSS/registries/CSSTransitionsRegistry.h>
13
13
  #include <reanimated/CSS/registries/StaticPropsRegistry.h>
14
+ #include <reanimated/Compat/WorkletsApi.h>
14
15
  #include <reanimated/Events/UIEventHandlerRegistry.h>
15
16
  #include <reanimated/Fabric/ReanimatedCommitHook.h>
16
17
  #include <reanimated/Fabric/ReanimatedCommitShadowNode.h>
@@ -24,8 +25,6 @@
24
25
  #include <reanimated/NativeModules/ReanimatedModuleProxySpec.h>
25
26
  #include <reanimated/Tools/PlatformDepMethodsHolder.h>
26
27
  #include <reanimated/Tools/SingleInstanceChecker.h>
27
- #include <worklets/Tools/UIScheduler.h>
28
- #include <worklets/WorkletRuntime/WorkletRuntime.h>
29
28
 
30
29
  #include <memory>
31
30
  #include <set>
@@ -7,31 +7,31 @@ namespace reanimated {
7
7
 
8
8
  void UIRuntimeDecorator::decorate(
9
9
  jsi::Runtime &uiRuntime,
10
- ObtainPropFunction obtainPropFunction,
11
- UpdatePropsFunction updateProps,
12
- MeasureFunction measure,
13
- DispatchCommandFunction dispatchCommand,
14
- GetAnimationTimestampFunction getAnimationTimestamp,
15
- SetGestureStateFunction setGestureState,
16
- ProgressLayoutAnimationFunction progressLayoutAnimation,
17
- EndLayoutAnimationFunction endLayoutAnimation,
18
- MaybeFlushUIUpdatesQueueFunction maybeFlushUIUpdatesQueue) {
19
-
20
- jsi_utils::installJsiFunction(uiRuntime, "_updateProps", std::move(updateProps));
21
- jsi_utils::installJsiFunction(uiRuntime, "_dispatchCommand", std::move(dispatchCommand));
22
- jsi_utils::installJsiFunction(uiRuntime, "_measure", std::move(measure));
23
- jsi_utils::installJsiFunction(uiRuntime, "_getAnimationTimestamp", std::move(getAnimationTimestamp));
24
- jsi_utils::installJsiFunction(uiRuntime, "_notifyAboutProgress", std::move(progressLayoutAnimation));
25
- jsi_utils::installJsiFunction(uiRuntime, "_notifyAboutEnd", std::move(endLayoutAnimation));
26
- jsi_utils::installJsiFunction(uiRuntime, "_setGestureState", std::move(setGestureState));
27
- jsi_utils::installJsiFunction(uiRuntime, "_obtainProp", std::move(obtainPropFunction));
28
-
29
- subscribeForMicrotasksFinalization(uiRuntime, std::move(maybeFlushUIUpdatesQueue));
10
+ const ObtainPropFunction &obtainPropFunction,
11
+ const UpdatePropsFunction &updateProps,
12
+ const MeasureFunction &measure,
13
+ const DispatchCommandFunction &dispatchCommand,
14
+ const GetAnimationTimestampFunction &getAnimationTimestamp,
15
+ const SetGestureStateFunction &setGestureState,
16
+ const ProgressLayoutAnimationFunction &progressLayoutAnimation,
17
+ const EndLayoutAnimationFunction &endLayoutAnimation,
18
+ const MaybeFlushUIUpdatesQueueFunction &maybeFlushUIUpdatesQueue) {
19
+
20
+ jsi_utils::installJsiFunction(uiRuntime, "_updateProps", updateProps);
21
+ jsi_utils::installJsiFunction(uiRuntime, "_dispatchCommand", dispatchCommand);
22
+ jsi_utils::installJsiFunction(uiRuntime, "_measure", measure);
23
+ jsi_utils::installJsiFunction(uiRuntime, "_getAnimationTimestamp", getAnimationTimestamp);
24
+ jsi_utils::installJsiFunction(uiRuntime, "_notifyAboutProgress", progressLayoutAnimation);
25
+ jsi_utils::installJsiFunction(uiRuntime, "_notifyAboutEnd", endLayoutAnimation);
26
+ jsi_utils::installJsiFunction(uiRuntime, "_setGestureState", setGestureState);
27
+ jsi_utils::installJsiFunction(uiRuntime, "_obtainProp", obtainPropFunction);
28
+
29
+ subscribeForMicrotasksFinalization(uiRuntime, maybeFlushUIUpdatesQueue);
30
30
  }
31
31
 
32
32
  void UIRuntimeDecorator::subscribeForMicrotasksFinalization(
33
33
  jsi::Runtime &uiRuntime,
34
- MaybeFlushUIUpdatesQueueFunction maybeFlushUIUpdatesQueue) {
34
+ const MaybeFlushUIUpdatesQueueFunction &maybeFlushUIUpdatesQueue) {
35
35
  auto maybeMicrotaskQueueFinalizers = uiRuntime.global().getProperty(uiRuntime, "_microtaskQueueFinalizers");
36
36
 
37
37
  if (maybeMicrotaskQueueFinalizers.isUndefined()) {
@@ -50,7 +50,7 @@ void UIRuntimeDecorator::subscribeForMicrotasksFinalization(
50
50
  uiRuntime,
51
51
  jsi::PropNameID::forAscii(uiRuntime, "_maybeFlushUIUpdatesQueue"),
52
52
  0,
53
- jsi_utils::createHostFunction(std::move(maybeFlushUIUpdatesQueue))));
53
+ jsi_utils::createHostFunction(maybeFlushUIUpdatesQueue)));
54
54
  }
55
55
 
56
56
  } // namespace reanimated
@@ -12,20 +12,20 @@ class UIRuntimeDecorator {
12
12
  public:
13
13
  static void decorate(
14
14
  jsi::Runtime &uiRuntime,
15
- const ObtainPropFunction obtainPropFunction,
16
- const UpdatePropsFunction updateProps,
17
- const MeasureFunction measure,
18
- const DispatchCommandFunction dispatchCommand,
19
- const GetAnimationTimestampFunction getAnimationTimestamp,
20
- const SetGestureStateFunction setGestureState,
21
- const ProgressLayoutAnimationFunction progressLayoutAnimation,
22
- const EndLayoutAnimationFunction endLayoutAnimation,
23
- const MaybeFlushUIUpdatesQueueFunction maybeFlushUIUpdatesQueue);
15
+ const ObtainPropFunction &obtainPropFunction,
16
+ const UpdatePropsFunction &updateProps,
17
+ const MeasureFunction &measure,
18
+ const DispatchCommandFunction &dispatchCommand,
19
+ const GetAnimationTimestampFunction &getAnimationTimestamp,
20
+ const SetGestureStateFunction &setGestureState,
21
+ const ProgressLayoutAnimationFunction &progressLayoutAnimation,
22
+ const EndLayoutAnimationFunction &endLayoutAnimation,
23
+ const MaybeFlushUIUpdatesQueueFunction &maybeFlushUIUpdatesQueue);
24
24
 
25
25
  private:
26
26
  static void subscribeForMicrotasksFinalization(
27
27
  jsi::Runtime &uiRuntime,
28
- MaybeFlushUIUpdatesQueueFunction maybeFlushUIUpdatesQueue);
28
+ const MaybeFlushUIUpdatesQueueFunction &maybeFlushUIUpdatesQueue);
29
29
  };
30
30
 
31
31
  } // namespace reanimated
@@ -75,7 +75,7 @@ inline std::tuple<T, Rest...> convertArgs(jsi::Runtime &rt, const jsi::Value *ar
75
75
  // native C++ types needed to call `function`
76
76
  template <typename Ret, typename... Args>
77
77
  std::tuple<Args...>
78
- getArgsForFunction(std::function<Ret(Args...)>, jsi::Runtime &rt, const jsi::Value *args, const size_t count) {
78
+ getArgsForFunction(const std::function<Ret(Args...)> &, jsi::Runtime &rt, const jsi::Value *args, const size_t count) {
79
79
  react_native_assert(sizeof...(Args) == count && "Argument list has different length than expected");
80
80
  return convertArgs<Args...>(rt, args);
81
81
  }
@@ -85,7 +85,7 @@ getArgsForFunction(std::function<Ret(Args...)>, jsi::Runtime &rt, const jsi::Val
85
85
  // passing `rt` as the first argument
86
86
  template <typename Ret, typename... Args>
87
87
  std::tuple<jsi::Runtime &, Args...> getArgsForFunction(
88
- std::function<Ret(jsi::Runtime &, Args...)>,
88
+ const std::function<Ret(jsi::Runtime &, Args...)> &,
89
89
  jsi::Runtime &rt,
90
90
  const jsi::Value *args,
91
91
  const size_t count) {
@@ -117,7 +117,7 @@ inline jsi::Value apply(std::function<void(Args...)> function, std::tuple<Args..
117
117
  // returns a function with JSI calling convention
118
118
  // from a native function `function`
119
119
  template <typename Fun>
120
- jsi::HostFunctionType createHostFunction(Fun function) {
120
+ jsi::HostFunctionType createHostFunction(const Fun &function) {
121
121
  return [function](jsi::Runtime &rt, const jsi::Value &, const jsi::Value *args, const size_t count) {
122
122
  auto argz = getArgsForFunction(function, rt, args, count);
123
123
  return apply(function, std::move(argz));
@@ -127,7 +127,7 @@ jsi::HostFunctionType createHostFunction(Fun function) {
127
127
  // returns a function with JSI calling convention
128
128
  // from a native function `function` returning a string
129
129
  template <typename... Args>
130
- jsi::HostFunctionType createHostFunction(std::function<std::string(Args...)> function) {
130
+ jsi::HostFunctionType createHostFunction(const std::function<std::string(Args...)> &function) {
131
131
  return [function](jsi::Runtime &rt, const jsi::Value &, const jsi::Value *args, const size_t count) {
132
132
  auto argz = getArgsForFunction(function, rt, args, count);
133
133
  return apply(rt, function, std::move(argz));
@@ -151,7 +151,7 @@ struct takes_runtime<jsi::Runtime &, Rest...> {
151
151
  // and installs it as a global function named `name`
152
152
  // in the `rt` JS runtime
153
153
  template <typename Ret, typename... Args>
154
- void installJsiFunction(jsi::Runtime &rt, std::string_view name, std::function<Ret(Args...)> function) {
154
+ void installJsiFunction(jsi::Runtime &rt, std::string_view name, const std::function<Ret(Args...)> &function) {
155
155
  auto clb = createHostFunction(function);
156
156
  auto argsCount = sizeof...(Args) - takes_runtime<Args...>::value;
157
157
  jsi::Value jsiFunction =
@@ -43,24 +43,6 @@ def resolveReactNativeDirectory() {
43
43
  throw new GradleException("[Reanimated] Unable to resolve react-native location in node_modules. You should set project extension property (in `app/build.gradle`) named `REACT_NATIVE_NODE_MODULES_DIR` with the path to react-native in node_modules.")
44
44
  }
45
45
 
46
- def resolveReactNativeWorkletsDirectory() {
47
- def reactNativeWorkletsLocation = safeAppExtGet("REACT_NATIVE_WORKLETS_NODE_MODULES_DIR", null)
48
- if (reactNativeWorkletsLocation != null) {
49
- return file(reactNativeWorkletsLocation)
50
- }
51
-
52
- // Fallback to node resolver for custom directory structures like monorepos.
53
- def reactNativeWorkletsPackage = file(providers.exec {
54
- workingDir(rootDir)
55
- commandLine("node", "--print", "require.resolve('react-native-worklets/package.json')")
56
- }.standardOutput.asText.get().trim())
57
- if (reactNativeWorkletsPackage.exists()) {
58
- return reactNativeWorkletsPackage.parentFile
59
- }
60
-
61
- throw new GradleException("[Reanimated] Unable to resolve react-native-worklets location in node_modules. You should set project extension property (in `app/build.gradle`) named `REACT_NATIVE_WORKLETS_NODE_MODULES_DIR` with the path to react-native-worklets in node_modules.")
62
- }
63
-
64
46
  def getReactNativeVersion() {
65
47
  def reactNativeRootDir = resolveReactNativeDirectory()
66
48
  def reactProperties = new Properties()
@@ -112,7 +94,6 @@ if (isNewArchitectureEnabled() && project != rootProject) {
112
94
 
113
95
  def packageDir = project.projectDir.parentFile
114
96
  def reactNativeRootDir = resolveReactNativeDirectory()
115
- def reactNativeWorkletsRootDir = resolveReactNativeWorkletsDirectory()
116
97
  def REACT_NATIVE_MINOR_VERSION = getReactNativeMinorVersion()
117
98
  def REACT_NATIVE_VERSION = getReactNativeVersion()
118
99
  def REANIMATED_VERSION = getReanimatedVersion()
@@ -138,7 +119,6 @@ buildscript {
138
119
  }
139
120
  dependencies {
140
121
  classpath "com.android.tools.build:gradle:8.13.1"
141
- classpath "de.undercouch:gradle-download-task:5.6.0"
142
122
  classpath "com.diffplug.spotless:spotless-plugin-gradle:8.1.0"
143
123
  }
144
124
  }
@@ -149,7 +129,6 @@ if (project == rootProject) {
149
129
 
150
130
  apply plugin: "com.android.library"
151
131
  apply plugin: "maven-publish"
152
- apply plugin: "de.undercouch.download"
153
132
 
154
133
  android {
155
134
  compileSdkVersion safeExtGet("compileSdkVersion", 36)
@@ -1,4 +1,5 @@
1
1
  #include <react/fabric/Binding.h>
2
+ #include <reanimated/Compat/WorkletsApi.h>
2
3
  #include <reanimated/RuntimeDecorators/RNRuntimeDecorator.h>
3
4
  #include <reanimated/Tools/PlatformDepMethodsHolder.h>
4
5
  #include <reanimated/Tools/ReanimatedVersion.h>
@@ -7,7 +8,6 @@
7
8
  #include <reanimated/android/KeyboardWorkletWrapper.h>
8
9
  #include <reanimated/android/NativeProxy.h>
9
10
  #include <reanimated/android/SensorSetter.h>
10
- #include <worklets/Compat/Holders.h>
11
11
 
12
12
  #include <memory>
13
13
  #include <string>
@@ -71,16 +71,11 @@ jni::local_ref<NativeProxy::jhybriddata> NativeProxy::initHybrid(
71
71
  auto jsCallInvoker = jsCallInvokerHolder->cthis()->getCallInvoker();
72
72
  auto &rnRuntime = *reinterpret_cast<jsi::Runtime *>(jsContext); // NOLINT //(performance-no-int-to-ptr)
73
73
  const auto global = rnRuntime.global();
74
-
75
74
  const auto uiRuntime =
76
- std::static_pointer_cast<WorkletRuntimeHolder>(
77
- global.getProperty(rnRuntime, "__UI_WORKLET_RUNTIME_HOLDER").asObject(rnRuntime).getNativeState(rnRuntime))
78
- ->runtime_;
75
+ getWorkletRuntimeFromHolder(rnRuntime, global.getPropertyAsObject(rnRuntime, "__UI_WORKLET_RUNTIME_HOLDER"));
79
76
 
80
77
  const auto uiScheduler =
81
- std::static_pointer_cast<UISchedulerHolder>(
82
- global.getProperty(rnRuntime, "__UI_SCHEDULER_HOLDER").asObject(rnRuntime).getNativeState(rnRuntime))
83
- ->scheduler_;
78
+ getUISchedulerFromHolder(rnRuntime, global.getPropertyAsObject(rnRuntime, "__UI_SCHEDULER_HOLDER"));
84
79
 
85
80
  return makeCxxInstance(jThis, &rnRuntime, jsCallInvoker, fabricUIManager, uiRuntime, uiScheduler);
86
81
  }
@@ -120,7 +115,8 @@ void NativeProxy::injectCppVersion() {
120
115
 
121
116
  void NativeProxy::installJSIBindings() {
122
117
  jsi::Runtime &rnRuntime = *rnRuntime_;
123
- RNRuntimeDecorator::decorate(rnRuntime, uiRuntime_->getJSIRuntime(), reanimatedModuleProxy_);
118
+ auto &uiRuntime = getJSIRuntimeFromWorkletRuntime(uiRuntime_);
119
+ RNRuntimeDecorator::decorate(rnRuntime, uiRuntime, reanimatedModuleProxy_);
124
120
  }
125
121
 
126
122
  bool NativeProxy::isAnyHandlerWaitingForEvent(const std::string &eventName, const int emitterReactTag) {
@@ -263,7 +259,7 @@ void NativeProxy::handleEvent(
263
259
  return;
264
260
  }
265
261
 
266
- auto &uiRuntime = uiRuntime_->getJSIRuntime();
262
+ auto &uiRuntime = getJSIRuntimeFromWorkletRuntime(uiRuntime_);
267
263
  jsi::Value payload;
268
264
  try {
269
265
  payload = jsi::Value::createFromJsonUtf8(uiRuntime, reinterpret_cast<uint8_t *>(&eventJSON[0]), eventJSON.size());
@@ -6,9 +6,8 @@
6
6
  #include <react/fabric/JFabricUIManager.h>
7
7
  #include <react/jni/WritableNativeMap.h>
8
8
  #include <react/renderer/scheduler/Scheduler.h>
9
+ #include <reanimated/Compat/WorkletsApi.h>
9
10
  #include <reanimated/NativeModules/ReanimatedModuleProxy.h>
10
- #include <worklets/Tools/UIScheduler.h>
11
- #include <worklets/WorkletRuntime/WorkletRuntime.h>
12
11
 
13
12
  #include <memory>
14
13
  #include <string>