@breeztech/breez-sdk-spark-react-native 0.1.8-dev1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +54 -0
- package/android/CMakeLists.txt +79 -0
- package/android/build.gradle +143 -0
- package/android/cpp-adapter.cpp +63 -0
- package/android/generated/android/app/build/generated/source/codegen/java/com/facebook/fbreact/specs/NativeBreezSdkSparkReactNativeSpec.java +41 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/BreezSdkSparkReactNativeSpec-generated.cpp +38 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/BreezSdkSparkReactNativeSpec.h +31 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/CMakeLists.txt +36 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/BreezSdkSparkReactNativeSpecJSI-generated.cpp +32 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/BreezSdkSparkReactNativeSpecJSI.h +80 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/ComponentDescriptors.cpp +22 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/ComponentDescriptors.h +24 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/EventEmitters.cpp +16 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/EventEmitters.h +17 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/Props.cpp +19 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/Props.h +18 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/ShadowNodes.cpp +17 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/ShadowNodes.h +23 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/States.cpp +16 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/BreezSdkSparkReactNativeSpec/States.h +19 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +5 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/breeztech/breezsdkspark/BreezSdkSparkReactNativeModule.kt +43 -0
- package/android/src/main/java/com/breeztech/breezsdkspark/BreezSdkSparkReactNativePackage.kt +34 -0
- package/breeztech-breez-sdk-spark-react-native.podspec +44 -0
- package/cpp/breeztech-breez-sdk-spark-react-native.cpp +20 -0
- package/cpp/breeztech-breez-sdk-spark-react-native.h +15 -0
- package/cpp/generated/breez_sdk_common.cpp +3834 -0
- package/cpp/generated/breez_sdk_common.hpp +251 -0
- package/cpp/generated/breez_sdk_spark.cpp +8722 -0
- package/cpp/generated/breez_sdk_spark.hpp +589 -0
- package/cpp/generated/breez_sdk_spark_bindings.cpp +1750 -0
- package/cpp/generated/breez_sdk_spark_bindings.hpp +65 -0
- package/ios/BreezSdkSparkReactNative.h +16 -0
- package/ios/BreezSdkSparkReactNative.mm +66 -0
- package/ios/generated/build/generated/ios/BreezSdkSparkReactNativeSpec/BreezSdkSparkReactNativeSpec-generated.mm +46 -0
- package/ios/generated/build/generated/ios/BreezSdkSparkReactNativeSpec/BreezSdkSparkReactNativeSpec.h +63 -0
- package/ios/generated/build/generated/ios/BreezSdkSparkReactNativeSpecJSI-generated.cpp +32 -0
- package/ios/generated/build/generated/ios/BreezSdkSparkReactNativeSpecJSI.h +80 -0
- package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/ComponentDescriptors.cpp +22 -0
- package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/ComponentDescriptors.h +24 -0
- package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/EventEmitters.cpp +16 -0
- package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/EventEmitters.h +17 -0
- package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/Props.cpp +19 -0
- package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/Props.h +18 -0
- package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/RCTComponentViewHelpers.h +18 -0
- package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/ShadowNodes.cpp +17 -0
- package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/ShadowNodes.h +23 -0
- package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/States.cpp +16 -0
- package/ios/generated/build/generated/ios/react/renderer/components/BreezSdkSparkReactNativeSpec/States.h +19 -0
- package/lib/commonjs/NativeBreezSdkSparkReactNative.js +10 -0
- package/lib/commonjs/NativeBreezSdkSparkReactNative.js.map +1 -0
- package/lib/commonjs/generated/breez_sdk_common-ffi.js +44 -0
- package/lib/commonjs/generated/breez_sdk_common-ffi.js.map +1 -0
- package/lib/commonjs/generated/breez_sdk_common.js +3948 -0
- package/lib/commonjs/generated/breez_sdk_common.js.map +1 -0
- package/lib/commonjs/generated/breez_sdk_spark-ffi.js +44 -0
- package/lib/commonjs/generated/breez_sdk_spark-ffi.js.map +1 -0
- package/lib/commonjs/generated/breez_sdk_spark.js +5775 -0
- package/lib/commonjs/generated/breez_sdk_spark.js.map +1 -0
- package/lib/commonjs/generated/breez_sdk_spark_bindings-ffi.js +44 -0
- package/lib/commonjs/generated/breez_sdk_spark_bindings-ffi.js.map +1 -0
- package/lib/commonjs/generated/breez_sdk_spark_bindings.js +51 -0
- package/lib/commonjs/generated/breez_sdk_spark_bindings.js.map +1 -0
- package/lib/commonjs/index.js +81 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/module/NativeBreezSdkSparkReactNative.js +7 -0
- package/lib/module/NativeBreezSdkSparkReactNative.js.map +1 -0
- package/lib/module/generated/breez_sdk_common-ffi.js +43 -0
- package/lib/module/generated/breez_sdk_common-ffi.js.map +1 -0
- package/lib/module/generated/breez_sdk_common.js +3942 -0
- package/lib/module/generated/breez_sdk_common.js.map +1 -0
- package/lib/module/generated/breez_sdk_spark-ffi.js +43 -0
- package/lib/module/generated/breez_sdk_spark-ffi.js.map +1 -0
- package/lib/module/generated/breez_sdk_spark.js +5759 -0
- package/lib/module/generated/breez_sdk_spark.js.map +1 -0
- package/lib/module/generated/breez_sdk_spark_bindings-ffi.js +43 -0
- package/lib/module/generated/breez_sdk_spark_bindings-ffi.js.map +1 -0
- package/lib/module/generated/breez_sdk_spark_bindings.js +46 -0
- package/lib/module/generated/breez_sdk_spark_bindings.js.map +1 -0
- package/lib/module/index.js +44 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeBreezSdkSparkReactNative.d.ts +8 -0
- package/lib/typescript/commonjs/src/NativeBreezSdkSparkReactNative.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeBreezSdkSparkReactNative.d.ts +8 -0
- package/lib/typescript/module/src/NativeBreezSdkSparkReactNative.d.ts.map +1 -0
- package/package.json +189 -0
- package/react-native.config.js +12 -0
- package/scripts/postinstall.sh +14 -0
- package/src/NativeBreezSdkSparkReactNative.ts +10 -0
- package/src/generated/breez_sdk_common-ffi.ts +394 -0
- package/src/generated/breez_sdk_common.ts +5502 -0
- package/src/generated/breez_sdk_spark-ffi.ts +751 -0
- package/src/generated/breez_sdk_spark.ts +9179 -0
- package/src/generated/breez_sdk_spark_bindings-ffi.ts +185 -0
- package/src/generated/breez_sdk_spark_bindings.ts +103 -0
- package/src/index.tsx +42 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate.
|
|
2
|
+
// Trust me, you don't want to mess with it!
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
type StructuralEquality as UniffiStructuralEquality,
|
|
6
|
+
type UniffiForeignFuture as RuntimeUniffiForeignFuture,
|
|
7
|
+
type UniffiRustCallStatus,
|
|
8
|
+
type UniffiRustArcPtr,
|
|
9
|
+
type UniffiRustFutureContinuationCallback as RuntimeUniffiRustFutureContinuationCallback,
|
|
10
|
+
type UniffiResult,
|
|
11
|
+
} from 'uniffi-bindgen-react-native';
|
|
12
|
+
|
|
13
|
+
interface NativeModuleInterface {
|
|
14
|
+
ubrn_uniffi_internal_fn_func_ffi__string_to_byte_length(
|
|
15
|
+
string: string,
|
|
16
|
+
uniffi_out_err: UniffiRustCallStatus
|
|
17
|
+
): number;
|
|
18
|
+
ubrn_uniffi_internal_fn_func_ffi__string_to_arraybuffer(
|
|
19
|
+
string: string,
|
|
20
|
+
uniffi_out_err: UniffiRustCallStatus
|
|
21
|
+
): Uint8Array;
|
|
22
|
+
ubrn_uniffi_internal_fn_func_ffi__arraybuffer_to_string(
|
|
23
|
+
buffer: Uint8Array,
|
|
24
|
+
uniffi_out_err: UniffiRustCallStatus
|
|
25
|
+
): string;
|
|
26
|
+
ubrn_ffi_breez_sdk_spark_bindings_uniffi_contract_version(): number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Casting globalThis to any allows us to look for `NativeBreezSdkSparkBindings`
|
|
30
|
+
// if it was added via JSI.
|
|
31
|
+
//
|
|
32
|
+
// We use a getter here rather than simply `globalThis.NativeBreezSdkSparkBindings` so that
|
|
33
|
+
// if/when the startup sequence isn't just so, an empty value isn't inadvertantly cached.
|
|
34
|
+
const getter: () => NativeModuleInterface = () =>
|
|
35
|
+
(globalThis as any).NativeBreezSdkSparkBindings;
|
|
36
|
+
export default getter;
|
|
37
|
+
|
|
38
|
+
// Structs and function types for calling back into Typescript from Rust.
|
|
39
|
+
export type UniffiRustFutureContinuationCallback = (
|
|
40
|
+
data: bigint,
|
|
41
|
+
pollResult: number
|
|
42
|
+
) => void;
|
|
43
|
+
type UniffiForeignFutureFree = (handle: bigint) => void;
|
|
44
|
+
type UniffiCallbackInterfaceFree = (handle: bigint) => void;
|
|
45
|
+
export type UniffiForeignFuture = {
|
|
46
|
+
handle: bigint;
|
|
47
|
+
free: UniffiForeignFutureFree;
|
|
48
|
+
};
|
|
49
|
+
export type UniffiForeignFutureStructU8 = {
|
|
50
|
+
returnValue: number;
|
|
51
|
+
callStatus: UniffiRustCallStatus;
|
|
52
|
+
};
|
|
53
|
+
export type UniffiForeignFutureCompleteU8 = (
|
|
54
|
+
callbackData: bigint,
|
|
55
|
+
result: UniffiForeignFutureStructU8
|
|
56
|
+
) => void;
|
|
57
|
+
export type UniffiForeignFutureStructI8 = {
|
|
58
|
+
returnValue: number;
|
|
59
|
+
callStatus: UniffiRustCallStatus;
|
|
60
|
+
};
|
|
61
|
+
export type UniffiForeignFutureCompleteI8 = (
|
|
62
|
+
callbackData: bigint,
|
|
63
|
+
result: UniffiForeignFutureStructI8
|
|
64
|
+
) => void;
|
|
65
|
+
export type UniffiForeignFutureStructU16 = {
|
|
66
|
+
returnValue: number;
|
|
67
|
+
callStatus: UniffiRustCallStatus;
|
|
68
|
+
};
|
|
69
|
+
export type UniffiForeignFutureCompleteU16 = (
|
|
70
|
+
callbackData: bigint,
|
|
71
|
+
result: UniffiForeignFutureStructU16
|
|
72
|
+
) => void;
|
|
73
|
+
export type UniffiForeignFutureStructI16 = {
|
|
74
|
+
returnValue: number;
|
|
75
|
+
callStatus: UniffiRustCallStatus;
|
|
76
|
+
};
|
|
77
|
+
export type UniffiForeignFutureCompleteI16 = (
|
|
78
|
+
callbackData: bigint,
|
|
79
|
+
result: UniffiForeignFutureStructI16
|
|
80
|
+
) => void;
|
|
81
|
+
export type UniffiForeignFutureStructU32 = {
|
|
82
|
+
returnValue: number;
|
|
83
|
+
callStatus: UniffiRustCallStatus;
|
|
84
|
+
};
|
|
85
|
+
export type UniffiForeignFutureCompleteU32 = (
|
|
86
|
+
callbackData: bigint,
|
|
87
|
+
result: UniffiForeignFutureStructU32
|
|
88
|
+
) => void;
|
|
89
|
+
export type UniffiForeignFutureStructI32 = {
|
|
90
|
+
returnValue: number;
|
|
91
|
+
callStatus: UniffiRustCallStatus;
|
|
92
|
+
};
|
|
93
|
+
export type UniffiForeignFutureCompleteI32 = (
|
|
94
|
+
callbackData: bigint,
|
|
95
|
+
result: UniffiForeignFutureStructI32
|
|
96
|
+
) => void;
|
|
97
|
+
export type UniffiForeignFutureStructU64 = {
|
|
98
|
+
returnValue: bigint;
|
|
99
|
+
callStatus: UniffiRustCallStatus;
|
|
100
|
+
};
|
|
101
|
+
export type UniffiForeignFutureCompleteU64 = (
|
|
102
|
+
callbackData: bigint,
|
|
103
|
+
result: UniffiForeignFutureStructU64
|
|
104
|
+
) => void;
|
|
105
|
+
export type UniffiForeignFutureStructI64 = {
|
|
106
|
+
returnValue: bigint;
|
|
107
|
+
callStatus: UniffiRustCallStatus;
|
|
108
|
+
};
|
|
109
|
+
export type UniffiForeignFutureCompleteI64 = (
|
|
110
|
+
callbackData: bigint,
|
|
111
|
+
result: UniffiForeignFutureStructI64
|
|
112
|
+
) => void;
|
|
113
|
+
export type UniffiForeignFutureStructF32 = {
|
|
114
|
+
returnValue: number;
|
|
115
|
+
callStatus: UniffiRustCallStatus;
|
|
116
|
+
};
|
|
117
|
+
export type UniffiForeignFutureCompleteF32 = (
|
|
118
|
+
callbackData: bigint,
|
|
119
|
+
result: UniffiForeignFutureStructF32
|
|
120
|
+
) => void;
|
|
121
|
+
export type UniffiForeignFutureStructF64 = {
|
|
122
|
+
returnValue: number;
|
|
123
|
+
callStatus: UniffiRustCallStatus;
|
|
124
|
+
};
|
|
125
|
+
export type UniffiForeignFutureCompleteF64 = (
|
|
126
|
+
callbackData: bigint,
|
|
127
|
+
result: UniffiForeignFutureStructF64
|
|
128
|
+
) => void;
|
|
129
|
+
export type UniffiForeignFutureStructPointer = {
|
|
130
|
+
returnValue: bigint;
|
|
131
|
+
callStatus: UniffiRustCallStatus;
|
|
132
|
+
};
|
|
133
|
+
export type UniffiForeignFutureCompletePointer = (
|
|
134
|
+
callbackData: bigint,
|
|
135
|
+
result: UniffiForeignFutureStructPointer
|
|
136
|
+
) => void;
|
|
137
|
+
export type UniffiForeignFutureStructRustBuffer = {
|
|
138
|
+
returnValue: Uint8Array;
|
|
139
|
+
callStatus: UniffiRustCallStatus;
|
|
140
|
+
};
|
|
141
|
+
export type UniffiForeignFutureCompleteRustBuffer = (
|
|
142
|
+
callbackData: bigint,
|
|
143
|
+
result: UniffiForeignFutureStructRustBuffer
|
|
144
|
+
) => void;
|
|
145
|
+
export type UniffiForeignFutureStructVoid = {
|
|
146
|
+
callStatus: UniffiRustCallStatus;
|
|
147
|
+
};
|
|
148
|
+
export type UniffiForeignFutureCompleteVoid = (
|
|
149
|
+
callbackData: bigint,
|
|
150
|
+
result: UniffiForeignFutureStructVoid
|
|
151
|
+
) => void;
|
|
152
|
+
|
|
153
|
+
// UniffiRustFutureContinuationCallback is generated as part of the component interface's
|
|
154
|
+
// ffi_definitions. However, we need it in the runtime.
|
|
155
|
+
// We could:
|
|
156
|
+
// (a) do some complicated template logic to ensure the declaration is not generated here (possible)
|
|
157
|
+
// (b) import the generated declaration into the runtime (m a y b e) or…
|
|
158
|
+
// (c) generate the declaration anyway, and use a different declaration in the runtime.
|
|
159
|
+
//
|
|
160
|
+
// We chose (c) here as the simplest. In addition, we perform a compile time check that
|
|
161
|
+
// the two versions of `UniffiRustFutureContinuationCallback` are structurally equivalent.
|
|
162
|
+
//
|
|
163
|
+
// If you see the error:
|
|
164
|
+
// ```
|
|
165
|
+
// Type 'true' is not assignable to type 'false'.(2322)
|
|
166
|
+
// ```
|
|
167
|
+
// Then a new version of uniffi has changed the signature of the callback. Most likely, code in
|
|
168
|
+
// `typescript/src/async-rust-call.ts` will need to be changed.
|
|
169
|
+
//
|
|
170
|
+
// If you see the error:
|
|
171
|
+
// ```
|
|
172
|
+
// Cannot find name 'UniffiRustFutureContinuationCallback'. Did you mean 'RuntimeUniffiRustFutureContinuationCallback'?(2552)
|
|
173
|
+
// ```
|
|
174
|
+
// then you may not be using callbacks or promises, and uniffi is now not generating Futures and callbacks.
|
|
175
|
+
// You should not generate this if that is the case.
|
|
176
|
+
//
|
|
177
|
+
// ('You' being the bindings generator maintainer).
|
|
178
|
+
const isRustFutureContinuationCallbackTypeCompatible: UniffiStructuralEquality<
|
|
179
|
+
RuntimeUniffiRustFutureContinuationCallback,
|
|
180
|
+
UniffiRustFutureContinuationCallback
|
|
181
|
+
> = true;
|
|
182
|
+
const isUniffiForeignFutureTypeCompatible: UniffiStructuralEquality<
|
|
183
|
+
RuntimeUniffiForeignFuture,
|
|
184
|
+
UniffiForeignFuture
|
|
185
|
+
> = true;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate.
|
|
2
|
+
// Trust me, you don't want to mess with it!
|
|
3
|
+
import nativeModule, {
|
|
4
|
+
type UniffiRustFutureContinuationCallback,
|
|
5
|
+
type UniffiForeignFuture,
|
|
6
|
+
type UniffiForeignFutureStructU8,
|
|
7
|
+
type UniffiForeignFutureCompleteU8,
|
|
8
|
+
type UniffiForeignFutureStructI8,
|
|
9
|
+
type UniffiForeignFutureCompleteI8,
|
|
10
|
+
type UniffiForeignFutureStructU16,
|
|
11
|
+
type UniffiForeignFutureCompleteU16,
|
|
12
|
+
type UniffiForeignFutureStructI16,
|
|
13
|
+
type UniffiForeignFutureCompleteI16,
|
|
14
|
+
type UniffiForeignFutureStructU32,
|
|
15
|
+
type UniffiForeignFutureCompleteU32,
|
|
16
|
+
type UniffiForeignFutureStructI32,
|
|
17
|
+
type UniffiForeignFutureCompleteI32,
|
|
18
|
+
type UniffiForeignFutureStructU64,
|
|
19
|
+
type UniffiForeignFutureCompleteU64,
|
|
20
|
+
type UniffiForeignFutureStructI64,
|
|
21
|
+
type UniffiForeignFutureCompleteI64,
|
|
22
|
+
type UniffiForeignFutureStructF32,
|
|
23
|
+
type UniffiForeignFutureCompleteF32,
|
|
24
|
+
type UniffiForeignFutureStructF64,
|
|
25
|
+
type UniffiForeignFutureCompleteF64,
|
|
26
|
+
type UniffiForeignFutureStructPointer,
|
|
27
|
+
type UniffiForeignFutureCompletePointer,
|
|
28
|
+
type UniffiForeignFutureStructRustBuffer,
|
|
29
|
+
type UniffiForeignFutureCompleteRustBuffer,
|
|
30
|
+
type UniffiForeignFutureStructVoid,
|
|
31
|
+
type UniffiForeignFutureCompleteVoid,
|
|
32
|
+
} from './breez_sdk_spark_bindings-ffi';
|
|
33
|
+
import {
|
|
34
|
+
type UniffiByteArray,
|
|
35
|
+
RustBuffer,
|
|
36
|
+
UniffiInternalError,
|
|
37
|
+
UniffiRustCaller,
|
|
38
|
+
uniffiCreateFfiConverterString,
|
|
39
|
+
} from 'uniffi-bindgen-react-native';
|
|
40
|
+
|
|
41
|
+
// Get converters from the other files, if any.
|
|
42
|
+
const uniffiCaller = new UniffiRustCaller();
|
|
43
|
+
|
|
44
|
+
const uniffiIsDebug =
|
|
45
|
+
// @ts-ignore -- The process global might not be defined
|
|
46
|
+
typeof process !== 'object' ||
|
|
47
|
+
// @ts-ignore -- The process global might not be defined
|
|
48
|
+
process?.env?.NODE_ENV !== 'production' ||
|
|
49
|
+
false;
|
|
50
|
+
// Public interface members begin here.
|
|
51
|
+
|
|
52
|
+
const stringConverter = {
|
|
53
|
+
stringToBytes: (s: string) =>
|
|
54
|
+
uniffiCaller.rustCall((status) =>
|
|
55
|
+
nativeModule().ubrn_uniffi_internal_fn_func_ffi__string_to_arraybuffer(
|
|
56
|
+
s,
|
|
57
|
+
status
|
|
58
|
+
)
|
|
59
|
+
),
|
|
60
|
+
bytesToString: (ab: UniffiByteArray) =>
|
|
61
|
+
uniffiCaller.rustCall((status) =>
|
|
62
|
+
nativeModule().ubrn_uniffi_internal_fn_func_ffi__arraybuffer_to_string(
|
|
63
|
+
ab,
|
|
64
|
+
status
|
|
65
|
+
)
|
|
66
|
+
),
|
|
67
|
+
stringByteLength: (s: string) =>
|
|
68
|
+
uniffiCaller.rustCall((status) =>
|
|
69
|
+
nativeModule().ubrn_uniffi_internal_fn_func_ffi__string_to_byte_length(
|
|
70
|
+
s,
|
|
71
|
+
status
|
|
72
|
+
)
|
|
73
|
+
),
|
|
74
|
+
};
|
|
75
|
+
const FfiConverterString = uniffiCreateFfiConverterString(stringConverter);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* This should be called before anything else.
|
|
79
|
+
*
|
|
80
|
+
* It is likely that this is being done for you by the library's `index.ts`.
|
|
81
|
+
*
|
|
82
|
+
* It checks versions of uniffi between when the Rust scaffolding was generated
|
|
83
|
+
* and when the bindings were generated.
|
|
84
|
+
*
|
|
85
|
+
* It also initializes the machinery to enable Rust to talk back to Javascript.
|
|
86
|
+
*/
|
|
87
|
+
function uniffiEnsureInitialized() {
|
|
88
|
+
// Get the bindings contract version from our ComponentInterface
|
|
89
|
+
const bindingsContractVersion = 26;
|
|
90
|
+
// Get the scaffolding contract version by calling the into the dylib
|
|
91
|
+
const scaffoldingContractVersion =
|
|
92
|
+
nativeModule().ubrn_ffi_breez_sdk_spark_bindings_uniffi_contract_version();
|
|
93
|
+
if (bindingsContractVersion !== scaffoldingContractVersion) {
|
|
94
|
+
throw new UniffiInternalError.ContractVersionMismatch(
|
|
95
|
+
scaffoldingContractVersion,
|
|
96
|
+
bindingsContractVersion
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export default Object.freeze({
|
|
102
|
+
initialize: uniffiEnsureInitialized,
|
|
103
|
+
});
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Generated by uniffi-bindgen-react-native
|
|
2
|
+
import installer from './NativeBreezSdkSparkReactNative';
|
|
3
|
+
|
|
4
|
+
// Register the rust crate with Hermes
|
|
5
|
+
// - the boolean flag ensures this loads exactly once, even if the JS
|
|
6
|
+
// code is reloaded (e.g. during development with metro).
|
|
7
|
+
let rustInstalled = false;
|
|
8
|
+
if (!rustInstalled) {
|
|
9
|
+
installer.installRustCrate();
|
|
10
|
+
rustInstalled = true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Export the generated bindings to the app.
|
|
14
|
+
export * from './generated/breez_sdk_common';
|
|
15
|
+
export * from './generated/breez_sdk_spark';
|
|
16
|
+
export * from './generated/breez_sdk_spark_bindings';
|
|
17
|
+
|
|
18
|
+
// Now import the bindings so we can:
|
|
19
|
+
// - intialize them
|
|
20
|
+
// - export them as namespaced objects as the default export.
|
|
21
|
+
import * as breez_sdk_common from './generated/breez_sdk_common';
|
|
22
|
+
import * as breez_sdk_spark from './generated/breez_sdk_spark';
|
|
23
|
+
import * as breez_sdk_spark_bindings from './generated/breez_sdk_spark_bindings';
|
|
24
|
+
|
|
25
|
+
// Initialize the generated bindings: mostly checksums, but also callbacks.
|
|
26
|
+
// - the boolean flag ensures this loads exactly once, even if the JS code
|
|
27
|
+
// is reloaded (e.g. during development with metro).
|
|
28
|
+
let initialized = false;
|
|
29
|
+
if (!initialized) {
|
|
30
|
+
breez_sdk_common.default.initialize();
|
|
31
|
+
breez_sdk_spark.default.initialize();
|
|
32
|
+
breez_sdk_spark_bindings.default.initialize();
|
|
33
|
+
initialized = true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Export the crates as individually namespaced objects.
|
|
37
|
+
export default {
|
|
38
|
+
breez_sdk_common,
|
|
39
|
+
breez_sdk_spark,
|
|
40
|
+
breez_sdk_spark_bindings,
|
|
41
|
+
};
|
|
42
|
+
|