@iternio/react-native-auto-play 0.4.2 → 0.4.4
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/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlay.kt +89 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridCluster.kt +0 -1
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputManager.kt +20 -276
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/utils/ThreadUtil.kt +13 -6
- package/ios/hybrid/HybridAutoPlay.swift +47 -2
- package/ios/hybrid/HybridCluster.swift +0 -1
- package/ios/utils/VoiceInputManager.swift +40 -141
- package/lib/hooks/useAndroidAutoTelemetry.js +6 -1
- package/lib/index.d.ts +1 -5
- package/lib/index.js +1 -4
- package/lib/specs/AutoPlay.nitro.d.ts +29 -0
- package/nitro.json +0 -10
- package/nitrogen/generated/android/ReactNativeAutoPlay+autolinking.cmake +0 -2
- package/nitrogen/generated/android/ReactNativeAutoPlayOnLoad.cpp +0 -18
- package/nitrogen/generated/android/c++/JHybridAutoPlaySpec.cpp +43 -0
- package/nitrogen/generated/android/c++/JHybridAutoPlaySpec.hpp +4 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlaySpec.kt +17 -0
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.cpp +16 -41
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.hpp +126 -201
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Umbrella.hpp +0 -11
- package/nitrogen/generated/ios/ReactNativeAutoPlayAutolinking.mm +0 -8
- package/nitrogen/generated/ios/ReactNativeAutoPlayAutolinking.swift +0 -12
- package/nitrogen/generated/ios/c++/HybridAutoPlaySpecSwift.hpp +34 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +5 -5
- package/nitrogen/generated/ios/swift/{Func_void_VoiceInputResult.swift → Func_void_std__shared_ptr_ArrayBuffer_.swift} +10 -10
- package/nitrogen/generated/ios/swift/HybridAutoPlaySpec.swift +4 -0
- package/nitrogen/generated/ios/swift/HybridAutoPlaySpec_cxx.swift +82 -0
- package/nitrogen/generated/shared/c++/HybridAutoPlaySpec.cpp +4 -0
- package/nitrogen/generated/shared/c++/HybridAutoPlaySpec.hpp +5 -0
- package/package.json +1 -1
- package/src/hooks/useAndroidAutoTelemetry.ts +13 -8
- package/src/index.ts +1 -5
- package/src/specs/AutoPlay.nitro.ts +37 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridVoice.kt +0 -95
- package/ios/hybrid/HybridVoice.swift +0 -63
- package/lib/hybrid/HybridVoice.d.ts +0 -12
- package/lib/hybrid/HybridVoice.js +0 -13
- package/lib/specs/Voice.nitro.d.ts +0 -51
- package/lib/specs/Voice.nitro.js +0 -1
- package/lib/types/Voice.d.ts +0 -15
- package/lib/types/Voice.js +0 -1
- package/nitrogen/generated/android/c++/JFunc_void_VoiceInputChunk.hpp +0 -81
- package/nitrogen/generated/android/c++/JHybridVoiceSpec.cpp +0 -104
- package/nitrogen/generated/android/c++/JHybridVoiceSpec.hpp +0 -66
- package/nitrogen/generated/android/c++/JVoiceInputChunk.hpp +0 -64
- package/nitrogen/generated/android/c++/JVoiceInputResult.hpp +0 -64
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_VoiceInputChunk.kt +0 -80
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridVoiceSpec.kt +0 -72
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputChunk.kt +0 -41
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputResult.kt +0 -41
- package/nitrogen/generated/ios/c++/HybridVoiceSpecSwift.cpp +0 -11
- package/nitrogen/generated/ios/c++/HybridVoiceSpecSwift.hpp +0 -116
- package/nitrogen/generated/ios/swift/Func_void_VoiceInputChunk.swift +0 -46
- package/nitrogen/generated/ios/swift/HybridVoiceSpec.swift +0 -58
- package/nitrogen/generated/ios/swift/HybridVoiceSpec_cxx.swift +0 -227
- package/nitrogen/generated/ios/swift/VoiceInputChunk.swift +0 -60
- package/nitrogen/generated/ios/swift/VoiceInputResult.swift +0 -60
- package/nitrogen/generated/shared/c++/HybridVoiceSpec.cpp +0 -24
- package/nitrogen/generated/shared/c++/HybridVoiceSpec.hpp +0 -73
- package/nitrogen/generated/shared/c++/VoiceInputChunk.hpp +0 -89
- package/nitrogen/generated/shared/c++/VoiceInputResult.hpp +0 -89
- package/src/hybrid/HybridVoice.ts +0 -30
- package/src/specs/Voice.nitro.ts +0 -58
- package/src/types/Voice.ts +0 -17
|
@@ -1,46 +0,0 @@
|
|
|
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,58 +0,0 @@
|
|
|
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
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridVoiceSpec_cxx.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
|
-
* A class implementation that bridges HybridVoiceSpec over to C++.
|
|
12
|
-
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
13
|
-
*
|
|
14
|
-
* Also, some Swift types need to be bridged with special handling:
|
|
15
|
-
* - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
|
|
16
|
-
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
17
|
-
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
18
|
-
*/
|
|
19
|
-
open class HybridVoiceSpec_cxx {
|
|
20
|
-
/**
|
|
21
|
-
* The Swift <> C++ bridge's namespace (`margelo::nitro::swe::iternio::reactnativeautoplay::bridge::swift`)
|
|
22
|
-
* from `ReactNativeAutoPlay-Swift-Cxx-Bridge.hpp`.
|
|
23
|
-
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
24
|
-
*/
|
|
25
|
-
public typealias bridge = margelo.nitro.swe.iternio.reactnativeautoplay.bridge.swift
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Holds an instance of the `HybridVoiceSpec` Swift protocol.
|
|
29
|
-
*/
|
|
30
|
-
private var __implementation: any HybridVoiceSpec
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
34
|
-
*/
|
|
35
|
-
private var __cxxPart: bridge.std__weak_ptr_HybridVoiceSpec_
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Create a new `HybridVoiceSpec_cxx` that wraps the given `HybridVoiceSpec`.
|
|
39
|
-
* All properties and methods bridge to C++ types.
|
|
40
|
-
*/
|
|
41
|
-
public init(_ implementation: any HybridVoiceSpec) {
|
|
42
|
-
self.__implementation = implementation
|
|
43
|
-
self.__cxxPart = .init()
|
|
44
|
-
/* no base class */
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Get the actual `HybridVoiceSpec` instance this class wraps.
|
|
49
|
-
*/
|
|
50
|
-
@inline(__always)
|
|
51
|
-
public func getHybridVoiceSpec() -> any HybridVoiceSpec {
|
|
52
|
-
return __implementation
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Casts this instance to a retained unsafe raw pointer.
|
|
57
|
-
* This acquires one additional strong reference on the object!
|
|
58
|
-
*/
|
|
59
|
-
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
60
|
-
return Unmanaged.passRetained(self).toOpaque()
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Casts an unsafe pointer to a `HybridVoiceSpec_cxx`.
|
|
65
|
-
* The pointer has to be a retained opaque `Unmanaged<HybridVoiceSpec_cxx>`.
|
|
66
|
-
* This removes one strong reference from the object!
|
|
67
|
-
*/
|
|
68
|
-
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridVoiceSpec_cxx {
|
|
69
|
-
return Unmanaged<HybridVoiceSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
74
|
-
* The C++ part is a `std::shared_ptr<HybridVoiceSpec>`.
|
|
75
|
-
*/
|
|
76
|
-
public func getCxxPart() -> bridge.std__shared_ptr_HybridVoiceSpec_ {
|
|
77
|
-
let cachedCxxPart = self.__cxxPart.lock()
|
|
78
|
-
if Bool(fromCxx: cachedCxxPart) {
|
|
79
|
-
return cachedCxxPart
|
|
80
|
-
} else {
|
|
81
|
-
let newCxxPart = bridge.create_std__shared_ptr_HybridVoiceSpec_(self.toUnsafe())
|
|
82
|
-
__cxxPart = bridge.weakify_std__shared_ptr_HybridVoiceSpec_(newCxxPart)
|
|
83
|
-
return newCxxPart
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Get the memory size of the Swift class (plus size of any other allocations)
|
|
91
|
-
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
|
92
|
-
*/
|
|
93
|
-
@inline(__always)
|
|
94
|
-
public var memorySize: Int {
|
|
95
|
-
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Compares this object with the given [other] object for reference equality.
|
|
100
|
-
*/
|
|
101
|
-
@inline(__always)
|
|
102
|
-
public func equals(other: HybridVoiceSpec_cxx) -> Bool {
|
|
103
|
-
return self.__implementation === other.__implementation
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Call dispose() on the Swift class.
|
|
108
|
-
* This _may_ be called manually from JS.
|
|
109
|
-
*/
|
|
110
|
-
@inline(__always)
|
|
111
|
-
public func dispose() {
|
|
112
|
-
self.__implementation.dispose()
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Call toString() on the Swift class.
|
|
117
|
-
*/
|
|
118
|
-
@inline(__always)
|
|
119
|
-
public func toString() -> String {
|
|
120
|
-
return self.__implementation.toString()
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Properties
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
// Methods
|
|
127
|
-
@inline(__always)
|
|
128
|
-
public final func hasVoiceInputPermission() -> bridge.Result_bool_ {
|
|
129
|
-
do {
|
|
130
|
-
let __result = try self.__implementation.hasVoiceInputPermission()
|
|
131
|
-
let __resultCpp = __result
|
|
132
|
-
return bridge.create_Result_bool_(__resultCpp)
|
|
133
|
-
} catch (let __error) {
|
|
134
|
-
let __exceptionPtr = __error.toCpp()
|
|
135
|
-
return bridge.create_Result_bool_(__exceptionPtr)
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
@inline(__always)
|
|
140
|
-
public final func requestVoiceInputPermission() -> bridge.Result_std__shared_ptr_Promise_bool___ {
|
|
141
|
-
do {
|
|
142
|
-
let __result = try self.__implementation.requestVoiceInputPermission()
|
|
143
|
-
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_bool__ in
|
|
144
|
-
let __promise = bridge.create_std__shared_ptr_Promise_bool__()
|
|
145
|
-
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_bool__(__promise)
|
|
146
|
-
__result
|
|
147
|
-
.then({ __result in __promiseHolder.resolve(__result) })
|
|
148
|
-
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
149
|
-
return __promise
|
|
150
|
-
}()
|
|
151
|
-
return bridge.create_Result_std__shared_ptr_Promise_bool___(__resultCpp)
|
|
152
|
-
} catch (let __error) {
|
|
153
|
-
let __exceptionPtr = __error.toCpp()
|
|
154
|
-
return bridge.create_Result_std__shared_ptr_Promise_bool___(__exceptionPtr)
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
@inline(__always)
|
|
159
|
-
public final func startVoiceInput(silenceThresholdMs: bridge.std__optional_double_, maxDurationMs: bridge.std__optional_double_, listeningText: bridge.std__optional_std__string_, preferSpeechToText: bridge.std__optional_bool_, onChunk: bridge.std__optional_std__function_void_const_VoiceInputChunk_____chunk______) -> bridge.Result_std__shared_ptr_Promise_VoiceInputResult___ {
|
|
160
|
-
do {
|
|
161
|
-
let __result = try self.__implementation.startVoiceInput(silenceThresholdMs: { () -> Double? in
|
|
162
|
-
if bridge.has_value_std__optional_double_(silenceThresholdMs) {
|
|
163
|
-
let __unwrapped = bridge.get_std__optional_double_(silenceThresholdMs)
|
|
164
|
-
return __unwrapped
|
|
165
|
-
} else {
|
|
166
|
-
return nil
|
|
167
|
-
}
|
|
168
|
-
}(), maxDurationMs: { () -> Double? in
|
|
169
|
-
if bridge.has_value_std__optional_double_(maxDurationMs) {
|
|
170
|
-
let __unwrapped = bridge.get_std__optional_double_(maxDurationMs)
|
|
171
|
-
return __unwrapped
|
|
172
|
-
} else {
|
|
173
|
-
return nil
|
|
174
|
-
}
|
|
175
|
-
}(), listeningText: { () -> String? in
|
|
176
|
-
if bridge.has_value_std__optional_std__string_(listeningText) {
|
|
177
|
-
let __unwrapped = bridge.get_std__optional_std__string_(listeningText)
|
|
178
|
-
return String(__unwrapped)
|
|
179
|
-
} else {
|
|
180
|
-
return nil
|
|
181
|
-
}
|
|
182
|
-
}(), preferSpeechToText: { () -> Bool? in
|
|
183
|
-
if bridge.has_value_std__optional_bool_(preferSpeechToText) {
|
|
184
|
-
let __unwrapped = bridge.get_std__optional_bool_(preferSpeechToText)
|
|
185
|
-
return __unwrapped
|
|
186
|
-
} else {
|
|
187
|
-
return nil
|
|
188
|
-
}
|
|
189
|
-
}(), onChunk: { () -> ((_ chunk: VoiceInputChunk) -> Void)? in
|
|
190
|
-
if bridge.has_value_std__optional_std__function_void_const_VoiceInputChunk_____chunk______(onChunk) {
|
|
191
|
-
let __unwrapped = bridge.get_std__optional_std__function_void_const_VoiceInputChunk_____chunk______(onChunk)
|
|
192
|
-
return { () -> (VoiceInputChunk) -> Void in
|
|
193
|
-
let __wrappedFunction = bridge.wrap_Func_void_VoiceInputChunk(__unwrapped)
|
|
194
|
-
return { (__chunk: VoiceInputChunk) -> Void in
|
|
195
|
-
__wrappedFunction.call(__chunk)
|
|
196
|
-
}
|
|
197
|
-
}()
|
|
198
|
-
} else {
|
|
199
|
-
return nil
|
|
200
|
-
}
|
|
201
|
-
}())
|
|
202
|
-
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_VoiceInputResult__ in
|
|
203
|
-
let __promise = bridge.create_std__shared_ptr_Promise_VoiceInputResult__()
|
|
204
|
-
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_VoiceInputResult__(__promise)
|
|
205
|
-
__result
|
|
206
|
-
.then({ __result in __promiseHolder.resolve(__result) })
|
|
207
|
-
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
208
|
-
return __promise
|
|
209
|
-
}()
|
|
210
|
-
return bridge.create_Result_std__shared_ptr_Promise_VoiceInputResult___(__resultCpp)
|
|
211
|
-
} catch (let __error) {
|
|
212
|
-
let __exceptionPtr = __error.toCpp()
|
|
213
|
-
return bridge.create_Result_std__shared_ptr_Promise_VoiceInputResult___(__exceptionPtr)
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
@inline(__always)
|
|
218
|
-
public final func stopVoiceInput() -> bridge.Result_void_ {
|
|
219
|
-
do {
|
|
220
|
-
try self.__implementation.stopVoiceInput()
|
|
221
|
-
return bridge.create_Result_void_()
|
|
222
|
-
} catch (let __error) {
|
|
223
|
-
let __exceptionPtr = __error.toCpp()
|
|
224
|
-
return bridge.create_Result_void_(__exceptionPtr)
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// 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
|
-
* Represents an instance of `VoiceInputChunk`, backed by a C++ struct.
|
|
12
|
-
*/
|
|
13
|
-
public typealias VoiceInputChunk = margelo.nitro.swe.iternio.reactnativeautoplay.VoiceInputChunk
|
|
14
|
-
|
|
15
|
-
public extension VoiceInputChunk {
|
|
16
|
-
private typealias bridge = margelo.nitro.swe.iternio.reactnativeautoplay.bridge.swift
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Create a new instance of `VoiceInputChunk`.
|
|
20
|
-
*/
|
|
21
|
-
init(partial: String?, audio: ArrayBuffer?) {
|
|
22
|
-
self.init({ () -> bridge.std__optional_std__string_ in
|
|
23
|
-
if let __unwrappedValue = partial {
|
|
24
|
-
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
25
|
-
} else {
|
|
26
|
-
return .init()
|
|
27
|
-
}
|
|
28
|
-
}(), { () -> bridge.std__optional_std__shared_ptr_ArrayBuffer__ in
|
|
29
|
-
if let __unwrappedValue = audio {
|
|
30
|
-
return bridge.create_std__optional_std__shared_ptr_ArrayBuffer__(__unwrappedValue.getArrayBuffer())
|
|
31
|
-
} else {
|
|
32
|
-
return .init()
|
|
33
|
-
}
|
|
34
|
-
}())
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
@inline(__always)
|
|
38
|
-
var partial: String? {
|
|
39
|
-
return { () -> String? in
|
|
40
|
-
if bridge.has_value_std__optional_std__string_(self.__partial) {
|
|
41
|
-
let __unwrapped = bridge.get_std__optional_std__string_(self.__partial)
|
|
42
|
-
return String(__unwrapped)
|
|
43
|
-
} else {
|
|
44
|
-
return nil
|
|
45
|
-
}
|
|
46
|
-
}()
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@inline(__always)
|
|
50
|
-
var audio: ArrayBuffer? {
|
|
51
|
-
return { () -> ArrayBuffer? in
|
|
52
|
-
if bridge.has_value_std__optional_std__shared_ptr_ArrayBuffer__(self.__audio) {
|
|
53
|
-
let __unwrapped = bridge.get_std__optional_std__shared_ptr_ArrayBuffer__(self.__audio)
|
|
54
|
-
return ArrayBuffer(__unwrapped)
|
|
55
|
-
} else {
|
|
56
|
-
return nil
|
|
57
|
-
}
|
|
58
|
-
}()
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// VoiceInputResult.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
|
-
* Represents an instance of `VoiceInputResult`, backed by a C++ struct.
|
|
12
|
-
*/
|
|
13
|
-
public typealias VoiceInputResult = margelo.nitro.swe.iternio.reactnativeautoplay.VoiceInputResult
|
|
14
|
-
|
|
15
|
-
public extension VoiceInputResult {
|
|
16
|
-
private typealias bridge = margelo.nitro.swe.iternio.reactnativeautoplay.bridge.swift
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Create a new instance of `VoiceInputResult`.
|
|
20
|
-
*/
|
|
21
|
-
init(transcription: String?, audio: ArrayBuffer?) {
|
|
22
|
-
self.init({ () -> bridge.std__optional_std__string_ in
|
|
23
|
-
if let __unwrappedValue = transcription {
|
|
24
|
-
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
25
|
-
} else {
|
|
26
|
-
return .init()
|
|
27
|
-
}
|
|
28
|
-
}(), { () -> bridge.std__optional_std__shared_ptr_ArrayBuffer__ in
|
|
29
|
-
if let __unwrappedValue = audio {
|
|
30
|
-
return bridge.create_std__optional_std__shared_ptr_ArrayBuffer__(__unwrappedValue.getArrayBuffer())
|
|
31
|
-
} else {
|
|
32
|
-
return .init()
|
|
33
|
-
}
|
|
34
|
-
}())
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
@inline(__always)
|
|
38
|
-
var transcription: String? {
|
|
39
|
-
return { () -> String? in
|
|
40
|
-
if bridge.has_value_std__optional_std__string_(self.__transcription) {
|
|
41
|
-
let __unwrapped = bridge.get_std__optional_std__string_(self.__transcription)
|
|
42
|
-
return String(__unwrapped)
|
|
43
|
-
} else {
|
|
44
|
-
return nil
|
|
45
|
-
}
|
|
46
|
-
}()
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@inline(__always)
|
|
50
|
-
var audio: ArrayBuffer? {
|
|
51
|
-
return { () -> ArrayBuffer? in
|
|
52
|
-
if bridge.has_value_std__optional_std__shared_ptr_ArrayBuffer__(self.__audio) {
|
|
53
|
-
let __unwrapped = bridge.get_std__optional_std__shared_ptr_ArrayBuffer__(self.__audio)
|
|
54
|
-
return ArrayBuffer(__unwrapped)
|
|
55
|
-
} else {
|
|
56
|
-
return nil
|
|
57
|
-
}
|
|
58
|
-
}()
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridVoiceSpec.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 "HybridVoiceSpec.hpp"
|
|
9
|
-
|
|
10
|
-
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
11
|
-
|
|
12
|
-
void HybridVoiceSpec::loadHybridMethods() {
|
|
13
|
-
// load base methods/properties
|
|
14
|
-
HybridObject::loadHybridMethods();
|
|
15
|
-
// load custom methods/properties
|
|
16
|
-
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
-
prototype.registerHybridMethod("hasVoiceInputPermission", &HybridVoiceSpec::hasVoiceInputPermission);
|
|
18
|
-
prototype.registerHybridMethod("requestVoiceInputPermission", &HybridVoiceSpec::requestVoiceInputPermission);
|
|
19
|
-
prototype.registerHybridMethod("startVoiceInput", &HybridVoiceSpec::startVoiceInput);
|
|
20
|
-
prototype.registerHybridMethod("stopVoiceInput", &HybridVoiceSpec::stopVoiceInput);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
} // namespace margelo::nitro::swe::iternio::reactnativeautoplay
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// HybridVoiceSpec.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
|
-
#if __has_include(<NitroModules/HybridObject.hpp>)
|
|
11
|
-
#include <NitroModules/HybridObject.hpp>
|
|
12
|
-
#else
|
|
13
|
-
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
-
#endif
|
|
15
|
-
|
|
16
|
-
// Forward declaration of `VoiceInputResult` to properly resolve imports.
|
|
17
|
-
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct VoiceInputResult; }
|
|
18
|
-
// Forward declaration of `VoiceInputChunk` to properly resolve imports.
|
|
19
|
-
namespace margelo::nitro::swe::iternio::reactnativeautoplay { struct VoiceInputChunk; }
|
|
20
|
-
|
|
21
|
-
#include <NitroModules/Promise.hpp>
|
|
22
|
-
#include "VoiceInputResult.hpp"
|
|
23
|
-
#include <optional>
|
|
24
|
-
#include <string>
|
|
25
|
-
#include "VoiceInputChunk.hpp"
|
|
26
|
-
#include <functional>
|
|
27
|
-
|
|
28
|
-
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
29
|
-
|
|
30
|
-
using namespace margelo::nitro;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* An abstract base class for `Voice`
|
|
34
|
-
* Inherit this class to create instances of `HybridVoiceSpec` in C++.
|
|
35
|
-
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
36
|
-
* @example
|
|
37
|
-
* ```cpp
|
|
38
|
-
* class HybridVoice: public HybridVoiceSpec {
|
|
39
|
-
* public:
|
|
40
|
-
* HybridVoice(...): HybridObject(TAG) { ... }
|
|
41
|
-
* // ...
|
|
42
|
-
* };
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
class HybridVoiceSpec: public virtual HybridObject {
|
|
46
|
-
public:
|
|
47
|
-
// Constructor
|
|
48
|
-
explicit HybridVoiceSpec(): HybridObject(TAG) { }
|
|
49
|
-
|
|
50
|
-
// Destructor
|
|
51
|
-
~HybridVoiceSpec() override = default;
|
|
52
|
-
|
|
53
|
-
public:
|
|
54
|
-
// Properties
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
public:
|
|
58
|
-
// Methods
|
|
59
|
-
virtual bool hasVoiceInputPermission() = 0;
|
|
60
|
-
virtual std::shared_ptr<Promise<bool>> requestVoiceInputPermission() = 0;
|
|
61
|
-
virtual 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) = 0;
|
|
62
|
-
virtual void stopVoiceInput() = 0;
|
|
63
|
-
|
|
64
|
-
protected:
|
|
65
|
-
// Hybrid Setup
|
|
66
|
-
void loadHybridMethods() override;
|
|
67
|
-
|
|
68
|
-
protected:
|
|
69
|
-
// Tag for logging
|
|
70
|
-
static constexpr auto TAG = "Voice";
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
} // namespace margelo::nitro::swe::iternio::reactnativeautoplay
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
///
|
|
2
|
-
/// VoiceInputChunk.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
|
-
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
-
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
-
#else
|
|
13
|
-
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
-
#endif
|
|
15
|
-
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
-
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
-
#else
|
|
18
|
-
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
-
#endif
|
|
20
|
-
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
-
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
-
#else
|
|
23
|
-
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
-
#endif
|
|
25
|
-
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
-
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
-
#else
|
|
28
|
-
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
-
#endif
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
#include <string>
|
|
34
|
-
#include <optional>
|
|
35
|
-
#include <NitroModules/ArrayBuffer.hpp>
|
|
36
|
-
|
|
37
|
-
namespace margelo::nitro::swe::iternio::reactnativeautoplay {
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* A struct which can be represented as a JavaScript object (VoiceInputChunk).
|
|
41
|
-
*/
|
|
42
|
-
struct VoiceInputChunk final {
|
|
43
|
-
public:
|
|
44
|
-
std::optional<std::string> partial SWIFT_PRIVATE;
|
|
45
|
-
std::optional<std::shared_ptr<ArrayBuffer>> audio SWIFT_PRIVATE;
|
|
46
|
-
|
|
47
|
-
public:
|
|
48
|
-
VoiceInputChunk() = default;
|
|
49
|
-
explicit VoiceInputChunk(std::optional<std::string> partial, std::optional<std::shared_ptr<ArrayBuffer>> audio): partial(partial), audio(audio) {}
|
|
50
|
-
|
|
51
|
-
public:
|
|
52
|
-
friend bool operator==(const VoiceInputChunk& lhs, const VoiceInputChunk& rhs) = default;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
} // namespace margelo::nitro::swe::iternio::reactnativeautoplay
|
|
56
|
-
|
|
57
|
-
namespace margelo::nitro {
|
|
58
|
-
|
|
59
|
-
// C++ VoiceInputChunk <> JS VoiceInputChunk (object)
|
|
60
|
-
template <>
|
|
61
|
-
struct JSIConverter<margelo::nitro::swe::iternio::reactnativeautoplay::VoiceInputChunk> final {
|
|
62
|
-
static inline margelo::nitro::swe::iternio::reactnativeautoplay::VoiceInputChunk fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
63
|
-
jsi::Object obj = arg.asObject(runtime);
|
|
64
|
-
return margelo::nitro::swe::iternio::reactnativeautoplay::VoiceInputChunk(
|
|
65
|
-
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "partial"))),
|
|
66
|
-
JSIConverter<std::optional<std::shared_ptr<ArrayBuffer>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "audio")))
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::swe::iternio::reactnativeautoplay::VoiceInputChunk& arg) {
|
|
70
|
-
jsi::Object obj(runtime);
|
|
71
|
-
obj.setProperty(runtime, PropNameIDCache::get(runtime, "partial"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.partial));
|
|
72
|
-
obj.setProperty(runtime, PropNameIDCache::get(runtime, "audio"), JSIConverter<std::optional<std::shared_ptr<ArrayBuffer>>>::toJSI(runtime, arg.audio));
|
|
73
|
-
return obj;
|
|
74
|
-
}
|
|
75
|
-
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
76
|
-
if (!value.isObject()) {
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
jsi::Object obj = value.getObject(runtime);
|
|
80
|
-
if (!nitro::isPlainObject(runtime, obj)) {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "partial")))) return false;
|
|
84
|
-
if (!JSIConverter<std::optional<std::shared_ptr<ArrayBuffer>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "audio")))) return false;
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
} // namespace margelo::nitro
|