minerva-plexus-csd 1.0.11 → 1.0.12
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.
|
@@ -32262,11 +32262,15 @@ const a6 = (e) => {
|
|
|
32262
32262
|
font-size: 14px;
|
|
32263
32263
|
text-align: center;
|
|
32264
32264
|
`, u6 = M.div`
|
|
32265
|
-
|
|
32266
|
-
|
|
32267
|
-
color: #
|
|
32268
|
-
|
|
32269
|
-
|
|
32265
|
+
align-self: flex-start;
|
|
32266
|
+
max-width: 70%;
|
|
32267
|
+
background-color: #f8f8f8;
|
|
32268
|
+
color: #252525;
|
|
32269
|
+
font-size: 14px;
|
|
32270
|
+
padding: 16px 19px;
|
|
32271
|
+
border-radius: 6px;
|
|
32272
|
+
box-shadow: 0px 0.8px 2px 1px rgba(161, 161, 161, 0.5);
|
|
32273
|
+
word-wrap: break-word;
|
|
32270
32274
|
`, Fy = ({
|
|
32271
32275
|
showControlButtons: e = !0,
|
|
32272
32276
|
showConversationTitle: t = !0,
|
|
@@ -36330,7 +36334,7 @@ const lL = ({
|
|
|
36330
36334
|
showDate: n = !0,
|
|
36331
36335
|
showHeader: r = !0,
|
|
36332
36336
|
createWhenLogin: a = !1,
|
|
36333
|
-
createWhenCsd: i = !
|
|
36337
|
+
createWhenCsd: i = !0,
|
|
36334
36338
|
showControlButtons: o = !0,
|
|
36335
36339
|
chatVersion: s = "mini",
|
|
36336
36340
|
className: l,
|
|
@@ -1015,11 +1015,15 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1015
1015
|
font-size: 14px;
|
|
1016
1016
|
text-align: center;
|
|
1017
1017
|
`,_4=D.div`
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
color: #
|
|
1021
|
-
|
|
1022
|
-
|
|
1018
|
+
align-self: flex-start;
|
|
1019
|
+
max-width: 70%;
|
|
1020
|
+
background-color: #f8f8f8;
|
|
1021
|
+
color: #252525;
|
|
1022
|
+
font-size: 14px;
|
|
1023
|
+
padding: 16px 19px;
|
|
1024
|
+
border-radius: 6px;
|
|
1025
|
+
box-shadow: 0px 0.8px 2px 1px rgba(161, 161, 161, 0.5);
|
|
1026
|
+
word-wrap: break-word;
|
|
1023
1027
|
`,q1=({showControlButtons:e=!0,showConversationTitle:t=!0,showDate:n=!0,showPlexo:r=!0,showFeedbackButtons:a=!0,showeditIcon:i=!0})=>{const{t:o}=Nt.useTranslation("minerva"),{selectedConversation:s}=Kt(),{messages:l,fetchMessages:u,isBotStreaming:c}=Ar(),[d,f]=I.useState(null),p=I.useRef(null),h=I.useRef(null);I.useEffect(()=>{p.current&&p.current.scrollIntoView({behavior:"smooth"})},[l]),I.useEffect(()=>{s&&s.id!==h.current&&(h.current=s.id,setTimeout(()=>{u(s.id)},0))},[s,u]);const S=I.useCallback((b,m)=>{const A=new SpeechSynthesisUtterance(b);f(m),A.onend=()=>{f(null)},speechSynthesis.speak(A)},[]),x=I.useCallback(()=>{speechSynthesis.cancel(),f(null)},[]),T=b=>{console.log("Feedback recibido:",b)};return g.jsx(C4,{children:s?g.jsxs("div",{children:[t&&g.jsx(x4,{children:s.title}),g.jsxs(T4,{children:[n&&g.jsx(A4,{children:w4(s.created_at)}),l.length===0?g.jsx(_4,{children:o("text.welcome_text")}):l.map(b=>{const m=d===b.id;return g.jsx("div",{children:b.sender_type==="user"?g.jsx(kv,{showeditIcon:i,message:b,showControlButtons:e}):g.jsx(s4,{showPlexo:r,showFeedbackButtons:a,message:b,isReading:m,onReadAloud:S,onStopReading:x,showControlButtons:e,onFeedback:T,isStreaming:c})},va())}),g.jsx("div",{ref:p})]})]}):g.jsx(g.Fragment,{children:g.jsx("p",{children:t?o("logMessages.no_conversations_available"):null})})})};var G1={exports:{}};/*!
|
|
1024
1028
|
Copyright (c) 2018 Jed Watson.
|
|
1025
1029
|
Licensed under the MIT License (MIT), see
|
|
@@ -1243,7 +1247,7 @@ Valid keys: `+JSON.stringify(Object.keys(N),null," "));var H=Te(ee,re,K,W,J+"."
|
|
|
1243
1247
|
padding-top: 19px;
|
|
1244
1248
|
margin-bottom: 20px;
|
|
1245
1249
|
box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.5);
|
|
1246
|
-
`;const T6=({showHeader:e,customLogo:t,showDate:n,showCreateConversation:r,showControlButtons:a,className:i,showConversationTitle:o})=>{const s=!!t;return g.jsx(w6,{className:i,showHeader:e,hasCustomLogo:s,showCreateConversation:r,showDate:n,showConversationTitle:o,showControlButtons:a})},yy=I.createContext(void 0),vy=({children:e})=>{const[t,n]=I.useState([]),[r,a]=I.useState(!1),[i,o]=I.useState(!1),s=I.useRef(null),l=I.useRef(null),[u,c]=I.useState(!1),{preloadInteractions:d,typeWritterSpeed:f}=Ap(),p=I.useRef(null),h=async m=>{try{a(!0);const E=(await Dy(m)).map(y=>({...y}));d(E),n(y=>{const k=y.find(M=>M.pendingSync&&M.sender_type==="ai");if(!k)return E;const L=E.find(M=>M.sender_type==="ai"&&Math.abs(new Date(M.created_at).getTime()-new Date(k.created_at).getTime())<3e3);return L?E.map(M=>M.id===L.id?{...L,content:k.content}:M):E})}catch(A){console.error("Failed to fetch messages:",A)}finally{a(!1)}},S=async(m,A,E)=>{const y={id:`user-${new Date().toISOString()}`,content:A,sender_type:"user",conversation_id:m,created_at:new Date().toISOString()};n(M=>[...M,y].sort((F,B)=>new Date(F.created_at).getTime()-new Date(B.created_at).getTime()));const k=`bot-loading-${new Date().toISOString()}`;s.current=k;const L={id:k,content:"",loadingContent:g.jsx(Ea,{}),sender_type:"ai",conversation_id:m,created_at:new Date().toISOString(),pendingSync:!0};n(M=>[...M,L].sort((F,B)=>new Date(F.created_at).getTime()-new Date(B.created_at).getTime())),a(!0),o(!0);const R=new AbortController;l.current=R,c(!0);try{const M=await My(m,A,E,R.signal);if(!M)throw new Error("Error: La respuesta en streaming es nula.");const O=M.getReader();p.current=O;const F=new TextDecoder;let B="";for(;;){const{done:z,value:q}=await O.read();if(z)break;const Z=F.decode(q,{stream:!0});i&&o(!1),await jc(Z,f,X=>{B+=X,n(Y=>Y.map(w=>w.id===k?{...w,content:B,loadingContent:void 0}:w).sort((w,N)=>new Date(w.created_at).getTime()-new Date(N.created_at).getTime()))})}await h(m)}catch(M){M instanceof Error&&M.message.includes("cancel")?console.log("Stream cancelado por el usuario"):console.error("Error en el streaming del bot:",M)}finally{a(!1),c(!1),l.current=null,p.current=null,s.current=null}},x=async(m,A,E)=>{n(L=>{const R=L.findIndex(O=>O.id===A);return R===-1?L:[...L.slice(0,R),{...L[R],content:E,created_at:new Date().toISOString()}]});const y=`bot-edit-loading-${Date.now()}`;let k={id:y,content:"",loadingContent:g.jsx(Ea,{}),sender_type:"ai",conversation_id:m,created_at:new Date().toISOString(),pendingSync:!0};n(L=>[...L,k]),a(!0);try{const R=(await Fy(m,A,E)).getReader();p.current=R;const M=new TextDecoder;let O="";for(;;){const{done:F,value:B}=await R.read();if(F)break;const z=M.decode(B,{stream:!0});await jc(z,f,q=>{O+=q,n(Z=>Z.map(X=>X.id===y?{...X,content:O,loadingContent:void 0}:X))})}await h(m)}catch(L){L instanceof Error&&L.message.includes("cancel")?console.log("Stream de edición cancelado por el usuario"):console.error("Error al editar mensaje y relanzar:",L)}finally{a(!1),c(!1),p.current=null,s.current=null}},T=async m=>{try{if(console.log("🔄 Intentando detener el stream desde MessageContext..."),l.current&&(l.current.abort(),l.current=null),s.current)try{await Tp.register(s.current,wt.STOP)}catch(A){console.warn("Error al cancelar el reader:",A)}return await $c(m),console.log("AAA Stream detenido correctamente en el backend"),c(!1),a(!1),o(!1),console.log("✅ Stream detenido correctamente"),!0}catch(A){return console.error("❌ Error al detener el stream:",A),!1}},b=I.useMemo(()=>({messages:t,fetchMessages:h,addMessage:S,isBotWriting:r,isBotStreaming:u,isWaitingForFirstResponse:i,setIsWaitingForFirstResponse:o,currentBotMessageId:s.current,editAndReplayMessage:x,stopStreamingResponse:T}),[t,r,u,i]);return g.jsx(yy.Provider,{value:b,children:e})},Ar=()=>{const e=I.useContext(yy);if(!e)throw new Error("useMessage must be used within a MessageProvider");return e},x6=({theme:e,customLogo:t,showDate:n=!0,showHeader:r=!0,createWhenLogin:a=!1,createWhenCsd:i=!
|
|
1250
|
+
`;const T6=({showHeader:e,customLogo:t,showDate:n,showCreateConversation:r,showControlButtons:a,className:i,showConversationTitle:o})=>{const s=!!t;return g.jsx(w6,{className:i,showHeader:e,hasCustomLogo:s,showCreateConversation:r,showDate:n,showConversationTitle:o,showControlButtons:a})},yy=I.createContext(void 0),vy=({children:e})=>{const[t,n]=I.useState([]),[r,a]=I.useState(!1),[i,o]=I.useState(!1),s=I.useRef(null),l=I.useRef(null),[u,c]=I.useState(!1),{preloadInteractions:d,typeWritterSpeed:f}=Ap(),p=I.useRef(null),h=async m=>{try{a(!0);const E=(await Dy(m)).map(y=>({...y}));d(E),n(y=>{const k=y.find(M=>M.pendingSync&&M.sender_type==="ai");if(!k)return E;const L=E.find(M=>M.sender_type==="ai"&&Math.abs(new Date(M.created_at).getTime()-new Date(k.created_at).getTime())<3e3);return L?E.map(M=>M.id===L.id?{...L,content:k.content}:M):E})}catch(A){console.error("Failed to fetch messages:",A)}finally{a(!1)}},S=async(m,A,E)=>{const y={id:`user-${new Date().toISOString()}`,content:A,sender_type:"user",conversation_id:m,created_at:new Date().toISOString()};n(M=>[...M,y].sort((F,B)=>new Date(F.created_at).getTime()-new Date(B.created_at).getTime()));const k=`bot-loading-${new Date().toISOString()}`;s.current=k;const L={id:k,content:"",loadingContent:g.jsx(Ea,{}),sender_type:"ai",conversation_id:m,created_at:new Date().toISOString(),pendingSync:!0};n(M=>[...M,L].sort((F,B)=>new Date(F.created_at).getTime()-new Date(B.created_at).getTime())),a(!0),o(!0);const R=new AbortController;l.current=R,c(!0);try{const M=await My(m,A,E,R.signal);if(!M)throw new Error("Error: La respuesta en streaming es nula.");const O=M.getReader();p.current=O;const F=new TextDecoder;let B="";for(;;){const{done:z,value:q}=await O.read();if(z)break;const Z=F.decode(q,{stream:!0});i&&o(!1),await jc(Z,f,X=>{B+=X,n(Y=>Y.map(w=>w.id===k?{...w,content:B,loadingContent:void 0}:w).sort((w,N)=>new Date(w.created_at).getTime()-new Date(N.created_at).getTime()))})}await h(m)}catch(M){M instanceof Error&&M.message.includes("cancel")?console.log("Stream cancelado por el usuario"):console.error("Error en el streaming del bot:",M)}finally{a(!1),c(!1),l.current=null,p.current=null,s.current=null}},x=async(m,A,E)=>{n(L=>{const R=L.findIndex(O=>O.id===A);return R===-1?L:[...L.slice(0,R),{...L[R],content:E,created_at:new Date().toISOString()}]});const y=`bot-edit-loading-${Date.now()}`;let k={id:y,content:"",loadingContent:g.jsx(Ea,{}),sender_type:"ai",conversation_id:m,created_at:new Date().toISOString(),pendingSync:!0};n(L=>[...L,k]),a(!0);try{const R=(await Fy(m,A,E)).getReader();p.current=R;const M=new TextDecoder;let O="";for(;;){const{done:F,value:B}=await R.read();if(F)break;const z=M.decode(B,{stream:!0});await jc(z,f,q=>{O+=q,n(Z=>Z.map(X=>X.id===y?{...X,content:O,loadingContent:void 0}:X))})}await h(m)}catch(L){L instanceof Error&&L.message.includes("cancel")?console.log("Stream de edición cancelado por el usuario"):console.error("Error al editar mensaje y relanzar:",L)}finally{a(!1),c(!1),p.current=null,s.current=null}},T=async m=>{try{if(console.log("🔄 Intentando detener el stream desde MessageContext..."),l.current&&(l.current.abort(),l.current=null),s.current)try{await Tp.register(s.current,wt.STOP)}catch(A){console.warn("Error al cancelar el reader:",A)}return await $c(m),console.log("AAA Stream detenido correctamente en el backend"),c(!1),a(!1),o(!1),console.log("✅ Stream detenido correctamente"),!0}catch(A){return console.error("❌ Error al detener el stream:",A),!1}},b=I.useMemo(()=>({messages:t,fetchMessages:h,addMessage:S,isBotWriting:r,isBotStreaming:u,isWaitingForFirstResponse:i,setIsWaitingForFirstResponse:o,currentBotMessageId:s.current,editAndReplayMessage:x,stopStreamingResponse:T}),[t,r,u,i]);return g.jsx(yy.Provider,{value:b,children:e})},Ar=()=>{const e=I.useContext(yy);if(!e)throw new Error("useMessage must be used within a MessageProvider");return e},x6=({theme:e,customLogo:t,showDate:n=!0,showHeader:r=!0,createWhenLogin:a=!1,createWhenCsd:i=!0,showControlButtons:o=!0,chatVersion:s="mini",className:l,showLogoutButton:u=!0,showCreateConversation:c=!0,showConversationTitle:d=!0,showPlexo:f=!0,showFeedbackButtons:p=!0,showeditIcon:h=!0})=>{const S=Uc[e];console.log("theme que llega",e);const{addConversation:x,selectConversation:T,service:b,conversations:m}=Kt();return Nr({enableAutoCreate:a,enableAutoCreateCsd:i,addConversation:x,selectConversation:T,service:b,conversations:m}),g.jsx(vy,{children:s==="mini"?g.jsx(y6,{showeditIcon:h,showPlexo:f,showFeedbackButtons:p,showLogoutButton:u,showDate:n,customLogo:t,themeDisplayName:S,showHeader:r,showCreateConversation:c,showControlButtons:o,className:l,showConversationTitle:d}):g.jsx(T6,{showDate:n,customLogo:t,showHeader:r,showCreateConversation:c,showControlButtons:o,className:l,showConversationTitle:d})})},_r=D.pre`
|
|
1247
1251
|
display: flex;
|
|
1248
1252
|
justify-content: start;
|
|
1249
1253
|
align-items: center;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "minerva-plexus-csd",
|
|
3
3
|
"private": false,
|
|
4
4
|
"description": "A reusable chat logic library for React applications",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.12",
|
|
6
6
|
"main": "dist/minerva-plexus-csd.umd.js",
|
|
7
7
|
"module": "dist/minerva-plexus-csd.es.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|