@botuyo/chat-widget-standalone 1.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Paseo Libre
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,438 @@
1
+ # BotUyo Chat Widget - Standalone/CDN Version
2
+
3
+ Widget de chat embebible enterprise-ready que puede ser usado en cualquier sitio web sin necesidad de React, Next.js u otros frameworks. También disponible como componente React con Provider y hooks.
4
+
5
+ ## 🎉 Última Actualización (25 Enero 2026)
6
+
7
+ **Stack Modernizado + Optimización en Progreso**
8
+
9
+ ### ✅ Completado
10
+ - 🚀 **React 19.2.3** - Última versión estable con concurrent features
11
+ - ⚡ **Vite 7.3.1** - Build tool más rápido y optimizado
12
+ - 📏 **ESLint 9.39.2** - Migrado a flat config (eslint.config.js)
13
+ - 🟢 **Node.js 22.22.0** - LTS actual
14
+ - 🔧 **TypeScript ESLint 8.53.1** - Mejores reglas de linting
15
+
16
+ ### ✅ Code Splitting Completado (26 Ene 2026)
17
+ - ✅ **Code Splitting Implementado**: 7 chunks separados
18
+ - ✅ **33% Reducción**: Carga inicial de 306KB → 208KB gzip
19
+ - ✅ **ES Module Format**: Lazy loading real con chunks
20
+ - ✅ **React.lazy() + Suspense**: ChatWidget bajo demanda
21
+ - 📦 **Bundle**: 683KB inicial + 324KB lazy (total 1,007KB)
22
+
23
+ ### 🔄 En Optimización (Semana 4)
24
+ - ⏳ **Lazy Loading Adicional**: Gallery y AudioPlayer
25
+ - 📋 **CSS Optimization**: cssnano compression
26
+ - 📋 **Preload Hints**: Recursos críticos
27
+
28
+ ### 📊 Estado del Proyecto
29
+ - ✅ **Build**: Exitoso (Vite 7.3.1)
30
+ - ✅ **Tests**: 616/626 pasando (98.4%)
31
+ - 📦 **Bundle**: 1,021 kB JS (306 kB gzip), 45 kB CSS (8.7 kB gzip)
32
+ - ⏳ **Optimización**: Code splitting en implementación
33
+ - ✅ **Lint**: 0 errores, 9 warnings informativos
34
+ - ✅ **TypeScript**: Tipos generados correctamente
35
+
36
+ ### 🔧 Cambios Técnicos Recientes
37
+ - Creado `vite.config.mjs` (JavaScript puro, evita transpilación)
38
+ - Migrado a `eslint.config.js` (flat config ESLint 9)
39
+ - Agregado `.nvmrc` para fijar Node 22
40
+ - Actualizado `tsconfig.json` con `esModuleInterop`
41
+ - Test fixes para React 19 concurrent rendering
42
+ - Instalado `rollup-plugin-visualizer` para análisis de bundle
43
+
44
+ 📖 **[Ver roadmap completo en MEJORAS_PROPUESTAS.md](./MEJORAS_PROPUESTAS.md)**
45
+ 🎯 **[Ver plan de optimización en OPTIMIZATION_PLAN.md](./OPTIMIZATION_PLAN.md)**
46
+ 📊 **[Ver estado actual en STATUS.md](./STATUS.md)**
47
+
48
+ ---
49
+
50
+ ## 🎨 Theme Builder (Herramienta de Configuración)
51
+
52
+ **[Abre el Theme Builder](./theme-builder.html)** - Herramienta visual para crear y personalizar temas en tiempo real.
53
+
54
+ Características:
55
+ - 🎨 **5 Temas Predefinidos**: Default, Ocean, Sunset, Midnight, Nature
56
+ - 🖌️ **Editor Visual**: Personaliza colores, espaciado, dimensiones
57
+ - 👁️ **Preview en Vivo**: Ve los cambios en tiempo real
58
+ - 📋 **Copiar Config**: Exporta la configuración lista para usar
59
+ - 🎯 **Para Dashboard**: Herramienta oficial para generar configs de clientes
60
+
61
+ ## 📚 Documentación
62
+ - **[🎯 Roadmap y Mejoras](./MEJORAS_PROPUESTAS.md)** - Estado actual y próximos pasos
63
+ - **[✅ Cobertura de Personalización](./CUSTOMIZATION_COVERAGE.md)** - ¡TODO lo que puedes personalizar!
64
+ - **[🎯 Guía Rápida de Temas](./QUICK_THEME_SETUP.md)** - ¡Empieza aquí si el widget se ve transparente!
65
+ - **[🎨 Guía Completa de Personalización](./THEME_GUIDE.md)** - Temas, colores y ejemplos avanzados
66
+ - **[📖 Documentación CSS Variables](./CSS_CUSTOMIZATION.md)** - Detalles técnicos del sistema de diseño
67
+
68
+ ## 🚀 Instalación Rápida
69
+
70
+ ### Opción 1: CDN (JavaScript Vanilla)
71
+
72
+ Agrega este código antes del cierre del `</body>` en tu HTML:
73
+
74
+ ```html
75
+ <!-- BotUyo Chat Widget -->
76
+ <script src="https://cdn.botuyo.com/chat-widget.js"></script>
77
+ <script>
78
+ BotUyoChat.init({
79
+ apiKey: 'tu-api-key-aqui',
80
+ apiBaseUrl: 'https://api.botuyo.com',
81
+ theme: {
82
+ primaryColor: 'hsl(160, 84%, 39%)',
83
+ botName: 'Asistente BotUyo',
84
+ position: 'bottom-right',
85
+ // ⚠️ IMPORTANTE: Variables CSS necesarias
86
+ cssVariables: {
87
+ background: '0 0% 100%', // Fondo blanco
88
+ foreground: '240 10% 3.9%', // Texto oscuro
89
+ primary: '160 84% 39%', // Color principal
90
+ // ... Ver QUICK_THEME_SETUP.md para más opciones
91
+ }
92
+ }
93
+ });
94
+ </script>
95
+ ```
96
+
97
+ ### Opción 2: NPM Package (React/Next.js)
98
+
99
+ **Instalación:**
100
+ ```bash
101
+ npm install @botuyo/chat-widget-standalone
102
+ ```
103
+
104
+ **Uso con Provider:**
105
+ ```tsx
106
+ import { ChatWidgetProvider, useChatWidget } from '@botuyo/chat-widget-standalone';
107
+
108
+ function App() {
109
+ return (
110
+ <ChatWidgetProvider
111
+ apiKey="tu-api-key-aqui"
112
+ apiBaseUrl="https://api.botuyo.com"
113
+ theme={{
114
+ primaryColor: 'hsl(160, 84%, 39%)',
115
+ // ⚠️ IMPORTANTE: Variables CSS necesarias
116
+ cssVariables: {
117
+ background: '0 0% 100%',
118
+ foreground: '240 10% 3.9%',
119
+ primary: '160 84% 39%',
120
+ // ... Ver QUICK_THEME_SETUP.md para configuración completa
121
+ }
122
+ }}
123
+ >
124
+ <YourApp />
125
+ </ChatWidgetProvider>
126
+ );
127
+ }
128
+
129
+ // En cualquier componente:
130
+ function MyComponent() {
131
+ const chat = useChatWidget();
132
+ return <button onClick={chat.open}>Abrir Chat</button>;
133
+ }
134
+ ```
135
+
136
+ **Uso directo:**
137
+ ```tsx
138
+ import { ChatWidget } from '@botuyo/chat-widget-standalone';
139
+
140
+ function App() {
141
+ return (
142
+ <ChatWidget
143
+ apiKey="tu-api-key-aqui"
144
+ apiBaseUrl="https://api.botuyo.com"
145
+ theme={{
146
+ primaryColor: 'hsl(160, 84%, 39%)',
147
+ cssVariables: {
148
+ background: '0 0% 100%',
149
+ foreground: '240 10% 3.9%',
150
+ primary: '160 84% 39%',
151
+ }
152
+ }}
153
+ />
154
+ );
155
+ }
156
+ ```
157
+
158
+ ## ⚙️ Configuración
159
+
160
+ ### Opciones Disponibles
161
+
162
+ ```typescript
163
+ interface StandaloneConfig {
164
+ // Requerido
165
+ apiKey: string; // Tu API key de BotUyo
166
+ apiBaseUrl: string; // URL del backend Socket.IO
167
+
168
+ // Tema (opcional)
169
+ theme?: {
170
+ primaryColor?: string; // Color principal (default: '#10b981')
171
+ botName?: string; // Nombre del bot (default: 'Asistente Virtual')
172
+ logoUrl?: string; // URL del logo (default: '/avatar/mar_default.webp')
173
+ position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
174
+ welcomeMessage?: string; // Mensaje de bienvenida
175
+ inputPlaceholder?: string; // Placeholder del input
176
+ borderRadius?: string; // Border radius (default: '0.75rem')
177
+ launcherBorderRadius?: string; // Border radius del botón (default: '50%')
178
+ };
179
+
180
+ // Contexto del usuario (opcional)
181
+ userContext?: {
182
+ token?: string; // Token de autenticación
183
+ metadata?: any; // Metadata adicional
184
+ };
185
+
186
+ // Contexto de la página (opcional)
187
+ pageContext?: {
188
+ url?: string;
189
+ title?: string;
190
+ path?: string;
191
+ referrer?: string;
192
+ };
193
+
194
+ // SEO (opcional)
195
+ includeSEOMetadata?: boolean; // Incluir metadata SEO (default: false)
196
+
197
+ // Callbacks (opcional)
198
+ onNavigate?: (url: string) => void;
199
+ onLogin?: (loginUrl: string) => void;
200
+ onEvent?: (eventName: string, data: any) => void;
201
+ onStateChange?: (isOpen: boolean) => void;
202
+ }
203
+ ```
204
+
205
+ ## 📚 Ejemplos de Uso
206
+
207
+ ### Ejemplo Básico
208
+
209
+ ```html
210
+ <!DOCTYPE html>
211
+ <html>
212
+ <head>
213
+ <title>Mi Sitio Web</title>
214
+ </head>
215
+ <body>
216
+ <h1>Bienvenido a mi sitio</h1>
217
+
218
+ <script src="https://cdn.botuyo.com/chat-widget.js"></script>
219
+ <script>
220
+ BotUyoChat.init({
221
+ apiKey: 'demo-key-12345',
222
+ apiBaseUrl: 'http://localhost:4000'
223
+ });
224
+ </script>
225
+ </body>
226
+ </html>
227
+ ```
228
+
229
+ ### Ejemplo con Personalización Completa
230
+
231
+ ```html
232
+ <script>
233
+ BotUyoChat.init({
234
+ apiKey: 'mi-api-key',
235
+ apiBaseUrl: 'https://api.botuyo.com',
236
+
237
+ theme: {
238
+ primaryColor: '#ff6b6b',
239
+ botName: 'Asistente Virtual de Mi Empresa',
240
+ logoUrl: 'https://mi-sitio.com/logo.png',
241
+ position: 'bottom-left',
242
+ welcomeMessage: '¡Hola! ¿Necesitas ayuda?',
243
+ inputPlaceholder: 'Pregúntame lo que quieras...',
244
+ },
245
+
246
+ userContext: {
247
+ token: 'user-auth-token',
248
+ metadata: {
249
+ userId: '12345',
250
+ email: 'user@example.com'
251
+ }
252
+ },
253
+
254
+ pageContext: {
255
+ url: window.location.href,
256
+ title: document.title,
257
+ path: window.location.pathname,
258
+ referrer: document.referrer
259
+ },
260
+
261
+ onNavigate: (url) => {
262
+ console.log('Navegando a:', url);
263
+ window.location.href = url;
264
+ },
265
+
266
+ onEvent: (eventName, data) => {
267
+ console.log('Evento recibido:', eventName, data);
268
+
269
+ // Manejo de eventos personalizados
270
+ if (eventName === 'reservation_created') {
271
+ alert('¡Reserva creada! ID: ' + data.reservationId);
272
+ }
273
+ },
274
+
275
+ onStateChange: (isOpen) => {
276
+ console.log('Chat está', isOpen ? 'abierto' : 'cerrado');
277
+ }
278
+ });
279
+ </script>
280
+ ```
281
+
282
+ ### Ejemplo con Control Programático
283
+
284
+ ```html
285
+ <script>
286
+ // Inicializar
287
+ const chat = BotUyoChat.init({
288
+ apiKey: 'demo-key',
289
+ apiBaseUrl: 'http://localhost:4000'
290
+ });
291
+
292
+ // Abrir el chat programáticamente
293
+ document.getElementById('btnAbrir').addEventListener('click', () => {
294
+ BotUyoChat.open();
295
+ });
296
+
297
+ // Cerrar el chat programáticamente
298
+ document.getElementById('btnCerrar').addEventListener('click', () => {
299
+ BotUyoChat.close();
300
+ });
301
+
302
+ // Enviar un mensaje programáticamente
303
+ document.getElementById('btnEnviar').addEventListener('click', () => {
304
+ BotUyoChat.sendMessage('Hola, necesito ayuda');
305
+ });
306
+
307
+ // Destruir el widget
308
+ document.getElementById('btnDestruir').addEventListener('click', () => {
309
+ BotUyoChat.destroy();
310
+ });
311
+
312
+ // Actualizar configuración
313
+ document.getElementById('btnActualizar').addEventListener('click', () => {
314
+ BotUyoChat.update({
315
+ theme: {
316
+ primaryColor: '#ff6b6b',
317
+ botName: 'Nuevo Nombre'
318
+ }
319
+ });
320
+ });
321
+ </script>
322
+ ```
323
+
324
+ ## 🛠️ API Pública
325
+
326
+ ### `BotUyoChat.init(config)`
327
+
328
+ Inicializa el widget con la configuración proporcionada.
329
+
330
+ **Retorna**: Instancia del widget para encadenamiento.
331
+
332
+ ### `BotUyoChat.open()`
333
+
334
+ Abre la ventana del chat programáticamente.
335
+
336
+ ### `BotUyoChat.close()`
337
+
338
+ Cierra la ventana del chat programáticamente.
339
+
340
+ ### `BotUyoChat.sendMessage(message)`
341
+
342
+ Envía un mensaje al chat programáticamente.
343
+
344
+ **Parámetros**:
345
+ - `message` (string): El mensaje a enviar.
346
+
347
+ ### `BotUyoChat.update(config)`
348
+
349
+ Actualiza la configuración del widget sin reiniciarlo.
350
+
351
+ **Parámetros**:
352
+ - `config` (Partial<StandaloneConfig>): Configuración parcial a actualizar.
353
+
354
+ ### `BotUyoChat.destroy()`
355
+
356
+ Destruye el widget y limpia todos los recursos.
357
+
358
+ ## 🎨 Personalización de Estilos
359
+
360
+ El widget utiliza variables CSS que puedes sobrescribir:
361
+
362
+ ```html
363
+ <style>
364
+ /* Sobrescribir estilos del widget */
365
+ #botuyo-chat-widget-root {
366
+ /* Tus estilos personalizados */
367
+ }
368
+
369
+ /* Variables CSS globales */
370
+ :root {
371
+ --paseo-chat-primary: #10b981;
372
+ --paseo-chat-background: #ffffff;
373
+ --paseo-chat-text: #1f2937;
374
+ --paseo-chat-border: #e5e7eb;
375
+ }
376
+ </style>
377
+ ```
378
+
379
+ ## 🧪 Testing Local
380
+
381
+ Para probar el widget localmente:
382
+
383
+ 1. Clona el repositorio
384
+ 2. Instala dependencias:
385
+ ```bash
386
+ c� Documentación
387
+
388
+ - **[Guía de Inicio Rápido](QUICK_START.md)** - Comienza en 5 minutos
389
+ - **[Guía de Instalación Completa](INSTALLATION_GUIDE.md)** - Instrucciones detalladas para CDN y React
390
+ - **[Checklist de Verificación](VERIFICATION_CHECKLIST.md)** - Verifica que todo funcione correctamente
391
+ - **[Resumen de Implementación](INSTALLATION_SUMMARY.md)** - Resumen técnico completo
392
+ - **[Ejemplos](examples/)** - Ejemplos funcionales (CDN, React, Next.js)
393
+
394
+ ## �d standalone-widget
395
+ npm install
396
+ ```
397
+
398
+ 3. Inicia el servidor de desarrollo:
399
+ ```bash
400
+ npm run dev
401
+ ```
402
+
403
+ 4. Abre `http://localhost:3001` en tu navegador
404
+
405
+ ## 📦 Build para Producción
406
+
407
+ ```bash
408
+ npm run build
409
+ ```
410
+
411
+ Esto generará:
412
+ - `dist/botuyo-chat.js` - Bundle minificado para CDN
413
+ - `dist/botuyo-chat.css` - Estilos del widget
414
+ - `dist/botuyo-chat.js.map` - Source map para debugging
415
+
416
+ ## 🌐 Compatibilidad
417
+
418
+ - ✅ Chrome 90+
419
+ - ✅ Firefox 88+
420
+ - ✅ Safari 14+
421
+ - ✅ Edge 90+
422
+ - ✅ Mobile browsers (iOS Safari, Chrome Mobile)
423
+
424
+ ## 📄 Licencia
425
+
426
+ MIT License - © 2025 BotUyo
427
+
428
+ ## 🆘 Soporte
429
+
430
+ - 📧 Email: soporte@botuyo.com
431
+ - 💬 Chat: https://botuyo.com/soporte
432
+ - 📖 Docs: https://docs.botuyo.com/chat-widget
433
+
434
+ ## 🔗 Links
435
+
436
+ - [Documentación completa](https://docs.botuyo.com)
437
+ - [Ejemplos en vivo](https://botuyo.com/widget-demo)
438
+ - [Repositorio GitHub](https://github.com/botuyo/chat-widget)