@echoease/streamdown-edge 1.0.1 → 1.1.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/dist/chunk-6UUYWCQP.cjs +2 -0
- package/dist/chunk-RBJCVADP.js +2 -0
- package/dist/code-block-6YFGNRWC.cjs +2 -0
- package/dist/code-block-MDXI4SPB.js +2 -0
- package/dist/index.cjs +10 -10
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +10 -10
- package/dist/math-renderer-NNGB3FFG.cjs +2 -0
- package/dist/math-renderer-NX6TIXIB.js +2 -0
- package/dist/math-renderer-VMU3RDDI.cjs +2 -0
- package/dist/math-renderer-WU7AB3QB.js +2 -0
- package/package.json +4 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';var clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),react=require('react');var m=(...o)=>tailwindMerge.twMerge(clsx.clsx(o)),x=(o,t,r)=>{let n=typeof t=="string"?new Blob([t],{type:r}):t,c=URL.createObjectURL(n),e=document.createElement("a");e.href=c,e.download=o,document.body.appendChild(e),e.click(),document.body.removeChild(e),URL.revokeObjectURL(c);};var C=react.createContext({code:""}),y=()=>react.useContext(C);exports.a=m;exports.b=x;exports.c=C;exports.d=y;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {createContext,useContext}from'react';var m=(...o)=>twMerge(clsx(o)),x=(o,t,r)=>{let n=typeof t=="string"?new Blob([t],{type:r}):t,c=URL.createObjectURL(n),e=document.createElement("a");e.href=c,e.download=o,document.body.appendChild(e),e.click(),document.body.removeChild(e),URL.revokeObjectURL(c);};var C=createContext({code:""}),y=()=>useContext(C);export{m as a,x as b,C as c,y as d};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';var chunk6UUYWCQP_cjs=require('./chunk-6UUYWCQP.cjs'),prismReactRenderer=require('prism-react-renderer'),jsxRuntime=require('react/jsx-runtime');var l=({className:o,language:e,style:n,...a})=>jsxRuntime.jsx("div",{className:chunk6UUYWCQP_cjs.a("my-4 w-full overflow-hidden rounded-xl border border-border",o),"data-language":e,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...n},...a});var i=({language:o,children:e})=>jsxRuntime.jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-language":o,"data-streamdown":"code-block-header",children:[jsxRuntime.jsx("span",{className:"ml-1 font-mono lowercase",children:o}),jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:e})]});var P=chunk6UUYWCQP_cjs.a("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),z=({code:o,language:e,className:n,children:a,...m})=>{let p=e.toLowerCase()||"text";return jsxRuntime.jsx(chunk6UUYWCQP_cjs.c.Provider,{value:{code:o},children:jsxRuntime.jsxs(l,{language:e,children:[jsxRuntime.jsx(i,{language:e,children:a}),jsxRuntime.jsx(prismReactRenderer.Highlight,{theme:prismReactRenderer.themes.github,code:o,language:p,children:({tokens:f,getLineProps:C,getTokenProps:b,style:g})=>jsxRuntime.jsx("pre",{className:chunk6UUYWCQP_cjs.a(n,"p-4 text-sm"),"data-language":e,"data-streamdown":"code-block-body",style:g,...m,children:jsxRuntime.jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:f.map((d,k)=>jsxRuntime.jsx("span",{className:P,...C({line:d}),children:d.map((u,B)=>jsxRuntime.jsx("span",{...b({token:u})},B))},k))})})})]})})};exports.CodeBlock=z;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {a,c}from'./chunk-RBJCVADP.js';import {Highlight,themes}from'prism-react-renderer';import {jsx,jsxs}from'react/jsx-runtime';var l=({className:o,language:e,style:n,...a$1})=>jsx("div",{className:a("my-4 w-full overflow-hidden rounded-xl border border-border",o),"data-language":e,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...n},...a$1});var i=({language:o,children:e})=>jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-language":o,"data-streamdown":"code-block-header",children:[jsx("span",{className:"ml-1 font-mono lowercase",children:o}),jsx("div",{className:"flex items-center gap-2",children:e})]});var P=a("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),z=({code:o,language:e,className:n,children:a$1,...m})=>{let p=e.toLowerCase()||"text";return jsx(c.Provider,{value:{code:o},children:jsxs(l,{language:e,children:[jsx(i,{language:e,children:a$1}),jsx(Highlight,{theme:themes.github,code:o,language:p,children:({tokens:f,getLineProps:C,getTokenProps:b,style:g})=>jsx("pre",{className:a(n,"p-4 text-sm"),"data-language":e,"data-streamdown":"code-block-body",style:g,...m,children:jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:f.map((d,k)=>jsx("span",{className:P,...C({line:d}),children:d.map((u,B)=>jsx("span",{...b({token:u})},B))},k))})})})]})})};export{z as CodeBlock};
|
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
'use strict';var chunkYHGJ7S36_cjs=require('./chunk-YHGJ7S36.cjs'),react=require('react'),
|
|
3
|
-
`)&&(
|
|
4
|
-
`)},
|
|
5
|
-
`||i==="\r"){
|
|
6
|
-
`?d.push("\\n"):i==="\r"?d.push("\\r"):d.push(i);return d.join("")},
|
|
7
|
-
`)},X=
|
|
8
|
-
`)};var pe=({children:e,className:t,onCopy:s,onError:o,timeout:a=2e3})=>{let[n,c]=react.useState(false),[r,l]=react.useState(false),d=react.useRef(null),i=react.useRef(0),{isAnimating:m}=react.useContext(v),u=async f=>{var y,k;if(typeof window=="undefined"||!((y=navigator==null?void 0:navigator.clipboard)!=null&&y.write)){o==null||o(new Error("Clipboard API not available"));return}try{let x=(k=d.current)==null?void 0:k.closest('[data-streamdown="table-wrapper"]'),P=x==null?void 0:x.querySelector("table");if(!P){o==null||o(new Error("Table not found"));return}let T=E(P),R=f==="csv"?I(T):le(T),$=new ClipboardItem({"text/plain":new Blob([R],{type:"text/plain"}),"text/html":new Blob([P.outerHTML],{type:"text/html"})});await navigator.clipboard.write([$]),l(!0),c(!1),s==null||s(f),i.current=window.setTimeout(()=>l(!1),a);}catch(x){o==null||o(x);}};react.useEffect(()=>{let f=y=>{d.current&&!d.current.contains(y.target)&&c(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f),window.clearTimeout(i.current);}},[]);let b=r?lucideReact.CheckIcon:lucideReact.CopyIcon;return jsxRuntime.jsxs("div",{className:"relative",ref:d,children:[jsxRuntime.jsx("button",{className:chunkYHGJ7S36_cjs.a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>c(!n),title:"Copy table",type:"button",children:e!=null?e:jsxRuntime.jsx(b,{size:14})}),n?jsxRuntime.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]}):null]})};var fe=({children:e,className:t,onDownload:s,onError:o})=>{let[a,n]=react.useState(false),c=react.useRef(null),{isAnimating:r}=react.useContext(v),l=d=>{var i;try{let m=(i=c.current)==null?void 0:i.closest('[data-streamdown="table-wrapper"]'),u=m==null?void 0:m.querySelector("table");if(!u){o==null||o(new Error("Table not found"));return}let b=E(u),f=d==="csv"?I(b):ie(b);chunkYHGJ7S36_cjs.b(`table.${d==="csv"?"csv":"md"}`,f,d==="csv"?"text/csv":"text/markdown"),n(!1),s==null||s(d);}catch(m){o==null||o(m);}};return react.useEffect(()=>{let d=i=>{c.current&&!c.current.contains(i.target)&&n(false);};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d);}},[]),jsxRuntime.jsxs("div",{className:"relative",ref:c,children:[jsxRuntime.jsx("button",{className:chunkYHGJ7S36_cjs.a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:r,onClick:()=>n(!a),title:"Download table",type:"button",children:e!=null?e:jsxRuntime.jsx(lucideReact.DownloadIcon,{size:14})}),a?jsxRuntime.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("csv"),title:"Download table as CSV",type:"button",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]}):null]})};var be=({children:e,className:t,showControls:s,...o})=>jsxRuntime.jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[s?jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsxRuntime.jsx(pe,{}),jsxRuntime.jsx(fe,{})]}):null,jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsx("table",{className:chunkYHGJ7S36_cjs.a("w-full border-collapse border border-border",t),"data-streamdown":"table",...o,children:e})})]});var Tt=react.lazy(()=>import('./code-block-RZYTVPVD.cjs').then(e=>({default:e.CodeBlock}))),Ct=/language-([^\s]+)/;function O(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return true;if(!(e!=null&&e.position&&(t!=null&&t.position)))return false;let s=e.position.start,o=t.position.start,a=e.position.end,n=t.position.end;return (s==null?void 0:s.line)===(o==null?void 0:o.line)&&(s==null?void 0:s.column)===(o==null?void 0:o.column)&&(a==null?void 0:a.line)===(n==null?void 0:n.line)&&(a==null?void 0:a.column)===(n==null?void 0:n.column)}function w(e,t){return e.className===t.className&&O(e.node,t.node)}var ye=(e,t)=>typeof e=="boolean"?e:e[t]!==false,W=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("ol",{className:chunkYHGJ7S36_cjs.a("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...o,children:e}),(e,t)=>w(e,t));W.displayName="MarkdownOl";var we=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("li",{className:chunkYHGJ7S36_cjs.a("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...o,children:e}),(e,t)=>e.className===t.className&&O(e.node,t.node));we.displayName="MarkdownLi";var ke=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("ul",{className:chunkYHGJ7S36_cjs.a("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...o,children:e}),(e,t)=>w(e,t));ke.displayName="MarkdownUl";var xe=react.memo(({className:e,node:t,...s})=>jsxRuntime.jsx("hr",{className:chunkYHGJ7S36_cjs.a("my-6 border-border",e),"data-streamdown":"horizontal-rule",...s}),(e,t)=>w(e,t));xe.displayName="MarkdownHr";var ve=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("span",{className:chunkYHGJ7S36_cjs.a("font-semibold",t),"data-streamdown":"strong",...o,children:e}),(e,t)=>w(e,t));ve.displayName="MarkdownStrong";var Te=react.memo(({children:e,className:t,href:s,node:o,...a})=>{let n=s==="streamdown:incomplete-link";return jsxRuntime.jsx("a",{className:chunkYHGJ7S36_cjs.a("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":n,"data-streamdown":"link",href:s,rel:"noreferrer",target:"_blank",...a,children:e})},(e,t)=>w(e,t)&&e.href===t.href);Te.displayName="MarkdownA";var Ce=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("h1",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...o,children:e}),(e,t)=>w(e,t));Ce.displayName="MarkdownH1";var Pe=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("h2",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...o,children:e}),(e,t)=>w(e,t));Pe.displayName="MarkdownH2";var Ne=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("h3",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...o,children:e}),(e,t)=>w(e,t));Ne.displayName="MarkdownH3";var Me=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("h4",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...o,children:e}),(e,t)=>w(e,t));Me.displayName="MarkdownH4";var Se=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("h5",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...o,children:e}),(e,t)=>w(e,t));Se.displayName="MarkdownH5";var De=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("h6",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...o,children:e}),(e,t)=>w(e,t));De.displayName="MarkdownH6";var Re=react.memo(({children:e,className:t,node:s,...o})=>{let{controls:a}=react.useContext(v),n=ye(a,"table");return jsxRuntime.jsx(be,{className:t,"data-streamdown":"table-wrapper",showControls:n,...o,children:e})},(e,t)=>w(e,t));Re.displayName="MarkdownTable";var je=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("thead",{className:chunkYHGJ7S36_cjs.a("bg-muted/80",t),"data-streamdown":"table-header",...o,children:e}),(e,t)=>w(e,t));je.displayName="MarkdownThead";var Ae=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("tbody",{className:chunkYHGJ7S36_cjs.a("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...o,children:e}),(e,t)=>w(e,t));Ae.displayName="MarkdownTbody";var Ee=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("tr",{className:chunkYHGJ7S36_cjs.a("border-border border-b",t),"data-streamdown":"table-row",...o,children:e}),(e,t)=>w(e,t));Ee.displayName="MarkdownTr";var Ie=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("th",{className:chunkYHGJ7S36_cjs.a("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...o,children:e}),(e,t)=>w(e,t));Ie.displayName="MarkdownTh";var Le=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("td",{className:chunkYHGJ7S36_cjs.a("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...o,children:e}),(e,t)=>w(e,t));Le.displayName="MarkdownTd";var He=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("blockquote",{className:chunkYHGJ7S36_cjs.a("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...o,children:e}),(e,t)=>w(e,t));He.displayName="MarkdownBlockquote";var Be=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("sup",{className:chunkYHGJ7S36_cjs.a("text-sm",t),"data-streamdown":"superscript",...o,children:e}),(e,t)=>w(e,t));Be.displayName="MarkdownSup";var Oe=react.memo(({children:e,className:t,node:s,...o})=>jsxRuntime.jsx("sub",{className:chunkYHGJ7S36_cjs.a("text-sm",t),"data-streamdown":"subscript",...o,children:e}),(e,t)=>w(e,t));Oe.displayName="MarkdownSub";var qe=react.memo(({children:e,className:t,node:s,...o})=>{if("data-footnotes"in o){let n=l=>{var u,b;if(!react.isValidElement(l))return false;let d=Array.isArray(l.props.children)?l.props.children:[l.props.children],i=false,m=false;for(let f of d)if(f){if(typeof f=="string")f.trim()!==""&&(i=true);else if(react.isValidElement(f))if(((u=f.props)==null?void 0:u["data-footnote-backref"])!==void 0)m=true;else {let y=Array.isArray(f.props.children)?f.props.children:[f.props.children];for(let k of y){if(typeof k=="string"&&k.trim()!==""){i=true;break}if(react.isValidElement(k)&&((b=k.props)==null?void 0:b["data-footnote-backref"])===void 0){i=true;break}}}}return m&&!i},c=Array.isArray(e)?e.map(l=>{if(!react.isValidElement(l))return l;if(l.type===W){let i=(Array.isArray(l.props.children)?l.props.children:[l.props.children]).filter(m=>!n(m));return i.length===0?null:{...l,props:{...l.props,children:i}}}return l}):e;return (Array.isArray(c)?c.some(l=>l!==null):c!==null)?jsxRuntime.jsx("section",{className:t,...o,children:c}):null}return jsxRuntime.jsx("section",{className:t,...o,children:e})},(e,t)=>w(e,t));qe.displayName="MarkdownSection";var Pt=({node:e,className:t,children:s,...o})=>{var i,m,u;let a=((i=e==null?void 0:e.position)==null?void 0:i.start.line)===((m=e==null?void 0:e.position)==null?void 0:m.end.line),{controls:n}=react.useContext(v);if(a)return jsxRuntime.jsx("code",{className:chunkYHGJ7S36_cjs.a("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...o,children:s});let c=t==null?void 0:t.match(Ct),r=(u=c==null?void 0:c.at(1))!=null?u:"",l="";react.isValidElement(s)&&s.props&&typeof s.props=="object"&&"children"in s.props&&typeof s.props.children=="string"?l=s.props.children:typeof s=="string"&&(l=s);let d=ye(n,"code");return jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(re,{}),children:jsxRuntime.jsx(Tt,{className:chunkYHGJ7S36_cjs.a("overflow-x-auto border-border border-t",t),code:l,language:r,children:d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ne,{code:l,language:r}),jsxRuntime.jsx(te,{})]}):null})})},$e=react.memo(Pt,(e,t)=>e.className===t.className&&O(e.node,t.node));$e.displayName="MarkdownCode";var Je=react.memo(ae,(e,t)=>e.className===t.className&&O(e.node,t.node));Je.displayName="MarkdownImg";var ze=react.memo(({children:e,className:t,node:s,...o})=>{var c;let n=(Array.isArray(e)?e:[e]).filter(r=>r!=null&&r!=="");return n.length===1&&react.isValidElement(n[0])&&((c=n[0].props.node)==null?void 0:c.tagName)==="img"?jsxRuntime.jsx(jsxRuntime.Fragment,{children:e}):jsxRuntime.jsx("p",{className:t,...o,children:e})},(e,t)=>w(e,t));ze.displayName="MarkdownParagraph";var Xe={ol:W,li:we,ul:ke,hr:xe,strong:ve,a:Te,h1:Ce,h2:Pe,h3:Ne,h4:Me,h5:Se,h6:De,table:Re,thead:je,tbody:Ae,tr:Ee,th:Ie,td:Le,blockquote:He,code:$e,img:Je,pre:({children:e})=>e,sup:Be,sub:Oe,p:ze,section:qe};var Ke=[],Ve={allowDangerousHtml:true},q=new WeakMap,K=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let s=this.keyCache.get(t);if(s)return s;let o=t.rehypePlugins,a=t.remarkPlugins,n=t.remarkRehypeOptions;if(!(o||a||n)){let m="default";return this.keyCache.set(t,m),m}let c=m=>{if(!m||m.length===0)return "";let u="";for(let b=0;b<m.length;b+=1){let f=m[b];if(b>0&&(u+=","),Array.isArray(f)){let[y,k]=f;if(typeof y=="function"){let x=q.get(y);x||(x=y.name,q.set(y,x)),u+=x;}else u+=String(y);u+=":",u+=JSON.stringify(k);}else if(typeof f=="function"){let y=q.get(f);y||(y=f.name,q.set(f,y)),u+=y;}else u+=String(f);}return u},r=c(o),l=c(a),d=n?JSON.stringify(n):"",i=`${l}::${r}::${d}`;return this.keyCache.set(t,i),i}get(t){let s=this.generateCacheKey(t),o=this.cache.get(s);return o&&(this.cache.delete(s),this.cache.set(s,o)),o}set(t,s){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let a=this.cache.keys().next().value;a&&this.cache.delete(a);}this.cache.set(o,s);}clear(){this.cache.clear();}},Fe=new K,V=e=>{let t=It(e),s=e.children||"";return Ht(t.runSync(t.parse(s),s),e)},It=e=>{let t=Fe.get(e);if(t)return t;let s=Lt(e);return Fe.set(e,s),s},Lt=e=>{let t=e.rehypePlugins||Ke,s=e.remarkPlugins||Ke,o=e.remarkRehypeOptions?{...Ve,...e.remarkRehypeOptions}:Ve;return unified.unified().use(jt__default.default).use(s).use(At__default.default,o).use(t)},Ht=(e,t)=>hastUtilToJsxRuntime.toJsxRuntime(e,{Fragment:jsxRuntime.Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsxRuntime.jsx,jsxs:jsxRuntime.jsxs,passKeys:true,passNode:true});var Ot=/\[\^[^\]\s]{1,200}\](?!:)/,qt=/\[\^[^\]\s]{1,200}\]:/,$t=/<\/(\w+)>/,Jt=/<(\w+)[\s>]/,F=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
|
|
9
|
-
`||e
|
|
10
|
-
`||e
|
|
11
|
-
exports.Block=Ye;exports.Streamdown=uo;exports.StreamdownContext=v;exports.defaultRehypePlugins=to;exports.defaultRemarkPlugins=oo;exports.parseMarkdownIntoBlocks=U;
|
|
2
|
+
'use strict';var chunkYHGJ7S36_cjs=require('./chunk-YHGJ7S36.cjs'),react=require('react'),Vt=require('rehype-sanitize'),_t=require('remark-cjk-friendly'),Ut=require('remark-cjk-friendly-gfm-strikethrough'),Gt=require('remark-gfm'),G=require('remark-math'),Yt=require('remend'),lucideReact=require('lucide-react'),jsxRuntime=require('react/jsx-runtime'),hastUtilToJsxRuntime=require('hast-util-to-jsx-runtime'),Dt=require('remark-parse'),jt=require('remark-rehype'),unified=require('unified'),marked=require('marked');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Vt__default=/*#__PURE__*/_interopDefault(Vt);var _t__default=/*#__PURE__*/_interopDefault(_t);var Ut__default=/*#__PURE__*/_interopDefault(Ut);var Gt__default=/*#__PURE__*/_interopDefault(Gt);var G__default=/*#__PURE__*/_interopDefault(G);var Yt__default=/*#__PURE__*/_interopDefault(Yt);var Dt__default=/*#__PURE__*/_interopDefault(Dt);var jt__default=/*#__PURE__*/_interopDefault(jt);var ee=({onCopy:t,onError:e,timeout:o=2e3,children:s,className:l,code:n,...c})=>{let[r,a]=react.useState(false),d=react.useRef(0),{code:i}=chunkYHGJ7S36_cjs.d(),{isAnimating:m}=react.useContext(v),u=n!=null?n:i,b=async()=>{var y;if(typeof window=="undefined"||!((y=navigator==null?void 0:navigator.clipboard)!=null&&y.writeText)){e==null||e(new Error("Clipboard API not available"));return}try{r||(await navigator.clipboard.writeText(u),a(!0),t==null||t(),d.current=window.setTimeout(()=>a(!1),o));}catch(k){e==null||e(k);}};react.useEffect(()=>()=>{window.clearTimeout(d.current);},[]);let f=r?lucideReact.CheckIcon:lucideReact.CopyIcon;return jsxRuntime.jsx("button",{className:chunkYHGJ7S36_cjs.a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",l),"data-streamdown":"code-block-copy-button",disabled:m,onClick:b,title:"Copy Code",type:"button",...c,children:s!=null?s:jsxRuntime.jsx(f,{size:14})})};var te={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",\u6587\u8A00:"wy"},se=({onDownload:t,onError:e,language:o,children:s,className:l,code:n,...c})=>{let{code:r}=chunkYHGJ7S36_cjs.d(),{isAnimating:a}=react.useContext(v),d=n!=null?n:r,m=`file.${o&&o in te?te[o]:"txt"}`,u="text/plain",b=()=>{try{chunkYHGJ7S36_cjs.b(m,d,u),t==null||t();}catch(f){e==null||e(f);}};return jsxRuntime.jsx("button",{className:chunkYHGJ7S36_cjs.a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",l),"data-streamdown":"code-block-download-button",disabled:a,onClick:b,title:"Download file",type:"button",...c,children:s!=null?s:jsxRuntime.jsx(lucideReact.DownloadIcon,{size:14})})};var ne=()=>jsxRuntime.jsxs("div",{className:"w-full divide-y divide-border overflow-hidden rounded-xl border border-border",children:[jsxRuntime.jsx("div",{className:"h-[46px] w-full bg-muted/80"}),jsxRuntime.jsx("div",{className:"flex w-full items-center justify-center p-4",children:jsxRuntime.jsx(lucideReact.Loader2Icon,{className:"size-4 animate-spin"})})]});var dt=/\.[^/.]+$/,re=({node:t,className:e,src:o,alt:s,...l})=>{let n=async()=>{if(o)try{let r=await(await fetch(o)).blob(),d=new URL(o,window.location.origin).pathname.split("/").pop()||"",i=d.split(".").pop(),m=d.includes(".")&&i!==void 0&&i.length<=4,u="";if(m)u=d;else {let b=r.type,f="png";b.includes("jpeg")||b.includes("jpg")?f="jpg":b.includes("png")?f="png":b.includes("svg")?f="svg":b.includes("gif")?f="gif":b.includes("webp")&&(f="webp"),u=`${(s||d||"image").replace(dt,"")}.${f}`;}chunkYHGJ7S36_cjs.b(u,r,r.type);}catch(c){console.error("Failed to download image:",c);}};return o?jsxRuntime.jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[jsxRuntime.jsx("img",{alt:s,className:chunkYHGJ7S36_cjs.a("max-w-full rounded-lg",e),"data-streamdown":"image",src:o,...l}),jsxRuntime.jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),jsxRuntime.jsx("button",{className:chunkYHGJ7S36_cjs.a("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 group-hover:opacity-100"),onClick:n,title:"Download image",type:"button",children:jsxRuntime.jsx(lucideReact.DownloadIcon,{size:14})})]}):null};var E=t=>{var n,c;let e=[],o=[],s=t.querySelectorAll("thead th");for(let r of s)e.push(((n=r.textContent)==null?void 0:n.trim())||"");let l=t.querySelectorAll("tbody tr");for(let r of l){let a=[],d=r.querySelectorAll("td");for(let i of d)a.push(((c=i.textContent)==null?void 0:c.trim())||"");o.push(a);}return {headers:e,rows:o}},I=t=>{let{headers:e,rows:o}=t,s=r=>{let a=false,d=false;for(let i of r){if(i==='"'){a=true,d=true;break}(i===","||i===`
|
|
3
|
+
`)&&(a=true);}return a?d?`"${r.replace(/"/g,'""')}"`:`"${r}"`:r},l=e.length>0?o.length+1:o.length,n=new Array(l),c=0;e.length>0&&(n[c]=e.map(s).join(","),c+=1);for(let r of o)n[c]=r.map(s).join(","),c+=1;return n.join(`
|
|
4
|
+
`)},ae=t=>{let{headers:e,rows:o}=t,s=r=>{let a=false;for(let i of r)if(i===" "||i===`
|
|
5
|
+
`||i==="\r"){a=true;break}if(!a)return r;let d=[];for(let i of r)i===" "?d.push("\\t"):i===`
|
|
6
|
+
`?d.push("\\n"):i==="\r"?d.push("\\r"):d.push(i);return d.join("")},l=e.length>0?o.length+1:o.length,n=new Array(l),c=0;e.length>0&&(n[c]=e.map(s).join(" "),c+=1);for(let r of o)n[c]=r.map(s).join(" "),c+=1;return n.join(`
|
|
7
|
+
`)},X=t=>{let e=false;for(let s of t)if(s==="\\"||s==="|"){e=true;break}if(!e)return t;let o=[];for(let s of t)s==="\\"?o.push("\\\\"):s==="|"?o.push("\\|"):o.push(s);return o.join("")},le=t=>{let{headers:e,rows:o}=t;if(e.length===0)return "";let s=new Array(o.length+2),l=0,n=e.map(r=>X(r));s[l]=`| ${n.join(" | ")} |`,l+=1;let c=new Array(e.length);for(let r=0;r<e.length;r+=1)c[r]="---";s[l]=`| ${c.join(" | ")} |`,l+=1;for(let r of o)if(r.length<e.length){let a=new Array(e.length);for(let d=0;d<e.length;d+=1)a[d]=d<r.length?X(r[d]):"";s[l]=`| ${a.join(" | ")} |`,l+=1;}else {let a=r.map(d=>X(d));s[l]=`| ${a.join(" | ")} |`,l+=1;}return s.join(`
|
|
8
|
+
`)};var me=({children:t,className:e,onCopy:o,onError:s,timeout:l=2e3})=>{let[n,c]=react.useState(false),[r,a]=react.useState(false),d=react.useRef(null),i=react.useRef(0),{isAnimating:m}=react.useContext(v),u=async f=>{var y,k;if(typeof window=="undefined"||!((y=navigator==null?void 0:navigator.clipboard)!=null&&y.write)){s==null||s(new Error("Clipboard API not available"));return}try{let x=(k=d.current)==null?void 0:k.closest('[data-streamdown="table-wrapper"]'),C=x==null?void 0:x.querySelector("table");if(!C){s==null||s(new Error("Table not found"));return}let T=E(C),D=f==="csv"?I(T):ae(T),$=new ClipboardItem({"text/plain":new Blob([D],{type:"text/plain"}),"text/html":new Blob([C.outerHTML],{type:"text/html"})});await navigator.clipboard.write([$]),a(!0),c(!1),o==null||o(f),i.current=window.setTimeout(()=>a(!1),l);}catch(x){s==null||s(x);}};react.useEffect(()=>{let f=y=>{d.current&&!d.current.contains(y.target)&&c(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f),window.clearTimeout(i.current);}},[]);let b=r?lucideReact.CheckIcon:lucideReact.CopyIcon;return jsxRuntime.jsxs("div",{className:"relative",ref:d,children:[jsxRuntime.jsx("button",{className:chunkYHGJ7S36_cjs.a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",e),disabled:m,onClick:()=>c(!n),title:"Copy table",type:"button",children:t!=null?t:jsxRuntime.jsx(b,{size:14})}),n?jsxRuntime.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]}):null]})};var ue=({children:t,className:e,onDownload:o,onError:s})=>{let[l,n]=react.useState(false),c=react.useRef(null),{isAnimating:r}=react.useContext(v),a=d=>{var i;try{let m=(i=c.current)==null?void 0:i.closest('[data-streamdown="table-wrapper"]'),u=m==null?void 0:m.querySelector("table");if(!u){s==null||s(new Error("Table not found"));return}let b=E(u),f=d==="csv"?I(b):le(b);chunkYHGJ7S36_cjs.b(`table.${d==="csv"?"csv":"md"}`,f,d==="csv"?"text/csv":"text/markdown"),n(!1),o==null||o(d);}catch(m){s==null||s(m);}};return react.useEffect(()=>{let d=i=>{c.current&&!c.current.contains(i.target)&&n(false);};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d);}},[]),jsxRuntime.jsxs("div",{className:"relative",ref:c,children:[jsxRuntime.jsx("button",{className:chunkYHGJ7S36_cjs.a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",e),disabled:r,onClick:()=>n(!l),title:"Download table",type:"button",children:t!=null?t:jsxRuntime.jsx(lucideReact.DownloadIcon,{size:14})}),l?jsxRuntime.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>a("csv"),title:"Download table as CSV",type:"button",children:"CSV"}),jsxRuntime.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>a("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]}):null]})};var ge=({children:t,className:e,showControls:o,...s})=>jsxRuntime.jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[o?jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsxRuntime.jsx(me,{}),jsxRuntime.jsx(ue,{})]}):null,jsxRuntime.jsx("div",{className:"overflow-x-auto",children:jsxRuntime.jsx("table",{className:chunkYHGJ7S36_cjs.a("w-full border-collapse border border-border",e),"data-streamdown":"table",...s,children:t})})]});var vt=react.lazy(()=>import('./code-block-RZYTVPVD.cjs').then(t=>({default:t.CodeBlock})));react.lazy(()=>import('./math-renderer-NNGB3FFG.cjs').then(t=>({default:t.MathRenderer})));var Tt=/language-([^\s]+)/;function O(t,e){if(!(t!=null&&t.position||e!=null&&e.position))return true;if(!(t!=null&&t.position&&(e!=null&&e.position)))return false;let o=t.position.start,s=e.position.start,l=t.position.end,n=e.position.end;return (o==null?void 0:o.line)===(s==null?void 0:s.line)&&(o==null?void 0:o.column)===(s==null?void 0:s.column)&&(l==null?void 0:l.line)===(n==null?void 0:n.line)&&(l==null?void 0:l.column)===(n==null?void 0:n.column)}function w(t,e){return t.className===e.className&&O(t.node,e.node)}var ye=(t,e)=>typeof t=="boolean"?t:t[e]!==false,W=react.memo(({children:t,className:e,node:o,...s})=>jsxRuntime.jsx("ol",{className:chunkYHGJ7S36_cjs.a("list-inside list-decimal whitespace-normal [li_&]:pl-6",e),"data-streamdown":"ordered-list",...s,children:t}),(t,e)=>w(t,e));W.displayName="MarkdownOl";var we=react.memo(({children:t,className:e,node:o,...s})=>jsxRuntime.jsx("li",{className:chunkYHGJ7S36_cjs.a("py-1 [&>p]:inline",e),"data-streamdown":"list-item",...s,children:t}),(t,e)=>t.className===e.className&&O(t.node,e.node));we.displayName="MarkdownLi";var ke=react.memo(({children:t,className:e,node:o,...s})=>jsxRuntime.jsx("ul",{className:chunkYHGJ7S36_cjs.a("list-inside list-disc whitespace-normal [li_&]:pl-6",e),"data-streamdown":"unordered-list",...s,children:t}),(t,e)=>w(t,e));ke.displayName="MarkdownUl";var xe=react.memo(({className:t,node:e,...o})=>jsxRuntime.jsx("hr",{className:chunkYHGJ7S36_cjs.a("my-6 border-border",t),"data-streamdown":"horizontal-rule",...o}),(t,e)=>w(t,e));xe.displayName="MarkdownHr";var ve=react.memo(({children:t,className:e,node:o,...s})=>jsxRuntime.jsx("span",{className:chunkYHGJ7S36_cjs.a("font-semibold",e),"data-streamdown":"strong",...s,children:t}),(t,e)=>w(t,e));ve.displayName="MarkdownStrong";var Te=react.memo(({children:t,className:e,href:o,node:s,...l})=>{let n=o==="streamdown:incomplete-link";return jsxRuntime.jsx("a",{className:chunkYHGJ7S36_cjs.a("wrap-anywhere font-medium text-primary underline",e),"data-incomplete":n,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...l,children:t})},(t,e)=>w(t,e)&&t.href===e.href);Te.displayName="MarkdownA";var Pe=react.memo(({children:t,className:e,node:o,...s})=>jsxRuntime.jsx("h1",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-3xl",e),"data-streamdown":"heading-1",...s,children:t}),(t,e)=>w(t,e));Pe.displayName="MarkdownH1";var Ce=react.memo(({children:t,className:e,node:o,...s})=>jsxRuntime.jsx("h2",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-2xl",e),"data-streamdown":"heading-2",...s,children:t}),(t,e)=>w(t,e));Ce.displayName="MarkdownH2";var Ne=react.memo(({children:t,className:e,node:o,...s})=>jsxRuntime.jsx("h3",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-xl",e),"data-streamdown":"heading-3",...s,children:t}),(t,e)=>w(t,e));Ne.displayName="MarkdownH3";var Me=react.memo(({children:t,className:e,node:o,...s})=>jsxRuntime.jsx("h4",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-lg",e),"data-streamdown":"heading-4",...s,children:t}),(t,e)=>w(t,e));Me.displayName="MarkdownH4";var Se=react.memo(({children:t,className:e,node:o,...s})=>jsxRuntime.jsx("h5",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-base",e),"data-streamdown":"heading-5",...s,children:t}),(t,e)=>w(t,e));Se.displayName="MarkdownH5";var Re=react.memo(({children:t,className:e,node:o,...s})=>jsxRuntime.jsx("h6",{className:chunkYHGJ7S36_cjs.a("mt-6 mb-2 font-semibold text-sm",e),"data-streamdown":"heading-6",...s,children:t}),(t,e)=>w(t,e));Re.displayName="MarkdownH6";var De=react.memo(({children:t,className:e,node:o,...s})=>{let{controls:l}=react.useContext(v),n=ye(l,"table");return jsxRuntime.jsx(ge,{className:e,"data-streamdown":"table-wrapper",showControls:n,...s,children:t})},(t,e)=>w(t,e));De.displayName="MarkdownTable";var je=react.memo(({children:t,className:e,node:o,...s})=>jsxRuntime.jsx("thead",{className:chunkYHGJ7S36_cjs.a("bg-muted/80",e),"data-streamdown":"table-header",...s,children:t}),(t,e)=>w(t,e));je.displayName="MarkdownThead";var Ae=react.memo(({children:t,className:e,node:o,...s})=>jsxRuntime.jsx("tbody",{className:chunkYHGJ7S36_cjs.a("divide-y divide-border bg-muted/40",e),"data-streamdown":"table-body",...s,children:t}),(t,e)=>w(t,e));Ae.displayName="MarkdownTbody";var Ee=react.memo(({children:t,className:e,node:o,...s})=>jsxRuntime.jsx("tr",{className:chunkYHGJ7S36_cjs.a("border-border border-b",e),"data-streamdown":"table-row",...s,children:t}),(t,e)=>w(t,e));Ee.displayName="MarkdownTr";var Ie=react.memo(({children:t,className:e,node:o,...s})=>jsxRuntime.jsx("th",{className:chunkYHGJ7S36_cjs.a("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",e),"data-streamdown":"table-header-cell",...s,children:t}),(t,e)=>w(t,e));Ie.displayName="MarkdownTh";var Le=react.memo(({children:t,className:e,node:o,...s})=>jsxRuntime.jsx("td",{className:chunkYHGJ7S36_cjs.a("px-4 py-2 text-sm",e),"data-streamdown":"table-cell",...s,children:t}),(t,e)=>w(t,e));Le.displayName="MarkdownTd";var He=react.memo(({children:t,className:e,node:o,...s})=>jsxRuntime.jsx("blockquote",{className:chunkYHGJ7S36_cjs.a("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",e),"data-streamdown":"blockquote",...s,children:t}),(t,e)=>w(t,e));He.displayName="MarkdownBlockquote";var Be=react.memo(({children:t,className:e,node:o,...s})=>jsxRuntime.jsx("sup",{className:chunkYHGJ7S36_cjs.a("text-sm",e),"data-streamdown":"superscript",...s,children:t}),(t,e)=>w(t,e));Be.displayName="MarkdownSup";var Oe=react.memo(({children:t,className:e,node:o,...s})=>jsxRuntime.jsx("sub",{className:chunkYHGJ7S36_cjs.a("text-sm",e),"data-streamdown":"subscript",...s,children:t}),(t,e)=>w(t,e));Oe.displayName="MarkdownSub";var qe=react.memo(({children:t,className:e,node:o,...s})=>{if("data-footnotes"in s){let n=a=>{var u,b;if(!react.isValidElement(a))return false;let d=Array.isArray(a.props.children)?a.props.children:[a.props.children],i=false,m=false;for(let f of d)if(f){if(typeof f=="string")f.trim()!==""&&(i=true);else if(react.isValidElement(f))if(((u=f.props)==null?void 0:u["data-footnote-backref"])!==void 0)m=true;else {let y=Array.isArray(f.props.children)?f.props.children:[f.props.children];for(let k of y){if(typeof k=="string"&&k.trim()!==""){i=true;break}if(react.isValidElement(k)&&((b=k.props)==null?void 0:b["data-footnote-backref"])===void 0){i=true;break}}}}return m&&!i},c=Array.isArray(t)?t.map(a=>{if(!react.isValidElement(a))return a;if(a.type===W){let i=(Array.isArray(a.props.children)?a.props.children:[a.props.children]).filter(m=>!n(m));return i.length===0?null:{...a,props:{...a.props,children:i}}}return a}):t;return (Array.isArray(c)?c.some(a=>a!==null):c!==null)?jsxRuntime.jsx("section",{className:e,...s,children:c}):null}return jsxRuntime.jsx("section",{className:e,...s,children:t})},(t,e)=>w(t,e));qe.displayName="MarkdownSection";var Pt=({node:t,className:e,children:o,...s})=>{var i,m,u;let l=((i=t==null?void 0:t.position)==null?void 0:i.start.line)===((m=t==null?void 0:t.position)==null?void 0:m.end.line),{controls:n}=react.useContext(v);if(l)return jsxRuntime.jsx("code",{className:chunkYHGJ7S36_cjs.a("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",e),"data-streamdown":"inline-code",...s,children:o});let c=e==null?void 0:e.match(Tt),r=(u=c==null?void 0:c.at(1))!=null?u:"",a="";react.isValidElement(o)&&o.props&&typeof o.props=="object"&&"children"in o.props&&typeof o.props.children=="string"?a=o.props.children:typeof o=="string"&&(a=o);let d=ye(n,"code");return jsxRuntime.jsx(react.Suspense,{fallback:jsxRuntime.jsx(ne,{}),children:jsxRuntime.jsx(vt,{className:chunkYHGJ7S36_cjs.a("overflow-x-auto border-border border-t",e),code:a,language:r,children:d?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(se,{code:a,language:r}),jsxRuntime.jsx(ee,{})]}):null})})},$e=react.memo(Pt,(t,e)=>t.className===e.className&&O(t.node,e.node));$e.displayName="MarkdownCode";var Je=react.memo(re,(t,e)=>t.className===e.className&&O(t.node,e.node));Je.displayName="MarkdownImg";var ze=react.memo(({children:t,className:e,node:o,...s})=>{var c;let n=(Array.isArray(t)?t:[t]).filter(r=>r!=null&&r!=="");return n.length===1&&react.isValidElement(n[0])&&((c=n[0].props.node)==null?void 0:c.tagName)==="img"?jsxRuntime.jsx(jsxRuntime.Fragment,{children:t}):jsxRuntime.jsx("p",{className:e,...s,children:t})},(t,e)=>w(t,e));ze.displayName="MarkdownParagraph";var Xe={ol:W,li:we,ul:ke,hr:xe,strong:ve,a:Te,h1:Pe,h2:Ce,h3:Ne,h4:Me,h5:Se,h6:Re,table:De,thead:je,tbody:Ae,tr:Ee,th:Ie,td:Le,blockquote:He,code:$e,img:Je,pre:({children:t})=>t,sup:Be,sub:Oe,p:ze,section:qe};var Fe=[],Ke={allowDangerousHtml:true},q=new WeakMap,F=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(e){let o=this.keyCache.get(e);if(o)return o;let s=e.rehypePlugins,l=e.remarkPlugins,n=e.remarkRehypeOptions;if(!(s||l||n)){let m="default";return this.keyCache.set(e,m),m}let c=m=>{if(!m||m.length===0)return "";let u="";for(let b=0;b<m.length;b+=1){let f=m[b];if(b>0&&(u+=","),Array.isArray(f)){let[y,k]=f;if(typeof y=="function"){let x=q.get(y);x||(x=y.name,q.set(y,x)),u+=x;}else u+=String(y);u+=":",u+=JSON.stringify(k);}else if(typeof f=="function"){let y=q.get(f);y||(y=f.name,q.set(f,y)),u+=y;}else u+=String(f);}return u},r=c(s),a=c(l),d=n?JSON.stringify(n):"",i=`${a}::${r}::${d}`;return this.keyCache.set(e,i),i}get(e){let o=this.generateCacheKey(e),s=this.cache.get(o);return s&&(this.cache.delete(o),this.cache.set(o,s)),s}set(e,o){let s=this.generateCacheKey(e);if(this.cache.size>=this.maxSize){let l=this.cache.keys().next().value;l&&this.cache.delete(l);}this.cache.set(s,o);}clear(){this.cache.clear();}},Ve=new F,K=t=>{let e=Et(t),o=t.children||"";return Lt(e.runSync(e.parse(o),o),t)},Et=t=>{let e=Ve.get(t);if(e)return e;let o=It(t);return Ve.set(t,o),o},It=t=>{let e=t.rehypePlugins||Fe,o=t.remarkPlugins||Fe,s=t.remarkRehypeOptions?{...Ke,...t.remarkRehypeOptions}:Ke;return unified.unified().use(Dt__default.default).use(o).use(jt__default.default,s).use(e)},Lt=(t,e)=>hastUtilToJsxRuntime.toJsxRuntime(t,{Fragment:jsxRuntime.Fragment,components:e.components,ignoreInvalidStyle:true,jsx:jsxRuntime.jsx,jsxs:jsxRuntime.jsxs,passKeys:true,passNode:true});var Bt=/\[\^[^\]\s]{1,200}\](?!:)/,Ot=/\[\^[^\]\s]{1,200}\]:/,qt=/<\/(\w+)>/,$t=/<(\w+)[\s>]/,V=t=>{let e=0;for(;e<t.length&&(t[e]===" "||t[e]===" "||t[e]===`
|
|
9
|
+
`||t[e]==="\r");)e+=1;return e+1<t.length&&t[e]==="$"&&t[e+1]==="$"},Jt=t=>{let e=t.length-1;for(;e>=0&&(t[e]===" "||t[e]===" "||t[e]===`
|
|
10
|
+
`||t[e]==="\r");)e-=1;return e>=1&&t[e]==="$"&&t[e-1]==="$"},_=t=>{let e=0;for(let o=0;o<t.length-1;o+=1)t[o]==="$"&&t[o+1]==="$"&&(e+=1,o+=1);return e},U=t=>{let e=Bt.test(t),o=Ot.test(t);if(e||o)return [t];let s=marked.Lexer.lex(t,{gfm:true}),l=[],n=[];for(let c of s){let r=c.raw,a=l.length;if(n.length>0){if(l[a-1]+=r,c.type==="html"){let i=r.match(qt);if(i){let m=i[1];n.at(-1)===m&&n.pop();}}continue}if(c.type==="html"&&c.block){let i=r.match($t);if(i){let m=i[1];r.includes(`</${m}>`)||n.push(m);}}if(r.trim()==="$$"&&a>0){let i=l[a-1],m=V(i),u=_(i);if(m&&u%2===1){l[a-1]=i+r;continue}}if(a>0&&Jt(r)){let i=l[a-1],m=V(i),u=_(i),b=_(r);if(m&&u%2===1&&!V(r)&&b===1){l[a-1]=i+r;continue}}l.push(r);}return l};var _e={dependencies:{katex:"^0.16.22"}};var Qt=/[^$]\$[^$]/,Zt=/^\$[^$]/,eo=/[^$]\$$/,to={sanitize:[Vt__default.default,{}]},Ls=async()=>{let[{harden:t},{default:e},{default:o}]=await Promise.all([import('rehype-harden'),import('rehype-katex'),import('rehype-raw')]);return {raw:[o,{}],harden:[t,{}],katex:[e,{output:"mathml"}]}},oo={gfm:[Gt__default.default,{}],math:[G__default.default,{singleDollarTextMath:false}],cjkFriendly:[_t__default.default,{}],cjkFriendlyGfmStrikethrough:[Ut__default.default,{}]},so=Object.values(to),no=Object.values(oo),ro={block:" \u258B",circle:" \u25CF"},ao={controls:true,isAnimating:false,mode:"streaming"},v=react.createContext(ao),Ye=react.memo(({content:t,...e})=>jsxRuntime.jsx(K,{...e,children:t}),(t,e)=>{if(t.content!==e.content||t.index!==e.index)return false;if(t.components!==e.components){let o=Object.keys(t.components||{}),s=Object.keys(e.components||{});if(o.length!==s.length||o.some(l=>{var n,c;return ((n=t.components)==null?void 0:n[l])!==((c=e.components)==null?void 0:c[l])}))return false}return !(t.rehypePlugins!==e.rehypePlugins||t.remarkPlugins!==e.remarkPlugins)});Ye.displayName="Block";var lo=t=>Array.isArray(t)&&t.some(e=>Array.isArray(e)?typeof e[0]=="function"&&e[0].name==="remarkMath":typeof e=="function"&&e.name==="remarkMath"),io=t=>{if(!Array.isArray(t))return false;let e=t.find(o=>Array.isArray(o)?o[0]===G__default.default:o===G__default.default);return e&&Array.isArray(e)&&e[1]?e[1].singleDollarTextMath===true:false},co=(t,e)=>{let o=t.includes("$$"),s=e&&(Qt.test(t)||Zt.test(t)||eo.test(t));return o||s},mo=/^\^/,po=()=>{var o,s;let t=((s=(o=_e.dependencies.katex)==null?void 0:o.replace(mo,""))==null?void 0:s.split(".").slice(0,3).join("."))||"0.16.22",e=document.createElement("link");e.rel="stylesheet",e.href=`https://cdn.jsdelivr.net/npm/katex@${t}/dist/katex.min.css`,document.head.appendChild(e);},uo=react.memo(({children:t,mode:e="streaming",parseIncompleteMarkdown:o=true,components:s,rehypePlugins:l=so,remarkPlugins:n=no,className:c,controls:r=true,isAnimating:a=false,BlockComponent:d=Ye,parseMarkdownIntoBlocksFn:i=U,caret:m,...u})=>{let b=react.useId(),[f,y]=react.useTransition(),[k,x]=react.useState([]),C=react.useMemo(()=>typeof t!="string"?"":e==="streaming"&&o?Yt__default.default(t):t,[t,e,o]),T=react.useMemo(()=>i(C),[C,i]);react.useEffect(()=>{e==="streaming"?y(()=>{x(T);}):x(T);},[T,e]);let D=e==="streaming"?k:T,$=react.useMemo(()=>D.map((J,N)=>`${b}-${N}`),[D.length,b]),Y=react.useMemo(()=>({controls:r,isAnimating:a,mode:e}),[r,a,e]),Q=react.useMemo(()=>({...Xe,...s}),[s]);react.useEffect(()=>{if(!lo(n))return;let N=io(n);co(typeof t=="string"?t:"",N)&&po();},[n,t]);let Qe=react.useMemo(()=>m&&a?{"--streamdown-caret":`"${ro[m]}"`}:void 0,[m,a]);return e==="static"?jsxRuntime.jsx(v.Provider,{value:Y,children:jsxRuntime.jsx("div",{className:chunkYHGJ7S36_cjs.a("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",c),children:jsxRuntime.jsx(K,{components:Q,rehypePlugins:l,remarkPlugins:n,...u,children:t})})}):jsxRuntime.jsx(v.Provider,{value:Y,children:jsxRuntime.jsx("div",{className:chunkYHGJ7S36_cjs.a("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",m?"*:last:after:inline *:last:after:align-baseline *:last:after:content-(--streamdown-caret)":null,c),style:Qe,children:D.map((J,N)=>jsxRuntime.jsx(d,{components:Q,content:J,index:N,rehypePlugins:l,remarkPlugins:n,shouldParseIncompleteMarkdown:o,...u},$[N]))})})},(t,e)=>t.children===e.children&&t.isAnimating===e.isAnimating&&t.mode===e.mode);uo.displayName="Streamdown";
|
|
11
|
+
exports.Block=Ye;exports.Streamdown=uo;exports.StreamdownContext=v;exports.defaultRehypePlugins=to;exports.defaultRemarkPlugins=oo;exports.getClientRehypePlugins=Ls;exports.parseMarkdownIntoBlocks=U;
|
package/dist/index.d.cts
CHANGED
|
@@ -36,6 +36,7 @@ type StreamdownProps = Options & {
|
|
|
36
36
|
caret?: keyof typeof carets;
|
|
37
37
|
};
|
|
38
38
|
declare const defaultRehypePlugins: Record<string, Pluggable>;
|
|
39
|
+
declare const getClientRehypePlugins: () => Promise<Record<string, Pluggable>>;
|
|
39
40
|
declare const defaultRemarkPlugins: Record<string, Pluggable>;
|
|
40
41
|
declare const carets: {
|
|
41
42
|
block: string;
|
|
@@ -55,4 +56,4 @@ type BlockProps = Options & {
|
|
|
55
56
|
declare const Block: react.MemoExoticComponent<({ content, ...props }: BlockProps) => react_jsx_runtime.JSX.Element>;
|
|
56
57
|
declare const Streamdown: react.MemoExoticComponent<({ children, mode, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, components, rehypePlugins, remarkPlugins, className, controls, isAnimating, BlockComponent, parseMarkdownIntoBlocksFn, caret, ...props }: StreamdownProps) => react_jsx_runtime.JSX.Element>;
|
|
57
58
|
|
|
58
|
-
export { Block, type ControlsConfig, Streamdown, StreamdownContext, type StreamdownContextType, type StreamdownProps, defaultRehypePlugins, defaultRemarkPlugins, parseMarkdownIntoBlocks };
|
|
59
|
+
export { Block, type ControlsConfig, Streamdown, StreamdownContext, type StreamdownContextType, type StreamdownProps, defaultRehypePlugins, defaultRemarkPlugins, getClientRehypePlugins, parseMarkdownIntoBlocks };
|
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ type StreamdownProps = Options & {
|
|
|
36
36
|
caret?: keyof typeof carets;
|
|
37
37
|
};
|
|
38
38
|
declare const defaultRehypePlugins: Record<string, Pluggable>;
|
|
39
|
+
declare const getClientRehypePlugins: () => Promise<Record<string, Pluggable>>;
|
|
39
40
|
declare const defaultRemarkPlugins: Record<string, Pluggable>;
|
|
40
41
|
declare const carets: {
|
|
41
42
|
block: string;
|
|
@@ -55,4 +56,4 @@ type BlockProps = Options & {
|
|
|
55
56
|
declare const Block: react.MemoExoticComponent<({ content, ...props }: BlockProps) => react_jsx_runtime.JSX.Element>;
|
|
56
57
|
declare const Streamdown: react.MemoExoticComponent<({ children, mode, parseIncompleteMarkdown: shouldParseIncompleteMarkdown, components, rehypePlugins, remarkPlugins, className, controls, isAnimating, BlockComponent, parseMarkdownIntoBlocksFn, caret, ...props }: StreamdownProps) => react_jsx_runtime.JSX.Element>;
|
|
57
58
|
|
|
58
|
-
export { Block, type ControlsConfig, Streamdown, StreamdownContext, type StreamdownContextType, type StreamdownProps, defaultRehypePlugins, defaultRemarkPlugins, parseMarkdownIntoBlocks };
|
|
59
|
+
export { Block, type ControlsConfig, Streamdown, StreamdownContext, type StreamdownContextType, type StreamdownProps, defaultRehypePlugins, defaultRemarkPlugins, getClientRehypePlugins, parseMarkdownIntoBlocks };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {a,d,b}from'./chunk-DDL734BZ.js';import {lazy,memo,useContext,createContext,isValidElement,useId,useTransition,useState,useMemo,useEffect,Suspense,useRef}from'react';import
|
|
3
|
-
`)&&(
|
|
4
|
-
`)},
|
|
5
|
-
`||i==="\r"){
|
|
6
|
-
`?d.push("\\n"):i==="\r"?d.push("\\r"):d.push(i);return d.join("")},
|
|
7
|
-
`)},X=
|
|
8
|
-
`)};var pe=({children:e,className:t,onCopy:s,onError:o,timeout:a$1=2e3})=>{let[n,c]=useState(false),[r,l]=useState(false),d=useRef(null),i=useRef(0),{isAnimating:m}=useContext(v),u=async f=>{var y,k;if(typeof window=="undefined"||!((y=navigator==null?void 0:navigator.clipboard)!=null&&y.write)){o==null||o(new Error("Clipboard API not available"));return}try{let x=(k=d.current)==null?void 0:k.closest('[data-streamdown="table-wrapper"]'),P=x==null?void 0:x.querySelector("table");if(!P){o==null||o(new Error("Table not found"));return}let T=E(P),R=f==="csv"?I(T):le(T),$=new ClipboardItem({"text/plain":new Blob([R],{type:"text/plain"}),"text/html":new Blob([P.outerHTML],{type:"text/html"})});await navigator.clipboard.write([$]),l(!0),c(!1),s==null||s(f),i.current=window.setTimeout(()=>l(!1),a$1);}catch(x){o==null||o(x);}};useEffect(()=>{let f=y=>{d.current&&!d.current.contains(y.target)&&c(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f),window.clearTimeout(i.current);}},[]);let b=r?CheckIcon:CopyIcon;return jsxs("div",{className:"relative",ref:d,children:[jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:m,onClick:()=>c(!n),title:"Copy table",type:"button",children:e!=null?e:jsx(b,{size:14})}),n?jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]}):null]})};var fe=({children:e,className:t,onDownload:s,onError:o})=>{let[a$1,n]=useState(false),c=useRef(null),{isAnimating:r}=useContext(v),l=d=>{var i;try{let m=(i=c.current)==null?void 0:i.closest('[data-streamdown="table-wrapper"]'),u=m==null?void 0:m.querySelector("table");if(!u){o==null||o(new Error("Table not found"));return}let b$1=E(u),f=d==="csv"?I(b$1):ie(b$1);b(`table.${d==="csv"?"csv":"md"}`,f,d==="csv"?"text/csv":"text/markdown"),n(!1),s==null||s(d);}catch(m){o==null||o(m);}};return useEffect(()=>{let d=i=>{c.current&&!c.current.contains(i.target)&&n(false);};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d);}},[]),jsxs("div",{className:"relative",ref:c,children:[jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",t),disabled:r,onClick:()=>n(!a$1),title:"Download table",type:"button",children:e!=null?e:jsx(DownloadIcon,{size:14})}),a$1?jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("csv"),title:"Download table as CSV",type:"button",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>l("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]}):null]})};var be=({children:e,className:t,showControls:s,...o})=>jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[s?jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsx(pe,{}),jsx(fe,{})]}):null,jsx("div",{className:"overflow-x-auto",children:jsx("table",{className:a("w-full border-collapse border border-border",t),"data-streamdown":"table",...o,children:e})})]});var Tt=lazy(()=>import('./code-block-HNJHFH25.js').then(e=>({default:e.CodeBlock}))),Ct=/language-([^\s]+)/;function O(e,t){if(!(e!=null&&e.position||t!=null&&t.position))return true;if(!(e!=null&&e.position&&(t!=null&&t.position)))return false;let s=e.position.start,o=t.position.start,a=e.position.end,n=t.position.end;return (s==null?void 0:s.line)===(o==null?void 0:o.line)&&(s==null?void 0:s.column)===(o==null?void 0:o.column)&&(a==null?void 0:a.line)===(n==null?void 0:n.line)&&(a==null?void 0:a.column)===(n==null?void 0:n.column)}function w(e,t){return e.className===t.className&&O(e.node,t.node)}var ye=(e,t)=>typeof e=="boolean"?e:e[t]!==false,W=memo(({children:e,className:t,node:s,...o})=>jsx("ol",{className:a("list-inside list-decimal whitespace-normal [li_&]:pl-6",t),"data-streamdown":"ordered-list",...o,children:e}),(e,t)=>w(e,t));W.displayName="MarkdownOl";var we=memo(({children:e,className:t,node:s,...o})=>jsx("li",{className:a("py-1 [&>p]:inline",t),"data-streamdown":"list-item",...o,children:e}),(e,t)=>e.className===t.className&&O(e.node,t.node));we.displayName="MarkdownLi";var ke=memo(({children:e,className:t,node:s,...o})=>jsx("ul",{className:a("list-inside list-disc whitespace-normal [li_&]:pl-6",t),"data-streamdown":"unordered-list",...o,children:e}),(e,t)=>w(e,t));ke.displayName="MarkdownUl";var xe=memo(({className:e,node:t,...s})=>jsx("hr",{className:a("my-6 border-border",e),"data-streamdown":"horizontal-rule",...s}),(e,t)=>w(e,t));xe.displayName="MarkdownHr";var ve=memo(({children:e,className:t,node:s,...o})=>jsx("span",{className:a("font-semibold",t),"data-streamdown":"strong",...o,children:e}),(e,t)=>w(e,t));ve.displayName="MarkdownStrong";var Te=memo(({children:e,className:t,href:s,node:o,...a$1})=>{let n=s==="streamdown:incomplete-link";return jsx("a",{className:a("wrap-anywhere font-medium text-primary underline",t),"data-incomplete":n,"data-streamdown":"link",href:s,rel:"noreferrer",target:"_blank",...a$1,children:e})},(e,t)=>w(e,t)&&e.href===t.href);Te.displayName="MarkdownA";var Ce=memo(({children:e,className:t,node:s,...o})=>jsx("h1",{className:a("mt-6 mb-2 font-semibold text-3xl",t),"data-streamdown":"heading-1",...o,children:e}),(e,t)=>w(e,t));Ce.displayName="MarkdownH1";var Pe=memo(({children:e,className:t,node:s,...o})=>jsx("h2",{className:a("mt-6 mb-2 font-semibold text-2xl",t),"data-streamdown":"heading-2",...o,children:e}),(e,t)=>w(e,t));Pe.displayName="MarkdownH2";var Ne=memo(({children:e,className:t,node:s,...o})=>jsx("h3",{className:a("mt-6 mb-2 font-semibold text-xl",t),"data-streamdown":"heading-3",...o,children:e}),(e,t)=>w(e,t));Ne.displayName="MarkdownH3";var Me=memo(({children:e,className:t,node:s,...o})=>jsx("h4",{className:a("mt-6 mb-2 font-semibold text-lg",t),"data-streamdown":"heading-4",...o,children:e}),(e,t)=>w(e,t));Me.displayName="MarkdownH4";var Se=memo(({children:e,className:t,node:s,...o})=>jsx("h5",{className:a("mt-6 mb-2 font-semibold text-base",t),"data-streamdown":"heading-5",...o,children:e}),(e,t)=>w(e,t));Se.displayName="MarkdownH5";var De=memo(({children:e,className:t,node:s,...o})=>jsx("h6",{className:a("mt-6 mb-2 font-semibold text-sm",t),"data-streamdown":"heading-6",...o,children:e}),(e,t)=>w(e,t));De.displayName="MarkdownH6";var Re=memo(({children:e,className:t,node:s,...o})=>{let{controls:a}=useContext(v),n=ye(a,"table");return jsx(be,{className:t,"data-streamdown":"table-wrapper",showControls:n,...o,children:e})},(e,t)=>w(e,t));Re.displayName="MarkdownTable";var je=memo(({children:e,className:t,node:s,...o})=>jsx("thead",{className:a("bg-muted/80",t),"data-streamdown":"table-header",...o,children:e}),(e,t)=>w(e,t));je.displayName="MarkdownThead";var Ae=memo(({children:e,className:t,node:s,...o})=>jsx("tbody",{className:a("divide-y divide-border bg-muted/40",t),"data-streamdown":"table-body",...o,children:e}),(e,t)=>w(e,t));Ae.displayName="MarkdownTbody";var Ee=memo(({children:e,className:t,node:s,...o})=>jsx("tr",{className:a("border-border border-b",t),"data-streamdown":"table-row",...o,children:e}),(e,t)=>w(e,t));Ee.displayName="MarkdownTr";var Ie=memo(({children:e,className:t,node:s,...o})=>jsx("th",{className:a("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",t),"data-streamdown":"table-header-cell",...o,children:e}),(e,t)=>w(e,t));Ie.displayName="MarkdownTh";var Le=memo(({children:e,className:t,node:s,...o})=>jsx("td",{className:a("px-4 py-2 text-sm",t),"data-streamdown":"table-cell",...o,children:e}),(e,t)=>w(e,t));Le.displayName="MarkdownTd";var He=memo(({children:e,className:t,node:s,...o})=>jsx("blockquote",{className:a("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",t),"data-streamdown":"blockquote",...o,children:e}),(e,t)=>w(e,t));He.displayName="MarkdownBlockquote";var Be=memo(({children:e,className:t,node:s,...o})=>jsx("sup",{className:a("text-sm",t),"data-streamdown":"superscript",...o,children:e}),(e,t)=>w(e,t));Be.displayName="MarkdownSup";var Oe=memo(({children:e,className:t,node:s,...o})=>jsx("sub",{className:a("text-sm",t),"data-streamdown":"subscript",...o,children:e}),(e,t)=>w(e,t));Oe.displayName="MarkdownSub";var qe=memo(({children:e,className:t,node:s,...o})=>{if("data-footnotes"in o){let n=l=>{var u,b;if(!isValidElement(l))return false;let d=Array.isArray(l.props.children)?l.props.children:[l.props.children],i=false,m=false;for(let f of d)if(f){if(typeof f=="string")f.trim()!==""&&(i=true);else if(isValidElement(f))if(((u=f.props)==null?void 0:u["data-footnote-backref"])!==void 0)m=true;else {let y=Array.isArray(f.props.children)?f.props.children:[f.props.children];for(let k of y){if(typeof k=="string"&&k.trim()!==""){i=true;break}if(isValidElement(k)&&((b=k.props)==null?void 0:b["data-footnote-backref"])===void 0){i=true;break}}}}return m&&!i},c=Array.isArray(e)?e.map(l=>{if(!isValidElement(l))return l;if(l.type===W){let i=(Array.isArray(l.props.children)?l.props.children:[l.props.children]).filter(m=>!n(m));return i.length===0?null:{...l,props:{...l.props,children:i}}}return l}):e;return (Array.isArray(c)?c.some(l=>l!==null):c!==null)?jsx("section",{className:t,...o,children:c}):null}return jsx("section",{className:t,...o,children:e})},(e,t)=>w(e,t));qe.displayName="MarkdownSection";var Pt=({node:e,className:t,children:s,...o})=>{var i,m,u;let a$1=((i=e==null?void 0:e.position)==null?void 0:i.start.line)===((m=e==null?void 0:e.position)==null?void 0:m.end.line),{controls:n}=useContext(v);if(a$1)return jsx("code",{className:a("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...o,children:s});let c=t==null?void 0:t.match(Ct),r=(u=c==null?void 0:c.at(1))!=null?u:"",l="";isValidElement(s)&&s.props&&typeof s.props=="object"&&"children"in s.props&&typeof s.props.children=="string"?l=s.props.children:typeof s=="string"&&(l=s);let d=ye(n,"code");return jsx(Suspense,{fallback:jsx(re,{}),children:jsx(Tt,{className:a("overflow-x-auto border-border border-t",t),code:l,language:r,children:d?jsxs(Fragment,{children:[jsx(ne,{code:l,language:r}),jsx(te,{})]}):null})})},$e=memo(Pt,(e,t)=>e.className===t.className&&O(e.node,t.node));$e.displayName="MarkdownCode";var Je=memo(ae,(e,t)=>e.className===t.className&&O(e.node,t.node));Je.displayName="MarkdownImg";var ze=memo(({children:e,className:t,node:s,...o})=>{var c;let n=(Array.isArray(e)?e:[e]).filter(r=>r!=null&&r!=="");return n.length===1&&isValidElement(n[0])&&((c=n[0].props.node)==null?void 0:c.tagName)==="img"?jsx(Fragment,{children:e}):jsx("p",{className:t,...o,children:e})},(e,t)=>w(e,t));ze.displayName="MarkdownParagraph";var Xe={ol:W,li:we,ul:ke,hr:xe,strong:ve,a:Te,h1:Ce,h2:Pe,h3:Ne,h4:Me,h5:Se,h6:De,table:Re,thead:je,tbody:Ae,tr:Ee,th:Ie,td:Le,blockquote:He,code:$e,img:Je,pre:({children:e})=>e,sup:Be,sub:Oe,p:ze,section:qe};var Ke=[],Ve={allowDangerousHtml:true},q=new WeakMap,K=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(t){let s=this.keyCache.get(t);if(s)return s;let o=t.rehypePlugins,a=t.remarkPlugins,n=t.remarkRehypeOptions;if(!(o||a||n)){let m="default";return this.keyCache.set(t,m),m}let c=m=>{if(!m||m.length===0)return "";let u="";for(let b=0;b<m.length;b+=1){let f=m[b];if(b>0&&(u+=","),Array.isArray(f)){let[y,k]=f;if(typeof y=="function"){let x=q.get(y);x||(x=y.name,q.set(y,x)),u+=x;}else u+=String(y);u+=":",u+=JSON.stringify(k);}else if(typeof f=="function"){let y=q.get(f);y||(y=f.name,q.set(f,y)),u+=y;}else u+=String(f);}return u},r=c(o),l=c(a),d=n?JSON.stringify(n):"",i=`${l}::${r}::${d}`;return this.keyCache.set(t,i),i}get(t){let s=this.generateCacheKey(t),o=this.cache.get(s);return o&&(this.cache.delete(s),this.cache.set(s,o)),o}set(t,s){let o=this.generateCacheKey(t);if(this.cache.size>=this.maxSize){let a=this.cache.keys().next().value;a&&this.cache.delete(a);}this.cache.set(o,s);}clear(){this.cache.clear();}},Fe=new K,V=e=>{let t=It(e),s=e.children||"";return Ht(t.runSync(t.parse(s),s),e)},It=e=>{let t=Fe.get(e);if(t)return t;let s=Lt(e);return Fe.set(e,s),s},Lt=e=>{let t=e.rehypePlugins||Ke,s=e.remarkPlugins||Ke,o=e.remarkRehypeOptions?{...Ve,...e.remarkRehypeOptions}:Ve;return unified().use(jt).use(s).use(At,o).use(t)},Ht=(e,t)=>toJsxRuntime(e,{Fragment:Fragment,components:t.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true});var Ot=/\[\^[^\]\s]{1,200}\](?!:)/,qt=/\[\^[^\]\s]{1,200}\]:/,$t=/<\/(\w+)>/,Jt=/<(\w+)[\s>]/,F=e=>{let t=0;for(;t<e.length&&(e[t]===" "||e[t]===" "||e[t]===`
|
|
9
|
-
`||e
|
|
10
|
-
`||e
|
|
11
|
-
export{Ye as Block,uo as Streamdown,v as StreamdownContext,to as defaultRehypePlugins,oo as defaultRemarkPlugins,U as parseMarkdownIntoBlocks};
|
|
2
|
+
import {a,d,b}from'./chunk-DDL734BZ.js';import {lazy,memo,useContext,createContext,isValidElement,useId,useTransition,useState,useMemo,useEffect,Suspense,useRef}from'react';import Vt from'rehype-sanitize';import _t from'remark-cjk-friendly';import Ut from'remark-cjk-friendly-gfm-strikethrough';import Gt from'remark-gfm';import G from'remark-math';import Yt from'remend';import {DownloadIcon,CheckIcon,CopyIcon,Loader2Icon}from'lucide-react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {toJsxRuntime}from'hast-util-to-jsx-runtime';import Dt from'remark-parse';import jt from'remark-rehype';import {unified}from'unified';import {Lexer}from'marked';var ee=({onCopy:t,onError:e,timeout:o=2e3,children:s,className:l,code:n,...c})=>{let[r,a$1]=useState(false),d$1=useRef(0),{code:i}=d(),{isAnimating:m}=useContext(v),u=n!=null?n:i,b=async()=>{var y;if(typeof window=="undefined"||!((y=navigator==null?void 0:navigator.clipboard)!=null&&y.writeText)){e==null||e(new Error("Clipboard API not available"));return}try{r||(await navigator.clipboard.writeText(u),a$1(!0),t==null||t(),d$1.current=window.setTimeout(()=>a$1(!1),o));}catch(k){e==null||e(k);}};useEffect(()=>()=>{window.clearTimeout(d$1.current);},[]);let f=r?CheckIcon:CopyIcon;return jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",l),"data-streamdown":"code-block-copy-button",disabled:m,onClick:b,title:"Copy Code",type:"button",...c,children:s!=null?s:jsx(f,{size:14})})};var te={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",\u6587\u8A00:"wy"},se=({onDownload:t,onError:e,language:o,children:s,className:l,code:n,...c})=>{let{code:r}=d(),{isAnimating:a$1}=useContext(v),d$1=n!=null?n:r,m=`file.${o&&o in te?te[o]:"txt"}`,u="text/plain",b$1=()=>{try{b(m,d$1,u),t==null||t();}catch(f){e==null||e(f);}};return jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",l),"data-streamdown":"code-block-download-button",disabled:a$1,onClick:b$1,title:"Download file",type:"button",...c,children:s!=null?s:jsx(DownloadIcon,{size:14})})};var ne=()=>jsxs("div",{className:"w-full divide-y divide-border overflow-hidden rounded-xl border border-border",children:[jsx("div",{className:"h-[46px] w-full bg-muted/80"}),jsx("div",{className:"flex w-full items-center justify-center p-4",children:jsx(Loader2Icon,{className:"size-4 animate-spin"})})]});var dt=/\.[^/.]+$/,re=({node:t,className:e,src:o,alt:s,...l})=>{let n=async()=>{if(o)try{let r=await(await fetch(o)).blob(),d=new URL(o,window.location.origin).pathname.split("/").pop()||"",i=d.split(".").pop(),m=d.includes(".")&&i!==void 0&&i.length<=4,u="";if(m)u=d;else {let b=r.type,f="png";b.includes("jpeg")||b.includes("jpg")?f="jpg":b.includes("png")?f="png":b.includes("svg")?f="svg":b.includes("gif")?f="gif":b.includes("webp")&&(f="webp"),u=`${(s||d||"image").replace(dt,"")}.${f}`;}b(u,r,r.type);}catch(c){console.error("Failed to download image:",c);}};return o?jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[jsx("img",{alt:s,className:a("max-w-full rounded-lg",e),"data-streamdown":"image",src:o,...l}),jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),jsx("button",{className:a("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 group-hover:opacity-100"),onClick:n,title:"Download image",type:"button",children:jsx(DownloadIcon,{size:14})})]}):null};var E=t=>{var n,c;let e=[],o=[],s=t.querySelectorAll("thead th");for(let r of s)e.push(((n=r.textContent)==null?void 0:n.trim())||"");let l=t.querySelectorAll("tbody tr");for(let r of l){let a=[],d=r.querySelectorAll("td");for(let i of d)a.push(((c=i.textContent)==null?void 0:c.trim())||"");o.push(a);}return {headers:e,rows:o}},I=t=>{let{headers:e,rows:o}=t,s=r=>{let a=false,d=false;for(let i of r){if(i==='"'){a=true,d=true;break}(i===","||i===`
|
|
3
|
+
`)&&(a=true);}return a?d?`"${r.replace(/"/g,'""')}"`:`"${r}"`:r},l=e.length>0?o.length+1:o.length,n=new Array(l),c=0;e.length>0&&(n[c]=e.map(s).join(","),c+=1);for(let r of o)n[c]=r.map(s).join(","),c+=1;return n.join(`
|
|
4
|
+
`)},ae=t=>{let{headers:e,rows:o}=t,s=r=>{let a=false;for(let i of r)if(i===" "||i===`
|
|
5
|
+
`||i==="\r"){a=true;break}if(!a)return r;let d=[];for(let i of r)i===" "?d.push("\\t"):i===`
|
|
6
|
+
`?d.push("\\n"):i==="\r"?d.push("\\r"):d.push(i);return d.join("")},l=e.length>0?o.length+1:o.length,n=new Array(l),c=0;e.length>0&&(n[c]=e.map(s).join(" "),c+=1);for(let r of o)n[c]=r.map(s).join(" "),c+=1;return n.join(`
|
|
7
|
+
`)},X=t=>{let e=false;for(let s of t)if(s==="\\"||s==="|"){e=true;break}if(!e)return t;let o=[];for(let s of t)s==="\\"?o.push("\\\\"):s==="|"?o.push("\\|"):o.push(s);return o.join("")},le=t=>{let{headers:e,rows:o}=t;if(e.length===0)return "";let s=new Array(o.length+2),l=0,n=e.map(r=>X(r));s[l]=`| ${n.join(" | ")} |`,l+=1;let c=new Array(e.length);for(let r=0;r<e.length;r+=1)c[r]="---";s[l]=`| ${c.join(" | ")} |`,l+=1;for(let r of o)if(r.length<e.length){let a=new Array(e.length);for(let d=0;d<e.length;d+=1)a[d]=d<r.length?X(r[d]):"";s[l]=`| ${a.join(" | ")} |`,l+=1;}else {let a=r.map(d=>X(d));s[l]=`| ${a.join(" | ")} |`,l+=1;}return s.join(`
|
|
8
|
+
`)};var me=({children:t,className:e,onCopy:o,onError:s,timeout:l=2e3})=>{let[n,c]=useState(false),[r,a$1]=useState(false),d=useRef(null),i=useRef(0),{isAnimating:m}=useContext(v),u=async f=>{var y,k;if(typeof window=="undefined"||!((y=navigator==null?void 0:navigator.clipboard)!=null&&y.write)){s==null||s(new Error("Clipboard API not available"));return}try{let x=(k=d.current)==null?void 0:k.closest('[data-streamdown="table-wrapper"]'),C=x==null?void 0:x.querySelector("table");if(!C){s==null||s(new Error("Table not found"));return}let T=E(C),D=f==="csv"?I(T):ae(T),$=new ClipboardItem({"text/plain":new Blob([D],{type:"text/plain"}),"text/html":new Blob([C.outerHTML],{type:"text/html"})});await navigator.clipboard.write([$]),a$1(!0),c(!1),o==null||o(f),i.current=window.setTimeout(()=>a$1(!1),l);}catch(x){s==null||s(x);}};useEffect(()=>{let f=y=>{d.current&&!d.current.contains(y.target)&&c(false);};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f),window.clearTimeout(i.current);}},[]);let b=r?CheckIcon:CopyIcon;return jsxs("div",{className:"relative",ref:d,children:[jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",e),disabled:m,onClick:()=>c(!n),title:"Copy table",type:"button",children:t!=null?t:jsx(b,{size:14})}),n?jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("csv"),title:"Copy table as CSV",type:"button",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>u("tsv"),title:"Copy table as TSV",type:"button",children:"TSV"})]}):null]})};var ue=({children:t,className:e,onDownload:o,onError:s})=>{let[l,n]=useState(false),c=useRef(null),{isAnimating:r}=useContext(v),a$1=d=>{var i;try{let m=(i=c.current)==null?void 0:i.closest('[data-streamdown="table-wrapper"]'),u=m==null?void 0:m.querySelector("table");if(!u){s==null||s(new Error("Table not found"));return}let b$1=E(u),f=d==="csv"?I(b$1):le(b$1);b(`table.${d==="csv"?"csv":"md"}`,f,d==="csv"?"text/csv":"text/markdown"),n(!1),o==null||o(d);}catch(m){s==null||s(m);}};return useEffect(()=>{let d=i=>{c.current&&!c.current.contains(i.target)&&n(false);};return document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d);}},[]),jsxs("div",{className:"relative",ref:c,children:[jsx("button",{className:a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",e),disabled:r,onClick:()=>n(!l),title:"Download table",type:"button",children:t!=null?t:jsx(DownloadIcon,{size:14})}),l?jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>a$1("csv"),title:"Download table as CSV",type:"button",children:"CSV"}),jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>a$1("markdown"),title:"Download table as Markdown",type:"button",children:"Markdown"})]}):null]})};var ge=({children:t,className:e,showControls:o,...s})=>jsxs("div",{className:"my-4 flex flex-col space-y-2","data-streamdown":"table-wrapper",children:[o?jsxs("div",{className:"flex items-center justify-end gap-1",children:[jsx(me,{}),jsx(ue,{})]}):null,jsx("div",{className:"overflow-x-auto",children:jsx("table",{className:a("w-full border-collapse border border-border",e),"data-streamdown":"table",...s,children:t})})]});var vt=lazy(()=>import('./code-block-HNJHFH25.js').then(t=>({default:t.CodeBlock})));lazy(()=>import('./math-renderer-NX6TIXIB.js').then(t=>({default:t.MathRenderer})));var Tt=/language-([^\s]+)/;function O(t,e){if(!(t!=null&&t.position||e!=null&&e.position))return true;if(!(t!=null&&t.position&&(e!=null&&e.position)))return false;let o=t.position.start,s=e.position.start,l=t.position.end,n=e.position.end;return (o==null?void 0:o.line)===(s==null?void 0:s.line)&&(o==null?void 0:o.column)===(s==null?void 0:s.column)&&(l==null?void 0:l.line)===(n==null?void 0:n.line)&&(l==null?void 0:l.column)===(n==null?void 0:n.column)}function w(t,e){return t.className===e.className&&O(t.node,e.node)}var ye=(t,e)=>typeof t=="boolean"?t:t[e]!==false,W=memo(({children:t,className:e,node:o,...s})=>jsx("ol",{className:a("list-inside list-decimal whitespace-normal [li_&]:pl-6",e),"data-streamdown":"ordered-list",...s,children:t}),(t,e)=>w(t,e));W.displayName="MarkdownOl";var we=memo(({children:t,className:e,node:o,...s})=>jsx("li",{className:a("py-1 [&>p]:inline",e),"data-streamdown":"list-item",...s,children:t}),(t,e)=>t.className===e.className&&O(t.node,e.node));we.displayName="MarkdownLi";var ke=memo(({children:t,className:e,node:o,...s})=>jsx("ul",{className:a("list-inside list-disc whitespace-normal [li_&]:pl-6",e),"data-streamdown":"unordered-list",...s,children:t}),(t,e)=>w(t,e));ke.displayName="MarkdownUl";var xe=memo(({className:t,node:e,...o})=>jsx("hr",{className:a("my-6 border-border",t),"data-streamdown":"horizontal-rule",...o}),(t,e)=>w(t,e));xe.displayName="MarkdownHr";var ve=memo(({children:t,className:e,node:o,...s})=>jsx("span",{className:a("font-semibold",e),"data-streamdown":"strong",...s,children:t}),(t,e)=>w(t,e));ve.displayName="MarkdownStrong";var Te=memo(({children:t,className:e,href:o,node:s,...l})=>{let n=o==="streamdown:incomplete-link";return jsx("a",{className:a("wrap-anywhere font-medium text-primary underline",e),"data-incomplete":n,"data-streamdown":"link",href:o,rel:"noreferrer",target:"_blank",...l,children:t})},(t,e)=>w(t,e)&&t.href===e.href);Te.displayName="MarkdownA";var Pe=memo(({children:t,className:e,node:o,...s})=>jsx("h1",{className:a("mt-6 mb-2 font-semibold text-3xl",e),"data-streamdown":"heading-1",...s,children:t}),(t,e)=>w(t,e));Pe.displayName="MarkdownH1";var Ce=memo(({children:t,className:e,node:o,...s})=>jsx("h2",{className:a("mt-6 mb-2 font-semibold text-2xl",e),"data-streamdown":"heading-2",...s,children:t}),(t,e)=>w(t,e));Ce.displayName="MarkdownH2";var Ne=memo(({children:t,className:e,node:o,...s})=>jsx("h3",{className:a("mt-6 mb-2 font-semibold text-xl",e),"data-streamdown":"heading-3",...s,children:t}),(t,e)=>w(t,e));Ne.displayName="MarkdownH3";var Me=memo(({children:t,className:e,node:o,...s})=>jsx("h4",{className:a("mt-6 mb-2 font-semibold text-lg",e),"data-streamdown":"heading-4",...s,children:t}),(t,e)=>w(t,e));Me.displayName="MarkdownH4";var Se=memo(({children:t,className:e,node:o,...s})=>jsx("h5",{className:a("mt-6 mb-2 font-semibold text-base",e),"data-streamdown":"heading-5",...s,children:t}),(t,e)=>w(t,e));Se.displayName="MarkdownH5";var Re=memo(({children:t,className:e,node:o,...s})=>jsx("h6",{className:a("mt-6 mb-2 font-semibold text-sm",e),"data-streamdown":"heading-6",...s,children:t}),(t,e)=>w(t,e));Re.displayName="MarkdownH6";var De=memo(({children:t,className:e,node:o,...s})=>{let{controls:l}=useContext(v),n=ye(l,"table");return jsx(ge,{className:e,"data-streamdown":"table-wrapper",showControls:n,...s,children:t})},(t,e)=>w(t,e));De.displayName="MarkdownTable";var je=memo(({children:t,className:e,node:o,...s})=>jsx("thead",{className:a("bg-muted/80",e),"data-streamdown":"table-header",...s,children:t}),(t,e)=>w(t,e));je.displayName="MarkdownThead";var Ae=memo(({children:t,className:e,node:o,...s})=>jsx("tbody",{className:a("divide-y divide-border bg-muted/40",e),"data-streamdown":"table-body",...s,children:t}),(t,e)=>w(t,e));Ae.displayName="MarkdownTbody";var Ee=memo(({children:t,className:e,node:o,...s})=>jsx("tr",{className:a("border-border border-b",e),"data-streamdown":"table-row",...s,children:t}),(t,e)=>w(t,e));Ee.displayName="MarkdownTr";var Ie=memo(({children:t,className:e,node:o,...s})=>jsx("th",{className:a("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm",e),"data-streamdown":"table-header-cell",...s,children:t}),(t,e)=>w(t,e));Ie.displayName="MarkdownTh";var Le=memo(({children:t,className:e,node:o,...s})=>jsx("td",{className:a("px-4 py-2 text-sm",e),"data-streamdown":"table-cell",...s,children:t}),(t,e)=>w(t,e));Le.displayName="MarkdownTd";var He=memo(({children:t,className:e,node:o,...s})=>jsx("blockquote",{className:a("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",e),"data-streamdown":"blockquote",...s,children:t}),(t,e)=>w(t,e));He.displayName="MarkdownBlockquote";var Be=memo(({children:t,className:e,node:o,...s})=>jsx("sup",{className:a("text-sm",e),"data-streamdown":"superscript",...s,children:t}),(t,e)=>w(t,e));Be.displayName="MarkdownSup";var Oe=memo(({children:t,className:e,node:o,...s})=>jsx("sub",{className:a("text-sm",e),"data-streamdown":"subscript",...s,children:t}),(t,e)=>w(t,e));Oe.displayName="MarkdownSub";var qe=memo(({children:t,className:e,node:o,...s})=>{if("data-footnotes"in s){let n=a=>{var u,b;if(!isValidElement(a))return false;let d=Array.isArray(a.props.children)?a.props.children:[a.props.children],i=false,m=false;for(let f of d)if(f){if(typeof f=="string")f.trim()!==""&&(i=true);else if(isValidElement(f))if(((u=f.props)==null?void 0:u["data-footnote-backref"])!==void 0)m=true;else {let y=Array.isArray(f.props.children)?f.props.children:[f.props.children];for(let k of y){if(typeof k=="string"&&k.trim()!==""){i=true;break}if(isValidElement(k)&&((b=k.props)==null?void 0:b["data-footnote-backref"])===void 0){i=true;break}}}}return m&&!i},c=Array.isArray(t)?t.map(a=>{if(!isValidElement(a))return a;if(a.type===W){let i=(Array.isArray(a.props.children)?a.props.children:[a.props.children]).filter(m=>!n(m));return i.length===0?null:{...a,props:{...a.props,children:i}}}return a}):t;return (Array.isArray(c)?c.some(a=>a!==null):c!==null)?jsx("section",{className:e,...s,children:c}):null}return jsx("section",{className:e,...s,children:t})},(t,e)=>w(t,e));qe.displayName="MarkdownSection";var Pt=({node:t,className:e,children:o,...s})=>{var i,m,u;let l=((i=t==null?void 0:t.position)==null?void 0:i.start.line)===((m=t==null?void 0:t.position)==null?void 0:m.end.line),{controls:n}=useContext(v);if(l)return jsx("code",{className:a("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",e),"data-streamdown":"inline-code",...s,children:o});let c=e==null?void 0:e.match(Tt),r=(u=c==null?void 0:c.at(1))!=null?u:"",a$1="";isValidElement(o)&&o.props&&typeof o.props=="object"&&"children"in o.props&&typeof o.props.children=="string"?a$1=o.props.children:typeof o=="string"&&(a$1=o);let d=ye(n,"code");return jsx(Suspense,{fallback:jsx(ne,{}),children:jsx(vt,{className:a("overflow-x-auto border-border border-t",e),code:a$1,language:r,children:d?jsxs(Fragment,{children:[jsx(se,{code:a$1,language:r}),jsx(ee,{})]}):null})})},$e=memo(Pt,(t,e)=>t.className===e.className&&O(t.node,e.node));$e.displayName="MarkdownCode";var Je=memo(re,(t,e)=>t.className===e.className&&O(t.node,e.node));Je.displayName="MarkdownImg";var ze=memo(({children:t,className:e,node:o,...s})=>{var c;let n=(Array.isArray(t)?t:[t]).filter(r=>r!=null&&r!=="");return n.length===1&&isValidElement(n[0])&&((c=n[0].props.node)==null?void 0:c.tagName)==="img"?jsx(Fragment,{children:t}):jsx("p",{className:e,...s,children:t})},(t,e)=>w(t,e));ze.displayName="MarkdownParagraph";var Xe={ol:W,li:we,ul:ke,hr:xe,strong:ve,a:Te,h1:Pe,h2:Ce,h3:Ne,h4:Me,h5:Se,h6:Re,table:De,thead:je,tbody:Ae,tr:Ee,th:Ie,td:Le,blockquote:He,code:$e,img:Je,pre:({children:t})=>t,sup:Be,sub:Oe,p:ze,section:qe};var Fe=[],Ke={allowDangerousHtml:true},q=new WeakMap,F=class{constructor(){this.cache=new Map;this.keyCache=new WeakMap;this.maxSize=100;}generateCacheKey(e){let o=this.keyCache.get(e);if(o)return o;let s=e.rehypePlugins,l=e.remarkPlugins,n=e.remarkRehypeOptions;if(!(s||l||n)){let m="default";return this.keyCache.set(e,m),m}let c=m=>{if(!m||m.length===0)return "";let u="";for(let b=0;b<m.length;b+=1){let f=m[b];if(b>0&&(u+=","),Array.isArray(f)){let[y,k]=f;if(typeof y=="function"){let x=q.get(y);x||(x=y.name,q.set(y,x)),u+=x;}else u+=String(y);u+=":",u+=JSON.stringify(k);}else if(typeof f=="function"){let y=q.get(f);y||(y=f.name,q.set(f,y)),u+=y;}else u+=String(f);}return u},r=c(s),a=c(l),d=n?JSON.stringify(n):"",i=`${a}::${r}::${d}`;return this.keyCache.set(e,i),i}get(e){let o=this.generateCacheKey(e),s=this.cache.get(o);return s&&(this.cache.delete(o),this.cache.set(o,s)),s}set(e,o){let s=this.generateCacheKey(e);if(this.cache.size>=this.maxSize){let l=this.cache.keys().next().value;l&&this.cache.delete(l);}this.cache.set(s,o);}clear(){this.cache.clear();}},Ve=new F,K=t=>{let e=Et(t),o=t.children||"";return Lt(e.runSync(e.parse(o),o),t)},Et=t=>{let e=Ve.get(t);if(e)return e;let o=It(t);return Ve.set(t,o),o},It=t=>{let e=t.rehypePlugins||Fe,o=t.remarkPlugins||Fe,s=t.remarkRehypeOptions?{...Ke,...t.remarkRehypeOptions}:Ke;return unified().use(Dt).use(o).use(jt,s).use(e)},Lt=(t,e)=>toJsxRuntime(t,{Fragment:Fragment,components:e.components,ignoreInvalidStyle:true,jsx:jsx,jsxs:jsxs,passKeys:true,passNode:true});var Bt=/\[\^[^\]\s]{1,200}\](?!:)/,Ot=/\[\^[^\]\s]{1,200}\]:/,qt=/<\/(\w+)>/,$t=/<(\w+)[\s>]/,V=t=>{let e=0;for(;e<t.length&&(t[e]===" "||t[e]===" "||t[e]===`
|
|
9
|
+
`||t[e]==="\r");)e+=1;return e+1<t.length&&t[e]==="$"&&t[e+1]==="$"},Jt=t=>{let e=t.length-1;for(;e>=0&&(t[e]===" "||t[e]===" "||t[e]===`
|
|
10
|
+
`||t[e]==="\r");)e-=1;return e>=1&&t[e]==="$"&&t[e-1]==="$"},_=t=>{let e=0;for(let o=0;o<t.length-1;o+=1)t[o]==="$"&&t[o+1]==="$"&&(e+=1,o+=1);return e},U=t=>{let e=Bt.test(t),o=Ot.test(t);if(e||o)return [t];let s=Lexer.lex(t,{gfm:true}),l=[],n=[];for(let c of s){let r=c.raw,a=l.length;if(n.length>0){if(l[a-1]+=r,c.type==="html"){let i=r.match(qt);if(i){let m=i[1];n.at(-1)===m&&n.pop();}}continue}if(c.type==="html"&&c.block){let i=r.match($t);if(i){let m=i[1];r.includes(`</${m}>`)||n.push(m);}}if(r.trim()==="$$"&&a>0){let i=l[a-1],m=V(i),u=_(i);if(m&&u%2===1){l[a-1]=i+r;continue}}if(a>0&&Jt(r)){let i=l[a-1],m=V(i),u=_(i),b=_(r);if(m&&u%2===1&&!V(r)&&b===1){l[a-1]=i+r;continue}}l.push(r);}return l};var _e={dependencies:{katex:"^0.16.22"}};var Qt=/[^$]\$[^$]/,Zt=/^\$[^$]/,eo=/[^$]\$$/,to={sanitize:[Vt,{}]},Ls=async()=>{let[{harden:t},{default:e},{default:o}]=await Promise.all([import('rehype-harden'),import('rehype-katex'),import('rehype-raw')]);return {raw:[o,{}],harden:[t,{}],katex:[e,{output:"mathml"}]}},oo={gfm:[Gt,{}],math:[G,{singleDollarTextMath:false}],cjkFriendly:[_t,{}],cjkFriendlyGfmStrikethrough:[Ut,{}]},so=Object.values(to),no=Object.values(oo),ro={block:" \u258B",circle:" \u25CF"},ao={controls:true,isAnimating:false,mode:"streaming"},v=createContext(ao),Ye=memo(({content:t,...e})=>jsx(K,{...e,children:t}),(t,e)=>{if(t.content!==e.content||t.index!==e.index)return false;if(t.components!==e.components){let o=Object.keys(t.components||{}),s=Object.keys(e.components||{});if(o.length!==s.length||o.some(l=>{var n,c;return ((n=t.components)==null?void 0:n[l])!==((c=e.components)==null?void 0:c[l])}))return false}return !(t.rehypePlugins!==e.rehypePlugins||t.remarkPlugins!==e.remarkPlugins)});Ye.displayName="Block";var lo=t=>Array.isArray(t)&&t.some(e=>Array.isArray(e)?typeof e[0]=="function"&&e[0].name==="remarkMath":typeof e=="function"&&e.name==="remarkMath"),io=t=>{if(!Array.isArray(t))return false;let e=t.find(o=>Array.isArray(o)?o[0]===G:o===G);return e&&Array.isArray(e)&&e[1]?e[1].singleDollarTextMath===true:false},co=(t,e)=>{let o=t.includes("$$"),s=e&&(Qt.test(t)||Zt.test(t)||eo.test(t));return o||s},mo=/^\^/,po=()=>{var o,s;let t=((s=(o=_e.dependencies.katex)==null?void 0:o.replace(mo,""))==null?void 0:s.split(".").slice(0,3).join("."))||"0.16.22",e=document.createElement("link");e.rel="stylesheet",e.href=`https://cdn.jsdelivr.net/npm/katex@${t}/dist/katex.min.css`,document.head.appendChild(e);},uo=memo(({children:t,mode:e="streaming",parseIncompleteMarkdown:o=true,components:s,rehypePlugins:l=so,remarkPlugins:n=no,className:c,controls:r=true,isAnimating:a$1=false,BlockComponent:d=Ye,parseMarkdownIntoBlocksFn:i=U,caret:m,...u})=>{let b=useId(),[f,y]=useTransition(),[k,x]=useState([]),C=useMemo(()=>typeof t!="string"?"":e==="streaming"&&o?Yt(t):t,[t,e,o]),T=useMemo(()=>i(C),[C,i]);useEffect(()=>{e==="streaming"?y(()=>{x(T);}):x(T);},[T,e]);let D=e==="streaming"?k:T,$=useMemo(()=>D.map((J,N)=>`${b}-${N}`),[D.length,b]),Y=useMemo(()=>({controls:r,isAnimating:a$1,mode:e}),[r,a$1,e]),Q=useMemo(()=>({...Xe,...s}),[s]);useEffect(()=>{if(!lo(n))return;let N=io(n);co(typeof t=="string"?t:"",N)&&po();},[n,t]);let Qe=useMemo(()=>m&&a$1?{"--streamdown-caret":`"${ro[m]}"`}:void 0,[m,a$1]);return e==="static"?jsx(v.Provider,{value:Y,children:jsx("div",{className:a("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",c),children:jsx(K,{components:Q,rehypePlugins:l,remarkPlugins:n,...u,children:t})})}):jsx(v.Provider,{value:Y,children:jsx("div",{className:a("space-y-4 whitespace-normal *:first:mt-0 *:last:mb-0",m?"*:last:after:inline *:last:after:align-baseline *:last:after:content-(--streamdown-caret)":null,c),style:Qe,children:D.map((J,N)=>jsx(d,{components:Q,content:J,index:N,rehypePlugins:l,remarkPlugins:n,shouldParseIncompleteMarkdown:o,...u},$[N]))})})},(t,e)=>t.children===e.children&&t.isAnimating===e.isAnimating&&t.mode===e.mode);uo.displayName="Streamdown";
|
|
11
|
+
export{Ye as Block,uo as Streamdown,v as StreamdownContext,to as defaultRehypePlugins,oo as defaultRemarkPlugins,Ls as getClientRehypePlugins,U as parseMarkdownIntoBlocks};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var react=require('react'),f=require('katex'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var f__default=/*#__PURE__*/_interopDefault(f);var t=react.memo(({math:e,display:r=false,className:o})=>{let n=react.useRef(null);return react.useEffect(()=>{if(n.current&&e)try{f__default.default.render(e,n.current,{displayMode:r,throwOnError:!1,errorColor:"var(--color-muted-foreground, #6b7280)",trust:!1,strict:!1});}catch(l){n.current&&(n.current.textContent=r?`$$${e}$$`:`$${e}$`);}},[e,r]),jsxRuntime.jsx("span",{ref:n,className:o,"data-math":r?"block":"inline",suppressHydrationWarning:true,children:r?`$$${e}$$`:`$${e}$`})});t.displayName="MathRenderer";var d=t;exports.MathRenderer=t;exports.default=d;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {memo,useRef,useEffect}from'react';import f from'katex';import {jsx}from'react/jsx-runtime';var t=memo(({math:e,display:r=false,className:o})=>{let n=useRef(null);return useEffect(()=>{if(n.current&&e)try{f.render(e,n.current,{displayMode:r,throwOnError:!1,errorColor:"var(--color-muted-foreground, #6b7280)",trust:!1,strict:!1});}catch(l){n.current&&(n.current.textContent=r?`$$${e}$$`:`$${e}$`);}},[e,r]),jsx("span",{ref:n,className:o,"data-math":r?"block":"inline",suppressHydrationWarning:true,children:r?`$$${e}$$`:`$${e}$`})});t.displayName="MathRenderer";var d=t;export{t as MathRenderer,d as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var react=require('react'),f=require('katex'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var f__default=/*#__PURE__*/_interopDefault(f);var t=react.memo(({math:e,display:r=false,className:o})=>{let n=react.useRef(null);return react.useEffect(()=>{if(n.current&&e)try{f__default.default.render(e,n.current,{displayMode:r,throwOnError:!1,errorColor:"var(--color-muted-foreground, #6b7280)",trust:!1,strict:!1});}catch(l){n.current&&(n.current.textContent=r?`$$${e}$$`:`$${e}$`);}},[e,r]),jsxRuntime.jsx("span",{ref:n,className:o,"data-math":r?"block":"inline",suppressHydrationWarning:true,children:r?`$$${e}$$`:`$${e}$`})});t.displayName="MathRenderer";var d=t;exports.MathRenderer=t;exports.default=d;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {memo,useRef,useEffect}from'react';import f from'katex';import {jsx}from'react/jsx-runtime';var t=memo(({math:e,display:r=false,className:o})=>{let n=useRef(null);return useEffect(()=>{if(n.current&&e)try{f.render(e,n.current,{displayMode:r,throwOnError:!1,errorColor:"var(--color-muted-foreground, #6b7280)",trust:!1,strict:!1});}catch(l){n.current&&(n.current.textContent=r?`$$${e}$$`:`$${e}$`);}},[e,r]),jsx("span",{ref:n,className:o,"data-math":r?"block":"inline",suppressHydrationWarning:true,children:r?`$$${e}$$`:`$${e}$`})});t.displayName="MathRenderer";var d=t;export{t as MathRenderer,d as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@echoease/streamdown-edge",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -44,10 +44,13 @@
|
|
|
44
44
|
"hast": "^1.0.0",
|
|
45
45
|
"hast-util-to-jsx-runtime": "^2.3.6",
|
|
46
46
|
"html-url-attributes": "^3.0.1",
|
|
47
|
+
"katex": "^0.16.22",
|
|
47
48
|
"lucide-react": "^0.560.0",
|
|
48
49
|
"marked": "^17.0.1",
|
|
49
50
|
"prism-react-renderer": "^2.4.1",
|
|
51
|
+
"rehype-harden": "^1.1.7",
|
|
50
52
|
"rehype-katex": "^7.0.1",
|
|
53
|
+
"rehype-raw": "^7.0.0",
|
|
51
54
|
"rehype-sanitize": "^6.0.0",
|
|
52
55
|
"remark-cjk-friendly": "^1.2.3",
|
|
53
56
|
"remark-cjk-friendly-gfm-strikethrough": "^1.2.3",
|