mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-21 15:55:36 +08:00
79 lines
25 KiB
JavaScript
79 lines
25 KiB
JavaScript
|
|
import{_ as u,s as Mt,g as Nt,t as Lt,q as zt,a as Tt,b as At,a1 as Xt,F as Et,H as J,l as Q,L as Yt,e as It,A as Ft,c as V}from"./mermaid.core.nRjnRDqC.js";import{p as Bt}from"./chunk-4BX2VUAB.CU_CNmGw.js";import{p as Rt}from"./wardley-L42UT6IY.C8rjnVeB.js";import"./framework.C2AwuPrQ.js";var G=u((o,r)=>{const e=o<=1?o*100:o;if(e<0||e>100)throw new Error(`${r} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${o}`);return e},"toPercent"),A=u((o,r,e)=>({x:G(r,`${e} evolution`),y:G(o,`${e} visibility`)}),"toCoordinates"),K=u(o=>{if(o){if(o==="+<>")return"bidirectional";if(o==="+<")return"backward";if(o==="+>")return"forward"}},"getFlowFromPort"),Ot=u(o=>{if(!o?.startsWith("+"))return{};const e=/^\+'([^']*)'/.exec(o)?.[1];return o.includes("<>")?{flow:"bidirectional",label:e}:o.includes("<")?{flow:"backward",label:e}:o.includes(">")?{flow:"forward",label:e}:{label:e}},"extractFlowFromArrow"),Wt=u((o,r)=>{if(Bt(o,r),o.size&&r.setSize(o.size.width,o.size.height),o.evolution){const e=o.evolution.stages.map(a=>a.secondName?`${a.name.trim()} / ${a.secondName.trim()}`:a.name.trim()),h=o.evolution.stages.filter(a=>a.boundary!==void 0).map(a=>a.boundary);r.updateAxes({stages:e,stageBoundaries:h})}if(o.anchors.forEach(e=>{const h=A(e.visibility,e.evolution,`Anchor "${e.name}"`);r.addNode(e.name,e.name,h.x,h.y,"anchor")}),o.components.forEach(e=>{const h=A(e.visibility,e.evolution,`Component "${e.name}"`),a=e.label?(e.label.negX?-1:1)*e.label.offsetX:void 0,d=e.label?(e.label.negY?-1:1)*e.label.offsetY:void 0,w=e.decorator?.strategy;r.addNode(e.name,e.name,h.x,h.y,"component",a,d,e.inertia,w)}),o.notes.forEach(e=>{const h=A(e.visibility,e.evolution,`Note "${e.text}"`);r.addNote(e.text,h.x,h.y)}),o.pipelines.forEach(e=>{const h=r.getNode(e.parent);if(!h||typeof h.y!="number")throw new Error(`Pipeline "${e.parent}" must reference an existing component with coordinates.`);const a=h.y;r.startPipeline(e.parent),e.components.forEach(d=>{const w=`${e.parent}_${d.name}`,C=d.label?(d.label.negX?-1:1)*d.label.offsetX:void 0,g=d.label?(d.label.negY?-1:1)*d.label.offsetY:void 0,R=G(d.evolution,`Pipeline component "${d.name}" evolution`);r.addNode(w,d.name,R,a,"pipeline-component",C,g),r.addPipelineComponent(e.parent,w)})}),o.links.forEach(e=>{const h=!!e.arrow&&(e.arrow.includes("-.->")||e.arrow.includes(".-."));let a=K(e.fromPort)??K(e.toPort);const{flow:d,label:w}=Ot(e.arrow);!a&&d&&(a=d);const C=e.linkLabel,g=w??C;r.addLink(r.resolveNodeId(e.from),r.resolveNodeId(e.to),h,g,a)}),o.evolves.forEach(e=>{const h=r.getNode(e.component);if(h?.y!==void 0){const a=G(e.target,`Evolve target for "${e.component}"`);r.addTrend(e.component,a,h.y)}}),o.annotations.length>0){const e=o.annotations[0],h=A(e.x,e.y,"Annotations box");r.setAnnotationsBox(h.x,h.y)}o.annotation.forEach(e=>{const h=A(e.x,e.y,`Annotation ${e.number}`);r.addAnnotation(e.number,[{x:h.x,y:h.y}],e.text)}),o.accelerators.forEach(e=>{const h=A(e.x,e.y,`Accelerator "${e.name}"`);r.addAccelerator(e.name,h.x,h.y)}),o.deaccelerators.forEach(e=>{const h=A(e.x,e.y,`Deaccelerator "${e.name}"`);r.addDeaccelerator(e.name,h.x,h.y)})},"populateDb"),tt={parser:{yy:void 0},parse:u(async o=>{const r=await Rt("wardley",o);Q.debug(r);const e=tt.parser?.yy;if(!e||typeof e.addNode!="function")throw new Error("parser.parser?.yy was not a WardleyDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");Wt(r,e)},"parse")},E,Dt=(E=class{constructor(){this.nodes=new Map,this.links=[],this.trends=new Map,this.pipelines=new Map,this.annotations=[],this.notes=[],this.accelerators=[],this.deaccelerators=[],this.axes={}}addNode(r){const e=this.nodes.get(r.id)??{id:r.id,label:r.label},h={...e,...r,className:r.className??e.className,labelOffsetX:r.labelOffsetX??e.labelOffsetX,labelOffsetY:r.labelOffsetY??e.labelOffsetY};this.nodes.set(r.id,h)}addLink(r){this.links.push(r)}addTrend(r){this.trends.set(r.nodeId,r)}startPipeline(r){this.pipelines.set(r,{nodeId:r,componentIds:[]});const e=this.nodes.get(r);e&&(e.isPipelineParent=!0)}addPipelineCompon
|
||
|
|
`+o);const a=jt(),d=Ht(),w=a.nodeRadius*1.6,C=h.db,g=C.getWardleyData(),R=C.getDiagramTitle(),S=g.size?.width??a.width,b=g.size?.height??a.height,Y=Yt(r);Y.selectAll("*").remove(),It(Y,b,S,a.useMaxWidth),Y.attr("viewBox",`0 0 ${S} ${b}`);const v=Y.append("g").attr("class","wardley-map"),q=Y.append("defs");q.append("marker").attr("id",`arrow-${r}`).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerWidth",6).attr("markerHeight",6).attr("orient","auto-start-reverse").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("fill",d.evolutionStroke).attr("stroke","none"),q.append("marker").attr("id",`link-arrow-end-${r}`).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("fill",d.linkStroke).attr("stroke","none"),q.append("marker").attr("id",`link-arrow-start-${r}`).attr("viewBox","0 0 10 10").attr("refX",1).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("path").attr("d","M 10 0 L 0 5 L 10 10 z").attr("fill",d.linkStroke).attr("stroke","none"),v.append("rect").attr("class","wardley-background").attr("width",S).attr("height",b).attr("fill",d.backgroundColor);const I=S-a.padding*2,F=b-a.padding*2;R&&v.append("text").attr("class","wardley-title").attr("x",S/2).attr("y",a.padding/2).attr("fill",d.axisTextColor).attr("font-size",a.axisFontSize*1.05).attr("font-weight","bold").attr("text-anchor","middle").attr("dominant-baseline","middle").text(R);const L=u(t=>a.padding+t/100*I,"projectX"),z=u(t=>b-a.padding-t/100*F,"projectY"),O=v.append("g").attr("class","wardley-axes");O.append("line").attr("x1",a.padding).attr("x2",S-a.padding).attr("y1",b-a.padding).attr("y2",b-a.padding).attr("stroke",d.axisColor).attr("stroke-width",1),O.append("line").attr("x1",a.padding).attr("x2",a.padding).attr("y1",a.padding).attr("y2",b-a.padding).attr("stroke",d.axisColor).attr("stroke-width",1);const wt=g.axes.xLabel??"Evolution",mt=g.axes.yLabel??"Visibility";O.append("text").attr("class","wardley-axis-label wardley-axis-label-x").attr("x",a.padding+I/2).attr("y",b-a.padding/4).attr("fill",d.axisTextColor).attr("font-size",a.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").text(wt),O.append("text").attr("class","wardley-axis-label wardley-axis-label-y").attr("x",a.padding/3).attr("y",a.padding+F/2).attr("fill",d.axisTextColor).attr("font-size",a.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").attr("transform",`rotate(-90 ${a.padding/3} ${a.padding+F/2})`).text(mt);const B=g.axes.stages&&g.axes.stages.length>0?g.axes.stages:qt;if(B.length>0){const t=v.append("g").attr("class","wardley-stages"),s=g.axes.stageBoundaries,n=[];if(s&&s.length===B.length){let i=0;s.forEach(p=>{n.push({start:i,end:p}),i=p})}else{const i=1/B.length;B.forEach((p,l)=>{n.push({start:l*i,end:(l+1)*i})})}B.forEach((i,p)=>{const l=n[p],f=a.padding+l.start*I,x=a.padding+l.end*I,y=(f+x)/2;p>0&&t.append("line").attr("x1",f).attr("x2",f).attr("y1",a.padding).attr("y2",b-a.padding).attr("stroke","#000").attr("stroke-width",1).attr("stroke-dasharray","5 5").attr("opacity",.8),t.append("text").attr("class","wardley-stage-label").attr("x",y).attr("y",b-a.padding/1.5).attr("fill",d.axisTextColor).attr("font-size",a.axisFontSize-2).attr("text-anchor","middle").text(i)})}if(a.showGrid){const t=v.append("g").attr("class","wardley-grid");for(let s=1;s<4;s++){const n=s/4,i=a.padding+I*n;t.append("line").attr("x1",i).attr("x2",i).attr("y1",a.padding).attr("y2",b-a.padding).attr("stroke",d.gridColor).attr("stroke-dasharray","2 6"),t.append("line").attr("x1",a.padding).attr("x2",S-a.padding).attr("y1",b-a.padding-F*n).attr("y2",b-a.padding-F*n).attr("stroke",d.gridColor).attr("stroke-dasharray","2 6")}}const c=new Map;if(g.nodes.forEach(t=>{c.set(t.id,{x:L(t.x),y:z(t.y),node:t})}),g.pipelines.length>0){const t=v.append("g").attr("class","wardley-pipelines"),s=v.append("g").attr("class","wardley-pipeline-links");g.pipelines.forEach(n=>{if(n.componentIds.length===0)retur
|
||
|
|
M ${n} ${i-l/2}
|
||
|
|
L ${n+p-f} ${i-l/2}
|
||
|
|
L ${n+p-f} ${i-l/2-8}
|
||
|
|
L ${n+p} ${i}
|
||
|
|
L ${n+p-f} ${i+l/2+8}
|
||
|
|
L ${n+p-f} ${i+l/2}
|
||
|
|
L ${n} ${i+l/2}
|
||
|
|
Z
|
||
|
|
`;t.append("path").attr("d",x).attr("fill","white").attr("stroke",d.componentStroke).attr("stroke-width",1),t.append("text").attr("x",n+p/2).attr("y",i+l/2+15).attr("text-anchor","middle").attr("font-size",10).attr("fill",d.axisTextColor).attr("font-weight","bold").text(s.name)})}if(g.deaccelerators.length>0){const t=v.append("g").attr("class","wardley-deaccelerators");g.deaccelerators.forEach(s=>{const n=L(s.x),i=z(s.y),p=60,l=30,f=20,x=`
|
||
|
|
M ${n+p} ${i-l/2}
|
||
|
|
L ${n+f} ${i-l/2}
|
||
|
|
L ${n+f} ${i-l/2-8}
|
||
|
|
L ${n} ${i}
|
||
|
|
L ${n+f} ${i+l/2+8}
|
||
|
|
L ${n+f} ${i+l/2}
|
||
|
|
L ${n+p} ${i+l/2}
|
||
|
|
Z
|
||
|
|
`;t.append("path").attr("d",x).attr("fill","white").attr("stroke",d.componentStroke).attr("stroke-width",1),t.append("text").attr("x",n+p/2).attr("y",i+l/2+15).attr("text-anchor","middle").attr("font-size",10).attr("fill",d.axisTextColor).attr("font-weight","bold").text(s.name)})}},"draw"),_t={draw:Vt},Zt=u(({wardley:o}={})=>{const r=Xt(),e=Et(),h=J(r,e.themeVariables),a=J(h.wardley,o);return`
|
||
|
|
.wardley-background {
|
||
|
|
fill: ${a.backgroundColor};
|
||
|
|
}
|
||
|
|
.wardley-axes line, .wardley-axes path {
|
||
|
|
stroke: ${a.axisColor};
|
||
|
|
}
|
||
|
|
.wardley-axis-label {
|
||
|
|
fill: ${a.axisTextColor};
|
||
|
|
}
|
||
|
|
.wardley-stage-label {
|
||
|
|
fill: ${a.axisTextColor};
|
||
|
|
}
|
||
|
|
.wardley-grid line {
|
||
|
|
stroke: ${a.gridColor};
|
||
|
|
}
|
||
|
|
.wardley-node circle {
|
||
|
|
fill: ${a.componentFill};
|
||
|
|
stroke: ${a.componentStroke};
|
||
|
|
}
|
||
|
|
.wardley-node-label {
|
||
|
|
fill: ${a.componentLabelColor};
|
||
|
|
}
|
||
|
|
.wardley-link {
|
||
|
|
stroke: ${a.linkStroke};
|
||
|
|
}
|
||
|
|
.wardley-link--dashed {
|
||
|
|
stroke-dasharray: 4 4;
|
||
|
|
}
|
||
|
|
.wardley-link-label {
|
||
|
|
fill: ${a.axisTextColor};
|
||
|
|
}
|
||
|
|
.wardley-trend line {
|
||
|
|
stroke: ${a.evolutionStroke};
|
||
|
|
}
|
||
|
|
.wardley-annotation-line {
|
||
|
|
stroke: ${a.annotationStroke};
|
||
|
|
}
|
||
|
|
.wardley-annotation circle {
|
||
|
|
fill: ${a.annotationFill};
|
||
|
|
stroke: ${a.annotationStroke};
|
||
|
|
}
|
||
|
|
.wardley-annotation text {
|
||
|
|
fill: ${a.annotationTextColor};
|
||
|
|
}
|
||
|
|
.wardley-annotations-box rect {
|
||
|
|
fill: ${a.annotationFill};
|
||
|
|
stroke: ${a.annotationStroke};
|
||
|
|
}
|
||
|
|
.wardley-annotations-box text {
|
||
|
|
fill: ${a.annotationTextColor};
|
||
|
|
}
|
||
|
|
.wardley-pipeline-box {
|
||
|
|
stroke: ${a.componentStroke};
|
||
|
|
}
|
||
|
|
.wardley-notes text {
|
||
|
|
fill: ${a.axisTextColor};
|
||
|
|
}
|
||
|
|
`},"styles"),ee={parser:tt,db:Gt,renderer:_t,styles:Zt};export{ee as diagram};
|