@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.
Files changed (165) hide show
  1. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlay.kt +93 -0
  2. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputManager.kt +20 -286
  3. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/utils/ThreadUtil.kt +13 -6
  4. package/ios/hybrid/HybridAutoPlay.swift +51 -2
  5. package/ios/utils/VoiceInputManager.swift +40 -144
  6. package/lib/index.d.ts +1 -3
  7. package/lib/index.js +1 -2
  8. package/lib/scenes/CarPlayDashboardScene.d.ts +1 -0
  9. package/lib/scenes/CarPlayDashboardScene.js +13 -7
  10. package/lib/specs/AutoPlay.nitro.d.ts +35 -0
  11. package/nitro.json +0 -10
  12. package/nitrogen/generated/android/ReactNativeAutoPlay+autolinking.cmake +0 -2
  13. package/nitrogen/generated/android/ReactNativeAutoPlayOnLoad.cpp +0 -18
  14. package/nitrogen/generated/android/c++/JActiveCarUxRestrictions.hpp +8 -8
  15. package/nitrogen/generated/android/c++/JGridTemplateConfig.hpp +16 -16
  16. package/nitrogen/generated/android/c++/JHybridAndroidAutoTelemetrySpec.cpp +4 -4
  17. package/nitrogen/generated/android/c++/JHybridAutoPlaySpec.cpp +52 -4
  18. package/nitrogen/generated/android/c++/JHybridAutoPlaySpec.hpp +5 -0
  19. package/nitrogen/generated/android/c++/JHybridClusterSpec.cpp +4 -4
  20. package/nitrogen/generated/android/c++/JHybridGridTemplateSpec.cpp +4 -4
  21. package/nitrogen/generated/android/c++/JHybridListTemplateSpec.cpp +4 -4
  22. package/nitrogen/generated/android/c++/JHybridMapTemplateSpec.cpp +15 -15
  23. package/nitrogen/generated/android/c++/JInformationTemplateConfig.hpp +16 -16
  24. package/nitrogen/generated/android/c++/JLaneGuidance.hpp +16 -16
  25. package/nitrogen/generated/android/c++/JListTemplateConfig.hpp +16 -16
  26. package/nitrogen/generated/android/c++/JMapTemplateConfig.hpp +16 -16
  27. package/nitrogen/generated/android/c++/JMessageTemplateConfig.hpp +16 -16
  28. package/nitrogen/generated/android/c++/JNitroAttributedString.hpp +8 -8
  29. package/nitrogen/generated/android/c++/JNitroBaseMapTemplateConfig.hpp +16 -16
  30. package/nitrogen/generated/android/c++/JNitroManeuver.cpp +4 -4
  31. package/nitrogen/generated/android/c++/JNitroManeuver.hpp +4 -4
  32. package/nitrogen/generated/android/c++/JNitroRoutingManeuver.hpp +16 -16
  33. package/nitrogen/generated/android/c++/JNitroSection.hpp +8 -8
  34. package/nitrogen/generated/android/c++/JPermissionRequestResult.hpp +16 -16
  35. package/nitrogen/generated/android/c++/JRouteChoice.hpp +32 -32
  36. package/nitrogen/generated/android/c++/JSearchTemplateConfig.hpp +8 -8
  37. package/nitrogen/generated/android/c++/JSignInTemplateConfig.hpp +16 -16
  38. package/nitrogen/generated/android/c++/JTripsConfig.hpp +8 -8
  39. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/ActiveCarUxRestrictions.kt +19 -0
  40. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/AppFocusState.kt +15 -0
  41. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/AssetImage.kt +23 -0
  42. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/AutoText.kt +17 -0
  43. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/BooleanTelemetryItem.kt +15 -0
  44. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Distance.kt +15 -0
  45. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/DurationWithTimeZone.kt +15 -0
  46. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/GlyphImage.kt +21 -0
  47. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/GoogleSignIn.kt +19 -0
  48. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/GoogleSignInAccount.kt +27 -0
  49. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/GridTemplateConfig.kt +33 -0
  50. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlaySpec.kt +21 -0
  51. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/ImageLane.kt +15 -0
  52. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/InformationTemplateConfig.kt +35 -0
  53. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/InputSignIn.kt +27 -0
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/LaneGuidance.kt +15 -0
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/ListTemplateConfig.kt +33 -0
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Location.kt +15 -0
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/MapTemplateConfig.kt +51 -0
  58. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/MessageTemplateConfig.kt +37 -0
  59. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NavigationAlertAction.kt +17 -0
  60. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroAction.kt +27 -0
  61. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroAttributedString.kt +15 -0
  62. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroAttributedStringImage.kt +15 -0
  63. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroBaseMapTemplateConfig.kt +29 -0
  64. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroColor.kt +15 -0
  65. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroGridButton.kt +17 -0
  66. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroImage.kt +18 -8
  67. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroLoadingManeuver.kt +17 -0
  68. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroManeuver.kt +18 -8
  69. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroMapButton.kt +17 -0
  70. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroMessageManeuver.kt +19 -0
  71. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroNavigationAlert.kt +31 -0
  72. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroRoutingManeuver.kt +49 -0
  73. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroRow.kt +27 -0
  74. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NitroSection.kt +17 -0
  75. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/NumericTelemetryItem.kt +15 -0
  76. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/PermissionRequestResult.kt +15 -0
  77. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/PinSignIn.kt +15 -0
  78. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Point.kt +15 -0
  79. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/PreferredImageLane.kt +19 -0
  80. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/QrSignIn.kt +15 -0
  81. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/RemoteImage.kt +17 -0
  82. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/RouteChoice.kt +21 -0
  83. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/SafeAreaInsets.kt +21 -0
  84. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/SearchTemplateConfig.kt +39 -0
  85. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/SignInTemplateConfig.kt +37 -0
  86. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/StringTelemetryItem.kt +15 -0
  87. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Telemetry.kt +35 -0
  88. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/TravelEstimates.kt +19 -0
  89. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/TripConfig.kt +15 -0
  90. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/TripPoint.kt +19 -0
  91. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/TripPreviewTextConfiguration.kt +19 -0
  92. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/TripSelectorCallback.kt +13 -0
  93. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/TripsConfig.kt +15 -0
  94. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Variant_GlyphImage_AssetImage_RemoteImage.kt +18 -8
  95. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Variant_PreferredImageLane_ImageLane.kt +16 -7
  96. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Variant_QrSignIn_PinSignIn_InputSignIn_GoogleSignIn.kt +20 -9
  97. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/VehicleTelemetryItem.kt +19 -0
  98. package/nitrogen/generated/ios/ReactNativeAutoPlay+autolinking.rb +2 -0
  99. package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.cpp +16 -41
  100. package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.hpp +126 -201
  101. package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Umbrella.hpp +0 -11
  102. package/nitrogen/generated/ios/ReactNativeAutoPlayAutolinking.mm +0 -8
  103. package/nitrogen/generated/ios/ReactNativeAutoPlayAutolinking.swift +0 -12
  104. package/nitrogen/generated/ios/c++/HybridAutoPlaySpecSwift.hpp +42 -0
  105. package/nitrogen/generated/ios/swift/Func_void_bool.swift +5 -5
  106. package/nitrogen/generated/ios/swift/{Func_void_VoiceInputResult.swift → Func_void_std__shared_ptr_ArrayBuffer_.swift} +10 -10
  107. package/nitrogen/generated/ios/swift/HybridAutoPlaySpec.swift +5 -0
  108. package/nitrogen/generated/ios/swift/HybridAutoPlaySpec_cxx.swift +94 -0
  109. package/nitrogen/generated/ios/swift/NitroImage.swift +13 -0
  110. package/nitrogen/generated/ios/swift/NitroManeuver.swift +13 -0
  111. package/nitrogen/generated/ios/swift/Variant_GlyphImage_AssetImage_RemoteImage.swift +13 -0
  112. package/nitrogen/generated/ios/swift/Variant_PreferredImageLane_ImageLane.swift +12 -0
  113. package/nitrogen/generated/shared/c++/HybridAutoPlaySpec.cpp +5 -0
  114. package/nitrogen/generated/shared/c++/HybridAutoPlaySpec.hpp +6 -0
  115. package/package.json +2 -2
  116. package/src/index.ts +1 -3
  117. package/src/scenes/CarPlayDashboardScene.ts +18 -11
  118. package/src/specs/AutoPlay.nitro.ts +44 -0
  119. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridVoice.kt +0 -97
  120. package/ios/hybrid/HybridVoice.swift +0 -65
  121. package/lib/HybridAutoPlay.d.ts +0 -2
  122. package/lib/HybridAutoPlay.js +0 -2
  123. package/lib/components/OnAppearedChildRenderer.d.ts +0 -10
  124. package/lib/components/OnAppearedChildRenderer.js +0 -26
  125. package/lib/hooks/useIsAutoPlayFocused.d.ts +0 -7
  126. package/lib/hooks/useIsAutoPlayFocused.js +0 -20
  127. package/lib/hybrid/HybridVoice.d.ts +0 -52
  128. package/lib/hybrid/HybridVoice.js +0 -52
  129. package/lib/hybrid.d.ts +0 -2
  130. package/lib/hybrid.js +0 -2
  131. package/lib/specs/AutomotivePermissionRequestTemplate.d.ts +0 -11
  132. package/lib/specs/AutomotivePermissionRequestTemplate.js +0 -1
  133. package/lib/specs/AutomotivePermissionRequestTemplate.nitro.d.ts +0 -11
  134. package/lib/specs/AutomotivePermissionRequestTemplate.nitro.js +0 -1
  135. package/lib/specs/Voice.nitro.d.ts +0 -11
  136. package/lib/specs/Voice.nitro.js +0 -1
  137. package/lib/templates/AutomotivePermissionRequestTemplate.d.ts +0 -23
  138. package/lib/templates/AutomotivePermissionRequestTemplate.js +0 -18
  139. package/lib/types/Glyphmap.d.ts +0 -4105
  140. package/lib/types/Glyphmap.js +0 -4105
  141. package/lib/types/Voice.d.ts +0 -16
  142. package/lib/types/Voice.js +0 -1
  143. package/nitrogen/generated/android/c++/JFunc_void_VoiceInputChunk.hpp +0 -81
  144. package/nitrogen/generated/android/c++/JHybridVoiceSpec.cpp +0 -104
  145. package/nitrogen/generated/android/c++/JHybridVoiceSpec.hpp +0 -66
  146. package/nitrogen/generated/android/c++/JVoiceInputChunk.hpp +0 -64
  147. package/nitrogen/generated/android/c++/JVoiceInputResult.hpp +0 -64
  148. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_VoiceInputChunk.kt +0 -80
  149. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridVoiceSpec.kt +0 -72
  150. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputChunk.kt +0 -41
  151. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputResult.kt +0 -41
  152. package/nitrogen/generated/ios/c++/HybridVoiceSpecSwift.cpp +0 -11
  153. package/nitrogen/generated/ios/c++/HybridVoiceSpecSwift.hpp +0 -116
  154. package/nitrogen/generated/ios/swift/Func_void_VoiceInputChunk.swift +0 -46
  155. package/nitrogen/generated/ios/swift/HybridVoiceSpec.swift +0 -58
  156. package/nitrogen/generated/ios/swift/HybridVoiceSpec_cxx.swift +0 -234
  157. package/nitrogen/generated/ios/swift/VoiceInputChunk.swift +0 -60
  158. package/nitrogen/generated/ios/swift/VoiceInputResult.swift +0 -60
  159. package/nitrogen/generated/shared/c++/HybridVoiceSpec.cpp +0 -24
  160. package/nitrogen/generated/shared/c++/HybridVoiceSpec.hpp +0 -73
  161. package/nitrogen/generated/shared/c++/VoiceInputChunk.hpp +0 -89
  162. package/nitrogen/generated/shared/c++/VoiceInputResult.hpp +0 -89
  163. package/src/hybrid/HybridVoice.ts +0 -79
  164. package/src/specs/Voice.nitro.ts +0 -16
  165. package/src/types/Voice.ts +0 -18
