@rusaint/react-native 0.10.0-dev.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/LICENSE +20 -0
- package/README.md +15 -0
- package/android/CMakeLists.txt +78 -0
- package/android/build.gradle +143 -0
- package/android/cpp-adapter.cpp +63 -0
- package/android/generated/java/dev/eatsteak/rusaint/reactnative/NativeReactNativeSpec.java +41 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNReactNativeSpec-generated.cpp +38 -0
- package/android/generated/jni/RNReactNativeSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNReactNativeSpec/RNReactNativeSpecJSI-generated.cpp +32 -0
- package/android/generated/jni/react/renderer/components/RNReactNativeSpec/RNReactNativeSpecJSI.h +80 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +5 -0
- package/android/src/main/java/dev/eatsteak/rusaint/reactnative/ReactNativeModule.kt +43 -0
- package/android/src/main/java/dev/eatsteak/rusaint/reactnative/ReactNativePackage.kt +34 -0
- package/android/src/main/jniLibs/arm64-v8a/librusaint_ffi.a +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/librusaint_ffi.a +0 -0
- package/android/src/main/jniLibs/x86/librusaint_ffi.a +0 -0
- package/android/src/main/jniLibs/x86_64/librusaint_ffi.a +0 -0
- package/build/RusaintReactNativeFramework.xcframework/Info.plist +43 -0
- package/build/RusaintReactNativeFramework.xcframework/ios-arm64/librusaint_ffi.a +0 -0
- package/build/RusaintReactNativeFramework.xcframework/ios-arm64-simulator/librusaint_ffi.a +0 -0
- package/cpp/generated/rusaint.cpp +2485 -0
- package/cpp/generated/rusaint.hpp +168 -0
- package/cpp/generated/rusaint_ffi.cpp +7397 -0
- package/cpp/generated/rusaint_ffi.hpp +873 -0
- package/cpp/rusaint-react-native.cpp +18 -0
- package/cpp/rusaint-react-native.h +15 -0
- package/ios/ReactNative.h +16 -0
- package/ios/ReactNative.mm +66 -0
- package/ios/generated/RNReactNativeSpec/RNReactNativeSpec-generated.mm +46 -0
- package/ios/generated/RNReactNativeSpec/RNReactNativeSpec.h +63 -0
- package/ios/generated/RNReactNativeSpecJSI-generated.cpp +32 -0
- package/ios/generated/RNReactNativeSpecJSI.h +80 -0
- package/lib/commonjs/NativeReactNative.ts +10 -0
- package/lib/commonjs/generated/rusaint-ffi.js +44 -0
- package/lib/commonjs/generated/rusaint-ffi.js.map +1 -0
- package/lib/commonjs/generated/rusaint.js +3232 -0
- package/lib/commonjs/generated/rusaint.js.map +1 -0
- package/lib/commonjs/generated/rusaint_ffi-ffi.js +44 -0
- package/lib/commonjs/generated/rusaint_ffi-ffi.js.map +1 -0
- package/lib/commonjs/generated/rusaint_ffi.js +2493 -0
- package/lib/commonjs/generated/rusaint_ffi.js.map +1 -0
- package/lib/commonjs/index.js +68 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/module/NativeReactNative.ts +10 -0
- package/lib/module/generated/rusaint-ffi.js +43 -0
- package/lib/module/generated/rusaint-ffi.js.map +1 -0
- package/lib/module/generated/rusaint.js +3226 -0
- package/lib/module/generated/rusaint.js.map +1 -0
- package/lib/module/generated/rusaint_ffi-ffi.js +43 -0
- package/lib/module/generated/rusaint_ffi-ffi.js.map +1 -0
- package/lib/module/generated/rusaint_ffi.js +2469 -0
- package/lib/module/generated/rusaint_ffi.js.map +1 -0
- package/lib/module/index.js +40 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeReactNative.d.ts +8 -0
- package/lib/typescript/commonjs/src/NativeReactNative.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/generated/rusaint-ffi.d.ts +109 -0
- package/lib/typescript/commonjs/src/generated/rusaint-ffi.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/generated/rusaint.d.ts +2330 -0
- package/lib/typescript/commonjs/src/generated/rusaint.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/generated/rusaint_ffi-ffi.d.ts +300 -0
- package/lib/typescript/commonjs/src/generated/rusaint_ffi-ffi.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/generated/rusaint_ffi.d.ts +1111 -0
- package/lib/typescript/commonjs/src/generated/rusaint_ffi.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +10 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/package.json +185 -0
- package/react-native.config.js +12 -0
- package/rusaint-react-native.podspec +44 -0
- package/src/NativeReactNative.ts +10 -0
- package/src/generated/rusaint-ffi.ts +276 -0
- package/src/generated/rusaint.ts +4867 -0
- package/src/generated/rusaint_ffi-ffi.ts +832 -0
- package/src/generated/rusaint_ffi.ts +5519 -0
- package/src/index.tsx +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Koo Hyomin <me@eatsteak.dev>
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Generated by uniffi-bindgen-react-native
|
|
2
|
+
cmake_minimum_required(VERSION 3.9.0)
|
|
3
|
+
project(ReactNative)
|
|
4
|
+
|
|
5
|
+
set (CMAKE_VERBOSE_MAKEFILE ON)
|
|
6
|
+
set (CMAKE_CXX_STANDARD 17)
|
|
7
|
+
|
|
8
|
+
# Resolve the path to the uniffi-bindgen-react-native package
|
|
9
|
+
execute_process(
|
|
10
|
+
COMMAND node -p "require.resolve('uniffi-bindgen-react-native/package.json')"
|
|
11
|
+
OUTPUT_VARIABLE UNIFFI_BINDGEN_PATH
|
|
12
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
13
|
+
)
|
|
14
|
+
string(REGEX
|
|
15
|
+
REPLACE "/package\\.json$" ""
|
|
16
|
+
UNIFFI_BINDGEN_PATH ${UNIFFI_BINDGEN_PATH}
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
# Specifies a path to native header files.
|
|
20
|
+
include_directories(
|
|
21
|
+
../cpp
|
|
22
|
+
../cpp/generated
|
|
23
|
+
|
|
24
|
+
${UNIFFI_BINDGEN_PATH}/cpp/includes
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
add_library(rusaint-react-native SHARED
|
|
28
|
+
../cpp/rusaint-react-native.cpp
|
|
29
|
+
../cpp/generated/rusaint.cpp
|
|
30
|
+
../cpp/generated/rusaint_ffi.cpp
|
|
31
|
+
cpp-adapter.cpp
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
# Set C++ compiler flags
|
|
35
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
|
36
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
|
|
37
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti")
|
|
38
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all")
|
|
39
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
|
40
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
|
41
|
+
|
|
42
|
+
cmake_path(
|
|
43
|
+
SET MY_RUST_LIB
|
|
44
|
+
${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/librusaint_ffi.a
|
|
45
|
+
NORMALIZE
|
|
46
|
+
)
|
|
47
|
+
add_library(my_rust_lib STATIC IMPORTED)
|
|
48
|
+
set_target_properties(my_rust_lib PROPERTIES IMPORTED_LOCATION ${MY_RUST_LIB})
|
|
49
|
+
|
|
50
|
+
# Add ReactAndroid libraries, being careful to account for different versions.
|
|
51
|
+
find_package(ReactAndroid REQUIRED CONFIG)
|
|
52
|
+
find_library(LOGCAT log)
|
|
53
|
+
|
|
54
|
+
# REACTNATIVE_MERGED_SO seems to be only be set in a build.gradle.kt file,
|
|
55
|
+
# which we don't use. Thus falling back to version number sniffing.
|
|
56
|
+
if (ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
|
57
|
+
set(REACTNATIVE_MERGED_SO true)
|
|
58
|
+
endif()
|
|
59
|
+
|
|
60
|
+
# https://github.com/react-native-community/discussions-and-proposals/discussions/816
|
|
61
|
+
# This if-then-else can be removed once this library does not support version below 0.76
|
|
62
|
+
if (REACTNATIVE_MERGED_SO)
|
|
63
|
+
target_link_libraries(rusaint-react-native ReactAndroid::reactnative)
|
|
64
|
+
else()
|
|
65
|
+
target_link_libraries(rusaint-react-native
|
|
66
|
+
ReactAndroid::turbomodulejsijni
|
|
67
|
+
ReactAndroid::react_nativemodule_core
|
|
68
|
+
)
|
|
69
|
+
endif()
|
|
70
|
+
|
|
71
|
+
find_package(fbjni REQUIRED CONFIG)
|
|
72
|
+
target_link_libraries(
|
|
73
|
+
rusaint-react-native
|
|
74
|
+
fbjni::fbjni
|
|
75
|
+
ReactAndroid::jsi
|
|
76
|
+
${LOGCAT}
|
|
77
|
+
my_rust_lib
|
|
78
|
+
)
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
|
|
3
|
+
buildscript {
|
|
4
|
+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
5
|
+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["DummyLibForAndroid_kotlinVersion"]
|
|
6
|
+
|
|
7
|
+
repositories {
|
|
8
|
+
google()
|
|
9
|
+
mavenCentral()
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
dependencies {
|
|
13
|
+
classpath "com.android.tools.build:gradle:7.2.1"
|
|
14
|
+
// noinspection DifferentKotlinGradleVersion
|
|
15
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
def reactNativeArchitectures() {
|
|
20
|
+
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
21
|
+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
def isNewArchitectureEnabled() {
|
|
25
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
apply plugin: "com.android.library"
|
|
29
|
+
apply plugin: "kotlin-android"
|
|
30
|
+
|
|
31
|
+
if (isNewArchitectureEnabled()) {
|
|
32
|
+
apply plugin: "com.facebook.react"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
def getExtOrDefault(name) {
|
|
36
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["ReactNative_" + name]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
def getExtOrIntegerDefault(name) {
|
|
40
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ReactNative_" + name]).toInteger()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
def supportsNamespace() {
|
|
44
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
45
|
+
def major = parsed[0].toInteger()
|
|
46
|
+
def minor = parsed[1].toInteger()
|
|
47
|
+
|
|
48
|
+
// Namespace support was added in 7.3.0
|
|
49
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
android {
|
|
53
|
+
if (supportsNamespace()) {
|
|
54
|
+
namespace "dev.eatsteak.rusaint.reactnative"
|
|
55
|
+
|
|
56
|
+
sourceSets {
|
|
57
|
+
main {
|
|
58
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
ndkVersion getExtOrDefault("ndkVersion")
|
|
64
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
65
|
+
|
|
66
|
+
defaultConfig {
|
|
67
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
68
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
69
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
70
|
+
|
|
71
|
+
buildFeatures {
|
|
72
|
+
prefab true
|
|
73
|
+
}
|
|
74
|
+
externalNativeBuild {
|
|
75
|
+
cmake {
|
|
76
|
+
arguments '-DANDROID_STL=c++_shared'
|
|
77
|
+
abiFilters (*reactNativeArchitectures())
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
ndk {
|
|
81
|
+
abiFilters "arm64-v8a", "armeabi-v7a", "x86", "x86_64"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
externalNativeBuild {
|
|
86
|
+
cmake {
|
|
87
|
+
path "CMakeLists.txt"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
buildFeatures {
|
|
92
|
+
buildConfig true
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
buildTypes {
|
|
96
|
+
release {
|
|
97
|
+
minifyEnabled false
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
lintOptions {
|
|
102
|
+
disable "GradleCompatible"
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
compileOptions {
|
|
106
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
107
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
sourceSets {
|
|
111
|
+
main {
|
|
112
|
+
if (isNewArchitectureEnabled()) {
|
|
113
|
+
java.srcDirs += [
|
|
114
|
+
"generated/java",
|
|
115
|
+
"generated/jni"
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
repositories {
|
|
123
|
+
mavenCentral()
|
|
124
|
+
google()
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
128
|
+
|
|
129
|
+
dependencies {
|
|
130
|
+
// For < 0.71, this will be from the local maven repo
|
|
131
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
132
|
+
//noinspection GradleDynamicVersion
|
|
133
|
+
implementation "com.facebook.react:react-native:+"
|
|
134
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (isNewArchitectureEnabled()) {
|
|
138
|
+
react {
|
|
139
|
+
jsRootDir = file("../src/")
|
|
140
|
+
libraryName = "ReactNative"
|
|
141
|
+
codegenJavaPackageName = "dev.eatsteak.rusaint.reactnative"
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
#include <jni.h>
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <ReactCommon/CallInvokerHolder.h>
|
|
5
|
+
#include "rusaint-react-native.h"
|
|
6
|
+
|
|
7
|
+
namespace jsi = facebook::jsi;
|
|
8
|
+
namespace react = facebook::react;
|
|
9
|
+
|
|
10
|
+
// Automated testing checks Java_dev_eatsteak_rusaint_reactnative_ReactNativeModule and rusaint_reactnative
|
|
11
|
+
// by comparing the whole line here.
|
|
12
|
+
/*
|
|
13
|
+
Java_dev_eatsteak_rusaint_reactnative_ReactNativeModule_nativeMultiply(JNIEnv *env, jclass type, jdouble a, jdouble b) {
|
|
14
|
+
return rusaint_reactnative::multiply(a, b);
|
|
15
|
+
}
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
// Installer coming from ReactNativeModule
|
|
19
|
+
extern "C"
|
|
20
|
+
JNIEXPORT jboolean JNICALL
|
|
21
|
+
Java_dev_eatsteak_rusaint_reactnative_ReactNativeModule_nativeInstallRustCrate(
|
|
22
|
+
JNIEnv *env,
|
|
23
|
+
jclass type,
|
|
24
|
+
jlong rtPtr,
|
|
25
|
+
jobject callInvokerHolderJavaObj
|
|
26
|
+
) {
|
|
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);
|
|
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();
|
|
53
|
+
|
|
54
|
+
auto runtime = reinterpret_cast<jsi::Runtime *>(rtPtr);
|
|
55
|
+
return rusaint_reactnative::installRustCrate(*runtime, jsCallInvoker);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
extern "C"
|
|
59
|
+
JNIEXPORT jboolean JNICALL
|
|
60
|
+
Java_dev_eatsteak_rusaint_reactnative_ReactNativeModule_nativeCleanupRustCrate(JNIEnv *env, jclass type, jlong rtPtr) {
|
|
61
|
+
auto runtime = reinterpret_cast<jsi::Runtime *>(rtPtr);
|
|
62
|
+
return rusaint_reactnative::cleanupRustCrate(*runtime);
|
|
63
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJavaSpec.js
|
|
9
|
+
*
|
|
10
|
+
* @nolint
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
package dev.eatsteak.rusaint.reactnative;
|
|
14
|
+
|
|
15
|
+
import com.facebook.proguard.annotations.DoNotStrip;
|
|
16
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
17
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
18
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
19
|
+
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
|
20
|
+
import javax.annotation.Nonnull;
|
|
21
|
+
|
|
22
|
+
public abstract class NativeReactNativeSpec extends ReactContextBaseJavaModule implements TurboModule {
|
|
23
|
+
public static final String NAME = "ReactNative";
|
|
24
|
+
|
|
25
|
+
public NativeReactNativeSpec(ReactApplicationContext reactContext) {
|
|
26
|
+
super(reactContext);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Override
|
|
30
|
+
public @Nonnull String getName() {
|
|
31
|
+
return NAME;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
35
|
+
@DoNotStrip
|
|
36
|
+
public abstract boolean installRustCrate();
|
|
37
|
+
|
|
38
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
public abstract boolean cleanupRustCrate();
|
|
41
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
cmake_minimum_required(VERSION 3.13)
|
|
7
|
+
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
8
|
+
|
|
9
|
+
file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/RNReactNativeSpec/*.cpp)
|
|
10
|
+
|
|
11
|
+
add_library(
|
|
12
|
+
react_codegen_RNReactNativeSpec
|
|
13
|
+
OBJECT
|
|
14
|
+
${react_codegen_SRCS}
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
target_include_directories(react_codegen_RNReactNativeSpec PUBLIC . react/renderer/components/RNReactNativeSpec)
|
|
18
|
+
|
|
19
|
+
target_link_libraries(
|
|
20
|
+
react_codegen_RNReactNativeSpec
|
|
21
|
+
fbjni
|
|
22
|
+
jsi
|
|
23
|
+
# We need to link different libraries based on whether we are building rncore or not, that's necessary
|
|
24
|
+
# because we want to break a circular dependency between react_codegen_rncore and reactnative
|
|
25
|
+
reactnative
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
target_compile_options(
|
|
29
|
+
react_codegen_RNReactNativeSpec
|
|
30
|
+
PRIVATE
|
|
31
|
+
-DLOG_TAG=\"ReactNative\"
|
|
32
|
+
-fexceptions
|
|
33
|
+
-frtti
|
|
34
|
+
-std=c++20
|
|
35
|
+
-Wall
|
|
36
|
+
)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJniCpp.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include "RNReactNativeSpec.h"
|
|
12
|
+
|
|
13
|
+
namespace facebook::react {
|
|
14
|
+
|
|
15
|
+
static facebook::jsi::Value __hostFunction_NativeReactNativeSpecJSI_installRustCrate(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
16
|
+
static jmethodID cachedMethodId = nullptr;
|
|
17
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, BooleanKind, "installRustCrate", "()Z", args, count, cachedMethodId);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static facebook::jsi::Value __hostFunction_NativeReactNativeSpecJSI_cleanupRustCrate(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
|
21
|
+
static jmethodID cachedMethodId = nullptr;
|
|
22
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, BooleanKind, "cleanupRustCrate", "()Z", args, count, cachedMethodId);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
NativeReactNativeSpecJSI::NativeReactNativeSpecJSI(const JavaTurboModule::InitParams ¶ms)
|
|
26
|
+
: JavaTurboModule(params) {
|
|
27
|
+
methodMap_["installRustCrate"] = MethodMetadata {0, __hostFunction_NativeReactNativeSpecJSI_installRustCrate};
|
|
28
|
+
methodMap_["cleanupRustCrate"] = MethodMetadata {0, __hostFunction_NativeReactNativeSpecJSI_cleanupRustCrate};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
std::shared_ptr<TurboModule> RNReactNativeSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) {
|
|
32
|
+
if (moduleName == "ReactNative") {
|
|
33
|
+
return std::make_shared<NativeReactNativeSpecJSI>(params);
|
|
34
|
+
}
|
|
35
|
+
return nullptr;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJniH.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include <ReactCommon/JavaTurboModule.h>
|
|
14
|
+
#include <ReactCommon/TurboModule.h>
|
|
15
|
+
#include <jsi/jsi.h>
|
|
16
|
+
|
|
17
|
+
namespace facebook::react {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* JNI C++ class for module 'NativeReactNative'
|
|
21
|
+
*/
|
|
22
|
+
class JSI_EXPORT NativeReactNativeSpecJSI : public JavaTurboModule {
|
|
23
|
+
public:
|
|
24
|
+
NativeReactNativeSpecJSI(const JavaTurboModule::InitParams ¶ms);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
JSI_EXPORT
|
|
29
|
+
std::shared_ptr<TurboModule> RNReactNativeSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms);
|
|
30
|
+
|
|
31
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleCpp.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include "RNReactNativeSpecJSI.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
static jsi::Value __hostFunction_NativeReactNativeCxxSpecJSI_installRustCrate(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
15
|
+
return static_cast<NativeReactNativeCxxSpecJSI *>(&turboModule)->installRustCrate(
|
|
16
|
+
rt
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
static jsi::Value __hostFunction_NativeReactNativeCxxSpecJSI_cleanupRustCrate(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
|
20
|
+
return static_cast<NativeReactNativeCxxSpecJSI *>(&turboModule)->cleanupRustCrate(
|
|
21
|
+
rt
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
NativeReactNativeCxxSpecJSI::NativeReactNativeCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
|
26
|
+
: TurboModule("ReactNative", jsInvoker) {
|
|
27
|
+
methodMap_["installRustCrate"] = MethodMetadata {0, __hostFunction_NativeReactNativeCxxSpecJSI_installRustCrate};
|
|
28
|
+
methodMap_["cleanupRustCrate"] = MethodMetadata {0, __hostFunction_NativeReactNativeCxxSpecJSI_cleanupRustCrate};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
} // namespace facebook::react
|
package/android/generated/jni/react/renderer/components/RNReactNativeSpec/RNReactNativeSpecJSI.h
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
+
*
|
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
+
* once the code is regenerated.
|
|
6
|
+
*
|
|
7
|
+
* @generated by codegen project: GenerateModuleH.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include <ReactCommon/TurboModule.h>
|
|
13
|
+
#include <react/bridging/Bridging.h>
|
|
14
|
+
|
|
15
|
+
namespace facebook::react {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class JSI_EXPORT NativeReactNativeCxxSpecJSI : public TurboModule {
|
|
19
|
+
protected:
|
|
20
|
+
NativeReactNativeCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
|
|
21
|
+
|
|
22
|
+
public:
|
|
23
|
+
virtual bool installRustCrate(jsi::Runtime &rt) = 0;
|
|
24
|
+
virtual bool cleanupRustCrate(jsi::Runtime &rt) = 0;
|
|
25
|
+
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
template <typename T>
|
|
29
|
+
class JSI_EXPORT NativeReactNativeCxxSpec : public TurboModule {
|
|
30
|
+
public:
|
|
31
|
+
jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
|
|
32
|
+
return delegate_.create(rt, propName);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
|
|
36
|
+
return delegate_.getPropertyNames(runtime);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static constexpr std::string_view kModuleName = "ReactNative";
|
|
40
|
+
|
|
41
|
+
protected:
|
|
42
|
+
NativeReactNativeCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
|
|
43
|
+
: TurboModule(std::string{NativeReactNativeCxxSpec::kModuleName}, jsInvoker),
|
|
44
|
+
delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
private:
|
|
48
|
+
class Delegate : public NativeReactNativeCxxSpecJSI {
|
|
49
|
+
public:
|
|
50
|
+
Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
|
|
51
|
+
NativeReactNativeCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
bool installRustCrate(jsi::Runtime &rt) override {
|
|
56
|
+
static_assert(
|
|
57
|
+
bridging::getParameterCount(&T::installRustCrate) == 1,
|
|
58
|
+
"Expected installRustCrate(...) to have 1 parameters");
|
|
59
|
+
|
|
60
|
+
return bridging::callFromJs<bool>(
|
|
61
|
+
rt, &T::installRustCrate, jsInvoker_, instance_);
|
|
62
|
+
}
|
|
63
|
+
bool cleanupRustCrate(jsi::Runtime &rt) override {
|
|
64
|
+
static_assert(
|
|
65
|
+
bridging::getParameterCount(&T::cleanupRustCrate) == 1,
|
|
66
|
+
"Expected cleanupRustCrate(...) to have 1 parameters");
|
|
67
|
+
|
|
68
|
+
return bridging::callFromJs<bool>(
|
|
69
|
+
rt, &T::cleanupRustCrate, jsInvoker_, instance_);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private:
|
|
73
|
+
friend class NativeReactNativeCxxSpec;
|
|
74
|
+
T *instance_;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
Delegate delegate_;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
package dev.eatsteak.rusaint.reactnative
|
|
3
|
+
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
6
|
+
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder
|
|
7
|
+
|
|
8
|
+
@ReactModule(name = ReactNativeModule.NAME)
|
|
9
|
+
class ReactNativeModule(reactContext: ReactApplicationContext) :
|
|
10
|
+
NativeReactNativeSpec(reactContext) {
|
|
11
|
+
|
|
12
|
+
override fun getName(): String {
|
|
13
|
+
return NAME
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Two native methods implemented in cpp-adapter.cpp, and ultimately
|
|
17
|
+
// rusaint-react-native.cpp
|
|
18
|
+
|
|
19
|
+
external fun nativeInstallRustCrate(runtimePointer: Long, callInvoker: CallInvokerHolder): Boolean
|
|
20
|
+
external fun nativeCleanupRustCrate(runtimePointer: Long): Boolean
|
|
21
|
+
|
|
22
|
+
override fun installRustCrate(): Boolean {
|
|
23
|
+
val context = this.reactApplicationContext
|
|
24
|
+
return nativeInstallRustCrate(
|
|
25
|
+
context.javaScriptContextHolder!!.get(),
|
|
26
|
+
context.jsCallInvokerHolder!!
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
override fun cleanupRustCrate(): Boolean {
|
|
31
|
+
return nativeCleanupRustCrate(
|
|
32
|
+
this.reactApplicationContext.javaScriptContextHolder!!.get()
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
companion object {
|
|
37
|
+
const val NAME = "ReactNative"
|
|
38
|
+
|
|
39
|
+
init {
|
|
40
|
+
System.loadLibrary("rusaint-react-native")
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
package dev.eatsteak.rusaint.reactnative
|
|
3
|
+
|
|
4
|
+
import com.facebook.react.TurboReactPackage
|
|
5
|
+
import com.facebook.react.bridge.NativeModule
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
8
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
9
|
+
import java.util.HashMap
|
|
10
|
+
|
|
11
|
+
class ReactNativePackage : TurboReactPackage() {
|
|
12
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
13
|
+
return if (name == ReactNativeModule.NAME) {
|
|
14
|
+
ReactNativeModule(reactContext)
|
|
15
|
+
} else {
|
|
16
|
+
null
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
21
|
+
return ReactModuleInfoProvider {
|
|
22
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
23
|
+
moduleInfos[ReactNativeModule.NAME] = ReactModuleInfo(
|
|
24
|
+
ReactNativeModule.NAME,
|
|
25
|
+
ReactNativeModule.NAME,
|
|
26
|
+
false, // canOverrideExistingModule
|
|
27
|
+
false, // needsEagerInit
|
|
28
|
+
false, // isCxxModule
|
|
29
|
+
true // isTurboModule
|
|
30
|
+
)
|
|
31
|
+
moduleInfos
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|