UNPKG

n8n-editor-ui

Version:

Workflow Editor UI for n8n

2 lines 5.15 kB
!function(){try{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{}).SENTRY_RELEASE={id:"n8n@2.13.4"}}catch(e){}}(),System.register(["./vue.runtime.esm-bundler-legacy-IafOlCW8.js","./_MapCache-legacy-DwgdC8YO.js","./src-legacy-Dwzr7bD0.js","./users.store-legacy-OKuN0qAC.js","./constants-legacy-DNCca_FT.js","./_baseOrderBy-legacy-PsQY_Pvh.js","./pushConnection.store-legacy-CdZe0qqo.js"],(function(e,n){var l,t,a,u,r,o,i,d,s,c,v,f,w,y,I,b,g,p,h,k,E,C;function A({route:e}){const n=s(),u=o(),r=a(),i=l(null),d=t((()=>e.name===y.DEMO)),c=[];function v(e){if(!d.value&&!window.preventNodeViewBeforeUnload)return c.forEach((e=>e())),n.stateIsDirty?(e.returnValue=!0,!0):void u.startLoading(r.baseText("nodeView.redirecting"))}return{onBeforeUnload:v,addBeforeUnloadEventBindings:function(){window.addEventListener("beforeunload",v)},removeBeforeUnloadEventBindings:function(){i.value&&clearTimeout(i.value),window.removeEventListener("beforeunload",v)},addBeforeUnloadHandler:function(e){c.push(e)}}}return e("n",A),{setters:[function(e){l=e.Ft,t=e.S},function(e){a=e.bt},function(e){u=e.gt},function(e){r=e.Gr,o=e.Or,i=e.cn,d=e.ka,s=e.r,c=e.s,v=e.sl,f=e.t},function(e){w=e.Cl,y=e.ms},function(e){I=e.j,b=e.r},function(e){g=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]="f2300201-20de-4e10-838b-f4077325360d",n._sentryDebugIdIdentifier="sentry-dbid-f2300201-20de-4e10-838b-f4077325360d")}catch(n){}var n,a;p=5*w.MINUTE,h=30*w.SECOND,k=20*w.SECOND,E=5*w.SECOND,C=20*w.SECOND,e("t",I(v.COLLABORATION,(()=>{const e=g(),n=c(),a=r(),o=f(),v=s(),y=b(),I=i(),{addBeforeUnloadEventBindings:B,removeBeforeUnloadEventBindings:D,addBeforeUnloadHandler:m}=A({route:u()}),U=l(null),O=l([]),T=l(null),R=l(Date.now()),S=l(null),W=l(null),N=l(null),j=l(null),L=l(null),_=l(null);let q=null;const H=t((()=>T.value?.clientId===y.pushRef)),x=t((()=>T.value?.userId===o.currentUserId)),M=t((()=>O.value.find((e=>e.user.id===T.value?.userId))??null)),V=t((()=>null!==T.value)),F=t((()=>V.value&&!H.value));async function z(){try{const{workflowId:e}=n;return n.isWorkflowSaved[e]?await d(y.restApiContext,e):null}catch{return null}}function G(){_.value&&e.send({type:"workflowOpened",workflowId:_.value})}function P(){_.value&&(e.send({type:"workflowClosed",workflowId:_.value}),O.value=O.value.filter((({user:e})=>e.id!==o.currentUserId)))}const Q=()=>{null!==W.value&&(clearInterval(W.value),W.value=null)},Y=()=>{Q(),W.value=window.setInterval(G,p)},J=()=>{null!==N.value&&(clearInterval(N.value),N.value=null)},K=()=>{H.value&&_.value?e.send({type:"writeAccessHeartbeat",workflowId:_.value}):J()},X=()=>{J(),N.value=window.setInterval(K,h)},Z=()=>{null!==j.value&&(clearInterval(j.value),j.value=null)},$=async()=>{F.value?!(await z())&&T.value&&(T.value=null,Z()):Z()},ee=()=>{Z(),j.value=window.setInterval($,k)};function ne(){R.value=Date.now()}function le(){if(T.value=null,J(),!_.value)return!0;try{return e.send({type:"writeAccessReleaseRequested",workflowId:_.value}),!0}catch{return!1}}function te(){H.value&&(I.streaming||Date.now()-R.value>=C&&le())}function ae(){null!==S.value&&(clearInterval(S.value),S.value=null)}return m((()=>{P(),v.stateIsDirty&&(U.value=setTimeout((()=>G),5*w.SECOND))})),{collaborators:O,currentWriter:M,isCurrentTabWriter:H,isCurrentUserWriter:x,isAnyoneWriting:V,shouldBeReadOnly:F,requestWriteAccess:function(){if(H.value)return!0;if(!_.value)return!1;try{e.send({type:"writeAccessRequested",workflowId:_.value})}catch{return!1}return!0},requestWriteAccessForce:function(){if(!_.value)return!1;try{e.send({type:"writeAccessRequested",workflowId:_.value,force:!0})}catch{return!1}return!0},releaseWriteAccess:le,recordActivity:ne,initialize:async function(){if(L.value)return;_.value=n.workflowId;const l=await z();l&&(T.value=l,H.value?X():ee()),L.value=e.addEventListener((e=>"collaboratorsChanged"===e.type&&e.data.workflowId===_.value?(O.value=e.data.collaborators,void(T.value&&(O.value.some((e=>e.user.id===T.value?.userId))||(T.value=null)))):"writeAccessAcquired"===e.type&&e.data.workflowId===_.value?(T.value={clientId:e.data.clientId,userId:e.data.userId},void(H.value?(ne(),X(),Z()):ee())):"writeAccessReleased"===e.type&&e.data.workflowId===_.value?(T.value=null,J(),void Z()):void("workflowUpdated"!==e.type||e.data.workflowId!==_.value||async function(){if(!H.value&&_.value)try{const e=await a.fetchWorkflow(_.value);q&&q(e)}catch(e){return console.error("[Collaboration] Error in handleWorkflowUpdate:",e),!1}}()))),B(),G(),Y(),ae(),S.value=window.setInterval(te,E)},terminate:function(){"function"==typeof L.value&&(L.value(),L.value=null),P(),Q(),J(),Z(),ae(),H.value&&le(),e.clearQueue(),D(),U.value&&clearTimeout(U.value),_.value=null,T.value=null,O.value=[]},startHeartbeat:Y,stopHeartbeat:Q,setRefreshCanvasCallback:function(e){q=e}}})))}}})); //# sourceMappingURL=collaboration.store-legacy-Cbihou7P.js.map