ruru
Version:
Grafast-flavoured GraphiQL distribution
2 lines • 4.81 kB
JavaScript
export const __webpack_esm_id__=710;export const __webpack_esm_ids__=[710];export const __webpack_esm_modules__={26637(t,e,a){function r(t,e){t.accDescr&&e.setAccDescription?.(t.accDescr),t.accTitle&&e.setAccTitle?.(t.accTitle),t.title&&e.setDiagramTitle?.(t.title)}a.r(e),a.d(e,{populateCommonDb:()=>r}),(0,a(79456).__name)(r,"populateCommonDb")},80710(t,e,a){a.r(e),a.d(e,{diagram:()=>_});var r=a(26637),n=a(64342),i=a(70848),o=a(39989),s=a(27166),l=a(79456),c=a(73744),d=o.defaultConfig_default.packet,p=class{constructor(){this.packet=[],this.setAccTitle=o.setAccTitle,this.getAccTitle=o.getAccTitle,this.setDiagramTitle=o.setDiagramTitle,this.getDiagramTitle=o.getDiagramTitle,this.getAccDescription=o.getAccDescription,this.setAccDescription=o.setAccDescription}static{(0,l.__name)(this,"PacketDB")}getConfig(){const t=(0,i.cleanAndMerge)({...d,...(0,o.getConfig)().packet});return t.showBits&&(t.paddingY+=10),t}getPacket(){return this.packet}pushWord(t){t.length>0&&this.packet.push(t)}clear(){(0,o.clear)(),this.packet=[]}},b=(0,l.__name)((t,e)=>{(0,r.populateCommonDb)(t,e);let a=-1,n=[],i=1;const{bitsPerRow:o}=e.getConfig();for(let{start:r,end:l,bits:c,label:d}of t.blocks){if(void 0!==r&&void 0!==l&&l<r)throw new Error(`Packet block ${r} - ${l} is invalid. End must be greater than start.`);if(r??=a+1,r!==a+1)throw new Error(`Packet block ${r} - ${l??r} is not contiguous. It should start from ${a+1}.`);if(0===c)throw new Error(`Packet block ${r} is invalid. Cannot have a zero bit field.`);for(l??=r+(c??1)-1,c??=l-r+1,a=l,s.log.debug(`Packet block ${r} - ${a} with label ${d}`);n.length<=o+1&&e.getPacket().length<1e4;){const[t,a]=h({start:r,end:l,bits:c,label:d},i,o);if(n.push(t),t.end+1===i*o&&(e.pushWord(n),n=[],i++),!a)break;({start:r,end:l,bits:c,label:d}=a)}}e.pushWord(n)},"populate"),h=(0,l.__name)((t,e,a)=>{if(void 0===t.start)throw new Error("start should have been set during first phase");if(void 0===t.end)throw new Error("end should have been set during first phase");if(t.start>t.end)throw new Error(`Block start ${t.start} is greater than block end ${t.end}.`);if(t.end+1<=e*a)return[t,void 0];const r=e*a-1,n=e*a;return[{start:t.start,end:r,label:t.label,bits:r-t.start},{start:n,end:t.end,label:t.label,bits:t.end-n}]},"getNextFittingBlock"),k={parser:{yy:void 0},parse:(0,l.__name)(async t=>{const e=await(0,c.parse)("packet",t),a=k.parser?.yy;if(!(a instanceof p))throw new Error("parser.parser?.yy was not a PacketDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");s.log.debug(e),b(e,a)},"parse")},g=(0,l.__name)((t,e,a,r)=>{const i=r.db,s=i.getConfig(),{rowHeight:l,paddingY:c,bitWidth:d,bitsPerRow:p}=s,b=i.getPacket(),h=i.getDiagramTitle(),k=l+c,g=k*(b.length+1)-(h?0:l),f=d*p+2,u=(0,n.selectSvgElement)(e);u.attr("viewBox",`0 0 ${f} ${g}`),(0,o.configureSvgSize)(u,g,f,s.useMaxWidth);for(const[t,e]of b.entries())m(u,e,t,s);u.append("text").text(h).attr("x",f/2).attr("y",g-k/2).attr("dominant-baseline","middle").attr("text-anchor","middle").attr("class","packetTitle")},"draw"),m=(0,l.__name)((t,e,a,{rowHeight:r,paddingX:n,paddingY:i,bitWidth:o,bitsPerRow:s,showBits:l})=>{const c=t.append("g"),d=a*(r+i)+i;for(const t of e){const e=t.start%s*o+1,a=(t.end-t.start+1)*o-n;if(c.append("rect").attr("x",e).attr("y",d).attr("width",a).attr("height",r).attr("class","packetBlock"),c.append("text").attr("x",e+a/2).attr("y",d+r/2).attr("class","packetLabel").attr("dominant-baseline","middle").attr("text-anchor","middle").text(t.label),!l)continue;const i=t.end===t.start,p=d-2;c.append("text").attr("x",e+(i?a/2:0)).attr("y",p).attr("class","packetByte start").attr("dominant-baseline","auto").attr("text-anchor",i?"middle":"start").text(t.start),i||c.append("text").attr("x",e+a).attr("y",p).attr("class","packetByte end").attr("dominant-baseline","auto").attr("text-anchor","end").text(t.end)}},"drawWord"),f={draw:g},u={byteFontSize:"10px",startByteColor:"black",endByteColor:"black",labelColor:"black",labelFontSize:"12px",titleColor:"black",titleFontSize:"14px",blockStrokeColor:"black",blockStrokeWidth:"1",blockFillColor:"#efefef"},w=(0,l.__name)(({packet:t}={})=>{const e=(0,i.cleanAndMerge)(u,t);return`\n\t.packetByte {\n\t\tfont-size: ${e.byteFontSize};\n\t}\n\t.packetByte.start {\n\t\tfill: ${e.startByteColor};\n\t}\n\t.packetByte.end {\n\t\tfill: ${e.endByteColor};\n\t}\n\t.packetLabel {\n\t\tfill: ${e.labelColor};\n\t\tfont-size: ${e.labelFontSize};\n\t}\n\t.packetTitle {\n\t\tfill: ${e.titleColor};\n\t\tfont-size: ${e.titleFontSize};\n\t}\n\t.packetBlock {\n\t\tstroke: ${e.blockStrokeColor};\n\t\tstroke-width: ${e.blockStrokeWidth};\n\t\tfill: ${e.blockFillColor};\n\t}\n\t`},"styles"),_={parser:k,get db(){return new p},renderer:f,styles:w}}};
//# sourceMappingURL=710.js.map