UNPKG

n8n-editor-ui

Version:

Workflow Editor UI for n8n

2 lines 5.2 kB
!function(){try{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{}).SENTRY_RELEASE={id:"n8n@2.16.1"}}catch(e){}}(),System.register(["./vue.runtime.esm-bundler-legacy-BW6xDdqj.js","./core-legacy-VD8c7QJ-.js","./src-legacy-B67uuxhB.js","./users.store-legacy-azRUgFdP.js","./constants-legacy-2_ytuuS3.js","./useRootStore-legacy-CC08el-l.js","./settings.store-legacy-I6rZOvfF.js","./pushConnection.store-legacy-idli-hOS.js"],(function(e,n){var l,t,a,u,r,o,i,s,d,c,v,f,w,y,I,g,b,p,E,h,k,A;function C({route:e}){const n=i(),u=v(),r=a(),o=l(null),s=t((()=>e.name===f.DEMO)),d=[];function c(e){if(!s.value&&!window.preventNodeViewBeforeUnload)return d.forEach((e=>e())),n.stateIsDirty?(e.returnValue=!0,!0):void u.startLoading(r.baseText("nodeView.redirecting"))}return{onBeforeUnload:c,addBeforeUnloadEventBindings:function(){window.addEventListener("beforeunload",c)},removeBeforeUnloadEventBindings:function(){o.value&&clearTimeout(o.value),window.removeEventListener("beforeunload",c)},addBeforeUnloadHandler:function(e){d.push(e)}}}return e("n",C),{setters:[function(e){l=e.Ft,t=e.S},function(e){a=e.at},function(e){u=e.ct},function(e){r=e.Ot,o=e.ja,i=e.r,s=e.s,d=e.sr,c=e.t,v=e.ur},function(e){f=e.Qo,w=e.sl},function(e){y=e.T,I=e.t},function(e){g=e.An},function(e){b=e.t}],execute:function(){try{n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},(a=(new n.Error).stack)&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[a]="56b9ed93-f92f-460c-9def-db10f096858f",n._sentryDebugIdIdentifier="sentry-dbid-56b9ed93-f92f-460c-9def-db10f096858f")}catch(n){}var n,a;p=5*w.MINUTE,E=30*w.SECOND,h=20*w.SECOND,k=5*w.SECOND,A=20*w.SECOND,e("t",y(g.COLLABORATION,(()=>{const e=b(),n=s(),a=d(),v=c(),f=i(),y=I(),g=r(),{addBeforeUnloadEventBindings:D,removeBeforeUnloadEventBindings:m,addBeforeUnloadHandler:B}=C({route:u()}),U=l(null),T=l([]),O=l(null),R=l(Date.now()),S=l(null),W=l(null),j=l(null),N=l(null),L=l(null),q=l(null);let H=null;const _=t((()=>O.value?.clientId===y.pushRef)),x=t((()=>O.value?.userId===v.currentUserId)),V=t((()=>T.value.find((e=>e.user.id===O.value?.userId))??null)),F=t((()=>null!==O.value)),M=t((()=>F.value&&!_.value));async function Q(){try{const{workflowId:e}=n;return n.isWorkflowSaved[e]?await o(y.restApiContext,e):null}catch{return null}}function z(){q.value&&e.send({type:"workflowOpened",workflowId:q.value})}function Y(){q.value&&(e.send({type:"workflowClosed",workflowId:q.value}),T.value=T.value.filter((({user:e})=>e.id!==v.currentUserId)))}const G=()=>{null!==W.value&&(clearInterval(W.value),W.value=null)},J=()=>{G(),W.value=window.setInterval(z,p)},K=()=>{null!==j.value&&(clearInterval(j.value),j.value=null)},P=()=>{_.value&&q.value?e.send({type:"writeAccessHeartbeat",workflowId:q.value}):K()},X=()=>{K(),j.value=window.setInterval(P,E)},Z=()=>{null!==N.value&&(clearInterval(N.value),N.value=null)},$=async()=>{M.value?!(await Q())&&O.value&&(O.value=null,Z()):Z()},ee=()=>{Z(),N.value=window.setInterval($,h)};function ne(){R.value=Date.now()}function le(){if(O.value=null,K(),!q.value)return!0;try{return e.send({type:"writeAccessReleaseRequested",workflowId:q.value}),!0}catch{return!1}}function te(){_.value&&(g.streaming||Date.now()-R.value>=A&&le())}function ae(){null!==S.value&&(clearInterval(S.value),S.value=null)}return B((()=>{Y(),f.stateIsDirty&&(U.value=setTimeout((()=>z),5*w.SECOND))})),{collaborators:T,currentWriter:V,isCurrentTabWriter:_,isCurrentUserWriter:x,isAnyoneWriting:F,shouldBeReadOnly:M,requestWriteAccess:function(){if(_.value)return!0;if(!q.value)return!1;try{e.send({type:"writeAccessRequested",workflowId:q.value})}catch{return!1}return!0},requestWriteAccessForce:function(){if(!q.value)return!1;try{e.send({type:"writeAccessRequested",workflowId:q.value,force:!0})}catch{return!1}return!0},releaseWriteAccess:le,recordActivity:ne,initialize:async function(){if(L.value)return;q.value=n.workflowId;const l=await Q();l&&(O.value=l,_.value?X():ee()),L.value=e.addEventListener((e=>"collaboratorsChanged"===e.type&&e.data.workflowId===q.value?(T.value=e.data.collaborators,void(O.value&&(T.value.some((e=>e.user.id===O.value?.userId))||(O.value=null)))):"writeAccessAcquired"===e.type&&e.data.workflowId===q.value?(O.value={clientId:e.data.clientId,userId:e.data.userId},void(_.value?(ne(),X(),Z()):ee())):"writeAccessReleased"===e.type&&e.data.workflowId===q.value?(O.value=null,K(),void Z()):void("workflowUpdated"!==e.type||e.data.workflowId!==q.value||async function(){if(!_.value&&q.value)try{const e=await a.fetchWorkflow(q.value);H&&H(e)}catch(e){return console.error("[Collaboration] Error in handleWorkflowUpdate:",e),!1}}()))),D(),z(),J(),ae(),S.value=window.setInterval(te,k)},terminate:function(){"function"==typeof L.value&&(L.value(),L.value=null),Y(),G(),K(),Z(),ae(),_.value&&le(),e.clearQueue(),m(),U.value&&clearTimeout(U.value),q.value=null,O.value=null,T.value=[]},startHeartbeat:J,stopHeartbeat:G,setRefreshCanvasCallback:function(e){H=e}}})))}}})); //# sourceMappingURL=collaboration.store-legacy-CFKDVv2B.js.map