Files
react-native-svg/apps/fabric-macos-example/patches/react-native-reanimated+3.9.0.patch
Jakub Grzywacz b3b175a7fb feat: move examples to ./apps (#2507)
# Summary

Due to the large number of example apps in the repository, I decided to
change the structure and move all applications into an "apps" folder to
maintain a clear structure.
2024-10-25 16:12:23 +02:00

133 lines
4.4 KiB
Diff

diff --git a/node_modules/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModule.cpp b/node_modules/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModule.cpp
index a1ace04..58d0303 100644
--- a/node_modules/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModule.cpp
+++ b/node_modules/react-native-reanimated/Common/cpp/NativeModules/NativeReanimatedModule.cpp
@@ -37,11 +37,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(
diff --git a/node_modules/react-native-reanimated/Common/cpp/SharedItems/Shareables.cpp b/node_modules/react-native-reanimated/Common/cpp/SharedItems/Shareables.cpp
index a0e002b..761cc03 100644
--- a/node_modules/react-native-reanimated/Common/cpp/SharedItems/Shareables.cpp
+++ b/node_modules/react-native-reanimated/Common/cpp/SharedItems/Shareables.cpp
@@ -78,10 +78,22 @@ jsi::Value makeShareableClone(
} else {
if (shouldRetainRemote.isBool() && shouldRetainRemote.getBool()) {
shareable = std::make_shared<RetainingShareable<ShareableObject>>(
- rt, object, nativeStateSource);
+ rt,
+ object
+#if SUPPORTS_NATIVE_STATE
+ ,
+ nativeStateSource
+#endif // SUPPORTS_NATIVE_STATE
+ );
} else {
- shareable =
- std::make_shared<ShareableObject>(rt, object, nativeStateSource);
+ shareable = std::make_shared<ShareableObject>(
+ rt,
+ object
+#if SUPPORTS_NATIVE_STATE
+ ,
+ nativeStateSource
+#endif // SUPPORTS_NATIVE_STATE
+ );
}
}
} else if (value.isString()) {
@@ -200,13 +212,16 @@ 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 REACT_NATIVE_MINOR_VERSION >= 71
if (object.hasNativeState(rt)) {
nativeState_ = object.getNativeState(rt);
}
#endif
+#endif // SUPPORTS_NATIVE_STATE
}
+#if SUPPORTS_NATIVE_STATE
ShareableObject::ShareableObject(
jsi::Runtime &rt,
const jsi::Object &object,
@@ -219,18 +234,20 @@ ShareableObject::ShareableObject(
}
#endif
}
+#endif // SUPPORTS_NATIVE_STATE
jsi::Value ShareableObject::toJSValue(jsi::Runtime &rt) {
auto obj = jsi::Object(rt);
for (size_t i = 0, size = data_.size(); i < size; i++) {
- obj.setProperty(
- rt, data_[i].first.c_str(), data_[i].second->getJSValue(rt));
+ obj.setProperty(rt, data_[i].first.c_str(), data_[i].second->toJSValue(rt));
}
+#if SUPPORTS_NATIVE_STATE
#if REACT_NATIVE_MINOR_VERSION >= 71
if (nativeState_ != nullptr) {
obj.setNativeState(rt, nativeState_);
}
#endif
+#endif // SUPPORTS_NATIVE_STATE
return obj;
}
diff --git a/node_modules/react-native-reanimated/Common/cpp/SharedItems/Shareables.h b/node_modules/react-native-reanimated/Common/cpp/SharedItems/Shareables.h
index e61bc58..52c7a9e 100644
--- a/node_modules/react-native-reanimated/Common/cpp/SharedItems/Shareables.h
+++ b/node_modules/react-native-reanimated/Common/cpp/SharedItems/Shareables.h
@@ -62,11 +62,9 @@ inline void cleanupIfRuntimeExists(
}
class Shareable {
- protected:
- virtual jsi::Value toJSValue(jsi::Runtime &rt) = 0;
-
public:
virtual ~Shareable();
+ virtual jsi::Value toJSValue(jsi::Runtime &rt) = 0;
enum ValueType {
UndefinedType,
@@ -183,18 +181,28 @@ 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
#if REACT_NATIVE_MINOR_VERSION >= 71
std::shared_ptr<jsi::NativeState> nativeState_;
#endif
+#endif // SUPPORTS_NATIVE_STATE
};
class ShareableHostObject : public Shareable {