@iternio/react-native-auto-play 0.4.1 → 0.4.2

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 (60) hide show
  1. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlay.kt +0 -89
  2. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridVoice.kt +95 -0
  3. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputManager.kt +276 -20
  4. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/utils/ThreadUtil.kt +6 -13
  5. package/ios/hybrid/HybridAutoPlay.swift +2 -47
  6. package/ios/hybrid/HybridVoice.swift +63 -0
  7. package/ios/utils/VoiceInputManager.swift +141 -40
  8. package/lib/hybrid/HybridVoice.d.ts +12 -0
  9. package/lib/hybrid/HybridVoice.js +13 -0
  10. package/lib/index.d.ts +3 -0
  11. package/lib/index.js +2 -0
  12. package/lib/specs/AutoPlay.nitro.d.ts +0 -29
  13. package/lib/specs/Voice.nitro.d.ts +51 -0
  14. package/lib/specs/Voice.nitro.js +1 -0
  15. package/lib/types/Voice.d.ts +15 -0
  16. package/lib/types/Voice.js +1 -0
  17. package/nitro.json +10 -0
  18. package/nitrogen/generated/android/ReactNativeAutoPlay+autolinking.cmake +2 -0
  19. package/nitrogen/generated/android/ReactNativeAutoPlayOnLoad.cpp +18 -0
  20. package/nitrogen/generated/android/c++/JFunc_void_VoiceInputChunk.hpp +81 -0
  21. package/nitrogen/generated/android/c++/JHybridAutoPlaySpec.cpp +0 -43
  22. package/nitrogen/generated/android/c++/JHybridAutoPlaySpec.hpp +0 -4
  23. package/nitrogen/generated/android/c++/JHybridVoiceSpec.cpp +104 -0
  24. package/nitrogen/generated/android/c++/JHybridVoiceSpec.hpp +66 -0
  25. package/nitrogen/generated/android/c++/JVoiceInputChunk.hpp +64 -0
  26. package/nitrogen/generated/android/c++/JVoiceInputResult.hpp +64 -0
  27. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_VoiceInputChunk.kt +80 -0
  28. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlaySpec.kt +0 -17
  29. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridVoiceSpec.kt +72 -0
  30. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputChunk.kt +41 -0
  31. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputResult.kt +41 -0
  32. package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.cpp +41 -16
  33. package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.hpp +201 -126
  34. package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Umbrella.hpp +11 -0
  35. package/nitrogen/generated/ios/ReactNativeAutoPlayAutolinking.mm +8 -0
  36. package/nitrogen/generated/ios/ReactNativeAutoPlayAutolinking.swift +12 -0
  37. package/nitrogen/generated/ios/c++/HybridAutoPlaySpecSwift.hpp +0 -34
  38. package/nitrogen/generated/ios/c++/HybridVoiceSpecSwift.cpp +11 -0
  39. package/nitrogen/generated/ios/c++/HybridVoiceSpecSwift.hpp +116 -0
  40. package/nitrogen/generated/ios/swift/Func_void_VoiceInputChunk.swift +46 -0
  41. package/nitrogen/generated/ios/swift/{Func_void_std__shared_ptr_ArrayBuffer_.swift → Func_void_VoiceInputResult.swift} +10 -10
  42. package/nitrogen/generated/ios/swift/Func_void_bool.swift +5 -5
  43. package/nitrogen/generated/ios/swift/HybridAutoPlaySpec.swift +0 -4
  44. package/nitrogen/generated/ios/swift/HybridAutoPlaySpec_cxx.swift +0 -82
  45. package/nitrogen/generated/ios/swift/HybridVoiceSpec.swift +58 -0
  46. package/nitrogen/generated/ios/swift/HybridVoiceSpec_cxx.swift +227 -0
  47. package/nitrogen/generated/ios/swift/VoiceInputChunk.swift +60 -0
  48. package/nitrogen/generated/ios/swift/VoiceInputResult.swift +60 -0
  49. package/nitrogen/generated/shared/c++/HybridAutoPlaySpec.cpp +0 -4
  50. package/nitrogen/generated/shared/c++/HybridAutoPlaySpec.hpp +0 -5
  51. package/nitrogen/generated/shared/c++/HybridVoiceSpec.cpp +24 -0
  52. package/nitrogen/generated/shared/c++/HybridVoiceSpec.hpp +73 -0
  53. package/nitrogen/generated/shared/c++/VoiceInputChunk.hpp +89 -0
  54. package/nitrogen/generated/shared/c++/VoiceInputResult.hpp +89 -0
  55. package/package.json +1 -1
  56. package/src/hybrid/HybridVoice.ts +30 -0
  57. package/src/index.ts +3 -0
  58. package/src/specs/AutoPlay.nitro.ts +0 -37
  59. package/src/specs/Voice.nitro.ts +58 -0
  60. package/src/types/Voice.ts +17 -0
