@facepe/widget-mobile-app 1.0.0 → 1.2.0
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 +293 -176
- package/dist/FacePeMobileAvatar.d.ts +1 -6
- package/dist/FacePeMobileAvatar.js +667 -95
- package/dist/FacePeMobileProvider.d.ts +2 -2
- package/dist/types.d.ts +35 -7
- package/dist/useFacePeAvatar.d.ts +3 -1
- package/dist/useFacePeAvatar.js +42 -1
- package/package.json +13 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
2
|
import type { FacePeMobileConfig, TokenProvider } from './types';
|
|
3
3
|
interface FacePeContextValue {
|
|
4
4
|
config: FacePeMobileConfig;
|
|
@@ -14,6 +14,6 @@ export interface FacePeMobileProviderProps {
|
|
|
14
14
|
apiBaseUrl?: string;
|
|
15
15
|
config?: FacePeMobileConfig;
|
|
16
16
|
}
|
|
17
|
-
export declare function FacePeMobileProvider({ children, getToken, apiBaseUrl, config, }: FacePeMobileProviderProps):
|
|
17
|
+
export declare function FacePeMobileProvider({ children, getToken, apiBaseUrl, config, }: FacePeMobileProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
18
18
|
export declare function useFacePeMobileContext(): FacePeContextValue;
|
|
19
19
|
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type AvatarGender = 'female' | 'male';
|
|
2
|
-
export type
|
|
2
|
+
export type FacePeConnectionStatus = 'idle' | 'connecting' | 'connected' | 'reconnecting' | 'disconnected' | 'error';
|
|
3
3
|
export interface FacePeMobileTheme {
|
|
4
4
|
primaryColor?: string;
|
|
5
5
|
backgroundColor?: string;
|
|
@@ -23,11 +23,9 @@ export interface FacePeMobileConfig {
|
|
|
23
23
|
avatarKey?: string;
|
|
24
24
|
/** Default language code (e.g., 'en', 'es', 'hi') */
|
|
25
25
|
language?: string;
|
|
26
|
-
/** Integration mode: 'auto', 'native', or 'webview' */
|
|
27
|
-
mode?: StreamMode;
|
|
28
26
|
/** Theme styling overrides */
|
|
29
27
|
theme?: FacePeMobileTheme;
|
|
30
|
-
/**
|
|
28
|
+
/** Auto start streaming when component mounts (default: true) */
|
|
31
29
|
autoStart?: boolean;
|
|
32
30
|
}
|
|
33
31
|
export interface TokenProviderParams {
|
|
@@ -35,12 +33,22 @@ export interface TokenProviderParams {
|
|
|
35
33
|
}
|
|
36
34
|
export type TokenProvider = (params: TokenProviderParams) => Promise<string>;
|
|
37
35
|
export interface FacePeMobileAvatarProps {
|
|
38
|
-
/**
|
|
36
|
+
/** Specific avatar identifier or key override */
|
|
39
37
|
avatarKey?: string;
|
|
40
38
|
/** Language to converse in ('en', 'es', 'hi', etc.) */
|
|
41
39
|
language?: string;
|
|
42
|
-
/** Custom style
|
|
40
|
+
/** Custom container style */
|
|
43
41
|
style?: any;
|
|
42
|
+
/** Custom video style */
|
|
43
|
+
videoStyle?: any;
|
|
44
|
+
/** Video scaling: 'cover' or 'contain' (default: 'cover') */
|
|
45
|
+
objectFit?: 'cover' | 'contain';
|
|
46
|
+
/** Whether to mirror the video stream (default: false) */
|
|
47
|
+
mirror?: boolean;
|
|
48
|
+
/** Auto start streaming when component mounts (default: true) */
|
|
49
|
+
autoStart?: boolean;
|
|
50
|
+
/** Whether microphone should be automatically enabled on stream start (default: true) */
|
|
51
|
+
enableMic?: boolean;
|
|
44
52
|
/** Called when real-time speech transcription arrives */
|
|
45
53
|
onTranscript?: (event: {
|
|
46
54
|
payload: TranscriptPayload;
|
|
@@ -49,7 +57,7 @@ export interface FacePeMobileAvatarProps {
|
|
|
49
57
|
onSpeakStart?: () => void;
|
|
50
58
|
/** Called when avatar finishes speaking */
|
|
51
59
|
onSpeakEnd?: () => void;
|
|
52
|
-
/** Called when user starts speaking (detected by VAD) */
|
|
60
|
+
/** Called when user starts speaking (detected by server VAD) */
|
|
53
61
|
onUserSpeakStart?: () => void;
|
|
54
62
|
/** Called when user finishes speaking */
|
|
55
63
|
onUserSpeakEnd?: () => void;
|
|
@@ -59,9 +67,29 @@ export interface FacePeMobileAvatarProps {
|
|
|
59
67
|
}) => void;
|
|
60
68
|
/** Called when customer says checkout / pay */
|
|
61
69
|
onCheckout?: () => void;
|
|
70
|
+
/** Called when stream connection status changes */
|
|
71
|
+
onStatusChange?: (status: FacePeConnectionStatus) => void;
|
|
62
72
|
/** Called when an error occurs */
|
|
63
73
|
onError?: (event: {
|
|
64
74
|
code: string;
|
|
65
75
|
message: string;
|
|
66
76
|
}) => void;
|
|
67
77
|
}
|
|
78
|
+
export interface FacePeMobileAvatarRef {
|
|
79
|
+
/** Start avatar streaming session */
|
|
80
|
+
start: () => Promise<void>;
|
|
81
|
+
/** Stop streaming and close session */
|
|
82
|
+
stop: () => Promise<void>;
|
|
83
|
+
/** Toggle user microphone on/off, returning new enabled state */
|
|
84
|
+
toggleMic: () => Promise<boolean>;
|
|
85
|
+
/** Explicitly set microphone state */
|
|
86
|
+
setMicEnabled: (enabled: boolean) => Promise<void>;
|
|
87
|
+
/** Programmatically make avatar speak a phrase */
|
|
88
|
+
speak: (text: string) => Promise<void>;
|
|
89
|
+
/** Interrupt avatar speech immediately */
|
|
90
|
+
interrupt: () => Promise<void>;
|
|
91
|
+
/** Current connection status */
|
|
92
|
+
readonly status: FacePeConnectionStatus;
|
|
93
|
+
/** Whether microphone is currently enabled */
|
|
94
|
+
readonly isMicEnabled: boolean;
|
|
95
|
+
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import type { TranscriptPayload, OrderItem } from './types';
|
|
1
|
+
import type { TranscriptPayload, OrderItem, FacePeConnectionStatus, FacePeMobileAvatarProps } from './types';
|
|
2
2
|
export interface UseFacePeAvatarResult {
|
|
3
3
|
token: string | null;
|
|
4
4
|
loading: boolean;
|
|
5
5
|
error: Error | null;
|
|
6
|
+
status: FacePeConnectionStatus;
|
|
6
7
|
transcripts: TranscriptPayload[];
|
|
7
8
|
isAvatarSpeaking: boolean;
|
|
8
9
|
isUserSpeaking: boolean;
|
|
9
10
|
orderItems: OrderItem[];
|
|
10
11
|
refreshToken: (force?: boolean) => Promise<string | null>;
|
|
11
12
|
clearTranscripts: () => void;
|
|
13
|
+
avatarProps: Pick<FacePeMobileAvatarProps, 'onTranscript' | 'onSpeakStart' | 'onSpeakEnd' | 'onUserSpeakStart' | 'onUserSpeakEnd' | 'onOrderUpdate' | 'onStatusChange'>;
|
|
12
14
|
}
|
|
13
15
|
export declare function useFacePeAvatar(): UseFacePeAvatarResult;
|
package/dist/useFacePeAvatar.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { useState, useCallback } from 'react';
|
|
1
|
+
import { useState, useCallback, useMemo } from 'react';
|
|
2
2
|
import { useFacePeMobileContext } from './FacePeMobileProvider';
|
|
3
3
|
export function useFacePeAvatar() {
|
|
4
4
|
const { token, loading, error, refreshToken } = useFacePeMobileContext();
|
|
5
|
+
const [status, setStatus] = useState('idle');
|
|
5
6
|
const [transcripts, setTranscripts] = useState([]);
|
|
6
7
|
const [isAvatarSpeaking, setIsAvatarSpeaking] = useState(false);
|
|
7
8
|
const [isUserSpeaking, setIsUserSpeaking] = useState(false);
|
|
@@ -9,15 +10,55 @@ export function useFacePeAvatar() {
|
|
|
9
10
|
const clearTranscripts = useCallback(() => {
|
|
10
11
|
setTranscripts([]);
|
|
11
12
|
}, []);
|
|
13
|
+
const handleTranscript = useCallback((event) => {
|
|
14
|
+
setTranscripts((prev) => [...prev, event.payload]);
|
|
15
|
+
}, []);
|
|
16
|
+
const handleSpeakStart = useCallback(() => {
|
|
17
|
+
setIsAvatarSpeaking(true);
|
|
18
|
+
}, []);
|
|
19
|
+
const handleSpeakEnd = useCallback(() => {
|
|
20
|
+
setIsAvatarSpeaking(false);
|
|
21
|
+
}, []);
|
|
22
|
+
const handleUserSpeakStart = useCallback(() => {
|
|
23
|
+
setIsUserSpeaking(true);
|
|
24
|
+
}, []);
|
|
25
|
+
const handleUserSpeakEnd = useCallback(() => {
|
|
26
|
+
setIsUserSpeaking(false);
|
|
27
|
+
}, []);
|
|
28
|
+
const handleOrderUpdate = useCallback((event) => {
|
|
29
|
+
setOrderItems(event.items);
|
|
30
|
+
}, []);
|
|
31
|
+
const handleStatusChange = useCallback((newStatus) => {
|
|
32
|
+
setStatus(newStatus);
|
|
33
|
+
}, []);
|
|
34
|
+
const avatarProps = useMemo(() => ({
|
|
35
|
+
onTranscript: handleTranscript,
|
|
36
|
+
onSpeakStart: handleSpeakStart,
|
|
37
|
+
onSpeakEnd: handleSpeakEnd,
|
|
38
|
+
onUserSpeakStart: handleUserSpeakStart,
|
|
39
|
+
onUserSpeakEnd: handleUserSpeakEnd,
|
|
40
|
+
onOrderUpdate: handleOrderUpdate,
|
|
41
|
+
onStatusChange: handleStatusChange,
|
|
42
|
+
}), [
|
|
43
|
+
handleTranscript,
|
|
44
|
+
handleSpeakStart,
|
|
45
|
+
handleSpeakEnd,
|
|
46
|
+
handleUserSpeakStart,
|
|
47
|
+
handleUserSpeakEnd,
|
|
48
|
+
handleOrderUpdate,
|
|
49
|
+
handleStatusChange,
|
|
50
|
+
]);
|
|
12
51
|
return {
|
|
13
52
|
token,
|
|
14
53
|
loading,
|
|
15
54
|
error,
|
|
55
|
+
status,
|
|
16
56
|
transcripts,
|
|
17
57
|
isAvatarSpeaking,
|
|
18
58
|
isUserSpeaking,
|
|
19
59
|
orderItems,
|
|
20
60
|
refreshToken,
|
|
21
61
|
clearTranscripts,
|
|
62
|
+
avatarProps,
|
|
22
63
|
};
|
|
23
64
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@facepe/widget-mobile-app",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "FacePe AI 3D Video Avatar Live Streaming SDK for React Native (iOS & Android)",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "FacePe AI 3D Video Avatar Native Live Streaming SDK for React Native (iOS & Android)",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"ios",
|
|
22
22
|
"android",
|
|
23
23
|
"webrtc",
|
|
24
|
-
"streaming"
|
|
24
|
+
"streaming",
|
|
25
|
+
"digital-human"
|
|
25
26
|
],
|
|
26
27
|
"author": "FacePe AI",
|
|
27
28
|
"license": "MIT",
|
|
@@ -30,8 +31,12 @@
|
|
|
30
31
|
"build": "tsc"
|
|
31
32
|
},
|
|
32
33
|
"peerDependencies": {
|
|
34
|
+
"@livekit/react-native": ">=2.0.0",
|
|
35
|
+
"@livekit/react-native-webrtc": ">=124.0.0",
|
|
36
|
+
"livekit-client": ">=2.0.0",
|
|
33
37
|
"react": ">=18.0.0",
|
|
34
|
-
"react-native": ">=0.70.0"
|
|
38
|
+
"react-native": ">=0.70.0",
|
|
39
|
+
"@anam-ai/js-sdk": ">=4.27.0"
|
|
35
40
|
},
|
|
36
41
|
"peerDependenciesMeta": {
|
|
37
42
|
"@livekit/react-native": {
|
|
@@ -40,7 +45,10 @@
|
|
|
40
45
|
"@livekit/react-native-webrtc": {
|
|
41
46
|
"optional": true
|
|
42
47
|
},
|
|
43
|
-
"
|
|
48
|
+
"livekit-client": {
|
|
49
|
+
"optional": true
|
|
50
|
+
},
|
|
51
|
+
"@anam-ai/js-sdk": {
|
|
44
52
|
"optional": true
|
|
45
53
|
}
|
|
46
54
|
},
|