react-native-neural-wallet-lib 0.1.52 → 0.1.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@
8
8
  <key>BinaryPath</key>
9
9
  <string>libwallet.a</string>
10
10
  <key>LibraryIdentifier</key>
11
- <string>ios-arm64</string>
11
+ <string>ios-arm64-simulator</string>
12
12
  <key>LibraryPath</key>
13
13
  <string>libwallet.a</string>
14
14
  <key>SupportedArchitectures</key>
@@ -17,12 +17,14 @@
17
17
  </array>
18
18
  <key>SupportedPlatform</key>
19
19
  <string>ios</string>
20
+ <key>SupportedPlatformVariant</key>
21
+ <string>simulator</string>
20
22
  </dict>
21
23
  <dict>
22
24
  <key>BinaryPath</key>
23
25
  <string>libwallet.a</string>
24
26
  <key>LibraryIdentifier</key>
25
- <string>ios-arm64-simulator</string>
27
+ <string>ios-arm64</string>
26
28
  <key>LibraryPath</key>
27
29
  <string>libwallet.a</string>
28
30
  <key>SupportedArchitectures</key>
@@ -31,8 +33,6 @@
31
33
  </array>
32
34
  <key>SupportedPlatform</key>
33
35
  <string>ios</string>
34
- <key>SupportedPlatformVariant</key>
35
- <string>simulator</string>
36
36
  </dict>
37
37
  </array>
38
38
  <key>CFBundlePackageType</key>
package/README.md CHANGED
@@ -44,6 +44,16 @@ A standalone `.a` commonly causes mixed-slice link failures between real device
44
44
  Also ensure the XCFramework is **real** (contains device/simulator slices), not a placeholder with only `Info.plist`.
45
45
  `npm pack` now runs `scripts/verify-ios-artifacts.js` to block publishing empty iOS artifacts.
46
46
 
47
+ ## Android JNI note (RN 0.82+)
48
+
49
+ For React Native 0.82+, JNI install must **not** access `CallInvokerHolderImpl.mHybridData` by reflection.
50
+ This repo now uses the fbjni bridge (`adopt_local + cthis()->getCallInvoker()`).
51
+
52
+ - After regenerate, run: `npm run patch:android:jni`
53
+ - Verify before publish: `npm run verify:android:jni`
54
+
55
+ `prepack` now includes Android JNI compatibility verification.
56
+
47
57
  ## GitHub Actions release (macOS build + npm publish)
48
58
 
49
59
  Workflow: `.github/workflows/release-npm-ios.yml`
@@ -1,6 +1,7 @@
1
1
  // Generated by uniffi-bindgen-react-native
2
2
  #include <jni.h>
3
3
  #include <jsi/jsi.h>
4
+ #include <fbjni/fbjni.h>
4
5
  #include <ReactCommon/CallInvokerHolder.h>
5
6
  #include "react-native-neural-wallet-lib.h"
6
7
 
@@ -24,34 +25,18 @@ Java_com_neuralwalletlib_NeuralWalletLibModule_nativeInstallRustCrate(
24
25
  jlong rtPtr,
25
26
  jobject callInvokerHolderJavaObj
26
27
  ) {
27
- // https://github.com/realm/realm-js/blob/main/packages/realm/binding/android/src/main/cpp/io_realm_react_RealmReactModule.cpp#L122-L145
28
- // React Native uses the fbjni library for handling JNI, which has the concept of "hybrid objects",
29
- // which are Java objects containing a pointer to a C++ object. The CallInvokerHolder, which has the
30
- // invokeAsync method we want access to, is one such hybrid object.
31
- // Rather than reworking our code to use fbjni throughout, this code unpacks the C++ object from the Java
32
- // object `callInvokerHolderJavaObj` manually, based on reverse engineering the fbjni code.
33
-
34
- // 1. Get the Java object referred to by the mHybridData field of the Java holder object
35
- auto callInvokerHolderClass = env->GetObjectClass(callInvokerHolderJavaObj);
36
- auto hybridDataField = env->GetFieldID(callInvokerHolderClass, "mHybridData", "Lcom/facebook/jni/HybridData;");
37
- auto hybridDataObj = env->GetObjectField(callInvokerHolderJavaObj, hybridDataField);
38
-
39
- // 2. Get the destructor Java object referred to by the mDestructor field from the myHybridData Java object
40
- auto hybridDataClass = env->FindClass("com/facebook/jni/HybridData");
41
- auto destructorField =
42
- env->GetFieldID(hybridDataClass, "mDestructor", "Lcom/facebook/jni/HybridData$Destructor;");
43
- auto destructorObj = env->GetObjectField(hybridDataObj, destructorField);
44
-
45
- // 3. Get the mNativePointer field from the mDestructor Java object
46
- auto destructorClass = env->FindClass("com/facebook/jni/HybridData$Destructor");
47
- auto nativePointerField = env->GetFieldID(destructorClass, "mNativePointer", "J");
48
- auto nativePointerValue = env->GetLongField(destructorObj, nativePointerField);
28
+ auto runtime = reinterpret_cast<jsi::Runtime *>(rtPtr);
29
+ if (runtime == nullptr || callInvokerHolderJavaObj == nullptr) {
30
+ return JNI_FALSE;
31
+ }
49
32
 
50
- // 4. Cast the mNativePointer back to its C++ type
51
- auto nativePointer = reinterpret_cast<facebook::react::CallInvokerHolder*>(nativePointerValue);
52
- auto jsCallInvoker = nativePointer->getCallInvoker();
33
+ auto callInvokerHolder = facebook::jni::adopt_local(
34
+ reinterpret_cast<facebook::react::CallInvokerHolder::javaobject>(callInvokerHolderJavaObj));
35
+ auto jsCallInvoker = callInvokerHolder->cthis()->getCallInvoker();
36
+ if (jsCallInvoker == nullptr) {
37
+ return JNI_FALSE;
38
+ }
53
39
 
54
- auto runtime = reinterpret_cast<jsi::Runtime *>(rtPtr);
55
40
  return neuralwalletlib::installRustCrate(*runtime, jsCallInvoker);
56
41
  }
57
42
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-neural-wallet-lib",
3
- "version": "0.1.52",
3
+ "version": "0.1.53",
4
4
  "description": "Neural wallet native lib",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -35,7 +35,7 @@
35
35
  ],
36
36
  "scripts": {
37
37
  "ubrn:ios": "ubrn build ios --release --and-generate",
38
- "ubrn:android": "ubrn build android --release --and-generate ",
38
+ "ubrn:android": "ubrn build android --release --and-generate && npm run patch:android:jni",
39
39
  "ubrn:web": "ubrn build web",
40
40
  "ubrn:checkout": "ubrn checkout",
41
41
  "ubrn:clean": "rm -rfv cpp/ android/CMakeLists.txt android/src/main/java android/*.cpp ios/ src/Native* src/index.*ts* src/generated/",
@@ -45,7 +45,9 @@
45
45
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
46
46
  "clean": "del-cli android/build NeuralWallet/android/build NeuralWallet/android/app/build NeuralWallet/ios/build lib",
47
47
  "prepare": "bob build",
48
- "prepack": "node scripts/verify-ios-artifacts.js",
48
+ "patch:android:jni": "node scripts/patch-android-cpp-adapter.js",
49
+ "verify:android:jni": "node scripts/verify-android-jni-compat.js",
50
+ "prepack": "node scripts/verify-ios-artifacts.js && node scripts/verify-android-jni-compat.js",
49
51
  "release": "release-it --only-version"
50
52
  },
51
53
  "keywords": [