@@ -18,8 +18,6 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class EventNa
18
18
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class VisibilityState; }
19
19
  // Forward declaration of `Location` to properly resolve imports.
20
20
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct Location; }
21
- // Forward declaration of `ArrayBufferHolder` to properly resolve imports.
22
- namespace NitroModules { class ArrayBufferHolder; }
23
21
  // Forward declaration of `SafeAreaInsets` to properly resolve imports.
24
22
  namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct SafeAreaInsets; }
25
23
  // Forward declaration of `NitroAction` to properly resolve imports.
@@ -46,8 +44,6 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay { enum class NitroBu
46
44
  #include "Location.hpp"
47
45
  #include <optional>
48
46
  #include <NitroModules/Promise.hpp>
49
- #include <NitroModules/ArrayBuffer.hpp>
50
- #include <NitroModules/ArrayBufferHolder.hpp>
51
47
  #include "SafeAreaInsets.hpp"
52
48
  #include "NitroAction.hpp"
53
49
  #include <vector>
@@ -134,36 +130,6 @@ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
134
130
  auto __value = std::move(__result.value());
135
131
  return __value;
136
132
  }
137
- inline bool hasVoiceInputPermission() override {
138
- auto __result = _swiftPart.hasVoiceInputPermission();
139
- if (__result.hasError()) [[unlikely]] {
140
- std::rethrow_exception(__result.error());
141
- }
142
- auto __value = std::move(__result.value());
143
- return __value;
144
- }
145
- inline std::shared_ptr<Promise<bool>> requestVoiceInputPermission() override {
146
- auto __result = _swiftPart.requestVoiceInputPermission();
147
- if (__result.hasError()) [[unlikely]] {
148
- std::rethrow_exception(__result.error());
149
- }
150
- auto __value = std::move(__result.value());
151
- return __value;
152
- }
153
- inline std::shared_ptr<Promise<std::shared_ptr<ArrayBuffer>>> startVoiceInput(std::optional<double> silenceThresholdMs, std::optional<double> maxDurationMs, const std::optional<std::string>& listeningText) override {
154
- auto __result = _swiftPart.startVoiceInput(silenceThresholdMs, maxDurationMs, listeningText);
155
- if (__result.hasError()) [[unlikely]] {
156
- std::rethrow_exception(__result.error());
157
- }
158
- auto __value = std::move(__result.value());
159
- return __value;
160
- }
161
- inline void stopVoiceInput() override {
162
- auto __result = _swiftPart.stopVoiceInput();
163
- if (__result.hasError()) [[unlikely]] {
164
- std::rethrow_exception(__result.error());
165
- }
166
- }
167
133
  inline std::shared_ptr<Promise<void>> setRootTemplate(const std::string& templateId) override {
168
134
  auto __result = _swiftPart.setRootTemplate(templateId);
169
135
  if (__result.hasError()) [[unlikely]] {
@@ -0,0 +1,11 @@
1
+ ///
2
+ /// HybridVoiceSpecSwift.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridVoiceSpecSwift.hpp"
9
+
10
+ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
11
+ } // namespace margelo::nitro::swe::iternio::reactnativeautoplay
@@ -0,0 +1,116 @@
1
+ ///
2
+ /// HybridVoiceSpecSwift.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include "HybridVoiceSpec.hpp"
11
+
12
+ // Forward declaration of `HybridVoiceSpec_cxx` to properly resolve imports.
13
+ namespace ReactNativeAutoPlay { class HybridVoiceSpec_cxx; }
14
+
15
+ // Forward declaration of `VoiceInputResult` to properly resolve imports.
16
+ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct VoiceInputResult; }
17
+ // Forward declaration of `ArrayBufferHolder` to properly resolve imports.
18
+ namespace NitroModules { class ArrayBufferHolder; }
19
+ // Forward declaration of `VoiceInputChunk` to properly resolve imports.
20
+ namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct VoiceInputChunk; }
21
+
22
+ #include <NitroModules/Promise.hpp>
23
+ #include "VoiceInputResult.hpp"
24
+ #include <string>
25
+ #include <optional>
26
+ #include <NitroModules/ArrayBuffer.hpp>
27
+ #include <NitroModules/ArrayBufferHolder.hpp>
28
+ #include "VoiceInputChunk.hpp"
29
+ #include <functional>
30
+
31
+ #include "ReactNativeAutoPlay-Swift-Cxx-Umbrella.hpp"
32
+
33
+ namespace margelo::nitro::swe::iternio::reactnativeautoplay {
34
+
35
+ /**
36
+ * The C++ part of HybridVoiceSpec_cxx.swift.
37
+ *
38
+ * HybridVoiceSpecSwift (C++) accesses HybridVoiceSpec_cxx (Swift), and might
39
+ * contain some additional bridging code for C++ <> Swift interop.
40
+ *
41
+ * Since this obviously introduces an overhead, I hope at some point in
42
+ * the future, HybridVoiceSpec_cxx can directly inherit from the C++ class HybridVoiceSpec
43
+ * to simplify the whole structure and memory management.
44
+ */
45
+ class HybridVoiceSpecSwift: public virtual HybridVoiceSpec {
46
+ public:
47
+ // Constructor from a Swift instance
48
+ explicit HybridVoiceSpecSwift(const ReactNativeAutoPlay::HybridVoiceSpec_cxx& swiftPart):
49
+ HybridObject(HybridVoiceSpec::TAG),
50
+ _swiftPart(swiftPart) { }
51
+
52
+ public:
53
+ // Get the Swift part
54
+ inline ReactNativeAutoPlay::HybridVoiceSpec_cxx& getSwiftPart() noexcept {
55
+ return _swiftPart;
56
+ }
57
+
58
+ public:
59
+ inline size_t getExternalMemorySize() noexcept override {
60
+ return _swiftPart.getMemorySize();
61
+ }
62
+ bool equals(const std::shared_ptr<HybridObject>& other) override {
63
+ if (auto otherCast = std::dynamic_pointer_cast<HybridVoiceSpecSwift>(other)) {
64
+ return _swiftPart.equals(otherCast->_swiftPart);
65
+ }
66
+ return false;
67
+ }
68
+ void dispose() noexcept override {
69
+ _swiftPart.dispose();
70
+ }
71
+ std::string toString() override {
72
+ return _swiftPart.toString();
73
+ }
74
+
75
+ public:
76
+ // Properties
77
+
78
+
79
+ public:
80
+ // Methods
81
+ inline bool hasVoiceInputPermission() override {
82
+ auto __result = _swiftPart.hasVoiceInputPermission();
83
+ if (__result.hasError()) [[unlikely]] {
84
+ std::rethrow_exception(__result.error());
85
+ }
86
+ auto __value = std::move(__result.value());
87
+ return __value;
88
+ }
89
+ inline std::shared_ptr<Promise<bool>> requestVoiceInputPermission() override {
90
+ auto __result = _swiftPart.requestVoiceInputPermission();
91
+ if (__result.hasError()) [[unlikely]] {
92
+ std::rethrow_exception(__result.error());
93
+ }
94
+ auto __value = std::move(__result.value());
95
+ return __value;
96
+ }
97
+ inline std::shared_ptr<Promise<VoiceInputResult>> startVoiceInput(std::optional<double> silenceThresholdMs, std::optional<double> maxDurationMs, const std::optional<std::string>& listeningText, std::optional<bool> preferSpeechToText, const std::optional<std::function<void(const VoiceInputChunk& /* chunk */)>>& onChunk) override {
98
+ auto __result = _swiftPart.startVoiceInput(silenceThresholdMs, maxDurationMs, listeningText, preferSpeechToText, onChunk);
99
+ if (__result.hasError()) [[unlikely]] {
100
+ std::rethrow_exception(__result.error());
101
+ }
102
+ auto __value = std::move(__result.value());
103
+ return __value;
104
+ }
105
+ inline void stopVoiceInput() override {
106
+ auto __result = _swiftPart.stopVoiceInput();
107
+ if (__result.hasError()) [[unlikely]] {
108
+ std::rethrow_exception(__result.error());
109
+ }
110
+ }
111
+
112
+ private:
113
+ ReactNativeAutoPlay::HybridVoiceSpec_cxx _swiftPart;
114
+ };
115
+
116
+ } // namespace margelo::nitro::swe::iternio::reactnativeautoplay
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_VoiceInputChunk.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `(_ chunk: VoiceInputChunk) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_VoiceInputChunk {
15
+ public typealias bridge = margelo.nitro.swe.iternio.reactnativeautoplay.bridge.swift
16
+
17
+ private let closure: (_ chunk: VoiceInputChunk) -> Void
18
+
19
+ public init(_ closure: @escaping (_ chunk: VoiceInputChunk) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(chunk: VoiceInputChunk) -> Void {
25
+ self.closure(chunk)
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_VoiceInputChunk`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_VoiceInputChunk>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_VoiceInputChunk {
44
+ return Unmanaged<Func_void_VoiceInputChunk>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -1,5 +1,5 @@
1
1
  ///
2
- /// Func_void_std__shared_ptr_ArrayBuffer_.swift
2
+ /// Func_void_VoiceInputResult.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
@@ -8,20 +8,20 @@
8
8
  import NitroModules
9
9
 
10
10
  /**
11
- * Wraps a Swift `(_ value: ArrayBuffer) -> Void` as a class.
11
+ * Wraps a Swift `(_ value: VoiceInputResult) -> Void` as a class.
12
12
  * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
13
  */
14
- public final class Func_void_std__shared_ptr_ArrayBuffer_ {
14
+ public final class Func_void_VoiceInputResult {
15
15
  public typealias bridge = margelo.nitro.swe.iternio.reactnativeautoplay.bridge.swift
16
16
 
17
- private let closure: (_ value: ArrayBuffer) -> Void
17
+ private let closure: (_ value: VoiceInputResult) -> Void
18
18
 
19
- public init(_ closure: @escaping (_ value: ArrayBuffer) -> Void) {
19
+ public init(_ closure: @escaping (_ value: VoiceInputResult) -> Void) {
20
20
  self.closure = closure
21
21
  }
22
22
 
23
23
  @inline(__always)
24
- public func call(value: ArrayBuffer) -> Void {
24
+ public func call(value: VoiceInputResult) -> Void {
25
25
  self.closure(value)
26
26
  }
27
27
 
@@ -35,12 +35,12 @@ public final class Func_void_std__shared_ptr_ArrayBuffer_ {
35
35
  }
36
36
 
37
37
  /**
38
- * Casts an unsafe pointer to a `Func_void_std__shared_ptr_ArrayBuffer_`.
39
- * The pointer has to be a retained opaque `Unmanaged<Func_void_std__shared_ptr_ArrayBuffer_>`.
38
+ * Casts an unsafe pointer to a `Func_void_VoiceInputResult`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_VoiceInputResult>`.
40
40
  * This removes one strong reference from the object!
41
41
  */
42
42
  @inline(__always)
43
- public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__shared_ptr_ArrayBuffer_ {
44
- return Unmanaged<Func_void_std__shared_ptr_ArrayBuffer_>.fromOpaque(pointer).takeRetainedValue()
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_VoiceInputResult {
44
+ return Unmanaged<Func_void_VoiceInputResult>.fromOpaque(pointer).takeRetainedValue()
45
45
  }
46
46
  }
@@ -8,21 +8,21 @@
8
8
  import NitroModules
9
9
 
10
10
  /**
11
- * Wraps a Swift `(_ isPanningInterfaceVisible: Bool) -> Void` as a class.
11
+ * Wraps a Swift `(_ value: Bool) -> Void` as a class.
12
12
  * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
13
  */
14
14
  public final class Func_void_bool {
15
15
  public typealias bridge = margelo.nitro.swe.iternio.reactnativeautoplay.bridge.swift
16
16
 
17
- private let closure: (_ isPanningInterfaceVisible: Bool) -> Void
17
+ private let closure: (_ value: Bool) -> Void
18
18
 
19
- public init(_ closure: @escaping (_ isPanningInterfaceVisible: Bool) -> Void) {
19
+ public init(_ closure: @escaping (_ value: Bool) -> Void) {
20
20
  self.closure = closure
21
21
  }
22
22
 
23
23
  @inline(__always)
24
- public func call(isPanningInterfaceVisible: Bool) -> Void {
25
- self.closure(isPanningInterfaceVisible)
24
+ public func call(value: Bool) -> Void {
25
+ self.closure(value)
26
26
  }
27
27
 
28
28
  /**
@@ -16,10 +16,6 @@ public protocol HybridAutoPlaySpec_protocol: HybridObject {
16
16
  func addListener(eventType: EventName, callback: @escaping () -> Void) throws -> () -> Void
17
17
  func addListenerRenderState(moduleName: String, callback: @escaping (_ payload: VisibilityState) -> Void) throws -> () -> Void
18
18
  func addListenerVoiceInput(callback: @escaping (_ coordinates: Location?, _ query: String?) -> Void) throws -> () -> Void
19
- func hasVoiceInputPermission() throws -> Bool
20
- func requestVoiceInputPermission() throws -> Promise<Bool>
21
- func startVoiceInput(silenceThresholdMs: Double?, maxDurationMs: Double?, listeningText: String?) throws -> Promise<ArrayBuffer>
22
- func stopVoiceInput() throws -> Void
23
19
  func setRootTemplate(templateId: String) throws -> Promise<Void>
24
20
  func pushTemplate(templateId: String) throws -> Promise<Void>
25
21
  func popTemplate(animate: Bool?) throws -> Promise<Void>
@@ -196,88 +196,6 @@ open class HybridAutoPlaySpec_cxx {
196
196
  }
197
197
  }
198
198
 
199
- @inline(__always)
200
- public final func hasVoiceInputPermission() -> bridge.Result_bool_ {
201
- do {
202
- let __result = try self.__implementation.hasVoiceInputPermission()
203
- let __resultCpp = __result
204
- return bridge.create_Result_bool_(__resultCpp)
205
- } catch (let __error) {
206
- let __exceptionPtr = __error.toCpp()
207
- return bridge.create_Result_bool_(__exceptionPtr)
208
- }
209
- }
210
-
211
- @inline(__always)
212
- public final func requestVoiceInputPermission() -> bridge.Result_std__shared_ptr_Promise_bool___ {
213
- do {
214
- let __result = try self.__implementation.requestVoiceInputPermission()
215
- let __resultCpp = { () -> bridge.std__shared_ptr_Promise_bool__ in
216
- let __promise = bridge.create_std__shared_ptr_Promise_bool__()
217
- let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
218
- __result
219
- .then({ __result in __promiseHolder.resolve(__result) })
220
- .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
221
- return __promise
222
- }()
223
- return bridge.create_Result_std__shared_ptr_Promise_bool___(__resultCpp)
224
- } catch (let __error) {
225
- let __exceptionPtr = __error.toCpp()
226
- return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
227
- }
228
- }
229
-
230
- @inline(__always)
231
- public final func startVoiceInput(silenceThresholdMs: bridge.std__optional_double_, maxDurationMs: bridge.std__optional_double_, listeningText: bridge.std__optional_std__string_) -> bridge.Result_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer____ {
232
- do {
233
- let __result = try self.__implementation.startVoiceInput(silenceThresholdMs: { () -> Double? in
234
- if bridge.has_value_std__optional_double_(silenceThresholdMs) {
235
- let __unwrapped = bridge.get_std__optional_double_(silenceThresholdMs)
236
- return __unwrapped
237
- } else {
238
- return nil
239
- }
240
- }(), maxDurationMs: { () -> Double? in
241
- if bridge.has_value_std__optional_double_(maxDurationMs) {
242
- let __unwrapped = bridge.get_std__optional_double_(maxDurationMs)
243
- return __unwrapped
244
- } else {
245
- return nil
246
- }
247
- }(), listeningText: { () -> String? in
248
- if bridge.has_value_std__optional_std__string_(listeningText) {
249
- let __unwrapped = bridge.get_std__optional_std__string_(listeningText)
250
- return String(__unwrapped)
251
- } else {
252
- return nil
253
- }
254
- }())
255
- let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer___ in
256
- let __promise = bridge.create_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer___()
257
- let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer___(__promise)
258
- __result
259
- .then({ __result in __promiseHolder.resolve(__result.getArrayBuffer()) })
260
- .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
261
- return __promise
262
- }()
263
- return bridge.create_Result_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer____(__resultCpp)
264
- } catch (let __error) {
265
- let __exceptionPtr = __error.toCpp()
266
- return bridge.create_Result_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer____(__exceptionPtr)
267
- }
268
- }
269
-
270
- @inline(__always)
271
- public final func stopVoiceInput() -> bridge.Result_void_ {
272
- do {
273
- try self.__implementation.stopVoiceInput()
274
- return bridge.create_Result_void_()
275
- } catch (let __error) {
276
- let __exceptionPtr = __error.toCpp()
277
- return bridge.create_Result_void_(__exceptionPtr)
278
- }
279
- }
280
-
281
199
  @inline(__always)
282
200
  public final func setRootTemplate(templateId: std.string) -> bridge.Result_std__shared_ptr_Promise_void___ {
283
201
  do {
@@ -0,0 +1,58 @@
1
+ ///
2
+ /// HybridVoiceSpec.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /// See ``HybridVoiceSpec``
11
+ public protocol HybridVoiceSpec_protocol: HybridObject {
12
+ // Properties
13
+
14
+
15
+ // Methods
16
+ func hasVoiceInputPermission() throws -> Bool
17
+ func requestVoiceInputPermission() throws -> Promise<Bool>
18
+ func startVoiceInput(silenceThresholdMs: Double?, maxDurationMs: Double?, listeningText: String?, preferSpeechToText: Bool?, onChunk: ((_ chunk: VoiceInputChunk) -> Void)?) throws -> Promise<VoiceInputResult>
19
+ func stopVoiceInput() throws -> Void
20
+ }
21
+
22
+ public extension HybridVoiceSpec_protocol {
23
+ /// Default implementation of ``HybridObject.toString``
24
+ func toString() -> String {
25
+ return "[HybridObject Voice]"
26
+ }
27
+ }
28
+
29
+ /// See ``HybridVoiceSpec``
30
+ open class HybridVoiceSpec_base {
31
+ private weak var cxxWrapper: HybridVoiceSpec_cxx? = nil
32
+ public init() { }
33
+ public func getCxxWrapper() -> HybridVoiceSpec_cxx {
34
+ #if DEBUG
35
+ guard self is any HybridVoiceSpec else {
36
+ fatalError("`self` is not a `HybridVoiceSpec`! Did you accidentally inherit from `HybridVoiceSpec_base` instead of `HybridVoiceSpec`?")
37
+ }
38
+ #endif
39
+ if let cxxWrapper = self.cxxWrapper {
40
+ return cxxWrapper
41
+ } else {
42
+ let cxxWrapper = HybridVoiceSpec_cxx(self as! any HybridVoiceSpec)
43
+ self.cxxWrapper = cxxWrapper
44
+ return cxxWrapper
45
+ }
46
+ }
47
+ }
48
+
49
+ /**
50
+ * A Swift base-protocol representing the Voice HybridObject.
51
+ * Implement this protocol to create Swift-based instances of Voice.
52
+ * ```swift
53
+ * class HybridVoice : HybridVoiceSpec {
54
+ * // ...
55
+ * }
56
+ * ```
57
+ */
58
+ public typealias HybridVoiceSpec = HybridVoiceSpec_protocol & HybridVoiceSpec_base