UNPKG

ruru

Version:

Grafast-flavoured GraphiQL distribution

2 lines • 12.1 kB
export const __webpack_esm_id__=3770;export const __webpack_esm_ids__=[3770];export const __webpack_esm_modules__={23770(t,e,a){a.r(e),a.d(e,{diagram:()=>z});var i,n=a(14229),o=(a(72012),a(2667),a(67594),a(37277),a(75972),a(41298),a(6342),a(51752),a(48550),a(77948),a(56350),a(70848)),g=a(39989),r=a(27166),d=a(79456),s=a(79806),f=a(71514),p=a(58558),l=(0,d.__name)(t=>t.append("circle").attr("class","start-state").attr("r",(0,g.getConfig2)().state.sizeUnit).attr("cx",(0,g.getConfig2)().state.padding+(0,g.getConfig2)().state.sizeUnit).attr("cy",(0,g.getConfig2)().state.padding+(0,g.getConfig2)().state.sizeUnit),"drawStartState"),c=(0,d.__name)(t=>t.append("line").style("stroke","grey").style("stroke-dasharray","3").attr("x1",(0,g.getConfig2)().state.textHeight).attr("class","divider").attr("x2",2*(0,g.getConfig2)().state.textHeight).attr("y1",0).attr("y2",0),"drawDivider"),h=(0,d.__name)((t,e)=>{const a=t.append("text").attr("x",2*(0,g.getConfig2)().state.padding).attr("y",(0,g.getConfig2)().state.textHeight+2*(0,g.getConfig2)().state.padding).attr("font-size",(0,g.getConfig2)().state.fontSize).attr("class","state-title").text(e.id),i=a.node().getBBox();return t.insert("rect",":first-child").attr("x",(0,g.getConfig2)().state.padding).attr("y",(0,g.getConfig2)().state.padding).attr("width",i.width+2*(0,g.getConfig2)().state.padding).attr("height",i.height+2*(0,g.getConfig2)().state.padding).attr("rx",(0,g.getConfig2)().state.radius),a},"drawSimpleState"),x=(0,d.__name)((t,e)=>{const a=(0,d.__name)(function(t,e,a){const i=t.append("tspan").attr("x",2*(0,g.getConfig2)().state.padding).text(e);a||i.attr("dy",(0,g.getConfig2)().state.textHeight)},"addTspan"),i=t.append("text").attr("x",2*(0,g.getConfig2)().state.padding).attr("y",(0,g.getConfig2)().state.textHeight+1.3*(0,g.getConfig2)().state.padding).attr("font-size",(0,g.getConfig2)().state.fontSize).attr("class","state-title").text(e.descriptions[0]).node().getBBox(),n=i.height,o=t.append("text").attr("x",(0,g.getConfig2)().state.padding).attr("y",n+.4*(0,g.getConfig2)().state.padding+(0,g.getConfig2)().state.dividerMargin+(0,g.getConfig2)().state.textHeight).attr("class","state-description");let r=!0,s=!0;e.descriptions.forEach(function(t){r||(a(o,t,s),s=!1),r=!1});const f=t.append("line").attr("x1",(0,g.getConfig2)().state.padding).attr("y1",(0,g.getConfig2)().state.padding+n+(0,g.getConfig2)().state.dividerMargin/2).attr("y2",(0,g.getConfig2)().state.padding+n+(0,g.getConfig2)().state.dividerMargin/2).attr("class","descr-divider"),p=o.node().getBBox(),l=Math.max(p.width,i.width);return f.attr("x2",l+3*(0,g.getConfig2)().state.padding),t.insert("rect",":first-child").attr("x",(0,g.getConfig2)().state.padding).attr("y",(0,g.getConfig2)().state.padding).attr("width",l+2*(0,g.getConfig2)().state.padding).attr("height",p.height+n+2*(0,g.getConfig2)().state.padding).attr("rx",(0,g.getConfig2)().state.radius),t},"drawDescrState"),C=(0,d.__name)((t,e,a)=>{const i=(0,g.getConfig2)().state.padding,n=2*(0,g.getConfig2)().state.padding,o=t.node().getBBox(),r=o.width,d=o.x,s=t.append("text").attr("x",0).attr("y",(0,g.getConfig2)().state.titleShift).attr("font-size",(0,g.getConfig2)().state.fontSize).attr("class","state-title").text(e.id),f=s.node().getBBox().width+n;let p,l=Math.max(f,r);l===r&&(l+=n);const c=t.node().getBBox();e.doc,p=d-i,f>r&&(p=(r-l)/2+i),Math.abs(d-c.x)<i&&f>r&&(p=d-(f-r)/2);const h=1-(0,g.getConfig2)().state.textHeight;return t.insert("rect",":first-child").attr("x",p).attr("y",h).attr("class",a?"alt-composit":"composit").attr("width",l).attr("height",c.height+(0,g.getConfig2)().state.textHeight+(0,g.getConfig2)().state.titleShift+1).attr("rx","0"),s.attr("x",p+i),f<=r&&s.attr("x",d+(l-n)/2-f/2+i),t.insert("rect",":first-child").attr("x",p).attr("y",(0,g.getConfig2)().state.titleShift-(0,g.getConfig2)().state.textHeight-(0,g.getConfig2)().state.padding).attr("width",l).attr("height",3*(0,g.getConfig2)().state.textHeight).attr("rx",(0,g.getConfig2)().state.radius),t.insert("rect",":first-child").attr("x",p).attr("y",(0,g.getConfig2)().state.titleShift-(0,g.getConfig2)().state.textHeight-(0,g.getConfig2)().state.padding).attr("width",l).attr("height",c.height+3+2*(0,g.getConfig2)().state.textHeight).attr("rx",(0,g.getConfig2)().state.radius),t},"addTitleAndBox"),u=(0,d.__name)(t=>(t.append("circle").attr("class","end-state-outer").attr("r",(0,g.getConfig2)().state.sizeUnit+(0,g.getConfig2)().state.miniPadding).attr("cx",(0,g.getConfig2)().state.padding+(0,g.getConfig2)().state.sizeUnit+(0,g.getConfig2)().state.miniPadding).attr("cy",(0,g.getConfig2)().state.padding+(0,g.getConfig2)().state.sizeUnit+(0,g.getConfig2)().state.miniPadding),t.append("circle").attr("class","end-state-inner").attr("r",(0,g.getConfig2)().state.sizeUnit).attr("cx",(0,g.getConfig2)().state.padding+(0,g.getConfig2)().state.sizeUnit+2).attr("cy",(0,g.getConfig2)().state.padding+(0,g.getConfig2)().state.sizeUnit+2)),"drawEndState"),y=(0,d.__name)((t,e)=>{let a=(0,g.getConfig2)().state.forkWidth,i=(0,g.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,g.getConfig2)().state.padding).attr("y",(0,g.getConfig2)().state.padding)},"drawForkJoinState"),m=(0,d.__name)((t,e,a,i)=>{let n=0;const o=i.append("text");o.style("text-anchor","start"),o.attr("class","noteText");let r=t.replace(/\r\n/g,"<br/>");r=r.replace(/\n/g,"<br/>");const d=r.split(g.common_default.lineBreakRegex);let s=1.25*(0,g.getConfig2)().state.noteMargin;for(const t of d){const i=t.trim();if(i.length>0){const t=o.append("tspan");t.text(i),0===s&&(s+=t.node().getBBox().height),n+=s,t.attr("x",e+(0,g.getConfig2)().state.noteMargin),t.attr("y",a+n+1.25*(0,g.getConfig2)().state.noteMargin)}}return{textWidth:o.node().getBBox().width,textHeight:n}},"_drawLongText"),_=(0,d.__name)((t,e)=>{e.attr("class","state-note");const a=e.append("rect").attr("x",0).attr("y",(0,g.getConfig2)().state.padding),i=e.append("g"),{textWidth:n,textHeight:o}=m(t,0,0,i);return a.attr("height",o+2*(0,g.getConfig2)().state.noteMargin),a.attr("width",n+2*(0,g.getConfig2)().state.noteMargin),a},"drawNote"),w=(0,d.__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&&u(n),"fork"!==e.type&&"join"!==e.type||y(n,e),"note"===e.type&&_(e.note.text,n),"divider"===e.type&&c(n),"default"===e.type&&0===e.descriptions.length&&h(n,e),"default"===e.type&&e.descriptions.length>0&&x(n,e);const o=n.node().getBBox();return i.width=o.width+2*(0,g.getConfig2)().state.padding,i.height=o.height+2*(0,g.getConfig2)().state.padding,i},"drawState"),B=0,b=(0,d.__name)(function(t,e,a){const i=(0,d.__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 f=e.points,p=(0,s.line)().x(function(t){return t.x}).y(function(t){return t.y}).curve(s.curveBasis),l=t.append("path").attr("d",p(f)).attr("id","edge"+B).attr("class","transition");let c="";if((0,g.getConfig2)().state.arrowMarkerAbsolute&&(c=(0,g.getUrl)(!0)),l.attr("marker-end","url("+c+"#"+i(n.StateDB.relationType.DEPENDENCY)+"End)"),void 0!==a.title){const i=t.append("g").attr("class","stateLabel"),{x:n,y:d}=o.utils_default.calcLabelPosition(e.points),s=g.common_default.getRows(a.title);let f=0;const p=[];let l=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(l=Math.max(l,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)}p.push(e)}let h=f*s.length;if(s.length>1){const t=(s.length-1)*f*.5;p.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-l/2-(0,g.getConfig2)().state.padding/2).attr("y",d-h/2-(0,g.getConfig2)().state.padding/2-3.5).attr("width",l+(0,g.getConfig2)().state.padding).attr("height",h+(0,g.getConfig2)().state.padding),r.log.info(x)}B++},"drawEdge"),S={},k=(0,d.__name)(function(){},"setConf"),N=(0,d.__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"),E=(0,d.__name)(function(t,e,a,n){i=(0,g.getConfig2)().state;const o=(0,g.getConfig2)().securityLevel;let d;"sandbox"===o&&(d=(0,s.select)("#i"+e));const f="sandbox"===o?(0,s.select)(d.nodes()[0].contentDocument.body):(0,s.select)("body"),p="sandbox"===o?d.nodes()[0].contentDocument:document;r.log.debug("Rendering diagram "+t);const l=f.select(`[id='${e}']`);N(l);const c=n.db.getRootDoc(),h=l.append("g").attr("id",e+"-root");v(c,h,void 0,!1,f,p,n);const x=i.padding,C=l.node().getBBox(),u=C.width+2*x,y=C.height+2*x,m=1.75*u;(0,g.configureSvgSize)(l,y,m,i.useMaxWidth),l.attr("viewBox",`${C.x-i.padding} ${C.y-i.padding} `+u+" "+y)},"draw"),M=(0,d.__name)(t=>t?t.length*i.fontSizeFactor:1,"getLabelWidth"),v=(0,d.__name)((t,e,a,n,o,d,s)=>{const l=new p.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?l.setGraph({rankdir:"LR",multigraph:!0,compound:!0,ranker:"tight-tree",ranksep:h?1:i.edgeLengthFactor,nodeSep:h?1:50,isMultiGraph:!0}):l.setGraph({rankdir:"TB",multigraph:!0,compound:!0,ranksep:h?1:i.edgeLengthFactor,nodeSep:h?1:50,ranker:"tight-tree",isMultiGraph:!0}),l.setDefaultEdgeLabel(function(){return{}});const x=s.db.getStates(),u=s.db.getRelations(),y=Object.keys(x);for(const t of y){const g=x[t];let r;if(a&&(g.parentId=a),g.doc){let t=e.append("g").attr("id",g.id).attr("class","stateGroup");r=v(g.doc,t,g.id,!n,o,d,s);{t=C(t,g,n);let e=t.node().getBBox();r.width=e.width,r.height=e.height+i.padding/2,S[g.id]={y:i.compositTitleSize}}}else r=w(e,g,l);if(g.note){const t={descriptions:[],id:g.id+"-note",note:g.note,type:"note"},a=w(e,t,l);"left of"===g.note.position?(l.setNode(r.id+"-note",a),l.setNode(r.id,r)):(l.setNode(r.id,r),l.setNode(r.id+"-note",a)),l.setParent(r.id,r.id+"-group"),l.setParent(r.id+"-note",r.id+"-group")}else l.setNode(r.id,r)}r.log.debug("Count=",l.nodeCount(),l);let m=0;u.forEach(function(t){m++,r.log.debug("Setting edge",t),l.setEdge(t.id1,t.id2,{relation:t,width:M(t.title),height:i.labelHeight*g.common_default.getRows(t.title).length,labelpos:"c"},"id"+m)}),(0,f.layout)(l),r.log.debug("Graph after layout",l.nodes());const _=e.node();l.nodes().forEach(function(t){void 0!==t&&void 0!==l.node(t)?(r.log.warn("Node "+t+": "+JSON.stringify(l.node(t))),o.select("#"+_.id+" #"+t).attr("transform","translate("+(l.node(t).x-l.node(t).width/2)+","+(l.node(t).y+(S[t]?S[t].y:0)-l.node(t).height/2)+" )"),o.select("#"+_.id+" #"+t).attr("data-x-shift",l.node(t).x-l.node(t).width/2),d.querySelectorAll("#"+_.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(l.node(t)))});let B=_.getBBox();l.edges().forEach(function(t){void 0!==t&&void 0!==l.edge(t)&&(r.log.debug("Edge "+t.v+" -> "+t.w+": "+JSON.stringify(l.edge(t))),b(e,l.edge(t),l.edge(t).relation))}),B=_.getBBox();const k={id:a||"root",label:a||"root",width:0,height:0};return k.width=B.width+2*i.padding,k.height=B.height+2*i.padding,r.log.debug("Doc rendered",k,l),k},"renderDoc"),D={setConf:k,draw:E},z={parser:n.stateDiagram_default,get db(){return new n.StateDB(1)},renderer:D,styles:n.styles_default,init:(0,d.__name)(t=>{t.state||(t.state={}),t.state.arrowMarkerAbsolute=t.arrowMarkerAbsolute},"init")}}}; //# sourceMappingURL=3770.js.map