UNPKG

ruru

Version:

Grafast-flavoured GraphiQL distribution

2 lines 7.87 kB
export const __webpack_esm_id__=8982;export const __webpack_esm_ids__=[8982];export const __webpack_esm_modules__={8982(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.mermaidEscape=t.COLORS=void 0,t.planToMermaid=function(e,{concise:r=!1,collapseLeaves:l=!0,skipBuckets:a=n.g.grafastExplainMermaidSkipBuckets??!1}={}){if("v1"!==e.version)throw new Error("planToMermaid only supports v1 plan JSON");const d=Object.create(null),f=Object.create(null),u=Object.create(null),$=[];e.buckets.forEach(e=>{if(f[e.id])throw new Error(`Two buckets with the same ID ${e.id}?`);f[e.id]=e;const t=[...e.steps].sort((e,t)=>t.dependencyIds.length-e.dependencyIds.length);for(const e of t){if(d[e.id])throw new Error(`Step ${e.id} (${e.stepClass}/${e.metaString}) duplicated in plan?!`);d[e.id]=e,$.push(e);for(const t of e.dependencyIds)u[t]?u[t].push(e):u[t]=[e]}});const h=e=>"ConstantStep"===e.stepClass||"undefined"===e.extra?.constant?.type||!(0!==e.bucketId||!e.isSyncAndSafe||u[e.id]),m=e=>"polymorphicPartition"===f[e].reason.type?y.find(t=>t.childIds.includes(e)):e,S=e=>{const t=d[e];if(!t)return!0;if("ConstantStep"===t.stepClass)return!0;if(0!==t.bucketId)return!1;const n=u[e];if(!n||0===n.length)return!1;const s=n[0];return n.some(e=>m(e.bucketId)!==m(s.bucketId))},b=e=>t.COLORS[e%t.COLORS.length],g=["%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%",(r?"flowchart":"graph")+" TD"," classDef path fill:#eee,stroke:#000,color:#000"," classDef plan fill:#fff,stroke-width:1px,color:#000"," classDef itemplan fill:#fff,stroke-width:2px,color:#000"," classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000"," classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000"," classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left",""],I=e=>`${e.stepClass.replace(/Step$/,"")}${0===e.bucketId?"":`{${e.bucketId}}`}${e.metaString?`<${e.metaString}>`:""}[${e.id}]`,y=Object.values(f);if(!a){r||g.push(" subgraph Buckets");for(let e=0,n=y.length;e<n;e++){const n=y[e],s=` (${n.reason.type})`+("polymorphicPartition"===n.reason.type?`\n|${n.reason.typeNames.join("\n|")}`:"polymorphic"===n.reason.type?`\n__typename: ${i(d[n.reason.parentStepId])}`:"");g.push(` Bucket${n.id}(${(0,t.mermaidEscape)(`Bucket ${n.id}${s}${null!=n.parentSideEffectStepId?`\nParent side effect step: ${d[n.parentSideEffectStepId].id}`:""}${n.copyStepIds.length>0?`\nDeps: ${n.copyStepIds.map(e=>d[e].id).join(", ")}`:""}${"polymorphicPartition"===n.reason.type?"\n"+o(n.reason.polymorphicPaths):""}\n${null!=n.rootStepId&&"root"!==n.reason.type?`\nROOT ${I(d[n.rootStepId])}`:""}${w(n)}`)}):::bucket`)}r||g.push(" end")}if(!a)for(let e=0,t=y.length;e<t;e++){const t=y[e],n=t.childIds.map(e=>`Bucket${e}`);n.length>0&&g.push(` Bucket${t.id} --\x3e ${n.join(" & ")}`)}const _=Object.create(null),k=e=>{if(!_[e.id]){h(e)&&console.warn(`Was expecting to hide step ${e.id}, but we're rendering it anyway?`);const n=e.stepClass.replace(/Step$/,""),c=`${n}${e.id}`;_[e.id]=c;const p=e.metaString,l=null!=p?(0,s.stripAnsi)(p):null,a=r&&l?((e,t=8,n=8)=>e.length>t+n+4?`${e.slice(0,t)}...${e.slice(e.length-n)}`:e)(l):l,f=e.supportsUnbatched,$=o(e.polymorphicPaths),m=e.dependencyIds.filter(t=>d[t].bucketId===e.bucketId),b=m.length>=1&&m.every(e=>o(d[e].polymorphicPaths)===$),I=b||""===$?"":`\n${$}`,[y,k,j="",O=n]="__ItemStep"===e.stepClass?["[/","\\]"]:"__ValueStep"===e.stepClass&&e.extra?.combined?[null,null,"docs","__Combined"]:e.isSyncAndSafe?f?["{{","}}"]:["[","]"]:["[[","]]"],E=S(e.id)?`\nDependents: ${u[e.id]?.length}`:"",x=e.dependencyIds.filter(S),w=x.length>0?`\nMore deps:\n${x.map(e=>`- ${i(d[e])}`).join("\n")}`:"",C=`${O}[${e.id}∈${e.bucketId}${e.stream?"@s":""}]${e.isUnary?" ➊":""}${b&&""!==$?"^":""}${a?`\n<${a}>`:""}${I}${E}${w}`,A=e.hasSideEffects?"sideeffectplan":"__ItemStep"===e.stepClass?"itemplan":f&&!e.isSyncAndSafe?"unbatchedplan":"plan";null===y?g.push(` ${c}:::${A}@{shape: ${j}, label: ${(0,t.mermaidEscape)(C)}}`):g.push(` ${c}${y}${(0,t.mermaidEscape)(C)}${k}:::${A}`)}return _[e.id]};g.push(""),g.push(" %% plan dependencies");const j=Object.create(null),O=(e,n)=>{const i=e.dependencyForbiddenFlags[n],c=e.dependencyOnReject[n],o=[];i&&(2&~i||o.push("rejectNull"),1&i||o.push("trapError"),4&i||o.push("trapInhibited"),c&&o.push(`onReject=${function(e,t=15){return e.length>t?e.substring(0,t-2)+"…":e}((0,s.stripAnsi)(c))}`));const p=o.join(";");return p?`|${(0,t.mermaidEscape)(p)}|`:""};$.forEach(e=>{if(h(e))return;const t=k(e),n=e.dependencyIds.map(e=>{const t=d[e];return h(t)||S(e)?null:k(t)}),s=n.find(e=>null!=e);if(n.length>0&&s)if("__ItemStep"===e.stepClass){const i=null==e.extra?.transformStepId?"==>":"-.->";g.push(` ${s} ${i}${O(e,0)} ${t}`);const c=[];for(let i=0;i<n.length;i++){const o=n[i];if(null==o||o===s)continue;const p=O(e,i);p?g.push(` ${o} --\x3e${p} ${t}`):c.push(o)}c.length>0&&p(g,t,c)}else if(!1===l||u[e.id]||1!==n.length){const s=[];for(let i=0;i<n.length;i++){const c=n[i];if(null==c)continue;const o=O(e,i);o?g.push(` ${c} --\x3e${o} ${t}`):s.push(c)}p(g,t,s)}else void 0===j[s]?g.push(` ${s} --\x3e${O(e,0)} ${t}`):g.push(` ${j[s]} o--o${O(e,0)} ${t}`),j[s]=t;return e}),g.push(""),g.push(" %% define steps"),$.forEach(e=>{h(e)||k(e)});for(let e=0,t=y.length;e<t;e++){const t=y[e],n=t.steps;g.push(` classDef bucket${t.id} stroke:${b("number"==typeof t.id?t.id:Object.values(f).indexOf(t))}`),g.push(` class ${[`Bucket${t.id}`,...n.filter(e=>!h(e)).map(k)].join(",")} bucket${t.id}`)}let E=!0;const x=(e,t)=>d[e].dependencyIds.some(e=>e===t||d[e].implicitSideEffectStepId===t||x(e,t));$.forEach(e=>{if(e.implicitSideEffectStepId&&!x(e.id,e.implicitSideEffectStepId)){E&&(g.push(""),g.push(" %% implicit side effects"),E=!1);const t=d[e.implicitSideEffectStepId];g.push(` ${k(t)} -.-o ${k(e)}`)}}),g.push("");for(let e=0,t=y.length;e<t;e++){const t=y[e];if("combined"===t.reason.type)for(const{targetStepId:e,sources:n}of t.reason.combinations){const t=d[e];for(const{stepId:e}of n){const n=d[e];g.push(` ${k(n)} -.-x ${k(t)}`)}}}return g.join("\n");function w(e){return 1===e.phases.length?"":`\n${e.phases.map((e,t)=>`${t+1}: ${c(e.normalStepIds?.map(e=>d[e]))}${e.unbatchedStepIds?`\n>: ${c(e.unbatchedStepIds.map(e=>d[e]))}`:""}`).join("\n")}`}};const s=n(76856);function i(e){return"ConstantStep"===e.stepClass?`Constant${e.metaString?`<${e.metaString}>`:""}[${e.id}]`:`${e.stepClass.replace(/Step$/,"")??""}[${e.id}]`}function c(e){if(!e)return"";const t=e.map(i).join(", ");return t.length<40?t:e.map(e=>e.id).join(", ")}function o(e){if(null==e)return"";const t=Object.create(null),n=[],s=Object.create(null);for(const i of e){const e=i.lastIndexOf(">");if(e<=0)n.push(i);else{const n=i.slice(e);s[n]=i,t[n]?t[n]++:t[n]=1}}for(const[e,i]of Object.entries(t))n.push(1===i?s[e]:`(${i}) ...${e}`);return n.join("\n")}function p(e,t,n){if(n.length){const s=Object.create(null);for(const e of n)s[e]?s[e]++:s[e]=1;const i=Object.keys(s).filter(e=>1===s[e]);i.length>=1&&e.push(` ${i.join(" & ")} --\x3e ${t}`);for(const[n,i]of Object.entries(s))1!==i&&e.push(` ${n} -- ${i} --\x3e ${t}`)}}t.COLORS=["#696969","#00bfff","#7f007f","#ffa500","#0000ff","#7fff00","#ff1493","#808000","#dda0dd","#ff0000","#ffff00","#00ffff","#4169e1","#3cb371","#a52a2a","#ff00ff","#f5deb3"],t.mermaidEscape=e=>e.match(/^[a-z0-9 ]+$/i)?e:`"${(0,s.stripAnsi)(e.trim()).replace(/[#"<>]/g,e=>({"#":"ꖛ",'"':"”","<":"ᐸ",">":"ᐳ"}[e])).replace(/\r?\n/g,"<br />")}"`},76856(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ANSI_REGEXP=void 0,t.stripAnsi=function(e){return e.replace(t.ANSI_REGEXP,"")},t.ANSI_REGEXP=/[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)|(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))/g}}; //# sourceMappingURL=8982.js.map