@botuyo/chat-widget-standalone 1.0.61 → 1.0.63

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 (42) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +302 -323
  3. package/dist/Avatar3D-LfNJe183.js.map +1 -1
  4. package/dist/botuyo-chat.es.js +35 -36
  5. package/dist/botuyo-chat.es.js.map +1 -1
  6. package/dist/botuyo-chat.umd.js +1 -1
  7. package/dist/botuyo-chat.umd.js.map +1 -1
  8. package/dist/{chunk-audio-BWzosE4G.js → chunk-audio-D3yXcqpi.js} +2 -2
  9. package/dist/chunk-audio-D3yXcqpi.js.map +1 -0
  10. package/dist/{chunk-chat-ui-DdO5hnyL.js → chunk-chat-ui-DHu5_wQn.js} +32 -32
  11. package/dist/chunk-chat-ui-DHu5_wQn.js.map +1 -0
  12. package/dist/{chunk-gallery-D3t-QnJv.js → chunk-gallery-CJ1ehwV0.js} +2 -2
  13. package/dist/chunk-gallery-CJ1ehwV0.js.map +1 -0
  14. package/dist/src/chat-widget/ChatWidget.d.ts.map +1 -1
  15. package/dist/src/chat-widget/components/Gallery.stories.d.ts.map +1 -1
  16. package/dist/src/chat-widget/components/MessageBubble.d.ts.map +1 -1
  17. package/dist/src/chat-widget/components/MessageList.d.ts.map +1 -1
  18. package/dist/src/chat-widget/hooks/useChatSocket.d.ts.map +1 -1
  19. package/dist/src/chat-widget/hooks/useWidgetTheme.d.ts +1 -1
  20. package/dist/src/chat-widget/types/index.d.ts +20 -0
  21. package/dist/src/chat-widget/types/index.d.ts.map +1 -1
  22. package/dist/src/chat-widget/utils/theme.d.ts +3 -2
  23. package/dist/src/chat-widget/utils/theme.d.ts.map +1 -1
  24. package/dist/standalone.d.ts +6 -1
  25. package/dist/standalone.d.ts.map +1 -1
  26. package/dist/stats-umd.html +1 -1
  27. package/dist/stats.html +1 -1
  28. package/package.json +155 -155
  29. package/dist/ShadowChatWidget.d.ts +0 -25
  30. package/dist/ShadowChatWidget.d.ts.map +0 -1
  31. package/dist/chunk-audio-BWzosE4G.js.map +0 -1
  32. package/dist/chunk-chat-ui-DdO5hnyL.js.map +0 -1
  33. package/dist/chunk-gallery-D3t-QnJv.js.map +0 -1
  34. package/dist/src/chat-widget/utils/theme.examples.d.ts +0 -47
  35. package/dist/src/chat-widget/utils/theme.examples.d.ts.map +0 -1
  36. package/dist/src/chat-widget/utils/themes/index.d.ts +0 -12
  37. package/dist/src/chat-widget/utils/themes/index.d.ts.map +0 -1
  38. package/examples/cdn-example.html +0 -226
  39. package/examples/nextjs-example.js +0 -188
  40. package/examples/nextjs-example.tsx +0 -229
  41. package/examples/react-example.js +0 -168
  42. package/examples/react-example.tsx +0 -221
