@secondts/bark-react-native 0.4.2 → 0.5.3

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.
Files changed (38) hide show
  1. package/README.md +1 -1
  2. package/cpp/generated/bark.cpp +523 -5
  3. package/cpp/generated/bark.hpp +4 -0
  4. package/lib/commonjs/Logger.js +48 -0
  5. package/lib/commonjs/Logger.js.map +1 -0
  6. package/lib/commonjs/generated/bark-ffi.js.map +1 -1
  7. package/lib/commonjs/generated/bark.js +113 -4
  8. package/lib/commonjs/generated/bark.js.map +1 -1
  9. package/lib/commonjs/index.js +13 -0
  10. package/lib/commonjs/index.js.map +1 -1
  11. package/lib/module/Logger.js +43 -0
  12. package/lib/module/Logger.js.map +1 -0
  13. package/lib/module/generated/bark-ffi.js.map +1 -1
  14. package/lib/module/generated/bark.js +112 -4
  15. package/lib/module/generated/bark.js.map +1 -1
  16. package/lib/module/index.js +3 -0
  17. package/lib/module/index.js.map +1 -1
  18. package/lib/typescript/commonjs/src/Logger.d.ts +18 -0
  19. package/lib/typescript/commonjs/src/Logger.d.ts.map +1 -0
  20. package/lib/typescript/commonjs/src/generated/bark-ffi.d.ts +11 -1
  21. package/lib/typescript/commonjs/src/generated/bark-ffi.d.ts.map +1 -1
  22. package/lib/typescript/commonjs/src/generated/bark.d.ts +32 -2
  23. package/lib/typescript/commonjs/src/generated/bark.d.ts.map +1 -1
  24. package/lib/typescript/commonjs/src/index.d.ts +1 -0
  25. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  26. package/lib/typescript/module/src/Logger.d.ts +18 -0
  27. package/lib/typescript/module/src/Logger.d.ts.map +1 -0
  28. package/lib/typescript/module/src/generated/bark-ffi.d.ts +11 -1
  29. package/lib/typescript/module/src/generated/bark-ffi.d.ts.map +1 -1
  30. package/lib/typescript/module/src/generated/bark.d.ts +32 -2
  31. package/lib/typescript/module/src/generated/bark.d.ts.map +1 -1
  32. package/lib/typescript/module/src/index.d.ts +1 -0
  33. package/lib/typescript/module/src/index.d.ts.map +1 -1
  34. package/package.json +4 -4
  35. package/src/Logger.ts +42 -0
  36. package/src/generated/bark-ffi.ts +23 -1
  37. package/src/generated/bark.ts +160 -2
  38. package/src/index.tsx +3 -0
package/README.md CHANGED
@@ -60,7 +60,7 @@ npx expo install @secondts/bark-react-native@beta
60
60
 
61
61
  ```bash
62
62
  # Or install a specific beta version
63
- npx expo install @secondts/bark-react-native@0.4.2
63
+ npx expo install @secondts/bark-react-native@0.5.0
64
64
  ```
65
65
 
66
66
  For bare React Native projects, use:
@@ -130,6 +130,14 @@ extern "C" {
130
130
  UniffiForeignFutureResultVoid result
131
131
  );
132
132
  typedef void
