@convai/web-sdk 1.9.2 → 2.0.0-beta.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.
Files changed (79) hide show
  1. package/README.md +22 -11
  2. package/dist/core/types.d.ts +2 -2
  3. package/dist/react/hooks/index.d.ts +0 -2
  4. package/dist/react/hooks/index.js +0 -3
  5. package/dist/react/index.d.ts +0 -3
  6. package/dist/react/index.js +3 -10
  7. package/dist/vanilla/index.d.ts +6 -18
  8. package/dist/vanilla/index.js +7 -19
  9. package/dist/version.d.ts +1 -1
  10. package/dist/version.js +1 -1
  11. package/package.json +9 -8
  12. package/dist/react/components/ConvaiWidget.d.ts +0 -86
  13. package/dist/react/components/ConvaiWidget.js +0 -610
  14. package/dist/react/components/index.d.ts +0 -1
  15. package/dist/react/components/index.js +0 -2
  16. package/dist/react/components/rtc-widget/components/AudioSettingsPanel.d.ts +0 -9
  17. package/dist/react/components/rtc-widget/components/AudioSettingsPanel.js +0 -315
  18. package/dist/react/components/rtc-widget/components/AudioVisualizer.d.ts +0 -35
  19. package/dist/react/components/rtc-widget/components/AudioVisualizer.js +0 -285
  20. package/dist/react/components/rtc-widget/components/ConviMessage.d.ts +0 -12
  21. package/dist/react/components/rtc-widget/components/ConviMessage.js +0 -13
  22. package/dist/react/components/rtc-widget/components/FloatingVideo.d.ts +0 -8
  23. package/dist/react/components/rtc-widget/components/FloatingVideo.js +0 -120
  24. package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts +0 -31
  25. package/dist/react/components/rtc-widget/components/MarkdownRenderer.js +0 -140
  26. package/dist/react/components/rtc-widget/components/MessageBubble.d.ts +0 -9
  27. package/dist/react/components/rtc-widget/components/MessageBubble.js +0 -22
  28. package/dist/react/components/rtc-widget/components/MessageList.d.ts +0 -13
  29. package/dist/react/components/rtc-widget/components/MessageList.js +0 -88
  30. package/dist/react/components/rtc-widget/components/SiteCard.d.ts +0 -14
  31. package/dist/react/components/rtc-widget/components/SiteCard.js +0 -34
  32. package/dist/react/components/rtc-widget/components/UserMessage.d.ts +0 -8
  33. package/dist/react/components/rtc-widget/components/UserMessage.js +0 -14
  34. package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.d.ts +0 -5
  35. package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.js +0 -14
  36. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.d.ts +0 -24
  37. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.js +0 -170
  38. package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.d.ts +0 -16
  39. package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.js +0 -64
  40. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.d.ts +0 -11
  41. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.js +0 -65
  42. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.d.ts +0 -13
  43. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js +0 -298
  44. package/dist/react/components/rtc-widget/components/conviComponents/index.d.ts +0 -5
  45. package/dist/react/components/rtc-widget/components/conviComponents/index.js +0 -5
  46. package/dist/react/components/rtc-widget/components/index.d.ts +0 -8
  47. package/dist/react/components/rtc-widget/components/index.js +0 -14
  48. package/dist/react/components/rtc-widget/index.d.ts +0 -5
  49. package/dist/react/components/rtc-widget/index.js +0 -8
  50. package/dist/react/components/rtc-widget/styles/framerConfig.d.ts +0 -115
  51. package/dist/react/components/rtc-widget/styles/framerConfig.js +0 -72
  52. package/dist/react/components/rtc-widget/styles/icons.d.ts +0 -27
  53. package/dist/react/components/rtc-widget/styles/icons.js +0 -256
  54. package/dist/react/components/rtc-widget/styles/index.d.ts +0 -5
  55. package/dist/react/components/rtc-widget/styles/index.js +0 -8
  56. package/dist/react/components/rtc-widget/styles/styledComponents.d.ts +0 -89
  57. package/dist/react/components/rtc-widget/styles/styledComponents.js +0 -662
  58. package/dist/react/components/rtc-widget/styles/theme.d.ts +0 -187
  59. package/dist/react/components/rtc-widget/styles/theme.js +0 -289
  60. package/dist/react/components/rtc-widget/types/index.d.ts +0 -59
  61. package/dist/react/components/rtc-widget/types/index.js +0 -1
  62. package/dist/react/hooks/useCharacterInfo.d.ts +0 -18
  63. package/dist/react/hooks/useCharacterInfo.js +0 -65
  64. package/dist/react/hooks/useLocalCameraTrack.d.ts +0 -21
  65. package/dist/react/hooks/useLocalCameraTrack.js +0 -33
  66. package/dist/react/icons.d.ts +0 -37
  67. package/dist/react/icons.js +0 -53
  68. package/dist/utils/lightbox.d.ts +0 -15
  69. package/dist/utils/lightbox.js +0 -94
  70. package/dist/vanilla/ConvaiWidget.d.ts +0 -46
  71. package/dist/vanilla/ConvaiWidget.js +0 -2866
  72. package/dist/vanilla/WidgetEventSubscriptions.d.ts +0 -14
  73. package/dist/vanilla/WidgetEventSubscriptions.js +0 -36
  74. package/dist/vanilla/icons.d.ts +0 -34
  75. package/dist/vanilla/icons.js +0 -268
  76. package/dist/vanilla/styles.d.ts +0 -168
  77. package/dist/vanilla/styles.js +0 -407
  78. package/dist/vanilla/types.d.ts +0 -170
  79. package/dist/vanilla/types.js +0 -1
