@hoosei/voxweave-react
Version:
A customizable and interactive voice UI component for React applications
92 lines (91 loc) • 4.01 kB
TypeScript
import { FC } from 'react';
import { ThreeElements } from '@react-three/fiber';
declare global {
namespace React {
namespace JSX {
interface IntrinsicElements extends ThreeElements {
}
}
}
}
export type ColorTuple = [string, string];
export type Position = 'left' | 'right';
export type ContainerStyle = 'bottom' | 'center';
export interface VoxweaveCommonProps {
isListening: boolean;
agentStatus?: 'idle' | 'speaking' | 'listening' | 'thinking';
/**
* Size of the component in pixels.
* - If both disableFixed and showControls are false, any size is allowed
* - Otherwise, size must be between 75 and 250 pixels
*/
size?: number;
className?: string;
darkMode?: boolean;
backgroundColor?: string;
disableBackground?: boolean;
disableShadow?: boolean;
isVisible?: boolean;
isAnimated?: boolean;
disableFixed?: boolean;
position?: Position;
containerStyle?: ContainerStyle;
isVertical?: boolean;
listeningColors?: ColorTuple;
notListeningColors?: ColorTuple;
theme?: 'default' | 'minimal';
animation?: FC<VoxweaveThreeJSProps> | string | undefined;
hideCloseButton?: boolean;
isExpanded?: boolean;
isCompact?: boolean;
showControls?: boolean;
useAsButton?: boolean;
startCallLabel?: string;
endCallLabel?: string;
statusLabel?: string;
expandLabel?: string;
privacyMode?: boolean;
privacyPolicyUrl?: string;
companyName?: string;
languageMode?: boolean;
defaultLanguage?: string;
onConsentAccept?: () => void;
onLanguageChange?: (language: string) => void;
onStartCall: () => void;
onEndCall?: () => void;
onClose: () => void;
}
export interface VoxweaveButtonProps extends VoxweaveCommonProps {
useAsButton: true;
onButtonClick: () => void | Promise<void>;
}
export interface VoxweaveNonButtonProps extends VoxweaveCommonProps {
useAsButton?: false;
onStartCall: (e?: any) => void | Promise<void>;
onClose: (e?: any) => void | Promise<void>;
containerStyle: 'bottom' | 'center';
position: 'left' | 'right';
}
type AllowedSize = 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250;
export type ValidatedVoxweaveProps<T extends VoxweaveCommonProps> = T['disableFixed'] extends true ? T['showControls'] extends false ? T & {
size?: number;
} : // No size restriction when disableFixed is true and showControls is false
T & {
size?: AllowedSize;
} : // Size must be 75-250 otherwise
T & {
size?: AllowedSize;
};
export type VoxweaveProps = VoxweaveButtonProps | VoxweaveNonButtonProps;
export interface VoxweaveComponent extends FC<VoxweaveProps> {
}
export interface VoxweaveThreeJSProps {
size: number;
isListening: boolean;
audioData: Uint8Array | null;
agentAudioData: Uint8Array | null;
listeningColors: ColorTuple | undefined;
notListeningColors: ColorTuple | undefined;
agentStatus?: 'idle' | 'speaking' | 'listening' | 'thinking';
}
export {};