rm patched pkg

This commit is contained in:
EthanShoeDev
2025-10-08 19:59:44 -04:00
parent 856be66449
commit 0f468b9f2d
5 changed files with 6 additions and 87 deletions

View File

@@ -2,10 +2,6 @@
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true,
// https://github.com/jhugman/uniffi-bindgen-react-native/pull/198
// https://github.com/microsoft/TypeScript/issues/41883#issuecomment-1758692340
// TODO: Get this merged
// https://github.com/jhugman/uniffi-bindgen-react-native/pull/297
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,

View File

@@ -92,7 +92,7 @@
"typescript": "~5.9.2"
},
"dependencies": {
"uniffi-bindgen-react-native": "github:EthanShoeDev/uniffi-bindgen-react-native#build-ts"
"uniffi-bindgen-react-native": "github:jhugman/uniffi-bindgen-react-native#main"
},
"peerDependencies": {
"react": "19.1.0",

View File

@@ -1,69 +0,0 @@
diff --git a/crates/ubrn_cli/templates/jsi/android/cpp-adapter.cpp b/crates/ubrn_cli/templates/jsi/android/cpp-adapter.cpp
index d8d1c1a1c1269ecee9467fd0ef809dcb1e375923..a031428d1eaecec2df94e7148e9d45d15642158d 100644
--- a/crates/ubrn_cli/templates/jsi/android/cpp-adapter.cpp
+++ b/crates/ubrn_cli/templates/jsi/android/cpp-adapter.cpp
@@ -2,6 +2,7 @@
#include <jni.h>
#include <jsi/jsi.h>
#include <ReactCommon/CallInvokerHolder.h>
+#include <fbjni/fbjni.h>
#include "{{ self.config.project.cpp_filename() }}.h"
{%- let package_name = self.config.project.android.package_name().replace(".", "_") %}
{%- let name = self.config.project.module_cpp() %}
@@ -29,35 +30,27 @@ JNIEXPORT jboolean JNICALL
jlong rtPtr,
jobject callInvokerHolderJavaObj
) {
- // https://github.com/realm/realm-js/blob/main/packages/realm/binding/android/src/main/cpp/io_realm_react_RealmReactModule.cpp#L122-L145
- // React Native uses the fbjni library for handling JNI, which has the concept of "hybrid objects",
- // which are Java objects containing a pointer to a C++ object. The CallInvokerHolder, which has the
- // invokeAsync method we want access to, is one such hybrid object.
- // Rather than reworking our code to use fbjni throughout, this code unpacks the C++ object from the Java
- // object `callInvokerHolderJavaObj` manually, based on reverse engineering the fbjni code.
-
- // 1. Get the Java object referred to by the mHybridData field of the Java holder object
- auto callInvokerHolderClass = env->GetObjectClass(callInvokerHolderJavaObj);
- auto hybridDataField = env->GetFieldID(callInvokerHolderClass, "mHybridData", "Lcom/facebook/jni/HybridData;");
- auto hybridDataObj = env->GetObjectField(callInvokerHolderJavaObj, hybridDataField);
-
- // 2. Get the destructor Java object referred to by the mDestructor field from the myHybridData Java object
- auto hybridDataClass = env->FindClass("com/facebook/jni/HybridData");
- auto destructorField =
- env->GetFieldID(hybridDataClass, "mDestructor", "Lcom/facebook/jni/HybridData$Destructor;");
- auto destructorObj = env->GetObjectField(hybridDataObj, destructorField);
-
- // 3. Get the mNativePointer field from the mDestructor Java object
- auto destructorClass = env->FindClass("com/facebook/jni/HybridData$Destructor");
- auto nativePointerField = env->GetFieldID(destructorClass, "mNativePointer", "J");
- auto nativePointerValue = env->GetLongField(destructorObj, nativePointerField);
-
- // 4. Cast the mNativePointer back to its C++ type
- auto nativePointer = reinterpret_cast<facebook::react::CallInvokerHolder*>(nativePointerValue);
- auto jsCallInvoker = nativePointer->getCallInvoker();
-
- auto runtime = reinterpret_cast<jsi::Runtime *>(rtPtr);
- return {{ ns }}::installRustCrate(*runtime, jsCallInvoker);
+ try {
+ if (callInvokerHolderJavaObj == nullptr) {
+ return false;
+ }
+
+ auto alias = facebook::jni::alias_ref<jobject>(callInvokerHolderJavaObj);
+ auto holder = facebook::jni::static_ref_cast<facebook::react::CallInvokerHolder::javaobject>(alias);
+ if (!holder) {
+ return false;
+ }
+
+ auto jsCallInvoker = holder->cthis()->getCallInvoker();
+ if (!jsCallInvoker) {
+ return false;
+ }
+
+ auto runtime = reinterpret_cast<jsi::Runtime *>(rtPtr);
+ return {{ ns }}::installRustCrate(*runtime, jsCallInvoker);
+ } catch (...) {
+ return false;
+ }
}
extern "C"