@@ -1,610 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useState, useRef, useEffect } from "react";
3
- import { motion, AnimatePresence } from "framer-motion";
4
- import { FiMoreVertical, FiPhoneOff, FiSend, IoVolumeHigh, IoVolumeMute, PiWaveform } from "../icons.js";
5
- import { RoomContext } from "@livekit/components-react";
6
- import { useCharacterInfo } from "../hooks/useCharacterInfo.js";
7
- import { AudioRenderer } from "../../vanilla/AudioRenderer.js";
8
- import { freshPublicationGrantOptions } from "../../core/publishedChat.js";
9
- // Import styled components and theme from rtc-widget
10
- import { ConvaiContainer, MorphingContainer, ButtonContent, Logo, ChatContent, Header, Title, CloseButton, SettingsButton, Content, Footer, InputContainer, Input, ActionButton, aeroTheme, iosTransitions, ConvaiLogo, ChevronDown, } from "./rtc-widget/index.js";
11
- // Import message components
12
- import { MessageList, SettingsTray, VoiceModeOverlay, FloatingVideo, } from "./rtc-widget/index.js";
13
- /**
14
- * ConvaiWidget - A consolidated chat widget component for real-time conversations
15
- *
16
- * This component provides a complete UI for interacting with Convai characters.
17
- * Connection configuration should be handled via useConvaiClient.connect().
18
- *
19
- * Features:
20
- * - Collapsed circular button with status indicator
21
- * - Expandable/collapsible chat interface
22
- * - Voice mode support
23
- * - Real-time message streaming
24
- * - Audio controls (mute/unmute)
25
- * - Settings tray with session reset
26
- * - Optional video and screen share (when connection type supports it)
27
- *
28
- * @param {ConvaiWidgetProps} props - Component props
29
- * @param {ConvaiClient} props.convaiClient - Convai client instance (required)
30
- * @param {boolean} props.showVideo - Show video toggle in settings (default: true)
31
- * @param {boolean} props.showScreenShare - Show screen share toggle in settings (default: true)
32
- * @param {boolean} props.defaultVoiceMode - Start in voice mode when widget opens (default: true)
33
- *
34
- * @example
35
- * ```tsx
36
- * function App() {
37
- * const convaiClient = useConvaiClient({
38
- * apiKey: 'your-api-key',
39
- * characterId: 'your-character-id',
40
- * enableVideo: true,
41
- * });
42
- *
43
- * return (
44
- * <ConvaiWidget
45
- * convaiClient={convaiClient}
46
- * showVideo={true}
47
- * showScreenShare={true}
48
- * />
49
- * );
50
- * }
51
- * ```
52
- */
53
- export const ConvaiWidget = ({ convaiClient, showVideo = true, showScreenShare = true, defaultVoiceMode = true, requestPublicationGrant, publishedChatConnectOptions, publishedChatDescriptor, linkPreviewResolver, }) => {
54
- const isTextOnly = Boolean(requestPublicationGrant) || convaiClient.connectionType === "text";
55
- // Fetch character information dynamically from client's stored values
56
- const { name: fetchedCharacterName, image: fetchedCharacterImage, isLoading: isFetchedCharacterLoading, } = useCharacterInfo(convaiClient.characterId || undefined, convaiClient.apiKey || undefined, convaiClient.authToken || undefined, convaiClient.characterInfoUrl);
57
- const characterName = publishedChatDescriptor?.display_name || fetchedCharacterName;
58
- const characterImage = publishedChatDescriptor?.image_url ?? fetchedCharacterImage;
59
- const isCharacterLoading = publishedChatDescriptor
60
- ? false
61
- : isFetchedCharacterLoading;
62
- // UI State
63
- const [isOpen, setIsOpen] = useState(false);
64
- const [inputValue, setInputValue] = useState("");
65
- const [isSettingsOpen, setIsSettingsOpen] = useState(false);
66
- const [isVoiceMode, setIsVoiceMode] = useState(defaultVoiceMode && !isTextOnly);
67
- const [isMuted, setIsMuted] = useState(false); // Character audio starts unmuted
68
- const [isVideoVisible, setIsVideoVisible] = useState(false);
69
- const [hasEnteredDefaultVoiceMode, setHasEnteredDefaultVoiceMode] = useState(false);
70
- const settingsButtonRef = useRef(null);
71
- /** True after we have connected at least once; used to call reconnect() instead of connect() when opening after disconnect */
72
- const hasConnectedBeforeRef = useRef(false);
73
- /** Prevent repeated open clicks from minting multiple one-time publication grants. */
74
- const isStartingConnectionRef = useRef(false);
75
- /** Avoid opening a room after this widget has been removed from the tree. */
76
- const isUnmountedRef = useRef(false);
77
- // Only published sessions wait for Core's bot-ready handshake. A normal
78
- // authenticated text session still uses the text-only layout, but can send
79
- // as soon as it connects.
80
- const requiresBotReadyForText = Boolean(requestPublicationGrant) || convaiClient.isPublishedChatSession;
81
- const canSendText = convaiClient.state.isConnected &&
82
- (!requiresBotReadyForText || convaiClient.isBotReady);
83
- // Character info from API (using client's stored values)
84
- const selectedCharacter = {
85
- id: convaiClient.characterId || "unknown",
86
- name: characterName,
87
- image: characterImage,
88
- };
89
- // Get bot status color for character image border
90
- const getBotStatusColor = () => {
91
- if (!convaiClient.state.isConnected) {
92
- return { color: "#ef4444", label: "Disconnected" }; // Red
93
- }
94
- if (convaiClient.state.isConnecting || !convaiClient.isBotReady) {
95
- return { color: "#f59e0b", label: "Connecting" }; // Yellow/Orange
96
- }
97
- if (convaiClient.state.isListening) {
98
- return { color: "#3b82f6", label: "Listening" }; // Blue - user speaking
99
- }
100
- return { color: "#10b981", label: "Connected" }; // Green
101
- };
102
- // Format chat messages for UI
103
- const formatMessages = () => {
104
- // Filter to only show relevant message types and exclude empty messages
105
- const filteredMessages = convaiClient.chatMessages.filter((msg) => (msg.type === "user-transcription" ||
106
- msg.type === "user-llm-text" ||
107
- msg.type === "bot-llm-text" ||
108
- msg.type === "bot-output" ||
109
- msg.type === "bot-emotion") &&
110
- msg.content && // Ensure content exists
111
- msg.content.trim().length > 0);
112
- return filteredMessages.map((msg) => ({
113
- id: msg.id,
114
- text: msg.content,
115
- isUser: msg.type.includes("user"),
116
- timestamp: new Date(msg.timestamp).toLocaleTimeString([], {
117
- hour: "2-digit",
118
- minute: "2-digit",
119
- }),
120
- sender: msg.type.includes("user") ? "You" : selectedCharacter.name,
121
- showLogo: msg.type.includes("bot"),
122
- }));
123
- };
124
- // Event Handlers
125
- const handleToggle = async () => {
126
- if (isStartingConnectionRef.current) {
127
- return;
128
- }
129
- // Connect on first click if not already connected/connecting
130
- if (!convaiClient.state.isConnected && !convaiClient.state.isConnecting) {
131
- isStartingConnectionRef.current = true;
132
- try {
133
- if (requestPublicationGrant || convaiClient.isPublishedChatSession) {
134
- if (!requestPublicationGrant) {
135
- throw new Error("Published chat widgets require requestPublicationGrant to start a new session");
136
- }
137
- if (!convaiClient.connectWithPublicationGrant) {
138
- throw new Error("This Convai client does not support published chat connections");
139
- }
140
- const launchToken = await requestPublicationGrant();
141
- if (isUnmountedRef.current)
142
- return;
143
- await convaiClient.connectWithPublicationGrant(launchToken, freshPublicationGrantOptions(publishedChatConnectOptions));
144
- }
145
- else if (hasConnectedBeforeRef.current &&
146
- typeof convaiClient.reconnect === "function") {
147
- await convaiClient.reconnect();
148
- }
149
- else {
150
- await convaiClient.connect();
151
- }
152
- if (isUnmountedRef.current) {
153
- await convaiClient.disconnect();
154
- return;
155
- }
156
- setIsOpen(true); // Open widget after successful connection
157
- }
158
- catch (error) {
159
- console.error("Failed to connect:", error);
160
- }
161
- finally {
162
- isStartingConnectionRef.current = false;
163
- }
164
- }
165
- else {
166
- // Just toggle open/close if already connected
167
- setIsOpen(!isOpen);
168
- }
169
- };
170
- const handleClose = () => {
171
- setIsOpen(false);
172
- };
173
- const handleInputChange = (e) => {
174
- setInputValue(e.target.value);
175
- };
176
- const handleSend = () => {
177
- if (inputValue.trim() && canSendText) {
178
- convaiClient.sendUserTextMessage(inputValue);
179
- setInputValue("");
180
- }
181
- };
182
- const handleKeyPress = (e) => {
183
- if (e.key === "Enter") {
184
- handleSend();
185
- }
186
- };
187
- const handleToggleMute = () => {
188
- const newMutedState = !isMuted;
189
- // The client owns this now. It replaces a branch that reached for
190
- // LiveKit's `@internal` RemoteTrack.setMuted on one transport and a DOM
191
- // query on the other, and it holds the state so tracks arriving later —
192
- // a reconnect, a joining roster member — honour it too.
193
- convaiClient.setCharacterMuted(newMutedState);
194
- setIsMuted(newMutedState);
195
- };
196
- const handleReset = async () => {
197
- setIsSettingsOpen(false);
198
- try {
199
- // Disconnect current session
200
- await convaiClient.disconnect();
201
- // Reset session ID so next connection creates a new session
202
- convaiClient.resetSession();
203
- // Reset UI states immediately
204
- setIsMuted(false);
205
- setIsVoiceMode(false);
206
- // Note: User is responsible for reconnecting after reset
207
- // They should call convaiClient.connect() themselves
208
- }
209
- catch (error) {
210
- console.error("Failed to reset:", error);
211
- }
212
- };
213
- const handleDisconnect = async () => {
214
- setIsSettingsOpen(false);
215
- await convaiClient.disconnect();
216
- // Reset UI states immediately
217
- setIsMuted(false);
218
- setIsVoiceMode(false);
219
- };
220
- const handleToggleVideo = async () => {
221
- // Only toggle if connection type is video
222
- if (convaiClient.connectionType !== "video") {
223
- console.warn("Video capability requires connection type to be 'video'");
224
- return;
225
- }
226
- if (convaiClient.isVideoEnabled) {
227
- await convaiClient.videoControls.disableVideo();
228
- }
229
- else {
230
- await convaiClient.videoControls.enableVideo();
231
- }
232
- };
233
- const handleToggleScreenShare = async () => {
234
- await convaiClient.screenShareControls.toggleScreenShare();
235
- };
236
- const handleSettingsToggle = () => {
237
- setIsSettingsOpen(!isSettingsOpen);
238
- };
239
- useEffect(() => {
240
- isUnmountedRef.current = false;
241
- return () => {
242
- isUnmountedRef.current = true;
243
- };
244
- }, []);
245
- // Remember that we have connected at least once (so we use reconnect() next time after disconnect)
246
- useEffect(() => {
247
- if (convaiClient.state.isConnected) {
248
- hasConnectedBeforeRef.current = true;
249
- }
250
- }, [convaiClient.state.isConnected]);
251
- // Auto-collapse when disconnected
252
- useEffect(() => {
253
- if (!convaiClient.state.isConnected && !convaiClient.state.isConnecting) {
254
- if (isOpen) {
255
- setIsOpen(false);
256
- }
257
- // Reset UI states on disconnect
258
- setIsMuted(false); // Reset character mute
259
- setIsVoiceMode(false); // Reset voice mode
260
- setHasEnteredDefaultVoiceMode(false); // Reset flag so voice mode can be entered again on reconnect
261
- }
262
- }, [convaiClient.state.isConnected, convaiClient.state.isConnecting, isOpen]);
263
- // Sync video visibility with video controls state
264
- useEffect(() => {
265
- setIsVideoVisible(convaiClient.isVideoEnabled);
266
- }, [convaiClient.isVideoEnabled]);
267
- // Ensure microphone is muted when not in voice mode
268
- useEffect(() => {
269
- if (isTextOnly && isVoiceMode) {
270
- setIsVoiceMode(false);
271
- }
272
- }, [isTextOnly, isVoiceMode]);
273
- useEffect(() => {
274
- const ensureMicState = async () => {
275
- if (!isVoiceMode && !convaiClient.isAudioMuted) {
276
- // Mute microphone when in text mode
277
- await convaiClient.audioControls.muteAudio();
278
- }
279
- };
280
- ensureMicState();
281
- }, [isVoiceMode, convaiClient]);
282
- // While default voice mode is still pending, render the voice view rather
283
- // than the text input. Otherwise the panel opens in text mode (the
284
- // disconnect reset below also runs on mount), the user starts typing, and
285
- // the moment the connection lands the input is swapped out and the mic goes
286
- // live under them.
287
- const showVoiceMode = isVoiceMode ||
288
- (defaultVoiceMode && !isTextOnly && !hasEnteredDefaultVoiceMode);
289
- // Handle default voice mode when widget opens (only once)
290
- useEffect(() => {
291
- if (isOpen &&
292
- defaultVoiceMode &&
293
- !isTextOnly &&
294
- convaiClient.state.isConnected &&
295
- !hasEnteredDefaultVoiceMode &&
296
- !isVoiceMode) {
297
- const enterVoiceMode = async () => {
298
- try {
299
- await convaiClient.audioControls.unmuteAudio();
300
- setIsVoiceMode(true);
301
- setHasEnteredDefaultVoiceMode(true);
302
- }
303
- catch (error) {
304
- console.error("Failed to enter voice mode:", error);
305
- }
306
- };
307
- enterVoiceMode();
308
- }
309
- }, [isOpen, defaultVoiceMode, isTextOnly, convaiClient.state.isConnected, hasEnteredDefaultVoiceMode, isVoiceMode, convaiClient]);
310
- // Close settings when clicking outside
311
- useEffect(() => {
312
- const handleClickOutside = (event) => {
313
- if (isSettingsOpen && settingsButtonRef.current) {
314
- const target = event.target;
315
- const settingsButton = settingsButtonRef.current;
316
- if (!settingsButton.contains(target)) {
317
- const settingsTray = document.querySelector("[data-settings-tray]");
318
- if (settingsTray && !settingsTray.contains(target)) {
319
- setIsSettingsOpen(false);
320
- }
321
- }
322
- }
323
- };
324
- if (isSettingsOpen) {
325
- document.addEventListener("mousedown", handleClickOutside);
326
- }
327
- return () => {
328
- document.removeEventListener("mousedown", handleClickOutside);
329
- };
330
- }, [isSettingsOpen]);
331
- // Determine logo state and color
332
- const getLogoState = () => {
333
- if (convaiClient.state.isConnecting)
334
- return "connecting";
335
- if (convaiClient.state.isConnected)
336
- return "connected";
337
- return "idle";
338
- };
339
- const getLogoColor = () => {
340
- if (convaiClient.state.isConnected)
341
- return aeroTheme.colors.primary[500]; // Green when connected
342
- if (convaiClient.state.isConnecting)
343
- return aeroTheme.colors.primary[300]; // Lighter green when connecting
344
- return aeroTheme.colors.primary[500]; // Default green
345
- };
346
- // Audio renderer for LiveKit direct audio playback (not used in WebSocket mode)
347
- const audioRendererRef = useRef(null);
348
- useEffect(() => {
349
- if (!convaiClient.room || convaiClient.room.state !== "connected")
350
- return;
351
- audioRendererRef.current = new AudioRenderer(convaiClient.room);
352
- return () => {
353
- if (audioRendererRef.current) {
354
- audioRendererRef.current.destroy();
355
- audioRendererRef.current = null;
356
- }
357
- };
358
- }, [convaiClient.room, convaiClient.state.isConnected]);
359
- return (_jsxs(RoomContext.Provider, { value: convaiClient.room?.state === "connected" ? convaiClient.room : undefined, children: [_jsxs(ConvaiContainer, { initial: { opacity: 0, scale: 0.8 }, animate: { opacity: 1, scale: 1 }, transition: { duration: 0.4, ease: "easeOut" }, children: [_jsxs(MorphingContainer, { onClick: !isOpen ? handleToggle : undefined, whileHover: !isOpen ? { scale: 1.05 } : undefined, whileTap: !isOpen ? { scale: 0.95 } : undefined, animate: {
360
- width: isOpen ? "400px" : "4rem",
361
- height: isOpen ? "600px" : "4rem",
362
- borderRadius: isOpen ? aeroTheme.borderRadius.xl : "50%",
363
- }, transition: { duration: 0.3, ease: "easeInOut" }, style: { cursor: !isOpen ? "pointer" : "default" }, children: [_jsx(ButtonContent, { animate: {
364
- opacity: isOpen ? 0 : 1,
365
- scale: isOpen ? 0.8 : 1,
366
- }, transition: { duration: 0.3 }, children: _jsx(Logo, { children: _jsx(ConvaiLogo, { size: "xl", color: getLogoColor(), animate: convaiClient.state.isConnecting, state: getLogoState() }) }) }), convaiClient.state.isConnected && (_jsxs(ChatContent, { animate: {
367
- opacity: isOpen ? 1 : 0,
368
- scale: isOpen ? 1 : 0.8,
369
- }, transition: {
370
- duration: 0.2,
371
- delay: isOpen ? 0.2 : 0,
372
- }, style: {
373
- pointerEvents: isOpen ? "auto" : "none",
374
- }, children: [_jsxs(Header, { initial: { opacity: 0, y: -20 }, animate: {
375
- opacity: isOpen ? 1 : 0,
376
- y: isOpen ? 0 : -20,
377
- }, transition: {
378
- delay: isOpen ? 0.4 : 0,
379
- ...iosTransitions.modalSlide,
380
- }, style: {
381
- pointerEvents: isOpen ? "auto" : "none",
382
- minHeight: "3.5rem", // Ensure consistent height
383
- }, children: [_jsx(CloseButton, { onClick: handleClose, whileHover: { scale: 1.1 }, whileTap: { scale: 0.9 }, transition: iosTransitions.snappy, style: { cursor: "pointer", pointerEvents: "auto" }, children: _jsx(ChevronDown, { size: "md" }) }), _jsxs(Title, { children: [selectedCharacter.image && !showVoiceMode && (_jsx(motion.img, { src: selectedCharacter.image, alt: selectedCharacter.name, initial: { scale: 0.8, opacity: 0 }, animate: { scale: 1, opacity: 1 }, exit: { scale: 0.8, opacity: 0 }, transition: iosTransitions.fadePop, style: {
384
- width: "1.5rem",
385
- height: "1.5rem",
386
- borderRadius: "50%",
387
- objectFit: "cover",
388
- marginRight: "0.5rem",
389
- border: `1.5px solid ${getBotStatusColor().color}`,
390
- boxShadow: `0 0 6px ${getBotStatusColor().color}40`,
391
- transition: "all 0.3s ease",
392
- } }, "header-avatar" // Use key instead of layoutId for independent animation
393
- )), selectedCharacter.name, _jsx(motion.button, { onClick: handleToggleMute, whileHover: { scale: 1.1 }, whileTap: { scale: 0.9 }, transition: iosTransitions.snappy, style: {
394
- cursor: "pointer",
395
- pointerEvents: "auto",
396
- background: "transparent",
397
- border: "none",
398
- boxShadow: "none",
399
- width: "auto",
400
- height: "auto",
401
- padding: "0",
402
- display: "inline-flex",
403
- alignItems: "center",
404
- marginLeft: "0.5rem",
405
- outline: "none",
406
- }, "aria-label": isMuted ? "Unmute" : "Mute", title: isMuted ? "Unmute" : "Mute", children: isMuted ? (_jsx(IoVolumeMute, { size: 16, color: "#919EABA6" })) : (_jsx(IoVolumeHigh, { size: 16, color: "#0E7360" })) }), showVoiceMode && (_jsx("span", { style: {
407
- fontSize: "10px",
408
- color: aeroTheme.colors.convai.light,
409
- fontWeight: 500,
410
- marginLeft: "8px",
411
- padding: "2px 6px",
412
- borderRadius: "4px",
413
- backgroundColor: aeroTheme.colors.convai.light + "20",
414
- }, children: "VOICE" })), convaiClient.state.isSpeaking && (_jsxs(motion.span, { initial: { scale: 0.8, opacity: 0 }, animate: { scale: 1, opacity: 1 }, exit: { scale: 0.8, opacity: 0 }, transition: { duration: 0.2 }, style: {
415
- fontSize: "10px",
416
- color: "#10b981",
417
- fontWeight: 600,
418
- marginLeft: "8px",
419
- padding: "3px 8px",
420
- borderRadius: "6px",
421
- backgroundColor: "#10b98120",
422
- border: "1px solid #10b98140",
423
- display: "inline-flex",
424
- alignItems: "center",
425
- gap: "4px",
426
- }, children: [_jsx(motion.span, { animate: {
427
- scale: [1, 1.2, 1],
428
- opacity: [1, 0.7, 1],
429
- }, transition: {
430
- duration: 1.5,
431
- repeat: Infinity,
432
- ease: "easeInOut",
433
- }, style: {
434
- width: "6px",
435
- height: "6px",
436
- borderRadius: "50%",
437
- backgroundColor: "#10b981",
438
- display: "inline-block",
439
- } }), "SPEAKING"] })), convaiClient.state.isListening && !convaiClient.state.isSpeaking && (_jsxs(motion.span, { initial: { scale: 0.8, opacity: 0 }, animate: { scale: 1, opacity: 1 }, exit: { scale: 0.8, opacity: 0 }, transition: { duration: 0.2 }, style: {
440
- fontSize: "10px",
441
- color: "#3b82f6",
442
- fontWeight: 600,
443
- marginLeft: "8px",
444
- padding: "3px 8px",
445
- borderRadius: "6px",
446
- backgroundColor: "#3b82f620",
447
- border: "1px solid #3b82f640",
448
- display: "inline-flex",
449
- alignItems: "center",
450
- gap: "4px",
451
- }, children: [_jsx(motion.span, { animate: {
452
- scale: [1, 1.2, 1],
453
- opacity: [1, 0.7, 1],
454
- }, transition: {
455
- duration: 1.5,
456
- repeat: Infinity,
457
- ease: "easeInOut",
458
- }, style: {
459
- width: "6px",
460
- height: "6px",
461
- borderRadius: "50%",
462
- backgroundColor: "#3b82f6",
463
- display: "inline-block",
464
- } }), "LISTENING"] }))] }), _jsx("div", { style: {
465
- display: "flex",
466
- alignItems: "center",
467
- gap: "0.5rem",
468
- position: "relative",
469
- }, children: _jsx(SettingsButton, { ref: settingsButtonRef, onClick: handleSettingsToggle, whileHover: { scale: 1.1 }, whileTap: { scale: 0.9 }, transition: iosTransitions.snappy, style: { cursor: "pointer" }, children: _jsx(FiMoreVertical, { size: 20 }) }) })] }), _jsxs(Content, { style: {
470
- background: showVoiceMode
471
- ? "rgba(255, 255, 255, 0.98)"
472
- : "transparent",
473
- filter: isSettingsOpen ? "blur(3px)" : "none",
474
- position: "relative",
475
- }, children: [_jsx(AnimatePresence, { children: convaiClient.state.isConnected && !convaiClient.isBotReady && (_jsxs(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.3 }, style: {
476
- position: "absolute",
477
- top: 0,
478
- left: 0,
479
- right: 0,
480
- bottom: 0,
481
- display: "flex",
482
- flexDirection: "column",
483
- alignItems: "center",
484
- justifyContent: "center",
485
- backgroundColor: "rgba(255, 255, 255, 0.95)",
486
- zIndex: 100,
487
- gap: "1rem",
488
- }, children: [_jsx(motion.div, { animate: {
489
- rotate: 360,
490
- }, transition: {
491
- duration: 2,
492
- repeat: Infinity,
493
- ease: "linear",
494
- }, children: _jsx(ConvaiLogo, { size: "xl", color: aeroTheme.colors.convai.light, state: "connecting" }) }), _jsxs(motion.div, { animate: {
495
- opacity: [0.5, 1, 0.5],
496
- }, transition: {
497
- duration: 2,
498
- repeat: Infinity,
499
- ease: "easeInOut",
500
- }, style: {
501
- fontSize: "14px",
502
- fontWeight: 500,
503
- color: aeroTheme.colors.text.secondary,
504
- }, children: ["Connecting to ", selectedCharacter.name, "..."] })] })) }), showVoiceMode && (_jsx(VoiceModeOverlay, { isActive: !convaiClient.isAudioMuted, isTalking: convaiClient.state.isSpeaking, isListening: convaiClient.state.isListening, convaiClient: null, characterImage: characterImage || undefined, characterName: characterName || undefined, room: convaiClient.room?.state === "connected" ? convaiClient.room : null })), !showVoiceMode && (_jsx(MessageList, { messages: formatMessages(), isStreaming: convaiClient.state.isSpeaking, forceToBottomToken: `${isOpen}-${convaiClient.chatMessages.length}`, linkPreviewResolver: linkPreviewResolver }))] }), _jsx(Footer, { initial: { y: 20, opacity: 0 }, animate: { y: 0, opacity: 1 }, transition: {
505
- delay: 0.7,
506
- ...iosTransitions.modalSlide,
507
- }, style: {
508
- filter: isSettingsOpen ? "blur(3px)" : "none",
509
- transition: "filter 0.2s ease",
510
- display: "flex",
511
- gap: "0.5rem",
512
- alignItems: "center",
513
- position: "relative",
514
- justifyContent: showVoiceMode ? "center" : "flex-start",
515
- minHeight: "3.5rem", // Ensure consistent height
516
- }, children: showVoiceMode ? (_jsx(motion.button, { initial: { scale: 0.8, opacity: 0 }, animate: { scale: 1, opacity: 1 }, exit: { scale: 0.8, opacity: 0 }, transition: {
517
- duration: 0.3,
518
- ease: "easeOut",
519
- }, onClick: async () => {
520
- convaiClient.sendInterruptMessage();
521
- await convaiClient.audioControls.muteAudio();
522
- // WebSocket: tell server to stop processing audio so the
523
- // character doesn't prompt "tap microphone to talk" on silence.
524
- if (convaiClient.room?.state !== "connected") {
525
- convaiClient.toggleStt(false);
526
- }
527
- setIsVoiceMode(false);
528
- // Leaving early also cancels a still-pending default.
529
- setHasEnteredDefaultVoiceMode(true);
530
- }, whileHover: { scale: 1.1 }, whileTap: { scale: 0.9 }, style: {
531
- cursor: "pointer",
532
- backgroundColor: "#ef4444",
533
- color: "#ffffff",
534
- border: "none",
535
- borderRadius: "50%",
536
- width: "2.25rem",
537
- height: "2.25rem",
538
- minWidth: "2.25rem",
539
- minHeight: "2.25rem",
540
- display: "flex",
541
- alignItems: "center",
542
- justifyContent: "center",
543
- flexShrink: 0,
544
- padding: 0,
545
- outline: "none",
546
- }, "aria-label": "Exit Voice Mode", title: "Exit voice mode", children: _jsx(FiPhoneOff, { size: 20 }) }, "voice-mode-exit")) : (_jsx(_Fragment, { children: _jsxs(InputContainer, { style: { flex: 1, position: "relative" }, children: [_jsx(Input, { type: "text", placeholder: "Conversation", value: inputValue, onChange: handleInputChange, onKeyPress: handleKeyPress, disabled: !canSendText, style: { paddingRight: "2.75rem" } }), _jsx("div", { style: {
547
- position: "absolute",
548
- right: "0.375rem",
549
- top: "50%",
550
- transform: "translateY(-50%)",
551
- width: "2.25rem",
552
- height: "2.25rem",
553
- minWidth: "2.25rem",
554
- minHeight: "2.25rem",
555
- flexShrink: 0,
556
- overflow: "visible",
557
- display: "flex",
558
- alignItems: "center",
559
- justifyContent: "center",
560
- zIndex: 2,
561
- }, children: _jsx(AnimatePresence, { mode: "wait", children: inputValue.length > 0 || isTextOnly ? (_jsx(ActionButton, { initial: { y: "100%" }, animate: { y: "0%" }, exit: { y: "-100%" }, transition: {
562
- duration: 0.1,
563
- ease: "linear",
564
- }, onClick: handleSend, disabled: inputValue.length === 0 || !canSendText, whileTap: { scale: 0.9 }, style: {
565
- position: "absolute",
566
- top: 0,
567
- left: 0,
568
- cursor: "pointer",
569
- }, children: _jsx(FiSend, { size: 20 }) }, "send")) : (_jsx(motion.button, { initial: { y: "100%" }, animate: { y: "0%" }, exit: { y: "-100%" }, transition: {
570
- duration: 0.1,
571
- ease: "linear",
572
- }, onClick: async () => {
573
- convaiClient.sendInterruptMessage();
574
- // WebSocket: re-enable server STT before unmuting.
575
- if (convaiClient.room?.state !== "connected") {
576
- convaiClient.toggleStt(true);
577
- }
578
- await convaiClient.audioControls.unmuteAudio();
579
- setIsVoiceMode(true);
580
- }, whileHover: { scale: 1.1 }, whileTap: { scale: 0.9 }, style: {
581
- position: "absolute",
582
- top: 0,
583
- left: 0,
584
- cursor: "pointer",
585
- backgroundColor: "transparent",
586
- color: aeroTheme.colors.text.primary,
587
- border: `1px solid ${aeroTheme.colors.neutral[300]}`,
588
- borderRadius: "50%",
589
- width: "2.25rem",
590
- height: "2.25rem",
591
- minWidth: "2.25rem",
592
- minHeight: "2.25rem",
593
- display: "flex",
594
- alignItems: "center",
595
- justifyContent: "center",
596
- flexShrink: 0,
597
- padding: 0,
598
- outline: "none",
599
- }, "aria-label": "Enter Voice Mode", title: "Use voice mode", children: _jsx(PiWaveform, { size: 20 }) }, "voice")) }) })] }) })) })] }))] }), convaiClient.state.isConnected && (_jsx(SettingsTray, { isOpen: isSettingsOpen, onReset: convaiClient.isPublishedChatSession && !requestPublicationGrant
600
- ? undefined
601
- : handleReset, onDisconnect: convaiClient.isPublishedChatSession && !requestPublicationGrant
602
- ? undefined
603
- : handleDisconnect, onToggleVideo: convaiClient.connectionType === "video" && showVideo
604
- ? handleToggleVideo
605
- : undefined, isVideoVisible: isVideoVisible, onToggleScreenShare: convaiClient.connectionType === "video" && showScreenShare
606
- ? handleToggleScreenShare
607
- : undefined, isScreenShareActive: convaiClient.isScreenShareActive }))] }), convaiClient.room?.state === "connected" && (_jsx(FloatingVideo, { isVisible: isVideoVisible, onClose: async () => {
608
- await convaiClient.videoControls.disableVideo();
609
- }, mirror: true }))] }));
610
- };
@@ -1 +0,0 @@
1
- export { ConvaiWidget } from './ConvaiWidget.js';
@@ -1,2 +0,0 @@
1
- // Main widget component
2
- export { ConvaiWidget } from './ConvaiWidget.js';
@@ -1,9 +0,0 @@
1
- import React from "react";
2
- import { AudioSettings } from "../../../../core/types.js";
3
- interface AudioSettingsPanelProps {
4
- currentSettings: AudioSettings;
5
- onUpdateSettings: (settings: Partial<AudioSettings>) => Promise<void>;
6
- isConnected: boolean;
7
- }
8
- export declare const AudioSettingsPanel: React.FC<AudioSettingsPanelProps>;
9
- export {};