UNPKG

markstream-vue

Version:

Vue 3 Markdown renderer optimized for large docs: progressive Mermaid, streaming diff code blocks, and fast real-time preview.

2 lines (1 loc) 2.39 kB
var n=(n,e,l)=>new Promise((a,t)=>{var o=n=>{try{i(l.next(n))}catch(e){t(e)}},r=n=>{try{i(l.throw(n))}catch(e){t(e)}},i=n=>n.done?a(n.value):Promise.resolve(n.value).then(o,r);i((l=l.apply(n,e)).next())});import{defineComponent as e,ref as l,watch as a,onMounted as t,onBeforeUnmount as o,createElementBlock as r,openBlock as i,withDirectives as s,createBlock as u,createCommentVNode as d,createElementVNode as c,vShow as v,Transition as p,withCtx as m,renderSlot as f}from"vue";import{a as h,r as _,e as y,f as g,W as R,d as w}from"./exports.js";const T={class:"math-inline__loading",role:"status","aria-live":"polite"},b=/* @__PURE__ */w(/* @__PURE__ */e({__name:"MathInlineNode",props:{node:{}},setup(e){const w=e;let b=null;const E=l(null),x=l(null);let I=!1,M=0,O=!1,k=null;const L=l(!0),W=h();let C=null;function H(){return n(this,null,function*(){if(!w.node.content||!x.value||O)return;k&&(k.abort(),k=null);const e=++M,l=new AbortController;if(k=l,!I)try{!C&&E.value&&(C=W(E.value)),yield null==C?void 0:C.whenVisible}catch(a){}_(w.node.content,!1,{timeout:1500,waitTimeout:0,maxRetries:0,signal:l.signal}).then(n=>{O||e!==M||x.value&&(x.value.innerHTML=n,L.value=!1,I=!0)}).catch(l=>n(null,null,function*(){if(O||e!==M)return;if(!x.value)return;const n=(null==l?void 0:l.code)||(null==l?void 0:l.name);if(("WORKER_INIT_ERROR"===n||(null==l?void 0:l.fallbackToRenderer)||n===R||"WORKER_TIMEOUT"===n)&&(b||(b=yield y()),b))try{const n=b.renderToString(w.node.content,{throwOnError:w.node.loading,displayMode:!1});L.value=!1,x.value.innerHTML=n,I=!0,g(w.node.content,!1,n)}catch(a){}else I||(L.value=!0),w.node.loading||(L.value=!1,x.value.textContent=w.node.raw)}))})}return a(()=>w.node.content,()=>{H()}),t(()=>{H()}),o(()=>{var n;O=!0,k&&(k.abort(),k=null),null==(n=null==C?void 0:C.destroy)||n.call(C),C=null}),(n,e)=>(i(),r("span",{ref_key:"containerEl",ref:E,class:"math-inline-wrapper"},[s(c("span",{ref_key:"mathElement",ref:x,class:"math-inline"},null,512),[[v,!L.value]]),L.value?(i(),u(p,{key:0,name:"table-node-fade"},{default:m(()=>[c("span",T,[f(n.$slots,"loading",{isLoading:L.value},()=>[e[0]||(e[0]=c("span",{class:"math-inline__spinner animate-spin","aria-hidden":"true"},null,-1)),e[1]||(e[1]=c("span",{class:"sr-only"},"Loading",-1))],!0)])]),_:3})):d("",!0)],512))}}),[["__scopeId","data-v-6b23009e"]]);b.install=n=>{n.component(b.__name,b)};export{b as default};