diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..8171a63 --- /dev/null +++ b/NOTICE @@ -0,0 +1,14 @@ +This project includes code from the SolidJs project (MIT) +https://github.com/solidjs/solid + +This project includes code from the Solid Ninja Keys project (MIT) +https://github.com/wobsoriano/solid-ninja-keys + +This project includes code from the Hotkeys.js project (MIT) +https://github.com/jaywcjlove/hotkeys-js + +This project includes code from the SD Prompt Parser project (MIT) +https://github.com/vczh/sd-prompt-parser + +This project includes code from the UE Nodes project (Apache 2.0) +https://github.com/chrisgoringe/cg-use-everywhere diff --git a/README.md b/README.md new file mode 100644 index 0000000..f8c5bfb --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# mape's ComfyUI Helpers + +Multi monitor image preview, Variable Assigment/Wireless Nodes, Prompt Tweaking, Command Palette, Pinned favourite nodes, Node navigation, Fuzzy search, Node time tracking, Organizing and Error management. + +For more info visit: https://comfyui.ma.pe/ + +![mape's ComfyUI helpers](https://comfyui.ma.pe/github.jpg) diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..ec3e244 --- /dev/null +++ b/__init__.py @@ -0,0 +1,33 @@ +""" +@author: mape +@title: mape's helpers +@nickname: 🟡 mape's helpers +@version: 0.1 +@description: Various QoL improvements like prompt tweaking, variable assignment, image preview, fuzzy search, error reporting, organizing and node navigation. +""" + +class MapeVariable(): + OUTPUT_NODE = True + FUNCTION = "func" + CATEGORY = "mape" + RETURN_TYPES = () + + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "name": ("STRING", {"name": ""}), + }, + "optional": { + "*": ("*", {}), + }, + "hidden": {"id": "UNIQUE_ID"}, + } + + RETURN_TYPES = ("*",) + +NODE_CLASS_MAPPINGS = { "mape Variable": MapeVariable } + +WEB_DIRECTORY = "./js" + +__all__ = ["NODE_CLASS_MAPPINGS", "WEB_DIRECTORY"] diff --git a/js/tweak/mape-helpers.js b/js/tweak/mape-helpers.js new file mode 100644 index 0000000..e4ae25d --- /dev/null +++ b/js/tweak/mape-helpers.js @@ -0,0 +1,39 @@ +const Ro="modulepreload",zo=function(t){return"/extensions/ComfyUI-Mape-Helpers/tweak/"+t},ii={},kt=function(e,n,i){let o=Promise.resolve();if(n&&n.length>0){const s=document.getElementsByTagName("link");o=Promise.all(n.map(r=>{if(r=zo(r),r in ii)return;ii[r]=!0;const l=r.endsWith(".css"),a=l?'[rel="stylesheet"]':"";if(!!i)for(let g=s.length-1;g>=0;g--){const p=s[g];if(p.href===r&&(!l||p.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${r}"]${a}`))return;const c=document.createElement("link");if(c.rel=l?"stylesheet":Ro,l||(c.as="script",c.crossOrigin=""),c.href=r,document.head.appendChild(c),l)return new Promise((g,p)=>{c.addEventListener("load",g),c.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${r}`)))})}))}return o.then(()=>e()).catch(s=>{const r=new Event("vite:preloadError",{cancelable:!0});if(r.payload=s,window.dispatchEvent(r),!r.defaultPrevented)throw s})},Do=(t,e)=>t===e,Ye=Symbol("solid-proxy"),In=Symbol("solid-track"),Yt={equals:Do};let Mi=Di;const Ue=1,Xt=2,Hi={owned:null,cleanups:null,context:null,owner:null};var ne=null;let mn=null,Bo=null,ce=null,ve=null,Ie=null,ln=0;function Bt(t,e){const n=ce,i=ne,o=t.length===0,s=e===void 0?i:e,r=o?Hi:{owned:null,cleanups:null,context:s?s.context:null,owner:s},l=o?t:()=>t(()=>Le(()=>an(r)));ne=r,ce=null;try{return ft(l,!0)}finally{ce=n,ne=i}}function Z(t,e){e=e?Object.assign({},Yt,e):Yt;const n={value:t,observers:null,observerSlots:null,comparator:e.equals||void 0},i=o=>(typeof o=="function"&&(o=o(n.value)),zi(n,o));return[Ri.bind(n),i]}function X(t,e,n){const i=Xn(t,e,!1,Ue);Ot(i)}function Se(t,e,n){Mi=Yo;const i=Xn(t,e,!1,Ue),o=oi&&Ko(oi);o&&(i.suspense=o),(!n||!n.render)&&(i.user=!0),Ie?Ie.push(i):Ot(i)}function oe(t,e,n){n=n?Object.assign({},Yt,n):Yt;const i=Xn(t,e,!0,0);return i.observers=null,i.observerSlots=null,i.comparator=n.equals||void 0,Ot(i),Ri.bind(i)}function Uo(t){return ft(t,!1)}function Le(t){if(ce===null)return t();const e=ce;ce=null;try{return t()}finally{ce=e}}function st(t){Se(()=>Le(t))}function xt(t){return ne===null||(ne.cleanups===null?ne.cleanups=[t]:ne.cleanups.push(t)),t}function Tn(){return ce}function Fo(){return ne}function Ko(t){return ne&&ne.context&&ne.context[t.id]!==void 0?ne.context[t.id]:t.defaultValue}function Vo(t){const e=oe(t),n=oe(()=>Nn(e()));return n.toArray=()=>{const i=n();return Array.isArray(i)?i:i!=null?[i]:[]},n}let oi;function Ri(){if(this.sources&&this.state)if(this.state===Ue)Ot(this);else{const t=ve;ve=null,ft(()=>qt(this),!1),ve=t}if(ce){const t=this.observers?this.observers.length:0;ce.sources?(ce.sources.push(this),ce.sourceSlots.push(t)):(ce.sources=[this],ce.sourceSlots=[t]),this.observers?(this.observers.push(ce),this.observerSlots.push(ce.sources.length-1)):(this.observers=[ce],this.observerSlots=[ce.sources.length-1])}return this.value}function zi(t,e,n){let i=t.value;return(!t.comparator||!t.comparator(i,e))&&(t.value=e,t.observers&&t.observers.length&&ft(()=>{for(let o=0;o1e6)throw ve=[],new Error},!1)),e}function Ot(t){if(!t.fn)return;an(t);const e=ln;Wo(t,t.value,e)}function Wo(t,e,n){let i;const o=ne,s=ce;ce=ne=t;try{i=t.fn(e)}catch(r){return t.pure&&(t.state=Ue,t.owned&&t.owned.forEach(an),t.owned=null),t.updatedAt=n+1,Ui(r)}finally{ce=s,ne=o}(!t.updatedAt||t.updatedAt<=n)&&(t.updatedAt!=null&&"observers"in t?zi(t,i):t.value=i,t.updatedAt=n)}function Xn(t,e,n,i=Ue,o){const s={fn:t,state:i,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:e,owner:ne,context:ne?ne.context:null,pure:n};return ne===null||ne!==Hi&&(ne.owned?ne.owned.push(s):ne.owned=[s]),s}function Jt(t){if(t.state===0)return;if(t.state===Xt)return qt(t);if(t.suspense&&Le(t.suspense.inFallback))return t.suspense.effects.push(t);const e=[t];for(;(t=t.owner)&&(!t.updatedAt||t.updatedAt=0;n--)if(t=e[n],t.state===Ue)Ot(t);else if(t.state===Xt){const i=ve;ve=null,ft(()=>qt(t,e[0]),!1),ve=i}}function ft(t,e){if(ve)return t();let n=!1;e||(ve=[]),Ie?n=!0:Ie=[],ln++;try{const i=t();return Go(n),i}catch(i){n||(Ie=null),ve=null,Ui(i)}}function Go(t){if(ve&&(Di(ve),ve=null),t)return;const e=Ie;Ie=null,e.length&&ft(()=>Mi(e),!1)}function Di(t){for(let e=0;e=0;e--)an(t.owned[e]);t.owned=null}if(t.cleanups){for(e=t.cleanups.length-1;e>=0;e--)t.cleanups[e]();t.cleanups=null}t.state=0}function Xo(t){return t instanceof Error?t:new Error(typeof t=="string"?t:"Unknown error",{cause:t})}function Ui(t,e=ne){throw Xo(t)}function Nn(t){if(typeof t=="function"&&!t.length)return Nn(t());if(Array.isArray(t)){const e=[];for(let n=0;n1?[]:null;return xt(()=>si(s)),()=>{let a=t()||[],u,c;return a[In],Le(()=>{let p=a.length,d,f,h,y,_,A,b,x,j;if(p===0)r!==0&&(si(s),s=[],i=[],o=[],r=0,l&&(l=[])),n.fallback&&(i=[Jo],o[0]=Bt(I=>(s[0]=I,n.fallback())),r=1);else if(r===0){for(o=new Array(p),c=0;c=A&&x>=A&&i[b]===a[x];b--,x--)h[x]=o[b],y[x]=s[b],l&&(_[x]=l[b]);for(d=new Map,f=new Array(x+1),c=x;c>=A;c--)j=a[c],u=d.get(j),f[c]=u===void 0?-1:u,d.set(j,c);for(u=A;u<=b;u++)j=i[u],c=d.get(j),c!==void 0&&c!==-1?(h[c]=o[u],y[c]=s[u],l&&(_[c]=l[u]),c=f[c],d.set(j,c)):s[u]();for(c=A;ct(e||{}))}const Qo=t=>`Stale read from <${t}>.`;function Fi(t){const e="fallback"in t&&{fallback:()=>t.fallback};return oe(qo(()=>t.each,t.children,e||void 0))}function Ki(t){let e=!1;const n=(s,r)=>(e?s[1]===r[1]:!s[1]==!r[1])&&s[2]===r[2],i=Vo(()=>t.children),o=oe(()=>{let s=i();Array.isArray(s)||(s=[s]);for(let r=0;r{const[s,r,l]=o();if(s<0)return t.fallback;const a=l.children;return typeof a=="function"&&a.length>0?Le(()=>a(e?r:()=>{if(Le(o)[0]!==s)throw Qo("Match");return l.when})):a},void 0,void 0)}function We(t){return t}function es(t,e,n){let i=n.length,o=e.length,s=i,r=0,l=0,a=e[o-1].nextSibling,u=null;for(;rc-l){const f=e[r];for(;l{o=s,e===document?t():K(e,t(),e.firstChild?null:void 0,n)},i.owner),()=>{o(),e.textContent=""}}function Y(t,e,n){let i;const o=()=>{const r=document.createElement("template");return r.innerHTML=t,n?r.content.firstChild.firstChild:r.content.firstChild},s=e?()=>Le(()=>document.importNode(i||(i=o()),!0)):()=>(i||(i=o())).cloneNode(!0);return s.cloneNode=s,s}function Ze(t,e=window.document){const n=e[ri]||(e[ri]=new Set);for(let i=0,o=t.length;io.call(t,n[1],s))}else t.addEventListener(e,n)}function _t(t,e,n){return Le(()=>t(e,n))}function K(t,e,n,i){if(n!==void 0&&!i&&(i=[]),typeof e!="function")return Zt(t,e,i,n);X(o=>Zt(t,e(),o,n),i)}function ns(t){const e=`$$${t.type}`;let n=t.composedPath&&t.composedPath()[0]||t.target;for(t.target!==n&&Object.defineProperty(t,"target",{configurable:!0,value:n}),Object.defineProperty(t,"currentTarget",{configurable:!0,get(){return n||document}});n;){const i=n[e];if(i&&!n.disabled){const o=n[`${e}Data`];if(o!==void 0?i.call(n,o,t):i.call(n,t),t.cancelBubble)return}n=n._$host||n.parentNode||n.host}}function Zt(t,e,n,i,o){for(;typeof n=="function";)n=n();if(e===n)return n;const s=typeof e,r=i!==void 0;if(t=r&&n[0]&&n[0].parentNode||t,s==="string"||s==="number")if(s==="number"&&(e=e.toString()),r){let l=n[0];l&&l.nodeType===3?l.data!==e&&(l.data=e):l=document.createTextNode(e),n=et(t,n,i,l)}else n!==""&&typeof n=="string"?n=t.firstChild.data=e:n=t.textContent=e;else if(e==null||s==="boolean")n=et(t,n,i);else{if(s==="function")return X(()=>{let l=e();for(;typeof l=="function";)l=l();n=Zt(t,l,n,i)}),()=>n;if(Array.isArray(e)){const l=[],a=n&&Array.isArray(n);if(Ln(l,e,n,o))return X(()=>n=Zt(t,l,n,i,!0)),()=>n;if(l.length===0){if(n=et(t,n,i),r)return n}else a?n.length===0?li(t,l,i):es(t,n,l):(n&&et(t),li(t,l));n=l}else if(e.nodeType){if(Array.isArray(n)){if(r)return n=et(t,n,i,e);et(t,n,null,e)}else n==null||n===""||!t.firstChild?t.appendChild(e):t.replaceChild(e,t.firstChild);n=e}}return n}function Ln(t,e,n,i){let o=!1;for(let s=0,r=e.length;s=0;r--){const l=e[r];if(o!==l){const a=l.parentNode===t;!s&&!r?a?t.replaceChild(o,l):t.insertBefore(o,n):a&&l.remove()}else s=!0}}else t.insertBefore(o,n);return[o]}const is=async()=>{const{ImagePreviews:t}=await kt(()=>Promise.resolve().then(()=>Ks),void 0),e=document.createElement("div");document.body.appendChild(e),Vi(()=>fe(t,{}),e)},os=async()=>{const{registerPlugin:t}=await kt(()=>Promise.resolve().then(()=>dr),void 0);t(),async function e(){if(typeof app>"u"){setTimeout(e);return}const{MapeTweak:n}=await kt(()=>Promise.resolve().then(()=>El),void 0),i=document.createElement("div");document.body.appendChild(i),Vi(()=>fe(n,{}),i)}()};window.standaloneImagePreview?is():os();const ai=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ci="eexxaacctt",ui=(t,e)=>e==0?"":e==1?`${t}??`:e==1/0?`${t}*?`:`${t}{0,${e}}?`;function ss(){const t={interSplit:"[^A-Za-z\\d']+",intraSplit:"[a-z][A-Z]",intraBound:"[A-Za-z]\\d|\\d[A-Za-z]|[a-z][A-Z]",interChars:".",interIns:1/0,intraChars:"[a-z\\d']",intraIns:0,intraContr:"'[a-z]{1,2}\\b"},{intraIns:e,intraContr:n,intraSplit:i,interSplit:o,intraBound:s,intraChars:r}=t,l='".+?"',a=new RegExp(l,"gi"),u=new RegExp(`(?:\\s+|^)-(?:${r}+|${l})`,"gi"),c=!!i,g=new RegExp(i,"g"),p=new RegExp(o,"g"),d=new RegExp(`^${o}|${o}$`,"g"),f=new RegExp(n,"gi"),h=b=>{const x=[];b=b.replace(a,I=>(x.push(I),ci)),b=b.replace(d,"").toLocaleLowerCase(),c&&(b=b.replace(g,I=>`${I[0]} ${I[1]}`));let j=0;return b.split(p).filter(I=>I!="").map(I=>I===ci?x[j++]:I)},y=b=>{let x=h(b);if(x.length==0)return[void 0];const j=Array(x.length).fill("");x=x.map((F,S)=>F.replace(f,$=>(j[S]=$,"")));const I=ui(r,e);let B=x.map((F,S)=>F[0]==='"'?ai(F.slice(1,-1)):F.split("").join(I)+j[S]);const M=ui(t.interChars,t.interIns);return B=B.join(M),[new RegExp(B,"i")]},_=(b,x,j)=>{const[I]=y(x);if(!I)return[];const B=[];if(j!=null)for(let M=0;M{let j,B=null,M=[];x=x.replace(u,S=>{let $=S.trim().slice(1);return $[0]==='"'&&($=ai($.slice(1,-1))),""});const F=h(x);if(F.length==0)return[];if(F.length>1){const S=F.slice().sort((N,H)=>H.length-N.length);for(let N=0;N2)return j;B=rs(F).map(N=>N.join(" ")),M.length=0;const $=new Set;for(let N=0;N!$.has(R)),E=_(b,B[N],H);for(let R=0;R0?j:_(b,x)]),M.flat()}}function rs(t){t=t.slice();const e=t.length,n=[t.slice()],i=new Array(e).fill(0);let o=1,s,r;for(;ot[Ye][e]),n}function Yi(t){Tn()&&St(Qt(t,rt),Wi)()}function as(t){return Yi(t),Reflect.ownKeys(t)}const cs={get(t,e,n){if(e===Mn)return t;if(e===Ye)return n;if(e===In)return Yi(t),n;const i=Qt(t,rt),o=i[e];let s=o?o():t[e];if(e===rt||e===Pe||e==="__proto__")return s;if(!o){const r=Object.getOwnPropertyDescriptor(t,e);Tn()&&(typeof s!="function"||t.hasOwnProperty(e))&&!(r&&r.get)&&(s=St(i,e,s)())}return Be(s)?Gi(s):s},has(t,e){return e===Mn||e===Ye||e===In||e===rt||e===Pe||e==="__proto__"?!0:(Tn()&&St(Qt(t,Pe),e)(),e in t)},set(){return!0},deleteProperty(){return!0},ownKeys:as,getOwnPropertyDescriptor:ls};function ke(t,e,n,i=!1){if(!i&&t[e]===n)return;const o=t[e],s=t.length;n===void 0?(delete t[e],t[Pe]&&t[Pe][e]&&o!==void 0&&t[Pe][e].$()):(t[e]=n,t[Pe]&&t[Pe][e]&&o===void 0&&t[Pe][e].$());let r=Qt(t,rt),l;if((l=St(r,e,o))&&l.$(()=>n),Array.isArray(t)&&t.length!==s){for(let a=t.length;a1){i=e.shift();const r=typeof i,l=Array.isArray(t);if(Array.isArray(i)){for(let a=0;a1){yt(t[i],e,[i].concat(n));return}o=t[i],n=[i].concat(n)}let s=e[0];typeof s=="function"&&(s=s(o,n),s===o)||i===void 0&&s==null||(s=ct(s),i===void 0||Be(o)&&Be(s)&&!Array.isArray(s)?Xi(o,s):ke(t,i,s))}function en(...[t,e]){const n=ct(t||{}),i=Array.isArray(n),o=Gi(n);function s(...r){Uo(()=>{i&&r.length===1?us(n,r[0]):yt(n,r)})}return[o,s]}const Hn=Symbol("store-root");function tt(t,e,n,i,o){const s=e[n];if(t===s)return;const r=Array.isArray(t);if(n!==Hn&&(!Be(t)||!Be(s)||r!==Array.isArray(s)||o&&t[o]!==s[o])){ke(e,n,t);return}if(r){if(t.length&&s.length&&(!i||o&&t[0]&&t[0][o]!=null)){let u,c,g,p,d,f,h,y;for(g=0,p=Math.min(s.length,t.length);g=g&&d>=g&&(s[p]===t[d]||o&&s[g]&&t[g]&&s[p][o]===t[d][o]);p--,d--)_[d]=s[p];if(g>d||g>p){for(c=g;c<=d;c++)ke(s,c,t[c]);for(;ct.length&&ke(s,"length",t.length);return}for(h=new Array(d+1),c=d;c>=g;c--)f=t[c],y=o&&f?f[o]:f,u=A.get(y),h[c]=u===void 0?-1:u,A.set(y,c);for(u=g;u<=p;u++)f=s[u],y=o&&f?f[o]:f,c=A.get(y),c!==void 0&&c!==-1&&(_[c]=s[u],c=h[c],A.set(y,c));for(c=g;ct.length&&ke(s,"length",t.length);return}const l=Object.keys(t);for(let u=0,c=l.length;u{if(!Be(s)||!Be(o))return o;const r=tt(o,{[Hn]:s},Hn,n,i);return r===void 0?s:r}}var ds=Y("
Settings
"),fs=Y(""),hs=Y(""),ps=Y(""),gs=Y(""),ms=Y('
♻️