ruru
Version:
Grafast-flavoured GraphiQL distribution
2 lines • 9.11 kB
JavaScript
export const __webpack_esm_id__=7108;export const __webpack_esm_ids__=[7108];export const __webpack_esm_modules__={58165(e,t,n){n.r(t),n.d(t,{ImperativeState:()=>o});var i=n(79456),o=class{constructor(e){this.init=e,this.records=this.init()}static{(0,i.__name)(this,"ImperativeState")}reset(){this.records=this.init()}}},26637(e,t,n){function i(e,t){e.accDescr&&t.setAccDescription?.(e.accDescr),e.accTitle&&t.setAccTitle?.(e.accTitle),e.title&&t.setDiagramTitle?.(e.title)}n.r(t),n.d(t,{populateCommonDb:()=>i}),(0,n(79456).__name)(i,"populateCommonDb")},57108(e,t,n){n.r(t),n.d(t,{diagram:()=>W});var i=n(58165),o=n(26637),r=n(64342),s=n(56350),a=n(70848),c=n(39989),d=n(27166),l=n(79456),h=n(73744),g=/[─━│┃└┗├┣]/,p=/[└┗├┣]/,f=/[─━]/,m=/^[\s│┃]+$/,u=/^\s*(title[\t ]|accTitle[\t ]*:|accDescr[\t ]*[:{])/,_=/^\s*%%/;function w(e){return e.some(e=>g.test(e))}function x(e){for(const t of e){const e=p.exec(t);if(e?.index&&e.index>0)return e.index}return 4}function b(e,t){return e.replace(/\bline\s+(\d+)\b/gi,(e,n)=>{const i=parseInt(n,10),o=t.get(i);return o?`line ${o}`:e})}function y(e){const t=e.split("\n"),n=new Map;let i=-1;for(const[e,n]of t.entries())if("treeView-beta"===n.trim()){i=e;break}if(-1===i)return{text:e,lineMap:n};const o=[];for(let e=i+1;e<t.length;e++){const n=t[e];""===n.trim()||_.test(n)||u.test(n)||m.test(n)||o.push(n.replace(/\t/g," "))}if(!w(o))return{text:e,lineMap:n};const r=x(o),s=[];let a=0;for(let e=0;e<=i;e++)s.push(t[e]),a++,n.set(a,e+1);for(let e=i+1;e<t.length;e++){const i=t[e],o=e+1;if(""===i.trim()){s.push(i),a++,n.set(a,o);continue}if(_.test(i)){s.push(i),a++,n.set(a,o);continue}if(u.test(i)){s.push(i),a++,n.set(a,o);continue}if(m.test(i))continue;const c=i.replace(/\t/g," "),d=p.exec(c);if(void 0!==d?.index){const e=d.index,t=Math.round(e/r)+1;let i=e+1;for(;i<c.length&&f.test(c[i]);)i++;for(;i<c.length&&" "===c[i];)i++;const l=c.slice(i).trimEnd();if(!l)throw new Error(`Line ${o}: Empty node — expected a filename or directory name after the box-drawing prefix`);const h=" ".repeat(t);s.push(h+l),a++,n.set(a,o)}else{if(/^[\s─━│┃└┗├┣]+$/.test(c))continue;if(g.test(c))s.push(i),a++,n.set(a,o);else{if(/^\s+/.test(c))throw new Error(`Line ${o}: Unexpected indentation without box-drawing characters. In box-drawing format, use ├── or └── prefixes for indented nodes.`);s.push(i),a++,n.set(a,o)}}}return{text:s.join("\n"),lineMap:n}}(0,l.__name)(w,"isBoxDrawingFormat"),(0,l.__name)(x,"inferSegmentWidth"),(0,l.__name)(b,"remapErrorLines"),(0,l.__name)(y,"preprocessBoxDrawing");var v=new i.ImperativeState(()=>({cnt:1,stack:[{id:0,level:-1,name:"/",nodeType:"directory",children:[]}]})),k=(0,l.__name)(()=>{v.reset(),(0,c.clear)()},"clear"),C=(0,l.__name)(()=>v.records.stack[0],"getRoot"),$=(0,l.__name)(()=>v.records.cnt,"getCount"),T=c.defaultConfig_default.treeView,V=(0,l.__name)(()=>(0,a.cleanAndMerge)(T,(0,c.getConfig)().treeView),"getConfig"),B={clear:k,addNode:(0,l.__name)((e,t,n,i,o,r)=>{for(;e<=v.records.stack[v.records.stack.length-1].level;)v.records.stack.pop();const s={id:v.records.cnt++,level:e,name:t,nodeType:n,icon:o,cssClass:i,description:r,children:[]};v.records.stack[v.records.stack.length-1].children.push(s),v.records.stack.push(s)},"addNode"),getRoot:C,getCount:$,getConfig:V,getAccTitle:c.getAccTitle,getAccDescription:c.getAccDescription,getDiagramTitle:c.getDiagramTitle,setAccDescription:c.setAccDescription,setAccTitle:c.setAccTitle,setDiagramTitle:c.setDiagramTitle},I=(0,l.__name)(e=>{(0,o.populateCommonDb)(e,B);for(const t of e.nodes){const e="number"==typeof t.indent?t.indent:0;let n=t.name;const i=n.endsWith("/");i&&(n=n.slice(0,-1));const o=i?"directory":"file",r=t.classAnnotation||void 0,s=t.iconAnnotation,a=void 0!==s?s||"none":void 0,d=t.descAnnotation||void 0,l=d?(0,c.sanitizeText)(d,(0,c.getConfig)()):void 0;B.addNode(e,n,o,r,a,l)}},"populate"),D={parse:(0,l.__name)(async e=>{const{text:t,lineMap:n}=y(e);try{const e=await(0,h.parse)("treeView",t);d.log.debug(e),I(e)}catch(e){throw n.size>0&&e instanceof Error&&(e.message=b(e.message,n)),e}},"parse")},A={prefix:"mermaid-treeview",height:24,width:24,icons:{folder:{body:'<path fill="currentColor" d="M10.59 4.59A2 2 0 0 0 9.17 4H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.17z"/>'},file:{body:'<path fill="currentColor" fill-rule="evenodd" d="M6 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8.83a2 2 0 0 0-.59-1.42l-4.82-4.82A2 2 0 0 0 13.17 2H6Zm7.5 1.9l4.6 4.6h-3.6a1 1 0 0 1-1-1V3.9Z" clip-rule="evenodd"/>'}}};function M(e,t){const n=t?.filenameIcons?.[e];if(n)return n;const i=e.lastIndexOf(".");if(i>0){const n=e.substring(i).toLowerCase(),o=t?.extensionIcons;return o?.[n]??o?.[n.slice(1)]}}function S(e,t){return e.includes(":")?e:e in A.icons||!t?`${A.prefix}:${e}`:`${t}:${e}`}function E(e,t){if("none"!==e.icon){if(e.icon)return S(e.icon,t.defaultIconPack);if(t.showIcons){if("file"===e.nodeType){const n=M(e.name,t);if("none"===n)return;if(n)return S(n,t.defaultIconPack)}return`${A.prefix}:${"directory"===e.nodeType?"folder":"file"}`}}}(0,l.__name)(M,"detectIcon"),(0,l.__name)(S,"qualifyIcon"),(0,l.__name)(E,"getNodeIcon"),(0,s.registerIconPacks)([{name:A.prefix,icons:A}]);var z=(0,l.__name)(async(e,t)=>{const n=[],i=(0,l.__name)(e=>{const o=E(e,t);o&&n.push({icon:o,node:e}),e.children.forEach(i)},"collect");i(e);const o=await Promise.all(n.map(async({icon:e,node:t})=>({id:t.id,svg:await(0,s.getIconSVG)(e,{height:14,width:14})})));return new Map(o.map(({id:e,svg:t})=>[e,t]))},"resolveNodeIcons"),N=(0,l.__name)((e,t,n,i,o,r)=>{const s=i.append("g");let a="treeView-node-label";"directory"===n.nodeType&&(a+=" treeView-node-dir"),n.cssClass&&(a+=` ${n.cssClass}`);const c=E(n,o),d=void 0!==c;c&&s.append("g").attr("class","treeView-node-icon").attr("transform",`translate(${e+o.paddingX}, ${t+o.paddingY})`).html(r.get(n.id)??"");const l=s.append("text").text(n.name).attr("dominant-baseline","middle").attr("class",a),{height:h,width:g}=l.node().getBBox(),p=h+2*o.paddingY,f=e+o.paddingX+(d?18:0);l.attr("x",f),l.attr("y",t+p/2);const m=f+g,u=g+2*o.paddingX+(d?18:0);return n.BBox={x:e,y:t,width:u,height:p},n.cssClass?.split(/\s+/).includes("highlight")&&s.insert("rect",":first-child").attr("x",e).attr("y",t+1).attr("width",0).attr("height",p-2).attr("rx",3).attr("class","treeView-highlight-bg"),{node:n,nodeGroup:s,labelRightEdge:m,centerY:t+p/2}},"positionLabel"),X=(0,l.__name)((e,t,n,i,o,r)=>e.append("line").attr("x1",t).attr("y1",n).attr("x2",i).attr("y2",o).attr("stroke-width",r).attr("class","treeView-node-line"),"positionLine"),L=(0,l.__name)((e,t,n,i)=>{let o=0,r=0;const s=[],a=(0,l.__name)((e,t,n,a)=>{const c=a*(n.rowIndent+n.paddingX),d=N(c,o,t,e,n,i);s.push(d);const{height:l,width:h}=t.BBox;X(e,c-n.rowIndent,o+l/2,c,o+l/2,n.lineThickness),r=Math.max(r,c+h),o+=l},"drawNode"),c=(0,l.__name)((t,i=0)=>{a(e,t,n,i),t.children.forEach(e=>{c(e,i+1)});const{x:o,y:r,height:s}=t.BBox;if(t.children.length){const{y:i,height:a}=t.children[t.children.length-1].BBox;X(e,o+n.paddingX,r+s,o+n.paddingX,i+a/2+n.lineThickness/2,n.lineThickness)}},"processNode");c(t);const d=s.filter(e=>e.node.description);if(d.length>0){const e=Math.max(...s.map(e=>e.labelRightEdge))+16;for(const t of d){const i=t.nodeGroup.append("text").text(t.node.description).attr("dominant-baseline","middle").attr("class","treeView-node-description").attr("x",e).attr("y",t.centerY).node().getBBox();r=Math.max(r,e+i.width+n.paddingX)}}for(const e of s)if(e.node.cssClass?.split(/\s+/).includes("highlight")){const t=e.nodeGroup.select(".treeView-highlight-bg");if(!t.empty()){const n=r-e.node.BBox.x+8;t.attr("width",n),r=Math.max(r,e.node.BBox.x+n+2)}}return{totalHeight:o,totalWidth:r}},"drawTree"),R={labelFontSize:"16px",labelColor:"black",lineColor:"black",iconColor:"#546e7a",descriptionColor:"#6a9955",highlightBg:"rgba(255, 193, 7, 0.15)",highlightStroke:"#ffc107"},W={db:B,renderer:{draw:(0,l.__name)(async(e,t,n,i)=>{d.log.debug("Rendering treeView diagram\n"+e);const o=i.db,s=o.getRoot(),a=o.getConfig(),l=(0,r.selectSvgElement)(t),h=l.append("g");h.attr("class","tree-view");const g=await z(s,a),{totalHeight:p,totalWidth:f}=L(h,s,a,g);l.attr("viewBox",`-${a.lineThickness/2} 0 ${f} ${p}`),(0,c.configureSvgSize)(l,p,f,a.useMaxWidth)},"draw")},parser:D,styles:(0,l.__name)(({treeView:e})=>{const{labelFontSize:t,labelColor:n,lineColor:i,iconColor:o,descriptionColor:r,highlightBg:s,highlightStroke:c}=(0,a.cleanAndMerge)(R,e);return`\n .treeView-node-label {\n font-size: ${t};\n fill: ${n};\n white-space: pre;\n }\n .treeView-node-dir {\n font-weight: bold;\n }\n .treeView-node-line {\n stroke: ${i};\n }\n .treeView-node-icon {\n color: ${o};\n }\n .treeView-node-description {\n font-size: ${t};\n fill: ${r};\n font-style: italic;\n white-space: pre;\n }\n .treeView-highlight-bg {\n fill: ${s};\n stroke: ${c};\n stroke-width: 1;\n }\n `},"styles")}}};
//# sourceMappingURL=7108.js.map