@convai/web-sdk 1.9.1 → 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 (86) hide show
  1. package/README.md +25 -14
  2. package/dist/core/ConvaiClient.js +10 -1
  3. package/dist/core/types.d.ts +13 -3
  4. package/dist/core/websocketUrl.d.ts +11 -0
  5. package/dist/core/websocketUrl.js +17 -0
  6. package/dist/react/hooks/index.d.ts +0 -2
  7. package/dist/react/hooks/index.js +0 -3
  8. package/dist/react/index.d.ts +0 -3
  9. package/dist/react/index.js +3 -10
  10. package/dist/utils/inlineMarkdown.d.ts +7 -5
  11. package/dist/utils/inlineMarkdown.js +7 -5
  12. package/dist/vanilla/WebSocketSession.d.ts +19 -13
  13. package/dist/vanilla/WebSocketSession.js +58 -14
  14. package/dist/vanilla/index.d.ts +6 -18
  15. package/dist/vanilla/index.js +7 -19
  16. package/dist/version.d.ts +1 -1
  17. package/dist/version.js +1 -1
  18. package/package.json +9 -8
  19. package/dist/react/components/ConvaiWidget.d.ts +0 -86
  20. package/dist/react/components/ConvaiWidget.js +0 -610
  21. package/dist/react/components/index.d.ts +0 -1
  22. package/dist/react/components/index.js +0 -2
  23. package/dist/react/components/rtc-widget/components/AudioSettingsPanel.d.ts +0 -9
  24. package/dist/react/components/rtc-widget/components/AudioSettingsPanel.js +0 -315
  25. package/dist/react/components/rtc-widget/components/AudioVisualizer.d.ts +0 -35
  26. package/dist/react/components/rtc-widget/components/AudioVisualizer.js +0 -285
  27. package/dist/react/components/rtc-widget/components/ConviMessage.d.ts +0 -12
  28. package/dist/react/components/rtc-widget/components/ConviMessage.js +0 -13
  29. package/dist/react/components/rtc-widget/components/FloatingVideo.d.ts +0 -8
  30. package/dist/react/components/rtc-widget/components/FloatingVideo.js +0 -120
  31. package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts +0 -31
  32. package/dist/react/components/rtc-widget/components/MarkdownRenderer.js +0 -140
  33. package/dist/react/components/rtc-widget/components/MessageBubble.d.ts +0 -9
  34. package/dist/react/components/rtc-widget/components/MessageBubble.js +0 -22
  35. package/dist/react/components/rtc-widget/components/MessageList.d.ts +0 -13
  36. package/dist/react/components/rtc-widget/components/MessageList.js +0 -88
  37. package/dist/react/components/rtc-widget/components/SiteCard.d.ts +0 -14
  38. package/dist/react/components/rtc-widget/components/SiteCard.js +0 -34
  39. package/dist/react/components/rtc-widget/components/UserMessage.d.ts +0 -8
  40. package/dist/react/components/rtc-widget/components/UserMessage.js +0 -14
  41. package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.d.ts +0 -5
  42. package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.js +0 -14
  43. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.d.ts +0 -24
  44. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.js +0 -170
  45. package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.d.ts +0 -16
  46. package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.js +0 -64
  47. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.d.ts +0 -11
  48. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.js +0 -65
  49. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.d.ts +0 -13
  50. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js +0 -298
  51. package/dist/react/components/rtc-widget/components/conviComponents/index.d.ts +0 -5
  52. package/dist/react/components/rtc-widget/components/conviComponents/index.js +0 -5
  53. package/dist/react/components/rtc-widget/components/index.d.ts +0 -8
  54. package/dist/react/components/rtc-widget/components/index.js +0 -14
  55. package/dist/react/components/rtc-widget/index.d.ts +0 -5
  56. package/dist/react/components/rtc-widget/index.js +0 -8
  57. package/dist/react/components/rtc-widget/styles/framerConfig.d.ts +0 -115
  58. package/dist/react/components/rtc-widget/styles/framerConfig.js +0 -72
  59. package/dist/react/components/rtc-widget/styles/icons.d.ts +0 -27
  60. package/dist/react/components/rtc-widget/styles/icons.js +0 -256
  61. package/dist/react/components/rtc-widget/styles/index.d.ts +0 -5
  62. package/dist/react/components/rtc-widget/styles/index.js +0 -8
  63. package/dist/react/components/rtc-widget/styles/styledComponents.d.ts +0 -89
  64. package/dist/react/components/rtc-widget/styles/styledComponents.js +0 -662
  65. package/dist/react/components/rtc-widget/styles/theme.d.ts +0 -187
  66. package/dist/react/components/rtc-widget/styles/theme.js +0 -289
  67. package/dist/react/components/rtc-widget/types/index.d.ts +0 -59
  68. package/dist/react/components/rtc-widget/types/index.js +0 -1
  69. package/dist/react/hooks/useCharacterInfo.d.ts +0 -18
  70. package/dist/react/hooks/useCharacterInfo.js +0 -65
  71. package/dist/react/hooks/useLocalCameraTrack.d.ts +0 -21
  72. package/dist/react/hooks/useLocalCameraTrack.js +0 -33
  73. package/dist/react/icons.d.ts +0 -37
  74. package/dist/react/icons.js +0 -53
  75. package/dist/utils/lightbox.d.ts +0 -15
  76. package/dist/utils/lightbox.js +0 -94
  77. package/dist/vanilla/ConvaiWidget.d.ts +0 -46
  78. package/dist/vanilla/ConvaiWidget.js +0 -2866
  79. package/dist/vanilla/WidgetEventSubscriptions.d.ts +0 -14
  80. package/dist/vanilla/WidgetEventSubscriptions.js +0 -36
  81. package/dist/vanilla/icons.d.ts +0 -34
  82. package/dist/vanilla/icons.js +0 -268
  83. package/dist/vanilla/styles.d.ts +0 -168
  84. package/dist/vanilla/styles.js +0 -407
  85. package/dist/vanilla/types.d.ts +0 -170
  86. package/dist/vanilla/types.js +0 -1
