@iternio/react-native-auto-play 0.4.8 → 0.4.11
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 +93 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputManager.kt +20 -286
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/utils/ThreadUtil.kt +13 -6
- package/ios/hybrid/HybridAutoPlay.swift +51 -2
- package/ios/utils/VoiceInputManager.swift +40 -144
- package/lib/index.d.ts +1 -3
- package/lib/index.js +1 -2
- package/lib/scenes/CarPlayDashboardScene.d.ts +1 -0
- package/lib/scenes/CarPlayDashboardScene.js +13 -7
- package/lib/specs/AutoPlay.nitro.d.ts +35 -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++/JActiveCarUxRestrictions.hpp +8 -8
- package/nitrogen/generated/android/c++/JGridTemplateConfig.hpp +16 -16
- package/nitrogen/generated/android/c++/JHybridAndroidAutoTelemetrySpec.cpp +4 -4
- package/nitrogen/generated/android/c++/JHybridAutoPlaySpec.cpp +52 -4
- package/nitrogen/generated/android/c++/JHybridAutoPlaySpec.hpp +5 -0
- package/nitrogen/generated/android/c++/JHybridClusterSpec.cpp +4 -4
- package/nitrogen/generated/android/c++/JHybridGridTemplateSpec.cpp +4 -4
- package/nitrogen/generated/android/c++/JHybridListTemplateSpec.cpp +4 -4
- package/nitrogen/generated/android/c++/JHybridMapTemplateSpec.cpp +15 -15
- package/nitrogen/generated/android/c++/JInformationTemplateConfig.hpp +16 -16
- package/nitrogen/generated/android/c++/JLaneGuidance.hpp +16 -16
- package/nitrogen/generated/android/c++/JListTemplateConfig.hpp +16 -16
- package/nitrogen/generated/android/c++/JMapTemplateConfig.hpp +16 -16
- package/nitrogen/generated/android/c++/JMessageTemplateConfig.hpp +16 -16
- package/nitrogen/generated/android/c++/JNitroAttributedString.hpp +8 -8
- package/nitrogen/generated/android/c++/JNitroBaseMapTemplateConfig.hpp +16 -16
- package/nitrogen/generated/android/c++/JNitroManeuver.cpp +4 -4
- package/nitrogen/generated/android/c++/JNitroManeuver.hpp +4 -4
- package/nitrogen/generated/android/c++/JNitroRoutingManeuver.hpp +16 -16
- package/nitrogen/generated/android/c++/JNitroSection.hpp +8 -8
- package/nitrogen/generated/android/c++/JPermissionRequestResult.hpp +16 -16
- package/nitrogen/generated/android/c++/JRouteChoice.hpp +32 -32
- package/nitrogen/generated/android/c++/JSearchTemplateConfig.hpp +8 -8
- package/nitrogen/generated/android/c++/JSignInTemplateConfig.hpp +16 -16
- package/nitrogen/generated/android/c++/JTripsConfig.hpp +8 -8
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/ActiveCarUxRestrictions.kt +19 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/AppFocusState.kt +15 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/AssetImage.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/AutoText.kt +17 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/BooleanTelemetryItem.kt +15 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Distance.kt +15 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/DurationWithTimeZone.kt +15 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/GlyphImage.kt +21 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/GoogleSignIn.kt +19 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/GoogleSignInAccount.kt +27 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/GridTemplateConfig.kt +33 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlaySpec.kt +21 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/ImageLane.kt +15 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/InformationTemplateConfig.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/InputSignIn.kt +27 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/LaneGuidance.kt +15 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/ListTemplateConfig.kt +33 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Location.kt +15 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/MapTemplateConfig.kt +51 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/MessageTemplateConfig.kt +37 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NavigationAlertAction.kt +17 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroAction.kt +27 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroAttributedString.kt +15 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroAttributedStringImage.kt +15 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroBaseMapTemplateConfig.kt +29 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroColor.kt +15 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroGridButton.kt +17 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroImage.kt +18 -8
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroLoadingManeuver.kt +17 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroManeuver.kt +18 -8
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroMapButton.kt +17 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroMessageManeuver.kt +19 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroNavigationAlert.kt +31 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroRoutingManeuver.kt +49 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroRow.kt +27 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroSection.kt +17 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NumericTelemetryItem.kt +15 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/PermissionRequestResult.kt +15 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/PinSignIn.kt +15 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Point.kt +15 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/PreferredImageLane.kt +19 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/QrSignIn.kt +15 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/RemoteImage.kt +17 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/RouteChoice.kt +21 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/SafeAreaInsets.kt +21 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/SearchTemplateConfig.kt +39 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/SignInTemplateConfig.kt +37 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/StringTelemetryItem.kt +15 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Telemetry.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/TravelEstimates.kt +19 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/TripConfig.kt +15 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/TripPoint.kt +19 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/TripPreviewTextConfiguration.kt +19 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/TripSelectorCallback.kt +13 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/TripsConfig.kt +15 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Variant_GlyphImage_AssetImage_RemoteImage.kt +18 -8
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Variant_PreferredImageLane_ImageLane.kt +16 -7
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Variant_QrSignIn_PinSignIn_InputSignIn_GoogleSignIn.kt +20 -9
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/VehicleTelemetryItem.kt +19 -0
- package/nitrogen/generated/ios/ReactNativeAutoPlay+autolinking.rb +2 -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 +42 -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 +5 -0
- package/nitrogen/generated/ios/swift/HybridAutoPlaySpec_cxx.swift +94 -0
- package/nitrogen/generated/ios/swift/NitroImage.swift +13 -0
- package/nitrogen/generated/ios/swift/NitroManeuver.swift +13 -0
- package/nitrogen/generated/ios/swift/Variant_GlyphImage_AssetImage_RemoteImage.swift +13 -0
- package/nitrogen/generated/ios/swift/Variant_PreferredImageLane_ImageLane.swift +12 -0
- package/nitrogen/generated/shared/c++/HybridAutoPlaySpec.cpp +5 -0
- package/nitrogen/generated/shared/c++/HybridAutoPlaySpec.hpp +6 -0
- package/package.json +2 -2
- package/src/index.ts +1 -3
- package/src/scenes/CarPlayDashboardScene.ts +18 -11
- package/src/specs/AutoPlay.nitro.ts +44 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridVoice.kt +0 -97
- package/ios/hybrid/HybridVoice.swift +0 -65
- package/lib/HybridAutoPlay.d.ts +0 -2
- package/lib/HybridAutoPlay.js +0 -2
- package/lib/components/OnAppearedChildRenderer.d.ts +0 -10
- package/lib/components/OnAppearedChildRenderer.js +0 -26
- package/lib/hooks/useIsAutoPlayFocused.d.ts +0 -7
- package/lib/hooks/useIsAutoPlayFocused.js +0 -20
- package/lib/hybrid/HybridVoice.d.ts +0 -52
- package/lib/hybrid/HybridVoice.js +0 -52
- package/lib/hybrid.d.ts +0 -2
- package/lib/hybrid.js +0 -2
- package/lib/specs/AutomotivePermissionRequestTemplate.d.ts +0 -11
- package/lib/specs/AutomotivePermissionRequestTemplate.js +0 -1
- package/lib/specs/AutomotivePermissionRequestTemplate.nitro.d.ts +0 -11
- package/lib/specs/AutomotivePermissionRequestTemplate.nitro.js +0 -1
- package/lib/specs/Voice.nitro.d.ts +0 -11
- package/lib/specs/Voice.nitro.js +0 -1
- package/lib/templates/AutomotivePermissionRequestTemplate.d.ts +0 -23
- package/lib/templates/AutomotivePermissionRequestTemplate.js +0 -18
- package/lib/types/Glyphmap.d.ts +0 -4105
- package/lib/types/Glyphmap.js +0 -4105
- package/lib/types/Voice.d.ts +0 -16
- 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 -234
- 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 -79
- package/src/specs/Voice.nitro.ts +0 -16
- package/src/types/Voice.ts +0 -18
package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridVoice.kt
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
package com.margelo.nitro.swe.iternio.reactnativeautoplay
|
|
2
|
-
|
|
3
|
-
import android.content.pm.PackageManager
|
|
4
|
-
import android.os.Build
|
|
5
|
-
import androidx.core.content.ContextCompat
|
|
6
|
-
import com.facebook.react.modules.core.PermissionAwareActivity
|
|
7
|
-
import com.facebook.react.modules.core.PermissionListener
|
|
8
|
-
import com.margelo.nitro.NitroModules
|
|
9
|
-
import com.margelo.nitro.core.Promise
|
|
10
|
-
import kotlinx.coroutines.suspendCancellableCoroutine
|
|
11
|
-
import kotlin.coroutines.resume
|
|
12
|
-
|
|
13
|
-
class HybridVoice : HybridVoiceSpec() {
|
|
14
|
-
@Volatile
|
|
15
|
-
private var voiceInputManager: VoiceInputManager? = null
|
|
16
|
-
|
|
17
|
-
override fun hasVoiceInputPermission(): Boolean {
|
|
18
|
-
return VoiceInputManager.hasVoiceInputPermission()
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
override fun requestVoiceInputPermission(): Promise<Boolean> {
|
|
22
|
-
return Promise.async {
|
|
23
|
-
if (hasVoiceInputPermission()) {
|
|
24
|
-
return@async true
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
val carContext = AndroidAutoSession.getRootContext()
|
|
28
|
-
|
|
29
|
-
if (carContext != null) {
|
|
30
|
-
suspendCancellableCoroutine { cont ->
|
|
31
|
-
carContext.requestPermissions(
|
|
32
|
-
listOf(android.Manifest.permission.RECORD_AUDIO)
|
|
33
|
-
) { approved, _ ->
|
|
34
|
-
cont.resume(approved.contains(android.Manifest.permission.RECORD_AUDIO))
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
val context = NitroModules.applicationContext ?: return@async false
|
|
39
|
-
val activity =
|
|
40
|
-
context.currentActivity as? PermissionAwareActivity ?: return@async false
|
|
41
|
-
val code = (Math.random() * 10000).toInt()
|
|
42
|
-
|
|
43
|
-
suspendCancellableCoroutine { cont ->
|
|
44
|
-
activity.requestPermissions(
|
|
45
|
-
arrayOf(android.Manifest.permission.RECORD_AUDIO),
|
|
46
|
-
code,
|
|
47
|
-
PermissionListener { requestCode, _, grantResults ->
|
|
48
|
-
if (requestCode != code) {
|
|
49
|
-
return@PermissionListener false
|
|
50
|
-
}
|
|
51
|
-
cont.resume(
|
|
52
|
-
grantResults.isNotEmpty() &&
|
|
53
|
-
grantResults.first() == PackageManager.PERMISSION_GRANTED
|
|
54
|
-
)
|
|
55
|
-
true
|
|
56
|
-
}
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
override fun startVoiceInput(
|
|
64
|
-
silenceThresholdMs: Double?,
|
|
65
|
-
maxDurationMs: Double?,
|
|
66
|
-
listeningText: String?,
|
|
67
|
-
preferSpeechToText: Boolean?,
|
|
68
|
-
onChunk: ((chunk: VoiceInputChunk) -> Unit)?,
|
|
69
|
-
language: String?
|
|
70
|
-
): Promise<VoiceInputResult> {
|
|
71
|
-
return Promise.async {
|
|
72
|
-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
|
73
|
-
throw UnsupportedOperationException("startVoiceInput requires at least API level ${Build.VERSION_CODES.O}")
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
val manager = VoiceInputManager(AndroidAutoSession.getRootContext())
|
|
77
|
-
voiceInputManager = manager
|
|
78
|
-
|
|
79
|
-
try {
|
|
80
|
-
manager.start(
|
|
81
|
-
silenceThresholdMs = silenceThresholdMs?.toLong() ?: 1_500L,
|
|
82
|
-
maxDurationMs = maxDurationMs?.toLong() ?: 10_000L,
|
|
83
|
-
preferSpeechToText = preferSpeechToText ?: false,
|
|
84
|
-
onChunk = onChunk,
|
|
85
|
-
language = language
|
|
86
|
-
)
|
|
87
|
-
} finally {
|
|
88
|
-
voiceInputManager = null
|
|
89
|
-
manager.dispose()
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
override fun stopVoiceInput() {
|
|
95
|
-
voiceInputManager?.stop()
|
|
96
|
-
}
|
|
97
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import AVFoundation
|
|
2
|
-
import NitroModules
|
|
3
|
-
import Speech
|
|
4
|
-
|
|
5
|
-
class HybridVoice: HybridVoiceSpec {
|
|
6
|
-
private var voiceInputManager: VoiceInputManager?
|
|
7
|
-
|
|
8
|
-
func hasVoiceInputPermission() throws -> Bool {
|
|
9
|
-
let micGranted = AVAudioSession.sharedInstance().recordPermission == .granted
|
|
10
|
-
let speechGranted = SFSpeechRecognizer.authorizationStatus() == .authorized
|
|
11
|
-
return micGranted && speechGranted
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
func requestVoiceInputPermission() throws -> Promise<Bool> {
|
|
15
|
-
return Promise.async {
|
|
16
|
-
let micGranted = await withCheckedContinuation { cont in
|
|
17
|
-
AVAudioSession.sharedInstance().requestRecordPermission { granted in
|
|
18
|
-
cont.resume(returning: granted)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
guard micGranted else { return false }
|
|
22
|
-
|
|
23
|
-
return await withCheckedContinuation { cont in
|
|
24
|
-
SFSpeechRecognizer.requestAuthorization { status in
|
|
25
|
-
cont.resume(returning: status == .authorized)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
func startVoiceInput(
|
|
32
|
-
silenceThresholdMs: Double?,
|
|
33
|
-
maxDurationMs: Double?,
|
|
34
|
-
listeningText: String?,
|
|
35
|
-
preferSpeechToText: Bool?,
|
|
36
|
-
onChunk: ((_ chunk: VoiceInputChunk) -> Void)?,
|
|
37
|
-
language: String?
|
|
38
|
-
) throws -> Promise<VoiceInputResult> {
|
|
39
|
-
return Promise.async {
|
|
40
|
-
let interfaceController = try? await RootModule.withInterfaceController { $0 }
|
|
41
|
-
|
|
42
|
-
let manager = VoiceInputManager()
|
|
43
|
-
self.voiceInputManager = manager
|
|
44
|
-
|
|
45
|
-
defer { self.voiceInputManager = nil }
|
|
46
|
-
|
|
47
|
-
return try await manager.start(
|
|
48
|
-
interfaceController: interfaceController,
|
|
49
|
-
silenceThresholdMs: silenceThresholdMs ?? 1_500,
|
|
50
|
-
maxDurationMs: maxDurationMs ?? 10_000,
|
|
51
|
-
listeningText: listeningText ?? "Listening...",
|
|
52
|
-
preferSpeechToText: preferSpeechToText ?? false,
|
|
53
|
-
onChunk: onChunk,
|
|
54
|
-
language: language
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
func stopVoiceInput() throws {
|
|
60
|
-
Task { @MainActor in
|
|
61
|
-
let interfaceController = try? await RootModule.withInterfaceController { $0 }
|
|
62
|
-
self.voiceInputManager?.stop(interfaceController: interfaceController)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
package/lib/HybridAutoPlay.d.ts
DELETED
package/lib/HybridAutoPlay.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
type Props = {
|
|
2
|
-
children: React.ReactNode;
|
|
3
|
-
moduleName: string;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* renders the passed children when the specified scene/screen appeared
|
|
7
|
-
* this makes sure child hooks are executed only when the map template is ready
|
|
8
|
-
*/
|
|
9
|
-
export default function OnAppearedChildRenderer({ children, moduleName }: Props): import("react").ReactNode;
|
|
10
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
import { HybridAutoPlay } from '../hybrid/HybridAutoPlay';
|
|
3
|
-
/**
|
|
4
|
-
* renders the passed children when the specified scene/screen appeared
|
|
5
|
-
* this makes sure child hooks are executed only when the map template is ready
|
|
6
|
-
*/
|
|
7
|
-
export default function OnAppearedChildRenderer({ children, moduleName }) {
|
|
8
|
-
const [didAppear, setDidAppear] = useState(false);
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
let remove = HybridAutoPlay.addListenerRenderState(moduleName, (renderState) => {
|
|
11
|
-
if (renderState === 'didAppear') {
|
|
12
|
-
remove?.();
|
|
13
|
-
remove = null;
|
|
14
|
-
setDidAppear(true);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
return () => {
|
|
18
|
-
remove?.();
|
|
19
|
-
remove = null;
|
|
20
|
-
};
|
|
21
|
-
}, [moduleName]);
|
|
22
|
-
if (didAppear) {
|
|
23
|
-
return children;
|
|
24
|
-
}
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A hook to determine if the CarPlay/Android Auto screen is currently focused (visible).
|
|
3
|
-
*
|
|
4
|
-
* @param moduleName The name of the module to listen to.
|
|
5
|
-
* @returns `true` if the screen is focused, `false` otherwise.
|
|
6
|
-
*/
|
|
7
|
-
export declare function useIsAutoPlayFocused(moduleName: string): boolean;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
import { HybridAutoPlay } from '..';
|
|
3
|
-
/**
|
|
4
|
-
* A hook to determine if the CarPlay/Android Auto screen is currently focused (visible).
|
|
5
|
-
*
|
|
6
|
-
* @param moduleName The name of the module to listen to.
|
|
7
|
-
* @returns `true` if the screen is focused, `false` otherwise.
|
|
8
|
-
*/
|
|
9
|
-
export function useIsAutoPlayFocused(moduleName) {
|
|
10
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
const remove = HybridAutoPlay.addListenerRenderState(moduleName, (state) => {
|
|
13
|
-
setIsFocused(state === 'didAppear');
|
|
14
|
-
});
|
|
15
|
-
return () => {
|
|
16
|
-
remove();
|
|
17
|
-
};
|
|
18
|
-
}, [moduleName]);
|
|
19
|
-
return isFocused;
|
|
20
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { VoiceInputOptions, VoiceInputResult } from '../types/Voice';
|
|
2
|
-
type StartVoiceInput = {
|
|
3
|
-
(options: VoiceInputOptions & Required<Pick<VoiceInputOptions, 'onChunk'>>): Promise<VoiceInputResult>;
|
|
4
|
-
(options?: Omit<VoiceInputOptions, 'onChunk'>): Promise<VoiceInputResult>;
|
|
5
|
-
};
|
|
6
|
-
export declare const HybridVoice: {
|
|
7
|
-
/**
|
|
8
|
-
* Returns true if all permissions required for voice input are granted.
|
|
9
|
-
* On iOS: checks both microphone and speech recognition authorization.
|
|
10
|
-
* On Android: checks RECORD_AUDIO permission.
|
|
11
|
-
*/
|
|
12
|
-
hasVoiceInputPermission: () => boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Request all permissions required for voice input.
|
|
15
|
-
* On iOS: requests microphone permission then speech recognition authorization.
|
|
16
|
-
* On Android: requests RECORD_AUDIO via car context when connected, otherwise
|
|
17
|
-
* via the React Native application context.
|
|
18
|
-
* Returns true only if all required permissions were granted.
|
|
19
|
-
*/
|
|
20
|
-
requestVoiceInputPermission: () => Promise<boolean>;
|
|
21
|
-
/**
|
|
22
|
-
* Start an in-app voice session.
|
|
23
|
-
*
|
|
24
|
-
* When preferSpeechToText is true:
|
|
25
|
-
* iOS — streams audio buffers into SFSpeechRecognizer during recording;
|
|
26
|
-
* onChunk fires with partial transcription results; resolves with
|
|
27
|
-
* { transcription } or falls back to { audio } if unavailable.
|
|
28
|
-
* Android — checks SpeechRecognizer availability upfront; if available it
|
|
29
|
-
* owns the mic and streams partial results via onChunk; if not
|
|
30
|
-
* available falls back to PCM recording.
|
|
31
|
-
*
|
|
32
|
-
* When preferSpeechToText is false (default):
|
|
33
|
-
* Both platforms record raw PCM; onChunk fires with audio chunks;
|
|
34
|
-
* resolves with { audio }.
|
|
35
|
-
*
|
|
36
|
-
* @param silenceThresholdMs ms of silence before auto-stop (default 1500)
|
|
37
|
-
* @param maxDurationMs hard cap on recording duration (default 10000)
|
|
38
|
-
* @param listeningText iOS only — text shown on CPVoiceControlTemplate
|
|
39
|
-
* @param preferSpeechToText request STT transcription instead of raw PCM
|
|
40
|
-
* @param onChunk optional streaming callback
|
|
41
|
-
* @param language specify the language for the SpeechRecognizer, falls back to system language if not set
|
|
42
|
-
*/
|
|
43
|
-
startVoiceInput: StartVoiceInput;
|
|
44
|
-
/**
|
|
45
|
-
* Stop the active voice session early.
|
|
46
|
-
* For PCM mode: resolves startVoiceInput with audio captured so far.
|
|
47
|
-
* For STT mode: finalises the recognition request.
|
|
48
|
-
* No-op if no session is active.
|
|
49
|
-
*/
|
|
50
|
-
stopVoiceInput: () => void;
|
|
51
|
-
};
|
|
52
|
-
export {};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { NitroModules } from 'react-native-nitro-modules';
|
|
2
|
-
const _native = NitroModules.createHybridObject('Voice');
|
|
3
|
-
const startVoiceInput = async (options) => {
|
|
4
|
-
const { onChunk, silenceThresholdMs, maxDurationMs, listeningText, preferSpeechToText, language, } = options ?? {};
|
|
5
|
-
return await _native.startVoiceInput(silenceThresholdMs, maxDurationMs, listeningText, preferSpeechToText, onChunk, language);
|
|
6
|
-
};
|
|
7
|
-
export const HybridVoice = {
|
|
8
|
-
/**
|
|
9
|
-
* Returns true if all permissions required for voice input are granted.
|
|
10
|
-
* On iOS: checks both microphone and speech recognition authorization.
|
|
11
|
-
* On Android: checks RECORD_AUDIO permission.
|
|
12
|
-
*/
|
|
13
|
-
hasVoiceInputPermission: () => _native.hasVoiceInputPermission(),
|
|
14
|
-
/**
|
|
15
|
-
* Request all permissions required for voice input.
|
|
16
|
-
* On iOS: requests microphone permission then speech recognition authorization.
|
|
17
|
-
* On Android: requests RECORD_AUDIO via car context when connected, otherwise
|
|
18
|
-
* via the React Native application context.
|
|
19
|
-
* Returns true only if all required permissions were granted.
|
|
20
|
-
*/
|
|
21
|
-
requestVoiceInputPermission: () => _native.requestVoiceInputPermission(),
|
|
22
|
-
/**
|
|
23
|
-
* Start an in-app voice session.
|
|
24
|
-
*
|
|
25
|
-
* When preferSpeechToText is true:
|
|
26
|
-
* iOS — streams audio buffers into SFSpeechRecognizer during recording;
|
|
27
|
-
* onChunk fires with partial transcription results; resolves with
|
|
28
|
-
* { transcription } or falls back to { audio } if unavailable.
|
|
29
|
-
* Android — checks SpeechRecognizer availability upfront; if available it
|
|
30
|
-
* owns the mic and streams partial results via onChunk; if not
|
|
31
|
-
* available falls back to PCM recording.
|
|
32
|
-
*
|
|
33
|
-
* When preferSpeechToText is false (default):
|
|
34
|
-
* Both platforms record raw PCM; onChunk fires with audio chunks;
|
|
35
|
-
* resolves with { audio }.
|
|
36
|
-
*
|
|
37
|
-
* @param silenceThresholdMs ms of silence before auto-stop (default 1500)
|
|
38
|
-
* @param maxDurationMs hard cap on recording duration (default 10000)
|
|
39
|
-
* @param listeningText iOS only — text shown on CPVoiceControlTemplate
|
|
40
|
-
* @param preferSpeechToText request STT transcription instead of raw PCM
|
|
41
|
-
* @param onChunk optional streaming callback
|
|
42
|
-
* @param language specify the language for the SpeechRecognizer, falls back to system language if not set
|
|
43
|
-
*/
|
|
44
|
-
startVoiceInput,
|
|
45
|
-
/**
|
|
46
|
-
* Stop the active voice session early.
|
|
47
|
-
* For PCM mode: resolves startVoiceInput with audio captured so far.
|
|
48
|
-
* For STT mode: finalises the recognition request.
|
|
49
|
-
* No-op if no session is active.
|
|
50
|
-
*/
|
|
51
|
-
stopVoiceInput: () => _native.stopVoiceInput(),
|
|
52
|
-
};
|
package/lib/hybrid.d.ts
DELETED
package/lib/hybrid.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
-
import type { NitroAutomotivePermissionRequestTemplateConfig } from '../templates/AutomotivePermissionRequestTemplate';
|
|
3
|
-
import type { NitroTemplateConfig } from './AutoPlay.nitro';
|
|
4
|
-
interface AutomotivePermissionRequestTemplateConfig extends NitroTemplateConfig, NitroAutomotivePermissionRequestTemplateConfig {
|
|
5
|
-
}
|
|
6
|
-
export interface AutomotivePermissionRequestTemplate extends HybridObject<{
|
|
7
|
-
android: 'kotlin';
|
|
8
|
-
}> {
|
|
9
|
-
createAutomotivePermissionRequestTemplate(config: AutomotivePermissionRequestTemplateConfig): void;
|
|
10
|
-
}
|
|
11
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
-
import type { NitroAutomotivePermissionRequestTemplateConfig } from '../templates/AutomotivePermissionRequestTemplate';
|
|
3
|
-
import type { NitroTemplateConfig } from './AutoPlay.nitro';
|
|
4
|
-
interface AutomotivePermissionRequestTemplateConfig extends NitroTemplateConfig, NitroAutomotivePermissionRequestTemplateConfig {
|
|
5
|
-
}
|
|
6
|
-
export interface AutomotivePermissionRequestTemplate extends HybridObject<{
|
|
7
|
-
android: 'kotlin';
|
|
8
|
-
}> {
|
|
9
|
-
createAutomotivePermissionRequestTemplate(config: AutomotivePermissionRequestTemplateConfig): void;
|
|
10
|
-
}
|
|
11
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
-
import type { VoiceInputChunk, VoiceInputResult } from '../types/Voice';
|
|
3
|
-
export interface Voice extends HybridObject<{
|
|
4
|
-
android: 'kotlin';
|
|
5
|
-
ios: 'swift';
|
|
6
|
-
}> {
|
|
7
|
-
hasVoiceInputPermission(): boolean;
|
|
8
|
-
requestVoiceInputPermission(): Promise<boolean>;
|
|
9
|
-
startVoiceInput(silenceThresholdMs?: number, maxDurationMs?: number, listeningText?: string, preferSpeechToText?: boolean, onChunk?: (chunk: VoiceInputChunk) => void, language?: string): Promise<VoiceInputResult>;
|
|
10
|
-
stopVoiceInput(): void;
|
|
11
|
-
}
|
package/lib/specs/Voice.nitro.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { CustomActionButtonAndroid } from '../types/Button';
|
|
2
|
-
import type { AutoText } from '../types/Text';
|
|
3
|
-
import { type NitroAction } from '../utils/NitroAction';
|
|
4
|
-
import { type HeaderActions, Template, type TemplateConfig } from './Template';
|
|
5
|
-
export interface NitroAutomotivePermissionRequestTemplateConfig extends TemplateConfig {
|
|
6
|
-
headerActions?: Array<NitroAction>;
|
|
7
|
-
title: AutoText;
|
|
8
|
-
actions: Array<NitroAction>;
|
|
9
|
-
}
|
|
10
|
-
export type AutomotivePermissionRequestTemplateConfig = Omit<NitroAutomotivePermissionRequestTemplateConfig, 'headerActions' | 'buttons'> & {
|
|
11
|
-
/**
|
|
12
|
-
* action buttons, usually at the the top right on Android and a top bar on iOS
|
|
13
|
-
*/
|
|
14
|
-
headerActions?: HeaderActions<AutomotivePermissionRequestTemplate>;
|
|
15
|
-
actions: [CustomActionButtonAndroid<AutomotivePermissionRequestTemplate>] | [
|
|
16
|
-
CustomActionButtonAndroid<AutomotivePermissionRequestTemplate>,
|
|
17
|
-
CustomActionButtonAndroid<AutomotivePermissionRequestTemplate>
|
|
18
|
-
];
|
|
19
|
-
};
|
|
20
|
-
export declare class AutomotivePermissionRequestTemplate extends Template<AutomotivePermissionRequestTemplateConfig, HeaderActions<AutomotivePermissionRequestTemplate>> {
|
|
21
|
-
private template;
|
|
22
|
-
constructor(config: AutomotivePermissionRequestTemplateConfig);
|
|
23
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { NitroModules } from 'react-native-nitro-modules';
|
|
2
|
-
import { NitroActionUtil } from '../utils/NitroAction';
|
|
3
|
-
import { Template, } from './Template';
|
|
4
|
-
const HybridAutomotivePermissionRequestTemplate = NitroModules.createHybridObject('AutomotivePermissionRequestTemplate');
|
|
5
|
-
export class AutomotivePermissionRequestTemplate extends Template {
|
|
6
|
-
template = this;
|
|
7
|
-
constructor(config) {
|
|
8
|
-
super(config);
|
|
9
|
-
const { headerActions, actions, ...rest } = config;
|
|
10
|
-
const nitroConfig = {
|
|
11
|
-
...rest,
|
|
12
|
-
id: this.id,
|
|
13
|
-
headerActions: NitroActionUtil.convert(this.template, headerActions),
|
|
14
|
-
actions: NitroActionUtil.convert(this.template, actions),
|
|
15
|
-
};
|
|
16
|
-
HybridAutomotivePermissionRequestTemplate.createAutomotivePermissionRequestTemplate(nitroConfig);
|
|
17
|
-
}
|
|
18
|
-
}
|