@bennyblader/ddk-rn 0.3.43 → 0.4.0
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.
- package/DdkRn.podspec +1 -1
- package/README.md +14 -0
- package/android/CMakeLists.txt +6 -3
- package/android/build.gradle +0 -1
- package/android/cpp-adapter.cpp +6 -26
- package/android/src/main/jniLibs/arm64-v8a/libddk_ffi.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libddk_ffi.so +0 -0
- package/android/src/main/jniLibs/x86/libddk_ffi.so +0 -0
- package/android/src/main/jniLibs/x86_64/libddk_ffi.so +0 -0
- package/cpp/bennyblader-ddk-rn.cpp +1 -1
- package/cpp/ddk_ffi.cpp +2361 -2671
- package/cpp/ddk_ffi.hpp +86 -255
- package/ios/DdkRn.xcframework/Info.plist +43 -0
- package/ios/DdkRn.xcframework/ios-arm64/libddk_ffi.a +0 -0
- package/ios/DdkRn.xcframework/ios-arm64-simulator/libddk_ffi.a +0 -0
- package/lib/commonjs/ddk_ffi-ffi.js +6 -29
- package/lib/commonjs/ddk_ffi-ffi.js.map +1 -1
- package/lib/commonjs/ddk_ffi.js +961 -944
- package/lib/commonjs/ddk_ffi.js.map +1 -1
- package/lib/module/ddk_ffi-ffi.js +6 -29
- package/lib/module/ddk_ffi-ffi.js.map +1 -1
- package/lib/module/ddk_ffi.js +924 -896
- package/lib/module/ddk_ffi.js.map +1 -1
- package/lib/typescript/commonjs/src/ddk_ffi-ffi.d.ts +71 -96
- package/lib/typescript/commonjs/src/ddk_ffi-ffi.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/ddk_ffi.d.ts +500 -471
- package/lib/typescript/commonjs/src/ddk_ffi.d.ts.map +1 -1
- package/lib/typescript/module/src/ddk_ffi-ffi.d.ts +71 -96
- package/lib/typescript/module/src/ddk_ffi-ffi.d.ts.map +1 -1
- package/lib/typescript/module/src/ddk_ffi.d.ts +500 -471
- package/lib/typescript/module/src/ddk_ffi.d.ts.map +1 -1
- package/package.json +8 -38
- package/src/ddk_ffi-ffi.ts +419 -170
- package/src/ddk_ffi.ts +2648 -1939
- package/ubrn.config.yaml +18 -1
- package/ddk-ffi/Cargo.lock +0 -1013
- package/ddk-ffi/Cargo.toml +0 -36
- package/ddk-ffi/build.rs +0 -3
- package/ddk-ffi/rust-toolchain.toml +0 -10
- package/ddk-ffi/src/ddk_ffi.udl +0 -376
- package/ddk-ffi/src/lib.rs +0 -2509
- package/ddk-ffi/src/uniffi-bindgen.rs +0 -3
- package/ddk-ffi/uniffi.toml +0 -18
- package/scripts/apply-hotfix.js +0 -96
- package/scripts/postinstall.js +0 -298
- package/scripts/prepare-rust-src.js +0 -51
package/DdkRn.podspec
CHANGED
|
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
|
|
|
17
17
|
|
|
18
18
|
s.source_files = "ios/**/*.{h,m,mm,swift}", "ios/generated/**/*.{h,m,mm}", "cpp/**/*.{hpp,cpp,c,h}", "cpp/**/*.{hpp,cpp,c,h}"
|
|
19
19
|
s.vendored_frameworks = "ios/DdkRn.xcframework"
|
|
20
|
-
s.dependency "uniffi-bindgen-react-native", "0.
|
|
20
|
+
s.dependency "uniffi-bindgen-react-native", "0.31.0-3"
|
|
21
21
|
|
|
22
22
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
23
23
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
package/README.md
CHANGED
|
@@ -10,6 +10,20 @@ npm install @bennyblader/ddk-rn
|
|
|
10
10
|
pnpm add @bennyblader/ddk-rn
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
+
That's the whole install. The package ships prebuilt native binaries — the iOS
|
|
14
|
+
XCFramework and the Android JNI libraries — so nothing is compiled on your
|
|
15
|
+
machine and no Rust toolchain, Android NDK, or extra download is required.
|
|
16
|
+
`pod install` and Gradle pick the binaries up from `node_modules` directly.
|
|
17
|
+
|
|
18
|
+
Prebuilt platform coverage:
|
|
19
|
+
|
|
20
|
+
| Platform | Architectures |
|
|
21
|
+
|----------|---------------|
|
|
22
|
+
| iOS | `arm64` device, `arm64` simulator |
|
|
23
|
+
| Android | `arm64-v8a`, `armeabi-v7a`, `x86`, `x86_64` |
|
|
24
|
+
|
|
25
|
+
The Intel Mac simulator (`x86_64`) is not included.
|
|
26
|
+
|
|
13
27
|
## Quick Start
|
|
14
28
|
|
|
15
29
|
```typescript
|
package/android/CMakeLists.txt
CHANGED
|
@@ -37,13 +37,16 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all")
|
|
|
37
37
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
|
38
38
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
|
39
39
|
|
|
40
|
+
# Set linker flags for 16KB page size alignment (required for Android 15+)
|
|
41
|
+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,max-page-size=16384")
|
|
42
|
+
|
|
40
43
|
cmake_path(
|
|
41
44
|
SET MY_RUST_LIB
|
|
42
|
-
${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libddk_ffi.
|
|
45
|
+
${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libddk_ffi.so
|
|
43
46
|
NORMALIZE
|
|
44
47
|
)
|
|
45
|
-
add_library(my_rust_lib
|
|
46
|
-
set_target_properties(my_rust_lib PROPERTIES IMPORTED_LOCATION ${MY_RUST_LIB})
|
|
48
|
+
add_library(my_rust_lib SHARED IMPORTED)
|
|
49
|
+
set_target_properties(my_rust_lib PROPERTIES IMPORTED_LOCATION ${MY_RUST_LIB} IMPORTED_NO_SONAME ON)
|
|
47
50
|
|
|
48
51
|
# Add ReactAndroid libraries, being careful to account for different versions.
|
|
49
52
|
find_package(ReactAndroid REQUIRED CONFIG)
|
package/android/build.gradle
CHANGED
|
@@ -133,7 +133,6 @@ dependencies {
|
|
|
133
133
|
//noinspection GradleDynamicVersion
|
|
134
134
|
implementation "com.facebook.react:react-native:+"
|
|
135
135
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
136
|
-
implementation "net.java.dev.jna:jna:5.17.0@aar"
|
|
137
136
|
}
|
|
138
137
|
|
|
139
138
|
if (isNewArchitectureEnabled()) {
|
package/android/cpp-adapter.cpp
CHANGED
|
@@ -24,34 +24,14 @@ Java_com_ddkrn_DdkRnModule_nativeInstallRustCrate(
|
|
|
24
24
|
jlong rtPtr,
|
|
25
25
|
jobject callInvokerHolderJavaObj
|
|
26
26
|
) {
|
|
27
|
-
|
|
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);
|
|
49
|
-
|
|
50
|
-
// 4. Cast the mNativePointer back to its C++ type
|
|
51
|
-
auto nativePointer = reinterpret_cast<facebook::react::CallInvokerHolder*>(nativePointerValue);
|
|
52
|
-
auto jsCallInvoker = nativePointer->getCallInvoker();
|
|
27
|
+
using JCallInvokerHolder = facebook::react::CallInvokerHolder;
|
|
53
28
|
|
|
29
|
+
auto holderLocal = facebook::jni::make_local(callInvokerHolderJavaObj);
|
|
30
|
+
auto holderRef = facebook::jni::static_ref_cast<JCallInvokerHolder::javaobject>(holderLocal);
|
|
31
|
+
auto* holderCxx = holderRef->cthis();
|
|
32
|
+
auto jsCallInvoker = holderCxx->getCallInvoker();
|
|
54
33
|
auto runtime = reinterpret_cast<jsi::Runtime *>(rtPtr);
|
|
34
|
+
|
|
55
35
|
return bennyblader_ddkrn::installRustCrate(*runtime, jsCallInvoker);
|
|
56
36
|
}
|
|
57
37
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|