markstream-vue 0.0.4-beta.7 → 0.0.4
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/exports.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +1 -1
- package/dist/index.tailwind.css +1 -1
- package/dist/index2.js +1 -1
- package/dist/index3.js +1 -1
- package/dist/index4.js +1 -1
- package/dist/index5.js +1 -0
- package/dist/safeRaf.js +1 -0
- package/dist/tailwind.ts +0 -0
- package/package.json +3 -2
package/dist/index5.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=Object.defineProperties,l=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,a=(t,l,n)=>l in t?e(t,l,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[l]=n,i=(e,t)=>{for(var l in t||(t={}))o.call(t,l)&&a(e,l,t[l]);if(n)for(var l of n(t))r.call(t,l)&&a(e,l,t[l]);return e},u=(e,t,l)=>new Promise((n,o)=>{var r=e=>{try{i(l.next(e))}catch(t){o(t)}},a=e=>{try{i(l.throw(e))}catch(t){o(t)}},i=e=>e.done?n(e.value):Promise.resolve(e.value).then(r,a);i((l=l.apply(e,t)).next())});import{defineComponent as s,ref as c,computed as v,watch as d,onBeforeUnmount as m,nextTick as h,onMounted as g,onUnmounted as f,createElementBlock as p,openBlock as w,normalizeClass as y,createCommentVNode as x,withDirectives as k,renderSlot as b,createElementVNode as M,unref as T,toDisplayString as C,normalizeStyle as D,createBlock as B,mergeProps as j,toHandlers as E,Teleport as S,createVNode as O,Transition as P,withCtx as L,withModifiers as $,vShow as z}from"vue";import{u as A,a as F,i as R,s as H,h as _,j as X,k as N,t as Y,_ as Z}from"./exports.js";import{s as I}from"./safeRaf.js";const q={key:0},V={key:1,class:"flex items-center space-x-2 overflow-hidden"},U=["src"],W={key:2},G={class:"flex items-center space-x-1"},K={class:"flex items-center space-x-1"},J={key:4},Q={key:5,class:"flex items-center space-x-1"},ee=["aria-pressed"],te={key:0,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},le={key:1,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},ne=["disabled"],oe=["disabled"],re={key:0,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"0.75rem",height:"0.75rem",viewBox:"0 0 24 24"},ae={key:1,xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"0.75rem",height:"0.75rem",viewBox:"0 0 24 24"},ie={key:1,class:"relative"},ue={key:0,class:"absolute top-2 right-2 z-10 rounded-lg"},se={class:"flex items-center gap-2 backdrop-blur rounded-lg"},ce={class:"markstream-vue"},ve={class:"absolute top-6 right-6 z-50 flex items-center gap-2"},de=/* @__PURE__ */Z(/* @__PURE__ */s({__name:"MermaidBlockNode",props:{node:{},maxHeight:{default:"500px"},loading:{type:Boolean,default:!0},isDark:{type:Boolean},workerTimeoutMs:{default:1400},parseTimeoutMs:{default:1800},renderTimeoutMs:{default:2500},fullRenderTimeoutMs:{default:4e3},showHeader:{type:Boolean,default:!0},showModeToggle:{type:Boolean,default:!0},showCopyButton:{type:Boolean,default:!0},showExportButton:{type:Boolean,default:!0},showFullscreenButton:{type:Boolean,default:!0},showCollapseButton:{type:Boolean,default:!0},showZoomControls:{type:Boolean,default:!0},enableWheelZoom:{type:Boolean,default:!1},isStrict:{type:Boolean,default:!1}},emits:["copy","export","openModal","toggleMode"],setup(e,{emit:n}){var o,r;const a=e,s=n,Z={USE_PROFILES:{svg:!0},FORBID_TAGS:["script"],FORBID_ATTR:[/^on/i],ADD_TAGS:["style"],ADD_ATTR:["style"],SAFE_FOR_TEMPLATES:!0},de=c(!1),me=v(()=>a.isStrict?"strict":"loose"),he=v(()=>({startOnLoad:!1,securityLevel:me.value,dompurifyConfig:"strict"===me.value?Z:void 0,flowchart:"strict"===me.value?{htmlLabels:!1}:void 0})),ge=[/javascript:/i,/expression\s*\(/i,/url\s*\(\s*javascript:/i,/@import/i],fe=/^(?:https?:|mailto:|tel:|#|\/|data:image\/(?:png|gif|jpe?g|webp);)/i;function pe(e){if(!e)return"";const t=e.trim();return fe.test(t)?t:""}function we(e){if(e)try{e.replaceChildren()}catch(t){e.innerHTML=""}}function ye(e,t){if(!e)return"";if("strict"===me.value)return function(e,t){if(!e)return"";try{e.replaceChildren()}catch(n){e.innerHTML=""}const l=function(e){if("undefined"==typeof window||"undefined"==typeof DOMParser)return null;if(!e)return null;const t=e.replace(/["']\s*javascript:/gi,"#").replace(/\bjavascript:/gi,"#").replace(/["']\s*vbscript:/gi,"#").replace(/\bvbscript:/gi,"#").replace(/\bdata:text\/html/gi,"#"),l=(new DOMParser).parseFromString(t,"image/svg+xml").documentElement;if(!l||"svg"!==l.nodeName.toLowerCase())return null;const n=l;return function(e){const t=/* @__PURE__ */new Set(["script"]),l=[e,...Array.from(e.querySelectorAll("*"))];for(const n of l){if(t.has(n.tagName.toLowerCase())){n.remove();continue}const e=Array.from(n.attributes);for(const t of e){const e=t.name;if(/^on/i.test(e))n.removeAttribute(e);else{if("style"===e&&t.value){const l=t.value;if(ge.some(e=>e.test(l))){n.removeAttribute(e);continue}}if(("href"===e||"xlink:href"===e)&&t.value){const l=pe(t.value);if(!l){n.removeAttribute(e);continue}l!==t.value&&n.setAttribute(e,l)}}}}}(n),n}(t);return l?(e.appendChild(l),e.innerHTML):""}(e,t);try{e.replaceChildren()}catch(l){e.innerHTML=""}if(t)try{e.insertAdjacentHTML("afterbegin",t)}catch(l){e.innerHTML=t}return e.innerHTML}const{t:xe}=A();function ke(){return u(this,null,function*(){try{const e=yield R();return de.value=!!e,e}catch(e){throw de.value=!1,e}})}"undefined"!=typeof window&&u(null,null,function*(){var e;try{const t=yield ke();if(!t)return;null==(e=null==t?void 0:t.initialize)||e.call(t,i({},he.value))}catch(t){de.value=!1,console.warn("[markstream-vue] Failed to initialize mermaid renderer. Call enableMermaid() to configure a loader.",t)}});const be=c(!1),Me=c(!1),Te=c(),Ce=c(),De=c(),Be=c(null),je=F(),Ee=c(null),Se=c("undefined"==typeof window),Oe=c(),Pe=v(()=>a.node.code.replace(/\]::([^:])/g,"]:::$1").replace(/:::subgraphNode$/gm,"::subgraphNode")),Le=c(1),$e=c(0),ze=c(0),Ae=c(!1),Fe=c({x:0,y:0}),Re=c(!1),He=c(!1),_e=c(!1),Xe=c(null),Ne=c(0),Ye=c(!1);let Ze=null,Ie=null,qe=0;const Ve=null!=(o=globalThis.requestIdleCallback)?o:(e,t)=>setTimeout(()=>e({didTimeout:!0}),16),Ue=function(){let e=null;return(...t)=>{e&&clearTimeout(e),e=setTimeout(()=>(()=>{Ve(()=>{Vt()},{timeout:500})})(...t),300)}}();function We(){null!=Ie&&(globalThis.clearTimeout(Ie),Ie=null)}function Ge(e=600){if("undefined"==typeof globalThis)return;const t=Math.max(0,e);We(),Ie=globalThis.setTimeout(()=>{Ie=null,a.loading||_e.value||!Se.value?Ge(Math.min(1200,Math.max(300,1.2*t))):Ue()},t)}const Ke=c("360px");let Je=null;const Qe=c(!1),et=c(!1),tt=c({}),lt=c(null),nt=c(""),ot=c(0);let rt=null;const at=c(!1),it=c({zoom:1,translateX:0,translateY:0,containerHeight:"360px"}),ut=v(()=>a.enableWheelZoom?{wheel:_t}:{}),st=v(()=>{var e,t,l,n;return{worker:null!=(e=a.workerTimeoutMs)?e:1400,parse:null!=(t=a.parseTimeoutMs)?t:1800,render:null!=(l=a.renderTimeoutMs)?l:2500,fullRender:null!=(n=a.fullRenderTimeoutMs)?n:4e3}}),ct=null!=(r=globalThis.cancelIdleCallback)?r:e=>clearTimeout(e);let vt=null,dt=null,mt=!1,ht=800,gt=null,ft=0,pt=!0;function wt(e,t){const l=null==t?void 0:t.timeoutMs,n=null==t?void 0:t.signal;if(null==n?void 0:n.aborted)return Promise.reject(new DOMException("Aborted","AbortError"));let o=null,r=!1,a=null;return new Promise((t,i)=>{const u=()=>{null!=o&&clearTimeout(o),a&&n&&n.removeEventListener("abort",a)};l&&l>0&&(o=globalThis.setTimeout(()=>{r||(r=!0,u(),i(new Error("Operation timed out")))},l)),n&&(a=()=>{r||(r=!0,u(),i(new DOMException("Aborted","AbortError")))},n.addEventListener("abort",a)),e().then(e=>{r||(r=!0,u(),t(e))}).catch(e=>{r||(r=!0,u(),i(e))})})}function yt(e){if("undefined"==typeof document)return;if(!Ce.value)return;const t=document.createElement("div");t.className="text-red-500 p-4",t.textContent="Failed to render diagram: ";const l=document.createElement("span");l.textContent=e instanceof Error?e.message:"Unknown error",t.appendChild(l),we(Ce.value),Ce.value.appendChild(t),Ke.value="360px",at.value=!0,Ut()}function xt(e){return!e||e.disabled}function kt(e,t,l="top"){if(xt(e.currentTarget))return;const n=e,o=null!=(null==n?void 0:n.clientX)&&null!=(null==n?void 0:n.clientY)?{x:n.clientX,y:n.clientY}:void 0;H(e.currentTarget,t,l,!1,o,a.isDark)}function bt(){_()}function Mt(e){if(xt(e.currentTarget))return;const t=be.value?xe("common.copied")||"Copied":xe("common.copy")||"Copy",l=e,n=null!=(null==l?void 0:l.clientX)&&null!=(null==l?void 0:l.clientY)?{x:l.clientX,y:l.clientY}:void 0;H(e.currentTarget,t,"top",!1,n,a.isDark)}function Tt(e,t){const l=`%%{init: {"theme": "${"dark"===t?"dark":"default"}"}}%%\n`;return e.trimStart().startsWith("%%{")?e:l+e}function Ct(){return pt&&!Re.value&&!Qe.value&&!at.value}function Dt(e){const t=e.split(/\r?\n/);for(;t.length>0;){const e=t[t.length-1].trimEnd();if(""!==e){if(!(/^[-=~>|<\s]+$/.test(e.trim())||/(?:--|==|~~|->|<-|-\||-\)|-x|o-|\|-|\.-)\s*$/.test(e)||/[-|><]$/.test(e)||/(?:graph|flowchart|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt)\s*$/i.test(e)))break;t.pop()}else t.pop()}return t.join("\n")}function Bt(e,t,l){return u(this,null,function*(){var n;try{return yield X(e,t,null!=(n=null==l?void 0:l.timeoutMs)?n:st.value.worker)}catch(o){return yield function(e,t,l){return u(this,null,function*(){var n,o;const r=yield ke();if(!r)return;const a=r,i=Tt(e,t);if("function"==typeof a.parse)return yield wt(()=>a.parse(i),{timeoutMs:null!=(n=null==l?void 0:l.timeoutMs)?n:st.value.parse,signal:null==l?void 0:l.signal}),!0;const u=`mermaid-parse-${Math.random().toString(36).slice(2,9)}`;return yield wt(()=>r.render(u,i),{timeoutMs:null!=(o=null==l?void 0:l.timeoutMs)?o:st.value.render,signal:null==l?void 0:l.signal}),!0})}(e,t,l)}})}"undefined"!=typeof window&&d(()=>Te.value,e=>{var t;if(null==(t=Ee.value)||t.destroy(),Ee.value=null,!e)return void(Se.value=!1);const l=je(e,{rootMargin:"400px"});Ee.value=l,Se.value=l.isVisible.value,l.whenVisible.then(()=>{Se.value=!0})},{immediate:!0}),m(()=>{var e;null==(e=Ee.value)||e.destroy(),Ee.value=null});const jt=v(()=>Re.value||_e.value||Me.value);function Et(e){if(!Te.value||!Ce.value)return;const t=Ce.value.querySelector("svg");if(!t)return;let l=0,n=0;const o=t.getAttribute("viewBox"),r=t.getAttribute("width"),a=t.getAttribute("height");if(o){const e=o.split(" ");4===e.length&&(l=Number.parseFloat(e[2]),n=Number.parseFloat(e[3]))}if(l&&n||r&&a&&(l=Number.parseFloat(r),n=Number.parseFloat(a)),Number.isNaN(l)||Number.isNaN(n)||l<=0||n<=0)try{const e=t.getBBox();e&&e.width>0&&e.height>0&&(l=e.width,n=e.height)}catch(i){return void console.error("Failed to get SVG BBox:",i)}if(l>0&&n>0){const t=n/l;let o=(null!=e?e:Te.value.clientWidth)*t;o>n&&(o=n),Ke.value=`${o}px`}}const St=c(!1),Ot=v(()=>({transform:`translate(${$e.value}px, ${ze.value}px) scale(${Le.value})`}));function Pt(e){"Escape"===e.key&&St.value&&Lt()}function Lt(){if(St.value=!1,De.value&&we(De.value),Be.value=null,"undefined"!=typeof document)try{document.body.style.overflow=""}catch(e){}if("undefined"!=typeof window)try{window.removeEventListener("keydown",Pt)}catch(e){}}function $t(){Le.value<3&&(Le.value+=.1)}function zt(){Le.value>.5&&(Le.value-=.1)}function At(){Le.value=1,$e.value=0,ze.value=0}function Ft(e){Ae.value=!0,e instanceof MouseEvent?Fe.value={x:e.clientX-$e.value,y:e.clientY-ze.value}:Fe.value={x:e.touches[0].clientX-$e.value,y:e.touches[0].clientY-ze.value}}function Rt(e){if(!Ae.value)return;let t,l;e instanceof MouseEvent?(t=e.clientX,l=e.clientY):(t=e.touches[0].clientX,l=e.touches[0].clientY),$e.value=t-Fe.value.x,ze.value=l-Fe.value.y}function Ht(){Ae.value=!1}function _t(e){if(a.enableWheelZoom&&(e.ctrlKey||e.metaKey)){if(e.preventDefault(),!Te.value)return;const t=Te.value.getBoundingClientRect(),l=e.clientX-t.left,n=e.clientY-t.top,o=l-t.width/2,r=n-t.height/2,a=(o-$e.value)/Le.value,i=(r-ze.value)/Le.value,u=.01,s=-e.deltaY*u,c=Math.min(Math.max(Le.value+s,.5),3);c!==Le.value&&($e.value=o-a*c,ze.value=r-i*c,Le.value=c)}}function Xt(){return u(this,null,function*(){try{const e=Pe.value,t={payload:{type:"copy",text:e},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0}};if(s("copy",t),t.defaultPrevented)return;"undefined"!=typeof navigator&&navigator.clipboard&&"function"==typeof navigator.clipboard.writeText&&(yield navigator.clipboard.writeText(e)),be.value=!0,setTimeout(()=>{be.value=!1},1e3)}catch(e){console.error("Failed to copy:",e)}})}function Nt(){var e;const t=null==(e=Ce.value)?void 0:e.querySelector("svg");if(!t)return void console.error("SVG element not found");const l=(new XMLSerializer).serializeToString(t),n={payload:{type:"export"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:t,svgString:l};s("export",n),n.defaultPrevented||function(e,t=null){u(this,null,function*(){try{const n=null!=t?t:(new XMLSerializer).serializeToString(e),o=new Blob([n],{type:"image/svg+xml;charset=utf-8"}),r=URL.createObjectURL(o);if("undefined"!=typeof document){const e=document.createElement("a");e.href=r,e.download=`mermaid-diagram-${Date.now()}.svg`;try{document.body.appendChild(e),e.click(),document.body.removeChild(e)}catch(l){}URL.revokeObjectURL(r)}}catch(n){console.error("Failed to export SVG:",n)}})}(t,l)}function Yt(){var e,t;const l=null!=(t=null==(e=Ce.value)?void 0:e.querySelector("svg"))?t:null,n=l?(new XMLSerializer).serializeToString(l):null,o={payload:{type:"open-modal"},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0},svgElement:l,svgString:n};s("openModal",o),o.defaultPrevented||function(){if(St.value=!0,"undefined"!=typeof document)try{document.body.style.overflow="hidden"}catch(e){}if("undefined"!=typeof window)try{window.addEventListener("keydown",Pt)}catch(e){}h(()=>{if(Te.value&&De.value){const e=Te.value.cloneNode(!0);e.classList.add("fullscreen");const t=e.querySelector("[data-mermaid-wrapper]");t&&(Be.value=t,t.style.transform=Ot.value.transform),we(De.value),De.value.appendChild(e)}})}()}function Zt(e){const t={payload:{type:"toggle-mode",target:e},defaultPrevented:!1,preventDefault(){this.defaultPrevented=!0}};s("toggleMode",e,t),t.defaultPrevented||It(e)}function It(e){return u(this,null,function*(){const t=Oe.value;if(!t)return He.value=!0,void(Re.value="source"===e);const l=t.getBoundingClientRect().height;t.style.height=`${l}px`,t.style.overflow="hidden",He.value=!0,Re.value="source"===e,yield h();const n=t.scrollHeight;t.style.transition="height 180ms ease",t.offsetHeight,t.style.height=`${n}px`;const o=()=>{t.style.transition="",t.style.height="",t.style.overflow="",t.removeEventListener("transitionend",r)};function r(){o()}t.addEventListener("transitionend",r),setTimeout(()=>o(),220)})}function qt(){return u(this,null,function*(){return _e.value?Xe.value:Ce.value||(yield h(),Ce.value)?(_e.value=!0,Xe.value=u(null,null,function*(){var e,n,o;Ce.value&&(Ce.value.style.opacity="0");try{const r=yield ke();if(!r)return;const u=`mermaid-${Date.now()}-${Math.random().toString(36).substring(2,11)}`;Qe.value||et.value||null==(e=r.initialize)||e.call(r,(n=i({},he.value),o={dompurifyConfig:i({},Z)},t(n,l(o))));const s=function(e,t=Pe.value){const l=t,n=`%%{init: {"theme": "${"dark"===e?"dark":"default"}"}}%%\n`;return l.trim().startsWith("%%{")?l:n+l}(a.isDark?"dark":"light"),c=yield wt(()=>r.render(u,s),{timeoutMs:st.value.fullRender}),v=null==c?void 0:c.svg;if(Ce.value){const e=ye(Ce.value,v);Qe.value||et.value||(Et(),Qe.value=!0,it.value={zoom:Le.value,translateX:$e.value,translateY:ze.value,containerHeight:Ke.value});const t=a.isDark?"dark":"light";e&&(tt.value[t]=e),et.value&&(et.value=!1),at.value=!1,qe=0,We()}}catch(r){const e=function(e){const t="string"==typeof e?e:"string"==typeof(null==e?void 0:e.message)?e.message:"";return"string"==typeof t&&/timed out/i.test(t)}(r),t=qe+1;e&&t<=3?(qe=t,Ge(Math.min(1200,600*t))):(qe=0,We(),console.error("Failed to render mermaid diagram:",r),!1===a.loading&&yt(r))}finally{yield h(),Ce.value&&(Ce.value.style.opacity="1"),_e.value=!1,Xe.value=null}}),Xe.value):void console.warn("Mermaid container not ready")})}function Vt(){return u(this,null,function*(){var e,t;const l=Date.now(),n=++ot.value;rt&&rt.abort(),rt=new AbortController;const o=rt.signal,r=a.isDark?"dark":"light",i=Pe.value,s=i.replace(/\s+/g,"");if(!i.trim())return Ce.value&&we(Ce.value),lt.value=null,nt.value="",void(at.value=!1);if(s===nt.value)return;try{const c=yield function(e,t,l){return u(this,null,function*(){var n;try{if(yield Bt(e,t,l))return{fullOk:!0,prefixOk:!1}}catch(r){if("AbortError"===(null==r?void 0:r.name))throw r}let o=Dt(e);if(o&&o.trim()&&o!==e)try{try{const r=yield N(e,t,null!=(n=null==l?void 0:l.timeoutMs)?n:st.value.worker);r&&r.trim()&&(o=r)}catch(r){}if(yield Bt(o,t,l))return{fullOk:!1,prefixOk:!0,prefix:o}}catch(r){if("AbortError"===(null==r?void 0:r.name))throw r}return{fullOk:!1,prefixOk:!1}})}(i,r,{signal:o,timeoutMs:st.value.worker});if(c.fullOk)return yield qt(),void(ot.value===n&&(lt.value=null!=(t=null==(e=Ce.value)?void 0:e.innerHTML)?t:null,nt.value=s,at.value=!1));const v=ft&&l<=ft;if(c.prefixOk&&c.prefix&&Ct()&&!v)return void(yield function(e){return u(this,null,function*(){if(Ct()&&(Ce.value||(yield h(),Ce.value))&&!_e.value){_e.value=!0;try{const t=yield ke();if(!t)return;const l=`mermaid-partial-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,n=a.isDark?"dark":"light",o=Dt(e),r=Tt(o&&o.trim()?o:e,n);Ce.value&&(Ce.value.style.opacity="0");const i=yield wt(()=>t.render(l,r),{timeoutMs:st.value.render}),u=null==i?void 0:i.svg;Ce.value&&u&&(ye(Ce.value,u),Et())}catch(t){}finally{yield h(),Ce.value&&(Ce.value.style.opacity="1"),_e.value=!1}}})}(c.prefix))}catch(v){if("AbortError"===(null==v?void 0:v.name))return}if(ot.value!==n)return;if(at.value)return;const c=tt.value[r];c&&Ce.value&&ye(Ce.value,c)})}function Ut(){mt&&(mt=!1,ht=800,pt=!1,gt&&(gt.abort(),gt=null),vt&&(globalThis.clearTimeout(vt),vt=null),dt&&(ct(dt),dt=null),ft=Date.now())}function Wt(){if(Ut(),rt){try{rt.abort()}catch(e){}rt=null}if(gt){try{gt.abort()}catch(e){}gt=null}Y(),We(),qe=0}function Gt(e=800){mt&&(vt&&globalThis.clearTimeout(vt),vt=globalThis.setTimeout(()=>{dt=Ve(()=>u(null,null,function*(){if(!mt)return;if(Re.value||Qe.value)return void Ut();const e=a.isDark?"dark":"light",t=Pe.value;if(t.trim()){gt&>.abort(),gt=new AbortController;try{if((yield Bt(t,e,{signal:gt.signal,timeoutMs:st.value.worker}))&&(yield qt(),Qe.value))return void Ut()}catch(l){}ht=Math.min(Math.floor(1.5*ht),4e3),Gt(ht)}else Gt(ht)}),{timeout:500})},e))}function Kt(){mt||Re.value||Qe.value||(mt=!0,ft=0,pt=!0,Gt(500))}d(Ot,e=>{St.value&&Be.value&&(Be.value.style.transform=e.transform)},{immediate:!0}),d(()=>Pe.value,()=>{Qe.value=!1,tt.value={},Ue(),!Re.value&&de.value&&Kt(),function(){if(!Re.value)return;if(!de.value)return;const e=Pe.value.length;e!==Ne.value&&(Ye.value=!0,Ne.value=e,Ze&&clearTimeout(Ze),Ze=setTimeout(()=>{Ye.value&&Re.value&&Pe.value.trim()&&(Ye.value=!1,It("preview"))},500))}()}),d(()=>a.isDark,()=>u(null,null,function*(){if(!Qe.value)return;if(at.value)return;const e=a.isDark?"dark":"light",t=tt.value[e];if(t)return void(Ce.value&&ye(Ce.value,t));const l={zoom:Le.value,translateX:$e.value,translateY:ze.value,containerHeight:Ke.value},n=1!==Le.value||0!==$e.value||0!==ze.value;et.value=!0,n&&(Le.value=1,$e.value=0,ze.value=0,yield h()),yield qt(),n&&(yield h(),Le.value=l.zoom,$e.value=l.translateX,ze.value=l.translateY,Ke.value=l.containerHeight,it.value=l)})),d(()=>Re.value,e=>u(null,null,function*(){if(e)Ut(),Qe.value&&(it.value={zoom:Le.value,translateX:$e.value,translateY:ze.value,containerHeight:Ke.value});else{if(at.value)return;const e=a.isDark?"dark":"light";if(Qe.value&&tt.value[e])return yield h(),Ce.value&&ye(Ce.value,tt.value[e]),Le.value=it.value.zoom,$e.value=it.value.translateX,ze.value=it.value.translateY,void(Ke.value=it.value.containerHeight);if(yield h(),!de.value)return;yield Vt(),Kt()}})),d(()=>a.loading,(e,t)=>u(null,null,function*(){if(!0===t&&!1===e){const e=Pe.value.trim();if(!e)return Wt();const t=a.isDark?"dark":"light",n=e.replace(/\s+/g,"");if(Qe.value&&n===nt.value)return yield h(),Ce.value&&!Ce.value.querySelector("svg")&&tt.value[t]&&ye(Ce.value,tt.value[t]),void Wt();try{yield Bt(e,t,{timeoutMs:st.value.worker}),yield qt(),nt.value=n,at.value=!1,Wt()}catch(l){Wt(),yt(l)}}})),d(Te,e=>{Je&&Je.disconnect(),!e||Qe.value||et.value||(Je=new ResizeObserver(e=>{e&&e.length>0&&!Qe.value&&!et.value&&I(()=>{Et(e[0].contentRect.width)})}),Je.observe(e))},{immediate:!0}),g(()=>u(null,null,function*(){yield h(),He.value||(Re.value=!de.value),Se.value&&(Ue(),Ne.value=Pe.value.length)})),d(()=>de.value,e=>{He.value||(Re.value=!e)}),d(()=>Se.value,e=>{e&&(Qe.value||(Ue(),Ne.value=Pe.value.length),a.loading||Qe.value||Ue())},{immediate:!1}),f(()=>{Ze&&clearTimeout(Ze),Je&&Je.disconnect(),rt&&(rt.abort(),rt=null),Y(),Ut(),We()}),d(()=>Me.value,e=>u(null,null,function*(){e?(Ut(),rt&&rt.abort()):Qe.value||(yield h(),Ue(),Re.value||Kt())}),{immediate:!1});const Jt=v(()=>a.isDark?"mermaid-action-btn p-2 text-xs rounded text-gray-400 hover:bg-gray-700 hover:text-gray-200":"mermaid-action-btn p-2 text-xs rounded text-gray-600 hover:bg-gray-200 hover:text-gray-700");return(e,t)=>(w(),p("div",{class:y(["my-4 rounded-lg border overflow-hidden shadow-sm",[a.isDark?"border-gray-700/30":"border-gray-200",{"is-rendering":a.loading}]])},[a.showHeader?(w(),p("div",{key:0,class:y(["mermaid-block-header flex justify-between items-center px-4 py-2.5 border-b",a.isDark?"bg-gray-800 border-gray-700/30":"bg-gray-50 border-gray-200"])},[e.$slots["header-left"]?(w(),p("div",q,[b(e.$slots,"header-left",{},void 0,!0)])):(w(),p("div",V,[M("img",{src:T("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%20width='16'%20height='16'%3e%3cpath%20fill='none'%20stroke='%23ca9ee6'%20stroke-linecap='round'%20stroke-linejoin='round'%20d='M1.5%202.5c0%206%202.25%205.75%204%207%20.83.67%201.17%202%201%204h3c-.17-2%20.17-3.33%201-4%201.75-1.25%204-1%204-7C12%202.5%2010%203%208%207%206%203%204%202.5%201.5%202.5'%20/%3e%3c/svg%3e"),class:"w-4 h-4 my-0",alt:"Mermaid"},null,8,U),M("span",{class:y(["text-sm font-medium font-mono truncate",a.isDark?"text-gray-400":"text-gray-600"])},"Mermaid",2)])),e.$slots["header-center"]?(w(),p("div",W,[b(e.$slots,"header-center",{},void 0,!0)])):a.showModeToggle&&de.value?(w(),p("div",{key:3,class:y(["flex items-center space-x-1 rounded-md p-0.5",a.isDark?"bg-gray-700":"bg-gray-100"])},[M("button",{class:y(["px-2.5 py-1 text-xs rounded transition-colors",[Re.value?a.isDark?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700":a.isDark?"bg-gray-600 text-gray-200 shadow-sm":"bg-white text-gray-700 shadow-sm"]]),onClick:t[0]||(t[0]=()=>Zt("preview")),onMouseenter:t[1]||(t[1]=e=>kt(e,T(xe)("common.preview")||"Preview")),onFocus:t[2]||(t[2]=e=>kt(e,T(xe)("common.preview")||"Preview")),onMouseleave:bt,onBlur:bt},[M("div",G,[t[21]||(t[21]=M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[M("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[M("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0"}),M("circle",{cx:"12",cy:"12",r:"3"})])],-1)),M("span",null,C(T(xe)("common.preview")||"Preview"),1)])],34),M("button",{class:y(["px-2.5 py-1 text-xs rounded transition-colors",[Re.value?a.isDark?"bg-gray-600 text-gray-200 shadow-sm":"bg-white text-gray-700 shadow-sm":a.isDark?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700"]]),onClick:t[3]||(t[3]=()=>Zt("source")),onMouseenter:t[4]||(t[4]=e=>kt(e,T(xe)("common.source")||"Source")),onFocus:t[5]||(t[5]=e=>kt(e,T(xe)("common.source")||"Source")),onMouseleave:bt,onBlur:bt},[M("div",K,[t[22]||(t[22]=M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[M("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m16 18l6-6l-6-6M8 6l-6 6l6 6"})],-1)),M("span",null,C(T(xe)("common.source")||"Source"),1)])],34)],2)):x("",!0),e.$slots["header-right"]?(w(),p("div",J,[b(e.$slots,"header-right",{},void 0,!0)])):(w(),p("div",Q,[a.showCollapseButton?(w(),p("button",{key:0,class:y(Jt.value),"aria-pressed":Me.value,onClick:t[6]||(t[6]=e=>Me.value=!Me.value),onMouseenter:t[7]||(t[7]=e=>kt(e,Me.value?T(xe)("common.expand")||"Expand":T(xe)("common.collapse")||"Collapse")),onFocus:t[8]||(t[8]=e=>kt(e,Me.value?T(xe)("common.expand")||"Expand":T(xe)("common.collapse")||"Collapse")),onMouseleave:bt,onBlur:bt},[(w(),p("svg",{style:D({rotate:Me.value?"0deg":"90deg"}),xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[...t[23]||(t[23]=[M("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m9 18l6-6l-6-6"},null,-1)])],4))],42,ee)):x("",!0),a.showCopyButton?(w(),p("button",{key:1,class:y(Jt.value),onClick:Xt,onMouseenter:t[9]||(t[9]=e=>Mt(e)),onFocus:t[10]||(t[10]=e=>Mt(e)),onMouseleave:bt,onBlur:bt},[be.value?(w(),p("svg",le,[...t[25]||(t[25]=[M("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 6L9 17l-5-5"},null,-1)])])):(w(),p("svg",te,[...t[24]||(t[24]=[M("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[M("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),M("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})],-1)])]))],34)):x("",!0),a.showExportButton&&de.value?(w(),p("button",{key:2,class:y(`${Jt.value} ${jt.value?"opacity-50 cursor-not-allowed":""}`),disabled:jt.value,onClick:Nt,onMouseenter:t[11]||(t[11]=e=>kt(e,T(xe)("common.export")||"Export")),onFocus:t[12]||(t[12]=e=>kt(e,T(xe)("common.export")||"Export")),onMouseleave:bt,onBlur:bt},[...t[26]||(t[26]=[M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[M("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[M("path",{d:"M12 15V3m9 12v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),M("path",{d:"m7 10l5 5l5-5"})])],-1)])],42,ne)):x("",!0),a.showFullscreenButton&&de.value?(w(),p("button",{key:3,class:y(`${Jt.value} ${jt.value?"opacity-50 cursor-not-allowed":""}`),disabled:jt.value,onClick:Yt,onMouseenter:t[13]||(t[13]=e=>kt(e,St.value?T(xe)("common.minimize")||"Minimize":T(xe)("common.open")||"Open")),onFocus:t[14]||(t[14]=e=>kt(e,St.value?T(xe)("common.minimize")||"Minimize":T(xe)("common.open")||"Open")),onMouseleave:bt,onBlur:bt},[St.value?(w(),p("svg",ae,[...t[28]||(t[28]=[M("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"},null,-1)])])):(w(),p("svg",re,[...t[27]||(t[27]=[M("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"},null,-1)])]))],42,oe)):x("",!0)]))],2)):x("",!0),k(M("div",{ref_key:"modeContainerRef",ref:Oe},[Re.value?(w(),p("div",{key:0,class:y(["p-4",a.isDark?"bg-gray-900":"bg-gray-50"])},[M("pre",{class:y(["text-sm font-mono whitespace-pre-wrap",a.isDark?"text-gray-300":"text-gray-700"])},C(Pe.value),3)],2)):(w(),p("div",ie,[a.showZoomControls?(w(),p("div",ue,[M("div",se,[M("button",{class:y(["p-2 text-xs rounded transition-colors",[a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"]]),onClick:$t,onMouseenter:t[15]||(t[15]=e=>kt(e,T(xe)("common.zoomIn")||"Zoom in")),onFocus:t[16]||(t[16]=e=>kt(e,T(xe)("common.zoomIn")||"Zoom in")),onMouseleave:bt,onBlur:bt},[...t[29]||(t[29]=[M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[M("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[M("circle",{cx:"11",cy:"11",r:"8"}),M("path",{d:"m21 21l-4.35-4.35M11 8v6m-3-3h6"})])],-1)])],34),M("button",{class:y(["p-2 text-xs rounded transition-colors",[a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"]]),onClick:zt,onMouseenter:t[17]||(t[17]=e=>kt(e,T(xe)("common.zoomOut")||"Zoom out")),onFocus:t[18]||(t[18]=e=>kt(e,T(xe)("common.zoomOut")||"Zoom out")),onMouseleave:bt,onBlur:bt},[...t[30]||(t[30]=[M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[M("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[M("circle",{cx:"11",cy:"11",r:"8"}),M("path",{d:"m21 21l-4.35-4.35M8 11h6"})])],-1)])],34),M("button",{class:y(["p-2 text-xs rounded transition-colors",[a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"]]),onClick:At,onMouseenter:t[19]||(t[19]=e=>kt(e,T(xe)("common.resetZoom")||"Reset zoom")),onFocus:t[20]||(t[20]=e=>kt(e,T(xe)("common.resetZoom")||"Reset zoom")),onMouseleave:bt,onBlur:bt},C(Math.round(100*Le.value))+"% ",35)])])):x("",!0),M("div",j({ref_key:"mermaidContainer",ref:Te,class:["min-h-[360px] relative transition-all duration-100 overflow-hidden block",a.isDark?"bg-gray-900":"bg-gray-50"],style:{height:Ke.value}},E(ut.value,!0),{onMousedown:Ft,onMousemove:Rt,onMouseup:Ht,onMouseleave:Ht,onTouchstartPassive:Ft,onTouchmovePassive:Rt,onTouchendPassive:Ht}),[M("div",{"data-mermaid-wrapper":"",class:y(["absolute inset-0 cursor-grab",{"cursor-grabbing":Ae.value}]),style:D(Ot.value)},[M("div",{ref_key:"mermaidContent",ref:Ce,class:"_mermaid w-full text-center flex items-center justify-center min-h-full"},null,512)],6)],16),(w(),B(S,{to:"body"},[M("div",ce,[O(P,{name:"mermaid-dialog",appear:""},{default:L(()=>[St.value?(w(),p("div",{key:0,class:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4",onClick:$(Lt,["self"])},[M("div",{class:y(["dialog-panel relative w-full h-full max-w-full max-h-full rounded shadow-lg overflow-hidden",a.isDark?"bg-gray-900":"bg-white"])},[M("div",ve,[M("button",{class:y(["p-2 text-xs rounded transition-colors",[a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"]]),onClick:$t},[...t[31]||(t[31]=[M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[M("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[M("circle",{cx:"11",cy:"11",r:"8"}),M("path",{d:"m21 21l-4.35-4.35M11 8v6m-3-3h6"})])],-1)])],2),M("button",{class:y(["p-2 text-xs rounded transition-colors",[a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"]]),onClick:zt},[...t[32]||(t[32]=[M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[M("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[M("circle",{cx:"11",cy:"11",r:"8"}),M("path",{d:"m21 21l-4.35-4.35M8 11h6"})])],-1)])],2),M("button",{class:y(["p-2 text-xs rounded transition-colors",[a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"]]),onClick:At},C(Math.round(100*Le.value))+"% ",3),M("button",{class:y(["inline-flex items-center justify-center p-2 rounded transition-colors",[a.isDark?"text-gray-400 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"]]),onClick:Lt},[...t[33]||(t[33]=[M("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",class:"w-3 h-3"},[M("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M18 6L6 18M6 6l12 12"})],-1)])],2)]),M("div",j({ref_key:"modalContent",ref:De,class:"w-full h-full flex items-center justify-center p-4 overflow-hidden"},E(ut.value,!0),{onMousedown:Ft,onMousemove:Rt,onMouseup:Ht,onMouseleave:Ht,onTouchstartPassive:Ft,onTouchmovePassive:Rt,onTouchendPassive:Ht}),null,16)],2)])):x("",!0)]),_:1})])]))]))],512),[[z,!Me.value]])],2))}}),[["__scopeId","data-v-802cdc0a"]]);de.install=e=>{e.component(de.__name,de)};export{de as default};
|
package/dist/safeRaf.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){try{if("undefined"!=typeof globalThis&&"function"==typeof globalThis.requestAnimationFrame)return globalThis.requestAnimationFrame(e)}catch(t){}return globalThis.setTimeout(e,0)}export{e as s};
|
package/dist/tailwind.ts
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markstream-vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.4
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"description": "Vue 3 Markdown renderer optimized for large docs: progressive Mermaid, streaming diff code blocks, and fast real-time preview.",
|
|
6
6
|
"author": "Simon He",
|
|
7
7
|
"license": "MIT",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
98
|
"@floating-ui/dom": "^1.7.4",
|
|
99
|
-
"stream-markdown-parser": "0.0.
|
|
99
|
+
"stream-markdown-parser": "0.0.53"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
102
|
"@antfu/eslint-config": "^5.4.1",
|
|
@@ -148,6 +148,7 @@
|
|
|
148
148
|
"play:vue2": "pnpm run -C playground-vue2 dev",
|
|
149
149
|
"play:build": "pnpm run -C playground build",
|
|
150
150
|
"play:vue2:build": "pnpm run -C playground-vue2 build",
|
|
151
|
+
"play:vue2:preview": "pnpm run -C playground-vue2 preview",
|
|
151
152
|
"play:nuxt": "pnpm run -C playground-nuxt dev",
|
|
152
153
|
"play:nuxt:build": "pnpm run -C playground-nuxt build",
|
|
153
154
|
"play:nuxt:preview": "pnpm run -C playground-nuxt preview",
|