UNPKG

ruru

Version:

Grafast-flavoured GraphiQL distribution

2 lines 8.2 kB
export const __webpack_id__=8983;export const __webpack_ids__=[8982,8983];export const __webpack_modules__={8982:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mermaidEscape=t.COLORS=void 0,t.planToMermaid=function(e,{concise:s=!1,skipBuckets:l=n.g.grafastExplainMermaidSkipBuckets??!1}={}){if("v1"!==e.version)throw new Error("planToMermaid only supports v1 plan JSON");const a=Object.create(null),d=Object.create(null),f=Object.create(null),u=[];e.buckets.forEach(e=>{if(d[e.id])throw new Error(`Two buckets with the same ID ${e.id}?`);d[e.id]=e;const t=[...e.steps].sort((e,t)=>t.dependencyIds.length-e.dependencyIds.length);for(const e of t){if(a[e.id])throw new Error(`Step ${e.id} (${e.stepClass}/${e.metaString}) duplicated in plan?!`);a[e.id]=e,u.push(e);for(const t of e.dependencyIds)f[t]?f[t].push(e):f[t]=[e]}});const $=e=>"ConstantStep"===e.stepClass||"undefined"===e.extra?.constant?.type||!(0!==e.bucketId||!e.isSyncAndSafe||0!==(f[e.id]?.length??0)),h=e=>"polymorphicPartition"===d[e].reason.type?y.find(t=>t.childIds.includes(e)):e,m=e=>{const t=a[e];if(!t)return!0;if("ConstantStep"===t.stepClass)return!0;if(0!==t.bucketId)return!1;const n=f[e];if(!n||0===n.length)return!1;const s=n[0];return n.some(e=>h(e.bucketId)!==h(s.bucketId))},b=e=>t.COLORS[e%t.COLORS.length],S=["%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%",(s?"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",""],g=e=>`${e.stepClass.replace(/Step$/,"")}${0===e.bucketId?"":`{${e.bucketId}}`}${e.metaString?`<${e.metaString}>`:""}[${e.id}]`,y=Object.values(d);if(!l){s||S.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(a[n.reason.parentStepId])}`:"");S.push(` Bucket${n.id}(${(0,t.mermaidEscape)(`Bucket ${n.id}${s}${null!=n.parentSideEffectStepId?`\nParent side effect step: ${a[n.parentSideEffectStepId].id}`:""}${n.copyStepIds.length>0?`\nDeps: ${n.copyStepIds.map(e=>a[e].id).join(", ")}`:""}${"polymorphicPartition"===n.reason.type?"\n"+r(n.reason.polymorphicPaths):""}\n${null!=n.rootStepId&&"root"!==n.reason.type?`\nROOT ${g(a[n.rootStepId])}`:""}${x(n)}`)}):::bucket`)}s||S.push(" end")}if(!l)for(let e=0,t=y.length;e<t;e++){const t=y[e],n=t.childIds.map(e=>`Bucket${e}`);n.length>0&&S.push(` Bucket${t.id} --\x3e ${n.join(" & ")}`)}const I=Object.create(null),_=e=>{if(!I[e.id]){$(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}`;I[e.id]=c;const p=e.metaString,l=null!=p?(0,o.stripAnsi)(p):null,d=s&&l?((e,t=8,n=8)=>e.length>t+n+4?`${e.slice(0,t)}...${e.slice(e.length-n)}`:e)(l):l,u=e.supportsUnbatched,h=r(e.polymorphicPaths),b=e.dependencyIds.filter(t=>a[t].bucketId===e.bucketId),g=b.length>=1&&b.every(e=>r(a[e].polymorphicPaths)===h),y=g||""===h?"":`\n${h}`,[_,k,j="",O=n]="__ItemStep"===e.stepClass?["[/","\\]"]:"__ValueStep"===e.stepClass&&e.extra?.combined?[null,null,"docs","__Combined"]:e.isSyncAndSafe?u?["{{","}}"]:["[","]"]:["[[","]]"],x=m(e.id)?`\nDependents: ${f[e.id]?.length}`:"",E=e.dependencyIds.filter(m),w=E.length>0?`\nMore deps:\n${E.map(e=>`- ${i(a[e])}`).join("\n")}`:"",C=`${O}[${e.id}∈${e.bucketId}${e.stream?"@s":""}]${e.isUnary?" ➊":""}${g&&""!==h?"^":""}${d?`\n<${d}>`:""}${y}${x}${w}`,v=e.hasSideEffects?"sideeffectplan":"__ItemStep"===e.stepClass?"itemplan":u&&!e.isSyncAndSafe?"unbatchedplan":"plan";null===_?S.push(` ${c}:::${v}@{shape: ${j}, label: ${(0,t.mermaidEscape)(C)}}`):S.push(` ${c}${_}${(0,t.mermaidEscape)(C)}${k}:::${v}`)}return I[e.id]};S.push(""),S.push(" %% plan dependencies");const k=Object.create(null),j=(e,n)=>{const s=e.dependencyForbiddenFlags[n],i=e.dependencyOnReject[n],c=[];s&&(2&~s||c.push("rejectNull"),1&s||c.push("trapError"),4&s||c.push("trapInhibited"),i&&c.push(`onReject=${function(e,t=15){return e.length>t?e.substring(0,t-2)+"…":e}((0,o.stripAnsi)(i))}`));const r=c.join(";");return r?`|${(0,t.mermaidEscape)(r)}|`:""};u.forEach(e=>{if($(e))return;const t=_(e),n=e.dependencyIds.map(e=>{const t=a[e];return $(t)||m(e)?null:_(t)}),o=n.find(e=>null!=e);if(n.length>0&&o)if("__ItemStep"===e.stepClass){const s=null==e.extra?.transformStepId?"==>":"-.->";S.push(` ${o} ${s}${j(e,0)} ${t}`);const i=[];for(let s=0;s<n.length;s++){const c=n[s];if(null==c||c===o)continue;const r=j(e,s);r?S.push(` ${c} --\x3e${r} ${t}`):i.push(c)}i.length>0&&p(S,t,i)}else if(s&&!f[e.id]&&1===n.length)void 0===k[o]?S.push(` ${o} --\x3e${j(e,0)} ${t}`):S.push(` ${k[o]} o--o${j(e,0)} ${t}`),k[o]=t;else{const s=[];for(let o=0;o<n.length;o++){const i=n[o];if(null==i)continue;const c=j(e,o);c?S.push(` ${i} --\x3e${c} ${t}`):s.push(i)}p(S,t,s)}return e}),S.push(""),S.push(" %% define steps"),u.forEach(e=>{$(e)||_(e)});for(let e=0,t=y.length;e<t;e++){const t=y[e],n=t.steps;S.push(` classDef bucket${t.id} stroke:${b("number"==typeof t.id?t.id:Object.values(d).indexOf(t))}`),S.push(` class ${[`Bucket${t.id}`,...n.filter(e=>!$(e)).map(_)].join(",")} bucket${t.id}`)}let O=!0;u.forEach(e=>{if(e.implicitSideEffectStepId){O&&(S.push(""),S.push(" %% implicit side effects"),O=!1);const t=a[e.implicitSideEffectStepId];S.push(` ${_(t)} -.-o ${_(e)}`)}}),S.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=a[e];for(const{stepId:e}of n){const n=a[e];S.push(` ${_(n)} -.-x ${_(t)}`)}}}return S.join("\n");function x(e){return 1===e.phases.length?"":`\n${e.phases.map((e,t)=>`${t+1}: ${c(e.normalStepIds?.map(e=>a[e]))}${e.unbatchedStepIds?`\n>: ${c(e.unbatchedStepIds.map(e=>a[e]))}`:""}`).join("\n")}`}};const s=n(85608),o=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 r(e){if(null==e)return"";const t=Object.create(null),n=[],s=Object.create(null);for(const o of e){const e=o.lastIndexOf(">");if(e<=0)n.push(o);else{const n=o.slice(e);s[n]=o,t[n]?t[n]++:t[n]=1}}for(const[e,o]of Object.entries(t))n.push(1===o?s[e]:`(${o}) ...${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 o=Object.keys(s).filter(e=>1===s[e]);o.length>=1&&e.push(` ${o.join(" & ")} --\x3e ${t}`);for(const[n,o]of Object.entries(s))1!==o&&e.push(` ${n} -- ${o} --\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,o.stripAnsi)(e.trim()).replace(/[#"<>]/g,e=>({"#":"ꖛ",'"':"”","<":"ᐸ",">":"ᐳ"}[e])).replace(/\r?\n/g,"<br />")}"`,s.__exportStar(n(43548),t)},43548:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},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},78983:(e,t,n)=>{n.r(t),n.d(t,{default:()=>p});var s=n(31085),o=n(8982),i=n(67367),c=n(14041);let r=!1;const p=({plan:e})=>{const t=(0,c.useMemo)(()=>(0,o.planToMermaid)(e),[e]);return(0,c.useEffect)(()=>{r||(r=!0,i.default.initialize({startOnLoad:!0,maxTextSize:1e6,maxEdges:1e3})),t&&i.default.contentLoaded()},[t]),(0,s.jsx)("div",{className:"mermaid",children:t},t)}}}; //# sourceMappingURL=8983.js.map