@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,187 +0,0 @@
1
- export declare const aeroTheme: {
2
- colors: {
3
- primary: {
4
- 50: string;
5
- 100: string;
6
- 200: string;
7
- 300: string;
8
- 400: string;
9
- 500: string;
10
- 600: string;
11
- 700: string;
12
- 800: string;
13
- 900: string;
14
- };
15
- convai: {
16
- light: string;
17
- medium: string;
18
- dark: string;
19
- };
20
- neutral: {
21
- 50: string;
22
- 100: string;
23
- 200: string;
24
- 300: string;
25
- 400: string;
26
- 500: string;
27
- 600: string;
28
- 700: string;
29
- 800: string;
30
- 900: string;
31
- };
32
- glass: {
33
- light: string;
34
- medium: string;
35
- dark: string;
36
- backdrop: string;
37
- card: string;
38
- backdropLight: string;
39
- borderLight: string;
40
- };
41
- accent: {
42
- purple: string;
43
- green: string;
44
- blue: string;
45
- orange: string;
46
- red: string;
47
- };
48
- error: {
49
- 50: string;
50
- 100: string;
51
- 200: string;
52
- 300: string;
53
- 400: string;
54
- 500: string;
55
- 600: string;
56
- 700: string;
57
- 800: string;
58
- 900: string;
59
- };
60
- text: {
61
- primary: string;
62
- secondary: string;
63
- tertiary: string;
64
- inverse: string;
65
- };
66
- };
67
- typography: {
68
- fontFamily: {
69
- primary: string;
70
- title: string;
71
- header: string;
72
- body: string;
73
- mono: string;
74
- };
75
- fontSize: {
76
- xs: string;
77
- sm: string;
78
- base: string;
79
- lg: string;
80
- xl: string;
81
- "2xl": string;
82
- "3xl": string;
83
- "4xl": string;
84
- };
85
- sizes: {
86
- xs: string;
87
- sm: string;
88
- body: string;
89
- lg: string;
90
- xl: string;
91
- "2xl": string;
92
- "3xl": string;
93
- "4xl": string;
94
- caption: string;
95
- };
96
- fontWeight: {
97
- normal: number;
98
- medium: number;
99
- semibold: number;
100
- bold: number;
101
- };
102
- lineHeight: {
103
- tight: number;
104
- normal: number;
105
- relaxed: number;
106
- };
107
- };
108
- spacing: {
109
- xs: string;
110
- sm: string;
111
- md: string;
112
- lg: string;
113
- xl: string;
114
- "2xl": string;
115
- "3xl": string;
116
- };
117
- borderRadius: {
118
- none: string;
119
- sm: string;
120
- md: string;
121
- lg: string;
122
- xl: string;
123
- "2xl": string;
124
- full: string;
125
- };
126
- shadows: {
127
- sm: string;
128
- md: string;
129
- lg: string;
130
- xl: string;
131
- glass: string;
132
- };
133
- glass: {
134
- backdrop: string;
135
- backdropLight: string;
136
- backdropHeavy: string;
137
- border: string;
138
- borderLight: string;
139
- };
140
- transitions: {
141
- fast: string;
142
- normal: string;
143
- slow: string;
144
- spring: string;
145
- snappy: string;
146
- };
147
- zIndex: {
148
- base: number;
149
- dropdown: number;
150
- sticky: number;
151
- fixed: number;
152
- modal: number;
153
- popover: number;
154
- tooltip: number;
155
- };
156
- };
157
- export declare const glassStyles: {
158
- container: string;
159
- overlay: string;
160
- card: string;
161
- input: string;
162
- button: string;
163
- };
164
- export declare const iconSizes: {
165
- xs: string;
166
- sm: string;
167
- md: string;
168
- lg: string;
169
- xl: string;
170
- "2xl": string;
171
- };
172
- export declare const variants: {
173
- button: {
174
- primary: string;
175
- secondary: string;
176
- ghost: string;
177
- };
178
- input: {
179
- default: string;
180
- search: string;
181
- };
182
- card: {
183
- default: string;
184
- elevated: string;
185
- interactive: string;
186
- };
187
- };
@@ -1,289 +0,0 @@
1
- // Aero AI Module Theme - Translucent Glass Design System
2
- export const aeroTheme = {
3
- // Color Palette
4
- colors: {
5
- // Primary colors
6
- primary: {
7
- 50: "#f0f9ff",
8
- 100: "#e0f2fe",
9
- 200: "#bae6fd",
10
- 300: "#7dd3fc",
11
- 400: "#38bdf8",
12
- 500: "#0ea5e9",
13
- 600: "#0284c7",
14
- 700: "#0369a1",
15
- 800: "#075985",
16
- 900: "#0c4a6e",
17
- },
18
- convai: {
19
- light: "#1EB453",
20
- medium: "#0b6049",
21
- dark: "#084c3a",
22
- },
23
- // Neutral colors for glass effects
24
- neutral: {
25
- 50: "#fafafa",
26
- 100: "#f5f5f5",
27
- 200: "#e5e5e5",
28
- 300: "#d4d4d4",
29
- 400: "#a3a3a3",
30
- 500: "#737373",
31
- 600: "#525252",
32
- 700: "#404040",
33
- 800: "#262626",
34
- 900: "#171717",
35
- },
36
- // Glass overlay colors
37
- glass: {
38
- light: "rgba(255, 255, 255, 0.1)",
39
- medium: "rgba(255, 255, 255, 0.15)",
40
- dark: "rgba(0, 0, 0, 0.1)",
41
- backdrop: "rgba(255, 255, 255, 0.8)",
42
- card: "rgba(255, 255, 255, 0.9)",
43
- backdropLight: "blur(20px)",
44
- borderLight: "1px solid rgba(255, 255, 255, 0.2)",
45
- },
46
- // Accent colors
47
- accent: {
48
- purple: "#8b5cf6",
49
- green: "#10b981",
50
- blue: "#3b82f6",
51
- orange: "#f59e0b",
52
- red: "#ef4444",
53
- },
54
- // Error colors
55
- error: {
56
- 50: "#fef2f2",
57
- 100: "#fee2e2",
58
- 200: "#fecaca",
59
- 300: "#fca5a5",
60
- 400: "#f87171",
61
- 500: "#ef4444",
62
- 600: "#dc2626",
63
- 700: "#b91c1c",
64
- 800: "#991b1b",
65
- 900: "#7f1d1d",
66
- },
67
- // Text colors
68
- text: {
69
- primary: "#1f2937",
70
- secondary: "#6b7280",
71
- tertiary: "#9ca3af",
72
- inverse: "#ffffff",
73
- },
74
- },
75
- // Typography
76
- typography: {
77
- fontFamily: {
78
- primary: '"Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
79
- title: '"Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
80
- header: '"Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
81
- body: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
82
- mono: 'SF Mono, Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace',
83
- },
84
- fontSize: {
85
- xs: "0.75rem",
86
- sm: "0.875rem",
87
- base: "1rem",
88
- lg: "1.125rem",
89
- xl: "1.25rem",
90
- "2xl": "1.5rem",
91
- "3xl": "1.875rem",
92
- "4xl": "2.25rem",
93
- },
94
- sizes: {
95
- xs: "0.75rem",
96
- sm: "0.875rem",
97
- body: "1rem",
98
- lg: "1.125rem",
99
- xl: "1.25rem",
100
- "2xl": "1.5rem",
101
- "3xl": "1.875rem",
102
- "4xl": "2.25rem",
103
- caption: "0.75rem",
104
- },
105
- fontWeight: {
106
- normal: 400,
107
- medium: 500,
108
- semibold: 600,
109
- bold: 700,
110
- },
111
- lineHeight: {
112
- tight: 1.25,
113
- normal: 1.5,
114
- relaxed: 1.75,
115
- },
116
- },
117
- // Spacing
118
- spacing: {
119
- xs: "0.25rem",
120
- sm: "0.5rem",
121
- md: "1rem",
122
- lg: "1.5rem",
123
- xl: "2rem",
124
- "2xl": "3rem",
125
- "3xl": "4rem",
126
- },
127
- // Border Radius
128
- borderRadius: {
129
- none: "0",
130
- sm: "0.25rem",
131
- md: "0.5rem",
132
- lg: "0.75rem",
133
- xl: "1rem",
134
- "2xl": "1.5rem",
135
- full: "9999px",
136
- },
137
- // Shadows
138
- shadows: {
139
- sm: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
140
- md: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
141
- lg: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",
142
- xl: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
143
- glass: "0 8px 32px rgba(0, 0, 0, 0.1)",
144
- },
145
- // Glass Effects
146
- glass: {
147
- backdrop: "blur(20px)",
148
- backdropLight: "blur(10px)",
149
- backdropHeavy: "blur(40px)",
150
- border: "1px solid rgba(255, 255, 255, 0.2)",
151
- borderLight: "1px solid rgba(255, 255, 255, 0.1)",
152
- },
153
- // Transitions
154
- transitions: {
155
- fast: "0.15s ease-in-out",
156
- normal: "0.2s ease-in-out",
157
- slow: "0.3s ease-in-out",
158
- spring: "0.4s cubic-bezier(0.4, 0, 0.2, 1)",
159
- snappy: "all 0.1s ease-out",
160
- },
161
- // Z-index scale
162
- zIndex: {
163
- base: 1,
164
- dropdown: 1000,
165
- sticky: 1020,
166
- fixed: 1030,
167
- modal: 1040,
168
- popover: 1050,
169
- tooltip: 1060,
170
- },
171
- };
172
- // Common glass component styles
173
- export const glassStyles = {
174
- // Primary glass container
175
- container: `
176
- background: ${aeroTheme.colors.glass.backdrop};
177
- backdrop-filter: ${aeroTheme.glass.backdrop};
178
- border: ${aeroTheme.glass.border};
179
- border-radius: ${aeroTheme.borderRadius.xl};
180
- box-shadow: ${aeroTheme.shadows.glass};
181
- `,
182
- // Light glass overlay
183
- overlay: `
184
- background: ${aeroTheme.colors.glass.light};
185
- backdrop-filter: ${aeroTheme.glass.backdropLight};
186
- border: ${aeroTheme.glass.borderLight};
187
- border-radius: ${aeroTheme.borderRadius.lg};
188
- `,
189
- // Card glass effect
190
- card: `
191
- background: ${aeroTheme.colors.glass.card};
192
- backdrop-filter: ${aeroTheme.glass.backdrop};
193
- border: ${aeroTheme.glass.borderLight};
194
- border-radius: ${aeroTheme.borderRadius.lg};
195
- box-shadow: ${aeroTheme.shadows.md};
196
- `,
197
- // Input glass effect
198
- input: `
199
- background: ${aeroTheme.colors.glass.medium};
200
- backdrop-filter: ${aeroTheme.glass.backdropLight};
201
- border: ${aeroTheme.glass.borderLight};
202
- border-radius: ${aeroTheme.borderRadius.full};
203
- transition: ${aeroTheme.transitions.normal};
204
-
205
- &:focus {
206
- background: ${aeroTheme.colors.glass.card};
207
- border-color: ${aeroTheme.colors.primary[400]};
208
- box-shadow: 0 0 0 3px ${aeroTheme.colors.primary[100]};
209
- }
210
- `,
211
- // Button glass effect
212
- button: `
213
- background: ${aeroTheme.colors.glass.medium};
214
- backdrop-filter: ${aeroTheme.glass.backdropLight};
215
- border: ${aeroTheme.glass.borderLight};
216
- border-radius: ${aeroTheme.borderRadius.lg};
217
- transition: ${aeroTheme.transitions.normal};
218
-
219
- &:hover {
220
- background: ${aeroTheme.colors.glass.card};
221
- transform: translateY(-1px);
222
- box-shadow: ${aeroTheme.shadows.lg};
223
- }
224
-
225
- &:active {
226
- transform: translateY(0);
227
- }
228
- `,
229
- };
230
- // Icon sizes for consistency
231
- export const iconSizes = {
232
- xs: "12px",
233
- sm: "16px",
234
- md: "20px",
235
- lg: "24px",
236
- xl: "32px",
237
- "2xl": "40px",
238
- };
239
- // Common component variants
240
- export const variants = {
241
- // Button variants
242
- button: {
243
- primary: `
244
- background: linear-gradient(135deg, ${aeroTheme.colors.primary[500]}, ${aeroTheme.colors.primary[600]});
245
- color: ${aeroTheme.colors.text.inverse};
246
- box-shadow: 0 4px 12px ${aeroTheme.colors.primary[200]};
247
- `,
248
- secondary: `
249
- background: ${aeroTheme.colors.glass.medium};
250
- color: ${aeroTheme.colors.text.primary};
251
- border: ${aeroTheme.glass.borderLight};
252
- `,
253
- ghost: `
254
- background: transparent;
255
- color: ${aeroTheme.colors.text.secondary};
256
-
257
- &:hover {
258
- background: ${aeroTheme.colors.glass.light};
259
- color: ${aeroTheme.colors.text.primary};
260
- }
261
- `,
262
- },
263
- // Input variants
264
- input: {
265
- default: glassStyles.input,
266
- search: `
267
- ${glassStyles.input}
268
- padding-left: 2.5rem;
269
- `,
270
- },
271
- // Card variants
272
- card: {
273
- default: glassStyles.card,
274
- elevated: `
275
- ${glassStyles.card}
276
- box-shadow: ${aeroTheme.shadows.xl};
277
- `,
278
- interactive: `
279
- ${glassStyles.card}
280
- cursor: pointer;
281
- transition: ${aeroTheme.transitions.normal};
282
-
283
- &:hover {
284
- transform: translateY(-2px);
285
- box-shadow: ${aeroTheme.shadows.xl};
286
- }
287
- `,
288
- },
289
- };
@@ -1,59 +0,0 @@
1
- export interface RTCChatMessage {
2
- id: string;
3
- text: string;
4
- isUser: boolean;
5
- timestamp: string;
6
- sender: string;
7
- showLogo?: boolean;
8
- }
9
- export interface CharacterVerbosityConfig {
10
- characterId: string;
11
- label?: string;
12
- }
13
- export interface ConviUIProps {
14
- isOpen: boolean;
15
- backgroundOpacity?: number;
16
- alwaysExpanded?: boolean;
17
- characterName?: string;
18
- characterImage?: string;
19
- verbosityLevels?: Array<{
20
- index: number;
21
- characterId: string;
22
- label?: string;
23
- }>;
24
- currentVerbosityIndex?: number;
25
- onVerbosityChange?: (index: number, characterId: string) => void;
26
- verbosityChanged?: boolean;
27
- messages: RTCChatMessage[];
28
- isStreaming?: boolean;
29
- inputMode?: "conversation" | "speaker" | "voice" | "verbosity";
30
- inputValue: string;
31
- liveUserText?: string;
32
- localIsTyping: boolean;
33
- convaiIsTyping: boolean;
34
- chatbotMic: boolean;
35
- isPressingMic: boolean;
36
- isTalking: boolean;
37
- isMuted: boolean;
38
- isVoiceMode: boolean;
39
- isSettingsOpen: boolean;
40
- isSpeakerEditMode: boolean;
41
- isVerbosityMode: boolean;
42
- isCreatingSpeaker?: boolean;
43
- onToggle: () => void;
44
- onClose: () => void;
45
- onInputChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
46
- onKeyPress: (e: React.KeyboardEvent) => void;
47
- onSend: () => void;
48
- onMicPress: () => void;
49
- onMicRelease: () => void;
50
- setIsPressingMic: (value: boolean) => void;
51
- onToggleMute: () => void;
52
- onToggleVoiceMode: () => void;
53
- onSettingsToggle: () => void;
54
- onReset: () => void;
55
- onToggleVerbosityMode: () => void;
56
- onContinue?: () => void;
57
- settingsButtonRef?: React.RefObject<HTMLButtonElement>;
58
- convaiClient?: any;
59
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,18 +0,0 @@
1
- import { type CharacterInfo } from "../../core/characterInfo.js";
2
- /**
3
- * Fetch a character's display name and avatar for the widget header.
4
- *
5
- * The request itself lives in `core/characterInfo` so the vanilla widget runs
6
- * the same code rather than a hand-synced copy of it.
7
- *
8
- * @param characterId - Character to look up
9
- * @param apiKey - Convai API key, sent as `X-API-Key`
10
- * @param authToken - Preferred over `apiKey`, sent as `API-AUTH-TOKEN`
11
- * @param baseUrl - Origin to ask; defaults to `https://api.convai.com`. Pass
12
- * `client.characterInfoUrl` so a non-SaaS deployment is not asked to send
13
- * its credential to Convai's public API.
14
- */
15
- export declare const useCharacterInfo: (characterId?: string, apiKey?: string, authToken?: string, baseUrl?: string | null) => CharacterInfo & {
16
- isLoading: boolean;
17
- error: Error | null;
18
- };
@@ -1,65 +0,0 @@
1
- import { useState, useEffect } from "react";
2
- import { logger } from "../../utils/logger.js";
3
- import { fetchCharacterInfo, FALLBACK_CHARACTER_NAME, } from "../../core/characterInfo.js";
4
- /**
5
- * Fetch a character's display name and avatar for the widget header.
6
- *
7
- * The request itself lives in `core/characterInfo` so the vanilla widget runs
8
- * the same code rather than a hand-synced copy of it.
9
- *
10
- * @param characterId - Character to look up
11
- * @param apiKey - Convai API key, sent as `X-API-Key`
12
- * @param authToken - Preferred over `apiKey`, sent as `API-AUTH-TOKEN`
13
- * @param baseUrl - Origin to ask; defaults to `https://api.convai.com`. Pass
14
- * `client.characterInfoUrl` so a non-SaaS deployment is not asked to send
15
- * its credential to Convai's public API.
16
- */
17
- export const useCharacterInfo = (characterId, apiKey, authToken, baseUrl) => {
18
- const [characterInfo, setCharacterInfo] = useState({
19
- name: FALLBACK_CHARACTER_NAME,
20
- image: null,
21
- });
22
- const [isLoading, setIsLoading] = useState(true);
23
- const [error, setError] = useState(null);
24
- useEffect(() => {
25
- if (!characterId || !apiKey) {
26
- setIsLoading(false);
27
- return;
28
- }
29
- // Dropped on unmount, and on any change of the inputs below: a resolved
30
- // response for a character the widget has moved off must not overwrite the
31
- // header with the previous one's name.
32
- const controller = new AbortController();
33
- let cancelled = false;
34
- setIsLoading(true);
35
- setError(null);
36
- fetchCharacterInfo({
37
- characterId,
38
- apiKey,
39
- authToken,
40
- baseUrl,
41
- signal: controller.signal,
42
- })
43
- .then((info) => {
44
- if (!cancelled)
45
- setCharacterInfo(info);
46
- })
47
- .catch((err) => {
48
- if (cancelled || controller.signal.aborted)
49
- return;
50
- const error = err instanceof Error ? err : new Error("Unknown error");
51
- logger.error("Failed to fetch character info:", error);
52
- setError(error);
53
- // Keep the fallback name and no image; the header is cosmetic.
54
- })
55
- .finally(() => {
56
- if (!cancelled)
57
- setIsLoading(false);
58
- });
59
- return () => {
60
- cancelled = true;
61
- controller.abort();
62
- };
63
- }, [characterId, apiKey, authToken, baseUrl]);
64
- return { ...characterInfo, isLoading, error };
65
- };
@@ -1,21 +0,0 @@
1
- import { TrackReferenceOrPlaceholder } from "@livekit/components-react";
2
- /**
3
- * Hook to get the local camera track reference from LiveKit.
4
- *
5
- * Returns a track reference that can be used with LiveKit components
6
- * to display the local participant's camera feed.
7
- *
8
- * @returns {TrackReferenceOrPlaceholder} Track reference for the local camera
9
- *
10
- * @example
11
- * ```tsx
12
- * function VideoComponent() {
13
- * const cameraTrackRef = useLocalCameraTrack();
14
- *
15
- * return (
16
- * <VideoTrack trackRef={cameraTrackRef} />
17
- * );
18
- * }
19
- * ```
20
- */
21
- export declare const useLocalCameraTrack: () => TrackReferenceOrPlaceholder;
@@ -1,33 +0,0 @@
1
- import { useLocalParticipant, } from "@livekit/components-react";
2
- import { Track } from "livekit-client";
3
- import { useMemo } from "react";
4
- /**
5
- * Hook to get the local camera track reference from LiveKit.
6
- *
7
- * Returns a track reference that can be used with LiveKit components
8
- * to display the local participant's camera feed.
9
- *
10
- * @returns {TrackReferenceOrPlaceholder} Track reference for the local camera
11
- *
12
- * @example
13
- * ```tsx
14
- * function VideoComponent() {
15
- * const cameraTrackRef = useLocalCameraTrack();
16
- *
17
- * return (
18
- * <VideoTrack trackRef={cameraTrackRef} />
19
- * );
20
- * }
21
- * ```
22
- */
23
- export const useLocalCameraTrack = () => {
24
- const { cameraTrack, localParticipant } = useLocalParticipant();
25
- const cameraTrackRef = useMemo(() => {
26
- return {
27
- participant: localParticipant,
28
- source: Track.Source.Camera,
29
- publication: cameraTrack,
30
- };
31
- }, [localParticipant, cameraTrack]);
32
- return cameraTrackRef;
33
- };