@@ -1,170 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { AnimatePresence, motion } from "framer-motion";
3
- import { FiMic, FiSend, PiWaveform } from "../../../../icons.js";
4
- import { aeroTheme } from "../../styles/theme.js";
5
- import { iosTransitions } from "../../styles/framerConfig.js";
6
- import { Footer, InputContainer, Input, ActionButton, } from "../../styles/styledComponents.js";
7
- export const ConviFooter = ({ inputMode, inputValue, liveUserText, chatbotMic, localIsTyping, convaiIsTyping, isCreatingSpeaker, isPressingMic, isSettingsOpen, isVoiceMode, onInputChange, onKeyPress, onSend, onMicPress, onMicRelease, setIsPressingMic, onToggleVoiceMode, verbosityChanged = false, onContinue, }) => {
8
- // Show Continue button in verbosity mode
9
- if (inputMode === "verbosity") {
10
- return (_jsx(Footer, { initial: { y: 20, opacity: 0 }, animate: { y: 0, opacity: 1 }, transition: {
11
- delay: 0.7,
12
- ...iosTransitions.modalSlide,
13
- }, style: {
14
- filter: isSettingsOpen ? "blur(3px)" : "none",
15
- transition: "filter 0.2s ease",
16
- padding: "0 !important",
17
- }, children: _jsx("div", { style: {
18
- width: "100%",
19
- height: "100%",
20
- padding: "1rem",
21
- }, children: _jsx(motion.button, { onClick: onContinue, whileTap: verbosityChanged ? { scale: 0.98 } : {}, disabled: !verbosityChanged, style: {
22
- // Full width and height (custom)
23
- width: "100%",
24
- height: "100%",
25
- minHeight: "3rem",
26
- // ActionButton base styles
27
- border: "none",
28
- borderRadius: "12px",
29
- display: "flex",
30
- alignItems: "center",
31
- justifyContent: "center",
32
- cursor: verbosityChanged ? "pointer" : "not-allowed",
33
- outline: "none",
34
- padding: 0,
35
- isolation: "isolate",
36
- // Custom appearance
37
- backgroundColor: verbosityChanged
38
- ? aeroTheme.colors.text.primary
39
- : aeroTheme.colors.neutral[400],
40
- color: "#ffffff",
41
- fontSize: "14px",
42
- fontWeight: 600,
43
- opacity: verbosityChanged ? 1 : 0.4,
44
- transition: aeroTheme.transitions.normal,
45
- }, children: "Continue" }) }) }));
46
- }
47
- return (_jsxs(Footer, { initial: { y: 20, opacity: 0 }, animate: { y: 0, opacity: 1 }, transition: {
48
- delay: 0.7,
49
- ...iosTransitions.modalSlide,
50
- }, style: {
51
- filter: isSettingsOpen ? "blur(3px)" : "none",
52
- transition: "filter 0.2s ease",
53
- display: "flex",
54
- gap: "0.5rem",
55
- alignItems: "center",
56
- position: "relative",
57
- }, children: [_jsx(motion.div, { initial: false, animate: inputMode === "voice"
58
- ? {
59
- position: "absolute",
60
- left: "calc(50% - 1.125rem)", // Center position (half of 2.25rem button width)
61
- }
62
- : {
63
- position: "relative",
64
- left: 0,
65
- }, transition: {
66
- delay: inputMode === "voice" ? 0.2 : 0,
67
- duration: 0.35,
68
- ease: [0.4, 0.0, 0.2, 1], // Material Design easing
69
- }, style: {
70
- position: inputMode === "voice" ? "absolute" : "relative",
71
- width: "2.25rem",
72
- height: "2.25rem",
73
- minWidth: "2.25rem",
74
- minHeight: "2.25rem",
75
- flexShrink: 0,
76
- zIndex: inputMode === "voice" ? 10 : 1,
77
- }, children: _jsx(ActionButton, { animate: {
78
- backgroundColor: isPressingMic || chatbotMic
79
- ? aeroTheme.colors.convai.light
80
- : aeroTheme.colors.text.primary,
81
- color: isPressingMic || chatbotMic
82
- ? aeroTheme.colors.text.inverse
83
- : "#ffffff",
84
- }, transition: {
85
- backgroundColor: { duration: 0.15, ease: "easeOut" },
86
- color: { duration: 0.15, ease: "easeOut" },
87
- },
88
- // Press-and-hold to talk
89
- onMouseDown: () => {
90
- setIsPressingMic(true);
91
- onMicPress();
92
- }, onMouseUp: () => {
93
- setIsPressingMic(false);
94
- onMicRelease();
95
- }, onMouseLeave: () => {
96
- setIsPressingMic(false);
97
- if (chatbotMic)
98
- onMicRelease();
99
- }, onTouchStart: () => {
100
- setIsPressingMic(true);
101
- onMicPress();
102
- }, onTouchEnd: () => {
103
- setIsPressingMic(false);
104
- onMicRelease();
105
- }, "aria-pressed": chatbotMic, "$active": isPressingMic || chatbotMic, whileTap: { scale: 0.9 }, style: {
106
- cursor: "pointer",
107
- borderRadius: "50%",
108
- }, children: _jsx(FiMic, { size: 20 }) }) }), _jsxs(InputContainer, { style: { flex: 1, position: "relative" }, children: [_jsx(AnimatePresence, { children: inputMode !== "voice" && inputMode !== "speaker" && (_jsx(motion.div, { initial: { opacity: 1 }, exit: {
109
- opacity: 0,
110
- width: 0,
111
- transition: { duration: 0.3, ease: "easeInOut" },
112
- }, style: {
113
- flex: 1,
114
- display: "flex",
115
- overflow: "hidden",
116
- paddingRight: "2.75rem",
117
- }, children: _jsx(Input, { type: "text", placeholder: "Conversation", value: chatbotMic ? liveUserText : inputValue, onChange: onInputChange, onKeyPress: onKeyPress, disabled: chatbotMic || isCreatingSpeaker }) })) }), inputMode !== "speaker" && (_jsx("div", { style: {
118
- position: "absolute",
119
- right: "0.375rem", // Match the InputContainer padding
120
- top: "50%",
121
- transform: "translateY(-50%)",
122
- width: "2.25rem",
123
- height: "2.25rem",
124
- minWidth: "2.25rem",
125
- minHeight: "2.25rem",
126
- flexShrink: 0,
127
- overflow: "visible",
128
- display: "flex",
129
- alignItems: "center",
130
- justifyContent: "center",
131
- zIndex: 2,
132
- }, children: _jsx(AnimatePresence, { mode: "wait", children: localIsTyping || convaiIsTyping ? (_jsx(ActionButton, { initial: { y: "100%" }, animate: { y: "0%" }, exit: { y: "-100%" }, transition: {
133
- duration: 0.1,
134
- ease: "linear",
135
- }, onClick: onSend, whileTap: { scale: 0.9 }, style: {
136
- position: "absolute",
137
- top: 0,
138
- left: 0,
139
- cursor: "pointer",
140
- opacity: isCreatingSpeaker ? 0.5 : 1,
141
- }, disabled: isCreatingSpeaker, children: _jsx(FiSend, { size: 20 }) }, "send")) : (_jsx(motion.button, { initial: { y: "100%" }, animate: { y: "0%" }, exit: { y: "-100%" }, transition: {
142
- duration: 0.1,
143
- ease: "linear",
144
- }, onClick: onToggleVoiceMode, whileHover: { scale: 1.1 }, whileTap: { scale: 0.9 }, style: {
145
- position: "absolute",
146
- top: 0,
147
- left: 0,
148
- cursor: "pointer",
149
- backgroundColor: isVoiceMode
150
- ? "#ef4444"
151
- : "transparent",
152
- color: isVoiceMode
153
- ? "#ffffff"
154
- : aeroTheme.colors.text.primary,
155
- border: isVoiceMode
156
- ? "none"
157
- : `1px solid ${aeroTheme.colors.neutral[300]}`,
158
- borderRadius: "50%",
159
- width: "2.25rem",
160
- height: "2.25rem",
161
- minWidth: "2.25rem",
162
- minHeight: "2.25rem",
163
- display: "flex",
164
- alignItems: "center",
165
- justifyContent: "center",
166
- flexShrink: 0,
167
- padding: 0,
168
- outline: "none",
169
- }, "aria-label": "Voice Mode", title: isVoiceMode ? "exit voice mode" : "use voice mode", children: _jsx(PiWaveform, { size: 20 }) }, "voice")) }) }))] })] }));
170
- };
@@ -1,16 +0,0 @@
1
- import React from "react";
2
- interface ConviHeaderProps {
3
- isOpen: boolean;
4
- isSpeakerEditMode: boolean;
5
- isVoiceMode: boolean;
6
- isVerbosityMode: boolean;
7
- isMuted: boolean;
8
- characterImage?: string;
9
- characterName?: string;
10
- onClose: () => void;
11
- onSettingsToggle: () => void;
12
- onToggleMute: () => void;
13
- settingsButtonRef: React.RefObject<HTMLButtonElement>;
14
- }
15
- export declare const ConviHeader: ({ isOpen, isSpeakerEditMode, isVoiceMode, isVerbosityMode, isMuted, characterImage, characterName, onClose, onSettingsToggle, onToggleMute, settingsButtonRef, }: ConviHeaderProps) => import("react/jsx-runtime").JSX.Element;
16
- export {};
@@ -1,64 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { motion } from "framer-motion";
3
- import { FiMoreVertical, IoVolumeHigh, IoVolumeMute } from "../../../../icons.js";
4
- import { ChevronDown } from "../../styles/icons.js";
5
- import { aeroTheme } from "../../styles/theme.js";
6
- import { iosTransitions } from "../../styles/framerConfig.js";
7
- import { Header, Title, CloseButton, SettingsButton, } from "../../styles/styledComponents.js";
8
- export const ConviHeader = ({ isOpen, isSpeakerEditMode, isVoiceMode, isVerbosityMode, isMuted, characterImage, characterName = "Character", onClose, onSettingsToggle, onToggleMute, settingsButtonRef, }) => {
9
- return (_jsxs(Header, { initial: { opacity: 0, y: -20 }, animate: {
10
- opacity: isOpen ? 1 : 0,
11
- y: isOpen ? 0 : -20,
12
- }, transition: {
13
- delay: isOpen ? 0.4 : 0,
14
- ...iosTransitions.modalSlide,
15
- }, children: [_jsx(CloseButton, { onClick: onClose, whileHover: { scale: 1.1 }, whileTap: { scale: 0.9 }, transition: iosTransitions.snappy, style: { cursor: "pointer" }, children: _jsx(ChevronDown, { size: "md" }) }), _jsxs(Title, { children: [characterImage && !isVoiceMode && (_jsx(motion.img, { layoutId: "character-avatar", src: characterImage, alt: characterName, transition: iosTransitions.fadePop, style: {
16
- width: "1.5rem",
17
- height: "1.5rem",
18
- borderRadius: "50%",
19
- objectFit: "cover",
20
- marginRight: "0.5rem",
21
- } })), characterName, _jsx(motion.button, { onClick: onToggleMute, whileHover: { scale: 1.1 }, whileTap: { scale: 0.9 }, transition: iosTransitions.snappy, style: {
22
- cursor: "pointer",
23
- pointerEvents: "auto",
24
- background: "transparent",
25
- border: "none",
26
- boxShadow: "none",
27
- width: "auto",
28
- height: "auto",
29
- padding: "0",
30
- display: "inline-flex",
31
- alignItems: "center",
32
- marginLeft: "0.5rem",
33
- outline: "none",
34
- }, "aria-label": isMuted ? "Unmute" : "Mute", title: isMuted ? "Unmute" : "Mute", children: isMuted ? (_jsx(IoVolumeMute, { size: 16, color: "#919EABA6" })) : (_jsx(IoVolumeHigh, { size: 16, color: "#0E7360" })) }), isSpeakerEditMode && (_jsx("span", { style: {
35
- fontSize: "10px",
36
- color: aeroTheme.colors.convai.light,
37
- fontWeight: 500,
38
- marginLeft: "8px",
39
- padding: "2px 6px",
40
- borderRadius: "4px",
41
- backgroundColor: aeroTheme.colors.convai.light + "20",
42
- }, children: "EDIT" })), isVoiceMode && (_jsx("span", { style: {
43
- fontSize: "10px",
44
- color: aeroTheme.colors.convai.light,
45
- fontWeight: 500,
46
- marginLeft: "8px",
47
- padding: "2px 6px",
48
- borderRadius: "4px",
49
- backgroundColor: aeroTheme.colors.convai.light + "20",
50
- }, children: "VOICE" })), isVerbosityMode && (_jsx("span", { style: {
51
- fontSize: "10px",
52
- color: aeroTheme.colors.convai.light,
53
- fontWeight: 500,
54
- marginLeft: "8px",
55
- padding: "2px 6px",
56
- borderRadius: "4px",
57
- backgroundColor: aeroTheme.colors.convai.light + "20",
58
- }, children: "VERBOSITY" }))] }), _jsx("div", { style: {
59
- display: "flex",
60
- alignItems: "center",
61
- gap: "0.5rem",
62
- position: "relative",
63
- }, children: _jsx(SettingsButton, { ref: settingsButtonRef, onClick: onSettingsToggle, whileHover: { scale: 1.1 }, whileTap: { scale: 0.9 }, transition: iosTransitions.snappy, style: { cursor: "pointer" }, children: _jsx(FiMoreVertical, { size: 20 }) }) })] }));
64
- };
@@ -1,11 +0,0 @@
1
- interface SettingsTrayProps {
2
- isOpen: boolean;
3
- isVideoVisible?: boolean;
4
- isScreenShareActive?: boolean;
5
- onReset?: () => void;
6
- onDisconnect?: () => void;
7
- onToggleVideo?: () => void;
8
- onToggleScreenShare?: () => void;
9
- }
10
- export declare const SettingsTray: ({ isOpen, isVideoVisible, isScreenShareActive, onReset, onDisconnect, onToggleVideo, onToggleScreenShare, }: SettingsTrayProps) => import("react/jsx-runtime").JSX.Element | null;
11
- export {};
@@ -1,65 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { AnimatePresence } from "framer-motion";
3
- import { IoVideocam, IoVideocamOff, LiaRedoAltSolid, MdScreenShare, MdStopScreenShare } from "../../../../icons.js";
4
- import { aeroTheme } from "../../styles/theme.js";
5
- import { iosTransitions } from "../../styles/framerConfig.js";
6
- import { SettingsTray as StyledSettingsTray, SettingsOption, } from "../../styles/styledComponents.js";
7
- export const SettingsTray = ({ isOpen, isVideoVisible, isScreenShareActive, onReset, onDisconnect, onToggleVideo, onToggleScreenShare, }) => {
8
- if (!isOpen)
9
- return null;
10
- return (_jsx(AnimatePresence, { children: _jsx(StyledSettingsTray, { "data-settings-tray": true, initial: { opacity: 0, y: -10, scale: 0.95 }, animate: { opacity: 1, y: 0, scale: 1 }, exit: { opacity: 0, y: -10, scale: 0.95 }, transition: iosTransitions.fadePop, style: {
11
- position: "absolute",
12
- top: "60px",
13
- right: "16px",
14
- zIndex: 9999,
15
- }, onClick: (e) => e.stopPropagation(), children: _jsxs("div", { style: {
16
- display: "flex",
17
- flexDirection: "row",
18
- alignItems: "center",
19
- padding: "8px",
20
- gap: "4px",
21
- }, children: [onReset && (_jsxs(SettingsOption, { onClick: onReset, whileHover: { scale: 1.02 }, whileTap: { scale: 0.98 }, transition: iosTransitions.snappy, style: {
22
- cursor: "pointer",
23
- flexDirection: "column",
24
- gap: "4px",
25
- padding: "8px 12px",
26
- }, "aria-label": "Reset", title: "Reset", children: [_jsx(LiaRedoAltSolid, { size: 18 }), _jsx("span", { style: { fontSize: "10px", fontWeight: 500 }, children: "Reset" })] })), onToggleVideo && (_jsxs(SettingsOption, { onClick: (e) => {
27
- e.stopPropagation();
28
- onToggleVideo();
29
- }, whileHover: { scale: 1.02 }, whileTap: { scale: 0.98 }, transition: iosTransitions.snappy, style: {
30
- cursor: "pointer",
31
- flexDirection: "column",
32
- gap: "4px",
33
- padding: "8px 12px",
34
- backgroundColor: isVideoVisible
35
- ? "rgba(16, 185, 129, 0.15)"
36
- : "transparent",
37
- color: isVideoVisible
38
- ? "#10b981"
39
- : aeroTheme.colors.text.primary,
40
- }, "aria-label": isVideoVisible ? "Hide Video" : "Show Video", title: isVideoVisible ? "Hide Video" : "Show Video", children: [isVideoVisible ? _jsx(IoVideocam, { size: 18 }) : _jsx(IoVideocamOff, { size: 18 }), _jsx("span", { style: { fontSize: "10px", fontWeight: 500 }, children: "Video" })] })), onToggleScreenShare && (_jsxs(SettingsOption, { onClick: (e) => {
41
- e.stopPropagation();
42
- onToggleScreenShare();
43
- }, whileHover: { scale: 1.02 }, whileTap: { scale: 0.98 }, transition: iosTransitions.snappy, style: {
44
- cursor: "pointer",
45
- flexDirection: "column",
46
- gap: "4px",
47
- padding: "8px 12px",
48
- backgroundColor: isScreenShareActive
49
- ? "rgba(16, 185, 129, 0.15)"
50
- : "transparent",
51
- color: isScreenShareActive
52
- ? "#10b981"
53
- : aeroTheme.colors.text.primary,
54
- }, "aria-label": isScreenShareActive ? "Stop Sharing" : "Share Screen", title: isScreenShareActive ? "Stop Sharing" : "Share Screen", children: [isScreenShareActive ? _jsx(MdStopScreenShare, { size: 18 }) : _jsx(MdScreenShare, { size: 18 }), _jsx("span", { style: { fontSize: "10px", fontWeight: 500 }, children: "Screen" })] })), onDisconnect && (_jsxs(SettingsOption, { onClick: (e) => {
55
- e.stopPropagation();
56
- onDisconnect();
57
- }, whileHover: { scale: 1.02 }, whileTap: { scale: 0.98 }, transition: iosTransitions.snappy, style: {
58
- cursor: "pointer",
59
- flexDirection: "column",
60
- gap: "4px",
61
- padding: "8px 12px",
62
- backgroundColor: "rgba(239, 68, 68, 0.1)",
63
- color: "#ef4444",
64
- }, "aria-label": "Disconnect", title: "Disconnect", children: [_jsx("span", { style: { fontSize: "18px" }, children: "\u23FB" }), _jsx("span", { style: { fontSize: "10px", fontWeight: 500 }, children: "Disconnect" })] }))] }) }) }));
65
- };
@@ -1,13 +0,0 @@
1
- import { Room } from "livekit-client";
2
- interface VoiceModeOverlayProps {
3
- isActive: boolean;
4
- isTalking: boolean;
5
- /** When true (user is speaking, from server), show "Listening..." label */
6
- isListening?: boolean;
7
- convaiClient?: any;
8
- characterImage?: string;
9
- characterName?: string;
10
- room?: Room | null;
11
- }
12
- export declare const VoiceModeOverlay: ({ isActive, isTalking, isListening, convaiClient, characterImage, characterName, room, }: VoiceModeOverlayProps) => import("react/jsx-runtime").JSX.Element;
13
- export {};
@@ -1,298 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect, useRef, useState } from "react";
3
- import { motion, AnimatePresence } from "framer-motion";
4
- import { aeroTheme } from "../../styles/theme.js";
5
- import { iosTransitions } from "../../styles/framerConfig.js";
6
- import { AudioVisualizer } from "../AudioVisualizer.js";
7
- export const VoiceModeOverlay = ({ isActive, isTalking, isListening = false, convaiClient, characterImage, characterName = "Character", room, }) => {
8
- const barsCount = 40; // Number of bars for user microphone waveform
9
- // PERF: the waveform is driven OUTSIDE React. A setState per animation
10
- // frame re-rendered the whole overlay (reconcile + style recalc +
11
- // framer-motion filter retarget) ~60x/s — ~30ms main-thread tasks that
12
- // visibly juddered the host page's 3D scene whenever voice mode was
13
- // open. Levels live in a ref and the SVG paths are updated directly.
14
- const audioLevelsRef = useRef(Array(barsCount).fill(0));
15
- const waveCanvasRef = useRef(null);
16
- const analyzerRef = useRef(null);
17
- const animationFrameRef = useRef(undefined);
18
- const audioContextRef = useRef(null);
19
- // Paint the three waves onto a small canvas — no React, no SVG filters.
20
- // (The previous SVG version re-rasterized a 35px drop-shadow blur every
21
- // frame; that GPU paint alone pushed the host page to ~30fps.) Glow is
22
- // approximated with a wide low-alpha understroke, which is ~free.
23
- // Painting is THROTTLED to 30fps and skipped entirely while silent:
24
- // every canvas update forces the compositor to re-blend the whole
25
- // panel stack over the host WebGL canvas, so idle repaints are pure
26
- // waste that judders the 3D scene.
27
- const waveFrameParityRef = useRef(0);
28
- const waveWasSilentRef = useRef(false);
29
- const drawWaves = () => {
30
- waveFrameParityRef.current ^= 1;
31
- if (waveFrameParityRef.current)
32
- return; // 30fps is plenty for a waveform
33
- const canvas = waveCanvasRef.current;
34
- if (!canvas)
35
- return;
36
- {
37
- const lv = audioLevelsRef.current;
38
- let sum = 0;
39
- for (let i = 0; i < lv.length; i++)
40
- sum += lv[i];
41
- const silent = sum / lv.length < 0.012;
42
- if (silent && waveWasSilentRef.current)
43
- return; // static line already drawn
44
- waveWasSilentRef.current = silent;
45
- }
46
- const dpr = Math.min(window.devicePixelRatio || 1, 2);
47
- if (canvas.width !== 250 * dpr) {
48
- canvas.width = 250 * dpr;
49
- canvas.height = 80 * dpr;
50
- }
51
- const ctx = canvas.getContext("2d");
52
- if (!ctx)
53
- return;
54
- ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
55
- ctx.clearRect(0, 0, 250, 80);
56
- const audioLevels = audioLevelsRef.current;
57
- const centerY = 40;
58
- const waveWidth = 250;
59
- const segments = barsCount;
60
- const avgLevel = audioLevels.reduce((sum, level) => sum + level, 0) / audioLevels.length;
61
- const waveColors = [
62
- aeroTheme.colors.convai.light,
63
- aeroTheme.colors.convai.light,
64
- "#34d399",
65
- ];
66
- ctx.lineCap = "round";
67
- ctx.lineJoin = "round";
68
- for (let waveIndex = 2; waveIndex >= 0; waveIndex--) {
69
- ctx.beginPath();
70
- for (let i = 0; i <= segments; i++) {
71
- const x = (i / segments) * waveWidth;
72
- const levelIndex = Math.floor((i / segments) * (audioLevels.length - 1));
73
- const level = audioLevels[levelIndex] || 0;
74
- const phase = (Date.now() / 500 + i * 0.2 + waveIndex * 1.5) % (Math.PI * 2);
75
- const baseAmplitude = avgLevel > 0.05 ? 2 + waveIndex * 1.5 : 0;
76
- const amplitude = baseAmplitude + level * (25 - baseAmplitude);
77
- const y = centerY + Math.sin(phase) * amplitude;
78
- if (i === 0)
79
- ctx.moveTo(x, y);
80
- else
81
- ctx.lineTo(x, y);
82
- }
83
- // glow understroke scaled by level, then the crisp line on top
84
- ctx.strokeStyle = waveColors[waveIndex];
85
- ctx.globalAlpha = 0.18 * (0.3 + avgLevel);
86
- ctx.lineWidth = (2.5 - waveIndex * 0.4) + 8 * avgLevel + 3;
87
- ctx.stroke();
88
- ctx.globalAlpha = 0.95 - waveIndex * 0.15;
89
- ctx.lineWidth = 2.5 - waveIndex * 0.4;
90
- ctx.stroke();
91
- }
92
- ctx.globalAlpha = 1;
93
- };
94
- // Setup audio analysis for USER microphone input ONLY
95
- useEffect(() => {
96
- if (!isActive) {
97
- // Clean up when user is not speaking
98
- if (animationFrameRef.current) {
99
- cancelAnimationFrame(animationFrameRef.current);
100
- }
101
- audioLevelsRef.current = Array(barsCount).fill(0);
102
- drawWaves();
103
- return;
104
- }
105
- let stream = null;
106
- const setupAudioAnalysis = async () => {
107
- try {
108
- // Get microphone stream
109
- stream = await navigator.mediaDevices.getUserMedia({ audio: true });
110
- // Create audio context and analyzer
111
- const audioContext = new (window.AudioContext ||
112
- window.webkitAudioContext)();
113
- audioContextRef.current = audioContext;
114
- const analyzer = audioContext.createAnalyser();
115
- analyzer.fftSize = 256; // Better resolution for time domain
116
- analyzer.smoothingTimeConstant = 0.7;
117
- analyzerRef.current = analyzer;
118
- const source = audioContext.createMediaStreamSource(stream);
119
- source.connect(analyzer);
120
- const dataArray = new Uint8Array(analyzer.fftSize);
121
- const updateLevels = () => {
122
- if (!analyzerRef.current)
123
- return;
124
- // Use time domain data (waveform) instead of frequency
125
- analyzer.getByteTimeDomainData(dataArray);
126
- // Calculate RMS (Root Mean Square) for volume
127
- let sum = 0;
128
- for (let i = 0; i < dataArray.length; i++) {
129
- const normalized = (dataArray[i] - 128) / 128; // Center around 0
130
- sum += normalized * normalized;
131
- }
132
- const rms = Math.sqrt(sum / dataArray.length);
133
- // Apply some scaling and clamping
134
- const volume = Math.min(1, rms * 3); // Boost sensitivity
135
- // Create left-to-right wave effect — write into the ref and paint
136
- // the SVG directly (no setState: a per-frame React render here
137
- // visibly juddered the host page).
138
- const levels = audioLevelsRef.current;
139
- for (let i = 0; i < barsCount; i++) {
140
- const position = i / barsCount; // 0 to 1 from left to right
141
- const wavePhase = Date.now() / 300 + position * Math.PI * 2;
142
- const waveVariation = Math.sin(wavePhase) * 0.15 + 0.85; // 0.7 to 1.0
143
- levels[i] = volume * waveVariation;
144
- }
145
- drawWaves();
146
- animationFrameRef.current = requestAnimationFrame(updateLevels);
147
- };
148
- updateLevels();
149
- }
150
- catch (error) {
151
- console.error("Error setting up audio analysis:", error);
152
- }
153
- };
154
- setupAudioAnalysis();
155
- return () => {
156
- if (animationFrameRef.current) {
157
- cancelAnimationFrame(animationFrameRef.current);
158
- }
159
- if (stream) {
160
- stream.getTracks().forEach((track) => track.stop());
161
- }
162
- if (audioContextRef.current) {
163
- audioContextRef.current.close();
164
- }
165
- };
166
- }, [isActive, barsCount]);
167
- const [isBotSpeaking, setIsBotSpeaking] = useState(false);
168
- return (_jsxs("div", { style: {
169
- position: "absolute",
170
- top: "50%",
171
- left: "50%",
172
- transform: "translate(-50%, -50%)",
173
- textAlign: "center",
174
- padding: "1rem",
175
- zIndex: 10,
176
- pointerEvents: "none",
177
- display: "flex",
178
- flexDirection: "column",
179
- alignItems: "center",
180
- gap: "2rem",
181
- }, children: [_jsxs("div", { style: {
182
- position: "relative",
183
- display: "flex",
184
- alignItems: "center",
185
- justifyContent: "center",
186
- isolation: "isolate", // Create stacking context
187
- }, children: [room && (_jsx(motion.div, { initial: { opacity: 0, scale: 0.8 }, animate: {
188
- opacity: isBotSpeaking ? 1 : 0,
189
- scale: isBotSpeaking ? 1 : 0.8,
190
- }, transition: iosTransitions.fadePop, style: {
191
- position: "absolute",
192
- width: "220px",
193
- height: "220px",
194
- zIndex: -1, // Negative z-index to ensure it's behind
195
- pointerEvents: "none",
196
- }, children: _jsx(AudioVisualizer, { room: room, size: 220, color: aeroTheme.colors.convai.light, opacity: 0.6, avatarRadius: 110, barCount: 48, onSpeakingChange: setIsBotSpeaking }) })), _jsxs(motion.div, { initial: { scale: 0.8, opacity: 0 }, animate: { scale: 1, opacity: 1 }, exit: { scale: 0.8, opacity: 0 }, transition: iosTransitions.fadePop, style: {
197
- position: "relative",
198
- zIndex: 10, // Higher z-index to be clearly on top
199
- borderRadius: "50%",
200
- overflow: "visible", // Changed to visible to show glow
201
- boxShadow: "0 8px 32px rgba(0, 0, 0, 0.3)",
202
- background: "white",
203
- }, children: [_jsx(motion.div, { animate: {
204
- rotate: [0, 360],
205
- scale: isBotSpeaking ? [1, 1.05, 1.02, 1.05, 1] : 1,
206
- }, transition: {
207
- rotate: { duration: 20, repeat: Infinity, ease: "linear" },
208
- scale: { duration: 3, repeat: Infinity, ease: "easeInOut" },
209
- }, style: {
210
- position: "absolute",
211
- width: "126px",
212
- height: "126px",
213
- borderRadius: "50%",
214
- background: `
215
- conic-gradient(
216
- from 0deg,
217
- ${aeroTheme.colors.convai.light}00 0%,
218
- ${aeroTheme.colors.convai.light}40 25%,
219
- ${aeroTheme.colors.convai.dark}60 50%,
220
- ${aeroTheme.colors.convai.light}40 75%,
221
- ${aeroTheme.colors.convai.light}00 100%
222
- )
223
- `,
224
- opacity: 0.8,
225
- filter: "blur(8px)",
226
- zIndex: -2,
227
- } }), _jsx(motion.div, { animate: {
228
- rotate: [360, 0],
229
- scale: isBotSpeaking ? [1, 1.03, 1.06, 1.03, 1] : 1,
230
- }, transition: {
231
- rotate: { duration: 15, repeat: Infinity, ease: "linear" },
232
- scale: { duration: 2.5, repeat: Infinity, ease: "easeInOut" },
233
- }, style: {
234
- position: "absolute",
235
- width: "126px",
236
- height: "126px",
237
- borderRadius: "50%",
238
- background: `
239
- radial-gradient(
240
- ellipse 80% 100% at 30% 40%,
241
- ${aeroTheme.colors.convai.light}50,
242
- ${aeroTheme.colors.convai.light}30 40%,
243
- transparent 70%
244
- ),
245
- radial-gradient(
246
- ellipse 80% 100% at 70% 60%,
247
- ${aeroTheme.colors.convai.dark}50,
248
- ${aeroTheme.colors.convai.dark}30 40%,
249
- transparent 70%
250
- )
251
- `,
252
- opacity: 0.9,
253
- filter: "blur(6px)",
254
- zIndex: -1,
255
- } }), _jsx("div", { style: {
256
- position: "relative",
257
- borderRadius: "50%",
258
- overflow: "hidden",
259
- border: `3px solid rgba(255, 255, 255, 0.2)`,
260
- }, children: characterImage ? (_jsx(motion.img, { src: characterImage, alt: characterName, animate: {
261
- scale: isBotSpeaking ? 1.05 : 1,
262
- }, transition: {
263
- duration: 0.3,
264
- ease: "easeInOut",
265
- }, style: {
266
- width: "120px",
267
- height: "120px",
268
- objectFit: "cover",
269
- display: "block",
270
- } })) : (_jsx("div", { style: {
271
- width: "120px",
272
- height: "120px",
273
- backgroundColor: aeroTheme.colors.convai.light + "20",
274
- display: "flex",
275
- alignItems: "center",
276
- justifyContent: "center",
277
- fontSize: "48px",
278
- color: aeroTheme.colors.convai.light,
279
- fontWeight: 600,
280
- }, children: characterName[0]?.toUpperCase() || "C" })) })] }, "center-avatar" // Use key instead of layoutId for independent animation
281
- )] }), _jsx(AnimatePresence, { children: isActive && (_jsx(motion.div, { initial: { opacity: 0, y: 20 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: -20 }, transition: iosTransitions.fadePop, style: {
282
- width: "250px",
283
- height: "80px",
284
- position: "relative",
285
- }, children: _jsx("canvas", { ref: waveCanvasRef, style: { width: "250px", height: "80px" } }) })) }), _jsxs(motion.div, { initial: { opacity: 0, y: 10 }, animate: { opacity: 1, y: 0 }, transition: { delay: 0.2, ...iosTransitions.fadePop }, children: [_jsx("div", { style: {
286
- fontSize: "16px",
287
- fontWeight: 600,
288
- color: aeroTheme.colors.text.primary,
289
- marginBottom: "0.5rem",
290
- }, children: isTalking
291
- ? `${characterName} Speaking...`
292
- : isListening || isActive
293
- ? "Listening..."
294
- : "Voice Mode" }), _jsx("div", { style: {
295
- fontSize: "13px",
296
- color: aeroTheme.colors.text.secondary,
297
- }, children: isListening || isActive || isTalking ? "Audio active" : "Tap microphone to talk" })] })] }));
298
- };
@@ -1,5 +0,0 @@
1
- export { ConviButton } from "./ConviButton.js";
2
- export { ConviHeader } from "./ConviHeader.js";
3
- export { ConviFooter } from "./ConviFooter.js";
4
- export { SettingsTray } from "./SettingsTray.js";
5
- export { VoiceModeOverlay } from "./VoiceModeOverlay.js";