UNPKG

code-server

Version:

Run VS Code on a remote server.

2 lines (1 loc) • 10.6 kB
import{a as _,c as N,d as F}from"./chunk-HSW5BITQ.js";import{a as U}from"./chunk-ORJ3II5F.js";import{D as C}from"./chunk-BBR2KTV7.js";import"./chunk-4JVZL74Y.js";import"./chunk-GEXIQSUR.js";import"./chunk-FEQH2MWK.js";import"./chunk-CL2PNEZF.js";import"./chunk-MI7L3JDQ.js";import"./chunk-EWILYK3H.js";import"./chunk-IR42YTGA.js";import"./chunk-MX6DGWIA.js";import"./chunk-JDBNYPCC.js";import"./chunk-623C5XAY.js";import{p as P}from"./chunk-PKRYIESI.js";import"./chunk-JBQZ5UCE.js";import{I as A,N as T,O as G,_ as t}from"./chunk-VBOJ6TJX.js";import{J as R,N as W,b as u,d as v,j as z}from"./chunk-XDY7PRES.js";import"./chunk-OOJM4CTU.js";var D=u(e=>e.append("circle").attr("class","start-state").attr("r",t().state.sizeUnit).attr("cx",t().state.padding+t().state.sizeUnit).attr("cy",t().state.padding+t().state.sizeUnit),"drawStartState"),Y=u(e=>e.append("line").style("stroke","grey").style("stroke-dasharray","3").attr("x1",t().state.textHeight).attr("class","divider").attr("x2",t().state.textHeight*2).attr("y1",0).attr("y2",0),"drawDivider"),I=u((e,i)=>{let s=e.append("text").attr("x",2*t().state.padding).attr("y",t().state.textHeight+2*t().state.padding).attr("font-size",t().state.fontSize).attr("class","state-title").text(i.id),g=s.node().getBBox();return e.insert("rect",":first-child").attr("x",t().state.padding).attr("y",t().state.padding).attr("width",g.width+2*t().state.padding).attr("height",g.height+2*t().state.padding).attr("rx",t().state.radius),s},"drawSimpleState"),$=u((e,i)=>{let s=u(function(o,w,m){let S=o.append("tspan").attr("x",2*t().state.padding).text(w);m||S.attr("dy",t().state.textHeight)},"addTspan"),n=e.append("text").attr("x",2*t().state.padding).attr("y",t().state.textHeight+1.3*t().state.padding).attr("font-size",t().state.fontSize).attr("class","state-title").text(i.descriptions[0]).node().getBBox(),h=n.height,p=e.append("text").attr("x",t().state.padding).attr("y",h+t().state.padding*.4+t().state.dividerMargin+t().state.textHeight).attr("class","state-description"),a=!0,d=!0;i.descriptions.forEach(function(o){a||(s(p,o,d),d=!1),a=!1});let y=e.append("line").attr("x1",t().state.padding).attr("y1",t().state.padding+h+t().state.dividerMargin/2).attr("y2",t().state.padding+h+t().state.dividerMargin/2).attr("class","descr-divider"),x=p.node().getBBox(),c=Math.max(x.width,n.width);return y.attr("x2",c+3*t().state.padding),e.insert("rect",":first-child").attr("x",t().state.padding).attr("y",t().state.padding).attr("width",c+2*t().state.padding).attr("height",x.height+h+2*t().state.padding).attr("rx",t().state.radius),e},"drawDescrState"),q=u((e,i,s)=>{let g=t().state.padding,n=2*t().state.padding,h=e.node().getBBox(),p=h.width,a=h.x,d=e.append("text").attr("x",0).attr("y",t().state.titleShift).attr("font-size",t().state.fontSize).attr("class","state-title").text(i.id),x=d.node().getBBox().width+n,c=Math.max(x,p);c===p&&(c=c+n);let o,w=e.node().getBBox();i.doc,o=a-g,x>p&&(o=(p-c)/2+g),Math.abs(a-w.x)<g&&x>p&&(o=a-(x-p)/2);let m=1-t().state.textHeight;return e.insert("rect",":first-child").attr("x",o).attr("y",m).attr("class",s?"alt-composit":"composit").attr("width",c).attr("height",w.height+t().state.textHeight+t().state.titleShift+1).attr("rx","0"),d.attr("x",o+g),x<=p&&d.attr("x",a+(c-n)/2-x/2+g),e.insert("rect",":first-child").attr("x",o).attr("y",t().state.titleShift-t().state.textHeight-t().state.padding).attr("width",c).attr("height",t().state.textHeight*3).attr("rx",t().state.radius),e.insert("rect",":first-child").attr("x",o).attr("y",t().state.titleShift-t().state.textHeight-t().state.padding).attr("width",c).attr("height",w.height+3+2*t().state.textHeight).attr("rx",t().state.radius),e},"addTitleAndBox"),Z=u(e=>(e.append("circle").attr("class","end-state-outer").attr("r",t().state.sizeUnit+t().state.miniPadding).attr("cx",t().state.padding+t().state.sizeUnit+t().state.miniPadding).attr("cy",t().state.padding+t().state.sizeUnit+t().state.miniPadding),e.append("circle").attr("class","end-state-inner").attr("r",t().state.sizeUnit).attr("cx",t().state.padding+t().state.sizeUnit+2).attr("cy",t().state.padding+t().state.sizeUnit+2)),"drawEndState"),j=u((e,i)=>{let s=t().state.forkWidth,g=t().state.forkHeight;if(i.parentId){let n=s;s=g,g=n}return e.append("rect").style("stroke","black").style("fill","black").attr("width",s).attr("height",g).attr("x",t().state.padding).attr("y",t().state.padding)},"drawForkJoinState"),K=u((e,i,s,g)=>{let n=0,h=g.append("text");h.style("text-anchor","start"),h.attr("class","noteText");let p=e.replace(/\r\n/g,"<br/>");p=p.replace(/\n/g,"<br/>");let a=p.split(T.lineBreakRegex),d=1.25*t().state.noteMargin;for(let y of a){let x=y.trim();if(x.length>0){let c=h.append("tspan");if(c.text(x),d===0){let o=c.node().getBBox();d+=o.height}n+=d,c.attr("x",i+t().state.noteMargin),c.attr("y",s+n+1.25*t().state.noteMargin)}}return{textWidth:h.node().getBBox().width,textHeight:n}},"_drawLongText"),Q=u((e,i)=>{i.attr("class","state-note");let s=i.append("rect").attr("x",0).attr("y",t().state.padding),g=i.append("g"),{textWidth:n,textHeight:h}=K(e,0,0,g);return s.attr("height",h+2*t().state.noteMargin),s.attr("width",n+t().state.noteMargin*2),s},"drawNote"),O=u(function(e,i){let s=i.id,g={id:s,label:i.id,width:0,height:0},n=e.append("g").attr("id",s).attr("class","stateGroup");i.type==="start"&&D(n),i.type==="end"&&Z(n),(i.type==="fork"||i.type==="join")&&j(n,i),i.type==="note"&&Q(i.note.text,n),i.type==="divider"&&Y(n),i.type==="default"&&i.descriptions.length===0&&I(n,i),i.type==="default"&&i.descriptions.length>0&&$(n,i);let h=n.node().getBBox();return g.width=h.width+2*t().state.padding,g.height=h.height+2*t().state.padding,g},"drawState"),J=0,V=u(function(e,i,s){let g=u(function(d){switch(d){case N.relationType.AGGREGATION:return"aggregation";case N.relationType.EXTENSION:return"extension";case N.relationType.COMPOSITION:return"composition";case N.relationType.DEPENDENCY:return"dependency"}},"getRelationType");i.points=i.points.filter(d=>!Number.isNaN(d.y));let n=i.points,h=R().x(function(d){return d.x}).y(function(d){return d.y}).curve(W),p=e.append("path").attr("d",h(n)).attr("id","edge"+J).attr("class","transition"),a="";if(t().state.arrowMarkerAbsolute&&(a=A(!0)),p.attr("marker-end","url("+a+"#"+g(N.relationType.DEPENDENCY)+"End)"),s.title!==void 0){let d=e.append("g").attr("class","stateLabel"),{x:y,y:x}=P.calcLabelPosition(i.points),c=T.getRows(s.title),o=0,w=[],m=0,S=0;for(let r=0;r<=c.length;r++){let f=d.append("text").attr("text-anchor","middle").text(c[r]).attr("x",y).attr("y",x+o),l=f.node().getBBox();m=Math.max(m,l.width),S=Math.min(S,l.x),v.info(l.x,y,x+o),o===0&&(o=f.node().getBBox().height,v.info("Title height",o,x)),w.push(f)}let k=o*c.length;if(c.length>1){let r=(c.length-1)*o*.5;w.forEach((f,l)=>f.attr("y",x+l*o-r)),k=o*c.length}let M=d.node().getBBox();d.insert("rect",":first-child").attr("class","box").attr("x",y-m/2-t().state.padding/2).attr("y",x-k/2-t().state.padding/2-3.5).attr("width",m+t().state.padding).attr("height",k+t().state.padding),v.info(M)}J++},"drawEdge"),b,L={},tt=u(function(){},"setConf"),et=u(function(e){e.append("defs").append("marker").attr("id","dependencyEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 19,7 L9,13 L14,7 L9,1 Z")},"insertMarkers"),at=u(function(e,i,s,g){b=t().state;let n=t().securityLevel,h;n==="sandbox"&&(h=z("#i"+i));let p=n==="sandbox"?z(h.nodes()[0].contentDocument.body):z("body"),a=n==="sandbox"?h.nodes()[0].contentDocument:document;v.debug("Rendering diagram "+e);let d=p.select(`[id='${i}']`);et(d);let y=g.db.getRootDoc(),x=d.append("g").attr("id",i+"-root");X(y,x,void 0,!1,p,a,g);let c=b.padding,o=d.node().getBBox(),w=o.width+c*2,m=o.height+c*2,S=w*1.75;G(d,m,S,b.useMaxWidth),d.attr("viewBox",`${o.x-b.padding} ${o.y-b.padding} `+w+" "+m)},"draw"),it=u(e=>e?e.length*b.fontSizeFactor:1,"getLabelWidth"),X=u((e,i,s,g,n,h,p)=>{let a=new C({compound:!0,multigraph:!0}),d,y=!0;for(d=0;d<e.length;d++)if(e[d].stmt==="relation"){y=!1;break}s?a.setGraph({rankdir:"LR",multigraph:!0,compound:!0,ranker:"tight-tree",ranksep:y?1:b.edgeLengthFactor,nodeSep:y?1:50,isMultiGraph:!0}):a.setGraph({rankdir:"TB",multigraph:!0,compound:!0,ranksep:y?1:b.edgeLengthFactor,nodeSep:y?1:50,ranker:"tight-tree",isMultiGraph:!0}),a.setDefaultEdgeLabel(function(){return{}});let x=p.db.getStates(),c=p.db.getRelations(),o=Object.keys(x),w=!0;for(let r of o){let f=x[r];s&&(f.parentId=s);let l;if(f.doc){let B=i.append("g").attr("id",f.id).attr("class","stateGroup");if(l=X(f.doc,B,f.id,!g,n,h,p),w){B=q(B,f,g);let E=B.node().getBBox();l.width=E.width,l.height=E.height+b.padding/2,L[f.id]={y:b.compositTitleSize}}else{let E=B.node().getBBox();l.width=E.width,l.height=E.height}}else l=O(i,f,a);if(f.note){let B={descriptions:[],id:f.id+"-note",note:f.note,type:"note"},E=O(i,B,a);f.note.position==="left of"?(a.setNode(l.id+"-note",E),a.setNode(l.id,l)):(a.setNode(l.id,l),a.setNode(l.id+"-note",E)),a.setParent(l.id,l.id+"-group"),a.setParent(l.id+"-note",l.id+"-group")}else a.setNode(l.id,l)}v.debug("Count=",a.nodeCount(),a);let m=0;c.forEach(function(r){m++,v.debug("Setting edge",r),a.setEdge(r.id1,r.id2,{relation:r,width:it(r.title),height:b.labelHeight*T.getRows(r.title).length,labelpos:"c"},"id"+m)}),U(a),v.debug("Graph after layout",a.nodes());let S=i.node();a.nodes().forEach(function(r){r!==void 0&&a.node(r)!==void 0?(v.warn("Node "+r+": "+JSON.stringify(a.node(r))),n.select("#"+S.id+" #"+r).attr("transform","translate("+(a.node(r).x-a.node(r).width/2)+","+(a.node(r).y+(L[r]?L[r].y:0)-a.node(r).height/2)+" )"),n.select("#"+S.id+" #"+r).attr("data-x-shift",a.node(r).x-a.node(r).width/2),h.querySelectorAll("#"+S.id+" #"+r+" .divider").forEach(l=>{let B=l.parentElement,E=0,H=0;B&&(B.parentElement&&(E=B.parentElement.getBBox().width),H=parseInt(B.getAttribute("data-x-shift"),10),Number.isNaN(H)&&(H=0)),l.setAttribute("x1",0-H+8),l.setAttribute("x2",E-H-8)})):v.debug("No Node "+r+": "+JSON.stringify(a.node(r)))});let k=S.getBBox();a.edges().forEach(function(r){r!==void 0&&a.edge(r)!==void 0&&(v.debug("Edge "+r.v+" -> "+r.w+": "+JSON.stringify(a.edge(r))),V(i,a.edge(r),a.edge(r).relation))}),k=S.getBBox();let M={id:s||"root",label:s||"root",width:0,height:0};return M.width=k.width+2*b.padding,M.height=k.height+2*b.padding,v.debug("Doc rendered",M,a),M},"renderDoc"),rt={setConf:tt,draw:at},St={parser:_,get db(){return new N(1)},renderer:rt,styles:F,init:u(e=>{e.state||(e.state={}),e.state.arrowMarkerAbsolute=e.arrowMarkerAbsolute},"init")};export{St as diagram};