n8n-editor-ui
Version:
Workflow Editor UI for n8n
2 lines • 4.64 kB
JavaScript
!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","./constants-legacy-2_ytuuS3.js","./useRootStore-legacy-CC08el-l.js","./settings.store-legacy-I6rZOvfF.js"],(function(e,n){var t,o,l,s,a,u,c,r,i,v,d,f,p,g;return{setters:[function(e){t=e.Ft,o=e.S,l=e.gt},function(e){s=e.Ur,a=e.cl,u=e.el},function(e){c=e.T,r=e.t},function(e){i=e.An,v=e.t}],execute:function(){try{n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},(m=(new n.Error).stack)&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[m]="64fc56ce-2f35-4ee8-9de0-2e4144c35988",n._sentryDebugIdIdentifier="sentry-dbid-64fc56ce-2f35-4ee8-9de0-2e4144c35988")}catch(n){}var n,m;e("n",d=e=>{const{interval:n,onHeartbeat:o}=e,l=t(null);return{startHeartbeat:()=>{l.value=setInterval(o,n)},stopHeartbeat:()=>{l.value&&(clearInterval(l.value),l.value=null)}}}),f=({onAttempt:e,onAttemptScheduled:n})=>{const o=t(null),l=t(0);return{scheduleReconnect:()=>{const t=Math.min(1e3*2**l.value,15e3);l.value++,n(t),o.value=setTimeout((()=>{e()}),t)},stopReconnectTimer:()=>{o.value&&(clearTimeout(o.value),o.value=null)},resetConnectionAttempts:()=>{l.value=0}}},p=e=>{const n=t(!1),o=t(null),{startHeartbeat:l,stopHeartbeat:a}=d({interval:3e4,onHeartbeat:()=>{o.value?.send(JSON.stringify(s()))}}),u=()=>{o.value?.removeEventListener("open",u),n.value=!0,l(),g.resetConnectionAttempts()},c=e=>{console.warn(`[WebSocketClient] Connection lost, code=${e.code??"unknown"}`),v(),g.scheduleReconnect()},r=n=>{e.onMessage(n.data)},i=e=>{console.warn("[WebSocketClient] Connection error:",e)},v=()=>{o.value&&(a(),g.stopReconnectTimer(),o.value.removeEventListener("message",r),o.value.removeEventListener("error",i),o.value.removeEventListener("close",c),o.value.close(1e3),o.value=null),n.value=!1},p=()=>{v(),o.value=new WebSocket(e.url),o.value.addEventListener("open",u),o.value.addEventListener("message",r),o.value.addEventListener("error",i),o.value.addEventListener("close",c),o.value.binaryType="arraybuffer"},g=f({onAttempt:p,onAttemptScheduled:e=>{console.log(`[WebSocketClient] Attempting to reconnect in ${e}ms`)}});return{isConnected:n,connect:p,disconnect:v,sendMessage:e=>{if(!n.value||!o.value)throw new Error("Not connected to the server");o.value.send(e)}}},g=e=>{const n=t(!1),o=t(null),l=()=>{n.value=!0,r.resetConnectionAttempts()},s=()=>{console.warn("[EventSourceClient] Connection lost"),n.value=!1,r.scheduleReconnect()},a=n=>{e.onMessage(n.data)},u=()=>{o.value&&(r.stopReconnectTimer(),o.value.close(),o.value=null),n.value=!1},c=()=>{u(),o.value=new EventSource(e.url,{withCredentials:!0}),o.value.addEventListener("open",l),o.value.addEventListener("message",a),o.value.addEventListener("close",s)},r=f({onAttempt:c,onAttemptScheduled:e=>{console.log(`[EventSourceClient] Attempting to reconnect in ${e}ms`)}});return{isConnected:n,connect:c,disconnect:u,sendMessage:e=>{}}},e("t",c(i.PUSH,(()=>{const e=r(),n=v(),s=t([]),c=t(!1),i=t(!1),d=t([]),f=o((()=>"websocket"===n.pushBackend));async function m(e){let n;e instanceof ArrayBuffer&&(e=new TextDecoder("utf-8").decode(new Uint8Array(e)));try{n=JSON.parse(e)}catch(t){return}d.value.forEach((e=>{e(n)}))}const h=(()=>{const n=e.restUrl,t=`/push?pushRef=${e.pushRef}`;if(f.value){const{protocol:e,host:o}=window.location;return`${n.startsWith("http")?n.replace(/^http/,"ws"):`${"https:"===e?"wss":"ws"}://${o+n}`}${t}`}return`${n}${t}`})(),y=o((()=>f.value?p({url:h,onMessage:m}):g({url:h,onMessage:m})));function b(e){y.value.isConnected.value?y.value.sendMessage(JSON.stringify(e)):s.value.push(e)}const w=()=>a(u.CONNECTION.WEBSOCKET_DISCONNECT);let C=!1,E=null,S=null;return l((()=>y.value.isConnected.value),(e=>{if(e&&(i.value=!1),e&&s.value.length){for(const e of s.value)b(e);s.value=[]}})),{isConnected:o((()=>y.value.isConnected.value)),isConnecting:i,isConnectionRequested:c,onMessageReceivedHandlers:d,addEventListener:e=>(d.value.push(e),()=>{const n=d.value.indexOf(e);-1!==n&&d.value.splice(n,1)}),pushConnect:()=>{C=!0,E&&clearTimeout(E),E=setTimeout((()=>{C=!1,E=null}),w()),S&&(clearTimeout(S),S=null),c.value=!0,i.value=!0,y.value.connect()},pushDisconnect:()=>{C||(S&&clearTimeout(S),S=setTimeout((()=>{C||(c.value=!1,i.value=!1,y.value.disconnect()),S=null}),w()))},send:b,clearQueue:()=>{s.value=[]}}})))}}}));
//# sourceMappingURL=pushConnection.store-legacy-idli-hOS.js.map