diff --git a/README.md b/README.md
index ab1de80b334..d7d5b17a312 100644
--- a/README.md
+++ b/README.md
@@ -5,9 +5,9 @@
> Reanimated 3 is here! Check out our [documentation page](https://docs.swmansion.com/react-native-reanimated/) for more information
React Native Reanimated provides a more comprehensive,
-low level abstraction for the Animated library API to be built
-on top of and hence allow for much greater flexibility especially when it
-comes to gesture based interactions.
+low-level abstraction for the Animated library API on which to build,
+allowing for much greater flexibility, especially when it comes to
+gesture-based interactions.
### Nightly CI state
diff --git a/package.json b/package.json
index b207048a35d..9df784781ff 100644
--- a/package.json
+++ b/package.json
@@ -7,6 +7,7 @@
"packages/react-native-reanimated",
"packages/eslint-plugin-reanimated",
"packages/react-native-reanimated/plugin",
+ "packages/react-native-worklets",
"apps/common-app",
"apps/paper-example",
"apps/fabric-example",
diff --git a/packages/docs-reanimated/docs/advanced/useEvent.mdx b/packages/docs-reanimated/docs/advanced/useEvent.mdx
index 83ffc0d98b8..2525a6d5b8b 100644
--- a/packages/docs-reanimated/docs/advanced/useEvent.mdx
+++ b/packages/docs-reanimated/docs/advanced/useEvent.mdx
@@ -4,7 +4,7 @@ sidebar_position: 4
# useEvent
-`useEvent` is a low-level hook. It returns event handler that will be called when native event occurs. You can use it to create custom event handler hooks, like [`useScrollViewOffset`](/docs/scroll/useScrollViewOffset/) or [`useAnimatedScrollHandler`](/docs/scroll/useAnimatedScrollHandler/).
+`useEvent` is a low-level hook. It returns an event handler that will be called when a native event occurs. You can use it to create custom event handler hooks, like [`useScrollViewOffset`](/docs/scroll/useScrollViewOffset/) or [`useAnimatedScrollHandler`](/docs/scroll/useAnimatedScrollHandler/).
## Reference
@@ -63,22 +63,22 @@ type EventHandlerProcessed<
#### `handler`
-Function that receives event object with native payload, that can be passed to custom handler hook's worklets.
+Function that receives an event object with a native payload, which can be passed to the custom handler hook's worklets.
- `event` - event object.
The payload can differ depending on the type of the event.
#### `eventNames`
-Array of event names that will be handled by handler.
+Array of event names that will be handled by the handler.
#### `rebuild`
-Value indicating whether handler should be rebuilt.
+Value indicating whether the handler should be rebuilt.
### Returns
-The hook returns event handler that will be invoked when native event is dispatched. That handler may be connected to multiple components and will be invoked for each one's specific events.
+The hook returns an event handler that will be invoked when a native event is dispatched. That handler may be connected to multiple components and will be invoked for each one's specific events.
## Example
diff --git a/packages/docs-reanimated/versioned_docs/version-2.x/api/hooks/useEvent.md b/packages/docs-reanimated/versioned_docs/version-2.x/api/hooks/useEvent.md
index 15325f7fd43..8abbbd924ac 100644
--- a/packages/docs-reanimated/versioned_docs/version-2.x/api/hooks/useEvent.md
+++ b/packages/docs-reanimated/versioned_docs/version-2.x/api/hooks/useEvent.md
@@ -4,13 +4,13 @@ title: useEvent
sidebar_label: useEvent
---
-This is low-level hook returning event handler that will be invoked with native events, which should be used in order to create custom event handler hook like `useAnimatedGestureHandler` or `useAnimatedScrollHandler`.
+This is a low-level hook returning an event handler that will be invoked with native events, which should be used in order to create custom event handler hooks, like `useAnimatedGestureHandler` or `useAnimatedScrollHandler`.
### Arguments
#### `handler` [function]
-Handler will receive event object with native payload, that can be passed to custom handler hook's worklets.
+Handler that will receive an event object with a native payload, which can be passed to the custom handler hook's worklets.
- `event` [object] - event object.
The payload can differ depending on the type of the event.
@@ -21,11 +21,11 @@ Array of event names that will be handled by handler.
#### `rebuilt` [boolean]
-Value indicating whether handler should be rebuilt.
+Value indicating whether the handler should be rebuilt.
### Returns
-The hook returns event handler that will be invoked when native event is dispatched.
+The hook returns an event handler that will be invoked when a native event is dispatched.
## Example
diff --git a/packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.cpp b/packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.cpp
index 0aeda945bb4..f55b383bdc8 100644
--- a/packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.cpp
+++ b/packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.cpp
@@ -1,7 +1,7 @@
#ifdef RCT_NEW_ARCH_ENABLED
#include
-#include
+#include
#include
#include
diff --git a/packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h b/packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h
index 8fd9a89d7fa..a37f43a414a 100644
--- a/packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h
+++ b/packages/react-native-reanimated/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h
@@ -19,7 +19,7 @@
namespace reanimated {
-class NativeReanimatedModule;
+class ReanimatedModuleProxy;
using namespace facebook;
diff --git a/packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp b/packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp
similarity index 89%
rename from packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp
rename to packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp
index b1f430a89cd..cc689308bd7 100644
--- a/packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.cpp
+++ b/packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp
@@ -1,5 +1,4 @@
-#include
-#include
+#include
#include
#include
#include
@@ -51,28 +50,22 @@ using namespace facebook;
namespace reanimated {
-NativeReanimatedModule::NativeReanimatedModule(
- const std::shared_ptr &nativeWorkletsModule,
+ReanimatedModuleProxy::ReanimatedModuleProxy(
+ const std::shared_ptr &workletsModuleProxy,
jsi::Runtime &rnRuntime,
- const std::shared_ptr &jsScheduler,
- const std::shared_ptr &jsQueue,
- const std::shared_ptr &uiScheduler,
+ const std::shared_ptr &jsCallInvoker,
const PlatformDepMethodsHolder &platformDepMethodsHolder,
const bool isBridgeless,
const bool isReducedMotion)
- : NativeReanimatedModuleSpec(
- isBridgeless ? nullptr : jsScheduler->getJSCallInvoker()),
+ : ReanimatedModuleProxySpec(jsCallInvoker),
isBridgeless_(isBridgeless),
isReducedMotion_(isReducedMotion),
- jsQueue_(jsQueue),
- nativeWorkletsModule_(nativeWorkletsModule),
- jsScheduler_(jsScheduler),
- uiScheduler_(uiScheduler),
- valueUnpackerCode_(nativeWorkletsModule->getValueUnpackerCode()),
+ workletsModuleProxy_(workletsModuleProxy),
+ valueUnpackerCode_(workletsModuleProxy->getValueUnpackerCode()),
uiWorkletRuntime_(std::make_shared(
rnRuntime,
- jsQueue,
- jsScheduler_,
+ workletsModuleProxy->getJSQueue(),
+ workletsModuleProxy->getJSScheduler(),
"Reanimated UI runtime",
true /* supportsLocking */,
valueUnpackerCode_)),
@@ -83,7 +76,8 @@ NativeReanimatedModule::NativeReanimatedModule(
onRender(timestampMs);
}),
animatedSensorModule_(platformDepMethodsHolder),
- jsLogger_(std::make_shared(jsScheduler_)),
+ jsLogger_(
+ std::make_shared(workletsModuleProxy->getJSScheduler())),
layoutAnimationsManager_(
std::make_shared(jsLogger_)),
#ifdef RCT_NEW_ARCH_ENABLED
@@ -103,7 +97,7 @@ NativeReanimatedModule::NativeReanimatedModule(
commonInit(platformDepMethodsHolder);
}
-void NativeReanimatedModule::commonInit(
+void ReanimatedModuleProxy::commonInit(
const PlatformDepMethodsHolder &platformDepMethodsHolder) {
auto requestAnimationFrame =
[this](jsi::Runtime &rt, const jsi::Value &callback) {
@@ -195,20 +189,23 @@ void NativeReanimatedModule::commonInit(
platformDepMethodsHolder.maybeFlushUIUpdatesQueueFunction);
}
-NativeReanimatedModule::~NativeReanimatedModule() {
+ReanimatedModuleProxy::~ReanimatedModuleProxy() {
// event handler registry and frame callbacks store some JSI values from UI
// runtime, so they have to go away before we tear down the runtime
eventHandlerRegistry_.reset();
frameCallbacks_.clear();
+#ifdef RCT_NEW_ARCH_ENABLED
+ operationsInBatch_.clear();
+#endif // RCT_NEW_ARCH_ENABLED
uiWorkletRuntime_.reset();
}
-void NativeReanimatedModule::scheduleOnUI(
+void ReanimatedModuleProxy::scheduleOnUI(
jsi::Runtime &rt,
const jsi::Value &worklet) {
auto shareableWorklet = extractShareableOrThrow(
rt, worklet, "[Reanimated] Only worklets can be scheduled to run on UI.");
- uiScheduler_->scheduleOnUI(COPY_CAPTURE_WITH_THIS {
+ workletsModuleProxy_->getUIScheduler()->scheduleOnUI(COPY_CAPTURE_WITH_THIS {
#if JS_RUNTIME_HERMES
// JSI's scope defined here allows for JSI-objects to be cleared up
// after each runtime loop. Within these loops we typically create some
@@ -221,31 +218,30 @@ void NativeReanimatedModule::scheduleOnUI(
});
}
-jsi::Value NativeReanimatedModule::executeOnUIRuntimeSync(
+jsi::Value ReanimatedModuleProxy::executeOnUIRuntimeSync(
jsi::Runtime &rt,
const jsi::Value &worklet) {
return uiWorkletRuntime_->executeSync(rt, worklet);
}
-jsi::Value NativeReanimatedModule::createWorkletRuntime(
+jsi::Value ReanimatedModuleProxy::createWorkletRuntime(
jsi::Runtime &rt,
const jsi::Value &name,
const jsi::Value &initializer) {
auto workletRuntime = std::make_shared(
rt,
- jsQueue_,
- jsScheduler_,
+ workletsModuleProxy_->getJSQueue(),
+ workletsModuleProxy_->getJSScheduler(),
name.asString(rt).utf8(rt),
false /* supportsLocking */,
valueUnpackerCode_);
auto initializerShareable = extractShareableOrThrow(
rt, initializer, "[Reanimated] Initializer must be a worklet.");
workletRuntime->runGuarded(initializerShareable);
- ReanimatedWorkletRuntimeDecorator::decorate(workletRuntime->getJSIRuntime());
return jsi::Object::createFromHostObject(rt, workletRuntime);
}
-jsi::Value NativeReanimatedModule::scheduleOnRuntime(
+jsi::Value ReanimatedModuleProxy::scheduleOnRuntime(
jsi::Runtime &rt,
const jsi::Value &workletRuntimeValue,
const jsi::Value &shareableWorkletValue) {
@@ -253,7 +249,7 @@ jsi::Value NativeReanimatedModule::scheduleOnRuntime(
return jsi::Value::undefined();
}
-jsi::Value NativeReanimatedModule::registerEventHandler(
+jsi::Value ReanimatedModuleProxy::registerEventHandler(
jsi::Runtime &rt,
const jsi::Value &worklet,
const jsi::Value &eventName,
@@ -266,7 +262,7 @@ jsi::Value NativeReanimatedModule::registerEventHandler(
rt, worklet, "[Reanimated] Event handler must be a worklet.");
int emitterReactTagInt = emitterReactTag.asNumber();
- uiScheduler_->scheduleOnUI(COPY_CAPTURE_WITH_THIS {
+ workletsModuleProxy_->getUIScheduler()->scheduleOnUI(COPY_CAPTURE_WITH_THIS {
auto handler = std::make_shared(
newRegistrationId, eventNameStr, emitterReactTagInt, handlerShareable);
eventHandlerRegistry_->registerEventHandler(std::move(handler));
@@ -275,11 +271,11 @@ jsi::Value NativeReanimatedModule::registerEventHandler(
return jsi::Value(static_cast(newRegistrationId));
}
-void NativeReanimatedModule::unregisterEventHandler(
+void ReanimatedModuleProxy::unregisterEventHandler(
jsi::Runtime &,
const jsi::Value ®istrationId) {
uint64_t id = registrationId.asNumber();
- uiScheduler_->scheduleOnUI(
+ workletsModuleProxy_->getUIScheduler()->scheduleOnUI(
COPY_CAPTURE_WITH_THIS
{ eventHandlerRegistry_->unregisterEventHandler(id); });
@@ -299,7 +295,7 @@ static inline std::string intColorToHex(const int val) {
return hexColor;
}
-std::string NativeReanimatedModule::obtainPropFromShadowNode(
+std::string ReanimatedModuleProxy::obtainPropFromShadowNode(
jsi::Runtime &rt,
const std::string &propName,
const ShadowNode::Shared &shadowNode) {
@@ -342,7 +338,7 @@ std::string NativeReanimatedModule::obtainPropFromShadowNode(
"` with function `getViewProp` is not supported"));
}
-jsi::Value NativeReanimatedModule::getViewProp(
+jsi::Value ReanimatedModuleProxy::getViewProp(
jsi::Runtime &rnRuntime,
const jsi::Value &shadowNodeWrapper,
const jsi::Value &propName,
@@ -351,23 +347,24 @@ jsi::Value NativeReanimatedModule::getViewProp(
const auto funPtr = std::make_shared(
callback.getObject(rnRuntime).asFunction(rnRuntime));
const auto shadowNode = shadowNodeFromValue(rnRuntime, shadowNodeWrapper);
- uiScheduler_->scheduleOnUI([=]() {
+ workletsModuleProxy_->getUIScheduler()->scheduleOnUI(COPY_CAPTURE_WITH_THIS {
jsi::Runtime &uiRuntime = uiWorkletRuntime_->getJSIRuntime();
const auto resultStr =
obtainPropFromShadowNode(uiRuntime, propNameStr, shadowNode);
- jsScheduler_->scheduleOnJS([=](jsi::Runtime &rnRuntime) {
- const auto resultValue =
- jsi::String::createFromUtf8(rnRuntime, resultStr);
- funPtr->call(rnRuntime, resultValue);
- });
+ workletsModuleProxy_->getJSScheduler()->scheduleOnJS(
+ [=](jsi::Runtime &rnRuntime) {
+ const auto resultValue =
+ jsi::String::createFromUtf8(rnRuntime, resultStr);
+ funPtr->call(rnRuntime, resultValue);
+ });
});
return jsi::Value::undefined();
}
#else
-jsi::Value NativeReanimatedModule::getViewProp(
+jsi::Value ReanimatedModuleProxy::getViewProp(
jsi::Runtime &rnRuntime,
const jsi::Value &viewTag,
const jsi::Value &propName,
@@ -378,7 +375,7 @@ jsi::Value NativeReanimatedModule::getViewProp(
const int viewTagInt = viewTag.asNumber();
- uiScheduler_->scheduleOnUI(
+ workletsModuleProxy_->getUIScheduler()->scheduleOnUI(
COPY_CAPTURE_WITH_THIS
() {
@@ -388,8 +385,8 @@ jsi::Value NativeReanimatedModule::getViewProp(
const auto resultValue =
obtainPropFunction_(uiRuntime, viewTagInt, propNameValue);
const auto resultStr = resultValue.asString(uiRuntime).utf8(uiRuntime);
-
- jsScheduler_->scheduleOnJS([=](jsi::Runtime &rnRuntime) {
+ const auto jsScheduler = workletsModuleProxy_->getJSScheduler();
+ jsScheduler->scheduleOnJS([=](jsi::Runtime &rnRuntime) {
const auto resultValue =
jsi::String::createFromUtf8(rnRuntime, resultStr);
funPtr->call(rnRuntime, resultValue);
@@ -400,14 +397,14 @@ jsi::Value NativeReanimatedModule::getViewProp(
#endif
-jsi::Value NativeReanimatedModule::enableLayoutAnimations(
+jsi::Value ReanimatedModuleProxy::enableLayoutAnimations(
jsi::Runtime &,
const jsi::Value &config) {
FeaturesConfig::setLayoutAnimationEnabled(config.getBool());
return jsi::Value::undefined();
}
-jsi::Value NativeReanimatedModule::configureProps(
+jsi::Value ReanimatedModuleProxy::configureProps(
jsi::Runtime &rt,
const jsi::Value &uiProps,
const jsi::Value &nativeProps) {
@@ -430,7 +427,7 @@ jsi::Value NativeReanimatedModule::configureProps(
return jsi::Value::undefined();
}
-jsi::Value NativeReanimatedModule::configureLayoutAnimationBatch(
+jsi::Value ReanimatedModuleProxy::configureLayoutAnimationBatch(
jsi::Runtime &rt,
const jsi::Value &layoutAnimationsBatch) {
auto array = layoutAnimationsBatch.asObject(rt).asArray(rt);
@@ -466,7 +463,7 @@ jsi::Value NativeReanimatedModule::configureLayoutAnimationBatch(
return jsi::Value::undefined();
}
-void NativeReanimatedModule::setShouldAnimateExiting(
+void ReanimatedModuleProxy::setShouldAnimateExiting(
jsi::Runtime &rt,
const jsi::Value &viewTag,
const jsi::Value &shouldAnimate) {
@@ -474,21 +471,21 @@ void NativeReanimatedModule::setShouldAnimateExiting(
viewTag.asNumber(), shouldAnimate.getBool());
}
-bool NativeReanimatedModule::isAnyHandlerWaitingForEvent(
+bool ReanimatedModuleProxy::isAnyHandlerWaitingForEvent(
const std::string &eventName,
const int emitterReactTag) {
return eventHandlerRegistry_->isAnyHandlerWaitingForEvent(
eventName, emitterReactTag);
}
-void NativeReanimatedModule::requestAnimationFrame(
+void ReanimatedModuleProxy::requestAnimationFrame(
jsi::Runtime &rt,
const jsi::Value &callback) {
frameCallbacks_.push_back(std::make_shared(rt, callback));
maybeRequestRender();
}
-void NativeReanimatedModule::maybeRequestRender() {
+void ReanimatedModuleProxy::maybeRequestRender() {
if (!renderRequested_) {
renderRequested_ = true;
jsi::Runtime &uiRuntime = uiWorkletRuntime_->getJSIRuntime();
@@ -496,7 +493,7 @@ void NativeReanimatedModule::maybeRequestRender() {
}
}
-void NativeReanimatedModule::onRender(double timestampMs) {
+void ReanimatedModuleProxy::onRender(double timestampMs) {
auto callbacks = std::move(frameCallbacks_);
frameCallbacks_.clear();
jsi::Runtime &uiRuntime = uiWorkletRuntime_->getJSIRuntime();
@@ -506,7 +503,7 @@ void NativeReanimatedModule::onRender(double timestampMs) {
}
}
-jsi::Value NativeReanimatedModule::registerSensor(
+jsi::Value ReanimatedModuleProxy::registerSensor(
jsi::Runtime &rt,
const jsi::Value &sensorType,
const jsi::Value &interval,
@@ -521,18 +518,18 @@ jsi::Value NativeReanimatedModule::registerSensor(
sensorDataHandler);
}
-void NativeReanimatedModule::unregisterSensor(
+void ReanimatedModuleProxy::unregisterSensor(
jsi::Runtime &,
const jsi::Value &sensorId) {
animatedSensorModule_.unregisterSensor(sensorId);
}
-void NativeReanimatedModule::cleanupSensors() {
+void ReanimatedModuleProxy::cleanupSensors() {
animatedSensorModule_.unregisterAllSensors();
}
#ifdef RCT_NEW_ARCH_ENABLED
-bool NativeReanimatedModule::isThereAnyLayoutProp(
+bool ReanimatedModuleProxy::isThereAnyLayoutProp(
jsi::Runtime &rt,
const jsi::Object &props) {
const jsi::Array propNames = props.getPropertyNames(rt);
@@ -548,7 +545,7 @@ bool NativeReanimatedModule::isThereAnyLayoutProp(
return false;
}
-jsi::Value NativeReanimatedModule::filterNonAnimatableProps(
+jsi::Value ReanimatedModuleProxy::filterNonAnimatableProps(
jsi::Runtime &rt,
const jsi::Value &props) {
jsi::Object nonAnimatableProps(rt);
@@ -572,7 +569,7 @@ jsi::Value NativeReanimatedModule::filterNonAnimatableProps(
}
#endif // RCT_NEW_ARCH_ENABLED
-bool NativeReanimatedModule::handleEvent(
+bool ReanimatedModuleProxy::handleEvent(
const std::string &eventName,
const int emitterReactTag,
const jsi::Value &payload,
@@ -586,7 +583,7 @@ bool NativeReanimatedModule::handleEvent(
}
#ifdef RCT_NEW_ARCH_ENABLED
-bool NativeReanimatedModule::handleRawEvent(
+bool ReanimatedModuleProxy::handleRawEvent(
const RawEvent &rawEvent,
double currentTime) {
const EventTarget *eventTarget = rawEvent.eventTarget.get();
@@ -617,7 +614,7 @@ bool NativeReanimatedModule::handleRawEvent(
return res;
}
-void NativeReanimatedModule::updateProps(
+void ReanimatedModuleProxy::updateProps(
jsi::Runtime &rt,
const jsi::Value &operations) {
auto array = operations.asObject(rt).asArray(rt);
@@ -632,7 +629,7 @@ void NativeReanimatedModule::updateProps(
}
}
-void NativeReanimatedModule::performOperations() {
+void ReanimatedModuleProxy::performOperations() {
if (operationsInBatch_.empty() && tagsToRemove_.empty()) {
// nothing to do
return;
@@ -757,7 +754,7 @@ void NativeReanimatedModule::performOperations() {
}
}
-void NativeReanimatedModule::removeFromPropsRegistry(
+void ReanimatedModuleProxy::removeFromPropsRegistry(
jsi::Runtime &rt,
const jsi::Value &viewTags) {
auto array = viewTags.asObject(rt).asArray(rt);
@@ -766,7 +763,7 @@ void NativeReanimatedModule::removeFromPropsRegistry(
}
}
-void NativeReanimatedModule::dispatchCommand(
+void ReanimatedModuleProxy::dispatchCommand(
jsi::Runtime &rt,
const jsi::Value &shadowNodeValue,
const jsi::Value &commandNameValue,
@@ -777,7 +774,7 @@ void NativeReanimatedModule::dispatchCommand(
uiManager_->dispatchCommand(shadowNode, commandName, args);
}
-jsi::String NativeReanimatedModule::obtainProp(
+jsi::String ReanimatedModuleProxy::obtainProp(
jsi::Runtime &rt,
const jsi::Value &shadowNodeWrapper,
const jsi::Value &propName) {
@@ -789,7 +786,7 @@ jsi::String NativeReanimatedModule::obtainProp(
return jsi::String::createFromUtf8(rt, resultStr);
}
-jsi::Value NativeReanimatedModule::measure(
+jsi::Value ReanimatedModuleProxy::measure(
jsi::Runtime &rt,
const jsi::Value &shadowNodeValue) {
// based on implementation from UIManagerBinding.cpp
@@ -833,7 +830,7 @@ jsi::Value NativeReanimatedModule::measure(
return result;
}
-void NativeReanimatedModule::initializeFabric(
+void ReanimatedModuleProxy::initializeFabric(
const std::shared_ptr &uiManager) {
uiManager_ = uiManager;
@@ -845,7 +842,7 @@ void NativeReanimatedModule::initializeFabric(
propsRegistry_, uiManager_, layoutAnimationsProxy_);
}
-void NativeReanimatedModule::initializeLayoutAnimationsProxy() {
+void ReanimatedModuleProxy::initializeLayoutAnimationsProxy() {
uiManager_->setAnimationDelegate(nullptr);
auto scheduler = reinterpret_cast(uiManager_->getDelegate());
auto componentDescriptorRegistry =
@@ -860,13 +857,13 @@ void NativeReanimatedModule::initializeLayoutAnimationsProxy() {
componentDescriptorRegistry,
scheduler->getContextContainer(),
uiWorkletRuntime_->getJSIRuntime(),
- uiScheduler_);
+ workletsModuleProxy_->getUIScheduler());
}
}
#endif // RCT_NEW_ARCH_ENABLED
-jsi::Value NativeReanimatedModule::subscribeForKeyboardEvents(
+jsi::Value ReanimatedModuleProxy::subscribeForKeyboardEvents(
jsi::Runtime &rt,
const jsi::Value &handlerWorklet,
const jsi::Value &isStatusBarTranslucent,
@@ -886,7 +883,7 @@ jsi::Value NativeReanimatedModule::subscribeForKeyboardEvents(
isNavigationBarTranslucent.getBool());
}
-void NativeReanimatedModule::unsubscribeFromKeyboardEvents(
+void ReanimatedModuleProxy::unsubscribeFromKeyboardEvents(
jsi::Runtime &,
const jsi::Value &listenerId) {
unsubscribeFromKeyboardEventsFunction_(listenerId.asNumber());
diff --git a/packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.h b/packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h
similarity index 88%
rename from packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.h
rename to packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h
index 29bfecc7a63..6e71a2e5654 100644
--- a/packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModule.h
+++ b/packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h
@@ -2,7 +2,7 @@
#include
#include
-#include
+#include
#include
#ifdef RCT_NEW_ARCH_ENABLED
@@ -12,7 +12,7 @@
#include
#endif // RCT_NEW_ARCH_ENABLED
-#include
+#include
#include
#include
#include
@@ -30,19 +30,17 @@
namespace reanimated {
-class NativeReanimatedModule : public NativeReanimatedModuleSpec {
+class ReanimatedModuleProxy : public ReanimatedModuleProxySpec {
public:
- NativeReanimatedModule(
- const std::shared_ptr &nativeWorkletsModule,
+ ReanimatedModuleProxy(
+ const std::shared_ptr &workletsModuleProxy,
jsi::Runtime &rnRuntime,
- const std::shared_ptr &jsScheduler,
- const std::shared_ptr &jsQueue,
- const std::shared_ptr &uiScheduler,
+ const std::shared_ptr &jsCallInvoker,
const PlatformDepMethodsHolder &platformDepMethodsHolder,
const bool isBridgeless,
const bool isReducedMotion);
- ~NativeReanimatedModule();
+ ~ReanimatedModuleProxy();
void scheduleOnUI(jsi::Runtime &rt, const jsi::Value &worklet) override;
jsi::Value executeOnUIRuntimeSync(jsi::Runtime &rt, const jsi::Value &worklet)
@@ -175,9 +173,9 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec {
return isReducedMotion_;
}
- [[nodiscard]] inline std::shared_ptr
- getNativeWorkletsModule() const {
- return nativeWorkletsModule_;
+ [[nodiscard]] inline std::shared_ptr
+ getWorkletsModuleProxy() const {
+ return workletsModuleProxy_;
}
private:
@@ -194,10 +192,7 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec {
const bool isBridgeless_;
const bool isReducedMotion_;
- const std::shared_ptr jsQueue_;
- const std::shared_ptr nativeWorkletsModule_;
- const std::shared_ptr jsScheduler_;
- const std::shared_ptr uiScheduler_;
+ const std::shared_ptr workletsModuleProxy_;
const std::string valueUnpackerCode_;
std::shared_ptr uiWorkletRuntime_;
@@ -237,8 +232,7 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec {
const KeyboardEventUnsubscribeFunction unsubscribeFromKeyboardEventsFunction_;
#ifndef NDEBUG
- worklets::SingleInstanceChecker
- singleInstanceChecker_;
+ worklets::SingleInstanceChecker singleInstanceChecker_;
#endif // NDEBUG
};
diff --git a/packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModuleSpec.cpp b/packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp
similarity index 83%
rename from packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModuleSpec.cpp
rename to packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp
index 036f201a88d..d797483bcf1 100644
--- a/packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModuleSpec.cpp
+++ b/packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.cpp
@@ -1,9 +1,9 @@
-#include
+#include
#include
#define REANIMATED_SPEC_PREFIX(FN_NAME) \
- __hostFunction_NativeReanimatedModuleSpec_##FN_NAME
+ __hostFunction_ReanimatedModuleProxySpec_##FN_NAME
namespace reanimated {
@@ -14,7 +14,7 @@ static jsi::Value REANIMATED_SPEC_PREFIX(scheduleOnUI)(
TurboModule &turboModule,
const jsi::Value *args,
size_t) {
- static_cast(&turboModule)
+ static_cast(&turboModule)
->scheduleOnUI(rt, std::move(args[0]));
return jsi::Value::undefined();
}
@@ -24,7 +24,7 @@ static jsi::Value REANIMATED_SPEC_PREFIX(executeOnUIRuntimeSync)(
TurboModule &turboModule,
const jsi::Value *args,
size_t) {
- return static_cast(&turboModule)
+ return static_cast(&turboModule)
->executeOnUIRuntimeSync(rt, std::move(args[0]));
}
@@ -33,7 +33,7 @@ static jsi::Value REANIMATED_SPEC_PREFIX(createWorkletRuntime)(
TurboModule &turboModule,
const jsi::Value *args,
size_t) {
- return static_cast(&turboModule)
+ return static_cast(&turboModule)
->createWorkletRuntime(rt, std::move(args[0]), std::move(args[1]));
}
@@ -42,7 +42,7 @@ static jsi::Value REANIMATED_SPEC_PREFIX(scheduleOnRuntime)(
TurboModule &turboModule,
const jsi::Value *args,
size_t) {
- return static_cast(&turboModule)
+ return static_cast(&turboModule)
->scheduleOnRuntime(rt, std::move(args[0]), std::move(args[1]));
}
@@ -51,7 +51,7 @@ static jsi::Value REANIMATED_SPEC_PREFIX(registerEventHandler)(
TurboModule &turboModule,
const jsi::Value *args,
size_t) {
- return static_cast(&turboModule)
+ return static_cast(&turboModule)
->registerEventHandler(
rt, std::move(args[0]), std::move(args[1]), std::move(args[2]));
}
@@ -61,7 +61,7 @@ static jsi::Value REANIMATED_SPEC_PREFIX(unregisterEventHandler)(
TurboModule &turboModule,
const jsi::Value *args,
size_t) {
- static_cast(&turboModule)
+ static_cast(&turboModule)
->unregisterEventHandler(rt, std::move(args[0]));
return jsi::Value::undefined();
}
@@ -71,7 +71,7 @@ static jsi::Value REANIMATED_SPEC_PREFIX(getViewProp)(
TurboModule &turboModule,
const jsi::Value *args,
size_t) {
- static_cast(&turboModule)
+ static_cast(&turboModule)
->getViewProp(
rt, std::move(args[0]), std::move(args[1]), std::move(args[2]));
return jsi::Value::undefined();
@@ -82,7 +82,7 @@ static jsi::Value REANIMATED_SPEC_PREFIX(enableLayoutAnimations)(
TurboModule &turboModule,
const jsi::Value *args,
size_t) {
- static_cast(&turboModule)
+ static_cast(&turboModule)
->enableLayoutAnimations(rt, std::move(args[0]));
return jsi::Value::undefined();
}
@@ -92,7 +92,7 @@ static jsi::Value REANIMATED_SPEC_PREFIX(registerSensor)(
TurboModule &turboModule,
const jsi::Value *args,
size_t) {
- return static_cast(&turboModule)
+ return static_cast(&turboModule)
->registerSensor(
rt,
std::move(args[0]),
@@ -106,7 +106,7 @@ static jsi::Value REANIMATED_SPEC_PREFIX(unregisterSensor)(
TurboModule &turboModule,
const jsi::Value *args,
size_t) {
- static_cast(&turboModule)
+ static_cast(&turboModule)
->unregisterSensor(rt, std::move(args[0]));
return jsi::Value::undefined();
}
@@ -116,7 +116,7 @@ static jsi::Value REANIMATED_SPEC_PREFIX(configureProps)(
TurboModule &turboModule,
const jsi::Value *args,
size_t) {
- static_cast(&turboModule)
+ static_cast(&turboModule)
->configureProps(rt, std::move(args[0]), std::move(args[1]));
return jsi::Value::undefined();
}
@@ -126,7 +126,7 @@ static jsi::Value REANIMATED_SPEC_PREFIX(subscribeForKeyboardEvents)(
TurboModule &turboModule,
const jsi::Value *args,
size_t) {
- return static_cast(&turboModule)
+ return static_cast(&turboModule)
->subscribeForKeyboardEvents(
rt, std::move(args[0]), std::move(args[1]), std::move(args[2]));
}
@@ -136,7 +136,7 @@ static jsi::Value REANIMATED_SPEC_PREFIX(unsubscribeFromKeyboardEvents)(
TurboModule &turboModule,
const jsi::Value *args,
size_t) {
- static_cast(&turboModule)
+ static_cast(&turboModule)
->unsubscribeFromKeyboardEvents(rt, std::move(args[0]));
return jsi::Value::undefined();
}
@@ -146,7 +146,7 @@ static jsi::Value REANIMATED_SPEC_PREFIX(configureLayoutAnimationBatch)(
TurboModule &turboModule,
const jsi::Value *args,
size_t) {
- return static_cast(&turboModule)
+ return static_cast(&turboModule)
->configureLayoutAnimationBatch(rt, std::move(args[0]));
}
@@ -155,12 +155,12 @@ static jsi::Value REANIMATED_SPEC_PREFIX(setShouldAnimateExiting)(
TurboModule &turboModule,
const jsi::Value *args,
size_t) {
- static_cast(&turboModule)
+ static_cast(&turboModule)
->setShouldAnimateExiting(rt, std::move(args[0]), std::move(args[1]));
return jsi::Value::undefined();
}
-NativeReanimatedModuleSpec::NativeReanimatedModuleSpec(
+ReanimatedModuleProxySpec::ReanimatedModuleProxySpec(
const std::shared_ptr &jsInvoker)
: TurboModule("NativeReanimated", jsInvoker) {
methodMap_["scheduleOnUI"] =
diff --git a/packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModuleSpec.h b/packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h
similarity index 96%
rename from packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModuleSpec.h
rename to packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h
index a9a85ad1a6c..3f82813abff 100644
--- a/packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/NativeReanimatedModuleSpec.h
+++ b/packages/react-native-reanimated/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxySpec.h
@@ -12,9 +12,9 @@ using namespace react;
namespace reanimated {
-class JSI_EXPORT NativeReanimatedModuleSpec : public TurboModule {
+class JSI_EXPORT ReanimatedModuleProxySpec : public TurboModule {
protected:
- explicit NativeReanimatedModuleSpec(
+ explicit ReanimatedModuleProxySpec(
const std::shared_ptr &jsInvoker);
public:
diff --git a/packages/react-native-reanimated/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp b/packages/react-native-reanimated/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp
index 660145a40f7..5bf60c154a8 100644
--- a/packages/react-native-reanimated/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp
+++ b/packages/react-native-reanimated/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp
@@ -5,10 +5,10 @@ namespace reanimated {
void RNRuntimeDecorator::decorate(
jsi::Runtime &rnRuntime,
- const std::shared_ptr &nativeReanimatedModule) {
+ const std::shared_ptr &reanimatedModuleProxy) {
rnRuntime.global().setProperty(rnRuntime, "_WORKLET", false);
- jsi::Runtime &uiRuntime = nativeReanimatedModule->getUIRuntime();
+ jsi::Runtime &uiRuntime = reanimatedModuleProxy->getUIRuntime();
auto workletRuntimeValue =
rnRuntime.global()
.getPropertyAsObject(rnRuntime, "ArrayBuffer")
@@ -29,22 +29,22 @@ void RNRuntimeDecorator::decorate(
rnRuntime.global().setProperty(rnRuntime, "_IS_FABRIC", isFabric);
rnRuntime.global().setProperty(
- rnRuntime, "_IS_BRIDGELESS", nativeReanimatedModule->isBridgeless());
+ rnRuntime, "_IS_BRIDGELESS", reanimatedModuleProxy->isBridgeless());
#ifndef NDEBUG
- checkJSVersion(rnRuntime, nativeReanimatedModule->getJSLogger());
+ checkJSVersion(rnRuntime, reanimatedModuleProxy->getJSLogger());
#endif // NDEBUG
injectReanimatedCppVersion(rnRuntime);
rnRuntime.global().setProperty(
rnRuntime,
"_REANIMATED_IS_REDUCED_MOTION",
- nativeReanimatedModule->isReducedMotion());
+ reanimatedModuleProxy->isReducedMotion());
rnRuntime.global().setProperty(
rnRuntime,
"__reanimatedModuleProxy",
- jsi::Object::createFromHostObject(rnRuntime, nativeReanimatedModule));
+ jsi::Object::createFromHostObject(rnRuntime, reanimatedModuleProxy));
}
} // namespace reanimated
diff --git a/packages/react-native-reanimated/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.h b/packages/react-native-reanimated/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.h
index ff18f2c2dc6..ac568a678b2 100644
--- a/packages/react-native-reanimated/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.h
+++ b/packages/react-native-reanimated/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.h
@@ -1,6 +1,6 @@
#pragma once
-#include
+#include
#include
@@ -14,7 +14,7 @@ class RNRuntimeDecorator {
public:
static void decorate(
jsi::Runtime &rnRuntime,
- const std::shared_ptr &nativeReanimatedModule);
+ const std::shared_ptr &reanimatedModuleProxy);
};
} // namespace reanimated
diff --git a/packages/react-native-reanimated/Common/cpp/reanimated/RuntimeDecorators/ReanimatedWorkletRuntimeDecorator.cpp b/packages/react-native-reanimated/Common/cpp/reanimated/RuntimeDecorators/ReanimatedWorkletRuntimeDecorator.cpp
deleted file mode 100644
index acd03e73677..00000000000
--- a/packages/react-native-reanimated/Common/cpp/reanimated/RuntimeDecorators/ReanimatedWorkletRuntimeDecorator.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-#include
-#include
-
-#include
-#include
-#include
-
-namespace reanimated {
-
-using namespace worklets;
-
-void ReanimatedWorkletRuntimeDecorator::decorate(jsi::Runtime &rt) {
- jsi_utils::installJsiFunction(
- rt, "_log", [](jsi::Runtime &rt, const jsi::Value &value) {
- PlatformLogger::log(stringifyJSIValue(rt, value));
- });
-}
-
-} // namespace reanimated
diff --git a/packages/react-native-reanimated/Common/cpp/reanimated/RuntimeDecorators/ReanimatedWorkletRuntimeDecorator.h b/packages/react-native-reanimated/Common/cpp/reanimated/RuntimeDecorators/ReanimatedWorkletRuntimeDecorator.h
deleted file mode 100644
index da7f2a923cd..00000000000
--- a/packages/react-native-reanimated/Common/cpp/reanimated/RuntimeDecorators/ReanimatedWorkletRuntimeDecorator.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#pragma once
-
-#include
-
-using namespace facebook;
-
-namespace reanimated {
-
-class ReanimatedWorkletRuntimeDecorator {
- public:
- static void decorate(jsi::Runtime &rt);
-};
-
-} // namespace reanimated
diff --git a/packages/react-native-reanimated/Common/cpp/worklets/NativeModules/NativeWorkletsModule.h b/packages/react-native-reanimated/Common/cpp/worklets/NativeModules/NativeWorkletsModule.h
deleted file mode 100644
index 5912056fb16..00000000000
--- a/packages/react-native-reanimated/Common/cpp/worklets/NativeModules/NativeWorkletsModule.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#pragma once
-
-#include
-#include
-#include
-#include
-
-namespace worklets {
-
-class NativeWorkletsModule : public NativeWorkletsModuleSpec {
- public:
- explicit NativeWorkletsModule(const std::string &valueUnpackerCode);
-
- ~NativeWorkletsModule();
-
- jsi::Value makeShareableClone(
- jsi::Runtime &rt,
- const jsi::Value &value,
- const jsi::Value &shouldRetainRemote,
- const jsi::Value &nativeStateSource) override;
-
- [[nodiscard]] inline std::string getValueUnpackerCode() const {
- return valueUnpackerCode_;
- }
-
- private:
- const std::string valueUnpackerCode_;
-#ifndef NDEBUG
- SingleInstanceChecker singleInstanceChecker_;
-#endif // NDEBUG
-};
-
-} // namespace worklets
diff --git a/packages/react-native-reanimated/Common/cpp/worklets/NativeModules/NativeWorkletsModule.cpp b/packages/react-native-reanimated/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp
similarity index 52%
rename from packages/react-native-reanimated/Common/cpp/worklets/NativeModules/NativeWorkletsModule.cpp
rename to packages/react-native-reanimated/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp
index 80270752948..e71837b1199 100644
--- a/packages/react-native-reanimated/Common/cpp/worklets/NativeModules/NativeWorkletsModule.cpp
+++ b/packages/react-native-reanimated/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp
@@ -5,7 +5,7 @@
#include
#endif // RCT_NEW_ARCH_ENABLED
-#include
+#include
#include
#ifdef __ANDROID__
@@ -18,13 +18,21 @@ using namespace facebook;
namespace worklets {
-NativeWorkletsModule::NativeWorkletsModule(const std::string &valueUnpackerCode)
- : NativeWorkletsModuleSpec(nullptr),
- valueUnpackerCode_(valueUnpackerCode) {}
-
-NativeWorkletsModule::~NativeWorkletsModule() {}
-
-jsi::Value NativeWorkletsModule::makeShareableClone(
+WorkletsModuleProxy::WorkletsModuleProxy(
+ const std::string &valueUnpackerCode,
+ const std::shared_ptr &jsQueue,
+ const std::shared_ptr &jsCallInvoker,
+ const std::shared_ptr &jsScheduler,
+ const std::shared_ptr &uiScheduler)
+ : WorkletsModuleProxySpec(jsCallInvoker),
+ valueUnpackerCode_(valueUnpackerCode),
+ jsQueue_(jsQueue),
+ jsScheduler_(jsScheduler),
+ uiScheduler_(uiScheduler) {}
+
+WorkletsModuleProxy::~WorkletsModuleProxy() {}
+
+jsi::Value WorkletsModuleProxy::makeShareableClone(
jsi::Runtime &rt,
const jsi::Value &value,
const jsi::Value &shouldRetainRemote,
diff --git a/packages/react-native-reanimated/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h b/packages/react-native-reanimated/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h
new file mode 100644
index 00000000000..dc7cee4cf27
--- /dev/null
+++ b/packages/react-native-reanimated/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h
@@ -0,0 +1,57 @@
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace worklets {
+
+class WorkletsModuleProxy : public WorkletsModuleProxySpec {
+ public:
+ explicit WorkletsModuleProxy(
+ const std::string &valueUnpackerCode,
+ const std::shared_ptr &jsQueue,
+ const std::shared_ptr &jsCallInvoker,
+ const std::shared_ptr &jsScheduler,
+ const std::shared_ptr &uiScheduler);
+
+ ~WorkletsModuleProxy();
+
+ jsi::Value makeShareableClone(
+ jsi::Runtime &rt,
+ const jsi::Value &value,
+ const jsi::Value &shouldRetainRemote,
+ const jsi::Value &nativeStateSource) override;
+
+ [[nodiscard]] inline std::string getValueUnpackerCode() const {
+ return valueUnpackerCode_;
+ }
+
+ [[nodiscard]] inline std::shared_ptr getJSQueue() const {
+ return jsQueue_;
+ }
+
+ [[nodiscard]] inline std::shared_ptr getJSScheduler() const {
+ return jsScheduler_;
+ }
+
+ [[nodiscard]] inline std::shared_ptr getUIScheduler() const {
+ return uiScheduler_;
+ }
+
+ private:
+ const std::string valueUnpackerCode_;
+ const std::shared_ptr jsQueue_;
+ const std::shared_ptr jsScheduler_;
+ const std::shared_ptr uiScheduler_;
+#ifndef NDEBUG
+ SingleInstanceChecker singleInstanceChecker_;
+#endif // NDEBUG
+};
+
+} // namespace worklets
diff --git a/packages/react-native-reanimated/Common/cpp/worklets/NativeModules/NativeWorkletsModuleSpec.cpp b/packages/react-native-reanimated/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.cpp
similarity index 71%
rename from packages/react-native-reanimated/Common/cpp/worklets/NativeModules/NativeWorkletsModuleSpec.cpp
rename to packages/react-native-reanimated/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.cpp
index 95f05ac8036..624c42ee224 100644
--- a/packages/react-native-reanimated/Common/cpp/worklets/NativeModules/NativeWorkletsModuleSpec.cpp
+++ b/packages/react-native-reanimated/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.cpp
@@ -1,9 +1,9 @@
-#include
+#include
#include
#define WORKLETS_SPEC_PREFIX(FN_NAME) \
- __hostFunction_NativeWorkletsModuleSpec_##FN_NAME
+ __hostFunction_WorkletsModuleProxySpec_##FN_NAME
namespace worklets {
@@ -12,12 +12,12 @@ static jsi::Value WORKLETS_SPEC_PREFIX(makeShareableClone)(
TurboModule &turboModule,
const jsi::Value *args,
size_t) {
- return static_cast(&turboModule)
+ return static_cast(&turboModule)
->makeShareableClone(
rt, std::move(args[0]), std::move(args[1]), std::move(args[2]));
}
-NativeWorkletsModuleSpec::NativeWorkletsModuleSpec(
+WorkletsModuleProxySpec::WorkletsModuleProxySpec(
const std::shared_ptr jsInvoker)
: TurboModule("NativeWorklets", jsInvoker) {
methodMap_["makeShareableClone"] =
diff --git a/packages/react-native-reanimated/Common/cpp/worklets/NativeModules/NativeWorkletsModuleSpec.h b/packages/react-native-reanimated/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.h
similarity index 82%
rename from packages/react-native-reanimated/Common/cpp/worklets/NativeModules/NativeWorkletsModuleSpec.h
rename to packages/react-native-reanimated/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.h
index 1c1d622e17c..c79a86b908f 100644
--- a/packages/react-native-reanimated/Common/cpp/worklets/NativeModules/NativeWorkletsModuleSpec.h
+++ b/packages/react-native-reanimated/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.h
@@ -9,9 +9,9 @@ using namespace react;
namespace worklets {
-class JSI_EXPORT NativeWorkletsModuleSpec : public TurboModule {
+class JSI_EXPORT WorkletsModuleProxySpec : public TurboModule {
protected:
- explicit NativeWorkletsModuleSpec(
+ explicit WorkletsModuleProxySpec(
const std::shared_ptr jsInvoker);
public:
diff --git a/packages/react-native-reanimated/Common/cpp/worklets/SharedItems/Shareables.cpp b/packages/react-native-reanimated/Common/cpp/worklets/SharedItems/Shareables.cpp
index 525cd114ebb..f8c5bfc1366 100644
--- a/packages/react-native-reanimated/Common/cpp/worklets/SharedItems/Shareables.cpp
+++ b/packages/react-native-reanimated/Common/cpp/worklets/SharedItems/Shareables.cpp
@@ -47,7 +47,12 @@ jsi::Value makeShareableClone(
if (value.isObject()) {
auto object = value.asObject(rt);
if (!object.getProperty(rt, "__workletHash").isUndefined()) {
- shareable = std::make_shared(rt, object);
+ if (shouldRetainRemote.isBool() && shouldRetainRemote.getBool()) {
+ shareable =
+ std::make_shared>(rt, object);
+ } else {
+ shareable = std::make_shared(rt, object);
+ }
} else if (!object.getProperty(rt, "__init").isUndefined()) {
shareable = std::make_shared(rt, object);
} else if (object.isFunction(rt)) {
@@ -284,7 +289,12 @@ jsi::Value ShareableHandle::toJSValue(jsi::Runtime &rt) {
remoteRuntime_ = &rt;
}
}
- return jsi::Value(rt, *remoteValue_);
+ if (&rt == remoteRuntime_) {
+ return jsi::Value(rt, *remoteValue_);
+ }
+ auto initObj = initializer_->toJSValue(rt);
+ return getValueUnpacker(rt).call(
+ rt, initObj, jsi::String::createFromAscii(rt, "Handle"));
}
jsi::Value ShareableString::toJSValue(jsi::Runtime &rt) {
diff --git a/packages/react-native-reanimated/Common/cpp/worklets/Tools/JSScheduler.cpp b/packages/react-native-reanimated/Common/cpp/worklets/Tools/JSScheduler.cpp
index 0699e0cebaa..b3f227ed409 100644
--- a/packages/react-native-reanimated/Common/cpp/worklets/Tools/JSScheduler.cpp
+++ b/packages/react-native-reanimated/Common/cpp/worklets/Tools/JSScheduler.cpp
@@ -17,24 +17,4 @@ JSScheduler::JSScheduler(
rnRuntime_(rnRuntime),
jsCallInvoker_(jsCallInvoker) {}
-#ifdef RCT_NEW_ARCH_ENABLED
-// With `runtimeExecutor`.
-JSScheduler::JSScheduler(
- jsi::Runtime &rnRuntime,
- RuntimeExecutor runtimeExecutor)
- : scheduleOnJS([&](Job job) {
- runtimeExecutor_(
- [job = std::move(job)](jsi::Runtime &runtime) { job(runtime); });
- }),
- rnRuntime_(rnRuntime),
- runtimeExecutor_(runtimeExecutor) {}
-#endif // RCT_NEW_ARCH_ENABLED
-
-const std::shared_ptr JSScheduler::getJSCallInvoker() const {
- assert(
- jsCallInvoker_ != nullptr &&
- "[Reanimated] Expected jsCallInvoker, got nullptr instead.");
- return jsCallInvoker_;
-}
-
} // namespace worklets
diff --git a/packages/react-native-reanimated/Common/cpp/worklets/Tools/JSScheduler.h b/packages/react-native-reanimated/Common/cpp/worklets/Tools/JSScheduler.h
index 84eaa512d81..c85ab8a9673 100644
--- a/packages/react-native-reanimated/Common/cpp/worklets/Tools/JSScheduler.h
+++ b/packages/react-native-reanimated/Common/cpp/worklets/Tools/JSScheduler.h
@@ -15,26 +15,14 @@ class JSScheduler {
using Job = std::function;
public:
- // With `jsCallInvoker`.
explicit JSScheduler(
jsi::Runtime &rnRuntime,
const std::shared_ptr &jsCallInvoker);
-#ifdef RCT_NEW_ARCH_ENABLED
- // With `runtimeExecutor`.
- explicit JSScheduler(
- jsi::Runtime &rnRuntime,
- RuntimeExecutor runtimeExecutor);
-#endif // RCT_NEW_ARCH_ENABLED
-
const std::function scheduleOnJS = nullptr;
- const std::shared_ptr getJSCallInvoker() const;
protected:
jsi::Runtime &rnRuntime_;
-#ifdef RCT_NEW_ARCH_ENABLED
- RuntimeExecutor runtimeExecutor_ = nullptr;
-#endif // RCT_NEW_ARCH_ENABLED
const std::shared_ptr jsCallInvoker_ = nullptr;
};
diff --git a/packages/react-native-reanimated/Common/cpp/reanimated/Tools/PlatformLogger.h b/packages/react-native-reanimated/Common/cpp/worklets/Tools/PlatformLogger.h
similarity index 83%
rename from packages/react-native-reanimated/Common/cpp/reanimated/Tools/PlatformLogger.h
rename to packages/react-native-reanimated/Common/cpp/worklets/Tools/PlatformLogger.h
index 37db18e3326..de58cb93098 100644
--- a/packages/react-native-reanimated/Common/cpp/reanimated/Tools/PlatformLogger.h
+++ b/packages/react-native-reanimated/Common/cpp/worklets/Tools/PlatformLogger.h
@@ -2,7 +2,7 @@
#include
-namespace reanimated {
+namespace worklets {
class PlatformLogger {
public:
@@ -13,4 +13,4 @@ class PlatformLogger {
static void log(const bool b);
};
-} // namespace reanimated
+} // namespace worklets
diff --git a/packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp b/packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp
index 37565314534..8575570f72b 100644
--- a/packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp
+++ b/packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp
@@ -4,11 +4,11 @@ namespace worklets {
void RNRuntimeWorkletDecorator::decorate(
jsi::Runtime &rnRuntime,
- const std::shared_ptr &nativeWorkletsModule) {
+ const std::shared_ptr &workletsModuleProxy) {
rnRuntime.global().setProperty(
rnRuntime,
"__workletsModuleProxy",
- jsi::Object::createFromHostObject(rnRuntime, nativeWorkletsModule));
+ jsi::Object::createFromHostObject(rnRuntime, workletsModuleProxy));
}
} // namespace worklets
diff --git a/packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h b/packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h
index 9884e71091a..41cf12b5598 100644
--- a/packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h
+++ b/packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h
@@ -1,7 +1,7 @@
#pragma once
#include
-#include
+#include
#include
using namespace facebook;
@@ -13,7 +13,7 @@ class RNRuntimeWorkletDecorator {
public:
static void decorate(
jsi::Runtime &rnRuntime,
- const std::shared_ptr &nativeWorkletsModule);
+ const std::shared_ptr &workletsModuleProxy);
};
} // namespace worklets
diff --git a/packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp b/packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp
index 07caee39767..4d677927155 100644
--- a/packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp
+++ b/packages/react-native-reanimated/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp
@@ -1,5 +1,6 @@
#include
#include
+#include
#include
#include
#include
@@ -76,6 +77,11 @@ void WorkletRuntimeDecorator::decorate(
evalWithSourceUrl));
#endif // NDEBUG
+ jsi_utils::installJsiFunction(
+ rt, "_log", [](jsi::Runtime &rt, const jsi::Value &value) {
+ PlatformLogger::log(stringifyJSIValue(rt, value));
+ });
+
jsi_utils::installJsiFunction(
rt, "_toString", [](jsi::Runtime &rt, const jsi::Value &value) {
return jsi::String::createFromUtf8(rt, stringifyJSIValue(rt, value));
diff --git a/packages/react-native-reanimated/android/build.gradle b/packages/react-native-reanimated/android/build.gradle
index a35ae1fcdf7..c98d195f462 100644
--- a/packages/react-native-reanimated/android/build.gradle
+++ b/packages/react-native-reanimated/android/build.gradle
@@ -362,22 +362,6 @@ android {
}
}
- if (IS_NEW_ARCHITECTURE_ENABLED) {
- // RuntimeExecutor and CallInvokerHolder
- if (REACT_NATIVE_MINOR_VERSION <= 74) {
- srcDirs += "src/reactNativeVersionPatch/NativeProxyFabric/74"
- } else {
- srcDirs += "src/reactNativeVersionPatch/NativeProxyFabric/latest"
- }
- } else {
- // CallInvokerHolder
- if (REACT_NATIVE_MINOR_VERSION <= 74) {
- srcDirs += "src/reactNativeVersionPatch/NativeProxyPaper/74"
- } else {
- srcDirs += "src/reactNativeVersionPatch/NativeProxyPaper/latest"
- }
- }
-
// BorderRadiiDrawableUtils
if (REACT_NATIVE_MINOR_VERSION <= 74) {
srcDirs += "src/reactNativeVersionPatch/BorderRadiiDrawableUtils/74"
diff --git a/packages/react-native-reanimated/android/src/reactNativeVersionPatch/NativeProxyFabric/74/com/swmansion/reanimated/NativeProxy.java b/packages/react-native-reanimated/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java
similarity index 65%
rename from packages/react-native-reanimated/android/src/reactNativeVersionPatch/NativeProxyFabric/74/com/swmansion/reanimated/NativeProxy.java
rename to packages/react-native-reanimated/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java
index 1f732ab91f1..1701b938ca4 100644
--- a/packages/react-native-reanimated/android/src/reactNativeVersionPatch/NativeProxyFabric/74/com/swmansion/reanimated/NativeProxy.java
+++ b/packages/react-native-reanimated/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java
@@ -4,8 +4,6 @@
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.ReactApplicationContext;
-import com.facebook.react.bridge.RuntimeExecutor;
-import com.facebook.react.bridge.queue.MessageQueueThread;
import com.facebook.react.common.annotations.FrameworkAPI;
import com.facebook.react.fabric.FabricUIManager;
import com.facebook.react.turbomodule.core.CallInvokerHolderImpl;
@@ -14,10 +12,14 @@
import com.swmansion.reanimated.layoutReanimation.LayoutAnimations;
import com.swmansion.reanimated.layoutReanimation.NativeMethodsHolder;
import com.swmansion.reanimated.nativeProxy.NativeProxyCommon;
+import com.swmansion.worklets.JSCallInvokerResolver;
import com.swmansion.worklets.WorkletsModule;
import java.util.HashMap;
import java.util.Objects;
+/**
+ * @noinspection JavaJniMissingFunction
+ */
public class NativeProxy extends NativeProxyCommon {
@DoNotStrip
@SuppressWarnings("unused")
@@ -33,32 +35,16 @@ public class NativeProxy extends NativeProxyCommon {
LayoutAnimations LayoutAnimations = new LayoutAnimations(context);
- ReanimatedMessageQueueThread messageQueueThread = new ReanimatedMessageQueueThread();
-
- if (context.isBridgeless()) {
- RuntimeExecutor runtimeExecutor = context.getRuntimeExecutor();
- mHybridData =
- initHybridBridgeless(
- workletsModule,
- Objects.requireNonNull(context.getJavaScriptContextHolder()).get(),
- runtimeExecutor,
- mAndroidUIScheduler,
- LayoutAnimations,
- messageQueueThread,
- fabricUIManager);
- } else {
- CallInvokerHolderImpl callInvokerHolder =
- (CallInvokerHolderImpl) context.getCatalystInstance().getJSCallInvokerHolder();
- mHybridData =
- initHybrid(
- workletsModule,
- Objects.requireNonNull(context.getJavaScriptContextHolder()).get(),
- callInvokerHolder,
- mAndroidUIScheduler,
- LayoutAnimations,
- messageQueueThread,
- fabricUIManager);
- }
+ CallInvokerHolderImpl callInvokerHolder = JSCallInvokerResolver.getJSCallInvokerHolder(context);
+ mHybridData =
+ initHybrid(
+ workletsModule,
+ Objects.requireNonNull(context.getJavaScriptContextHolder()).get(),
+ callInvokerHolder,
+ LayoutAnimations,
+ context.isBridgeless(),
+ fabricUIManager);
+
prepareLayoutAnimations(LayoutAnimations);
installJSIBindings();
if (BuildConfig.DEBUG) {
@@ -66,22 +52,13 @@ public class NativeProxy extends NativeProxyCommon {
}
}
+ @OptIn(markerClass = FrameworkAPI.class)
private native HybridData initHybrid(
WorkletsModule workletsModule,
long jsContext,
CallInvokerHolderImpl jsCallInvokerHolder,
- AndroidUIScheduler androidUIScheduler,
- LayoutAnimations LayoutAnimations,
- MessageQueueThread messageQueueThread,
- FabricUIManager fabricUIManager);
-
- private native HybridData initHybridBridgeless(
- WorkletsModule workletsModule,
- long jsContext,
- RuntimeExecutor runtimeExecutor,
- AndroidUIScheduler androidUIScheduler,
LayoutAnimations LayoutAnimations,
- MessageQueueThread messageQueueThread,
+ boolean isBridgeless,
FabricUIManager fabricUIManager);
public native boolean isAnyHandlerWaitingForEvent(String eventName, int emitterReactTag);
@@ -93,7 +70,8 @@ protected HybridData getHybridData() {
return mHybridData;
}
- public static NativeMethodsHolder createNativeMethodsHolder(LayoutAnimations layoutAnimations) {
+ public static NativeMethodsHolder createNativeMethodsHolder(
+ LayoutAnimations ignoredLayoutAnimations) {
return new NativeMethodsHolder() {
@Override
public void startAnimation(int tag, int type, HashMap values) {
diff --git a/packages/react-native-reanimated/android/src/main/cpp/reanimated/android/NativeProxy.cpp b/packages/react-native-reanimated/android/src/main/cpp/reanimated/android/NativeProxy.cpp
index 42b1f21ce14..8b9c4753320 100644
--- a/packages/react-native-reanimated/android/src/main/cpp/reanimated/android/NativeProxy.cpp
+++ b/packages/react-native-reanimated/android/src/main/cpp/reanimated/android/NativeProxy.cpp
@@ -1,7 +1,6 @@
#include
#include
#include
-#include
#include
#include
@@ -9,12 +8,12 @@
#include
#include
#include
+#include
#include
#include
#include
#include
-#include
#include
#include
@@ -29,12 +28,11 @@ using namespace react;
NativeProxy::NativeProxy(
jni::alias_ref jThis,
- const std::shared_ptr &nativeWorkletsModule,
+ const std::shared_ptr &workletsModuleProxy,
jsi::Runtime *rnRuntime,
const std::shared_ptr &jsCallInvoker,
- const std::shared_ptr &uiScheduler,
jni::global_ref layoutAnimations,
- jni::alias_ref messageQueueThread
+ const bool isBridgeless
#ifdef RCT_NEW_ARCH_ENABLED
,
jni::alias_ref
@@ -43,14 +41,12 @@ NativeProxy::NativeProxy(
)
: javaPart_(jni::make_global(jThis)),
rnRuntime_(rnRuntime),
- nativeReanimatedModule_(std::make_shared(
- nativeWorkletsModule,
+ reanimatedModuleProxy_(std::make_shared(
+ workletsModuleProxy,
*rnRuntime,
- std::make_shared(*rnRuntime, jsCallInvoker),
- std::make_shared(messageQueueThread),
- uiScheduler,
+ jsCallInvoker,
getPlatformDependentMethods(),
- /* isBridgeless */ false,
+ isBridgeless,
getIsReducedMotion())),
layoutAnimations_(std::move(layoutAnimations)) {
#ifdef RCT_NEW_ARCH_ENABLED
@@ -59,42 +55,17 @@ NativeProxy::NativeProxy(
}
#ifdef RCT_NEW_ARCH_ENABLED
-NativeProxy::NativeProxy(
- jni::alias_ref jThis,
- const std::shared_ptr &nativeWorkletsModule,
- jsi::Runtime *rnRuntime,
- RuntimeExecutor runtimeExecutor,
- const std::shared_ptr &uiScheduler,
- jni::global_ref layoutAnimations,
- jni::alias_ref messageQueueThread,
- jni::alias_ref
- fabricUIManager)
- : javaPart_(jni::make_global(jThis)),
- rnRuntime_(rnRuntime),
- nativeReanimatedModule_(std::make_shared(
- nativeWorkletsModule,
- *rnRuntime,
- std::make_shared(*rnRuntime, runtimeExecutor),
- std::make_shared(messageQueueThread),
- uiScheduler,
- getPlatformDependentMethods(),
- /* isBridgeless */ true,
- getIsReducedMotion())),
- layoutAnimations_(std::move(layoutAnimations)) {
- commonInit(fabricUIManager);
-}
-
void NativeProxy::commonInit(
jni::alias_ref
&fabricUIManager) {
const auto &uiManager =
fabricUIManager->getBinding()->getScheduler()->getUIManager();
- nativeReanimatedModule_->initializeFabric(uiManager);
+ reanimatedModuleProxy_->initializeFabric(uiManager);
// removed temporarily, event listener mechanism needs to be fixed on RN side
// eventListener_ = std::make_shared(
- // [nativeReanimatedModule,
+ // [reanimatedModuleProxy,
// getAnimationTimestamp](const RawEvent &rawEvent) {
- // return nativeReanimatedModule->handleRawEvent(
+ // return reanimatedModuleProxy->handleRawEvent(
// rawEvent, getAnimationTimestamp());
// });
// reactScheduler_ = binding->getScheduler();
@@ -109,7 +80,7 @@ NativeProxy::~NativeProxy() {
// cleanup all animated sensors here, since NativeProxy
// has already been destroyed when AnimatedSensorModule's
// destructor is ran
- nativeReanimatedModule_->cleanupSensors();
+ reanimatedModuleProxy_->cleanupSensors();
}
jni::local_ref NativeProxy::initHybrid(
@@ -118,9 +89,8 @@ jni::local_ref NativeProxy::initHybrid(
jlong jsContext,
jni::alias_ref
jsCallInvokerHolder,
- jni::alias_ref androidUiScheduler,
jni::alias_ref layoutAnimations,
- jni::alias_ref messageQueueThread
+ bool isBridgeless
#ifdef RCT_NEW_ARCH_ENABLED
,
jni::alias_ref
@@ -128,17 +98,14 @@ jni::local_ref NativeProxy::initHybrid(
#endif
) {
auto jsCallInvoker = jsCallInvokerHolder->cthis()->getCallInvoker();
- auto uiScheduler = androidUiScheduler->cthis()->getUIScheduler();
- auto nativeWorkletsModule =
- jWorkletsModule->cthis()->getNativeWorkletsModule();
+ auto workletsModuleProxy = jWorkletsModule->cthis()->getWorkletsModuleProxy();
return makeCxxInstance(
jThis,
- nativeWorkletsModule,
+ workletsModuleProxy,
(jsi::Runtime *)jsContext,
jsCallInvoker,
- uiScheduler,
make_global(layoutAnimations),
- messageQueueThread
+ isBridgeless
#ifdef RCT_NEW_ARCH_ENABLED
,
fabricUIManager
@@ -146,33 +113,6 @@ jni::local_ref NativeProxy::initHybrid(
);
}
-#ifdef RCT_NEW_ARCH_ENABLED
-jni::local_ref NativeProxy::initHybridBridgeless(
- jni::alias_ref jThis,
- jni::alias_ref jWorkletsModule,
- jlong jsContext,
- jni::alias_ref runtimeExecutorHolder,
- jni::alias_ref androidUiScheduler,
- jni::alias_ref layoutAnimations,
- jni::alias_ref messageQueueThread,
- jni::alias_ref
- fabricUIManager) {
- auto uiScheduler = androidUiScheduler->cthis()->getUIScheduler();
- auto runtimeExecutor = runtimeExecutorHolder->cthis()->get();
- auto nativeWorkletsModule =
- jWorkletsModule->cthis()->getNativeWorkletsModule();
- return makeCxxInstance(
- jThis,
- nativeWorkletsModule,
- (jsi::Runtime *)jsContext,
- runtimeExecutor,
- uiScheduler,
- make_global(layoutAnimations),
- messageQueueThread,
- fabricUIManager);
-}
-#endif // RCT_NEW_ARCH_ENABLED
-
#ifndef NDEBUG
void NativeProxy::checkJavaVersion(jsi::Runtime &rnRuntime) {
std::string javaVersion;
@@ -215,7 +155,7 @@ void NativeProxy::injectCppVersion() {
void NativeProxy::installJSIBindings() {
jsi::Runtime &rnRuntime = *rnRuntime_;
WorkletRuntimeCollector::install(rnRuntime);
- RNRuntimeDecorator::decorate(rnRuntime, nativeReanimatedModule_);
+ RNRuntimeDecorator::decorate(rnRuntime, reanimatedModuleProxy_);
#ifndef NDEBUG
checkJavaVersion(rnRuntime);
injectCppVersion();
@@ -228,13 +168,13 @@ void NativeProxy::installJSIBindings() {
bool NativeProxy::isAnyHandlerWaitingForEvent(
const std::string &eventName,
const int emitterReactTag) {
- return nativeReanimatedModule_->isAnyHandlerWaitingForEvent(
+ return reanimatedModuleProxy_->isAnyHandlerWaitingForEvent(
eventName, emitterReactTag);
}
void NativeProxy::performOperations() {
#ifdef RCT_NEW_ARCH_ENABLED
- nativeReanimatedModule_->performOperations();
+ reanimatedModuleProxy_->performOperations();
#endif
}
@@ -246,10 +186,6 @@ bool NativeProxy::getIsReducedMotion() {
void NativeProxy::registerNatives() {
registerHybrid(
{makeNativeMethod("initHybrid", NativeProxy::initHybrid),
-#ifdef RCT_NEW_ARCH_ENABLED
- makeNativeMethod(
- "initHybridBridgeless", NativeProxy::initHybridBridgeless),
-#endif // RCT_NEW_ARCH_ENABLED
makeNativeMethod("installJSIBindings", NativeProxy::installJSIBindings),
makeNativeMethod(
"isAnyHandlerWaitingForEvent",
@@ -471,7 +407,7 @@ void NativeProxy::handleEvent(
return;
}
- jsi::Runtime &rt = nativeReanimatedModule_->getUIRuntime();
+ jsi::Runtime &rt = reanimatedModuleProxy_->getUIRuntime();
jsi::Value payload;
try {
payload = jsi::Value::createFromJsonUtf8(
@@ -481,7 +417,7 @@ void NativeProxy::handleEvent(
return;
}
- nativeReanimatedModule_->handleEvent(
+ reanimatedModuleProxy_->handleEvent(
eventName->toString(), emitterReactTag, payload, getAnimationTimestamp());
}
@@ -567,14 +503,14 @@ PlatformDepMethodsHolder NativeProxy::getPlatformDependentMethods() {
}
void NativeProxy::setupLayoutAnimations() {
- auto weakNativeReanimatedModule =
- std::weak_ptr(nativeReanimatedModule_);
+ auto weakReanimatedModuleProxy =
+ std::weak_ptr(reanimatedModuleProxy_);
layoutAnimations_->cthis()->setAnimationStartingBlock(
- [weakNativeReanimatedModule](
+ [weakReanimatedModuleProxy](
int tag, int type, alias_ref> values) {
- if (auto nativeReanimatedModule = weakNativeReanimatedModule.lock()) {
- jsi::Runtime &rt = nativeReanimatedModule->getUIRuntime();
+ if (auto reanimatedModuleProxy = weakReanimatedModuleProxy.lock()) {
+ jsi::Runtime &rt = reanimatedModuleProxy->getUIRuntime();
jsi::Object yogaValues(rt);
for (const auto &entry : *values) {
try {
@@ -595,25 +531,24 @@ void NativeProxy::setupLayoutAnimations() {
"[Reanimated] Failed to convert value to number.");
}
}
- nativeReanimatedModule->layoutAnimationsManager()
- .startLayoutAnimation(
- rt, tag, static_cast(type), yogaValues);
+ reanimatedModuleProxy->layoutAnimationsManager().startLayoutAnimation(
+ rt, tag, static_cast(type), yogaValues);
}
});
layoutAnimations_->cthis()->setHasAnimationBlock(
- [weakNativeReanimatedModule](int tag, int type) {
- if (auto nativeReanimatedModule = weakNativeReanimatedModule.lock()) {
- return nativeReanimatedModule->layoutAnimationsManager()
+ [weakReanimatedModuleProxy](int tag, int type) {
+ if (auto reanimatedModuleProxy = weakReanimatedModuleProxy.lock()) {
+ return reanimatedModuleProxy->layoutAnimationsManager()
.hasLayoutAnimation(tag, static_cast(type));
}
return false;
});
layoutAnimations_->cthis()->setShouldAnimateExitingBlock(
- [weakNativeReanimatedModule](int tag, bool shouldAnimate) {
- if (auto nativeReanimatedModule = weakNativeReanimatedModule.lock()) {
- return nativeReanimatedModule->layoutAnimationsManager()
+ [weakReanimatedModuleProxy](int tag, bool shouldAnimate) {
+ if (auto reanimatedModuleProxy = weakReanimatedModuleProxy.lock()) {
+ return reanimatedModuleProxy->layoutAnimationsManager()
.shouldAnimateExiting(tag, shouldAnimate);
}
return false;
@@ -621,35 +556,35 @@ void NativeProxy::setupLayoutAnimations() {
#ifndef NDEBUG
layoutAnimations_->cthis()->setCheckDuplicateSharedTag(
- [weakNativeReanimatedModule](int viewTag, int screenTag) {
- if (auto nativeReanimatedModule = weakNativeReanimatedModule.lock()) {
- nativeReanimatedModule->layoutAnimationsManager()
+ [weakReanimatedModuleProxy](int viewTag, int screenTag) {
+ if (auto reanimatedModuleProxy = weakReanimatedModuleProxy.lock()) {
+ reanimatedModuleProxy->layoutAnimationsManager()
.checkDuplicateSharedTag(viewTag, screenTag);
}
});
#endif
layoutAnimations_->cthis()->setClearAnimationConfigBlock(
- [weakNativeReanimatedModule](int tag) {
- if (auto nativeReanimatedModule = weakNativeReanimatedModule.lock()) {
- nativeReanimatedModule->layoutAnimationsManager()
+ [weakReanimatedModuleProxy](int tag) {
+ if (auto reanimatedModuleProxy = weakReanimatedModuleProxy.lock()) {
+ reanimatedModuleProxy->layoutAnimationsManager()
.clearLayoutAnimationConfig(tag);
}
});
layoutAnimations_->cthis()->setCancelAnimationForTag(
- [weakNativeReanimatedModule](int tag) {
- if (auto nativeReanimatedModule = weakNativeReanimatedModule.lock()) {
- jsi::Runtime &rt = nativeReanimatedModule->getUIRuntime();
- nativeReanimatedModule->layoutAnimationsManager()
+ [weakReanimatedModuleProxy](int tag) {
+ if (auto reanimatedModuleProxy = weakReanimatedModuleProxy.lock()) {
+ jsi::Runtime &rt = reanimatedModuleProxy->getUIRuntime();
+ reanimatedModuleProxy->layoutAnimationsManager()
.cancelLayoutAnimation(rt, tag);
}
});
layoutAnimations_->cthis()->setFindPrecedingViewTagForTransition(
- [weakNativeReanimatedModule](int tag) {
- if (auto nativeReanimatedModule = weakNativeReanimatedModule.lock()) {
- return nativeReanimatedModule->layoutAnimationsManager()
+ [weakReanimatedModuleProxy](int tag) {
+ if (auto reanimatedModuleProxy = weakReanimatedModuleProxy.lock()) {
+ return reanimatedModuleProxy->layoutAnimationsManager()
.findPrecedingViewTagForTransition(tag);
} else {
return -1;
@@ -657,9 +592,9 @@ void NativeProxy::setupLayoutAnimations() {
});
layoutAnimations_->cthis()->setGetSharedGroupBlock(
- [weakNativeReanimatedModule](int tag) -> std::vector {
- if (auto nativeReanimatedModule = weakNativeReanimatedModule.lock()) {
- return nativeReanimatedModule->layoutAnimationsManager()
+ [weakReanimatedModuleProxy](int tag) -> std::vector {
+ if (auto reanimatedModuleProxy = weakReanimatedModuleProxy.lock()) {
+ return reanimatedModuleProxy->layoutAnimationsManager()
.getSharedGroup(tag);
} else {
return {};
diff --git a/packages/react-native-reanimated/android/src/main/cpp/reanimated/android/NativeProxy.h b/packages/react-native-reanimated/android/src/main/cpp/reanimated/android/NativeProxy.h
index 1f2ac757987..318e3acf7a7 100644
--- a/packages/react-native-reanimated/android/src/main/cpp/reanimated/android/NativeProxy.h
+++ b/packages/react-native-reanimated/android/src/main/cpp/reanimated/android/NativeProxy.h
@@ -1,18 +1,15 @@
#pragma once
-#include
-#include
+#include
#include
#include
-#include
#include
#include
#include
#include
#include
-#include
#include
#include
@@ -154,9 +151,8 @@ class NativeProxy : public jni::HybridClass {
jlong jsContext,
jni::alias_ref
jsCallInvokerHolder,
- jni::alias_ref androidUiScheduler,
jni::alias_ref layoutAnimations,
- jni::alias_ref messageQueueThread
+ const bool isBridgeless
#ifdef RCT_NEW_ARCH_ENABLED
,
jni::alias_ref