@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.
Files changed (64) hide show
  1. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlay.kt +89 -0
  2. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridCluster.kt +0 -1
  3. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputManager.kt +20 -276
  4. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/utils/ThreadUtil.kt +13 -6
  5. package/ios/hybrid/HybridAutoPlay.swift +47 -2
  6. package/ios/hybrid/HybridCluster.swift +0 -1
  7. package/ios/utils/VoiceInputManager.swift +40 -141
  8. package/lib/hooks/useAndroidAutoTelemetry.js +6 -1
  9. package/lib/index.d.ts +1 -5
  10. package/lib/index.js +1 -4
  11. package/lib/specs/AutoPlay.nitro.d.ts +29 -0
  12. package/nitro.json +0 -10
  13. package/nitrogen/generated/android/ReactNativeAutoPlay+autolinking.cmake +0 -2
  14. package/nitrogen/generated/android/ReactNativeAutoPlayOnLoad.cpp +0 -18
  15. package/nitrogen/generated/android/c++/JHybridAutoPlaySpec.cpp +43 -0
  16. package/nitrogen/generated/android/c++/JHybridAutoPlaySpec.hpp +4 -0
  17. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlaySpec.kt +17 -0
  18. package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.cpp +16 -41
  19. package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.hpp +126 -201
  20. package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Umbrella.hpp +0 -11
  21. package/nitrogen/generated/ios/ReactNativeAutoPlayAutolinking.mm +0 -8
  22. package/nitrogen/generated/ios/ReactNativeAutoPlayAutolinking.swift +0 -12
  23. package/nitrogen/generated/ios/c++/HybridAutoPlaySpecSwift.hpp +34 -0
  24. package/nitrogen/generated/ios/swift/Func_void_bool.swift +5 -5
  25. package/nitrogen/generated/ios/swift/{Func_void_VoiceInputResult.swift → Func_void_std__shared_ptr_ArrayBuffer_.swift} +10 -10
  26. package/nitrogen/generated/ios/swift/HybridAutoPlaySpec.swift +4 -0
  27. package/nitrogen/generated/ios/swift/HybridAutoPlaySpec_cxx.swift +82 -0
  28. package/nitrogen/generated/shared/c++/HybridAutoPlaySpec.cpp +4 -0
  29. package/nitrogen/generated/shared/c++/HybridAutoPlaySpec.hpp +5 -0
  30. package/package.json +1 -1
  31. package/src/hooks/useAndroidAutoTelemetry.ts +13 -8
  32. package/src/index.ts +1 -5
  33. package/src/specs/AutoPlay.nitro.ts +37 -0
  34. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridVoice.kt +0 -95
  35. package/ios/hybrid/HybridVoice.swift +0 -63
  36. package/lib/hybrid/HybridVoice.d.ts +0 -12
  37. package/lib/hybrid/HybridVoice.js +0 -13
  38. package/lib/specs/Voice.nitro.d.ts +0 -51
  39. package/lib/specs/Voice.nitro.js +0 -1
  40. package/lib/types/Voice.d.ts +0 -15
  41. package/lib/types/Voice.js +0 -1
  42. package/nitrogen/generated/android/c++/JFunc_void_VoiceInputChunk.hpp +0 -81
  43. package/nitrogen/generated/android/c++/JHybridVoiceSpec.cpp +0 -104
  44. package/nitrogen/generated/android/c++/JHybridVoiceSpec.hpp +0 -66
  45. package/nitrogen/generated/android/c++/JVoiceInputChunk.hpp +0 -64
  46. package/nitrogen/generated/android/c++/JVoiceInputResult.hpp +0 -64
  47. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_VoiceInputChunk.kt +0 -80
  48. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridVoiceSpec.kt +0 -72
  49. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputChunk.kt +0 -41
  50. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputResult.kt +0 -41
  51. package/nitrogen/generated/ios/c++/HybridVoiceSpecSwift.cpp +0 -11
  52. package/nitrogen/generated/ios/c++/HybridVoiceSpecSwift.hpp +0 -116
  53. package/nitrogen/generated/ios/swift/Func_void_VoiceInputChunk.swift +0 -46
  54. package/nitrogen/generated/ios/swift/HybridVoiceSpec.swift +0 -58
  55. package/nitrogen/generated/ios/swift/HybridVoiceSpec_cxx.swift +0 -227
  56. package/nitrogen/generated/ios/swift/VoiceInputChunk.swift +0 -60
  57. package/nitrogen/generated/ios/swift/VoiceInputResult.swift +0 -60
  58. package/nitrogen/generated/shared/c++/HybridVoiceSpec.cpp +0 -24
  59. package/nitrogen/generated/shared/c++/HybridVoiceSpec.hpp +0 -73
  60. package/nitrogen/generated/shared/c++/VoiceInputChunk.hpp +0 -89
  61. package/nitrogen/generated/shared/c++/VoiceInputResult.hpp +0 -89
  62. package/src/hybrid/HybridVoice.ts +0 -30
  63. package/src/specs/Voice.nitro.ts +0 -58
  64. package/src/types/Voice.ts +0 -17
@@ -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,30 +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
- (options: VoiceInputOptions & Required<Pick<VoiceInputOptions, 'onChunk'>>): Promise<void>;
9
- (options?: Omit<VoiceInputOptions, 'onChunk'>): Promise<VoiceInputResult>;
10
- };
11
-
12
- const startVoiceInput: StartVoiceInput = (async (options?: VoiceInputOptions) => {
13
- const { onChunk, silenceThresholdMs, maxDurationMs, listeningText, preferSpeechToText } =
14
- options ?? {};
15
- const result = await _native.startVoiceInput(
16
- silenceThresholdMs,
17
- maxDurationMs,
18
- listeningText,
19
- preferSpeechToText,
20
- onChunk
21
- );
22
- return onChunk !== undefined ? undefined : result;
23
- }) as unknown as StartVoiceInput;
24
-
25
- export const HybridVoice = {
26
- hasVoiceInputPermission: () => _native.hasVoiceInputPermission(),
27
- requestVoiceInputPermission: () => _native.requestVoiceInputPermission(),
28
- startVoiceInput,
29
- stopVoiceInput: () => _native.stopVoiceInput(),
30
- };
@@ -1,58 +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
- /**
6
- * Returns true if all permissions required for voice input are granted.
7
- * On iOS: checks both microphone and speech recognition authorization.
8
- * On Android: checks RECORD_AUDIO permission.
9
- */
10
- hasVoiceInputPermission(): boolean;
11
-
12
- /**
13
- * Request all permissions required for voice input.
14
- * On iOS: requests microphone permission then speech recognition authorization.
15
- * On Android: requests RECORD_AUDIO via car context when connected, otherwise
16
- * via the React Native application context.
17
- * Returns true only if all required permissions were granted.
18
- */
19
- requestVoiceInputPermission(): Promise<boolean>;
20
-
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; when set the
41
- * promise resolves with an empty VoiceInputResult
42
- */
43
- startVoiceInput(
44
- silenceThresholdMs?: number,
45
- maxDurationMs?: number,
46
- listeningText?: string,
47
- preferSpeechToText?: boolean,
48
- onChunk?: (chunk: VoiceInputChunk) => void
49
- ): Promise<VoiceInputResult>;
50
-
51
- /**
52
- * Stop the active voice session early.
53
- * For PCM mode: resolves startVoiceInput with audio captured so far.
54
- * For STT mode: finalises the recognition request.
55
- * No-op if no session is active.
56
- */
57
- stopVoiceInput(): void;
58
- }
@@ -1,17 +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
- }