@@ -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
@@ -1,89 +0,0 @@
1
- ///
2
- /// VoiceInputResult.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 (VoiceInputResult).
41
- */
42
- struct VoiceInputResult final {
43
- public:
44
- std::optional<std::string> transcription SWIFT_PRIVATE;
45
- std::optional<std::shared_ptr<ArrayBuffer>> audio SWIFT_PRIVATE;
46
-
47
- public:
48
- VoiceInputResult() = default;
49
- explicit VoiceInputResult(std::optional<std::string> transcription, std::optional<std::shared_ptr<ArrayBuffer>> audio): transcription(transcription), audio(audio) {}
50
-
51
- public:
52
- friend bool operator==(const VoiceInputResult& lhs, const VoiceInputResult& rhs) = default;
53
- };
54
-
55
- } // namespace margelo::nitro::swe::iternio::reactnativeautoplay
56
-
57
- namespace margelo::nitro {
58
-
59
- // C++ VoiceInputResult <> JS VoiceInputResult (object)
60
- template <>
61
- struct JSIConverter<margelo::nitro::swe::iternio::reactnativeautoplay::VoiceInputResult> final {
62
- static inline margelo::nitro::swe::iternio::reactnativeautoplay::VoiceInputResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
63
- jsi::Object obj = arg.asObject(runtime);
64
- return margelo::nitro::swe::iternio::reactnativeautoplay::VoiceInputResult(
65
- JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "transcription"))),
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::VoiceInputResult& arg) {
70
- jsi::Object obj(runtime);
71
- obj.setProperty(runtime, PropNameIDCache::get(runtime, "transcription"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.transcription));
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, "transcription")))) 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
@@ -1,79 +0,0 @@
1
- import { NitroModules } from 'react-native-nitro-modules';
2
- import type { Voice } from '../specs/Voice.nitro';
3
- import type { VoiceInputOptions, VoiceInputResult } from '../types/Voice';
4
-
5
- const _native = NitroModules.createHybridObject<Voice>('Voice');
6
-
7
- type StartVoiceInput = {
8
- (
9
- options: VoiceInputOptions & Required<Pick<VoiceInputOptions, 'onChunk'>>
10
- ): Promise<VoiceInputResult>;
11
- (options?: Omit<VoiceInputOptions, 'onChunk'>): Promise<VoiceInputResult>;
12
- };
13
-
14
- const startVoiceInput: StartVoiceInput = async (options?: VoiceInputOptions) => {
15
- const {
16
- onChunk,
17
- silenceThresholdMs,
18
- maxDurationMs,
19
- listeningText,
20
- preferSpeechToText,
21
- language,
22
- } = options ?? {};
23
-
24
- return await _native.startVoiceInput(
25
- silenceThresholdMs,
26
- maxDurationMs,
27
- listeningText,
28
- preferSpeechToText,
29
- onChunk,
30
- language
31
- );
32
- };
33
-
34
- export const HybridVoice = {
35
- /**
36
- * Returns true if all permissions required for voice input are granted.
37
- * On iOS: checks both microphone and speech recognition authorization.
38
- * On Android: checks RECORD_AUDIO permission.
39
- */
40
- hasVoiceInputPermission: () => _native.hasVoiceInputPermission(),
41
- /**
42
- * Request all permissions required for voice input.
43
- * On iOS: requests microphone permission then speech recognition authorization.
44
- * On Android: requests RECORD_AUDIO via car context when connected, otherwise
45
- * via the React Native application context.
46
- * Returns true only if all required permissions were granted.
47
- */
48
- requestVoiceInputPermission: () => _native.requestVoiceInputPermission(),
49
- /**
50
- * Start an in-app voice session.
51
- *
52
- * When preferSpeechToText is true:
53
- * iOS — streams audio buffers into SFSpeechRecognizer during recording;
54
- * onChunk fires with partial transcription results; resolves with
55
- * { transcription } or falls back to { audio } if unavailable.
56
- * Android — checks SpeechRecognizer availability upfront; if available it
57
- * owns the mic and streams partial results via onChunk; if not
58
- * available falls back to PCM recording.
59
- *
60
- * When preferSpeechToText is false (default):
61
- * Both platforms record raw PCM; onChunk fires with audio chunks;
62
- * resolves with { audio }.
63
- *
64
- * @param silenceThresholdMs ms of silence before auto-stop (default 1500)
65
- * @param maxDurationMs hard cap on recording duration (default 10000)
66
- * @param listeningText iOS only — text shown on CPVoiceControlTemplate
67
- * @param preferSpeechToText request STT transcription instead of raw PCM
68
- * @param onChunk optional streaming callback
69
- * @param language specify the language for the SpeechRecognizer, falls back to system language if not set
70
- */
71
- startVoiceInput,
72
- /**
73
- * Stop the active voice session early.
74
- * For PCM mode: resolves startVoiceInput with audio captured so far.
75
- * For STT mode: finalises the recognition request.
76
- * No-op if no session is active.
77
- */
78
- stopVoiceInput: () => _native.stopVoiceInput(),
79
- };
@@ -1,16 +0,0 @@
1
- import type { HybridObject } from 'react-native-nitro-modules';
2
- import type { VoiceInputChunk, VoiceInputResult } from '../types/Voice';
3
-
4
- export interface Voice extends HybridObject<{ android: 'kotlin'; ios: 'swift' }> {
5
- hasVoiceInputPermission(): boolean;
6
- requestVoiceInputPermission(): Promise<boolean>;
7
- startVoiceInput(
8
- silenceThresholdMs?: number,
9
- maxDurationMs?: number,
10
- listeningText?: string,
11
- preferSpeechToText?: boolean,
12
- onChunk?: (chunk: VoiceInputChunk) => void,
13
- language?: string
14
- ): Promise<VoiceInputResult>;
15
- stopVoiceInput(): void;
16
- }
@@ -1,18 +0,0 @@
1
- export interface VoiceInputChunk {
2
- partial?: string;
3
- audio?: ArrayBuffer;
4
- }
5
-
6
- export interface VoiceInputResult {
7
- transcription?: string;
8
- audio?: ArrayBuffer;
9
- }
10
-
11
- export interface VoiceInputOptions {
12
- silenceThresholdMs?: number;
13
- maxDurationMs?: number;
14
- listeningText?: string;
15
- preferSpeechToText?: boolean;
16
- onChunk?: (chunk: VoiceInputChunk) => void;
17
- language?: string;
18
- }