133
+ (*UniffiCallbackInterfaceBarkLoggerMethod0)(
134
+ uint64_t uniffi_handle,
135
+ RustBuffer level,
136
+ RustBuffer target,
137
+ RustBuffer message,
138
+ void * uniffi_out_return, RustCallStatus* rust_call_status
139
+ );
140
+ typedef void
133
141
  (*UniffiCallbackInterfaceCustomOnchainWalletCallbacksMethod0)(
134
142
  uint64_t uniffi_handle,
135
143
  uint64_t * uniffi_out_return, RustCallStatus* rust_call_status
@@ -183,7 +191,11 @@ extern "C" {
183
191
  uint64_t uniffi_handle,
184
192
  RustBuffer tx_hex,
185
193
  void * uniffi_out_return, RustCallStatus* rust_call_status
186
- );typedef struct UniffiVTableCallbackInterfaceCustomOnchainWalletCallbacks {
194
+ );typedef struct UniffiVTableCallbackInterfaceBarkLogger {
195
+ UniffiCallbackInterfaceFree uniffi_free;
196
+ UniffiCallbackInterfaceClone uniffi_clone;
197
+ UniffiCallbackInterfaceBarkLoggerMethod0 log;
198
+ } UniffiVTableCallbackInterfaceBarkLogger;typedef struct UniffiVTableCallbackInterfaceCustomOnchainWalletCallbacks {
187
199
  UniffiCallbackInterfaceFree uniffi_free;
188
200
  UniffiCallbackInterfaceClone uniffi_clone;
189
201
  UniffiCallbackInterfaceCustomOnchainWalletCallbacksMethod0 get_balance;
@@ -304,7 +316,8 @@ extern "C" {
304
316
  );
305
317
  /*handle*/ uint64_t uniffi_bark_ffi_fn_method_wallet_bolt11_invoice(
306
318
  /*handle*/ uint64_t ptr,
307
- uint64_t amount_sats
319
+ uint64_t amount_sats,
320
+ RustBuffer description
308
321
  );
309
322
  /*handle*/ uint64_t uniffi_bark_ffi_fn_method_wallet_broadcast_tx(
310
323
  /*handle*/ uint64_t ptr,
@@ -604,6 +617,9 @@ extern "C" {
604
617
  /*handle*/ uint64_t uniffi_bark_ffi_fn_method_wallet_vtxos(
605
618
  /*handle*/ uint64_t ptr
606
619
  );
620
+ void uniffi_bark_ffi_fn_init_callback_vtable_barklogger(
621
+ UniffiVTableCallbackInterfaceBarkLogger * vtable
622
+ );
607
623
  void uniffi_bark_ffi_fn_init_callback_vtable_customonchainwalletcallbacks(
608
624
  UniffiVTableCallbackInterfaceCustomOnchainWalletCallbacks * vtable
609
625
  );
@@ -613,6 +629,11 @@ extern "C" {
613
629
  );
614
630
  RustBuffer uniffi_bark_ffi_fn_func_generate_mnemonic(RustCallStatus *uniffi_out_err
615
631
  );
632
+ void uniffi_bark_ffi_fn_func_set_logger(
633
+ uint64_t logger,
634
+ RustBuffer max_level,
635
+ RustCallStatus *uniffi_out_err
636
+ );
616
637
  int8_t uniffi_bark_ffi_fn_func_validate_ark_address(
617
638
  RustBuffer address,
618
639
  RustCallStatus *uniffi_out_err
@@ -822,6 +843,8 @@ extern "C" {
822
843
  );
823
844
  uint16_t uniffi_bark_ffi_checksum_func_generate_mnemonic(
824
845
  );
846
+ uint16_t uniffi_bark_ffi_checksum_func_set_logger(
847
+ );
825
848
  uint16_t uniffi_bark_ffi_checksum_func_validate_ark_address(
826
849
  );
827
850
  uint16_t uniffi_bark_ffi_checksum_func_validate_mnemonic(
@@ -1024,6 +1047,8 @@ extern "C" {
1024
1047
  );
1025
1048
  uint16_t uniffi_bark_ffi_checksum_constructor_wallet_open_with_onchain(
1026
1049
  );
1050
+ uint16_t uniffi_bark_ffi_checksum_method_barklogger_log(
1051
+ );
1027
1052
  uint16_t uniffi_bark_ffi_checksum_method_customonchainwalletcallbacks_get_balance(
1028
1053
  );
1029
1054
  uint16_t uniffi_bark_ffi_checksum_method_customonchainwalletcallbacks_prepare_tx(
@@ -1502,6 +1527,121 @@ namespace uniffi::bark::cb::foreignfuturedroppedcallback {
1502
1527
  // Implementation of free callback function CallbackInterfaceFree
1503
1528
 
1504
1529
 
1530
+ // Callback function: uniffi::bark::st::vtablecallbackinterfacebarklogger::vtablecallbackinterfacebarklogger::free::UniffiCallbackInterfaceFree
1531
+ //
1532
+ // We have the following constraints:
1533
+ // - we need to pass a function pointer to Rust.
1534
+ // - we need a jsi::Runtime and jsi::Function to call into JS.
1535
+ // - function pointers can't store state, so we can't use a lamda.
1536
+ //
1537
+ // For this, we store a lambda as a global, as `rsLambda`. The `callback` function calls
1538
+ // the lambda, which itself calls the `body` which then calls into JS.
1539
+ //
1540
+ // We then give the `callback` function pointer to Rust which will call the lambda sometime in the
1541
+ // future.
1542
+ namespace uniffi::bark::st::vtablecallbackinterfacebarklogger::vtablecallbackinterfacebarklogger::free {
1543
+ using namespace facebook;
1544
+
1545
+ // We need to store a lambda in a global so we can call it from
1546
+ // a function pointer. The function pointer is passed to Rust.
1547
+ static std::function<void(uint64_t)> rsLambda = nullptr;
1548
+
1549
+ // This is the main body of the callback. It's called from the lambda,
1550
+ // which itself is called from the callback function which is passed to Rust.
1551
+ static void body(jsi::Runtime &rt,
1552
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
1553
+ std::shared_ptr<jsi::Value> callbackValue
1554
+ ,uint64_t rs_handle) {
1555
+
1556
+ // Convert the arguments from Rust, into jsi::Values.
1557
+ // We'll use the Bridging class to do this…
1558
+ auto js_handle = uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_handle);
1559
+
1560
+ // Now we are ready to call the callback.
1561
+ // We are already on the JS thread, because this `body` function was
1562
+ // invoked from the CallInvoker.
1563
+ try {
1564
+ // Getting the callback function
1565
+ auto cb = callbackValue->asObject(rt).asFunction(rt);
1566
+ auto uniffiResult = cb.call(rt, js_handle
1567
+ );
1568
+
1569
+
1570
+
1571
+
1572
+ } catch (const jsi::JSError &error) {
1573
+ std::cout << "Error in callback UniffiCallbackInterfaceFree: "
1574
+ << error.what() << std::endl;
1575
+ throw error;
1576
+ }
1577
+ }
1578
+
1579
+ static void callback(uint64_t rs_handle) {
1580
+ // If the runtime has shutdown, then there is no point in trying to
1581
+ // call into Javascript. BUT how do we tell if the runtime has shutdown?
1582
+ //
1583
+ // Answer: the module destructor calls into callback `cleanup` method,
1584
+ // which nulls out the rsLamda.
1585
+ //
1586
+ // If rsLamda is null, then there is no runtime to call into.
1587
+ if (rsLambda == nullptr) {
1588
+ // This only occurs when destructors are calling into Rust free/drop,
1589
+ // which causes the JS callback to be dropped.
1590
+ return;
1591
+ }
1592
+
1593
+ // The runtime, the actual callback jsi::funtion, and the callInvoker
1594
+ // are all in the lambda.
1595
+ rsLambda(
1596
+ rs_handle);
1597
+ }
1598
+
1599
+ [[maybe_unused]] static UniffiCallbackInterfaceFree
1600
+ makeCallbackFunction( // uniffi::bark::st::vtablecallbackinterfacebarklogger::vtablecallbackinterfacebarklogger::free
1601
+ jsi::Runtime &rt,
1602
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
1603
+ const jsi::Value &value) {
1604
+ if (rsLambda != nullptr) {
1605
+ // `makeCallbackFunction` is called in two circumstances:
1606
+ //
1607
+ // 1. at startup, when initializing callback interface vtables.
1608
+ // 2. when polling futures. This happens at least once per future that is
1609
+ // exposed to Javascript. We know that this is always the same function,
1610
+ // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
1611
+ //
1612
+ // We can therefore return the callback function without making anything
1613
+ // new if we've been initialized already.
1614
+ return callback;
1615
+ }
1616
+ auto callbackFunction = value.asObject(rt).asFunction(rt);
1617
+ auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
1618
+ rsLambda = [&rt, callInvoker, callbackValue](uint64_t rs_handle) {
1619
+ // We immediately make a lambda which will do the work of transforming the
1620
+ // arguments into JSI values and calling the callback.
1621
+ uniffi_runtime::UniffiCallFunc jsLambda = [
1622
+ callInvoker,
1623
+ callbackValue
1624
+ , rs_handle](jsi::Runtime &rt) mutable {
1625
+ body(rt, callInvoker, callbackValue
1626
+ , rs_handle);
1627
+ };
1628
+ // We'll then call that lambda from the callInvoker which will
1629
+ // look after calling it on the correct thread.
1630
+
1631
+ callInvoker->invokeNonBlocking(rt, jsLambda);
1632
+ };
1633
+ return callback;
1634
+ }
1635
+
1636
+ // This method is called from the destructor of NativeBark, which only happens
1637
+ // when the jsi::Runtime is being destroyed.
1638
+ static void cleanup() {
1639
+ // The lambda holds a reference to the the Runtime, so when this is nulled out,
1640
+ // then the pointer will no longer be left dangling.
1641
+ rsLambda = nullptr;
1642
+ }
1643
+ } // namespace uniffi::bark::st::vtablecallbackinterfacebarklogger::vtablecallbackinterfacebarklogger::free
1644
+
1505
1645
  // Callback function: uniffi::bark::st::vtablecallbackinterfacecustomonchainwalletcallbacks::vtablecallbackinterfacecustomonchainwalletcallbacks::free::UniffiCallbackInterfaceFree
1506
1646
  //
1507
1647
  // We have the following constraints:
@@ -2533,6 +2673,309 @@ template <> struct Bridging<UniffiForeignFutureCompleteVoid> {
2533
2673
  return jsi::Value::undefined();
2534
2674
  }
2535
2675
  };
2676
+ } // namespace uniffi::bark
2677
+ // Implementation of CallbackInterfaceClone for vtable field uniffi_clone in VTableCallbackInterfaceBarkLogger
2678
+
2679
+
2680
+ // Callback function: uniffi::bark::cb::callbackinterfaceclone::vtablecallbackinterfacebarklogger::UniffiCallbackInterfaceClone
2681
+ //
2682
+ // We have the following constraints:
2683
+ // - we need to pass a function pointer to Rust.
2684
+ // - we need a jsi::Runtime and jsi::Function to call into JS.
2685
+ // - function pointers can't store state, so we can't use a lamda.
2686
+ //
2687
+ // For this, we store a lambda as a global, as `rsLambda`. The `callback` function calls
2688
+ // the lambda, which itself calls the `body` which then calls into JS.
2689
+ //
2690
+ // We then give the `callback` function pointer to Rust which will call the lambda sometime in the
2691
+ // future.
2692
+ namespace uniffi::bark::cb::callbackinterfaceclone::vtablecallbackinterfacebarklogger {
2693
+ using namespace facebook;
2694
+
2695
+ // We need to store a lambda in a global so we can call it from
2696
+ // a function pointer. The function pointer is passed to Rust.
2697
+ static std::function<void(uint64_t, uint64_t*)> rsLambda = nullptr;
2698
+
2699
+ // This is the main body of the callback. It's called from the lambda,
2700
+ // which itself is called from the callback function which is passed to Rust.
2701
+ static void body(jsi::Runtime &rt,
2702
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
2703
+ std::shared_ptr<jsi::Value> callbackValue
2704
+ ,uint64_t rs_handle
2705
+ , uint64_t* uniffi_direct_return) {
2706
+
2707
+ // Convert the arguments from Rust, into jsi::Values.
2708
+ // We'll use the Bridging class to do this…
2709
+ auto js_handle = uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_handle);
2710
+
2711
+ // Now we are ready to call the callback.
2712
+ // We are already on the JS thread, because this `body` function was
2713
+ // invoked from the CallInvoker.
2714
+ try {
2715
+ // Getting the callback function
2716
+ auto cb = callbackValue->asObject(rt).asFunction(rt);
2717
+ auto uniffiResult = cb.call(rt, js_handle
2718
+ );
2719
+
2720
+
2721
+
2722
+
2723
+ // Write the direct return value back to the caller.
2724
+ if (uniffi_direct_return != nullptr) {
2725
+ *uniffi_direct_return = uniffi_jsi::Bridging<uint64_t>::fromJs(
2726
+ rt, callInvoker, uniffiResult
2727
+ );
2728
+ }
2729
+ } catch (const jsi::JSError &error) {
2730
+ std::cout << "Error in callback UniffiCallbackInterfaceClone: "
2731
+ << error.what() << std::endl;
2732
+ throw error;
2733
+ }
2734
+ }
2735
+
2736
+ static uint64_t callback(uint64_t rs_handle) {
2737
+ // If the runtime has shutdown, then there is no point in trying to
2738
+ // call into Javascript. BUT how do we tell if the runtime has shutdown?
2739
+ //
2740
+ // Answer: the module destructor calls into callback `cleanup` method,
2741
+ // which nulls out the rsLamda.
2742
+ //
2743
+ // If rsLamda is null, then there is no runtime to call into.
2744
+ if (rsLambda == nullptr) {
2745
+ // This only occurs when destructors are calling into Rust free/drop,
2746
+ // which causes the JS callback to be dropped.
2747
+ return 0;
2748
+ }
2749
+ uint64_t uniffi_result = 0;
2750
+
2751
+ // The runtime, the actual callback jsi::funtion, and the callInvoker
2752
+ // are all in the lambda.
2753
+ rsLambda(
2754
+ rs_handle,
2755
+ &uniffi_result);
2756
+ return uniffi_result;
2757
+ }
2758
+
2759
+ [[maybe_unused]] static UniffiCallbackInterfaceClone
2760
+ makeCallbackFunction( // uniffi::bark::cb::callbackinterfaceclone::vtablecallbackinterfacebarklogger
2761
+ jsi::Runtime &rt,
2762
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
2763
+ const jsi::Value &value) {
2764
+ if (rsLambda != nullptr) {
2765
+ // `makeCallbackFunction` is called in two circumstances:
2766
+ //
2767
+ // 1. at startup, when initializing callback interface vtables.
2768
+ // 2. when polling futures. This happens at least once per future that is
2769
+ // exposed to Javascript. We know that this is always the same function,
2770
+ // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
2771
+ //
2772
+ // We can therefore return the callback function without making anything
2773
+ // new if we've been initialized already.
2774
+ return callback;
2775
+ }
2776
+ auto callbackFunction = value.asObject(rt).asFunction(rt);
2777
+ auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
2778
+ rsLambda = [&rt, callInvoker, callbackValue](uint64_t rs_handle, uint64_t* uniffi_direct_return) {
2779
+ // We immediately make a lambda which will do the work of transforming the
2780
+ // arguments into JSI values and calling the callback.
2781
+ uniffi_runtime::UniffiCallFunc jsLambda = [
2782
+ callInvoker,
2783
+ callbackValue
2784
+ , rs_handle, uniffi_direct_return](jsi::Runtime &rt) mutable {
2785
+ body(rt, callInvoker, callbackValue
2786
+ , rs_handle, uniffi_direct_return);
2787
+ };
2788
+ // We'll then call that lambda from the callInvoker which will
2789
+ // look after calling it on the correct thread.
2790
+ callInvoker->invokeBlocking(rt, jsLambda);
2791
+ };
2792
+ return callback;
2793
+ }
2794
+
2795
+ // This method is called from the destructor of NativeBark, which only happens
2796
+ // when the jsi::Runtime is being destroyed.
2797
+ static void cleanup() {
2798
+ // The lambda holds a reference to the the Runtime, so when this is nulled out,
2799
+ // then the pointer will no longer be left dangling.
2800
+ rsLambda = nullptr;
2801
+ }
2802
+ } // namespace uniffi::bark::cb::callbackinterfaceclone::vtablecallbackinterfacebarklogger
2803
+ // Implementation of CallbackInterfaceBarkLoggerMethod0 for vtable field log in VTableCallbackInterfaceBarkLogger
2804
+
2805
+
2806
+ // Callback function: uniffi::bark::cb::callbackinterfacebarkloggermethod0::vtablecallbackinterfacebarklogger::UniffiCallbackInterfaceBarkLoggerMethod0
2807
+ //
2808
+ // We have the following constraints:
2809
+ // - we need to pass a function pointer to Rust.
2810
+ // - we need a jsi::Runtime and jsi::Function to call into JS.
2811
+ // - function pointers can't store state, so we can't use a lamda.
2812
+ //
2813
+ // For this, we store a lambda as a global, as `rsLambda`. The `callback` function calls
2814
+ // the lambda, which itself calls the `body` which then calls into JS.
2815
+ //
2816
+ // We then give the `callback` function pointer to Rust which will call the lambda sometime in the
2817
+ // future.
2818
+ namespace uniffi::bark::cb::callbackinterfacebarkloggermethod0::vtablecallbackinterfacebarklogger {
2819
+ using namespace facebook;
2820
+
2821
+ // We need to store a lambda in a global so we can call it from
2822
+ // a function pointer. The function pointer is passed to Rust.
2823
+ static std::function<void(uint64_t, RustBuffer, RustBuffer, RustBuffer, void *, RustCallStatus*)> rsLambda = nullptr;
2824
+
2825
+ // This is the main body of the callback. It's called from the lambda,
2826
+ // which itself is called from the callback function which is passed to Rust.
2827
+ static void body(jsi::Runtime &rt,
2828
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
2829
+ std::shared_ptr<jsi::Value> callbackValue
2830
+ ,uint64_t rs_uniffiHandle
2831
+ ,RustBuffer rs_level
2832
+ ,RustBuffer rs_target
2833
+ ,RustBuffer rs_message
2834
+ ,void * rs_uniffiOutReturn, RustCallStatus* uniffi_call_status) {
2835
+
2836
+ // Convert the arguments from Rust, into jsi::Values.
2837
+ // We'll use the Bridging class to do this…
2838
+ auto js_uniffiHandle = uniffi_jsi::Bridging<uint64_t>::toJs(rt, callInvoker, rs_uniffiHandle);
2839
+ auto js_level = uniffi::bark::Bridging<RustBuffer>::toJs(rt, callInvoker, rs_level);
2840
+ auto js_target = uniffi::bark::Bridging<RustBuffer>::toJs(rt, callInvoker, rs_target);
2841
+ auto js_message = uniffi::bark::Bridging<RustBuffer>::toJs(rt, callInvoker, rs_message);
2842
+
2843
+ // Now we are ready to call the callback.
2844
+ // We are already on the JS thread, because this `body` function was
2845
+ // invoked from the CallInvoker.
2846
+ try {
2847
+ // Getting the callback function
2848
+ auto cb = callbackValue->asObject(rt).asFunction(rt);
2849
+ auto uniffiResult = cb.call(rt, js_uniffiHandle, js_level, js_target, js_message
2850
+ );
2851
+
2852
+ // Now copy the result back from JS into the RustCallStatus object.
2853
+ uniffi::bark::Bridging<RustCallStatus>::copyFromJs(rt, callInvoker, uniffiResult, uniffi_call_status);
2854
+
2855
+ if (uniffi_call_status->code != UNIFFI_CALL_STATUS_OK) {
2856
+ // The JS callback finished abnormally, so we cannot retrieve the return value.
2857
+ return;
2858
+ }
2859
+
2860
+
2861
+ } catch (const jsi::JSError &error) {
2862
+ std::cout << "Error in callback UniffiCallbackInterfaceBarkLoggerMethod0: "
2863
+ << error.what() << std::endl;
2864
+ throw error;
2865
+ }
2866
+ }
2867
+
2868
+ static void callback(uint64_t rs_uniffiHandle, RustBuffer rs_level, RustBuffer rs_target, RustBuffer rs_message, void * rs_uniffiOutReturn, RustCallStatus* uniffi_call_status) {
2869
+ // If the runtime has shutdown, then there is no point in trying to
2870
+ // call into Javascript. BUT how do we tell if the runtime has shutdown?
2871
+ //
2872
+ // Answer: the module destructor calls into callback `cleanup` method,
2873
+ // which nulls out the rsLamda.
2874
+ //
2875
+ // If rsLamda is null, then there is no runtime to call into.
2876
+ if (rsLambda == nullptr) {
2877
+ // This only occurs when destructors are calling into Rust free/drop,
2878
+ // which causes the JS callback to be dropped.
2879
+ return;
2880
+ }
2881
+
2882
+ // The runtime, the actual callback jsi::funtion, and the callInvoker
2883
+ // are all in the lambda.
2884
+ rsLambda(
2885
+ rs_uniffiHandle,
2886
+ rs_level,
2887
+ rs_target,
2888
+ rs_message,
2889
+ rs_uniffiOutReturn, uniffi_call_status);
2890
+ }
2891
+
2892
+ [[maybe_unused]] static UniffiCallbackInterfaceBarkLoggerMethod0
2893
+ makeCallbackFunction( // uniffi::bark::cb::callbackinterfacebarkloggermethod0::vtablecallbackinterfacebarklogger
2894
+ jsi::Runtime &rt,
2895
+ std::shared_ptr<uniffi_runtime::UniffiCallInvoker> callInvoker,
2896
+ const jsi::Value &value) {
2897
+ if (rsLambda != nullptr) {
2898
+ // `makeCallbackFunction` is called in two circumstances:
2899
+ //
2900
+ // 1. at startup, when initializing callback interface vtables.
2901
+ // 2. when polling futures. This happens at least once per future that is
2902
+ // exposed to Javascript. We know that this is always the same function,
2903
+ // `uniffiFutureContinuationCallback` in `async-rust-calls.ts`.
2904
+ //
2905
+ // We can therefore return the callback function without making anything
2906
+ // new if we've been initialized already.
2907
+ return callback;
2908
+ }
2909
+ auto callbackFunction = value.asObject(rt).asFunction(rt);
2910
+ auto callbackValue = std::make_shared<jsi::Value>(rt, callbackFunction);
2911
+ rsLambda = [&rt, callInvoker, callbackValue](uint64_t rs_uniffiHandle, RustBuffer rs_level, RustBuffer rs_target, RustBuffer rs_message, void * rs_uniffiOutReturn, RustCallStatus* uniffi_call_status) {
2912
+ // We immediately make a lambda which will do the work of transforming the
2913
+ // arguments into JSI values and calling the callback.
2914
+ uniffi_runtime::UniffiCallFunc jsLambda = [
2915
+ callInvoker,
2916
+ callbackValue
2917
+ , rs_uniffiHandle
2918
+ , rs_level
2919
+ , rs_target
2920
+ , rs_message
2921
+ , rs_uniffiOutReturn, uniffi_call_status](jsi::Runtime &rt) mutable {
2922
+ body(rt, callInvoker, callbackValue
2923
+ , rs_uniffiHandle
2924
+ , rs_level
2925
+ , rs_target
2926
+ , rs_message
2927
+ , rs_uniffiOutReturn, uniffi_call_status);
2928
+ };
2929
+ // We'll then call that lambda from the callInvoker which will
2930
+ // look after calling it on the correct thread.
2931
+ callInvoker->invokeBlocking(rt, jsLambda);
2932
+ };
2933
+ return callback;
2934
+ }
2935
+
2936
+ // This method is called from the destructor of NativeBark, which only happens
2937
+ // when the jsi::Runtime is being destroyed.
2938
+ static void cleanup() {
2939
+ // The lambda holds a reference to the the Runtime, so when this is nulled out,
2940
+ // then the pointer will no longer be left dangling.
2941
+ rsLambda = nullptr;
2942
+ }
2943
+ } // namespace uniffi::bark::cb::callbackinterfacebarkloggermethod0::vtablecallbackinterfacebarklogger
2944
+ namespace uniffi::bark {
2945
+ using namespace facebook;
2946
+ using CallInvoker = uniffi_runtime::UniffiCallInvoker;
2947
+
2948
+ template <> struct Bridging<UniffiVTableCallbackInterfaceBarkLogger> {
2949
+ static UniffiVTableCallbackInterfaceBarkLogger fromJs(jsi::Runtime &rt,
2950
+ std::shared_ptr<CallInvoker> callInvoker,
2951
+ const jsi::Value &jsValue
2952
+ ) {
2953
+ // Check if the input is an object
2954
+ if (!jsValue.isObject()) {
2955
+ throw jsi::JSError(rt, "Expected an object for UniffiVTableCallbackInterfaceBarkLogger");
2956
+ }
2957
+
2958
+ // Get the object from the jsi::Value
2959
+ auto jsObject = jsValue.getObject(rt);
2960
+
2961
+ // Create the vtable struct
2962
+ UniffiVTableCallbackInterfaceBarkLogger rsObject;
2963
+
2964
+ // Create the vtable from the js callbacks.
2965
+ rsObject.uniffi_free = uniffi::bark::st::vtablecallbackinterfacebarklogger::vtablecallbackinterfacebarklogger::free::makeCallbackFunction(
2966
+ rt, callInvoker, jsObject.getProperty(rt, "uniffiFree")
2967
+ );
2968
+ rsObject.uniffi_clone = uniffi::bark::cb::callbackinterfaceclone::vtablecallbackinterfacebarklogger::makeCallbackFunction(
2969
+ rt, callInvoker, jsObject.getProperty(rt, "uniffiClone")
2970
+ );
2971
+ rsObject.log = uniffi::bark::cb::callbackinterfacebarkloggermethod0::vtablecallbackinterfacebarklogger::makeCallbackFunction(
2972
+ rt, callInvoker, jsObject.getProperty(rt, "log")
2973
+ );
2974
+
2975
+ return rsObject;
2976
+ }
2977
+ };
2978
+
2536
2979
  } // namespace uniffi::bark
2537
2980
  // Implementation of CallbackInterfaceClone for vtable field uniffi_clone in VTableCallbackInterfaceCustomOnchainWalletCallbacks
2538
2981
 
@@ -4226,7 +4669,7 @@ NativeBark::NativeBark(
4226
4669
  props["ubrn_uniffi_bark_ffi_fn_method_wallet_bolt11_invoice"] = jsi::Function::createFromHostFunction(
4227
4670
  rt,
4228
4671
  jsi::PropNameID::forAscii(rt, "ubrn_uniffi_bark_ffi_fn_method_wallet_bolt11_invoice"),
4229
- 2,
4672
+ 3,
4230
4673
  [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
4231
4674
  return this->cpp_uniffi_bark_ffi_fn_method_wallet_bolt11_invoice(rt, thisVal, args, count);
4232
4675
  }
@@ -4863,6 +5306,14 @@ NativeBark::NativeBark(
4863
5306
  return this->cpp_uniffi_bark_ffi_fn_method_wallet_vtxos(rt, thisVal, args, count);
4864
5307
  }
4865
5308
  );
5309
+ props["ubrn_uniffi_bark_ffi_fn_init_callback_vtable_barklogger"] = jsi::Function::createFromHostFunction(
5310
+ rt,
5311
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_bark_ffi_fn_init_callback_vtable_barklogger"),
5312
+ 1,
5313
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
5314
+ return this->cpp_uniffi_bark_ffi_fn_init_callback_vtable_barklogger(rt, thisVal, args, count);
5315
+ }
5316
+ );
4866
5317
  props["ubrn_uniffi_bark_ffi_fn_init_callback_vtable_customonchainwalletcallbacks"] = jsi::Function::createFromHostFunction(
4867
5318
  rt,
4868
5319
  jsi::PropNameID::forAscii(rt, "ubrn_uniffi_bark_ffi_fn_init_callback_vtable_customonchainwalletcallbacks"),
@@ -4887,6 +5338,14 @@ NativeBark::NativeBark(
4887
5338
  return this->cpp_uniffi_bark_ffi_fn_func_generate_mnemonic(rt, thisVal, args, count);
4888
5339
  }
4889
5340
  );
5341
+ props["ubrn_uniffi_bark_ffi_fn_func_set_logger"] = jsi::Function::createFromHostFunction(
5342
+ rt,
5343
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_bark_ffi_fn_func_set_logger"),
5344
+ 2,
5345
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
5346
+ return this->cpp_uniffi_bark_ffi_fn_func_set_logger(rt, thisVal, args, count);
5347
+ }
5348
+ );
4890
5349
  props["ubrn_uniffi_bark_ffi_fn_func_validate_ark_address"] = jsi::Function::createFromHostFunction(
4891
5350
  rt,
4892
5351
  jsi::PropNameID::forAscii(rt, "ubrn_uniffi_bark_ffi_fn_func_validate_ark_address"),
@@ -5303,6 +5762,14 @@ NativeBark::NativeBark(
5303
5762
  return this->cpp_uniffi_bark_ffi_checksum_func_generate_mnemonic(rt, thisVal, args, count);
5304
5763
  }
5305
5764
  );
5765
+ props["ubrn_uniffi_bark_ffi_checksum_func_set_logger"] = jsi::Function::createFromHostFunction(
5766
+ rt,
5767
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_bark_ffi_checksum_func_set_logger"),
5768
+ 0,
5769
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
5770
+ return this->cpp_uniffi_bark_ffi_checksum_func_set_logger(rt, thisVal, args, count);
5771
+ }
5772
+ );
5306
5773
  props["ubrn_uniffi_bark_ffi_checksum_func_validate_ark_address"] = jsi::Function::createFromHostFunction(
5307
5774
  rt,
5308
5775
  jsi::PropNameID::forAscii(rt, "ubrn_uniffi_bark_ffi_checksum_func_validate_ark_address"),
@@ -6111,6 +6578,14 @@ NativeBark::NativeBark(
6111
6578
  return this->cpp_uniffi_bark_ffi_checksum_constructor_wallet_open_with_onchain(rt, thisVal, args, count);
6112
6579
  }
6113
6580
  );
6581
+ props["ubrn_uniffi_bark_ffi_checksum_method_barklogger_log"] = jsi::Function::createFromHostFunction(
6582
+ rt,
6583
+ jsi::PropNameID::forAscii(rt, "ubrn_uniffi_bark_ffi_checksum_method_barklogger_log"),
6584
+ 0,
6585
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args, size_t count) -> jsi::Value {
6586
+ return this->cpp_uniffi_bark_ffi_checksum_method_barklogger_log(rt, thisVal, args, count);
6587
+ }
6588
+ );
6114
6589
  props["ubrn_uniffi_bark_ffi_checksum_method_customonchainwalletcallbacks_get_balance"] = jsi::Function::createFromHostFunction(
6115
6590
  rt,
6116
6591
  jsi::PropNameID::forAscii(rt, "ubrn_uniffi_bark_ffi_checksum_method_customonchainwalletcallbacks_get_balance"),
@@ -6255,7 +6730,9 @@ uniffi::bark::cb::rustfuturecontinuationcallback::cleanup();
6255
6730
  // Cleanup for callback function ForeignFutureDroppedCallback
6256
6731
  uniffi::bark::cb::foreignfuturedroppedcallback::cleanup();
6257
6732
  // Cleanup for "free" callback function CallbackInterfaceFree
6258
- uniffi::bark::st::vtablecallbackinterfacecustomonchainwalletcallbacks::vtablecallbackinterfacecustomonchainwalletcallbacks::free::cleanup();
6733
+ uniffi::bark::st::vtablecallbackinterfacebarklogger::vtablecallbackinterfacebarklogger::free::cleanup();uniffi::bark::st::vtablecallbackinterfacecustomonchainwalletcallbacks::vtablecallbackinterfacecustomonchainwalletcallbacks::free::cleanup();
6734
+ uniffi::bark::cb::callbackinterfaceclone::vtablecallbackinterfacebarklogger::cleanup();
6735
+ uniffi::bark::cb::callbackinterfacebarkloggermethod0::vtablecallbackinterfacebarklogger::cleanup();
6259
6736
  uniffi::bark::cb::callbackinterfaceclone::vtablecallbackinterfacecustomonchainwalletcallbacks::cleanup();
6260
6737
  uniffi::bark::cb::callbackinterfacecustomonchainwalletcallbacksmethod0::vtablecallbackinterfacecustomonchainwalletcallbacks::cleanup();
6261
6738
  uniffi::bark::cb::callbackinterfacecustomonchainwalletcallbacksmethod1::vtablecallbackinterfacecustomonchainwalletcallbacks::cleanup();
@@ -6509,7 +6986,7 @@ jsi::Value NativeBark::cpp_uniffi_bark_ffi_fn_method_wallet_board_amount(jsi::Ru
6509
6986
  return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker, value);
6510
6987
  }
6511
6988
  jsi::Value NativeBark::cpp_uniffi_bark_ffi_fn_method_wallet_bolt11_invoice(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
6512
- auto value = uniffi_bark_ffi_fn_method_wallet_bolt11_invoice(uniffi_jsi::Bridging</*handle*/ uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[1])
6989
+ auto value = uniffi_bark_ffi_fn_method_wallet_bolt11_invoice(uniffi_jsi::Bridging</*handle*/ uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[1]), uniffi::bark::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[2])
6513
6990
  );
