UNPKG

n8n-editor-ui

Version:

Workflow Editor UI for n8n

2 lines 4.64 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","./users.store-legacy-OKuN0qAC.js","./constants-legacy-DNCca_FT.js","./_baseOrderBy-legacy-PsQY_Pvh.js"],(function(e,n){var t,l,o,s,a,u,r,c,i,v,d,f,p,g;return{setters:[function(e){t=e.Ft,l=e.S,o=e.gt},function(e){s=e.As,a=e.sl},function(e){u=e.gl,r=e.oi,c=e.wl},function(e){i=e.j,v=e.r}],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]="13d9187b-6d34-457e-9a3f-9710f3114751",n._sentryDebugIdIdentifier="sentry-dbid-13d9187b-6d34-457e-9a3f-9710f3114751")}catch(n){}var n,m;e("n",d=e=>{const{interval:n,onHeartbeat:l}=e,o=t(null);return{startHeartbeat:()=>{o.value=setInterval(l,n)},stopHeartbeat:()=>{o.value&&(clearInterval(o.value),o.value=null)}}}),f=({onAttempt:e,onAttemptScheduled:n})=>{const l=t(null),o=t(0);return{scheduleReconnect:()=>{const t=Math.min(1e3*2**o.value,15e3);o.value++,n(t),l.value=setTimeout((()=>{e()}),t)},stopReconnectTimer:()=>{l.value&&(clearTimeout(l.value),l.value=null)},resetConnectionAttempts:()=>{o.value=0}}},p=e=>{const n=t(!1),l=t(null),{startHeartbeat:o,stopHeartbeat:s}=d({interval:3e4,onHeartbeat:()=>{l.value?.send(JSON.stringify(r()))}}),a=()=>{l.value?.removeEventListener("open",a),n.value=!0,o(),g.resetConnectionAttempts()},u=e=>{console.warn(`[WebSocketClient] Connection lost, code=${e.code??"unknown"}`),v(),g.scheduleReconnect()},c=n=>{e.onMessage(n.data)},i=e=>{console.warn("[WebSocketClient] Connection error:",e)},v=()=>{l.value&&(s(),g.stopReconnectTimer(),l.value.removeEventListener("message",c),l.value.removeEventListener("error",i),l.value.removeEventListener("close",u),l.value.close(1e3),l.value=null),n.value=!1},p=()=>{v(),l.value=new WebSocket(e.url),l.value.addEventListener("open",a),l.value.addEventListener("message",c),l.value.addEventListener("error",i),l.value.addEventListener("close",u),l.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||!l.value)throw new Error("Not connected to the server");l.value.send(e)}}},g=e=>{const n=t(!1),l=t(null),o=()=>{n.value=!0,c.resetConnectionAttempts()},s=()=>{console.warn("[EventSourceClient] Connection lost"),n.value=!1,c.scheduleReconnect()},a=n=>{e.onMessage(n.data)},u=()=>{l.value&&(c.stopReconnectTimer(),l.value.close(),l.value=null),n.value=!1},r=()=>{u(),l.value=new EventSource(e.url,{withCredentials:!0}),l.value.addEventListener("open",o),l.value.addEventListener("message",a),l.value.addEventListener("close",s)},c=f({onAttempt:r,onAttemptScheduled:e=>{console.log(`[EventSourceClient] Attempting to reconnect in ${e}ms`)}});return{isConnected:n,connect:r,disconnect:u,sendMessage:e=>{}}},e("t",i(a.PUSH,(()=>{const e=v(),n=s(),a=t([]),r=t(!1),i=t(!1),d=t([]),f=l((()=>"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:l}=window.location;return`${n.startsWith("http")?n.replace(/^http/,"ws"):`${"https:"===e?"wss":"ws"}://${l+n}`}${t}`}return`${n}${t}`})(),b=l((()=>f.value?p({url:h,onMessage:m}):g({url:h,onMessage:m})));function y(e){b.value.isConnected.value?b.value.sendMessage(JSON.stringify(e)):a.value.push(e)}const w=()=>c(u.CONNECTION.WEBSOCKET_DISCONNECT);let C=!1,E=null,S=null;return o((()=>b.value.isConnected.value),(e=>{if(e&&(i.value=!1),e&&a.value.length){for(const e of a.value)y(e);a.value=[]}})),{isConnected:l((()=>b.value.isConnected.value)),isConnecting:i,isConnectionRequested:r,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),r.value=!0,i.value=!0,b.value.connect()},pushDisconnect:()=>{C||(S&&clearTimeout(S),S=setTimeout((()=>{C||(r.value=!1,i.value=!1,b.value.disconnect()),S=null}),w()))},send:y,clearQueue:()=>{a.value=[]}}})))}}})); //# sourceMappingURL=pushConnection.store-legacy-CdZe0qqo.js.map