From ce5f96fbda20540e600a9cc309e231f3609bbad1 Mon Sep 17 00:00:00 2001 From: mape Date: Mon, 24 Jun 2024 16:43:26 +0200 Subject: [PATCH] Add Comfy Registry related files, toggle bar, inline variable sorting/filtering, quick rename, disable minify and missing reference in notice * Add Comfy Registry related files * Remove unnecessary minification * Added ability to toggle top bar * Added sorting based on types to inline variable prompt * Added filtering based on types to inline variable prompt * Added ability to Shift Double Click to rename variable * Added missing reference to uFuzzy in NOTICE file --- .github/workflows/publish.yml | 20 + NOTICE | 3 + js/tweak/mape-helpers.js | 8248 ++++++++++++++++++++++++++++++++- pyproject.toml | 13 + 4 files changed, 8275 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/publish.yml create mode 100644 pyproject.toml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..be0b02f --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,20 @@ +name: Publish to Comfy registry +on: + workflow_dispatch: + push: + branches: + - main + paths: + - "pyproject.toml" + +jobs: + publish-node: + name: Publish Custom Node to registry + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Publish Custom Node + uses: Comfy-Org/publish-node-action@main + with: + personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }} diff --git a/NOTICE b/NOTICE index 8171a63..8703195 100644 --- a/NOTICE +++ b/NOTICE @@ -12,3 +12,6 @@ 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 + +This project includes code from the uFuzzy project (MIT) +https://github.com/leeoniya/uFuzzy diff --git a/js/tweak/mape-helpers.js b/js/tweak/mape-helpers.js index ae64394..0ae24ea 100644 --- a/js/tweak/mape-helpers.js +++ b/js/tweak/mape-helpers.js @@ -1,6 +1,7868 @@ -const ds="modulepreload",fs=function(e){return"/extensions/ComfyUI-Mape-Helpers/tweak/"+e},Ro={},Et=function(t,n,o){let i=Promise.resolve();if(n&&n.length>0){const s=document.getElementsByTagName("link");i=Promise.all(n.map(r=>{if(r=fs(r),r in Ro)return;Ro[r]=!0;const l=r.endsWith(".css"),a=l?'[rel="stylesheet"]':"";if(!!o)for(let p=s.length-1;p>=0;p--){const h=s[p];if(h.href===r&&(!l||h.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${r}"]${a}`))return;const c=document.createElement("link");if(c.rel=l?"stylesheet":ds,l||(c.as="script",c.crossOrigin=""),c.href=r,document.head.appendChild(c),l)return new Promise((p,h)=>{c.addEventListener("load",p),c.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${r}`)))})}))}return i.then(()=>t()).catch(s=>{const r=new Event("vite:preloadError",{cancelable:!0});if(r.payload=s,window.dispatchEvent(r),!r.defaultPrevented)throw s})},ps=(e,t)=>e===t,ht=Symbol("solid-proxy"),lo=Symbol("solid-track"),$n={equals:ps};let gi=$i;const st=1,wn=2,vi={owned:null,cleanups:null,context:null,owner:null};var me=null;let Bn=null,hs=null,$e=null,je=null,Ve=null,Tn=0;function dn(e,t){const n=$e,o=me,i=e.length===0,s=t===void 0?o:t,r=i?vi:{owned:null,cleanups:null,context:s?s.context:null,owner:s},l=i?e:()=>e(()=>Xe(()=>Ln(r)));me=r,$e=null;try{return Tt(l,!0)}finally{$e=n,me=o}}function ne(e,t){t=t?Object.assign({},$n,t):$n;const n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},o=i=>(typeof i=="function"&&(i=i(n.value)),_i(n,i));return[yi.bind(n),o]}function F(e,t,n){const o=Ao(e,t,!1,st);tn(o)}function Le(e,t,n){gi=ws;const o=Ao(e,t,!1,st),i=Ho&&vs(Ho);i&&(o.suspense=i),(!n||!n.render)&&(o.user=!0),Ve?Ve.push(o):tn(o)}function le(e,t,n){n=n?Object.assign({},$n,n):$n;const o=Ao(e,t,!0,0);return o.observers=null,o.observerSlots=null,o.comparator=n.equals||void 0,tn(o),yi.bind(o)}function ms(e){return Tt(e,!1)}function Xe(e){if($e===null)return e();const t=$e;$e=null;try{return e()}finally{$e=t}}function Qe(e){Le(()=>Xe(e))}function Vt(e){return me===null||(me.cleanups===null?me.cleanups=[e]:me.cleanups.push(e)),e}function ao(){return $e}function gs(){return me}function vs(e){return me&&me.context&&me.context[e.id]!==void 0?me.context[e.id]:e.defaultValue}function ys(e){const t=le(e),n=le(()=>co(t()));return n.toArray=()=>{const o=n();return Array.isArray(o)?o:o!=null?[o]:[]},n}let Ho;function yi(){if(this.sources&&this.state)if(this.state===st)tn(this);else{const e=je;je=null,Tt(()=>kn(this),!1),je=e}if($e){const e=this.observers?this.observers.length:0;$e.sources?($e.sources.push(this),$e.sourceSlots.push(e)):($e.sources=[this],$e.sourceSlots=[e]),this.observers?(this.observers.push($e),this.observerSlots.push($e.sources.length-1)):(this.observers=[$e],this.observerSlots=[$e.sources.length-1])}return this.value}function _i(e,t,n){let o=e.value;return(!e.comparator||!e.comparator(o,t))&&(e.value=t,e.observers&&e.observers.length&&Tt(()=>{for(let i=0;i1e6)throw je=[],new Error},!1)),t}function tn(e){if(!e.fn)return;Ln(e);const t=Tn;_s(e,e.value,t)}function _s(e,t,n){let o;const i=me,s=$e;$e=me=e;try{o=e.fn(t)}catch(r){return e.pure&&(e.state=st,e.owned&&e.owned.forEach(Ln),e.owned=null),e.updatedAt=n+1,bi(r)}finally{$e=s,me=i}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&"observers"in e?_i(e,o):e.value=o,e.updatedAt=n)}function Ao(e,t,n,o=st,i){const s={fn:e,state:o,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:me,context:me?me.context:null,pure:n};return me===null||me!==vi&&(me.owned?me.owned.push(s):me.owned=[s]),s}function bn(e){if(e.state===0)return;if(e.state===wn)return kn(e);if(e.suspense&&Xe(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt=0;n--)if(e=t[n],e.state===st)tn(e);else if(e.state===wn){const o=je;je=null,Tt(()=>kn(e,t[0]),!1),je=o}}function Tt(e,t){if(je)return e();let n=!1;t||(je=[]),Ve?n=!0:Ve=[],Tn++;try{const o=e();return $s(n),o}catch(o){n||(Ve=null),je=null,bi(o)}}function $s(e){if(je&&($i(je),je=null),e)return;const t=Ve;Ve=null,t.length&&Tt(()=>gi(t),!1)}function $i(e){for(let t=0;t=0;t--)Ln(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function bs(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function bi(e,t=me){throw bs(e)}function co(e){if(typeof e=="function"&&!e.length)return co(e());if(Array.isArray(e)){const t=[];for(let n=0;n1?[]:null;return Vt(()=>zo(s)),()=>{let a=e()||[],u,c;return a[lo],Xe(()=>{let h=a.length,d,f,m,w,$,b,_,k,x;if(h===0)r!==0&&(zo(s),s=[],o=[],i=[],r=0,l&&(l=[])),n.fallback&&(o=[ks],i[0]=dn(j=>(s[0]=j,n.fallback())),r=1);else if(r===0){for(i=new Array(h),c=0;c=b&&k>=b&&o[_]===a[k];_--,k--)m[k]=i[_],w[k]=s[_],l&&($[k]=l[_]);for(d=new Map,f=new Array(k+1),c=k;c>=b;c--)x=a[c],u=d.get(x),f[c]=u===void 0?-1:u,d.set(x,c);for(u=b;u<=_;u++)x=o[u],c=d.get(x),c!==void 0&&c!==-1?(m[c]=i[u],w[c]=s[u],l&&($[c]=l[u]),c=f[c],d.set(x,c)):s[u]();for(c=b;ce(t||{}))}const As=e=>`Stale read from <${e}>.`;function ki(e){const t="fallback"in e&&{fallback:()=>e.fallback};return le(xs(()=>e.each,e.children,t||void 0))}function xi(e){let t=!1;const n=(s,r)=>(t?s[1]===r[1]:!s[1]==!r[1])&&s[2]===r[2],o=ys(()=>e.children),i=le(()=>{let s=o();Array.isArray(s)||(s=[s]);for(let r=0;r{const[s,r,l]=i();if(s<0)return e.fallback;const a=l.children;return typeof a=="function"&&a.length>0?Xe(()=>a(t?r:()=>{if(Xe(i)[0]!==s)throw As("Match");return l.when})):a},void 0,void 0)}function dt(e){return e}function Es(e,t,n){let o=n.length,i=t.length,s=o,r=0,l=0,a=t[i-1].nextSibling,u=null;for(;rc-l){const f=t[r];for(;l{i=s,t===document?e():L(t,e(),t.firstChild?null:void 0,n)},o.owner),()=>{i(),t.textContent=""}}function S(e,t,n){let o;const i=()=>{const r=document.createElement("template");return r.innerHTML=e,n?r.content.firstChild.firstChild:r.content.firstChild},s=t?()=>Xe(()=>document.importNode(o||(o=i()),!0)):()=>(o||(o=i())).cloneNode(!0);return s.cloneNode=s,s}function yt(e,t=window.document){const n=t[Do]||(t[Do]=new Set);for(let o=0,i=e.length;oi.call(e,n[1],s))}else e.addEventListener(t,n)}function Fo(e,t,n){if(!t)return n?he(e,"style"):t;const o=e.style;if(typeof t=="string")return o.cssText=t;typeof n=="string"&&(o.cssText=n=void 0),n||(n={}),t||(t={});let i,s;for(s in n)t[s]==null&&o.removeProperty(s),delete n[s];for(s in t)i=t[s],i!==n[s]&&(o.setProperty(s,i),n[s]=i);return n}function Ct(e,t,n){return Xe(()=>e(t,n))}function L(e,t,n,o){if(n!==void 0&&!o&&(o=[]),typeof t!="function")return xn(e,t,o,n);F(i=>xn(e,t(),i,n),o)}function Os(e){const t=`$$${e.type}`;let n=e.composedPath&&e.composedPath()[0]||e.target;for(e.target!==n&&Object.defineProperty(e,"target",{configurable:!0,value:n}),Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return n||document}});n;){const o=n[t];if(o&&!n.disabled){const i=n[`${t}Data`];if(i!==void 0?o.call(n,i,e):o.call(n,e),e.cancelBubble)return}n=n._$host||n.parentNode||n.host}}function xn(e,t,n,o,i){for(;typeof n=="function";)n=n();if(t===n)return n;const s=typeof t,r=o!==void 0;if(e=r&&n[0]&&n[0].parentNode||e,s==="string"||s==="number")if(s==="number"&&(t=t.toString()),r){let l=n[0];l&&l.nodeType===3?l.data!==t&&(l.data=t):l=document.createTextNode(t),n=$t(e,n,o,l)}else n!==""&&typeof n=="string"?n=e.firstChild.data=t:n=e.textContent=t;else if(t==null||s==="boolean")n=$t(e,n,o);else{if(s==="function")return F(()=>{let l=t();for(;typeof l=="function";)l=l();n=xn(e,l,n,o)}),()=>n;if(Array.isArray(t)){const l=[],a=n&&Array.isArray(n);if(uo(l,t,n,i))return F(()=>n=xn(e,l,n,o,!0)),()=>n;if(l.length===0){if(n=$t(e,n,o),r)return n}else a?n.length===0?Bo(e,l,o):Es(e,n,l):(n&&$t(e),Bo(e,l));n=l}else if(t.nodeType){if(Array.isArray(n)){if(r)return n=$t(e,n,o,t);$t(e,n,null,t)}else n==null||n===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}}return n}function uo(e,t,n,o){let i=!1;for(let s=0,r=t.length;s=0;r--){const l=t[r];if(i!==l){const a=l.parentNode===e;!s&&!r?a?e.replaceChild(i,l):e.insertBefore(i,n):a&&l.remove()}else s=!0}}else e.insertBefore(i,n);return[i]}const Ps=async()=>{const{ImagePreviews:e}=await Et(()=>Promise.resolve().then(()=>Vs),void 0),t=document.createElement("div");document.body.appendChild(t),Si(()=>Ae(e,{}),t)},js=async()=>{const{registerPlugin:e}=await Et(()=>Promise.resolve().then(()=>Lr),void 0);e(),async function t(){if(typeof app>"u"){setTimeout(t);return}const{MapeTweak:n}=await Et(()=>Promise.resolve().then(()=>Wa),void 0),o=document.createElement("div");document.body.appendChild(o),Si(()=>Ae(n,{}),o)}()};window.standaloneImagePreview?Ps():js();function se(e){let t=e.type;return e.IS_MAPE_VARIABLE?!0:(t===void 0&&(t=e.comfyClass),t?t.startsWith(Ye):!1)}const pt=e=>{var t,n,o;return!!(se(e)&&((o=(n=(t=e.outputs)==null?void 0:t[0])==null?void 0:n.links)!=null&&o.length))},Ie=e=>{var t,n;return!!(se(e)&&((n=(t=e.inputs)==null?void 0:t[0])!=null&&n.link))},cn="mape_tweak_",Is="mape_imagepreview_",tt="mape_tweak_pos_",Un="mape_group",Ye="mape Variable",Ns="*",He=()=>graph._nodes,ae=(e,t)=>t?t.find(n=>n.id===e):graph.getNodeById(e),nn=(e=He())=>e.filter(se),Ai=(e=He())=>nn(e).filter(Ie),fn=()=>graph._groups,Ts=()=>{var e;return(e=Ze())==null?void 0:e[0]},Ze=()=>Object.values(graph.list_of_graphcanvas[0].selected_nodes),et=e=>e?`/view?filename=${e.filename}&subfolder=${e.subfolder}&type=${e.type}&rand=42`:void 0,Sn=(e,t,n,o)=>{const i=n-e,s=o-t;return Math.sqrt(i**2+s**2)},Ei=e=>{const t=Object.fromEntries(Object.values(e).map(s=>[s.name,s.pos??[0,0]])),n=Math.min(...Object.values(t).map(([s,r])=>s)),o=Math.min(...Object.values(t).map(([s,r])=>r)),i=Object.fromEntries(Object.entries(t).map(([s,[r,l]])=>[s,Sn(n,o,r,l)]));return(s,r)=>i[s.name]-i[r.name]},Ls=(e,t,n)=>{const o=Object.fromEntries(e.map(l=>[l[t],l[n]??[0,0]])),i=Math.min(...Object.values(o).map(([l,a])=>l)),s=Math.min(...Object.values(o).map(([l,a])=>a)),r=Object.fromEntries(Object.entries(o).map(([l,[a,u]])=>[l,Sn(i,s,a,u)]));return(l,a)=>r[l[t]]-r[a[t]]},Ms=(e,t,n=.35)=>{let o=1,i=1,s=1,r=1,l=1,a=1,u=1;const c=e[0],p=e[1],h=p/c;for(let d=1;d<=t;d++){const f=d,m=Math.ceil(t/f);m/f*n>h?(u=Math.floor(p/m),a=Math.floor(u/n)):(a=Math.floor(c/f),u=Math.floor(a*n));const w=a*u*t;(o===void 0||w>o)&&(o=w,r=u,l=a,i=f,s=m)}return{targetCols:i,targetRows:s,targetHeight:r,targetWidth:l}};var Rs=S("
"),Hs=S("