Skip to content

Commit

Permalink
chore: Remove dead code for RN 73 and below (#6658)
Browse files Browse the repository at this point in the history
## Summary

## Test plan
  • Loading branch information
tjzel authored Nov 11, 2024
1 parent dfb1cf4 commit f3597c8
Show file tree
Hide file tree
Showing 34 changed files with 54 additions and 1,146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class ReanimatedCommitHook : public UIManagerCommitHook {

~ReanimatedCommitHook() noexcept override;

#if REACT_NATIVE_MINOR_VERSION >= 73
void commitHookWasRegistered(UIManager const &) noexcept override {}

void commitHookWasUnregistered(UIManager const &) noexcept override {}
Expand All @@ -30,17 +29,6 @@ class ReanimatedCommitHook : public UIManagerCommitHook {
ShadowTree const &shadowTree,
RootShadowNode::Shared const &oldRootShadowNode,
RootShadowNode::Unshared const &newRootShadowNode) noexcept override;
#else
void commitHookWasRegistered(UIManager const &) const noexcept override {}

void commitHookWasUnregistered(UIManager const &) const noexcept override {}

RootShadowNode::Unshared shadowTreeWillCommit(
ShadowTree const &shadowTree,
RootShadowNode::Shared const &oldRootShadowNode,
RootShadowNode::Unshared const &newRootShadowNode)
const noexcept override;
#endif

private:
std::shared_ptr<PropsRegistry> propsRegistry_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
#include <react/renderer/scheduler/Scheduler.h>
#include <react/renderer/uimanager/UIManagerBinding.h>
#include <react/renderer/uimanager/primitives.h>
#if REACT_NATIVE_MINOR_VERSION >= 73
#include <react/utils/CoreFeatures.h>
#endif // REACT_NATIVE_MINOR_VERSION
#endif // RCT_NEW_ARCH_ENABLED

#include <functional>
Expand All @@ -48,11 +46,6 @@

using namespace facebook;

#if REACT_NATIVE_MINOR_VERSION == 73 && defined(RCT_NEW_ARCH_ENABLED)
// Android can't find the definition of this static field
bool CoreFeatures::useNativeState;
#endif

namespace reanimated {

NativeReanimatedModule::NativeReanimatedModule(
Expand Down Expand Up @@ -617,13 +610,8 @@ bool NativeReanimatedModule::handleRawEvent(
eventType = "on" + eventType.substr(3);
}
jsi::Runtime &rt = uiWorkletRuntime_->getJSIRuntime();
#if REACT_NATIVE_MINOR_VERSION >= 73
const auto &eventPayload = rawEvent.eventPayload;
jsi::Value payload = eventPayload->asJSIValue(rt);
#else
const auto &payloadFactory = rawEvent.payloadFactory;
jsi::Value payload = payloadFactory(rt);
#endif

auto res = handleEvent(eventType, tag, std::move(payload), currentTime);
// TODO: we should call performOperations conditionally if event is handled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,10 @@ jsi::Value makeShareableClone(
} else {
if (shouldRetainRemote.isBool() && shouldRetainRemote.getBool()) {
shareable = std::make_shared<RetainingShareable<ShareableObject>>(
rt,
object
#if SUPPORTS_NATIVE_STATE
,
nativeStateSource
#endif // SUPPORTS_NATIVE_STATE
);
rt, object, nativeStateSource);
} else {
shareable = std::make_shared<ShareableObject>(
rt,
object
#if SUPPORTS_NATIVE_STATE
,
nativeStateSource
#endif // SUPPORTS_NATIVE_STATE
);
shareable =
std::make_shared<ShareableObject>(rt, object, nativeStateSource);
}
}
} else if (value.isString()) {
Expand Down Expand Up @@ -210,14 +198,11 @@ ShareableObject::ShareableObject(jsi::Runtime &rt, const jsi::Object &object)
auto value = extractShareableOrThrow(rt, object.getProperty(rt, key));
data_.emplace_back(key.utf8(rt), value);
}
#if SUPPORTS_NATIVE_STATE
if (object.hasNativeState(rt)) {
nativeState_ = object.getNativeState(rt);
}
#endif // SUPPORTS_NATIVE_STATE
}

