@botuyo/chat-widget-standalone 1.0.64 → 1.0.66
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 +21 -21
- package/dist/Avatar3D-LfNJe183.js.map +1 -1
- package/dist/botuyo-chat.es.js +22 -22
- package/dist/botuyo-chat.es.js.map +1 -1
- package/dist/botuyo-chat.umd.js +1 -1
- package/dist/botuyo-chat.umd.js.map +1 -1
- package/dist/chunk-audio-f-7lTw8u.js.map +1 -1
- package/dist/chunk-chat-ui-C3MpSoay.js.map +1 -1
- package/dist/chunk-gallery-UGD27UqU.js.map +1 -1
- package/dist/src/chat-widget/ChatWidgetProvider.d.ts.map +1 -1
- package/dist/src/chat-widget/components/Gallery.stories.d.ts.map +1 -1
- package/dist/stats-umd.html +1 -1
- package/dist/stats.html +1 -1
- package/package.json +155 -155
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk-audio-f-7lTw8u.js","sources":["../src/chat-widget/components/AudioPlayer.tsx"],"sourcesContent":["'use client'\
|
|
1
|
+
{"version":3,"file":"chunk-audio-f-7lTw8u.js","sources":["../src/chat-widget/components/AudioPlayer.tsx"],"sourcesContent":["'use client'\n\nimport { useState, useRef, useMemo, memo, useCallback } from 'react'\nimport { Play, Pause, Loader2, AlertCircle, RotateCw } from './Icons'\nimport { cn } from '@/lib/utils'\nimport { getPrimaryColor } from '../utils/theme'\n\ninterface AudioPlayerProps {\n url: string\n isBot: boolean\n primaryColor?: string\n}\n\nexport type { AudioPlayerProps }\n\nexport const AudioPlayer = memo(function AudioPlayer({\n url,\n isBot,\n primaryColor,\n}: AudioPlayerProps) {\n const [isPlaying, setIsPlaying] = useState(false)\n const [duration, setDuration] = useState(0)\n const [currentTime, setCurrentTime] = useState(0)\n // Blob URLs from URL.createObjectURL() are valid during the current session\n const [isLoading, setIsLoading] = useState(true)\n const [error, setError] = useState<string | null>(null)\n const audioRef = useRef<HTMLAudioElement>(null)\n\n const brandColor = useMemo(() => getPrimaryColor({ primaryColor }), [primaryColor])\n\n const togglePlay = useCallback(() => {\n if (error) return\n if (isPlaying) audioRef.current?.pause()\n else audioRef.current?.play().catch((e) => {\n console.error('[AudioPlayer] Play error:', e)\n setError('Error al reproducir')\n })\n setIsPlaying(!isPlaying)\n }, [isPlaying, error])\n\n const handleLoadedMetadata = useCallback(() => {\n setDuration(audioRef.current?.duration || 0)\n }, [])\n\n const handleCanPlayThrough = useCallback(() => {\n setIsLoading(false)\n setError(null)\n }, [])\n\n const handleError = useCallback(() => {\n console.error('[AudioPlayer] Failed to load audio:', url)\n setIsLoading(false)\n setError('No se pudo cargar')\n }, [url])\n\n const handleRetry = useCallback(() => {\n setIsLoading(true)\n setError(null)\n if (audioRef.current) {\n audioRef.current.load()\n }\n }, [])\n\n return (\n <div\n className={cn(\n 'flex items-center gap-3 py-1 min-w-[200px]',\n isBot ? 'text-foreground' : 'text-primary-foreground'\n )}\n >\n {/* Always render <audio> — onError handles expired URLs naturally */}\n <audio\n ref={audioRef}\n src={url}\n preload=\"metadata\"\n onLoadedMetadata={handleLoadedMetadata}\n onCanPlayThrough={handleCanPlayThrough}\n onTimeUpdate={() => setCurrentTime(audioRef.current?.currentTime || 0)}\n onEnded={() => setIsPlaying(false)}\n onError={handleError}\n />\n \n {error ? (\n // Error state - show retry button\n <button\n onClick={handleRetry}\n className=\"w-8 h-8 rounded-full flex items-center justify-center shrink-0 bg-red-500/20 text-red-500 hover:bg-red-500/30 transition-colors\"\n title=\"Reintentar\"\n >\n <RotateCw className=\"w-4 h-4\" />\n </button>\n ) : (\n // Normal play/pause button\n <button\n onClick={togglePlay}\n disabled={isLoading}\n className=\"w-8 h-8 rounded-full flex items-center justify-center shrink-0 transition-opacity\"\n style={{\n backgroundColor: isBot ? brandColor : 'hsl(var(--card))',\n color: isBot ? 'white' : brandColor,\n opacity: isLoading ? 0.6 : 1,\n }}\n >\n {isLoading ? (\n <Loader2 className=\"w-4 h-4 animate-spin\" />\n ) : isPlaying ? (\n <Pause className=\"w-4 h-4 fill-current\" />\n ) : (\n <Play className=\"w-4 h-4 fill-current ml-0.5\" />\n )}\n </button>\n )}\n \n <div className=\"flex-1 space-y-1\">\n {error ? (\n <div className=\"flex items-center gap-1.5 text-red-500\">\n <AlertCircle className=\"w-3 h-3\" />\n <span className=\"text-[9px] font-bold\">{error}</span>\n </div>\n ) : (\n <>\n <div className=\"relative h-1 w-full bg-current/20 rounded-full overflow-hidden\">\n <div\n className=\"absolute h-full bg-current rounded-full transition-all\"\n style={{ width: `${(currentTime / duration) * 100 || 0}%` }}\n />\n </div>\n <div className=\"flex justify-between text-[9px] font-bold opacity-60\">\n <span>\n {Math.floor(currentTime / 60)}:\n {Math.floor(currentTime % 60)\n .toString()\n .padStart(2, '0')}\n </span>\n <span>\n {isLoading ? '--:--' : `${Math.floor(duration / 60)}:${Math.floor(duration % 60).toString().padStart(2, '0')}`}\n </span>\n </div>\n </>\n )}\n </div>\n </div>\n )\n})\n"],"names":["AudioPlayer","memo","url","isBot","primaryColor","isPlaying","setIsPlaying","useState","duration","setDuration","currentTime","setCurrentTime","isLoading","setIsLoading","error","setError","audioRef","useRef","brandColor","useMemo","getPrimaryColor","togglePlay","useCallback","current","pause","play","catch","e","console","handleLoadedMetadata","handleCanPlayThrough","handleError","handleRetry","load","jsxs","className","cn","children","jsx","ref","src","preload","onLoadedMetadata","onCanPlayThrough","onTimeUpdate","onEnded","onError","onClick","title","RotateCw","disabled","style","backgroundColor","color","opacity","Loader2","Pause","Play","AlertCircle","Fragment","width","Math","floor","toString","padStart"],"mappings":"0OAeO,MAAMA,EAAcC,EAAK,UAAqBC,IACnDA,EAAAC,MACAA,EAAAC,aACAA,IAEA,MAAOC,EAAWC,GAAgBC,GAAS,IACpCC,EAAUC,GAAeF,EAAS,IAClCG,EAAaC,GAAkBJ,EAAS,IAExCK,EAAWC,GAAgBN,GAAS,IACpCO,EAAOC,GAAYR,EAAwB,MAC5CS,EAAWC,EAAyB,MA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