@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.
- package/README.md +26 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlay.kt +4 -89
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridVoice.kt +97 -0
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputManager.kt +286 -20
- package/android/src/main/java/com/margelo/nitro/swe/iternio/reactnativeautoplay/utils/ThreadUtil.kt +6 -13
- package/ios/hybrid/HybridAutoPlay.swift +6 -47
- package/ios/hybrid/HybridVoice.swift +65 -0
- package/ios/utils/VoiceInputManager.swift +144 -40
- package/lib/HybridAutoPlay.d.ts +2 -0
- package/lib/HybridAutoPlay.js +2 -0
- package/lib/components/OnAppearedChildRenderer.d.ts +10 -0
- package/lib/components/OnAppearedChildRenderer.js +26 -0
- package/lib/hooks/useIsAutoPlayFocused.d.ts +7 -0
- package/lib/hooks/useIsAutoPlayFocused.js +20 -0
- package/lib/hybrid/HybridVoice.d.ts +52 -0
- package/lib/hybrid/HybridVoice.js +52 -0
- package/lib/hybrid.d.ts +2 -0
- package/lib/hybrid.js +2 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +2 -1
- package/lib/scenes/CarPlayDashboardScene.d.ts +1 -0
- package/lib/scenes/CarPlayDashboardScene.js +13 -7
- package/lib/specs/AutoPlay.nitro.d.ts +6 -29
- package/lib/specs/AutomotivePermissionRequestTemplate.d.ts +11 -0
- package/lib/specs/AutomotivePermissionRequestTemplate.js +1 -0
- package/lib/specs/AutomotivePermissionRequestTemplate.nitro.d.ts +11 -0
- package/lib/specs/AutomotivePermissionRequestTemplate.nitro.js +1 -0
- package/lib/specs/Voice.nitro.d.ts +11 -0
- package/lib/specs/Voice.nitro.js +1 -0
- package/lib/templates/AutomotivePermissionRequestTemplate.d.ts +23 -0
- package/lib/templates/AutomotivePermissionRequestTemplate.js +18 -0
- package/lib/types/Glyphmap.d.ts +4105 -0
- package/lib/types/Glyphmap.js +4105 -0
- package/lib/types/Voice.d.ts +16 -0
- package/lib/types/Voice.js +1 -0
- package/nitro.json +10 -0
- package/nitrogen/generated/android/ReactNativeAutoPlay+autolinking.cmake +2 -0
- package/nitrogen/generated/android/ReactNativeAutoPlayOnLoad.cpp +18 -0
- package/nitrogen/generated/android/c++/JFunc_void_VoiceInputChunk.hpp +81 -0
- package/nitrogen/generated/android/c++/JHybridAutoPlaySpec.cpp +5 -43
- package/nitrogen/generated/android/c++/JHybridAutoPlaySpec.hpp +1 -4
- package/nitrogen/generated/android/c++/JHybridVoiceSpec.cpp +104 -0
- package/nitrogen/generated/android/c++/JHybridVoiceSpec.hpp +66 -0
- package/nitrogen/generated/android/c++/JVoiceInputChunk.hpp +64 -0
- package/nitrogen/generated/android/c++/JVoiceInputResult.hpp +64 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/Func_void_VoiceInputChunk.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridAutoPlaySpec.kt +4 -17
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/HybridVoiceSpec.kt +72 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputChunk.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/swe/iternio/reactnativeautoplay/VoiceInputResult.kt +41 -0
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.cpp +41 -16
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Bridge.hpp +201 -126
- package/nitrogen/generated/ios/ReactNativeAutoPlay-Swift-Cxx-Umbrella.hpp +11 -0
- package/nitrogen/generated/ios/ReactNativeAutoPlayAutolinking.mm +8 -0
- package/nitrogen/generated/ios/ReactNativeAutoPlayAutolinking.swift +12 -0
- package/nitrogen/generated/ios/c++/HybridAutoPlaySpecSwift.hpp +8 -34
- package/nitrogen/generated/ios/c++/HybridVoiceSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridVoiceSpecSwift.hpp +116 -0
- package/nitrogen/generated/ios/swift/Func_void_VoiceInputChunk.swift +46 -0
- package/nitrogen/generated/ios/swift/{Func_void_std__shared_ptr_ArrayBuffer_.swift → Func_void_VoiceInputResult.swift} +10 -10
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +5 -5
- package/nitrogen/generated/ios/swift/HybridAutoPlaySpec.swift +1 -4
- package/nitrogen/generated/ios/swift/HybridAutoPlaySpec_cxx.swift +12 -82
- package/nitrogen/generated/ios/swift/HybridVoiceSpec.swift +58 -0
- package/nitrogen/generated/ios/swift/HybridVoiceSpec_cxx.swift +234 -0
- package/nitrogen/generated/ios/swift/VoiceInputChunk.swift +60 -0
- package/nitrogen/generated/ios/swift/VoiceInputResult.swift +60 -0
- package/nitrogen/generated/shared/c++/HybridAutoPlaySpec.cpp +1 -4
- package/nitrogen/generated/shared/c++/HybridAutoPlaySpec.hpp +1 -5
- package/nitrogen/generated/shared/c++/HybridVoiceSpec.cpp +24 -0
- package/nitrogen/generated/shared/c++/HybridVoiceSpec.hpp +73 -0
- package/nitrogen/generated/shared/c++/VoiceInputChunk.hpp +89 -0
- package/nitrogen/generated/shared/c++/VoiceInputResult.hpp +89 -0
- package/package.json +1 -1
- package/src/hybrid/HybridVoice.ts +79 -0
- package/src/index.ts +3 -1
- package/src/scenes/CarPlayDashboardScene.ts +18 -11
- package/src/specs/AutoPlay.nitro.ts +7 -37
- package/src/specs/Voice.nitro.ts +16 -0
- 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 (
|
|
31
|
+
if (component == null) {
|
|
31
32
|
return;
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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 @@
|
|
|
1
|
+
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
|
+
}
|