ruru
Version:
Grafast-flavoured GraphiQL distribution
2 lines • 12.1 kB
JavaScript
export const __webpack_esm_id__=3311;export const __webpack_esm_ids__=[3311];export const __webpack_esm_modules__={13311(t,e,a){a.r(e),a.d(e,{diagram:()=>D});var i,n=a(48075),g=(a(65934),a(26819),a(87094),a(54275),a(51437),a(85533),a(70998),a(96540),a(67099),a(82029)),o=a(54141),r=a(60162),d=a(79806),s=a(8042),f=a(58558),l=(0,r.__name)(t=>t.append("circle").attr("class","start-state").attr("r",(0,o.getConfig2)().state.sizeUnit).attr("cx",(0,o.getConfig2)().state.padding+(0,o.getConfig2)().state.sizeUnit).attr("cy",(0,o.getConfig2)().state.padding+(0,o.getConfig2)().state.sizeUnit),"drawStartState"),p=(0,r.__name)(t=>t.append("line").style("stroke","grey").style("stroke-dasharray","3").attr("x1",(0,o.getConfig2)().state.textHeight).attr("class","divider").attr("x2",2*(0,o.getConfig2)().state.textHeight).attr("y1",0).attr("y2",0),"drawDivider"),c=(0,r.__name)((t,e)=>{const a=t.append("text").attr("x",2*(0,o.getConfig2)().state.padding).attr("y",(0,o.getConfig2)().state.textHeight+2*(0,o.getConfig2)().state.padding).attr("font-size",(0,o.getConfig2)().state.fontSize).attr("class","state-title").text(e.id),i=a.node().getBBox();return t.insert("rect",":first-child").attr("x",(0,o.getConfig2)().state.padding).attr("y",(0,o.getConfig2)().state.padding).attr("width",i.width+2*(0,o.getConfig2)().state.padding).attr("height",i.height+2*(0,o.getConfig2)().state.padding).attr("rx",(0,o.getConfig2)().state.radius),a},"drawSimpleState"),h=(0,r.__name)((t,e)=>{const a=(0,r.__name)(function(t,e,a){const i=t.append("tspan").attr("x",2*(0,o.getConfig2)().state.padding).text(e);a||i.attr("dy",(0,o.getConfig2)().state.textHeight)},"addTspan"),i=t.append("text").attr("x",2*(0,o.getConfig2)().state.padding).attr("y",(0,o.getConfig2)().state.textHeight+1.3*(0,o.getConfig2)().state.padding).attr("font-size",(0,o.getConfig2)().state.fontSize).attr("class","state-title").text(e.descriptions[0]).node().getBBox(),n=i.height,g=t.append("text").attr("x",(0,o.getConfig2)().state.padding).attr("y",n+.4*(0,o.getConfig2)().state.padding+(0,o.getConfig2)().state.dividerMargin+(0,o.getConfig2)().state.textHeight).attr("class","state-description");let d=!0,s=!0;e.descriptions.forEach(function(t){d||(a(g,t,s),s=!1),d=!1});const f=t.append("line").attr("x1",(0,o.getConfig2)().state.padding).attr("y1",(0,o.getConfig2)().state.padding+n+(0,o.getConfig2)().state.dividerMargin/2).attr("y2",(0,o.getConfig2)().state.padding+n+(0,o.getConfig2)().state.dividerMargin/2).attr("class","descr-divider"),l=g.node().getBBox(),p=Math.max(l.width,i.width);return f.attr("x2",p+3*(0,o.getConfig2)().state.padding),t.insert("rect",":first-child").attr("x",(0,o.getConfig2)().state.padding).attr("y",(0,o.getConfig2)().state.padding).attr("width",p+2*(0,o.getConfig2)().state.padding).attr("height",l.height+n+2*(0,o.getConfig2)().state.padding).attr("rx",(0,o.getConfig2)().state.radius),t},"drawDescrState"),x=(0,r.__name)((t,e,a)=>{const i=(0,o.getConfig2)().state.padding,n=2*(0,o.getConfig2)().state.padding,g=t.node().getBBox(),r=g.width,d=g.x,s=t.append("text").attr("x",0).attr("y",(0,o.getConfig2)().state.titleShift).attr("font-size",(0,o.getConfig2)().state.fontSize).attr("class","state-title").text(e.id),f=s.node().getBBox().width+n;let l,p=Math.max(f,r);p===r&&(p+=n);const c=t.node().getBBox();e.doc,l=d-i,f>r&&(l=(r-p)/2+i),Math.abs(d-c.x)<i&&f>r&&(l=d-(f-r)/2);const h=1-(0,o.getConfig2)().state.textHeight;return t.insert("rect",":first-child").attr("x",l).attr("y",h).attr("class",a?"alt-composit":"composit").attr("width",p).attr("height",c.height+(0,o.getConfig2)().state.textHeight+(0,o.getConfig2)().state.titleShift+1).attr("rx","0"),s.attr("x",l+i),f<=r&&s.attr("x",d+(p-n)/2-f/2+i),t.insert("rect",":first-child").attr("x",l).attr("y",(0,o.getConfig2)().state.titleShift-(0,o.getConfig2)().state.textHeight-(0,o.getConfig2)().state.padding).attr("width",p).attr("height",3*(0,o.getConfig2)().state.textHeight).attr("rx",(0,o.getConfig2)().state.radius),t.insert("rect",":first-child").attr("x",l).attr("y",(0,o.getConfig2)().state.titleShift-(0,o.getConfig2)().state.textHeight-(0,o.getConfig2)().state.padding).attr("width",p).attr("height",c.height+3+2*(0,o.getConfig2)().state.textHeight).attr("rx",(0,o.getConfig2)().state.radius),t},"addTitleAndBox"),C=(0,r.__name)(t=>(t.append("circle").attr("class","end-state-outer").attr("r",(0,o.getConfig2)().state.sizeUnit+(0,o.getConfig2)().state.miniPadding).attr("cx",(0,o.getConfig2)().state.padding+(0,o.getConfig2)().state.sizeUnit+(0,o.getConfig2)().state.miniPadding).attr("cy",(0,o.getConfig2)().state.padding+(0,o.getConfig2)().state.sizeUnit+(0,o.getConfig2)().state.miniPadding),t.append("circle").attr("class","end-state-inner").attr("r",(0,o.getConfig2)().state.sizeUnit).attr("cx",(0,o.getConfig2)().state.padding+(0,o.getConfig2)().state.sizeUnit+2).attr("cy",(0,o.getConfig2)().state.padding+(0,o.getConfig2)().state.sizeUnit+2)),"drawEndState"),u=(0,r.__name)((t,e)=>{let a=(0,o.getConfig2)().state.forkWidth,i=(0,o.getConfig2)().state.forkHeight;if(e.parentId){let t=a;a=i,i=t}return t.append("rect").style("stroke","black").style("fill","black").attr("width",a).attr("height",i).attr("x",(0,o.getConfig2)().state.padding).attr("y",(0,o.getConfig2)().state.padding)},"drawForkJoinState"),y=(0,r.__name)((t,e,a,i)=>{let n=0;const g=i.append("text");g.style("text-anchor","start"),g.attr("class","noteText");let r=t.replace(/\r\n/g,"<br/>");r=r.replace(/\n/g,"<br/>");const d=r.split(o.common_default.lineBreakRegex);let s=1.25*(0,o.getConfig2)().state.noteMargin;for(const t of d){const i=t.trim();if(i.length>0){const t=g.append("tspan");t.text(i),0===s&&(s+=t.node().getBBox().height),n+=s,t.attr("x",e+(0,o.getConfig2)().state.noteMargin),t.attr("y",a+n+1.25*(0,o.getConfig2)().state.noteMargin)}}return{textWidth:g.node().getBBox().width,textHeight:n}},"_drawLongText"),m=(0,r.__name)((t,e)=>{e.attr("class","state-note");const a=e.append("rect").attr("x",0).attr("y",(0,o.getConfig2)().state.padding),i=e.append("g"),{textWidth:n,textHeight:g}=y(t,0,0,i);return a.attr("height",g+2*(0,o.getConfig2)().state.noteMargin),a.attr("width",n+2*(0,o.getConfig2)().state.noteMargin),a},"drawNote"),_=(0,r.__name)(function(t,e){const a=e.id,i={id:a,label:e.id,width:0,height:0},n=t.append("g").attr("id",a).attr("class","stateGroup");"start"===e.type&&l(n),"end"===e.type&&C(n),"fork"!==e.type&&"join"!==e.type||u(n,e),"note"===e.type&&m(e.note.text,n),"divider"===e.type&&p(n),"default"===e.type&&0===e.descriptions.length&&c(n,e),"default"===e.type&&e.descriptions.length>0&&h(n,e);const g=n.node().getBBox();return i.width=g.width+2*(0,o.getConfig2)().state.padding,i.height=g.height+2*(0,o.getConfig2)().state.padding,i},"drawState"),w=0,B=(0,r.__name)(function(t,e,a){const i=(0,r.__name)(function(t){switch(t){case n.StateDB.relationType.AGGREGATION:return"aggregation";case n.StateDB.relationType.EXTENSION:return"extension";case n.StateDB.relationType.COMPOSITION:return"composition";case n.StateDB.relationType.DEPENDENCY:return"dependency"}},"getRelationType");e.points=e.points.filter(t=>!Number.isNaN(t.y));const s=e.points,f=(0,d.line)().x(function(t){return t.x}).y(function(t){return t.y}).curve(d.curveBasis),l=t.append("path").attr("d",f(s)).attr("id","edge"+w).attr("class","transition");let p="";if((0,o.getConfig2)().state.arrowMarkerAbsolute&&(p=(0,o.getUrl)(!0)),l.attr("marker-end","url("+p+"#"+i(n.StateDB.relationType.DEPENDENCY)+"End)"),void 0!==a.title){const i=t.append("g").attr("class","stateLabel"),{x:n,y:d}=g.utils_default.calcLabelPosition(e.points),s=o.common_default.getRows(a.title);let f=0;const l=[];let p=0,c=0;for(let t=0;t<=s.length;t++){const e=i.append("text").attr("text-anchor","middle").text(s[t]).attr("x",n).attr("y",d+f),a=e.node().getBBox();if(p=Math.max(p,a.width),c=Math.min(c,a.x),r.log.info(a.x,n,d+f),0===f){const t=e.node().getBBox();f=t.height,r.log.info("Title height",f,d)}l.push(e)}let h=f*s.length;if(s.length>1){const t=(s.length-1)*f*.5;l.forEach((e,a)=>e.attr("y",d+a*f-t)),h=f*s.length}const x=i.node().getBBox();i.insert("rect",":first-child").attr("class","box").attr("x",n-p/2-(0,o.getConfig2)().state.padding/2).attr("y",d-h/2-(0,o.getConfig2)().state.padding/2-3.5).attr("width",p+(0,o.getConfig2)().state.padding).attr("height",h+(0,o.getConfig2)().state.padding),r.log.info(x)}w++},"drawEdge"),b={},S=(0,r.__name)(function(){},"setConf"),k=(0,r.__name)(function(t){t.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"),N=(0,r.__name)(function(t,e,a,n){i=(0,o.getConfig2)().state;const g=(0,o.getConfig2)().securityLevel;let s;"sandbox"===g&&(s=(0,d.select)("#i"+e));const f="sandbox"===g?(0,d.select)(s.nodes()[0].contentDocument.body):(0,d.select)("body"),l="sandbox"===g?s.nodes()[0].contentDocument:document;r.log.debug("Rendering diagram "+t);const p=f.select(`[id='${e}']`);k(p);const c=n.db.getRootDoc();M(c,p,void 0,!1,f,l,n);const h=i.padding,x=p.node().getBBox(),C=x.width+2*h,u=x.height+2*h,y=1.75*C;(0,o.configureSvgSize)(p,u,y,i.useMaxWidth),p.attr("viewBox",`${x.x-i.padding} ${x.y-i.padding} `+C+" "+u)},"draw"),E=(0,r.__name)(t=>t?t.length*i.fontSizeFactor:1,"getLabelWidth"),M=(0,r.__name)((t,e,a,n,g,d,l)=>{const p=new f.Graph({compound:!0,multigraph:!0});let c,h=!0;for(c=0;c<t.length;c++)if("relation"===t[c].stmt){h=!1;break}a?p.setGraph({rankdir:"LR",multigraph:!0,compound:!0,ranker:"tight-tree",ranksep:h?1:i.edgeLengthFactor,nodeSep:h?1:50,isMultiGraph:!0}):p.setGraph({rankdir:"TB",multigraph:!0,compound:!0,ranksep:h?1:i.edgeLengthFactor,nodeSep:h?1:50,ranker:"tight-tree",isMultiGraph:!0}),p.setDefaultEdgeLabel(function(){return{}});const C=l.db.getStates(),u=l.db.getRelations(),y=Object.keys(C);for(const t of y){const o=C[t];let r;if(a&&(o.parentId=a),o.doc){let t=e.append("g").attr("id",o.id).attr("class","stateGroup");r=M(o.doc,t,o.id,!n,g,d,l);{t=x(t,o,n);let e=t.node().getBBox();r.width=e.width,r.height=e.height+i.padding/2,b[o.id]={y:i.compositTitleSize}}}else r=_(e,o,p);if(o.note){const t={descriptions:[],id:o.id+"-note",note:o.note,type:"note"},a=_(e,t,p);"left of"===o.note.position?(p.setNode(r.id+"-note",a),p.setNode(r.id,r)):(p.setNode(r.id,r),p.setNode(r.id+"-note",a)),p.setParent(r.id,r.id+"-group"),p.setParent(r.id+"-note",r.id+"-group")}else p.setNode(r.id,r)}r.log.debug("Count=",p.nodeCount(),p);let m=0;u.forEach(function(t){m++,r.log.debug("Setting edge",t),p.setEdge(t.id1,t.id2,{relation:t,width:E(t.title),height:i.labelHeight*o.common_default.getRows(t.title).length,labelpos:"c"},"id"+m)}),(0,s.layout)(p),r.log.debug("Graph after layout",p.nodes());const w=e.node();p.nodes().forEach(function(t){void 0!==t&&void 0!==p.node(t)?(r.log.warn("Node "+t+": "+JSON.stringify(p.node(t))),g.select("#"+w.id+" #"+t).attr("transform","translate("+(p.node(t).x-p.node(t).width/2)+","+(p.node(t).y+(b[t]?b[t].y:0)-p.node(t).height/2)+" )"),g.select("#"+w.id+" #"+t).attr("data-x-shift",p.node(t).x-p.node(t).width/2),d.querySelectorAll("#"+w.id+" #"+t+" .divider").forEach(t=>{const e=t.parentElement;let a=0,i=0;e&&(e.parentElement&&(a=e.parentElement.getBBox().width),i=parseInt(e.getAttribute("data-x-shift"),10),Number.isNaN(i)&&(i=0)),t.setAttribute("x1",0-i+8),t.setAttribute("x2",a-i-8)})):r.log.debug("No Node "+t+": "+JSON.stringify(p.node(t)))});let S=w.getBBox();p.edges().forEach(function(t){void 0!==t&&void 0!==p.edge(t)&&(r.log.debug("Edge "+t.v+" -> "+t.w+": "+JSON.stringify(p.edge(t))),B(e,p.edge(t),p.edge(t).relation))}),S=w.getBBox();const k={id:a||"root",label:a||"root",width:0,height:0};return k.width=S.width+2*i.padding,k.height=S.height+2*i.padding,r.log.debug("Doc rendered",k,p),k},"renderDoc"),v={setConf:S,draw:N},D={parser:n.stateDiagram_default,get db(){return new n.StateDB(1)},renderer:v,styles:n.styles_default,init:(0,r.__name)(t=>{t.state||(t.state={}),t.state.arrowMarkerAbsolute=t.arrowMarkerAbsolute},"init")}}};
//# sourceMappingURL=3311.js.map