mirror of
https://github.com/EthanShoeDev/fressh.git
synced 2026-01-11 14:22:51 +00:00
add calc getting started to main app
This commit is contained in:
@@ -84,3 +84,7 @@ android/generated
|
||||
|
||||
# React Native Nitro Modules
|
||||
nitrogen/
|
||||
|
||||
# From uniffi-bindgen-react-native
|
||||
rust_modules/
|
||||
*.a
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 EthanShoeDev
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
76
packages/react-native-uniffi-russh/android/CMakeLists.txt
Normal file
76
packages/react-native-uniffi-russh/android/CMakeLists.txt
Normal file
@@ -0,0 +1,76 @@
|
||||
# Generated by uniffi-bindgen-react-native
|
||||
cmake_minimum_required(VERSION 3.9.0)
|
||||
project(UniffiRussh)
|
||||
|
||||
set (CMAKE_VERBOSE_MAKEFILE ON)
|
||||
set (CMAKE_CXX_STANDARD 17)
|
||||
|
||||
# Resolve the path to the uniffi-bindgen-react-native package
|
||||
execute_process(
|
||||
COMMAND node -p "require.resolve('uniffi-bindgen-react-native/package.json')"
|
||||
OUTPUT_VARIABLE UNIFFI_BINDGEN_PATH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
# Get the directory; get_filename_component and cmake_path will normalize
|
||||
# paths with Windows path separators.
|
||||
get_filename_component(UNIFFI_BINDGEN_PATH "${UNIFFI_BINDGEN_PATH}" DIRECTORY)
|
||||
|
||||
# Specifies a path to native header files.
|
||||
include_directories(
|
||||
../cpp
|
||||
../cpp/generated
|
||||
|
||||
${UNIFFI_BINDGEN_PATH}/cpp/includes
|
||||
)
|
||||
|
||||
add_library(react-native-uniffi-russh SHARED
|
||||
../cpp/react-native-uniffi-russh.cpp
|
||||
../cpp/generated/foobar.cpp
|
||||
cpp-adapter.cpp
|
||||
)
|
||||
|
||||
# Set C++ compiler flags
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
||||
|
||||
cmake_path(
|
||||
SET MY_RUST_LIB
|
||||
${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libfoobar.a
|
||||
NORMALIZE
|
||||
)
|
||||
add_library(my_rust_lib STATIC IMPORTED)
|
||||
set_target_properties(my_rust_lib PROPERTIES IMPORTED_LOCATION ${MY_RUST_LIB})
|
||||
|
||||
# Add ReactAndroid libraries, being careful to account for different versions.
|
||||
find_package(ReactAndroid REQUIRED CONFIG)
|
||||
find_library(LOGCAT log)
|
||||
|
||||
# REACTNATIVE_MERGED_SO seems to be only be set in a build.gradle.kt file,
|
||||
# which we don't use. Thus falling back to version number sniffing.
|
||||
if (ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
||||
set(REACTNATIVE_MERGED_SO true)
|
||||
endif()
|
||||
|
||||
# https://github.com/react-native-community/discussions-and-proposals/discussions/816
|
||||
# This if-then-else can be removed once this library does not support version below 0.76
|
||||
if (REACTNATIVE_MERGED_SO)
|
||||
target_link_libraries(react-native-uniffi-russh ReactAndroid::reactnative)
|
||||
else()
|
||||
target_link_libraries(react-native-uniffi-russh
|
||||
ReactAndroid::turbomodulejsijni
|
||||
ReactAndroid::react_nativemodule_core
|
||||
)
|
||||
endif()
|
||||
|
||||
find_package(fbjni REQUIRED CONFIG)
|
||||
target_link_libraries(
|
||||
react-native-uniffi-russh
|
||||
fbjni::fbjni
|
||||
ReactAndroid::jsi
|
||||
${LOGCAT}
|
||||
my_rust_lib
|
||||
)
|
||||
@@ -1,7 +1,8 @@
|
||||
// Generated by uniffi-bindgen-react-native
|
||||
|
||||
buildscript {
|
||||
ext.getExtOrDefault = {name ->
|
||||
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['UniffiRussh_' + name]
|
||||
}
|
||||
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
||||
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["DummyLibForAndroid_kotlinVersion"]
|
||||
|
||||
repositories {
|
||||
google()
|
||||
@@ -9,30 +10,83 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:8.7.2"
|
||||
classpath "com.android.tools.build:gradle:7.2.1"
|
||||
// noinspection DifferentKotlinGradleVersion
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
def reactNativeArchitectures() {
|
||||
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
||||
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
||||
}
|
||||
|
||||
def isNewArchitectureEnabled() {
|
||||
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
||||
}
|
||||
|
||||
apply plugin: "com.android.library"
|
||||
apply plugin: "kotlin-android"
|
||||
|
||||
apply plugin: "com.facebook.react"
|
||||
if (isNewArchitectureEnabled()) {
|
||||
apply plugin: "com.facebook.react"
|
||||
}
|
||||
|
||||
def getExtOrDefault(name) {
|
||||
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["UniffiRussh_" + name]
|
||||
}
|
||||
|
||||
def getExtOrIntegerDefault(name) {
|
||||
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["UniffiRussh_" + name]).toInteger()
|
||||
}
|
||||
|
||||
android {
|
||||
namespace "com.uniffirussh"
|
||||
def supportsNamespace() {
|
||||
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
||||
def major = parsed[0].toInteger()
|
||||
def minor = parsed[1].toInteger()
|
||||
|
||||
// Namespace support was added in 7.3.0
|
||||
return (major == 7 && minor >= 3) || major >= 8
|
||||
}
|
||||
|
||||
android {
|
||||
if (supportsNamespace()) {
|
||||
namespace "com.uniffirussh"
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ndkVersion getExtOrDefault("ndkVersion")
|
||||
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
||||
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
||||
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
||||
consumerProguardFiles 'proguard-rules.pro'
|
||||
|
||||
buildFeatures {
|
||||
prefab true
|
||||
}
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments '-DANDROID_STL=c++_shared'
|
||||
abiFilters (*reactNativeArchitectures())
|
||||
}
|
||||
}
|
||||
ndk {
|
||||
abiFilters "arm64-v8a", "armeabi-v7a", "x86", "x86_64"
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path "CMakeLists.txt"
|
||||
}
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
@@ -56,10 +110,12 @@ android {
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java.srcDirs += [
|
||||
"generated/java",
|
||||
"generated/jni"
|
||||
]
|
||||
if (isNewArchitectureEnabled()) {
|
||||
java.srcDirs += [
|
||||
"generated/java",
|
||||
"generated/jni"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,6 +128,17 @@ repositories {
|
||||
def kotlin_version = getExtOrDefault("kotlinVersion")
|
||||
|
||||
dependencies {
|
||||
implementation "com.facebook.react:react-android"
|
||||
// For < 0.71, this will be from the local maven repo
|
||||
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
||||
//noinspection GradleDynamicVersion
|
||||
implementation "com.facebook.react:react-native:+"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
}
|
||||
|
||||
if (isNewArchitectureEnabled()) {
|
||||
react {
|
||||
jsRootDir = file("../src/")
|
||||
libraryName = "UniffiRussh"
|
||||
codegenJavaPackageName = "com.uniffirussh"
|
||||
}
|
||||
}
|
||||
|
||||
63
packages/react-native-uniffi-russh/android/cpp-adapter.cpp
Normal file
63
packages/react-native-uniffi-russh/android/cpp-adapter.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
// Generated by uniffi-bindgen-react-native
|
||||
#include <jni.h>
|
||||
#include <jsi/jsi.h>
|
||||
#include <ReactCommon/CallInvokerHolder.h>
|
||||
#include "react-native-uniffi-russh.h"
|
||||
|
||||
namespace jsi = facebook::jsi;
|
||||
namespace react = facebook::react;
|
||||
|
||||
// Automated testing checks Java_com_uniffirussh_UniffiRusshModule and uniffirussh
|
||||
// by comparing the whole line here.
|
||||
/*
|
||||
Java_com_uniffirussh_UniffiRusshModule_nativeMultiply(JNIEnv *env, jclass type, jdouble a, jdouble b) {
|
||||
return uniffirussh::multiply(a, b);
|
||||
}
|
||||
*/
|
||||
|
||||
// Installer coming from UniffiRusshModule
|
||||
extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_uniffirussh_UniffiRusshModule_nativeInstallRustCrate(
|
||||
JNIEnv *env,
|
||||
jclass type,
|
||||
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 uniffirussh::installRustCrate(*runtime, jsCallInvoker);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_uniffirussh_UniffiRusshModule_nativeCleanupRustCrate(JNIEnv *env, jclass type, jlong rtPtr) {
|
||||
auto runtime = reinterpret_cast<jsi::Runtime *>(rtPtr);
|
||||
return uniffirussh::cleanupRustCrate(*runtime);
|
||||
}
|
||||
@@ -1,2 +1,5 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
</manifest>
|
||||
|
||||
<!-- Generated by uniffi-bindgen-react-native -->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.uniffirussh">
|
||||
</manifest>
|
||||
@@ -0,0 +1,43 @@
|
||||
// Generated by uniffi-bindgen-react-native
|
||||
package com.uniffirussh
|
||||
|
||||
import com.facebook.react.bridge.ReactApplicationContext
|
||||
import com.facebook.react.module.annotations.ReactModule
|
||||
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder
|
||||
|
||||
@ReactModule(name = UniffiRusshModule.NAME)
|
||||
class UniffiRusshModule(reactContext: ReactApplicationContext) :
|
||||
NativeUniffiRusshSpec(reactContext) {
|
||||
|
||||
override fun getName(): String {
|
||||
return NAME
|
||||
}
|
||||
|
||||
// Two native methods implemented in cpp-adapter.cpp, and ultimately
|
||||
// react-native-uniffi-russh.cpp
|
||||
|
||||
external fun nativeInstallRustCrate(runtimePointer: Long, callInvoker: CallInvokerHolder): Boolean
|
||||
external fun nativeCleanupRustCrate(runtimePointer: Long): Boolean
|
||||
|
||||
override fun installRustCrate(): Boolean {
|
||||
val context = this.reactApplicationContext
|
||||
return nativeInstallRustCrate(
|
||||
context.javaScriptContextHolder!!.get(),
|
||||
context.jsCallInvokerHolder!!
|
||||
)
|
||||
}
|
||||
|
||||
override fun cleanupRustCrate(): Boolean {
|
||||
return nativeCleanupRustCrate(
|
||||
this.reactApplicationContext.javaScriptContextHolder!!.get()
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val NAME = "UniffiRussh"
|
||||
|
||||
init {
|
||||
System.loadLibrary("react-native-uniffi-russh")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Generated by uniffi-bindgen-react-native
|
||||
package com.uniffirussh
|
||||
|
||||
import com.facebook.react.TurboReactPackage
|
||||
import com.facebook.react.bridge.NativeModule
|
||||
import com.facebook.react.bridge.ReactApplicationContext
|
||||
import com.facebook.react.module.model.ReactModuleInfo
|
||||
import com.facebook.react.module.model.ReactModuleInfoProvider
|
||||
import java.util.HashMap
|
||||
|
||||
class UniffiRusshPackage : TurboReactPackage() {
|
||||
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
||||
return if (name == UniffiRusshModule.NAME) {
|
||||
UniffiRusshModule(reactContext)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
||||
return ReactModuleInfoProvider {
|
||||
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
||||
moduleInfos[UniffiRusshModule.NAME] = ReactModuleInfo(
|
||||
UniffiRusshModule.NAME,
|
||||
UniffiRusshModule.NAME,
|
||||
false, // canOverrideExistingModule
|
||||
false, // needsEagerInit
|
||||
false, // isCxxModule
|
||||
true // isTurboModule
|
||||
)
|
||||
moduleInfos
|
||||
}
|
||||
}
|
||||
}
|
||||
2965
packages/react-native-uniffi-russh/cpp/generated/foobar.cpp
Normal file
2965
packages/react-native-uniffi-russh/cpp/generated/foobar.cpp
Normal file
File diff suppressed because it is too large
Load Diff
85
packages/react-native-uniffi-russh/cpp/generated/foobar.hpp
Normal file
85
packages/react-native-uniffi-russh/cpp/generated/foobar.hpp
Normal file
@@ -0,0 +1,85 @@
|
||||
// This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate.
|
||||
// Trust me, you don't want to mess with it!
|
||||
#pragma once
|
||||
#include <jsi/jsi.h>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <ReactCommon/CallInvoker.h>
|
||||
#include "UniffiCallInvoker.h"
|
||||
|
||||
namespace react = facebook::react;
|
||||
namespace jsi = facebook::jsi;
|
||||
|
||||
class NativeFoobar : public jsi::HostObject {
|
||||
private:
|
||||
// For calling back into JS from Rust.
|
||||
std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker;
|
||||
|
||||
protected:
|
||||
std::map<std::string,jsi::Value> props;
|
||||
jsi::Value cpp_uniffi_internal_fn_func_ffi__string_to_byte_length(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_internal_fn_func_ffi__string_to_arraybuffer(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_internal_fn_func_ffi__arraybuffer_to_string(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_fn_clone_binaryoperator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_fn_free_binaryoperator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_fn_init_callback_vtable_binaryoperator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_fn_method_binaryoperator_perform(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_fn_clone_calculator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_fn_free_calculator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_fn_constructor_calculator_new(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_fn_method_calculator_calculate(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_fn_method_calculator_calculate_more(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_fn_method_calculator_last_result(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_fn_clone_safeaddition(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_fn_free_safeaddition(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_fn_constructor_safeaddition_new(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_fn_method_safeaddition_perform(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_fn_clone_safedivision(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_fn_free_safedivision(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_fn_constructor_safedivision_new(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_fn_method_safedivision_perform(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_fn_func_safe_addition_operator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_fn_func_safe_division_operator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_checksum_func_safe_addition_operator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_checksum_func_safe_division_operator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_checksum_method_binaryoperator_perform(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_checksum_method_calculator_calculate(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_checksum_method_calculator_calculate_more(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_checksum_method_calculator_last_result(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_checksum_method_safeaddition_perform(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_checksum_method_safedivision_perform(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_checksum_constructor_calculator_new(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_checksum_constructor_safeaddition_new(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_foobar_checksum_constructor_safedivision_new(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_ffi_foobar_uniffi_contract_version(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_internal_fn_method_binaryoperator_ffi__bless_pointer(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_internal_fn_method_calculator_ffi__bless_pointer(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_internal_fn_method_safeaddition_ffi__bless_pointer(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
jsi::Value cpp_uniffi_internal_fn_method_safedivision_ffi__bless_pointer(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count);
|
||||
|
||||
public:
|
||||
NativeFoobar(jsi::Runtime &rt, std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker);
|
||||
virtual ~NativeFoobar();
|
||||
|
||||
/**
|
||||
* The entry point into the crate.
|
||||
*
|
||||
* React Native must call `NativeFoobar.registerModule(rt, callInvoker)` before using
|
||||
* the Javascript interface.
|
||||
*/
|
||||
static void registerModule(jsi::Runtime &rt, std::shared_ptr<react::CallInvoker> callInvoker);
|
||||
|
||||
/**
|
||||
* Some cleanup into the crate goes here.
|
||||
*
|
||||
* Current implementation is empty, however, this is not guaranteed to always be the case.
|
||||
*
|
||||
* Clients should call `NativeFoobar.unregisterModule(rt)` after final use where possible.
|
||||
*/
|
||||
static void unregisterModule(jsi::Runtime &rt);
|
||||
|
||||
virtual jsi::Value get(jsi::Runtime& rt, const jsi::PropNameID& name);
|
||||
virtual void set(jsi::Runtime& rt,const jsi::PropNameID& name,const jsi::Value& value);
|
||||
virtual std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& rt);
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
// Generated by uniffi-bindgen-react-native
|
||||
#include "react-native-uniffi-russh.h"
|
||||
#include "generated/foobar.hpp"
|
||||
|
||||
namespace uniffirussh {
|
||||
using namespace facebook;
|
||||
|
||||
uint8_t installRustCrate(jsi::Runtime &runtime, std::shared_ptr<react::CallInvoker> callInvoker) {
|
||||
NativeFoobar::registerModule(runtime, callInvoker);
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t cleanupRustCrate(jsi::Runtime &runtime) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef UNIFFIRUSSH_H
|
||||
#define UNIFFIRUSSH_H
|
||||
// Generated by uniffi-bindgen-react-native
|
||||
#include <cstdint>
|
||||
#include <jsi/jsi.h>
|
||||
#include <ReactCommon/CallInvoker.h>
|
||||
|
||||
namespace uniffirussh {
|
||||
using namespace facebook;
|
||||
|
||||
uint8_t installRustCrate(jsi::Runtime &runtime, std::shared_ptr<react::CallInvoker> callInvoker);
|
||||
uint8_t cleanupRustCrate(jsi::Runtime &runtime);
|
||||
}
|
||||
|
||||
#endif /* UNIFFIRUSSH_H */
|
||||
@@ -24,6 +24,6 @@ export default defineConfig([
|
||||
},
|
||||
},
|
||||
{
|
||||
ignores: ['node_modules/', 'lib/'],
|
||||
ignores: ['node_modules/', 'lib/', 'src/generated/'],
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "react-native-uniffi-russh",
|
||||
"version": "0.1.0",
|
||||
"name": "@fressh/react-native-uniffi-russh",
|
||||
"description": "Uniffi bindings for russh",
|
||||
"version": "0.0.1",
|
||||
"main": "./lib/module/index.js",
|
||||
"types": "./lib/typescript/src/index.d.ts",
|
||||
"exports": {
|
||||
@@ -33,7 +33,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"ubrn:ios": "ubrn build ios --and-generate && (cd example/ios && pod install)",
|
||||
"ubrn:android": "ubrn build android --and-generate",
|
||||
"ubrn:android": "ubrn build android --and-generate --release",
|
||||
"ubrn:web": "ubrn build web",
|
||||
"ubrn:checkout": "ubrn checkout",
|
||||
"ubrn:clean": "rm -rfv cpp/ android/CMakeLists.txt android/src/main/java android/*.cpp ios/ src/Native* src/index.*ts* src/generated/",
|
||||
@@ -54,16 +54,10 @@
|
||||
"url": "git+https://github.com/EthanShoeDev/fressh.git"
|
||||
},
|
||||
"author": "EthanShoeDev <13422990+EthanShoeDev@users.noreply.github.com> (https://github.com/EthanShoeDev)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/EthanShoeDev/fressh/issues"
|
||||
},
|
||||
"homepage": "https://github.com/EthanShoeDev/fressh#readme",
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/config-conventional": "^19.8.1",
|
||||
"@eslint/compat": "^1.3.2",
|
||||
"@eslint/eslintrc": "^3.3.1",
|
||||
"@eslint/js": "^9.35.0",
|
||||
@@ -73,7 +67,6 @@
|
||||
"@release-it/conventional-changelog": "^10.0.1",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/react": "^19.1.0",
|
||||
"commitlint": "^19.8.1",
|
||||
"del-cli": "^6.0.0",
|
||||
"eslint": "^9.35.0",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
@@ -91,9 +84,6 @@
|
||||
"react": "*",
|
||||
"react-native": "*"
|
||||
},
|
||||
"workspaces": [
|
||||
"example"
|
||||
],
|
||||
"packageManager": "pnpm@10.15.1",
|
||||
"jest": {
|
||||
"preset": "react-native",
|
||||
@@ -102,30 +92,6 @@
|
||||
"<rootDir>/lib/"
|
||||
]
|
||||
},
|
||||
"commitlint": {
|
||||
"extends": [
|
||||
"@commitlint/config-conventional"
|
||||
]
|
||||
},
|
||||
"release-it": {
|
||||
"git": {
|
||||
"commitMessage": "chore: release ${version}",
|
||||
"tagName": "v${version}"
|
||||
},
|
||||
"npm": {
|
||||
"publish": true
|
||||
},
|
||||
"github": {
|
||||
"release": true
|
||||
},
|
||||
"plugins": {
|
||||
"@release-it/conventional-changelog": {
|
||||
"preset": {
|
||||
"name": "angular"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"prettier": {
|
||||
"quoteProps": "consistent",
|
||||
"singleQuote": true,
|
||||
|
||||
10
packages/react-native-uniffi-russh/src/NativeUniffiRussh.ts
Normal file
10
packages/react-native-uniffi-russh/src/NativeUniffiRussh.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
// Generated by uniffi-bindgen-react-native
|
||||
import type { TurboModule } from 'react-native';
|
||||
import { TurboModuleRegistry } from 'react-native';
|
||||
|
||||
export interface Spec extends TurboModule {
|
||||
installRustCrate(): boolean;
|
||||
cleanupRustCrate(): boolean;
|
||||
}
|
||||
|
||||
export default TurboModuleRegistry.getEnforcing<Spec>('UniffiRussh');
|
||||
306
packages/react-native-uniffi-russh/src/generated/foobar-ffi.ts
Normal file
306
packages/react-native-uniffi-russh/src/generated/foobar-ffi.ts
Normal file
@@ -0,0 +1,306 @@
|
||||
// This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate.
|
||||
// Trust me, you don't want to mess with it!
|
||||
|
||||
import {
|
||||
type StructuralEquality as UniffiStructuralEquality,
|
||||
type UniffiForeignFuture as RuntimeUniffiForeignFuture,
|
||||
type UniffiRustCallStatus,
|
||||
type UniffiRustArcPtr,
|
||||
type UniffiRustFutureContinuationCallback as RuntimeUniffiRustFutureContinuationCallback,
|
||||
type UniffiResult,
|
||||
} from 'uniffi-bindgen-react-native';
|
||||
|
||||
interface NativeModuleInterface {
|
||||
ubrn_uniffi_internal_fn_func_ffi__string_to_byte_length(
|
||||
string: string,
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): number;
|
||||
ubrn_uniffi_internal_fn_func_ffi__string_to_arraybuffer(
|
||||
string: string,
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): Uint8Array;
|
||||
ubrn_uniffi_internal_fn_func_ffi__arraybuffer_to_string(
|
||||
buffer: Uint8Array,
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): string;
|
||||
ubrn_uniffi_foobar_fn_clone_binaryoperator(
|
||||
ptr: bigint,
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): bigint;
|
||||
ubrn_uniffi_foobar_fn_free_binaryoperator(
|
||||
ptr: bigint,
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): void;
|
||||
ubrn_uniffi_foobar_fn_init_callback_vtable_binaryoperator(
|
||||
vtable: UniffiVTableCallbackInterfaceBinaryOperator
|
||||
): void;
|
||||
ubrn_uniffi_foobar_fn_method_binaryoperator_perform(
|
||||
ptr: bigint,
|
||||
lhs: bigint,
|
||||
rhs: bigint,
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): bigint;
|
||||
ubrn_uniffi_foobar_fn_clone_calculator(
|
||||
ptr: bigint,
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): bigint;
|
||||
ubrn_uniffi_foobar_fn_free_calculator(
|
||||
ptr: bigint,
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): void;
|
||||
ubrn_uniffi_foobar_fn_constructor_calculator_new(
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): bigint;
|
||||
ubrn_uniffi_foobar_fn_method_calculator_calculate(
|
||||
ptr: bigint,
|
||||
op: bigint,
|
||||
lhs: bigint,
|
||||
rhs: bigint,
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): bigint;
|
||||
ubrn_uniffi_foobar_fn_method_calculator_calculate_more(
|
||||
ptr: bigint,
|
||||
op: bigint,
|
||||
rhs: bigint,
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): bigint;
|
||||
ubrn_uniffi_foobar_fn_method_calculator_last_result(
|
||||
ptr: bigint,
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): Uint8Array;
|
||||
ubrn_uniffi_foobar_fn_clone_safeaddition(
|
||||
ptr: bigint,
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): bigint;
|
||||
ubrn_uniffi_foobar_fn_free_safeaddition(
|
||||
ptr: bigint,
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): void;
|
||||
ubrn_uniffi_foobar_fn_constructor_safeaddition_new(
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): bigint;
|
||||
ubrn_uniffi_foobar_fn_method_safeaddition_perform(
|
||||
ptr: bigint,
|
||||
lhs: bigint,
|
||||
rhs: bigint,
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): bigint;
|
||||
ubrn_uniffi_foobar_fn_clone_safedivision(
|
||||
ptr: bigint,
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): bigint;
|
||||
ubrn_uniffi_foobar_fn_free_safedivision(
|
||||
ptr: bigint,
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): void;
|
||||
ubrn_uniffi_foobar_fn_constructor_safedivision_new(
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): bigint;
|
||||
ubrn_uniffi_foobar_fn_method_safedivision_perform(
|
||||
ptr: bigint,
|
||||
lhs: bigint,
|
||||
rhs: bigint,
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): bigint;
|
||||
ubrn_uniffi_foobar_fn_func_safe_addition_operator(
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): bigint;
|
||||
ubrn_uniffi_foobar_fn_func_safe_division_operator(
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): bigint;
|
||||
ubrn_uniffi_foobar_checksum_func_safe_addition_operator(): number;
|
||||
ubrn_uniffi_foobar_checksum_func_safe_division_operator(): number;
|
||||
ubrn_uniffi_foobar_checksum_method_binaryoperator_perform(): number;
|
||||
ubrn_uniffi_foobar_checksum_method_calculator_calculate(): number;
|
||||
ubrn_uniffi_foobar_checksum_method_calculator_calculate_more(): number;
|
||||
ubrn_uniffi_foobar_checksum_method_calculator_last_result(): number;
|
||||
ubrn_uniffi_foobar_checksum_method_safeaddition_perform(): number;
|
||||
ubrn_uniffi_foobar_checksum_method_safedivision_perform(): number;
|
||||
ubrn_uniffi_foobar_checksum_constructor_calculator_new(): number;
|
||||
ubrn_uniffi_foobar_checksum_constructor_safeaddition_new(): number;
|
||||
ubrn_uniffi_foobar_checksum_constructor_safedivision_new(): number;
|
||||
ubrn_ffi_foobar_uniffi_contract_version(): number;
|
||||
ubrn_uniffi_internal_fn_method_binaryoperator_ffi__bless_pointer(
|
||||
pointer: bigint,
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): UniffiRustArcPtr;
|
||||
ubrn_uniffi_internal_fn_method_calculator_ffi__bless_pointer(
|
||||
pointer: bigint,
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): UniffiRustArcPtr;
|
||||
ubrn_uniffi_internal_fn_method_safeaddition_ffi__bless_pointer(
|
||||
pointer: bigint,
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): UniffiRustArcPtr;
|
||||
ubrn_uniffi_internal_fn_method_safedivision_ffi__bless_pointer(
|
||||
pointer: bigint,
|
||||
uniffi_out_err: UniffiRustCallStatus
|
||||
): UniffiRustArcPtr;
|
||||
}
|
||||
|
||||
// Casting globalThis to any allows us to look for `NativeFoobar`
|
||||
// if it was added via JSI.
|
||||
//
|
||||
// We use a getter here rather than simply `globalThis.NativeFoobar` so that
|
||||
// if/when the startup sequence isn't just so, an empty value isn't inadvertantly cached.
|
||||
const getter: () => NativeModuleInterface = () =>
|
||||
(globalThis as any).NativeFoobar;
|
||||
export default getter;
|
||||
|
||||
// Structs and function types for calling back into Typescript from Rust.
|
||||
export type UniffiRustFutureContinuationCallback = (
|
||||
data: bigint,
|
||||
pollResult: number
|
||||
) => void;
|
||||
type UniffiForeignFutureFree = (handle: bigint) => void;
|
||||
type UniffiCallbackInterfaceFree = (handle: bigint) => void;
|
||||
export type UniffiForeignFuture = {
|
||||
handle: bigint;
|
||||
free: UniffiForeignFutureFree;
|
||||
};
|
||||
export type UniffiForeignFutureStructU8 = {
|
||||
returnValue: number;
|
||||
callStatus: UniffiRustCallStatus;
|
||||
};
|
||||
export type UniffiForeignFutureCompleteU8 = (
|
||||
callbackData: bigint,
|
||||
result: UniffiForeignFutureStructU8
|
||||
) => void;
|
||||
export type UniffiForeignFutureStructI8 = {
|
||||
returnValue: number;
|
||||
callStatus: UniffiRustCallStatus;
|
||||
};
|
||||
export type UniffiForeignFutureCompleteI8 = (
|
||||
callbackData: bigint,
|
||||
result: UniffiForeignFutureStructI8
|
||||
) => void;
|
||||
export type UniffiForeignFutureStructU16 = {
|
||||
returnValue: number;
|
||||
callStatus: UniffiRustCallStatus;
|
||||
};
|
||||
export type UniffiForeignFutureCompleteU16 = (
|
||||
callbackData: bigint,
|
||||
result: UniffiForeignFutureStructU16
|
||||
) => void;
|
||||
export type UniffiForeignFutureStructI16 = {
|
||||
returnValue: number;
|
||||
callStatus: UniffiRustCallStatus;
|
||||
};
|
||||
export type UniffiForeignFutureCompleteI16 = (
|
||||
callbackData: bigint,
|
||||
result: UniffiForeignFutureStructI16
|
||||
) => void;
|
||||
export type UniffiForeignFutureStructU32 = {
|
||||
returnValue: number;
|
||||
callStatus: UniffiRustCallStatus;
|
||||
};
|
||||
export type UniffiForeignFutureCompleteU32 = (
|
||||
callbackData: bigint,
|
||||
result: UniffiForeignFutureStructU32
|
||||
) => void;
|
||||
export type UniffiForeignFutureStructI32 = {
|
||||
returnValue: number;
|
||||
callStatus: UniffiRustCallStatus;
|
||||
};
|
||||
export type UniffiForeignFutureCompleteI32 = (
|
||||
callbackData: bigint,
|
||||
result: UniffiForeignFutureStructI32
|
||||
) => void;
|
||||
export type UniffiForeignFutureStructU64 = {
|
||||
returnValue: bigint;
|
||||
callStatus: UniffiRustCallStatus;
|
||||
};
|
||||
export type UniffiForeignFutureCompleteU64 = (
|
||||
callbackData: bigint,
|
||||
result: UniffiForeignFutureStructU64
|
||||
) => void;
|
||||
export type UniffiForeignFutureStructI64 = {
|
||||
returnValue: bigint;
|
||||
callStatus: UniffiRustCallStatus;
|
||||
};
|
||||
export type UniffiForeignFutureCompleteI64 = (
|
||||
callbackData: bigint,
|
||||
result: UniffiForeignFutureStructI64
|
||||
) => void;
|
||||
export type UniffiForeignFutureStructF32 = {
|
||||
returnValue: number;
|
||||
callStatus: UniffiRustCallStatus;
|
||||
};
|
||||
export type UniffiForeignFutureCompleteF32 = (
|
||||
callbackData: bigint,
|
||||
result: UniffiForeignFutureStructF32
|
||||
) => void;
|
||||
export type UniffiForeignFutureStructF64 = {
|
||||
returnValue: number;
|
||||
callStatus: UniffiRustCallStatus;
|
||||
};
|
||||
export type UniffiForeignFutureCompleteF64 = (
|
||||
callbackData: bigint,
|
||||
result: UniffiForeignFutureStructF64
|
||||
) => void;
|
||||
export type UniffiForeignFutureStructPointer = {
|
||||
returnValue: bigint;
|
||||
callStatus: UniffiRustCallStatus;
|
||||
};
|
||||
export type UniffiForeignFutureCompletePointer = (
|
||||
callbackData: bigint,
|
||||
result: UniffiForeignFutureStructPointer
|
||||
) => void;
|
||||
export type UniffiForeignFutureStructRustBuffer = {
|
||||
returnValue: Uint8Array;
|
||||
callStatus: UniffiRustCallStatus;
|
||||
};
|
||||
export type UniffiForeignFutureCompleteRustBuffer = (
|
||||
callbackData: bigint,
|
||||
result: UniffiForeignFutureStructRustBuffer
|
||||
) => void;
|
||||
export type UniffiForeignFutureStructVoid = {
|
||||
callStatus: UniffiRustCallStatus;
|
||||
};
|
||||
export type UniffiForeignFutureCompleteVoid = (
|
||||
callbackData: bigint,
|
||||
result: UniffiForeignFutureStructVoid
|
||||
) => void;
|
||||
type UniffiCallbackInterfaceBinaryOperatorMethod0 = (
|
||||
uniffiHandle: bigint,
|
||||
lhs: bigint,
|
||||
rhs: bigint
|
||||
) => UniffiResult<bigint>;
|
||||
export type UniffiVTableCallbackInterfaceBinaryOperator = {
|
||||
perform: UniffiCallbackInterfaceBinaryOperatorMethod0;
|
||||
uniffiFree: UniffiCallbackInterfaceFree;
|
||||
};
|
||||
|
||||
// UniffiRustFutureContinuationCallback is generated as part of the component interface's
|
||||
// ffi_definitions. However, we need it in the runtime.
|
||||
// We could:
|
||||
// (a) do some complicated template logic to ensure the declaration is not generated here (possible)
|
||||
// (b) import the generated declaration into the runtime (m a y b e) or…
|
||||
// (c) generate the declaration anyway, and use a different declaration in the runtime.
|
||||
//
|
||||
// We chose (c) here as the simplest. In addition, we perform a compile time check that
|
||||
// the two versions of `UniffiRustFutureContinuationCallback` are structurally equivalent.
|
||||
//
|
||||
// If you see the error:
|
||||
// ```
|
||||
// Type 'true' is not assignable to type 'false'.(2322)
|
||||
// ```
|
||||
// Then a new version of uniffi has changed the signature of the callback. Most likely, code in
|
||||
// `typescript/src/async-rust-call.ts` will need to be changed.
|
||||
//
|
||||
// If you see the error:
|
||||
// ```
|
||||
// Cannot find name 'UniffiRustFutureContinuationCallback'. Did you mean 'RuntimeUniffiRustFutureContinuationCallback'?(2552)
|
||||
// ```
|
||||
// then you may not be using callbacks or promises, and uniffi is now not generating Futures and callbacks.
|
||||
// You should not generate this if that is the case.
|
||||
//
|
||||
// ('You' being the bindings generator maintainer).
|
||||
const isRustFutureContinuationCallbackTypeCompatible: UniffiStructuralEquality<
|
||||
RuntimeUniffiRustFutureContinuationCallback,
|
||||
UniffiRustFutureContinuationCallback
|
||||
> = true;
|
||||
const isUniffiForeignFutureTypeCompatible: UniffiStructuralEquality<
|
||||
RuntimeUniffiForeignFuture,
|
||||
UniffiForeignFuture
|
||||
> = true;
|
||||
1271
packages/react-native-uniffi-russh/src/generated/foobar.ts
Normal file
1271
packages/react-native-uniffi-russh/src/generated/foobar.ts
Normal file
File diff suppressed because it is too large
Load Diff
41
packages/react-native-uniffi-russh/src/index.tsx
Normal file
41
packages/react-native-uniffi-russh/src/index.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
// Generated by uniffi-bindgen-react-native
|
||||
import installer from './NativeUniffiRussh';
|
||||
|
||||
// Register the rust crate with Hermes
|
||||
// - the boolean flag ensures this loads exactly once, even if the JS
|
||||
// code is reloaded (e.g. during development with metro).
|
||||
let rustInstalled = false;
|
||||
if (!rustInstalled) {
|
||||
installer.installRustCrate();
|
||||
rustInstalled = true;
|
||||
}
|
||||
|
||||
// Export the generated bindings to the app.
|
||||
export * from './generated/foobar';
|
||||
|
||||
// Now import the bindings so we can:
|
||||
// - intialize them
|
||||
// - export them as namespaced objects as the default export.
|
||||
import * as foobar from './generated/foobar';
|
||||
|
||||
// Initialize the generated bindings: mostly checksums, but also callbacks.
|
||||
// - the boolean flag ensures this loads exactly once, even if the JS code
|
||||
// is reloaded (e.g. during development with metro).
|
||||
let initialized = false;
|
||||
if (!initialized) {
|
||||
foobar.default.initialize();
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
// This provides parity with the index.web.ts version of this file.
|
||||
// The web version relies on an asynchronous fetch, which this doesn't
|
||||
// need, so we just no-op.
|
||||
export async function uniffiInitAsync() {
|
||||
// NOOP.
|
||||
}
|
||||
|
||||
// Export the crates as individually namespaced objects.
|
||||
export default {
|
||||
foobar,
|
||||
};
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
{
|
||||
"extends": "./tsconfig",
|
||||
"exclude": ["example", "lib"]
|
||||
"exclude": ["example", "lib"],
|
||||
"compilerOptions": {
|
||||
"noUnusedParameters": false,
|
||||
"noUnusedLocals": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
rust:
|
||||
repo: https://github.com/jhugman/uniffi-starter.git
|
||||
branch: jhugman/bump-uniffi-to-0.29
|
||||
manifestPath: rust/foobar/Cargo.toml
|
||||
|
||||
Reference in New Issue
Block a user