UNPKG

ruru

Version:

Grafast-flavoured GraphiQL distribution

2 lines 11.9 kB
export const __webpack_esm_id__=3102;export const __webpack_esm_ids__=[3102];export const __webpack_esm_modules__={13012(e,n,t){t.r(n),t.d(n,{default:()=>r});var o=t(12406);const r=function(e){return(0,o.default)(e,4)}},43102(e,n,t){t.d(n,{render:()=>G}),t.r(n);var o=t(54275),r=(t(51437),t(85533)),a=t(70998),i=(t(96540),t(67099),t(82029),t(54141)),d=t(60162),s=t(8042),g=t(34501),l=t(13012),c=t(64683);function f(e){var n={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:u(e),edges:p(e)};return g.default(e.graph())||(n.value=l.default(e.graph())),n}function u(e){return c.default(e.nodes(),function(n){var t=e.node(n),o=e.parent(n),r={v:n};return g.default(t)||(r.value=t),g.default(o)||(r.parent=o),r})}function p(e){return c.default(e.edges(),function(n){var t=e.edge(n),o={v:n.v,w:n.w};return g.default(n.name)||(o.name=n.name),g.default(t)||(o.value=t),o})}t(28539),t(37134);var h=t(58558),w=new Map,m=new Map,v=new Map,y=(0,d.__name)(()=>{m.clear(),v.clear(),w.clear()},"clear"),X=(0,d.__name)((e,n)=>{const t=m.get(n)||[];return d.log.trace("In isDescendant",n," ",e," = ",t.includes(e)),t.includes(e)},"isDescendant"),_=(0,d.__name)((e,n)=>{const t=m.get(n)||[];return d.log.info("Descendants of ",n," is ",t),d.log.info("Edge is ",e),e.v!==n&&e.w!==n&&(t?t.includes(e.v)||X(e.v,n)||X(e.w,n)||t.includes(e.w):(d.log.debug("Tilt, ",n,",not in descendants"),!1))},"edgeInCluster"),b=(0,d.__name)((e,n,t,o)=>{d.log.warn("Copying children of ",e,"root",o,"data",n.node(e),o);const r=n.children(e)||[];e!==o&&r.push(e),d.log.warn("Copying (nodes) clusterId",e,"nodes",r),r.forEach(r=>{if(n.children(r).length>0)b(r,n,t,o);else{const a=n.node(r);d.log.info("cp ",r," to ",o," with parent ",e),t.setNode(r,a),o!==n.parent(r)&&(d.log.warn("Setting parent",r,n.parent(r)),t.setParent(r,n.parent(r))),e!==o&&r!==e?(d.log.debug("Setting parent",r,e),t.setParent(r,e)):(d.log.info("In copy ",e,"root",o,"data",n.node(e),o),d.log.debug("Not Setting parent for node=",r,"cluster!==rootId",e!==o,"node!==clusterId",r!==e));const i=n.edges(r);d.log.debug("Copying Edges",i),i.forEach(r=>{d.log.info("Edge",r);const a=n.edge(r.v,r.w,r.name);d.log.info("Edge data",a,o);try{_(r,o)?(d.log.info("Copying as ",r.v,r.w,a,r.name),t.setEdge(r.v,r.w,a,r.name),d.log.info("newGraph edges ",t.edges(),t.edge(t.edges()[0]))):d.log.info("Skipping copy of edge ",r.v,"--\x3e",r.w," rootId: ",o," clusterId:",e)}catch(e){d.log.error(e)}})}d.log.debug("Removing node",r),n.removeNode(r)})},"copy"),E=(0,d.__name)((e,n)=>{const t=n.children(e);let o=[...t];for(const r of t)v.set(r,e),o=[...o,...E(r,n)];return o},"extractDescendants"),N=(0,d.__name)((e,n,t)=>{const o=e.edges().filter(e=>e.v===n||e.w===n),r=e.edges().filter(e=>e.v===t||e.w===t),a=o.map(e=>({v:e.v===n?t:e.v,w:e.w===n?n:e.w})),i=r.map(e=>({v:e.v,w:e.w}));return a.filter(e=>i.some(n=>e.v===n.v&&e.w===n.w))},"findCommonEdges"),C=(0,d.__name)((e,n,t)=>{const o=n.children(e);if(d.log.trace("Searching children of id ",e,o),o.length<1)return e;let r;for(const e of o){const o=C(e,n,t),a=N(n,t,o);if(o){if(!(a.length>0))return o;r=o}}return r},"findNonClusterChild"),x=(0,d.__name)(e=>w.has(e)&&w.get(e).externalConnections&&w.has(e)?w.get(e).id:e,"getAnchorId"),S=(0,d.__name)((e,n)=>{if(!e||n>10)d.log.debug("Opting out, no graph ");else{d.log.debug("Opting in, graph "),e.nodes().forEach(function(n){e.children(n).length>0&&(d.log.warn("Cluster identified",n," Replacement id in edges: ",C(n,e,n)),m.set(n,E(n,e)),w.set(n,{id:C(n,e,n),clusterData:e.node(n)}))}),e.nodes().forEach(function(n){const t=e.children(n),o=e.edges();t.length>0?(d.log.debug("Cluster identified",n,m),o.forEach(e=>{X(e.v,n)^X(e.w,n)&&(d.log.warn("Edge: ",e," leaves cluster ",n),d.log.warn("Descendants of XXX ",n,": ",m.get(n)),w.get(n).externalConnections=!0)})):d.log.debug("Not a cluster ",n,m)});for(let n of w.keys()){const t=w.get(n).id,o=e.parent(t);o!==n&&w.has(o)&&!w.get(o).externalConnections&&(w.get(n).id=o)}e.edges().forEach(function(n){const t=e.edge(n);d.log.warn("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(n)),d.log.warn("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(e.edge(n)));let o=n.v,r=n.w;if(d.log.warn("Fix XXX",w,"ids:",n.v,n.w,"Translating: ",w.get(n.v)," --- ",w.get(n.w)),w.get(n.v)||w.get(n.w)){if(d.log.warn("Fixing and trying - removing XXX",n.v,n.w,n.name),o=x(n.v),r=x(n.w),e.removeEdge(n.v,n.w,n.name),o!==n.v){const r=e.parent(o);w.get(r).externalConnections=!0,t.fromCluster=n.v}if(r!==n.w){const o=e.parent(r);w.get(o).externalConnections=!0,t.toCluster=n.w}d.log.warn("Fix Replacing with XXX",o,r,n.name),e.setEdge(o,r,t,n.name)}}),d.log.warn("Adjusted Graph",f(e)),I(e,0),d.log.trace(w)}},"adjustClustersAndEdges"),I=(0,d.__name)((e,n)=>{if(d.log.warn("extractor - ",n,f(e),e.children("D")),n>10)return void d.log.error("Bailing out");let t=e.nodes(),o=!1;for(const n of t){const t=e.children(n);o=o||t.length>0}if(o){d.log.debug("Nodes = ",t,n);for(const o of t)if(d.log.debug("Extracting node",o,w,w.has(o)&&!w.get(o).externalConnections,!e.parent(o),e.node(o),e.children("D")," Depth ",n),w.has(o))if(!w.get(o).externalConnections&&e.children(o)&&e.children(o).length>0){d.log.warn("Cluster without external connections, without a parent and with children",o,n);let t="TB"===e.graph().rankdir?"LR":"TB";w.get(o)?.clusterData?.dir&&(t=w.get(o).clusterData.dir,d.log.warn("Fixing dir",w.get(o).clusterData.dir,t));const r=new h.Graph({multigraph:!0,compound:!0}).setGraph({rankdir:t,nodesep:50,ranksep:50,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});d.log.warn("Old graph before copy",f(e)),b(o,e,r,o),e.setNode(o,{clusterNode:!0,id:o,clusterData:w.get(o).clusterData,label:w.get(o).label,graph:r}),d.log.warn("New graph after copy node: (",o,")",f(r)),d.log.debug("Old graph after copy",f(e))}else d.log.warn("Cluster ** ",o," **not meeting the criteria !externalConnections:",!w.get(o).externalConnections," no parent: ",!e.parent(o)," children ",e.children(o)&&e.children(o).length>0,e.children("D"),n),d.log.debug(w);else d.log.debug("Not a cluster",o,n);t=e.nodes(),d.log.warn("New list of nodes",t);for(const o of t){const t=e.node(o);d.log.warn(" Now next level",o,t),t?.clusterNode&&I(t.graph,n+1)}}else d.log.debug("Done, no node has children",e.nodes())},"extractor"),D=(0,d.__name)((e,n)=>{if(0===n.length)return[];let t=Object.assign([],n);return n.forEach(n=>{const o=e.children(n),r=D(e,o);t=[...t,...r]}),t},"sorter"),k=(0,d.__name)(e=>D(e,e.children()),"sortNodesByHierarchy"),O=(0,d.__name)(async(e,n,t,i,g,l)=>{d.log.warn("Graph in recursive render:XAX",f(n),g);const c=n.graph().rankdir;d.log.trace("Dir in recursive render - dir:",c);const u=e.insert("g").attr("class","root");n.nodes()?d.log.info("Recursive render XXX",n.nodes()):d.log.info("No nodes found for",n),n.edges().length>0&&d.log.info("Recursive edges",n.edge(n.edges()[0]));const p=u.insert("g").attr("class","clusters"),h=u.insert("g").attr("class","edgePaths"),m=u.insert("g").attr("class","edgeLabels"),v=u.insert("g").attr("class","nodes");await Promise.all(n.nodes().map(async function(e){const o=n.node(e);if(void 0!==g){const t=JSON.parse(JSON.stringify(g.clusterData));d.log.trace("Setting data for parent cluster XXX\n Node.id = ",e,"\n data=",t.height,"\nParent cluster",g.height),n.setNode(g.id,t),n.parent(e)||(d.log.trace("Setting parent",e,g.id),n.setParent(e,g.id,t))}if(d.log.info("(Insert) Node XXX"+e+": "+JSON.stringify(n.node(e))),o?.clusterNode){d.log.info("Cluster identified XBX",e,o.width,n.node(e));const{ranksep:a,nodesep:s}=n.graph();o.graph.setGraph({...o.graph.graph(),ranksep:a+25,nodesep:s});const g=await O(v,o.graph,t,i,n.node(e),l),c=g.elem;(0,r.updateNodeBounds)(o,c),o.diff=g.diff||0,d.log.info("New compound node after recursive render XAX",e,"width",o.width,"height",o.height),(0,r.setNodeElem)(c,o)}else n.children(e).length>0?(d.log.trace("Cluster - the non recursive path XBX",e,o.id,o,o.width,"Graph:",n),d.log.trace(C(o.id,n)),w.set(o.id,{id:C(o.id,n),node:o})):(d.log.trace("Node - the non recursive path XAX",e,v,n.node(e),c),await(0,r.insertNode)(v,n.node(e),{config:l,dir:c}))}));const y=(0,d.__name)(async()=>{const e=n.edges().map(async function(e){const t=n.edge(e.v,e.w,e.name);d.log.info("Edge "+e.v+" -> "+e.w+": "+JSON.stringify(e)),d.log.info("Edge "+e.v+" -> "+e.w+": ",e," ",JSON.stringify(n.edge(e))),d.log.info("Fix",w,"ids:",e.v,e.w,"Translating: ",w.get(e.v),w.get(e.w)),await(0,o.insertEdgeLabel)(m,t)});await Promise.all(e)},"processEdges");await y(),d.log.info("Graph before layout:",JSON.stringify(f(n))),d.log.info("############################################# XXX"),d.log.info("### Layout ### XXX"),d.log.info("############################################# XXX"),(0,s.layout)(n),d.log.info("Graph after layout:",JSON.stringify(f(n)));let X=0,{subGraphTitleTotalMargin:_}=(0,a.getSubGraphTitleMargins)(l);return await Promise.all(k(n).map(async function(e){const t=n.node(e);if(d.log.info("Position XBX => "+e+": ("+t.x,","+t.y,") width: ",t.width," height: ",t.height),t?.clusterNode)t.y+=_,d.log.info("A tainted cluster node XBX1",e,t.id,t.width,t.height,t.x,t.y,n.parent(e)),w.get(t.id).node=t,(0,r.positionNode)(t);else if(n.children(e).length>0){d.log.info("A pure cluster node XBX1",e,t.id,t.x,t.y,t.width,t.height,n.parent(e)),t.height+=_,n.node(t.parentId);const o=t?.padding/2||0,a=t?.labelBBox?.height||0,i=a-o||0;d.log.debug("OffsetY",i,"labelHeight",a,"halfPadding",o),await(0,r.insertCluster)(p,t),w.get(t.id).node=t}else{const e=n.node(t.parentId);t.y+=_/2,d.log.info("A regular node XBX1 - using the padding",t.id,"parent",t.parentId,t.width,t.height,t.x,t.y,"offsetY",t.offsetY,"parent",e,e?.offsetY,t),(0,r.positionNode)(t)}})),n.edges().forEach(function(e){const r=n.edge(e);d.log.info("Edge "+e.v+" -> "+e.w+": "+JSON.stringify(r),r),r.points.forEach(e=>e.y+=_/2);const a=n.node(e.v);var s=n.node(e.w);const g=(0,o.insertEdge)(h,r,w,t,a,s,i);(0,o.positionEdgeLabel)(r,g)}),n.nodes().forEach(function(e){const t=n.node(e);d.log.info(e,t.type,t.diff),t.isGroup&&(X=t.diff)}),d.log.warn("Returning from recursive render XAX",u,X),{elem:u,diff:X}},"recursiveRender"),G=(0,d.__name)(async(e,n)=>{const t=new h.Graph({multigraph:!0,compound:!0}).setGraph({rankdir:e.direction,nodesep:e.config?.nodeSpacing||e.config?.flowchart?.nodeSpacing||e.nodeSpacing,ranksep:e.config?.rankSpacing||e.config?.flowchart?.rankSpacing||e.rankSpacing,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}}),a=n.select("g");(0,o.markers_default)(a,e.markers,e.type,e.diagramId),(0,r.clear2)(),(0,o.clear)(),(0,r.clear)(),y(),e.nodes.forEach(e=>{t.setNode(e.id,{...e}),e.parentId&&t.setParent(e.id,e.parentId)}),d.log.debug("Edges:",e.edges),e.edges.forEach(e=>{if(e.start===e.end){const n=e.start,o=n+"---"+n+"---1",r=n+"---"+n+"---2",a=t.node(n);t.setNode(o,{domId:o,id:o,parentId:a.parentId,labelStyle:"",label:"",padding:0,shape:"labelRect",style:"",width:10,height:10}),t.setParent(o,a.parentId),t.setNode(r,{domId:r,id:r,parentId:a.parentId,labelStyle:"",padding:0,shape:"labelRect",label:"",style:"",width:10,height:10}),t.setParent(r,a.parentId);const i=structuredClone(e),d=structuredClone(e),s=structuredClone(e);i.label="",i.arrowTypeEnd="none",i.id=n+"-cyclic-special-1",d.arrowTypeStart="none",d.arrowTypeEnd="none",d.id=n+"-cyclic-special-mid",s.label="",a.isGroup&&(i.fromCluster=n,s.toCluster=n),s.id=n+"-cyclic-special-2",s.arrowTypeStart="none",t.setEdge(n,o,i,n+"-cyclic-special-0"),t.setEdge(o,r,d,n+"-cyclic-special-1"),t.setEdge(r,n,s,n+"-cyc<lic-special-2")}else t.setEdge(e.start,e.end,{...e},e.id)}),d.log.warn("Graph at first:",JSON.stringify(f(t))),S(t),d.log.warn("Graph after XAX:",JSON.stringify(f(t)));const s=(0,i.getConfig2)();await O(a,t,e.type,e.diagramId,void 0,s)},"render")}}; //# sourceMappingURL=3102.js.map