streamdown 1.1.5 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +13 -0
- package/README.md +8 -5
- package/dist/index.cjs +7 -4
- package/dist/index.js +7 -4
- package/package.json +8 -8
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Vercel, Inc.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -17,8 +17,8 @@ Streamdown powers the [AI Elements Response](https://ai-sdk.dev/elements/compone
|
|
|
17
17
|
- 🎨 **Unterminated block parsing** - Styles incomplete bold, italic, code, links, and headings
|
|
18
18
|
- 📊 **GitHub Flavored Markdown** - Tables, task lists, and strikethrough support
|
|
19
19
|
- 🔢 **Math rendering** - LaTeX equations via KaTeX
|
|
20
|
+
- 📈 **Mermaid diagrams** - Render Mermaid diagrams as code blocks with a button to render them
|
|
20
21
|
- 🎯 **Code syntax highlighting** - Beautiful code blocks with Shiki
|
|
21
|
-
- 📈 **Mermaid diagrams** - Render flowcharts, sequence diagrams, and more
|
|
22
22
|
- 🛡️ **Security-first** - Built on harden-react-markdown for safe rendering
|
|
23
23
|
- ⚡ **Performance optimized** - Memoized rendering for efficient updates
|
|
24
24
|
|
|
@@ -28,7 +28,7 @@ Streamdown powers the [AI Elements Response](https://ai-sdk.dev/elements/compone
|
|
|
28
28
|
npm i streamdown
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
Then, update your Tailwind `globals.css` to include the following
|
|
31
|
+
Then, update your Tailwind `globals.css` to include the following.
|
|
32
32
|
|
|
33
33
|
```css
|
|
34
34
|
@source "../node_modules/streamdown/dist/index.js";
|
|
@@ -45,7 +45,7 @@ import { Streamdown } from 'streamdown';
|
|
|
45
45
|
|
|
46
46
|
export default function Page() {
|
|
47
47
|
const markdown = "# Hello World\n\nThis is **streaming** markdown!";
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
return <Streamdown>{markdown}</Streamdown>;
|
|
50
50
|
}
|
|
51
51
|
```
|
|
@@ -76,14 +76,14 @@ sequenceDiagram
|
|
|
76
76
|
participant User
|
|
77
77
|
participant API
|
|
78
78
|
participant Database
|
|
79
|
-
|
|
79
|
+
|
|
80
80
|
User->>API: Request data
|
|
81
81
|
API->>Database: Query
|
|
82
82
|
Database-->>API: Results
|
|
83
83
|
API-->>User: Response
|
|
84
84
|
\`\`\`
|
|
85
85
|
`;
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
return <Streamdown>{markdown}</Streamdown>;
|
|
88
88
|
}
|
|
89
89
|
```
|
|
@@ -165,6 +165,9 @@ Streamdown is built as a monorepo with:
|
|
|
165
165
|
# Install dependencies
|
|
166
166
|
pnpm install
|
|
167
167
|
|
|
168
|
+
# Build the streamdown package
|
|
169
|
+
pnpm --filter streamdown build
|
|
170
|
+
|
|
168
171
|
# Run development server
|
|
169
172
|
pnpm dev
|
|
170
173
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
"use strict";"use client";var j=Object.create;var $=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var ne=(e,t)=>{for(var r in t)$(e,r,{get:t[r],enumerable:!0})},A=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ee(t))!re.call(e,o)&&o!==r&&$(e,o,{get:()=>t[o],enumerable:!(n=x(t,o))||n.enumerable});return e};var M=(e,t,r)=>(r=e!=null?j(te(e)):{},A(t||!e||!e.__esModule?$(r,"default",{value:e,enumerable:!0}):r,e)),oe=e=>A($({},"__esModule",{value:!0}),e);var Ee={};ne(Ee,{ShikiThemeContext:()=>P,Streamdown:()=>Y});module.exports=oe(Ee);var h=require("react"),G=M(require("react-markdown"),1),F=M(require("rehype-katex"),1),J=M(require("remark-gfm"),1),Q=M(require("remark-math"),1),je=require("katex/dist/katex.min.css"),H=M(require("harden-react-markdown"),1);var U=require("react");var B=require("lucide-react"),m=require("react"),N=require("shiki");var _=require("clsx"),R=require("tailwind-merge"),s=(...e)=>(0,R.twMerge)((0,_.clsx)(e));var k=require("react/jsx-runtime"),D=(0,m.createContext)({code:""});async function se(e,t,r){return Promise.all([await(0,N.codeToHtml)(e,{lang:t,theme:r[0]}),await(0,N.codeToHtml)(e,{lang:t,theme:r[1]})])}var K=({code:e,language:t,className:r,children:n,...o})=>{let[i,d]=(0,m.useState)(""),[c,l]=(0,m.useState)(""),u=(0,m.useRef)(!1),[g,y]=(0,m.useContext)(P);return(0,m.useEffect)(()=>(se(e,t,[g,y]).then(([f,b])=>{u.current||(d(f),l(b),u.current=!0)}),()=>{u.current=!1}),[e,t,g,y]),(0,k.jsx)(D.Provider,{value:{code:e},children:(0,k.jsxs)("div",{className:"group relative",children:[(0,k.jsx)("div",{className:s("overflow-x-auto dark:hidden [&>pre]:bg-transparent!",r),dangerouslySetInnerHTML:{__html:i},...o}),(0,k.jsx)("div",{className:s("hidden overflow-x-auto dark:block [&>pre]:bg-transparent!",r),dangerouslySetInnerHTML:{__html:c},...o}),n]})})},S=({onCopy:e,onError:t,timeout:r=2e3,children:n,className:o,code:i,...d})=>{let[c,l]=(0,m.useState)(!1),u=(0,m.useContext)(D).code,g=i!=null?i:u,y=async()=>{var b;if(typeof window=="undefined"||!((b=navigator==null?void 0:navigator.clipboard)!=null&&b.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{await navigator.clipboard.writeText(g),l(!0),e==null||e(),setTimeout(()=>l(!1),r)}catch(w){t==null||t(w)}},f=c?B.CheckIcon:B.CopyIcon;return(0,k.jsx)("button",{className:s("absolute top-2 right-2 shrink-0 rounded-md p-3 opacity-0 transition-all","hover:bg-secondary group-hover:opacity-100",o),onClick:y,type:"button",...d,children:n!=null?n:(0,k.jsx)(f,{size:14})})};var C=require("react");var p=require("react/jsx-runtime"),E=!1,ae=async()=>{if(!E){let r=(await import("mermaid")).default;return r.initialize({startOnLoad:!1,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:!0}),E=!0,r}return(await import("mermaid")).default},O=({chart:e,className:t})=>{let[r,n]=(0,C.useState)(null),[o,i]=(0,C.useState)(!0),[d,c]=(0,C.useState)(""),[l,u]=(0,C.useState)("");if((0,C.useEffect)(()=>{(async()=>{try{n(null),i(!0);let f=await ae(),b=e.split("").reduce((L,Z)=>(L<<5)-L+Z.charCodeAt(0)|0,0),w=`mermaid-${Math.abs(b)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:T}=await f.render(w,e);c(T),u(T)}catch(f){if(!(l||d)){let b=f instanceof Error?f.message:"Failed to render Mermaid chart";n(b)}}finally{i(!1)}})()},[e]),o&&!d&&!l)return(0,p.jsx)("div",{className:s("my-4 flex justify-center p-4",t),children:(0,p.jsxs)("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[(0,p.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),(0,p.jsx)("span",{className:"text-sm",children:"Loading diagram..."})]})});if(r&&!d&&!l)return(0,p.jsxs)("div",{className:s("rounded-lg border border-red-200 bg-red-50 p-4",t),children:[(0,p.jsxs)("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",r]}),(0,p.jsxs)("details",{className:"mt-2",children:[(0,p.jsx)("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),(0,p.jsx)("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]});let g=d||l;return(0,p.jsx)("div",{"aria-label":"Mermaid chart",className:s("my-4 flex justify-center",t),dangerouslySetInnerHTML:{__html:g},role:"img"})};var a=require("react/jsx-runtime"),ie=/language-([^\s]+)/,de=({node:e,className:t,children:r,...n})=>{var l,u,g;if(((l=e==null?void 0:e.position)==null?void 0:l.start.line)===((u=e==null?void 0:e.position)==null?void 0:u.end.line))return(0,a.jsx)("code",{className:s("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:r});let i=t==null?void 0:t.match(ie),d=(g=i==null?void 0:i.at(1))!=null?g:"plaintext",c="";return(0,U.isValidElement)(r)&&r.props&&typeof r.props=="object"&&"children"in r.props&&typeof r.props.children=="string"?c=r.props.children:typeof r=="string"&&(c=r),d==="mermaid"?(0,a.jsxs)("div",{className:s("group relative my-4 h-auto rounded-lg border p-4",t),"data-streamdown":"mermaid-block",children:[(0,a.jsx)(O,{chart:c}),(0,a.jsx)(S,{code:c})]}):(0,a.jsx)(K,{className:s("my-4 h-auto rounded-lg border p-4",t),code:c,"data-language":d,"data-streamdown":"code-block",language:d,children:(0,a.jsx)(S,{})})},q={ol:({node:e,children:t,className:r,...n})=>(0,a.jsx)("ol",{className:s("ml-4 list-outside list-decimal",r),"data-streamdown":"ordered-list",...n,children:t}),li:({node:e,children:t,className:r,...n})=>(0,a.jsx)("li",{className:s("py-1",r),"data-streamdown":"list-item",...n,children:t}),ul:({node:e,children:t,className:r,...n})=>(0,a.jsx)("ul",{className:s("ml-4 list-outside list-disc",r),"data-streamdown":"unordered-list",...n,children:t}),hr:({node:e,className:t,...r})=>(0,a.jsx)("hr",{className:s("my-6 border-border",t),"data-streamdown":"horizontal-rule",...r}),strong:({node:e,children:t,className:r,...n})=>(0,a.jsx)("span",{className:s("font-semibold",r),"data-streamdown":"strong",...n,children:t}),a:({node:e,children:t,className:r,href:n,...o})=>(0,a.jsx)("a",{className:s("font-medium text-primary underline",r),"data-streamdown":"link",href:n,rel:"noreferrer",target:"_blank",...o,children:t}),h1:({node:e,children:t,className:r,...n})=>(0,a.jsx)("h1",{className:s("mt-6 mb-2 font-semibold text-3xl",r),"data-streamdown":"heading-1",...n,children:t}),h2:({node:e,children:t,className:r,...n})=>(0,a.jsx)("h2",{className:s("mt-6 mb-2 font-semibold text-2xl",r),"data-streamdown":"heading-2",...n,children:t}),h3:({node:e,children:t,className:r,...n})=>(0,a.jsx)("h3",{className:s("mt-6 mb-2 font-semibold text-xl",r),"data-streamdown":"heading-3",...n,children:t}),h4:({node:e,children:t,className:r,...n})=>(0,a.jsx)("h4",{className:s("mt-6 mb-2 font-semibold text-lg",r),"data-streamdown":"heading-4",...n,children:t}),h5:({node:e,children:t,className:r,...n})=>(0,a.jsx)("h5",{className:s("mt-6 mb-2 font-semibold text-base",r),"data-streamdown":"heading-5",...n,children:t}),h6:({node:e,children:t,className:r,...n})=>(0,a.jsx)("h6",{className:s("mt-6 mb-2 font-semibold text-sm",r),"data-streamdown":"heading-6",...n,children:t}),table:({node:e,children:t,className:r,...n})=>(0,a.jsx)("div",{className:"my-4 overflow-x-auto","data-streamdown":"table-wrapper",children:(0,a.jsx)("table",{className:s("w-full border-collapse border border-border",r),"data-streamdown":"table",...n,children:t})}),thead:({node:e,children:t,className:r,...n})=>(0,a.jsx)("thead",{className:s("bg-muted/50",r),"data-streamdown":"table-header",...n,children:t}),tbody:({node:e,children:t,className:r,...n})=>(0,a.jsx)("tbody",{className:s("divide-y divide-border",r),"data-streamdown":"table-body",...n,children:t}),tr:({node:e,children:t,className:r,...n})=>(0,a.jsx)("tr",{className:s("border-border border-b",r),"data-streamdown":"table-row",...n,children:t}),th:({node:e,children:t,className:r,...n})=>(0,a.jsx)("th",{className:s("px-4 py-2 text-left font-semibold text-sm",r),"data-streamdown":"table-header-cell",...n,children:t}),td:({node:e,children:t,className:r,...n})=>(0,a.jsx)("td",{className:s("px-4 py-2 text-sm",r),"data-streamdown":"table-cell",...n,children:t}),blockquote:({node:e,children:t,className:r,...n})=>(0,a.jsx)("blockquote",{className:s("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",r),"data-streamdown":"blockquote",...n,children:t}),code:de,pre:({children:e})=>e,sup:({node:e,children:t,className:r,...n})=>(0,a.jsx)("sup",{className:s("text-sm",r),"data-streamdown":"superscript",...n,children:t}),sub:({node:e,children:t,className:r,...n})=>(0,a.jsx)("sub",{className:s("text-sm",r),"data-streamdown":"subscript",...n,children:t})};var z=require("marked"),V=e=>z.marked.use({gfm:!0}).lexer(e).map(r=>r.raw);var le=/(!?\[)([^\]]*?)$/,ce=/(\*\*)([^*]*?)$/,me=/(__)([^_]*?)$/,ue=/(\*\*\*)([^*]*?)$/,pe=/(\*)([^*]*?)$/,ge=/(_)([^_]*?)$/,he=/(`)([^`]*?)$/,fe=/(~~)([^~]*?)$/,be=/(\$)([^$]*?)$/,ke=/(\$\$)([^$]*?)$/,v=e=>{let t=(e.match(/```/g)||[]).length;return t>0&&t%2===0&&e.includes(`
|
|
2
|
-
`)},
|
|
3
|
-
`){d
|
|
1
|
+
"use strict";"use client";var te=Object.create;var B=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var ae=(e,t)=>{for(var r in t)B(e,r,{get:t[r],enumerable:!0})},_=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ne(t))!se.call(e,o)&&o!==r&&B(e,o,{get:()=>t[o],enumerable:!(n=re(t,o))||n.enumerable});return e};var v=(e,t,r)=>(r=e!=null?te(oe(e)):{},_(t||!e||!e.__esModule?B(r,"default",{value:e,enumerable:!0}):r,e)),ie=e=>_(B({},"__esModule",{value:!0}),e);var We={};ae(We,{ShikiThemeContext:()=>N,Streamdown:()=>Z});module.exports=ie(We);var b=require("react"),F=v(require("react-markdown"),1),X=v(require("rehype-katex"),1),J=v(require("remark-gfm"),1),Q=v(require("remark-math"),1),Ye=require("katex/dist/katex.min.css"),A=v(require("harden-react-markdown"),1);var G=require("react");var I=require("lucide-react"),p=require("react"),P=require("shiki"),W=require("shiki/engine/javascript");var E=require("clsx"),R=require("tailwind-merge"),s=(...e)=>(0,R.twMerge)((0,E.clsx)(e));var h=require("react/jsx-runtime"),le=/<pre(\s|>)/,O=(0,p.createContext)({code:""}),g={light:null,dark:null,lightTheme:null,darkTheme:null};async function de(e,t,r,n){let o=m=>n?m.replace(le,`<pre class="${n}"$1`):m,a=(0,W.createJavaScriptRegexEngine)({forgiving:!0}),[i,c]=r;!g.light||g.lightTheme!==i?(g.light=await(0,P.createHighlighter)({themes:[i],langs:[t],engine:a}),g.lightTheme=i):await g.light.loadLanguage(t),!g.dark||g.darkTheme!==c?(g.dark=await(0,P.createHighlighter)({themes:[c],langs:[t],engine:a}),g.darkTheme=c):await g.dark.loadLanguage(t);let d=g.light.codeToHtml(e,{lang:t,theme:i}),u=g.dark.codeToHtml(e,{lang:t,theme:c});return[D(o(d)),D(o(u))]}function D(e){return e.replace(/(<pre[^>]*)(style="[^"]*background[^";]*;?[^"]*")([^>]*>)/g,"$1$3")}var U=({code:e,language:t,className:r,children:n,preClassName:o,...a})=>{let[i,c]=(0,p.useState)(""),[d,u]=(0,p.useState)(""),m=(0,p.useRef)(!1),[w,k]=(0,p.useContext)(N);return(0,p.useEffect)(()=>(m.current=!0,de(e,t,[w,k],o).then(([y,M])=>{m.current&&(c(y),u(M))}),()=>{m.current=!1}),[e,t,w,k,o]),(0,h.jsx)(O.Provider,{value:{code:e},children:(0,h.jsxs)("div",{className:"my-4 w-full overflow-hidden rounded-xl border",children:[(0,h.jsxs)("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs",children:[(0,h.jsx)("span",{className:"ml-1 font-mono lowercase",children:t}),(0,h.jsx)("div",{children:n})]}),(0,h.jsx)("div",{className:"w-full",children:(0,h.jsxs)("div",{className:"min-w-full",children:[(0,h.jsx)("div",{className:s("overflow-x-auto dark:hidden",r),dangerouslySetInnerHTML:{__html:i},...a}),(0,h.jsx)("div",{className:s("hidden overflow-x-auto dark:block",r),dangerouslySetInnerHTML:{__html:d},...a})]})})]})})},H=({onCopy:e,onError:t,timeout:r=2e3,children:n,className:o,code:a,...i})=>{let[c,d]=(0,p.useState)(!1),u=(0,p.useContext)(O).code,m=a!=null?a:u,w=async()=>{var y;if(typeof window=="undefined"||!((y=navigator==null?void 0:navigator.clipboard)!=null&&y.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{await navigator.clipboard.writeText(m),d(!0),e==null||e(),setTimeout(()=>d(!1),r)}catch(M){t==null||t(M)}},k=c?I.CheckIcon:I.CopyIcon;return(0,h.jsx)("button",{className:s("text-muted-foreground","p-1 transition-all",o),onClick:w,type:"button",...i,children:n!=null?n:(0,h.jsx)(k,{size:14})})};var C=require("react");var f=require("react/jsx-runtime"),q=!1,ce=async()=>{if(!q){let r=(await import("mermaid")).default;return r.initialize({startOnLoad:!1,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:!0}),q=!0,r}return(await import("mermaid")).default},x=({chart:e,className:t})=>{let[r,n]=(0,C.useState)(null),[o,a]=(0,C.useState)(!0),[i,c]=(0,C.useState)(""),[d,u]=(0,C.useState)("");if((0,C.useEffect)(()=>{(async()=>{try{n(null),a(!0);let k=await ce(),y=e.split("").reduce((L,ee)=>(L<<5)-L+ee.charCodeAt(0)|0,0),M=`mermaid-${Math.abs(y)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:T}=await k.render(M,e);c(T),u(T)}catch(k){if(!(d||i)){let y=k instanceof Error?k.message:"Failed to render Mermaid chart";n(y)}}finally{a(!1)}})()},[e]),o&&!i&&!d)return(0,f.jsx)("div",{className:s("my-4 flex justify-center p-4",t),children:(0,f.jsxs)("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[(0,f.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),(0,f.jsx)("span",{className:"text-sm",children:"Loading diagram..."})]})});if(r&&!i&&!d)return(0,f.jsxs)("div",{className:s("rounded-lg border border-red-200 bg-red-50 p-4",t),children:[(0,f.jsxs)("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",r]}),(0,f.jsxs)("details",{className:"mt-2",children:[(0,f.jsx)("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),(0,f.jsx)("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]});let m=i||d;return(0,f.jsx)("div",{"aria-label":"Mermaid chart",className:s("my-4 flex justify-center",t),dangerouslySetInnerHTML:{__html:m},role:"img"})};var l=require("react/jsx-runtime"),me=/language-([^\s]+)/,ue=({node:e,className:t,children:r,...n})=>{var d,u,m;if(((d=e==null?void 0:e.position)==null?void 0:d.start.line)===((u=e==null?void 0:e.position)==null?void 0:u.end.line))return(0,l.jsx)("code",{className:s("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:r});let a=t==null?void 0:t.match(me),i=(m=a==null?void 0:a.at(1))!=null?m:"",c="";return(0,G.isValidElement)(r)&&r.props&&typeof r.props=="object"&&"children"in r.props&&typeof r.props.children=="string"?c=r.props.children:typeof r=="string"&&(c=r),i==="mermaid"?(0,l.jsxs)("div",{className:s("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[(0,l.jsx)("div",{className:"flex items-center justify-end",children:(0,l.jsx)(H,{code:c})}),(0,l.jsx)(x,{chart:c})]}):(0,l.jsx)(U,{className:s("overflow-x-auto border-t",t),code:c,"data-language":i,"data-streamdown":"code-block",language:i,preClassName:"overflow-x-auto font-mono text-xs p-4 bg-muted/40",children:(0,l.jsx)(H,{})})},K={ol:({node:e,children:t,className:r,...n})=>(0,l.jsx)("ol",{className:s("ml-4 list-outside list-decimal",r),"data-streamdown":"ordered-list",...n,children:t}),li:({node:e,children:t,className:r,...n})=>(0,l.jsx)("li",{className:s("py-1",r),"data-streamdown":"list-item",...n,children:t}),ul:({node:e,children:t,className:r,...n})=>(0,l.jsx)("ul",{className:s("ml-4 list-outside list-disc",r),"data-streamdown":"unordered-list",...n,children:t}),hr:({node:e,className:t,...r})=>(0,l.jsx)("hr",{className:s("my-6 border-border",t),"data-streamdown":"horizontal-rule",...r}),strong:({node:e,children:t,className:r,...n})=>(0,l.jsx)("span",{className:s("font-semibold",r),"data-streamdown":"strong",...n,children:t}),a:({node:e,children:t,className:r,href:n,...o})=>(0,l.jsx)("a",{className:s("font-medium text-primary underline",r),"data-streamdown":"link",href:n,rel:"noreferrer",target:"_blank",...o,children:t}),h1:({node:e,children:t,className:r,...n})=>(0,l.jsx)("h1",{className:s("mt-6 mb-2 font-semibold text-3xl",r),"data-streamdown":"heading-1",...n,children:t}),h2:({node:e,children:t,className:r,...n})=>(0,l.jsx)("h2",{className:s("mt-6 mb-2 font-semibold text-2xl",r),"data-streamdown":"heading-2",...n,children:t}),h3:({node:e,children:t,className:r,...n})=>(0,l.jsx)("h3",{className:s("mt-6 mb-2 font-semibold text-xl",r),"data-streamdown":"heading-3",...n,children:t}),h4:({node:e,children:t,className:r,...n})=>(0,l.jsx)("h4",{className:s("mt-6 mb-2 font-semibold text-lg",r),"data-streamdown":"heading-4",...n,children:t}),h5:({node:e,children:t,className:r,...n})=>(0,l.jsx)("h5",{className:s("mt-6 mb-2 font-semibold text-base",r),"data-streamdown":"heading-5",...n,children:t}),h6:({node:e,children:t,className:r,...n})=>(0,l.jsx)("h6",{className:s("mt-6 mb-2 font-semibold text-sm",r),"data-streamdown":"heading-6",...n,children:t}),table:({node:e,children:t,className:r,...n})=>(0,l.jsx)("div",{className:"my-4 overflow-x-auto","data-streamdown":"table-wrapper",children:(0,l.jsx)("table",{className:s("w-full border-collapse border border-border",r),"data-streamdown":"table",...n,children:t})}),thead:({node:e,children:t,className:r,...n})=>(0,l.jsx)("thead",{className:s("bg-muted/50",r),"data-streamdown":"table-header",...n,children:t}),tbody:({node:e,children:t,className:r,...n})=>(0,l.jsx)("tbody",{className:s("divide-y divide-border",r),"data-streamdown":"table-body",...n,children:t}),tr:({node:e,children:t,className:r,...n})=>(0,l.jsx)("tr",{className:s("border-border border-b",r),"data-streamdown":"table-row",...n,children:t}),th:({node:e,children:t,className:r,...n})=>(0,l.jsx)("th",{className:s("px-4 py-2 text-left font-semibold text-sm",r),"data-streamdown":"table-header-cell",...n,children:t}),td:({node:e,children:t,className:r,...n})=>(0,l.jsx)("td",{className:s("px-4 py-2 text-sm",r),"data-streamdown":"table-cell",...n,children:t}),blockquote:({node:e,children:t,className:r,...n})=>(0,l.jsx)("blockquote",{className:s("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",r),"data-streamdown":"blockquote",...n,children:t}),code:ue,pre:({children:e})=>e,sup:({node:e,children:t,className:r,...n})=>(0,l.jsx)("sup",{className:s("text-sm",r),"data-streamdown":"superscript",...n,children:t}),sub:({node:e,children:t,className:r,...n})=>(0,l.jsx)("sub",{className:s("text-sm",r),"data-streamdown":"subscript",...n,children:t})};var z=require("marked"),V=e=>{let r=z.marked.use({gfm:!0}).lexer(e).map(o=>o.raw),n=[];for(let o=0;o<r.length;o++){let a=r[o];if(a.trim()==="$$"&&n.length>0){let i=n[n.length-1],c=i.trimStart().startsWith("$$"),d=(i.match(/\$\$/g)||[]).length;if(c&&d%2===1){n[n.length-1]=i+a;continue}}if(n.length>0&&a.trimEnd().endsWith("$$")){let i=n[n.length-1],c=i.trimStart().startsWith("$$"),d=(i.match(/\$\$/g)||[]).length,u=(a.match(/\$\$/g)||[]).length;if(c&&d%2===1&&!a.trimStart().startsWith("$$")&&u===1){n[n.length-1]=i+a;continue}}n.push(a)}return n};var he=/(!?\[)([^\]]*?)$/,pe=/(\*\*)([^*]*?)$/,ge=/(__)([^_]*?)$/,fe=/(\*\*\*)([^*]*?)$/,ke=/(\*)([^*]*?)$/,be=/(_)([^_]*?)$/,ye=/(`)([^`]*?)$/,we=/(~~)([^~]*?)$/;var S=e=>{let t=(e.match(/```/g)||[]).length;return t>0&&t%2===0&&e.includes(`
|
|
2
|
+
`)},Me=e=>{let t=e.match(he);if(t){let r=e.lastIndexOf(t[1]);return e.substring(0,r)}return e},ve=e=>S(e)?e:e.match(pe)&&(e.match(/\*\*/g)||[]).length%2===1?`${e}**`:e,Ce=e=>e.match(ge)&&(e.match(/__/g)||[]).length%2===1?`${e}__`:e,$e=e=>e.split("").reduce((t,r,n)=>{if(r==="*"){let o=e[n-1],a=e[n+1];if(o==="\\")return t;let i=n;for(let d=n-1;d>=0;d--){if(e[d]===`
|
|
3
|
+
`){i=d+1;break}if(d===0){i=0;break}}if(e.substring(i,n).trim()===""&&(a===" "||a===" "))return t;if(o!=="*"&&a!=="*")return t+1}return t},0),Te=e=>S(e)?e:e.match(ke)&&$e(e)%2===1?`${e}*`:e,Be=(e,t)=>{let r=!1,n=!1;for(let o=0;o<e.length&&o<t;o++){if(e[o]==="\\"&&e[o+1]==="$"){o++;continue}e[o]==="$"&&(e[o+1]==="$"?(n=!n,o++,r=!1):n||(r=!r))}return r||n},Ie=e=>e.split("").reduce((t,r,n)=>{if(r==="_"){let o=e[n-1],a=e[n+1];if(o==="\\"||Be(e,n))return t;if(o!=="_"&&a!=="_")return t+1}return t},0),Ne=e=>S(e)?e:e.match(be)&&Ie(e)%2===1?`${e}_`:e,Se=(e,t)=>{let r=e.substring(t,t+3)==="```",n=t>0&&e.substring(t-1,t+2)==="```",o=t>1&&e.substring(t-2,t+1)==="```";return r||n||o},Pe=e=>{let t=0;for(let r=0;r<e.length;r++)e[r]==="`"&&!Se(e,r)&&t++;return t},He=e=>{if(e.match(/^```[^`\n]*```?$/)&&!e.includes(`
|
|
4
4
|
`))return e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e;let r=(e.match(/```/g)||[]).length,n=r%2===1;return r>0&&r%2===0&&e.includes(`
|
|
5
|
-
`)||(e.endsWith("```\n")||e.endsWith("```"))&&r%2===0?e:e.match(
|
|
5
|
+
`)||(e.endsWith("```\n")||e.endsWith("```"))&&r%2===0?e:e.match(ye)&&!n&&Pe(e)%2===1?`${e}\``:e},Ae=e=>e.match(we)&&(e.match(/~~/g)||[]).length%2===1?`${e}~~`:e;var Le=e=>{if((e.match(/\$\$/g)||[]).length%2===0)return e;let r=e.indexOf("$$");return r!==-1&&e.indexOf(`
|
|
6
|
+
`,r)!==-1&&!e.endsWith(`
|
|
7
|
+
`)?`${e}
|
|
8
|
+
$$`:`${e}$$`};var _e=e=>{let t=0,r=e.match(/\*+/g)||[];for(let n of r){let o=n.length;o>=3&&(t+=Math.floor(o/3))}return t},Ee=e=>S(e)||/^\*{4,}$/.test(e)?e:e.match(fe)&&_e(e)%2===1?`${e}***`:e,j=e=>{if(!e||typeof e!="string")return e;let t=e;return t=Me(t),t=Ee(t),t=ve(t),t=Ce(t),t=Te(t),t=Ne(t),t=He(t),t=Ae(t),t=Le(t),t};var $=require("react/jsx-runtime"),Re=A.default.default||A.default,De=Re(F.default),N=(0,b.createContext)(["github-light","github-dark"]),Y=(0,b.memo)(({content:e,shouldParseIncompleteMarkdown:t,...r})=>{let n=(0,b.useMemo)(()=>typeof e=="string"&&t?j(e.trim()):e,[e,t]);return(0,$.jsx)(De,{...r,children:n})},(e,t)=>e.content===t.content);Y.displayName="Block";var Z=(0,b.memo)(({children:e,allowedImagePrefixes:t,allowedLinkPrefixes:r,defaultOrigin:n,parseIncompleteMarkdown:o=!0,components:a,rehypePlugins:i,remarkPlugins:c,className:d,shikiTheme:u=["github-light","github-dark"],...m})=>{let w=(0,b.useId)(),k=(0,b.useMemo)(()=>V(typeof e=="string"?e:""),[e]),y=(0,b.useMemo)(()=>()=>(0,X.default)({errorColor:"var(--color-muted-foreground)"}),[]);return(0,$.jsx)(N.Provider,{value:u,children:(0,$.jsx)("div",{className:s("space-y-4",d),...m,children:k.map((M,T)=>(0,$.jsx)(Y,{allowedImagePrefixes:t!=null?t:["*"],allowedLinkPrefixes:r!=null?r:["*"],components:{...K,...a},content:M,defaultOrigin:n,rehypePlugins:[y,...i!=null?i:[]],remarkPlugins:[J.default,[Q.default,{singleDollarTextMath:!1}],...c!=null?c:[]],shouldParseIncompleteMarkdown:o},`${w}-block_${T}`))})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme);Z.displayName="Streamdown";0&&(module.exports={ShikiThemeContext,Streamdown});
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
"use client";import{createContext as He,memo as
|
|
2
|
-
`)},
|
|
3
|
-
`){d
|
|
1
|
+
"use client";import{createContext as He,memo as x,useId as Ae,useMemo as S}from"react";import Le from"react-markdown";import _e from"rehype-katex";import Ee from"remark-gfm";import Re from"remark-math";import"katex/dist/katex.min.css";import q from"harden-react-markdown";import{isValidElement as ne}from"react";import{CheckIcon as j,CopyIcon as F}from"lucide-react";import{createContext as X,useContext as L,useEffect as J,useRef as Q,useState as B}from"react";import{createHighlighter as H}from"shiki";import{createJavaScriptRegexEngine as Y}from"shiki/engine/javascript";import{clsx as z}from"clsx";import{twMerge as V}from"tailwind-merge";var s=(...e)=>V(z(e));import{jsx as f,jsxs as T}from"react/jsx-runtime";var Z=/<pre(\s|>)/,_=X({code:""}),h={light:null,dark:null,lightTheme:null,darkTheme:null};async function ee(e,t,r,n){let o=m=>n?m.replace(Z,`<pre class="${n}"$1`):m,a=Y({forgiving:!0}),[i,c]=r;!h.light||h.lightTheme!==i?(h.light=await H({themes:[i],langs:[t],engine:a}),h.lightTheme=i):await h.light.loadLanguage(t),!h.dark||h.darkTheme!==c?(h.dark=await H({themes:[c],langs:[t],engine:a}),h.darkTheme=c):await h.dark.loadLanguage(t);let d=h.light.codeToHtml(e,{lang:t,theme:i}),u=h.dark.codeToHtml(e,{lang:t,theme:c});return[A(o(d)),A(o(u))]}function A(e){return e.replace(/(<pre[^>]*)(style="[^"]*background[^";]*;?[^"]*")([^>]*>)/g,"$1$3")}var E=({code:e,language:t,className:r,children:n,preClassName:o,...a})=>{let[i,c]=B(""),[d,u]=B(""),m=Q(!1),[k,p]=L(N);return J(()=>(m.current=!0,ee(e,t,[k,p],o).then(([g,b])=>{m.current&&(c(g),u(b))}),()=>{m.current=!1}),[e,t,k,p,o]),f(_.Provider,{value:{code:e},children:T("div",{className:"my-4 w-full overflow-hidden rounded-xl border",children:[T("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs",children:[f("span",{className:"ml-1 font-mono lowercase",children:t}),f("div",{children:n})]}),f("div",{className:"w-full",children:T("div",{className:"min-w-full",children:[f("div",{className:s("overflow-x-auto dark:hidden",r),dangerouslySetInnerHTML:{__html:i},...a}),f("div",{className:s("hidden overflow-x-auto dark:block",r),dangerouslySetInnerHTML:{__html:d},...a})]})})]})})},I=({onCopy:e,onError:t,timeout:r=2e3,children:n,className:o,code:a,...i})=>{let[c,d]=B(!1),u=L(_).code,m=a!=null?a:u,k=async()=>{var g;if(typeof window=="undefined"||!((g=navigator==null?void 0:navigator.clipboard)!=null&&g.writeText)){t==null||t(new Error("Clipboard API not available"));return}try{await navigator.clipboard.writeText(m),d(!0),e==null||e(),setTimeout(()=>d(!1),r)}catch(b){t==null||t(b)}},p=c?j:F;return f("button",{className:s("text-muted-foreground","p-1 transition-all",o),onClick:k,type:"button",...i,children:n!=null?n:f(p,{size:14})})};import{useEffect as te,useState as M}from"react";import{jsx as y,jsxs as v}from"react/jsx-runtime";var R=!1,re=async()=>{if(!R){let r=(await import("mermaid")).default;return r.initialize({startOnLoad:!1,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:!0}),R=!0,r}return(await import("mermaid")).default},D=({chart:e,className:t})=>{let[r,n]=M(null),[o,a]=M(!0),[i,c]=M(""),[d,u]=M("");if(te(()=>{(async()=>{try{n(null),a(!0);let p=await re(),g=e.split("").reduce((P,K)=>(P<<5)-P+K.charCodeAt(0)|0,0),b=`mermaid-${Math.abs(g)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:w}=await p.render(b,e);c(w),u(w)}catch(p){if(!(d||i)){let g=p instanceof Error?p.message:"Failed to render Mermaid chart";n(g)}}finally{a(!1)}})()},[e]),o&&!i&&!d)return y("div",{className:s("my-4 flex justify-center p-4",t),children:v("div",{className:"flex items-center space-x-2 text-muted-foreground",children:[y("div",{className:"h-4 w-4 animate-spin rounded-full border-current border-b-2"}),y("span",{className:"text-sm",children:"Loading diagram..."})]})});if(r&&!i&&!d)return v("div",{className:s("rounded-lg border border-red-200 bg-red-50 p-4",t),children:[v("p",{className:"font-mono text-red-700 text-sm",children:["Mermaid Error: ",r]}),v("details",{className:"mt-2",children:[y("summary",{className:"cursor-pointer text-red-600 text-xs",children:"Show Code"}),y("pre",{className:"mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs",children:e})]})]});let m=i||d;return y("div",{"aria-label":"Mermaid chart",className:s("my-4 flex justify-center",t),dangerouslySetInnerHTML:{__html:m},role:"img"})};import{jsx as l,jsxs as ae}from"react/jsx-runtime";var oe=/language-([^\s]+)/,se=({node:e,className:t,children:r,...n})=>{var d,u,m;if(((d=e==null?void 0:e.position)==null?void 0:d.start.line)===((u=e==null?void 0:e.position)==null?void 0:u.end.line))return l("code",{className:s("rounded bg-muted px-1.5 py-0.5 font-mono text-sm",t),"data-streamdown":"inline-code",...n,children:r});let a=t==null?void 0:t.match(oe),i=(m=a==null?void 0:a.at(1))!=null?m:"",c="";return ne(r)&&r.props&&typeof r.props=="object"&&"children"in r.props&&typeof r.props.children=="string"?c=r.props.children:typeof r=="string"&&(c=r),i==="mermaid"?ae("div",{className:s("group relative my-4 h-auto rounded-xl border p-4",t),"data-streamdown":"mermaid-block",children:[l("div",{className:"flex items-center justify-end",children:l(I,{code:c})}),l(D,{chart:c})]}):l(E,{className:s("overflow-x-auto border-t",t),code:c,"data-language":i,"data-streamdown":"code-block",language:i,preClassName:"overflow-x-auto font-mono text-xs p-4 bg-muted/40",children:l(I,{})})},W={ol:({node:e,children:t,className:r,...n})=>l("ol",{className:s("ml-4 list-outside list-decimal",r),"data-streamdown":"ordered-list",...n,children:t}),li:({node:e,children:t,className:r,...n})=>l("li",{className:s("py-1",r),"data-streamdown":"list-item",...n,children:t}),ul:({node:e,children:t,className:r,...n})=>l("ul",{className:s("ml-4 list-outside list-disc",r),"data-streamdown":"unordered-list",...n,children:t}),hr:({node:e,className:t,...r})=>l("hr",{className:s("my-6 border-border",t),"data-streamdown":"horizontal-rule",...r}),strong:({node:e,children:t,className:r,...n})=>l("span",{className:s("font-semibold",r),"data-streamdown":"strong",...n,children:t}),a:({node:e,children:t,className:r,href:n,...o})=>l("a",{className:s("font-medium text-primary underline",r),"data-streamdown":"link",href:n,rel:"noreferrer",target:"_blank",...o,children:t}),h1:({node:e,children:t,className:r,...n})=>l("h1",{className:s("mt-6 mb-2 font-semibold text-3xl",r),"data-streamdown":"heading-1",...n,children:t}),h2:({node:e,children:t,className:r,...n})=>l("h2",{className:s("mt-6 mb-2 font-semibold text-2xl",r),"data-streamdown":"heading-2",...n,children:t}),h3:({node:e,children:t,className:r,...n})=>l("h3",{className:s("mt-6 mb-2 font-semibold text-xl",r),"data-streamdown":"heading-3",...n,children:t}),h4:({node:e,children:t,className:r,...n})=>l("h4",{className:s("mt-6 mb-2 font-semibold text-lg",r),"data-streamdown":"heading-4",...n,children:t}),h5:({node:e,children:t,className:r,...n})=>l("h5",{className:s("mt-6 mb-2 font-semibold text-base",r),"data-streamdown":"heading-5",...n,children:t}),h6:({node:e,children:t,className:r,...n})=>l("h6",{className:s("mt-6 mb-2 font-semibold text-sm",r),"data-streamdown":"heading-6",...n,children:t}),table:({node:e,children:t,className:r,...n})=>l("div",{className:"my-4 overflow-x-auto","data-streamdown":"table-wrapper",children:l("table",{className:s("w-full border-collapse border border-border",r),"data-streamdown":"table",...n,children:t})}),thead:({node:e,children:t,className:r,...n})=>l("thead",{className:s("bg-muted/50",r),"data-streamdown":"table-header",...n,children:t}),tbody:({node:e,children:t,className:r,...n})=>l("tbody",{className:s("divide-y divide-border",r),"data-streamdown":"table-body",...n,children:t}),tr:({node:e,children:t,className:r,...n})=>l("tr",{className:s("border-border border-b",r),"data-streamdown":"table-row",...n,children:t}),th:({node:e,children:t,className:r,...n})=>l("th",{className:s("px-4 py-2 text-left font-semibold text-sm",r),"data-streamdown":"table-header-cell",...n,children:t}),td:({node:e,children:t,className:r,...n})=>l("td",{className:s("px-4 py-2 text-sm",r),"data-streamdown":"table-cell",...n,children:t}),blockquote:({node:e,children:t,className:r,...n})=>l("blockquote",{className:s("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic",r),"data-streamdown":"blockquote",...n,children:t}),code:se,pre:({children:e})=>e,sup:({node:e,children:t,className:r,...n})=>l("sup",{className:s("text-sm",r),"data-streamdown":"superscript",...n,children:t}),sub:({node:e,children:t,className:r,...n})=>l("sub",{className:s("text-sm",r),"data-streamdown":"subscript",...n,children:t})};import{marked as ie}from"marked";var O=e=>{let r=ie.use({gfm:!0}).lexer(e).map(o=>o.raw),n=[];for(let o=0;o<r.length;o++){let a=r[o];if(a.trim()==="$$"&&n.length>0){let i=n[n.length-1],c=i.trimStart().startsWith("$$"),d=(i.match(/\$\$/g)||[]).length;if(c&&d%2===1){n[n.length-1]=i+a;continue}}if(n.length>0&&a.trimEnd().endsWith("$$")){let i=n[n.length-1],c=i.trimStart().startsWith("$$"),d=(i.match(/\$\$/g)||[]).length,u=(a.match(/\$\$/g)||[]).length;if(c&&d%2===1&&!a.trimStart().startsWith("$$")&&u===1){n[n.length-1]=i+a;continue}}n.push(a)}return n};var le=/(!?\[)([^\]]*?)$/,de=/(\*\*)([^*]*?)$/,ce=/(__)([^_]*?)$/,me=/(\*\*\*)([^*]*?)$/,ue=/(\*)([^*]*?)$/,he=/(_)([^_]*?)$/,pe=/(`)([^`]*?)$/,ge=/(~~)([^~]*?)$/;var C=e=>{let t=(e.match(/```/g)||[]).length;return t>0&&t%2===0&&e.includes(`
|
|
2
|
+
`)},fe=e=>{let t=e.match(le);if(t){let r=e.lastIndexOf(t[1]);return e.substring(0,r)}return e},ke=e=>C(e)?e:e.match(de)&&(e.match(/\*\*/g)||[]).length%2===1?`${e}**`:e,be=e=>e.match(ce)&&(e.match(/__/g)||[]).length%2===1?`${e}__`:e,ye=e=>e.split("").reduce((t,r,n)=>{if(r==="*"){let o=e[n-1],a=e[n+1];if(o==="\\")return t;let i=n;for(let d=n-1;d>=0;d--){if(e[d]===`
|
|
3
|
+
`){i=d+1;break}if(d===0){i=0;break}}if(e.substring(i,n).trim()===""&&(a===" "||a===" "))return t;if(o!=="*"&&a!=="*")return t+1}return t},0),we=e=>C(e)?e:e.match(ue)&&ye(e)%2===1?`${e}*`:e,Me=(e,t)=>{let r=!1,n=!1;for(let o=0;o<e.length&&o<t;o++){if(e[o]==="\\"&&e[o+1]==="$"){o++;continue}e[o]==="$"&&(e[o+1]==="$"?(n=!n,o++,r=!1):n||(r=!r))}return r||n},ve=e=>e.split("").reduce((t,r,n)=>{if(r==="_"){let o=e[n-1],a=e[n+1];if(o==="\\"||Me(e,n))return t;if(o!=="_"&&a!=="_")return t+1}return t},0),Ce=e=>C(e)?e:e.match(he)&&ve(e)%2===1?`${e}_`:e,$e=(e,t)=>{let r=e.substring(t,t+3)==="```",n=t>0&&e.substring(t-1,t+2)==="```",o=t>1&&e.substring(t-2,t+1)==="```";return r||n||o},Te=e=>{let t=0;for(let r=0;r<e.length;r++)e[r]==="`"&&!$e(e,r)&&t++;return t},Be=e=>{if(e.match(/^```[^`\n]*```?$/)&&!e.includes(`
|
|
4
4
|
`))return e.endsWith("``")&&!e.endsWith("```")?`${e}\``:e;let r=(e.match(/```/g)||[]).length,n=r%2===1;return r>0&&r%2===0&&e.includes(`
|
|
5
|
-
`)||(e.endsWith("```\n")||e.endsWith("```"))&&r%2===0?e:e.match(
|
|
5
|
+
`)||(e.endsWith("```\n")||e.endsWith("```"))&&r%2===0?e:e.match(pe)&&!n&&Te(e)%2===1?`${e}\``:e},Ie=e=>e.match(ge)&&(e.match(/~~/g)||[]).length%2===1?`${e}~~`:e;var Ne=e=>{if((e.match(/\$\$/g)||[]).length%2===0)return e;let r=e.indexOf("$$");return r!==-1&&e.indexOf(`
|
|
6
|
+
`,r)!==-1&&!e.endsWith(`
|
|
7
|
+
`)?`${e}
|
|
8
|
+
$$`:`${e}$$`};var Se=e=>{let t=0,r=e.match(/\*+/g)||[];for(let n of r){let o=n.length;o>=3&&(t+=Math.floor(o/3))}return t},Pe=e=>C(e)||/^\*{4,}$/.test(e)?e:e.match(me)&&Se(e)%2===1?`${e}***`:e,U=e=>{if(!e||typeof e!="string")return e;let t=e;return t=fe(t),t=Pe(t),t=ke(t),t=be(t),t=we(t),t=Ce(t),t=Be(t),t=Ie(t),t=Ne(t),t};import{jsx as $}from"react/jsx-runtime";var De=q.default||q,We=De(Le),N=He(["github-light","github-dark"]),G=x(({content:e,shouldParseIncompleteMarkdown:t,...r})=>{let n=S(()=>typeof e=="string"&&t?U(e.trim()):e,[e,t]);return $(We,{...r,children:n})},(e,t)=>e.content===t.content);G.displayName="Block";var Oe=x(({children:e,allowedImagePrefixes:t,allowedLinkPrefixes:r,defaultOrigin:n,parseIncompleteMarkdown:o=!0,components:a,rehypePlugins:i,remarkPlugins:c,className:d,shikiTheme:u=["github-light","github-dark"],...m})=>{let k=Ae(),p=S(()=>O(typeof e=="string"?e:""),[e]),g=S(()=>()=>_e({errorColor:"var(--color-muted-foreground)"}),[]);return $(N.Provider,{value:u,children:$("div",{className:s("space-y-4",d),...m,children:p.map((b,w)=>$(G,{allowedImagePrefixes:t!=null?t:["*"],allowedLinkPrefixes:r!=null?r:["*"],components:{...W,...a},content:b,defaultOrigin:n,rehypePlugins:[g,...i!=null?i:[]],remarkPlugins:[Ee,[Re,{singleDollarTextMath:!1}],...c!=null?c:[]],shouldParseIncompleteMarkdown:o},`${k}-block_${w}`))})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme);Oe.displayName="Streamdown";export{N as ShikiThemeContext,Oe as Streamdown};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "streamdown",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -22,12 +22,6 @@
|
|
|
22
22
|
"url": "git+https://github.com/vercel/streamdown.git",
|
|
23
23
|
"directory": "packages/streamdown"
|
|
24
24
|
},
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "tsup",
|
|
27
|
-
"test": "vitest run",
|
|
28
|
-
"test:ui": "vitest --ui run",
|
|
29
|
-
"test:coverage": "vitest --coverage run"
|
|
30
|
-
},
|
|
31
25
|
"author": "Hayden Bleasel <hayden.bleasel@vercel.com>",
|
|
32
26
|
"license": "Apache-2.0",
|
|
33
27
|
"description": "A drop-in replacement for react-markdown, designed for AI-powered streaming.",
|
|
@@ -60,5 +54,11 @@
|
|
|
60
54
|
"remark-math": "^6.0.0",
|
|
61
55
|
"shiki": "^3.9.2",
|
|
62
56
|
"tailwind-merge": "^3.3.1"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "tsup",
|
|
60
|
+
"test": "vitest run",
|
|
61
|
+
"test:ui": "vitest --ui run",
|
|
62
|
+
"test:coverage": "vitest --coverage run"
|
|
63
63
|
}
|
|
64
|
-
}
|
|
64
|
+
}
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.tsx","../lib/components.tsx","../lib/code-block.tsx","../lib/utils.ts","../lib/parse-blocks.tsx","../lib/parse-incomplete-markdown.ts"],"sourcesContent":["'use client';\n\nimport type { ComponentProps } from 'react';\nimport { memo, useId, useMemo } from 'react';\nimport ReactMarkdown from 'react-markdown';\nimport rehypeKatex from 'rehype-katex';\nimport remarkGfm from 'remark-gfm';\nimport remarkMath from 'remark-math';\nimport 'katex/dist/katex.min.css';\nimport hardenReactMarkdownImport from 'harden-react-markdown';\nimport { components as defaultComponents } from './lib/components';\nimport { parseMarkdownIntoBlocks } from './lib/parse-blocks';\nimport { parseIncompleteMarkdown } from './lib/parse-incomplete-markdown';\nimport { cn } from './lib/utils';\n\n// Handle both ESM and CJS imports\nconst hardenReactMarkdown = (hardenReactMarkdownImport as any).default || hardenReactMarkdownImport;\n\n// Create a hardened version of ReactMarkdown\nconst HardenedMarkdown: ReturnType<typeof hardenReactMarkdown> =\n hardenReactMarkdown(ReactMarkdown);\n\nexport type StreamdownProps = ComponentProps<typeof HardenedMarkdown> & {\n parseIncompleteMarkdown?: boolean;\n className?: string;\n};\n\ntype BlockProps = ComponentProps<typeof HardenedMarkdown> & {\n content: string;\n shouldParseIncompleteMarkdown: boolean;\n};\n\nconst Block = memo(\n ({ content, shouldParseIncompleteMarkdown, ...props }: BlockProps) => {\n const parsedContent = useMemo(\n () =>\n typeof content === 'string' && shouldParseIncompleteMarkdown\n ? parseIncompleteMarkdown(content.trim())\n : content,\n [content, shouldParseIncompleteMarkdown]\n );\n\n return <HardenedMarkdown {...props}>{parsedContent}</HardenedMarkdown>;\n },\n (prevProps, nextProps) => prevProps.content === nextProps.content\n);\n\nexport const Streamdown = memo(\n ({\n children,\n allowedImagePrefixes,\n allowedLinkPrefixes,\n defaultOrigin,\n parseIncompleteMarkdown: shouldParseIncompleteMarkdown = true,\n components,\n rehypePlugins,\n remarkPlugins,\n className,\n ...props\n }: StreamdownProps) => {\n // Parse the children to remove incomplete markdown tokens if enabled\n const generatedId = useId();\n const blocks = useMemo(\n () =>\n parseMarkdownIntoBlocks(typeof children === 'string' ? children : ''),\n [children]\n );\n\n return (\n <div className={cn('space-y-4', className)} {...props}>\n {blocks.map((block, index) => (\n <Block\n allowedImagePrefixes={allowedImagePrefixes ?? ['*']}\n allowedLinkPrefixes={allowedLinkPrefixes ?? ['*']}\n components={{\n ...defaultComponents,\n ...components,\n }}\n content={block}\n defaultOrigin={defaultOrigin}\n // biome-ignore lint/suspicious/noArrayIndexKey: \"required\"\n key={`${generatedId}-block_${index}`}\n rehypePlugins={[rehypeKatex, ...(rehypePlugins ?? [])]}\n remarkPlugins={[remarkGfm, remarkMath, ...(remarkPlugins ?? [])]}\n shouldParseIncompleteMarkdown={shouldParseIncompleteMarkdown}\n />\n ))}\n </div>\n );\n },\n (prevProps, nextProps) => prevProps.children === nextProps.children\n);\nStreamdown.displayName = 'Streamdown';\n\nexport default Streamdown;\n","import { isValidElement } from 'react';\nimport type { Options } from 'react-markdown';\nimport type { BundledLanguage } from 'shiki';\nimport { CodeBlock, CodeBlockCopyButton } from './code-block';\nimport { cn } from './utils';\n\nexport const components: Options['components'] = {\n ol: ({ node, children, className, ...props }) => (\n <ol className={cn('ml-4 list-outside list-decimal', className)} {...props}>\n {children}\n </ol>\n ),\n li: ({ node, children, className, ...props }) => (\n <li className={cn('py-1', className)} {...props}>\n {children}\n </li>\n ),\n ul: ({ node, children, className, ...props }) => (\n <ul className={cn('ml-4 list-outside list-disc', className)} {...props}>\n {children}\n </ul>\n ),\n hr: ({ node, className, ...props }) => (\n <hr className={cn('my-6 border-border', className)} {...props} />\n ),\n strong: ({ node, children, className, ...props }) => (\n <span className={cn('font-semibold', className)} {...props}>\n {children}\n </span>\n ),\n a: ({ node, children, className, href, ...props }) => (\n <a\n className={cn('font-medium text-primary underline', className)}\n href={href}\n rel=\"noreferrer\"\n target=\"_blank\"\n {...props}\n >\n {children}\n </a>\n ),\n h1: ({ node, children, className, ...props }) => (\n <h1\n className={cn('mt-6 mb-2 font-semibold text-3xl', className)}\n {...props}\n >\n {children}\n </h1>\n ),\n h2: ({ node, children, className, ...props }) => (\n <h2\n className={cn('mt-6 mb-2 font-semibold text-2xl', className)}\n {...props}\n >\n {children}\n </h2>\n ),\n h3: ({ node, children, className, ...props }) => (\n <h3 className={cn('mt-6 mb-2 font-semibold text-xl', className)} {...props}>\n {children}\n </h3>\n ),\n h4: ({ node, children, className, ...props }) => (\n <h4 className={cn('mt-6 mb-2 font-semibold text-lg', className)} {...props}>\n {children}\n </h4>\n ),\n h5: ({ node, children, className, ...props }) => (\n <h5\n className={cn('mt-6 mb-2 font-semibold text-base', className)}\n {...props}\n >\n {children}\n </h5>\n ),\n h6: ({ node, children, className, ...props }) => (\n <h6 className={cn('mt-6 mb-2 font-semibold text-sm', className)} {...props}>\n {children}\n </h6>\n ),\n table: ({ node, children, className, ...props }) => (\n <div className=\"my-4 overflow-x-auto\">\n <table\n className={cn('w-full border-collapse border border-border', className)}\n {...props}\n >\n {children}\n </table>\n </div>\n ),\n thead: ({ node, children, className, ...props }) => (\n <thead className={cn('bg-muted/50', className)} {...props}>\n {children}\n </thead>\n ),\n tbody: ({ node, children, className, ...props }) => (\n <tbody className={cn('divide-y divide-border', className)} {...props}>\n {children}\n </tbody>\n ),\n tr: ({ node, children, className, ...props }) => (\n <tr className={cn('border-border border-b', className)} {...props}>\n {children}\n </tr>\n ),\n th: ({ node, children, className, ...props }) => (\n <th\n className={cn('px-4 py-2 text-left font-semibold text-sm', className)}\n {...props}\n >\n {children}\n </th>\n ),\n td: ({ node, children, className, ...props }) => (\n <td className={cn('px-4 py-2 text-sm', className)} {...props}>\n {children}\n </td>\n ),\n blockquote: ({ node, children, className, ...props }) => (\n <blockquote\n className={cn(\n 'my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic',\n className\n )}\n {...props}\n >\n {children}\n </blockquote>\n ),\n code: ({ node, className, ...props }) => {\n const inline = node?.position?.start.line === node?.position?.end.line;\n\n if (!inline) {\n return <code className={className} {...props} />;\n }\n\n return (\n <code\n className={cn(\n 'rounded bg-muted px-1.5 py-0.5 font-mono text-sm',\n className\n )}\n {...props}\n />\n );\n },\n pre: ({ node, className, children }) => {\n let language: BundledLanguage = 'javascript';\n\n if (typeof node?.properties?.className === 'string') {\n language = node.properties.className.replace(\n 'language-',\n ''\n ) as BundledLanguage;\n }\n\n // Extract code content from children safely\n let code = '';\n if (\n isValidElement(children) &&\n children.props &&\n typeof children.props === 'object' &&\n 'children' in children.props &&\n typeof children.props.children === 'string'\n ) {\n code = children.props.children;\n } else if (typeof children === 'string') {\n code = children;\n }\n\n return (\n <CodeBlock\n className={cn('my-4 h-auto rounded-lg border p-4', className)}\n code={code}\n language={language}\n >\n <CodeBlockCopyButton />\n </CodeBlock>\n );\n },\n sup: ({ node, children, className, ...props }) => (\n <sup className={cn('text-sm', className)} {...props}>\n {children}\n </sup>\n ),\n sub: ({ node, children, className, ...props }) => (\n <sub className={cn('text-sm', className)} {...props}>\n {children}\n </sub>\n ),\n};\n","'use client';\n\nimport { CheckIcon, CopyIcon } from 'lucide-react';\nimport {\n type ComponentProps,\n createContext,\n type HTMLAttributes,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { type BundledLanguage, codeToHtml } from 'shiki';\nimport { cn } from './utils';\n\ntype CodeBlockProps = HTMLAttributes<HTMLDivElement> & {\n code: string;\n language: BundledLanguage;\n};\n\ntype CodeBlockContextType = {\n code: string;\n};\n\nconst CodeBlockContext = createContext<CodeBlockContextType>({\n code: '',\n});\n\nexport async function highlightCode(code: string, language: BundledLanguage) {\n return await codeToHtml(code, {\n lang: language,\n theme: 'github-light',\n });\n}\n\nexport const CodeBlock = ({\n code,\n language,\n className,\n children,\n ...props\n}: CodeBlockProps) => {\n const [html, setHtml] = useState<string>('');\n\n useEffect(() => {\n let isMounted = true;\n\n highlightCode(code, language).then((result) => {\n if (isMounted) {\n setHtml(result);\n }\n });\n\n return () => {\n isMounted = false;\n };\n }, [code, language]);\n\n return (\n <CodeBlockContext.Provider value={{ code }}>\n <div className=\"group relative\">\n <div\n className={cn('overflow-x-auto', className)}\n // biome-ignore lint/security/noDangerouslySetInnerHtml: \"this is needed.\"\n dangerouslySetInnerHTML={{ __html: html }}\n {...props}\n />\n {children}\n </div>\n </CodeBlockContext.Provider>\n );\n};\n\nexport type CodeBlockCopyButtonProps = ComponentProps<'button'> & {\n onCopy?: () => void;\n onError?: (error: Error) => void;\n timeout?: number;\n};\n\nexport const CodeBlockCopyButton = ({\n onCopy,\n onError,\n timeout = 2000,\n children,\n className,\n ...props\n}: CodeBlockCopyButtonProps) => {\n const [isCopied, setIsCopied] = useState(false);\n const { code } = useContext(CodeBlockContext);\n\n const copyToClipboard = async () => {\n if (typeof window === 'undefined' || !navigator?.clipboard?.writeText) {\n onError?.(new Error('Clipboard API not available'));\n return;\n }\n\n try {\n await navigator.clipboard.writeText(code);\n setIsCopied(true);\n onCopy?.();\n setTimeout(() => setIsCopied(false), timeout);\n } catch (error) {\n onError?.(error as Error);\n }\n };\n\n const Icon = isCopied ? CheckIcon : CopyIcon;\n\n return (\n <button\n className={cn(\n 'absolute top-2 right-2 shrink-0 rounded-md p-3 opacity-0 transition-all',\n 'hover:bg-secondary group-hover:opacity-100',\n className\n )}\n onClick={copyToClipboard}\n type=\"button\"\n {...props}\n >\n {children ?? <Icon size={14} />}\n </button>\n );\n};\n","import { type ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport const cn = (...inputs: ClassValue[]) => twMerge(clsx(inputs));\n","import { marked } from 'marked';\n\nexport const parseMarkdownIntoBlocks = (markdown: string): string[] => {\n const tokens = marked.lexer(markdown);\n return tokens.map((token) => token.raw);\n};\n","const linkImagePattern = /(!?\\[)([^\\]]*?)$/;\nconst boldPattern = /(\\*\\*)([^*]*?)$/;\nconst italicPattern = /(__)([^_]*?)$/;\nconst singleAsteriskPattern = /(\\*)([^*]*?)$/;\nconst singleUnderscorePattern = /(_)([^_]*?)$/;\nconst inlineCodePattern = /(`)([^`]*?)$/;\nconst strikethroughPattern = /(~~)([^~]*?)$/;\nconst inlineKatexPattern = /(\\$)([^$]*?)$/;\nconst blockKatexPattern = /(\\$\\$)([^$]*?)$/;\n\n// Handles incomplete links and images by removing them if not closed\nconst handleIncompleteLinksAndImages = (text: string): string => {\n const linkMatch = text.match(linkImagePattern);\n\n if (linkMatch) {\n const startIndex = text.lastIndexOf(linkMatch[1]);\n return text.substring(0, startIndex);\n }\n\n return text;\n};\n\n// Completes incomplete bold formatting (**)\nconst handleIncompleteBold = (text: string): string => {\n const boldMatch = text.match(boldPattern);\n\n if (boldMatch) {\n const asteriskPairs = (text.match(/\\*\\*/g) || []).length;\n if (asteriskPairs % 2 === 1) {\n return `${text}**`;\n }\n }\n\n return text;\n};\n\n// Completes incomplete italic formatting with double underscores (__)\nconst handleIncompleteDoubleUnderscoreItalic = (text: string): string => {\n const italicMatch = text.match(italicPattern);\n\n if (italicMatch) {\n const underscorePairs = (text.match(/__/g) || []).length;\n if (underscorePairs % 2 === 1) {\n return `${text}__`;\n }\n }\n\n return text;\n};\n\n// Counts single asterisks that are not part of double asterisks and not escaped\nconst countSingleAsterisks = (text: string): number => {\n return text.split('').reduce((acc, char, index) => {\n if (char === '*') {\n const prevChar = text[index - 1];\n const nextChar = text[index + 1];\n // Skip if escaped with backslash\n if (prevChar === '\\\\') {\n return acc;\n }\n if (prevChar !== '*' && nextChar !== '*') {\n return acc + 1;\n }\n }\n return acc;\n }, 0);\n};\n\n// Completes incomplete italic formatting with single asterisks (*)\nconst handleIncompleteSingleAsteriskItalic = (text: string): string => {\n const singleAsteriskMatch = text.match(singleAsteriskPattern);\n\n if (singleAsteriskMatch) {\n const singleAsterisks = countSingleAsterisks(text);\n if (singleAsterisks % 2 === 1) {\n return `${text}*`;\n }\n }\n\n return text;\n};\n\n// Counts single underscores that are not part of double underscores and not escaped\nconst countSingleUnderscores = (text: string): number => {\n return text.split('').reduce((acc, char, index) => {\n if (char === '_') {\n const prevChar = text[index - 1];\n const nextChar = text[index + 1];\n // Skip if escaped with backslash\n if (prevChar === '\\\\') {\n return acc;\n }\n if (prevChar !== '_' && nextChar !== '_') {\n return acc + 1;\n }\n }\n return acc;\n }, 0);\n};\n\n// Completes incomplete italic formatting with single underscores (_)\nconst handleIncompleteSingleUnderscoreItalic = (text: string): string => {\n const singleUnderscoreMatch = text.match(singleUnderscorePattern);\n\n if (singleUnderscoreMatch) {\n const singleUnderscores = countSingleUnderscores(text);\n if (singleUnderscores % 2 === 1) {\n return `${text}_`;\n }\n }\n\n return text;\n};\n\n// Checks if a backtick at position i is part of a triple backtick sequence\nconst isPartOfTripleBacktick = (text: string, i: number): boolean => {\n const isTripleStart = text.substring(i, i + 3) === '```';\n const isTripleMiddle = i > 0 && text.substring(i - 1, i + 2) === '```';\n const isTripleEnd = i > 1 && text.substring(i - 2, i + 1) === '```';\n\n return isTripleStart || isTripleMiddle || isTripleEnd;\n};\n\n// Counts single backticks that are not part of triple backticks\nconst countSingleBackticks = (text: string): number => {\n let count = 0;\n for (let i = 0; i < text.length; i++) {\n if (text[i] === '`' && !isPartOfTripleBacktick(text, i)) {\n count++;\n }\n }\n return count;\n};\n\n// Completes incomplete inline code formatting (`)\n// Avoids completing if inside an incomplete code block\nconst handleIncompleteInlineCode = (text: string): string => {\n // Check if we're inside a code block (complete or incomplete)\n const allTripleBackticks = (text.match(/```/g) || []).length;\n const insideIncompleteCodeBlock = allTripleBackticks % 2 === 1;\n \n // Don't modify text if we have complete code blocks (even pairs of ```)\n if (allTripleBackticks > 0 && allTripleBackticks % 2 === 0) {\n // We have complete code blocks, don't add any backticks\n return text;\n }\n\n const inlineCodeMatch = text.match(inlineCodePattern);\n\n if (inlineCodeMatch && !insideIncompleteCodeBlock) {\n const singleBacktickCount = countSingleBackticks(text);\n if (singleBacktickCount % 2 === 1) {\n return `${text}\\``;\n }\n }\n\n return text;\n};\n\n// Completes incomplete strikethrough formatting (~~)\nconst handleIncompleteStrikethrough = (text: string): string => {\n const strikethroughMatch = text.match(strikethroughPattern);\n\n if (strikethroughMatch) {\n const tildePairs = (text.match(/~~/g) || []).length;\n if (tildePairs % 2 === 1) {\n return `${text}~~`;\n }\n }\n\n return text;\n};\n\n// Counts single dollar signs that are not part of double dollar signs and not escaped\nconst countSingleDollarSigns = (text: string): number => {\n return text.split('').reduce((acc, char, index) => {\n if (char === '$') {\n const prevChar = text[index - 1];\n const nextChar = text[index + 1];\n // Skip if escaped with backslash\n if (prevChar === '\\\\') {\n return acc;\n }\n if (prevChar !== '$' && nextChar !== '$') {\n return acc + 1;\n }\n }\n return acc;\n }, 0);\n};\n\n// Completes incomplete block KaTeX formatting ($$)\nconst handleIncompleteBlockKatex = (text: string): string => {\n const blockKatexMatch = text.match(blockKatexPattern);\n\n if (blockKatexMatch) {\n const dollarPairs = (text.match(/\\$\\$/g) || []).length;\n if (dollarPairs % 2 === 1) {\n return `${text}$$`;\n }\n }\n\n return text;\n};\n\n// Completes incomplete inline KaTeX formatting ($)\nconst handleIncompleteInlineKatex = (text: string): string => {\n const inlineKatexMatch = text.match(inlineKatexPattern);\n\n if (inlineKatexMatch) {\n const singleDollars = countSingleDollarSigns(text);\n if (singleDollars % 2 === 1) {\n return `${text}$`;\n }\n }\n\n return text;\n};\n\n// Parses markdown text and removes incomplete tokens to prevent partial rendering\nexport const parseIncompleteMarkdown = (text: string): string => {\n if (!text || typeof text !== 'string') {\n return text;\n }\n\n let result = text;\n\n // Handle incomplete links and images first (removes content)\n result = handleIncompleteLinksAndImages(result);\n\n // Handle various formatting completions\n result = handleIncompleteBold(result);\n result = handleIncompleteDoubleUnderscoreItalic(result);\n result = handleIncompleteSingleAsteriskItalic(result);\n result = handleIncompleteSingleUnderscoreItalic(result);\n result = handleIncompleteInlineCode(result);\n result = handleIncompleteStrikethrough(result);\n \n // Handle KaTeX formatting (block first, then inline)\n result = handleIncompleteBlockKatex(result);\n result = handleIncompleteInlineKatex(result);\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,IAAAA,gBAAqC;AACrC,4BAA0B;AAC1B,0BAAwB;AACxB,wBAAsB;AACtB,yBAAuB;AACvB,uBAAO;AACP,mCAAsC;;;ACTtC,IAAAC,gBAA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b,MACE,wBAAwB,OAAO,aAAa,WAAW,WAAW,EAAE;AAAA,MACtE,CAAC,QAAQ;AAAA,IACX;AAEA,WACE,6CAAC,SAAI,WAAW,GAAG,aAAa,SAAS,GAAI,GAAG,OAC7C,iBAAO,IAAI,CAAC,OAAO,UAClB;AAAA,MAAC;AAAA;AAAA,QACC,sBAAsB,sDAAwB,CAAC,GAAG;AAAA,QAClD,qBAAqB,oDAAuB,CAAC,GAAG;AAAA,QAChD,YAAY;AAAA,UACV,GAAG;AAAA,UACH,GAAGA;AAAA,QACL;AAAA,QACA,SAAS;AAAA,QACT;AAAA,QAGA,eAAe,CAAC,oBAAAC,SAAa,GAAI,wCAAiB,CAAC,CAAE;AAAA,QACrD,eAAe,CAAC,kBAAAC,SAAW,mBAAAC,SAAY,GAAI,wCAAiB,CAAC,CAAE;AAAA,QAC/D;AAAA;AAAA,MAHK,GAAG,WAAW,UAAU,KAAK;AAAA,IAIpC,CACD,GACH;AAAA,EAEJ;AAAA,EACA,CAAC,WAAW,cAAc,UAAU,aAAa,UAAU;AAC7D;AACA,WAAW,cAAc;AAEzB,IAAO,gBAAQ;","names":["import_react","import_react","import_jsx_runtime","import_jsx_runtime","hardenReactMarkdownImport","ReactMarkdown","components","rehypeKatex","remarkGfm","remarkMath"]}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.tsx","../lib/components.tsx","../lib/code-block.tsx","../lib/utils.ts","../lib/parse-blocks.tsx","../lib/parse-incomplete-markdown.ts"],"sourcesContent":["'use client';\n\nimport type { ComponentProps } from 'react';\nimport { memo, useId, useMemo } from 'react';\nimport ReactMarkdown from 'react-markdown';\nimport rehypeKatex from 'rehype-katex';\nimport remarkGfm from 'remark-gfm';\nimport remarkMath from 'remark-math';\nimport 'katex/dist/katex.min.css';\nimport hardenReactMarkdownImport from 'harden-react-markdown';\nimport { components as defaultComponents } from './lib/components';\nimport { parseMarkdownIntoBlocks } from './lib/parse-blocks';\nimport { parseIncompleteMarkdown } from './lib/parse-incomplete-markdown';\nimport { cn } from './lib/utils';\n\n// Handle both ESM and CJS imports\nconst hardenReactMarkdown = (hardenReactMarkdownImport as any).default || hardenReactMarkdownImport;\n\n// Create a hardened version of ReactMarkdown\nconst HardenedMarkdown: ReturnType<typeof hardenReactMarkdown> =\n hardenReactMarkdown(ReactMarkdown);\n\nexport type StreamdownProps = ComponentProps<typeof HardenedMarkdown> & {\n parseIncompleteMarkdown?: boolean;\n className?: string;\n};\n\ntype BlockProps = ComponentProps<typeof HardenedMarkdown> & {\n content: string;\n shouldParseIncompleteMarkdown: boolean;\n};\n\nconst Block = memo(\n ({ content, shouldParseIncompleteMarkdown, ...props }: BlockProps) => {\n const parsedContent = useMemo(\n () =>\n typeof content === 'string' && shouldParseIncompleteMarkdown\n ? parseIncompleteMarkdown(content.trim())\n : content,\n [content, shouldParseIncompleteMarkdown]\n );\n\n return <HardenedMarkdown {...props}>{parsedContent}</HardenedMarkdown>;\n },\n (prevProps, nextProps) => prevProps.content === nextProps.content\n);\n\nexport const Streamdown = memo(\n ({\n children,\n allowedImagePrefixes,\n allowedLinkPrefixes,\n defaultOrigin,\n parseIncompleteMarkdown: shouldParseIncompleteMarkdown = true,\n components,\n rehypePlugins,\n remarkPlugins,\n className,\n ...props\n }: StreamdownProps) => {\n // Parse the children to remove incomplete markdown tokens if enabled\n const generatedId = useId();\n const blocks = useMemo(\n () =>\n parseMarkdownIntoBlocks(typeof children === 'string' ? children : ''),\n [children]\n );\n\n return (\n <div className={cn('space-y-4', className)} {...props}>\n {blocks.map((block, index) => (\n <Block\n allowedImagePrefixes={allowedImagePrefixes ?? ['*']}\n allowedLinkPrefixes={allowedLinkPrefixes ?? ['*']}\n components={{\n ...defaultComponents,\n ...components,\n }}\n content={block}\n defaultOrigin={defaultOrigin}\n // biome-ignore lint/suspicious/noArrayIndexKey: \"required\"\n key={`${generatedId}-block_${index}`}\n rehypePlugins={[rehypeKatex, ...(rehypePlugins ?? [])]}\n remarkPlugins={[remarkGfm, remarkMath, ...(remarkPlugins ?? [])]}\n shouldParseIncompleteMarkdown={shouldParseIncompleteMarkdown}\n />\n ))}\n </div>\n );\n },\n (prevProps, nextProps) => prevProps.children === nextProps.children\n);\nStreamdown.displayName = 'Streamdown';\n\nexport default Streamdown;\n","import { isValidElement } from 'react';\nimport type { Options } from 'react-markdown';\nimport type { BundledLanguage } from 'shiki';\nimport { CodeBlock, CodeBlockCopyButton } from './code-block';\nimport { cn } from './utils';\n\nexport const components: Options['components'] = {\n ol: ({ node, children, className, ...props }) => (\n <ol className={cn('ml-4 list-outside list-decimal', className)} {...props}>\n {children}\n </ol>\n ),\n li: ({ node, children, className, ...props }) => (\n <li className={cn('py-1', className)} {...props}>\n {children}\n </li>\n ),\n ul: ({ node, children, className, ...props }) => (\n <ul className={cn('ml-4 list-outside list-disc', className)} {...props}>\n {children}\n </ul>\n ),\n hr: ({ node, className, ...props }) => (\n <hr className={cn('my-6 border-border', className)} {...props} />\n ),\n strong: ({ node, children, className, ...props }) => (\n <span className={cn('font-semibold', className)} {...props}>\n {children}\n </span>\n ),\n a: ({ node, children, className, href, ...props }) => (\n <a\n className={cn('font-medium text-primary underline', className)}\n href={href}\n rel=\"noreferrer\"\n target=\"_blank\"\n {...props}\n >\n {children}\n </a>\n ),\n h1: ({ node, children, className, ...props }) => (\n <h1\n className={cn('mt-6 mb-2 font-semibold text-3xl', className)}\n {...props}\n >\n {children}\n </h1>\n ),\n h2: ({ node, children, className, ...props }) => (\n <h2\n className={cn('mt-6 mb-2 font-semibold text-2xl', className)}\n {...props}\n >\n {children}\n </h2>\n ),\n h3: ({ node, children, className, ...props }) => (\n <h3 className={cn('mt-6 mb-2 font-semibold text-xl', className)} {...props}>\n {children}\n </h3>\n ),\n h4: ({ node, children, className, ...props }) => (\n <h4 className={cn('mt-6 mb-2 font-semibold text-lg', className)} {...props}>\n {children}\n </h4>\n ),\n h5: ({ node, children, className, ...props }) => (\n <h5\n className={cn('mt-6 mb-2 font-semibold text-base', className)}\n {...props}\n >\n {children}\n </h5>\n ),\n h6: ({ node, children, className, ...props }) => (\n <h6 className={cn('mt-6 mb-2 font-semibold text-sm', className)} {...props}>\n {children}\n </h6>\n ),\n table: ({ node, children, className, ...props }) => (\n <div className=\"my-4 overflow-x-auto\">\n <table\n className={cn('w-full border-collapse border border-border', className)}\n {...props}\n >\n {children}\n </table>\n </div>\n ),\n thead: ({ node, children, className, ...props }) => (\n <thead className={cn('bg-muted/50', className)} {...props}>\n {children}\n </thead>\n ),\n tbody: ({ node, children, className, ...props }) => (\n <tbody className={cn('divide-y divide-border', className)} {...props}>\n {children}\n </tbody>\n ),\n tr: ({ node, children, className, ...props }) => (\n <tr className={cn('border-border border-b', className)} {...props}>\n {children}\n </tr>\n ),\n th: ({ node, children, className, ...props }) => (\n <th\n className={cn('px-4 py-2 text-left font-semibold text-sm', className)}\n {...props}\n >\n {children}\n </th>\n ),\n td: ({ node, children, className, ...props }) => (\n <td className={cn('px-4 py-2 text-sm', className)} {...props}>\n {children}\n </td>\n ),\n blockquote: ({ node, children, className, ...props }) => (\n <blockquote\n className={cn(\n 'my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic',\n className\n )}\n {...props}\n >\n {children}\n </blockquote>\n ),\n code: ({ node, className, ...props }) => {\n const inline = node?.position?.start.line === node?.position?.end.line;\n\n if (!inline) {\n return <code className={className} {...props} />;\n }\n\n return (\n <code\n className={cn(\n 'rounded bg-muted px-1.5 py-0.5 font-mono text-sm',\n className\n )}\n {...props}\n />\n );\n },\n pre: ({ node, className, children }) => {\n let language: BundledLanguage = 'javascript';\n\n if (typeof node?.properties?.className === 'string') {\n language = node.properties.className.replace(\n 'language-',\n ''\n ) as BundledLanguage;\n }\n\n // Extract code content from children safely\n let code = '';\n if (\n isValidElement(children) &&\n children.props &&\n typeof children.props === 'object' &&\n 'children' in children.props &&\n typeof children.props.children === 'string'\n ) {\n code = children.props.children;\n } else if (typeof children === 'string') {\n code = children;\n }\n\n return (\n <CodeBlock\n className={cn('my-4 h-auto rounded-lg border p-4', className)}\n code={code}\n language={language}\n >\n <CodeBlockCopyButton />\n </CodeBlock>\n );\n },\n sup: ({ node, children, className, ...props }) => (\n <sup className={cn('text-sm', className)} {...props}>\n {children}\n </sup>\n ),\n sub: ({ node, children, className, ...props }) => (\n <sub className={cn('text-sm', className)} {...props}>\n {children}\n </sub>\n ),\n};\n","'use client';\n\nimport { CheckIcon, CopyIcon } from 'lucide-react';\nimport {\n type ComponentProps,\n createContext,\n type HTMLAttributes,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { type BundledLanguage, codeToHtml } from 'shiki';\nimport { cn } from './utils';\n\ntype CodeBlockProps = HTMLAttributes<HTMLDivElement> & {\n code: string;\n language: BundledLanguage;\n};\n\ntype CodeBlockContextType = {\n code: string;\n};\n\nconst CodeBlockContext = createContext<CodeBlockContextType>({\n code: '',\n});\n\nexport async function highlightCode(code: string, language: BundledLanguage) {\n return await codeToHtml(code, {\n lang: language,\n theme: 'github-light',\n });\n}\n\nexport const CodeBlock = ({\n code,\n language,\n className,\n children,\n ...props\n}: CodeBlockProps) => {\n const [html, setHtml] = useState<string>('');\n\n useEffect(() => {\n let isMounted = true;\n\n highlightCode(code, language).then((result) => {\n if (isMounted) {\n setHtml(result);\n }\n });\n\n return () => {\n isMounted = false;\n };\n }, [code, language]);\n\n return (\n <CodeBlockContext.Provider value={{ code }}>\n <div className=\"group relative\">\n <div\n className={cn('overflow-x-auto', className)}\n // biome-ignore lint/security/noDangerouslySetInnerHtml: \"this is needed.\"\n dangerouslySetInnerHTML={{ __html: html }}\n {...props}\n />\n {children}\n </div>\n </CodeBlockContext.Provider>\n );\n};\n\nexport type CodeBlockCopyButtonProps = ComponentProps<'button'> & {\n onCopy?: () => void;\n onError?: (error: Error) => void;\n timeout?: number;\n};\n\nexport const CodeBlockCopyButton = ({\n onCopy,\n onError,\n timeout = 2000,\n children,\n className,\n ...props\n}: CodeBlockCopyButtonProps) => {\n const [isCopied, setIsCopied] = useState(false);\n const { code } = useContext(CodeBlockContext);\n\n const copyToClipboard = async () => {\n if (typeof window === 'undefined' || !navigator?.clipboard?.writeText) {\n onError?.(new Error('Clipboard API not available'));\n return;\n }\n\n try {\n await navigator.clipboard.writeText(code);\n setIsCopied(true);\n onCopy?.();\n setTimeout(() => setIsCopied(false), timeout);\n } catch (error) {\n onError?.(error as Error);\n }\n };\n\n const Icon = isCopied ? CheckIcon : CopyIcon;\n\n return (\n <button\n className={cn(\n 'absolute top-2 right-2 shrink-0 rounded-md p-3 opacity-0 transition-all',\n 'hover:bg-secondary group-hover:opacity-100',\n className\n )}\n onClick={copyToClipboard}\n type=\"button\"\n {...props}\n >\n {children ?? <Icon size={14} />}\n </button>\n );\n};\n","import { type ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport const cn = (...inputs: ClassValue[]) => twMerge(clsx(inputs));\n","import { marked } from 'marked';\n\nexport const parseMarkdownIntoBlocks = (markdown: string): string[] => {\n const tokens = marked.lexer(markdown);\n return tokens.map((token) => token.raw);\n};\n","const linkImagePattern = /(!?\\[)([^\\]]*?)$/;\nconst boldPattern = /(\\*\\*)([^*]*?)$/;\nconst italicPattern = /(__)([^_]*?)$/;\nconst singleAsteriskPattern = /(\\*)([^*]*?)$/;\nconst singleUnderscorePattern = /(_)([^_]*?)$/;\nconst inlineCodePattern = /(`)([^`]*?)$/;\nconst strikethroughPattern = /(~~)([^~]*?)$/;\nconst inlineKatexPattern = /(\\$)([^$]*?)$/;\nconst blockKatexPattern = /(\\$\\$)([^$]*?)$/;\n\n// Handles incomplete links and images by removing them if not closed\nconst handleIncompleteLinksAndImages = (text: string): string => {\n const linkMatch = text.match(linkImagePattern);\n\n if (linkMatch) {\n const startIndex = text.lastIndexOf(linkMatch[1]);\n return text.substring(0, startIndex);\n }\n\n return text;\n};\n\n// Completes incomplete bold formatting (**)\nconst handleIncompleteBold = (text: string): string => {\n const boldMatch = text.match(boldPattern);\n\n if (boldMatch) {\n const asteriskPairs = (text.match(/\\*\\*/g) || []).length;\n if (asteriskPairs % 2 === 1) {\n return `${text}**`;\n }\n }\n\n return text;\n};\n\n// Completes incomplete italic formatting with double underscores (__)\nconst handleIncompleteDoubleUnderscoreItalic = (text: string): string => {\n const italicMatch = text.match(italicPattern);\n\n if (italicMatch) {\n const underscorePairs = (text.match(/__/g) || []).length;\n if (underscorePairs % 2 === 1) {\n return `${text}__`;\n }\n }\n\n return text;\n};\n\n// Counts single asterisks that are not part of double asterisks and not escaped\nconst countSingleAsterisks = (text: string): number => {\n return text.split('').reduce((acc, char, index) => {\n if (char === '*') {\n const prevChar = text[index - 1];\n const nextChar = text[index + 1];\n // Skip if escaped with backslash\n if (prevChar === '\\\\') {\n return acc;\n }\n if (prevChar !== '*' && nextChar !== '*') {\n return acc + 1;\n }\n }\n return acc;\n }, 0);\n};\n\n// Completes incomplete italic formatting with single asterisks (*)\nconst handleIncompleteSingleAsteriskItalic = (text: string): string => {\n const singleAsteriskMatch = text.match(singleAsteriskPattern);\n\n if (singleAsteriskMatch) {\n const singleAsterisks = countSingleAsterisks(text);\n if (singleAsterisks % 2 === 1) {\n return `${text}*`;\n }\n }\n\n return text;\n};\n\n// Counts single underscores that are not part of double underscores and not escaped\nconst countSingleUnderscores = (text: string): number => {\n return text.split('').reduce((acc, char, index) => {\n if (char === '_') {\n const prevChar = text[index - 1];\n const nextChar = text[index + 1];\n // Skip if escaped with backslash\n if (prevChar === '\\\\') {\n return acc;\n }\n if (prevChar !== '_' && nextChar !== '_') {\n return acc + 1;\n }\n }\n return acc;\n }, 0);\n};\n\n// Completes incomplete italic formatting with single underscores (_)\nconst handleIncompleteSingleUnderscoreItalic = (text: string): string => {\n const singleUnderscoreMatch = text.match(singleUnderscorePattern);\n\n if (singleUnderscoreMatch) {\n const singleUnderscores = countSingleUnderscores(text);\n if (singleUnderscores % 2 === 1) {\n return `${text}_`;\n }\n }\n\n return text;\n};\n\n// Checks if a backtick at position i is part of a triple backtick sequence\nconst isPartOfTripleBacktick = (text: string, i: number): boolean => {\n const isTripleStart = text.substring(i, i + 3) === '```';\n const isTripleMiddle = i > 0 && text.substring(i - 1, i + 2) === '```';\n const isTripleEnd = i > 1 && text.substring(i - 2, i + 1) === '```';\n\n return isTripleStart || isTripleMiddle || isTripleEnd;\n};\n\n// Counts single backticks that are not part of triple backticks\nconst countSingleBackticks = (text: string): number => {\n let count = 0;\n for (let i = 0; i < text.length; i++) {\n if (text[i] === '`' && !isPartOfTripleBacktick(text, i)) {\n count++;\n }\n }\n return count;\n};\n\n// Completes incomplete inline code formatting (`)\n// Avoids completing if inside an incomplete code block\nconst handleIncompleteInlineCode = (text: string): string => {\n // Check if we're inside a code block (complete or incomplete)\n const allTripleBackticks = (text.match(/```/g) || []).length;\n const insideIncompleteCodeBlock = allTripleBackticks % 2 === 1;\n \n // Don't modify text if we have complete code blocks (even pairs of ```)\n if (allTripleBackticks > 0 && allTripleBackticks % 2 === 0) {\n // We have complete code blocks, don't add any backticks\n return text;\n }\n\n const inlineCodeMatch = text.match(inlineCodePattern);\n\n if (inlineCodeMatch && !insideIncompleteCodeBlock) {\n const singleBacktickCount = countSingleBackticks(text);\n if (singleBacktickCount % 2 === 1) {\n return `${text}\\``;\n }\n }\n\n return text;\n};\n\n// Completes incomplete strikethrough formatting (~~)\nconst handleIncompleteStrikethrough = (text: string): string => {\n const strikethroughMatch = text.match(strikethroughPattern);\n\n if (strikethroughMatch) {\n const tildePairs = (text.match(/~~/g) || []).length;\n if (tildePairs % 2 === 1) {\n return `${text}~~`;\n }\n }\n\n return text;\n};\n\n// Counts single dollar signs that are not part of double dollar signs and not escaped\nconst countSingleDollarSigns = (text: string): number => {\n return text.split('').reduce((acc, char, index) => {\n if (char === '$') {\n const prevChar = text[index - 1];\n const nextChar = text[index + 1];\n // Skip if escaped with backslash\n if (prevChar === '\\\\') {\n return acc;\n }\n if (prevChar !== '$' && nextChar !== '$') {\n return acc + 1;\n }\n }\n return acc;\n }, 0);\n};\n\n// Completes incomplete block KaTeX formatting ($$)\nconst handleIncompleteBlockKatex = (text: string): string => {\n const blockKatexMatch = text.match(blockKatexPattern);\n\n if (blockKatexMatch) {\n const dollarPairs = (text.match(/\\$\\$/g) || []).length;\n if (dollarPairs % 2 === 1) {\n return `${text}$$`;\n }\n }\n\n return text;\n};\n\n// Completes incomplete inline KaTeX formatting ($)\nconst handleIncompleteInlineKatex = (text: string): string => {\n const inlineKatexMatch = text.match(inlineKatexPattern);\n\n if (inlineKatexMatch) {\n const singleDollars = countSingleDollarSigns(text);\n if (singleDollars % 2 === 1) {\n return `${text}$`;\n }\n }\n\n return text;\n};\n\n// Parses markdown text and removes incomplete tokens to prevent partial rendering\nexport const parseIncompleteMarkdown = (text: string): string => {\n if (!text || typeof text !== 'string') {\n return text;\n }\n\n let result = text;\n\n // Handle incomplete links and images first (removes content)\n result = handleIncompleteLinksAndImages(result);\n\n // Handle various formatting completions\n result = handleIncompleteBold(result);\n result = handleIncompleteDoubleUnderscoreItalic(result);\n result = handleIncompleteSingleAsteriskItalic(result);\n result = handleIncompleteSingleUnderscoreItalic(result);\n result = handleIncompleteInlineCode(result);\n result = handleIncompleteStrikethrough(result);\n \n // Handle KaTeX formatting (block first, then inline)\n result = handleIncompleteBlockKatex(result);\n result = handleIncompleteInlineKatex(result);\n\n return result;\n};\n"],"mappings":";;;AAGA,SAAS,MAAM,OAAO,eAAe;AACrC,OAAO,mBAAmB;AAC1B,OAAO,iBAAiB;AACxB,OAAO,eAAe;AACtB,OAAO,gBAAgB;AACvB,OAAO;AACP,OAAO,+BAA+B;;;ACTtC,SAAS,sBAAsB;;;ACE/B,SAAS,WAAW,gBAAgB;AACpC;AAAA,EAEE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAA+B,kBAAkB;;;ACXjD,SAA0B,YAAY;AACtC,SAAS,eAAe;AAEjB,IAAM,KAAK,IAAI,WAAyB,QAAQ,KAAK,MAAM,CAAC;;;ADw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