package/README.md CHANGED
@@ -1,323 +1,302 @@
1
- # BotUyo Chat Widget
2
-
3
- Widget de chat AI embebible enterprise-ready. Disponible via **NPM** y **CDN** para cualquier sitio web.
4
-
5
- [![npm version](https://badge.fury.io/js/%40botuyo%2Fchat-widget-standalone.svg)](https://www.npmjs.com/package/@botuyo/chat-widget-standalone)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
7
-
8
- ---
9
-
10
- ## 🚀 Instalación Rápida
11
-
12
- ### Opción 1: CDN (JavaScript Vanilla)
13
-
14
- ```html
15
- <!-- CSS (REQUERIDO) -->
16
- <link rel="stylesheet" href="https://cdn-chatbot.botuyo.com/latest/botuyo-chat.css">
17
-
18
- <!-- JavaScript -->
19
- <script src="https://cdn-chatbot.botuyo.com/latest/botuyo-chat.js"></script>
20
- <script>
21
- BotUyoChat.init({
22
- apiKey: 'tu-api-key',
23
- apiBaseUrl: 'https://api.botuyo.com',
24
- theme: {
25
- primaryColor: '#10b981',
26
- botName: 'Asistente BotUyo',
27
- position: 'bottom-right'
28
- }
29
- });
30
- </script>
31
- ```
32
-
33
- **CDN Alternativo (jsDelivr/unpkg):**
34
- ```html
35
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@botuyo/chat-widget-standalone@1.0.4/dist/botuyo-chat.umd.css">
36
- <script src="https://cdn.jsdelivr.net/npm/@botuyo/chat-widget-standalone@1.0.4/dist/botuyo-chat.umd.js"></script>
37
- ```
38
-
39
- ### Opción 2: NPM Package (React/Next.js)
40
-
41
- ```bash
42
- npm install @botuyo/chat-widget-standalone@1.0.4
43
- ```
44
-
45
- ```tsx
46
- import BotUyoChat from '@botuyo/chat-widget-standalone';
47
-
48
- // En useEffect o al cargar
49
- BotUyoChat.init({
50
- apiKey: 'tu-api-key',
51
- apiBaseUrl: 'https://api.botuyo.com',
52
- theme: {
53
- primaryColor: '#10b981',
54
- botName: 'Asistente Virtual'
55
- }
56
- });
57
- ```
58
-
59
- ---
60
-
61
- ## ⚙️ Configuración Completa
62
-
63
- ```typescript
64
- interface StandaloneConfig {
65
- // ═══════════════════════════════════════════
66
- // REQUERIDO
67
- // ═══════════════════════════════════════════
68
- apiKey: string; // Tu API key de BotUyo
69
- apiBaseUrl: string; // URL del backend WebSocket
70
-
71
- // ═══════════════════════════════════════════
72
- // TEMA (opcional)
73
- // ═══════════════════════════════════════════
74
- theme?: {
75
- primaryColor?: string; // Color principal (default: '#10b981')
76
- botName?: string; // Nombre del bot (default: 'Asistente Virtual')
77
- logoUrl?: string; // URL del avatar del bot
78
- position?: 'bottom-right' | 'bottom-left';
79
- welcomeMessage?: string; // Mensaje de bienvenida inicial
80
- inputPlaceholder?: string; // Placeholder del input
81
- borderRadius?: string; // Border radius ventana (default: '1.5rem')
82
- height?: string; // Altura del chat (default: '600px')
83
- bottom?: string; // Distancia desde abajo (default: '24px')
84
-
85
- // Animaciones
86
- animations?: {
87
- enabled?: boolean; // Toggle maestro (default: true)
88
- messageEntry?: 'spring' | 'slide' | 'fade' | 'scale' | 'none';
89
- typingIndicator?: 'wave' | 'dots' | 'pulse' | 'none';
90
- launcherPulse?: boolean; // Pulso del botón launcher
91
- windowTransitions?: boolean; // Animación apertura/cierre
92
- };
93
-
94
- // Efectos visuales
95
- effects?: {
96
- glassmorphism?: boolean; // Blur en headers
97
- gradients?: boolean; // Fondos degradados
98
- softShadows?: boolean; // Sombras suaves
99
- glowEffects?: boolean; // Glow en focus/hover
100
- shimmerLoading?: boolean; // Shimmer en carga
101
- hoverLift?: boolean; // Elevación en hover
102
- };
103
- };
104
-
105
- // ═══════════════════════════════════════════
106
- // MEDIA CONFIG (opcional)
107
- // ═══════════════════════════════════════════
108
- mediaConfig?: {
109
- enableVoice?: boolean; // Habilitar notas de voz (default: true)
110
- enableAttachments?: boolean; // Habilitar adjuntos (default: true)
111
- enableLocation?: boolean; // Habilitar ubicación (default: true)
112
- };
113
-
114
- // ═══════════════════════════════════════════
115
- // CALLBACKS (opcional)
116
- // ═══════════════════════════════════════════
117
- onVoiceCall?: () => void; // Cuando se presiona el botón de llamada
118
- onNavigate?: (url: string) => void;
119
- onStateChange?: (isOpen: boolean) => void;
120
- onEvent?: (eventName: string, data: any) => void;
121
- }
122
- ```
123
-
124
- ---
125
-
126
- ## 📞 Llamada de Voz (Demo)
127
-
128
- El widget incluye un **demo interactivo de llamada de voz** que:
129
- - Accede al micrófono real del usuario
130
- - Muestra waveform animado según el nivel de audio
131
- - Simula respuestas del bot después de 1 segundo de silencio
132
-
133
- ```javascript
134
- BotUyoChat.init({
135
- apiKey: 'tu-api-key',
136
- apiBaseUrl: 'https://api.botuyo.com',
137
- onVoiceCall: () => {
138
- console.log('Llamada de voz iniciada');
139
- // El demo se abre automáticamente dentro del widget
140
- }
141
- });
142
- ```
143
-
144
- > **Nota:** Este es un demo visual. Para integrar llamadas de voz reales, conecta con tu servicio de voz preferido (OpenAI Realtime, LiveKit, Twilio, etc.)
145
-
146
- ---
147
-
148
- ## 🎨 Theme Builder
149
-
150
- Usa el **Theme Builder** para personalizar visualmente el widget:
151
-
152
- ```
153
- https://tu-dominio.com/builder.html
154
- ```
155
-
156
- El builder permite:
157
- - Cambiar colores en tiempo real
158
- - Presets: Default, Dark, Ocean, Sunset, Forest
159
- - Copiar código de integración listo para usar
160
-
161
- ---
162
-
163
- ## 🛠️ API Pública
164
-
165
- ```javascript
166
- // Inicializar
167
- BotUyoChat.init(config);
168
-
169
- // Controles
170
- BotUyoChat.open(); // Abrir chat
171
- BotUyoChat.close(); // Cerrar chat
172
- BotUyoChat.toggle(); // Toggle abierto/cerrado
173
- BotUyoChat.destroy(); // Destruir widget
174
-
175
- // Actualizar configuración en vivo
176
- BotUyoChat.update({
177
- theme: { primaryColor: '#ef4444' }
178
- });
179
- ```
180
-
181
- ---
182
-
183
- ## 📚 Ejemplos
184
-
185
- ### Ejemplo Mínimo
186
- ```html
187
- <link rel="stylesheet" href="https://cdn-chatbot.botuyo.com/latest/botuyo-chat.css">
188
- <script src="https://cdn-chatbot.botuyo.com/latest/botuyo-chat.js"></script>
189
- <script>
190
- BotUyoChat.init({
191
- apiKey: 'demo-key',
192
- apiBaseUrl: 'https://api.botuyo.com'
193
- });
194
- </script>
195
- ```
196
-
197
- ### Ejemplo Completo
198
- ```html
199
- <script>
200
- BotUyoChat.init({
201
- apiKey: 'mi-api-key',
202
- apiBaseUrl: 'https://api.botuyo.com',
203
-
204
- theme: {
205
- primaryColor: '#6366f1',
206
- botName: 'Asistente Mi Empresa',
207
- logoUrl: 'https://mi-sitio.com/logo.png',
208
- position: 'bottom-right',
209
- welcomeMessage: '¡Hola! 👋 ¿En qué puedo ayudarte?',
210
- borderRadius: '1.5rem',
211
- height: '550px',
212
-
213
- animations: {
214
- enabled: true,
215
- messageEntry: 'spring',
216
- launcherPulse: true,
217
- },
218
-
219
- effects: {
220
- glassmorphism: true,
221
- softShadows: true,
222
- glowEffects: true,
223
- },
224
- },
225
-
226
- mediaConfig: {
227
- enableVoice: true,
228
- enableAttachments: true,
229
- enableLocation: false,
230
- },
231
-
232
- onStateChange: (isOpen) => {
233
- console.log('Chat:', isOpen ? 'abierto' : 'cerrado');
234
- },
235
-
236
- onVoiceCall: () => {
237
- console.log('Llamada de voz iniciada');
238
- },
239
- });
240
- </script>
241
- ```
242
-
243
- ---
244
-
245
- ## 🎭 Temas Predefinidos
246
-
247
- ### Tema Claro (Default)
248
- ```javascript
249
- theme: {
250
- primaryColor: '#10b981'
251
- }
252
- ```
253
-
254
- ### Tema Oscuro
255
- ```javascript
256
- theme: {
257
- primaryColor: '#8b5cf6',
258
- cssVariables: {
259
- background: '240 10% 3.9%',
260
- foreground: '0 0% 98%',
261
- card: '240 4% 16%',
262
- border: '240 4% 20%'
263
- }
264
- }
265
- ```
266
-
267
- ### Tema Ocean
268
- ```javascript
269
- theme: {
270
- primaryColor: '#0ea5e9'
271
- }
272
- ```
273
-
274
- ---
275
-
276
- ## 🌐 Compatibilidad
277
-
278
- | Navegador | Versión Mínima |
279
- |-----------|----------------|
280
- | Chrome | 90+ |
281
- | Firefox | 88+ |
282
- | Safari | 14+ |
283
- | Edge | 90+ |
284
- | iOS Safari | 14+ |
285
- | Chrome Mobile | 90+ |
286
-
287
- ---
288
-
289
- ## 📦 Build Local
290
-
291
- ```bash
292
- git clone https://github.com/botuyo/chat-widget.git
293
- cd chat-widget
294
-
295
- npm install
296
-
297
- # Desarrollo
298
- npm run dev
299
-
300
- # Build producción
301
- npm run build
302
-
303
- # Solo UMD bundle
304
- npm run build:umd
305
-
306
- # Tests
307
- npm test
308
- ```
309
-
310
- ---
311
-
312
- ## 🔗 Links
313
-
314
- - **NPM**: [npmjs.com/package/@botuyo/chat-widget-standalone](https://www.npmjs.com/package/@botuyo/chat-widget-standalone)
315
- - **CDN BotUyo**: `https://cdn-chatbot.botuyo.com/latest/`
316
- - **CDN jsDelivr**: `https://cdn.jsdelivr.net/npm/@botuyo/chat-widget-standalone@1.0.4/dist/`
317
- - **Documentación**: [docs.botuyo.com](https://docs.botuyo.com)
318
-
319
- ---
320
-
321
- ## 📄 Licencia
322
-
323
- MIT License - © 2026 BotUyo
1
+ # @botuyo/chat-widget
2
+
3
+ > AI-powered chat widget with Shadow DOM isolation, dark mode, voice chat, and full white-labeling. Works as a CDN script tag or NPM React component.
4
+
5
+ ---
6
+
7
+ ## Quick Start — CDN (Standalone)
8
+
9
+ Add a single script tag to any HTML page. No build step required.
10
+
11
+ ```html
12
+ <script src="https://cdn.botuyo.com/widget/botuyo-chat.js"></script>
13
+ <script>
14
+ BotUyoChat.init({
15
+ apiKey: 'YOUR_API_KEY'
16
+ });
17
+ </script>
18
+ ```
19
+
20
+ That's it. The widget connects to the BotUyo backend, receives the agent configuration (name, avatar, colors, voice settings), and renders itself in a Shadow DOM so it never conflicts with your site's CSS.
21
+
22
+ ### CDN — Custom Theme Override
23
+
24
+ You can override any server-sent value locally:
25
+
26
+ ```html
27
+ <script src="https://cdn.botuyo.com/widget/botuyo-chat.js"></script>
28
+ <script>
29
+ BotUyoChat.init({
30
+ apiKey: 'YOUR_API_KEY',
31
+ theme: {
32
+ botName: 'Soporte',
33
+ position: 'bottom-left',
34
+ welcomeMessage: '¡Hola! ¿En qué te puedo ayudar?',
35
+ inputPlaceholder: 'Escribí tu mensaje...',
36
+ cssVariables: {
37
+ primary: '210 100% 50%', // Blue
38
+ primaryForeground: '0 0% 100%', // White text on blue
39
+ background: '0 0% 100%', // White background
40
+ foreground: '210 20% 12%', // Dark text
41
+ radius: '0.75rem',
42
+ },
43
+ darkCssVariables: {
44
+ background: '220 40% 3%',
45
+ foreground: '210 20% 98%',
46
+ card: '220 40% 5%',
47
+ muted: '220 30% 10%',
48
+ border: '220 30% 12%',
49
+ },
50
+ },
51
+ });
52
+ </script>
53
+ ```
54
+
55
+ ### CDN — Programmatic API
56
+
57
+ ```js
58
+ BotUyoChat.open(); // Open the chat window
59
+ BotUyoChat.close(); // Close the chat window
60
+ BotUyoChat.sendMessage('Hola!'); // Send a message
61
+ BotUyoChat.destroy(); // Remove widget from page
62
+
63
+ // Update config at runtime
64
+ BotUyoChat.update({
65
+ theme: { botName: 'New Name' }
66
+ });
67
+ ```
68
+
69
+ ---
70
+
71
+ ## NPM — React / Next.js
72
+
73
+ ```bash
74
+ npm install @botuyo/chat-widget-standalone
75
+ ```
76
+
77
+ ### Option 1: Drop-in Component (Shadow DOM)
78
+
79
+ The default `ChatWidget` export renders inside Shadow DOM for full CSS isolation:
80
+
81
+ ```tsx
82
+ import { ChatWidget } from '@botuyo/chat-widget-standalone';
83
+
84
+ export default function App() {
85
+ return (
86
+ <ChatWidget
87
+ apiKey="YOUR_API_KEY"
88
+ theme={{
89
+ position: 'bottom-right',
90
+ cssVariables: {
91
+ primary: '210 100% 50%',
92
+ },
93
+ }}
94
+ />
95
+ );
96
+ }
97
+ ```
98
+
99
+ ### Option 2: Provider + Hook (Programmatic Control)
100
+
101
+ Use `ChatWidgetProvider` to access the widget state from any component:
102
+
103
+ ```tsx
104
+ import { ChatWidgetProvider, useChatWidget } from '@botuyo/chat-widget-standalone';
105
+
106
+ function App() {
107
+ return (
108
+ <ChatWidgetProvider apiKey="YOUR_API_KEY">
109
+ <MyPage />
110
+ </ChatWidgetProvider>
111
+ );
112
+ }
113
+
114
+ function MyPage() {
115
+ const { open, close, isOpen, unreadCount, sendMessage } = useChatWidget();
116
+
117
+ return (
118
+ <button onClick={open}>
119
+ Chat {unreadCount > 0 && `(${unreadCount})`}
120
+ </button>
121
+ );
122
+ }
123
+ ```
124
+
125
+ ### Option 3: Unstyled Component (No Shadow DOM)
126
+
127
+ If you want the widget in your own DOM tree (useful inside existing design systems):
128
+
129
+ ```tsx
130
+ import { ChatWidgetUnstyled } from '@botuyo/chat-widget-standalone';
131
+ import '@botuyo/chat-widget-standalone/style.css';
132
+
133
+ export default function App() {
134
+ return <ChatWidgetUnstyled apiKey="YOUR_API_KEY" />;
135
+ }
136
+ ```
137
+
138
+ ---
139
+
140
+ ## Configuration Reference
141
+
142
+ ### `ChatWidgetProps`
143
+
144
+ | Prop | Type | Default | Description |
145
+ |------|------|---------|-------------|
146
+ | `apiKey` | `string` | **(required)** | Your public API key |
147
+ | `apiBaseUrl` | `string` | `https://api.botuyo.com` | Backend gateway URL |
148
+ | `agentId` | `string` | — | Connect to a specific agent flow |
149
+ | `theme` | `ChatTheme` | — | Visual configuration (see below) |
150
+ | `mediaConfig` | `MediaConfig` | | Toggle images, audio, files, location, voice |
151
+ | `userContext` | `{ token?, metadata? }` | — | Pass authenticated user info |
152
+ | `pageContext` | `PageContext` | — | Page-level context sent with each message |
153
+ | `includeSEOMetadata` | `boolean` | `false` | Auto-capture page SEO data |
154
+ | `onNavigate` | `(url) => void` | — | Bot requests navigation |
155
+ | `onLogin` | `(userData) => void` | — | Bot completes authentication |
156
+ | `onEvent` | `(name, data) => void` | — | Widget lifecycle events |
157
+ | `onStateChange` | `(isOpen) => void` | — | Window open/close callback |
158
+
159
+ ### `ChatTheme`
160
+
161
+ | Property | Type | Description |
162
+ |----------|------|-------------|
163
+ | `botName` | `string` | Bot display name |
164
+ | `logoUrl` | `string` | Bot avatar URL |
165
+ | `headerText` | `string` | Header bar text (overrides botName in header) |
166
+ | `position` | `'bottom-right' \| 'bottom-left'` | Launcher position |
167
+ | `welcomeMessage` | `string` | First message shown to user |
168
+ | `inputPlaceholder` | `string` | Input field placeholder |
169
+ | `starterPrompt` | `string` | Prompt bubble shown when chat is closed |
170
+ | `defaultLocale` | `'es' \| 'en' \| 'pt' \| 'fr'` | Widget language |
171
+ | `avatarScale` | `number` | Avatar zoom (e.g., `1.2` = 20% bigger) |
172
+ | `showPromptAvatar` | `boolean` | Show mini avatar in prompt bubble |
173
+ | `isHidden` | `boolean` | Hide widget (draft/paused agents) |
174
+ | `cssVariables` | `CSSVariables` | Light mode colors and layout (see below) |
175
+ | `darkCssVariables` | `Partial<CSSVariables>` | Dark mode color overrides |
176
+ | `animations` | `AnimationConfig` | Animation toggles |
177
+ | `effects` | `EffectsConfig` | Visual effect toggles |
178
+ | `avatars` | `EmotionAvatarMap` | Per-emotion avatar URLs |
179
+ | `avatar3dUrl` | `string` | URL to `.vrm`/`.glb` 3D model for voice calls |
180
+ | `bubbleStyles` | `BubbleStyles` | Fine-grained bubble/card styling |
181
+
182
+ ### `cssVariables` — Design Tokens (HSL format)
183
+
184
+ All color values use **HSL without the `hsl()` wrapper**, e.g., `"210 100% 50%"`.
185
+
186
+ | Variable | CSS Property | Default (Light) | Description |
187
+ |----------|-------------|-----------------|-------------|
188
+ | `background` | `--background` | `0 0% 100%` | Page/widget background |
189
+ | `foreground` | `--foreground` | `240 10% 3.9%` | Main text color |
190
+ | `card` | `--card` | `0 0% 100%` | Card background |
191
+ | `cardForeground` | `--card-foreground` | `240 10% 3.9%` | Card text |
192
+ | `primary` | `--primary` | `160 84% 39%` | Brand/accent color |
193
+ | `primaryForeground` | `--primary-foreground` | `0 0% 100%` | Text on primary bg |
194
+ | `muted` | `--muted` | `240 4.8% 95.9%` | Muted backgrounds |
195
+ | `mutedForeground` | `--muted-foreground` | `240 3.8% 46.1%` | Muted text |
196
+ | `border` | `--border` | `240 5.9% 90%` | Border color |
197
+ | `destructive` | `--destructive` | `0 84.2% 60.2%` | Error/danger color |
198
+ | `radius` | `--radius` | `0.5rem` | Base border radius |
199
+
200
+ **Layout variables:**
201
+
202
+ | Variable | CSS Property | Default | Description |
203
+ |----------|-------------|---------|-------------|
204
+ | `windowBorderRadius` | `--window-border-radius` | `24px` | Chat window corner radius |
205
+ | `launcherBorderRadius` | `--launcher-border-radius` | `50%` | Launcher button radius |
206
+ | `windowHeight` | `--window-height` | `700px` | Chat window height (desktop) |
207
+ | `windowBottom` | `--window-bottom` | `24px` | Distance from bottom edge |
208
+
209
+ **Spacing variables:**
210
+
211
+ | Variable | CSS Property | Default |
212
+ |----------|-------------|---------|
213
+ | `spacing1` | `--spacing-1` | `0.25rem` (4px) |
214
+ | `spacing2` | `--spacing-2` | `0.5rem` (8px) |
215
+ | `spacing3` | `--spacing-3` | `0.75rem` (12px) |
216
+ | `spacing4` | `--spacing-4` | `1rem` (16px) |
217
+ | `spacing5` | `--spacing-5` | `0.75rem` (12px) |
218
+ | `spacing6` | `--spacing-6` | `1.5rem` (24px) |
219
+ | `spacing7` | `--spacing-7` | `1.75rem` (28px) |
220
+ | `spacing8` | `--spacing-8` | `2rem` (32px) |
221
+
222
+ ### `darkCssVariables`
223
+
224
+ Same keys as `cssVariables`. Only override surface colors — `primary` and `primaryForeground` are preserved from the light theme by default:
225
+
226
+ ```js
227
+ darkCssVariables: {
228
+ background: '220 40% 3%',
229
+ foreground: '210 20% 98%',
230
+ card: '220 40% 5%',
231
+ muted: '220 30% 10%',
232
+ border: '220 30% 12%',
233
+ }
234
+ ```
235
+
236
+ ### `AnimationConfig`
237
+
238
+ | Property | Type | Default | Description |
239
+ |----------|------|---------|-------------|
240
+ | `enabled` | `boolean` | `true` | Master toggle |
241
+ | `messageEntry` | `'slide' \| 'fade' \| 'scale' \| 'spring' \| 'none'` | `'spring'` | Message entry style |
242
+ | `typingIndicator` | `'dots' \| 'wave' \| 'pulse' \| 'none'` | `'dots'` | Typing animation |
243
+ | `buttonEffects` | `boolean` | `true` | Hover/press effects |
244
+ | `smoothScroll` | `boolean` | `true` | Smooth scroll in messages |
245
+ | `launcherPulse` | `boolean` | `true` | Launcher pulse animation |
246
+ | `windowTransitions` | `boolean` | `true` | Window open/close animation |
247
+
248
+ ### `EffectsConfig`
249
+
250
+ | Property | Type | Default | Description |
251
+ |----------|------|---------|-------------|
252
+ | `glassmorphism` | `boolean` | `true` | Blur effect on headers |
253
+ | `gradients` | `boolean` | `true` | Gradient backgrounds |
254
+ | `softShadows` | `boolean` | `true` | Soft shadow effects |
255
+ | `glowEffects` | `boolean` | `true` | Hover/focus glow |
256
+ | `shimmerLoading` | `boolean` | `true` | Shimmer loading skeleton |
257
+ | `hoverLift` | `boolean` | `true` | Card hover lift effect |
258
+
259
+ ---
260
+
261
+ ## Dark Mode
262
+
263
+ The widget auto-detects dark mode via:
264
+ 1. `data-theme="dark"` attribute on `<html>`
265
+ 2. `prefers-color-scheme: dark` media query
266
+
267
+ When dark mode is active, colors are applied in this priority:
268
+ 1. **User-provided `darkCssVariables`** (highest priority)
269
+ 2. **Server-sent `darkCssVariables`** (from agent config)
270
+ 3. **Built-in dark defaults** (fallback)
271
+
272
+ `primary` and `primaryForeground` are **never overridden** by dark defaults — they always come from your brand configuration.
273
+
274
+ ---
275
+
276
+ ## Events
277
+
278
+ Listen to widget lifecycle events via `onEvent`:
279
+
280
+ | Event Name | Data | Description |
281
+ |-----------|------|-------------|
282
+ | `backend_config` | `config` | Agent config received from server |
283
+ | `history_loaded` | `{ messages }` | Chat history loaded |
284
+ | `message_sent` | `{ id }` | Message delivered successfully |
285
+ | `message_failed` | `{ id, payload }` | Message delivery failed |
286
+ | `queued_message` | `{ id, payload }` | Message queued (offline) |
287
+
288
+ ---
289
+
290
+ ## Development
291
+
292
+ ```bash
293
+ npm run dev # Start dev server
294
+ npm run build # Production build (ES + UMD + types)
295
+ npm run test:run # Run all tests
296
+ npm run lint # ESLint
297
+ npm run typecheck # TypeScript check
298
+ ```
299
+
300
+ ## License
301
+
302
+ MIT