15
pnpm-lock.yaml generated
View File

@@ -4,11 +4,6 @@ settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
patchedDependencies:
uniffi-bindgen-react-native:
hash: 527b712c8fb029b29d9ac7caa72e593fa37a6dcebb63e15a56e21e75ffcb88ec
path: patches/uniffi-bindgen-react-native.patch
importers:
.:
@@ -315,8 +310,8 @@ importers:
packages/react-native-uniffi-russh:
dependencies:
uniffi-bindgen-react-native:
specifier: github:EthanShoeDev/uniffi-bindgen-react-native#build-ts
version: https://codeload.github.com/EthanShoeDev/uniffi-bindgen-react-native/tar.gz/54dd681081a4117ee417f78607a942544636b145(patch_hash=527b712c8fb029b29d9ac7caa72e593fa37a6dcebb63e15a56e21e75ffcb88ec)
specifier: github:jhugman/uniffi-bindgen-react-native#main
version: https://codeload.github.com/jhugman/uniffi-bindgen-react-native/tar.gz/b9301797ef697331d29edb9d2402ea35c218571e
devDependencies:
'@epic-web/config':
specifier: ^1.21.3
@@ -8991,8 +8986,8 @@ packages:
resolution: {integrity: sha512-+QBBXBCvifc56fsbuxZQ6Sic3wqqc3WWaqxs58gvJrcOuN83HGTCwz3oS5phzU9LthRNE9VrJCFCLUgHeeFnfA==}
engines: {node: '>=18'}
uniffi-bindgen-react-native@https://codeload.github.com/EthanShoeDev/uniffi-bindgen-react-native/tar.gz/54dd681081a4117ee417f78607a942544636b145:
resolution: {tarball: https://codeload.github.com/EthanShoeDev/uniffi-bindgen-react-native/tar.gz/54dd681081a4117ee417f78607a942544636b145}
uniffi-bindgen-react-native@https://codeload.github.com/jhugman/uniffi-bindgen-react-native/tar.gz/b9301797ef697331d29edb9d2402ea35c218571e:
resolution: {tarball: https://codeload.github.com/jhugman/uniffi-bindgen-react-native/tar.gz/b9301797ef697331d29edb9d2402ea35c218571e}
version: 0.29.3-1
hasBin: true
@@ -20270,7 +20265,7 @@ snapshots:
unicorn-magic@0.3.0: {}
uniffi-bindgen-react-native@https://codeload.github.com/EthanShoeDev/uniffi-bindgen-react-native/tar.gz/54dd681081a4117ee417f78607a942544636b145(patch_hash=527b712c8fb029b29d9ac7caa72e593fa37a6dcebb63e15a56e21e75ffcb88ec): {}
uniffi-bindgen-react-native@https://codeload.github.com/jhugman/uniffi-bindgen-react-native/tar.gz/b9301797ef697331d29edb9d2402ea35c218571e: {}
unified@11.0.5:
dependencies:

View File

@@ -10,6 +10,3 @@ onlyBuiltDependencies:
- oxc-resolver
- sharp
- unrs-resolver
patchedDependencies:
uniffi-bindgen-react-native: patches/uniffi-bindgen-react-native.patch