fix some isdirty problem, like when clicking chakra menus and it will set canvas as dirty :(

This commit is contained in:
Weixuan Fu
2024-03-19 23:15:57 +08:00
parent 00fd6b6ef3
commit bfbced5395
15 changed files with 36 additions and 31 deletions
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
import{r as l,j as y}from"./input.js";import{app as o}from"/scripts/app.js";import{a6 as S,j as C,ar as E,as as A,E as g,o as W,A as c,at as j,B as x}from"./App-bqAziDgv.js";import"/scripts/api.js";function v(d,f){const i=l.useRef(0),u=l.useCallback(()=>{i.current!==null&&(clearTimeout(i.current),i.current=0)},[]),p=l.useCallback((...k)=>{u(),i.current=setTimeout(()=>d(...k),f)},[d,f,u]);return l.useEffect(()=>()=>{u()},[]),[p,u]}function F(){const{isDirty:d,setIsDirty:f,setRoute:i,saveCurWorkflow:u}=l.useContext(S),p=C();l.useEffect(()=>{const a=async e=>{switch(e){case g.SAVE:u();break;case g.SAVE_AS:i("saveAsModal");break}},s=o.canvas.onAfterChange;o.graph.onAfterChange=function(){s==null||s.apply(this,arguments),h()};const n=o.graph.onConfigure;o.graph.onConfigure=function(){n==null||n.apply(this,arguments),setTimeout(()=>{var t,r;E(o.graph.serialize(),JSON.parse(((r=(t=c)==null?void 0:t.curWorkflow)==null?void 0:r.json)??"{}"))||h()},1e3)},document.addEventListener("click",e=>{Object.keys(o.canvas.selected_nodes??{}).length&&(o.canvas.node_over!=null||o.canvas.node_capturing_input!=null||o.canvas.node_widget!=null)&&h()}),document.addEventListener("keydown",async function(e){var r;if(document.visibilityState==="hidden")return;const t=await A(e);t?a(t):(r=e.target)!=null&&r.matches("input, textarea")&&Object.keys(o.canvas.selected_nodes??{}).length&&h()})},[]);const k=async()=>{var s,n,e,t;if(!((n=(s=c)==null?void 0:s.curWorkflow)!=null&&n.id))return;const a=JSON.stringify(o.graph.serialize());a!=null&&await((e=c)==null?void 0:e.updateFlow(c.curWorkflow.id,{json:a})),(t=j)==null||t.create({workflowID:c.curWorkflow.id,isAutoSave:!0,json:a}),f(!1),p({position:"bottom-left",duration:1e3,render:()=>y.jsx(x,{color:"white",p:3,children:"Auto saved"})})},[b,D]=v(k,1e3),m=async()=>{var s,n,e,t,r,w;if((n=(s=c)==null?void 0:s.curWorkflow)!=null&&n.saveLock)return;const a=await((e=W)==null?void 0:e.getSetting("autoSave"));if(!a){!d&&f(!0);return}(r=(t=c)==null?void 0:t.curWorkflow)!=null&&r.id&&a&&(await((w=c)==null?void 0:w.latestVersionCheck())?b():p({title:"Your changes cannot be saved!",description:"You are working on an outdated version. This workflow is changed by another tab. Please refresh to get the latest version.",status:"warning",isClosable:!0,duration:null}))},[h,_]=v(m,500);return null}export{F as default};
@@ -1 +0,0 @@
import{r as i,j as v}from"./input.js";import{app as n}from"/scripts/app.js";import{a6 as m,j as b,ar as S,o as y,E as k,A as u,as as E,B as A}from"./App-m2_qh9T8.js";import"/scripts/api.js";function C(l,p){const c=i.useRef(0),a=i.useCallback(()=>{c.current!==null&&(clearTimeout(c.current),c.current=0)},[]),w=i.useCallback((...g)=>{a(),c.current=setTimeout(()=>l(...g),p)},[l,p,a]);return i.useEffect(()=>()=>{a()},[]),[w,a]}function D(){const{setIsDirty:l,setRoute:p,saveCurWorkflow:c}=i.useContext(m),a=b();i.useEffect(()=>{let t=!0;const r=async e=>{switch(e){case k.SAVE:c();break;case k.SAVE_AS:p("saveAsModal");break}},o=n.canvas.onAfterChange;n.graph.onAfterChange=function(){o==null||o.apply(this,arguments),h()};const s=n.graph.onConfigure;n.graph.onConfigure=function(){if(s==null||s.apply(this,arguments),t){t=!1;return}h()},document.addEventListener("click",e=>{(n.canvas.node_over!=null||n.canvas.node_capturing_input!=null||n.canvas.node_widget!=null)&&h()}),document.addEventListener("keydown",async function(e){var d;if(document.visibilityState==="hidden")return;const f=await S(e);f?r(f):(d=e.target)!=null&&d.matches("input, textarea")&&Object.keys(n.canvas.selected_nodes??{}).length&&h()})},[]);const w=async()=>{var r,o,s,e;if(!((o=(r=u)==null?void 0:r.curWorkflow)!=null&&o.id))return;const t=JSON.stringify(n.graph.serialize());t!=null&&await((s=u)==null?void 0:s.updateFlow(u.curWorkflow.id,{json:t})),(e=E)==null||e.create({workflowID:u.curWorkflow.id,isAutoSave:!0,json:t}),l(!1),a({position:"bottom-left",duration:1e3,render:()=>v.jsx(A,{color:"white",p:3,children:"Auto saved"})})},[g,W]=C(w,1e3),h=async()=>{var r,o,s,e,f,d;if((o=(r=u)==null?void 0:r.curWorkflow)!=null&&o.saveLock)return;const t=await((s=y)==null?void 0:s.getSetting("autoSave"));if(!t){l(!0);return}(f=(e=u)==null?void 0:e.curWorkflow)!=null&&f.id&&t&&(await((d=u)==null?void 0:d.latestVersionCheck())?g():a({title:"Your changes cannot be saved!",description:"You are working on an outdated version. This workflow is changed by another tab. Please refresh to get the latest version.",status:"warning",isClosable:!0,duration:null}))};return null}export{D as default};
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
import{h as a}from"./App-m2_qh9T8.js";var p=a("copy","IconCopy",[["path",{d:"M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z",key:"svg-0"}],["path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1",key:"svg-1"}]]);export{p as I};
import{h as a}from"./App-bqAziDgv.js";var p=a("copy","IconCopy",[["path",{d:"M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z",key:"svg-0"}],["path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1",key:"svg-1"}]]);export{p as I};
@@ -1 +1 @@
import{r as c,j as e,h as d,P as f}from"./input.js";import{app as m}from"/scripts/app.js";import{G as x,g as j,I as v}from"./ModelManagerTopbar-HBujathO.js";import{l as h,H as w,ab as g,B as _,ad as M,ae as E,aL as I,F as S,an as b}from"./App-m2_qh9T8.js";import{V as k}from"./chunk-NTCQBYKE-4jGnRs0h.js";import{I as y,G as C}from"./chunk-JARCRF6W-woB8iy4E.js";import"/scripts/api.js";import"./chunk-3RSXBRAN-EWGr6OhB.js";import"./index-pz0vT7Or.js";function z({model:s}){const[a,t]=c.useState([]),n=D(s.received_value),p=async()=>{const l=await(await fetch(`https://huggingface.co/api/models?limit=3&search=${n}&full=true`)).json(),i=[];l.slice(0,1).forEach(({modelId:r,siblings:H})=>{i.push({name:r,downloadUrl:`https://huggingface.co/${r}/resolve/main/`,url:`https://huggingface.co/${r}/tree/main`,icon:"https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.png"})}),t(r=>[...r,...i])},u=async()=>{const o=await j(n);t(l=>[...l,...o==null?void 0:o.slice(0,1).map(i=>({name:i.name,url:"https://civitai.com/models/"+i.id,icon:"https://images.crunchbase.com/image/upload/c_pad,h_170,w_170,f_auto,b_white,q_auto:eco,dpr_1/gtxrcmtsvpjjevozblfa"}))])};return c.useEffect(()=>{p(),u()},[]),e.jsx(x,{p:3,shadow:"md",borderWidth:"1px",children:e.jsxs(k,{align:"start",children:[e.jsx(h,{children:s.class_type}),e.jsxs(w,{ml:3,children:[e.jsxs(h,{children:[s.input_name,": "]}),e.jsx(h,{color:"red.400",children:s.received_value})]}),a.map(({url:o,name:l,icon:i})=>e.jsx(d,{size:"sm",onClick:r=>{r.stopPropagation(),window.open(o,"_blank")},leftIcon:e.jsx(y,{width:5,src:i}),rightIcon:e.jsx(g,{size:20}),children:l})),e.jsx(d,{colorScheme:"blue",mt:5,iconSpacing:1,leftIcon:e.jsx(g,{size:20}),size:"sm",onClick:()=>{window.open(`https://civitai.com/search/models?sortBy=models_v5&query=${n}`,"_blank")},children:"Search in CivitAI"})]})})}function D(s){return s.replace(/^.*(\\|\/|\:)/,"").replace(/\.[^/.]+$/,"").replaceAll("_"," ").replace(/([A-Z])/g," $1").trim()}function B({onClose:s,missingModels:a}){c.useEffect(()=>(m.canvasEl.addEventListener("click",s),()=>{m.canvasEl.removeEventListener("click",s)}),[]);const t=480;return e.jsx(f,{children:e.jsx(_,{style:{width:t},children:e.jsxs(M,{width:t,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:E,overflowY:"auto",children:[e.jsx(I,{children:e.jsxs(S,{justifyContent:"space-between",alignContent:"center",children:[e.jsxs(b,{size:"md",mr:2,children:["Missing Models (",a.length,")"]}),e.jsx(v,{})]})}),e.jsx(C,{templateColumns:"1",gap:1,marginTop:2,width:"100%",children:a.map(n=>e.jsx(z,{model:n},n.received_value))})]})})})}function T({}){const[s,a]=c.useState(!1),[t,n]=c.useState([]);return c.useEffect(()=>{},[]),t.length===0?null:e.jsxs(e.Fragment,{children:[e.jsxs(d,{size:"sm","aria-label":"missing models",px:2,onClick:()=>a(!0),colorScheme:"teal",children:["Install Missing (",t.length,")"]}),s&&e.jsx(B,{onClose:()=>a(!1),missingModels:t})]})}export{T as default};
import{r as c,j as e,h as d,P as f}from"./input.js";import{app as m}from"/scripts/app.js";import{G as x,g as j,I as v}from"./ModelManagerTopbar--uE4bw7I.js";import{l as h,H as w,ab as g,B as _,ad as M,ae as E,aM as I,F as S,an as b}from"./App-bqAziDgv.js";import{V as k}from"./chunk-NTCQBYKE-ZJqEVTS0.js";import{I as y,G as C}from"./chunk-JARCRF6W-fNDfXRta.js";import"/scripts/api.js";import"./chunk-3RSXBRAN-ajfTuIGC.js";import"./index-pz0vT7Or.js";function z({model:s}){const[a,t]=c.useState([]),n=D(s.received_value),p=async()=>{const l=await(await fetch(`https://huggingface.co/api/models?limit=3&search=${n}&full=true`)).json(),i=[];l.slice(0,1).forEach(({modelId:r,siblings:H})=>{i.push({name:r,downloadUrl:`https://huggingface.co/${r}/resolve/main/`,url:`https://huggingface.co/${r}/tree/main`,icon:"https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.png"})}),t(r=>[...r,...i])},u=async()=>{const o=await j(n);t(l=>[...l,...o==null?void 0:o.slice(0,1).map(i=>({name:i.name,url:"https://civitai.com/models/"+i.id,icon:"https://images.crunchbase.com/image/upload/c_pad,h_170,w_170,f_auto,b_white,q_auto:eco,dpr_1/gtxrcmtsvpjjevozblfa"}))])};return c.useEffect(()=>{p(),u()},[]),e.jsx(x,{p:3,shadow:"md",borderWidth:"1px",children:e.jsxs(k,{align:"start",children:[e.jsx(h,{children:s.class_type}),e.jsxs(w,{ml:3,children:[e.jsxs(h,{children:[s.input_name,": "]}),e.jsx(h,{color:"red.400",children:s.received_value})]}),a.map(({url:o,name:l,icon:i})=>e.jsx(d,{size:"sm",onClick:r=>{r.stopPropagation(),window.open(o,"_blank")},leftIcon:e.jsx(y,{width:5,src:i}),rightIcon:e.jsx(g,{size:20}),children:l})),e.jsx(d,{colorScheme:"blue",mt:5,iconSpacing:1,leftIcon:e.jsx(g,{size:20}),size:"sm",onClick:()=>{window.open(`https://civitai.com/search/models?sortBy=models_v5&query=${n}`,"_blank")},children:"Search in CivitAI"})]})})}function D(s){return s.replace(/^.*(\\|\/|\:)/,"").replace(/\.[^/.]+$/,"").replaceAll("_"," ").replace(/([A-Z])/g," $1").trim()}function B({onClose:s,missingModels:a}){c.useEffect(()=>(m.canvasEl.addEventListener("click",s),()=>{m.canvasEl.removeEventListener("click",s)}),[]);const t=480;return e.jsx(f,{children:e.jsx(_,{style:{width:t},children:e.jsxs(M,{width:t,height:"100vh",p:4,gap:2,position:"fixed",top:0,left:0,shadow:"xl",zIndex:E,overflowY:"auto",children:[e.jsx(I,{children:e.jsxs(S,{justifyContent:"space-between",alignContent:"center",children:[e.jsxs(b,{size:"md",mr:2,children:["Missing Models (",a.length,")"]}),e.jsx(v,{})]})}),e.jsx(C,{templateColumns:"1",gap:1,marginTop:2,width:"100%",children:a.map(n=>e.jsx(z,{model:n},n.received_value))})]})})})}function T({}){const[s,a]=c.useState(!1),[t,n]=c.useState([]);return c.useEffect(()=>{},[]),t.length===0?null:e.jsxs(e.Fragment,{children:[e.jsxs(d,{size:"sm","aria-label":"missing models",px:2,onClick:()=>a(!0),colorScheme:"teal",children:["Install Missing (",t.length,")"]}),s&&e.jsx(B,{onClose:()=>a(!1),missingModels:t})]})}export{T as default};
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
import{f as x,j as l,g as i,e as b,k as C,o as E,l as I,r as f,ah as P}from"./input.js";import{$ as z}from"./App-m2_qh9T8.js";var v=x(function(o,s){const{children:t,placeholder:n,className:r,...a}=o;return l.jsxs(i.select,{...a,ref:s,className:b("chakra-select",r),children:[n&&l.jsx("option",{value:"",children:n}),t]})});v.displayName="SelectField";function F(e,o){const s={},t={};for(const[n,r]of Object.entries(e))o.includes(n)?s[n]=r:t[n]=r;return[s,t]}var H=x((e,o)=>{var s;const t=C("Select",e),{rootProps:n,placeholder:r,icon:a,color:c,height:_,h:d,minH:h,minHeight:y,iconColor:p,iconSize:u,...j}=E(e),[g,N]=F(j,P),m=z(N),k={width:"100%",height:"fit-content",position:"relative",color:c},w={paddingEnd:"2rem",...t.field,_focus:{zIndex:"unset",...(s=t.field)==null?void 0:s._focus}};return l.jsxs(i.div,{className:"chakra-select__wrapper",__css:k,...g,...n,children:[l.jsx(v,{ref:o,height:d??_,minH:h??y,placeholder:r,...m,__css:w,children:e.children}),l.jsx(S,{"data-disabled":I(m.disabled),...(p||c)&&{color:p||c},__css:t.icon,...u&&{fontSize:u},children:a})]})});H.displayName="Select";var M=e=>l.jsx("svg",{viewBox:"0 0 24 24",...e,children:l.jsx("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"})}),R=i("div",{baseStyle:{position:"absolute",display:"inline-flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",top:"50%",transform:"translateY(-50%)"}}),S=e=>{const{children:o=l.jsx(M,{}),...s}=e,t=f.cloneElement(o,{role:"presentation",className:"chakra-select__icon",focusable:!1,"aria-hidden":!0,style:{width:"1em",height:"1em",color:"currentColor"}});return l.jsx(R,{...s,className:"chakra-select__icon-wrapper",children:f.isValidElement(o)?t:null})};S.displayName="SelectIcon";export{H as S};
import{f as x,j as l,g as i,e as b,k as C,o as E,l as I,r as f,ah as P}from"./input.js";import{$ as z}from"./App-bqAziDgv.js";var v=x(function(o,s){const{children:t,placeholder:n,className:r,...a}=o;return l.jsxs(i.select,{...a,ref:s,className:b("chakra-select",r),children:[n&&l.jsx("option",{value:"",children:n}),t]})});v.displayName="SelectField";function F(e,o){const s={},t={};for(const[n,r]of Object.entries(e))o.includes(n)?s[n]=r:t[n]=r;return[s,t]}var H=x((e,o)=>{var s;const t=C("Select",e),{rootProps:n,placeholder:r,icon:a,color:c,height:_,h:d,minH:h,minHeight:y,iconColor:p,iconSize:u,...j}=E(e),[g,N]=F(j,P),m=z(N),k={width:"100%",height:"fit-content",position:"relative",color:c},w={paddingEnd:"2rem",...t.field,_focus:{zIndex:"unset",...(s=t.field)==null?void 0:s._focus}};return l.jsxs(i.div,{className:"chakra-select__wrapper",__css:k,...g,...n,children:[l.jsx(v,{ref:o,height:d??_,minH:h??y,placeholder:r,...m,__css:w,children:e.children}),l.jsx(S,{"data-disabled":I(m.disabled),...(p||c)&&{color:p||c},__css:t.icon,...u&&{fontSize:u},children:a})]})});H.displayName="Select";var M=e=>l.jsx("svg",{viewBox:"0 0 24 24",...e,children:l.jsx("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"})}),R=i("div",{baseStyle:{position:"absolute",display:"inline-flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",top:"50%",transform:"translateY(-50%)"}}),S=e=>{const{children:o=l.jsx(M,{}),...s}=e,t=f.cloneElement(o,{role:"presentation",className:"chakra-select__icon",focusable:!1,"aria-hidden":!0,style:{width:"1em",height:"1em",color:"currentColor"}});return l.jsx(R,{...s,className:"chakra-select__icon-wrapper",children:f.isValidElement(o)?t:null})};S.displayName="SelectIcon";export{H as S};
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
import{k as t}from"./App-m2_qh9T8.js";import{f as o,j as s}from"./input.js";var e=o((a,r)=>s.jsx(t,{align:"center",...a,direction:"column",ref:r}));e.displayName="VStack";export{e as V};
import{k as t}from"./App-bqAziDgv.js";import{f as o,j as s}from"./input.js";var e=o((a,r)=>s.jsx(t,{align:"center",...a,direction:"column",ref:r}));e.displayName="VStack";export{e as V};
+2 -2
View File
@@ -679,10 +679,10 @@ Error generating stack: `+i.message+`
}
${hB}
`}),Lw=document.createElement("div");document.body.append(Lw);const mB=Ar.lazy(()=>Jk(()=>import("./App-m2_qh9T8.js").then(e=>e.aM),__vite__mapDeps([0,1])).then(({default:e})=>({default:e}))),vB={hide:-1,auto:"auto",base:0,docked:10,dropdown:1e7,sticky:11e6,banner:12e6,overlay:13e6,modal:14e6,popover:15e6,skipLink:16e6,toast:17e6,tooltip:18e6},gB=zz({zIndices:vB});bd.createRoot(Lw).render(E.jsx(Ar.StrictMode,{children:E.jsxs(GI,{resetCSS:!1,disableGlobalStyle:!0,theme:gB,children:[E.jsx(pB,{scope:".workspace_manager"}),E.jsx(NP,{initialColorMode:"dark"}),E.jsx(fB,{children:E.jsx(S.Suspense,{children:E.jsx(mB,{})})})]})}));const Yf=document.body,yB={attributes:!0,attributeFilter:["class"]},bB=function(e,t){const r=document.documentElement;r.style.colorScheme==="dark"&&r.style.removeProperty("color-scheme");for(const n of e)if(n.type==="attributes"&&n.attributeName==="class")for(const o of Yf.classList)o.includes("chakra")&&Yf.classList.remove(o)},SB=new MutationObserver(bB);SB.observe(Yf,yB);export{gL as $,LB as A,DB as B,OB as C,IB as D,zP as E,lr as F,ii as G,PB as H,Xa as I,Ip as J,EB as K,Ya as L,ww as M,Mw as N,$w as O,Na as P,Rw as Q,Fw as R,zw as S,Aw as T,Pb as U,BB as V,is as W,Ar as X,RB as Y,Du as Z,Jk as _,FB as a,nL as a0,vL as a1,Wf as a2,Ra as a3,wP as a4,xB as a5,Hn as a6,Uh as a7,xP as a8,zp as a9,wB as aa,CB as ab,Bn as ac,M0 as ad,kB as ae,uB as af,cB as ag,TB as ah,mn as b,zB as c,f3 as d,Be as e,pt as f,_e as g,Ix as h,AB as i,E as j,eS as k,Rv as l,Bf as m,Nu as n,Ou as o,_B as p,$i as q,S as r,Xf as s,hw as t,VP as u,$B as v,Kt as w,Cg as x,ka as y,vO as z};
`}),Lw=document.createElement("div");document.body.append(Lw);const mB=Ar.lazy(()=>Jk(()=>import("./App-bqAziDgv.js").then(e=>e.aN),__vite__mapDeps([0,1])).then(({default:e})=>({default:e}))),vB={hide:-1,auto:"auto",base:0,docked:10,dropdown:1e7,sticky:11e6,banner:12e6,overlay:13e6,modal:14e6,popover:15e6,skipLink:16e6,toast:17e6,tooltip:18e6},gB=zz({zIndices:vB});bd.createRoot(Lw).render(E.jsx(Ar.StrictMode,{children:E.jsxs(GI,{resetCSS:!1,disableGlobalStyle:!0,theme:gB,children:[E.jsx(pB,{scope:".workspace_manager"}),E.jsx(NP,{initialColorMode:"dark"}),E.jsx(fB,{children:E.jsx(S.Suspense,{children:E.jsx(mB,{})})})]})}));const Yf=document.body,yB={attributes:!0,attributeFilter:["class"]},bB=function(e,t){const r=document.documentElement;r.style.colorScheme==="dark"&&r.style.removeProperty("color-scheme");for(const n of e)if(n.type==="attributes"&&n.attributeName==="class")for(const o of Yf.classList)o.includes("chakra")&&Yf.classList.remove(o)},SB=new MutationObserver(bB);SB.observe(Yf,yB);export{gL as $,LB as A,DB as B,OB as C,IB as D,zP as E,lr as F,ii as G,PB as H,Xa as I,Ip as J,EB as K,Ya as L,ww as M,Mw as N,$w as O,Na as P,Rw as Q,Fw as R,zw as S,Aw as T,Pb as U,BB as V,is as W,Ar as X,RB as Y,Du as Z,Jk as _,FB as a,nL as a0,vL as a1,Wf as a2,Ra as a3,wP as a4,xB as a5,Hn as a6,Uh as a7,xP as a8,zp as a9,wB as aa,CB as ab,Bn as ac,M0 as ad,kB as ae,uB as af,cB as ag,TB as ah,mn as b,zB as c,f3 as d,Be as e,pt as f,_e as g,Ix as h,AB as i,E as j,eS as k,Rv as l,Bf as m,Nu as n,Ou as o,_B as p,$i as q,S as r,Xf as s,hw as t,VP as u,$B as v,Kt as w,Cg as x,ka as y,vO as z};
function __vite__mapDeps(indexes) {
if (!__vite__mapDeps.viteFileDeps) {
__vite__mapDeps.viteFileDeps = ["workspace_web/App-m2_qh9T8.js","workspace_web/assets/App-JXePnJiV.css"]
__vite__mapDeps.viteFileDeps = ["workspace_web/App-bqAziDgv.js","workspace_web/assets/App-JXePnJiV.css"]
}
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}
+19 -14
View File
@@ -11,14 +11,13 @@ import { Box, useToast } from "@chakra-ui/react";
import { matchShortcut } from "../utils";
import { EShortcutKeys } from "../types/dbTypes";
import useDebounceFn from "../customHooks/useDebounceFn";
import { deepJsonDiffCheck } from "../utils/deepJsonDiffCheck";
export default function AppIsDirtyEventListener() {
const { setIsDirty, setRoute, saveCurWorkflow } =
const { isDirty, setIsDirty, setRoute, saveCurWorkflow } =
useContext(WorkspaceContext);
const toast = useToast();
useEffect(() => {
let isFirstConfigureCall = true;
const shortcutListener = async (matchResult: string) => {
switch (matchResult) {
case EShortcutKeys.SAVE:
@@ -33,28 +32,32 @@ export default function AppIsDirtyEventListener() {
app.graph.onAfterChange = function () {
// Call the original onAfterChange method
originalOnAfterChange?.apply(this, arguments);
onIsDirty();
debounceOnIsDirty();
};
const originalOnConfigure = app.graph.onConfigure;
app.graph.onConfigure = function () {
originalOnConfigure?.apply(this, arguments);
if (isFirstConfigureCall) {
isFirstConfigureCall = false;
return;
}
// Call the original onConfigure method
onIsDirty();
// delay check diff json cuz it takes time for graph.serialize() to settle up and return the correct json
setTimeout(() => {
const deepCheck = deepJsonDiffCheck(
app.graph.serialize(),
JSON.parse(workflowsTable?.curWorkflow?.json ?? "{}"),
);
if (!deepCheck) {
debounceOnIsDirty();
}
}, 1000);
};
document.addEventListener("click", (e) => {
if (!Object.keys(app.canvas.selected_nodes ?? {}).length) return;
if (
app.canvas.node_over != null ||
app.canvas.node_capturing_input != null ||
app.canvas.node_widget != null
) {
onIsDirty();
debounceOnIsDirty();
}
});
document.addEventListener("keydown", async function (event) {
@@ -67,7 +70,7 @@ export default function AppIsDirtyEventListener() {
event.target?.matches("input, textarea") &&
Object.keys(app.canvas.selected_nodes ?? {}).length
) {
onIsDirty();
debounceOnIsDirty();
}
});
}, []);
@@ -103,7 +106,7 @@ export default function AppIsDirtyEventListener() {
if (workflowsTable?.curWorkflow?.saveLock) return;
const autoSaveEnabled = await userSettingsTable?.getSetting("autoSave");
if (!autoSaveEnabled) {
setIsDirty(true);
!isDirty && setIsDirty(true);
return;
}
if (workflowsTable?.curWorkflow?.id && autoSaveEnabled) {
@@ -124,5 +127,7 @@ export default function AppIsDirtyEventListener() {
}
}
};
const [debounceOnIsDirty, _] = useDebounceFn(onIsDirty, 500);
return null;
}