@iternio/react-native-auto-play 0.4.7 → 0.4.9

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 (80) hide show
  1. package/README.md +26 -0
  2. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlay.kt +4 -89
  3. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridVoice.kt +97 -0
  4. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputManager.kt +286 -20
  5. package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/utils/ThreadUtil.kt +6 -13
  6. package/ios/hybrid/HybridAutoPlay.swift +6 -47
  7. package/ios/hybrid/HybridVoice.swift +65 -0
  8. package/ios/utils/VoiceInputManager.swift +144 -40
  9. package/lib/HybridAutoPlay.d.ts +2 -0
  10. package/lib/HybridAutoPlay.js +2 -0
  11. package/lib/components/OnAppearedChildRenderer.d.ts +10 -0
  12. package/lib/components/OnAppearedChildRenderer.js +26 -0
  13. package/lib/hooks/useIsAutoPlayFocused.d.ts +7 -0
  14. package/lib/hooks/useIsAutoPlayFocused.js +20 -0
  15. package/lib/hybrid/HybridVoice.d.ts +52 -0
  16. package/lib/hybrid/HybridVoice.js +52 -0
  17. package/lib/hybrid.d.ts +2 -0
  18. package/lib/hybrid.js +2 -0
  19. package/lib/index.d.ts +3 -1
  20. package/lib/index.js +2 -1
  21. package/lib/scenes/CarPlayDashboardScene.d.ts +1 -0
  22. package/lib/scenes/CarPlayDashboardScene.js +13 -7
  23. package/lib/specs/AutoPlay.nitro.d.ts +6 -29
  24. package/lib/specs/AutomotivePermissionRequestTemplate.d.ts +11 -0
  25. package/lib/specs/AutomotivePermissionRequestTemplate.js +1 -0
  26. package/lib/specs/AutomotivePermissionRequestTemplate.nitro.d.ts +11 -0
  27. package/lib/specs/AutomotivePermissionRequestTemplate.nitro.js +1 -0
  28. package/lib/specs/Voice.nitro.d.ts +11 -0
  29. package/lib/specs/Voice.nitro.js +1 -0
  30. package/lib/templates/AutomotivePermissionRequestTemplate.d.ts +23 -0
  31. package/lib/templates/AutomotivePermissionRequestTemplate.js +18 -0
  32. package/lib/types/Glyphmap.d.ts +4105 -0
  33. package/lib/types/Glyphmap.js +4105 -0
  34. package/lib/types/Voice.d.ts +16 -0
  35. package/lib/types/Voice.js +1 -0
  36. package/nitro.json +10 -0
  37. package/nitrogen/generated/android/ReactNativeAutoPlay+autolinking.cmake +2 -0
  38. package/nitrogen/generated/android/ReactNativeAutoPlayOnLoad.cpp +18 -0
  39. package/nitrogen/generated/android/c++/JFunc_void_VoiceInputChunk.hpp +81 -0
  40. package/nitrogen/generated/android/c++/JHybridAutoPlaySpec.cpp +5 -43
  41. package/nitrogen/generated/android/c++/JHybridAutoPlaySpec.hpp +1 -4
  42. package/nitrogen/generated/android/c++/JHybridVoiceSpec.cpp +104 -0
  43. package/nitrogen/generated/android/c++/JHybridVoiceSpec.hpp +66 -0
  44. package/nitrogen/generated/android/c++/JVoiceInputChunk.hpp +64 -0
  45. package/nitrogen/generated/android/c++/JVoiceInputResult.hpp +64 -0
  46. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_VoiceInputChunk.kt +80 -0
  47. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlaySpec.kt +4 -17
  48. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridVoiceSpec.kt +72 -0
  49. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputChunk.kt +41 -0
  50. package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputResult.kt +41 -0
  51. package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.cpp +41 -16
  52. package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.hpp +201 -126
  53. package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Umbrella.hpp +11 -0
  54. package/nitrogen/generated/ios/ReactNativeAutoPlayAutolinking.mm +8 -0
  55. package/nitrogen/generated/ios/ReactNativeAutoPlayAutolinking.swift +12 -0
  56. package/nitrogen/generated/ios/c++/HybridAutoPlaySpecSwift.hpp +8 -34
  57. package/nitrogen/generated/ios/c++/HybridVoiceSpecSwift.cpp +11 -0
  58. package/nitrogen/generated/ios/c++/HybridVoiceSpecSwift.hpp +116 -0
  59. package/nitrogen/generated/ios/swift/Func_void_VoiceInputChunk.swift +46 -0
  60. package/nitrogen/generated/ios/swift/{Func_void_std__shared_ptr_ArrayBuffer_.swift → Func_void_VoiceInputResult.swift} +10 -10
  61. package/nitrogen/generated/ios/swift/Func_void_bool.swift +5 -5
  62. package/nitrogen/generated/ios/swift/HybridAutoPlaySpec.swift +1 -4
  63. package/nitrogen/generated/ios/swift/HybridAutoPlaySpec_cxx.swift +12 -82
  64. package/nitrogen/generated/ios/swift/HybridVoiceSpec.swift +58 -0
  65. package/nitrogen/generated/ios/swift/HybridVoiceSpec_cxx.swift +234 -0
  66. package/nitrogen/generated/ios/swift/VoiceInputChunk.swift +60 -0
  67. package/nitrogen/generated/ios/swift/VoiceInputResult.swift +60 -0
  68. package/nitrogen/generated/shared/c++/HybridAutoPlaySpec.cpp +1 -4
  69. package/nitrogen/generated/shared/c++/HybridAutoPlaySpec.hpp +1 -5
  70. package/nitrogen/generated/shared/c++/HybridVoiceSpec.cpp +24 -0
  71. package/nitrogen/generated/shared/c++/HybridVoiceSpec.hpp +73 -0
  72. package/nitrogen/generated/shared/c++/VoiceInputChunk.hpp +89 -0
  73. package/nitrogen/generated/shared/c++/VoiceInputResult.hpp +89 -0
  74. package/package.json +1 -1
  75. package/src/hybrid/HybridVoice.ts +79 -0
  76. package/src/index.ts +3 -1
  77. package/src/scenes/CarPlayDashboardScene.ts +18 -11
  78. package/src/specs/AutoPlay.nitro.ts +7 -37
  79. package/src/specs/Voice.nitro.ts +16 -0
  80. package/src/types/Voice.ts +18 -0
