UNPKG

code-server

Version:

Run VS Code on a remote server.

5 lines (4 loc) • 11.3 kB
import{a as q}from"./chunk-ORJ3II5F.js";import{D as C,d as V,l as k,q as y}from"./chunk-BBR2KTV7.js";import{a as F,b as U,c as Y,d as H,e as j}from"./chunk-CL2PNEZF.js";import{b as B,d as A,e as G,g as T,h as L,i as M,j as O}from"./chunk-MI7L3JDQ.js";import"./chunk-EWILYK3H.js";import"./chunk-IR42YTGA.js";import"./chunk-MX6DGWIA.js";import{a as _}from"./chunk-JDBNYPCC.js";import"./chunk-623C5XAY.js";import"./chunk-PKRYIESI.js";import"./chunk-JBQZ5UCE.js";import{_ as R}from"./chunk-VBOJ6TJX.js";import{b as g,d as r}from"./chunk-XDY7PRES.js";import"./chunk-OOJM4CTU.js";function v(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:ne(e),edges:te(e)};return y(e.graph())||(t.value=V(e.graph())),t}function ne(e){return k(e.nodes(),function(t){var n=e.node(t),a=e.parent(t),s={v:t};return y(n)||(s.value=n),y(a)||(s.parent=a),s})}function te(e){return k(e.edges(),function(t){var n=e.edge(t),a={v:t.v,w:t.w};return y(t.name)||(a.name=t.name),y(n)||(a.value=n),a})}var d=new Map,X=new Map,Q=new Map,ie=g(()=>{X.clear(),Q.clear(),d.clear()},"clear"),J=g((e,t)=>{let n=X.get(t)||[];return r.trace("In isDescendant",t," ",e," = ",n.includes(e)),n.includes(e)},"isDescendant"),se=g((e,t)=>{let n=X.get(t)||[];return r.info("Descendants of ",t," is ",n),r.info("Edge is ",e),e.v===t||e.w===t?!1:n?n.includes(e.v)||J(e.v,t)||J(e.w,t)||n.includes(e.w):(r.debug("Tilt, ",t,",not in descendants"),!1)},"edgeInCluster"),W=g((e,t,n,a)=>{r.warn("Copying children of ",e,"root",a,"data",t.node(e),a);let s=t.children(e)||[];e!==a&&s.push(e),r.warn("Copying (nodes) clusterId",e,"nodes",s),s.forEach(o=>{if(t.children(o).length>0)W(o,t,n,a);else{let l=t.node(o);r.info("cp ",o," to ",a," with parent ",e),n.setNode(o,l),a!==t.parent(o)&&(r.warn("Setting parent",o,t.parent(o)),n.setParent(o,t.parent(o))),e!==a&&o!==e?(r.debug("Setting parent",o,e),n.setParent(o,e)):(r.info("In copy ",e,"root",a,"data",t.node(e),a),r.debug("Not Setting parent for node=",o,"cluster!==rootId",e!==a,"node!==clusterId",o!==e));let u=t.edges(o);r.debug("Copying Edges",u),u.forEach(c=>{r.info("Edge",c);let m=t.edge(c.v,c.w,c.name);r.info("Edge data",m,a);try{se(c,a)?(r.info("Copying as ",c.v,c.w,m,c.name),n.setEdge(c.v,c.w,m,c.name),r.info("newGraph edges ",n.edges(),n.edge(n.edges()[0]))):r.info("Skipping copy of edge ",c.v,"-->",c.w," rootId: ",a," clusterId:",e)}catch(h){r.error(h)}})}r.debug("Removing node",o),t.removeNode(o)})},"copy"),Z=g((e,t)=>{let n=t.children(e),a=[...n];for(let s of n)Q.set(s,e),a=[...a,...Z(s,t)];return a},"extractDescendants"),oe=g((e,t,n)=>{let a=e.edges().filter(c=>c.v===t||c.w===t),s=e.edges().filter(c=>c.v===n||c.w===n),o=a.map(c=>({v:c.v===t?n:c.v,w:c.w===t?t:c.w})),l=s.map(c=>({v:c.v,w:c.w}));return o.filter(c=>l.some(m=>c.v===m.v&&c.w===m.w))},"findCommonEdges"),S=g((e,t,n)=>{let a=t.children(e);if(r.trace("Searching children of id ",e,a),a.length<1)return e;let s;for(let o of a){let l=S(o,t,n),u=oe(t,n,l);if(l)if(u.length>0)s=l;else return l}return s},"findNonClusterChild"),K=g(e=>!d.has(e)||!d.get(e).externalConnections?e:d.has(e)?d.get(e).id:e,"getAnchorId"),ae=g((e,t)=>{if(!e||t>10){r.debug("Opting out, no graph ");return}else r.debug("Opting in, graph ");e.nodes().forEach(function(n){e.children(n).length>0&&(r.warn("Cluster identified",n," Replacement id in edges: ",S(n,e,n)),X.set(n,Z(n,e)),d.set(n,{id:S(n,e,n),clusterData:e.node(n)}))}),e.nodes().forEach(function(n){let a=e.children(n),s=e.edges();a.length>0?(r.debug("Cluster identified",n,X),s.forEach(o=>{let l=J(o.v,n),u=J(o.w,n);l^u&&(r.warn("Edge: ",o," leaves cluster ",n),r.warn("Descendants of XXX ",n,": ",X.get(n)),d.get(n).externalConnections=!0)})):r.debug("Not a cluster ",n,X)});for(let n of d.keys()){let a=d.get(n).id,s=e.parent(a);s!==n&&d.has(s)&&!d.get(s).externalConnections&&(d.get(n).id=s)}e.edges().forEach(function(n){let a=e.edge(n);r.warn("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(n)),r.warn("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(e.edge(n)));let s=n.v,o=n.w;if(r.warn("Fix XXX",d,"ids:",n.v,n.w,"Translating: ",d.get(n.v)," --- ",d.get(n.w)),d.get(n.v)||d.get(n.w)){if(r.warn("Fixing and trying - removing XXX",n.v,n.w,n.name),s=K(n.v),o=K(n.w),e.removeEdge(n.v,n.w,n.name),s!==n.v){let l=e.parent(s);d.get(l).externalConnections=!0,a.fromCluster=n.v}if(o!==n.w){let l=e.parent(o);d.get(l).externalConnections=!0,a.toCluster=n.w}r.warn("Fix Replacing with XXX",s,o,n.name),e.setEdge(s,o,a,n.name)}}),r.warn("Adjusted Graph",v(e)),$(e,0),r.trace(d)},"adjustClustersAndEdges"),$=g((e,t)=>{if(r.warn("extractor - ",t,v(e),e.children("D")),t>10){r.error("Bailing out");return}let n=e.nodes(),a=!1;for(let s of n){let o=e.children(s);a=a||o.length>0}if(!a){r.debug("Done, no node has children",e.nodes());return}r.debug("Nodes = ",n,t);for(let s of n)if(r.debug("Extracting node",s,d,d.has(s)&&!d.get(s).externalConnections,!e.parent(s),e.node(s),e.children("D")," Depth ",t),!d.has(s))r.debug("Not a cluster",s,t);else if(!d.get(s).externalConnections&&e.children(s)&&e.children(s).length>0){r.warn("Cluster without external connections, without a parent and with children",s,t);let l=e.graph().rankdir==="TB"?"LR":"TB";d.get(s)?.clusterData?.dir&&(l=d.get(s).clusterData.dir,r.warn("Fixing dir",d.get(s).clusterData.dir,l));let u=new C({multigraph:!0,compound:!0}).setGraph({rankdir:l,nodesep:50,ranksep:50,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});r.warn("Old graph before copy",v(e)),W(s,e,u,s),e.setNode(s,{clusterNode:!0,id:s,clusterData:d.get(s).clusterData,label:d.get(s).label,graph:u}),r.warn("New graph after copy node: (",s,")",v(u)),r.debug("Old graph after copy",v(e))}else r.warn("Cluster ** ",s," **not meeting the criteria !externalConnections:",!d.get(s).externalConnections," no parent: ",!e.parent(s)," children ",e.children(s)&&e.children(s).length>0,e.children("D"),t),r.debug(d);n=e.nodes(),r.warn("New list of nodes",n);for(let s of n){let o=e.node(s);r.warn(" Now next level",s,o),o?.clusterNode&&$(o.graph,t+1)}},"extractor"),I=g((e,t)=>{if(t.length===0)return[];let n=Object.assign([],t);return t.forEach(a=>{let s=e.children(a),o=I(e,s);n=[...n,...o]}),n},"sorter"),ce=g(e=>I(e,e.children()),"sortNodesByHierarchy"),ee=g(async(e,t,n,a,s,o)=>{r.warn("Graph in recursive render:XAX",v(t),s);let l=t.graph().rankdir;r.trace("Dir in recursive render - dir:",l);let u=e.insert("g").attr("class","root");t.nodes()?r.info("Recursive render XXX",t.nodes()):r.info("No nodes found for",t),t.edges().length>0&&r.info("Recursive edges",t.edge(t.edges()[0]));let c=u.insert("g").attr("class","clusters"),m=u.insert("g").attr("class","edgePaths"),h=u.insert("g").attr("class","edgeLabels"),p=u.insert("g").attr("class","nodes");await Promise.all(t.nodes().map(async function(f){let i=t.node(f);if(s!==void 0){let w=JSON.parse(JSON.stringify(s.clusterData));r.trace(`Setting data for parent cluster XXX Node.id = `,f,` data=`,w.height,` Parent cluster`,s.height),t.setNode(s.id,w),t.parent(f)||(r.trace("Setting parent",f,s.id),t.setParent(f,s.id,w))}if(r.info("(Insert) Node XXX"+f+": "+JSON.stringify(t.node(f))),i?.clusterNode){r.info("Cluster identified XBX",f,i.width,t.node(f));let{ranksep:w,nodesep:E}=t.graph();i.graph.setGraph({...i.graph.graph(),ranksep:w+25,nodesep:E});let N=await ee(p,i.graph,n,a,t.node(f),o),D=N.elem;B(i,D),i.diff=N.diff||0,r.info("New compound node after recursive render XAX",f,"width",i.width,"height",i.height),L(D,i)}else t.children(f).length>0?(r.trace("Cluster - the non recursive path XBX",f,i.id,i,i.width,"Graph:",t),r.trace(S(i.id,t)),d.set(i.id,{id:S(i.id,t),node:i})):(r.trace("Node - the non recursive path XAX",f,p,t.node(f),l),await T(p,t.node(f),{config:o,dir:l}))})),await g(async()=>{let f=t.edges().map(async function(i){let w=t.edge(i.v,i.w,i.name);r.info("Edge "+i.v+" -> "+i.w+": "+JSON.stringify(i)),r.info("Edge "+i.v+" -> "+i.w+": ",i," ",JSON.stringify(t.edge(i))),r.info("Fix",d,"ids:",i.v,i.w,"Translating: ",d.get(i.v),d.get(i.w)),await U(h,w)});await Promise.all(f)},"processEdges")(),r.info("Graph before layout:",JSON.stringify(v(t))),r.info("############################################# XXX"),r.info("### Layout ### XXX"),r.info("############################################# XXX"),q(t),r.info("Graph after layout:",JSON.stringify(v(t)));let P=0,{subGraphTitleTotalMargin:x}=_(o);return await Promise.all(ce(t).map(async function(f){let i=t.node(f);if(r.info("Position XBX => "+f+": ("+i.x,","+i.y,") width: ",i.width," height: ",i.height),i?.clusterNode)i.y+=x,r.info("A tainted cluster node XBX1",f,i.id,i.width,i.height,i.x,i.y,t.parent(f)),d.get(i.id).node=i,O(i);else if(t.children(f).length>0){r.info("A pure cluster node XBX1",f,i.id,i.x,i.y,i.width,i.height,t.parent(f)),i.height+=x,t.node(i.parentId);let w=i?.padding/2||0,E=i?.labelBBox?.height||0,N=E-w||0;r.debug("OffsetY",N,"labelHeight",E,"halfPadding",w),await A(c,i),d.get(i.id).node=i}else{let w=t.node(i.parentId);i.y+=x/2,r.info("A regular node XBX1 - using the padding",i.id,"parent",i.parentId,i.width,i.height,i.x,i.y,"offsetY",i.offsetY,"parent",w,w?.offsetY,i),O(i)}})),t.edges().forEach(function(f){let i=t.edge(f);r.info("Edge "+f.v+" -> "+f.w+": "+JSON.stringify(i),i),i.points.forEach(D=>D.y+=x/2);let w=t.node(f.v);var E=t.node(f.w);let N=H(m,i,d,n,w,E,a);Y(i,N)}),t.nodes().forEach(function(f){let i=t.node(f);r.info(f,i.type,i.diff),i.isGroup&&(P=i.diff)}),r.warn("Returning from recursive render XAX",u,P),{elem:u,diff:P}},"recursiveRender"),Ne=g(async(e,t)=>{let n=new C({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=t.select("g");j(a,e.markers,e.type,e.diagramId),M(),F(),G(),ie(),e.nodes.forEach(o=>{n.setNode(o.id,{...o}),o.parentId&&n.setParent(o.id,o.parentId)}),r.debug("Edges:",e.edges),e.edges.forEach(o=>{if(o.start===o.end){let l=o.start,u=l+"---"+l+"---1",c=l+"---"+l+"---2",m=n.node(l);n.setNode(u,{domId:u,id:u,parentId:m.parentId,labelStyle:"",label:"",padding:0,shape:"labelRect",style:"",width:10,height:10}),n.setParent(u,m.parentId),n.setNode(c,{domId:c,id:c,parentId:m.parentId,labelStyle:"",padding:0,shape:"labelRect",label:"",style:"",width:10,height:10}),n.setParent(c,m.parentId);let h=structuredClone(o),p=structuredClone(o),b=structuredClone(o);h.label="",h.arrowTypeEnd="none",h.endLabelLeft="",h.endLabelRight="",h.startLabelLeft="",h.id=l+"-cyclic-special-1",p.startLabelRight="",p.startLabelLeft="",p.endLabelLeft="",p.endLabelRight="",p.arrowTypeStart="none",p.arrowTypeEnd="none",p.id=l+"-cyclic-special-mid",b.label="",b.startLabelRight="",b.startLabelLeft="",b.arrowTypeStart="none",m.isGroup&&(h.fromCluster=l,b.toCluster=l),b.id=l+"-cyclic-special-2",b.arrowTypeStart="none",n.setEdge(l,u,h,l+"-cyclic-special-0"),n.setEdge(u,c,p,l+"-cyclic-special-1"),n.setEdge(c,l,b,l+"-cyc<lic-special-2")}else n.setEdge(o.start,o.end,{...o},o.id)}),r.warn("Graph at first:",JSON.stringify(v(n))),ae(n),r.warn("Graph after XAX:",JSON.stringify(v(n)));let s=R();await ee(a,n,e.type,e.diagramId,void 0,s)},"render");export{Ne as render};