#if SUPPORTS_NATIVE_STATE
ShareableObject::ShareableObject(
jsi::Runtime &rt,
const jsi::Object &object,
Expand All @@ -228,7 +213,6 @@ ShareableObject::ShareableObject(
nativeState_ = nativeStateSource.asObject(rt).getNativeState(rt);
}
}
#endif // SUPPORTS_NATIVE_STATE

jsi::Value ShareableObject::toJSValue(jsi::Runtime &rt) {
auto obj = jsi::Object(rt);
Expand All @@ -238,11 +222,9 @@ jsi::Value ShareableObject::toJSValue(jsi::Runtime &rt) {
jsi::String::createFromUtf8(rt, data_[i].first),
data_[i].second->toJSValue(rt));
}
#if SUPPORTS_NATIVE_STATE
if (nativeState_ != nullptr) {
obj.setNativeState(rt, nativeState_);
}
#endif // SUPPORTS_NATIVE_STATE
return obj;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,26 +179,16 @@ class ShareableObject : public Shareable {
public:
ShareableObject(jsi::Runtime &rt, const jsi::Object &object);

#if defined(USE_HERMES) || REACT_NATIVE_MINOR_VERSION >= 74
#define SUPPORTS_NATIVE_STATE 1
#else
#define SUPPORTS_NATIVE_STATE 0
#endif

#if SUPPORTS_NATIVE_STATE
ShareableObject(
jsi::Runtime &rt,
const jsi::Object &object,
const jsi::Value &nativeStateSource);
#endif // SUPPORTS_NATIVE_STATE

jsi::Value toJSValue(jsi::Runtime &rt) override;

protected:
std::vector<std::pair<std::string, std::shared_ptr<Shareable>>> data_;
#if SUPPORTS_NATIVE_STATE
std::shared_ptr<jsi::NativeState> nativeState_;
#endif // SUPPORTS_NATIVE_STATE
};