@@ -9,6 +9,7 @@ export interface CarPlayDashboardButton extends BaseCarPlayDashboardButton {
9
9
  export type CarPlayDashboardEvent = EventName | VisibilityState;
10
10
  declare class Dashboard {
11
11
  private component;
12
+ private componentRegistered;
12
13
  isConnected: boolean;
13
14
  readonly id = "CarPlayDashboard";
14
15
  constructor();
@@ -9,6 +9,7 @@ const HybridCarPlayDashboard = Platform.OS === 'ios'
9
9
  : null;
10
10
  class Dashboard {
11
11
  component = null;
12
+ componentRegistered = false;
12
13
  isConnected = false;
13
14
  id = 'CarPlayDashboard';
14
15
  constructor() {
@@ -27,15 +28,20 @@ class Dashboard {
27
28
  return;
28
29
  }
29
30
  const { component, isConnected } = this;
30
- if (!isConnected || component == null) {
31
+ if (component == null) {
31
32
  return;
32
33
  }
33
- AppRegistry.registerComponent(this.id, () => (props) => React.createElement(SafeAreaInsetsProvider, {
34
- moduleName: this.id,
35
- // biome-ignore lint/correctness/noChildrenProp: there is no other way in a ts file
36
- children: React.createElement(component, props),
37
- }));
38
- HybridCarPlayDashboard.initRootView();
34
+ if (!this.componentRegistered) {
35
+ AppRegistry.registerComponent(this.id, () => (props) => React.createElement(SafeAreaInsetsProvider, {
36
+ moduleName: this.id,
37
+ // biome-ignore lint/correctness/noChildrenProp: there is no other way in a ts file
38
+ children: React.createElement(component, props),
39
+ }));
40
+ this.componentRegistered = true;
41
+ }
42
+ if (isConnected) {
43
+ HybridCarPlayDashboard.initRootView();
44
+ }
39
45
  }
40
46
  setComponent(component) {
41
47
  if (Platform.OS !== 'ios') {
@@ -31,35 +31,6 @@ export interface AutoPlay extends HybridObject<{
31
31
  * @namespace Android
32
32
  */
33
33
  addListenerVoiceInput(callback: (coordinates: Location | undefined, query: string | undefined) => void): CleanupCallback;
34
- /**
35
- * Returns true if microphone permission has already been granted.
36
- */
37
- hasVoiceInputPermission(): boolean;
38
- /**
39
- * Request microphone permission from the user.
40
- * On Android: uses the car context when Android Auto is connected, otherwise
41
- * falls back to the React Native application context.
42
- * On iOS: uses AVAudioApplication (iOS 17+) or AVAudioSession (iOS 15–16).
43
- * Returns true if permission was granted, false if denied.
44
- */
45
- requestVoiceInputPermission(): Promise<boolean>;
46
- /**
47
- * Start an in-app voice recording session.
48
- * On Android: acquires audio focus and captures via CarAudioRecord when
49
- * Android Auto is connected, otherwise uses standard AudioRecord.
50
- * On iOS: presents CPVoiceControlTemplate (when a car is connected) and
51
- * captures audio via AVAudioEngine.
52
- * Resolves with the complete raw PCM buffer (16 kHz, 16-bit, mono) when
53
- * silence is detected, the max duration is reached, or stopVoiceInput() is called.
54
- * Rejects if microphone permission has not been granted or recording fails to start.
55
- */
56
- startVoiceInput(silenceThresholdMs?: number, maxDurationMs?: number, listeningText?: string): Promise<ArrayBuffer>;
57
- /**
58
- * Stop the active voice recording session early. Causes the Promise returned
59
- * by startVoiceInput() to resolve with the audio captured so far.
60
- * No-op if no recording is in progress.
61
- */
62
- stopVoiceInput(): void;
63
34
  /**
64
35
  * sets the specified template as root template, initializes a new stack
65
36
  * Promise might contain an error message in case setting root template failed
@@ -98,4 +69,10 @@ export interface AutoPlay extends HybridObject<{
98
69
  * @returns true if AutoPlay is connected, false otherwise.
99
70
  */
100
71
  isConnected(): boolean;
72
+ /**
73
+ * Check if the native AutoPlay is currently running.
74
+ * Use this to distinguish a headless execution triggered by AA / CP
75
+ * from one triggered by other sources (e.g. notification updates).
76
+ */
77
+ isCarServiceRunning(): boolean;
101
78
  }
@@ -0,0 +1,11 @@
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 {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
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 {};
@@ -0,0 +1,11 @@
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
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
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
+ }
@@ -0,0 +1,18 @@
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
+ }