diff --git a/apps/mobile/package.json b/apps/mobile/package.json index 94f7181..c53cb93 100644 --- a/apps/mobile/package.json +++ b/apps/mobile/package.json @@ -27,6 +27,7 @@ "@dylankenneally/react-native-ssh-sftp": "^1.5.20", "@expo/vector-icons": "^15.0.2", "@fressh/assets": "workspace:*", + "@fressh/react-native-uniffi-russh": "workspace:*", "@react-native-picker/picker": "2.11.1", "@react-native-segmented-control/segmented-control": "2.5.7", "@react-navigation/bottom-tabs": "^7.4.0", diff --git a/apps/mobile/src/app/index.tsx b/apps/mobile/src/app/index.tsx index 37b0b42..b5bbd4d 100644 --- a/apps/mobile/src/app/index.tsx +++ b/apps/mobile/src/app/index.tsx @@ -13,7 +13,7 @@ import { secretsManager, } from '../lib/secrets-manager'; import { sshConnectionManager } from '../lib/ssh-connection-manager'; - +import { result } from '../lib/test-uniffi-russh'; const defaultValues: ConnectionDetails = { host: 'test.rebex.net', port: 22, @@ -119,7 +119,9 @@ export default function Index() { > fressh - A fast, friendly SSH client + + A fast, friendly SSH client {result} + Connect to SSH Server diff --git a/apps/mobile/src/lib/test-uniffi-russh.ts b/apps/mobile/src/lib/test-uniffi-russh.ts new file mode 100644 index 0000000..7708035 --- /dev/null +++ b/apps/mobile/src/lib/test-uniffi-russh.ts @@ -0,0 +1,32 @@ +import { + Calculator, + type BinaryOperator, + SafeAddition, + type ComputationResult, +} from '@fressh/react-native-uniffi-russh'; + +const calculator = new Calculator(); + +const addOp = new SafeAddition(); + +class SafeMultiply implements BinaryOperator { + perform(lhs: bigint, rhs: bigint): bigint { + return lhs * rhs; + } +} + +const multOp = new SafeMultiply(); + +// bigints +const three = 3n; +const seven = 7n; + +// Perform the calculation, and to get an object +// representing the computation result. +const computation: ComputationResult = calculator + .calculate(addOp, three, three) + .calculateMore(multOp, seven) + .lastResult()!; + +// Unpack the bigint value into a string. +export const result = computation.value.toString(); diff --git a/flake.nix b/flake.nix index 1b6cb4d..958bade 100644 --- a/flake.nix +++ b/flake.nix @@ -35,6 +35,9 @@ build-tools-36-0-0 platforms-android-36 system-images-android-36-0-Baklava-google-apis-playstore-x86-64 + # Add NDK + CMake for native builds + ndk-26-1-10909125 + cmake-3-22-1 ]) else if mode == "remote" then (with sdk; [ diff --git a/packages/react-native-uniffi-russh/.gitignore b/packages/react-native-uniffi-russh/.gitignore index 67f3212..a23406b 100644 --- a/packages/react-native-uniffi-russh/.gitignore +++ b/packages/react-native-uniffi-russh/.gitignore @@ -84,3 +84,7 @@ android/generated # React Native Nitro Modules nitrogen/ + +# From uniffi-bindgen-react-native +rust_modules/ +*.a diff --git a/packages/react-native-uniffi-russh/LICENSE b/packages/react-native-uniffi-russh/LICENSE deleted file mode 100644 index 39e9838..0000000 --- a/packages/react-native-uniffi-russh/LICENSE +++ /dev/null @@ -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. diff --git a/packages/react-native-uniffi-russh/android/CMakeLists.txt b/packages/react-native-uniffi-russh/android/CMakeLists.txt new file mode 100644 index 0000000..25f6b55 --- /dev/null +++ b/packages/react-native-uniffi-russh/android/CMakeLists.txt @@ -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 +) diff --git a/packages/react-native-uniffi-russh/android/build.gradle b/packages/react-native-uniffi-russh/android/build.gradle index dd1076e..17adb3a 100644 --- a/packages/react-native-uniffi-russh/android/build.gradle +++ b/packages/react-native-uniffi-russh/android/build.gradle @@ -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" + } +} diff --git a/packages/react-native-uniffi-russh/android/cpp-adapter.cpp b/packages/react-native-uniffi-russh/android/cpp-adapter.cpp new file mode 100644 index 0000000..22e0254 --- /dev/null +++ b/packages/react-native-uniffi-russh/android/cpp-adapter.cpp @@ -0,0 +1,63 @@ +// Generated by uniffi-bindgen-react-native +#include +#include +#include +#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(nativePointerValue); + auto jsCallInvoker = nativePointer->getCallInvoker(); + + auto runtime = reinterpret_cast(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(rtPtr); + return uniffirussh::cleanupRustCrate(*runtime); +} \ No newline at end of file diff --git a/packages/react-native-uniffi-russh/android/src/main/AndroidManifest.xml b/packages/react-native-uniffi-russh/android/src/main/AndroidManifest.xml index a2f47b6..118c2e8 100644 --- a/packages/react-native-uniffi-russh/android/src/main/AndroidManifest.xml +++ b/packages/react-native-uniffi-russh/android/src/main/AndroidManifest.xml @@ -1,2 +1,5 @@ - - + + + + \ No newline at end of file diff --git a/packages/react-native-uniffi-russh/android/src/main/java/com/uniffirussh/UniffiRusshModule.kt b/packages/react-native-uniffi-russh/android/src/main/java/com/uniffirussh/UniffiRusshModule.kt new file mode 100644 index 0000000..52d9f7d --- /dev/null +++ b/packages/react-native-uniffi-russh/android/src/main/java/com/uniffirussh/UniffiRusshModule.kt @@ -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") + } + } +} \ No newline at end of file diff --git a/packages/react-native-uniffi-russh/android/src/main/java/com/uniffirussh/UniffiRusshPackage.kt b/packages/react-native-uniffi-russh/android/src/main/java/com/uniffirussh/UniffiRusshPackage.kt new file mode 100644 index 0000000..396e306 --- /dev/null +++ b/packages/react-native-uniffi-russh/android/src/main/java/com/uniffirussh/UniffiRusshPackage.kt @@ -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 = HashMap() + moduleInfos[UniffiRusshModule.NAME] = ReactModuleInfo( + UniffiRusshModule.NAME, + UniffiRusshModule.NAME, + false, // canOverrideExistingModule + false, // needsEagerInit + false, // isCxxModule + true // isTurboModule + ) + moduleInfos + } + } +} \ No newline at end of file diff --git a/packages/react-native-uniffi-russh/cpp/generated/foobar.cpp b/packages/react-native-uniffi-russh/cpp/generated/foobar.cpp new file mode 100644 index 0000000..ab608ad --- /dev/null +++ b/packages/react-native-uniffi-russh/cpp/generated/foobar.cpp @@ -0,0 +1,2965 @@ +// 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! +#include "foobar.hpp" + +#include "UniffiJsiTypes.h" +#include +#include +#include +#include +#include + +namespace react = facebook::react; +namespace jsi = facebook::jsi; + +// Calling into Rust. +extern "C" { + typedef void + (*UniffiRustFutureContinuationCallback)( + uint64_t data, + int8_t poll_result + ); + typedef void + (*UniffiForeignFutureFree)( + uint64_t handle + ); + typedef void + (*UniffiCallbackInterfaceFree)( + uint64_t handle + );typedef struct UniffiForeignFuture { + uint64_t handle; + UniffiForeignFutureFree free; + } UniffiForeignFuture;typedef struct UniffiForeignFutureStructU8 { + uint8_t return_value; + RustCallStatus call_status; + } UniffiForeignFutureStructU8; + typedef void + (*UniffiForeignFutureCompleteU8)( + uint64_t callback_data, + UniffiForeignFutureStructU8 result + );typedef struct UniffiForeignFutureStructI8 { + int8_t return_value; + RustCallStatus call_status; + } UniffiForeignFutureStructI8; + typedef void + (*UniffiForeignFutureCompleteI8)( + uint64_t callback_data, + UniffiForeignFutureStructI8 result + );typedef struct UniffiForeignFutureStructU16 { + uint16_t return_value; + RustCallStatus call_status; + } UniffiForeignFutureStructU16; + typedef void + (*UniffiForeignFutureCompleteU16)( + uint64_t callback_data, + UniffiForeignFutureStructU16 result + );typedef struct UniffiForeignFutureStructI16 { + int16_t return_value; + RustCallStatus call_status; + } UniffiForeignFutureStructI16; + typedef void + (*UniffiForeignFutureCompleteI16)( + uint64_t callback_data, + UniffiForeignFutureStructI16 result + );typedef struct UniffiForeignFutureStructU32 { + uint32_t return_value; + RustCallStatus call_status; + } UniffiForeignFutureStructU32; + typedef void + (*UniffiForeignFutureCompleteU32)( + uint64_t callback_data, + UniffiForeignFutureStructU32 result + );typedef struct UniffiForeignFutureStructI32 { + int32_t return_value; + RustCallStatus call_status; + } UniffiForeignFutureStructI32; + typedef void + (*UniffiForeignFutureCompleteI32)( + uint64_t callback_data, + UniffiForeignFutureStructI32 result + );typedef struct UniffiForeignFutureStructU64 { + uint64_t return_value; + RustCallStatus call_status; + } UniffiForeignFutureStructU64; + typedef void + (*UniffiForeignFutureCompleteU64)( + uint64_t callback_data, + UniffiForeignFutureStructU64 result + );typedef struct UniffiForeignFutureStructI64 { + int64_t return_value; + RustCallStatus call_status; + } UniffiForeignFutureStructI64; + typedef void + (*UniffiForeignFutureCompleteI64)( + uint64_t callback_data, + UniffiForeignFutureStructI64 result + );typedef struct UniffiForeignFutureStructF32 { + float return_value; + RustCallStatus call_status; + } UniffiForeignFutureStructF32; + typedef void + (*UniffiForeignFutureCompleteF32)( + uint64_t callback_data, + UniffiForeignFutureStructF32 result + );typedef struct UniffiForeignFutureStructF64 { + double return_value; + RustCallStatus call_status; + } UniffiForeignFutureStructF64; + typedef void + (*UniffiForeignFutureCompleteF64)( + uint64_t callback_data, + UniffiForeignFutureStructF64 result + );typedef struct UniffiForeignFutureStructPointer { + void * return_value; + RustCallStatus call_status; + } UniffiForeignFutureStructPointer; + typedef void + (*UniffiForeignFutureCompletePointer)( + uint64_t callback_data, + UniffiForeignFutureStructPointer result + );typedef struct UniffiForeignFutureStructRustBuffer { + RustBuffer return_value; + RustCallStatus call_status; + } UniffiForeignFutureStructRustBuffer; + typedef void + (*UniffiForeignFutureCompleteRustBuffer)( + uint64_t callback_data, + UniffiForeignFutureStructRustBuffer result + );typedef struct UniffiForeignFutureStructVoid { + RustCallStatus call_status; + } UniffiForeignFutureStructVoid; + typedef void + (*UniffiForeignFutureCompleteVoid)( + uint64_t callback_data, + UniffiForeignFutureStructVoid result + ); + typedef void + (*UniffiCallbackInterfaceBinaryOperatorMethod0)( + uint64_t uniffi_handle, + int64_t lhs, + int64_t rhs, + int64_t * uniffi_out_return, RustCallStatus* rust_call_status + );typedef struct UniffiVTableCallbackInterfaceBinaryOperator { + UniffiCallbackInterfaceBinaryOperatorMethod0 perform; + UniffiCallbackInterfaceFree uniffi_free; + } UniffiVTableCallbackInterfaceBinaryOperator; + void * uniffi_foobar_fn_clone_binaryoperator( + void * ptr, + RustCallStatus *uniffi_out_err + ); + void uniffi_foobar_fn_free_binaryoperator( + void * ptr, + RustCallStatus *uniffi_out_err + ); + void uniffi_foobar_fn_init_callback_vtable_binaryoperator( + UniffiVTableCallbackInterfaceBinaryOperator * vtable + ); + int64_t uniffi_foobar_fn_method_binaryoperator_perform( + void * ptr, + int64_t lhs, + int64_t rhs, + RustCallStatus *uniffi_out_err + ); + void * uniffi_foobar_fn_clone_calculator( + void * ptr, + RustCallStatus *uniffi_out_err + ); + void uniffi_foobar_fn_free_calculator( + void * ptr, + RustCallStatus *uniffi_out_err + ); + void * uniffi_foobar_fn_constructor_calculator_new(RustCallStatus *uniffi_out_err + ); + void * uniffi_foobar_fn_method_calculator_calculate( + void * ptr, + void * op, + int64_t lhs, + int64_t rhs, + RustCallStatus *uniffi_out_err + ); + void * uniffi_foobar_fn_method_calculator_calculate_more( + void * ptr, + void * op, + int64_t rhs, + RustCallStatus *uniffi_out_err + ); + RustBuffer uniffi_foobar_fn_method_calculator_last_result( + void * ptr, + RustCallStatus *uniffi_out_err + ); + void * uniffi_foobar_fn_clone_safeaddition( + void * ptr, + RustCallStatus *uniffi_out_err + ); + void uniffi_foobar_fn_free_safeaddition( + void * ptr, + RustCallStatus *uniffi_out_err + ); + void * uniffi_foobar_fn_constructor_safeaddition_new(RustCallStatus *uniffi_out_err + ); + int64_t uniffi_foobar_fn_method_safeaddition_perform( + void * ptr, + int64_t lhs, + int64_t rhs, + RustCallStatus *uniffi_out_err + ); + void * uniffi_foobar_fn_clone_safedivision( + void * ptr, + RustCallStatus *uniffi_out_err + ); + void uniffi_foobar_fn_free_safedivision( + void * ptr, + RustCallStatus *uniffi_out_err + ); + void * uniffi_foobar_fn_constructor_safedivision_new(RustCallStatus *uniffi_out_err + ); + int64_t uniffi_foobar_fn_method_safedivision_perform( + void * ptr, + int64_t lhs, + int64_t rhs, + RustCallStatus *uniffi_out_err + ); + void * uniffi_foobar_fn_func_safe_addition_operator(RustCallStatus *uniffi_out_err + ); + void * uniffi_foobar_fn_func_safe_division_operator(RustCallStatus *uniffi_out_err + ); + RustBuffer ffi_foobar_rustbuffer_alloc( + uint64_t size, + RustCallStatus *uniffi_out_err + ); + RustBuffer ffi_foobar_rustbuffer_from_bytes( + ForeignBytes bytes, + RustCallStatus *uniffi_out_err + ); + void ffi_foobar_rustbuffer_free( + RustBuffer buf, + RustCallStatus *uniffi_out_err + ); + RustBuffer ffi_foobar_rustbuffer_reserve( + RustBuffer buf, + uint64_t additional, + RustCallStatus *uniffi_out_err + ); + void ffi_foobar_rust_future_poll_u8( + /*handle*/ uint64_t handle, + UniffiRustFutureContinuationCallback callback, + /*handle*/ uint64_t callback_data + ); + void ffi_foobar_rust_future_cancel_u8( + /*handle*/ uint64_t handle + ); + void ffi_foobar_rust_future_free_u8( + /*handle*/ uint64_t handle + ); + uint8_t ffi_foobar_rust_future_complete_u8( + /*handle*/ uint64_t handle, + RustCallStatus *uniffi_out_err + ); + void ffi_foobar_rust_future_poll_i8( + /*handle*/ uint64_t handle, + UniffiRustFutureContinuationCallback callback, + /*handle*/ uint64_t callback_data + ); + void ffi_foobar_rust_future_cancel_i8( + /*handle*/ uint64_t handle + ); + void ffi_foobar_rust_future_free_i8( + /*handle*/ uint64_t handle + ); + int8_t ffi_foobar_rust_future_complete_i8( + /*handle*/ uint64_t handle, + RustCallStatus *uniffi_out_err + ); + void ffi_foobar_rust_future_poll_u16( + /*handle*/ uint64_t handle, + UniffiRustFutureContinuationCallback callback, + /*handle*/ uint64_t callback_data + ); + void ffi_foobar_rust_future_cancel_u16( + /*handle*/ uint64_t handle + ); + void ffi_foobar_rust_future_free_u16( + /*handle*/ uint64_t handle + ); + uint16_t ffi_foobar_rust_future_complete_u16( + /*handle*/ uint64_t handle, + RustCallStatus *uniffi_out_err + ); + void ffi_foobar_rust_future_poll_i16( + /*handle*/ uint64_t handle, + UniffiRustFutureContinuationCallback callback, + /*handle*/ uint64_t callback_data + ); + void ffi_foobar_rust_future_cancel_i16( + /*handle*/ uint64_t handle + ); + void ffi_foobar_rust_future_free_i16( + /*handle*/ uint64_t handle + ); + int16_t ffi_foobar_rust_future_complete_i16( + /*handle*/ uint64_t handle, + RustCallStatus *uniffi_out_err + ); + void ffi_foobar_rust_future_poll_u32( + /*handle*/ uint64_t handle, + UniffiRustFutureContinuationCallback callback, + /*handle*/ uint64_t callback_data + ); + void ffi_foobar_rust_future_cancel_u32( + /*handle*/ uint64_t handle + ); + void ffi_foobar_rust_future_free_u32( + /*handle*/ uint64_t handle + ); + uint32_t ffi_foobar_rust_future_complete_u32( + /*handle*/ uint64_t handle, + RustCallStatus *uniffi_out_err + ); + void ffi_foobar_rust_future_poll_i32( + /*handle*/ uint64_t handle, + UniffiRustFutureContinuationCallback callback, + /*handle*/ uint64_t callback_data + ); + void ffi_foobar_rust_future_cancel_i32( + /*handle*/ uint64_t handle + ); + void ffi_foobar_rust_future_free_i32( + /*handle*/ uint64_t handle + ); + int32_t ffi_foobar_rust_future_complete_i32( + /*handle*/ uint64_t handle, + RustCallStatus *uniffi_out_err + ); + void ffi_foobar_rust_future_poll_u64( + /*handle*/ uint64_t handle, + UniffiRustFutureContinuationCallback callback, + /*handle*/ uint64_t callback_data + ); + void ffi_foobar_rust_future_cancel_u64( + /*handle*/ uint64_t handle + ); + void ffi_foobar_rust_future_free_u64( + /*handle*/ uint64_t handle + ); + uint64_t ffi_foobar_rust_future_complete_u64( + /*handle*/ uint64_t handle, + RustCallStatus *uniffi_out_err + ); + void ffi_foobar_rust_future_poll_i64( + /*handle*/ uint64_t handle, + UniffiRustFutureContinuationCallback callback, + /*handle*/ uint64_t callback_data + ); + void ffi_foobar_rust_future_cancel_i64( + /*handle*/ uint64_t handle + ); + void ffi_foobar_rust_future_free_i64( + /*handle*/ uint64_t handle + ); + int64_t ffi_foobar_rust_future_complete_i64( + /*handle*/ uint64_t handle, + RustCallStatus *uniffi_out_err + ); + void ffi_foobar_rust_future_poll_f32( + /*handle*/ uint64_t handle, + UniffiRustFutureContinuationCallback callback, + /*handle*/ uint64_t callback_data + ); + void ffi_foobar_rust_future_cancel_f32( + /*handle*/ uint64_t handle + ); + void ffi_foobar_rust_future_free_f32( + /*handle*/ uint64_t handle + ); + float ffi_foobar_rust_future_complete_f32( + /*handle*/ uint64_t handle, + RustCallStatus *uniffi_out_err + ); + void ffi_foobar_rust_future_poll_f64( + /*handle*/ uint64_t handle, + UniffiRustFutureContinuationCallback callback, + /*handle*/ uint64_t callback_data + ); + void ffi_foobar_rust_future_cancel_f64( + /*handle*/ uint64_t handle + ); + void ffi_foobar_rust_future_free_f64( + /*handle*/ uint64_t handle + ); + double ffi_foobar_rust_future_complete_f64( + /*handle*/ uint64_t handle, + RustCallStatus *uniffi_out_err + ); + void ffi_foobar_rust_future_poll_pointer( + /*handle*/ uint64_t handle, + UniffiRustFutureContinuationCallback callback, + /*handle*/ uint64_t callback_data + ); + void ffi_foobar_rust_future_cancel_pointer( + /*handle*/ uint64_t handle + ); + void ffi_foobar_rust_future_free_pointer( + /*handle*/ uint64_t handle + ); + void * ffi_foobar_rust_future_complete_pointer( + /*handle*/ uint64_t handle, + RustCallStatus *uniffi_out_err + ); + void ffi_foobar_rust_future_poll_rust_buffer( + /*handle*/ uint64_t handle, + UniffiRustFutureContinuationCallback callback, + /*handle*/ uint64_t callback_data + ); + void ffi_foobar_rust_future_cancel_rust_buffer( + /*handle*/ uint64_t handle + ); + void ffi_foobar_rust_future_free_rust_buffer( + /*handle*/ uint64_t handle + ); + RustBuffer ffi_foobar_rust_future_complete_rust_buffer( + /*handle*/ uint64_t handle, + RustCallStatus *uniffi_out_err + ); + void ffi_foobar_rust_future_poll_void( + /*handle*/ uint64_t handle, + UniffiRustFutureContinuationCallback callback, + /*handle*/ uint64_t callback_data + ); + void ffi_foobar_rust_future_cancel_void( + /*handle*/ uint64_t handle + ); + void ffi_foobar_rust_future_free_void( + /*handle*/ uint64_t handle + ); + void ffi_foobar_rust_future_complete_void( + /*handle*/ uint64_t handle, + RustCallStatus *uniffi_out_err + ); + uint16_t uniffi_foobar_checksum_func_safe_addition_operator( + ); + uint16_t uniffi_foobar_checksum_func_safe_division_operator( + ); + uint16_t uniffi_foobar_checksum_method_binaryoperator_perform( + ); + uint16_t uniffi_foobar_checksum_method_calculator_calculate( + ); + uint16_t uniffi_foobar_checksum_method_calculator_calculate_more( + ); + uint16_t uniffi_foobar_checksum_method_calculator_last_result( + ); + uint16_t uniffi_foobar_checksum_method_safeaddition_perform( + ); + uint16_t uniffi_foobar_checksum_method_safedivision_perform( + ); + uint16_t uniffi_foobar_checksum_constructor_calculator_new( + ); + uint16_t uniffi_foobar_checksum_constructor_safeaddition_new( + ); + uint16_t uniffi_foobar_checksum_constructor_safedivision_new( + ); + uint32_t ffi_foobar_uniffi_contract_version( + ); +} + + +namespace uniffi::foobar { +template struct Bridging; + +using namespace facebook; +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template struct Bridging> { + static jsi::Value jsNew(jsi::Runtime &rt) { + auto holder = jsi::Object(rt); + return holder; + } + static T fromJs(jsi::Runtime &rt, std::shared_ptr callInvoker, + const jsi::Value &value) { + auto obj = value.asObject(rt); + if (obj.hasProperty(rt, "pointee")) { + auto pointee = obj.getProperty(rt, "pointee"); + return uniffi::foobar::Bridging::fromJs(rt, callInvoker, pointee); + } + throw jsi::JSError( + rt, + "Expected ReferenceHolder to have a pointee property. This is likely a bug in uniffi-bindgen-react-native" + ); + } +}; +} // namespace uniffi::foobar +namespace uniffi::foobar { +using namespace facebook; +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static RustBuffer rustbuffer_alloc(int32_t size) { + RustCallStatus status = { UNIFFI_CALL_STATUS_OK }; + return ffi_foobar_rustbuffer_alloc( + size, + &status + ); + } + + static void rustbuffer_free(RustBuffer buf) { + RustCallStatus status = { UNIFFI_CALL_STATUS_OK }; + ffi_foobar_rustbuffer_free( + buf, + &status + ); + } + + static RustBuffer rustbuffer_from_bytes(ForeignBytes bytes) { + RustCallStatus status = { UNIFFI_CALL_STATUS_OK }; + return ffi_foobar_rustbuffer_from_bytes( + bytes, + &status + ); + } + + static RustBuffer fromJs(jsi::Runtime &rt, std::shared_ptr, + const jsi::Value &value) { + try { + auto buffer = uniffi_jsi::Bridging::value_to_arraybuffer(rt, value); + auto bytes = ForeignBytes{ + .len = static_cast(buffer.length(rt)), + .data = buffer.data(rt), + }; + + // This buffer is constructed from foreign bytes. Rust scaffolding copies + // the bytes, to make the RustBuffer. + auto buf = rustbuffer_from_bytes(bytes); + // Once it leaves this function, the buffer is immediately passed back + // into Rust, where it's used to deserialize into the Rust versions of the + // arguments. At that point, the copy is destroyed. + return buf; + } catch (const std::logic_error &e) { + throw jsi::JSError(rt, e.what()); + } + } + + static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr, + RustBuffer buf) { + // We need to make a copy of the bytes from Rust's memory space into + // Javascripts memory space. We need to do this because the two languages + // manages memory very differently: a garbage collector needs to track all + // the memory at runtime, Rust is doing it all closer to compile time. + uint8_t *bytes = new uint8_t[buf.len]; + std::memcpy(bytes, buf.data, buf.len); + + // Construct an ArrayBuffer with copy of the bytes from the RustBuffer. + auto payload = std::make_shared( + uniffi_jsi::CMutableBuffer((uint8_t *)bytes, buf.len)); + auto arrayBuffer = jsi::ArrayBuffer(rt, payload); + + // Once we have a Javascript version, we no longer need the Rust version, so + // we can call into Rust to tell it it's okay to free that memory. + rustbuffer_free(buf); + + // Finally, return the ArrayBuffer. + return uniffi_jsi::Bridging::arraybuffer_to_value(rt, arrayBuffer);; + } +}; + +} // namespace uniffi::foobar + +namespace uniffi::foobar { +using namespace facebook; +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static jsi::Value jsSuccess(jsi::Runtime &rt) { + auto statusObject = jsi::Object(rt); + statusObject.setProperty(rt, "code", jsi::Value(rt, UNIFFI_CALL_STATUS_OK)); + return statusObject; + } + static RustCallStatus rustSuccess(jsi::Runtime &rt) { + return {UNIFFI_CALL_STATUS_OK}; + } + static void copyIntoJs(jsi::Runtime &rt, + std::shared_ptr callInvoker, + const RustCallStatus status, + const jsi::Value &jsStatus) { + auto statusObject = jsStatus.asObject(rt); + if (status.error_buf.data != nullptr) { + auto rbuf = Bridging::toJs(rt, callInvoker, + status.error_buf); + statusObject.setProperty(rt, "errorBuf", rbuf); + } + if (status.code != UNIFFI_CALL_STATUS_OK) { + auto code = + uniffi_jsi::Bridging::toJs(rt, callInvoker, status.code); + statusObject.setProperty(rt, "code", code); + } + } + + static RustCallStatus fromJs(jsi::Runtime &rt, + std::shared_ptr invoker, + const jsi::Value &jsStatus) { + RustCallStatus status; + auto statusObject = jsStatus.asObject(rt); + if (statusObject.hasProperty(rt, "errorBuf")) { + auto rbuf = statusObject.getProperty(rt, "errorBuf"); + status.error_buf = + Bridging::fromJs(rt, invoker, rbuf); + } + if (statusObject.hasProperty(rt, "code")) { + auto code = statusObject.getProperty(rt, "code"); + status.code = uniffi_jsi::Bridging::fromJs(rt, invoker, code); + } + return status; + } + + static void copyFromJs(jsi::Runtime &rt, std::shared_ptr invoker, + const jsi::Value &jsStatus, RustCallStatus *status) { + auto statusObject = jsStatus.asObject(rt); + if (statusObject.hasProperty(rt, "errorBuf")) { + auto rbuf = statusObject.getProperty(rt, "errorBuf"); + status->error_buf = + Bridging::fromJs(rt, invoker, rbuf); + } + if (statusObject.hasProperty(rt, "code")) { + auto code = statusObject.getProperty(rt, "code"); + status->code = uniffi_jsi::Bridging::fromJs(rt, invoker, code); + } + } +}; + +} // namespace uniffi::foobar +// In other uniffi bindings, it is assumed that the foreign language holds on +// to the vtable, which the Rust just gets a pointer to. +// Here, we need to hold on to them, but also be able to clear them at just the +// right time so we can support hot-reloading. +namespace uniffi::foobar::registry { + template + class VTableHolder { + public: + T vtable; + VTableHolder(T v) : vtable(v) {} + }; + + // Mutex to bind the storage and setting of vtable together. + // We declare it here, but the lock is taken by callers of the putTable + // method who are also sending a pointer to Rust. + static std::mutex vtableMutex; + + // Registry to hold all vtables so they persist even when JS objects are GC'd. + // The only reason this exists is to prevent a dangling pointer in the + // Rust machinery: i.e. we don't need to access or write to this registry + // after startup. + // Registry to hold all vtables so they persist even when JS objects are GC'd. + // Maps string identifiers to vtable holders using type erasure + static std::unordered_map> vtableRegistry; + + // Add a vtable to the registry with an identifier + template + static T* putTable(std::string_view identifier, T vtable) { + auto holder = std::make_shared>(vtable); + // Store the raw pointer to the vtable before type erasure + T* rawPtr = &(holder->vtable); + // Store the holder using type erasure with the string identifier + vtableRegistry[std::string(identifier)] = std::shared_ptr(holder); + return rawPtr; + } + + // Clear the registry. + // + // Conceptually, this is called after teardown of the module (i.e. after + // teardown of the jsi::Runtime). However, because Rust is dropping callbacks + // because the Runtime is being torn down, we must keep the registry intact + // until after the runtime goes away. + // + // Therefore, in practice we should call this when the next runtime is + // being stood up. + static void clearRegistry() { + std::lock_guard lock(vtableMutex); + vtableRegistry.clear(); + } +} // namespace uniffi::foobar::registry + +// This calls into Rust. + // Implementation of callback function calling from Rust to JS RustFutureContinuationCallback + +// Callback function: uniffi::foobar::cb::rustfuturecontinuationcallback::UniffiRustFutureContinuationCallback +// +// We have the following constraints: +// - we need to pass a function pointer to Rust. +// - we need a jsi::Runtime and jsi::Function to call into JS. +// - function pointers can't store state, so we can't use a lamda. +// +// For this, we store a lambda as a global, as `rsLambda`. The `callback` function calls +// the lambda, which itself calls the `body` which then calls into JS. +// +// We then give the `callback` function pointer to Rust which will call the lambda sometime in the +// future. +namespace uniffi::foobar::cb::rustfuturecontinuationcallback { + using namespace facebook; + + // We need to store a lambda in a global so we can call it from + // a function pointer. The function pointer is passed to Rust. + static std::function rsLambda = nullptr; + + // This is the main body of the callback. It's called from the lambda, + // which itself is called from the callback function which is passed to Rust. + static void body(jsi::Runtime &rt, + std::shared_ptr callInvoker, + std::shared_ptr callbackValue + ,uint64_t rs_data + ,int8_t rs_pollResult) { + + // Convert the arguments from Rust, into jsi::Values. + // We'll use the Bridging class to do this… + auto js_data = uniffi_jsi::Bridging::toJs(rt, callInvoker, rs_data); + auto js_pollResult = uniffi_jsi::Bridging::toJs(rt, callInvoker, rs_pollResult); + + // Now we are ready to call the callback. + // We are already on the JS thread, because this `body` function was + // invoked from the CallInvoker. + try { + // Getting the callback function + auto cb = callbackValue->asObject(rt).asFunction(rt); + auto uniffiResult = cb.call(rt, js_data, js_pollResult + ); + + + + + } catch (const jsi::JSError &error) { + std::cout << "Error in callback UniffiRustFutureContinuationCallback: " + << error.what() << std::endl; + throw error; + } + } + + static void callback(uint64_t rs_data, int8_t rs_pollResult) { + // If the runtime has shutdown, then there is no point in trying to + // call into Javascript. BUT how do we tell if the runtime has shutdown? + // + // Answer: the module destructor calls into callback `cleanup` method, + // which nulls out the rsLamda. + // + // If rsLamda is null, then there is no runtime to call into. + if (rsLambda == nullptr) { + // This only occurs when destructors are calling into Rust free/drop, + // which causes the JS callback to be dropped. + return; + } + + // The runtime, the actual callback jsi::funtion, and the callInvoker + // are all in the lambda. + rsLambda( + rs_data, + rs_pollResult); + } + + static UniffiRustFutureContinuationCallback + makeCallbackFunction( // uniffi::foobar::cb::rustfuturecontinuationcallback + jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &value) { + if (rsLambda != nullptr) { + // `makeCallbackFunction` is called in two circumstances: + // + // 1. at startup, when initializing callback interface vtables. + // 2. when polling futures. This happens at least once per future that is + // exposed to Javascript. We know that this is always the same function, + // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`. + // + // We can therefore return the callback function without making anything + // new if we've been initialized already. + return callback; + } + auto callbackFunction = value.asObject(rt).asFunction(rt); + auto callbackValue = std::make_shared(rt, callbackFunction); + rsLambda = [&rt, callInvoker, callbackValue](uint64_t rs_data, int8_t rs_pollResult) { + // We immediately make a lambda which will do the work of transforming the + // arguments into JSI values and calling the callback. + uniffi_runtime::UniffiCallFunc jsLambda = [ + callInvoker, + callbackValue + , rs_data + , rs_pollResult](jsi::Runtime &rt) mutable { + body(rt, callInvoker, callbackValue + , rs_data + , rs_pollResult); + }; + // We'll then call that lambda from the callInvoker which will + // look after calling it on the correct thread. + + callInvoker->invokeNonBlocking(rt, jsLambda); + }; + return callback; + } + + // This method is called from the destructor of NativeFoobar, which only happens + // when the jsi::Runtime is being destroyed. + static void cleanup() { + // The lambda holds a reference to the the Runtime, so when this is nulled out, + // then the pointer will no longer be left dangling. + rsLambda = nullptr; + } +} // namespace uniffi::foobar::cb::rustfuturecontinuationcallback + // Implementation of callback function calling from JS to Rust ForeignFutureFree, + // passed from Rust to JS as part of async callbacks. +namespace uniffi::foobar { +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr callInvoker, UniffiForeignFutureFree rsCallback) { + return jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "--ForeignFutureFree"), + 1, + [rsCallback, callInvoker]( + jsi::Runtime &rt, + const jsi::Value &thisValue, + const jsi::Value *arguments, + size_t count) -> jsi::Value + { + return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback); + } + ); + } + + static jsi::Value intoRust( + jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &thisValue, + const jsi::Value *args, + size_t count, + UniffiForeignFutureFree func) { + // Convert the arguments into the Rust, with Bridging::fromJs, + // then call the rs_callback with those arguments. + func(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]) + ); + + + return jsi::Value::undefined(); + } +}; +} // namespace uniffi::foobar + // Implementation of free callback function CallbackInterfaceFree + + +// Callback function: uniffi::foobar::st::foreignfuture::foreignfuture::free::UniffiCallbackInterfaceFree +// +// We have the following constraints: +// - we need to pass a function pointer to Rust. +// - we need a jsi::Runtime and jsi::Function to call into JS. +// - function pointers can't store state, so we can't use a lamda. +// +// For this, we store a lambda as a global, as `rsLambda`. The `callback` function calls +// the lambda, which itself calls the `body` which then calls into JS. +// +// We then give the `callback` function pointer to Rust which will call the lambda sometime in the +// future. +namespace uniffi::foobar::st::foreignfuture::foreignfuture::free { + using namespace facebook; + + // We need to store a lambda in a global so we can call it from + // a function pointer. The function pointer is passed to Rust. + static std::function rsLambda = nullptr; + + // This is the main body of the callback. It's called from the lambda, + // which itself is called from the callback function which is passed to Rust. + static void body(jsi::Runtime &rt, + std::shared_ptr callInvoker, + std::shared_ptr callbackValue + ,uint64_t rs_handle) { + + // Convert the arguments from Rust, into jsi::Values. + // We'll use the Bridging class to do this… + auto js_handle = uniffi_jsi::Bridging::toJs(rt, callInvoker, rs_handle); + + // Now we are ready to call the callback. + // We are already on the JS thread, because this `body` function was + // invoked from the CallInvoker. + try { + // Getting the callback function + auto cb = callbackValue->asObject(rt).asFunction(rt); + auto uniffiResult = cb.call(rt, js_handle + ); + + + + + } catch (const jsi::JSError &error) { + std::cout << "Error in callback UniffiCallbackInterfaceFree: " + << error.what() << std::endl; + throw error; + } + } + + static void callback(uint64_t rs_handle) { + // If the runtime has shutdown, then there is no point in trying to + // call into Javascript. BUT how do we tell if the runtime has shutdown? + // + // Answer: the module destructor calls into callback `cleanup` method, + // which nulls out the rsLamda. + // + // If rsLamda is null, then there is no runtime to call into. + if (rsLambda == nullptr) { + // This only occurs when destructors are calling into Rust free/drop, + // which causes the JS callback to be dropped. + return; + } + + // The runtime, the actual callback jsi::funtion, and the callInvoker + // are all in the lambda. + rsLambda( + rs_handle); + } + + static UniffiCallbackInterfaceFree + makeCallbackFunction( // uniffi::foobar::st::foreignfuture::foreignfuture::free + jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &value) { + if (rsLambda != nullptr) { + // `makeCallbackFunction` is called in two circumstances: + // + // 1. at startup, when initializing callback interface vtables. + // 2. when polling futures. This happens at least once per future that is + // exposed to Javascript. We know that this is always the same function, + // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`. + // + // We can therefore return the callback function without making anything + // new if we've been initialized already. + return callback; + } + auto callbackFunction = value.asObject(rt).asFunction(rt); + auto callbackValue = std::make_shared(rt, callbackFunction); + rsLambda = [&rt, callInvoker, callbackValue](uint64_t rs_handle) { + // We immediately make a lambda which will do the work of transforming the + // arguments into JSI values and calling the callback. + uniffi_runtime::UniffiCallFunc jsLambda = [ + callInvoker, + callbackValue + , rs_handle](jsi::Runtime &rt) mutable { + body(rt, callInvoker, callbackValue + , rs_handle); + }; + // We'll then call that lambda from the callInvoker which will + // look after calling it on the correct thread. + + callInvoker->invokeNonBlocking(rt, jsLambda); + }; + return callback; + } + + // This method is called from the destructor of NativeFoobar, which only happens + // when the jsi::Runtime is being destroyed. + static void cleanup() { + // The lambda holds a reference to the the Runtime, so when this is nulled out, + // then the pointer will no longer be left dangling. + rsLambda = nullptr; + } +} // namespace uniffi::foobar::st::foreignfuture::foreignfuture::free + +// Callback function: uniffi::foobar::st::vtablecallbackinterfacebinaryoperator::vtablecallbackinterfacebinaryoperator::free::UniffiCallbackInterfaceFree +// +// We have the following constraints: +// - we need to pass a function pointer to Rust. +// - we need a jsi::Runtime and jsi::Function to call into JS. +// - function pointers can't store state, so we can't use a lamda. +// +// For this, we store a lambda as a global, as `rsLambda`. The `callback` function calls +// the lambda, which itself calls the `body` which then calls into JS. +// +// We then give the `callback` function pointer to Rust which will call the lambda sometime in the +// future. +namespace uniffi::foobar::st::vtablecallbackinterfacebinaryoperator::vtablecallbackinterfacebinaryoperator::free { + using namespace facebook; + + // We need to store a lambda in a global so we can call it from + // a function pointer. The function pointer is passed to Rust. + static std::function rsLambda = nullptr; + + // This is the main body of the callback. It's called from the lambda, + // which itself is called from the callback function which is passed to Rust. + static void body(jsi::Runtime &rt, + std::shared_ptr callInvoker, + std::shared_ptr callbackValue + ,uint64_t rs_handle) { + + // Convert the arguments from Rust, into jsi::Values. + // We'll use the Bridging class to do this… + auto js_handle = uniffi_jsi::Bridging::toJs(rt, callInvoker, rs_handle); + + // Now we are ready to call the callback. + // We are already on the JS thread, because this `body` function was + // invoked from the CallInvoker. + try { + // Getting the callback function + auto cb = callbackValue->asObject(rt).asFunction(rt); + auto uniffiResult = cb.call(rt, js_handle + ); + + + + + } catch (const jsi::JSError &error) { + std::cout << "Error in callback UniffiCallbackInterfaceFree: " + << error.what() << std::endl; + throw error; + } + } + + static void callback(uint64_t rs_handle) { + // If the runtime has shutdown, then there is no point in trying to + // call into Javascript. BUT how do we tell if the runtime has shutdown? + // + // Answer: the module destructor calls into callback `cleanup` method, + // which nulls out the rsLamda. + // + // If rsLamda is null, then there is no runtime to call into. + if (rsLambda == nullptr) { + // This only occurs when destructors are calling into Rust free/drop, + // which causes the JS callback to be dropped. + return; + } + + // The runtime, the actual callback jsi::funtion, and the callInvoker + // are all in the lambda. + rsLambda( + rs_handle); + } + + static UniffiCallbackInterfaceFree + makeCallbackFunction( // uniffi::foobar::st::vtablecallbackinterfacebinaryoperator::vtablecallbackinterfacebinaryoperator::free + jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &value) { + if (rsLambda != nullptr) { + // `makeCallbackFunction` is called in two circumstances: + // + // 1. at startup, when initializing callback interface vtables. + // 2. when polling futures. This happens at least once per future that is + // exposed to Javascript. We know that this is always the same function, + // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`. + // + // We can therefore return the callback function without making anything + // new if we've been initialized already. + return callback; + } + auto callbackFunction = value.asObject(rt).asFunction(rt); + auto callbackValue = std::make_shared(rt, callbackFunction); + rsLambda = [&rt, callInvoker, callbackValue](uint64_t rs_handle) { + // We immediately make a lambda which will do the work of transforming the + // arguments into JSI values and calling the callback. + uniffi_runtime::UniffiCallFunc jsLambda = [ + callInvoker, + callbackValue + , rs_handle](jsi::Runtime &rt) mutable { + body(rt, callInvoker, callbackValue + , rs_handle); + }; + // We'll then call that lambda from the callInvoker which will + // look after calling it on the correct thread. + + callInvoker->invokeNonBlocking(rt, jsLambda); + }; + return callback; + } + + // This method is called from the destructor of NativeFoobar, which only happens + // when the jsi::Runtime is being destroyed. + static void cleanup() { + // The lambda holds a reference to the the Runtime, so when this is nulled out, + // then the pointer will no longer be left dangling. + rsLambda = nullptr; + } +} // namespace uniffi::foobar::st::vtablecallbackinterfacebinaryoperator::vtablecallbackinterfacebinaryoperator::free +namespace uniffi::foobar { +using namespace facebook; +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static UniffiForeignFuture fromJs(jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &jsValue + ) { + // Check if the input is an object + if (!jsValue.isObject()) { + throw jsi::JSError(rt, "Expected an object for UniffiForeignFuture"); + } + + // Get the object from the jsi::Value + auto jsObject = jsValue.getObject(rt); + + // Create the vtable struct + UniffiForeignFuture rsObject; + + // Create the vtable from the js callbacks. + rsObject.handle = uniffi_jsi::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "handle") + ); + rsObject.free = uniffi::foobar::st::foreignfuture::foreignfuture::free::makeCallbackFunction( + rt, callInvoker, jsObject.getProperty(rt, "free") + ); + + return rsObject; + } +}; + +} // namespace uniffi::foobar +namespace uniffi::foobar { +using namespace facebook; +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static UniffiForeignFutureStructU8 fromJs(jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &jsValue + ) { + // Check if the input is an object + if (!jsValue.isObject()) { + throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructU8"); + } + + // Get the object from the jsi::Value + auto jsObject = jsValue.getObject(rt); + + // Create the vtable struct + UniffiForeignFutureStructU8 rsObject; + + // Create the vtable from the js callbacks. + rsObject.return_value = uniffi_jsi::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "returnValue") + ); + rsObject.call_status = uniffi::foobar::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "callStatus") + ); + + return rsObject; + } +}; + +} // namespace uniffi::foobar + // Implementation of callback function calling from JS to Rust ForeignFutureCompleteU8, + // passed from Rust to JS as part of async callbacks. +namespace uniffi::foobar { +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr callInvoker, UniffiForeignFutureCompleteU8 rsCallback) { + return jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteU8"), + 2, + [rsCallback, callInvoker]( + jsi::Runtime &rt, + const jsi::Value &thisValue, + const jsi::Value *arguments, + size_t count) -> jsi::Value + { + return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback); + } + ); + } + + static jsi::Value intoRust( + jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &thisValue, + const jsi::Value *args, + size_t count, + UniffiForeignFutureCompleteU8 func) { + // Convert the arguments into the Rust, with Bridging::fromJs, + // then call the rs_callback with those arguments. + func(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging::fromJs(rt, callInvoker, args[1]) + ); + + + return jsi::Value::undefined(); + } +}; +} // namespace uniffi::foobar +namespace uniffi::foobar { +using namespace facebook; +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static UniffiForeignFutureStructI8 fromJs(jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &jsValue + ) { + // Check if the input is an object + if (!jsValue.isObject()) { + throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructI8"); + } + + // Get the object from the jsi::Value + auto jsObject = jsValue.getObject(rt); + + // Create the vtable struct + UniffiForeignFutureStructI8 rsObject; + + // Create the vtable from the js callbacks. + rsObject.return_value = uniffi_jsi::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "returnValue") + ); + rsObject.call_status = uniffi::foobar::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "callStatus") + ); + + return rsObject; + } +}; + +} // namespace uniffi::foobar + // Implementation of callback function calling from JS to Rust ForeignFutureCompleteI8, + // passed from Rust to JS as part of async callbacks. +namespace uniffi::foobar { +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr callInvoker, UniffiForeignFutureCompleteI8 rsCallback) { + return jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteI8"), + 2, + [rsCallback, callInvoker]( + jsi::Runtime &rt, + const jsi::Value &thisValue, + const jsi::Value *arguments, + size_t count) -> jsi::Value + { + return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback); + } + ); + } + + static jsi::Value intoRust( + jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &thisValue, + const jsi::Value *args, + size_t count, + UniffiForeignFutureCompleteI8 func) { + // Convert the arguments into the Rust, with Bridging::fromJs, + // then call the rs_callback with those arguments. + func(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging::fromJs(rt, callInvoker, args[1]) + ); + + + return jsi::Value::undefined(); + } +}; +} // namespace uniffi::foobar +namespace uniffi::foobar { +using namespace facebook; +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static UniffiForeignFutureStructU16 fromJs(jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &jsValue + ) { + // Check if the input is an object + if (!jsValue.isObject()) { + throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructU16"); + } + + // Get the object from the jsi::Value + auto jsObject = jsValue.getObject(rt); + + // Create the vtable struct + UniffiForeignFutureStructU16 rsObject; + + // Create the vtable from the js callbacks. + rsObject.return_value = uniffi_jsi::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "returnValue") + ); + rsObject.call_status = uniffi::foobar::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "callStatus") + ); + + return rsObject; + } +}; + +} // namespace uniffi::foobar + // Implementation of callback function calling from JS to Rust ForeignFutureCompleteU16, + // passed from Rust to JS as part of async callbacks. +namespace uniffi::foobar { +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr callInvoker, UniffiForeignFutureCompleteU16 rsCallback) { + return jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteU16"), + 2, + [rsCallback, callInvoker]( + jsi::Runtime &rt, + const jsi::Value &thisValue, + const jsi::Value *arguments, + size_t count) -> jsi::Value + { + return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback); + } + ); + } + + static jsi::Value intoRust( + jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &thisValue, + const jsi::Value *args, + size_t count, + UniffiForeignFutureCompleteU16 func) { + // Convert the arguments into the Rust, with Bridging::fromJs, + // then call the rs_callback with those arguments. + func(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging::fromJs(rt, callInvoker, args[1]) + ); + + + return jsi::Value::undefined(); + } +}; +} // namespace uniffi::foobar +namespace uniffi::foobar { +using namespace facebook; +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static UniffiForeignFutureStructI16 fromJs(jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &jsValue + ) { + // Check if the input is an object + if (!jsValue.isObject()) { + throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructI16"); + } + + // Get the object from the jsi::Value + auto jsObject = jsValue.getObject(rt); + + // Create the vtable struct + UniffiForeignFutureStructI16 rsObject; + + // Create the vtable from the js callbacks. + rsObject.return_value = uniffi_jsi::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "returnValue") + ); + rsObject.call_status = uniffi::foobar::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "callStatus") + ); + + return rsObject; + } +}; + +} // namespace uniffi::foobar + // Implementation of callback function calling from JS to Rust ForeignFutureCompleteI16, + // passed from Rust to JS as part of async callbacks. +namespace uniffi::foobar { +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr callInvoker, UniffiForeignFutureCompleteI16 rsCallback) { + return jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteI16"), + 2, + [rsCallback, callInvoker]( + jsi::Runtime &rt, + const jsi::Value &thisValue, + const jsi::Value *arguments, + size_t count) -> jsi::Value + { + return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback); + } + ); + } + + static jsi::Value intoRust( + jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &thisValue, + const jsi::Value *args, + size_t count, + UniffiForeignFutureCompleteI16 func) { + // Convert the arguments into the Rust, with Bridging::fromJs, + // then call the rs_callback with those arguments. + func(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging::fromJs(rt, callInvoker, args[1]) + ); + + + return jsi::Value::undefined(); + } +}; +} // namespace uniffi::foobar +namespace uniffi::foobar { +using namespace facebook; +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static UniffiForeignFutureStructU32 fromJs(jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &jsValue + ) { + // Check if the input is an object + if (!jsValue.isObject()) { + throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructU32"); + } + + // Get the object from the jsi::Value + auto jsObject = jsValue.getObject(rt); + + // Create the vtable struct + UniffiForeignFutureStructU32 rsObject; + + // Create the vtable from the js callbacks. + rsObject.return_value = uniffi_jsi::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "returnValue") + ); + rsObject.call_status = uniffi::foobar::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "callStatus") + ); + + return rsObject; + } +}; + +} // namespace uniffi::foobar + // Implementation of callback function calling from JS to Rust ForeignFutureCompleteU32, + // passed from Rust to JS as part of async callbacks. +namespace uniffi::foobar { +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr callInvoker, UniffiForeignFutureCompleteU32 rsCallback) { + return jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteU32"), + 2, + [rsCallback, callInvoker]( + jsi::Runtime &rt, + const jsi::Value &thisValue, + const jsi::Value *arguments, + size_t count) -> jsi::Value + { + return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback); + } + ); + } + + static jsi::Value intoRust( + jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &thisValue, + const jsi::Value *args, + size_t count, + UniffiForeignFutureCompleteU32 func) { + // Convert the arguments into the Rust, with Bridging::fromJs, + // then call the rs_callback with those arguments. + func(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging::fromJs(rt, callInvoker, args[1]) + ); + + + return jsi::Value::undefined(); + } +}; +} // namespace uniffi::foobar +namespace uniffi::foobar { +using namespace facebook; +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static UniffiForeignFutureStructI32 fromJs(jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &jsValue + ) { + // Check if the input is an object + if (!jsValue.isObject()) { + throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructI32"); + } + + // Get the object from the jsi::Value + auto jsObject = jsValue.getObject(rt); + + // Create the vtable struct + UniffiForeignFutureStructI32 rsObject; + + // Create the vtable from the js callbacks. + rsObject.return_value = uniffi_jsi::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "returnValue") + ); + rsObject.call_status = uniffi::foobar::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "callStatus") + ); + + return rsObject; + } +}; + +} // namespace uniffi::foobar + // Implementation of callback function calling from JS to Rust ForeignFutureCompleteI32, + // passed from Rust to JS as part of async callbacks. +namespace uniffi::foobar { +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr callInvoker, UniffiForeignFutureCompleteI32 rsCallback) { + return jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteI32"), + 2, + [rsCallback, callInvoker]( + jsi::Runtime &rt, + const jsi::Value &thisValue, + const jsi::Value *arguments, + size_t count) -> jsi::Value + { + return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback); + } + ); + } + + static jsi::Value intoRust( + jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &thisValue, + const jsi::Value *args, + size_t count, + UniffiForeignFutureCompleteI32 func) { + // Convert the arguments into the Rust, with Bridging::fromJs, + // then call the rs_callback with those arguments. + func(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging::fromJs(rt, callInvoker, args[1]) + ); + + + return jsi::Value::undefined(); + } +}; +} // namespace uniffi::foobar +namespace uniffi::foobar { +using namespace facebook; +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static UniffiForeignFutureStructU64 fromJs(jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &jsValue + ) { + // Check if the input is an object + if (!jsValue.isObject()) { + throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructU64"); + } + + // Get the object from the jsi::Value + auto jsObject = jsValue.getObject(rt); + + // Create the vtable struct + UniffiForeignFutureStructU64 rsObject; + + // Create the vtable from the js callbacks. + rsObject.return_value = uniffi_jsi::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "returnValue") + ); + rsObject.call_status = uniffi::foobar::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "callStatus") + ); + + return rsObject; + } +}; + +} // namespace uniffi::foobar + // Implementation of callback function calling from JS to Rust ForeignFutureCompleteU64, + // passed from Rust to JS as part of async callbacks. +namespace uniffi::foobar { +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr callInvoker, UniffiForeignFutureCompleteU64 rsCallback) { + return jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteU64"), + 2, + [rsCallback, callInvoker]( + jsi::Runtime &rt, + const jsi::Value &thisValue, + const jsi::Value *arguments, + size_t count) -> jsi::Value + { + return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback); + } + ); + } + + static jsi::Value intoRust( + jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &thisValue, + const jsi::Value *args, + size_t count, + UniffiForeignFutureCompleteU64 func) { + // Convert the arguments into the Rust, with Bridging::fromJs, + // then call the rs_callback with those arguments. + func(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging::fromJs(rt, callInvoker, args[1]) + ); + + + return jsi::Value::undefined(); + } +}; +} // namespace uniffi::foobar +namespace uniffi::foobar { +using namespace facebook; +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static UniffiForeignFutureStructI64 fromJs(jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &jsValue + ) { + // Check if the input is an object + if (!jsValue.isObject()) { + throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructI64"); + } + + // Get the object from the jsi::Value + auto jsObject = jsValue.getObject(rt); + + // Create the vtable struct + UniffiForeignFutureStructI64 rsObject; + + // Create the vtable from the js callbacks. + rsObject.return_value = uniffi_jsi::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "returnValue") + ); + rsObject.call_status = uniffi::foobar::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "callStatus") + ); + + return rsObject; + } +}; + +} // namespace uniffi::foobar + // Implementation of callback function calling from JS to Rust ForeignFutureCompleteI64, + // passed from Rust to JS as part of async callbacks. +namespace uniffi::foobar { +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr callInvoker, UniffiForeignFutureCompleteI64 rsCallback) { + return jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteI64"), + 2, + [rsCallback, callInvoker]( + jsi::Runtime &rt, + const jsi::Value &thisValue, + const jsi::Value *arguments, + size_t count) -> jsi::Value + { + return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback); + } + ); + } + + static jsi::Value intoRust( + jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &thisValue, + const jsi::Value *args, + size_t count, + UniffiForeignFutureCompleteI64 func) { + // Convert the arguments into the Rust, with Bridging::fromJs, + // then call the rs_callback with those arguments. + func(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging::fromJs(rt, callInvoker, args[1]) + ); + + + return jsi::Value::undefined(); + } +}; +} // namespace uniffi::foobar +namespace uniffi::foobar { +using namespace facebook; +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static UniffiForeignFutureStructF32 fromJs(jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &jsValue + ) { + // Check if the input is an object + if (!jsValue.isObject()) { + throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructF32"); + } + + // Get the object from the jsi::Value + auto jsObject = jsValue.getObject(rt); + + // Create the vtable struct + UniffiForeignFutureStructF32 rsObject; + + // Create the vtable from the js callbacks. + rsObject.return_value = uniffi_jsi::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "returnValue") + ); + rsObject.call_status = uniffi::foobar::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "callStatus") + ); + + return rsObject; + } +}; + +} // namespace uniffi::foobar + // Implementation of callback function calling from JS to Rust ForeignFutureCompleteF32, + // passed from Rust to JS as part of async callbacks. +namespace uniffi::foobar { +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr callInvoker, UniffiForeignFutureCompleteF32 rsCallback) { + return jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteF32"), + 2, + [rsCallback, callInvoker]( + jsi::Runtime &rt, + const jsi::Value &thisValue, + const jsi::Value *arguments, + size_t count) -> jsi::Value + { + return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback); + } + ); + } + + static jsi::Value intoRust( + jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &thisValue, + const jsi::Value *args, + size_t count, + UniffiForeignFutureCompleteF32 func) { + // Convert the arguments into the Rust, with Bridging::fromJs, + // then call the rs_callback with those arguments. + func(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging::fromJs(rt, callInvoker, args[1]) + ); + + + return jsi::Value::undefined(); + } +}; +} // namespace uniffi::foobar +namespace uniffi::foobar { +using namespace facebook; +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static UniffiForeignFutureStructF64 fromJs(jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &jsValue + ) { + // Check if the input is an object + if (!jsValue.isObject()) { + throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructF64"); + } + + // Get the object from the jsi::Value + auto jsObject = jsValue.getObject(rt); + + // Create the vtable struct + UniffiForeignFutureStructF64 rsObject; + + // Create the vtable from the js callbacks. + rsObject.return_value = uniffi_jsi::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "returnValue") + ); + rsObject.call_status = uniffi::foobar::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "callStatus") + ); + + return rsObject; + } +}; + +} // namespace uniffi::foobar + // Implementation of callback function calling from JS to Rust ForeignFutureCompleteF64, + // passed from Rust to JS as part of async callbacks. +namespace uniffi::foobar { +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr callInvoker, UniffiForeignFutureCompleteF64 rsCallback) { + return jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteF64"), + 2, + [rsCallback, callInvoker]( + jsi::Runtime &rt, + const jsi::Value &thisValue, + const jsi::Value *arguments, + size_t count) -> jsi::Value + { + return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback); + } + ); + } + + static jsi::Value intoRust( + jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &thisValue, + const jsi::Value *args, + size_t count, + UniffiForeignFutureCompleteF64 func) { + // Convert the arguments into the Rust, with Bridging::fromJs, + // then call the rs_callback with those arguments. + func(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging::fromJs(rt, callInvoker, args[1]) + ); + + + return jsi::Value::undefined(); + } +}; +} // namespace uniffi::foobar +namespace uniffi::foobar { +using namespace facebook; +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static UniffiForeignFutureStructPointer fromJs(jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &jsValue + ) { + // Check if the input is an object + if (!jsValue.isObject()) { + throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructPointer"); + } + + // Get the object from the jsi::Value + auto jsObject = jsValue.getObject(rt); + + // Create the vtable struct + UniffiForeignFutureStructPointer rsObject; + + // Create the vtable from the js callbacks. + rsObject.return_value = uniffi_jsi::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "returnValue") + ); + rsObject.call_status = uniffi::foobar::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "callStatus") + ); + + return rsObject; + } +}; + +} // namespace uniffi::foobar + // Implementation of callback function calling from JS to Rust ForeignFutureCompletePointer, + // passed from Rust to JS as part of async callbacks. +namespace uniffi::foobar { +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr callInvoker, UniffiForeignFutureCompletePointer rsCallback) { + return jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "--ForeignFutureCompletePointer"), + 2, + [rsCallback, callInvoker]( + jsi::Runtime &rt, + const jsi::Value &thisValue, + const jsi::Value *arguments, + size_t count) -> jsi::Value + { + return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback); + } + ); + } + + static jsi::Value intoRust( + jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &thisValue, + const jsi::Value *args, + size_t count, + UniffiForeignFutureCompletePointer func) { + // Convert the arguments into the Rust, with Bridging::fromJs, + // then call the rs_callback with those arguments. + func(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging::fromJs(rt, callInvoker, args[1]) + ); + + + return jsi::Value::undefined(); + } +}; +} // namespace uniffi::foobar +namespace uniffi::foobar { +using namespace facebook; +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static UniffiForeignFutureStructRustBuffer fromJs(jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &jsValue + ) { + // Check if the input is an object + if (!jsValue.isObject()) { + throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructRustBuffer"); + } + + // Get the object from the jsi::Value + auto jsObject = jsValue.getObject(rt); + + // Create the vtable struct + UniffiForeignFutureStructRustBuffer rsObject; + + // Create the vtable from the js callbacks. + rsObject.return_value = uniffi::foobar::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "returnValue") + ); + rsObject.call_status = uniffi::foobar::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "callStatus") + ); + + return rsObject; + } +}; + +} // namespace uniffi::foobar + // Implementation of callback function calling from JS to Rust ForeignFutureCompleteRustBuffer, + // passed from Rust to JS as part of async callbacks. +namespace uniffi::foobar { +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr callInvoker, UniffiForeignFutureCompleteRustBuffer rsCallback) { + return jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteRustBuffer"), + 2, + [rsCallback, callInvoker]( + jsi::Runtime &rt, + const jsi::Value &thisValue, + const jsi::Value *arguments, + size_t count) -> jsi::Value + { + return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback); + } + ); + } + + static jsi::Value intoRust( + jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &thisValue, + const jsi::Value *args, + size_t count, + UniffiForeignFutureCompleteRustBuffer func) { + // Convert the arguments into the Rust, with Bridging::fromJs, + // then call the rs_callback with those arguments. + func(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging::fromJs(rt, callInvoker, args[1]) + ); + + + return jsi::Value::undefined(); + } +}; +} // namespace uniffi::foobar +namespace uniffi::foobar { +using namespace facebook; +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static UniffiForeignFutureStructVoid fromJs(jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &jsValue + ) { + // Check if the input is an object + if (!jsValue.isObject()) { + throw jsi::JSError(rt, "Expected an object for UniffiForeignFutureStructVoid"); + } + + // Get the object from the jsi::Value + auto jsObject = jsValue.getObject(rt); + + // Create the vtable struct + UniffiForeignFutureStructVoid rsObject; + + // Create the vtable from the js callbacks. + rsObject.call_status = uniffi::foobar::Bridging::fromJs( + rt, callInvoker, + jsObject.getProperty(rt, "callStatus") + ); + + return rsObject; + } +}; + +} // namespace uniffi::foobar + // Implementation of callback function calling from JS to Rust ForeignFutureCompleteVoid, + // passed from Rust to JS as part of async callbacks. +namespace uniffi::foobar { +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static jsi::Value toJs(jsi::Runtime &rt, std::shared_ptr callInvoker, UniffiForeignFutureCompleteVoid rsCallback) { + return jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "--ForeignFutureCompleteVoid"), + 2, + [rsCallback, callInvoker]( + jsi::Runtime &rt, + const jsi::Value &thisValue, + const jsi::Value *arguments, + size_t count) -> jsi::Value + { + return intoRust(rt, callInvoker, thisValue, arguments, count, rsCallback); + } + ); + } + + static jsi::Value intoRust( + jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &thisValue, + const jsi::Value *args, + size_t count, + UniffiForeignFutureCompleteVoid func) { + // Convert the arguments into the Rust, with Bridging::fromJs, + // then call the rs_callback with those arguments. + func(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), uniffi::foobar::Bridging::fromJs(rt, callInvoker, args[1]) + ); + + + return jsi::Value::undefined(); + } +}; +} // namespace uniffi::foobar + // Implementation of callback function calling from Rust to JS CallbackInterfaceBinaryOperatorMethod0 + +// Callback function: uniffi::foobar::cb::callbackinterfacebinaryoperatormethod0::UniffiCallbackInterfaceBinaryOperatorMethod0 +// +// We have the following constraints: +// - we need to pass a function pointer to Rust. +// - we need a jsi::Runtime and jsi::Function to call into JS. +// - function pointers can't store state, so we can't use a lamda. +// +// For this, we store a lambda as a global, as `rsLambda`. The `callback` function calls +// the lambda, which itself calls the `body` which then calls into JS. +// +// We then give the `callback` function pointer to Rust which will call the lambda sometime in the +// future. +namespace uniffi::foobar::cb::callbackinterfacebinaryoperatormethod0 { + using namespace facebook; + + // We need to store a lambda in a global so we can call it from + // a function pointer. The function pointer is passed to Rust. + static std::function rsLambda = nullptr; + + // This is the main body of the callback. It's called from the lambda, + // which itself is called from the callback function which is passed to Rust. + static void body(jsi::Runtime &rt, + std::shared_ptr callInvoker, + std::shared_ptr callbackValue + ,uint64_t rs_uniffiHandle + ,int64_t rs_lhs + ,int64_t rs_rhs + ,int64_t * rs_uniffiOutReturn, RustCallStatus* uniffi_call_status) { + + // Convert the arguments from Rust, into jsi::Values. + // We'll use the Bridging class to do this… + auto js_uniffiHandle = uniffi_jsi::Bridging::toJs(rt, callInvoker, rs_uniffiHandle); + auto js_lhs = uniffi_jsi::Bridging::toJs(rt, callInvoker, rs_lhs); + auto js_rhs = uniffi_jsi::Bridging::toJs(rt, callInvoker, rs_rhs); + + // Now we are ready to call the callback. + // We are already on the JS thread, because this `body` function was + // invoked from the CallInvoker. + try { + // Getting the callback function + auto cb = callbackValue->asObject(rt).asFunction(rt); + auto uniffiResult = cb.call(rt, js_uniffiHandle, js_lhs, js_rhs + ); + + // Now copy the result back from JS into the RustCallStatus object. + uniffi::foobar::Bridging::copyFromJs(rt, callInvoker, uniffiResult, uniffi_call_status); + + if (uniffi_call_status->code != UNIFFI_CALL_STATUS_OK) { + // The JS callback finished abnormally, so we cannot retrieve the return value. + return; + } + + + // return type is MutReference(Int64) + // Finally, we need to copy the return value back into the Rust pointer. + *rs_uniffiOutReturn = + uniffi_jsi::Bridging< + ReferenceHolder + >::fromJs( + rt, callInvoker, uniffiResult + ); + } catch (const jsi::JSError &error) { + std::cout << "Error in callback UniffiCallbackInterfaceBinaryOperatorMethod0: " + << error.what() << std::endl; + throw error; + } + } + + static void callback(uint64_t rs_uniffiHandle, int64_t rs_lhs, int64_t rs_rhs, int64_t * rs_uniffiOutReturn, RustCallStatus* uniffi_call_status) { + // If the runtime has shutdown, then there is no point in trying to + // call into Javascript. BUT how do we tell if the runtime has shutdown? + // + // Answer: the module destructor calls into callback `cleanup` method, + // which nulls out the rsLamda. + // + // If rsLamda is null, then there is no runtime to call into. + if (rsLambda == nullptr) { + // This only occurs when destructors are calling into Rust free/drop, + // which causes the JS callback to be dropped. + return; + } + + // The runtime, the actual callback jsi::funtion, and the callInvoker + // are all in the lambda. + rsLambda( + rs_uniffiHandle, + rs_lhs, + rs_rhs, + rs_uniffiOutReturn, uniffi_call_status); + } + + static UniffiCallbackInterfaceBinaryOperatorMethod0 + makeCallbackFunction( // uniffi::foobar::cb::callbackinterfacebinaryoperatormethod0 + jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &value) { + if (rsLambda != nullptr) { + // `makeCallbackFunction` is called in two circumstances: + // + // 1. at startup, when initializing callback interface vtables. + // 2. when polling futures. This happens at least once per future that is + // exposed to Javascript. We know that this is always the same function, + // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`. + // + // We can therefore return the callback function without making anything + // new if we've been initialized already. + return callback; + } + auto callbackFunction = value.asObject(rt).asFunction(rt); + auto callbackValue = std::make_shared(rt, callbackFunction); + rsLambda = [&rt, callInvoker, callbackValue](uint64_t rs_uniffiHandle, int64_t rs_lhs, int64_t rs_rhs, int64_t * rs_uniffiOutReturn, RustCallStatus* uniffi_call_status) { + // We immediately make a lambda which will do the work of transforming the + // arguments into JSI values and calling the callback. + uniffi_runtime::UniffiCallFunc jsLambda = [ + callInvoker, + callbackValue + , rs_uniffiHandle + , rs_lhs + , rs_rhs + , rs_uniffiOutReturn, uniffi_call_status](jsi::Runtime &rt) mutable { + body(rt, callInvoker, callbackValue + , rs_uniffiHandle + , rs_lhs + , rs_rhs + , rs_uniffiOutReturn, uniffi_call_status); + }; + // We'll then call that lambda from the callInvoker which will + // look after calling it on the correct thread. + callInvoker->invokeBlocking(rt, jsLambda); + }; + return callback; + } + + // This method is called from the destructor of NativeFoobar, which only happens + // when the jsi::Runtime is being destroyed. + static void cleanup() { + // The lambda holds a reference to the the Runtime, so when this is nulled out, + // then the pointer will no longer be left dangling. + rsLambda = nullptr; + } +} // namespace uniffi::foobar::cb::callbackinterfacebinaryoperatormethod0 +namespace uniffi::foobar { +using namespace facebook; +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static UniffiVTableCallbackInterfaceBinaryOperator fromJs(jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &jsValue + ) { + // Check if the input is an object + if (!jsValue.isObject()) { + throw jsi::JSError(rt, "Expected an object for UniffiVTableCallbackInterfaceBinaryOperator"); + } + + // Get the object from the jsi::Value + auto jsObject = jsValue.getObject(rt); + + // Create the vtable struct + UniffiVTableCallbackInterfaceBinaryOperator rsObject; + + // Create the vtable from the js callbacks. + rsObject.perform = uniffi::foobar::cb::callbackinterfacebinaryoperatormethod0::makeCallbackFunction( + rt, callInvoker, jsObject.getProperty(rt, "perform") + ); + rsObject.uniffi_free = uniffi::foobar::st::vtablecallbackinterfacebinaryoperator::vtablecallbackinterfacebinaryoperator::free::makeCallbackFunction( + rt, callInvoker, jsObject.getProperty(rt, "uniffiFree") + ); + + return rsObject; + } +}; + +} // namespace uniffi::foobar + + +namespace uniffi::foobar { +using namespace facebook; +using CallInvoker = uniffi_runtime::UniffiCallInvoker; + +template <> struct Bridging { + static UniffiRustFutureContinuationCallback fromJs( + jsi::Runtime &rt, + std::shared_ptr callInvoker, + const jsi::Value &value + ) { + try { + return uniffi::foobar::cb::rustfuturecontinuationcallback::makeCallbackFunction( + rt, + callInvoker, + value + ); + } catch (const std::logic_error &e) { + throw jsi::JSError(rt, e.what()); + } + } +}; + +} // namespace uniffi::foobar + +NativeFoobar::NativeFoobar( + jsi::Runtime &rt, + std::shared_ptr invoker +) : callInvoker(invoker), props() { + // Map from Javascript names to the cpp names + props["ubrn_uniffi_internal_fn_func_ffi__string_to_byte_length"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_internal_fn_func_ffi__string_to_byte_length"), + 1, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_internal_fn_func_ffi__string_to_byte_length(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_internal_fn_func_ffi__string_to_arraybuffer"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_internal_fn_func_ffi__string_to_arraybuffer"), + 1, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_internal_fn_func_ffi__string_to_arraybuffer(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_internal_fn_func_ffi__arraybuffer_to_string"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_internal_fn_func_ffi__arraybuffer_to_string"), + 1, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_internal_fn_func_ffi__arraybuffer_to_string(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_fn_clone_binaryoperator"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_clone_binaryoperator"), + 1, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_fn_clone_binaryoperator(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_fn_free_binaryoperator"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_free_binaryoperator"), + 1, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_fn_free_binaryoperator(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_fn_init_callback_vtable_binaryoperator"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_init_callback_vtable_binaryoperator"), + 1, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_fn_init_callback_vtable_binaryoperator(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_fn_method_binaryoperator_perform"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_method_binaryoperator_perform"), + 3, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_fn_method_binaryoperator_perform(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_fn_clone_calculator"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_clone_calculator"), + 1, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_fn_clone_calculator(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_fn_free_calculator"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_free_calculator"), + 1, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_fn_free_calculator(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_fn_constructor_calculator_new"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_constructor_calculator_new"), + 0, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_fn_constructor_calculator_new(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_fn_method_calculator_calculate"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_method_calculator_calculate"), + 4, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_fn_method_calculator_calculate(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_fn_method_calculator_calculate_more"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_method_calculator_calculate_more"), + 3, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_fn_method_calculator_calculate_more(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_fn_method_calculator_last_result"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_method_calculator_last_result"), + 1, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_fn_method_calculator_last_result(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_fn_clone_safeaddition"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_clone_safeaddition"), + 1, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_fn_clone_safeaddition(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_fn_free_safeaddition"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_free_safeaddition"), + 1, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_fn_free_safeaddition(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_fn_constructor_safeaddition_new"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_constructor_safeaddition_new"), + 0, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_fn_constructor_safeaddition_new(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_fn_method_safeaddition_perform"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_method_safeaddition_perform"), + 3, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_fn_method_safeaddition_perform(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_fn_clone_safedivision"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_clone_safedivision"), + 1, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_fn_clone_safedivision(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_fn_free_safedivision"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_free_safedivision"), + 1, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_fn_free_safedivision(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_fn_constructor_safedivision_new"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_constructor_safedivision_new"), + 0, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_fn_constructor_safedivision_new(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_fn_method_safedivision_perform"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_method_safedivision_perform"), + 3, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_fn_method_safedivision_perform(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_fn_func_safe_addition_operator"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_func_safe_addition_operator"), + 0, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_fn_func_safe_addition_operator(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_fn_func_safe_division_operator"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_fn_func_safe_division_operator"), + 0, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_fn_func_safe_division_operator(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_checksum_func_safe_addition_operator"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_func_safe_addition_operator"), + 0, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_checksum_func_safe_addition_operator(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_checksum_func_safe_division_operator"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_func_safe_division_operator"), + 0, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_checksum_func_safe_division_operator(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_checksum_method_binaryoperator_perform"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_method_binaryoperator_perform"), + 0, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_checksum_method_binaryoperator_perform(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_checksum_method_calculator_calculate"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_method_calculator_calculate"), + 0, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_checksum_method_calculator_calculate(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_checksum_method_calculator_calculate_more"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_method_calculator_calculate_more"), + 0, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_checksum_method_calculator_calculate_more(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_checksum_method_calculator_last_result"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_method_calculator_last_result"), + 0, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_checksum_method_calculator_last_result(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_checksum_method_safeaddition_perform"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_method_safeaddition_perform"), + 0, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_checksum_method_safeaddition_perform(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_checksum_method_safedivision_perform"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_method_safedivision_perform"), + 0, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_checksum_method_safedivision_perform(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_checksum_constructor_calculator_new"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_constructor_calculator_new"), + 0, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_checksum_constructor_calculator_new(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_checksum_constructor_safeaddition_new"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_constructor_safeaddition_new"), + 0, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_checksum_constructor_safeaddition_new(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_foobar_checksum_constructor_safedivision_new"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_foobar_checksum_constructor_safedivision_new"), + 0, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_foobar_checksum_constructor_safedivision_new(rt, thisVal, args, count); + } + ); + props["ubrn_ffi_foobar_uniffi_contract_version"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_ffi_foobar_uniffi_contract_version"), + 0, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_ffi_foobar_uniffi_contract_version(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_internal_fn_method_binaryoperator_ffi__bless_pointer"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_internal_fn_method_binaryoperator_ffi__bless_pointer"), + 1, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_internal_fn_method_binaryoperator_ffi__bless_pointer(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_internal_fn_method_calculator_ffi__bless_pointer"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_internal_fn_method_calculator_ffi__bless_pointer"), + 1, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_internal_fn_method_calculator_ffi__bless_pointer(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_internal_fn_method_safeaddition_ffi__bless_pointer"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_internal_fn_method_safeaddition_ffi__bless_pointer"), + 1, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_internal_fn_method_safeaddition_ffi__bless_pointer(rt, thisVal, args, count); + } + ); + props["ubrn_uniffi_internal_fn_method_safedivision_ffi__bless_pointer"] = jsi::Function::createFromHostFunction( + rt, + jsi::PropNameID::forAscii(rt, "ubrn_uniffi_internal_fn_method_safedivision_ffi__bless_pointer"), + 1, + [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value { + return this->cpp_uniffi_internal_fn_method_safedivision_ffi__bless_pointer(rt, thisVal, args, count); + } + ); +} + +void NativeFoobar::registerModule(jsi::Runtime &rt, std::shared_ptr callInvoker) { + auto invoker = std::make_shared(callInvoker); + auto tm = std::make_shared(rt, invoker); + auto obj = rt.global().createFromHostObject(rt, tm); + rt.global().setProperty(rt, "NativeFoobar", obj); +} + +void NativeFoobar::unregisterModule(jsi::Runtime &rt) { + uniffi::foobar::registry::clearRegistry(); +} + +jsi::Value NativeFoobar::get(jsi::Runtime& rt, const jsi::PropNameID& name) { + try { + return jsi::Value(rt, props.at(name.utf8(rt))); + } + catch (std::out_of_range &e) { + return jsi::Value::undefined(); + } +} + +std::vector NativeFoobar::getPropertyNames(jsi::Runtime& rt) { + std::vector rval; + for (auto& [key, value] : props) { + rval.push_back(jsi::PropNameID::forUtf8(rt, key)); + } + return rval; +} + +void NativeFoobar::set(jsi::Runtime& rt, const jsi::PropNameID& name, const jsi::Value& value) { + props.insert_or_assign(name.utf8(rt), &value); +} + +NativeFoobar::~NativeFoobar() { + // Cleanup for callback function RustFutureContinuationCallback +uniffi::foobar::cb::rustfuturecontinuationcallback::cleanup(); + // Cleanup for "free" callback function CallbackInterfaceFree +uniffi::foobar::st::foreignfuture::foreignfuture::free::cleanup();uniffi::foobar::st::vtablecallbackinterfacebinaryoperator::vtablecallbackinterfacebinaryoperator::free::cleanup(); + // Cleanup for callback function CallbackInterfaceBinaryOperatorMethod0 +uniffi::foobar::cb::callbackinterfacebinaryoperatormethod0::cleanup(); +} + +// Utility functions for serialization/deserialization of strings. +jsi::Value NativeFoobar::cpp_uniffi_internal_fn_func_ffi__string_to_byte_length(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + return uniffi_jsi::Bridging::string_to_bytelength(rt, args[0]); +} + +jsi::Value NativeFoobar::cpp_uniffi_internal_fn_func_ffi__string_to_arraybuffer(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + return uniffi_jsi::Bridging::string_to_arraybuffer(rt, args[0]); +} + +jsi::Value NativeFoobar::cpp_uniffi_internal_fn_func_ffi__arraybuffer_to_string(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + return uniffi_jsi::Bridging::arraybuffer_to_string(rt, args[0]); +}jsi::Value NativeFoobar::cpp_uniffi_internal_fn_method_binaryoperator_ffi__bless_pointer(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + auto pointer = uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]); + auto static destructor = [](uint64_t p) { + auto pointer = reinterpret_cast(static_cast(p)); + RustCallStatus status = {0}; + uniffi_foobar_fn_free_binaryoperator(pointer, &status); + }; + auto ptrObj = std::make_shared(pointer, destructor); + auto obj = jsi::Object::createFromHostObject(rt, ptrObj); + return jsi::Value(rt, obj); +}jsi::Value NativeFoobar::cpp_uniffi_internal_fn_method_calculator_ffi__bless_pointer(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + auto pointer = uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]); + auto static destructor = [](uint64_t p) { + auto pointer = reinterpret_cast(static_cast(p)); + RustCallStatus status = {0}; + uniffi_foobar_fn_free_calculator(pointer, &status); + }; + auto ptrObj = std::make_shared(pointer, destructor); + auto obj = jsi::Object::createFromHostObject(rt, ptrObj); + return jsi::Value(rt, obj); +}jsi::Value NativeFoobar::cpp_uniffi_internal_fn_method_safeaddition_ffi__bless_pointer(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + auto pointer = uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]); + auto static destructor = [](uint64_t p) { + auto pointer = reinterpret_cast(static_cast(p)); + RustCallStatus status = {0}; + uniffi_foobar_fn_free_safeaddition(pointer, &status); + }; + auto ptrObj = std::make_shared(pointer, destructor); + auto obj = jsi::Object::createFromHostObject(rt, ptrObj); + return jsi::Value(rt, obj); +}jsi::Value NativeFoobar::cpp_uniffi_internal_fn_method_safedivision_ffi__bless_pointer(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + auto pointer = uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]); + auto static destructor = [](uint64_t p) { + auto pointer = reinterpret_cast(static_cast(p)); + RustCallStatus status = {0}; + uniffi_foobar_fn_free_safedivision(pointer, &status); + }; + auto ptrObj = std::make_shared(pointer, destructor); + auto obj = jsi::Object::createFromHostObject(rt, ptrObj); + return jsi::Value(rt, obj); +} + +// Methods calling directly into the uniffi generated C API of the Rust crate. +jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_clone_binaryoperator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + RustCallStatus status = uniffi::foobar::Bridging::rustSuccess(rt); + auto value = uniffi_foobar_fn_clone_binaryoperator(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), + &status + ); + uniffi::foobar::Bridging::copyIntoJs(rt, callInvoker, status, args[count - 1]); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_free_binaryoperator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + RustCallStatus status = uniffi::foobar::Bridging::rustSuccess(rt); + uniffi_foobar_fn_free_binaryoperator(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), + &status + ); + uniffi::foobar::Bridging::copyIntoJs(rt, callInvoker, status, args[count - 1]); + + + return jsi::Value::undefined(); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_init_callback_vtable_binaryoperator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + auto vtableInstance = + uniffi::foobar::Bridging::fromJs( + rt, + callInvoker, + args[0] + ); + + std::lock_guard lock(uniffi::foobar::registry::vtableMutex); + uniffi_foobar_fn_init_callback_vtable_binaryoperator( + uniffi::foobar::registry::putTable( + "UniffiVTableCallbackInterfaceBinaryOperator", + vtableInstance + ) + ); + return jsi::Value::undefined(); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_method_binaryoperator_perform(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + RustCallStatus status = uniffi::foobar::Bridging::rustSuccess(rt); + auto value = uniffi_foobar_fn_method_binaryoperator_perform(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[1]), uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[2]), + &status + ); + uniffi::foobar::Bridging::copyIntoJs(rt, callInvoker, status, args[count - 1]); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_clone_calculator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + RustCallStatus status = uniffi::foobar::Bridging::rustSuccess(rt); + auto value = uniffi_foobar_fn_clone_calculator(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), + &status + ); + uniffi::foobar::Bridging::copyIntoJs(rt, callInvoker, status, args[count - 1]); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_free_calculator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + RustCallStatus status = uniffi::foobar::Bridging::rustSuccess(rt); + uniffi_foobar_fn_free_calculator(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), + &status + ); + uniffi::foobar::Bridging::copyIntoJs(rt, callInvoker, status, args[count - 1]); + + + return jsi::Value::undefined(); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_constructor_calculator_new(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + RustCallStatus status = uniffi::foobar::Bridging::rustSuccess(rt); + auto value = uniffi_foobar_fn_constructor_calculator_new(&status + ); + uniffi::foobar::Bridging::copyIntoJs(rt, callInvoker, status, args[count - 1]); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_method_calculator_calculate(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + RustCallStatus status = uniffi::foobar::Bridging::rustSuccess(rt); + auto value = uniffi_foobar_fn_method_calculator_calculate(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[1]), uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[2]), uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[3]), + &status + ); + uniffi::foobar::Bridging::copyIntoJs(rt, callInvoker, status, args[count - 1]); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_method_calculator_calculate_more(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + RustCallStatus status = uniffi::foobar::Bridging::rustSuccess(rt); + auto value = uniffi_foobar_fn_method_calculator_calculate_more(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[1]), uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[2]), + &status + ); + uniffi::foobar::Bridging::copyIntoJs(rt, callInvoker, status, args[count - 1]); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_method_calculator_last_result(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + RustCallStatus status = uniffi::foobar::Bridging::rustSuccess(rt); + auto value = uniffi_foobar_fn_method_calculator_last_result(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), + &status + ); + uniffi::foobar::Bridging::copyIntoJs(rt, callInvoker, status, args[count - 1]); + + + return uniffi::foobar::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_clone_safeaddition(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + RustCallStatus status = uniffi::foobar::Bridging::rustSuccess(rt); + auto value = uniffi_foobar_fn_clone_safeaddition(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), + &status + ); + uniffi::foobar::Bridging::copyIntoJs(rt, callInvoker, status, args[count - 1]); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_free_safeaddition(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + RustCallStatus status = uniffi::foobar::Bridging::rustSuccess(rt); + uniffi_foobar_fn_free_safeaddition(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), + &status + ); + uniffi::foobar::Bridging::copyIntoJs(rt, callInvoker, status, args[count - 1]); + + + return jsi::Value::undefined(); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_constructor_safeaddition_new(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + RustCallStatus status = uniffi::foobar::Bridging::rustSuccess(rt); + auto value = uniffi_foobar_fn_constructor_safeaddition_new(&status + ); + uniffi::foobar::Bridging::copyIntoJs(rt, callInvoker, status, args[count - 1]); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_method_safeaddition_perform(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + RustCallStatus status = uniffi::foobar::Bridging::rustSuccess(rt); + auto value = uniffi_foobar_fn_method_safeaddition_perform(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[1]), uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[2]), + &status + ); + uniffi::foobar::Bridging::copyIntoJs(rt, callInvoker, status, args[count - 1]); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_clone_safedivision(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + RustCallStatus status = uniffi::foobar::Bridging::rustSuccess(rt); + auto value = uniffi_foobar_fn_clone_safedivision(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), + &status + ); + uniffi::foobar::Bridging::copyIntoJs(rt, callInvoker, status, args[count - 1]); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_free_safedivision(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + RustCallStatus status = uniffi::foobar::Bridging::rustSuccess(rt); + uniffi_foobar_fn_free_safedivision(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), + &status + ); + uniffi::foobar::Bridging::copyIntoJs(rt, callInvoker, status, args[count - 1]); + + + return jsi::Value::undefined(); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_constructor_safedivision_new(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + RustCallStatus status = uniffi::foobar::Bridging::rustSuccess(rt); + auto value = uniffi_foobar_fn_constructor_safedivision_new(&status + ); + uniffi::foobar::Bridging::copyIntoJs(rt, callInvoker, status, args[count - 1]); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_method_safedivision_perform(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + RustCallStatus status = uniffi::foobar::Bridging::rustSuccess(rt); + auto value = uniffi_foobar_fn_method_safedivision_perform(uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[0]), uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[1]), uniffi_jsi::Bridging::fromJs(rt, callInvoker, args[2]), + &status + ); + uniffi::foobar::Bridging::copyIntoJs(rt, callInvoker, status, args[count - 1]); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_func_safe_addition_operator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + RustCallStatus status = uniffi::foobar::Bridging::rustSuccess(rt); + auto value = uniffi_foobar_fn_func_safe_addition_operator(&status + ); + uniffi::foobar::Bridging::copyIntoJs(rt, callInvoker, status, args[count - 1]); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_fn_func_safe_division_operator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + RustCallStatus status = uniffi::foobar::Bridging::rustSuccess(rt); + auto value = uniffi_foobar_fn_func_safe_division_operator(&status + ); + uniffi::foobar::Bridging::copyIntoJs(rt, callInvoker, status, args[count - 1]); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_func_safe_addition_operator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + auto value = uniffi_foobar_checksum_func_safe_addition_operator( + ); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_func_safe_division_operator(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + auto value = uniffi_foobar_checksum_func_safe_division_operator( + ); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_method_binaryoperator_perform(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + auto value = uniffi_foobar_checksum_method_binaryoperator_perform( + ); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_method_calculator_calculate(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + auto value = uniffi_foobar_checksum_method_calculator_calculate( + ); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_method_calculator_calculate_more(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + auto value = uniffi_foobar_checksum_method_calculator_calculate_more( + ); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_method_calculator_last_result(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + auto value = uniffi_foobar_checksum_method_calculator_last_result( + ); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_method_safeaddition_perform(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + auto value = uniffi_foobar_checksum_method_safeaddition_perform( + ); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_method_safedivision_perform(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + auto value = uniffi_foobar_checksum_method_safedivision_perform( + ); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_constructor_calculator_new(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + auto value = uniffi_foobar_checksum_constructor_calculator_new( + ); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_constructor_safeaddition_new(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + auto value = uniffi_foobar_checksum_constructor_safeaddition_new( + ); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_uniffi_foobar_checksum_constructor_safedivision_new(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + auto value = uniffi_foobar_checksum_constructor_safedivision_new( + ); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} +jsi::Value NativeFoobar::cpp_ffi_foobar_uniffi_contract_version(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) { + auto value = ffi_foobar_uniffi_contract_version( + ); + + + return uniffi_jsi::Bridging::toJs(rt, callInvoker, value); +} \ No newline at end of file diff --git a/packages/react-native-uniffi-russh/cpp/generated/foobar.hpp b/packages/react-native-uniffi-russh/cpp/generated/foobar.hpp new file mode 100644 index 0000000..c42fac3 --- /dev/null +++ b/packages/react-native-uniffi-russh/cpp/generated/foobar.hpp @@ -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 +#include +#include +#include +#include +#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 callInvoker; + + protected: + std::map 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 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 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 getPropertyNames(jsi::Runtime& rt); +}; \ No newline at end of file diff --git a/packages/react-native-uniffi-russh/cpp/react-native-uniffi-russh.cpp b/packages/react-native-uniffi-russh/cpp/react-native-uniffi-russh.cpp new file mode 100644 index 0000000..5752403 --- /dev/null +++ b/packages/react-native-uniffi-russh/cpp/react-native-uniffi-russh.cpp @@ -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 callInvoker) { + NativeFoobar::registerModule(runtime, callInvoker); + return true; + } + + uint8_t cleanupRustCrate(jsi::Runtime &runtime) { + return false; + } +} \ No newline at end of file diff --git a/packages/react-native-uniffi-russh/cpp/react-native-uniffi-russh.h b/packages/react-native-uniffi-russh/cpp/react-native-uniffi-russh.h new file mode 100644 index 0000000..9339fd8 --- /dev/null +++ b/packages/react-native-uniffi-russh/cpp/react-native-uniffi-russh.h @@ -0,0 +1,15 @@ +#ifndef UNIFFIRUSSH_H +#define UNIFFIRUSSH_H +// Generated by uniffi-bindgen-react-native +#include +#include +#include + +namespace uniffirussh { + using namespace facebook; + + uint8_t installRustCrate(jsi::Runtime &runtime, std::shared_ptr callInvoker); + uint8_t cleanupRustCrate(jsi::Runtime &runtime); +} + +#endif /* UNIFFIRUSSH_H */ \ No newline at end of file diff --git a/packages/react-native-uniffi-russh/eslint.config.mjs b/packages/react-native-uniffi-russh/eslint.config.mjs index 16b00bb..8fc7174 100644 --- a/packages/react-native-uniffi-russh/eslint.config.mjs +++ b/packages/react-native-uniffi-russh/eslint.config.mjs @@ -24,6 +24,6 @@ export default defineConfig([ }, }, { - ignores: ['node_modules/', 'lib/'], + ignores: ['node_modules/', 'lib/', 'src/generated/'], }, ]); diff --git a/packages/react-native-uniffi-russh/package.json b/packages/react-native-uniffi-russh/package.json index d8be60e..df3a10b 100644 --- a/packages/react-native-uniffi-russh/package.json +++ b/packages/react-native-uniffi-russh/package.json @@ -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 @@ "/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, diff --git a/packages/react-native-uniffi-russh/src/NativeUniffiRussh.ts b/packages/react-native-uniffi-russh/src/NativeUniffiRussh.ts new file mode 100644 index 0000000..4bbe5cf --- /dev/null +++ b/packages/react-native-uniffi-russh/src/NativeUniffiRussh.ts @@ -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('UniffiRussh'); \ No newline at end of file diff --git a/packages/react-native-uniffi-russh/src/generated/foobar-ffi.ts b/packages/react-native-uniffi-russh/src/generated/foobar-ffi.ts new file mode 100644 index 0000000..dbd0548 --- /dev/null +++ b/packages/react-native-uniffi-russh/src/generated/foobar-ffi.ts @@ -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; +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; diff --git a/packages/react-native-uniffi-russh/src/generated/foobar.ts b/packages/react-native-uniffi-russh/src/generated/foobar.ts new file mode 100644 index 0000000..cce9158 --- /dev/null +++ b/packages/react-native-uniffi-russh/src/generated/foobar.ts @@ -0,0 +1,1271 @@ +// 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 nativeModule, { + type UniffiRustFutureContinuationCallback, + type UniffiForeignFuture, + type UniffiForeignFutureStructU8, + type UniffiForeignFutureCompleteU8, + type UniffiForeignFutureStructI8, + type UniffiForeignFutureCompleteI8, + type UniffiForeignFutureStructU16, + type UniffiForeignFutureCompleteU16, + type UniffiForeignFutureStructI16, + type UniffiForeignFutureCompleteI16, + type UniffiForeignFutureStructU32, + type UniffiForeignFutureCompleteU32, + type UniffiForeignFutureStructI32, + type UniffiForeignFutureCompleteI32, + type UniffiForeignFutureStructU64, + type UniffiForeignFutureCompleteU64, + type UniffiForeignFutureStructI64, + type UniffiForeignFutureCompleteI64, + type UniffiForeignFutureStructF32, + type UniffiForeignFutureCompleteF32, + type UniffiForeignFutureStructF64, + type UniffiForeignFutureCompleteF64, + type UniffiForeignFutureStructPointer, + type UniffiForeignFutureCompletePointer, + type UniffiForeignFutureStructRustBuffer, + type UniffiForeignFutureCompleteRustBuffer, + type UniffiForeignFutureStructVoid, + type UniffiForeignFutureCompleteVoid, + type UniffiVTableCallbackInterfaceBinaryOperator, +} from './foobar-ffi'; +import { + type FfiConverter, + type UniffiByteArray, + type UniffiHandle, + type UniffiObjectFactory, + type UniffiReferenceHolder, + type UniffiRustArcPtr, + type UniffiRustCallStatus, + type UnsafeMutableRawPointer, + AbstractFfiConverterByteArray, + FfiConverterBool, + FfiConverterInt32, + FfiConverterInt64, + FfiConverterObject, + FfiConverterObjectWithCallbacks, + FfiConverterOptional, + FfiConverterUInt64, + RustBuffer, + UniffiAbstractObject, + UniffiEnum, + UniffiError, + UniffiInternalError, + UniffiResult, + UniffiRustCaller, + destructorGuardSymbol, + pointerLiteralSymbol, + uniffiCreateFfiConverterString, + uniffiCreateRecord, + uniffiTraitInterfaceCallWithError, + uniffiTypeNameSymbol, + variantOrdinalSymbol, +} from 'uniffi-bindgen-react-native'; + +// Get converters from the other files, if any. +const uniffiCaller = new UniffiRustCaller(() => ({ code: 0 })); + +const uniffiIsDebug = + // @ts-ignore -- The process global might not be defined + typeof process !== 'object' || + // @ts-ignore -- The process global might not be defined + process?.env?.NODE_ENV !== 'production' || + false; +// Public interface members begin here. + +export function safeAdditionOperator(): BinaryOperator { + return FfiConverterTypeBinaryOperator.lift( + uniffiCaller.rustCall( + /*caller:*/ (callStatus) => { + return nativeModule().ubrn_uniffi_foobar_fn_func_safe_addition_operator( + callStatus + ); + }, + /*liftString:*/ FfiConverterString.lift + ) + ); +} +export function safeDivisionOperator(): BinaryOperator { + return FfiConverterTypeBinaryOperator.lift( + uniffiCaller.rustCall( + /*caller:*/ (callStatus) => { + return nativeModule().ubrn_uniffi_foobar_fn_func_safe_division_operator( + callStatus + ); + }, + /*liftString:*/ FfiConverterString.lift + ) + ); +} + +export type ComputationResult = { + value: /*i64*/ bigint; +}; + +/** + * Generated factory for {@link ComputationResult} record objects. + */ +export const ComputationResult = (() => { + const defaults = () => ({}); + const create = (() => { + return uniffiCreateRecord>( + defaults + ); + })(); + return Object.freeze({ + /** + * Create a frozen instance of {@link ComputationResult}, with defaults specified + * in Rust, in the {@link foobar} crate. + */ + create, + + /** + * Create a frozen instance of {@link ComputationResult}, with defaults specified + * in Rust, in the {@link foobar} crate. + */ + new: create, + + /** + * Defaults specified in the {@link foobar} crate. + */ + defaults: () => Object.freeze(defaults()) as Partial, + }); +})(); + +const FfiConverterTypeComputationResult = (() => { + type TypeName = ComputationResult; + class FFIConverter extends AbstractFfiConverterByteArray { + read(from: RustBuffer): TypeName { + return { + value: FfiConverterInt64.read(from), + }; + } + write(value: TypeName, into: RustBuffer): void { + FfiConverterInt64.write(value.value, into); + } + allocationSize(value: TypeName): number { + return FfiConverterInt64.allocationSize(value.value); + } + } + return new FFIConverter(); +})(); + +const stringConverter = { + stringToBytes: (s: string) => + uniffiCaller.rustCall((status) => + nativeModule().ubrn_uniffi_internal_fn_func_ffi__string_to_arraybuffer( + s, + status + ) + ), + bytesToString: (ab: UniffiByteArray) => + uniffiCaller.rustCall((status) => + nativeModule().ubrn_uniffi_internal_fn_func_ffi__arraybuffer_to_string( + ab, + status + ) + ), + stringByteLength: (s: string) => + uniffiCaller.rustCall((status) => + nativeModule().ubrn_uniffi_internal_fn_func_ffi__string_to_byte_length( + s, + status + ) + ), +}; +const FfiConverterString = uniffiCreateFfiConverterString(stringConverter); + +// Error type: ComputationError + +// Enum: ComputationError +export enum ComputationError_Tags { + DivisionByZero = 'DivisionByZero', + Overflow = 'Overflow', + IllegalComputationWithInitState = 'IllegalComputationWithInitState', +} +export const ComputationError = (() => { + type DivisionByZero__interface = { + tag: ComputationError_Tags.DivisionByZero; + }; + + class DivisionByZero_ + extends UniffiError + implements DivisionByZero__interface + { + /** + * @private + * This field is private and should not be used, use `tag` instead. + */ + readonly [uniffiTypeNameSymbol] = 'ComputationError'; + readonly tag = ComputationError_Tags.DivisionByZero; + constructor() { + super('ComputationError', 'DivisionByZero'); + } + + static new(): DivisionByZero_ { + return new DivisionByZero_(); + } + + static instanceOf(obj: any): obj is DivisionByZero_ { + return obj.tag === ComputationError_Tags.DivisionByZero; + } + + static hasInner(obj: any): obj is DivisionByZero_ { + return false; + } + } + + type Overflow__interface = { + tag: ComputationError_Tags.Overflow; + }; + + class Overflow_ extends UniffiError implements Overflow__interface { + /** + * @private + * This field is private and should not be used, use `tag` instead. + */ + readonly [uniffiTypeNameSymbol] = 'ComputationError'; + readonly tag = ComputationError_Tags.Overflow; + constructor() { + super('ComputationError', 'Overflow'); + } + + static new(): Overflow_ { + return new Overflow_(); + } + + static instanceOf(obj: any): obj is Overflow_ { + return obj.tag === ComputationError_Tags.Overflow; + } + + static hasInner(obj: any): obj is Overflow_ { + return false; + } + } + + type IllegalComputationWithInitState__interface = { + tag: ComputationError_Tags.IllegalComputationWithInitState; + }; + + class IllegalComputationWithInitState_ + extends UniffiError + implements IllegalComputationWithInitState__interface + { + /** + * @private + * This field is private and should not be used, use `tag` instead. + */ + readonly [uniffiTypeNameSymbol] = 'ComputationError'; + readonly tag = ComputationError_Tags.IllegalComputationWithInitState; + constructor() { + super('ComputationError', 'IllegalComputationWithInitState'); + } + + static new(): IllegalComputationWithInitState_ { + return new IllegalComputationWithInitState_(); + } + + static instanceOf(obj: any): obj is IllegalComputationWithInitState_ { + return obj.tag === ComputationError_Tags.IllegalComputationWithInitState; + } + + static hasInner(obj: any): obj is IllegalComputationWithInitState_ { + return false; + } + } + + function instanceOf(obj: any): obj is ComputationError { + return obj[uniffiTypeNameSymbol] === 'ComputationError'; + } + + return Object.freeze({ + instanceOf, + DivisionByZero: DivisionByZero_, + Overflow: Overflow_, + IllegalComputationWithInitState: IllegalComputationWithInitState_, + }); +})(); + +export type ComputationError = InstanceType< + (typeof ComputationError)[keyof Omit] +>; + +// FfiConverter for enum ComputationError +const FfiConverterTypeComputationError = (() => { + const ordinalConverter = FfiConverterInt32; + type TypeName = ComputationError; + class FFIConverter extends AbstractFfiConverterByteArray { + read(from: RustBuffer): TypeName { + switch (ordinalConverter.read(from)) { + case 1: + return new ComputationError.DivisionByZero(); + case 2: + return new ComputationError.Overflow(); + case 3: + return new ComputationError.IllegalComputationWithInitState(); + default: + throw new UniffiInternalError.UnexpectedEnumCase(); + } + } + write(value: TypeName, into: RustBuffer): void { + switch (value.tag) { + case ComputationError_Tags.DivisionByZero: { + ordinalConverter.write(1, into); + return; + } + case ComputationError_Tags.Overflow: { + ordinalConverter.write(2, into); + return; + } + case ComputationError_Tags.IllegalComputationWithInitState: { + ordinalConverter.write(3, into); + return; + } + default: + // Throwing from here means that ComputationError_Tags hasn't matched an ordinal. + throw new UniffiInternalError.UnexpectedEnumCase(); + } + } + allocationSize(value: TypeName): number { + switch (value.tag) { + case ComputationError_Tags.DivisionByZero: { + return ordinalConverter.allocationSize(1); + } + case ComputationError_Tags.Overflow: { + return ordinalConverter.allocationSize(2); + } + case ComputationError_Tags.IllegalComputationWithInitState: { + return ordinalConverter.allocationSize(3); + } + default: + throw new UniffiInternalError.UnexpectedEnumCase(); + } + } + } + return new FFIConverter(); +})(); + +// Enum: ComputationState +export enum ComputationState_Tags { + Init = 'Init', + Computed = 'Computed', +} +export const ComputationState = (() => { + type Init__interface = { + tag: ComputationState_Tags.Init; + }; + + /** + * Initial state with no value computed + */ + class Init_ extends UniffiEnum implements Init__interface { + /** + * @private + * This field is private and should not be used, use `tag` instead. + */ + readonly [uniffiTypeNameSymbol] = 'ComputationState'; + readonly tag = ComputationState_Tags.Init; + constructor() { + super('ComputationState', 'Init'); + } + + static new(): Init_ { + return new Init_(); + } + + static instanceOf(obj: any): obj is Init_ { + return obj.tag === ComputationState_Tags.Init; + } + } + + type Computed__interface = { + tag: ComputationState_Tags.Computed; + inner: Readonly<{ result: ComputationResult }>; + }; + + class Computed_ extends UniffiEnum implements Computed__interface { + /** + * @private + * This field is private and should not be used, use `tag` instead. + */ + readonly [uniffiTypeNameSymbol] = 'ComputationState'; + readonly tag = ComputationState_Tags.Computed; + readonly inner: Readonly<{ result: ComputationResult }>; + constructor(inner: { result: ComputationResult }) { + super('ComputationState', 'Computed'); + this.inner = Object.freeze(inner); + } + + static new(inner: { result: ComputationResult }): Computed_ { + return new Computed_(inner); + } + + static instanceOf(obj: any): obj is Computed_ { + return obj.tag === ComputationState_Tags.Computed; + } + } + + function instanceOf(obj: any): obj is ComputationState { + return obj[uniffiTypeNameSymbol] === 'ComputationState'; + } + + return Object.freeze({ + instanceOf, + Init: Init_, + Computed: Computed_, + }); +})(); + +export type ComputationState = InstanceType< + (typeof ComputationState)[keyof Omit] +>; + +// FfiConverter for enum ComputationState +const FfiConverterTypeComputationState = (() => { + const ordinalConverter = FfiConverterInt32; + type TypeName = ComputationState; + class FFIConverter extends AbstractFfiConverterByteArray { + read(from: RustBuffer): TypeName { + switch (ordinalConverter.read(from)) { + case 1: + return new ComputationState.Init(); + case 2: + return new ComputationState.Computed({ + result: FfiConverterTypeComputationResult.read(from), + }); + default: + throw new UniffiInternalError.UnexpectedEnumCase(); + } + } + write(value: TypeName, into: RustBuffer): void { + switch (value.tag) { + case ComputationState_Tags.Init: { + ordinalConverter.write(1, into); + return; + } + case ComputationState_Tags.Computed: { + ordinalConverter.write(2, into); + const inner = value.inner; + FfiConverterTypeComputationResult.write(inner.result, into); + return; + } + default: + // Throwing from here means that ComputationState_Tags hasn't matched an ordinal. + throw new UniffiInternalError.UnexpectedEnumCase(); + } + } + allocationSize(value: TypeName): number { + switch (value.tag) { + case ComputationState_Tags.Init: { + return ordinalConverter.allocationSize(1); + } + case ComputationState_Tags.Computed: { + const inner = value.inner; + let size = ordinalConverter.allocationSize(2); + size += FfiConverterTypeComputationResult.allocationSize( + inner.result + ); + return size; + } + default: + throw new UniffiInternalError.UnexpectedEnumCase(); + } + } + } + return new FFIConverter(); +})(); + +/** + * A binary operator that performs some mathematical operation with two numbers. + */ +export interface BinaryOperator { + perform(lhs: /*i64*/ bigint, rhs: /*i64*/ bigint) /*throws*/ : /*i64*/ bigint; +} + +/** + * A binary operator that performs some mathematical operation with two numbers. + */ +export class BinaryOperatorImpl + extends UniffiAbstractObject + implements BinaryOperator +{ + readonly [uniffiTypeNameSymbol] = 'BinaryOperatorImpl'; + readonly [destructorGuardSymbol]: UniffiRustArcPtr; + readonly [pointerLiteralSymbol]: UnsafeMutableRawPointer; + // No primary constructor declared for this class. + private constructor(pointer: UnsafeMutableRawPointer) { + super(); + this[pointerLiteralSymbol] = pointer; + this[destructorGuardSymbol] = + uniffiTypeBinaryOperatorImplObjectFactory.bless(pointer); + } + + public perform( + lhs: /*i64*/ bigint, + rhs: /*i64*/ bigint + ): /*i64*/ bigint /*throws*/ { + return FfiConverterInt64.lift( + uniffiCaller.rustCallWithError( + /*liftError:*/ FfiConverterTypeComputationError.lift.bind( + FfiConverterTypeComputationError + ), + /*caller:*/ (callStatus) => { + return nativeModule().ubrn_uniffi_foobar_fn_method_binaryoperator_perform( + uniffiTypeBinaryOperatorImplObjectFactory.clonePointer(this), + FfiConverterInt64.lower(lhs), + FfiConverterInt64.lower(rhs), + callStatus + ); + }, + /*liftString:*/ FfiConverterString.lift + ) + ); + } + + /** + * {@inheritDoc uniffi-bindgen-react-native#UniffiAbstractObject.uniffiDestroy} + */ + uniffiDestroy(): void { + const ptr = (this as any)[destructorGuardSymbol]; + if (ptr !== undefined) { + const pointer = uniffiTypeBinaryOperatorImplObjectFactory.pointer(this); + uniffiTypeBinaryOperatorImplObjectFactory.freePointer(pointer); + uniffiTypeBinaryOperatorImplObjectFactory.unbless(ptr); + delete (this as any)[destructorGuardSymbol]; + } + } + + static instanceOf(obj: any): obj is BinaryOperatorImpl { + return uniffiTypeBinaryOperatorImplObjectFactory.isConcreteType(obj); + } +} + +const uniffiTypeBinaryOperatorImplObjectFactory: UniffiObjectFactory = + (() => { + return { + create(pointer: UnsafeMutableRawPointer): BinaryOperator { + const instance = Object.create(BinaryOperatorImpl.prototype); + instance[pointerLiteralSymbol] = pointer; + instance[destructorGuardSymbol] = this.bless(pointer); + instance[uniffiTypeNameSymbol] = 'BinaryOperatorImpl'; + return instance; + }, + + bless(p: UnsafeMutableRawPointer): UniffiRustArcPtr { + return uniffiCaller.rustCall( + /*caller:*/ (status) => + nativeModule().ubrn_uniffi_internal_fn_method_binaryoperator_ffi__bless_pointer( + p, + status + ), + /*liftString:*/ FfiConverterString.lift + ); + }, + + unbless(ptr: UniffiRustArcPtr) { + ptr.markDestroyed(); + }, + + pointer(obj: BinaryOperator): UnsafeMutableRawPointer { + if ((obj as any)[destructorGuardSymbol] === undefined) { + throw new UniffiInternalError.UnexpectedNullPointer(); + } + return (obj as any)[pointerLiteralSymbol]; + }, + + clonePointer(obj: BinaryOperator): UnsafeMutableRawPointer { + const pointer = this.pointer(obj); + return uniffiCaller.rustCall( + /*caller:*/ (callStatus) => + nativeModule().ubrn_uniffi_foobar_fn_clone_binaryoperator( + pointer, + callStatus + ), + /*liftString:*/ FfiConverterString.lift + ); + }, + + freePointer(pointer: UnsafeMutableRawPointer): void { + uniffiCaller.rustCall( + /*caller:*/ (callStatus) => + nativeModule().ubrn_uniffi_foobar_fn_free_binaryoperator( + pointer, + callStatus + ), + /*liftString:*/ FfiConverterString.lift + ); + }, + + isConcreteType(obj: any): obj is BinaryOperator { + return ( + obj[destructorGuardSymbol] && + obj[uniffiTypeNameSymbol] === 'BinaryOperatorImpl' + ); + }, + }; + })(); +// FfiConverter for BinaryOperator +const FfiConverterTypeBinaryOperator = new FfiConverterObjectWithCallbacks( + uniffiTypeBinaryOperatorImplObjectFactory +); + +// Add a vtavble for the callbacks that go in BinaryOperator. + +// Put the implementation in a struct so we don't pollute the top-level namespace +const uniffiCallbackInterfaceBinaryOperator: { + vtable: UniffiVTableCallbackInterfaceBinaryOperator; + register: () => void; +} = { + // Create the VTable using a series of closures. + // ts automatically converts these into C callback functions. + vtable: { + perform: (uniffiHandle: bigint, lhs: bigint, rhs: bigint) => { + const uniffiMakeCall = (): /*i64*/ bigint => { + const jsCallback = FfiConverterTypeBinaryOperator.lift(uniffiHandle); + return jsCallback.perform( + FfiConverterInt64.lift(lhs), + FfiConverterInt64.lift(rhs) + ); + }; + const uniffiResult = UniffiResult.ready(); + const uniffiHandleSuccess = (obj: any) => { + UniffiResult.writeSuccess(uniffiResult, FfiConverterInt64.lower(obj)); + }; + const uniffiHandleError = (code: number, errBuf: UniffiByteArray) => { + UniffiResult.writeError(uniffiResult, code, errBuf); + }; + uniffiTraitInterfaceCallWithError( + /*makeCall:*/ uniffiMakeCall, + /*handleSuccess:*/ uniffiHandleSuccess, + /*handleError:*/ uniffiHandleError, + /*isErrorType:*/ ComputationError.instanceOf, + /*lowerError:*/ FfiConverterTypeComputationError.lower.bind( + FfiConverterTypeComputationError + ), + /*lowerString:*/ FfiConverterString.lower + ); + return uniffiResult; + }, + uniffiFree: (uniffiHandle: UniffiHandle): void => { + // BinaryOperator: this will throw a stale handle error if the handle isn't found. + FfiConverterTypeBinaryOperator.drop(uniffiHandle); + }, + }, + register: () => { + nativeModule().ubrn_uniffi_foobar_fn_init_callback_vtable_binaryoperator( + uniffiCallbackInterfaceBinaryOperator.vtable + ); + }, +}; + +/** + * A somewhat silly demonstration of functional core/imperative shell in the form of a calculator with arbitrary operators. + * + * Operations return a new calculator with updated internal state reflecting the computation. + */ +export interface CalculatorInterface { + /** + * Performs a calculation using the supplied binary operator and operands. + */ + calculate( + op: BinaryOperator, + lhs: /*i64*/ bigint, + rhs: /*i64*/ bigint + ) /*throws*/ : CalculatorInterface; + /** + * Performs a calculation using the supplied binary operator, the last computation result, and the supplied operand. + * + * The supplied operand will be the right-hand side in the mathematical operation. + */ + calculateMore( + op: BinaryOperator, + rhs: /*i64*/ bigint + ) /*throws*/ : CalculatorInterface; + lastResult(): ComputationResult | undefined; +} + +/** + * A somewhat silly demonstration of functional core/imperative shell in the form of a calculator with arbitrary operators. + * + * Operations return a new calculator with updated internal state reflecting the computation. + */ +export class Calculator + extends UniffiAbstractObject + implements CalculatorInterface +{ + readonly [uniffiTypeNameSymbol] = 'Calculator'; + readonly [destructorGuardSymbol]: UniffiRustArcPtr; + readonly [pointerLiteralSymbol]: UnsafeMutableRawPointer; + constructor() { + super(); + const pointer = uniffiCaller.rustCall( + /*caller:*/ (callStatus) => { + return nativeModule().ubrn_uniffi_foobar_fn_constructor_calculator_new( + callStatus + ); + }, + /*liftString:*/ FfiConverterString.lift + ); + this[pointerLiteralSymbol] = pointer; + this[destructorGuardSymbol] = + uniffiTypeCalculatorObjectFactory.bless(pointer); + } + + /** + * Performs a calculation using the supplied binary operator and operands. + */ + public calculate( + op: BinaryOperator, + lhs: /*i64*/ bigint, + rhs: /*i64*/ bigint + ): CalculatorInterface /*throws*/ { + return FfiConverterTypeCalculator.lift( + uniffiCaller.rustCallWithError( + /*liftError:*/ FfiConverterTypeComputationError.lift.bind( + FfiConverterTypeComputationError + ), + /*caller:*/ (callStatus) => { + return nativeModule().ubrn_uniffi_foobar_fn_method_calculator_calculate( + uniffiTypeCalculatorObjectFactory.clonePointer(this), + FfiConverterTypeBinaryOperator.lower(op), + FfiConverterInt64.lower(lhs), + FfiConverterInt64.lower(rhs), + callStatus + ); + }, + /*liftString:*/ FfiConverterString.lift + ) + ); + } + + /** + * Performs a calculation using the supplied binary operator, the last computation result, and the supplied operand. + * + * The supplied operand will be the right-hand side in the mathematical operation. + */ + public calculateMore( + op: BinaryOperator, + rhs: /*i64*/ bigint + ): CalculatorInterface /*throws*/ { + return FfiConverterTypeCalculator.lift( + uniffiCaller.rustCallWithError( + /*liftError:*/ FfiConverterTypeComputationError.lift.bind( + FfiConverterTypeComputationError + ), + /*caller:*/ (callStatus) => { + return nativeModule().ubrn_uniffi_foobar_fn_method_calculator_calculate_more( + uniffiTypeCalculatorObjectFactory.clonePointer(this), + FfiConverterTypeBinaryOperator.lower(op), + FfiConverterInt64.lower(rhs), + callStatus + ); + }, + /*liftString:*/ FfiConverterString.lift + ) + ); + } + + public lastResult(): ComputationResult | undefined { + return FfiConverterOptionalTypeComputationResult.lift( + uniffiCaller.rustCall( + /*caller:*/ (callStatus) => { + return nativeModule().ubrn_uniffi_foobar_fn_method_calculator_last_result( + uniffiTypeCalculatorObjectFactory.clonePointer(this), + callStatus + ); + }, + /*liftString:*/ FfiConverterString.lift + ) + ); + } + + /** + * {@inheritDoc uniffi-bindgen-react-native#UniffiAbstractObject.uniffiDestroy} + */ + uniffiDestroy(): void { + const ptr = (this as any)[destructorGuardSymbol]; + if (ptr !== undefined) { + const pointer = uniffiTypeCalculatorObjectFactory.pointer(this); + uniffiTypeCalculatorObjectFactory.freePointer(pointer); + uniffiTypeCalculatorObjectFactory.unbless(ptr); + delete (this as any)[destructorGuardSymbol]; + } + } + + static instanceOf(obj: any): obj is Calculator { + return uniffiTypeCalculatorObjectFactory.isConcreteType(obj); + } +} + +const uniffiTypeCalculatorObjectFactory: UniffiObjectFactory = + (() => { + return { + create(pointer: UnsafeMutableRawPointer): CalculatorInterface { + const instance = Object.create(Calculator.prototype); + instance[pointerLiteralSymbol] = pointer; + instance[destructorGuardSymbol] = this.bless(pointer); + instance[uniffiTypeNameSymbol] = 'Calculator'; + return instance; + }, + + bless(p: UnsafeMutableRawPointer): UniffiRustArcPtr { + return uniffiCaller.rustCall( + /*caller:*/ (status) => + nativeModule().ubrn_uniffi_internal_fn_method_calculator_ffi__bless_pointer( + p, + status + ), + /*liftString:*/ FfiConverterString.lift + ); + }, + + unbless(ptr: UniffiRustArcPtr) { + ptr.markDestroyed(); + }, + + pointer(obj: CalculatorInterface): UnsafeMutableRawPointer { + if ((obj as any)[destructorGuardSymbol] === undefined) { + throw new UniffiInternalError.UnexpectedNullPointer(); + } + return (obj as any)[pointerLiteralSymbol]; + }, + + clonePointer(obj: CalculatorInterface): UnsafeMutableRawPointer { + const pointer = this.pointer(obj); + return uniffiCaller.rustCall( + /*caller:*/ (callStatus) => + nativeModule().ubrn_uniffi_foobar_fn_clone_calculator( + pointer, + callStatus + ), + /*liftString:*/ FfiConverterString.lift + ); + }, + + freePointer(pointer: UnsafeMutableRawPointer): void { + uniffiCaller.rustCall( + /*caller:*/ (callStatus) => + nativeModule().ubrn_uniffi_foobar_fn_free_calculator( + pointer, + callStatus + ), + /*liftString:*/ FfiConverterString.lift + ); + }, + + isConcreteType(obj: any): obj is CalculatorInterface { + return ( + obj[destructorGuardSymbol] && + obj[uniffiTypeNameSymbol] === 'Calculator' + ); + }, + }; + })(); +// FfiConverter for CalculatorInterface +const FfiConverterTypeCalculator = new FfiConverterObject( + uniffiTypeCalculatorObjectFactory +); + +export interface SafeAdditionInterface { + perform(lhs: /*i64*/ bigint, rhs: /*i64*/ bigint) /*throws*/ : /*i64*/ bigint; +} + +export class SafeAddition + extends UniffiAbstractObject + implements SafeAdditionInterface +{ + readonly [uniffiTypeNameSymbol] = 'SafeAddition'; + readonly [destructorGuardSymbol]: UniffiRustArcPtr; + readonly [pointerLiteralSymbol]: UnsafeMutableRawPointer; + constructor() { + super(); + const pointer = uniffiCaller.rustCall( + /*caller:*/ (callStatus) => { + return nativeModule().ubrn_uniffi_foobar_fn_constructor_safeaddition_new( + callStatus + ); + }, + /*liftString:*/ FfiConverterString.lift + ); + this[pointerLiteralSymbol] = pointer; + this[destructorGuardSymbol] = + uniffiTypeSafeAdditionObjectFactory.bless(pointer); + } + + public perform( + lhs: /*i64*/ bigint, + rhs: /*i64*/ bigint + ): /*i64*/ bigint /*throws*/ { + return FfiConverterInt64.lift( + uniffiCaller.rustCallWithError( + /*liftError:*/ FfiConverterTypeComputationError.lift.bind( + FfiConverterTypeComputationError + ), + /*caller:*/ (callStatus) => { + return nativeModule().ubrn_uniffi_foobar_fn_method_safeaddition_perform( + uniffiTypeSafeAdditionObjectFactory.clonePointer(this), + FfiConverterInt64.lower(lhs), + FfiConverterInt64.lower(rhs), + callStatus + ); + }, + /*liftString:*/ FfiConverterString.lift + ) + ); + } + + /** + * {@inheritDoc uniffi-bindgen-react-native#UniffiAbstractObject.uniffiDestroy} + */ + uniffiDestroy(): void { + const ptr = (this as any)[destructorGuardSymbol]; + if (ptr !== undefined) { + const pointer = uniffiTypeSafeAdditionObjectFactory.pointer(this); + uniffiTypeSafeAdditionObjectFactory.freePointer(pointer); + uniffiTypeSafeAdditionObjectFactory.unbless(ptr); + delete (this as any)[destructorGuardSymbol]; + } + } + + static instanceOf(obj: any): obj is SafeAddition { + return uniffiTypeSafeAdditionObjectFactory.isConcreteType(obj); + } +} + +const uniffiTypeSafeAdditionObjectFactory: UniffiObjectFactory = + (() => { + return { + create(pointer: UnsafeMutableRawPointer): SafeAdditionInterface { + const instance = Object.create(SafeAddition.prototype); + instance[pointerLiteralSymbol] = pointer; + instance[destructorGuardSymbol] = this.bless(pointer); + instance[uniffiTypeNameSymbol] = 'SafeAddition'; + return instance; + }, + + bless(p: UnsafeMutableRawPointer): UniffiRustArcPtr { + return uniffiCaller.rustCall( + /*caller:*/ (status) => + nativeModule().ubrn_uniffi_internal_fn_method_safeaddition_ffi__bless_pointer( + p, + status + ), + /*liftString:*/ FfiConverterString.lift + ); + }, + + unbless(ptr: UniffiRustArcPtr) { + ptr.markDestroyed(); + }, + + pointer(obj: SafeAdditionInterface): UnsafeMutableRawPointer { + if ((obj as any)[destructorGuardSymbol] === undefined) { + throw new UniffiInternalError.UnexpectedNullPointer(); + } + return (obj as any)[pointerLiteralSymbol]; + }, + + clonePointer(obj: SafeAdditionInterface): UnsafeMutableRawPointer { + const pointer = this.pointer(obj); + return uniffiCaller.rustCall( + /*caller:*/ (callStatus) => + nativeModule().ubrn_uniffi_foobar_fn_clone_safeaddition( + pointer, + callStatus + ), + /*liftString:*/ FfiConverterString.lift + ); + }, + + freePointer(pointer: UnsafeMutableRawPointer): void { + uniffiCaller.rustCall( + /*caller:*/ (callStatus) => + nativeModule().ubrn_uniffi_foobar_fn_free_safeaddition( + pointer, + callStatus + ), + /*liftString:*/ FfiConverterString.lift + ); + }, + + isConcreteType(obj: any): obj is SafeAdditionInterface { + return ( + obj[destructorGuardSymbol] && + obj[uniffiTypeNameSymbol] === 'SafeAddition' + ); + }, + }; + })(); +// FfiConverter for SafeAdditionInterface +const FfiConverterTypeSafeAddition = new FfiConverterObject( + uniffiTypeSafeAdditionObjectFactory +); + +export interface SafeDivisionInterface { + perform(lhs: /*i64*/ bigint, rhs: /*i64*/ bigint) /*throws*/ : /*i64*/ bigint; +} + +export class SafeDivision + extends UniffiAbstractObject + implements SafeDivisionInterface +{ + readonly [uniffiTypeNameSymbol] = 'SafeDivision'; + readonly [destructorGuardSymbol]: UniffiRustArcPtr; + readonly [pointerLiteralSymbol]: UnsafeMutableRawPointer; + constructor() { + super(); + const pointer = uniffiCaller.rustCall( + /*caller:*/ (callStatus) => { + return nativeModule().ubrn_uniffi_foobar_fn_constructor_safedivision_new( + callStatus + ); + }, + /*liftString:*/ FfiConverterString.lift + ); + this[pointerLiteralSymbol] = pointer; + this[destructorGuardSymbol] = + uniffiTypeSafeDivisionObjectFactory.bless(pointer); + } + + public perform( + lhs: /*i64*/ bigint, + rhs: /*i64*/ bigint + ): /*i64*/ bigint /*throws*/ { + return FfiConverterInt64.lift( + uniffiCaller.rustCallWithError( + /*liftError:*/ FfiConverterTypeComputationError.lift.bind( + FfiConverterTypeComputationError + ), + /*caller:*/ (callStatus) => { + return nativeModule().ubrn_uniffi_foobar_fn_method_safedivision_perform( + uniffiTypeSafeDivisionObjectFactory.clonePointer(this), + FfiConverterInt64.lower(lhs), + FfiConverterInt64.lower(rhs), + callStatus + ); + }, + /*liftString:*/ FfiConverterString.lift + ) + ); + } + + /** + * {@inheritDoc uniffi-bindgen-react-native#UniffiAbstractObject.uniffiDestroy} + */ + uniffiDestroy(): void { + const ptr = (this as any)[destructorGuardSymbol]; + if (ptr !== undefined) { + const pointer = uniffiTypeSafeDivisionObjectFactory.pointer(this); + uniffiTypeSafeDivisionObjectFactory.freePointer(pointer); + uniffiTypeSafeDivisionObjectFactory.unbless(ptr); + delete (this as any)[destructorGuardSymbol]; + } + } + + static instanceOf(obj: any): obj is SafeDivision { + return uniffiTypeSafeDivisionObjectFactory.isConcreteType(obj); + } +} + +const uniffiTypeSafeDivisionObjectFactory: UniffiObjectFactory = + (() => { + return { + create(pointer: UnsafeMutableRawPointer): SafeDivisionInterface { + const instance = Object.create(SafeDivision.prototype); + instance[pointerLiteralSymbol] = pointer; + instance[destructorGuardSymbol] = this.bless(pointer); + instance[uniffiTypeNameSymbol] = 'SafeDivision'; + return instance; + }, + + bless(p: UnsafeMutableRawPointer): UniffiRustArcPtr { + return uniffiCaller.rustCall( + /*caller:*/ (status) => + nativeModule().ubrn_uniffi_internal_fn_method_safedivision_ffi__bless_pointer( + p, + status + ), + /*liftString:*/ FfiConverterString.lift + ); + }, + + unbless(ptr: UniffiRustArcPtr) { + ptr.markDestroyed(); + }, + + pointer(obj: SafeDivisionInterface): UnsafeMutableRawPointer { + if ((obj as any)[destructorGuardSymbol] === undefined) { + throw new UniffiInternalError.UnexpectedNullPointer(); + } + return (obj as any)[pointerLiteralSymbol]; + }, + + clonePointer(obj: SafeDivisionInterface): UnsafeMutableRawPointer { + const pointer = this.pointer(obj); + return uniffiCaller.rustCall( + /*caller:*/ (callStatus) => + nativeModule().ubrn_uniffi_foobar_fn_clone_safedivision( + pointer, + callStatus + ), + /*liftString:*/ FfiConverterString.lift + ); + }, + + freePointer(pointer: UnsafeMutableRawPointer): void { + uniffiCaller.rustCall( + /*caller:*/ (callStatus) => + nativeModule().ubrn_uniffi_foobar_fn_free_safedivision( + pointer, + callStatus + ), + /*liftString:*/ FfiConverterString.lift + ); + }, + + isConcreteType(obj: any): obj is SafeDivisionInterface { + return ( + obj[destructorGuardSymbol] && + obj[uniffiTypeNameSymbol] === 'SafeDivision' + ); + }, + }; + })(); +// FfiConverter for SafeDivisionInterface +const FfiConverterTypeSafeDivision = new FfiConverterObject( + uniffiTypeSafeDivisionObjectFactory +); + +// FfiConverter for ComputationResult | undefined +const FfiConverterOptionalTypeComputationResult = new FfiConverterOptional( + FfiConverterTypeComputationResult +); + +/** + * This should be called before anything else. + * + * It is likely that this is being done for you by the library's `index.ts`. + * + * It checks versions of uniffi between when the Rust scaffolding was generated + * and when the bindings were generated. + * + * It also initializes the machinery to enable Rust to talk back to Javascript. + */ +function uniffiEnsureInitialized() { + // Get the bindings contract version from our ComponentInterface + const bindingsContractVersion = 29; + // Get the scaffolding contract version by calling the into the dylib + const scaffoldingContractVersion = + nativeModule().ubrn_ffi_foobar_uniffi_contract_version(); + if (bindingsContractVersion !== scaffoldingContractVersion) { + throw new UniffiInternalError.ContractVersionMismatch( + scaffoldingContractVersion, + bindingsContractVersion + ); + } + if ( + nativeModule().ubrn_uniffi_foobar_checksum_func_safe_addition_operator() !== + 2550 + ) { + throw new UniffiInternalError.ApiChecksumMismatch( + 'uniffi_foobar_checksum_func_safe_addition_operator' + ); + } + if ( + nativeModule().ubrn_uniffi_foobar_checksum_func_safe_division_operator() !== + 26772 + ) { + throw new UniffiInternalError.ApiChecksumMismatch( + 'uniffi_foobar_checksum_func_safe_division_operator' + ); + } + if ( + nativeModule().ubrn_uniffi_foobar_checksum_method_binaryoperator_perform() !== + 14159 + ) { + throw new UniffiInternalError.ApiChecksumMismatch( + 'uniffi_foobar_checksum_method_binaryoperator_perform' + ); + } + if ( + nativeModule().ubrn_uniffi_foobar_checksum_method_calculator_calculate() !== + 63226 + ) { + throw new UniffiInternalError.ApiChecksumMismatch( + 'uniffi_foobar_checksum_method_calculator_calculate' + ); + } + if ( + nativeModule().ubrn_uniffi_foobar_checksum_method_calculator_calculate_more() !== + 55050 + ) { + throw new UniffiInternalError.ApiChecksumMismatch( + 'uniffi_foobar_checksum_method_calculator_calculate_more' + ); + } + if ( + nativeModule().ubrn_uniffi_foobar_checksum_method_calculator_last_result() !== + 48598 + ) { + throw new UniffiInternalError.ApiChecksumMismatch( + 'uniffi_foobar_checksum_method_calculator_last_result' + ); + } + if ( + nativeModule().ubrn_uniffi_foobar_checksum_method_safeaddition_perform() !== + 41639 + ) { + throw new UniffiInternalError.ApiChecksumMismatch( + 'uniffi_foobar_checksum_method_safeaddition_perform' + ); + } + if ( + nativeModule().ubrn_uniffi_foobar_checksum_method_safedivision_perform() !== + 11259 + ) { + throw new UniffiInternalError.ApiChecksumMismatch( + 'uniffi_foobar_checksum_method_safedivision_perform' + ); + } + if ( + nativeModule().ubrn_uniffi_foobar_checksum_constructor_calculator_new() !== + 50473 + ) { + throw new UniffiInternalError.ApiChecksumMismatch( + 'uniffi_foobar_checksum_constructor_calculator_new' + ); + } + if ( + nativeModule().ubrn_uniffi_foobar_checksum_constructor_safeaddition_new() !== + 7323 + ) { + throw new UniffiInternalError.ApiChecksumMismatch( + 'uniffi_foobar_checksum_constructor_safeaddition_new' + ); + } + if ( + nativeModule().ubrn_uniffi_foobar_checksum_constructor_safedivision_new() !== + 18654 + ) { + throw new UniffiInternalError.ApiChecksumMismatch( + 'uniffi_foobar_checksum_constructor_safedivision_new' + ); + } + + uniffiCallbackInterfaceBinaryOperator.register(); +} + +export default Object.freeze({ + initialize: uniffiEnsureInitialized, + converters: { + FfiConverterTypeBinaryOperator, + FfiConverterTypeCalculator, + FfiConverterTypeComputationError, + FfiConverterTypeComputationResult, + FfiConverterTypeComputationState, + FfiConverterTypeSafeAddition, + FfiConverterTypeSafeDivision, + }, +}); diff --git a/packages/react-native-uniffi-russh/src/index.tsx b/packages/react-native-uniffi-russh/src/index.tsx new file mode 100644 index 0000000..c3d44b4 --- /dev/null +++ b/packages/react-native-uniffi-russh/src/index.tsx @@ -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, +}; + diff --git a/packages/react-native-uniffi-russh/tsconfig.build.json b/packages/react-native-uniffi-russh/tsconfig.build.json index 3c0636a..c1c061b 100644 --- a/packages/react-native-uniffi-russh/tsconfig.build.json +++ b/packages/react-native-uniffi-russh/tsconfig.build.json @@ -1,4 +1,8 @@ { "extends": "./tsconfig", - "exclude": ["example", "lib"] + "exclude": ["example", "lib"], + "compilerOptions": { + "noUnusedParameters": false, + "noUnusedLocals": false + } } diff --git a/packages/react-native-uniffi-russh/ubrn.config.yaml b/packages/react-native-uniffi-russh/ubrn.config.yaml index e69de29..e33ac4b 100644 --- a/packages/react-native-uniffi-russh/ubrn.config.yaml +++ b/packages/react-native-uniffi-russh/ubrn.config.yaml @@ -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 diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e0152e0..5862707 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -44,6 +44,9 @@ importers: '@fressh/assets': specifier: workspace:* version: link:../../packages/assets + '@fressh/react-native-uniffi-russh': + specifier: workspace:* + version: link:../../packages/react-native-uniffi-russh '@react-native-picker/picker': specifier: 2.11.1 version: 2.11.1(react-native@0.81.4(@babel/core@7.28.3)(@react-native-community/cli@20.0.2(typescript@5.9.2))(@types/react@19.1.12)(react@19.1.0))(react@19.1.0) @@ -238,9 +241,6 @@ importers: specifier: 0.29.3-1 version: 0.29.3-1 devDependencies: - '@commitlint/config-conventional': - specifier: ^19.8.1 - version: 19.8.1 '@eslint/compat': specifier: ^1.3.2 version: 1.3.2(eslint@9.35.0(jiti@2.5.1)) @@ -268,9 +268,6 @@ importers: '@types/react': specifier: ^19.1.0 version: 19.1.12 - commitlint: - specifier: ^19.8.1 - version: 19.8.1(@types/node@24.3.0)(typescript@5.9.2) del-cli: specifier: ^6.0.0 version: 6.0.0 @@ -1064,75 +1061,6 @@ packages: resolution: {integrity: sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==} engines: {node: '>=0.1.90'} - '@commitlint/cli@19.8.1': - resolution: {integrity: sha512-LXUdNIkspyxrlV6VDHWBmCZRtkEVRpBKxi2Gtw3J54cGWhLCTouVD/Q6ZSaSvd2YaDObWK8mDjrz3TIKtaQMAA==} - engines: {node: '>=v18'} - hasBin: true - - '@commitlint/config-conventional@19.8.1': - resolution: {integrity: sha512-/AZHJL6F6B/G959CsMAzrPKKZjeEiAVifRyEwXxcT6qtqbPwGw+iQxmNS+Bu+i09OCtdNRW6pNpBvgPrtMr9EQ==} - engines: {node: '>=v18'} - - '@commitlint/config-validator@19.8.1': - resolution: {integrity: sha512-0jvJ4u+eqGPBIzzSdqKNX1rvdbSU1lPNYlfQQRIFnBgLy26BtC0cFnr7c/AyuzExMxWsMOte6MkTi9I3SQ3iGQ==} - engines: {node: '>=v18'} - - '@commitlint/ensure@19.8.1': - resolution: {integrity: sha512-mXDnlJdvDzSObafjYrOSvZBwkD01cqB4gbnnFuVyNpGUM5ijwU/r/6uqUmBXAAOKRfyEjpkGVZxaDsCVnHAgyw==} - engines: {node: '>=v18'} - - '@commitlint/execute-rule@19.8.1': - resolution: {integrity: sha512-YfJyIqIKWI64Mgvn/sE7FXvVMQER/Cd+s3hZke6cI1xgNT/f6ZAz5heND0QtffH+KbcqAwXDEE1/5niYayYaQA==} - engines: {node: '>=v18'} - - '@commitlint/format@19.8.1': - resolution: {integrity: sha512-kSJj34Rp10ItP+Eh9oCItiuN/HwGQMXBnIRk69jdOwEW9llW9FlyqcWYbHPSGofmjsqeoxa38UaEA5tsbm2JWw==} - engines: {node: '>=v18'} - - '@commitlint/is-ignored@19.8.1': - resolution: {integrity: sha512-AceOhEhekBUQ5dzrVhDDsbMaY5LqtN8s1mqSnT2Kz1ERvVZkNihrs3Sfk1Je/rxRNbXYFzKZSHaPsEJJDJV8dg==} - engines: {node: '>=v18'} - - '@commitlint/lint@19.8.1': - resolution: {integrity: sha512-52PFbsl+1EvMuokZXLRlOsdcLHf10isTPlWwoY1FQIidTsTvjKXVXYb7AvtpWkDzRO2ZsqIgPK7bI98x8LRUEw==} - engines: {node: '>=v18'} - - '@commitlint/load@19.8.1': - resolution: {integrity: sha512-9V99EKG3u7z+FEoe4ikgq7YGRCSukAcvmKQuTtUyiYPnOd9a2/H9Ak1J9nJA1HChRQp9OA/sIKPugGS+FK/k1A==} - engines: {node: '>=v18'} - - '@commitlint/message@19.8.1': - resolution: {integrity: sha512-+PMLQvjRXiU+Ae0Wc+p99EoGEutzSXFVwQfa3jRNUZLNW5odZAyseb92OSBTKCu+9gGZiJASt76Cj3dLTtcTdg==} - engines: {node: '>=v18'} - - '@commitlint/parse@19.8.1': - resolution: {integrity: sha512-mmAHYcMBmAgJDKWdkjIGq50X4yB0pSGpxyOODwYmoexxxiUCy5JJT99t1+PEMK7KtsCtzuWYIAXYAiKR+k+/Jw==} - engines: {node: '>=v18'} - - '@commitlint/read@19.8.1': - resolution: {integrity: sha512-03Jbjb1MqluaVXKHKRuGhcKWtSgh3Jizqy2lJCRbRrnWpcM06MYm8th59Xcns8EqBYvo0Xqb+2DoZFlga97uXQ==} - engines: {node: '>=v18'} - - '@commitlint/resolve-extends@19.8.1': - resolution: {integrity: sha512-GM0mAhFk49I+T/5UCYns5ayGStkTt4XFFrjjf0L4S26xoMTSkdCf9ZRO8en1kuopC4isDFuEm7ZOm/WRVeElVg==} - engines: {node: '>=v18'} - - '@commitlint/rules@19.8.1': - resolution: {integrity: sha512-Hnlhd9DyvGiGwjfjfToMi1dsnw1EXKGJNLTcsuGORHz6SS9swRgkBsou33MQ2n51/boIDrbsg4tIBbRpEWK2kw==} - engines: {node: '>=v18'} - - '@commitlint/to-lines@19.8.1': - resolution: {integrity: sha512-98Mm5inzbWTKuZQr2aW4SReY6WUukdWXuZhrqf1QdKPZBCCsXuG87c+iP0bwtD6DBnmVVQjgp4whoHRVixyPBg==} - engines: {node: '>=v18'} - - '@commitlint/top-level@19.8.1': - resolution: {integrity: sha512-Ph8IN1IOHPSDhURCSXBz44+CIu+60duFwRsg6HqaISFHQHbmBtxVw4ZrFNIYUzEP7WwrNPxa2/5qJ//NK1FGcw==} - engines: {node: '>=v18'} - - '@commitlint/types@19.8.1': - resolution: {integrity: sha512-/yCrWGCoA1SVKOks25EGadP9Pnj0oAIHGpl2wH2M2Y46dPM2ueb8wyCVOD7O3WCTkaJ0IkKvzhl1JY7+uCT2Dw==} - engines: {node: '>=v18'} - '@conventional-changelog/git-client@1.0.1': resolution: {integrity: sha512-PJEqBwAleffCMETaVm/fUgHldzBE35JFk3/9LL6NUA5EXa3qednu+UT6M7E5iBu3zIQZCULYIiZ90fBYHt6xUw==} engines: {node: '>=18'} @@ -2901,9 +2829,6 @@ packages: '@types/babel__traverse@7.28.0': resolution: {integrity: sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q==} - '@types/conventional-commits-parser@5.0.1': - resolution: {integrity: sha512-7uz5EHdzz2TqoMfV7ee61Egf5y6NkcO4FB/1iCCQnbeiI1F3xzv3vK5dBCXUCLQgGYS+mUeigK1iKQzvED+QnQ==} - '@types/debug@4.1.12': resolution: {integrity: sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==} @@ -3337,10 +3262,6 @@ packages: resolution: {integrity: sha512-nQvrCBu7K2pSSEtIM0EEF03FVjcczCXInMt3moLNFbjlWx6bZrX72uT6/1uAXDbnzGUAx9gTyDiQ+vrFi663oA==} deprecated: Package no longer supported. Contact support@npmjs.com for more info. - JSONStream@1.3.5: - resolution: {integrity: sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==} - hasBin: true - abbrev@3.0.1: resolution: {integrity: sha512-AO2ac6pjRB3SJmGJo+v5/aK6Omggp6fsLrs6wN9bd35ulu4cCwaAU9+7ZhXjeqHVkaHThLuzH0nZr0YpCDhygg==} engines: {node: ^18.17.0 || >=20.5.0} @@ -3979,11 +3900,6 @@ packages: resolution: {integrity: sha512-buhp5kePrmda3vhc5B9t7pUQXAb2Tnd0qgpkIhPhkHXxJpiPJ11H0ZEU0oBpJ2QztSbzG/ZxMj/CHsYJqRHmyg==} engines: {node: '>= 12.0.0'} - commitlint@19.8.1: - resolution: {integrity: sha512-j7jojdmHrVOZ16gnjK2nbQuzdwA9TpxS9iNb9Q9QS3ytgt3JZVIGmsNbCuhmnsJWGspotlQ34yH8n1HvIKImiQ==} - engines: {node: '>=v18'} - hasBin: true - common-ancestor-path@1.0.1: resolution: {integrity: sha512-L3sHRo1pXXEqX8VU28kfgUY+YGsk09hPqZiZmLacNib6XNTCM8ubYeT7ryXQw8asB1sKgcU5lkB7ONug08aB8w==} @@ -4023,10 +3939,6 @@ packages: resolution: {integrity: sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==} engines: {node: '>= 0.6'} - conventional-changelog-angular@7.0.0: - resolution: {integrity: sha512-ROjNchA9LgfNMTTFSIWPzebCwOGFdgkEq45EnvvrmSLvCtAw0HSmrCs7/ty+wAeYUZyNay0YMUNYFTRL72PkBQ==} - engines: {node: '>=16'} - conventional-changelog-angular@8.0.0: resolution: {integrity: sha512-CLf+zr6St0wIxos4bmaKHRXWAcsCXrJU6F4VdNDrGRK3B8LDLKoX3zuMV5GhtbGkVR/LohZ6MT6im43vZLSjmA==} engines: {node: '>=18'} @@ -4039,10 +3951,6 @@ packages: resolution: {integrity: sha512-8gsBDI5Y3vrKUCxN6Ue8xr6occZ5nsDEc4C7jO/EovFGozx8uttCAyfhRrvoUAWi2WMm3OmYs+0mPJU7kQdYWQ==} engines: {node: '>=18'} - conventional-changelog-conventionalcommits@7.0.2: - resolution: {integrity: sha512-NKXYmMR/Hr1DevQegFB4MwfM5Vv0m4UIxKZTTYuD98lpTknaZlSRrDOG4X7wIXpGkfsYxZTghUN+Qq+T0YQI7w==} - engines: {node: '>=16'} - conventional-changelog-conventionalcommits@8.0.0: resolution: {integrity: sha512-eOvlTO6OcySPyyyk8pKz2dP4jjElYunj9hn9/s0OB+gapTO8zwS9UQWrZ1pmF2hFs3vw1xhonOLGcGjy/zgsuA==} engines: {node: '>=18'} @@ -4088,11 +3996,6 @@ packages: resolution: {integrity: sha512-tQMagCOC59EVgNZcC5zl7XqO30Wki9i9J3acbUvkaosCT6JX3EeFwJD7Qqp4MCikRnzS18WXV3BLIQ66ytu6+Q==} engines: {node: '>=18'} - conventional-commits-parser@5.0.0: - resolution: {integrity: sha512-ZPMl0ZJbw74iS9LuX9YIAiW8pfM5p3yh2o/NbXHbkFuZzY5jvdi5jFycEOkmBW5H5I7nA+D6f3UcsCLP2vvSEA==} - engines: {node: '>=16'} - hasBin: true - conventional-commits-parser@6.2.0: resolution: {integrity: sha512-uLnoLeIW4XaoFtH37qEcg/SXMJmKF4vi7V0H2rnPueg+VEtFGA/asSCNTcq4M/GQ6QmlzchAEtOoDTtKqWeHag==} engines: {node: '>=18'} @@ -4116,14 +4019,6 @@ packages: core-js-compat@3.45.1: resolution: {integrity: sha512-tqTt5T4PzsMIZ430XGviK4vzYSoeNJ6CXODi6c/voxOT6IZqBht5/EKaSNnYiEjjRYxjVz7DQIsOsY0XNi8PIA==} - cosmiconfig-typescript-loader@6.1.0: - resolution: {integrity: sha512-tJ1w35ZRUiM5FeTzT7DtYWAFFv37ZLqSRkGi2oeCK1gPhvaWjkAtfXvLmvE1pRfxxp9aQo6ba/Pvg1dKj05D4g==} - engines: {node: '>=v18'} - peerDependencies: - '@types/node': '*' - cosmiconfig: '>=9' - typescript: '>=5' - cosmiconfig@5.2.1: resolution: {integrity: sha512-H65gsXo1SKjf8zmrJ67eJk8aIRKV5ff2D4uKZIBZShbhGSpEmsQOPW/SKMKYhSTrqR7ufy6RP69rPogdaPh/kA==} engines: {node: '>=4'} @@ -4183,10 +4078,6 @@ packages: damerau-levenshtein@1.0.8: resolution: {integrity: sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==} - dargs@8.1.0: - resolution: {integrity: sha512-wAV9QHOsNbwnWdNW2FYvE1P56wtgSbM+3SZcdGiWQILwVjACCXDCI3Ai8QlCjMDB8YK5zySiXZYBiwGmNY3lnw==} - engines: {node: '>=12'} - data-uri-to-buffer@6.0.2: resolution: {integrity: sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw==} engines: {node: '>= 14'} @@ -5159,10 +5050,6 @@ packages: resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==} engines: {node: '>=10'} - find-up@7.0.0: - resolution: {integrity: sha512-YyZM99iHrqLKjmt4LJDj58KI+fYyufRLBSYcqycxf//KpBk9FoewoGX0450m9nB44qrZnovzC2oeP5hUibxc/g==} - engines: {node: '>=18'} - flat-cache@3.2.0: resolution: {integrity: sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==} engines: {node: ^10.12.0 || >=12.0.0} @@ -5300,11 +5187,6 @@ packages: resolution: {integrity: sha512-L5bGsVkxJbJgdnwyuheIunkGatUF/zssUoxxjACCseZYAVbaqdh9Tsmmlkl8vYan09H7sbvKt4pS8GqKLBrEzA==} hasBin: true - git-raw-commits@4.0.0: - resolution: {integrity: sha512-ICsMM1Wk8xSGMowkOmPrzo2Fgmfo4bMHLNX6ytHjajRJUqvHOw/TFapQ+QG75c3X/tTDDhOSRPGC52dDbNM8FQ==} - engines: {node: '>=16'} - hasBin: true - git-raw-commits@5.0.0: resolution: {integrity: sha512-I2ZXrXeOc0KrCvC7swqtIFXFN+rbjnC7b2T943tvemIOVNl+XP8YnA9UVwqFhzzLClnSA60KR/qEjLpXzs73Qg==} engines: {node: '>=18'} @@ -5349,10 +5231,6 @@ packages: engines: {node: '>=12'} deprecated: Glob versions prior to v9 are no longer supported - global-directory@4.0.1: - resolution: {integrity: sha512-wHTUcDUoZ1H5/0iVqEudYW4/kAlN5cZ3j/bXn0Dpbizl9iaUVeWSHqiOjsgk6OW2bkLclbBjzewBz6weQ1zA2Q==} - engines: {node: '>=18'} - global-dirs@0.1.1: resolution: {integrity: sha512-NknMLn7F2J7aflwFOlGdNIuCDpN3VGoSoB+aap3KABFWbHVn1TCgFC+np23J8W2BiZbjfEw3BFBycSMv1AFblg==} engines: {node: '>=4'} @@ -5591,10 +5469,6 @@ packages: ini@1.3.8: resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==} - ini@4.1.1: - resolution: {integrity: sha512-QQnnxNyfvmHFIsj7gkPcYymR8Jdw/o7mp5ZFihxn6h8Ci6fh3Dx4E1gPjpQEpIuPo9XVNY/ZUwh4BPMjGyL01g==} - engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} - inline-style-prefixer@7.0.1: resolution: {integrity: sha512-lhYo5qNTQp3EvSSp3sRvXMbVQTLrvGV6DycRMJ5dm2BLMiJ30wpXKdDdgX+GmJZ5uQMucwRKHamXSst3Sj/Giw==} @@ -5809,10 +5683,6 @@ packages: resolution: {integrity: sha512-9gGx6GTtCQM73BgmHQXfDmLtfjjTUDSyoxTCbp5WtoixAhfgsDirWIcVQ/IHpvI5Vgd5i/J5F7B9cN/WlVbC/w==} engines: {node: '>= 0.4'} - is-text-path@2.0.0: - resolution: {integrity: sha512-+oDTluR6WEjdXEJMnC2z6A4FRwFoYuvShVVEGsS7ewc0UTi2QtAKMDJuL4BDEVt+5T7MjFo12RP8ghOM75oKJw==} - engines: {node: '>=8'} - is-typed-array@1.1.15: resolution: {integrity: sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ==} engines: {node: '>= 0.4'} @@ -6111,10 +5981,6 @@ packages: jsonfile@6.2.0: resolution: {integrity: sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==} - jsonparse@1.3.1: - resolution: {integrity: sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==} - engines: {'0': node >= 0.2.0} - jstransformer@1.0.0: resolution: {integrity: sha512-C9YK3Rf8q6VAPDCCU9fnqo3mAfOH6vUGnMcP4AQAYIEpWtfGLpwOTmZ+igtdK5y+VvI2n3CyYSzy4Qh34eq24A==} @@ -6245,13 +6111,6 @@ packages: resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} engines: {node: '>=10'} - locate-path@7.2.0: - resolution: {integrity: sha512-gvVijfZvn7R+2qyPX8mAuKcFGDf6Nc61GdvGafQsHL0sBIxfKzA+usWn4GFC/bk+QdwPUD4kWFJLhElipq+0VA==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - - lodash.camelcase@4.3.0: - resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==} - lodash.capitalize@4.2.1: resolution: {integrity: sha512-kZzYOKspf8XVX5AvmQF94gQW0lejFVgb80G85bU4ZWzoJ6C03PQg3coYAUpSTpQWelrZELd3XWgHzw4Ck5kaIw==} @@ -6267,33 +6126,15 @@ packages: lodash.isstring@4.0.1: resolution: {integrity: sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==} - lodash.kebabcase@4.1.1: - resolution: {integrity: sha512-N8XRTIMMqqDgSy4VLKPnJ/+hpGZN+PHQiJnSenYqPaVV/NCqEogTnAdZLQiGKhxX+JCs8waWq2t1XHWKOmlY8g==} - lodash.merge@4.6.2: resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} - lodash.mergewith@4.6.2: - resolution: {integrity: sha512-GK3g5RPZWTRSeLSpgP8Xhra+pnjBC56q9FZYe1d5RN3TJ35dbkGy3YqBSMbyCrlbi+CM9Z3Jk5yTL7RCsqboyQ==} - - lodash.snakecase@4.1.1: - resolution: {integrity: sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==} - - lodash.startcase@4.4.0: - resolution: {integrity: sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==} - lodash.throttle@4.1.1: resolution: {integrity: sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ==} - lodash.uniq@4.5.0: - resolution: {integrity: sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==} - lodash.uniqby@4.7.0: resolution: {integrity: sha512-e/zcLx6CSbmaEgFHCA7BnoQKyCtKMxnuWrJygbwPs/AIn+IMKl66L8/s+wBUn5LRw2pZx3bUHibiV1b6aTWIww==} - lodash.upperfirst@4.3.1: - resolution: {integrity: sha512-sReKOYJIJf74dhJONhU4e0/shzi1trVbSWDOhKYE5XV2O+H7Sb2Dihwuc7xWxVl+DgFPyTqIN3zMfT9cq5iWDg==} - lodash@4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} @@ -6416,10 +6257,6 @@ packages: resolution: {integrity: sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw==} engines: {node: '>= 0.10.0'} - meow@12.1.1: - resolution: {integrity: sha512-BhXM0Au22RwUneMPwSCnyhTOizdWoIEPU9sp0Aqa1PnDMR5Wv2FGXYDjuzJEIX+Eo2Rb8xuYe5jrnm5QowQFkw==} - engines: {node: '>=16.10'} - meow@13.2.0: resolution: {integrity: sha512-pxQJQzB6djGPXh08dacEloMFopsOqGVRKFPYvPOt9XDZ1HasbgDZA74CJGreSU4G3Ak7EFJGoiH2auq+yXISgA==} engines: {node: '>=18'} @@ -6929,10 +6766,6 @@ packages: resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} engines: {node: '>=10'} - p-limit@4.0.0: - resolution: {integrity: sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - p-limit@6.2.0: resolution: {integrity: sha512-kuUqqHNUqoIWp/c467RI4X6mmyuojY5jGutNU0wVTmEOOfcuwLqyMVoAi9MKi2Ak+5i9+nhmrK4ufZE8069kHA==} engines: {node: '>=18'} @@ -6945,10 +6778,6 @@ packages: resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==} engines: {node: '>=10'} - p-locate@6.0.0: - resolution: {integrity: sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - p-map@4.0.0: resolution: {integrity: sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==} engines: {node: '>=10'} @@ -7027,10 +6856,6 @@ packages: resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} engines: {node: '>=8'} - path-exists@5.0.0: - resolution: {integrity: sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - path-is-absolute@1.0.1: resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} engines: {node: '>=0.10.0'} @@ -7950,10 +7775,6 @@ packages: resolution: {integrity: sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==} engines: {node: '>=6'} - split2@4.2.0: - resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==} - engines: {node: '>= 10.x'} - sprintf-js@1.0.3: resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} @@ -8165,10 +7986,6 @@ packages: resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==} engines: {node: '>=8'} - text-extensions@2.4.0: - resolution: {integrity: sha512-te/NtwBwfiNRLf9Ijqx3T0nlqZiQ2XrrtBvu+cLL8ZRrGkO0NHTug8MYFKyoSrv/sHTaSKfilUkizV6XhxMJ3g==} - engines: {node: '>=8'} - text-table@0.2.0: resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} @@ -8182,9 +7999,6 @@ packages: throat@5.0.0: resolution: {integrity: sha512-fcwX4mndzpLQKBS1DVYhGAcYaYt7vsHNIvQV+WXMvnow5cgjPphq5CaayLaGsjRdSCKZFNGt7/GYAuXaNOiYCA==} - through@2.3.8: - resolution: {integrity: sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==} - tightrope@0.2.0: resolution: {integrity: sha512-Kw36UHxJEELq2VUqdaSGR2/8cAsPgMtvX8uGVU6Jk26O66PhXec0A5ZnRYs47btbtwPDpXXF66+Fo3vimCM9aQ==} engines: {node: '>=16'} @@ -9931,116 +9745,6 @@ snapshots: '@colors/colors@1.5.0': optional: true - '@commitlint/cli@19.8.1(@types/node@24.3.0)(typescript@5.9.2)': - dependencies: - '@commitlint/format': 19.8.1 - '@commitlint/lint': 19.8.1 - '@commitlint/load': 19.8.1(@types/node@24.3.0)(typescript@5.9.2) - '@commitlint/read': 19.8.1 - '@commitlint/types': 19.8.1 - tinyexec: 1.0.1 - yargs: 17.7.2 - transitivePeerDependencies: - - '@types/node' - - typescript - - '@commitlint/config-conventional@19.8.1': - dependencies: - '@commitlint/types': 19.8.1 - conventional-changelog-conventionalcommits: 7.0.2 - - '@commitlint/config-validator@19.8.1': - dependencies: - '@commitlint/types': 19.8.1 - ajv: 8.17.1 - - '@commitlint/ensure@19.8.1': - dependencies: - '@commitlint/types': 19.8.1 - lodash.camelcase: 4.3.0 - lodash.kebabcase: 4.1.1 - lodash.snakecase: 4.1.1 - lodash.startcase: 4.4.0 - lodash.upperfirst: 4.3.1 - - '@commitlint/execute-rule@19.8.1': {} - - '@commitlint/format@19.8.1': - dependencies: - '@commitlint/types': 19.8.1 - chalk: 5.6.2 - - '@commitlint/is-ignored@19.8.1': - dependencies: - '@commitlint/types': 19.8.1 - semver: 7.7.2 - - '@commitlint/lint@19.8.1': - dependencies: - '@commitlint/is-ignored': 19.8.1 - '@commitlint/parse': 19.8.1 - '@commitlint/rules': 19.8.1 - '@commitlint/types': 19.8.1 - - '@commitlint/load@19.8.1(@types/node@24.3.0)(typescript@5.9.2)': - dependencies: - '@commitlint/config-validator': 19.8.1 - '@commitlint/execute-rule': 19.8.1 - '@commitlint/resolve-extends': 19.8.1 - '@commitlint/types': 19.8.1 - chalk: 5.6.2 - cosmiconfig: 9.0.0(typescript@5.9.2) - cosmiconfig-typescript-loader: 6.1.0(@types/node@24.3.0)(cosmiconfig@9.0.0(typescript@5.9.2))(typescript@5.9.2) - lodash.isplainobject: 4.0.6 - lodash.merge: 4.6.2 - lodash.uniq: 4.5.0 - transitivePeerDependencies: - - '@types/node' - - typescript - - '@commitlint/message@19.8.1': {} - - '@commitlint/parse@19.8.1': - dependencies: - '@commitlint/types': 19.8.1 - conventional-changelog-angular: 7.0.0 - conventional-commits-parser: 5.0.0 - - '@commitlint/read@19.8.1': - dependencies: - '@commitlint/top-level': 19.8.1 - '@commitlint/types': 19.8.1 - git-raw-commits: 4.0.0 - minimist: 1.2.8 - tinyexec: 1.0.1 - - '@commitlint/resolve-extends@19.8.1': - dependencies: - '@commitlint/config-validator': 19.8.1 - '@commitlint/types': 19.8.1 - global-directory: 4.0.1 - import-meta-resolve: 4.2.0 - lodash.mergewith: 4.6.2 - resolve-from: 5.0.0 - - '@commitlint/rules@19.8.1': - dependencies: - '@commitlint/ensure': 19.8.1 - '@commitlint/message': 19.8.1 - '@commitlint/to-lines': 19.8.1 - '@commitlint/types': 19.8.1 - - '@commitlint/to-lines@19.8.1': {} - - '@commitlint/top-level@19.8.1': - dependencies: - find-up: 7.0.0 - - '@commitlint/types@19.8.1': - dependencies: - '@types/conventional-commits-parser': 5.0.1 - chalk: 5.6.2 - '@conventional-changelog/git-client@1.0.1(conventional-commits-filter@5.0.0)(conventional-commits-parser@6.2.0)': dependencies: '@types/semver': 7.7.1 @@ -12227,10 +11931,6 @@ snapshots: dependencies: '@babel/types': 7.28.2 - '@types/conventional-commits-parser@5.0.1': - dependencies: - '@types/node': 24.3.0 - '@types/debug@4.1.12': dependencies: '@types/ms': 2.1.0 @@ -12704,11 +12404,6 @@ snapshots: D@1.0.0: {} - JSONStream@1.3.5: - dependencies: - jsonparse: 1.3.1 - through: 2.3.8 - abbrev@3.0.1: {} abort-controller@3.0.0: @@ -13527,14 +13222,6 @@ snapshots: comment-parser@1.4.1: {} - commitlint@19.8.1(@types/node@24.3.0)(typescript@5.9.2): - dependencies: - '@commitlint/cli': 19.8.1(@types/node@24.3.0)(typescript@5.9.2) - '@commitlint/types': 19.8.1 - transitivePeerDependencies: - - '@types/node' - - typescript - common-ancestor-path@1.0.1: {} compare-func@2.0.0: @@ -13587,10 +13274,6 @@ snapshots: content-type@1.0.5: {} - conventional-changelog-angular@7.0.0: - dependencies: - compare-func: 2.0.0 - conventional-changelog-angular@8.0.0: dependencies: compare-func: 2.0.0 @@ -13599,10 +13282,6 @@ snapshots: conventional-changelog-codemirror@5.0.0: {} - conventional-changelog-conventionalcommits@7.0.2: - dependencies: - compare-func: 2.0.0 - conventional-changelog-conventionalcommits@8.0.0: dependencies: compare-func: 2.0.0 @@ -13661,13 +13340,6 @@ snapshots: conventional-commits-filter@5.0.0: {} - conventional-commits-parser@5.0.0: - dependencies: - JSONStream: 1.3.5 - is-text-path: 2.0.0 - meow: 12.1.1 - split2: 4.2.0 - conventional-commits-parser@6.2.0: dependencies: meow: 13.2.0 @@ -13690,13 +13362,6 @@ snapshots: dependencies: browserslist: 4.25.4 - cosmiconfig-typescript-loader@6.1.0(@types/node@24.3.0)(cosmiconfig@9.0.0(typescript@5.9.2))(typescript@5.9.2): - dependencies: - '@types/node': 24.3.0 - cosmiconfig: 9.0.0(typescript@5.9.2) - jiti: 2.5.1 - typescript: 5.9.2 - cosmiconfig@5.2.1: dependencies: import-fresh: 2.0.0 @@ -13774,8 +13439,6 @@ snapshots: damerau-levenshtein@1.0.8: {} - dargs@8.1.0: {} - data-uri-to-buffer@6.0.2: {} data-view-buffer@1.0.2: @@ -14968,12 +14631,6 @@ snapshots: locate-path: 6.0.0 path-exists: 4.0.0 - find-up@7.0.0: - dependencies: - locate-path: 7.2.0 - path-exists: 5.0.0 - unicorn-magic: 0.1.0 - flat-cache@3.2.0: dependencies: flatted: 3.3.3 @@ -15128,12 +14785,6 @@ snapshots: nypm: 0.6.1 pathe: 2.0.3 - git-raw-commits@4.0.0: - dependencies: - dargs: 8.1.0 - meow: 12.1.1 - split2: 4.2.0 - git-raw-commits@5.0.0(conventional-commits-filter@5.0.0)(conventional-commits-parser@6.2.0): dependencies: '@conventional-changelog/git-client': 1.0.1(conventional-commits-filter@5.0.0)(conventional-commits-parser@6.2.0) @@ -15197,10 +14848,6 @@ snapshots: minimatch: 5.1.6 once: 1.4.0 - global-directory@4.0.1: - dependencies: - ini: 4.1.1 - global-dirs@0.1.1: dependencies: ini: 1.3.8 @@ -15490,8 +15137,6 @@ snapshots: ini@1.3.8: {} - ini@4.1.1: {} - inline-style-prefixer@7.0.1: dependencies: css-in-js-utils: 3.1.0 @@ -15688,10 +15333,6 @@ snapshots: has-symbols: 1.1.0 safe-regex-test: 1.1.0 - is-text-path@2.0.0: - dependencies: - text-extensions: 2.4.0 - is-typed-array@1.1.15: dependencies: which-typed-array: 1.1.19 @@ -16184,8 +15825,6 @@ snapshots: optionalDependencies: graceful-fs: 4.2.11 - jsonparse@1.3.1: {} - jstransformer@1.0.0: dependencies: is-promise: 2.2.2 @@ -16313,12 +15952,6 @@ snapshots: dependencies: p-locate: 5.0.0 - locate-path@7.2.0: - dependencies: - p-locate: 6.0.0 - - lodash.camelcase@4.3.0: {} - lodash.capitalize@4.2.1: {} lodash.debounce@4.0.8: {} @@ -16329,24 +15962,12 @@ snapshots: lodash.isstring@4.0.1: {} - lodash.kebabcase@4.1.1: {} - lodash.merge@4.6.2: {} - lodash.mergewith@4.6.2: {} - - lodash.snakecase@4.1.1: {} - - lodash.startcase@4.4.0: {} - lodash.throttle@4.1.1: {} - lodash.uniq@4.5.0: {} - lodash.uniqby@4.7.0: {} - lodash.upperfirst@4.3.1: {} - lodash@4.17.21: {} log-symbols@2.2.0: @@ -16543,8 +16164,6 @@ snapshots: memorystream@0.3.1: {} - meow@12.1.1: {} - meow@13.2.0: {} merge-stream@2.0.0: {} @@ -17299,10 +16918,6 @@ snapshots: dependencies: yocto-queue: 0.1.0 - p-limit@4.0.0: - dependencies: - yocto-queue: 1.2.1 - p-limit@6.2.0: dependencies: yocto-queue: 1.2.1 @@ -17315,10 +16930,6 @@ snapshots: dependencies: p-limit: 3.1.0 - p-locate@6.0.0: - dependencies: - p-limit: 4.0.0 - p-map@4.0.0: dependencies: aggregate-error: 3.1.0 @@ -17410,8 +17021,6 @@ snapshots: path-exists@4.0.0: {} - path-exists@5.0.0: {} - path-is-absolute@1.0.1: {} path-key@2.0.1: {} @@ -18559,8 +18168,6 @@ snapshots: split-on-first@1.1.0: {} - split2@4.2.0: {} - sprintf-js@1.0.3: {} stable-hash-x@0.2.0: {} @@ -18807,8 +18414,6 @@ snapshots: glob: 7.2.3 minimatch: 3.1.2 - text-extensions@2.4.0: {} - text-table@0.2.0: {} thenify-all@1.6.0: @@ -18821,8 +18426,6 @@ snapshots: throat@5.0.0: {} - through@2.3.8: {} - tightrope@0.2.0: {} tiny-inflate@1.0.3: {}