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
@@ -11,7 +11,7 @@ AnimatedSensorModule::AnimatedSensorModule(const PlatformDepMethodsHolder &platf
11
11
  platformUnregisterSensorFunction_(platformDepMethodsHolder.unregisterSensor) {}
12
12
 
13
13
  jsi::Value AnimatedSensorModule::registerSensor(
14
- jsi::Runtime &rt,
14
+ jsi::Runtime &rnRuntime,
15
15
  const std::shared_ptr<WorkletRuntime> &uiWorkletRuntime,
16
16
  const jsi::Value &sensorTypeValue,
17
17
  const jsi::Value &interval,
@@ -19,8 +19,11 @@ jsi::Value AnimatedSensorModule::registerSensor(
19
19
  const jsi::Value &sensorDataHandler) {
20
20
  SensorType sensorType = static_cast<SensorType>(sensorTypeValue.asNumber());
21
21
 
22
- auto serializableHandler = extractSerializableOrThrow<SerializableWorklet>(
23
- rt, sensorDataHandler, "[Reanimated] Sensor event handler must be a worklet.");
22
+ auto serializableHandler = extractSerializable(
23
+ rnRuntime,
24
+ sensorDataHandler,
25
+ "[Reanimated] Sensor event handler must be a worklet.",
26
+ Serializable::ValueType::WorkletType);
24
27
 
25
28
  int sensorId = platformRegisterSensorFunction_(
26
29
  static_cast<int>(sensorType),
@@ -33,7 +36,7 @@ jsi::Value AnimatedSensorModule::registerSensor(
33
36
  return;
34
37
  }
35
38
 
36
- jsi::Runtime &uiRuntime = uiWorkletRuntime->getJSIRuntime();
39
+ jsi::Runtime &uiRuntime = getJSIRuntimeFromWorkletRuntime(uiWorkletRuntime);
37
40
  jsi::Object value(uiRuntime);
38
41
  if (sensorType == SensorType::ROTATION_VECTOR) {
39
42
  // TODO: timestamp should be provided by the platform implementation
@@ -53,7 +56,7 @@ jsi::Value AnimatedSensorModule::registerSensor(
53
56
  }
54
57
  value.setProperty(uiRuntime, "interfaceOrientation", orientationDegrees);
55
58
 
56
- uiWorkletRuntime->runSync(serializableHandler, value);
59
+ runSyncOnRuntime(uiWorkletRuntime, serializableHandler, jsi::Value(uiRuntime, value));
57
60
  });
58
61
  if (sensorId != -1) {
59
62
  sensorsIds_.insert(sensorId);
@@ -1,10 +1,8 @@
1
1
  #pragma once
2
2
 
3
+ #include <reanimated/Compat/WorkletsApi.h>
3
4
  #include <reanimated/Tools/PlatformDepMethodsHolder.h>
4
5
 
5
- #include <worklets/SharedItems/Serializable.h>
6
- #include <worklets/WorkletRuntime/WorkletRuntime.h>
7
-
8
6
  #include <jsi/jsi.h>
9
7
 
10
8
  #include <memory>
@@ -32,8 +30,8 @@ class AnimatedSensorModule {
32
30
  explicit AnimatedSensorModule(const PlatformDepMethodsHolder &platformDepMethodsHolder);
33
31
 
34
32
  jsi::Value registerSensor(
35
- jsi::Runtime &rt,
36
- const std::shared_ptr<WorkletRuntime> &uiWorkletRuntime,
33
+ jsi::Runtime &rnRuntime,
34
+ const std::shared_ptr<WorkletRuntime> &uiRuntime,
37
35
  const jsi::Value &sensorType,
38
36
  const jsi::Value &interval,
39
37
  const jsi::Value &iosReferenceFrame,
@@ -12,8 +12,7 @@
12
12
  #include <reanimated/CSS/svg/values/SVGPath.h>
13
13
  #include <reanimated/CSS/svg/values/SVGStops.h>
14
14
  #include <reanimated/CSS/svg/values/SVGStrokeDashArray.h>
15
-
16
- #include <worklets/Tools/JSISerializer.h>
15
+ #include <reanimated/Compat/WorkletsApi.h>
17
16
 
18
17
  #include <string>
19
18
  #include <utility>
@@ -41,7 +40,7 @@ CSSValueVariant<AllowedTypes...>::CSSValueVariant(jsi::Runtime &rt, const jsi::V
41
40
  // Try constructing with each allowed type until one succeeds
42
41
  if (!(tryOne.template operator()<AllowedTypes>() || ...)) {
43
42
  throw std::runtime_error(
44
- "[Reanimated] No compatible type found for construction from: " + worklets::stringifyJSIValue(rt, jsiValue));
43
+ "[Reanimated] No compatible type found for construction from: " + worklets::JSIValueToStdString(rt, jsiValue));
45
44
  }
46
45
  }
47
46
 
@@ -1,6 +1,5 @@
1
1
  #include <reanimated/CSS/interpolation/PropertyInterpolator.h>
2
-
3
- #include <worklets/Tools/JSISerializer.h>
2
+ #include <reanimated/Compat/WorkletsApi.h>
4
3
 
5
4
  #include <memory>
6
5
  #include <utility>
@@ -35,7 +34,7 @@ std::vector<std::pair<double, jsi::Value>> PropertyInterpolator::parseJSIKeyfram
35
34
  throw std::invalid_argument(
36
35
  "[Reanimated] Received invalid keyframes object for property: " + getPropertyPathString() +
37
36
  ".\n\nExpected an array of objects with 'offset' and 'value' properties, got: " +
38
- worklets::stringifyJSIValue(rt, keyframes));
37
+ worklets::JSIValueToStdString(rt, keyframes));
39
38
  }
40
39
 
41
40
  const auto keyframeArray = keyframes.asObject(rt).asArray(rt);
@@ -18,7 +18,7 @@ bool DelayedItemComparator<TValue>::operator()(const DelayedItem<TValue> &lhs, c
18
18
  }
19
19
 
20
20
  template <typename TValue>
21
- void DelayedItemsManager<TValue>::add(const double timestamp, const TValue value) {
21
+ void DelayedItemsManager<TValue>::add(const double timestamp, const TValue &value) {
22
22
  auto result = itemsSet_.emplace(timestamp, value);
23
23
  if (result.second) {
24
24
  itemsMap_[result.first->value] = result.first;
@@ -38,7 +38,7 @@ typename DelayedItemsManager<TValue>::Item DelayedItemsManager<TValue>::pop() {
38
38
  }
39
39
 
40
40
  template <typename TValue>
41
- bool DelayedItemsManager<TValue>::remove(const TValue value) {
41
+ bool DelayedItemsManager<TValue>::remove(const TValue &value) {
42
42
  auto it = itemsMap_.find(value);
43
43
 
44
44
  if (it == itemsMap_.end()) {
@@ -34,9 +34,9 @@ class DelayedItemsManager {
34
34
  ItemMap itemsMap_;
35
35
 
36
36
  public:
37
- void add(double timestamp, TValue value);
37
+ void add(double timestamp, const TValue &value);
38
38
  Item pop();
39
- bool remove(TValue value);
39
+ bool remove(const TValue &value);
40
40
  const Item &top() const;
41
41
  bool empty() const;
42
42
  size_t size() const;
@@ -0,0 +1,13 @@
1
+ #pragma once
2
+
3
+ #include <worklets/Compat/StableApi.h>
4
+ #include <string>
5
+
6
+ #define EXPECTED_WORKLETS_STABLE_API_VERSION "0.8.0"
7
+
8
+ static_assert(
9
+ std::string(WORKLETS_STABLE_API_VERSION) == EXPECTED_WORKLETS_STABLE_API_VERSION,
10
+ "Incompatible worklets stable API version. Expected " EXPECTED_WORKLETS_STABLE_API_VERSION
11
+ ", but got " WORKLETS_STABLE_API_VERSION ".");
12
+
13
+ #undef EXPECTED_WORKLETS_STABLE_API_VERSION
@@ -11,7 +11,7 @@ void UIEventHandler::process(
11
11
  const std::shared_ptr<WorkletRuntime> &uiRuntime,
12
12
  const double eventTimestamp,
13
13
  const jsi::Value &eventValue) const {
14
- uiRuntime->runSync(handlerFunction_, jsi::Value(eventTimestamp), eventValue);
14
+ runSyncOnRuntime(uiRuntime, handlerFunction_, jsi::Value(eventTimestamp), eventValue);
15
15
  }
16
16
 
17
17
  uint64_t UIEventHandler::getHandlerId() const {
@@ -1,8 +1,7 @@
1
1
  #pragma once
2
2
 
3
3
  #include <jsi/jsi.h>
4
- #include <worklets/SharedItems/Serializable.h>
5
- #include <worklets/WorkletRuntime/WorkletRuntime.h>
4
+ #include <reanimated/Compat/WorkletsApi.h>
6
5
 
7
6
  #include <memory>
8
7
  #include <string>
@@ -15,14 +14,14 @@ class UIEventHandler {
15
14
  const uint64_t handlerId_;
16
15
  const uint64_t emitterReactTag_;
17
16
  const std::string eventName_;
18
- const std::shared_ptr<worklets::SerializableWorklet> handlerFunction_;
17
+ const std::shared_ptr<worklets::Serializable> handlerFunction_;
19
18
 
20
19
  public:
21
20
  UIEventHandler(
22
21
  const uint64_t handlerId,
23
22
  const std::string &eventName,
24
23
  const uint64_t emitterReactTag,
25
- const std::shared_ptr<worklets::SerializableWorklet> &handlerFunction)
24
+ const std::shared_ptr<worklets::Serializable> &handlerFunction)
26
25
  : handlerId_(handlerId),
27
26
  emitterReactTag_(emitterReactTag),
28
27
  eventName_(eventName),
@@ -77,8 +77,9 @@ void UIEventHandlerRegistry::processEvent(
77
77
  }
78
78
  }
79
79
 
80
- jsi::Runtime &rt = uiWorkletRuntime->getJSIRuntime();
81
- eventPayload.asObject(rt).setProperty(rt, "eventName", jsi::String::createFromUtf8(rt, eventName));
80
+ jsi::Runtime &uiRuntime = getJSIRuntimeFromWorkletRuntime(uiWorkletRuntime);
81
+ eventPayload.asObject(uiRuntime).setProperty(
82
+ uiRuntime, "eventName", jsi::String::createFromUtf8(uiRuntime, eventName));
82
83
  for (const auto &handler : handlersForEvent) {
83
84
  handler->process(uiWorkletRuntime, eventTimestamp, eventPayload);
84
85
  }
@@ -1,7 +1,7 @@
1
1
  #pragma once
2
2
 
3
3
  #include <jsi/jsi.h>
4
- #include <worklets/WorkletRuntime/WorkletRuntime.h>
4
+ #include <reanimated/Compat/WorkletsApi.h>
5
5
 
6
6
  #include <map>
7
7
  #include <memory>
@@ -53,12 +53,8 @@ void ReanimatedCommitHook::maybeInitializeLayoutAnimations(SurfaceId surfaceId)
53
53
  RootShadowNode::Unshared ReanimatedCommitHook::shadowTreeWillCommit(
54
54
  ShadowTree const &,
55
55
  RootShadowNode::Shared const &,
56
- RootShadowNode::Unshared const &newRootShadowNode
57
- #if REACT_NATIVE_MINOR_VERSION >= 80
58
- ,
59
- const ShadowTreeCommitOptions &commitOptions
60
- #endif
61
- ) noexcept {
56
+ RootShadowNode::Unshared const &newRootShadowNode,
57
+ const ShadowTreeCommitOptions &commitOptions) noexcept {
62
58
  ReanimatedSystraceSection s("ReanimatedCommitHook::shadowTreeWillCommit");
63
59
 
64
60
  maybeInitializeLayoutAnimations(newRootShadowNode->getSurfaceId());
@@ -73,7 +69,6 @@ RootShadowNode::Unshared ReanimatedCommitHook::shadowTreeWillCommit(
73
69
  return newRootShadowNode;
74
70
  }
75
71
 
76
- #if REACT_NATIVE_MINOR_VERSION >= 80
77
72
  if constexpr (StaticFeatureFlags::getFlag("USE_COMMIT_HOOK_ONLY_FOR_REACT_COMMITS")) {
78
73
  // State updates are based on the currently committed ShadowTree,
79
74
  // which means that all animation changes are already included.
@@ -82,7 +77,6 @@ RootShadowNode::Unshared ReanimatedCommitHook::shadowTreeWillCommit(
82
77
  return newRootShadowNode;
83
78
  }
84
79
  }
85
- #endif
86
80
 
87
81
  // ShadowTree not commited by Reanimated, apply updates from the updates
88
82
  // registry manager
@@ -29,12 +29,8 @@ class ReanimatedCommitHook : public UIManagerCommitHook, public std::enable_shar
29
29
  RootShadowNode::Unshared shadowTreeWillCommit(
30
30
  ShadowTree const &shadowTree,
31
31
  RootShadowNode::Shared const &oldRootShadowNode,
32
- RootShadowNode::Unshared const &newRootShadowNode
33
- #if REACT_NATIVE_MINOR_VERSION >= 80
34
- ,
35
- const ShadowTreeCommitOptions &commitOptions
36
- #endif
37
- ) noexcept override;
32
+ RootShadowNode::Unshared const &newRootShadowNode,
33
+ const ShadowTreeCommitOptions &commitOptions) noexcept override;
38
34
 
39
35
  private:
40
36
  std::shared_ptr<UIManager> uiManager_;
@@ -20,12 +20,7 @@ ReanimatedMountHook::~ReanimatedMountHook() noexcept {
20
20
 
21
21
  void ReanimatedMountHook::shadowTreeDidMount(
22
22
  const RootShadowNode::Shared &rootShadowNode,
23
- #if REACT_NATIVE_MINOR_VERSION >= 81
24
- HighResTimeStamp
25
- #else
26
- double
27
- #endif // REACT_NATIVE_MINOR_VERSION >= 81
28
- ) noexcept {
23
+ HighResTimeStamp mountTime) noexcept {
29
24
  ReanimatedSystraceSection s("ReanimatedMountHook::shadowTreeDidMount");
30
25
 
31
26
  auto reaShadowNode = std::reinterpret_pointer_cast<ReanimatedCommitShadowNode>(
@@ -19,14 +19,7 @@ class ReanimatedMountHook : public UIManagerMountHook {
19
19
  const std::function<void()> &requestFlush);
20
20
  ~ReanimatedMountHook() noexcept override;
21
21
 
22
- void shadowTreeDidMount(
23
- RootShadowNode::Shared const &rootShadowNode,
24
- #if REACT_NATIVE_MINOR_VERSION >= 81
25
- HighResTimeStamp mountTime
26
- #else
27
- double mountTime
28
- #endif // REACT_NATIVE_MINOR_VERSION >= 81
29
- ) noexcept override;
22
+ void shadowTreeDidMount(RootShadowNode::Shared const &rootShadowNode, HighResTimeStamp mountTime) noexcept override;
30
23
 
31
24
  private:
32
25
  const std::shared_ptr<UIManager> uiManager_;
@@ -6,13 +6,11 @@
6
6
 
7
7
  namespace reanimated {
8
8
 
9
- #if REACT_NATIVE_MINOR_VERSION >= 81
10
9
  static inline std::shared_ptr<const ShadowNode> shadowNodeFromValue(
11
10
  jsi::Runtime &rt,
12
11
  const jsi::Value &shadowNodeWrapper) {
13
12
  return Bridging<std::shared_ptr<const ShadowNode>>::fromJs(rt, shadowNodeWrapper);
14
13
  }
15
- #endif
16
14
 
17
15
  void AnimatedPropsRegistry::update(jsi::Runtime &rt, const jsi::Value &operations, const double timestamp) {
18
16
  auto operationsArray = operations.asObject(rt).asArray(rt);
@@ -2,10 +2,9 @@
2
2
 
3
3
  #include <react/renderer/graphics/Transform.h>
4
4
  #include <react/renderer/mounting/ShadowView.h>
5
+ #include <reanimated/Compat/WorkletsApi.h>
5
6
  #include <reanimated/LayoutAnimations/LayoutAnimationType.h>
6
7
 
7
- #include <worklets/SharedItems/Serializable.h>
8
-
9
8
  #include <jsi/jsi.h>
10
9
  #include <stdio.h>
11
10
  #include <functional>
@@ -4,9 +4,9 @@
4
4
  #include <react/renderer/componentregistry/ComponentDescriptorFactory.h>
5
5
  #include <react/renderer/mounting/MountingOverrideDelegate.h>
6
6
  #include <react/renderer/uimanager/UIManager.h>
7
+ #include <reanimated/Compat/WorkletsApi.h>
7
8
  #include <reanimated/LayoutAnimations/LayoutAnimationsManager.h>
8
9
  #include <reanimated/Tools/PlatformDepMethodsHolder.h>
9
- #include <worklets/Tools/UIScheduler.h>
10
10
 
11
11
  #include <memory>
12
12
  #include <optional>
@@ -32,7 +32,7 @@ std::optional<MountingTransaction> LayoutAnimationsProxy_Experimental::pullTrans
32
32
  ShadowViewMutationList filteredMutations;
33
33
  auto rootChildCount = static_cast<int>(lightNodes_[surfaceId]->children.size());
34
34
  const std::vector<std::shared_ptr<MutationNode>> roots;
35
- const bool isInTransition = transitionState_;
35
+ const bool isInTransition = static_cast<bool>(transitionState_);
36
36
 
37
37
  if (isInTransition) {
38
38
  updateLightTree(propsParserContext, mutations, filteredMutations);
@@ -538,7 +538,7 @@ void LayoutAnimationsProxy_Experimental::maybeCancelAnimation(const int tag) con
538
538
  return;
539
539
  }
540
540
  layoutAnimations_.erase(tag);
541
- uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), tag]() {
541
+ scheduleOnUI(uiScheduler_, [weakThis = weak_from_this(), tag]() {
542
542
  auto strongThis = weakThis.lock();
543
543
  if (!strongThis) {
544
544
  return;
@@ -679,8 +679,8 @@ void LayoutAnimationsProxy_Experimental::startEnteringAnimation(const std::share
679
679
  react_native_assert(parent && "Parent node is nullptr");
680
680
  const auto parentTag = parent->current.tag;
681
681
 
682
- uiScheduler_->scheduleOnUI(
683
- [weakThis = weak_from_this(), finalView, currentView, newChildShadowView, parentTag, opacity]() {
682
+ scheduleOnUI(
683
+ uiScheduler_, [weakThis = weak_from_this(), finalView, currentView, newChildShadowView, parentTag, opacity]() {
684
684
  auto strongThis = weakThis.lock();
685
685
  if (!strongThis) {
686
686
  return;
@@ -724,7 +724,7 @@ void LayoutAnimationsProxy_Experimental::startExitingAnimation(const std::shared
724
724
  react_native_assert(parent && "Parent node is nullptr");
725
725
  const auto parentTag = parent->current.tag;
726
726
 
727
- uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), tag, parentTag, oldChildShadowView, surfaceId]() {
727
+ scheduleOnUI(uiScheduler_, [weakThis = weak_from_this(), tag, parentTag, oldChildShadowView, surfaceId]() {
728
728
  auto strongThis = weakThis.lock();
729
729
  if (!strongThis) {
730
730
  return;
@@ -766,8 +766,8 @@ void LayoutAnimationsProxy_Experimental::startLayoutAnimation(const std::shared_
766
766
  react_native_assert(parent && "Parent node is nullptr");
767
767
  const auto parentTag = parent->current.tag;
768
768
 
769
- uiScheduler_->scheduleOnUI(
770
- [weakThis = weak_from_this(), surfaceId, oldChildShadowView, newChildShadowView, parentTag, tag]() {
769
+ scheduleOnUI(
770
+ uiScheduler_, [weakThis = weak_from_this(), surfaceId, oldChildShadowView, newChildShadowView, parentTag, tag]() {
771
771
  auto strongThis = weakThis.lock();
772
772
  if (!strongThis) {
773
773
  return;
@@ -811,7 +811,7 @@ void LayoutAnimationsProxy_Experimental::startSharedTransition(
811
811
  const ShadowView &before,
812
812
  const ShadowView &after,
813
813
  SurfaceId surfaceId) const {
814
- uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), before, after, surfaceId, tag]() {
814
+ scheduleOnUI(uiScheduler_, [weakThis = weak_from_this(), before, after, surfaceId, tag]() {
815
815
  auto strongThis = weakThis.lock();
816
816
  if (!strongThis) {
817
817
  return;
@@ -844,7 +844,7 @@ void LayoutAnimationsProxy_Experimental::startProgressTransition(
844
844
  const ShadowView &before,
845
845
  const ShadowView &after,
846
846
  SurfaceId surfaceId) const {
847
- uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), before, after, surfaceId]() {
847
+ scheduleOnUI(uiScheduler_, [weakThis = weak_from_this(), before, after, surfaceId]() {
848
848
  auto strongThis = weakThis.lock();
849
849
  if (!strongThis) {
850
850
  return;
@@ -1,12 +1,11 @@
1
1
  #pragma once
2
2
 
3
+ #include <reanimated/Compat/WorkletsApi.h>
3
4
  #include <reanimated/LayoutAnimations/LayoutAnimationsManager.h>
4
5
  #include <reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h>
5
6
  #include <reanimated/LayoutAnimations/LayoutAnimationsUtils.h>
6
7
  #include <reanimated/Tools/PlatformDepMethodsHolder.h>
7
8
 
8
- #include <worklets/Tools/UIScheduler.h>
9
-
10
9
  #include <react/renderer/componentregistry/ComponentDescriptorFactory.h>
11
10
  #include <react/renderer/graphics/Transform.h>
12
11
  #include <react/renderer/mounting/MountingOverrideDelegate.h>
@@ -44,7 +43,7 @@ struct LayoutAnimationsProxy_Experimental : public LayoutAnimationsProxyCommon,
44
43
  mutable Tag transitionTag_;
45
44
  mutable double transitionProgress_;
46
45
  mutable bool transitionUpdated_;
47
- mutable TransitionState transitionState_ = NONE;
46
+ mutable TransitionState transitionState_ = TransitionState::NONE;
48
47
  mutable SurfaceId transitioningSurfaceId_ = -1;
49
48
  mutable std::unordered_map<SurfaceId, std::shared_ptr<LightNode>> topScreen;
50
49
  mutable int containerTag_ = 10000002;
@@ -124,7 +124,7 @@ std::optional<SurfaceId> LayoutAnimationsProxy_Legacy::endLayoutAnimation(int ta
124
124
 
125
125
  auto node = nodeForTag_[tag];
126
126
  auto mutationNode = std::static_pointer_cast<MutationNode>(node);
127
- mutationNode->state = DEAD;
127
+ mutationNode->state = ExitingState_Legacy::DEAD;
128
128
  auto &[deadNodes] = surfaceContext_[surfaceId];
129
129
  deadNodes.insert(mutationNode);
130
130
 
@@ -172,7 +172,7 @@ void LayoutAnimationsProxy_Legacy::parseRemoveMutations(
172
172
  }
173
173
  }
174
174
  if (!deletedViews.contains(mutation.oldChildShadowView.tag)) {
175
- mutationNode->state = MOVED;
175
+ mutationNode->state = ExitingState_Legacy::MOVED;
176
176
  movedViews.insert_or_assign(mutation.oldChildShadowView.tag, -1);
177
177
  }
178
178
  nodeForTag_[tag] = mutationNode;
@@ -245,11 +245,11 @@ void LayoutAnimationsProxy_Legacy::handleRemovals(
245
245
  if (!startAnimationsRecursively(node, true, shouldAnimate, false, filteredMutations)) {
246
246
  filteredMutations.push_back(node->mutation);
247
247
  node->unflattenedParent->removeChildFromUnflattenedTree(node); //???
248
- if (node->state != MOVED) {
248
+ if (node->state != ExitingState_Legacy::MOVED) {
249
249
  maybeCancelAnimation(node->tag);
250
250
  filteredMutations.push_back(ShadowViewMutation::DeleteMutation(node->mutation.oldChildShadowView));
251
251
  nodeForTag_.erase(node->tag);
252
- node->state = DELETED;
252
+ node->state = ExitingState_Legacy::DELETED;
253
253
  #ifdef LAYOUT_ANIMATIONS_LOGS
254
254
  LOG(INFO) << "delete " << node->tag << std::endl;
255
255
  #endif
@@ -258,7 +258,7 @@ void LayoutAnimationsProxy_Legacy::handleRemovals(
258
258
  }
259
259
 
260
260
  for (const auto &node : deadNodes) {
261
- if (node->state != DELETED) {
261
+ if (node->state != ExitingState_Legacy::DELETED) {
262
262
  endAnimationsRecursively(node, filteredMutations);
263
263
  maybeDropAncestors(node->unflattenedParent, node, filteredMutations);
264
264
  }
@@ -429,12 +429,12 @@ void LayoutAnimationsProxy_Legacy::endAnimationsRecursively(
429
429
  const std::shared_ptr<MutationNode> &node,
430
430
  ShadowViewMutationList &mutations) const {
431
431
  maybeCancelAnimation(node->tag);
432
- node->state = DELETED;
432
+ node->state = ExitingState_Legacy::DELETED;
433
433
  // iterate from the end, so that children
434
434
  // with higher indices appear first in the mutations list
435
435
  for (auto it = node->unflattenedChildren.rbegin(); it != node->unflattenedChildren.rend(); it++) {
436
436
  auto &subNode = *it;
437
- if (subNode->state != DELETED) {
437
+ if (subNode->state != ExitingState_Legacy::DELETED) {
438
438
  endAnimationsRecursively(subNode, mutations);
439
439
  }
440
440
  }
@@ -457,11 +457,11 @@ void LayoutAnimationsProxy_Legacy::maybeDropAncestors(
457
457
 
458
458
  auto node = std::static_pointer_cast<MutationNode>(parent);
459
459
 
460
- if (node->children.size() == 0 && node->state != ANIMATING) {
460
+ if (node->children.size() == 0 && node->state != ExitingState_Legacy::ANIMATING) {
461
461
  nodeForTag_.erase(node->tag);
462
462
  cleanupMutations.push_back(node->mutation);
463
463
  maybeCancelAnimation(node->tag);
464
- node->state = DELETED;
464
+ node->state = ExitingState_Legacy::DELETED;
465
465
  #ifdef LAYOUT_ANIMATIONS_LOGS
466
466
  LOG(INFO) << "delete " << node->tag << std::endl;
467
467
  #endif
@@ -492,7 +492,7 @@ bool LayoutAnimationsProxy_Legacy::startAnimationsRecursively(
492
492
  bool hasAnimatedChildren = false;
493
493
 
494
494
  shouldRemoveSubviewsWithoutAnimations =
495
- shouldRemoveSubviewsWithoutAnimations && (!hasExitAnimation || node->state == MOVED);
495
+ shouldRemoveSubviewsWithoutAnimations && (!hasExitAnimation || node->state == ExitingState_Legacy::MOVED);
496
496
  std::vector<std::shared_ptr<MutationNode>> toBeRemoved;
497
497
 
498
498
  // iterate from the end, so that children
@@ -503,8 +503,8 @@ bool LayoutAnimationsProxy_Legacy::startAnimationsRecursively(
503
503
  LOG(INFO) << "child " << subNode->tag << " "
504
504
  << " " << shouldAnimate << " " << shouldRemoveSubviewsWithoutAnimations << std::endl;
505
505
  #endif
506
- if (subNode->state != UNDEFINED && subNode->state != MOVED) {
507
- if (shouldAnimate && subNode->state != DEAD) {
506
+ if (subNode->state != ExitingState_Legacy::UNDEFINED && subNode->state != ExitingState_Legacy::MOVED) {
507
+ if (shouldAnimate && subNode->state != ExitingState_Legacy::DEAD) {
508
508
  hasAnimatedChildren = true;
509
509
  } else {
510
510
  endAnimationsRecursively(subNode, mutations);
@@ -516,21 +516,21 @@ bool LayoutAnimationsProxy_Legacy::startAnimationsRecursively(
516
516
  LOG(INFO) << "child " << subNode->tag << " start animations returned true " << std::endl;
517
517
  #endif
518
518
  hasAnimatedChildren = true;
519
- } else if (subNode->state == MOVED) {
519
+ } else if (subNode->state == ExitingState_Legacy::MOVED) {
520
520
  mutations.push_back(subNode->mutation);
521
521
  toBeRemoved.push_back(subNode);
522
522
  } else if (shouldRemoveSubviewsWithoutAnimations) {
523
523
  maybeCancelAnimation(subNode->tag);
524
524
  mutations.push_back(subNode->mutation);
525
525
  toBeRemoved.push_back(subNode);
526
- subNode->state = DELETED;
526
+ subNode->state = ExitingState_Legacy::DELETED;
527
527
  nodeForTag_.erase(subNode->tag);
528
528
  #ifdef LAYOUT_ANIMATIONS_LOGS
529
529
  LOG(INFO) << "delete " << subNode->tag << std::endl;
530
530
  #endif
531
531
  mutations.push_back(ShadowViewMutation::DeleteMutation(subNode->mutation.oldChildShadowView));
532
532
  } else {
533
- subNode->state = WAITING;
533
+ subNode->state = ExitingState_Legacy::WAITING;
534
534
  }
535
535
  }
536
536
 
@@ -538,7 +538,7 @@ bool LayoutAnimationsProxy_Legacy::startAnimationsRecursively(
538
538
  node->removeChildFromUnflattenedTree(subNode);
539
539
  }
540
540
 
541
- if (node->state == MOVED) {
541
+ if (node->state == ExitingState_Legacy::MOVED) {
542
542
  auto replacement = std::make_shared<Node>(*node);
543
543
  for (const auto &subNode : node->children) {
544
544
  subNode->parent = replacement;
@@ -553,7 +553,7 @@ bool LayoutAnimationsProxy_Legacy::startAnimationsRecursively(
553
553
  bool wantAnimateExit = hasExitAnimation || hasAnimatedChildren;
554
554
 
555
555
  if (hasExitAnimation) {
556
- node->state = ANIMATING;
556
+ node->state = ExitingState_Legacy::ANIMATING;
557
557
  startExitingAnimation(node->tag, node->mutation);
558
558
  } else {
559
559
  layoutAnimationsManager_->clearLayoutAnimationConfig(node->tag);
@@ -636,7 +636,7 @@ void LayoutAnimationsProxy_Legacy::startEnteringAnimation(const int tag, ShadowV
636
636
  auto &viewProps = static_cast<const ViewProps &>(*mutation.newChildShadowView.props);
637
637
  auto opacity = viewProps.opacity;
638
638
 
639
- uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), finalView, current, mutation, opacity, tag]() {
639
+ scheduleOnUI(uiScheduler_, [weakThis = weak_from_this(), finalView, current, mutation, opacity, tag]() {
640
640
  auto strongThis = weakThis.lock();
641
641
  if (!strongThis) {
642
642
  return;
@@ -675,7 +675,7 @@ void LayoutAnimationsProxy_Legacy::startExitingAnimation(const int tag, ShadowVi
675
675
  #endif
676
676
  auto surfaceId = mutation.oldChildShadowView.surfaceId;
677
677
 
678
- uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), tag, mutation, surfaceId]() {
678
+ scheduleOnUI(uiScheduler_, [weakThis = weak_from_this(), tag, mutation, surfaceId]() {
679
679
  auto strongThis = weakThis.lock();
680
680
  if (!strongThis) {
681
681
  return;
@@ -714,7 +714,7 @@ void LayoutAnimationsProxy_Legacy::startLayoutAnimation(const int tag, const Sha
714
714
  #endif
715
715
  auto surfaceId = mutation.oldChildShadowView.surfaceId;
716
716
 
717
- uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), mutation, surfaceId, tag]() {
717
+ scheduleOnUI(uiScheduler_, [weakThis = weak_from_this(), mutation, surfaceId, tag]() {
718
718
  auto strongThis = weakThis.lock();
719
719
  if (!strongThis) {
720
720
  return;
@@ -763,7 +763,7 @@ void LayoutAnimationsProxy_Legacy::maybeCancelAnimation(const int tag) const {
763
763
  return;
764
764
  }
765
765
  layoutAnimations_.erase(tag);
766
- uiScheduler_->scheduleOnUI([weakThis = weak_from_this(), tag]() {
766
+ scheduleOnUI(uiScheduler_, [weakThis = weak_from_this(), tag]() {
767
767
  auto strongThis = weakThis.lock();
768
768
  if (!strongThis) {
769
769
  return;
@@ -5,11 +5,11 @@
5
5
  #include <react/renderer/scheduler/Scheduler.h>
6
6
  #include <react/renderer/uimanager/UIManagerAnimationDelegate.h>
7
7
  #include <react/renderer/uimanager/UIManagerBinding.h>
8
+ #include <reanimated/Compat/WorkletsApi.h>
8
9
  #include <reanimated/LayoutAnimations/LayoutAnimationsManager.h>
9
10
  #include <reanimated/LayoutAnimations/LayoutAnimationsProxyCommon.h>
10
11
  #include <reanimated/LayoutAnimations/LayoutAnimationsUtils.h>
11
12
  #include <reanimated/Tools/PlatformDepMethodsHolder.h>
12
- #include <worklets/Tools/UIScheduler.h>
13
13
 
14
14
  #include <memory>
15
15
  #include <string>
@@ -24,7 +24,7 @@ class ReanimatedModuleProxy;
24
24
 
25
25
  using namespace facebook;
26
26
 
27
- typedef enum ExitingState_Legacy : std::uint8_t {
27
+ typedef enum class ExitingState_Legacy : std::uint8_t {
28
28
  UNDEFINED = 1,
29
29
  WAITING = 2,
30
30
  ANIMATING = 4,
@@ -60,7 +60,7 @@ struct Node {
60
60
  */
61
61
  struct MutationNode : public Node {
62
62
  ShadowViewMutation mutation;
63
- ExitingState_Legacy state = UNDEFINED;
63
+ ExitingState_Legacy state = ExitingState_Legacy::UNDEFINED;
64
64
  explicit MutationNode(ShadowViewMutation &mutation) : Node(mutation.oldChildShadowView.tag), mutation(mutation) {}
65
65
  MutationNode(ShadowViewMutation &mutation, Node &&node) : Node(std::move(node)), mutation(mutation) {}
66
66
  bool isMutationNode() override;
@@ -13,7 +13,7 @@
13
13
 
14
14
  namespace reanimated {
15
15
 
16
- enum BeforeOrAfter : std::uint8_t { BEFORE = 0, AFTER = 1 };
16
+ enum BeforeOrAfter : std::uint8_t { BEFORE = 0, AFTER = 1 }; // NOLINT
17
17
 
18
18
  struct Rect {
19
19
  double width, height;
@@ -66,7 +66,7 @@ typedef enum class ExitingState : std::uint8_t {
66
66
 
67
67
  struct MutationNode;
68
68
 
69
- enum TransitionState : std::uint8_t {
69
+ enum class TransitionState : std::uint8_t {
70
70
  NONE = 0,
71
71
  START = 1,
72
72
  ACTIVE = 2,
@@ -74,7 +74,7 @@ enum TransitionState : std::uint8_t {
74
74
  CANCELLED = 4,
75
75
  };
76
76
 
77
- enum Intent : std::uint8_t {
77
+ enum class Intent : std::uint8_t {
78
78
  NO_INTENT = 0,
79
79
  TO_MOVE = 1,
80
80
  TO_DELETE = 2,