diff --git a/.breakpoints b/.breakpoints new file mode 100644 index 0000000..5cc232f --- /dev/null +++ b/.breakpoints @@ -0,0 +1,3 @@ +{ + "files": {} +} \ No newline at end of file diff --git a/ROADMAP.md b/ROADMAP.md index 23384cb..96ed771 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,32 +1,38 @@ # Roadmap + ### The end goal of this application is to provide a powerful application able to process and handle all of the your realtime QA data needs ## v0.0.1 + - [x] Initial Skeleton - [x] Frontend Drafts - [ ] Frontend Core - [ ] Frontend Pages ## v0.0.2 + - [ ] Database Queries (Req PG) - [ ] Database Tables (Req PG) - [ ] Backend Routes (Req Database) - [ ] Crons ## v0.0.3 + - [ ] Rabbitmq Consumers (Req Database) -- [ ] Alerting +- [ ] Alerting - [ ] Silencing ## v0.0.4 + - [ ] Auth ## v0.0.5 + - [ ] Docker config - [ ] Gitlab Integration - [ ] Garden config ## v0.0.6 + - [ ] Internal Tests - [ ] Self Test Suite - diff --git a/dev/query.js b/dev/query.js new file mode 100644 index 0000000..a61a873 --- /dev/null +++ b/dev/query.js @@ -0,0 +1,18 @@ +import { + insertQuery, + selectWhereAnyQuery, + updateWhereAnyQuery, +} from "../lib/database/pg-query.js"; +import { readFileSync } from "fs"; +var data = JSON.parse(readFileSync("lib/routes/mocks/results.json")); + +var table = "test_results"; +var queries = data.results.map((r) => insertQuery(table, r)); +queries.forEach((q) => console.log(q + ";")); + +console.log(); + +table = "test_catalog"; +data = JSON.parse(readFileSync("lib/routes/mocks/catalog.json")); +queries = data["tests:full"].map((r) => insertQuery(table, r)); +queries.forEach((q) => console.log(q + ";")); diff --git a/dist/bundles/qualiteer-executor.js b/dist/bundles/qualiteer-executor.js index 5082148..230a0c5 100644 --- a/dist/bundles/qualiteer-executor.js +++ b/dist/bundles/qualiteer-executor.js @@ -1,4 +1,265 @@ -"use strict";var e=require("fs"),t=require("url"),s=require("child_process"),r=require("http"),i=require("https"),n=require("stream"),o=require("zlib"),a=require("net"),h=require("tls"),c=require("crypto"),l=require("events");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function u(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(s){if("default"!==s&&!(s in e)){var r=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,r.get?r:{enumerable:!0,get:function(){return t[s]}})}}))})),Object.freeze(e)}var p=d(e),f=d(t),_=d(s),y=d(r),m=d(i),g=d(n),b=d(o),v=d(a),E=d(h),w=d(c),S=d(l);const k=Object.create(null);k.open="0",k.close="1",k.ping="2",k.pong="3",k.message="4",k.upgrade="5",k.noop="6";const x=Object.create(null);Object.keys(k).forEach((e=>{x[k[e]]=e}));const O={type:"error",data:"parser error"},T=({type:e,data:t},s,r)=>{if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)){const e=N(t);return r(R(e,s))}return r(k[e]+(t||""))},N=e=>Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):Buffer.from(e.buffer,e.byteOffset,e.byteLength),R=(e,t)=>t?e:"b"+e.toString("base64"),C=(e,t)=>{if("string"!=typeof e)return{type:"message",data:L(e,t)};const s=e.charAt(0);if("b"===s){const s=Buffer.from(e.substring(1),"base64");return{type:"message",data:L(s,t)}}return x[s]?e.length>1?{type:x[s],data:e.substring(1)}:{type:x[s]}:O},L=(e,t)=>{const s=Buffer.isBuffer(e);return"arraybuffer"===t&&s?A(e):e},A=e=>{const t=new ArrayBuffer(e.length),s=new Uint8Array(t);for(let t=0;t(e.hasOwnProperty(s)&&(t[s]=e[s]),t)),{})}const U=setTimeout,q=clearTimeout;function j(e,t){t.useNativeTimers?(e.setTimeoutFn=U.bind(I),e.clearTimeoutFn=q.bind(I)):(e.setTimeoutFn=setTimeout.bind(I),e.clearTimeoutFn=clearTimeout.bind(I))}class F extends Error{constructor(e,t,s){super(e),this.description=t,this.context=s,this.type="TransportError"}}class M extends P{constructor(e){super(),this.writable=!1,j(this,e),this.opts=e,this.query=e.query,this.readyState="",this.socket=e.socket}onError(e,t,s){return super.emitReserved("error",new F(e,t,s)),this}open(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=C(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}}const W="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),V={};let $,G=0,H=0;function z(e){let t="";do{t=W[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}function Y(){const e=z(+new Date);return e!==$?(G=0,$=e):e+"."+z(G++)}for(;H<64;H++)V[W[H]]=H;function K(e){let t="";for(let s in e)e.hasOwnProperty(s)&&(t.length&&(t+="&"),t+=encodeURIComponent(s)+"="+encodeURIComponent(e[s]));return t} +"use strict"; +var e = require("fs"), + t = require("url"), + s = require("child_process"), + r = require("http"), + i = require("https"), + n = require("stream"), + o = require("zlib"), + a = require("net"), + h = require("tls"), + c = require("crypto"), + l = require("events"); +function d(e) { + return e && "object" == typeof e && "default" in e ? e : { default: e }; +} +function u(e, t) { + return ( + t.forEach(function (t) { + t && + "string" != typeof t && + !Array.isArray(t) && + Object.keys(t).forEach(function (s) { + if ("default" !== s && !(s in e)) { + var r = Object.getOwnPropertyDescriptor(t, s); + Object.defineProperty( + e, + s, + r.get + ? r + : { + enumerable: !0, + get: function () { + return t[s]; + }, + } + ); + } + }); + }), + Object.freeze(e) + ); +} +var p = d(e), + f = d(t), + _ = d(s), + y = d(r), + m = d(i), + g = d(n), + b = d(o), + v = d(a), + E = d(h), + w = d(c), + S = d(l); +const k = Object.create(null); +(k.open = "0"), + (k.close = "1"), + (k.ping = "2"), + (k.pong = "3"), + (k.message = "4"), + (k.upgrade = "5"), + (k.noop = "6"); +const x = Object.create(null); +Object.keys(k).forEach((e) => { + x[k[e]] = e; +}); +const O = { type: "error", data: "parser error" }, + T = ({ type: e, data: t }, s, r) => { + if (t instanceof ArrayBuffer || ArrayBuffer.isView(t)) { + const e = N(t); + return r(R(e, s)); + } + return r(k[e] + (t || "")); + }, + N = (e) => + Buffer.isBuffer(e) + ? e + : e instanceof ArrayBuffer + ? Buffer.from(e) + : Buffer.from(e.buffer, e.byteOffset, e.byteLength), + R = (e, t) => (t ? e : "b" + e.toString("base64")), + C = (e, t) => { + if ("string" != typeof e) return { type: "message", data: L(e, t) }; + const s = e.charAt(0); + if ("b" === s) { + const s = Buffer.from(e.substring(1), "base64"); + return { type: "message", data: L(s, t) }; + } + return x[s] + ? e.length > 1 + ? { type: x[s], data: e.substring(1) } + : { type: x[s] } + : O; + }, + L = (e, t) => { + const s = Buffer.isBuffer(e); + return "arraybuffer" === t && s ? A(e) : e; + }, + A = (e) => { + const t = new ArrayBuffer(e.length), + s = new Uint8Array(t); + for (let t = 0; t < e.length; t++) s[t] = e[t]; + return t; + }, + B = String.fromCharCode(30); +function P(e) { + if (e) + return (function (e) { + for (var t in P.prototype) e[t] = P.prototype[t]; + return e; + })(e); +} +(P.prototype.on = P.prototype.addEventListener = + function (e, t) { + return ( + (this._callbacks = this._callbacks || {}), + (this._callbacks["$" + e] = this._callbacks["$" + e] || []).push(t), + this + ); + }), + (P.prototype.once = function (e, t) { + function s() { + this.off(e, s), t.apply(this, arguments); + } + return (s.fn = t), this.on(e, s), this; + }), + (P.prototype.off = + P.prototype.removeListener = + P.prototype.removeAllListeners = + P.prototype.removeEventListener = + function (e, t) { + if (((this._callbacks = this._callbacks || {}), 0 == arguments.length)) + return (this._callbacks = {}), this; + var s, + r = this._callbacks["$" + e]; + if (!r) return this; + if (1 == arguments.length) return delete this._callbacks["$" + e], this; + for (var i = 0; i < r.length; i++) + if ((s = r[i]) === t || s.fn === t) { + r.splice(i, 1); + break; + } + return 0 === r.length && delete this._callbacks["$" + e], this; + }), + (P.prototype.emit = function (e) { + this._callbacks = this._callbacks || {}; + for ( + var t = new Array(arguments.length - 1), + s = this._callbacks["$" + e], + r = 1; + r < arguments.length; + r++ + ) + t[r - 1] = arguments[r]; + if (s) { + r = 0; + for (var i = (s = s.slice(0)).length; r < i; ++r) s[r].apply(this, t); + } + return this; + }), + (P.prototype.emitReserved = P.prototype.emit), + (P.prototype.listeners = function (e) { + return ( + (this._callbacks = this._callbacks || {}), this._callbacks["$" + e] || [] + ); + }), + (P.prototype.hasListeners = function (e) { + return !!this.listeners(e).length; + }); +const I = global; +function D(e, ...t) { + return t.reduce((t, s) => (e.hasOwnProperty(s) && (t[s] = e[s]), t), {}); +} +const U = setTimeout, + q = clearTimeout; +function j(e, t) { + t.useNativeTimers + ? ((e.setTimeoutFn = U.bind(I)), (e.clearTimeoutFn = q.bind(I))) + : ((e.setTimeoutFn = setTimeout.bind(I)), + (e.clearTimeoutFn = clearTimeout.bind(I))); +} +class F extends Error { + constructor(e, t, s) { + super(e), + (this.description = t), + (this.context = s), + (this.type = "TransportError"); + } +} +class M extends P { + constructor(e) { + super(), + (this.writable = !1), + j(this, e), + (this.opts = e), + (this.query = e.query), + (this.readyState = ""), + (this.socket = e.socket); + } + onError(e, t, s) { + return super.emitReserved("error", new F(e, t, s)), this; + } + open() { + return ( + ("closed" !== this.readyState && "" !== this.readyState) || + ((this.readyState = "opening"), this.doOpen()), + this + ); + } + close() { + return ( + ("opening" !== this.readyState && "open" !== this.readyState) || + (this.doClose(), this.onClose()), + this + ); + } + send(e) { + "open" === this.readyState && this.write(e); + } + onOpen() { + (this.readyState = "open"), + (this.writable = !0), + super.emitReserved("open"); + } + onData(e) { + const t = C(e, this.socket.binaryType); + this.onPacket(t); + } + onPacket(e) { + super.emitReserved("packet", e); + } + onClose(e) { + (this.readyState = "closed"), super.emitReserved("close", e); + } +} +const W = + "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split( + "" + ), + V = {}; +let $, + G = 0, + H = 0; +function z(e) { + let t = ""; + do { + (t = W[e % 64] + t), (e = Math.floor(e / 64)); + } while (e > 0); + return t; +} +function Y() { + const e = z(+new Date()); + return e !== $ ? ((G = 0), ($ = e)) : e + "." + z(G++); +} +for (; H < 64; H++) V[W[H]] = H; +function K(e) { + let t = ""; + for (let s in e) + e.hasOwnProperty(s) && + (t.length && (t += "&"), + (t += encodeURIComponent(s) + "=" + encodeURIComponent(e[s]))); + return t; +} /** * Wrapper for built-in http.js to emulate the browser XMLHttpRequest object. * @@ -11,4 +272,3721 @@ * @contributor David Ellis * @license MIT */ -var X=p.default,J=f.default,Q=_.default.spawn,Z=ee;function ee(e){e=e||{};var t,s,r=this,i=y.default,n=m.default,o={},a=!1,h={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},c=Object.assign({},h),l=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","content-transfer-encoding","cookie","cookie2","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"],d=["TRACE","TRACK","CONNECT"],u=!1,p=!1,f=!1,_={};this.UNSENT=0,this.OPENED=1,this.HEADERS_RECEIVED=2,this.LOADING=3,this.DONE=4,this.readyState=this.UNSENT,this.onreadystatechange=null,this.responseText="",this.responseXML="",this.status=null,this.statusText=null;this.open=function(e,t,s,r,i){if(this.abort(),p=!1,f=!1,!function(e){return e&&-1===d.indexOf(e)}(e))throw new Error("SecurityError: Request method not allowed");o={method:e,url:t.toString(),async:"boolean"!=typeof s||s,user:r||null,password:i||null},g(this.OPENED)},this.setDisableHeaderCheck=function(e){a=e},this.setRequestHeader=function(e,t){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");if(!function(e){return a||e&&-1===l.indexOf(e.toLowerCase())}(e))return console.warn('Refused to set unsafe header "'+e+'"'),!1;if(u)throw new Error("INVALID_STATE_ERR: send flag is true");return c[e]=t,!0},this.getResponseHeader=function(e){return"string"==typeof e&&this.readyState>this.OPENED&&s.headers[e.toLowerCase()]&&!p?s.headers[e.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState{e.unref()})),a&&t.write(a),t.end(),r.dispatchEvent("loadstart")}else{var k=".node-xmlhttprequest-content-"+process.pid,x=".node-xmlhttprequest-sync-"+process.pid;X.writeFileSync(x,"","utf8");for(var O="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(l?"s":"")+".request;var options = "+JSON.stringify(v)+";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('"+k+"', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('"+x+"');});response.on('error', function(error) {fs.writeFileSync('"+k+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+x+"');});}).on('error', function(error) {fs.writeFileSync('"+k+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+x+"');});"+(a?"req.write('"+JSON.stringify(a).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",T=Q(process.argv[0],["-e",O]);X.existsSync(x););if(r.responseText=X.readFileSync(k,"utf8"),T.stdin.end(),X.unlinkSync(k),r.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var N=r.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,"");r.handleError(N,503)}else r.status=r.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1"),r.responseText=r.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"),g(r.DONE)}}},this.handleError=function(e,t){this.status=t||0,this.statusText=e,this.responseText=e.stack,p=!0,g(this.DONE)},this.abort=function(){t&&(t.abort(),t=null),c=Object.assign({},h),this.responseText="",this.responseXML="",p=f=!0,this.readyState===this.UNSENT||this.readyState===this.OPENED&&!u||this.readyState===this.DONE||(u=!1,g(this.DONE)),this.readyState=this.UNSENT},this.addEventListener=function(e,t){e in _||(_[e]=[]),_[e].push(t)},this.removeEventListener=function(e,t){e in _&&(_[e]=_[e].filter((function(e){return e!==t})))},this.dispatchEvent=function(e){if("function"==typeof r["on"+e]&&(this.readyState===this.DONE?setImmediate((function(){r["on"+e]()})):r["on"+e]()),e in _)for(let t=0,s=_[e].length;t{4===t.readyState&&(200===t.status||1223===t.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof t.status?t.status:0)}),0))},t.send(this.data)}catch(e){return void this.setTimeoutFn((()=>{this.onError(e)}),0)}"undefined"!=typeof document&&(this.index=ie.requestsCount++,ie.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=se,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete ie.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(ie.requestsCount=0,ie.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",ne);else if("function"==typeof addEventListener){addEventListener("onpagehide"in I?"pagehide":"unload",ne,!1)}function ne(){for(let e in ie.requests)ie.requests.hasOwnProperty(e)&&ie.requests[e].abort()}var oe={exports:{}},ae={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}};const{EMPTY_BUFFER:he}=ae;function ce(e,t){if(0===e.length)return he;if(1===e.length)return e[0];const s=Buffer.allocUnsafe(t);let r=0;for(let t=0;t{this.pending--,this[_e]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[_e]()}[_e](){if(this.pending!==this.concurrency&&this.jobs.length){const e=this.jobs.shift();this.pending++,e(this[fe])}}};const me=b.default,ge=oe.exports,be=ye,{kStatusCode:ve}=ae,Ee=Buffer.from([0,0,255,255]),we=Symbol("permessage-deflate"),Se=Symbol("total-length"),ke=Symbol("callback"),xe=Symbol("buffers"),Oe=Symbol("error");let Te;var Ne=class{constructor(e,t,s){if(this._maxPayload=0|s,this._options=e||{},this._threshold=void 0!==this._options.threshold?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!Te){const e=void 0!==this._options.concurrencyLimit?this._options.concurrencyLimit:10;Te=new be(e)}}static get extensionName(){return"permessage-deflate"}offer(){const e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:null==this._options.clientMaxWindowBits&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){const e=this._deflate[ke];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){const t=this._options,s=e.find((e=>!(!1===t.serverNoContextTakeover&&e.server_no_context_takeover||e.server_max_window_bits&&(!1===t.serverMaxWindowBits||"number"==typeof t.serverMaxWindowBits&&t.serverMaxWindowBits>e.server_max_window_bits)||"number"==typeof t.clientMaxWindowBits&&!e.client_max_window_bits)));if(!s)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(s.server_no_context_takeover=!0),t.clientNoContextTakeover&&(s.client_no_context_takeover=!0),"number"==typeof t.serverMaxWindowBits&&(s.server_max_window_bits=t.serverMaxWindowBits),"number"==typeof t.clientMaxWindowBits?s.client_max_window_bits=t.clientMaxWindowBits:!0!==s.client_max_window_bits&&!1!==t.clientMaxWindowBits||delete s.client_max_window_bits,s}acceptAsClient(e){const t=e[0];if(!1===this._options.clientNoContextTakeover&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(t.client_max_window_bits){if(!1===this._options.clientMaxWindowBits||"number"==typeof this._options.clientMaxWindowBits&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"')}else"number"==typeof this._options.clientMaxWindowBits&&(t.client_max_window_bits=this._options.clientMaxWindowBits);return t}normalizeParams(e){return e.forEach((e=>{Object.keys(e).forEach((t=>{let s=e[t];if(s.length>1)throw new Error(`Parameter "${t}" must have only a single value`);if(s=s[0],"client_max_window_bits"===t){if(!0!==s){const e=+s;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}else if("server_max_window_bits"===t){const e=+s;if(!Number.isInteger(e)||e<8||e>15)throw new TypeError(`Invalid value for parameter "${t}": ${s}`);s=e}else{if("client_no_context_takeover"!==t&&"server_no_context_takeover"!==t)throw new Error(`Unknown parameter "${t}"`);if(!0!==s)throw new TypeError(`Invalid value for parameter "${t}": ${s}`)}e[t]=s}))})),e}decompress(e,t,s){Te.add((r=>{this._decompress(e,t,((e,t)=>{r(),s(e,t)}))}))}compress(e,t,s){Te.add((r=>{this._compress(e,t,((e,t)=>{r(),s(e,t)}))}))}_decompress(e,t,s){const r=this._isServer?"client":"server";if(!this._inflate){const e=`${r}_max_window_bits`,t="number"!=typeof this.params[e]?me.Z_DEFAULT_WINDOWBITS:this.params[e];this._inflate=me.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[we]=this,this._inflate[Se]=0,this._inflate[xe]=[],this._inflate.on("error",Le),this._inflate.on("data",Ce)}this._inflate[ke]=s,this._inflate.write(e),t&&this._inflate.write(Ee),this._inflate.flush((()=>{const e=this._inflate[Oe];if(e)return this._inflate.close(),this._inflate=null,void s(e);const i=ge.concat(this._inflate[xe],this._inflate[Se]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Se]=0,this._inflate[xe]=[],t&&this.params[`${r}_no_context_takeover`]&&this._inflate.reset()),s(null,i)}))}_compress(e,t,s){const r=this._isServer?"server":"client";if(!this._deflate){const e=`${r}_max_window_bits`,t="number"!=typeof this.params[e]?me.Z_DEFAULT_WINDOWBITS:this.params[e];this._deflate=me.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:t}),this._deflate[Se]=0,this._deflate[xe]=[],this._deflate.on("data",Re)}this._deflate[ke]=s,this._deflate.write(e),this._deflate.flush(me.Z_SYNC_FLUSH,(()=>{if(!this._deflate)return;let e=ge.concat(this._deflate[xe],this._deflate[Se]);t&&(e=e.slice(0,e.length-4)),this._deflate[ke]=null,this._deflate[Se]=0,this._deflate[xe]=[],t&&this.params[`${r}_no_context_takeover`]&&this._deflate.reset(),s(null,e)}))}};function Re(e){this[xe].push(e),this[Se]+=e.length}function Ce(e){this[Se]+=e.length,this[we]._maxPayload<1||this[Se]<=this[we]._maxPayload?this[xe].push(e):(this[Oe]=new RangeError("Max payload size exceeded"),this[Oe].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Oe][ve]=1009,this.removeListener("data",Ce),this.reset())}function Le(e){this[we]._inflate=null,e[ve]=1007,this[ke](e)}var Ae={exports:{}};const Be=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function Pe(e){return e>=1e3&&e<=1014&&1004!==e&&1005!==e&&1006!==e||e>=3e3&&e<=4999}function Ie(e){const t=e.length;let s=0;for(;s=t||128!=(192&e[s+1])||128!=(192&e[s+2])||224===e[s]&&128==(224&e[s+1])||237===e[s]&&160==(224&e[s+1]))return!1;s+=3}else{if(240!=(248&e[s]))return!1;if(s+3>=t||128!=(192&e[s+1])||128!=(192&e[s+2])||128!=(192&e[s+3])||240===e[s]&&128==(240&e[s+1])||244===e[s]&&e[s+1]>143||e[s]>244)return!1;s+=4}return!0}try{const e=require("utf-8-validate");Ae.exports={isValidStatusCode:Pe,isValidUTF8:t=>t.length<150?Ie(t):e(t),tokenChars:Be}}catch(e){Ae.exports={isValidStatusCode:Pe,isValidUTF8:Ie,tokenChars:Be}}const{Writable:De}=g.default,Ue=Ne,{BINARY_TYPES:qe,EMPTY_BUFFER:je,kStatusCode:Fe,kWebSocket:Me}=ae,{concat:We,toArrayBuffer:Ve,unmask:$e}=oe.exports,{isValidStatusCode:Ge,isValidUTF8:He}=Ae.exports;var ze=class extends De{constructor(e={}){super(),this._binaryType=e.binaryType||qe[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=0|e.maxPayload,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Me]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._state=0,this._loop=!1}_write(e,t,s){if(8===this._opcode&&0==this._state)return s();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(s)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e=s.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(s.buffer,s.byteOffset,e),r),this._buffers[0]=s.slice(e)),e-=s.length}while(e>0);return t}startLoop(e){let t;this._loop=!0;do{switch(this._state){case 0:t=this.getInfo();break;case 1:t=this.getPayloadLength16();break;case 2:t=this.getPayloadLength64();break;case 3:this.getMask();break;case 4:t=this.getData(e);break;default:return void(this._loop=!1)}}while(this._loop);e(t)}getInfo(){if(this._bufferedBytes<2)return void(this._loop=!1);const e=this.consume(2);if(0!=(48&e[0]))return this._loop=!1,Ye(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");const t=64==(64&e[0]);if(t&&!this._extensions[Ue.extensionName])return this._loop=!1,Ye(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._fin=128==(128&e[0]),this._opcode=15&e[0],this._payloadLength=127&e[1],0===this._opcode){if(t)return this._loop=!1,Ye(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,Ye(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");this._opcode=this._fragmented}else if(1===this._opcode||2===this._opcode){if(this._fragmented)return this._loop=!1,Ye(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");this._compressed=t}else{if(!(this._opcode>7&&this._opcode<11))return this._loop=!1,Ye(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");if(!this._fin)return this._loop=!1,Ye(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(t)return this._loop=!1,Ye(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,Ye(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}if(this._fin||this._fragmented||(this._fragmented=this._opcode),this._masked=128==(128&e[1]),this._isServer){if(!this._masked)return this._loop=!1,Ye(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,Ye(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(126===this._payloadLength)this._state=1;else{if(127!==this._payloadLength)return this.haveLength();this._state=2}}getPayloadLength16(){if(!(this._bufferedBytes<2))return this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength();this._loop=!1}getPayloadLength64(){if(this._bufferedBytes<8)return void(this._loop=!1);const e=this.consume(8),t=e.readUInt32BE(0);return t>Math.pow(2,21)-1?(this._loop=!1,Ye(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=t*Math.pow(2,32)+e.readUInt32BE(4),this.haveLength())}haveLength(){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0))return this._loop=!1,Ye(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=3:this._state=4}getMask(){this._bufferedBytes<4?this._loop=!1:(this._mask=this.consume(4),this._state=4)}getData(e){let t=je;if(this._payloadLength){if(this._bufferedBytes7?this.controlMessage(t):this._compressed?(this._state=5,void this.decompress(t,e)):(t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage())}decompress(e,t){this._extensions[Ue.extensionName].decompress(e,this._fin,((e,s)=>{if(e)return t(e);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return t(Ye(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(s)}const r=this.dataMessage();if(r)return t(r);this.startLoop(t)}))}dataMessage(){if(this._fin){const e=this._messageLength,t=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],2===this._opcode){let s;s="nodebuffer"===this._binaryType?We(t,e):"arraybuffer"===this._binaryType?Ve(We(t,e)):t,this.emit("message",s,!0)}else{const s=We(t,e);if(!this._skipUTF8Validation&&!He(s))return this._loop=!1,Ye(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",s,!1)}}this._state=0}controlMessage(e){if(8===this._opcode)if(this._loop=!1,0===e.length)this.emit("conclude",1005,je),this.end();else{if(1===e.length)return Ye(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{const t=e.readUInt16BE(0);if(!Ge(t))return Ye(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");const s=e.slice(2);if(!this._skipUTF8Validation&&!He(s))return Ye(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("conclude",t,s),this.end()}}else 9===this._opcode?this.emit("ping",e):this.emit("pong",e);this._state=0}};function Ye(e,t,s,r,i){const n=new e(s?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(n,Ye),n.code=i,n[Fe]=r,n}const{randomFillSync:Ke}=w.default,Xe=Ne,{EMPTY_BUFFER:Je}=ae,{isValidStatusCode:Qe}=Ae.exports,{mask:Ze,toBuffer:et}=oe.exports,tt=Buffer.alloc(4);class st{constructor(e,t){this._extensions=t||{},this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(e,t){const s=t.mask&&t.readOnly;let r=t.mask?6:2,i=e.length;e.length>=65536?(r+=8,i=127):e.length>125&&(r+=2,i=126);const n=Buffer.allocUnsafe(s?e.length+r:r);return n[0]=t.fin?128|t.opcode:t.opcode,t.rsv1&&(n[0]|=64),n[1]=i,126===i?n.writeUInt16BE(e.length,2):127===i&&(n.writeUInt32BE(0,2),n.writeUInt32BE(e.length,6)),t.mask?(Ke(tt,0,4),n[1]|=128,n[r-4]=tt[0],n[r-3]=tt[1],n[r-2]=tt[2],n[r-1]=tt[3],s?(Ze(e,tt,n,r,e.length),[n]):(Ze(e,tt,e,0,e.length),[n,e])):[n,e]}close(e,t,s,r){let i;if(void 0===e)i=Je;else{if("number"!=typeof e||!Qe(e))throw new TypeError("First argument must be a valid error code number");if(void 0!==t&&t.length){const s=Buffer.byteLength(t);if(s>123)throw new RangeError("The message must not be greater than 123 bytes");i=Buffer.allocUnsafe(2+s),i.writeUInt16BE(e,0),"string"==typeof t?i.write(t,2):i.set(t,2)}else i=Buffer.allocUnsafe(2),i.writeUInt16BE(e,0)}this._deflating?this.enqueue([this.doClose,i,s,r]):this.doClose(i,s,r)}doClose(e,t,s){this.sendFrame(st.frame(e,{fin:!0,rsv1:!1,opcode:8,mask:t,readOnly:!1}),s)}ping(e,t,s){const r=et(e);if(r.length>125)throw new RangeError("The data size must not be greater than 125 bytes");this._deflating?this.enqueue([this.doPing,r,t,et.readOnly,s]):this.doPing(r,t,et.readOnly,s)}doPing(e,t,s,r){this.sendFrame(st.frame(e,{fin:!0,rsv1:!1,opcode:9,mask:t,readOnly:s}),r)}pong(e,t,s){const r=et(e);if(r.length>125)throw new RangeError("The data size must not be greater than 125 bytes");this._deflating?this.enqueue([this.doPong,r,t,et.readOnly,s]):this.doPong(r,t,et.readOnly,s)}doPong(e,t,s,r){this.sendFrame(st.frame(e,{fin:!0,rsv1:!1,opcode:10,mask:t,readOnly:s}),r)}send(e,t,s){const r=et(e),i=this._extensions[Xe.extensionName];let n=t.binary?2:1,o=t.compress;if(this._firstFragment?(this._firstFragment=!1,o&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=r.length>=i._threshold),this._compress=o):(o=!1,n=0),t.fin&&(this._firstFragment=!0),i){const e={fin:t.fin,rsv1:o,opcode:n,mask:t.mask,readOnly:et.readOnly};this._deflating?this.enqueue([this.dispatch,r,this._compress,e,s]):this.dispatch(r,this._compress,e,s)}else this.sendFrame(st.frame(r,{fin:t.fin,rsv1:!1,opcode:n,mask:t.mask,readOnly:et.readOnly}),s)}dispatch(e,t,s,r){if(!t)return void this.sendFrame(st.frame(e,s),r);const i=this._extensions[Xe.extensionName];this._bufferedBytes+=e.length,this._deflating=!0,i.compress(e,s.fin,((t,i)=>{if(this._socket.destroyed){const e=new Error("The socket was closed while data was being compressed");"function"==typeof r&&r(e);for(let t=0;t{let s=e[t];return Array.isArray(s)||(s=[s]),s.map((e=>[t].concat(Object.keys(e).map((t=>{let s=e[t];return Array.isArray(s)||(s=[s]),s.map((e=>!0===e?t:`${t}=${e}`)).join("; ")}))).join("; "))).join(", ")})).join(", ")},parse:function(e){const t=Object.create(null);let s,r,i=Object.create(null),n=!1,o=!1,a=!1,h=-1,c=-1,l=-1,d=0;for(;d0&&e.unshift(t),e.on("close",ls),e.on("data",ds),e.on("end",us),e.on("error",ps),this._readyState=Xt.OPEN,this.emit("open")}emitClose(){if(!this._socket)return this._readyState=Xt.CLOSED,void this.emit("close",this._closeCode,this._closeMessage);this._extensions[Lt.extensionName]&&this._extensions[Lt.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=Xt.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==Xt.CLOSED){if(this.readyState===Xt.CONNECTING){const e="WebSocket was closed before the connection was established";return es(this,this._req,e)}this.readyState!==Xt.CLOSING?(this._readyState=Xt.CLOSING,this._sender.close(e,t,!this._isServer,(e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())})),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),3e4)):this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end()}}ping(e,t,s){if(this.readyState===Xt.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===Xt.OPEN?(void 0===t&&(t=!this._isServer),this._sender.ping(e||It,t,s)):ts(this,e,s)}pong(e,t,s){if(this.readyState===Xt.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"function"==typeof e?(s=e,e=t=void 0):"function"==typeof t&&(s=t,t=void 0),"number"==typeof e&&(e=e.toString()),this.readyState===Xt.OPEN?(void 0===t&&(t=!this._isServer),this._sender.pong(e||It,t,s)):ts(this,e,s)}send(e,t,s){if(this.readyState===Xt.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if("function"==typeof t&&(s=t,t={}),"number"==typeof e&&(e=e.toString()),this.readyState!==Xt.OPEN)return void ts(this,e,s);const r={binary:"string"!=typeof e,mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[Lt.extensionName]||(r.compress=!1),this._sender.send(e||It,r,s)}terminate(){if(this.readyState!==Xt.CLOSED){if(this.readyState===Xt.CONNECTING){const e="WebSocket was closed before the connection was established";return es(this,this._req,e)}this._socket&&(this._readyState=Xt.CLOSING,this._socket.destroy())}}}function Jt(e,t,s,r){const i={protocolVersion:Kt[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,createConnection:void 0,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:void 0,host:void 0,path:void 0,port:void 0};if(!Kt.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${Kt.join(", ")})`);let n;if(t instanceof Ct)n=t,e._url=t.href;else{try{n=new Ct(t)}catch(e){throw new SyntaxError(`Invalid URL: ${t}`)}e._url=t}const o="wss:"===n.protocol,a="ws+unix:"===n.protocol;if("ws:"!==n.protocol&&!o&&!a)throw new SyntaxError('The URL\'s protocol must be one of "ws:", "wss:", or "ws+unix:"');if(a&&!n.pathname)throw new SyntaxError("The URL's pathname is empty");if(n.hash)throw new SyntaxError("The URL contains a fragment identifier");const h=o?443:80,c=Nt(16).toString("base64"),l=o?kt.get:xt.get,d=new Set;let u;if(i.createConnection=o?Zt:Qt,i.defaultPort=i.defaultPort||h,i.port=n.port||h,i.host=n.hostname.startsWith("[")?n.hostname.slice(1,-1):n.hostname,i.headers={"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":c,Connection:"Upgrade",Upgrade:"websocket",...i.headers},i.path=n.pathname+n.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(u=new Lt(!0!==i.perMessageDeflate?i.perMessageDeflate:{},!1,i.maxPayload),i.headers["Sec-WebSocket-Extensions"]=$t({[Lt.extensionName]:u.offer()})),s.length){for(const e of s){if("string"!=typeof e||!Yt.test(e)||d.has(e))throw new SyntaxError("An invalid or duplicated subprotocol was specified");d.add(e)}i.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(n.username||n.password)&&(i.auth=`${n.username}:${n.password}`),a){const e=i.path.split(":");i.socketPath=e[0],i.path=e[1]}let p=e._req=l(i);i.timeout&&p.on("timeout",(()=>{es(e,p,"Opening handshake has timed out")})),p.on("error",(t=>{null===p||p.aborted||(p=e._req=null,e._readyState=Xt.CLOSING,e.emit("error",t),e.emitClose())})),p.on("response",(n=>{const o=n.headers.location,a=n.statusCode;if(o&&i.followRedirects&&a>=300&&a<400){if(++e._redirects>i.maxRedirects)return void es(e,p,"Maximum redirects exceeded");p.abort();const n=new Ct(o,t);Jt(e,n,s,r)}else e.emit("unexpected-response",p,n)||es(e,p,`Unexpected server response: ${n.statusCode}`)})),p.on("upgrade",((t,s,r)=>{if(e.emit("upgrade",t),e.readyState!==Xt.CONNECTING)return;p=e._req=null;const n=Rt("sha1").update(c+Dt).digest("base64");if(t.headers["sec-websocket-accept"]!==n)return void es(e,s,"Invalid Sec-WebSocket-Accept header");const o=t.headers["sec-websocket-protocol"];let a;if(void 0!==o?d.size?d.has(o)||(a="Server sent an invalid subprotocol"):a="Server sent a subprotocol but none was requested":d.size&&(a="Server sent no subprotocol"),a)return void es(e,s,a);o&&(e._protocol=o);const h=t.headers["sec-websocket-extensions"];if(void 0!==h){if(!u){return void es(e,s,"Server sent a Sec-WebSocket-Extensions header but no extension was requested")}let t;try{t=Gt(h)}catch(t){return void es(e,s,"Invalid Sec-WebSocket-Extensions header")}const r=Object.keys(t);if(1!==r.length||r[0]!==Lt.extensionName){return void es(e,s,"Server indicated an extension that was not requested")}try{u.accept(t[Lt.extensionName])}catch(t){return void es(e,s,"Invalid Sec-WebSocket-Extensions header")}e._extensions[Lt.extensionName]=u}e.setSocket(s,r,{maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}))}function Qt(e){return e.path=e.socketPath,Ot.connect(e)}function Zt(e){return e.path=void 0,e.servername||""===e.servername||(e.servername=Ot.isIP(e.host)?"":e.host),Tt.connect(e)}function es(e,t,s){e._readyState=Xt.CLOSING;const r=new Error(s);Error.captureStackTrace(r,es),t.setHeader?(t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),t.once("abort",e.emitClose.bind(e)),e.emit("error",r)):(t.destroy(r),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function ts(e,t,s){if(t){const s=Ht(t).length;e._socket?e._sender._bufferedBytes+=s:e._bufferedAmount+=s}if(s){s(new Error(`WebSocket is not open: readyState ${e.readyState} (${zt[e.readyState]})`))}}function ss(e,t){const s=this[Ft];s._closeFrameReceived=!0,s._closeMessage=t,s._closeCode=e,void 0!==s._socket[Ft]&&(s._socket.removeListener("data",ds),process.nextTick(cs,s._socket),1005===e?s.close():s.close(e,t))}function rs(){this[Ft]._socket.resume()}function is(e){const t=this[Ft];void 0!==t._socket[Ft]&&(t._socket.removeListener("data",ds),process.nextTick(cs,t._socket),t.close(e[jt])),t.emit("error",e)}function ns(){this[Ft].emitClose()}function os(e,t){this[Ft].emit("message",e,t)}function as(e){const t=this[Ft];t.pong(e,!t._isServer,Mt),t.emit("ping",e)}function hs(e){this[Ft].emit("pong",e)}function cs(e){e.resume()}function ls(){const e=this[Ft];let t;this.removeListener("close",ls),this.removeListener("data",ds),this.removeListener("end",us),e._readyState=Xt.CLOSING,this._readableState.endEmitted||e._closeFrameReceived||e._receiver._writableState.errorEmitted||null===(t=e._socket.read())||e._receiver.write(t),e._receiver.end(),this[Ft]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",ns),e._receiver.on("finish",ns))}function ds(e){this[Ft]._receiver.write(e)||this.pause()}function us(){const e=this[Ft];e._readyState=Xt.CLOSING,e._receiver.end(),this.end()}function ps(){const e=this[Ft];this.removeListener("error",ps),this.on("error",Mt),e&&(e._readyState=Xt.CLOSING,this.destroy())}Object.defineProperty(Xt,"CONNECTING",{enumerable:!0,value:zt.indexOf("CONNECTING")}),Object.defineProperty(Xt.prototype,"CONNECTING",{enumerable:!0,value:zt.indexOf("CONNECTING")}),Object.defineProperty(Xt,"OPEN",{enumerable:!0,value:zt.indexOf("OPEN")}),Object.defineProperty(Xt.prototype,"OPEN",{enumerable:!0,value:zt.indexOf("OPEN")}),Object.defineProperty(Xt,"CLOSING",{enumerable:!0,value:zt.indexOf("CLOSING")}),Object.defineProperty(Xt.prototype,"CLOSING",{enumerable:!0,value:zt.indexOf("CLOSING")}),Object.defineProperty(Xt,"CLOSED",{enumerable:!0,value:zt.indexOf("CLOSED")}),Object.defineProperty(Xt.prototype,"CLOSED",{enumerable:!0,value:zt.indexOf("CLOSED")}),["binaryType","bufferedAmount","extensions","protocol","readyState","url"].forEach((e=>{Object.defineProperty(Xt.prototype,e,{enumerable:!0})})),["open","error","close","message"].forEach((e=>{Object.defineProperty(Xt.prototype,`on${e}`,{enumerable:!0,get(){for(const t of this.listeners(e))if(t[Ut])return t[qt];return null},set(t){for(const t of this.listeners(e))if(t[Ut]){this.removeListener(e,t);break}"function"==typeof t&&this.addEventListener(e,t,{[Ut]:!0})}})})),Xt.prototype.addEventListener=Wt,Xt.prototype.removeEventListener=Vt;const fs=Xt,_s=process.nextTick,ys="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();const ms={websocket:class extends M{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,s=ys?{}:D(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=new fs(e,t,s)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType||"nodebuffer",this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t{const t={};if(s.options&&(t.compress=s.options.compress),this.opts.perMessageDeflate){("string"==typeof e?Buffer.byteLength(e):e.length){this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){let e=this.query||{};const t=this.opts.secure?"wss":"ws";let s="";this.opts.port&&("wss"===t&&443!==Number(this.opts.port)||"ws"===t&&80!==Number(this.opts.port))&&(s=":"+this.opts.port),this.opts.timestampRequests&&(e[this.opts.timestampParam]=Y()),this.supportsBinary||(e.b64=1);const r=K(e);return t+"://"+(-1!==this.opts.hostname.indexOf(":")?"["+this.opts.hostname+"]":this.opts.hostname)+s+this.opts.path+(r.length?"?"+r:"")}check(){return!!fs}},polling:class extends M{constructor(e){if(super(e),this.polling=!1,"undefined"!=typeof location){const t="https:"===location.protocol;let s=location.port;s||(s=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||s!==e.port,this.xs=e.secure!==t}const t=e&&e.forceBase64;this.supportsBinary=re&&!t}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let e=0;this.polling&&(e++,this.once("pollComplete",(function(){--e||t()}))),this.writable||(e++,this.once("drain",(function(){--e||t()})))}else t()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){((e,t)=>{const s=e.split(B),r=[];for(let e=0;e{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}write(e){this.writable=!1,((e,t)=>{const s=e.length,r=new Array(s);let i=0;e.forEach(((e,n)=>{T(e,!1,(e=>{r[n]=e,++i===s&&t(r.join(B))}))}))})(e,(e=>{this.doWrite(e,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){let e=this.query||{};const t=this.opts.secure?"https":"http";let s="";!1!==this.opts.timestampRequests&&(e[this.opts.timestampParam]=Y()),this.supportsBinary||e.sid||(e.b64=1),this.opts.port&&("https"===t&&443!==Number(this.opts.port)||"http"===t&&80!==Number(this.opts.port))&&(s=":"+this.opts.port);const r=K(e);return t+"://"+(-1!==this.opts.hostname.indexOf(":")?"["+this.opts.hostname+"]":this.opts.hostname)+s+this.opts.path+(r.length?"?"+r:"")}request(e={}){return Object.assign(e,{xd:this.xd,xs:this.xs},this.opts),new ie(this.uri(),e)}doWrite(e,t){const s=this.request({method:"POST",data:e});s.on("success",t),s.on("error",((e,t)=>{this.onError("xhr post error",e,t)}))}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",((e,t)=>{this.onError("xhr poll error",e,t)})),this.pollXhr=e}}},gs=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,bs=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function vs(e){const t=e,s=e.indexOf("["),r=e.indexOf("]");-1!=s&&-1!=r&&(e=e.substring(0,s)+e.substring(s,r).replace(/:/g,";")+e.substring(r,e.length));let i=gs.exec(e||""),n={},o=14;for(;o--;)n[bs[o]]=i[o]||"";return-1!=s&&-1!=r&&(n.source=t,n.host=n.host.substring(1,n.host.length-1).replace(/;/g,":"),n.authority=n.authority.replace("[","").replace("]","").replace(/;/g,":"),n.ipv6uri=!0),n.pathNames=function(e,t){const s=/\/{2,9}/g,r=t.replace(s,"/").split("/");"/"!=t.substr(0,1)&&0!==t.length||r.splice(0,1);"/"==t.substr(t.length-1,1)&&r.splice(r.length-1,1);return r}(0,n.path),n.queryKey=function(e,t){const s={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,r){t&&(s[t]=r)})),s}(0,n.query),n}class Es extends P{constructor(e,t={}){super(),e&&"object"==typeof e&&(t=e,e=null),e?(e=vs(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=vs(t.host).host),j(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket"],this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},t),this.opts.path=this.opts.path.replace(/\/$/,"")+"/","string"==typeof this.opts.query&&(this.opts.query=function(e){let t={},s=e.split("&");for(let e=0,r=s.length;e{this.transport&&(this.transport.removeAllListeners(),this.transport.close())}),!1),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);const s=Object.assign({},this.opts.transportOptions[e],this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return new ms[e](s)}open(){let e;if(this.opts.rememberUpgrade&&Es.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(e=>this.onClose("transport close",e)))}probe(e){let t=this.createTransport(e),s=!1;Es.priorWebsocketSuccess=!1;const r=()=>{s||(t.send([{type:"ping",data:"probe"}]),t.once("packet",(e=>{if(!s)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;Es.priorWebsocketSuccess="websocket"===t.name,this.transport.pause((()=>{s||"closed"!==this.readyState&&(c(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())}))}else{const e=new Error("probe error");e.transport=t.name,this.emitReserved("upgradeError",e)}})))};function i(){s||(s=!0,c(),t.close(),t=null)}const n=e=>{const s=new Error("probe error: "+e);s.transport=t.name,i(),this.emitReserved("upgradeError",s)};function o(){n("transport closed")}function a(){n("socket closed")}function h(e){t&&e.name!==t.name&&i()}const c=()=>{t.removeListener("open",r),t.removeListener("error",n),t.removeListener("close",o),this.off("close",a),this.off("upgrading",h)};t.once("open",r),t.once("error",n),t.once("close",o),this.once("close",a),this.once("upgrading",h),t.open()}onOpen(){if(this.readyState="open",Es.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade&&this.transport.pause){let e=0;const t=this.upgrades.length;for(;e{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let s=0;s=57344?s+=3:(r++,s+=4);return s}(t):Math.ceil(1.33*(t.byteLength||t.size))),s>0&&e>this.maxPayload)return this.writeBuffer.slice(0,s);e+=2}var t;return this.writeBuffer}write(e,t,s){return this.sendPacket("message",e,t,s),this}send(e,t,s){return this.sendPacket("message",e,t,s),this}sendPacket(e,t,s,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof s&&(r=s,s=null),"closing"===this.readyState||"closed"===this.readyState)return;(s=s||{}).compress=!1!==s.compress;const i={type:e,data:t,options:s};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},s=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?s():e()})):this.upgrading?s():e()),this}onError(e){Es.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&removeEventListener("offline",this.offlineEventListener,!1),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let s=0;const r=e.length;for(;s"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||ks&&e instanceof Blob||xs&&e instanceof File}function Ts(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,s=e.length;t0;case As.ACK:case As.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&this.reconstructor.finishedReconstruction()}}class Ps{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=Cs(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}var Is=Object.freeze({__proto__:null,protocol:5,get PacketType(){return As},Encoder:class{constructor(e){this.replacer=e}encode(e){return e.type!==As.EVENT&&e.type!==As.ACK||!Ts(e)?[this.encodeAsString(e)]:(e.type=e.type===As.EVENT?As.BINARY_EVENT:As.BINARY_ACK,this.encodeAsBinary(e))}encodeAsString(e){let t=""+e.type;return e.type!==As.BINARY_EVENT&&e.type!==As.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=Ns(e),s=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(s),r}},Decoder:Bs});function Ds(e,t,s){return e.on(t,s),function(){e.off(t,s)}}const Us=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class qs extends P{constructor(e,t,s){super(),this.connected=!1,this.receiveBuffer=[],this.sendBuffer=[],this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,s&&s.auth&&(this.auth=s.auth),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Ds(e,"open",this.onopen.bind(this)),Ds(e,"packet",this.onpacket.bind(this)),Ds(e,"error",this.onerror.bind(this)),Ds(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(Us.hasOwnProperty(e))throw new Error('"'+e+'" is a reserved event name');t.unshift(e);const s={type:As.EVENT,data:t,options:{}};if(s.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++,r=t.pop();this._registerAckCallback(e,r),s.id=e}const r=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!r||!this.connected)||(this.connected?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),this.flags={},this}_registerAckCallback(e,t){const s=this.flags.timeout;if(void 0===s)return void(this.acks[e]=t);const r=this.io.setTimeoutFn((()=>{delete this.acks[e];for(let t=0;t{this.io.clearTimeoutFn(r),t.apply(this,[null,...e])}}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){"function"==typeof this.auth?this.auth((e=>{this.packet({type:As.CONNECT,data:e})})):this.packet({type:As.CONNECT,data:this.auth})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case As.CONNECT:if(e.data&&e.data.sid){const t=e.data.sid;this.onconnect(t)}else this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case As.EVENT:case As.BINARY_EVENT:this.onevent(e);break;case As.ACK:case As.BINARY_ACK:this.onack(e);break;case As.DISCONNECT:this.ondisconnect();break;case As.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const s of t)s.apply(this,e)}super.emit.apply(this,e)}ack(e){const t=this;let s=!1;return function(...r){s||(s=!0,t.packet({type:As.ACK,id:e,data:r}))}}onack(e){const t=this.acks[e.id];"function"==typeof t&&(t.apply(this,e.data),delete this.acks[e.id])}onconnect(e){this.id=e,this.connected=!0,this.emitBuffered(),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach((e=>this.emitEvent(e))),this.receiveBuffer=[],this.sendBuffer.forEach((e=>{this.notifyOutgoingListeners(e),this.packet(e)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((e=>e())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:As.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let s=0;s0&&e.jitter<=1?e.jitter:0,this.attempts=0}js.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),s=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-s:e+s}return 0|Math.min(e,this.max)},js.prototype.reset=function(){this.attempts=0},js.prototype.setMin=function(e){this.ms=e},js.prototype.setMax=function(e){this.max=e},js.prototype.setJitter=function(e){this.jitter=e};class Fs extends P{constructor(e,t){var s;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,j(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(s=t.randomizationFactor)&&void 0!==s?s:.5),this.backoff=new js({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const r=t.parser||Is;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new Es(this.uri,this.opts);const t=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const r=Ds(t,"open",(function(){s.onopen(),e&&e()})),i=Ds(t,"error",(t=>{s.cleanup(),s._readyState="closed",this.emitReserved("error",t),e?e(t):s.maybeReconnectOnOpen()}));if(!1!==this._timeout){const e=this._timeout;0===e&&r();const s=this.setTimeoutFn((()=>{r(),t.close(),t.emit("error",new Error("timeout"))}),e);this.opts.autoUnref&&s.unref(),this.subs.push((function(){clearTimeout(s)}))}return this.subs.push(r),this.subs.push(i),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Ds(e,"ping",this.onping.bind(this)),Ds(e,"data",this.ondata.bind(this)),Ds(e,"error",this.onerror.bind(this)),Ds(e,"close",this.onclose.bind(this)),Ds(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){this.decoder.add(e)}ondecoded(e){this.emitReserved("packet",e)}onerror(e){this.emitReserved("error",e)}socket(e,t){let s=this.nsps[e];return s||(s=new qs(this,e,t),this.nsps[e]=s),s}_destroy(e){const t=Object.keys(this.nsps);for(const e of t){if(this.nsps[e].active)return}this._close()}_packet(e){const t=this.encoder.encode(e);for(let s=0;se())),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn((()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open((t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):e.onreconnect()})))}),t);this.opts.autoUnref&&s.unref(),this.subs.push((function(){clearTimeout(s)}))}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const Ms={};function Ws(e,t){"object"==typeof e&&(t=e,e=void 0);const s=function(e,t="",s){let r=e;s=s||"undefined"!=typeof location&&location,null==e&&(e=s.protocol+"//"+s.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?s.protocol+e:s.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==s?s.protocol+"//"+e:"https://"+e),r=vs(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const i=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+t,r.href=r.protocol+"://"+i+(s&&s.port===r.port?"":":"+r.port),r}(e,(t=t||{}).path||"/socket.io"),r=s.source,i=s.id,n=s.path,o=Ms[i]&&n in Ms[i].nsps;let a;return t.forceNew||t["force new connection"]||!1===t.multiplex||o?a=new Fs(r,t):(Ms[i]||(Ms[i]=new Fs(r,t)),a=Ms[i]),s.query&&!t.query&&(t.query=s.queryKey),a.socket(s.path,t)}Object.assign(Ws,{Manager:Fs,Socket:qs,io:Ws,connect:Ws});var Vs="e";var $s="jr",Gs="jc";const Hs=process.argv.slice(2),zs=Hs[0],Ys=Hs[1],Ks=Hs.slice(2),Xs={id:Ys,command:Ks},Js=new class{constructor(e,t,s={}){this.url=e,this.job=t,this.mode=Vs,this.buf={},this.buf.e="",this.buf.o="",this.spawn=s.spawn??this.spawn.bind(this),this.report=s.report??this.report.bind(this),this.onProcClose=s.onProcClose??this.onProcClose.bind(this),this.onClose=s.onClose??this.onClose.bind(this)}spawn(){const e=this.job.command,t=e.shift();this.proc=_.default.spawn(t,e),this.proc.stdout.setEncoding("utf8"),this.proc.stderr.setEncoding("utf8"),this.proc.stdout.on("data",(e=>this.report(e.toString(),"o"))),this.proc.stderr.on("data",(e=>this.report(e.toString(),"e"))),this.proc.on("close",this.onProcClose)}runJob(){const e=new Fs(this.url,{query:{mode:this.mode,jobId:this.job.id}});this.socket=e.socket("/"),this.socket.on("connect",this.spawn),this.socket.on("disconnect",this.onClose)}onClose(){console.log("Server disconnected, terminating process."),this.proc.kill("SIGINT")}onProcClose(e){this.socket.emit(Gs,e),console.log(`Process finished with code ${e}`),this.socket.disconnect()}report(e,t){this.buf[t]+=e,this.buf[t].includes("\n")&&(this.buf[t].endsWith("\n")&&(this.buf[t]=this.buf[t].slice(0,-1)),this.socket.emit($s,this.buf[t]),"e"===t?console.error(`err: ${this.buf[t]}`):console.log(`out: ${this.buf[t]}`),this.buf[t]="")}}(zs,Xs,Ks);Js.runJob(); +var X = p.default, + J = f.default, + Q = _.default.spawn, + Z = ee; +function ee(e) { + e = e || {}; + var t, + s, + r = this, + i = y.default, + n = m.default, + o = {}, + a = !1, + h = { "User-Agent": "node-XMLHttpRequest", Accept: "*/*" }, + c = Object.assign({}, h), + l = [ + "accept-charset", + "accept-encoding", + "access-control-request-headers", + "access-control-request-method", + "connection", + "content-length", + "content-transfer-encoding", + "cookie", + "cookie2", + "date", + "expect", + "host", + "keep-alive", + "origin", + "referer", + "te", + "trailer", + "transfer-encoding", + "upgrade", + "via", + ], + d = ["TRACE", "TRACK", "CONNECT"], + u = !1, + p = !1, + f = !1, + _ = {}; + (this.UNSENT = 0), + (this.OPENED = 1), + (this.HEADERS_RECEIVED = 2), + (this.LOADING = 3), + (this.DONE = 4), + (this.readyState = this.UNSENT), + (this.onreadystatechange = null), + (this.responseText = ""), + (this.responseXML = ""), + (this.status = null), + (this.statusText = null); + (this.open = function (e, t, s, r, i) { + if ( + (this.abort(), + (p = !1), + (f = !1), + !(function (e) { + return e && -1 === d.indexOf(e); + })(e)) + ) + throw new Error("SecurityError: Request method not allowed"); + (o = { + method: e, + url: t.toString(), + async: "boolean" != typeof s || s, + user: r || null, + password: i || null, + }), + g(this.OPENED); + }), + (this.setDisableHeaderCheck = function (e) { + a = e; + }), + (this.setRequestHeader = function (e, t) { + if (this.readyState != this.OPENED) + throw new Error( + "INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN" + ); + if ( + !(function (e) { + return a || (e && -1 === l.indexOf(e.toLowerCase())); + })(e) + ) + return console.warn('Refused to set unsafe header "' + e + '"'), !1; + if (u) throw new Error("INVALID_STATE_ERR: send flag is true"); + return (c[e] = t), !0; + }), + (this.getResponseHeader = function (e) { + return "string" == typeof e && + this.readyState > this.OPENED && + s.headers[e.toLowerCase()] && + !p + ? s.headers[e.toLowerCase()] + : null; + }), + (this.getAllResponseHeaders = function () { + if (this.readyState < this.HEADERS_RECEIVED || p) return ""; + var e = ""; + for (var t in s.headers) + "set-cookie" !== t && + "set-cookie2" !== t && + (e += t + ": " + s.headers[t] + "\r\n"); + return e.substr(0, e.length - 2); + }), + (this.getRequestHeader = function (e) { + return "string" == typeof e && c[e] ? c[e] : ""; + }), + (this.send = function (a) { + if (this.readyState != this.OPENED) + throw new Error( + "INVALID_STATE_ERR: connection must be opened before send() is called" + ); + if (u) throw new Error("INVALID_STATE_ERR: send has already been called"); + var h, + l = !1, + d = !1, + f = J.parse(o.url); + switch (f.protocol) { + case "https:": + l = !0; + case "http:": + h = f.hostname; + break; + case "file:": + d = !0; + break; + case void 0: + case "": + h = "localhost"; + break; + default: + throw new Error("Protocol not supported."); + } + if (d) { + if ("GET" !== o.method) + throw new Error("XMLHttpRequest: Only GET method is supported"); + if (o.async) + X.readFile(unescape(f.pathname), "utf8", function (e, t) { + e + ? r.handleError(e, e.errno || -1) + : ((r.status = 200), (r.responseText = t), g(r.DONE)); + }); + else + try { + (this.responseText = X.readFileSync(unescape(f.pathname), "utf8")), + (this.status = 200), + g(r.DONE); + } catch (e) { + this.handleError(e, e.errno || -1); + } + } else { + var _ = f.port || (l ? 443 : 80), + y = f.pathname + (f.search ? f.search : ""); + if ( + ((c.Host = h), + (l && 443 === _) || 80 === _ || (c.Host += ":" + f.port), + o.user) + ) { + void 0 === o.password && (o.password = ""); + var m = new Buffer(o.user + ":" + o.password); + c.Authorization = "Basic " + m.toString("base64"); + } + "GET" === o.method || "HEAD" === o.method + ? (a = null) + : a + ? ((c["Content-Length"] = Buffer.isBuffer(a) + ? a.length + : Buffer.byteLength(a)), + c["Content-Type"] || + (c["Content-Type"] = "text/plain;charset=UTF-8")) + : "POST" === o.method && (c["Content-Length"] = 0); + var b = e.agent || !1, + v = { + host: h, + port: _, + path: y, + method: o.method, + headers: c, + agent: b, + }; + if ( + (l && + ((v.pfx = e.pfx), + (v.key = e.key), + (v.passphrase = e.passphrase), + (v.cert = e.cert), + (v.ca = e.ca), + (v.ciphers = e.ciphers), + (v.rejectUnauthorized = !1 !== e.rejectUnauthorized)), + (p = !1), + o.async) + ) { + var E = l ? n.request : i.request; + (u = !0), r.dispatchEvent("readystatechange"); + var w = function (i) { + if ( + 302 === (s = i).statusCode || + 303 === s.statusCode || + 307 === s.statusCode + ) { + o.url = s.headers.location; + var n = J.parse(o.url); + h = n.hostname; + var a = { + hostname: n.hostname, + port: n.port, + path: n.path, + method: 303 === s.statusCode ? "GET" : o.method, + headers: c, + }; + return ( + l && + ((a.pfx = e.pfx), + (a.key = e.key), + (a.passphrase = e.passphrase), + (a.cert = e.cert), + (a.ca = e.ca), + (a.ciphers = e.ciphers), + (a.rejectUnauthorized = !1 !== e.rejectUnauthorized)), + void (t = E(a, w).on("error", S)).end() + ); + } + s && s.setEncoding && s.setEncoding("utf8"), + g(r.HEADERS_RECEIVED), + (r.status = s.statusCode), + s.on("data", function (e) { + e && (r.responseText += e), u && g(r.LOADING); + }), + s.on("end", function () { + u && ((u = !1), g(r.DONE)); + }), + s.on("error", function (e) { + r.handleError(e); + }); + }, + S = function (e) { + r.handleError(e); + }; + (t = E(v, w).on("error", S)), + e.autoUnref && + t.on("socket", (e) => { + e.unref(); + }), + a && t.write(a), + t.end(), + r.dispatchEvent("loadstart"); + } else { + var k = ".node-xmlhttprequest-content-" + process.pid, + x = ".node-xmlhttprequest-sync-" + process.pid; + X.writeFileSync(x, "", "utf8"); + for ( + var O = + "var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http" + + (l ? "s" : "") + + ".request;var options = " + + JSON.stringify(v) + + ";var responseText = '';var req = doRequest(options, function(response) {response.setEncoding('utf8');response.on('data', function(chunk) { responseText += chunk;});response.on('end', function() {fs.writeFileSync('" + + k + + "', 'NODE-XMLHTTPREQUEST-STATUS:' + response.statusCode + ',' + responseText, 'utf8');fs.unlinkSync('" + + x + + "');});response.on('error', function(error) {fs.writeFileSync('" + + k + + "', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('" + + x + + "');});}).on('error', function(error) {fs.writeFileSync('" + + k + + "', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('" + + x + + "');});" + + (a + ? "req.write('" + + JSON.stringify(a).slice(1, -1).replace(/'/g, "\\'") + + "');" + : "") + + "req.end();", + T = Q(process.argv[0], ["-e", O]); + X.existsSync(x); + + ); + if ( + ((r.responseText = X.readFileSync(k, "utf8")), + T.stdin.end(), + X.unlinkSync(k), + r.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)) + ) { + var N = r.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/, ""); + r.handleError(N, 503); + } else + (r.status = r.responseText.replace( + /^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/, + "$1" + )), + (r.responseText = r.responseText.replace( + /^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/, + "$1" + )), + g(r.DONE); + } + } + }), + (this.handleError = function (e, t) { + (this.status = t || 0), + (this.statusText = e), + (this.responseText = e.stack), + (p = !0), + g(this.DONE); + }), + (this.abort = function () { + t && (t.abort(), (t = null)), + (c = Object.assign({}, h)), + (this.responseText = ""), + (this.responseXML = ""), + (p = f = !0), + this.readyState === this.UNSENT || + (this.readyState === this.OPENED && !u) || + this.readyState === this.DONE || + ((u = !1), g(this.DONE)), + (this.readyState = this.UNSENT); + }), + (this.addEventListener = function (e, t) { + e in _ || (_[e] = []), _[e].push(t); + }), + (this.removeEventListener = function (e, t) { + e in _ && + (_[e] = _[e].filter(function (e) { + return e !== t; + })); + }), + (this.dispatchEvent = function (e) { + if ( + ("function" == typeof r["on" + e] && + (this.readyState === this.DONE + ? setImmediate(function () { + r["on" + e](); + }) + : r["on" + e]()), + e in _) + ) + for (let t = 0, s = _[e].length; t < s; t++) + this.readyState === this.DONE + ? setImmediate(function () { + _[e][t].call(r); + }) + : _[e][t].call(r); + }); + var g = function (e) { + if ( + !(r.readyState === e || (r.readyState === r.UNSENT && f)) && + ((r.readyState = e), + (o.async || r.readyState < r.OPENED || r.readyState === r.DONE) && + r.dispatchEvent("readystatechange"), + r.readyState === r.DONE) + ) { + let e; + (e = f ? "abort" : p ? "error" : "load"), + r.dispatchEvent(e), + r.dispatchEvent("loadend"); + } + }; +} +ee.XMLHttpRequest = ee; +const te = Z || u({ __proto__: null, default: Z }, [Z]); +function se() {} +const re = null != new te({ xdomain: !1 }).responseType; +class ie extends P { + constructor(e, t) { + super(), + j(this, t), + (this.opts = t), + (this.method = t.method || "GET"), + (this.uri = e), + (this.async = !1 !== t.async), + (this.data = void 0 !== t.data ? t.data : null), + this.create(); + } + create() { + const e = D( + this.opts, + "agent", + "pfx", + "key", + "passphrase", + "cert", + "ca", + "ciphers", + "rejectUnauthorized", + "autoUnref" + ); + (e.xdomain = !!this.opts.xd), (e.xscheme = !!this.opts.xs); + const t = (this.xhr = new te(e)); + try { + t.open(this.method, this.uri, this.async); + try { + if (this.opts.extraHeaders) { + t.setDisableHeaderCheck && t.setDisableHeaderCheck(!0); + for (let e in this.opts.extraHeaders) + this.opts.extraHeaders.hasOwnProperty(e) && + t.setRequestHeader(e, this.opts.extraHeaders[e]); + } + } catch (e) {} + if ("POST" === this.method) + try { + t.setRequestHeader("Content-type", "text/plain;charset=UTF-8"); + } catch (e) {} + try { + t.setRequestHeader("Accept", "*/*"); + } catch (e) {} + "withCredentials" in t && (t.withCredentials = this.opts.withCredentials), + this.opts.requestTimeout && (t.timeout = this.opts.requestTimeout), + (t.onreadystatechange = () => { + 4 === t.readyState && + (200 === t.status || 1223 === t.status + ? this.onLoad() + : this.setTimeoutFn(() => { + this.onError("number" == typeof t.status ? t.status : 0); + }, 0)); + }), + t.send(this.data); + } catch (e) { + return void this.setTimeoutFn(() => { + this.onError(e); + }, 0); + } + "undefined" != typeof document && + ((this.index = ie.requestsCount++), (ie.requests[this.index] = this)); + } + onError(e) { + this.emitReserved("error", e, this.xhr), this.cleanup(!0); + } + cleanup(e) { + if (void 0 !== this.xhr && null !== this.xhr) { + if (((this.xhr.onreadystatechange = se), e)) + try { + this.xhr.abort(); + } catch (e) {} + "undefined" != typeof document && delete ie.requests[this.index], + (this.xhr = null); + } + } + onLoad() { + const e = this.xhr.responseText; + null !== e && + (this.emitReserved("data", e), + this.emitReserved("success"), + this.cleanup()); + } + abort() { + this.cleanup(); + } +} +if ( + ((ie.requestsCount = 0), (ie.requests = {}), "undefined" != typeof document) +) + if ("function" == typeof attachEvent) attachEvent("onunload", ne); + else if ("function" == typeof addEventListener) { + addEventListener("onpagehide" in I ? "pagehide" : "unload", ne, !1); + } +function ne() { + for (let e in ie.requests) + ie.requests.hasOwnProperty(e) && ie.requests[e].abort(); +} +var oe = { exports: {} }, + ae = { + BINARY_TYPES: ["nodebuffer", "arraybuffer", "fragments"], + EMPTY_BUFFER: Buffer.alloc(0), + GUID: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11", + kForOnEventAttribute: Symbol("kIsForOnEventAttribute"), + kListener: Symbol("kListener"), + kStatusCode: Symbol("status-code"), + kWebSocket: Symbol("websocket"), + NOOP: () => {}, + }; +const { EMPTY_BUFFER: he } = ae; +function ce(e, t) { + if (0 === e.length) return he; + if (1 === e.length) return e[0]; + const s = Buffer.allocUnsafe(t); + let r = 0; + for (let t = 0; t < e.length; t++) { + const i = e[t]; + s.set(i, r), (r += i.length); + } + return r < t ? s.slice(0, r) : s; +} +function le(e, t, s, r, i) { + for (let n = 0; n < i; n++) s[r + n] = e[n] ^ t[3 & n]; +} +function de(e, t) { + for (let s = 0; s < e.length; s++) e[s] ^= t[3 & s]; +} +function ue(e) { + return e.byteLength === e.buffer.byteLength + ? e.buffer + : e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength); +} +function pe(e) { + if (((pe.readOnly = !0), Buffer.isBuffer(e))) return e; + let t; + return ( + e instanceof ArrayBuffer + ? (t = Buffer.from(e)) + : ArrayBuffer.isView(e) + ? (t = Buffer.from(e.buffer, e.byteOffset, e.byteLength)) + : ((t = Buffer.from(e)), (pe.readOnly = !1)), + t + ); +} +try { + const e = require("bufferutil"); + oe.exports = { + concat: ce, + mask(t, s, r, i, n) { + n < 48 ? le(t, s, r, i, n) : e.mask(t, s, r, i, n); + }, + toArrayBuffer: ue, + toBuffer: pe, + unmask(t, s) { + t.length < 32 ? de(t, s) : e.unmask(t, s); + }, + }; +} catch (e) { + oe.exports = { + concat: ce, + mask: le, + toArrayBuffer: ue, + toBuffer: pe, + unmask: de, + }; +} +const fe = Symbol("kDone"), + _e = Symbol("kRun"); +var ye = class { + constructor(e) { + (this[fe] = () => { + this.pending--, this[_e](); + }), + (this.concurrency = e || 1 / 0), + (this.jobs = []), + (this.pending = 0); + } + add(e) { + this.jobs.push(e), this[_e](); + } + [_e]() { + if (this.pending !== this.concurrency && this.jobs.length) { + const e = this.jobs.shift(); + this.pending++, e(this[fe]); + } + } +}; +const me = b.default, + ge = oe.exports, + be = ye, + { kStatusCode: ve } = ae, + Ee = Buffer.from([0, 0, 255, 255]), + we = Symbol("permessage-deflate"), + Se = Symbol("total-length"), + ke = Symbol("callback"), + xe = Symbol("buffers"), + Oe = Symbol("error"); +let Te; +var Ne = class { + constructor(e, t, s) { + if ( + ((this._maxPayload = 0 | s), + (this._options = e || {}), + (this._threshold = + void 0 !== this._options.threshold ? this._options.threshold : 1024), + (this._isServer = !!t), + (this._deflate = null), + (this._inflate = null), + (this.params = null), + !Te) + ) { + const e = + void 0 !== this._options.concurrencyLimit + ? this._options.concurrencyLimit + : 10; + Te = new be(e); + } + } + static get extensionName() { + return "permessage-deflate"; + } + offer() { + const e = {}; + return ( + this._options.serverNoContextTakeover && + (e.server_no_context_takeover = !0), + this._options.clientNoContextTakeover && + (e.client_no_context_takeover = !0), + this._options.serverMaxWindowBits && + (e.server_max_window_bits = this._options.serverMaxWindowBits), + this._options.clientMaxWindowBits + ? (e.client_max_window_bits = this._options.clientMaxWindowBits) + : null == this._options.clientMaxWindowBits && + (e.client_max_window_bits = !0), + e + ); + } + accept(e) { + return ( + (e = this.normalizeParams(e)), + (this.params = this._isServer + ? this.acceptAsServer(e) + : this.acceptAsClient(e)), + this.params + ); + } + cleanup() { + if ( + (this._inflate && (this._inflate.close(), (this._inflate = null)), + this._deflate) + ) { + const e = this._deflate[ke]; + this._deflate.close(), + (this._deflate = null), + e && + e( + new Error( + "The deflate stream was closed while data was being processed" + ) + ); + } + } + acceptAsServer(e) { + const t = this._options, + s = e.find( + (e) => + !( + (!1 === t.serverNoContextTakeover && + e.server_no_context_takeover) || + (e.server_max_window_bits && + (!1 === t.serverMaxWindowBits || + ("number" == typeof t.serverMaxWindowBits && + t.serverMaxWindowBits > e.server_max_window_bits))) || + ("number" == typeof t.clientMaxWindowBits && + !e.client_max_window_bits) + ) + ); + if (!s) throw new Error("None of the extension offers can be accepted"); + return ( + t.serverNoContextTakeover && (s.server_no_context_takeover = !0), + t.clientNoContextTakeover && (s.client_no_context_takeover = !0), + "number" == typeof t.serverMaxWindowBits && + (s.server_max_window_bits = t.serverMaxWindowBits), + "number" == typeof t.clientMaxWindowBits + ? (s.client_max_window_bits = t.clientMaxWindowBits) + : (!0 !== s.client_max_window_bits && !1 !== t.clientMaxWindowBits) || + delete s.client_max_window_bits, + s + ); + } + acceptAsClient(e) { + const t = e[0]; + if ( + !1 === this._options.clientNoContextTakeover && + t.client_no_context_takeover + ) + throw new Error('Unexpected parameter "client_no_context_takeover"'); + if (t.client_max_window_bits) { + if ( + !1 === this._options.clientMaxWindowBits || + ("number" == typeof this._options.clientMaxWindowBits && + t.client_max_window_bits > this._options.clientMaxWindowBits) + ) + throw new Error( + 'Unexpected or invalid parameter "client_max_window_bits"' + ); + } else + "number" == typeof this._options.clientMaxWindowBits && + (t.client_max_window_bits = this._options.clientMaxWindowBits); + return t; + } + normalizeParams(e) { + return ( + e.forEach((e) => { + Object.keys(e).forEach((t) => { + let s = e[t]; + if (s.length > 1) + throw new Error(`Parameter "${t}" must have only a single value`); + if (((s = s[0]), "client_max_window_bits" === t)) { + if (!0 !== s) { + const e = +s; + if (!Number.isInteger(e) || e < 8 || e > 15) + throw new TypeError(`Invalid value for parameter "${t}": ${s}`); + s = e; + } else if (!this._isServer) + throw new TypeError(`Invalid value for parameter "${t}": ${s}`); + } else if ("server_max_window_bits" === t) { + const e = +s; + if (!Number.isInteger(e) || e < 8 || e > 15) + throw new TypeError(`Invalid value for parameter "${t}": ${s}`); + s = e; + } else { + if ( + "client_no_context_takeover" !== t && + "server_no_context_takeover" !== t + ) + throw new Error(`Unknown parameter "${t}"`); + if (!0 !== s) + throw new TypeError(`Invalid value for parameter "${t}": ${s}`); + } + e[t] = s; + }); + }), + e + ); + } + decompress(e, t, s) { + Te.add((r) => { + this._decompress(e, t, (e, t) => { + r(), s(e, t); + }); + }); + } + compress(e, t, s) { + Te.add((r) => { + this._compress(e, t, (e, t) => { + r(), s(e, t); + }); + }); + } + _decompress(e, t, s) { + const r = this._isServer ? "client" : "server"; + if (!this._inflate) { + const e = `${r}_max_window_bits`, + t = + "number" != typeof this.params[e] + ? me.Z_DEFAULT_WINDOWBITS + : this.params[e]; + (this._inflate = me.createInflateRaw({ + ...this._options.zlibInflateOptions, + windowBits: t, + })), + (this._inflate[we] = this), + (this._inflate[Se] = 0), + (this._inflate[xe] = []), + this._inflate.on("error", Le), + this._inflate.on("data", Ce); + } + (this._inflate[ke] = s), + this._inflate.write(e), + t && this._inflate.write(Ee), + this._inflate.flush(() => { + const e = this._inflate[Oe]; + if (e) return this._inflate.close(), (this._inflate = null), void s(e); + const i = ge.concat(this._inflate[xe], this._inflate[Se]); + this._inflate._readableState.endEmitted + ? (this._inflate.close(), (this._inflate = null)) + : ((this._inflate[Se] = 0), + (this._inflate[xe] = []), + t && + this.params[`${r}_no_context_takeover`] && + this._inflate.reset()), + s(null, i); + }); + } + _compress(e, t, s) { + const r = this._isServer ? "server" : "client"; + if (!this._deflate) { + const e = `${r}_max_window_bits`, + t = + "number" != typeof this.params[e] + ? me.Z_DEFAULT_WINDOWBITS + : this.params[e]; + (this._deflate = me.createDeflateRaw({ + ...this._options.zlibDeflateOptions, + windowBits: t, + })), + (this._deflate[Se] = 0), + (this._deflate[xe] = []), + this._deflate.on("data", Re); + } + (this._deflate[ke] = s), + this._deflate.write(e), + this._deflate.flush(me.Z_SYNC_FLUSH, () => { + if (!this._deflate) return; + let e = ge.concat(this._deflate[xe], this._deflate[Se]); + t && (e = e.slice(0, e.length - 4)), + (this._deflate[ke] = null), + (this._deflate[Se] = 0), + (this._deflate[xe] = []), + t && this.params[`${r}_no_context_takeover`] && this._deflate.reset(), + s(null, e); + }); + } +}; +function Re(e) { + this[xe].push(e), (this[Se] += e.length); +} +function Ce(e) { + (this[Se] += e.length), + this[we]._maxPayload < 1 || this[Se] <= this[we]._maxPayload + ? this[xe].push(e) + : ((this[Oe] = new RangeError("Max payload size exceeded")), + (this[Oe].code = "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"), + (this[Oe][ve] = 1009), + this.removeListener("data", Ce), + this.reset()); +} +function Le(e) { + (this[we]._inflate = null), (e[ve] = 1007), this[ke](e); +} +var Ae = { exports: {} }; +const Be = [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, +]; +function Pe(e) { + return ( + (e >= 1e3 && e <= 1014 && 1004 !== e && 1005 !== e && 1006 !== e) || + (e >= 3e3 && e <= 4999) + ); +} +function Ie(e) { + const t = e.length; + let s = 0; + for (; s < t; ) + if (0 == (128 & e[s])) s++; + else if (192 == (224 & e[s])) { + if (s + 1 === t || 128 != (192 & e[s + 1]) || 192 == (254 & e[s])) + return !1; + s += 2; + } else if (224 == (240 & e[s])) { + if ( + s + 2 >= t || + 128 != (192 & e[s + 1]) || + 128 != (192 & e[s + 2]) || + (224 === e[s] && 128 == (224 & e[s + 1])) || + (237 === e[s] && 160 == (224 & e[s + 1])) + ) + return !1; + s += 3; + } else { + if (240 != (248 & e[s])) return !1; + if ( + s + 3 >= t || + 128 != (192 & e[s + 1]) || + 128 != (192 & e[s + 2]) || + 128 != (192 & e[s + 3]) || + (240 === e[s] && 128 == (240 & e[s + 1])) || + (244 === e[s] && e[s + 1] > 143) || + e[s] > 244 + ) + return !1; + s += 4; + } + return !0; +} +try { + const e = require("utf-8-validate"); + Ae.exports = { + isValidStatusCode: Pe, + isValidUTF8: (t) => (t.length < 150 ? Ie(t) : e(t)), + tokenChars: Be, + }; +} catch (e) { + Ae.exports = { isValidStatusCode: Pe, isValidUTF8: Ie, tokenChars: Be }; +} +const { Writable: De } = g.default, + Ue = Ne, + { BINARY_TYPES: qe, EMPTY_BUFFER: je, kStatusCode: Fe, kWebSocket: Me } = ae, + { concat: We, toArrayBuffer: Ve, unmask: $e } = oe.exports, + { isValidStatusCode: Ge, isValidUTF8: He } = Ae.exports; +var ze = class extends De { + constructor(e = {}) { + super(), + (this._binaryType = e.binaryType || qe[0]), + (this._extensions = e.extensions || {}), + (this._isServer = !!e.isServer), + (this._maxPayload = 0 | e.maxPayload), + (this._skipUTF8Validation = !!e.skipUTF8Validation), + (this[Me] = void 0), + (this._bufferedBytes = 0), + (this._buffers = []), + (this._compressed = !1), + (this._payloadLength = 0), + (this._mask = void 0), + (this._fragmented = 0), + (this._masked = !1), + (this._fin = !1), + (this._opcode = 0), + (this._totalPayloadLength = 0), + (this._messageLength = 0), + (this._fragments = []), + (this._state = 0), + (this._loop = !1); + } + _write(e, t, s) { + if (8 === this._opcode && 0 == this._state) return s(); + (this._bufferedBytes += e.length), this._buffers.push(e), this.startLoop(s); + } + consume(e) { + if (((this._bufferedBytes -= e), e === this._buffers[0].length)) + return this._buffers.shift(); + if (e < this._buffers[0].length) { + const t = this._buffers[0]; + return (this._buffers[0] = t.slice(e)), t.slice(0, e); + } + const t = Buffer.allocUnsafe(e); + do { + const s = this._buffers[0], + r = t.length - e; + e >= s.length + ? t.set(this._buffers.shift(), r) + : (t.set(new Uint8Array(s.buffer, s.byteOffset, e), r), + (this._buffers[0] = s.slice(e))), + (e -= s.length); + } while (e > 0); + return t; + } + startLoop(e) { + let t; + this._loop = !0; + do { + switch (this._state) { + case 0: + t = this.getInfo(); + break; + case 1: + t = this.getPayloadLength16(); + break; + case 2: + t = this.getPayloadLength64(); + break; + case 3: + this.getMask(); + break; + case 4: + t = this.getData(e); + break; + default: + return void (this._loop = !1); + } + } while (this._loop); + e(t); + } + getInfo() { + if (this._bufferedBytes < 2) return void (this._loop = !1); + const e = this.consume(2); + if (0 != (48 & e[0])) + return ( + (this._loop = !1), + Ye( + RangeError, + "RSV2 and RSV3 must be clear", + !0, + 1002, + "WS_ERR_UNEXPECTED_RSV_2_3" + ) + ); + const t = 64 == (64 & e[0]); + if (t && !this._extensions[Ue.extensionName]) + return ( + (this._loop = !1), + Ye( + RangeError, + "RSV1 must be clear", + !0, + 1002, + "WS_ERR_UNEXPECTED_RSV_1" + ) + ); + if ( + ((this._fin = 128 == (128 & e[0])), + (this._opcode = 15 & e[0]), + (this._payloadLength = 127 & e[1]), + 0 === this._opcode) + ) { + if (t) + return ( + (this._loop = !1), + Ye( + RangeError, + "RSV1 must be clear", + !0, + 1002, + "WS_ERR_UNEXPECTED_RSV_1" + ) + ); + if (!this._fragmented) + return ( + (this._loop = !1), + Ye(RangeError, "invalid opcode 0", !0, 1002, "WS_ERR_INVALID_OPCODE") + ); + this._opcode = this._fragmented; + } else if (1 === this._opcode || 2 === this._opcode) { + if (this._fragmented) + return ( + (this._loop = !1), + Ye( + RangeError, + `invalid opcode ${this._opcode}`, + !0, + 1002, + "WS_ERR_INVALID_OPCODE" + ) + ); + this._compressed = t; + } else { + if (!(this._opcode > 7 && this._opcode < 11)) + return ( + (this._loop = !1), + Ye( + RangeError, + `invalid opcode ${this._opcode}`, + !0, + 1002, + "WS_ERR_INVALID_OPCODE" + ) + ); + if (!this._fin) + return ( + (this._loop = !1), + Ye(RangeError, "FIN must be set", !0, 1002, "WS_ERR_EXPECTED_FIN") + ); + if (t) + return ( + (this._loop = !1), + Ye( + RangeError, + "RSV1 must be clear", + !0, + 1002, + "WS_ERR_UNEXPECTED_RSV_1" + ) + ); + if (this._payloadLength > 125) + return ( + (this._loop = !1), + Ye( + RangeError, + `invalid payload length ${this._payloadLength}`, + !0, + 1002, + "WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH" + ) + ); + } + if ( + (this._fin || this._fragmented || (this._fragmented = this._opcode), + (this._masked = 128 == (128 & e[1])), + this._isServer) + ) { + if (!this._masked) + return ( + (this._loop = !1), + Ye(RangeError, "MASK must be set", !0, 1002, "WS_ERR_EXPECTED_MASK") + ); + } else if (this._masked) + return ( + (this._loop = !1), + Ye(RangeError, "MASK must be clear", !0, 1002, "WS_ERR_UNEXPECTED_MASK") + ); + if (126 === this._payloadLength) this._state = 1; + else { + if (127 !== this._payloadLength) return this.haveLength(); + this._state = 2; + } + } + getPayloadLength16() { + if (!(this._bufferedBytes < 2)) + return ( + (this._payloadLength = this.consume(2).readUInt16BE(0)), + this.haveLength() + ); + this._loop = !1; + } + getPayloadLength64() { + if (this._bufferedBytes < 8) return void (this._loop = !1); + const e = this.consume(8), + t = e.readUInt32BE(0); + return t > Math.pow(2, 21) - 1 + ? ((this._loop = !1), + Ye( + RangeError, + "Unsupported WebSocket frame: payload length > 2^53 - 1", + !1, + 1009, + "WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH" + )) + : ((this._payloadLength = t * Math.pow(2, 32) + e.readUInt32BE(4)), + this.haveLength()); + } + haveLength() { + if ( + this._payloadLength && + this._opcode < 8 && + ((this._totalPayloadLength += this._payloadLength), + this._totalPayloadLength > this._maxPayload && this._maxPayload > 0) + ) + return ( + (this._loop = !1), + Ye( + RangeError, + "Max payload size exceeded", + !1, + 1009, + "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH" + ) + ); + this._masked ? (this._state = 3) : (this._state = 4); + } + getMask() { + this._bufferedBytes < 4 + ? (this._loop = !1) + : ((this._mask = this.consume(4)), (this._state = 4)); + } + getData(e) { + let t = je; + if (this._payloadLength) { + if (this._bufferedBytes < this._payloadLength) + return void (this._loop = !1); + (t = this.consume(this._payloadLength)), + this._masked && $e(t, this._mask); + } + return this._opcode > 7 + ? this.controlMessage(t) + : this._compressed + ? ((this._state = 5), void this.decompress(t, e)) + : (t.length && + ((this._messageLength = this._totalPayloadLength), + this._fragments.push(t)), + this.dataMessage()); + } + decompress(e, t) { + this._extensions[Ue.extensionName].decompress(e, this._fin, (e, s) => { + if (e) return t(e); + if (s.length) { + if ( + ((this._messageLength += s.length), + this._messageLength > this._maxPayload && this._maxPayload > 0) + ) + return t( + Ye( + RangeError, + "Max payload size exceeded", + !1, + 1009, + "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH" + ) + ); + this._fragments.push(s); + } + const r = this.dataMessage(); + if (r) return t(r); + this.startLoop(t); + }); + } + dataMessage() { + if (this._fin) { + const e = this._messageLength, + t = this._fragments; + if ( + ((this._totalPayloadLength = 0), + (this._messageLength = 0), + (this._fragmented = 0), + (this._fragments = []), + 2 === this._opcode) + ) { + let s; + (s = + "nodebuffer" === this._binaryType + ? We(t, e) + : "arraybuffer" === this._binaryType + ? Ve(We(t, e)) + : t), + this.emit("message", s, !0); + } else { + const s = We(t, e); + if (!this._skipUTF8Validation && !He(s)) + return ( + (this._loop = !1), + Ye(Error, "invalid UTF-8 sequence", !0, 1007, "WS_ERR_INVALID_UTF8") + ); + this.emit("message", s, !1); + } + } + this._state = 0; + } + controlMessage(e) { + if (8 === this._opcode) + if (((this._loop = !1), 0 === e.length)) + this.emit("conclude", 1005, je), this.end(); + else { + if (1 === e.length) + return Ye( + RangeError, + "invalid payload length 1", + !0, + 1002, + "WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH" + ); + { + const t = e.readUInt16BE(0); + if (!Ge(t)) + return Ye( + RangeError, + `invalid status code ${t}`, + !0, + 1002, + "WS_ERR_INVALID_CLOSE_CODE" + ); + const s = e.slice(2); + if (!this._skipUTF8Validation && !He(s)) + return Ye( + Error, + "invalid UTF-8 sequence", + !0, + 1007, + "WS_ERR_INVALID_UTF8" + ); + this.emit("conclude", t, s), this.end(); + } + } + else 9 === this._opcode ? this.emit("ping", e) : this.emit("pong", e); + this._state = 0; + } +}; +function Ye(e, t, s, r, i) { + const n = new e(s ? `Invalid WebSocket frame: ${t}` : t); + return Error.captureStackTrace(n, Ye), (n.code = i), (n[Fe] = r), n; +} +const { randomFillSync: Ke } = w.default, + Xe = Ne, + { EMPTY_BUFFER: Je } = ae, + { isValidStatusCode: Qe } = Ae.exports, + { mask: Ze, toBuffer: et } = oe.exports, + tt = Buffer.alloc(4); +class st { + constructor(e, t) { + (this._extensions = t || {}), + (this._socket = e), + (this._firstFragment = !0), + (this._compress = !1), + (this._bufferedBytes = 0), + (this._deflating = !1), + (this._queue = []); + } + static frame(e, t) { + const s = t.mask && t.readOnly; + let r = t.mask ? 6 : 2, + i = e.length; + e.length >= 65536 + ? ((r += 8), (i = 127)) + : e.length > 125 && ((r += 2), (i = 126)); + const n = Buffer.allocUnsafe(s ? e.length + r : r); + return ( + (n[0] = t.fin ? 128 | t.opcode : t.opcode), + t.rsv1 && (n[0] |= 64), + (n[1] = i), + 126 === i + ? n.writeUInt16BE(e.length, 2) + : 127 === i && (n.writeUInt32BE(0, 2), n.writeUInt32BE(e.length, 6)), + t.mask + ? (Ke(tt, 0, 4), + (n[1] |= 128), + (n[r - 4] = tt[0]), + (n[r - 3] = tt[1]), + (n[r - 2] = tt[2]), + (n[r - 1] = tt[3]), + s + ? (Ze(e, tt, n, r, e.length), [n]) + : (Ze(e, tt, e, 0, e.length), [n, e])) + : [n, e] + ); + } + close(e, t, s, r) { + let i; + if (void 0 === e) i = Je; + else { + if ("number" != typeof e || !Qe(e)) + throw new TypeError("First argument must be a valid error code number"); + if (void 0 !== t && t.length) { + const s = Buffer.byteLength(t); + if (s > 123) + throw new RangeError( + "The message must not be greater than 123 bytes" + ); + (i = Buffer.allocUnsafe(2 + s)), + i.writeUInt16BE(e, 0), + "string" == typeof t ? i.write(t, 2) : i.set(t, 2); + } else (i = Buffer.allocUnsafe(2)), i.writeUInt16BE(e, 0); + } + this._deflating + ? this.enqueue([this.doClose, i, s, r]) + : this.doClose(i, s, r); + } + doClose(e, t, s) { + this.sendFrame( + st.frame(e, { fin: !0, rsv1: !1, opcode: 8, mask: t, readOnly: !1 }), + s + ); + } + ping(e, t, s) { + const r = et(e); + if (r.length > 125) + throw new RangeError("The data size must not be greater than 125 bytes"); + this._deflating + ? this.enqueue([this.doPing, r, t, et.readOnly, s]) + : this.doPing(r, t, et.readOnly, s); + } + doPing(e, t, s, r) { + this.sendFrame( + st.frame(e, { fin: !0, rsv1: !1, opcode: 9, mask: t, readOnly: s }), + r + ); + } + pong(e, t, s) { + const r = et(e); + if (r.length > 125) + throw new RangeError("The data size must not be greater than 125 bytes"); + this._deflating + ? this.enqueue([this.doPong, r, t, et.readOnly, s]) + : this.doPong(r, t, et.readOnly, s); + } + doPong(e, t, s, r) { + this.sendFrame( + st.frame(e, { fin: !0, rsv1: !1, opcode: 10, mask: t, readOnly: s }), + r + ); + } + send(e, t, s) { + const r = et(e), + i = this._extensions[Xe.extensionName]; + let n = t.binary ? 2 : 1, + o = t.compress; + if ( + (this._firstFragment + ? ((this._firstFragment = !1), + o && + i && + i.params[ + i._isServer + ? "server_no_context_takeover" + : "client_no_context_takeover" + ] && + (o = r.length >= i._threshold), + (this._compress = o)) + : ((o = !1), (n = 0)), + t.fin && (this._firstFragment = !0), + i) + ) { + const e = { + fin: t.fin, + rsv1: o, + opcode: n, + mask: t.mask, + readOnly: et.readOnly, + }; + this._deflating + ? this.enqueue([this.dispatch, r, this._compress, e, s]) + : this.dispatch(r, this._compress, e, s); + } else + this.sendFrame( + st.frame(r, { + fin: t.fin, + rsv1: !1, + opcode: n, + mask: t.mask, + readOnly: et.readOnly, + }), + s + ); + } + dispatch(e, t, s, r) { + if (!t) return void this.sendFrame(st.frame(e, s), r); + const i = this._extensions[Xe.extensionName]; + (this._bufferedBytes += e.length), + (this._deflating = !0), + i.compress(e, s.fin, (t, i) => { + if (this._socket.destroyed) { + const e = new Error( + "The socket was closed while data was being compressed" + ); + "function" == typeof r && r(e); + for (let t = 0; t < this._queue.length; t++) { + const s = this._queue[t][4]; + "function" == typeof s && s(e); + } + } else + (this._bufferedBytes -= e.length), + (this._deflating = !1), + (s.readOnly = !1), + this.sendFrame(st.frame(i, s), r), + this.dequeue(); + }); + } + dequeue() { + for (; !this._deflating && this._queue.length; ) { + const e = this._queue.shift(); + (this._bufferedBytes -= e[1].length), + Reflect.apply(e[0], this, e.slice(1)); + } + } + enqueue(e) { + (this._bufferedBytes += e[1].length), this._queue.push(e); + } + sendFrame(e, t) { + 2 === e.length + ? (this._socket.cork(), + this._socket.write(e[0]), + this._socket.write(e[1], t), + this._socket.uncork()) + : this._socket.write(e[0], t); + } +} +var rt = st; +const { kForOnEventAttribute: it, kListener: nt } = ae, + ot = Symbol("kCode"), + at = Symbol("kData"), + ht = Symbol("kError"), + ct = Symbol("kMessage"), + lt = Symbol("kReason"), + dt = Symbol("kTarget"), + ut = Symbol("kType"), + pt = Symbol("kWasClean"); +class ft { + constructor(e) { + (this[dt] = null), (this[ut] = e); + } + get target() { + return this[dt]; + } + get type() { + return this[ut]; + } +} +Object.defineProperty(ft.prototype, "target", { enumerable: !0 }), + Object.defineProperty(ft.prototype, "type", { enumerable: !0 }); +class _t extends ft { + constructor(e, t = {}) { + super(e), + (this[ot] = void 0 === t.code ? 0 : t.code), + (this[lt] = void 0 === t.reason ? "" : t.reason), + (this[pt] = void 0 !== t.wasClean && t.wasClean); + } + get code() { + return this[ot]; + } + get reason() { + return this[lt]; + } + get wasClean() { + return this[pt]; + } +} +Object.defineProperty(_t.prototype, "code", { enumerable: !0 }), + Object.defineProperty(_t.prototype, "reason", { enumerable: !0 }), + Object.defineProperty(_t.prototype, "wasClean", { enumerable: !0 }); +class yt extends ft { + constructor(e, t = {}) { + super(e), + (this[ht] = void 0 === t.error ? null : t.error), + (this[ct] = void 0 === t.message ? "" : t.message); + } + get error() { + return this[ht]; + } + get message() { + return this[ct]; + } +} +Object.defineProperty(yt.prototype, "error", { enumerable: !0 }), + Object.defineProperty(yt.prototype, "message", { enumerable: !0 }); +class mt extends ft { + constructor(e, t = {}) { + super(e), (this[at] = void 0 === t.data ? null : t.data); + } + get data() { + return this[at]; + } +} +Object.defineProperty(mt.prototype, "data", { enumerable: !0 }); +const gt = { + addEventListener(e, t, s = {}) { + let r; + if ("message" === e) + r = function (e, s) { + const r = new mt("message", { data: s ? e : e.toString() }); + (r[dt] = this), t.call(this, r); + }; + else if ("close" === e) + r = function (e, s) { + const r = new _t("close", { + code: e, + reason: s.toString(), + wasClean: this._closeFrameReceived && this._closeFrameSent, + }); + (r[dt] = this), t.call(this, r); + }; + else if ("error" === e) + r = function (e) { + const s = new yt("error", { error: e, message: e.message }); + (s[dt] = this), t.call(this, s); + }; + else { + if ("open" !== e) return; + r = function () { + const e = new ft("open"); + (e[dt] = this), t.call(this, e); + }; + } + (r[it] = !!s[it]), (r[nt] = t), s.once ? this.once(e, r) : this.on(e, r); + }, + removeEventListener(e, t) { + for (const s of this.listeners(e)) + if (s[nt] === t && !s[it]) { + this.removeListener(e, s); + break; + } + }, +}; +var bt = { + CloseEvent: _t, + ErrorEvent: yt, + Event: ft, + EventTarget: gt, + MessageEvent: mt, +}; +const { tokenChars: vt } = Ae.exports; +function Et(e, t, s) { + void 0 === e[t] ? (e[t] = [s]) : e[t].push(s); +} +var wt = { + format: function (e) { + return Object.keys(e) + .map((t) => { + let s = e[t]; + return ( + Array.isArray(s) || (s = [s]), + s + .map((e) => + [t] + .concat( + Object.keys(e).map((t) => { + let s = e[t]; + return ( + Array.isArray(s) || (s = [s]), + s.map((e) => (!0 === e ? t : `${t}=${e}`)).join("; ") + ); + }) + ) + .join("; ") + ) + .join(", ") + ); + }) + .join(", "); + }, + parse: function (e) { + const t = Object.create(null); + let s, + r, + i = Object.create(null), + n = !1, + o = !1, + a = !1, + h = -1, + c = -1, + l = -1, + d = 0; + for (; d < e.length; d++) + if (((c = e.charCodeAt(d)), void 0 === s)) + if (-1 === l && 1 === vt[c]) -1 === h && (h = d); + else if (0 === d || (32 !== c && 9 !== c)) { + if (59 !== c && 44 !== c) + throw new SyntaxError(`Unexpected character at index ${d}`); + { + if (-1 === h) + throw new SyntaxError(`Unexpected character at index ${d}`); + -1 === l && (l = d); + const r = e.slice(h, l); + 44 === c ? (Et(t, r, i), (i = Object.create(null))) : (s = r), + (h = l = -1); + } + } else -1 === l && -1 !== h && (l = d); + else if (void 0 === r) + if (-1 === l && 1 === vt[c]) -1 === h && (h = d); + else if (32 === c || 9 === c) -1 === l && -1 !== h && (l = d); + else if (59 === c || 44 === c) { + if (-1 === h) + throw new SyntaxError(`Unexpected character at index ${d}`); + -1 === l && (l = d), + Et(i, e.slice(h, l), !0), + 44 === c && (Et(t, s, i), (i = Object.create(null)), (s = void 0)), + (h = l = -1); + } else { + if (61 !== c || -1 === h || -1 !== l) + throw new SyntaxError(`Unexpected character at index ${d}`); + (r = e.slice(h, d)), (h = l = -1); + } + else if (o) { + if (1 !== vt[c]) + throw new SyntaxError(`Unexpected character at index ${d}`); + -1 === h ? (h = d) : n || (n = !0), (o = !1); + } else if (a) + if (1 === vt[c]) -1 === h && (h = d); + else if (34 === c && -1 !== h) (a = !1), (l = d); + else { + if (92 !== c) + throw new SyntaxError(`Unexpected character at index ${d}`); + o = !0; + } + else if (34 === c && 61 === e.charCodeAt(d - 1)) a = !0; + else if (-1 === l && 1 === vt[c]) -1 === h && (h = d); + else if (-1 === h || (32 !== c && 9 !== c)) { + if (59 !== c && 44 !== c) + throw new SyntaxError(`Unexpected character at index ${d}`); + { + if (-1 === h) + throw new SyntaxError(`Unexpected character at index ${d}`); + -1 === l && (l = d); + let o = e.slice(h, l); + n && ((o = o.replace(/\\/g, "")), (n = !1)), + Et(i, r, o), + 44 === c && (Et(t, s, i), (i = Object.create(null)), (s = void 0)), + (r = void 0), + (h = l = -1); + } + } else -1 === l && (l = d); + if (-1 === h || a || 32 === c || 9 === c) + throw new SyntaxError("Unexpected end of input"); + -1 === l && (l = d); + const u = e.slice(h, l); + return ( + void 0 === s + ? Et(t, u, i) + : (void 0 === r ? Et(i, u, !0) : Et(i, r, n ? u.replace(/\\/g, "") : u), + Et(t, s, i)), + t + ); + }, +}; +const St = S.default, + kt = m.default, + xt = y.default, + Ot = v.default, + Tt = E.default, + { randomBytes: Nt, createHash: Rt } = w.default, + { URL: Ct } = f.default, + Lt = Ne, + At = ze, + Bt = rt, + { + BINARY_TYPES: Pt, + EMPTY_BUFFER: It, + GUID: Dt, + kForOnEventAttribute: Ut, + kListener: qt, + kStatusCode: jt, + kWebSocket: Ft, + NOOP: Mt, + } = ae, + { + EventTarget: { addEventListener: Wt, removeEventListener: Vt }, + } = bt, + { format: $t, parse: Gt } = wt, + { toBuffer: Ht } = oe.exports, + zt = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"], + Yt = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/, + Kt = [8, 13]; +class Xt extends St { + constructor(e, t, s) { + super(), + (this._binaryType = Pt[0]), + (this._closeCode = 1006), + (this._closeFrameReceived = !1), + (this._closeFrameSent = !1), + (this._closeMessage = It), + (this._closeTimer = null), + (this._extensions = {}), + (this._protocol = ""), + (this._readyState = Xt.CONNECTING), + (this._receiver = null), + (this._sender = null), + (this._socket = null), + null !== e + ? ((this._bufferedAmount = 0), + (this._isServer = !1), + (this._redirects = 0), + void 0 === t + ? (t = []) + : Array.isArray(t) || + ("object" == typeof t && null !== t + ? ((s = t), (t = [])) + : (t = [t])), + Jt(this, e, t, s)) + : (this._isServer = !0); + } + get binaryType() { + return this._binaryType; + } + set binaryType(e) { + Pt.includes(e) && + ((this._binaryType = e), + this._receiver && (this._receiver._binaryType = e)); + } + get bufferedAmount() { + return this._socket + ? this._socket._writableState.length + this._sender._bufferedBytes + : this._bufferedAmount; + } + get extensions() { + return Object.keys(this._extensions).join(); + } + get onclose() { + return null; + } + get onerror() { + return null; + } + get onopen() { + return null; + } + get onmessage() { + return null; + } + get protocol() { + return this._protocol; + } + get readyState() { + return this._readyState; + } + get url() { + return this._url; + } + setSocket(e, t, s) { + const r = new At({ + binaryType: this.binaryType, + extensions: this._extensions, + isServer: this._isServer, + maxPayload: s.maxPayload, + skipUTF8Validation: s.skipUTF8Validation, + }); + (this._sender = new Bt(e, this._extensions)), + (this._receiver = r), + (this._socket = e), + (r[Ft] = this), + (e[Ft] = this), + r.on("conclude", ss), + r.on("drain", rs), + r.on("error", is), + r.on("message", os), + r.on("ping", as), + r.on("pong", hs), + e.setTimeout(0), + e.setNoDelay(), + t.length > 0 && e.unshift(t), + e.on("close", ls), + e.on("data", ds), + e.on("end", us), + e.on("error", ps), + (this._readyState = Xt.OPEN), + this.emit("open"); + } + emitClose() { + if (!this._socket) + return ( + (this._readyState = Xt.CLOSED), + void this.emit("close", this._closeCode, this._closeMessage) + ); + this._extensions[Lt.extensionName] && + this._extensions[Lt.extensionName].cleanup(), + this._receiver.removeAllListeners(), + (this._readyState = Xt.CLOSED), + this.emit("close", this._closeCode, this._closeMessage); + } + close(e, t) { + if (this.readyState !== Xt.CLOSED) { + if (this.readyState === Xt.CONNECTING) { + const e = "WebSocket was closed before the connection was established"; + return es(this, this._req, e); + } + this.readyState !== Xt.CLOSING + ? ((this._readyState = Xt.CLOSING), + this._sender.close(e, t, !this._isServer, (e) => { + e || + ((this._closeFrameSent = !0), + (this._closeFrameReceived || + this._receiver._writableState.errorEmitted) && + this._socket.end()); + }), + (this._closeTimer = setTimeout( + this._socket.destroy.bind(this._socket), + 3e4 + ))) + : this._closeFrameSent && + (this._closeFrameReceived || + this._receiver._writableState.errorEmitted) && + this._socket.end(); + } + } + ping(e, t, s) { + if (this.readyState === Xt.CONNECTING) + throw new Error("WebSocket is not open: readyState 0 (CONNECTING)"); + "function" == typeof e + ? ((s = e), (e = t = void 0)) + : "function" == typeof t && ((s = t), (t = void 0)), + "number" == typeof e && (e = e.toString()), + this.readyState === Xt.OPEN + ? (void 0 === t && (t = !this._isServer), + this._sender.ping(e || It, t, s)) + : ts(this, e, s); + } + pong(e, t, s) { + if (this.readyState === Xt.CONNECTING) + throw new Error("WebSocket is not open: readyState 0 (CONNECTING)"); + "function" == typeof e + ? ((s = e), (e = t = void 0)) + : "function" == typeof t && ((s = t), (t = void 0)), + "number" == typeof e && (e = e.toString()), + this.readyState === Xt.OPEN + ? (void 0 === t && (t = !this._isServer), + this._sender.pong(e || It, t, s)) + : ts(this, e, s); + } + send(e, t, s) { + if (this.readyState === Xt.CONNECTING) + throw new Error("WebSocket is not open: readyState 0 (CONNECTING)"); + if ( + ("function" == typeof t && ((s = t), (t = {})), + "number" == typeof e && (e = e.toString()), + this.readyState !== Xt.OPEN) + ) + return void ts(this, e, s); + const r = { + binary: "string" != typeof e, + mask: !this._isServer, + compress: !0, + fin: !0, + ...t, + }; + this._extensions[Lt.extensionName] || (r.compress = !1), + this._sender.send(e || It, r, s); + } + terminate() { + if (this.readyState !== Xt.CLOSED) { + if (this.readyState === Xt.CONNECTING) { + const e = "WebSocket was closed before the connection was established"; + return es(this, this._req, e); + } + this._socket && ((this._readyState = Xt.CLOSING), this._socket.destroy()); + } + } +} +function Jt(e, t, s, r) { + const i = { + protocolVersion: Kt[1], + maxPayload: 104857600, + skipUTF8Validation: !1, + perMessageDeflate: !0, + followRedirects: !1, + maxRedirects: 10, + ...r, + createConnection: void 0, + socketPath: void 0, + hostname: void 0, + protocol: void 0, + timeout: void 0, + method: void 0, + host: void 0, + path: void 0, + port: void 0, + }; + if (!Kt.includes(i.protocolVersion)) + throw new RangeError( + `Unsupported protocol version: ${ + i.protocolVersion + } (supported versions: ${Kt.join(", ")})` + ); + let n; + if (t instanceof Ct) (n = t), (e._url = t.href); + else { + try { + n = new Ct(t); + } catch (e) { + throw new SyntaxError(`Invalid URL: ${t}`); + } + e._url = t; + } + const o = "wss:" === n.protocol, + a = "ws+unix:" === n.protocol; + if ("ws:" !== n.protocol && !o && !a) + throw new SyntaxError( + 'The URL\'s protocol must be one of "ws:", "wss:", or "ws+unix:"' + ); + if (a && !n.pathname) throw new SyntaxError("The URL's pathname is empty"); + if (n.hash) throw new SyntaxError("The URL contains a fragment identifier"); + const h = o ? 443 : 80, + c = Nt(16).toString("base64"), + l = o ? kt.get : xt.get, + d = new Set(); + let u; + if ( + ((i.createConnection = o ? Zt : Qt), + (i.defaultPort = i.defaultPort || h), + (i.port = n.port || h), + (i.host = n.hostname.startsWith("[") + ? n.hostname.slice(1, -1) + : n.hostname), + (i.headers = { + "Sec-WebSocket-Version": i.protocolVersion, + "Sec-WebSocket-Key": c, + Connection: "Upgrade", + Upgrade: "websocket", + ...i.headers, + }), + (i.path = n.pathname + n.search), + (i.timeout = i.handshakeTimeout), + i.perMessageDeflate && + ((u = new Lt( + !0 !== i.perMessageDeflate ? i.perMessageDeflate : {}, + !1, + i.maxPayload + )), + (i.headers["Sec-WebSocket-Extensions"] = $t({ + [Lt.extensionName]: u.offer(), + }))), + s.length) + ) { + for (const e of s) { + if ("string" != typeof e || !Yt.test(e) || d.has(e)) + throw new SyntaxError( + "An invalid or duplicated subprotocol was specified" + ); + d.add(e); + } + i.headers["Sec-WebSocket-Protocol"] = s.join(","); + } + if ( + (i.origin && + (i.protocolVersion < 13 + ? (i.headers["Sec-WebSocket-Origin"] = i.origin) + : (i.headers.Origin = i.origin)), + (n.username || n.password) && (i.auth = `${n.username}:${n.password}`), + a) + ) { + const e = i.path.split(":"); + (i.socketPath = e[0]), (i.path = e[1]); + } + let p = (e._req = l(i)); + i.timeout && + p.on("timeout", () => { + es(e, p, "Opening handshake has timed out"); + }), + p.on("error", (t) => { + null === p || + p.aborted || + ((p = e._req = null), + (e._readyState = Xt.CLOSING), + e.emit("error", t), + e.emitClose()); + }), + p.on("response", (n) => { + const o = n.headers.location, + a = n.statusCode; + if (o && i.followRedirects && a >= 300 && a < 400) { + if (++e._redirects > i.maxRedirects) + return void es(e, p, "Maximum redirects exceeded"); + p.abort(); + const n = new Ct(o, t); + Jt(e, n, s, r); + } else + e.emit("unexpected-response", p, n) || + es(e, p, `Unexpected server response: ${n.statusCode}`); + }), + p.on("upgrade", (t, s, r) => { + if ((e.emit("upgrade", t), e.readyState !== Xt.CONNECTING)) return; + p = e._req = null; + const n = Rt("sha1") + .update(c + Dt) + .digest("base64"); + if (t.headers["sec-websocket-accept"] !== n) + return void es(e, s, "Invalid Sec-WebSocket-Accept header"); + const o = t.headers["sec-websocket-protocol"]; + let a; + if ( + (void 0 !== o + ? d.size + ? d.has(o) || (a = "Server sent an invalid subprotocol") + : (a = "Server sent a subprotocol but none was requested") + : d.size && (a = "Server sent no subprotocol"), + a) + ) + return void es(e, s, a); + o && (e._protocol = o); + const h = t.headers["sec-websocket-extensions"]; + if (void 0 !== h) { + if (!u) { + return void es( + e, + s, + "Server sent a Sec-WebSocket-Extensions header but no extension was requested" + ); + } + let t; + try { + t = Gt(h); + } catch (t) { + return void es(e, s, "Invalid Sec-WebSocket-Extensions header"); + } + const r = Object.keys(t); + if (1 !== r.length || r[0] !== Lt.extensionName) { + return void es( + e, + s, + "Server indicated an extension that was not requested" + ); + } + try { + u.accept(t[Lt.extensionName]); + } catch (t) { + return void es(e, s, "Invalid Sec-WebSocket-Extensions header"); + } + e._extensions[Lt.extensionName] = u; + } + e.setSocket(s, r, { + maxPayload: i.maxPayload, + skipUTF8Validation: i.skipUTF8Validation, + }); + }); +} +function Qt(e) { + return (e.path = e.socketPath), Ot.connect(e); +} +function Zt(e) { + return ( + (e.path = void 0), + e.servername || + "" === e.servername || + (e.servername = Ot.isIP(e.host) ? "" : e.host), + Tt.connect(e) + ); +} +function es(e, t, s) { + e._readyState = Xt.CLOSING; + const r = new Error(s); + Error.captureStackTrace(r, es), + t.setHeader + ? (t.abort(), + t.socket && !t.socket.destroyed && t.socket.destroy(), + t.once("abort", e.emitClose.bind(e)), + e.emit("error", r)) + : (t.destroy(r), + t.once("error", e.emit.bind(e, "error")), + t.once("close", e.emitClose.bind(e))); +} +function ts(e, t, s) { + if (t) { + const s = Ht(t).length; + e._socket ? (e._sender._bufferedBytes += s) : (e._bufferedAmount += s); + } + if (s) { + s( + new Error( + `WebSocket is not open: readyState ${e.readyState} (${ + zt[e.readyState] + })` + ) + ); + } +} +function ss(e, t) { + const s = this[Ft]; + (s._closeFrameReceived = !0), + (s._closeMessage = t), + (s._closeCode = e), + void 0 !== s._socket[Ft] && + (s._socket.removeListener("data", ds), + process.nextTick(cs, s._socket), + 1005 === e ? s.close() : s.close(e, t)); +} +function rs() { + this[Ft]._socket.resume(); +} +function is(e) { + const t = this[Ft]; + void 0 !== t._socket[Ft] && + (t._socket.removeListener("data", ds), + process.nextTick(cs, t._socket), + t.close(e[jt])), + t.emit("error", e); +} +function ns() { + this[Ft].emitClose(); +} +function os(e, t) { + this[Ft].emit("message", e, t); +} +function as(e) { + const t = this[Ft]; + t.pong(e, !t._isServer, Mt), t.emit("ping", e); +} +function hs(e) { + this[Ft].emit("pong", e); +} +function cs(e) { + e.resume(); +} +function ls() { + const e = this[Ft]; + let t; + this.removeListener("close", ls), + this.removeListener("data", ds), + this.removeListener("end", us), + (e._readyState = Xt.CLOSING), + this._readableState.endEmitted || + e._closeFrameReceived || + e._receiver._writableState.errorEmitted || + null === (t = e._socket.read()) || + e._receiver.write(t), + e._receiver.end(), + (this[Ft] = void 0), + clearTimeout(e._closeTimer), + e._receiver._writableState.finished || + e._receiver._writableState.errorEmitted + ? e.emitClose() + : (e._receiver.on("error", ns), e._receiver.on("finish", ns)); +} +function ds(e) { + this[Ft]._receiver.write(e) || this.pause(); +} +function us() { + const e = this[Ft]; + (e._readyState = Xt.CLOSING), e._receiver.end(), this.end(); +} +function ps() { + const e = this[Ft]; + this.removeListener("error", ps), + this.on("error", Mt), + e && ((e._readyState = Xt.CLOSING), this.destroy()); +} +Object.defineProperty(Xt, "CONNECTING", { + enumerable: !0, + value: zt.indexOf("CONNECTING"), +}), + Object.defineProperty(Xt.prototype, "CONNECTING", { + enumerable: !0, + value: zt.indexOf("CONNECTING"), + }), + Object.defineProperty(Xt, "OPEN", { + enumerable: !0, + value: zt.indexOf("OPEN"), + }), + Object.defineProperty(Xt.prototype, "OPEN", { + enumerable: !0, + value: zt.indexOf("OPEN"), + }), + Object.defineProperty(Xt, "CLOSING", { + enumerable: !0, + value: zt.indexOf("CLOSING"), + }), + Object.defineProperty(Xt.prototype, "CLOSING", { + enumerable: !0, + value: zt.indexOf("CLOSING"), + }), + Object.defineProperty(Xt, "CLOSED", { + enumerable: !0, + value: zt.indexOf("CLOSED"), + }), + Object.defineProperty(Xt.prototype, "CLOSED", { + enumerable: !0, + value: zt.indexOf("CLOSED"), + }), + [ + "binaryType", + "bufferedAmount", + "extensions", + "protocol", + "readyState", + "url", + ].forEach((e) => { + Object.defineProperty(Xt.prototype, e, { enumerable: !0 }); + }), + ["open", "error", "close", "message"].forEach((e) => { + Object.defineProperty(Xt.prototype, `on${e}`, { + enumerable: !0, + get() { + for (const t of this.listeners(e)) if (t[Ut]) return t[qt]; + return null; + }, + set(t) { + for (const t of this.listeners(e)) + if (t[Ut]) { + this.removeListener(e, t); + break; + } + "function" == typeof t && this.addEventListener(e, t, { [Ut]: !0 }); + }, + }); + }), + (Xt.prototype.addEventListener = Wt), + (Xt.prototype.removeEventListener = Vt); +const fs = Xt, + _s = process.nextTick, + ys = + "undefined" != typeof navigator && + "string" == typeof navigator.product && + "reactnative" === navigator.product.toLowerCase(); +const ms = { + websocket: class extends M { + constructor(e) { + super(e), (this.supportsBinary = !e.forceBase64); + } + get name() { + return "websocket"; + } + doOpen() { + if (!this.check()) return; + const e = this.uri(), + t = this.opts.protocols, + s = ys + ? {} + : D( + this.opts, + "agent", + "perMessageDeflate", + "pfx", + "key", + "passphrase", + "cert", + "ca", + "ciphers", + "rejectUnauthorized", + "localAddress", + "protocolVersion", + "origin", + "maxPayload", + "family", + "checkServerIdentity" + ); + this.opts.extraHeaders && (s.headers = this.opts.extraHeaders); + try { + this.ws = new fs(e, t, s); + } catch (e) { + return this.emitReserved("error", e); + } + (this.ws.binaryType = this.socket.binaryType || "nodebuffer"), + this.addEventListeners(); + } + addEventListeners() { + (this.ws.onopen = () => { + this.opts.autoUnref && this.ws._socket.unref(), this.onOpen(); + }), + (this.ws.onclose = (e) => + this.onClose({ + description: "websocket connection closed", + context: e, + })), + (this.ws.onmessage = (e) => this.onData(e.data)), + (this.ws.onerror = (e) => this.onError("websocket error", e)); + } + write(e) { + this.writable = !1; + for (let t = 0; t < e.length; t++) { + const s = e[t], + r = t === e.length - 1; + T(s, this.supportsBinary, (e) => { + const t = {}; + if ( + (s.options && (t.compress = s.options.compress), + this.opts.perMessageDeflate) + ) { + ("string" == typeof e ? Buffer.byteLength(e) : e.length) < + this.opts.perMessageDeflate.threshold && (t.compress = !1); + } + try { + this.ws.send(e, t); + } catch (e) {} + r && + _s(() => { + (this.writable = !0), this.emitReserved("drain"); + }, this.setTimeoutFn); + }); + } + } + doClose() { + void 0 !== this.ws && (this.ws.close(), (this.ws = null)); + } + uri() { + let e = this.query || {}; + const t = this.opts.secure ? "wss" : "ws"; + let s = ""; + this.opts.port && + (("wss" === t && 443 !== Number(this.opts.port)) || + ("ws" === t && 80 !== Number(this.opts.port))) && + (s = ":" + this.opts.port), + this.opts.timestampRequests && (e[this.opts.timestampParam] = Y()), + this.supportsBinary || (e.b64 = 1); + const r = K(e); + return ( + t + + "://" + + (-1 !== this.opts.hostname.indexOf(":") + ? "[" + this.opts.hostname + "]" + : this.opts.hostname) + + s + + this.opts.path + + (r.length ? "?" + r : "") + ); + } + check() { + return !!fs; + } + }, + polling: class extends M { + constructor(e) { + if ((super(e), (this.polling = !1), "undefined" != typeof location)) { + const t = "https:" === location.protocol; + let s = location.port; + s || (s = t ? "443" : "80"), + (this.xd = + ("undefined" != typeof location && + e.hostname !== location.hostname) || + s !== e.port), + (this.xs = e.secure !== t); + } + const t = e && e.forceBase64; + this.supportsBinary = re && !t; + } + get name() { + return "polling"; + } + doOpen() { + this.poll(); + } + pause(e) { + this.readyState = "pausing"; + const t = () => { + (this.readyState = "paused"), e(); + }; + if (this.polling || !this.writable) { + let e = 0; + this.polling && + (e++, + this.once("pollComplete", function () { + --e || t(); + })), + this.writable || + (e++, + this.once("drain", function () { + --e || t(); + })); + } else t(); + } + poll() { + (this.polling = !0), this.doPoll(), this.emitReserved("poll"); + } + onData(e) { + ((e, t) => { + const s = e.split(B), + r = []; + for (let e = 0; e < s.length; e++) { + const i = C(s[e], t); + if ((r.push(i), "error" === i.type)) break; + } + return r; + })(e, this.socket.binaryType).forEach((e) => { + if ( + ("opening" === this.readyState && + "open" === e.type && + this.onOpen(), + "close" === e.type) + ) + return ( + this.onClose({ description: "transport closed by the server" }), + !1 + ); + this.onPacket(e); + }), + "closed" !== this.readyState && + ((this.polling = !1), + this.emitReserved("pollComplete"), + "open" === this.readyState && this.poll()); + } + doClose() { + const e = () => { + this.write([{ type: "close" }]); + }; + "open" === this.readyState ? e() : this.once("open", e); + } + write(e) { + (this.writable = !1), + ((e, t) => { + const s = e.length, + r = new Array(s); + let i = 0; + e.forEach((e, n) => { + T(e, !1, (e) => { + (r[n] = e), ++i === s && t(r.join(B)); + }); + }); + })(e, (e) => { + this.doWrite(e, () => { + (this.writable = !0), this.emitReserved("drain"); + }); + }); + } + uri() { + let e = this.query || {}; + const t = this.opts.secure ? "https" : "http"; + let s = ""; + !1 !== this.opts.timestampRequests && + (e[this.opts.timestampParam] = Y()), + this.supportsBinary || e.sid || (e.b64 = 1), + this.opts.port && + (("https" === t && 443 !== Number(this.opts.port)) || + ("http" === t && 80 !== Number(this.opts.port))) && + (s = ":" + this.opts.port); + const r = K(e); + return ( + t + + "://" + + (-1 !== this.opts.hostname.indexOf(":") + ? "[" + this.opts.hostname + "]" + : this.opts.hostname) + + s + + this.opts.path + + (r.length ? "?" + r : "") + ); + } + request(e = {}) { + return ( + Object.assign(e, { xd: this.xd, xs: this.xs }, this.opts), + new ie(this.uri(), e) + ); + } + doWrite(e, t) { + const s = this.request({ method: "POST", data: e }); + s.on("success", t), + s.on("error", (e, t) => { + this.onError("xhr post error", e, t); + }); + } + doPoll() { + const e = this.request(); + e.on("data", this.onData.bind(this)), + e.on("error", (e, t) => { + this.onError("xhr poll error", e, t); + }), + (this.pollXhr = e); + } + }, + }, + gs = + /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, + bs = [ + "source", + "protocol", + "authority", + "userInfo", + "user", + "password", + "host", + "port", + "relative", + "path", + "directory", + "file", + "query", + "anchor", + ]; +function vs(e) { + const t = e, + s = e.indexOf("["), + r = e.indexOf("]"); + -1 != s && + -1 != r && + (e = + e.substring(0, s) + + e.substring(s, r).replace(/:/g, ";") + + e.substring(r, e.length)); + let i = gs.exec(e || ""), + n = {}, + o = 14; + for (; o--; ) n[bs[o]] = i[o] || ""; + return ( + -1 != s && + -1 != r && + ((n.source = t), + (n.host = n.host.substring(1, n.host.length - 1).replace(/;/g, ":")), + (n.authority = n.authority + .replace("[", "") + .replace("]", "") + .replace(/;/g, ":")), + (n.ipv6uri = !0)), + (n.pathNames = (function (e, t) { + const s = /\/{2,9}/g, + r = t.replace(s, "/").split("/"); + ("/" != t.substr(0, 1) && 0 !== t.length) || r.splice(0, 1); + "/" == t.substr(t.length - 1, 1) && r.splice(r.length - 1, 1); + return r; + })(0, n.path)), + (n.queryKey = (function (e, t) { + const s = {}; + return ( + t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function (e, t, r) { + t && (s[t] = r); + }), + s + ); + })(0, n.query)), + n + ); +} +class Es extends P { + constructor(e, t = {}) { + super(), + e && "object" == typeof e && ((t = e), (e = null)), + e + ? ((e = vs(e)), + (t.hostname = e.host), + (t.secure = "https" === e.protocol || "wss" === e.protocol), + (t.port = e.port), + e.query && (t.query = e.query)) + : t.host && (t.hostname = vs(t.host).host), + j(this, t), + (this.secure = + null != t.secure + ? t.secure + : "undefined" != typeof location && "https:" === location.protocol), + t.hostname && !t.port && (t.port = this.secure ? "443" : "80"), + (this.hostname = + t.hostname || + ("undefined" != typeof location ? location.hostname : "localhost")), + (this.port = + t.port || + ("undefined" != typeof location && location.port + ? location.port + : this.secure + ? "443" + : "80")), + (this.transports = t.transports || ["polling", "websocket"]), + (this.readyState = ""), + (this.writeBuffer = []), + (this.prevBufferLen = 0), + (this.opts = Object.assign( + { + path: "/engine.io", + agent: !1, + withCredentials: !1, + upgrade: !0, + timestampParam: "t", + rememberUpgrade: !1, + rejectUnauthorized: !0, + perMessageDeflate: { threshold: 1024 }, + transportOptions: {}, + closeOnBeforeunload: !0, + }, + t + )), + (this.opts.path = this.opts.path.replace(/\/$/, "") + "/"), + "string" == typeof this.opts.query && + (this.opts.query = (function (e) { + let t = {}, + s = e.split("&"); + for (let e = 0, r = s.length; e < r; e++) { + let r = s[e].split("="); + t[decodeURIComponent(r[0])] = decodeURIComponent(r[1]); + } + return t; + })(this.opts.query)), + (this.id = null), + (this.upgrades = null), + (this.pingInterval = null), + (this.pingTimeout = null), + (this.pingTimeoutTimer = null), + "function" == typeof addEventListener && + (this.opts.closeOnBeforeunload && + addEventListener( + "beforeunload", + () => { + this.transport && + (this.transport.removeAllListeners(), this.transport.close()); + }, + !1 + ), + "localhost" !== this.hostname && + ((this.offlineEventListener = () => { + this.onClose("transport close", { + description: "network connection lost", + }); + }), + addEventListener("offline", this.offlineEventListener, !1))), + this.open(); + } + createTransport(e) { + const t = Object.assign({}, this.opts.query); + (t.EIO = 4), (t.transport = e), this.id && (t.sid = this.id); + const s = Object.assign({}, this.opts.transportOptions[e], this.opts, { + query: t, + socket: this, + hostname: this.hostname, + secure: this.secure, + port: this.port, + }); + return new ms[e](s); + } + open() { + let e; + if ( + this.opts.rememberUpgrade && + Es.priorWebsocketSuccess && + -1 !== this.transports.indexOf("websocket") + ) + e = "websocket"; + else { + if (0 === this.transports.length) + return void this.setTimeoutFn(() => { + this.emitReserved("error", "No transports available"); + }, 0); + e = this.transports[0]; + } + this.readyState = "opening"; + try { + e = this.createTransport(e); + } catch (e) { + return this.transports.shift(), void this.open(); + } + e.open(), this.setTransport(e); + } + setTransport(e) { + this.transport && this.transport.removeAllListeners(), + (this.transport = e), + e + .on("drain", this.onDrain.bind(this)) + .on("packet", this.onPacket.bind(this)) + .on("error", this.onError.bind(this)) + .on("close", (e) => this.onClose("transport close", e)); + } + probe(e) { + let t = this.createTransport(e), + s = !1; + Es.priorWebsocketSuccess = !1; + const r = () => { + s || + (t.send([{ type: "ping", data: "probe" }]), + t.once("packet", (e) => { + if (!s) + if ("pong" === e.type && "probe" === e.data) { + if ( + ((this.upgrading = !0), this.emitReserved("upgrading", t), !t) + ) + return; + (Es.priorWebsocketSuccess = "websocket" === t.name), + this.transport.pause(() => { + s || + ("closed" !== this.readyState && + (c(), + this.setTransport(t), + t.send([{ type: "upgrade" }]), + this.emitReserved("upgrade", t), + (t = null), + (this.upgrading = !1), + this.flush())); + }); + } else { + const e = new Error("probe error"); + (e.transport = t.name), this.emitReserved("upgradeError", e); + } + })); + }; + function i() { + s || ((s = !0), c(), t.close(), (t = null)); + } + const n = (e) => { + const s = new Error("probe error: " + e); + (s.transport = t.name), i(), this.emitReserved("upgradeError", s); + }; + function o() { + n("transport closed"); + } + function a() { + n("socket closed"); + } + function h(e) { + t && e.name !== t.name && i(); + } + const c = () => { + t.removeListener("open", r), + t.removeListener("error", n), + t.removeListener("close", o), + this.off("close", a), + this.off("upgrading", h); + }; + t.once("open", r), + t.once("error", n), + t.once("close", o), + this.once("close", a), + this.once("upgrading", h), + t.open(); + } + onOpen() { + if ( + ((this.readyState = "open"), + (Es.priorWebsocketSuccess = "websocket" === this.transport.name), + this.emitReserved("open"), + this.flush(), + "open" === this.readyState && this.opts.upgrade && this.transport.pause) + ) { + let e = 0; + const t = this.upgrades.length; + for (; e < t; e++) this.probe(this.upgrades[e]); + } + } + onPacket(e) { + if ( + "opening" === this.readyState || + "open" === this.readyState || + "closing" === this.readyState + ) + switch ( + (this.emitReserved("packet", e), this.emitReserved("heartbeat"), e.type) + ) { + case "open": + this.onHandshake(JSON.parse(e.data)); + break; + case "ping": + this.resetPingTimeout(), + this.sendPacket("pong"), + this.emitReserved("ping"), + this.emitReserved("pong"); + break; + case "error": + const t = new Error("server error"); + (t.code = e.data), this.onError(t); + break; + case "message": + this.emitReserved("data", e.data), + this.emitReserved("message", e.data); + } + } + onHandshake(e) { + this.emitReserved("handshake", e), + (this.id = e.sid), + (this.transport.query.sid = e.sid), + (this.upgrades = this.filterUpgrades(e.upgrades)), + (this.pingInterval = e.pingInterval), + (this.pingTimeout = e.pingTimeout), + (this.maxPayload = e.maxPayload), + this.onOpen(), + "closed" !== this.readyState && this.resetPingTimeout(); + } + resetPingTimeout() { + this.clearTimeoutFn(this.pingTimeoutTimer), + (this.pingTimeoutTimer = this.setTimeoutFn(() => { + this.onClose("ping timeout"); + }, this.pingInterval + this.pingTimeout)), + this.opts.autoUnref && this.pingTimeoutTimer.unref(); + } + onDrain() { + this.writeBuffer.splice(0, this.prevBufferLen), + (this.prevBufferLen = 0), + 0 === this.writeBuffer.length ? this.emitReserved("drain") : this.flush(); + } + flush() { + if ( + "closed" !== this.readyState && + this.transport.writable && + !this.upgrading && + this.writeBuffer.length + ) { + const e = this.getWritablePackets(); + this.transport.send(e), + (this.prevBufferLen = e.length), + this.emitReserved("flush"); + } + } + getWritablePackets() { + if ( + !( + this.maxPayload && + "polling" === this.transport.name && + this.writeBuffer.length > 1 + ) + ) + return this.writeBuffer; + let e = 1; + for (let s = 0; s < this.writeBuffer.length; s++) { + const r = this.writeBuffer[s].data; + if ( + (r && + (e += + "string" == typeof (t = r) + ? (function (e) { + let t = 0, + s = 0; + for (let r = 0, i = e.length; r < i; r++) + (t = e.charCodeAt(r)), + t < 128 + ? (s += 1) + : t < 2048 + ? (s += 2) + : t < 55296 || t >= 57344 + ? (s += 3) + : (r++, (s += 4)); + return s; + })(t) + : Math.ceil(1.33 * (t.byteLength || t.size))), + s > 0 && e > this.maxPayload) + ) + return this.writeBuffer.slice(0, s); + e += 2; + } + var t; + return this.writeBuffer; + } + write(e, t, s) { + return this.sendPacket("message", e, t, s), this; + } + send(e, t, s) { + return this.sendPacket("message", e, t, s), this; + } + sendPacket(e, t, s, r) { + if ( + ("function" == typeof t && ((r = t), (t = void 0)), + "function" == typeof s && ((r = s), (s = null)), + "closing" === this.readyState || "closed" === this.readyState) + ) + return; + (s = s || {}).compress = !1 !== s.compress; + const i = { type: e, data: t, options: s }; + this.emitReserved("packetCreate", i), + this.writeBuffer.push(i), + r && this.once("flush", r), + this.flush(); + } + close() { + const e = () => { + this.onClose("forced close"), this.transport.close(); + }, + t = () => { + this.off("upgrade", t), this.off("upgradeError", t), e(); + }, + s = () => { + this.once("upgrade", t), this.once("upgradeError", t); + }; + return ( + ("opening" !== this.readyState && "open" !== this.readyState) || + ((this.readyState = "closing"), + this.writeBuffer.length + ? this.once("drain", () => { + this.upgrading ? s() : e(); + }) + : this.upgrading + ? s() + : e()), + this + ); + } + onError(e) { + (Es.priorWebsocketSuccess = !1), + this.emitReserved("error", e), + this.onClose("transport error", e); + } + onClose(e, t) { + ("opening" !== this.readyState && + "open" !== this.readyState && + "closing" !== this.readyState) || + (this.clearTimeoutFn(this.pingTimeoutTimer), + this.transport.removeAllListeners("close"), + this.transport.close(), + this.transport.removeAllListeners(), + "function" == typeof removeEventListener && + removeEventListener("offline", this.offlineEventListener, !1), + (this.readyState = "closed"), + (this.id = null), + this.emitReserved("close", e, t), + (this.writeBuffer = []), + (this.prevBufferLen = 0)); + } + filterUpgrades(e) { + const t = []; + let s = 0; + const r = e.length; + for (; s < r; s++) ~this.transports.indexOf(e[s]) && t.push(e[s]); + return t; + } +} +Es.protocol = 4; +const ws = "function" == typeof ArrayBuffer, + Ss = Object.prototype.toString, + ks = + "function" == typeof Blob || + ("undefined" != typeof Blob && + "[object BlobConstructor]" === Ss.call(Blob)), + xs = + "function" == typeof File || + ("undefined" != typeof File && + "[object FileConstructor]" === Ss.call(File)); +function Os(e) { + return ( + (ws && + (e instanceof ArrayBuffer || + ((e) => + "function" == typeof ArrayBuffer.isView + ? ArrayBuffer.isView(e) + : e.buffer instanceof ArrayBuffer)(e))) || + (ks && e instanceof Blob) || + (xs && e instanceof File) + ); +} +function Ts(e, t) { + if (!e || "object" != typeof e) return !1; + if (Array.isArray(e)) { + for (let t = 0, s = e.length; t < s; t++) if (Ts(e[t])) return !0; + return !1; + } + if (Os(e)) return !0; + if (e.toJSON && "function" == typeof e.toJSON && 1 === arguments.length) + return Ts(e.toJSON(), !0); + for (const t in e) + if (Object.prototype.hasOwnProperty.call(e, t) && Ts(e[t])) return !0; + return !1; +} +function Ns(e) { + const t = [], + s = e.data, + r = e; + return ( + (r.data = Rs(s, t)), (r.attachments = t.length), { packet: r, buffers: t } + ); +} +function Rs(e, t) { + if (!e) return e; + if (Os(e)) { + const s = { _placeholder: !0, num: t.length }; + return t.push(e), s; + } + if (Array.isArray(e)) { + const s = new Array(e.length); + for (let r = 0; r < e.length; r++) s[r] = Rs(e[r], t); + return s; + } + if ("object" == typeof e && !(e instanceof Date)) { + const s = {}; + for (const r in e) + Object.prototype.hasOwnProperty.call(e, r) && (s[r] = Rs(e[r], t)); + return s; + } + return e; +} +function Cs(e, t) { + return (e.data = Ls(e.data, t)), (e.attachments = void 0), e; +} +function Ls(e, t) { + if (!e) return e; + if (e && e._placeholder) return t[e.num]; + if (Array.isArray(e)) for (let s = 0; s < e.length; s++) e[s] = Ls(e[s], t); + else if ("object" == typeof e) + for (const s in e) + Object.prototype.hasOwnProperty.call(e, s) && (e[s] = Ls(e[s], t)); + return e; +} +var As; +!(function (e) { + (e[(e.CONNECT = 0)] = "CONNECT"), + (e[(e.DISCONNECT = 1)] = "DISCONNECT"), + (e[(e.EVENT = 2)] = "EVENT"), + (e[(e.ACK = 3)] = "ACK"), + (e[(e.CONNECT_ERROR = 4)] = "CONNECT_ERROR"), + (e[(e.BINARY_EVENT = 5)] = "BINARY_EVENT"), + (e[(e.BINARY_ACK = 6)] = "BINARY_ACK"); +})(As || (As = {})); +class Bs extends P { + constructor(e) { + super(), (this.reviver = e); + } + add(e) { + let t; + if ("string" == typeof e) + (t = this.decodeString(e)), + t.type === As.BINARY_EVENT || t.type === As.BINARY_ACK + ? ((this.reconstructor = new Ps(t)), + 0 === t.attachments && super.emitReserved("decoded", t)) + : super.emitReserved("decoded", t); + else { + if (!Os(e) && !e.base64) throw new Error("Unknown type: " + e); + if (!this.reconstructor) + throw new Error("got binary data when not reconstructing a packet"); + (t = this.reconstructor.takeBinaryData(e)), + t && ((this.reconstructor = null), super.emitReserved("decoded", t)); + } + } + decodeString(e) { + let t = 0; + const s = { type: Number(e.charAt(0)) }; + if (void 0 === As[s.type]) throw new Error("unknown packet type " + s.type); + if (s.type === As.BINARY_EVENT || s.type === As.BINARY_ACK) { + const r = t + 1; + for (; "-" !== e.charAt(++t) && t != e.length; ); + const i = e.substring(r, t); + if (i != Number(i) || "-" !== e.charAt(t)) + throw new Error("Illegal attachments"); + s.attachments = Number(i); + } + if ("/" === e.charAt(t + 1)) { + const r = t + 1; + for (; ++t; ) { + if ("," === e.charAt(t)) break; + if (t === e.length) break; + } + s.nsp = e.substring(r, t); + } else s.nsp = "/"; + const r = e.charAt(t + 1); + if ("" !== r && Number(r) == r) { + const r = t + 1; + for (; ++t; ) { + const s = e.charAt(t); + if (null == s || Number(s) != s) { + --t; + break; + } + if (t === e.length) break; + } + s.id = Number(e.substring(r, t + 1)); + } + if (e.charAt(++t)) { + const r = this.tryParse(e.substr(t)); + if (!Bs.isPayloadValid(s.type, r)) throw new Error("invalid payload"); + s.data = r; + } + return s; + } + tryParse(e) { + try { + return JSON.parse(e, this.reviver); + } catch (e) { + return !1; + } + } + static isPayloadValid(e, t) { + switch (e) { + case As.CONNECT: + return "object" == typeof t; + case As.DISCONNECT: + return void 0 === t; + case As.CONNECT_ERROR: + return "string" == typeof t || "object" == typeof t; + case As.EVENT: + case As.BINARY_EVENT: + return Array.isArray(t) && t.length > 0; + case As.ACK: + case As.BINARY_ACK: + return Array.isArray(t); + } + } + destroy() { + this.reconstructor && this.reconstructor.finishedReconstruction(); + } +} +class Ps { + constructor(e) { + (this.packet = e), (this.buffers = []), (this.reconPack = e); + } + takeBinaryData(e) { + if ( + (this.buffers.push(e), this.buffers.length === this.reconPack.attachments) + ) { + const e = Cs(this.reconPack, this.buffers); + return this.finishedReconstruction(), e; + } + return null; + } + finishedReconstruction() { + (this.reconPack = null), (this.buffers = []); + } +} +var Is = Object.freeze({ + __proto__: null, + protocol: 5, + get PacketType() { + return As; + }, + Encoder: class { + constructor(e) { + this.replacer = e; + } + encode(e) { + return (e.type !== As.EVENT && e.type !== As.ACK) || !Ts(e) + ? [this.encodeAsString(e)] + : ((e.type = e.type === As.EVENT ? As.BINARY_EVENT : As.BINARY_ACK), + this.encodeAsBinary(e)); + } + encodeAsString(e) { + let t = "" + e.type; + return ( + (e.type !== As.BINARY_EVENT && e.type !== As.BINARY_ACK) || + (t += e.attachments + "-"), + e.nsp && "/" !== e.nsp && (t += e.nsp + ","), + null != e.id && (t += e.id), + null != e.data && (t += JSON.stringify(e.data, this.replacer)), + t + ); + } + encodeAsBinary(e) { + const t = Ns(e), + s = this.encodeAsString(t.packet), + r = t.buffers; + return r.unshift(s), r; + } + }, + Decoder: Bs, +}); +function Ds(e, t, s) { + return ( + e.on(t, s), + function () { + e.off(t, s); + } + ); +} +const Us = Object.freeze({ + connect: 1, + connect_error: 1, + disconnect: 1, + disconnecting: 1, + newListener: 1, + removeListener: 1, +}); +class qs extends P { + constructor(e, t, s) { + super(), + (this.connected = !1), + (this.receiveBuffer = []), + (this.sendBuffer = []), + (this.ids = 0), + (this.acks = {}), + (this.flags = {}), + (this.io = e), + (this.nsp = t), + s && s.auth && (this.auth = s.auth), + this.io._autoConnect && this.open(); + } + get disconnected() { + return !this.connected; + } + subEvents() { + if (this.subs) return; + const e = this.io; + this.subs = [ + Ds(e, "open", this.onopen.bind(this)), + Ds(e, "packet", this.onpacket.bind(this)), + Ds(e, "error", this.onerror.bind(this)), + Ds(e, "close", this.onclose.bind(this)), + ]; + } + get active() { + return !!this.subs; + } + connect() { + return ( + this.connected || + (this.subEvents(), + this.io._reconnecting || this.io.open(), + "open" === this.io._readyState && this.onopen()), + this + ); + } + open() { + return this.connect(); + } + send(...e) { + return e.unshift("message"), this.emit.apply(this, e), this; + } + emit(e, ...t) { + if (Us.hasOwnProperty(e)) + throw new Error('"' + e + '" is a reserved event name'); + t.unshift(e); + const s = { type: As.EVENT, data: t, options: {} }; + if ( + ((s.options.compress = !1 !== this.flags.compress), + "function" == typeof t[t.length - 1]) + ) { + const e = this.ids++, + r = t.pop(); + this._registerAckCallback(e, r), (s.id = e); + } + const r = + this.io.engine && + this.io.engine.transport && + this.io.engine.transport.writable; + return ( + (this.flags.volatile && (!r || !this.connected)) || + (this.connected + ? (this.notifyOutgoingListeners(s), this.packet(s)) + : this.sendBuffer.push(s)), + (this.flags = {}), + this + ); + } + _registerAckCallback(e, t) { + const s = this.flags.timeout; + if (void 0 === s) return void (this.acks[e] = t); + const r = this.io.setTimeoutFn(() => { + delete this.acks[e]; + for (let t = 0; t < this.sendBuffer.length; t++) + this.sendBuffer[t].id === e && this.sendBuffer.splice(t, 1); + t.call(this, new Error("operation has timed out")); + }, s); + this.acks[e] = (...e) => { + this.io.clearTimeoutFn(r), t.apply(this, [null, ...e]); + }; + } + packet(e) { + (e.nsp = this.nsp), this.io._packet(e); + } + onopen() { + "function" == typeof this.auth + ? this.auth((e) => { + this.packet({ type: As.CONNECT, data: e }); + }) + : this.packet({ type: As.CONNECT, data: this.auth }); + } + onerror(e) { + this.connected || this.emitReserved("connect_error", e); + } + onclose(e, t) { + (this.connected = !1), + delete this.id, + this.emitReserved("disconnect", e, t); + } + onpacket(e) { + if (e.nsp === this.nsp) + switch (e.type) { + case As.CONNECT: + if (e.data && e.data.sid) { + const t = e.data.sid; + this.onconnect(t); + } else + this.emitReserved( + "connect_error", + new Error( + "It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)" + ) + ); + break; + case As.EVENT: + case As.BINARY_EVENT: + this.onevent(e); + break; + case As.ACK: + case As.BINARY_ACK: + this.onack(e); + break; + case As.DISCONNECT: + this.ondisconnect(); + break; + case As.CONNECT_ERROR: + this.destroy(); + const t = new Error(e.data.message); + (t.data = e.data.data), this.emitReserved("connect_error", t); + } + } + onevent(e) { + const t = e.data || []; + null != e.id && t.push(this.ack(e.id)), + this.connected + ? this.emitEvent(t) + : this.receiveBuffer.push(Object.freeze(t)); + } + emitEvent(e) { + if (this._anyListeners && this._anyListeners.length) { + const t = this._anyListeners.slice(); + for (const s of t) s.apply(this, e); + } + super.emit.apply(this, e); + } + ack(e) { + const t = this; + let s = !1; + return function (...r) { + s || ((s = !0), t.packet({ type: As.ACK, id: e, data: r })); + }; + } + onack(e) { + const t = this.acks[e.id]; + "function" == typeof t && (t.apply(this, e.data), delete this.acks[e.id]); + } + onconnect(e) { + (this.id = e), + (this.connected = !0), + this.emitBuffered(), + this.emitReserved("connect"); + } + emitBuffered() { + this.receiveBuffer.forEach((e) => this.emitEvent(e)), + (this.receiveBuffer = []), + this.sendBuffer.forEach((e) => { + this.notifyOutgoingListeners(e), this.packet(e); + }), + (this.sendBuffer = []); + } + ondisconnect() { + this.destroy(), this.onclose("io server disconnect"); + } + destroy() { + this.subs && (this.subs.forEach((e) => e()), (this.subs = void 0)), + this.io._destroy(this); + } + disconnect() { + return ( + this.connected && this.packet({ type: As.DISCONNECT }), + this.destroy(), + this.connected && this.onclose("io client disconnect"), + this + ); + } + close() { + return this.disconnect(); + } + compress(e) { + return (this.flags.compress = e), this; + } + get volatile() { + return (this.flags.volatile = !0), this; + } + timeout(e) { + return (this.flags.timeout = e), this; + } + onAny(e) { + return ( + (this._anyListeners = this._anyListeners || []), + this._anyListeners.push(e), + this + ); + } + prependAny(e) { + return ( + (this._anyListeners = this._anyListeners || []), + this._anyListeners.unshift(e), + this + ); + } + offAny(e) { + if (!this._anyListeners) return this; + if (e) { + const t = this._anyListeners; + for (let s = 0; s < t.length; s++) + if (e === t[s]) return t.splice(s, 1), this; + } else this._anyListeners = []; + return this; + } + listenersAny() { + return this._anyListeners || []; + } + onAnyOutgoing(e) { + return ( + (this._anyOutgoingListeners = this._anyOutgoingListeners || []), + this._anyOutgoingListeners.push(e), + this + ); + } + prependAnyOutgoing(e) { + return ( + (this._anyOutgoingListeners = this._anyOutgoingListeners || []), + this._anyOutgoingListeners.unshift(e), + this + ); + } + offAnyOutgoing(e) { + if (!this._anyOutgoingListeners) return this; + if (e) { + const t = this._anyOutgoingListeners; + for (let s = 0; s < t.length; s++) + if (e === t[s]) return t.splice(s, 1), this; + } else this._anyOutgoingListeners = []; + return this; + } + listenersAnyOutgoing() { + return this._anyOutgoingListeners || []; + } + notifyOutgoingListeners(e) { + if (this._anyOutgoingListeners && this._anyOutgoingListeners.length) { + const t = this._anyOutgoingListeners.slice(); + for (const s of t) s.apply(this, e.data); + } + } +} +function js(e) { + (e = e || {}), + (this.ms = e.min || 100), + (this.max = e.max || 1e4), + (this.factor = e.factor || 2), + (this.jitter = e.jitter > 0 && e.jitter <= 1 ? e.jitter : 0), + (this.attempts = 0); +} +(js.prototype.duration = function () { + var e = this.ms * Math.pow(this.factor, this.attempts++); + if (this.jitter) { + var t = Math.random(), + s = Math.floor(t * this.jitter * e); + e = 0 == (1 & Math.floor(10 * t)) ? e - s : e + s; + } + return 0 | Math.min(e, this.max); +}), + (js.prototype.reset = function () { + this.attempts = 0; + }), + (js.prototype.setMin = function (e) { + this.ms = e; + }), + (js.prototype.setMax = function (e) { + this.max = e; + }), + (js.prototype.setJitter = function (e) { + this.jitter = e; + }); +class Fs extends P { + constructor(e, t) { + var s; + super(), + (this.nsps = {}), + (this.subs = []), + e && "object" == typeof e && ((t = e), (e = void 0)), + ((t = t || {}).path = t.path || "/socket.io"), + (this.opts = t), + j(this, t), + this.reconnection(!1 !== t.reconnection), + this.reconnectionAttempts(t.reconnectionAttempts || 1 / 0), + this.reconnectionDelay(t.reconnectionDelay || 1e3), + this.reconnectionDelayMax(t.reconnectionDelayMax || 5e3), + this.randomizationFactor( + null !== (s = t.randomizationFactor) && void 0 !== s ? s : 0.5 + ), + (this.backoff = new js({ + min: this.reconnectionDelay(), + max: this.reconnectionDelayMax(), + jitter: this.randomizationFactor(), + })), + this.timeout(null == t.timeout ? 2e4 : t.timeout), + (this._readyState = "closed"), + (this.uri = e); + const r = t.parser || Is; + (this.encoder = new r.Encoder()), + (this.decoder = new r.Decoder()), + (this._autoConnect = !1 !== t.autoConnect), + this._autoConnect && this.open(); + } + reconnection(e) { + return arguments.length + ? ((this._reconnection = !!e), this) + : this._reconnection; + } + reconnectionAttempts(e) { + return void 0 === e + ? this._reconnectionAttempts + : ((this._reconnectionAttempts = e), this); + } + reconnectionDelay(e) { + var t; + return void 0 === e + ? this._reconnectionDelay + : ((this._reconnectionDelay = e), + null === (t = this.backoff) || void 0 === t || t.setMin(e), + this); + } + randomizationFactor(e) { + var t; + return void 0 === e + ? this._randomizationFactor + : ((this._randomizationFactor = e), + null === (t = this.backoff) || void 0 === t || t.setJitter(e), + this); + } + reconnectionDelayMax(e) { + var t; + return void 0 === e + ? this._reconnectionDelayMax + : ((this._reconnectionDelayMax = e), + null === (t = this.backoff) || void 0 === t || t.setMax(e), + this); + } + timeout(e) { + return arguments.length ? ((this._timeout = e), this) : this._timeout; + } + maybeReconnectOnOpen() { + !this._reconnecting && + this._reconnection && + 0 === this.backoff.attempts && + this.reconnect(); + } + open(e) { + if (~this._readyState.indexOf("open")) return this; + this.engine = new Es(this.uri, this.opts); + const t = this.engine, + s = this; + (this._readyState = "opening"), (this.skipReconnect = !1); + const r = Ds(t, "open", function () { + s.onopen(), e && e(); + }), + i = Ds(t, "error", (t) => { + s.cleanup(), + (s._readyState = "closed"), + this.emitReserved("error", t), + e ? e(t) : s.maybeReconnectOnOpen(); + }); + if (!1 !== this._timeout) { + const e = this._timeout; + 0 === e && r(); + const s = this.setTimeoutFn(() => { + r(), t.close(), t.emit("error", new Error("timeout")); + }, e); + this.opts.autoUnref && s.unref(), + this.subs.push(function () { + clearTimeout(s); + }); + } + return this.subs.push(r), this.subs.push(i), this; + } + connect(e) { + return this.open(e); + } + onopen() { + this.cleanup(), (this._readyState = "open"), this.emitReserved("open"); + const e = this.engine; + this.subs.push( + Ds(e, "ping", this.onping.bind(this)), + Ds(e, "data", this.ondata.bind(this)), + Ds(e, "error", this.onerror.bind(this)), + Ds(e, "close", this.onclose.bind(this)), + Ds(this.decoder, "decoded", this.ondecoded.bind(this)) + ); + } + onping() { + this.emitReserved("ping"); + } + ondata(e) { + this.decoder.add(e); + } + ondecoded(e) { + this.emitReserved("packet", e); + } + onerror(e) { + this.emitReserved("error", e); + } + socket(e, t) { + let s = this.nsps[e]; + return s || ((s = new qs(this, e, t)), (this.nsps[e] = s)), s; + } + _destroy(e) { + const t = Object.keys(this.nsps); + for (const e of t) { + if (this.nsps[e].active) return; + } + this._close(); + } + _packet(e) { + const t = this.encoder.encode(e); + for (let s = 0; s < t.length; s++) this.engine.write(t[s], e.options); + } + cleanup() { + this.subs.forEach((e) => e()), + (this.subs.length = 0), + this.decoder.destroy(); + } + _close() { + (this.skipReconnect = !0), + (this._reconnecting = !1), + this.onclose("forced close"), + this.engine && this.engine.close(); + } + disconnect() { + return this._close(); + } + onclose(e, t) { + this.cleanup(), + this.backoff.reset(), + (this._readyState = "closed"), + this.emitReserved("close", e, t), + this._reconnection && !this.skipReconnect && this.reconnect(); + } + reconnect() { + if (this._reconnecting || this.skipReconnect) return this; + const e = this; + if (this.backoff.attempts >= this._reconnectionAttempts) + this.backoff.reset(), + this.emitReserved("reconnect_failed"), + (this._reconnecting = !1); + else { + const t = this.backoff.duration(); + this._reconnecting = !0; + const s = this.setTimeoutFn(() => { + e.skipReconnect || + (this.emitReserved("reconnect_attempt", e.backoff.attempts), + e.skipReconnect || + e.open((t) => { + t + ? ((e._reconnecting = !1), + e.reconnect(), + this.emitReserved("reconnect_error", t)) + : e.onreconnect(); + })); + }, t); + this.opts.autoUnref && s.unref(), + this.subs.push(function () { + clearTimeout(s); + }); + } + } + onreconnect() { + const e = this.backoff.attempts; + (this._reconnecting = !1), + this.backoff.reset(), + this.emitReserved("reconnect", e); + } +} +const Ms = {}; +function Ws(e, t) { + "object" == typeof e && ((t = e), (e = void 0)); + const s = (function (e, t = "", s) { + let r = e; + (s = s || ("undefined" != typeof location && location)), + null == e && (e = s.protocol + "//" + s.host), + "string" == typeof e && + ("/" === e.charAt(0) && + (e = "/" === e.charAt(1) ? s.protocol + e : s.host + e), + /^(https?|wss?):\/\//.test(e) || + (e = void 0 !== s ? s.protocol + "//" + e : "https://" + e), + (r = vs(e))), + r.port || + (/^(http|ws)$/.test(r.protocol) + ? (r.port = "80") + : /^(http|ws)s$/.test(r.protocol) && (r.port = "443")), + (r.path = r.path || "/"); + const i = -1 !== r.host.indexOf(":") ? "[" + r.host + "]" : r.host; + return ( + (r.id = r.protocol + "://" + i + ":" + r.port + t), + (r.href = + r.protocol + + "://" + + i + + (s && s.port === r.port ? "" : ":" + r.port)), + r + ); + })(e, (t = t || {}).path || "/socket.io"), + r = s.source, + i = s.id, + n = s.path, + o = Ms[i] && n in Ms[i].nsps; + let a; + return ( + t.forceNew || t["force new connection"] || !1 === t.multiplex || o + ? (a = new Fs(r, t)) + : (Ms[i] || (Ms[i] = new Fs(r, t)), (a = Ms[i])), + s.query && !t.query && (t.query = s.queryKey), + a.socket(s.path, t) + ); +} +Object.assign(Ws, { Manager: Fs, Socket: qs, io: Ws, connect: Ws }); +var Vs = "e"; +var $s = "jr", + Gs = "jc"; +const Hs = process.argv.slice(2), + zs = Hs[0], + Ys = Hs[1], + Ks = Hs.slice(2), + Xs = { id: Ys, command: Ks }, + Js = new (class { + constructor(e, t, s = {}) { + (this.url = e), + (this.job = t), + (this.mode = Vs), + (this.buf = {}), + (this.buf.e = ""), + (this.buf.o = ""), + (this.spawn = s.spawn ?? this.spawn.bind(this)), + (this.report = s.report ?? this.report.bind(this)), + (this.onProcClose = s.onProcClose ?? this.onProcClose.bind(this)), + (this.onClose = s.onClose ?? this.onClose.bind(this)); + } + spawn() { + const e = this.job.command, + t = e.shift(); + (this.proc = _.default.spawn(t, e)), + this.proc.stdout.setEncoding("utf8"), + this.proc.stderr.setEncoding("utf8"), + this.proc.stdout.on("data", (e) => this.report(e.toString(), "o")), + this.proc.stderr.on("data", (e) => this.report(e.toString(), "e")), + this.proc.on("close", this.onProcClose); + } + runJob() { + const e = new Fs(this.url, { + query: { mode: this.mode, jobId: this.job.id }, + }); + (this.socket = e.socket("/")), + this.socket.on("connect", this.spawn), + this.socket.on("disconnect", this.onClose); + } + onClose() { + console.log("Server disconnected, terminating process."), + this.proc.kill("SIGINT"); + } + onProcClose(e) { + this.socket.emit(Gs, e), + console.log(`Process finished with code ${e}`), + this.socket.disconnect(); + } + report(e, t) { + (this.buf[t] += e), + this.buf[t].includes("\n") && + (this.buf[t].endsWith("\n") && + (this.buf[t] = this.buf[t].slice(0, -1)), + this.socket.emit($s, this.buf[t]), + "e" === t + ? console.error(`err: ${this.buf[t]}`) + : console.log(`out: ${this.buf[t]}`), + (this.buf[t] = "")); + } + })(zs, Xs, Ks); +Js.runJob(); diff --git a/lib/core/internal-deploy.js b/lib/core/internal-deploy.js index 90ad3e0..3590aed 100644 --- a/lib/core/internal-deploy.js +++ b/lib/core/internal-deploy.js @@ -6,11 +6,10 @@ const jobStr = process.argv.slice(2)[0]; const job = JSON.parse(jobStr); const { command } = job.spec.template.spec.containers[0]; INFO("EXEC", "Internal Executor Starting!"); -cp.exec(command, (error, stdout, stderr)=>{ -if(error) ERR("EXEC", error); -//if(stdout) VERB("EXEC-STDOUT", stdout); -//if(stderr) VERB("EXEC-STDERR", stderr); -OK("EXEC", "Internal Executor Finished!"); -process.exit(error? 1 : 0 ); +cp.exec(command, (error, stdout, stderr) => { + if (error) ERR("EXEC", error); + //if(stdout) VERB("EXEC-STDOUT", stdout); + //if(stderr) VERB("EXEC-STDERR", stderr); + OK("EXEC", "Internal Executor Finished!"); + process.exit(error ? 1 : 0); }); - diff --git a/lib/core/kubernetes.js b/lib/core/kubernetes.js index 3b466d8..e0767c5 100644 --- a/lib/core/kubernetes.js +++ b/lib/core/kubernetes.js @@ -5,9 +5,11 @@ import path from "path"; const internalDeploy = process.env.INTERNAL_DEPLOY === "true"; const executorUrl = process.env.EXECUTOR_URL; const executorScriptOnly = process.env.EXECUTOR_SCRIPT_ONLY === "true"; -const executorBin = process.env.EXECUTOR_BIN ?? `qltr-executor${executorScriptOnly ? ".js": ""}`; +const executorBin = + process.env.EXECUTOR_BIN ?? `qltr-executor${executorScriptOnly ? ".js" : ""}`; -const qualiteerUrl = process.env.QUALITEER_URL ?? "file:///home/runner/Qualiteer/bin/executor"; +const qualiteerUrl = + process.env.QUALITEER_URL ?? "file:///home/runner/Qualiteer/bin/executor"; const kubCmd = "kubectl apply -f"; const jobsDir = "jobs/"; @@ -16,11 +18,15 @@ const defaults = JSON.parse( ); const wrapCommand = (jobId, command) => { - const bin = executorScriptOnly ? `node ${executorBin}`:`chmod +x ${executorBin} && ./${executorBin}`; - const cmd = command.map((arg)=>JSON.stringify(arg)) - const curlCmd = `curl -o qltr-executor ${executorUrl} && ${bin} ${qualiteerUrl} ${jobId} ${cmd.join(" ")}`; + const bin = executorScriptOnly + ? `node ${executorBin}` + : `chmod +x ${executorBin} && ./${executorBin}`; + const cmd = command.map((arg) => JSON.stringify(arg)); + const curlCmd = `curl -o qltr-executor ${executorUrl} && ${bin} ${qualiteerUrl} ${jobId} ${cmd.join( + " " + )}`; return curlCmd; -} +}; const createFile = (job) => { const { name } = job.metadata; diff --git a/lib/core/server.js b/lib/core/server.js index 8ebddbb..de78cf1 100644 --- a/lib/core/server.js +++ b/lib/core/server.js @@ -5,11 +5,15 @@ import express from "express"; import results from "../routes/results-route.js"; import alerting from "../routes/alerting-route.js"; import react from "../routes/react-route.js"; -import tests from "../routes/tests-route.js"; +import catalog from "../routes/catalog-route.js"; import jobs from "../routes/jobs-route.js"; +import mock from "../routes/mock-route.js"; + const app = express(); +// Special Routes app.all("/", (req, res) => res.redirect("/qualiteer")); +if (process.env.MOCK_ROUTES === "true") app.use(mock); // Middlewares @@ -17,7 +21,7 @@ app.all("/", (req, res) => res.redirect("/qualiteer")); app.use(react); // Static Build Route app.use("/api/results", results); app.use("/api/alerting", alerting); -app.use("/api/tests", tests); +app.use("/api/catalog", catalog); app.use("/api/jobs", jobs); export default app; diff --git a/lib/database/TABLES.md b/lib/database/TABLES.md index d128ade..048e05d 100644 --- a/lib/database/TABLES.md +++ b/lib/database/TABLES.md @@ -1,32 +1,34 @@ CREATE SEQUENCE test_results_id_seq; CREATE TABLE test_results ( - id bigint NOT NULL DEFAULT nextval('test_results_seq') PRIMARY KEY, - test_name varchar(255) DEFAULT NULL, - test_class varchar(255) DEFAULT NULL, - test_method varchar(255) DEFAULT NULL, - test_path varchar(255) DEFAULT NULL, - test_type varchar(32) DEFAULT NULL, - test_timestamp timestamptz NOT NULL DEFAULT now(), - test_retry BOOLEAN DEFAULT FALSE, - origin varchar(255) DEFAULT NULL, - failed BOOLEAN DEFAULT FALSE, - failed_message varchar(2047) DEFAULT NULL, - screenshot_url varchar(255) DEFAULT NULL, - weblog_url varchar(255) DEFAULT NULL, +id bigint NOT NULL DEFAULT nextval('test_results_seq') PRIMARY KEY, +test_name varchar(255) DEFAULT NULL, +test_class varchar(255) DEFAULT NULL, +test_method varchar(255) DEFAULT NULL, +test_path varchar(255) DEFAULT NULL, +test_type varchar(32) DEFAULT NULL, +test_timestamp timestamptz NOT NULL DEFAULT now(), +test_retry BOOLEAN DEFAULT FALSE, +origin varchar(255) DEFAULT NULL, +failed BOOLEAN DEFAULT FALSE, +failed_message varchar(2047) DEFAULT NULL, +screenshot_url varchar(255) DEFAULT NULL, +weblog_url varchar(255) DEFAULT NULL, ); ALTER SEQUENCE test_results_id_seq OWNED BY test_results.id; # Tables + PG Database Tables Mapped Out -## ```test_results``` +## `test_results` + | id | test_name | test_class | test_method | test_path | test_type | test_timestamp | test_retry | origin | failed | failed_message | screenshot_url | weblog_url | | int | string | string | string | string | string | timestamp | boolean | string | boolean | string | string | string | | 1 | My Test | My Test Class | My Failing Test Method | My Test Class Path | API | Date.now() | false | Test Suite A | true | Some Failure Messsage | screenshotUrl | weblogUrl | - id Automatically Generated - test_name\* Name of test -- test_class\* Name of class +- test_class\* Name of class - test_method Name of failed method if failed else null - test_path Path to test class - test_type API/UI/Mobile @@ -35,8 +37,5 @@ PG Database Tables Mapped Out - origin Test Suite test belongs to - failed Indicates if the test failed or not - failed_message Failure Message of test or null -- screenshot_url Screenshot of failure +- screenshot_url Screenshot of failure - weblog_url Log from the web console - - - diff --git a/lib/database/migrations/1_create_test_results_table.sql b/lib/database/migrations/1_create_test_results_table.sql index bd65e86..eef75b4 100644 --- a/lib/database/migrations/1_create_test_results_table.sql +++ b/lib/database/migrations/1_create_test_results_table.sql @@ -1,19 +1,14 @@ CREATE SEQUENCE test_results_id_seq; CREATE TABLE test_results ( - id bigint NOT NULL DEFAULT nextval('test_results_seq') PRIMARY KEY, - test_name varchar(255) DEFAULT NULL, - test_class varchar(255) DEFAULT NULL, - test_method varchar(255) DEFAULT NULL, - test_path varchar(255) DEFAULT NULL, - test_type varchar(32) DEFAULT NULL, - test_timestamp timestamptz NOT NULL DEFAULT now(), - test_retry BOOLEAN DEFAULT FALSE, - origin varchar(255) DEFAULT NULL, + id bigint NOT NULL DEFAULT nextval('test_results_id_seq') PRIMARY KEY, + name varchar(255) DEFAULT NULL, + "method" varchar(255) DEFAULT NULL, + env varchar(31) DEFAULT NULL, + "timestamp" TIMESTAMP NOT NULL DEFAULT now(), + retry BOOLEAN DEFAULT FALSE, failed BOOLEAN DEFAULT FALSE, failed_message varchar(2047) DEFAULT NULL, - screenshot_url varchar(255) DEFAULT NULL, - weblog_url varchar(255) DEFAULT NULL, + screenshot varchar(255) DEFAULT NULL, + weblog varchar(255) DEFAULT NULL ); -ALTER SEQUENCE test_results_id_seq OWNED BY test_results.id; - - +ALTER SEQUENCE test_results_id_seq OWNED BY test_results.id; \ No newline at end of file diff --git a/lib/database/migrations/2_create_catalog_table.sql b/lib/database/migrations/2_create_catalog_table.sql new file mode 100644 index 0000000..4a42d7c --- /dev/null +++ b/lib/database/migrations/2_create_catalog_table.sql @@ -0,0 +1,18 @@ +CREATE SEQUENCE test_catalog_id_seq; +CREATE TABLE test_catalog ( + id bigint NOT NULL DEFAULT nextval('test_catalog_id_seq') PRIMARY KEY, + name varchar(255) DEFAULT NULL, + class varchar(255) DEFAULT NULL, + compound BOOLEAN DEFAULT FALSE, + type varchar(31) DEFAULT NULL, + markers varchar(255)[] DEFAULT NULL, + ignored BOOLEAN DEFAULT FALSE, + comment varchar(1023) DEFAULT NULL, + coverage varchar(255)[] DEFAULT NULL, + env varchar(31)[] DEFAULT NULL, + "path" varchar(255) DEFAULT NULL, + regions varchar(15)[] DEFAULT NULL, + origin varchar(255) DEFAULT NULL, + cron varchar(127) DEFAULT NULL +); +ALTER SEQUENCE test_catalog_id_seq OWNED BY test_catalog.id; \ No newline at end of file diff --git a/lib/database/postgres.js b/lib/database/postgres.js index 4326bf3..ea1ecae 100644 --- a/lib/database/postgres.js +++ b/lib/database/postgres.js @@ -2,7 +2,7 @@ import { migrate } from "postgres-migrations"; import createPgp from "pg-promise"; import moment from "moment"; -import { WARN } from "../util/logging.js"; +import { INFO, WARN } from "../util/logging.js"; // Environment Variables const { POSTGRES_DATABASE: database, diff --git a/lib/database/queries/silenced_tests.js b/lib/database/queries/alerting.js similarity index 99% rename from lib/database/queries/silenced_tests.js rename to lib/database/queries/alerting.js index bf1049e..bcbf806 100644 --- a/lib/database/queries/silenced_tests.js +++ b/lib/database/queries/alerting.js @@ -12,4 +12,3 @@ export const getSilencedTests = () => { const query = `SELECT * from ${table}`; return pg.query(query); }; - diff --git a/lib/database/queries/tests.js b/lib/database/queries/catalog.js similarity index 99% rename from lib/database/queries/tests.js rename to lib/database/queries/catalog.js index 82ce5dd..e0c27e1 100644 --- a/lib/database/queries/tests.js +++ b/lib/database/queries/catalog.js @@ -12,4 +12,3 @@ export const getTests = () => { const query = `SELECT * from ${table}`; return pg.query(query); }; - diff --git a/lib/database/queries/results.js b/lib/database/queries/results.js new file mode 100644 index 0000000..1cb0b99 --- /dev/null +++ b/lib/database/queries/results.js @@ -0,0 +1,64 @@ +import pg from "../postgres.js"; +// Imports +import { + insertQuery, + selectWhereAnyQuery, + selectWhereAllQuery, + updateWhereAnyQuery, +} from "../pg-query.js"; +// Constants +const table = "test_results"; +// Queries +export const insertTestResult = (testResult) => { + const { + test_name, + test_class, + test_method, + test_path, + test_type, + test_timestamp, + test_retry, + origin, + failed, + failed_message, + screenshot_url, + expected_screenshot_url, + weblog_url, + } = testResult; + + var query = insertQuery(table, { + test_name, + test_class, + test_method, + test_path, + test_type, + test_timestamp, + test_retry, + origin, + failed, + failed_message, + screenshot_url, + expected_screenshot_url, + weblog_url, + }); + + query += "\n RETURNING *"; + return pg.query(query); +}; + +export const getCurrentlyFailing = () => { + const query = `WITH recent as (SELECT * FROM test_results WHERE (timestamp BETWEEN NOW() - INTERVAL '24 HOURS' AND NOW()) AND NOT(failed AND retry)) SELECT * FROM recent WHERE timestamp = (SELECT MAX(timestamp) FROM recent r2 WHERE recent.name = r2.name) AND failed; +`; + return pg.query(query); + + /*SELECT * FROM test_results WHERE "timestamp" BETWEEN NOW() - INTERVAL '24 HOURS' AND NOW(); <-- Last 24 hours all runs*/ + + /* SELECT * FROM test_results tr1 WHERE timestamp BETWEEN NOW() - INTERVAL '24 HOURS' AND NOW() AND timestamp = (SELECT MAX(timestamp) FROM test_results tr2 WHERE tr1.name = tr2.name); <-- Last 24 hours only most recent + */ +}; + +export const getCurrentlyFailingFull = (env) => { + const query = `WITH recent AS (SELECT * FROM test_results WHERE (timestamp BETWEEN NOW() - INTERVAL '24 HOURS' AND NOW()) AND NOT(failed AND retry) AND env='prod') SELECT * FROM recent INNER JOIN test_catalog USING(name) WHERE timestamp = (SELECT MAX(timestamp) FROM recent r2 WHERE recent.name = r2.name) AND failed; +;`; + return pg.query(query); +}; diff --git a/lib/database/queries/test_results.js b/lib/database/queries/test_results.js deleted file mode 100644 index 64d48f4..0000000 --- a/lib/database/queries/test_results.js +++ /dev/null @@ -1,51 +0,0 @@ -import pg from "../postgres.js"; -// Imports -import { - insertQuery, - selectWhereAnyQuery, - updateWhereAnyQuery, -} from "../pg-query.js"; -// Constants -const table = "test_results"; -// Queries -export const insertTestResult = (testResult) => { - const { - test_name, - test_class, - test_method, - test_path, - test_type, - test_timestamp, - test_retry, - origin, - failed, - failed_message, - screenshot_url, - expected_screenshot_url, - weblog_url, - } = testResult; - - var query = insertQuery(table, { - test_name, - test_class, - test_method, - test_path, - test_type, - test_timestamp, - test_retry, - origin, - failed, - failed_message, - screenshot_url, - expected_screenshot_url, - weblog_url, - }); - - query += "\n RETURNING *"; - return pg.query(query); -}; - -export const getCurrentlyFailing = () => { - const query = "SELECT *"; - return pg.query(query); -}; diff --git a/lib/routes/alerting-route.js b/lib/routes/alerting-route.js index f328235..31d9b90 100644 --- a/lib/routes/alerting-route.js +++ b/lib/routes/alerting-route.js @@ -1,5 +1,5 @@ import { Router, json as jsonMiddleware } from "express"; -import { getSilencedTests } from "../database/queries/silenced_tests.js"; +import { getSilencedTests } from "../database/queries/alerting.js"; const router = Router(); // Apply Middlewares @@ -11,8 +11,8 @@ router.get("/silenced", (req, res) => { }); // Post Routes -router.post("/silence", (req,res)=>{ - res.sendStatus(200); +router.post("/silence", (req, res) => { + res.sendStatus(200); }); export default router; diff --git a/lib/routes/tests-route.js b/lib/routes/catalog-route.js similarity index 70% rename from lib/routes/tests-route.js rename to lib/routes/catalog-route.js index 2cb1d38..a2f5b41 100644 --- a/lib/routes/tests-route.js +++ b/lib/routes/catalog-route.js @@ -1,11 +1,11 @@ import { Router, json as jsonMiddleware } from "express"; -import { getTests } from "../database/queries/tests.js"; +import { getTests } from "../database/queries/catalog.js"; const router = Router(); const maxSize = 1024 * 1024 * 100; // 100MB // Apply Middlewares -router.use(jsonMiddleware({limit: maxSize})); +router.use(jsonMiddleware({ limit: maxSize })); // Get Routes router.get("/tests", async (req, res) => { @@ -14,7 +14,7 @@ router.get("/tests", async (req, res) => { }); // Post Routes -router.post("/update", (req,res)=>{ +router.post("/update", (req, res) => { // Update All Tests res.sendStatus(200); }); diff --git a/lib/routes/jobs-route.js b/lib/routes/jobs-route.js index b007a19..c5149e8 100644 --- a/lib/routes/jobs-route.js +++ b/lib/routes/jobs-route.js @@ -4,9 +4,9 @@ import jobs from "../core/JobManager.js"; const router = Router(); router.get("/jobs", (req, res) => { - const { clients } = jobs; + const { clients } = jobs; const allJobs = []; - for(var c of clients) allJobs.push(...c.jobs); + for (var c of clients) allJobs.push(...c.jobs); res.json(allJobs); }); export default router; diff --git a/lib/routes/mock-route.js b/lib/routes/mock-route.js new file mode 100644 index 0000000..a88bf2f --- /dev/null +++ b/lib/routes/mock-route.js @@ -0,0 +1,37 @@ +import { Router } from "express"; +import { readFileSync } from "fs"; + +const router = Router(); + +const catalog = "lib/routes/mocks/catalog.json"; +const alerting = "lib/routes/mocks/alerting.json"; +const results = "lib/routes/mocks/results.json"; + +const query = async (mock) => JSON.parse(readFileSync(mock)); + +// Queries +router.get("/api/catalog/tests", (req, res) => { + query(catalog).then((catalog) => { + res.json(req.get("full") ? catalog["tests:full"] : catalog.tests); + }); +}); + +router.get("/api/results/failing", async (req, res) => { + query(results).then(async (results) => { + if (req.get("count")) res.json({ failing: results.results.length }); + else if (!req.get("full")) res.json(results.results); + else + query(catalog).then((catalog) => { + res.json( + results.results.map((r) => ({ + ...catalog["tests:full"].find((t) => t.name === r.name), + ...r, + })) + ); + }); + }); +}); + +// Mutations + +export default router; diff --git a/lib/routes/mocks/alerting.json b/lib/routes/mocks/alerting.json new file mode 100644 index 0000000..f98f5cc --- /dev/null +++ b/lib/routes/mocks/alerting.json @@ -0,0 +1,32 @@ +{ + "silenced": [ + { + "name": "Test1", + "class": "TestClass1", + "method": "TestMethod1", + "regions": ["us"], + "alerting": "MyUtcDate" + }, + { + "name": "Test2", + "class": null, + "method": "TestMethod1", + "regions": [], + "alerting": "MyUtcDate" + }, + { + "name": "*", + "class": "*", + "method": "TestMethod1", + "regions": [], + "alerting": "MyUtcDate" + }, + { + "name": "Test3", + "class": "TestClass3", + "method": "*", + "regions": ["us", "au"], + "alerting": "MyUtcDate" + } + ] +} diff --git a/lib/routes/mocks/catalog.json b/lib/routes/mocks/catalog.json new file mode 100644 index 0000000..bf89bf3 --- /dev/null +++ b/lib/routes/mocks/catalog.json @@ -0,0 +1,92 @@ +{ + "tests": [ + { + "name": "Test 1", + "class": "Test Class 1", + "compound": false, + "type": "api" + }, + { + "name": "Test 2", + "class": "Test Class 2", + "compound": false, + "type": "ui" + }, + { + "name": "Test Primary", + "class": "Test Class Primary", + "compound": true, + "type": "api" + }, + { + "name": "Test Secondary", + "class": "Test Class Secondary", + "compound": true, + "type": "ui" + } + ], + "tests:full": [ + { + "name": "Test1", + "class": "TestClass1", + "compound": false, + "type": "api", + "markers": ["Service1"], + "ignored": false, + "comment": "This Comment Is Part Of Test 1", + "coverage": ["/api/test1", "/api/test2"], + "env": ["prod", "ci"], + "path": "tests/api/test1.js", + "regions": ["us", "ca"], + "origin": "Repo1", + "cron": "1hour" + }, + { + "name": "Test2", + "class": "TestClass2", + "compound": false, + "type": "ui", + "markers": ["Service2"], + "ignored": false, + "comment": "Comment belonging to Test2", + "coverage": ["Page1/FeatureA"], + "env": ["prod"], + "path": "tests/ui/test2.js", + "regions": [], + "origin": "Repo2", + "cron": "30min" + }, + { + "name": "TestPrimary", + "class": "TestClassPrimary", + "compound": true, + "type": "api", + "markers": [ + "ServiceComplex", + "compound_Repo2!TestClassSecondary#TestSecondary" + ], + "ignored": false, + "comment": "Comment belonging to Test Primary", + "coverage": ["/api/compound"], + "env": ["ci"], + "path": "tests/api/primary.js", + "regions": [], + "origin": "Repo1", + "cron": "2hour" + }, + { + "name": "TestSecondary", + "class": "TestClassSecondary", + "compound": true, + "type": "ui", + "markers": ["ServiceComplex"], + "ignored": false, + "coverage": ["PageComplex/FeatureA"], + "env": ["ci"], + "path": "tests/ui/secondary.js", + "regions": [], + "origin": "Repo2", + "cron": "2hour" + } + ] +} diff --git a/lib/routes/mocks/results.json b/lib/routes/mocks/results.json new file mode 100644 index 0000000..c0ddf9c --- /dev/null +++ b/lib/routes/mocks/results.json @@ -0,0 +1,48 @@ +{ + "results": [ + { + "name": "Test1", + "method": "Test1Method", + "env": "prod", + "timestamp": "2022-05-10T16:35:27.220Z", + "retry": false, + "failed": true, + "failed_message": "Some failure message", + "screenshot": "https://example.com", + "weblog": "https://example.com" + }, + { + "name": "Test2", + "method": "Test2Method", + "env": "prod", + "timestamp": "2022-05-10T16:35:31.682Z", + "retry": false, + "failed": true, + "failed_message": "Some failure message 2", + "screenshot": "https://example.com", + "weblog": "https://example.com" + }, + { + "name": "Test1", + "method": null, + "env": "prod", + "timestamp": "2022-05-10T16:35:33.810Z", + "retry": false, + "failed": false, + "failed_message": null, + "screenshot": "https://example.com", + "weblog": "https://example.com" + }, + { + "name": "Test1", + "method": null, + "env": "ci", + "timestamp": "2022-05-10T16:35:33.810Z", + "retry": false, + "failed": false, + "failed_message": null, + "screenshot": "https://example.com", + "weblog": "https://example.com" + } + ] +} diff --git a/lib/routes/results-route.js b/lib/routes/results-route.js index 8675d09..025b8ff 100644 --- a/lib/routes/results-route.js +++ b/lib/routes/results-route.js @@ -1,5 +1,5 @@ import { Router, json as jsonMiddleware } from "express"; -import { getCurrentlyFailing } from "../database/queries/test_results.js"; +import { getCurrentlyFailing } from "../database/queries/results.js"; const router = Router(); // Apply Middlewares @@ -11,8 +11,8 @@ router.get("/failing", (req, res) => { }); // Post Routes -router.post("/history", (req,res)=>{ - res.send([]); +router.post("/history", (req, res) => { + res.send([]); }); export default router; diff --git a/lib/sockets/clients/Executor.js b/lib/sockets/clients/Executor.js index 88bb68e..b1db3ca 100644 --- a/lib/sockets/clients/Executor.js +++ b/lib/sockets/clients/Executor.js @@ -67,7 +67,8 @@ export default class Executor { report(d, dType) { this.buf[dType] += d; if (!this.buf[dType].includes("\n")) return; - if(this.buf[dType].endsWith("\n")) this.buf[dType] = this.buf[dType].slice(0, -1); + if (this.buf[dType].endsWith("\n")) + this.buf[dType] = this.buf[dType].slice(0, -1); this.socket.emit(events.JOB_REP, this.buf[dType]); if (dType === ERR) console.error(`err: ${this.buf[dType]}`); else console.log(`out: ${this.buf[dType]}`); diff --git a/package-lock.json b/package-lock.json index 05edad5..1479e7e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "qualiteer", - "version": "1.0.0", + "version": "0.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "qualiteer", - "version": "1.0.0", + "version": "0.0.1", "license": "LGPL-2.1-only", "dependencies": { "amqplib": "^0.8.0", @@ -18,12 +18,13 @@ "path": "^0.12.7", "pg-promise": "^10.11.1", "postgres-migrations": "^5.3.0", + "react-router-dom": "^6.3.0", "socket.io": "^4.4.1", "socket.io-client": "^4.4.1", "uuid": "^8.3.2" }, "bin": { - "qualiteer": "bin/app.js" + "qualiteer": "dist/app.js" }, "devDependencies": { "@emotion/react": "^11.9.0", @@ -33,6 +34,7 @@ "@rollup/plugin-commonjs": "^22.0.0", "@rollup/plugin-node-resolve": "^13.3.0", "@rollup/plugin-replace": "^4.0.0", + "axios": "^0.27.2", "caxa": "^2.1.0", "nodemon": "^2.0.15", "react": "^18.1.0", @@ -1904,7 +1906,6 @@ "version": "7.17.9", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.17.9.tgz", "integrity": "sha512-lSiBBvodq29uShpWGNbgFdKYNiFDo5/HIYsaCEY9ff4sb10x9jizo2+pRrSyF4jKZCXqgzuqBOQKbUm90gQwJg==", - "dev": true, "dependencies": { "regenerator-runtime": "^0.13.4" }, @@ -5160,6 +5161,30 @@ "node": ">=4" } }, + "node_modules/axios": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "dev": true, + "dependencies": { + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + } + }, + "node_modules/axios/node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dev": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/axobject-query": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", @@ -9674,6 +9699,14 @@ "he": "bin/he" } }, + "node_modules/history": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/history/-/history-5.3.0.tgz", + "integrity": "sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==", + "dependencies": { + "@babel/runtime": "^7.7.6" + } + }, "node_modules/hoist-non-react-statics": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", @@ -12764,8 +12797,7 @@ "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, "node_modules/js-yaml": { "version": "3.14.1", @@ -13173,7 +13205,6 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", - "dev": true, "dependencies": { "js-tokens": "^3.0.0 || ^4.0.0" }, @@ -15814,7 +15845,6 @@ "version": "18.1.0", "resolved": "https://registry.npmjs.org/react/-/react-18.1.0.tgz", "integrity": "sha512-4oL8ivCz5ZEPyclFQXaNksK3adutVS8l2xzZU0cqEFrE9Sb7fC0EFK5uEk74wIreL1DERyjvsU915j1pcT2uEQ==", - "dev": true, "dependencies": { "loose-envify": "^1.1.0" }, @@ -16012,7 +16042,6 @@ "version": "18.1.0", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.1.0.tgz", "integrity": "sha512-fU1Txz7Budmvamp7bshe4Zi32d0ll7ect+ccxNu9FlObT605GOEB8BfO4tmRJ39R5Zj831VCpvQ05QPBW5yb+w==", - "dev": true, "dependencies": { "loose-envify": "^1.1.0", "scheduler": "^0.22.0" @@ -16042,6 +16071,30 @@ "node": ">=0.10.0" } }, + "node_modules/react-router": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.3.0.tgz", + "integrity": "sha512-7Wh1DzVQ+tlFjkeo+ujvjSqSJmkt1+8JO+T5xklPlgrh70y7ogx75ODRW0ThWhY7S+6yEDks8TYrtQe/aoboBQ==", + "dependencies": { + "history": "^5.2.0" + }, + "peerDependencies": { + "react": ">=16.8" + } + }, + "node_modules/react-router-dom": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.3.0.tgz", + "integrity": "sha512-uaJj7LKytRxZNQV8+RbzJWnJ8K2nPsOOEuX7aQstlMZKQT0164C+X2w6bnkqU3sjtLvpd5ojrezAyfZ1+0sStw==", + "dependencies": { + "history": "^5.2.0", + "react-router": "6.3.0" + }, + "peerDependencies": { + "react": ">=16.8", + "react-dom": ">=16.8" + } + }, "node_modules/react-scripts": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-5.0.1.tgz", @@ -16407,8 +16460,7 @@ "node_modules/regenerator-runtime": { "version": "0.13.9", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", - "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==", - "dev": true + "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==" }, "node_modules/regenerator-transform": { "version": "0.15.0", @@ -16913,7 +16965,6 @@ "version": "0.22.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.22.0.tgz", "integrity": "sha512-6QAm1BgQI88NPYymgGQLCZgvep4FyePDWFpXVK+zNSUgHwlqpJy8VEh8Et0KxTACS4VWwMousBElAZOH9nkkoQ==", - "dev": true, "dependencies": { "loose-envify": "^1.1.0" } @@ -21090,7 +21141,6 @@ "version": "7.17.9", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.17.9.tgz", "integrity": "sha512-lSiBBvodq29uShpWGNbgFdKYNiFDo5/HIYsaCEY9ff4sb10x9jizo2+pRrSyF4jKZCXqgzuqBOQKbUm90gQwJg==", - "dev": true, "requires": { "regenerator-runtime": "^0.13.4" } @@ -23495,6 +23545,29 @@ "integrity": "sha512-gd1kmb21kwNuWr6BQz8fv6GNECPBnUasepcoLbekws23NVBLODdsClRZ+bQ8+9Uomf3Sm3+Vwn0oYG9NvwnJCw==", "dev": true }, + "axios": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "dev": true, + "requires": { + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + }, + "dependencies": { + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dev": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } + } + }, "axobject-query": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", @@ -26887,6 +26960,14 @@ "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true }, + "history": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/history/-/history-5.3.0.tgz", + "integrity": "sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==", + "requires": { + "@babel/runtime": "^7.7.6" + } + }, "hoist-non-react-statics": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", @@ -29151,8 +29232,7 @@ "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, "js-yaml": { "version": "3.14.1", @@ -29495,7 +29575,6 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", - "dev": true, "requires": { "js-tokens": "^3.0.0 || ^4.0.0" } @@ -31312,7 +31391,6 @@ "version": "18.1.0", "resolved": "https://registry.npmjs.org/react/-/react-18.1.0.tgz", "integrity": "sha512-4oL8ivCz5ZEPyclFQXaNksK3adutVS8l2xzZU0cqEFrE9Sb7fC0EFK5uEk74wIreL1DERyjvsU915j1pcT2uEQ==", - "dev": true, "requires": { "loose-envify": "^1.1.0" } @@ -31455,7 +31533,6 @@ "version": "18.1.0", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.1.0.tgz", "integrity": "sha512-fU1Txz7Budmvamp7bshe4Zi32d0ll7ect+ccxNu9FlObT605GOEB8BfO4tmRJ39R5Zj831VCpvQ05QPBW5yb+w==", - "dev": true, "requires": { "loose-envify": "^1.1.0", "scheduler": "^0.22.0" @@ -31479,6 +31556,23 @@ "integrity": "sha512-F27qZr8uUqwhWZboondsPx8tnC3Ct3SxZA3V5WyEvujRyyNv0VYPhoBg1gZ8/MV5tubQp76Trw8lTv9hzRBa+A==", "dev": true }, + "react-router": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.3.0.tgz", + "integrity": "sha512-7Wh1DzVQ+tlFjkeo+ujvjSqSJmkt1+8JO+T5xklPlgrh70y7ogx75ODRW0ThWhY7S+6yEDks8TYrtQe/aoboBQ==", + "requires": { + "history": "^5.2.0" + } + }, + "react-router-dom": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.3.0.tgz", + "integrity": "sha512-uaJj7LKytRxZNQV8+RbzJWnJ8K2nPsOOEuX7aQstlMZKQT0164C+X2w6bnkqU3sjtLvpd5ojrezAyfZ1+0sStw==", + "requires": { + "history": "^5.2.0", + "react-router": "6.3.0" + } + }, "react-scripts": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-5.0.1.tgz", @@ -31727,8 +31821,7 @@ "regenerator-runtime": { "version": "0.13.9", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", - "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==", - "dev": true + "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==" }, "regenerator-transform": { "version": "0.15.0", @@ -32072,7 +32165,6 @@ "version": "0.22.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.22.0.tgz", "integrity": "sha512-6QAm1BgQI88NPYymgGQLCZgvep4FyePDWFpXVK+zNSUgHwlqpJy8VEh8Et0KxTACS4VWwMousBElAZOH9nkkoQ==", - "dev": true, "requires": { "loose-envify": "^1.1.0" } diff --git a/package.json b/package.json index aaf16d4..f027423 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "start:react": "react-scripts start", "start:react:replit": "DANGEROUSLY_DISABLE_HOST_CHECK=true npm run start:react", "test": "node tests/index.js", + "test:api": "node tests/api.js", "test:dev": "nodemon tests/index.js" }, "browserslist": { @@ -49,6 +50,7 @@ "path": "^0.12.7", "pg-promise": "^10.11.1", "postgres-migrations": "^5.3.0", + "react-router-dom": "^6.3.0", "socket.io": "^4.4.1", "socket.io-client": "^4.4.1", "uuid": "^8.3.2" @@ -61,6 +63,7 @@ "@rollup/plugin-commonjs": "^22.0.0", "@rollup/plugin-node-resolve": "^13.3.0", "@rollup/plugin-replace": "^4.0.0", + "axios": "^0.27.2", "caxa": "^2.1.0", "nodemon": "^2.0.15", "react": "^18.1.0", diff --git a/public/assets/QA.jpg b/public/assets/QA.jpg deleted file mode 100644 index 519c194..0000000 Binary files a/public/assets/QA.jpg and /dev/null differ diff --git a/public/assets/QA.png b/public/assets/QA.png new file mode 100644 index 0000000..0c7813c Binary files /dev/null and b/public/assets/QA.png differ diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..0319194 Binary files /dev/null and b/public/favicon.ico differ diff --git a/rollup.config.js b/rollup.config.js index 0dcd42a..412c6d0 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -6,7 +6,7 @@ export default { input: "lib/core/executor.js", output: { file: "dist/bundles/qualiteer-executor.js", - format: "cjs" + format: "cjs", }, plugins: [nodeResolve(), commonjs(), terser()], }; diff --git a/src/Dashboard.jsx b/src/Dashboard.jsx index c529f7d..fa66f17 100644 --- a/src/Dashboard.jsx +++ b/src/Dashboard.jsx @@ -1,10 +1,7 @@ -import { useContext } from "react"; - // Import Contexts import { JobProvider } from "./ctx/JobContext.jsx"; -import { ViewProvider } from "./ctx/ViewContext.jsx"; import { StoreProvider } from "./ctx/StoreContext.jsx"; - +import { BrowserRouter } from "react-router-dom"; // Import Views import Views from "./Views.jsx"; @@ -13,9 +10,9 @@ export default function Dashboard() {
- + - +
diff --git a/src/Views.jsx b/src/Views.jsx index 1e70e6e..7c4e3d1 100644 --- a/src/Views.jsx +++ b/src/Views.jsx @@ -1,21 +1,23 @@ import { useContext, useState } from "react"; -import ViewContext from "./ctx/ViewContext.jsx"; - import * as React from "react"; +import { + Routes, + Route, + Link, + BrowserRouter, + Navigate, + useLocation, +} from "react-router-dom"; import AppBar from "@mui/material/AppBar"; +import Badge, { BadgeProps } from "@mui/material/Badge"; +import { styled } from "@mui/material/styles"; import Box from "@mui/material/Box"; import Toolbar from "@mui/material/Toolbar"; import IconButton from "@mui/material/IconButton"; import Typography from "@mui/material/Typography"; -import Menu from "@mui/material/Menu"; import MenuIcon from "@mui/icons-material/Menu"; -import Container from "@mui/material/Container"; import Avatar from "@mui/material/Avatar"; -import Button from "@mui/material/Button"; -import Tooltip from "@mui/material/Tooltip"; -import MenuItem from "@mui/material/MenuItem"; import Drawer from "@mui/material/Drawer"; -import ListItem from "@mui/material/ListItem"; import ListItemIcon from "@mui/material/ListItemIcon"; import ListItemText from "@mui/material/ListItemText"; import List from "@mui/material/List"; @@ -24,79 +26,124 @@ import NotificationsIcon from "@mui/icons-material/Notifications"; import WorkIcon from "@mui/icons-material/Work"; import FormatListBulletedIcon from "@mui/icons-material/FormatListBulleted"; import SettingsIcon from "@mui/icons-material/Settings"; -import ErrorIcon from "@mui/icons-material/Error"; +import WarningIcon from "@mui/icons-material/Warning"; +import InfoIcon from "@mui/icons-material/Info"; +// Import Pages +import Failing from "./views/Failing.jsx"; +import Alerting from "./views/Alerting.jsx"; +import Jobs from "./views/Jobs.jsx"; +import Catalog from "./views/Catalog.jsx"; +import Settings from "./views/Settings.jsx"; +import About from "./views/About.jsx"; -const pages = ["failing", "alerting", "jobs", "tests", "settings"]; +const pages = ["failing", "alerting", "jobs", "catalog", "settings", "about"]; const icons = [ - ErrorIcon, - NotificationsIcon, - WorkIcon, - FormatListBulletedIcon, - SettingsIcon, + + + , + , + + + , + , + , + , ]; +const drawerWidth = 240; + export default function Views() { - const [view, setView] = useState(pages[0]); + const location = useLocation(); const [drawerOpen, setDrawer] = React.useState(false); const toggleDrawer = () => setDrawer(!drawerOpen); const closeDrawer = () => setDrawer(false); - const openPage = (e) => setView(e.target.outerText.toLowerCase()); + + const reloadPage = () => window.location.reload(false); + + const SideBadge = styled(Badge)(({ theme }) => ({ + "& .MuiBadge-badge": { + right: -6, + top: 10, + padding: "0 4px", + }, + })); + + const navHeader = () => { + const pathStr = + location.pathname.charAt(1).toUpperCase() + location.pathname.slice(2); + if (location.pathname !== "/failing") return pathStr; + return ( + + {pathStr} + + ); + }; return ( - - - - - {" "} - - - {pages.map((text, index) => ( - - {/*icons[index]*/} - - - ))} - - - - - - - - {view.charAt(0).toUpperCase() + view.slice(1)} - - - {view.charAt(0).toUpperCase() + view.slice(1)} - - - - - - - +
+ theme.zIndex.drawer + 1 }} + > + + + + + + + + + + {pages.map((text, index) => ( + + {icons[index]} + + + ))} + + + + + {navHeader()} + + + + + + + + + + } /> + } /> + } /> + } /> + } /> + } /> + } /> + + +
); } diff --git a/src/ctx/JobContext.jsx b/src/ctx/JobContext.jsx index 010b4c4..10a8d73 100644 --- a/src/ctx/JobContext.jsx +++ b/src/ctx/JobContext.jsx @@ -36,16 +36,32 @@ const reducer = (state, action) => { } }; + + export const JobProvider = ({ children }) => { const [state, dispatch] = useReducer(reducer, initialState); + const jobUpdate = (job, jobId) => dispatch({ type: ACTIONS.UPDATE, jobId, job }); + const jobCreate = (job) => + dispatch({ type: ACTIONS.CREATE, job: { ...job, log: [] } }); + const jobDelete = (jobId) => dispatch({ type: ACTIONS.DELETE, jobId }); + + function retryAll(failing){ + // Query Full Locator + console.log("Would retry all failing tests!"); +} + +function jobBuilder(){ + +} + const context = { state, dispatch, - jobUpdate: (job, jobId) => dispatch({ type: ACTIONS.UPDATE, jobId, job }), - jobCreate: (job) => - dispatch({ type: ACTIONS.CREATE, job: { ...job, log: [] } }), - jobDelete: (jobId) => dispatch({ type: ACTIONS.DELETE, jobId }), + jobUpdate, + jobCreate, + jobDelete, + retryAll }; const contextValue = useMemo(() => context, [state, dispatch]); diff --git a/src/ctx/StoreContext.jsx b/src/ctx/StoreContext.jsx index 9ed8246..ff71176 100644 --- a/src/ctx/StoreContext.jsx +++ b/src/ctx/StoreContext.jsx @@ -5,9 +5,18 @@ const ACTIONS = { UPDATE: "u", }; -const initialState = {}; +const initialState = { + intervals: [], + failing: [], + regions: [], + focusJob: false, + simplifiedControls: false, + defaultRegion: "us", // Local Store + defaultPage: "failing", // Local Store +}; const reducer = (state, action) => { + const { store } = action; // Actions switch (action.type) { case ACTIONS.UPDATE: @@ -23,7 +32,7 @@ export const StoreProvider = ({ children }) => { const context = { state, dispatch, - updateStore: (store) => dispatch(state, { type: ACTIONS.UPDATE, store }), + updateStore: (store) => dispatch({ type: ACTIONS.UPDATE, store }), }; const contextValue = useMemo(() => context, [state, dispatch]); diff --git a/src/ctx/ViewContext.jsx b/src/ctx/ViewContext.jsx deleted file mode 100644 index b1519d1..0000000 --- a/src/ctx/ViewContext.jsx +++ /dev/null @@ -1,32 +0,0 @@ -import React, { useReducer, createContext, useMemo } from "react"; -const ViewContext = createContext(); - -const ACTIONS = { - UPDATE: "u", -}; - -const initialState = { - activePage: "Home", -}; - -const reducer = (state, action) => { - // Actions - switch (action.type) { - case ACTIONS.UPDATE: - return { ...state }; - default: - return state; - } -}; - -export const ViewProvider = ({ children }) => { - const [state, dispatch] = useReducer(reducer, initialState); - - const contextValue = useMemo(() => ({ state, dispatch }), [state, dispatch]); - - return ( - {children} - ); -}; - -export default ViewContext; diff --git a/src/views/About.jsx b/src/views/About.jsx new file mode 100644 index 0000000..98f28bb --- /dev/null +++ b/src/views/About.jsx @@ -0,0 +1,32 @@ +import Typography from "@mui/material/Typography"; +import Link from "@mui/material/Link"; +import Container from "@mui/material/Container"; +import Box from "@mui/material/Box"; + +const memeUrl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"; +const repoUrl = "https://gitlab.com/dunemask/Qualiteer"; + +export default function About() { + return ( +
+ + + Why? + + + Qualiteer was designed to solve the issue of "on call". A state of being in which QA tests will fail, stiring everyone into a frenzy of what is broken in production! 🤯 + Qualiteer gives users power to resolve and reattempt failing tests, run a particular suite of tests, and mute pesky alerts reminding you the navbar's color changed... 🤦‍♂️ + +
+ + {"Repository: "} + {repoUrl} + +
+
+ Qualiteer +
+
+
+ ); +} diff --git a/src/views/Alerting.jsx b/src/views/Alerting.jsx new file mode 100644 index 0000000..55dce25 --- /dev/null +++ b/src/views/Alerting.jsx @@ -0,0 +1,61 @@ +import { useState, useContext } from "react"; +import StoreContext from "../ctx/StoreContext.jsx"; + +import SpeedDial from '@mui/material/SpeedDial'; +import SpeedDialAction from '@mui/material/SpeedDialAction'; +import SpeedDialIcon from '@mui/material/SpeedDialIcon'; + +import Button from '@mui/material/Button'; +import Dialog from '@mui/material/Dialog'; +import DialogActions from '@mui/material/DialogActions'; +import DialogContent from '@mui/material/DialogContent'; +import DialogContentText from '@mui/material/DialogContentText'; +import DialogTitle from '@mui/material/DialogTitle'; + +export default function Alerting() { + const { state: store, updateStore } = useContext(StoreContext); + + const [alertDialogOpen, setAlertDialogOpen] = useState(false); + const quickAlertClick = () => setAlertDialogOpen(!alertDialogOpen); + + function silenceAlert(){ + + } + const handleClose = (confirmed) => () => { + quickAlertClick(); + if(!confirmed) return; + silenceAlert(); + } + + return ( +
+ + + Silence Alert + + + + + + + + + + + } + onClick={quickAlertClick} + open={false} + /> +
+ ); +} diff --git a/src/views/Catalog.jsx b/src/views/Catalog.jsx new file mode 100644 index 0000000..69c8d99 --- /dev/null +++ b/src/views/Catalog.jsx @@ -0,0 +1,29 @@ +import { useContext } from "react"; +import StoreContext from "../ctx/StoreContext.jsx"; +import JobContext from "../ctx/JobContext.jsx"; + +import TextField from "@mui/material/TextField"; + +import CatalogSearch from "./components/CatalogSearch.jsx"; + +export default function Catalog() { + const { + state: jobState, + dispatch: jobDispatch, + jobUpdate, + jobCreate, + } = useContext(JobContext); + + const { state: store, updateStore } = useContext(StoreContext); + + return ( +
+ + +
+ ); +} diff --git a/src/views/Failing.jsx b/src/views/Failing.jsx new file mode 100644 index 0000000..e1b7bab --- /dev/null +++ b/src/views/Failing.jsx @@ -0,0 +1,70 @@ +import { useState, useContext } from "react"; +import StoreContext from "../ctx/StoreContext.jsx"; +import JobContext from "../ctx/JobContext.jsx"; + +import SpeedDial from '@mui/material/SpeedDial'; +import SpeedDialAction from '@mui/material/SpeedDialAction'; +import SpeedDialIcon from '@mui/material/SpeedDialIcon'; + +import Button from '@mui/material/Button'; +import Dialog from '@mui/material/Dialog'; +import DialogActions from '@mui/material/DialogActions'; +import DialogContent from '@mui/material/DialogContent'; +import DialogContentText from '@mui/material/DialogContentText'; +import DialogTitle from '@mui/material/DialogTitle'; + +import ReplayIcon from '@mui/icons-material/Replay'; + +export default function Failing() { + const { + state: jobState, + retryAll + } = useContext(JobContext); + + const { state: store, updateStore } = useContext(StoreContext); + + const [retryAllOpen, setRetryAllOpen] = useState(false); + const retryAllClick = () => setRetryAllOpen(!retryAllOpen); + const handleClose = (confirmed) => ()=> { + retryAllClick(); + if(!confirmed) return; + retryAll(store.failing); + } + + return ( +
+ + + + + Retry all failing tests? + + + + This will create x jobs and run y tests + + + + + + + + + } + onClick={retryAllClick} + open={false} + /> + +
+ ); +} diff --git a/src/views/Jobs.jsx b/src/views/Jobs.jsx new file mode 100644 index 0000000..0ab6a26 --- /dev/null +++ b/src/views/Jobs.jsx @@ -0,0 +1,55 @@ +import { useState, useContext } from "react"; +import StoreContext from "../ctx/StoreContext.jsx"; +import JobContext from "../ctx/JobContext.jsx"; + + +import ClickAwayListener from '@mui/material/ClickAwayListener'; +import SpeedDial from '@mui/material/SpeedDial'; +import SpeedDialAction from '@mui/material/SpeedDialAction'; +import SpeedDialIcon from '@mui/material/SpeedDialIcon'; + +import PageviewIcon from '@mui/icons-material/Pageview'; +import ViewColumnIcon from '@mui/icons-material/ViewColumn'; +import ViewCarouselIcon from '@mui/icons-material/ViewCarousel'; + +export default function Jobs() { + const { + state: jobState, + dispatch: jobDispatch, + jobUpdate, + jobCreate, + } = useContext(JobContext); + + const { state: store, updateStore } = useContext(StoreContext); + + const [quickOpen, setQuickOpen] = useState(false); + + const quickOpenClick = () => setQuickOpen(!quickOpen); + const quickOpenClose = () => setQuickOpen(false); + + const actions = [ + {name: "Suite", icon: }, {name: "Compound", icon: }, {name: "Manual", icon: } + ] + + return ( +
+ + } + onClick={quickOpenClick} + open={quickOpen} + > + {actions.map((action) => ( + + ))} + + +
+ ); +} diff --git a/src/views/Settings.jsx b/src/views/Settings.jsx new file mode 100644 index 0000000..fee6ce2 --- /dev/null +++ b/src/views/Settings.jsx @@ -0,0 +1,124 @@ +import { useContext, useState, useEffect } from "react"; +import StoreContext from "../ctx/StoreContext.jsx"; + +import MultiOptionDialog from "./components/MultiOptionDialog.jsx"; + +import * as React from 'react'; +import PropTypes from 'prop-types'; +import Box from '@mui/material/Box'; +import Button from '@mui/material/Button'; +import List from '@mui/material/List'; +import ListItem from '@mui/material/ListItem'; +import ListItemText from '@mui/material/ListItemText'; +import Switch from "@mui/material/Switch"; +import SummarizeIcon from '@mui/icons-material/Summarize'; +import Typography from "@mui/material/Typography"; + + +export default function Settings(props) { + + const { state: store, updateStore } = useContext(StoreContext); + const { regions } = store; + const { pages } = props; + +const defaultDialog = {title: "", options: [], current: null, onSelect: null, open: false}; + const [dialog, setDialog] = React.useState(defaultDialog); + + const optionSettings = {region: { + title: "Region", + options: ["us", "au"], + current: store.defaultRegion, + onSelect: (r) => updateStore({defaultRegion: r}) +}, + defaultPage: { + title: "Default Page", + options: ["failing", "alerting"], + current: store.defaultPage, + onSelect: (p) => updateStore({defaultPage: p}) +}} + + const handleOptionsMenu = (s) => { + setDialog({...s, open:true}); + }; + + const handleClose = (newValue, onSelect) => { + setDialog({...dialog, open:false}) + if (!newValue) return; + onSelect(newValue); + }; + + const handleToggle = (booleanSetting) => ()=> { + const storeUpdate = {}; + storeUpdate[booleanSetting] = !store[booleanSetting]; + updateStore(storeUpdate) + } + + function MultiOptionSubtext(props){ + return( + + {props.value} + + ) + } + + + return ( + + + + handleOptionsMenu(optionSettings.defaultPage)} + > + + }/> + + + handleOptionsMenu(optionSettings.region)} + > + } /> + + + + + + + + + + + + + + + + ); +} diff --git a/src/views/components/CatalogSearch.jsx b/src/views/components/CatalogSearch.jsx new file mode 100644 index 0000000..220f50a --- /dev/null +++ b/src/views/components/CatalogSearch.jsx @@ -0,0 +1,31 @@ +import * as React from 'react'; +import Paper from '@mui/material/Paper'; +import InputBase from '@mui/material/InputBase'; +import Divider from '@mui/material/Divider'; +import IconButton from '@mui/material/IconButton'; +import MenuIcon from '@mui/icons-material/Menu'; +import SearchIcon from '@mui/icons-material/Search'; +import DirectionsIcon from '@mui/icons-material/Directions'; + import ClearOutlinedIcon from "@mui/icons-material/ClearOutlined"; + +export default function SearchBar(props) { + return ( + + + + + + + + + + + ); +} \ No newline at end of file diff --git a/src/views/components/MultiOptionDialog.jsx b/src/views/components/MultiOptionDialog.jsx new file mode 100644 index 0000000..63e1789 --- /dev/null +++ b/src/views/components/MultiOptionDialog.jsx @@ -0,0 +1,73 @@ +import {useState, useRef, useEffect} from "react"; + +import Button from "@mui/material/Button" +import DialogTitle from '@mui/material/DialogTitle'; +import DialogContent from '@mui/material/DialogContent'; +import DialogActions from '@mui/material/DialogActions'; +import Dialog from '@mui/material/Dialog'; +import RadioGroup from '@mui/material/RadioGroup'; +import Radio from '@mui/material/Radio'; +import FormControlLabel from '@mui/material/FormControlLabel'; + + +export default function MultiOptionDialog(props) { + + const { dialog: dialogProp, onClose, open, ...other } = props; + const [value, setValue] = useState(dialogProp.current); + const [dialog, setDialog] = useState(dialogProp); + + const radioGroupRef = useRef(null); + + useEffect(() => { + setDialog(dialogProp); + setValue(dialogProp.current); + }, [dialogProp, open]); + + const handleEntering = () => { + if (radioGroupRef.current != null) radioGroupRef.current.focus(); + }; + + const handleCancel = () => onClose(); + + const handleOk = () => onClose(value, dialog.onSelect); + + + const handleChange = (e) =>{ setValue(e.target.value); + } + + return ( + + {dialog.title} + + + {dialog.options.map((option) => ( + } + label={option} + /> + ))} + + + + + + + + ); +} diff --git a/tests/api.js b/tests/api.js new file mode 100644 index 0000000..1f2c29f --- /dev/null +++ b/tests/api.js @@ -0,0 +1,22 @@ +#!/usr/bin/env node +import "dotenv/config"; // Load Envars +import Qualiteer from "qualiteer"; +import axios from "axios"; + +// Start server +const qltr = new Qualiteer(); +await qltr.start(); + +const url = "https://Qualiteer.elijahparker3.repl.co"; + +const testsUrl = "/api/catalog/tests"; +const resultsUrl = "/api/results/failing"; + +const get = (...args) => axios.get(`${url}/${args[0]}`, args[1]); + +var res = await get(resultsUrl); +console.log(res.data); + +res = await get(resultsUrl, { headers: { count: true } }); + +console.log(res.data); diff --git a/tests/index.js b/tests/index.js index 4733a71..ba875dc 100644 --- a/tests/index.js +++ b/tests/index.js @@ -11,7 +11,11 @@ const url = "https://Qualiteer.elijahparker3.repl.co"; // Create an initiator and make a job request const primary = new Initiator(url); -const job = { command: ["node", "dev/other.js"], name: "testing", image: "node" }; +const job = { + command: ["node", "dev/other.js"], + name: "testing", + image: "node", +}; await primary.newJob(job, null, () => console.log("Primary Job Concluded")); /*const { clients } = qltr.jobs;