diff --git a/apps/mobile/tsconfig.json b/apps/mobile/tsconfig.json index 9ce9c3d..5bfe4e5 100644 --- a/apps/mobile/tsconfig.json +++ b/apps/mobile/tsconfig.json @@ -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, diff --git a/packages/react-native-uniffi-russh/package.json b/packages/react-native-uniffi-russh/package.json index 53a3edb..a740a84 100644 --- a/packages/react-native-uniffi-russh/package.json +++ b/packages/react-native-uniffi-russh/package.json @@ -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", diff --git a/patches/uniffi-bindgen-react-native.patch b/patches/uniffi-bindgen-react-native.patch deleted file mode 100644 index cdf7573..0000000 --- a/patches/uniffi-bindgen-react-native.patch +++ /dev/null @@ -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 - #include - #include -+#include - #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(nativePointerValue); -- auto jsCallInvoker = nativePointer->getCallInvoker(); -- -- auto runtime = reinterpret_cast(rtPtr); -- return {{ ns }}::installRustCrate(*runtime, jsCallInvoker); -+ try { -+ if (callInvokerHolderJavaObj == nullptr) { -+ return false; -+ } -+ -+ auto alias = facebook::jni::alias_ref(callInvokerHolderJavaObj); -+ auto holder = facebook::jni::static_ref_cast(alias); -+ if (!holder) { -+ return false; -+ } -+ -+ auto jsCallInvoker = holder->cthis()->getCallInvoker(); -+ if (!jsCallInvoker) { -+ return false; -+ } -+ -+ auto runtime = reinterpret_cast(rtPtr); -+ return {{ ns }}::installRustCrate(*runtime, jsCallInvoker); -+ } catch (...) { -+ return false; -+ } - } - - extern "C" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2b83694..de60239 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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: diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 2a7eb3f..c712e51 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -10,6 +10,3 @@ onlyBuiltDependencies: - oxc-resolver - sharp - unrs-resolver - -patchedDependencies: - uniffi-bindgen-react-native: patches/uniffi-bindgen-react-native.patch