@alicloud/appflow-chat 0.0.5-alpha.1 → 0.0.5-alpha.2
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/dist/appflow-chat.cjs.js
CHANGED
|
@@ -1191,7 +1191,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1191
1191
|
&:hover {
|
|
1192
1192
|
background: #f5f5f5;
|
|
1193
1193
|
}
|
|
1194
|
-
`,So=({text:e=""})=>C.jsx(V_,{children:C.jsx("span",{children:e})}),B4=()=>new Promise((e,t)=>{if(typeof window!="undefined"&&window.mermaid){e();return}R4("https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.9.0/mermaid.min.js").then(()=>{window.mermaid.initialize({startOnLoad:!1,theme:"default",securityLevel:"loose",fontFamily:"inherit"}),e()}).catch(n=>{console.error("mermaid加载失败:",n),t(n)})});let W_=0;const G_=()=>`mermaid-${Date.now()}-${W_++}`,X_=e=>{if(!e||e.trim().length<10)return!1;const t=e.trim();return["graph","flowchart","sequenceDiagram","classDiagram","stateDiagram","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","mindmap","timeline"].some(i=>t.startsWith(i)||t.match(new RegExp(`^${i}\\s`,"m")))?/(\w+\s*-->|\w+\s*---|\w+\s*-\.->|\w+\s*==>|\w+\s*\[.*?\]|\w+\s*\(.*?\)|participant\s+\w+|\w+\s*->>)/m.test(t):!1},K_=({code:e})=>{const{t}=gt(),r=K.useRef(null),[n,a]=K.useState(""),[i,s]=K.useState(""),[o,u]=K.useState(!0),[l,c]=K.useState(!1),[f,p]=K.useState(!0),h=K.useRef(""),b=K.useRef(null),y=K.useRef(null);return K.useEffect(()=>(He(exports,null,function*(){try{yield B4(),c(!0)}catch(x){console.error("mermaid加载失败:",x),s(t("markdown.mermaidLoadFailed")),u(!1)}}),()=>{b.current&&clearTimeout(b.current),y.current&&clearTimeout(y.current)}),[]),K.useEffect(()=>{if(!e||!l)return;const T=window.mermaid;if(!T){s(t("markdown.mermaidNotLoaded")),u(!1);return}const x=e!==h.current;if(h.current=e,x&&(p(!0),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{p(!1)},500)),!X_(e)){u(!0),s("");return}return b.current&&clearTimeout(b.current),b.current=setTimeout(()=>He(exports,null,function*(){u(!0),s("");try{const w=G_(),{svg:I}=yield T.render(w,e.trim());a(I),s("");const L=document.getElementById(w);L&&L.remove()}catch(w){document.querySelectorAll('[id^="dmermaid-"]').forEach(L=>L.remove()),f?console.log("Mermaid 流式输出中,暂不显示错误"):(console.error("Mermaid 渲染错误:",w),s((w==null?void 0:w.message)||t("markdown.mermaidRenderFailed")))}finally{u(!1)}}),300),()=>{b.current&&clearTimeout(b.current)}},[e,l,f]),o?C.jsx("div",{style:{width:"100%",minHeight:"100px",padding:"20px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed #d9d9d9",borderRadius:"6px",color:"#666",backgroundColor:"#fafafa",marginTop:"10px",marginBottom:"10px"},children:t("markdown.chartLoading")}):i&&!f?C.jsxs("div",{style:{width:"100%",padding:"20px",border:"1px solid #ffccc7",borderRadius:"6px",color:"#cf1322",backgroundColor:"#fff2f0",marginTop:"10px",marginBottom:"10px"},children:[C.jsx("div",{style:{fontWeight:"bold",marginBottom:"8px"},children:t("markdown.mermaidRenderFailed")}),C.jsx("div",{style:{fontSize:"12px",color:"#666",wordBreak:"break-word",overflowWrap:"break-word",whiteSpace:"pre-wrap"},children:i})]}):i&&f?C.jsx("div",{style:{width:"100%",minHeight:"100px",padding:"20px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed #d9d9d9",borderRadius:"6px",color:"#666",backgroundColor:"#fafafa",marginTop:"10px",marginBottom:"10px"},children:t("markdown.chartLoading")}):C.jsx("div",{ref:r,style:{width:"100%",overflow:"auto",marginTop:"10px",marginBottom:"10px",padding:"10px",backgroundColor:"#fff",borderRadius:"6px",border:"1px solid #e8e8e8"},dangerouslySetInnerHTML:{__html:n}})},Zt=({content:e,waitingMessage:t=""})=>{const{t:r}=gt(),n=K.useMemo(()=>({remarkPlugins:[KE,nv,YS],rehypePlugins:[Dv,jS],components:{img:c=>{var f=c,{node:u}=f,l=ki(f,["node"]);return C.jsx(ve.Image,{style:{maxWidth:"100%",maxHeight:"
|
|
1194
|
+
`,So=({text:e=""})=>C.jsx(V_,{children:C.jsx("span",{children:e})}),B4=()=>new Promise((e,t)=>{if(typeof window!="undefined"&&window.mermaid){e();return}R4("https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.9.0/mermaid.min.js").then(()=>{window.mermaid.initialize({startOnLoad:!1,theme:"default",securityLevel:"loose",fontFamily:"inherit"}),e()}).catch(n=>{console.error("mermaid加载失败:",n),t(n)})});let W_=0;const G_=()=>`mermaid-${Date.now()}-${W_++}`,X_=e=>{if(!e||e.trim().length<10)return!1;const t=e.trim();return["graph","flowchart","sequenceDiagram","classDiagram","stateDiagram","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","mindmap","timeline"].some(i=>t.startsWith(i)||t.match(new RegExp(`^${i}\\s`,"m")))?/(\w+\s*-->|\w+\s*---|\w+\s*-\.->|\w+\s*==>|\w+\s*\[.*?\]|\w+\s*\(.*?\)|participant\s+\w+|\w+\s*->>)/m.test(t):!1},K_=({code:e})=>{const{t}=gt(),r=K.useRef(null),[n,a]=K.useState(""),[i,s]=K.useState(""),[o,u]=K.useState(!0),[l,c]=K.useState(!1),[f,p]=K.useState(!0),h=K.useRef(""),b=K.useRef(null),y=K.useRef(null);return K.useEffect(()=>(He(exports,null,function*(){try{yield B4(),c(!0)}catch(x){console.error("mermaid加载失败:",x),s(t("markdown.mermaidLoadFailed")),u(!1)}}),()=>{b.current&&clearTimeout(b.current),y.current&&clearTimeout(y.current)}),[]),K.useEffect(()=>{if(!e||!l)return;const T=window.mermaid;if(!T){s(t("markdown.mermaidNotLoaded")),u(!1);return}const x=e!==h.current;if(h.current=e,x&&(p(!0),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{p(!1)},500)),!X_(e)){u(!0),s("");return}return b.current&&clearTimeout(b.current),b.current=setTimeout(()=>He(exports,null,function*(){u(!0),s("");try{const w=G_(),{svg:I}=yield T.render(w,e.trim());a(I),s("");const L=document.getElementById(w);L&&L.remove()}catch(w){document.querySelectorAll('[id^="dmermaid-"]').forEach(L=>L.remove()),f?console.log("Mermaid 流式输出中,暂不显示错误"):(console.error("Mermaid 渲染错误:",w),s((w==null?void 0:w.message)||t("markdown.mermaidRenderFailed")))}finally{u(!1)}}),300),()=>{b.current&&clearTimeout(b.current)}},[e,l,f]),o?C.jsx("div",{style:{width:"100%",minHeight:"100px",padding:"20px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed #d9d9d9",borderRadius:"6px",color:"#666",backgroundColor:"#fafafa",marginTop:"10px",marginBottom:"10px"},children:t("markdown.chartLoading")}):i&&!f?C.jsxs("div",{style:{width:"100%",padding:"20px",border:"1px solid #ffccc7",borderRadius:"6px",color:"#cf1322",backgroundColor:"#fff2f0",marginTop:"10px",marginBottom:"10px"},children:[C.jsx("div",{style:{fontWeight:"bold",marginBottom:"8px"},children:t("markdown.mermaidRenderFailed")}),C.jsx("div",{style:{fontSize:"12px",color:"#666",wordBreak:"break-word",overflowWrap:"break-word",whiteSpace:"pre-wrap"},children:i})]}):i&&f?C.jsx("div",{style:{width:"100%",minHeight:"100px",padding:"20px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed #d9d9d9",borderRadius:"6px",color:"#666",backgroundColor:"#fafafa",marginTop:"10px",marginBottom:"10px"},children:t("markdown.chartLoading")}):C.jsx("div",{ref:r,style:{width:"100%",overflow:"auto",marginTop:"10px",marginBottom:"10px",padding:"10px",backgroundColor:"#fff",borderRadius:"6px",border:"1px solid #e8e8e8"},dangerouslySetInnerHTML:{__html:n}})},Zt=({content:e,waitingMessage:t=""})=>{const{t:r}=gt(),n=K.useMemo(()=>({remarkPlugins:[KE,nv,YS],rehypePlugins:[Dv,jS],components:{img:c=>{var f=c,{node:u}=f,l=ki(f,["node"]);return C.jsx(ve.Image,{style:{maxWidth:"100%",maxHeight:"600px"},src:l.src,alt:l.alt,preview:{zIndex:1100}})},code:p=>{var h=p,{node:u,inline:l,className:c}=h,f=ki(h,["node","inline","className"]);var w,I,L,P,M;if(l||!c&&!((w=u==null?void 0:u.properties)!=null&&w.className))return C.jsx("code",{style:{backgroundColor:"rgba(175, 184, 193, 0.2)",padding:"0.2em 0.4em",borderRadius:"3px",fontSize:"85%",fontFamily:'Consolas, Monaco, "Andale Mono", monospace'},children:f.children});const y=(L=/language-(\w+)/.exec(((I=u==null?void 0:u.properties)==null?void 0:I.className)||c||""))==null?void 0:L[0],T=((M=(P=u==null?void 0:u.position)==null?void 0:P.start)==null?void 0:M.line)===2?"language-file":null,x=y||T;if(x==="language-file"){const z=String(f.children).replace(/\n$/,""),B=o(z);return C.jsx(B_,{fileInfo:B})}if(x==="language-ant_table")try{const z=String(f==null?void 0:f.children).replace(/\n$/,""),B=JSON.parse(z),$=ac(B);return C.jsx(Zt,{content:$})}catch(z){return a(String(f==null?void 0:f.children))?(console.error("ant_table数据解析错误:",z),C.jsx(So,{text:r("markdown.tableLoadFailed")})):C.jsx(Gi,{text:r("markdown.tableLoading")})}if(x==="language-echarts")try{const z=Array.isArray(f.children)?f.children.join(""):f.children.toString();if(!a(z))return C.jsx(Gi,{});const B=JSON.parse(z);let $;try{return typeof(B==null?void 0:B.option)=="string"?$=JSON.parse(B==null?void 0:B.option):$=B==null?void 0:B.option,!$||Object.keys($).length===0?C.jsx(Gi,{}):C.jsx("div",{style:{minWidth:"300px"},children:C.jsx(j_,{options:$})})}catch(D){return console.error("图表配置解析错误:",D),C.jsx(So,{text:r("markdown.chartLoadFailed")})}}catch(z){return a(String(f.children))?(console.error("图表数据解析错误:",z),C.jsx(So,{text:r("markdown.chartLoadFailed")})):C.jsx(Gi,{})}if(x==="language-mermaid"){const z=String(f.children).replace(/\n$/,"");return C.jsx(K_,{code:z})}return C.jsx(Bv,{children:f.children})},p:u=>{var c,f,p;const{node:l}=u||{};if(((c=l==null?void 0:l.children[0])==null?void 0:c.tagName)==="img"){const h=l.children[0],b=Array.isArray(u==null?void 0:u.children)||typeof((f=u==null?void 0:u.children)==null?void 0:f.slice)=="function";return C.jsxs(C.Fragment,{children:[C.jsx(ve.Image,{style:{maxWidth:"100%",maxHeight:"600px"},src:h.properties.src,className:"max-w-full h-auto align-middle border-none rounded-lg shadow-md hover:shadow-lg transition-shadow duration-300 ease-in-out mt-2 mb-2",alt:h.properties.alt,preview:{zIndex:1100}}),b&&C.jsx("p",{children:(p=u==null?void 0:u.children)==null?void 0:p.slice(1)})]})}return C.jsx("p",{children:u==null?void 0:u.children})},a:({children:u,href:l})=>C.jsx("a",{href:l,target:"_blank",children:u})}}),[r]),a=u=>{try{const l=u==null?void 0:u.trim()[0],c=u==null?void 0:u.trim()[(u==null?void 0:u.trim().length)-1];return l==="{"&&c==="}"||l==="["&&c==="]"}catch(l){return!1}},i=u=>{const l=r("markdown.deepThinking");return u==null?void 0:u.replace(/<think>([\s\S]*?)<\/think>/g,`<details open><summary>${l}</summary><pre class="think">$1</pre></details>
|
|
1195
1195
|
|
|
1196
1196
|
`)},s=u=>{if(!u)return`<span><span class="prompt-message">${t}</span><span class="prompt-loading-cursor">...</span></span>`;const l=`${u==null?void 0:u.replace(new RegExp("\\\\\\[.*?\\\\\\]","gims"),c=>c.split(/[\r\n]/g)[0].trim()==="\\["?"$$"+c.slice(2,-2)+"$$":"$"+c.slice(2,-2)+"$").replace(new RegExp("\\\\\\(.*?\\\\\\)","gims"),c=>"$"+c.slice(2,-2)+"$")}`;return i(l)},o=u=>{const l=u.split(`
|
|
1197
1197
|
`),c={name:"",size:"",type:"unknown"};return l.forEach(f=>{const[p,h]=f.split(":").map(b=>b.trim());p&&h&&(p.toLowerCase()==="名称"&&(c.name=h),p.toLowerCase()==="大小"&&(c.size=h),p.toLowerCase()==="类型"&&(c.type=h))}),c};return C.jsx(VS,{children:C.jsx(B9,it(re({},n),{children:`${s(e)}`}))})},Q_=ue.div`
|
package/dist/appflow-chat.esm.js
CHANGED
|
@@ -35405,8 +35405,7 @@ const gI = () => `mermaid-${Date.now()}-${pI++}`, bI = (e) => {
|
|
|
35405
35405
|
{
|
|
35406
35406
|
style: {
|
|
35407
35407
|
maxWidth: "100%",
|
|
35408
|
-
maxHeight: "
|
|
35409
|
-
objectFit: "contain"
|
|
35408
|
+
maxHeight: "600px"
|
|
35410
35409
|
},
|
|
35411
35410
|
src: l.src,
|
|
35412
35411
|
alt: l.alt,
|
|
@@ -35468,9 +35467,8 @@ const gI = () => `mermaid-${Date.now()}-${pI++}`, bI = (e) => {
|
|
|
35468
35467
|
Xa,
|
|
35469
35468
|
{
|
|
35470
35469
|
style: {
|
|
35471
|
-
maxWidth: "
|
|
35472
|
-
maxHeight: "
|
|
35473
|
-
objectFit: "contain"
|
|
35470
|
+
maxWidth: "100%",
|
|
35471
|
+
maxHeight: "600px"
|
|
35474
35472
|
},
|
|
35475
35473
|
src: h.properties.src,
|
|
35476
35474
|
className: "max-w-full h-auto align-middle border-none rounded-lg shadow-md hover:shadow-lg transition-shadow duration-300 ease-in-out mt-2 mb-2",
|
package/package.json
CHANGED
package/src/markdown/index.tsx
CHANGED
|
@@ -46,8 +46,7 @@ export const MarkdownView: React.FC<MarkdownViewProps> = ({
|
|
|
46
46
|
<Image
|
|
47
47
|
style={{
|
|
48
48
|
maxWidth: '100%',
|
|
49
|
-
maxHeight: '
|
|
50
|
-
objectFit: 'contain',
|
|
49
|
+
maxHeight: '600px',
|
|
51
50
|
}}
|
|
52
51
|
src={props.src}
|
|
53
52
|
alt={props.alt}
|
|
@@ -176,9 +175,8 @@ export const MarkdownView: React.FC<MarkdownViewProps> = ({
|
|
|
176
175
|
<>
|
|
177
176
|
<Image
|
|
178
177
|
style={{
|
|
179
|
-
maxWidth: '
|
|
180
|
-
maxHeight: '
|
|
181
|
-
objectFit: 'contain',
|
|
178
|
+
maxWidth: '100%',
|
|
179
|
+
maxHeight: '600px',
|
|
182
180
|
}}
|
|
183
181
|
src={image.properties.src}
|
|
184
182
|
className="max-w-full h-auto align-middle border-none rounded-lg shadow-md hover:shadow-lg transition-shadow duration-300 ease-in-out mt-2 mb-2"
|