class ShareableHostObject : public Shareable {
Expand Down Expand Up @@ -234,19 +224,11 @@ class ShareableHostFunction : public Shareable {

class ShareableArrayBuffer : public Shareable {
public:
ShareableArrayBuffer(
jsi::Runtime &rt,
#if REACT_NATIVE_MINOR_VERSION >= 72
const jsi::ArrayBuffer &arrayBuffer
#else
jsi::ArrayBuffer arrayBuffer
#endif
)
ShareableArrayBuffer(jsi::Runtime &rt, const jsi::ArrayBuffer &arrayBuffer)
: Shareable(ArrayBufferType),
data_(
arrayBuffer.data(rt),
arrayBuffer.data(rt) + arrayBuffer.size(rt)) {
}
arrayBuffer.data(rt) + arrayBuffer.size(rt)) {}

jsi::Value toJSValue(jsi::Runtime &rt) override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ JSScheduler::JSScheduler(
rnRuntime_(rnRuntime),
jsCallInvoker_(jsCallInvoker) {}

#if REACT_NATIVE_MINOR_VERSION >= 74 && defined(RCT_NEW_ARCH_ENABLED)
#ifdef RCT_NEW_ARCH_ENABLED
// With `runtimeExecutor`.
JSScheduler::JSScheduler(
jsi::Runtime &rnRuntime,
Expand All @@ -28,7 +28,7 @@ JSScheduler::JSScheduler(
}),
rnRuntime_(rnRuntime),
runtimeExecutor_(runtimeExecutor) {}
#endif // REACT_NATIVE_MINOR_VERSION >= 74 && defined(RCT_NEW_ARCH_ENABLED
#endif // RCT_NEW_ARCH_ENABLED

const std::shared_ptr<CallInvoker> JSScheduler::getJSCallInvoker() const {
assert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ class JSScheduler {
jsi::Runtime &rnRuntime,
const std::shared_ptr<CallInvoker> &jsCallInvoker);

#if REACT_NATIVE_MINOR_VERSION >= 74 && defined(RCT_NEW_ARCH_ENABLED)
#ifdef RCT_NEW_ARCH_ENABLED
// With `runtimeExecutor`.
explicit JSScheduler(
jsi::Runtime &rnRuntime,
RuntimeExecutor runtimeExecutor);
#endif // REACT_NATIVE_MINOR_VERSION >= 74 && defined(RCT_NEW_ARCH_ENABLED
#endif // RCT_NEW_ARCH_ENABLED

const std::function<void(Job)> scheduleOnJS = nullptr;
const std::shared_ptr<CallInvoker> getJSCallInvoker() const;

protected:
jsi::Runtime &rnRuntime_;
#if REACT_NATIVE_MINOR_VERSION >= 74 && defined(RCT_NEW_ARCH_ENABLED)
#ifdef RCT_NEW_ARCH_ENABLED
RuntimeExecutor runtimeExecutor_ = nullptr;
#endif // REACT_NATIVE_MINOR_VERSION >= 74 && defined(RCT_NEW_ARCH_ENABLED
#endif // RCT_NEW_ARCH_ENABLED
const std::shared_ptr<CallInvoker> jsCallInvoker_ = nullptr;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ namespace worklets {
using namespace facebook;
using namespace react;
#if HERMES_ENABLE_DEBUGGER
#if REACT_NATIVE_MINOR_VERSION >= 73
using namespace facebook::hermes::inspector_modern;
#else
using namespace facebook::hermes::inspector;
#endif
#endif // HERMES_ENABLE_DEBUGGER

#if HERMES_ENABLE_DEBUGGER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,15 @@
#endif

#if HERMES_ENABLE_DEBUGGER
#if REACT_NATIVE_MINOR_VERSION >= 73
#include <hermes/inspector-modern/chrome/Registration.h>
#else
#include <hermes/inspector/RuntimeAdapter.h>
#include <hermes/inspector/chrome/Registration.h>
#endif
#endif // HERMES_ENABLE_DEBUGGER

namespace worklets {

using namespace facebook;
using namespace react;
#if HERMES_ENABLE_DEBUGGER
#if REACT_NATIVE_MINOR_VERSION >= 73
using namespace facebook::hermes::inspector_modern;
#else
using namespace facebook::hermes::inspector;
#endif
#endif // HERMES_ENABLE_DEBUGGER

// ReentrancyCheck is copied from React Native
Expand Down
54 changes: 0 additions & 54 deletions packages/react-native-reanimated/__typetests__/72plus/index.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function InlineStylesTest() {
}

function InlineStylesTest4() {
const sv = useSharedValue(true);
const sv = useSharedValue('0');
// @ts-expect-error properly detects illegal type
return <Animated.View style={{ width: sv }} />;
}
Expand All @@ -55,7 +55,7 @@ function InlineStylesTest() {
}

function InlineStylesTest6() {
const sv = useSharedValue({ width: true });
const sv = useSharedValue({ width: '0' });
// @ts-expect-error properly detects illegal type
return <Animated.View style={sv} />;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function UseAnimatedStyleTest() {
}

function UseAnimatedStyleTest2() {
const sv = useSharedValue(true);
const sv = useSharedValue('0');
// @ts-expect-error properly detects illegal type
const animatedStyle = useAnimatedStyle(() => {
return {
Expand All @@ -36,7 +36,7 @@ function UseAnimatedStyleTest() {
}

function UseAnimatedStyleTest4() {
const sv = useSharedValue({ width: true });
const sv = useSharedValue({ width: '0' });
// @ts-expect-error properly detects illegal type
const animatedStyle = useAnimatedStyle(() => {
return sv.value;
Expand Down
Loading

0 comments on commit f3597c8

Please sign in to comment.