6514
6991
 
6515
6992
 
@@ -7080,6 +7557,23 @@ jsi::Value NativeBark::cpp_uniffi_bark_ffi_fn_method_wallet_vtxos(jsi::Runtime&
7080
7557
 
7081
7558
  return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker, value);
7082
7559
  }
7560
+ jsi::Value NativeBark::cpp_uniffi_bark_ffi_fn_init_callback_vtable_barklogger(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
7561
+ auto vtableInstance =
7562
+ uniffi::bark::Bridging<UniffiVTableCallbackInterfaceBarkLogger>::fromJs(
7563
+ rt,
7564
+ callInvoker,
7565
+ args[0]
7566
+ );
7567
+
7568
+ std::lock_guard<std::mutex> lock(uniffi::bark::registry::vtableMutex);
7569
+ uniffi_bark_ffi_fn_init_callback_vtable_barklogger(
7570
+ uniffi::bark::registry::putTable(
7571
+ "UniffiVTableCallbackInterfaceBarkLogger",
7572
+ vtableInstance
7573
+ )
7574
+ );
7575
+ return jsi::Value::undefined();
7576
+ }
7083
7577
  jsi::Value NativeBark::cpp_uniffi_bark_ffi_fn_init_callback_vtable_customonchainwalletcallbacks(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
7084
7578
  auto vtableInstance =
7085
7579
  uniffi::bark::Bridging<UniffiVTableCallbackInterfaceCustomOnchainWalletCallbacks>::fromJs(
@@ -7116,6 +7610,16 @@ jsi::Value NativeBark::cpp_uniffi_bark_ffi_fn_func_generate_mnemonic(jsi::Runtim
7116
7610
 
7117
7611
  return uniffi::bark::Bridging<RustBuffer>::toJs(rt, callInvoker, value);
7118
7612
  }
7613
+ jsi::Value NativeBark::cpp_uniffi_bark_ffi_fn_func_set_logger(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
7614
+ RustCallStatus status = uniffi::bark::Bridging<RustCallStatus>::rustSuccess(rt);
7615
+ uniffi_bark_ffi_fn_func_set_logger(uniffi_jsi::Bridging<uint64_t>::fromJs(rt, callInvoker, args[0]), uniffi::bark::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[1]),
7616
+ &status
7617
+ );
7618
+ uniffi::bark::Bridging<RustCallStatus>::copyIntoJs(rt, callInvoker, status, args[count - 1]);
7619
+
7620
+
7621
+ return jsi::Value::undefined();
7622
+ }
7119
7623
  jsi::Value NativeBark::cpp_uniffi_bark_ffi_fn_func_validate_ark_address(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
7120
7624
  RustCallStatus status = uniffi::bark::Bridging<RustCallStatus>::rustSuccess(rt);
7121
7625
  auto value = uniffi_bark_ffi_fn_func_validate_ark_address(uniffi::bark::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]),
@@ -7520,6 +8024,13 @@ jsi::Value NativeBark::cpp_uniffi_bark_ffi_checksum_func_generate_mnemonic(jsi::
7520
8024
  );
7521
8025
 
7522
8026
 
8027
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
8028
+ }
8029
+ jsi::Value NativeBark::cpp_uniffi_bark_ffi_checksum_func_set_logger(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
8030
+ auto value = uniffi_bark_ffi_checksum_func_set_logger(
8031
+ );
8032
+
8033
+
7523
8034
  return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
7524
8035
  }
7525
8036
  jsi::Value NativeBark::cpp_uniffi_bark_ffi_checksum_func_validate_ark_address(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
@@ -8227,6 +8738,13 @@ jsi::Value NativeBark::cpp_uniffi_bark_ffi_checksum_constructor_wallet_open_with
8227
8738
  );
8228
8739
 
8229
8740
 
8741
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
8742
+ }
8743
+ jsi::Value NativeBark::cpp_uniffi_bark_ffi_checksum_method_barklogger_log(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {
8744
+ auto value = uniffi_bark_ffi_checksum_method_barklogger_log(
8745
+ );
8746
+
8747
+
8230
8748
  return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
8231
8749
  }
8232
8750
  jsi::Value NativeBark::cpp_uniffi_bark_ffi_checksum_method_customonchainwalletcallbacks_get_balance(jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args, size_t count) {