fix: fix name conflict

Resolves name conflicts with other native modules.
Bump version to 0.1.1.
This commit is contained in:
coreyphillips
2024-09-15 12:35:12 -04:00
parent 9dcb906636
commit 31ecec8366
58 changed files with 14698 additions and 32882 deletions

View File

@@ -9,7 +9,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import uniffi.mobile.auth
import uniffi.pubkymobile.auth
class PubkyModule(reactContext: ReactApplicationContext) :
ReactContextBaseJavaModule(reactContext) {
@@ -18,24 +18,24 @@ class PubkyModule(reactContext: ReactApplicationContext) :
return NAME
}
@ReactMethod
fun auth(url: String, secretKey: String, promise: Promise) {
CoroutineScope(Dispatchers.IO).launch {
try {
val result = auth(url, secretKey)
val array = Arguments.createArray().apply {
result.forEach { pushString(it) }
}
withContext(Dispatchers.Main) {
promise.resolve(array)
}
} catch (e: Exception) {
withContext(Dispatchers.Main) {
promise.reject("Error", e.message)
}
}
}
}
@ReactMethod
fun auth(url: String, secretKey: String, promise: Promise) {
CoroutineScope(Dispatchers.IO).launch {
try {
val result = auth(url, secretKey)
val array = Arguments.createArray().apply {
result.forEach { pushString(it) }
}
withContext(Dispatchers.Main) {
promise.resolve(array)
}
} catch (e: Exception) {
withContext(Dispatchers.Main) {
promise.reject("Error", e.message)
}
}
}
}
companion object {
const val NAME = "Pubky"

View File

@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" packagePrefix="com.pubky" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -3,7 +3,7 @@
@file:Suppress("NAME_SHADOWING")
package uniffi.mobile;
package uniffi.pubkymobile;
// Common helper code.
//
@@ -48,7 +48,7 @@ open class RustBuffer : Structure() {
companion object {
internal fun alloc(size: Int = 0) = rustCall() { status ->
_UniFFILib.INSTANCE.ffi_mobile_rustbuffer_alloc(size, status)
_UniFFILib.INSTANCE.ffi_pubkymobile_rustbuffer_alloc(size, status)
}.also {
if(it.data == null) {
throw RuntimeException("RustBuffer.alloc() returned null data pointer (size=${size})")
@@ -64,7 +64,7 @@ open class RustBuffer : Structure() {
}
internal fun free(buf: RustBuffer.ByValue) = rustCall() { status ->
_UniFFILib.INSTANCE.ffi_mobile_rustbuffer_free(buf, status)
_UniFFILib.INSTANCE.ffi_pubkymobile_rustbuffer_free(buf, status)
}
}
@@ -361,7 +361,7 @@ private fun findLibraryName(componentName: String): String {
if (libOverride != null) {
return libOverride
}
return "mobile"
return "pubkymobile"
}
private inline fun <reified Lib : Library> loadIndirect(
@@ -376,7 +376,7 @@ private inline fun <reified Lib : Library> loadIndirect(
internal interface _UniFFILib : Library {
companion object {
internal val INSTANCE: _UniFFILib by lazy {
loadIndirect<_UniFFILib>(componentName = "mobile")
loadIndirect<_UniFFILib>(componentName = "pubkymobile")
.also { lib: _UniFFILib ->
uniffiCheckContractApiVersion(lib)
uniffiCheckApiChecksums(lib)
@@ -385,129 +385,125 @@ internal interface _UniFFILib : Library {
}
}
fun uniffi_mobile_fn_func_auth(`url`: RustBuffer.ByValue,`secretKey`: RustBuffer.ByValue,
fun uniffi_pubkymobile_fn_func_auth(`url`: RustBuffer.ByValue,`secretKey`: RustBuffer.ByValue,
): Pointer
fun uniffi_mobile_fn_func_myexample(_uniffi_out_err: RustCallStatus,
fun ffi_pubkymobile_rustbuffer_alloc(`size`: Int,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
fun ffi_mobile_rustbuffer_alloc(`size`: Int,_uniffi_out_err: RustCallStatus,
fun ffi_pubkymobile_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
fun ffi_mobile_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,_uniffi_out_err: RustCallStatus,
fun ffi_pubkymobile_rustbuffer_free(`buf`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
): Unit
fun ffi_pubkymobile_rustbuffer_reserve(`buf`: RustBuffer.ByValue,`additional`: Int,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
fun ffi_mobile_rustbuffer_free(`buf`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
fun ffi_pubkymobile_rust_future_continuation_callback_set(`callback`: UniFffiRustFutureContinuationCallbackType,
): Unit
fun ffi_mobile_rustbuffer_reserve(`buf`: RustBuffer.ByValue,`additional`: Int,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
fun ffi_mobile_rust_future_continuation_callback_set(`callback`: UniFffiRustFutureContinuationCallbackType,
fun ffi_pubkymobile_rust_future_poll_u8(`handle`: Pointer,`uniffiCallback`: USize,
): Unit
fun ffi_mobile_rust_future_poll_u8(`handle`: Pointer,`uniffiCallback`: USize,
fun ffi_pubkymobile_rust_future_cancel_u8(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_cancel_u8(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_free_u8(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_free_u8(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_complete_u8(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
fun ffi_pubkymobile_rust_future_complete_u8(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
): Byte
fun ffi_mobile_rust_future_poll_i8(`handle`: Pointer,`uniffiCallback`: USize,
fun ffi_pubkymobile_rust_future_poll_i8(`handle`: Pointer,`uniffiCallback`: USize,
): Unit
fun ffi_mobile_rust_future_cancel_i8(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_cancel_i8(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_free_i8(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_free_i8(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_complete_i8(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
fun ffi_pubkymobile_rust_future_complete_i8(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
): Byte
fun ffi_mobile_rust_future_poll_u16(`handle`: Pointer,`uniffiCallback`: USize,
fun ffi_pubkymobile_rust_future_poll_u16(`handle`: Pointer,`uniffiCallback`: USize,
): Unit
fun ffi_mobile_rust_future_cancel_u16(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_cancel_u16(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_free_u16(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_free_u16(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_complete_u16(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
fun ffi_pubkymobile_rust_future_complete_u16(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
): Short
fun ffi_mobile_rust_future_poll_i16(`handle`: Pointer,`uniffiCallback`: USize,
fun ffi_pubkymobile_rust_future_poll_i16(`handle`: Pointer,`uniffiCallback`: USize,
): Unit
fun ffi_mobile_rust_future_cancel_i16(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_cancel_i16(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_free_i16(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_free_i16(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_complete_i16(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
fun ffi_pubkymobile_rust_future_complete_i16(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
): Short
fun ffi_mobile_rust_future_poll_u32(`handle`: Pointer,`uniffiCallback`: USize,
fun ffi_pubkymobile_rust_future_poll_u32(`handle`: Pointer,`uniffiCallback`: USize,
): Unit
fun ffi_mobile_rust_future_cancel_u32(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_cancel_u32(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_free_u32(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_free_u32(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_complete_u32(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
fun ffi_pubkymobile_rust_future_complete_u32(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
): Int
fun ffi_mobile_rust_future_poll_i32(`handle`: Pointer,`uniffiCallback`: USize,
fun ffi_pubkymobile_rust_future_poll_i32(`handle`: Pointer,`uniffiCallback`: USize,
): Unit
fun ffi_mobile_rust_future_cancel_i32(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_cancel_i32(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_free_i32(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_free_i32(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_complete_i32(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
fun ffi_pubkymobile_rust_future_complete_i32(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
): Int
fun ffi_mobile_rust_future_poll_u64(`handle`: Pointer,`uniffiCallback`: USize,
fun ffi_pubkymobile_rust_future_poll_u64(`handle`: Pointer,`uniffiCallback`: USize,
): Unit
fun ffi_mobile_rust_future_cancel_u64(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_cancel_u64(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_free_u64(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_free_u64(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_complete_u64(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
fun ffi_pubkymobile_rust_future_complete_u64(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
): Long
fun ffi_mobile_rust_future_poll_i64(`handle`: Pointer,`uniffiCallback`: USize,
fun ffi_pubkymobile_rust_future_poll_i64(`handle`: Pointer,`uniffiCallback`: USize,
): Unit
fun ffi_mobile_rust_future_cancel_i64(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_cancel_i64(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_free_i64(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_free_i64(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_complete_i64(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
fun ffi_pubkymobile_rust_future_complete_i64(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
): Long
fun ffi_mobile_rust_future_poll_f32(`handle`: Pointer,`uniffiCallback`: USize,
fun ffi_pubkymobile_rust_future_poll_f32(`handle`: Pointer,`uniffiCallback`: USize,
): Unit
fun ffi_mobile_rust_future_cancel_f32(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_cancel_f32(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_free_f32(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_free_f32(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_complete_f32(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
fun ffi_pubkymobile_rust_future_complete_f32(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
): Float
fun ffi_mobile_rust_future_poll_f64(`handle`: Pointer,`uniffiCallback`: USize,
fun ffi_pubkymobile_rust_future_poll_f64(`handle`: Pointer,`uniffiCallback`: USize,
): Unit
fun ffi_mobile_rust_future_cancel_f64(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_cancel_f64(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_free_f64(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_free_f64(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_complete_f64(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
fun ffi_pubkymobile_rust_future_complete_f64(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
): Double
fun ffi_mobile_rust_future_poll_pointer(`handle`: Pointer,`uniffiCallback`: USize,
fun ffi_pubkymobile_rust_future_poll_pointer(`handle`: Pointer,`uniffiCallback`: USize,
): Unit
fun ffi_mobile_rust_future_cancel_pointer(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_cancel_pointer(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_free_pointer(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_free_pointer(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_complete_pointer(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
fun ffi_pubkymobile_rust_future_complete_pointer(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
): Pointer
fun ffi_mobile_rust_future_poll_rust_buffer(`handle`: Pointer,`uniffiCallback`: USize,
fun ffi_pubkymobile_rust_future_poll_rust_buffer(`handle`: Pointer,`uniffiCallback`: USize,
): Unit
fun ffi_mobile_rust_future_cancel_rust_buffer(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_cancel_rust_buffer(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_free_rust_buffer(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_free_rust_buffer(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_complete_rust_buffer(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
fun ffi_pubkymobile_rust_future_complete_rust_buffer(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
fun ffi_mobile_rust_future_poll_void(`handle`: Pointer,`uniffiCallback`: USize,
fun ffi_pubkymobile_rust_future_poll_void(`handle`: Pointer,`uniffiCallback`: USize,
): Unit
fun ffi_mobile_rust_future_cancel_void(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_cancel_void(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_free_void(`handle`: Pointer,
fun ffi_pubkymobile_rust_future_free_void(`handle`: Pointer,
): Unit
fun ffi_mobile_rust_future_complete_void(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
fun ffi_pubkymobile_rust_future_complete_void(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
): Unit
fun uniffi_mobile_checksum_func_auth(
fun uniffi_pubkymobile_checksum_func_auth(
): Short
fun uniffi_mobile_checksum_func_myexample(
): Short
fun ffi_mobile_uniffi_contract_version(
fun ffi_pubkymobile_uniffi_contract_version(
): Int
}
@@ -516,7 +512,7 @@ private fun uniffiCheckContractApiVersion(lib: _UniFFILib) {
// Get the bindings contract version from our ComponentInterface
val bindings_contract_version = 24
// Get the scaffolding contract version by calling the into the dylib
val scaffolding_contract_version = lib.ffi_mobile_uniffi_contract_version()
val scaffolding_contract_version = lib.ffi_pubkymobile_uniffi_contract_version()
if (bindings_contract_version != scaffolding_contract_version) {
throw RuntimeException("UniFFI contract version mismatch: try cleaning and rebuilding your project")
}
@@ -524,10 +520,7 @@ private fun uniffiCheckContractApiVersion(lib: _UniFFILib) {
@Suppress("UNUSED_PARAMETER")
private fun uniffiCheckApiChecksums(lib: _UniFFILib) {
if (lib.uniffi_mobile_checksum_func_auth() != 55720.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_mobile_checksum_func_myexample() != 65225.toShort()) {
if (lib.uniffi_pubkymobile_checksum_func_auth() != 46918.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
}
@@ -547,7 +540,7 @@ internal object uniffiRustFutureContinuationCallback: UniFffiRustFutureContinuat
}
internal fun register(lib: _UniFFILib) {
lib.ffi_mobile_rust_future_continuation_callback_set(this)
lib.ffi_pubkymobile_rust_future_continuation_callback_set(this)
}
}
@@ -667,10 +660,10 @@ public object FfiConverterSequenceString: FfiConverterRustBuffer<List<String>> {
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
suspend fun `auth`(`url`: String, `secretKey`: String) : List<String> {
return uniffiRustCallAsync(
_UniFFILib.INSTANCE.uniffi_mobile_fn_func_auth(FfiConverterString.lower(`url`),FfiConverterString.lower(`secretKey`),),
{ future, continuation -> _UniFFILib.INSTANCE.ffi_mobile_rust_future_poll_rust_buffer(future, continuation) },
{ future, continuation -> _UniFFILib.INSTANCE.ffi_mobile_rust_future_complete_rust_buffer(future, continuation) },
{ future -> _UniFFILib.INSTANCE.ffi_mobile_rust_future_free_rust_buffer(future) },
_UniFFILib.INSTANCE.uniffi_pubkymobile_fn_func_auth(FfiConverterString.lower(`url`),FfiConverterString.lower(`secretKey`),),
{ future, continuation -> _UniFFILib.INSTANCE.ffi_pubkymobile_rust_future_poll_rust_buffer(future, continuation) },
{ future, continuation -> _UniFFILib.INSTANCE.ffi_pubkymobile_rust_future_complete_rust_buffer(future, continuation) },
{ future -> _UniFFILib.INSTANCE.ffi_pubkymobile_rust_future_free_rust_buffer(future) },
// lift function
{ FfiConverterSequenceString.lift(it) },
// Error FFI converter
@@ -678,11 +671,3 @@ suspend fun `auth`(`url`: String, `secretKey`: String) : List<String> {
)
}
fun `myexample`(): List<String> {
return FfiConverterSequenceString.lift(
rustCall() { _status ->
_UniFFILib.INSTANCE.uniffi_mobile_fn_func_myexample(_status)
})
}

Binary file not shown.