@nsshunt/stsrunnerframework 2.0.21 → 2.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -6,7 +6,16 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
9
+ var __commonJSMin$1 = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
10
+ var __exportAll = (all, no_symbols) => {
11
+ let target = {};
12
+ for (var name in all) __defProp(target, name, {
13
+ get: all[name],
14
+ enumerable: true
15
+ });
16
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
17
+ return target;
18
+ };
10
19
  var __copyProps = (to, from, except, desc) => {
11
20
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
21
  key = keys[i];
@@ -24,6 +33,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
33
  //#endregion
25
34
  let _nsshunt_stsutils = require("@nsshunt/stsutils");
26
35
  let _nsshunt_stsobservability = require("@nsshunt/stsobservability");
36
+ let fflate = require("fflate");
27
37
  //#region src/commonTypes.ts
28
38
  /**
29
39
  * Inter-Worker (IW) message commands.
@@ -1501,7 +1511,7 @@ var AbstractRunnerExecutionWorker = class {
1501
1511
  * - The broker itself does not interpret business meaning of unsolicited messages;
1502
1512
  * those are delegated to a caller-supplied callback
1503
1513
  */
1504
- var import_lodash_merge = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
1514
+ var import_lodash_merge = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin$1(((exports, module) => {
1505
1515
  /**
1506
1516
  * Lodash (Custom Build) <https://lodash.com/>
1507
1517
  * Build: `lodash modularize exports="npm" -o ./`
@@ -1959,7 +1969,8 @@ var import_lodash_merge = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin
1959
1969
  * @param {Array} [entries] The key-value pairs to cache.
1960
1970
  */
1961
1971
  function Stack(entries) {
1962
- this.size = (this.__data__ = new ListCache(entries)).size;
1972
+ var data = this.__data__ = new ListCache(entries);
1973
+ this.size = data.size;
1963
1974
  }
1964
1975
  /**
1965
1976
  * Removes all key-value entries from the stack.
@@ -4872,7 +4883,10 @@ var WorkerRegistry = class {
4872
4883
  if (worker) {
4873
4884
  const runnersMap = worker.GetAllRunnersExMap();
4874
4885
  if (runnersMap) {
4875
- if (runnersMap[runnerId]) delete runnersMap[runnerId];
4886
+ if (runnersMap[runnerId]) {
4887
+ delete runnersMap[runnerId];
4888
+ this.options.logger.debug(`DeleteRunner(): RunnerId: [${runnerId}] has been removed from this workerId: [${workerId}], Remaining Runners: [${Object.keys(worker.GetAllRunnersExMap()).length}]`);
4889
+ }
4876
4890
  }
4877
4891
  }
4878
4892
  };
@@ -5848,7 +5862,7 @@ var WorkerCommandCoordinator = class {
5848
5862
  * @returns Array of worker-level aggregated results.
5849
5863
  */
5850
5864
  ExecuteWorkerCommands = async (workerIds, command, runnerOptions) => {
5851
- this.options.logger.debug(`_ProcessWorkerCommands: workerIds: [${workerIds}] command: [${command}`);
5865
+ this.options.logger.debug(`_ProcessWorkerCommands: workerIds: [${workerIds}] command: [${command}]`);
5852
5866
  try {
5853
5867
  /**
5854
5868
  * Promise array holding each worker's command execution result.
@@ -6584,11 +6598,3932 @@ var STSWorkerManager = class {
6584
6598
  };
6585
6599
  };
6586
6600
  //#endregion
6601
+ //#region node_modules/@nsshunt/stssocketioutils/dist/tiny-emitter-DB59cw42.js
6602
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
6603
+ var require_tiny_emitter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6604
+ function E() {}
6605
+ E.prototype = {
6606
+ on: function(name, callback, ctx) {
6607
+ var e = this.e || (this.e = {});
6608
+ (e[name] || (e[name] = [])).push({
6609
+ fn: callback,
6610
+ ctx
6611
+ });
6612
+ return this;
6613
+ },
6614
+ once: function(name, callback, ctx) {
6615
+ var self = this;
6616
+ function listener() {
6617
+ self.off(name, listener);
6618
+ callback.apply(ctx, arguments);
6619
+ }
6620
+ listener._ = callback;
6621
+ return this.on(name, listener, ctx);
6622
+ },
6623
+ emit: function(name) {
6624
+ var data = [].slice.call(arguments, 1);
6625
+ var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
6626
+ var i = 0;
6627
+ var len = evtArr.length;
6628
+ for (; i < len; i++) evtArr[i].fn.apply(evtArr[i].ctx, data);
6629
+ return this;
6630
+ },
6631
+ off: function(name, callback) {
6632
+ var e = this.e || (this.e = {});
6633
+ var evts = e[name];
6634
+ var liveEvents = [];
6635
+ if (evts && callback) {
6636
+ for (var i = 0, len = evts.length; i < len; i++) if (evts[i].fn !== callback && evts[i].fn._ !== callback) liveEvents.push(evts[i]);
6637
+ }
6638
+ liveEvents.length ? e[name] = liveEvents : delete e[name];
6639
+ return this;
6640
+ }
6641
+ };
6642
+ module.exports = E;
6643
+ module.exports.TinyEmitter = E;
6644
+ }));
6645
+ //#endregion
6646
+ //#region node_modules/engine.io-parser/build/esm/commons.js
6647
+ var PACKET_TYPES = Object.create(null);
6648
+ PACKET_TYPES["open"] = "0";
6649
+ PACKET_TYPES["close"] = "1";
6650
+ PACKET_TYPES["ping"] = "2";
6651
+ PACKET_TYPES["pong"] = "3";
6652
+ PACKET_TYPES["message"] = "4";
6653
+ PACKET_TYPES["upgrade"] = "5";
6654
+ PACKET_TYPES["noop"] = "6";
6655
+ var PACKET_TYPES_REVERSE = Object.create(null);
6656
+ Object.keys(PACKET_TYPES).forEach((key) => {
6657
+ PACKET_TYPES_REVERSE[PACKET_TYPES[key]] = key;
6658
+ });
6659
+ var ERROR_PACKET = {
6660
+ type: "error",
6661
+ data: "parser error"
6662
+ };
6663
+ //#endregion
6664
+ //#region node_modules/engine.io-parser/build/esm/encodePacket.browser.js
6665
+ var withNativeBlob$1 = typeof Blob === "function" || typeof Blob !== "undefined" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]";
6666
+ var withNativeArrayBuffer$2 = typeof ArrayBuffer === "function";
6667
+ var isView$1 = (obj) => {
6668
+ return typeof ArrayBuffer.isView === "function" ? ArrayBuffer.isView(obj) : obj && obj.buffer instanceof ArrayBuffer;
6669
+ };
6670
+ var encodePacket = ({ type, data }, supportsBinary, callback) => {
6671
+ if (withNativeBlob$1 && data instanceof Blob) if (supportsBinary) return callback(data);
6672
+ else return encodeBlobAsBase64(data, callback);
6673
+ else if (withNativeArrayBuffer$2 && (data instanceof ArrayBuffer || isView$1(data))) if (supportsBinary) return callback(data);
6674
+ else return encodeBlobAsBase64(new Blob([data]), callback);
6675
+ return callback(PACKET_TYPES[type] + (data || ""));
6676
+ };
6677
+ var encodeBlobAsBase64 = (data, callback) => {
6678
+ const fileReader = new FileReader();
6679
+ fileReader.onload = function() {
6680
+ const content = fileReader.result.split(",")[1];
6681
+ callback("b" + (content || ""));
6682
+ };
6683
+ return fileReader.readAsDataURL(data);
6684
+ };
6685
+ function toArray(data) {
6686
+ if (data instanceof Uint8Array) return data;
6687
+ else if (data instanceof ArrayBuffer) return new Uint8Array(data);
6688
+ else return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
6689
+ }
6690
+ var TEXT_ENCODER;
6691
+ function encodePacketToBinary(packet, callback) {
6692
+ if (withNativeBlob$1 && packet.data instanceof Blob) return packet.data.arrayBuffer().then(toArray).then(callback);
6693
+ else if (withNativeArrayBuffer$2 && (packet.data instanceof ArrayBuffer || isView$1(packet.data))) return callback(toArray(packet.data));
6694
+ encodePacket(packet, false, (encoded) => {
6695
+ if (!TEXT_ENCODER) TEXT_ENCODER = new TextEncoder();
6696
+ callback(TEXT_ENCODER.encode(encoded));
6697
+ });
6698
+ }
6699
+ //#endregion
6700
+ //#region node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js
6701
+ var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
6702
+ var lookup$1 = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
6703
+ for (let i = 0; i < 64; i++) lookup$1[chars.charCodeAt(i)] = i;
6704
+ var decode$1 = (base64) => {
6705
+ let bufferLength = base64.length * .75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;
6706
+ if (base64[base64.length - 1] === "=") {
6707
+ bufferLength--;
6708
+ if (base64[base64.length - 2] === "=") bufferLength--;
6709
+ }
6710
+ const arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);
6711
+ for (i = 0; i < len; i += 4) {
6712
+ encoded1 = lookup$1[base64.charCodeAt(i)];
6713
+ encoded2 = lookup$1[base64.charCodeAt(i + 1)];
6714
+ encoded3 = lookup$1[base64.charCodeAt(i + 2)];
6715
+ encoded4 = lookup$1[base64.charCodeAt(i + 3)];
6716
+ bytes[p++] = encoded1 << 2 | encoded2 >> 4;
6717
+ bytes[p++] = (encoded2 & 15) << 4 | encoded3 >> 2;
6718
+ bytes[p++] = (encoded3 & 3) << 6 | encoded4 & 63;
6719
+ }
6720
+ return arraybuffer;
6721
+ };
6722
+ //#endregion
6723
+ //#region node_modules/engine.io-parser/build/esm/decodePacket.browser.js
6724
+ var withNativeArrayBuffer$1 = typeof ArrayBuffer === "function";
6725
+ var decodePacket = (encodedPacket, binaryType) => {
6726
+ if (typeof encodedPacket !== "string") return {
6727
+ type: "message",
6728
+ data: mapBinary(encodedPacket, binaryType)
6729
+ };
6730
+ const type = encodedPacket.charAt(0);
6731
+ if (type === "b") return {
6732
+ type: "message",
6733
+ data: decodeBase64Packet(encodedPacket.substring(1), binaryType)
6734
+ };
6735
+ if (!PACKET_TYPES_REVERSE[type]) return ERROR_PACKET;
6736
+ return encodedPacket.length > 1 ? {
6737
+ type: PACKET_TYPES_REVERSE[type],
6738
+ data: encodedPacket.substring(1)
6739
+ } : { type: PACKET_TYPES_REVERSE[type] };
6740
+ };
6741
+ var decodeBase64Packet = (data, binaryType) => {
6742
+ if (withNativeArrayBuffer$1) return mapBinary(decode$1(data), binaryType);
6743
+ else return {
6744
+ base64: true,
6745
+ data
6746
+ };
6747
+ };
6748
+ var mapBinary = (data, binaryType) => {
6749
+ switch (binaryType) {
6750
+ case "blob": if (data instanceof Blob) return data;
6751
+ else return new Blob([data]);
6752
+ default: if (data instanceof ArrayBuffer) return data;
6753
+ else return data.buffer;
6754
+ }
6755
+ };
6756
+ //#endregion
6757
+ //#region node_modules/engine.io-parser/build/esm/index.js
6758
+ var SEPARATOR = String.fromCharCode(30);
6759
+ var encodePayload = (packets, callback) => {
6760
+ const length = packets.length;
6761
+ const encodedPackets = new Array(length);
6762
+ let count = 0;
6763
+ packets.forEach((packet, i) => {
6764
+ encodePacket(packet, false, (encodedPacket) => {
6765
+ encodedPackets[i] = encodedPacket;
6766
+ if (++count === length) callback(encodedPackets.join(SEPARATOR));
6767
+ });
6768
+ });
6769
+ };
6770
+ var decodePayload = (encodedPayload, binaryType) => {
6771
+ const encodedPackets = encodedPayload.split(SEPARATOR);
6772
+ const packets = [];
6773
+ for (let i = 0; i < encodedPackets.length; i++) {
6774
+ const decodedPacket = decodePacket(encodedPackets[i], binaryType);
6775
+ packets.push(decodedPacket);
6776
+ if (decodedPacket.type === "error") break;
6777
+ }
6778
+ return packets;
6779
+ };
6780
+ function createPacketEncoderStream() {
6781
+ return new TransformStream({ transform(packet, controller) {
6782
+ encodePacketToBinary(packet, (encodedPacket) => {
6783
+ const payloadLength = encodedPacket.length;
6784
+ let header;
6785
+ if (payloadLength < 126) {
6786
+ header = new Uint8Array(1);
6787
+ new DataView(header.buffer).setUint8(0, payloadLength);
6788
+ } else if (payloadLength < 65536) {
6789
+ header = new Uint8Array(3);
6790
+ const view = new DataView(header.buffer);
6791
+ view.setUint8(0, 126);
6792
+ view.setUint16(1, payloadLength);
6793
+ } else {
6794
+ header = new Uint8Array(9);
6795
+ const view = new DataView(header.buffer);
6796
+ view.setUint8(0, 127);
6797
+ view.setBigUint64(1, BigInt(payloadLength));
6798
+ }
6799
+ if (packet.data && typeof packet.data !== "string") header[0] |= 128;
6800
+ controller.enqueue(header);
6801
+ controller.enqueue(encodedPacket);
6802
+ });
6803
+ } });
6804
+ }
6805
+ var TEXT_DECODER;
6806
+ function totalLength(chunks) {
6807
+ return chunks.reduce((acc, chunk) => acc + chunk.length, 0);
6808
+ }
6809
+ function concatChunks(chunks, size) {
6810
+ if (chunks[0].length === size) return chunks.shift();
6811
+ const buffer = new Uint8Array(size);
6812
+ let j = 0;
6813
+ for (let i = 0; i < size; i++) {
6814
+ buffer[i] = chunks[0][j++];
6815
+ if (j === chunks[0].length) {
6816
+ chunks.shift();
6817
+ j = 0;
6818
+ }
6819
+ }
6820
+ if (chunks.length && j < chunks[0].length) chunks[0] = chunks[0].slice(j);
6821
+ return buffer;
6822
+ }
6823
+ function createPacketDecoderStream(maxPayload, binaryType) {
6824
+ if (!TEXT_DECODER) TEXT_DECODER = new TextDecoder();
6825
+ const chunks = [];
6826
+ let state = 0;
6827
+ let expectedLength = -1;
6828
+ let isBinary = false;
6829
+ return new TransformStream({ transform(chunk, controller) {
6830
+ chunks.push(chunk);
6831
+ while (true) {
6832
+ if (state === 0) {
6833
+ if (totalLength(chunks) < 1) break;
6834
+ const header = concatChunks(chunks, 1);
6835
+ isBinary = (header[0] & 128) === 128;
6836
+ expectedLength = header[0] & 127;
6837
+ if (expectedLength < 126) state = 3;
6838
+ else if (expectedLength === 126) state = 1;
6839
+ else state = 2;
6840
+ } else if (state === 1) {
6841
+ if (totalLength(chunks) < 2) break;
6842
+ const headerArray = concatChunks(chunks, 2);
6843
+ expectedLength = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length).getUint16(0);
6844
+ state = 3;
6845
+ } else if (state === 2) {
6846
+ if (totalLength(chunks) < 8) break;
6847
+ const headerArray = concatChunks(chunks, 8);
6848
+ const view = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length);
6849
+ const n = view.getUint32(0);
6850
+ if (n > Math.pow(2, 21) - 1) {
6851
+ controller.enqueue(ERROR_PACKET);
6852
+ break;
6853
+ }
6854
+ expectedLength = n * Math.pow(2, 32) + view.getUint32(4);
6855
+ state = 3;
6856
+ } else {
6857
+ if (totalLength(chunks) < expectedLength) break;
6858
+ const data = concatChunks(chunks, expectedLength);
6859
+ controller.enqueue(decodePacket(isBinary ? data : TEXT_DECODER.decode(data), binaryType));
6860
+ state = 0;
6861
+ }
6862
+ if (expectedLength === 0 || expectedLength > maxPayload) {
6863
+ controller.enqueue(ERROR_PACKET);
6864
+ break;
6865
+ }
6866
+ }
6867
+ } });
6868
+ }
6869
+ //#endregion
6870
+ //#region node_modules/@socket.io/component-emitter/lib/esm/index.js
6871
+ /**
6872
+ * Initialize a new `Emitter`.
6873
+ *
6874
+ * @api public
6875
+ */
6876
+ function Emitter(obj) {
6877
+ if (obj) return mixin(obj);
6878
+ }
6879
+ /**
6880
+ * Mixin the emitter properties.
6881
+ *
6882
+ * @param {Object} obj
6883
+ * @return {Object}
6884
+ * @api private
6885
+ */
6886
+ function mixin(obj) {
6887
+ for (var key in Emitter.prototype) obj[key] = Emitter.prototype[key];
6888
+ return obj;
6889
+ }
6890
+ /**
6891
+ * Listen on the given `event` with `fn`.
6892
+ *
6893
+ * @param {String} event
6894
+ * @param {Function} fn
6895
+ * @return {Emitter}
6896
+ * @api public
6897
+ */
6898
+ Emitter.prototype.on = Emitter.prototype.addEventListener = function(event, fn) {
6899
+ this._callbacks = this._callbacks || {};
6900
+ (this._callbacks["$" + event] = this._callbacks["$" + event] || []).push(fn);
6901
+ return this;
6902
+ };
6903
+ /**
6904
+ * Adds an `event` listener that will be invoked a single
6905
+ * time then automatically removed.
6906
+ *
6907
+ * @param {String} event
6908
+ * @param {Function} fn
6909
+ * @return {Emitter}
6910
+ * @api public
6911
+ */
6912
+ Emitter.prototype.once = function(event, fn) {
6913
+ function on() {
6914
+ this.off(event, on);
6915
+ fn.apply(this, arguments);
6916
+ }
6917
+ on.fn = fn;
6918
+ this.on(event, on);
6919
+ return this;
6920
+ };
6921
+ /**
6922
+ * Remove the given callback for `event` or all
6923
+ * registered callbacks.
6924
+ *
6925
+ * @param {String} event
6926
+ * @param {Function} fn
6927
+ * @return {Emitter}
6928
+ * @api public
6929
+ */
6930
+ Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.removeAllListeners = Emitter.prototype.removeEventListener = function(event, fn) {
6931
+ this._callbacks = this._callbacks || {};
6932
+ if (0 == arguments.length) {
6933
+ this._callbacks = {};
6934
+ return this;
6935
+ }
6936
+ var callbacks = this._callbacks["$" + event];
6937
+ if (!callbacks) return this;
6938
+ if (1 == arguments.length) {
6939
+ delete this._callbacks["$" + event];
6940
+ return this;
6941
+ }
6942
+ var cb;
6943
+ for (var i = 0; i < callbacks.length; i++) {
6944
+ cb = callbacks[i];
6945
+ if (cb === fn || cb.fn === fn) {
6946
+ callbacks.splice(i, 1);
6947
+ break;
6948
+ }
6949
+ }
6950
+ if (callbacks.length === 0) delete this._callbacks["$" + event];
6951
+ return this;
6952
+ };
6953
+ /**
6954
+ * Emit `event` with the given args.
6955
+ *
6956
+ * @param {String} event
6957
+ * @param {Mixed} ...
6958
+ * @return {Emitter}
6959
+ */
6960
+ Emitter.prototype.emit = function(event) {
6961
+ this._callbacks = this._callbacks || {};
6962
+ var args = new Array(arguments.length - 1), callbacks = this._callbacks["$" + event];
6963
+ for (var i = 1; i < arguments.length; i++) args[i - 1] = arguments[i];
6964
+ if (callbacks) {
6965
+ callbacks = callbacks.slice(0);
6966
+ for (var i = 0, len = callbacks.length; i < len; ++i) callbacks[i].apply(this, args);
6967
+ }
6968
+ return this;
6969
+ };
6970
+ Emitter.prototype.emitReserved = Emitter.prototype.emit;
6971
+ /**
6972
+ * Return array of callbacks for `event`.
6973
+ *
6974
+ * @param {String} event
6975
+ * @return {Array}
6976
+ * @api public
6977
+ */
6978
+ Emitter.prototype.listeners = function(event) {
6979
+ this._callbacks = this._callbacks || {};
6980
+ return this._callbacks["$" + event] || [];
6981
+ };
6982
+ /**
6983
+ * Check if this emitter has `event` handlers.
6984
+ *
6985
+ * @param {String} event
6986
+ * @return {Boolean}
6987
+ * @api public
6988
+ */
6989
+ Emitter.prototype.hasListeners = function(event) {
6990
+ return !!this.listeners(event).length;
6991
+ };
6992
+ //#endregion
6993
+ //#region node_modules/engine.io-client/build/esm/globals.js
6994
+ var nextTick = (() => {
6995
+ if (typeof Promise === "function" && typeof Promise.resolve === "function") return (cb) => Promise.resolve().then(cb);
6996
+ else return (cb, setTimeoutFn) => setTimeoutFn(cb, 0);
6997
+ })();
6998
+ var globalThisShim = (() => {
6999
+ if (typeof self !== "undefined") return self;
7000
+ else if (typeof window !== "undefined") return window;
7001
+ else return Function("return this")();
7002
+ })();
7003
+ var defaultBinaryType = "arraybuffer";
7004
+ function createCookieJar() {}
7005
+ //#endregion
7006
+ //#region node_modules/engine.io-client/build/esm/util.js
7007
+ function pick(obj, ...attr) {
7008
+ return attr.reduce((acc, k) => {
7009
+ if (obj.hasOwnProperty(k)) acc[k] = obj[k];
7010
+ return acc;
7011
+ }, {});
7012
+ }
7013
+ var NATIVE_SET_TIMEOUT = globalThisShim.setTimeout;
7014
+ var NATIVE_CLEAR_TIMEOUT = globalThisShim.clearTimeout;
7015
+ function installTimerFunctions(obj, opts) {
7016
+ if (opts.useNativeTimers) {
7017
+ obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globalThisShim);
7018
+ obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globalThisShim);
7019
+ } else {
7020
+ obj.setTimeoutFn = globalThisShim.setTimeout.bind(globalThisShim);
7021
+ obj.clearTimeoutFn = globalThisShim.clearTimeout.bind(globalThisShim);
7022
+ }
7023
+ }
7024
+ var BASE64_OVERHEAD = 1.33;
7025
+ function byteLength(obj) {
7026
+ if (typeof obj === "string") return utf8Length(obj);
7027
+ return Math.ceil((obj.byteLength || obj.size) * BASE64_OVERHEAD);
7028
+ }
7029
+ function utf8Length(str) {
7030
+ let c = 0, length = 0;
7031
+ for (let i = 0, l = str.length; i < l; i++) {
7032
+ c = str.charCodeAt(i);
7033
+ if (c < 128) length += 1;
7034
+ else if (c < 2048) length += 2;
7035
+ else if (c < 55296 || c >= 57344) length += 3;
7036
+ else {
7037
+ i++;
7038
+ length += 4;
7039
+ }
7040
+ }
7041
+ return length;
7042
+ }
7043
+ /**
7044
+ * Generates a random 8-characters string.
7045
+ */
7046
+ function randomString() {
7047
+ return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
7048
+ }
7049
+ //#endregion
7050
+ //#region node_modules/engine.io-client/build/esm/contrib/parseqs.js
7051
+ /**
7052
+ * Compiles a querystring
7053
+ * Returns string representation of the object
7054
+ *
7055
+ * @param {Object}
7056
+ * @api private
7057
+ */
7058
+ function encode(obj) {
7059
+ let str = "";
7060
+ for (let i in obj) if (obj.hasOwnProperty(i)) {
7061
+ if (str.length) str += "&";
7062
+ str += encodeURIComponent(i) + "=" + encodeURIComponent(obj[i]);
7063
+ }
7064
+ return str;
7065
+ }
7066
+ /**
7067
+ * Parses a simple querystring into an object
7068
+ *
7069
+ * @param {String} qs
7070
+ * @api private
7071
+ */
7072
+ function decode(qs) {
7073
+ let qry = {};
7074
+ let pairs = qs.split("&");
7075
+ for (let i = 0, l = pairs.length; i < l; i++) {
7076
+ let pair = pairs[i].split("=");
7077
+ qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
7078
+ }
7079
+ return qry;
7080
+ }
7081
+ //#endregion
7082
+ //#region node_modules/engine.io-client/build/esm/transport.js
7083
+ var TransportError = class extends Error {
7084
+ constructor(reason, description, context) {
7085
+ super(reason);
7086
+ this.description = description;
7087
+ this.context = context;
7088
+ this.type = "TransportError";
7089
+ }
7090
+ };
7091
+ var Transport = class extends Emitter {
7092
+ /**
7093
+ * Transport abstract constructor.
7094
+ *
7095
+ * @param {Object} opts - options
7096
+ * @protected
7097
+ */
7098
+ constructor(opts) {
7099
+ super();
7100
+ this.writable = false;
7101
+ installTimerFunctions(this, opts);
7102
+ this.opts = opts;
7103
+ this.query = opts.query;
7104
+ this.socket = opts.socket;
7105
+ this.supportsBinary = !opts.forceBase64;
7106
+ }
7107
+ /**
7108
+ * Emits an error.
7109
+ *
7110
+ * @param {String} reason
7111
+ * @param description
7112
+ * @param context - the error context
7113
+ * @return {Transport} for chaining
7114
+ * @protected
7115
+ */
7116
+ onError(reason, description, context) {
7117
+ super.emitReserved("error", new TransportError(reason, description, context));
7118
+ return this;
7119
+ }
7120
+ /**
7121
+ * Opens the transport.
7122
+ */
7123
+ open() {
7124
+ this.readyState = "opening";
7125
+ this.doOpen();
7126
+ return this;
7127
+ }
7128
+ /**
7129
+ * Closes the transport.
7130
+ */
7131
+ close() {
7132
+ if (this.readyState === "opening" || this.readyState === "open") {
7133
+ this.doClose();
7134
+ this.onClose();
7135
+ }
7136
+ return this;
7137
+ }
7138
+ /**
7139
+ * Sends multiple packets.
7140
+ *
7141
+ * @param {Array} packets
7142
+ */
7143
+ send(packets) {
7144
+ if (this.readyState === "open") this.write(packets);
7145
+ }
7146
+ /**
7147
+ * Called upon open
7148
+ *
7149
+ * @protected
7150
+ */
7151
+ onOpen() {
7152
+ this.readyState = "open";
7153
+ this.writable = true;
7154
+ super.emitReserved("open");
7155
+ }
7156
+ /**
7157
+ * Called with data.
7158
+ *
7159
+ * @param {String} data
7160
+ * @protected
7161
+ */
7162
+ onData(data) {
7163
+ const packet = decodePacket(data, this.socket.binaryType);
7164
+ this.onPacket(packet);
7165
+ }
7166
+ /**
7167
+ * Called with a decoded packet.
7168
+ *
7169
+ * @protected
7170
+ */
7171
+ onPacket(packet) {
7172
+ super.emitReserved("packet", packet);
7173
+ }
7174
+ /**
7175
+ * Called upon close.
7176
+ *
7177
+ * @protected
7178
+ */
7179
+ onClose(details) {
7180
+ this.readyState = "closed";
7181
+ super.emitReserved("close", details);
7182
+ }
7183
+ /**
7184
+ * Pauses the transport, in order not to lose packets during an upgrade.
7185
+ *
7186
+ * @param onPause
7187
+ */
7188
+ pause(onPause) {}
7189
+ createUri(schema, query = {}) {
7190
+ return schema + "://" + this._hostname() + this._port() + this.opts.path + this._query(query);
7191
+ }
7192
+ _hostname() {
7193
+ const hostname = this.opts.hostname;
7194
+ return hostname.indexOf(":") === -1 ? hostname : "[" + hostname + "]";
7195
+ }
7196
+ _port() {
7197
+ if (this.opts.port && (this.opts.secure && Number(this.opts.port) !== 443 || !this.opts.secure && Number(this.opts.port) !== 80)) return ":" + this.opts.port;
7198
+ else return "";
7199
+ }
7200
+ _query(query) {
7201
+ const encodedQuery = encode(query);
7202
+ return encodedQuery.length ? "?" + encodedQuery : "";
7203
+ }
7204
+ };
7205
+ //#endregion
7206
+ //#region node_modules/engine.io-client/build/esm/transports/polling.js
7207
+ var Polling = class extends Transport {
7208
+ constructor() {
7209
+ super(...arguments);
7210
+ this._polling = false;
7211
+ }
7212
+ get name() {
7213
+ return "polling";
7214
+ }
7215
+ /**
7216
+ * Opens the socket (triggers polling). We write a PING message to determine
7217
+ * when the transport is open.
7218
+ *
7219
+ * @protected
7220
+ */
7221
+ doOpen() {
7222
+ this._poll();
7223
+ }
7224
+ /**
7225
+ * Pauses polling.
7226
+ *
7227
+ * @param {Function} onPause - callback upon buffers are flushed and transport is paused
7228
+ * @package
7229
+ */
7230
+ pause(onPause) {
7231
+ this.readyState = "pausing";
7232
+ const pause = () => {
7233
+ this.readyState = "paused";
7234
+ onPause();
7235
+ };
7236
+ if (this._polling || !this.writable) {
7237
+ let total = 0;
7238
+ if (this._polling) {
7239
+ total++;
7240
+ this.once("pollComplete", function() {
7241
+ --total || pause();
7242
+ });
7243
+ }
7244
+ if (!this.writable) {
7245
+ total++;
7246
+ this.once("drain", function() {
7247
+ --total || pause();
7248
+ });
7249
+ }
7250
+ } else pause();
7251
+ }
7252
+ /**
7253
+ * Starts polling cycle.
7254
+ *
7255
+ * @private
7256
+ */
7257
+ _poll() {
7258
+ this._polling = true;
7259
+ this.doPoll();
7260
+ this.emitReserved("poll");
7261
+ }
7262
+ /**
7263
+ * Overloads onData to detect payloads.
7264
+ *
7265
+ * @protected
7266
+ */
7267
+ onData(data) {
7268
+ const callback = (packet) => {
7269
+ if ("opening" === this.readyState && packet.type === "open") this.onOpen();
7270
+ if ("close" === packet.type) {
7271
+ this.onClose({ description: "transport closed by the server" });
7272
+ return false;
7273
+ }
7274
+ this.onPacket(packet);
7275
+ };
7276
+ decodePayload(data, this.socket.binaryType).forEach(callback);
7277
+ if ("closed" !== this.readyState) {
7278
+ this._polling = false;
7279
+ this.emitReserved("pollComplete");
7280
+ if ("open" === this.readyState) this._poll();
7281
+ }
7282
+ }
7283
+ /**
7284
+ * For polling, send a close packet.
7285
+ *
7286
+ * @protected
7287
+ */
7288
+ doClose() {
7289
+ const close = () => {
7290
+ this.write([{ type: "close" }]);
7291
+ };
7292
+ if ("open" === this.readyState) close();
7293
+ else this.once("open", close);
7294
+ }
7295
+ /**
7296
+ * Writes a packets payload.
7297
+ *
7298
+ * @param {Array} packets - data packets
7299
+ * @protected
7300
+ */
7301
+ write(packets) {
7302
+ this.writable = false;
7303
+ encodePayload(packets, (data) => {
7304
+ this.doWrite(data, () => {
7305
+ this.writable = true;
7306
+ this.emitReserved("drain");
7307
+ });
7308
+ });
7309
+ }
7310
+ /**
7311
+ * Generates uri for connection.
7312
+ *
7313
+ * @private
7314
+ */
7315
+ uri() {
7316
+ const schema = this.opts.secure ? "https" : "http";
7317
+ const query = this.query || {};
7318
+ if (false !== this.opts.timestampRequests) query[this.opts.timestampParam] = randomString();
7319
+ if (!this.supportsBinary && !query.sid) query.b64 = 1;
7320
+ return this.createUri(schema, query);
7321
+ }
7322
+ };
7323
+ //#endregion
7324
+ //#region node_modules/engine.io-client/build/esm/contrib/has-cors.js
7325
+ var value = false;
7326
+ try {
7327
+ value = typeof XMLHttpRequest !== "undefined" && "withCredentials" in new XMLHttpRequest();
7328
+ } catch (err) {}
7329
+ var hasCORS = value;
7330
+ //#endregion
7331
+ //#region node_modules/engine.io-client/build/esm/transports/polling-xhr.js
7332
+ function empty() {}
7333
+ var BaseXHR = class extends Polling {
7334
+ /**
7335
+ * XHR Polling constructor.
7336
+ *
7337
+ * @param {Object} opts
7338
+ * @package
7339
+ */
7340
+ constructor(opts) {
7341
+ super(opts);
7342
+ if (typeof location !== "undefined") {
7343
+ const isSSL = "https:" === location.protocol;
7344
+ let port = location.port;
7345
+ if (!port) port = isSSL ? "443" : "80";
7346
+ this.xd = typeof location !== "undefined" && opts.hostname !== location.hostname || port !== opts.port;
7347
+ }
7348
+ }
7349
+ /**
7350
+ * Sends data.
7351
+ *
7352
+ * @param {String} data to send.
7353
+ * @param {Function} called upon flush.
7354
+ * @private
7355
+ */
7356
+ doWrite(data, fn) {
7357
+ const req = this.request({
7358
+ method: "POST",
7359
+ data
7360
+ });
7361
+ req.on("success", fn);
7362
+ req.on("error", (xhrStatus, context) => {
7363
+ this.onError("xhr post error", xhrStatus, context);
7364
+ });
7365
+ }
7366
+ /**
7367
+ * Starts a poll cycle.
7368
+ *
7369
+ * @private
7370
+ */
7371
+ doPoll() {
7372
+ const req = this.request();
7373
+ req.on("data", this.onData.bind(this));
7374
+ req.on("error", (xhrStatus, context) => {
7375
+ this.onError("xhr poll error", xhrStatus, context);
7376
+ });
7377
+ this.pollXhr = req;
7378
+ }
7379
+ };
7380
+ var Request = class Request extends Emitter {
7381
+ /**
7382
+ * Request constructor
7383
+ *
7384
+ * @param {Object} options
7385
+ * @package
7386
+ */
7387
+ constructor(createRequest, uri, opts) {
7388
+ super();
7389
+ this.createRequest = createRequest;
7390
+ installTimerFunctions(this, opts);
7391
+ this._opts = opts;
7392
+ this._method = opts.method || "GET";
7393
+ this._uri = uri;
7394
+ this._data = void 0 !== opts.data ? opts.data : null;
7395
+ this._create();
7396
+ }
7397
+ /**
7398
+ * Creates the XHR object and sends the request.
7399
+ *
7400
+ * @private
7401
+ */
7402
+ _create() {
7403
+ var _a;
7404
+ const opts = pick(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
7405
+ opts.xdomain = !!this._opts.xd;
7406
+ const xhr = this._xhr = this.createRequest(opts);
7407
+ try {
7408
+ xhr.open(this._method, this._uri, true);
7409
+ try {
7410
+ if (this._opts.extraHeaders) {
7411
+ xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true);
7412
+ for (let i in this._opts.extraHeaders) if (this._opts.extraHeaders.hasOwnProperty(i)) xhr.setRequestHeader(i, this._opts.extraHeaders[i]);
7413
+ }
7414
+ } catch (e) {}
7415
+ if ("POST" === this._method) try {
7416
+ xhr.setRequestHeader("Content-type", "text/plain;charset=UTF-8");
7417
+ } catch (e) {}
7418
+ try {
7419
+ xhr.setRequestHeader("Accept", "*/*");
7420
+ } catch (e) {}
7421
+ (_a = this._opts.cookieJar) === null || _a === void 0 || _a.addCookies(xhr);
7422
+ if ("withCredentials" in xhr) xhr.withCredentials = this._opts.withCredentials;
7423
+ if (this._opts.requestTimeout) xhr.timeout = this._opts.requestTimeout;
7424
+ xhr.onreadystatechange = () => {
7425
+ var _a;
7426
+ if (xhr.readyState === 3) (_a = this._opts.cookieJar) === null || _a === void 0 || _a.parseCookies(xhr.getResponseHeader("set-cookie"));
7427
+ if (4 !== xhr.readyState) return;
7428
+ if (200 === xhr.status || 1223 === xhr.status) this._onLoad();
7429
+ else this.setTimeoutFn(() => {
7430
+ this._onError(typeof xhr.status === "number" ? xhr.status : 0);
7431
+ }, 0);
7432
+ };
7433
+ xhr.send(this._data);
7434
+ } catch (e) {
7435
+ this.setTimeoutFn(() => {
7436
+ this._onError(e);
7437
+ }, 0);
7438
+ return;
7439
+ }
7440
+ if (typeof document !== "undefined") {
7441
+ this._index = Request.requestsCount++;
7442
+ Request.requests[this._index] = this;
7443
+ }
7444
+ }
7445
+ /**
7446
+ * Called upon error.
7447
+ *
7448
+ * @private
7449
+ */
7450
+ _onError(err) {
7451
+ this.emitReserved("error", err, this._xhr);
7452
+ this._cleanup(true);
7453
+ }
7454
+ /**
7455
+ * Cleans up house.
7456
+ *
7457
+ * @private
7458
+ */
7459
+ _cleanup(fromError) {
7460
+ if ("undefined" === typeof this._xhr || null === this._xhr) return;
7461
+ this._xhr.onreadystatechange = empty;
7462
+ if (fromError) try {
7463
+ this._xhr.abort();
7464
+ } catch (e) {}
7465
+ if (typeof document !== "undefined") delete Request.requests[this._index];
7466
+ this._xhr = null;
7467
+ }
7468
+ /**
7469
+ * Called upon load.
7470
+ *
7471
+ * @private
7472
+ */
7473
+ _onLoad() {
7474
+ const data = this._xhr.responseText;
7475
+ if (data !== null) {
7476
+ this.emitReserved("data", data);
7477
+ this.emitReserved("success");
7478
+ this._cleanup();
7479
+ }
7480
+ }
7481
+ /**
7482
+ * Aborts the request.
7483
+ *
7484
+ * @package
7485
+ */
7486
+ abort() {
7487
+ this._cleanup();
7488
+ }
7489
+ };
7490
+ Request.requestsCount = 0;
7491
+ Request.requests = {};
7492
+ /**
7493
+ * Aborts pending requests when unloading the window. This is needed to prevent
7494
+ * memory leaks (e.g. when using IE) and to ensure that no spurious error is
7495
+ * emitted.
7496
+ */
7497
+ if (typeof document !== "undefined") {
7498
+ if (typeof attachEvent === "function") attachEvent("onunload", unloadHandler);
7499
+ else if (typeof addEventListener === "function") {
7500
+ const terminationEvent = "onpagehide" in globalThisShim ? "pagehide" : "unload";
7501
+ addEventListener(terminationEvent, unloadHandler, false);
7502
+ }
7503
+ }
7504
+ function unloadHandler() {
7505
+ for (let i in Request.requests) if (Request.requests.hasOwnProperty(i)) Request.requests[i].abort();
7506
+ }
7507
+ var hasXHR2 = (function() {
7508
+ const xhr = newRequest({ xdomain: false });
7509
+ return xhr && xhr.responseType !== null;
7510
+ })();
7511
+ /**
7512
+ * HTTP long-polling based on the built-in `XMLHttpRequest` object.
7513
+ *
7514
+ * Usage: browser
7515
+ *
7516
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest
7517
+ */
7518
+ var XHR = class extends BaseXHR {
7519
+ constructor(opts) {
7520
+ super(opts);
7521
+ const forceBase64 = opts && opts.forceBase64;
7522
+ this.supportsBinary = hasXHR2 && !forceBase64;
7523
+ }
7524
+ request(opts = {}) {
7525
+ Object.assign(opts, { xd: this.xd }, this.opts);
7526
+ return new Request(newRequest, this.uri(), opts);
7527
+ }
7528
+ };
7529
+ function newRequest(opts) {
7530
+ const xdomain = opts.xdomain;
7531
+ try {
7532
+ if ("undefined" !== typeof XMLHttpRequest && (!xdomain || hasCORS)) return new XMLHttpRequest();
7533
+ } catch (e) {}
7534
+ if (!xdomain) try {
7535
+ return new globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
7536
+ } catch (e) {}
7537
+ }
7538
+ //#endregion
7539
+ //#region node_modules/engine.io-client/build/esm/transports/websocket.js
7540
+ var isReactNative = typeof navigator !== "undefined" && typeof navigator.product === "string" && navigator.product.toLowerCase() === "reactnative";
7541
+ var BaseWS = class extends Transport {
7542
+ get name() {
7543
+ return "websocket";
7544
+ }
7545
+ doOpen() {
7546
+ const uri = this.uri();
7547
+ const protocols = this.opts.protocols;
7548
+ const opts = isReactNative ? {} : pick(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
7549
+ if (this.opts.extraHeaders) opts.headers = this.opts.extraHeaders;
7550
+ try {
7551
+ this.ws = this.createSocket(uri, protocols, opts);
7552
+ } catch (err) {
7553
+ return this.emitReserved("error", err);
7554
+ }
7555
+ this.ws.binaryType = this.socket.binaryType;
7556
+ this.addEventListeners();
7557
+ }
7558
+ /**
7559
+ * Adds event listeners to the socket
7560
+ *
7561
+ * @private
7562
+ */
7563
+ addEventListeners() {
7564
+ this.ws.onopen = () => {
7565
+ if (this.opts.autoUnref) this.ws._socket.unref();
7566
+ this.onOpen();
7567
+ };
7568
+ this.ws.onclose = (closeEvent) => this.onClose({
7569
+ description: "websocket connection closed",
7570
+ context: closeEvent
7571
+ });
7572
+ this.ws.onmessage = (ev) => this.onData(ev.data);
7573
+ this.ws.onerror = (e) => this.onError("websocket error", e);
7574
+ }
7575
+ write(packets) {
7576
+ this.writable = false;
7577
+ for (let i = 0; i < packets.length; i++) {
7578
+ const packet = packets[i];
7579
+ const lastPacket = i === packets.length - 1;
7580
+ encodePacket(packet, this.supportsBinary, (data) => {
7581
+ try {
7582
+ this.doWrite(packet, data);
7583
+ } catch (e) {}
7584
+ if (lastPacket) nextTick(() => {
7585
+ this.writable = true;
7586
+ this.emitReserved("drain");
7587
+ }, this.setTimeoutFn);
7588
+ });
7589
+ }
7590
+ }
7591
+ doClose() {
7592
+ if (typeof this.ws !== "undefined") {
7593
+ this.ws.onerror = () => {};
7594
+ this.ws.close();
7595
+ this.ws = null;
7596
+ }
7597
+ }
7598
+ /**
7599
+ * Generates uri for connection.
7600
+ *
7601
+ * @private
7602
+ */
7603
+ uri() {
7604
+ const schema = this.opts.secure ? "wss" : "ws";
7605
+ const query = this.query || {};
7606
+ if (this.opts.timestampRequests) query[this.opts.timestampParam] = randomString();
7607
+ if (!this.supportsBinary) query.b64 = 1;
7608
+ return this.createUri(schema, query);
7609
+ }
7610
+ };
7611
+ var WebSocketCtor = globalThisShim.WebSocket || globalThisShim.MozWebSocket;
7612
+ /**
7613
+ * WebSocket transport based on the built-in `WebSocket` object.
7614
+ *
7615
+ * Usage: browser, Node.js (since v21), Deno, Bun
7616
+ *
7617
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
7618
+ * @see https://caniuse.com/mdn-api_websocket
7619
+ * @see https://nodejs.org/api/globals.html#websocket
7620
+ */
7621
+ var WS = class extends BaseWS {
7622
+ createSocket(uri, protocols, opts) {
7623
+ return !isReactNative ? protocols ? new WebSocketCtor(uri, protocols) : new WebSocketCtor(uri) : new WebSocketCtor(uri, protocols, opts);
7624
+ }
7625
+ doWrite(_packet, data) {
7626
+ this.ws.send(data);
7627
+ }
7628
+ };
7629
+ //#endregion
7630
+ //#region node_modules/engine.io-client/build/esm/transports/webtransport.js
7631
+ /**
7632
+ * WebTransport transport based on the built-in `WebTransport` object.
7633
+ *
7634
+ * Usage: browser, Node.js (with the `@fails-components/webtransport` package)
7635
+ *
7636
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WebTransport
7637
+ * @see https://caniuse.com/webtransport
7638
+ */
7639
+ var WT = class extends Transport {
7640
+ get name() {
7641
+ return "webtransport";
7642
+ }
7643
+ doOpen() {
7644
+ try {
7645
+ this._transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]);
7646
+ } catch (err) {
7647
+ return this.emitReserved("error", err);
7648
+ }
7649
+ this._transport.closed.then(() => {
7650
+ this.onClose();
7651
+ }).catch((err) => {
7652
+ this.onError("webtransport error", err);
7653
+ });
7654
+ this._transport.ready.then(() => {
7655
+ this._transport.createBidirectionalStream().then((stream) => {
7656
+ const decoderStream = createPacketDecoderStream(Number.MAX_SAFE_INTEGER, this.socket.binaryType);
7657
+ const reader = stream.readable.pipeThrough(decoderStream).getReader();
7658
+ const encoderStream = createPacketEncoderStream();
7659
+ encoderStream.readable.pipeTo(stream.writable);
7660
+ this._writer = encoderStream.writable.getWriter();
7661
+ const read = () => {
7662
+ reader.read().then(({ done, value }) => {
7663
+ if (done) return;
7664
+ this.onPacket(value);
7665
+ read();
7666
+ }).catch((err) => {});
7667
+ };
7668
+ read();
7669
+ const packet = { type: "open" };
7670
+ if (this.query.sid) packet.data = `{"sid":"${this.query.sid}"}`;
7671
+ this._writer.write(packet).then(() => this.onOpen());
7672
+ });
7673
+ });
7674
+ }
7675
+ write(packets) {
7676
+ this.writable = false;
7677
+ for (let i = 0; i < packets.length; i++) {
7678
+ const packet = packets[i];
7679
+ const lastPacket = i === packets.length - 1;
7680
+ this._writer.write(packet).then(() => {
7681
+ if (lastPacket) nextTick(() => {
7682
+ this.writable = true;
7683
+ this.emitReserved("drain");
7684
+ }, this.setTimeoutFn);
7685
+ });
7686
+ }
7687
+ }
7688
+ doClose() {
7689
+ var _a;
7690
+ (_a = this._transport) === null || _a === void 0 || _a.close();
7691
+ }
7692
+ };
7693
+ //#endregion
7694
+ //#region node_modules/engine.io-client/build/esm/transports/index.js
7695
+ var transports = {
7696
+ websocket: WS,
7697
+ webtransport: WT,
7698
+ polling: XHR
7699
+ };
7700
+ //#endregion
7701
+ //#region node_modules/engine.io-client/build/esm/contrib/parseuri.js
7702
+ /**
7703
+ * Parses a URI
7704
+ *
7705
+ * Note: we could also have used the built-in URL object, but it isn't supported on all platforms.
7706
+ *
7707
+ * See:
7708
+ * - https://developer.mozilla.org/en-US/docs/Web/API/URL
7709
+ * - https://caniuse.com/url
7710
+ * - https://www.rfc-editor.org/rfc/rfc3986#appendix-B
7711
+ *
7712
+ * History of the parse() method:
7713
+ * - first commit: https://github.com/socketio/socket.io-client/commit/4ee1d5d94b3906a9c052b459f1a818b15f38f91c
7714
+ * - export into its own module: https://github.com/socketio/engine.io-client/commit/de2c561e4564efeb78f1bdb1ba39ef81b2822cb3
7715
+ * - reimport: https://github.com/socketio/engine.io-client/commit/df32277c3f6d622eec5ed09f493cae3f3391d242
7716
+ *
7717
+ * @author Steven Levithan <stevenlevithan.com> (MIT license)
7718
+ * @api private
7719
+ */
7720
+ var re = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
7721
+ var parts = [
7722
+ "source",
7723
+ "protocol",
7724
+ "authority",
7725
+ "userInfo",
7726
+ "user",
7727
+ "password",
7728
+ "host",
7729
+ "port",
7730
+ "relative",
7731
+ "path",
7732
+ "directory",
7733
+ "file",
7734
+ "query",
7735
+ "anchor"
7736
+ ];
7737
+ function parse(str) {
7738
+ if (str.length > 8e3) throw "URI too long";
7739
+ const src = str, b = str.indexOf("["), e = str.indexOf("]");
7740
+ if (b != -1 && e != -1) str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ";") + str.substring(e, str.length);
7741
+ let m = re.exec(str || ""), uri = {}, i = 14;
7742
+ while (i--) uri[parts[i]] = m[i] || "";
7743
+ if (b != -1 && e != -1) {
7744
+ uri.source = src;
7745
+ uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ":");
7746
+ uri.authority = uri.authority.replace("[", "").replace("]", "").replace(/;/g, ":");
7747
+ uri.ipv6uri = true;
7748
+ }
7749
+ uri.pathNames = pathNames(uri, uri["path"]);
7750
+ uri.queryKey = queryKey(uri, uri["query"]);
7751
+ return uri;
7752
+ }
7753
+ function pathNames(obj, path) {
7754
+ const names = path.replace(/\/{2,9}/g, "/").split("/");
7755
+ if (path.slice(0, 1) == "/" || path.length === 0) names.splice(0, 1);
7756
+ if (path.slice(-1) == "/") names.splice(names.length - 1, 1);
7757
+ return names;
7758
+ }
7759
+ function queryKey(uri, query) {
7760
+ const data = {};
7761
+ query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function($0, $1, $2) {
7762
+ if ($1) data[$1] = $2;
7763
+ });
7764
+ return data;
7765
+ }
7766
+ //#endregion
7767
+ //#region node_modules/engine.io-client/build/esm/socket.js
7768
+ var withEventListeners = typeof addEventListener === "function" && typeof removeEventListener === "function";
7769
+ var OFFLINE_EVENT_LISTENERS = [];
7770
+ if (withEventListeners) addEventListener("offline", () => {
7771
+ OFFLINE_EVENT_LISTENERS.forEach((listener) => listener());
7772
+ }, false);
7773
+ /**
7774
+ * This class provides a WebSocket-like interface to connect to an Engine.IO server. The connection will be established
7775
+ * with one of the available low-level transports, like HTTP long-polling, WebSocket or WebTransport.
7776
+ *
7777
+ * This class comes without upgrade mechanism, which means that it will keep the first low-level transport that
7778
+ * successfully establishes the connection.
7779
+ *
7780
+ * In order to allow tree-shaking, there are no transports included, that's why the `transports` option is mandatory.
7781
+ *
7782
+ * @example
7783
+ * import { SocketWithoutUpgrade, WebSocket } from "engine.io-client";
7784
+ *
7785
+ * const socket = new SocketWithoutUpgrade({
7786
+ * transports: [WebSocket]
7787
+ * });
7788
+ *
7789
+ * socket.on("open", () => {
7790
+ * socket.send("hello");
7791
+ * });
7792
+ *
7793
+ * @see SocketWithUpgrade
7794
+ * @see Socket
7795
+ */
7796
+ var SocketWithoutUpgrade = class SocketWithoutUpgrade extends Emitter {
7797
+ /**
7798
+ * Socket constructor.
7799
+ *
7800
+ * @param {String|Object} uri - uri or options
7801
+ * @param {Object} opts - options
7802
+ */
7803
+ constructor(uri, opts) {
7804
+ super();
7805
+ this.binaryType = defaultBinaryType;
7806
+ this.writeBuffer = [];
7807
+ this._prevBufferLen = 0;
7808
+ this._pingInterval = -1;
7809
+ this._pingTimeout = -1;
7810
+ this._maxPayload = -1;
7811
+ /**
7812
+ * The expiration timestamp of the {@link _pingTimeoutTimer} object is tracked, in case the timer is throttled and the
7813
+ * callback is not fired on time. This can happen for example when a laptop is suspended or when a phone is locked.
7814
+ */
7815
+ this._pingTimeoutTime = Infinity;
7816
+ if (uri && "object" === typeof uri) {
7817
+ opts = uri;
7818
+ uri = null;
7819
+ }
7820
+ if (uri) {
7821
+ const parsedUri = parse(uri);
7822
+ opts.hostname = parsedUri.host;
7823
+ opts.secure = parsedUri.protocol === "https" || parsedUri.protocol === "wss";
7824
+ opts.port = parsedUri.port;
7825
+ if (parsedUri.query) opts.query = parsedUri.query;
7826
+ } else if (opts.host) opts.hostname = parse(opts.host).host;
7827
+ installTimerFunctions(this, opts);
7828
+ this.secure = null != opts.secure ? opts.secure : typeof location !== "undefined" && "https:" === location.protocol;
7829
+ if (opts.hostname && !opts.port) opts.port = this.secure ? "443" : "80";
7830
+ this.hostname = opts.hostname || (typeof location !== "undefined" ? location.hostname : "localhost");
7831
+ this.port = opts.port || (typeof location !== "undefined" && location.port ? location.port : this.secure ? "443" : "80");
7832
+ this.transports = [];
7833
+ this._transportsByName = {};
7834
+ opts.transports.forEach((t) => {
7835
+ const transportName = t.prototype.name;
7836
+ this.transports.push(transportName);
7837
+ this._transportsByName[transportName] = t;
7838
+ });
7839
+ this.opts = Object.assign({
7840
+ path: "/engine.io",
7841
+ agent: false,
7842
+ withCredentials: false,
7843
+ upgrade: true,
7844
+ timestampParam: "t",
7845
+ rememberUpgrade: false,
7846
+ addTrailingSlash: true,
7847
+ rejectUnauthorized: true,
7848
+ perMessageDeflate: { threshold: 1024 },
7849
+ transportOptions: {},
7850
+ closeOnBeforeunload: false
7851
+ }, opts);
7852
+ this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : "");
7853
+ if (typeof this.opts.query === "string") this.opts.query = decode(this.opts.query);
7854
+ if (withEventListeners) {
7855
+ if (this.opts.closeOnBeforeunload) {
7856
+ this._beforeunloadEventListener = () => {
7857
+ if (this.transport) {
7858
+ this.transport.removeAllListeners();
7859
+ this.transport.close();
7860
+ }
7861
+ };
7862
+ addEventListener("beforeunload", this._beforeunloadEventListener, false);
7863
+ }
7864
+ if (this.hostname !== "localhost") {
7865
+ this._offlineEventListener = () => {
7866
+ this._onClose("transport close", { description: "network connection lost" });
7867
+ };
7868
+ OFFLINE_EVENT_LISTENERS.push(this._offlineEventListener);
7869
+ }
7870
+ }
7871
+ if (this.opts.withCredentials) this._cookieJar = /* @__PURE__ */ createCookieJar();
7872
+ this._open();
7873
+ }
7874
+ /**
7875
+ * Creates transport of the given type.
7876
+ *
7877
+ * @param {String} name - transport name
7878
+ * @return {Transport}
7879
+ * @private
7880
+ */
7881
+ createTransport(name) {
7882
+ const query = Object.assign({}, this.opts.query);
7883
+ query.EIO = 4;
7884
+ query.transport = name;
7885
+ if (this.id) query.sid = this.id;
7886
+ const opts = Object.assign({}, this.opts, {
7887
+ query,
7888
+ socket: this,
7889
+ hostname: this.hostname,
7890
+ secure: this.secure,
7891
+ port: this.port
7892
+ }, this.opts.transportOptions[name]);
7893
+ return new this._transportsByName[name](opts);
7894
+ }
7895
+ /**
7896
+ * Initializes transport to use and starts probe.
7897
+ *
7898
+ * @private
7899
+ */
7900
+ _open() {
7901
+ if (this.transports.length === 0) {
7902
+ this.setTimeoutFn(() => {
7903
+ this.emitReserved("error", "No transports available");
7904
+ }, 0);
7905
+ return;
7906
+ }
7907
+ const transportName = this.opts.rememberUpgrade && SocketWithoutUpgrade.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
7908
+ this.readyState = "opening";
7909
+ const transport = this.createTransport(transportName);
7910
+ transport.open();
7911
+ this.setTransport(transport);
7912
+ }
7913
+ /**
7914
+ * Sets the current transport. Disables the existing one (if any).
7915
+ *
7916
+ * @private
7917
+ */
7918
+ setTransport(transport) {
7919
+ if (this.transport) this.transport.removeAllListeners();
7920
+ this.transport = transport;
7921
+ transport.on("drain", this._onDrain.bind(this)).on("packet", this._onPacket.bind(this)).on("error", this._onError.bind(this)).on("close", (reason) => this._onClose("transport close", reason));
7922
+ }
7923
+ /**
7924
+ * Called when connection is deemed open.
7925
+ *
7926
+ * @private
7927
+ */
7928
+ onOpen() {
7929
+ this.readyState = "open";
7930
+ SocketWithoutUpgrade.priorWebsocketSuccess = "websocket" === this.transport.name;
7931
+ this.emitReserved("open");
7932
+ this.flush();
7933
+ }
7934
+ /**
7935
+ * Handles a packet.
7936
+ *
7937
+ * @private
7938
+ */
7939
+ _onPacket(packet) {
7940
+ if ("opening" === this.readyState || "open" === this.readyState || "closing" === this.readyState) {
7941
+ this.emitReserved("packet", packet);
7942
+ this.emitReserved("heartbeat");
7943
+ switch (packet.type) {
7944
+ case "open":
7945
+ this.onHandshake(JSON.parse(packet.data));
7946
+ break;
7947
+ case "ping":
7948
+ this._sendPacket("pong");
7949
+ this.emitReserved("ping");
7950
+ this.emitReserved("pong");
7951
+ this._resetPingTimeout();
7952
+ break;
7953
+ case "error":
7954
+ const err = /* @__PURE__ */ new Error("server error");
7955
+ err.code = packet.data;
7956
+ this._onError(err);
7957
+ break;
7958
+ case "message":
7959
+ this.emitReserved("data", packet.data);
7960
+ this.emitReserved("message", packet.data);
7961
+ break;
7962
+ }
7963
+ }
7964
+ }
7965
+ /**
7966
+ * Called upon handshake completion.
7967
+ *
7968
+ * @param {Object} data - handshake obj
7969
+ * @private
7970
+ */
7971
+ onHandshake(data) {
7972
+ this.emitReserved("handshake", data);
7973
+ this.id = data.sid;
7974
+ this.transport.query.sid = data.sid;
7975
+ this._pingInterval = data.pingInterval;
7976
+ this._pingTimeout = data.pingTimeout;
7977
+ this._maxPayload = data.maxPayload;
7978
+ this.onOpen();
7979
+ if ("closed" === this.readyState) return;
7980
+ this._resetPingTimeout();
7981
+ }
7982
+ /**
7983
+ * Sets and resets ping timeout timer based on server pings.
7984
+ *
7985
+ * @private
7986
+ */
7987
+ _resetPingTimeout() {
7988
+ this.clearTimeoutFn(this._pingTimeoutTimer);
7989
+ const delay = this._pingInterval + this._pingTimeout;
7990
+ this._pingTimeoutTime = Date.now() + delay;
7991
+ this._pingTimeoutTimer = this.setTimeoutFn(() => {
7992
+ this._onClose("ping timeout");
7993
+ }, delay);
7994
+ if (this.opts.autoUnref) this._pingTimeoutTimer.unref();
7995
+ }
7996
+ /**
7997
+ * Called on `drain` event
7998
+ *
7999
+ * @private
8000
+ */
8001
+ _onDrain() {
8002
+ this.writeBuffer.splice(0, this._prevBufferLen);
8003
+ this._prevBufferLen = 0;
8004
+ if (0 === this.writeBuffer.length) this.emitReserved("drain");
8005
+ else this.flush();
8006
+ }
8007
+ /**
8008
+ * Flush write buffers.
8009
+ *
8010
+ * @private
8011
+ */
8012
+ flush() {
8013
+ if ("closed" !== this.readyState && this.transport.writable && !this.upgrading && this.writeBuffer.length) {
8014
+ const packets = this._getWritablePackets();
8015
+ this.transport.send(packets);
8016
+ this._prevBufferLen = packets.length;
8017
+ this.emitReserved("flush");
8018
+ }
8019
+ }
8020
+ /**
8021
+ * Ensure the encoded size of the writeBuffer is below the maxPayload value sent by the server (only for HTTP
8022
+ * long-polling)
8023
+ *
8024
+ * @private
8025
+ */
8026
+ _getWritablePackets() {
8027
+ if (!(this._maxPayload && this.transport.name === "polling" && this.writeBuffer.length > 1)) return this.writeBuffer;
8028
+ let payloadSize = 1;
8029
+ for (let i = 0; i < this.writeBuffer.length; i++) {
8030
+ const data = this.writeBuffer[i].data;
8031
+ if (data) payloadSize += byteLength(data);
8032
+ if (i > 0 && payloadSize > this._maxPayload) return this.writeBuffer.slice(0, i);
8033
+ payloadSize += 2;
8034
+ }
8035
+ return this.writeBuffer;
8036
+ }
8037
+ /**
8038
+ * Checks whether the heartbeat timer has expired but the socket has not yet been notified.
8039
+ *
8040
+ * Note: this method is private for now because it does not really fit the WebSocket API, but if we put it in the
8041
+ * `write()` method then the message would not be buffered by the Socket.IO client.
8042
+ *
8043
+ * @return {boolean}
8044
+ * @private
8045
+ */
8046
+ _hasPingExpired() {
8047
+ if (!this._pingTimeoutTime) return true;
8048
+ const hasExpired = Date.now() > this._pingTimeoutTime;
8049
+ if (hasExpired) {
8050
+ this._pingTimeoutTime = 0;
8051
+ nextTick(() => {
8052
+ this._onClose("ping timeout");
8053
+ }, this.setTimeoutFn);
8054
+ }
8055
+ return hasExpired;
8056
+ }
8057
+ /**
8058
+ * Sends a message.
8059
+ *
8060
+ * @param {String} msg - message.
8061
+ * @param {Object} options.
8062
+ * @param {Function} fn - callback function.
8063
+ * @return {Socket} for chaining.
8064
+ */
8065
+ write(msg, options, fn) {
8066
+ this._sendPacket("message", msg, options, fn);
8067
+ return this;
8068
+ }
8069
+ /**
8070
+ * Sends a message. Alias of {@link Socket#write}.
8071
+ *
8072
+ * @param {String} msg - message.
8073
+ * @param {Object} options.
8074
+ * @param {Function} fn - callback function.
8075
+ * @return {Socket} for chaining.
8076
+ */
8077
+ send(msg, options, fn) {
8078
+ this._sendPacket("message", msg, options, fn);
8079
+ return this;
8080
+ }
8081
+ /**
8082
+ * Sends a packet.
8083
+ *
8084
+ * @param {String} type: packet type.
8085
+ * @param {String} data.
8086
+ * @param {Object} options.
8087
+ * @param {Function} fn - callback function.
8088
+ * @private
8089
+ */
8090
+ _sendPacket(type, data, options, fn) {
8091
+ if ("function" === typeof data) {
8092
+ fn = data;
8093
+ data = void 0;
8094
+ }
8095
+ if ("function" === typeof options) {
8096
+ fn = options;
8097
+ options = null;
8098
+ }
8099
+ if ("closing" === this.readyState || "closed" === this.readyState) return;
8100
+ options = options || {};
8101
+ options.compress = false !== options.compress;
8102
+ const packet = {
8103
+ type,
8104
+ data,
8105
+ options
8106
+ };
8107
+ this.emitReserved("packetCreate", packet);
8108
+ this.writeBuffer.push(packet);
8109
+ if (fn) this.once("flush", fn);
8110
+ this.flush();
8111
+ }
8112
+ /**
8113
+ * Closes the connection.
8114
+ */
8115
+ close() {
8116
+ const close = () => {
8117
+ this._onClose("forced close");
8118
+ this.transport.close();
8119
+ };
8120
+ const cleanupAndClose = () => {
8121
+ this.off("upgrade", cleanupAndClose);
8122
+ this.off("upgradeError", cleanupAndClose);
8123
+ close();
8124
+ };
8125
+ const waitForUpgrade = () => {
8126
+ this.once("upgrade", cleanupAndClose);
8127
+ this.once("upgradeError", cleanupAndClose);
8128
+ };
8129
+ if ("opening" === this.readyState || "open" === this.readyState) {
8130
+ this.readyState = "closing";
8131
+ if (this.writeBuffer.length) this.once("drain", () => {
8132
+ if (this.upgrading) waitForUpgrade();
8133
+ else close();
8134
+ });
8135
+ else if (this.upgrading) waitForUpgrade();
8136
+ else close();
8137
+ }
8138
+ return this;
8139
+ }
8140
+ /**
8141
+ * Called upon transport error
8142
+ *
8143
+ * @private
8144
+ */
8145
+ _onError(err) {
8146
+ SocketWithoutUpgrade.priorWebsocketSuccess = false;
8147
+ if (this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening") {
8148
+ this.transports.shift();
8149
+ return this._open();
8150
+ }
8151
+ this.emitReserved("error", err);
8152
+ this._onClose("transport error", err);
8153
+ }
8154
+ /**
8155
+ * Called upon transport close.
8156
+ *
8157
+ * @private
8158
+ */
8159
+ _onClose(reason, description) {
8160
+ if ("opening" === this.readyState || "open" === this.readyState || "closing" === this.readyState) {
8161
+ this.clearTimeoutFn(this._pingTimeoutTimer);
8162
+ this.transport.removeAllListeners("close");
8163
+ this.transport.close();
8164
+ this.transport.removeAllListeners();
8165
+ if (withEventListeners) {
8166
+ if (this._beforeunloadEventListener) removeEventListener("beforeunload", this._beforeunloadEventListener, false);
8167
+ if (this._offlineEventListener) {
8168
+ const i = OFFLINE_EVENT_LISTENERS.indexOf(this._offlineEventListener);
8169
+ if (i !== -1) OFFLINE_EVENT_LISTENERS.splice(i, 1);
8170
+ }
8171
+ }
8172
+ this.readyState = "closed";
8173
+ this.id = null;
8174
+ this.emitReserved("close", reason, description);
8175
+ this.writeBuffer = [];
8176
+ this._prevBufferLen = 0;
8177
+ }
8178
+ }
8179
+ };
8180
+ SocketWithoutUpgrade.protocol = 4;
8181
+ /**
8182
+ * This class provides a WebSocket-like interface to connect to an Engine.IO server. The connection will be established
8183
+ * with one of the available low-level transports, like HTTP long-polling, WebSocket or WebTransport.
8184
+ *
8185
+ * This class comes with an upgrade mechanism, which means that once the connection is established with the first
8186
+ * low-level transport, it will try to upgrade to a better transport.
8187
+ *
8188
+ * In order to allow tree-shaking, there are no transports included, that's why the `transports` option is mandatory.
8189
+ *
8190
+ * @example
8191
+ * import { SocketWithUpgrade, WebSocket } from "engine.io-client";
8192
+ *
8193
+ * const socket = new SocketWithUpgrade({
8194
+ * transports: [WebSocket]
8195
+ * });
8196
+ *
8197
+ * socket.on("open", () => {
8198
+ * socket.send("hello");
8199
+ * });
8200
+ *
8201
+ * @see SocketWithoutUpgrade
8202
+ * @see Socket
8203
+ */
8204
+ var SocketWithUpgrade = class extends SocketWithoutUpgrade {
8205
+ constructor() {
8206
+ super(...arguments);
8207
+ this._upgrades = [];
8208
+ }
8209
+ onOpen() {
8210
+ super.onOpen();
8211
+ if ("open" === this.readyState && this.opts.upgrade) for (let i = 0; i < this._upgrades.length; i++) this._probe(this._upgrades[i]);
8212
+ }
8213
+ /**
8214
+ * Probes a transport.
8215
+ *
8216
+ * @param {String} name - transport name
8217
+ * @private
8218
+ */
8219
+ _probe(name) {
8220
+ let transport = this.createTransport(name);
8221
+ let failed = false;
8222
+ SocketWithoutUpgrade.priorWebsocketSuccess = false;
8223
+ const onTransportOpen = () => {
8224
+ if (failed) return;
8225
+ transport.send([{
8226
+ type: "ping",
8227
+ data: "probe"
8228
+ }]);
8229
+ transport.once("packet", (msg) => {
8230
+ if (failed) return;
8231
+ if ("pong" === msg.type && "probe" === msg.data) {
8232
+ this.upgrading = true;
8233
+ this.emitReserved("upgrading", transport);
8234
+ if (!transport) return;
8235
+ SocketWithoutUpgrade.priorWebsocketSuccess = "websocket" === transport.name;
8236
+ this.transport.pause(() => {
8237
+ if (failed) return;
8238
+ if ("closed" === this.readyState) return;
8239
+ cleanup();
8240
+ this.setTransport(transport);
8241
+ transport.send([{ type: "upgrade" }]);
8242
+ this.emitReserved("upgrade", transport);
8243
+ transport = null;
8244
+ this.upgrading = false;
8245
+ this.flush();
8246
+ });
8247
+ } else {
8248
+ const err = /* @__PURE__ */ new Error("probe error");
8249
+ err.transport = transport.name;
8250
+ this.emitReserved("upgradeError", err);
8251
+ }
8252
+ });
8253
+ };
8254
+ function freezeTransport() {
8255
+ if (failed) return;
8256
+ failed = true;
8257
+ cleanup();
8258
+ transport.close();
8259
+ transport = null;
8260
+ }
8261
+ const onerror = (err) => {
8262
+ const error = /* @__PURE__ */ new Error("probe error: " + err);
8263
+ error.transport = transport.name;
8264
+ freezeTransport();
8265
+ this.emitReserved("upgradeError", error);
8266
+ };
8267
+ function onTransportClose() {
8268
+ onerror("transport closed");
8269
+ }
8270
+ function onclose() {
8271
+ onerror("socket closed");
8272
+ }
8273
+ function onupgrade(to) {
8274
+ if (transport && to.name !== transport.name) freezeTransport();
8275
+ }
8276
+ const cleanup = () => {
8277
+ transport.removeListener("open", onTransportOpen);
8278
+ transport.removeListener("error", onerror);
8279
+ transport.removeListener("close", onTransportClose);
8280
+ this.off("close", onclose);
8281
+ this.off("upgrading", onupgrade);
8282
+ };
8283
+ transport.once("open", onTransportOpen);
8284
+ transport.once("error", onerror);
8285
+ transport.once("close", onTransportClose);
8286
+ this.once("close", onclose);
8287
+ this.once("upgrading", onupgrade);
8288
+ if (this._upgrades.indexOf("webtransport") !== -1 && name !== "webtransport") this.setTimeoutFn(() => {
8289
+ if (!failed) transport.open();
8290
+ }, 200);
8291
+ else transport.open();
8292
+ }
8293
+ onHandshake(data) {
8294
+ this._upgrades = this._filterUpgrades(data.upgrades);
8295
+ super.onHandshake(data);
8296
+ }
8297
+ /**
8298
+ * Filters upgrades, returning only those matching client transports.
8299
+ *
8300
+ * @param {Array} upgrades - server upgrades
8301
+ * @private
8302
+ */
8303
+ _filterUpgrades(upgrades) {
8304
+ const filteredUpgrades = [];
8305
+ for (let i = 0; i < upgrades.length; i++) if (~this.transports.indexOf(upgrades[i])) filteredUpgrades.push(upgrades[i]);
8306
+ return filteredUpgrades;
8307
+ }
8308
+ };
8309
+ /**
8310
+ * This class provides a WebSocket-like interface to connect to an Engine.IO server. The connection will be established
8311
+ * with one of the available low-level transports, like HTTP long-polling, WebSocket or WebTransport.
8312
+ *
8313
+ * This class comes with an upgrade mechanism, which means that once the connection is established with the first
8314
+ * low-level transport, it will try to upgrade to a better transport.
8315
+ *
8316
+ * @example
8317
+ * import { Socket } from "engine.io-client";
8318
+ *
8319
+ * const socket = new Socket();
8320
+ *
8321
+ * socket.on("open", () => {
8322
+ * socket.send("hello");
8323
+ * });
8324
+ *
8325
+ * @see SocketWithoutUpgrade
8326
+ * @see SocketWithUpgrade
8327
+ */
8328
+ var Socket$1 = class extends SocketWithUpgrade {
8329
+ constructor(uri, opts = {}) {
8330
+ const o = typeof uri === "object" ? uri : opts;
8331
+ if (!o.transports || o.transports && typeof o.transports[0] === "string") o.transports = (o.transports || [
8332
+ "polling",
8333
+ "websocket",
8334
+ "webtransport"
8335
+ ]).map((transportName) => transports[transportName]).filter((t) => !!t);
8336
+ super(uri, o);
8337
+ }
8338
+ };
8339
+ Socket$1.protocol;
8340
+ //#endregion
8341
+ //#region node_modules/socket.io-client/build/esm/url.js
8342
+ /**
8343
+ * URL parser.
8344
+ *
8345
+ * @param uri - url
8346
+ * @param path - the request path of the connection
8347
+ * @param loc - An object meant to mimic window.location.
8348
+ * Defaults to window.location.
8349
+ * @public
8350
+ */
8351
+ function url(uri, path = "", loc) {
8352
+ let obj = uri;
8353
+ loc = loc || typeof location !== "undefined" && location;
8354
+ if (null == uri) uri = loc.protocol + "//" + loc.host;
8355
+ if (typeof uri === "string") {
8356
+ if ("/" === uri.charAt(0)) if ("/" === uri.charAt(1)) uri = loc.protocol + uri;
8357
+ else uri = loc.host + uri;
8358
+ if (!/^(https?|wss?):\/\//.test(uri)) if ("undefined" !== typeof loc) uri = loc.protocol + "//" + uri;
8359
+ else uri = "https://" + uri;
8360
+ obj = parse(uri);
8361
+ }
8362
+ if (!obj.port) {
8363
+ if (/^(http|ws)$/.test(obj.protocol)) obj.port = "80";
8364
+ else if (/^(http|ws)s$/.test(obj.protocol)) obj.port = "443";
8365
+ }
8366
+ obj.path = obj.path || "/";
8367
+ const host = obj.host.indexOf(":") !== -1 ? "[" + obj.host + "]" : obj.host;
8368
+ obj.id = obj.protocol + "://" + host + ":" + obj.port + path;
8369
+ obj.href = obj.protocol + "://" + host + (loc && loc.port === obj.port ? "" : ":" + obj.port);
8370
+ return obj;
8371
+ }
8372
+ //#endregion
8373
+ //#region node_modules/socket.io-parser/build/esm/is-binary.js
8374
+ var withNativeArrayBuffer = typeof ArrayBuffer === "function";
8375
+ var isView = (obj) => {
8376
+ return typeof ArrayBuffer.isView === "function" ? ArrayBuffer.isView(obj) : obj.buffer instanceof ArrayBuffer;
8377
+ };
8378
+ var toString = Object.prototype.toString;
8379
+ var withNativeBlob = typeof Blob === "function" || typeof Blob !== "undefined" && toString.call(Blob) === "[object BlobConstructor]";
8380
+ var withNativeFile = typeof File === "function" || typeof File !== "undefined" && toString.call(File) === "[object FileConstructor]";
8381
+ /**
8382
+ * Returns true if obj is a Buffer, an ArrayBuffer, a Blob or a File.
8383
+ *
8384
+ * @private
8385
+ */
8386
+ function isBinary(obj) {
8387
+ return withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj)) || withNativeBlob && obj instanceof Blob || withNativeFile && obj instanceof File;
8388
+ }
8389
+ function hasBinary(obj, toJSON) {
8390
+ if (!obj || typeof obj !== "object") return false;
8391
+ if (Array.isArray(obj)) {
8392
+ for (let i = 0, l = obj.length; i < l; i++) if (hasBinary(obj[i])) return true;
8393
+ return false;
8394
+ }
8395
+ if (isBinary(obj)) return true;
8396
+ if (obj.toJSON && typeof obj.toJSON === "function" && arguments.length === 1) return hasBinary(obj.toJSON(), true);
8397
+ for (const key in obj) if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) return true;
8398
+ return false;
8399
+ }
8400
+ //#endregion
8401
+ //#region node_modules/socket.io-parser/build/esm/binary.js
8402
+ /**
8403
+ * Replaces every Buffer | ArrayBuffer | Blob | File in packet with a numbered placeholder.
8404
+ *
8405
+ * @param {Object} packet - socket.io event packet
8406
+ * @return {Object} with deconstructed packet and list of buffers
8407
+ * @public
8408
+ */
8409
+ function deconstructPacket(packet) {
8410
+ const buffers = [];
8411
+ const packetData = packet.data;
8412
+ const pack = packet;
8413
+ pack.data = _deconstructPacket(packetData, buffers);
8414
+ pack.attachments = buffers.length;
8415
+ return {
8416
+ packet: pack,
8417
+ buffers
8418
+ };
8419
+ }
8420
+ function _deconstructPacket(data, buffers) {
8421
+ if (!data) return data;
8422
+ if (isBinary(data)) {
8423
+ const placeholder = {
8424
+ _placeholder: true,
8425
+ num: buffers.length
8426
+ };
8427
+ buffers.push(data);
8428
+ return placeholder;
8429
+ } else if (Array.isArray(data)) {
8430
+ const newData = new Array(data.length);
8431
+ for (let i = 0; i < data.length; i++) newData[i] = _deconstructPacket(data[i], buffers);
8432
+ return newData;
8433
+ } else if (typeof data === "object" && !(data instanceof Date)) {
8434
+ const newData = {};
8435
+ for (const key in data) if (Object.prototype.hasOwnProperty.call(data, key)) newData[key] = _deconstructPacket(data[key], buffers);
8436
+ return newData;
8437
+ }
8438
+ return data;
8439
+ }
8440
+ /**
8441
+ * Reconstructs a binary packet from its placeholder packet and buffers
8442
+ *
8443
+ * @param {Object} packet - event packet with placeholders
8444
+ * @param {Array} buffers - binary buffers to put in placeholder positions
8445
+ * @return {Object} reconstructed packet
8446
+ * @public
8447
+ */
8448
+ function reconstructPacket(packet, buffers) {
8449
+ packet.data = _reconstructPacket(packet.data, buffers);
8450
+ delete packet.attachments;
8451
+ return packet;
8452
+ }
8453
+ function _reconstructPacket(data, buffers) {
8454
+ if (!data) return data;
8455
+ if (data && data._placeholder === true) if (typeof data.num === "number" && data.num >= 0 && data.num < buffers.length) return buffers[data.num];
8456
+ else throw new Error("illegal attachments");
8457
+ else if (Array.isArray(data)) for (let i = 0; i < data.length; i++) data[i] = _reconstructPacket(data[i], buffers);
8458
+ else if (typeof data === "object") {
8459
+ for (const key in data) if (Object.prototype.hasOwnProperty.call(data, key)) data[key] = _reconstructPacket(data[key], buffers);
8460
+ }
8461
+ return data;
8462
+ }
8463
+ //#endregion
8464
+ //#region node_modules/socket.io-parser/build/esm/index.js
8465
+ var esm_exports = /* @__PURE__ */ __exportAll({
8466
+ Decoder: () => Decoder,
8467
+ Encoder: () => Encoder,
8468
+ PacketType: () => PacketType,
8469
+ isPacketValid: () => isPacketValid,
8470
+ protocol: () => 5
8471
+ });
8472
+ /**
8473
+ * These strings must not be used as event names, as they have a special meaning.
8474
+ */
8475
+ var RESERVED_EVENTS$1 = [
8476
+ "connect",
8477
+ "connect_error",
8478
+ "disconnect",
8479
+ "disconnecting",
8480
+ "newListener",
8481
+ "removeListener"
8482
+ ];
8483
+ var PacketType;
8484
+ (function(PacketType) {
8485
+ PacketType[PacketType["CONNECT"] = 0] = "CONNECT";
8486
+ PacketType[PacketType["DISCONNECT"] = 1] = "DISCONNECT";
8487
+ PacketType[PacketType["EVENT"] = 2] = "EVENT";
8488
+ PacketType[PacketType["ACK"] = 3] = "ACK";
8489
+ PacketType[PacketType["CONNECT_ERROR"] = 4] = "CONNECT_ERROR";
8490
+ PacketType[PacketType["BINARY_EVENT"] = 5] = "BINARY_EVENT";
8491
+ PacketType[PacketType["BINARY_ACK"] = 6] = "BINARY_ACK";
8492
+ })(PacketType || (PacketType = {}));
8493
+ /**
8494
+ * A socket.io Encoder instance
8495
+ */
8496
+ var Encoder = class {
8497
+ /**
8498
+ * Encoder constructor
8499
+ *
8500
+ * @param {function} replacer - custom replacer to pass down to JSON.parse
8501
+ */
8502
+ constructor(replacer) {
8503
+ this.replacer = replacer;
8504
+ }
8505
+ /**
8506
+ * Encode a packet as a single string if non-binary, or as a
8507
+ * buffer sequence, depending on packet type.
8508
+ *
8509
+ * @param {Object} obj - packet object
8510
+ */
8511
+ encode(obj) {
8512
+ if (obj.type === PacketType.EVENT || obj.type === PacketType.ACK) {
8513
+ if (hasBinary(obj)) return this.encodeAsBinary({
8514
+ type: obj.type === PacketType.EVENT ? PacketType.BINARY_EVENT : PacketType.BINARY_ACK,
8515
+ nsp: obj.nsp,
8516
+ data: obj.data,
8517
+ id: obj.id
8518
+ });
8519
+ }
8520
+ return [this.encodeAsString(obj)];
8521
+ }
8522
+ /**
8523
+ * Encode packet as string.
8524
+ */
8525
+ encodeAsString(obj) {
8526
+ let str = "" + obj.type;
8527
+ if (obj.type === PacketType.BINARY_EVENT || obj.type === PacketType.BINARY_ACK) str += obj.attachments + "-";
8528
+ if (obj.nsp && "/" !== obj.nsp) str += obj.nsp + ",";
8529
+ if (null != obj.id) str += obj.id;
8530
+ if (null != obj.data) str += JSON.stringify(obj.data, this.replacer);
8531
+ return str;
8532
+ }
8533
+ /**
8534
+ * Encode packet as 'buffer sequence' by removing blobs, and
8535
+ * deconstructing packet into object with placeholders and
8536
+ * a list of buffers.
8537
+ */
8538
+ encodeAsBinary(obj) {
8539
+ const deconstruction = deconstructPacket(obj);
8540
+ const pack = this.encodeAsString(deconstruction.packet);
8541
+ const buffers = deconstruction.buffers;
8542
+ buffers.unshift(pack);
8543
+ return buffers;
8544
+ }
8545
+ };
8546
+ /**
8547
+ * A socket.io Decoder instance
8548
+ *
8549
+ * @return {Object} decoder
8550
+ */
8551
+ var Decoder = class Decoder extends Emitter {
8552
+ /**
8553
+ * Decoder constructor
8554
+ */
8555
+ constructor(opts) {
8556
+ super();
8557
+ this.opts = Object.assign({
8558
+ reviver: void 0,
8559
+ maxAttachments: 10
8560
+ }, typeof opts === "function" ? { reviver: opts } : opts);
8561
+ }
8562
+ /**
8563
+ * Decodes an encoded packet string into packet JSON.
8564
+ *
8565
+ * @param {String} obj - encoded packet
8566
+ */
8567
+ add(obj) {
8568
+ let packet;
8569
+ if (typeof obj === "string") {
8570
+ if (this.reconstructor) throw new Error("got plaintext data when reconstructing a packet");
8571
+ packet = this.decodeString(obj);
8572
+ const isBinaryEvent = packet.type === PacketType.BINARY_EVENT;
8573
+ if (isBinaryEvent || packet.type === PacketType.BINARY_ACK) {
8574
+ packet.type = isBinaryEvent ? PacketType.EVENT : PacketType.ACK;
8575
+ this.reconstructor = new BinaryReconstructor(packet);
8576
+ if (packet.attachments === 0) super.emitReserved("decoded", packet);
8577
+ } else super.emitReserved("decoded", packet);
8578
+ } else if (isBinary(obj) || obj.base64) if (!this.reconstructor) throw new Error("got binary data when not reconstructing a packet");
8579
+ else {
8580
+ packet = this.reconstructor.takeBinaryData(obj);
8581
+ if (packet) {
8582
+ this.reconstructor = null;
8583
+ super.emitReserved("decoded", packet);
8584
+ }
8585
+ }
8586
+ else throw new Error("Unknown type: " + obj);
8587
+ }
8588
+ /**
8589
+ * Decode a packet String (JSON data)
8590
+ *
8591
+ * @param {String} str
8592
+ * @return {Object} packet
8593
+ */
8594
+ decodeString(str) {
8595
+ let i = 0;
8596
+ const p = { type: Number(str.charAt(0)) };
8597
+ if (PacketType[p.type] === void 0) throw new Error("unknown packet type " + p.type);
8598
+ if (p.type === PacketType.BINARY_EVENT || p.type === PacketType.BINARY_ACK) {
8599
+ const start = i + 1;
8600
+ while (str.charAt(++i) !== "-" && i != str.length);
8601
+ const buf = str.substring(start, i);
8602
+ if (buf != Number(buf) || str.charAt(i) !== "-") throw new Error("Illegal attachments");
8603
+ const n = Number(buf);
8604
+ if (!isInteger(n) || n < 0) throw new Error("Illegal attachments");
8605
+ else if (n > this.opts.maxAttachments) throw new Error("too many attachments");
8606
+ p.attachments = n;
8607
+ }
8608
+ if ("/" === str.charAt(i + 1)) {
8609
+ const start = i + 1;
8610
+ while (++i) {
8611
+ if ("," === str.charAt(i)) break;
8612
+ if (i === str.length) break;
8613
+ }
8614
+ p.nsp = str.substring(start, i);
8615
+ } else p.nsp = "/";
8616
+ const next = str.charAt(i + 1);
8617
+ if ("" !== next && Number(next) == next) {
8618
+ const start = i + 1;
8619
+ while (++i) {
8620
+ const c = str.charAt(i);
8621
+ if (null == c || Number(c) != c) {
8622
+ --i;
8623
+ break;
8624
+ }
8625
+ if (i === str.length) break;
8626
+ }
8627
+ p.id = Number(str.substring(start, i + 1));
8628
+ }
8629
+ if (str.charAt(++i)) {
8630
+ const payload = this.tryParse(str.substr(i));
8631
+ if (Decoder.isPayloadValid(p.type, payload)) p.data = payload;
8632
+ else throw new Error("invalid payload");
8633
+ }
8634
+ return p;
8635
+ }
8636
+ tryParse(str) {
8637
+ try {
8638
+ return JSON.parse(str, this.opts.reviver);
8639
+ } catch (e) {
8640
+ return false;
8641
+ }
8642
+ }
8643
+ static isPayloadValid(type, payload) {
8644
+ switch (type) {
8645
+ case PacketType.CONNECT: return isObject(payload);
8646
+ case PacketType.DISCONNECT: return payload === void 0;
8647
+ case PacketType.CONNECT_ERROR: return typeof payload === "string" || isObject(payload);
8648
+ case PacketType.EVENT:
8649
+ case PacketType.BINARY_EVENT: return Array.isArray(payload) && (typeof payload[0] === "number" || typeof payload[0] === "string" && RESERVED_EVENTS$1.indexOf(payload[0]) === -1);
8650
+ case PacketType.ACK:
8651
+ case PacketType.BINARY_ACK: return Array.isArray(payload);
8652
+ }
8653
+ }
8654
+ /**
8655
+ * Deallocates a parser's resources
8656
+ */
8657
+ destroy() {
8658
+ if (this.reconstructor) {
8659
+ this.reconstructor.finishedReconstruction();
8660
+ this.reconstructor = null;
8661
+ }
8662
+ }
8663
+ };
8664
+ /**
8665
+ * A manager of a binary event's 'buffer sequence'. Should
8666
+ * be constructed whenever a packet of type BINARY_EVENT is
8667
+ * decoded.
8668
+ *
8669
+ * @param {Object} packet
8670
+ * @return {BinaryReconstructor} initialized reconstructor
8671
+ */
8672
+ var BinaryReconstructor = class {
8673
+ constructor(packet) {
8674
+ this.packet = packet;
8675
+ this.buffers = [];
8676
+ this.reconPack = packet;
8677
+ }
8678
+ /**
8679
+ * Method to be called when binary data received from connection
8680
+ * after a BINARY_EVENT packet.
8681
+ *
8682
+ * @param {Buffer | ArrayBuffer} binData - the raw binary data received
8683
+ * @return {null | Object} returns null if more binary data is expected or
8684
+ * a reconstructed packet object if all buffers have been received.
8685
+ */
8686
+ takeBinaryData(binData) {
8687
+ this.buffers.push(binData);
8688
+ if (this.buffers.length === this.reconPack.attachments) {
8689
+ const packet = reconstructPacket(this.reconPack, this.buffers);
8690
+ this.finishedReconstruction();
8691
+ return packet;
8692
+ }
8693
+ return null;
8694
+ }
8695
+ /**
8696
+ * Cleans up binary packet reconstruction variables.
8697
+ */
8698
+ finishedReconstruction() {
8699
+ this.reconPack = null;
8700
+ this.buffers = [];
8701
+ }
8702
+ };
8703
+ function isNamespaceValid(nsp) {
8704
+ return typeof nsp === "string";
8705
+ }
8706
+ var isInteger = Number.isInteger || function(value) {
8707
+ return typeof value === "number" && isFinite(value) && Math.floor(value) === value;
8708
+ };
8709
+ function isAckIdValid(id) {
8710
+ return id === void 0 || isInteger(id);
8711
+ }
8712
+ function isObject(value) {
8713
+ return Object.prototype.toString.call(value) === "[object Object]";
8714
+ }
8715
+ function isDataValid(type, payload) {
8716
+ switch (type) {
8717
+ case PacketType.CONNECT: return payload === void 0 || isObject(payload);
8718
+ case PacketType.DISCONNECT: return payload === void 0;
8719
+ case PacketType.EVENT: return Array.isArray(payload) && (typeof payload[0] === "number" || typeof payload[0] === "string" && RESERVED_EVENTS$1.indexOf(payload[0]) === -1);
8720
+ case PacketType.ACK: return Array.isArray(payload);
8721
+ case PacketType.CONNECT_ERROR: return typeof payload === "string" || isObject(payload);
8722
+ default: return false;
8723
+ }
8724
+ }
8725
+ function isPacketValid(packet) {
8726
+ return isNamespaceValid(packet.nsp) && isAckIdValid(packet.id) && isDataValid(packet.type, packet.data);
8727
+ }
8728
+ //#endregion
8729
+ //#region node_modules/socket.io-client/build/esm/on.js
8730
+ function on(obj, ev, fn) {
8731
+ obj.on(ev, fn);
8732
+ return function subDestroy() {
8733
+ obj.off(ev, fn);
8734
+ };
8735
+ }
8736
+ //#endregion
8737
+ //#region node_modules/socket.io-client/build/esm/socket.js
8738
+ /**
8739
+ * Internal events.
8740
+ * These events can't be emitted by the user.
8741
+ */
8742
+ var RESERVED_EVENTS = Object.freeze({
8743
+ connect: 1,
8744
+ connect_error: 1,
8745
+ disconnect: 1,
8746
+ disconnecting: 1,
8747
+ newListener: 1,
8748
+ removeListener: 1
8749
+ });
8750
+ /**
8751
+ * A Socket is the fundamental class for interacting with the server.
8752
+ *
8753
+ * A Socket belongs to a certain Namespace (by default /) and uses an underlying {@link Manager} to communicate.
8754
+ *
8755
+ * @example
8756
+ * const socket = io();
8757
+ *
8758
+ * socket.on("connect", () => {
8759
+ * console.log("connected");
8760
+ * });
8761
+ *
8762
+ * // send an event to the server
8763
+ * socket.emit("foo", "bar");
8764
+ *
8765
+ * socket.on("foobar", () => {
8766
+ * // an event was received from the server
8767
+ * });
8768
+ *
8769
+ * // upon disconnection
8770
+ * socket.on("disconnect", (reason) => {
8771
+ * console.log(`disconnected due to ${reason}`);
8772
+ * });
8773
+ */
8774
+ var Socket = class extends Emitter {
8775
+ /**
8776
+ * `Socket` constructor.
8777
+ */
8778
+ constructor(io, nsp, opts) {
8779
+ super();
8780
+ /**
8781
+ * Whether the socket is currently connected to the server.
8782
+ *
8783
+ * @example
8784
+ * const socket = io();
8785
+ *
8786
+ * socket.on("connect", () => {
8787
+ * console.log(socket.connected); // true
8788
+ * });
8789
+ *
8790
+ * socket.on("disconnect", () => {
8791
+ * console.log(socket.connected); // false
8792
+ * });
8793
+ */
8794
+ this.connected = false;
8795
+ /**
8796
+ * Whether the connection state was recovered after a temporary disconnection. In that case, any missed packets will
8797
+ * be transmitted by the server.
8798
+ */
8799
+ this.recovered = false;
8800
+ /**
8801
+ * Buffer for packets received before the CONNECT packet
8802
+ */
8803
+ this.receiveBuffer = [];
8804
+ /**
8805
+ * Buffer for packets that will be sent once the socket is connected
8806
+ */
8807
+ this.sendBuffer = [];
8808
+ /**
8809
+ * The queue of packets to be sent with retry in case of failure.
8810
+ *
8811
+ * Packets are sent one by one, each waiting for the server acknowledgement, in order to guarantee the delivery order.
8812
+ * @private
8813
+ */
8814
+ this._queue = [];
8815
+ /**
8816
+ * A sequence to generate the ID of the {@link QueuedPacket}.
8817
+ * @private
8818
+ */
8819
+ this._queueSeq = 0;
8820
+ this.ids = 0;
8821
+ /**
8822
+ * A map containing acknowledgement handlers.
8823
+ *
8824
+ * The `withError` attribute is used to differentiate handlers that accept an error as first argument:
8825
+ *
8826
+ * - `socket.emit("test", (err, value) => { ... })` with `ackTimeout` option
8827
+ * - `socket.timeout(5000).emit("test", (err, value) => { ... })`
8828
+ * - `const value = await socket.emitWithAck("test")`
8829
+ *
8830
+ * From those that don't:
8831
+ *
8832
+ * - `socket.emit("test", (value) => { ... });`
8833
+ *
8834
+ * In the first case, the handlers will be called with an error when:
8835
+ *
8836
+ * - the timeout is reached
8837
+ * - the socket gets disconnected
8838
+ *
8839
+ * In the second case, the handlers will be simply discarded upon disconnection, since the client will never receive
8840
+ * an acknowledgement from the server.
8841
+ *
8842
+ * @private
8843
+ */
8844
+ this.acks = {};
8845
+ this.flags = {};
8846
+ this.io = io;
8847
+ this.nsp = nsp;
8848
+ if (opts && opts.auth) this.auth = opts.auth;
8849
+ this._opts = Object.assign({}, opts);
8850
+ if (this.io._autoConnect) this.open();
8851
+ }
8852
+ /**
8853
+ * Whether the socket is currently disconnected
8854
+ *
8855
+ * @example
8856
+ * const socket = io();
8857
+ *
8858
+ * socket.on("connect", () => {
8859
+ * console.log(socket.disconnected); // false
8860
+ * });
8861
+ *
8862
+ * socket.on("disconnect", () => {
8863
+ * console.log(socket.disconnected); // true
8864
+ * });
8865
+ */
8866
+ get disconnected() {
8867
+ return !this.connected;
8868
+ }
8869
+ /**
8870
+ * Subscribe to open, close and packet events
8871
+ *
8872
+ * @private
8873
+ */
8874
+ subEvents() {
8875
+ if (this.subs) return;
8876
+ const io = this.io;
8877
+ this.subs = [
8878
+ on(io, "open", this.onopen.bind(this)),
8879
+ on(io, "packet", this.onpacket.bind(this)),
8880
+ on(io, "error", this.onerror.bind(this)),
8881
+ on(io, "close", this.onclose.bind(this))
8882
+ ];
8883
+ }
8884
+ /**
8885
+ * Whether the Socket will try to reconnect when its Manager connects or reconnects.
8886
+ *
8887
+ * @example
8888
+ * const socket = io();
8889
+ *
8890
+ * console.log(socket.active); // true
8891
+ *
8892
+ * socket.on("disconnect", (reason) => {
8893
+ * if (reason === "io server disconnect") {
8894
+ * // the disconnection was initiated by the server, you need to manually reconnect
8895
+ * console.log(socket.active); // false
8896
+ * }
8897
+ * // else the socket will automatically try to reconnect
8898
+ * console.log(socket.active); // true
8899
+ * });
8900
+ */
8901
+ get active() {
8902
+ return !!this.subs;
8903
+ }
8904
+ /**
8905
+ * "Opens" the socket.
8906
+ *
8907
+ * @example
8908
+ * const socket = io({
8909
+ * autoConnect: false
8910
+ * });
8911
+ *
8912
+ * socket.connect();
8913
+ */
8914
+ connect() {
8915
+ if (this.connected) return this;
8916
+ this.subEvents();
8917
+ if (!this.io["_reconnecting"]) this.io.open();
8918
+ if ("open" === this.io._readyState) this.onopen();
8919
+ return this;
8920
+ }
8921
+ /**
8922
+ * Alias for {@link connect()}.
8923
+ */
8924
+ open() {
8925
+ return this.connect();
8926
+ }
8927
+ /**
8928
+ * Sends a `message` event.
8929
+ *
8930
+ * This method mimics the WebSocket.send() method.
8931
+ *
8932
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send
8933
+ *
8934
+ * @example
8935
+ * socket.send("hello");
8936
+ *
8937
+ * // this is equivalent to
8938
+ * socket.emit("message", "hello");
8939
+ *
8940
+ * @return self
8941
+ */
8942
+ send(...args) {
8943
+ args.unshift("message");
8944
+ this.emit.apply(this, args);
8945
+ return this;
8946
+ }
8947
+ /**
8948
+ * Override `emit`.
8949
+ * If the event is in `events`, it's emitted normally.
8950
+ *
8951
+ * @example
8952
+ * socket.emit("hello", "world");
8953
+ *
8954
+ * // all serializable datastructures are supported (no need to call JSON.stringify)
8955
+ * socket.emit("hello", 1, "2", { 3: ["4"], 5: Uint8Array.from([6]) });
8956
+ *
8957
+ * // with an acknowledgement from the server
8958
+ * socket.emit("hello", "world", (val) => {
8959
+ * // ...
8960
+ * });
8961
+ *
8962
+ * @return self
8963
+ */
8964
+ emit(ev, ...args) {
8965
+ var _a, _b, _c;
8966
+ if (RESERVED_EVENTS.hasOwnProperty(ev)) throw new Error("\"" + ev.toString() + "\" is a reserved event name");
8967
+ args.unshift(ev);
8968
+ if (this._opts.retries && !this.flags.fromQueue && !this.flags.volatile) {
8969
+ this._addToQueue(args);
8970
+ return this;
8971
+ }
8972
+ const packet = {
8973
+ type: PacketType.EVENT,
8974
+ data: args
8975
+ };
8976
+ packet.options = {};
8977
+ packet.options.compress = this.flags.compress !== false;
8978
+ if ("function" === typeof args[args.length - 1]) {
8979
+ const id = this.ids++;
8980
+ const ack = args.pop();
8981
+ this._registerAckCallback(id, ack);
8982
+ packet.id = id;
8983
+ }
8984
+ const isTransportWritable = (_b = (_a = this.io.engine) === null || _a === void 0 ? void 0 : _a.transport) === null || _b === void 0 ? void 0 : _b.writable;
8985
+ const isConnected = this.connected && !((_c = this.io.engine) === null || _c === void 0 ? void 0 : _c._hasPingExpired());
8986
+ if (this.flags.volatile && !isTransportWritable) {} else if (isConnected) {
8987
+ this.notifyOutgoingListeners(packet);
8988
+ this.packet(packet);
8989
+ } else this.sendBuffer.push(packet);
8990
+ this.flags = {};
8991
+ return this;
8992
+ }
8993
+ /**
8994
+ * @private
8995
+ */
8996
+ _registerAckCallback(id, ack) {
8997
+ var _a;
8998
+ const timeout = (_a = this.flags.timeout) !== null && _a !== void 0 ? _a : this._opts.ackTimeout;
8999
+ if (timeout === void 0) {
9000
+ this.acks[id] = ack;
9001
+ return;
9002
+ }
9003
+ const timer = this.io.setTimeoutFn(() => {
9004
+ delete this.acks[id];
9005
+ for (let i = 0; i < this.sendBuffer.length; i++) if (this.sendBuffer[i].id === id) this.sendBuffer.splice(i, 1);
9006
+ ack.call(this, /* @__PURE__ */ new Error("operation has timed out"));
9007
+ }, timeout);
9008
+ const fn = (...args) => {
9009
+ this.io.clearTimeoutFn(timer);
9010
+ ack.apply(this, args);
9011
+ };
9012
+ fn.withError = true;
9013
+ this.acks[id] = fn;
9014
+ }
9015
+ /**
9016
+ * Emits an event and waits for an acknowledgement
9017
+ *
9018
+ * @example
9019
+ * // without timeout
9020
+ * const response = await socket.emitWithAck("hello", "world");
9021
+ *
9022
+ * // with a specific timeout
9023
+ * try {
9024
+ * const response = await socket.timeout(1000).emitWithAck("hello", "world");
9025
+ * } catch (err) {
9026
+ * // the server did not acknowledge the event in the given delay
9027
+ * }
9028
+ *
9029
+ * @return a Promise that will be fulfilled when the server acknowledges the event
9030
+ */
9031
+ emitWithAck(ev, ...args) {
9032
+ return new Promise((resolve, reject) => {
9033
+ const fn = (arg1, arg2) => {
9034
+ return arg1 ? reject(arg1) : resolve(arg2);
9035
+ };
9036
+ fn.withError = true;
9037
+ args.push(fn);
9038
+ this.emit(ev, ...args);
9039
+ });
9040
+ }
9041
+ /**
9042
+ * Add the packet to the queue.
9043
+ * @param args
9044
+ * @private
9045
+ */
9046
+ _addToQueue(args) {
9047
+ let ack;
9048
+ if (typeof args[args.length - 1] === "function") ack = args.pop();
9049
+ const packet = {
9050
+ id: this._queueSeq++,
9051
+ tryCount: 0,
9052
+ pending: false,
9053
+ args,
9054
+ flags: Object.assign({ fromQueue: true }, this.flags)
9055
+ };
9056
+ args.push((err, ...responseArgs) => {
9057
+ if (packet !== this._queue[0]) {}
9058
+ if (err !== null) {
9059
+ if (packet.tryCount > this._opts.retries) {
9060
+ this._queue.shift();
9061
+ if (ack) ack(err);
9062
+ }
9063
+ } else {
9064
+ this._queue.shift();
9065
+ if (ack) ack(null, ...responseArgs);
9066
+ }
9067
+ packet.pending = false;
9068
+ return this._drainQueue();
9069
+ });
9070
+ this._queue.push(packet);
9071
+ this._drainQueue();
9072
+ }
9073
+ /**
9074
+ * Send the first packet of the queue, and wait for an acknowledgement from the server.
9075
+ * @param force - whether to resend a packet that has not been acknowledged yet
9076
+ *
9077
+ * @private
9078
+ */
9079
+ _drainQueue(force = false) {
9080
+ if (!this.connected || this._queue.length === 0) return;
9081
+ const packet = this._queue[0];
9082
+ if (packet.pending && !force) return;
9083
+ packet.pending = true;
9084
+ packet.tryCount++;
9085
+ this.flags = packet.flags;
9086
+ this.emit.apply(this, packet.args);
9087
+ }
9088
+ /**
9089
+ * Sends a packet.
9090
+ *
9091
+ * @param packet
9092
+ * @private
9093
+ */
9094
+ packet(packet) {
9095
+ packet.nsp = this.nsp;
9096
+ this.io._packet(packet);
9097
+ }
9098
+ /**
9099
+ * Called upon engine `open`.
9100
+ *
9101
+ * @private
9102
+ */
9103
+ onopen() {
9104
+ if (typeof this.auth == "function") this.auth((data) => {
9105
+ this._sendConnectPacket(data);
9106
+ });
9107
+ else this._sendConnectPacket(this.auth);
9108
+ }
9109
+ /**
9110
+ * Sends a CONNECT packet to initiate the Socket.IO session.
9111
+ *
9112
+ * @param data
9113
+ * @private
9114
+ */
9115
+ _sendConnectPacket(data) {
9116
+ this.packet({
9117
+ type: PacketType.CONNECT,
9118
+ data: this._pid ? Object.assign({
9119
+ pid: this._pid,
9120
+ offset: this._lastOffset
9121
+ }, data) : data
9122
+ });
9123
+ }
9124
+ /**
9125
+ * Called upon engine or manager `error`.
9126
+ *
9127
+ * @param err
9128
+ * @private
9129
+ */
9130
+ onerror(err) {
9131
+ if (!this.connected) this.emitReserved("connect_error", err);
9132
+ }
9133
+ /**
9134
+ * Called upon engine `close`.
9135
+ *
9136
+ * @param reason
9137
+ * @param description
9138
+ * @private
9139
+ */
9140
+ onclose(reason, description) {
9141
+ this.connected = false;
9142
+ delete this.id;
9143
+ this.emitReserved("disconnect", reason, description);
9144
+ this._clearAcks();
9145
+ }
9146
+ /**
9147
+ * Clears the acknowledgement handlers upon disconnection, since the client will never receive an acknowledgement from
9148
+ * the server.
9149
+ *
9150
+ * @private
9151
+ */
9152
+ _clearAcks() {
9153
+ Object.keys(this.acks).forEach((id) => {
9154
+ if (!this.sendBuffer.some((packet) => String(packet.id) === id)) {
9155
+ const ack = this.acks[id];
9156
+ delete this.acks[id];
9157
+ if (ack.withError) ack.call(this, /* @__PURE__ */ new Error("socket has been disconnected"));
9158
+ }
9159
+ });
9160
+ }
9161
+ /**
9162
+ * Called with socket packet.
9163
+ *
9164
+ * @param packet
9165
+ * @private
9166
+ */
9167
+ onpacket(packet) {
9168
+ if (!(packet.nsp === this.nsp)) return;
9169
+ switch (packet.type) {
9170
+ case PacketType.CONNECT:
9171
+ if (packet.data && packet.data.sid) this.onconnect(packet.data.sid, packet.data.pid);
9172
+ else this.emitReserved("connect_error", /* @__PURE__ */ 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/)"));
9173
+ break;
9174
+ case PacketType.EVENT:
9175
+ case PacketType.BINARY_EVENT:
9176
+ this.onevent(packet);
9177
+ break;
9178
+ case PacketType.ACK:
9179
+ case PacketType.BINARY_ACK:
9180
+ this.onack(packet);
9181
+ break;
9182
+ case PacketType.DISCONNECT:
9183
+ this.ondisconnect();
9184
+ break;
9185
+ case PacketType.CONNECT_ERROR:
9186
+ this.destroy();
9187
+ const err = new Error(packet.data.message);
9188
+ err.data = packet.data.data;
9189
+ this.emitReserved("connect_error", err);
9190
+ break;
9191
+ }
9192
+ }
9193
+ /**
9194
+ * Called upon a server event.
9195
+ *
9196
+ * @param packet
9197
+ * @private
9198
+ */
9199
+ onevent(packet) {
9200
+ const args = packet.data || [];
9201
+ if (null != packet.id) args.push(this.ack(packet.id));
9202
+ if (this.connected) this.emitEvent(args);
9203
+ else this.receiveBuffer.push(Object.freeze(args));
9204
+ }
9205
+ emitEvent(args) {
9206
+ if (this._anyListeners && this._anyListeners.length) {
9207
+ const listeners = this._anyListeners.slice();
9208
+ for (const listener of listeners) listener.apply(this, args);
9209
+ }
9210
+ super.emit.apply(this, args);
9211
+ if (this._pid && args.length && typeof args[args.length - 1] === "string") this._lastOffset = args[args.length - 1];
9212
+ }
9213
+ /**
9214
+ * Produces an ack callback to emit with an event.
9215
+ *
9216
+ * @private
9217
+ */
9218
+ ack(id) {
9219
+ const self = this;
9220
+ let sent = false;
9221
+ return function(...args) {
9222
+ if (sent) return;
9223
+ sent = true;
9224
+ self.packet({
9225
+ type: PacketType.ACK,
9226
+ id,
9227
+ data: args
9228
+ });
9229
+ };
9230
+ }
9231
+ /**
9232
+ * Called upon a server acknowledgement.
9233
+ *
9234
+ * @param packet
9235
+ * @private
9236
+ */
9237
+ onack(packet) {
9238
+ const ack = this.acks[packet.id];
9239
+ if (typeof ack !== "function") return;
9240
+ delete this.acks[packet.id];
9241
+ if (ack.withError) packet.data.unshift(null);
9242
+ ack.apply(this, packet.data);
9243
+ }
9244
+ /**
9245
+ * Called upon server connect.
9246
+ *
9247
+ * @private
9248
+ */
9249
+ onconnect(id, pid) {
9250
+ this.id = id;
9251
+ this.recovered = pid && this._pid === pid;
9252
+ this._pid = pid;
9253
+ this.connected = true;
9254
+ this.emitBuffered();
9255
+ this._drainQueue(true);
9256
+ this.emitReserved("connect");
9257
+ }
9258
+ /**
9259
+ * Emit buffered events (received and emitted).
9260
+ *
9261
+ * @private
9262
+ */
9263
+ emitBuffered() {
9264
+ this.receiveBuffer.forEach((args) => this.emitEvent(args));
9265
+ this.receiveBuffer = [];
9266
+ this.sendBuffer.forEach((packet) => {
9267
+ this.notifyOutgoingListeners(packet);
9268
+ this.packet(packet);
9269
+ });
9270
+ this.sendBuffer = [];
9271
+ }
9272
+ /**
9273
+ * Called upon server disconnect.
9274
+ *
9275
+ * @private
9276
+ */
9277
+ ondisconnect() {
9278
+ this.destroy();
9279
+ this.onclose("io server disconnect");
9280
+ }
9281
+ /**
9282
+ * Called upon forced client/server side disconnections,
9283
+ * this method ensures the manager stops tracking us and
9284
+ * that reconnections don't get triggered for this.
9285
+ *
9286
+ * @private
9287
+ */
9288
+ destroy() {
9289
+ if (this.subs) {
9290
+ this.subs.forEach((subDestroy) => subDestroy());
9291
+ this.subs = void 0;
9292
+ }
9293
+ this.io["_destroy"](this);
9294
+ }
9295
+ /**
9296
+ * Disconnects the socket manually. In that case, the socket will not try to reconnect.
9297
+ *
9298
+ * If this is the last active Socket instance of the {@link Manager}, the low-level connection will be closed.
9299
+ *
9300
+ * @example
9301
+ * const socket = io();
9302
+ *
9303
+ * socket.on("disconnect", (reason) => {
9304
+ * // console.log(reason); prints "io client disconnect"
9305
+ * });
9306
+ *
9307
+ * socket.disconnect();
9308
+ *
9309
+ * @return self
9310
+ */
9311
+ disconnect() {
9312
+ if (this.connected) this.packet({ type: PacketType.DISCONNECT });
9313
+ this.destroy();
9314
+ if (this.connected) this.onclose("io client disconnect");
9315
+ return this;
9316
+ }
9317
+ /**
9318
+ * Alias for {@link disconnect()}.
9319
+ *
9320
+ * @return self
9321
+ */
9322
+ close() {
9323
+ return this.disconnect();
9324
+ }
9325
+ /**
9326
+ * Sets the compress flag.
9327
+ *
9328
+ * @example
9329
+ * socket.compress(false).emit("hello");
9330
+ *
9331
+ * @param compress - if `true`, compresses the sending data
9332
+ * @return self
9333
+ */
9334
+ compress(compress) {
9335
+ this.flags.compress = compress;
9336
+ return this;
9337
+ }
9338
+ /**
9339
+ * Sets a modifier for a subsequent event emission that the event message will be dropped when this socket is not
9340
+ * ready to send messages.
9341
+ *
9342
+ * @example
9343
+ * socket.volatile.emit("hello"); // the server may or may not receive it
9344
+ *
9345
+ * @returns self
9346
+ */
9347
+ get volatile() {
9348
+ this.flags.volatile = true;
9349
+ return this;
9350
+ }
9351
+ /**
9352
+ * Sets a modifier for a subsequent event emission that the callback will be called with an error when the
9353
+ * given number of milliseconds have elapsed without an acknowledgement from the server:
9354
+ *
9355
+ * @example
9356
+ * socket.timeout(5000).emit("my-event", (err) => {
9357
+ * if (err) {
9358
+ * // the server did not acknowledge the event in the given delay
9359
+ * }
9360
+ * });
9361
+ *
9362
+ * @returns self
9363
+ */
9364
+ timeout(timeout) {
9365
+ this.flags.timeout = timeout;
9366
+ return this;
9367
+ }
9368
+ /**
9369
+ * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
9370
+ * callback.
9371
+ *
9372
+ * @example
9373
+ * socket.onAny((event, ...args) => {
9374
+ * console.log(`got ${event}`);
9375
+ * });
9376
+ *
9377
+ * @param listener
9378
+ */
9379
+ onAny(listener) {
9380
+ this._anyListeners = this._anyListeners || [];
9381
+ this._anyListeners.push(listener);
9382
+ return this;
9383
+ }
9384
+ /**
9385
+ * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
9386
+ * callback. The listener is added to the beginning of the listeners array.
9387
+ *
9388
+ * @example
9389
+ * socket.prependAny((event, ...args) => {
9390
+ * console.log(`got event ${event}`);
9391
+ * });
9392
+ *
9393
+ * @param listener
9394
+ */
9395
+ prependAny(listener) {
9396
+ this._anyListeners = this._anyListeners || [];
9397
+ this._anyListeners.unshift(listener);
9398
+ return this;
9399
+ }
9400
+ /**
9401
+ * Removes the listener that will be fired when any event is emitted.
9402
+ *
9403
+ * @example
9404
+ * const catchAllListener = (event, ...args) => {
9405
+ * console.log(`got event ${event}`);
9406
+ * }
9407
+ *
9408
+ * socket.onAny(catchAllListener);
9409
+ *
9410
+ * // remove a specific listener
9411
+ * socket.offAny(catchAllListener);
9412
+ *
9413
+ * // or remove all listeners
9414
+ * socket.offAny();
9415
+ *
9416
+ * @param listener
9417
+ */
9418
+ offAny(listener) {
9419
+ if (!this._anyListeners) return this;
9420
+ if (listener) {
9421
+ const listeners = this._anyListeners;
9422
+ for (let i = 0; i < listeners.length; i++) if (listener === listeners[i]) {
9423
+ listeners.splice(i, 1);
9424
+ return this;
9425
+ }
9426
+ } else this._anyListeners = [];
9427
+ return this;
9428
+ }
9429
+ /**
9430
+ * Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,
9431
+ * e.g. to remove listeners.
9432
+ */
9433
+ listenersAny() {
9434
+ return this._anyListeners || [];
9435
+ }
9436
+ /**
9437
+ * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
9438
+ * callback.
9439
+ *
9440
+ * Note: acknowledgements sent to the server are not included.
9441
+ *
9442
+ * @example
9443
+ * socket.onAnyOutgoing((event, ...args) => {
9444
+ * console.log(`sent event ${event}`);
9445
+ * });
9446
+ *
9447
+ * @param listener
9448
+ */
9449
+ onAnyOutgoing(listener) {
9450
+ this._anyOutgoingListeners = this._anyOutgoingListeners || [];
9451
+ this._anyOutgoingListeners.push(listener);
9452
+ return this;
9453
+ }
9454
+ /**
9455
+ * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
9456
+ * callback. The listener is added to the beginning of the listeners array.
9457
+ *
9458
+ * Note: acknowledgements sent to the server are not included.
9459
+ *
9460
+ * @example
9461
+ * socket.prependAnyOutgoing((event, ...args) => {
9462
+ * console.log(`sent event ${event}`);
9463
+ * });
9464
+ *
9465
+ * @param listener
9466
+ */
9467
+ prependAnyOutgoing(listener) {
9468
+ this._anyOutgoingListeners = this._anyOutgoingListeners || [];
9469
+ this._anyOutgoingListeners.unshift(listener);
9470
+ return this;
9471
+ }
9472
+ /**
9473
+ * Removes the listener that will be fired when any event is emitted.
9474
+ *
9475
+ * @example
9476
+ * const catchAllListener = (event, ...args) => {
9477
+ * console.log(`sent event ${event}`);
9478
+ * }
9479
+ *
9480
+ * socket.onAnyOutgoing(catchAllListener);
9481
+ *
9482
+ * // remove a specific listener
9483
+ * socket.offAnyOutgoing(catchAllListener);
9484
+ *
9485
+ * // or remove all listeners
9486
+ * socket.offAnyOutgoing();
9487
+ *
9488
+ * @param [listener] - the catch-all listener (optional)
9489
+ */
9490
+ offAnyOutgoing(listener) {
9491
+ if (!this._anyOutgoingListeners) return this;
9492
+ if (listener) {
9493
+ const listeners = this._anyOutgoingListeners;
9494
+ for (let i = 0; i < listeners.length; i++) if (listener === listeners[i]) {
9495
+ listeners.splice(i, 1);
9496
+ return this;
9497
+ }
9498
+ } else this._anyOutgoingListeners = [];
9499
+ return this;
9500
+ }
9501
+ /**
9502
+ * Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,
9503
+ * e.g. to remove listeners.
9504
+ */
9505
+ listenersAnyOutgoing() {
9506
+ return this._anyOutgoingListeners || [];
9507
+ }
9508
+ /**
9509
+ * Notify the listeners for each packet sent
9510
+ *
9511
+ * @param packet
9512
+ *
9513
+ * @private
9514
+ */
9515
+ notifyOutgoingListeners(packet) {
9516
+ if (this._anyOutgoingListeners && this._anyOutgoingListeners.length) {
9517
+ const listeners = this._anyOutgoingListeners.slice();
9518
+ for (const listener of listeners) listener.apply(this, packet.data);
9519
+ }
9520
+ }
9521
+ };
9522
+ //#endregion
9523
+ //#region node_modules/socket.io-client/build/esm/contrib/backo2.js
9524
+ /**
9525
+ * Initialize backoff timer with `opts`.
9526
+ *
9527
+ * - `min` initial timeout in milliseconds [100]
9528
+ * - `max` max timeout [10000]
9529
+ * - `jitter` [0]
9530
+ * - `factor` [2]
9531
+ *
9532
+ * @param {Object} opts
9533
+ * @api public
9534
+ */
9535
+ function Backoff(opts) {
9536
+ opts = opts || {};
9537
+ this.ms = opts.min || 100;
9538
+ this.max = opts.max || 1e4;
9539
+ this.factor = opts.factor || 2;
9540
+ this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;
9541
+ this.attempts = 0;
9542
+ }
9543
+ /**
9544
+ * Return the backoff duration.
9545
+ *
9546
+ * @return {Number}
9547
+ * @api public
9548
+ */
9549
+ Backoff.prototype.duration = function() {
9550
+ var ms = this.ms * Math.pow(this.factor, this.attempts++);
9551
+ if (this.jitter) {
9552
+ var rand = Math.random();
9553
+ var deviation = Math.floor(rand * this.jitter * ms);
9554
+ ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;
9555
+ }
9556
+ return Math.min(ms, this.max) | 0;
9557
+ };
9558
+ /**
9559
+ * Reset the number of attempts.
9560
+ *
9561
+ * @api public
9562
+ */
9563
+ Backoff.prototype.reset = function() {
9564
+ this.attempts = 0;
9565
+ };
9566
+ /**
9567
+ * Set the minimum duration
9568
+ *
9569
+ * @api public
9570
+ */
9571
+ Backoff.prototype.setMin = function(min) {
9572
+ this.ms = min;
9573
+ };
9574
+ /**
9575
+ * Set the maximum duration
9576
+ *
9577
+ * @api public
9578
+ */
9579
+ Backoff.prototype.setMax = function(max) {
9580
+ this.max = max;
9581
+ };
9582
+ /**
9583
+ * Set the jitter
9584
+ *
9585
+ * @api public
9586
+ */
9587
+ Backoff.prototype.setJitter = function(jitter) {
9588
+ this.jitter = jitter;
9589
+ };
9590
+ //#endregion
9591
+ //#region node_modules/socket.io-client/build/esm/manager.js
9592
+ var Manager = class extends Emitter {
9593
+ constructor(uri, opts) {
9594
+ var _a;
9595
+ super();
9596
+ this.nsps = {};
9597
+ this.subs = [];
9598
+ if (uri && "object" === typeof uri) {
9599
+ opts = uri;
9600
+ uri = void 0;
9601
+ }
9602
+ opts = opts || {};
9603
+ opts.path = opts.path || "/socket.io";
9604
+ this.opts = opts;
9605
+ installTimerFunctions(this, opts);
9606
+ this.reconnection(opts.reconnection !== false);
9607
+ this.reconnectionAttempts(opts.reconnectionAttempts || Infinity);
9608
+ this.reconnectionDelay(opts.reconnectionDelay || 1e3);
9609
+ this.reconnectionDelayMax(opts.reconnectionDelayMax || 5e3);
9610
+ this.randomizationFactor((_a = opts.randomizationFactor) !== null && _a !== void 0 ? _a : .5);
9611
+ this.backoff = new Backoff({
9612
+ min: this.reconnectionDelay(),
9613
+ max: this.reconnectionDelayMax(),
9614
+ jitter: this.randomizationFactor()
9615
+ });
9616
+ this.timeout(null == opts.timeout ? 2e4 : opts.timeout);
9617
+ this._readyState = "closed";
9618
+ this.uri = uri;
9619
+ const _parser = opts.parser || esm_exports;
9620
+ this.encoder = new _parser.Encoder();
9621
+ this.decoder = new _parser.Decoder();
9622
+ this._autoConnect = opts.autoConnect !== false;
9623
+ if (this._autoConnect) this.open();
9624
+ }
9625
+ reconnection(v) {
9626
+ if (!arguments.length) return this._reconnection;
9627
+ this._reconnection = !!v;
9628
+ if (!v) this.skipReconnect = true;
9629
+ return this;
9630
+ }
9631
+ reconnectionAttempts(v) {
9632
+ if (v === void 0) return this._reconnectionAttempts;
9633
+ this._reconnectionAttempts = v;
9634
+ return this;
9635
+ }
9636
+ reconnectionDelay(v) {
9637
+ var _a;
9638
+ if (v === void 0) return this._reconnectionDelay;
9639
+ this._reconnectionDelay = v;
9640
+ (_a = this.backoff) === null || _a === void 0 || _a.setMin(v);
9641
+ return this;
9642
+ }
9643
+ randomizationFactor(v) {
9644
+ var _a;
9645
+ if (v === void 0) return this._randomizationFactor;
9646
+ this._randomizationFactor = v;
9647
+ (_a = this.backoff) === null || _a === void 0 || _a.setJitter(v);
9648
+ return this;
9649
+ }
9650
+ reconnectionDelayMax(v) {
9651
+ var _a;
9652
+ if (v === void 0) return this._reconnectionDelayMax;
9653
+ this._reconnectionDelayMax = v;
9654
+ (_a = this.backoff) === null || _a === void 0 || _a.setMax(v);
9655
+ return this;
9656
+ }
9657
+ timeout(v) {
9658
+ if (!arguments.length) return this._timeout;
9659
+ this._timeout = v;
9660
+ return this;
9661
+ }
9662
+ /**
9663
+ * Starts trying to reconnect if reconnection is enabled and we have not
9664
+ * started reconnecting yet
9665
+ *
9666
+ * @private
9667
+ */
9668
+ maybeReconnectOnOpen() {
9669
+ if (!this._reconnecting && this._reconnection && this.backoff.attempts === 0) this.reconnect();
9670
+ }
9671
+ /**
9672
+ * Sets the current transport `socket`.
9673
+ *
9674
+ * @param {Function} fn - optional, callback
9675
+ * @return self
9676
+ * @public
9677
+ */
9678
+ open(fn) {
9679
+ if (~this._readyState.indexOf("open")) return this;
9680
+ this.engine = new Socket$1(this.uri, this.opts);
9681
+ const socket = this.engine;
9682
+ const self = this;
9683
+ this._readyState = "opening";
9684
+ this.skipReconnect = false;
9685
+ const openSubDestroy = on(socket, "open", function() {
9686
+ self.onopen();
9687
+ fn && fn();
9688
+ });
9689
+ const onError = (err) => {
9690
+ this.cleanup();
9691
+ this._readyState = "closed";
9692
+ this.emitReserved("error", err);
9693
+ if (fn) fn(err);
9694
+ else this.maybeReconnectOnOpen();
9695
+ };
9696
+ const errorSub = on(socket, "error", onError);
9697
+ if (false !== this._timeout) {
9698
+ const timeout = this._timeout;
9699
+ const timer = this.setTimeoutFn(() => {
9700
+ openSubDestroy();
9701
+ onError(/* @__PURE__ */ new Error("timeout"));
9702
+ socket.close();
9703
+ }, timeout);
9704
+ if (this.opts.autoUnref) timer.unref();
9705
+ this.subs.push(() => {
9706
+ this.clearTimeoutFn(timer);
9707
+ });
9708
+ }
9709
+ this.subs.push(openSubDestroy);
9710
+ this.subs.push(errorSub);
9711
+ return this;
9712
+ }
9713
+ /**
9714
+ * Alias for open()
9715
+ *
9716
+ * @return self
9717
+ * @public
9718
+ */
9719
+ connect(fn) {
9720
+ return this.open(fn);
9721
+ }
9722
+ /**
9723
+ * Called upon transport open.
9724
+ *
9725
+ * @private
9726
+ */
9727
+ onopen() {
9728
+ this.cleanup();
9729
+ this._readyState = "open";
9730
+ this.emitReserved("open");
9731
+ const socket = this.engine;
9732
+ this.subs.push(on(socket, "ping", this.onping.bind(this)), on(socket, "data", this.ondata.bind(this)), on(socket, "error", this.onerror.bind(this)), on(socket, "close", this.onclose.bind(this)), on(this.decoder, "decoded", this.ondecoded.bind(this)));
9733
+ }
9734
+ /**
9735
+ * Called upon a ping.
9736
+ *
9737
+ * @private
9738
+ */
9739
+ onping() {
9740
+ this.emitReserved("ping");
9741
+ }
9742
+ /**
9743
+ * Called with data.
9744
+ *
9745
+ * @private
9746
+ */
9747
+ ondata(data) {
9748
+ try {
9749
+ this.decoder.add(data);
9750
+ } catch (e) {
9751
+ this.onclose("parse error", e);
9752
+ }
9753
+ }
9754
+ /**
9755
+ * Called when parser fully decodes a packet.
9756
+ *
9757
+ * @private
9758
+ */
9759
+ ondecoded(packet) {
9760
+ nextTick(() => {
9761
+ this.emitReserved("packet", packet);
9762
+ }, this.setTimeoutFn);
9763
+ }
9764
+ /**
9765
+ * Called upon socket error.
9766
+ *
9767
+ * @private
9768
+ */
9769
+ onerror(err) {
9770
+ this.emitReserved("error", err);
9771
+ }
9772
+ /**
9773
+ * Creates a new socket for the given `nsp`.
9774
+ *
9775
+ * @return {Socket}
9776
+ * @public
9777
+ */
9778
+ socket(nsp, opts) {
9779
+ let socket = this.nsps[nsp];
9780
+ if (!socket) {
9781
+ socket = new Socket(this, nsp, opts);
9782
+ this.nsps[nsp] = socket;
9783
+ } else if (this._autoConnect && !socket.active) socket.connect();
9784
+ return socket;
9785
+ }
9786
+ /**
9787
+ * Called upon a socket close.
9788
+ *
9789
+ * @param socket
9790
+ * @private
9791
+ */
9792
+ _destroy(socket) {
9793
+ const nsps = Object.keys(this.nsps);
9794
+ for (const nsp of nsps) if (this.nsps[nsp].active) return;
9795
+ this._close();
9796
+ }
9797
+ /**
9798
+ * Writes a packet.
9799
+ *
9800
+ * @param packet
9801
+ * @private
9802
+ */
9803
+ _packet(packet) {
9804
+ const encodedPackets = this.encoder.encode(packet);
9805
+ for (let i = 0; i < encodedPackets.length; i++) this.engine.write(encodedPackets[i], packet.options);
9806
+ }
9807
+ /**
9808
+ * Clean up transport subscriptions and packet buffer.
9809
+ *
9810
+ * @private
9811
+ */
9812
+ cleanup() {
9813
+ this.subs.forEach((subDestroy) => subDestroy());
9814
+ this.subs.length = 0;
9815
+ this.decoder.destroy();
9816
+ }
9817
+ /**
9818
+ * Close the current socket.
9819
+ *
9820
+ * @private
9821
+ */
9822
+ _close() {
9823
+ this.skipReconnect = true;
9824
+ this._reconnecting = false;
9825
+ this.onclose("forced close");
9826
+ }
9827
+ /**
9828
+ * Alias for close()
9829
+ *
9830
+ * @private
9831
+ */
9832
+ disconnect() {
9833
+ return this._close();
9834
+ }
9835
+ /**
9836
+ * Called when:
9837
+ *
9838
+ * - the low-level engine is closed
9839
+ * - the parser encountered a badly formatted packet
9840
+ * - all sockets are disconnected
9841
+ *
9842
+ * @private
9843
+ */
9844
+ onclose(reason, description) {
9845
+ var _a;
9846
+ this.cleanup();
9847
+ (_a = this.engine) === null || _a === void 0 || _a.close();
9848
+ this.backoff.reset();
9849
+ this._readyState = "closed";
9850
+ this.emitReserved("close", reason, description);
9851
+ if (this._reconnection && !this.skipReconnect) this.reconnect();
9852
+ }
9853
+ /**
9854
+ * Attempt a reconnection.
9855
+ *
9856
+ * @private
9857
+ */
9858
+ reconnect() {
9859
+ if (this._reconnecting || this.skipReconnect) return this;
9860
+ const self = this;
9861
+ if (this.backoff.attempts >= this._reconnectionAttempts) {
9862
+ this.backoff.reset();
9863
+ this.emitReserved("reconnect_failed");
9864
+ this._reconnecting = false;
9865
+ } else {
9866
+ const delay = this.backoff.duration();
9867
+ this._reconnecting = true;
9868
+ const timer = this.setTimeoutFn(() => {
9869
+ if (self.skipReconnect) return;
9870
+ this.emitReserved("reconnect_attempt", self.backoff.attempts);
9871
+ if (self.skipReconnect) return;
9872
+ self.open((err) => {
9873
+ if (err) {
9874
+ self._reconnecting = false;
9875
+ self.reconnect();
9876
+ this.emitReserved("reconnect_error", err);
9877
+ } else self.onreconnect();
9878
+ });
9879
+ }, delay);
9880
+ if (this.opts.autoUnref) timer.unref();
9881
+ this.subs.push(() => {
9882
+ this.clearTimeoutFn(timer);
9883
+ });
9884
+ }
9885
+ }
9886
+ /**
9887
+ * Called upon successful reconnect.
9888
+ *
9889
+ * @private
9890
+ */
9891
+ onreconnect() {
9892
+ const attempt = this.backoff.attempts;
9893
+ this._reconnecting = false;
9894
+ this.backoff.reset();
9895
+ this.emitReserved("reconnect", attempt);
9896
+ }
9897
+ };
9898
+ //#endregion
9899
+ //#region node_modules/socket.io-client/build/esm/index.js
9900
+ /**
9901
+ * Managers cache.
9902
+ */
9903
+ var cache = {};
9904
+ function lookup(uri, opts) {
9905
+ if (typeof uri === "object") {
9906
+ opts = uri;
9907
+ uri = void 0;
9908
+ }
9909
+ opts = opts || {};
9910
+ const parsed = url(uri, opts.path || "/socket.io");
9911
+ const source = parsed.source;
9912
+ const id = parsed.id;
9913
+ const path = parsed.path;
9914
+ const sameNamespace = cache[id] && path in cache[id]["nsps"];
9915
+ const newConnection = opts.forceNew || opts["force new connection"] || false === opts.multiplex || sameNamespace;
9916
+ let io;
9917
+ if (newConnection) io = new Manager(source, opts);
9918
+ else {
9919
+ if (!cache[id]) cache[id] = new Manager(source, opts);
9920
+ io = cache[id];
9921
+ }
9922
+ if (parsed.query && !opts.query) opts.query = parsed.queryKey;
9923
+ return io.socket(parsed.path, opts);
9924
+ }
9925
+ Object.assign(lookup, {
9926
+ Manager,
9927
+ Socket,
9928
+ io: lookup,
9929
+ connect: lookup
9930
+ });
9931
+ //#endregion
9932
+ //#region node_modules/@nsshunt/stssocketioutils/dist/index.mjs
9933
+ var import_tiny_emitter = require_tiny_emitter();
9934
+ var SocketIoClient = class extends import_tiny_emitter.TinyEmitter {
9935
+ #agentManager;
9936
+ #logger;
9937
+ #name;
9938
+ #address;
9939
+ #socketIoCustomPath;
9940
+ #authToken;
9941
+ #socket;
9942
+ #reconnectTimeout = 2e3;
9943
+ constructor(name) {
9944
+ super();
9945
+ this.#name = name;
9946
+ }
9947
+ get logPrefix() {
9948
+ return `SocketIoClient[${this.#name}]:`;
9949
+ }
9950
+ LogDebugMessage(message) {
9951
+ if (this.#logger) this.#logger.debug(`${this.logPrefix}${message}`);
9952
+ }
9953
+ LogErrorMessage(message) {
9954
+ if (this.#logger) this.#logger.error(`${this.logPrefix}${message}`);
9955
+ }
9956
+ LogWarningMessage(message) {
9957
+ if (this.#logger) this.#logger.warn(`${this.logPrefix}${message}`);
9958
+ }
9959
+ get name() {
9960
+ return this.#name;
9961
+ }
9962
+ get reconnectTimeout() {
9963
+ return this.#reconnectTimeout;
9964
+ }
9965
+ get agentManager() {
9966
+ return this.#agentManager;
9967
+ }
9968
+ get logger() {
9969
+ return this.#logger;
9970
+ }
9971
+ get address() {
9972
+ return this.#address;
9973
+ }
9974
+ get authToken() {
9975
+ return this.#authToken;
9976
+ }
9977
+ get socketIoCustomPath() {
9978
+ return this.#socketIoCustomPath;
9979
+ }
9980
+ get socket() {
9981
+ return this.#socket;
9982
+ }
9983
+ WithAddress(address) {
9984
+ this.#address = address;
9985
+ return this;
9986
+ }
9987
+ WithAuthToken(authToken) {
9988
+ this.#authToken = authToken;
9989
+ return this;
9990
+ }
9991
+ WithSocketIoCustomPath(socketIoCustomPath) {
9992
+ this.#socketIoCustomPath = socketIoCustomPath;
9993
+ return this;
9994
+ }
9995
+ WithLogger(logger) {
9996
+ this.#logger = logger;
9997
+ return this;
9998
+ }
9999
+ WithAgentManager(agentManager) {
10000
+ this.#agentManager = agentManager;
10001
+ return this;
10002
+ }
10003
+ WithReconnectTimeout(reconnectTimeout) {
10004
+ this.#reconnectTimeout = reconnectTimeout;
10005
+ return this;
10006
+ }
10007
+ SetupSocket() {
10008
+ if (!this.#address) throw new Error(`SocketIoClientHelper:SetupSocket(): Error: [address not provided]`);
10009
+ this.#EstablishSocketConnect();
10010
+ return this;
10011
+ }
10012
+ EngineError(error) {}
10013
+ EngineReconnectError(error) {}
10014
+ EngineConnectError(error) {}
10015
+ EngineReconnect(attempt) {}
10016
+ #EstablishSocketConnect() {
10017
+ if (this.#socket !== void 0) {
10018
+ if (this.#socket.connected === true) this.#socket.disconnect();
10019
+ this.#socket = void 0;
10020
+ if (_nsshunt_stsutils.isNode) setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout).unref();
10021
+ else setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout);
10022
+ return;
10023
+ }
10024
+ let socketOptions;
10025
+ if (_nsshunt_stsutils.isNode) {
10026
+ socketOptions = { transports: ["websocket"] };
10027
+ if (this.#agentManager) {
10028
+ if (!this.#address) throw new Error(`SocketIoClient:SetupSocket(): Error: [address not provided when using agentManager]`);
10029
+ socketOptions.agent = this.#agentManager.GetAgent(this.#address);
10030
+ }
10031
+ } else socketOptions = { transports: ["websocket"] };
10032
+ if (this.#authToken) socketOptions.auth = (cb) => {
10033
+ cb({ token: this.#authToken });
10034
+ };
10035
+ if (this.#socketIoCustomPath && this.#socketIoCustomPath.localeCompare("") !== 0) socketOptions.path = this.#socketIoCustomPath;
10036
+ this.#socket = lookup(this.#address, socketOptions);
10037
+ this.#socket.io.on("error", (err) => {
10038
+ this.LogErrorMessage(`socketDetail.socket.io.on('error'): [${err}] Address: [${this.#address}]`);
10039
+ this.EngineError(err);
10040
+ });
10041
+ this.#socket.io.on("reconnect_error", (err) => {
10042
+ this.LogErrorMessage(`socketDetail.socket.io.on('reconnect_error'): [${err}] Address: [${this.#address}]`);
10043
+ this.EngineReconnectError(err);
10044
+ });
10045
+ this.#socket.on("connect_error", (err) => {
10046
+ this.LogErrorMessage(`socketDetail.socket.on('connect_error'): [${err}] Address: [${this.#address}]`);
10047
+ this.EngineConnectError(err);
10048
+ });
10049
+ this.#socket.io.on("reconnect", (attempt) => {
10050
+ this.LogErrorMessage(`socketDetail.socket.io.on('reconnect'): Number: [${attempt}] Address: [${this.#address}]`);
10051
+ this.EngineReconnect(attempt);
10052
+ });
10053
+ this.#socket.on("connect", () => {
10054
+ if (this.#socket) {
10055
+ this.LogDebugMessage(`Socket: [${this.#socket.id}]: connected, Address: [${this.#address}]`);
10056
+ setTimeout(() => {
10057
+ this.SocketConnect(this.#socket);
10058
+ }, 0);
10059
+ this.SetupSocketEvents(this.#socket);
10060
+ } else {
10061
+ const errorMessage = "Could not get socket object from socket.io, Address: [${socketDetail.address}]";
10062
+ this.LogErrorMessage(errorMessage);
10063
+ this.SocketConnectError(new Error(errorMessage));
10064
+ }
10065
+ });
10066
+ this.#socket.on("disconnect", (reason) => {
10067
+ this.LogDebugMessage("socket disconnect: " + reason);
10068
+ this.SocketDisconnect(reason);
10069
+ switch (reason) {
10070
+ case "io server disconnect":
10071
+ this.LogDebugMessage("The server disconnected using disconnectSockets, i.e. normal safe shutdown from explicit disconnection by the server.");
10072
+ this.LogDebugMessage("The connection will be re-established when the server becomes available.");
10073
+ this.#socket = void 0;
10074
+ if (_nsshunt_stsutils.isNode) {
10075
+ if (this.#agentManager) this.#agentManager.ResetAgent();
10076
+ setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout).unref();
10077
+ } else setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout);
10078
+ break;
10079
+ case "io client disconnect":
10080
+ this.LogDebugMessage("The client disconnected using disconnectSockets, i.e. normal safe disconnection from explicit disconnection by the client.");
10081
+ this.LogDebugMessage("The connection will not be re-established automatically.");
10082
+ break;
10083
+ case "transport close":
10084
+ case "ping timeout":
10085
+ case "transport error":
10086
+ this.LogDebugMessage(`Server unexpectedly disconnected. Reason: [${reason}]`);
10087
+ this.LogDebugMessage("The connection will be re-established when the server becomes available.");
10088
+ if (this.#socket) this.#socket.disconnect();
10089
+ this.#socket = void 0;
10090
+ if (_nsshunt_stsutils.isNode) {
10091
+ if (this.#agentManager) this.#agentManager?.ResetAgent();
10092
+ setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout).unref();
10093
+ } else setTimeout(() => this.#EstablishSocketConnect(), this.#reconnectTimeout);
10094
+ break;
10095
+ }
10096
+ });
10097
+ }
10098
+ };
10099
+ //#endregion
10100
+ //#region src/wsevents.ts
10101
+ var IEventReturnValueBaseType = /* @__PURE__ */ function(IEventReturnValueBaseType) {
10102
+ IEventReturnValueBaseType["serviceDetails"] = "serviceDetails";
10103
+ IEventReturnValueBaseType["workers"] = "workers";
10104
+ IEventReturnValueBaseType["archiveList"] = "archiveList";
10105
+ IEventReturnValueBaseType["runner"] = "runner";
10106
+ IEventReturnValueBaseType["worker"] = "worker";
10107
+ IEventReturnValueBaseType["executeWorkerActionResult"] = "executeWorkerActionResult";
10108
+ IEventReturnValueBaseType["executeRunnerActionResult"] = "executeRunnerActionResult";
10109
+ return IEventReturnValueBaseType;
10110
+ }({});
10111
+ var IEventRequestCommand = /* @__PURE__ */ function(IEventRequestCommand) {
10112
+ IEventRequestCommand["AddRunner"] = "AddRunner";
10113
+ IEventRequestCommand["AddRunnerToWorker"] = "AddRunnerToWorker";
10114
+ IEventRequestCommand["AddWorker"] = "AddWorker";
10115
+ IEventRequestCommand["GetService"] = "GetService";
10116
+ IEventRequestCommand["GetWorkers"] = "GetWorkers";
10117
+ IEventRequestCommand["GetWorkersSmall"] = "GetWorkersSmall";
10118
+ IEventRequestCommand["GetArchiveList"] = "GetArchiveList";
10119
+ IEventRequestCommand["StartWorkers"] = "StartWorkers";
10120
+ IEventRequestCommand["StopWorkers"] = "StopWorkers";
10121
+ IEventRequestCommand["PauseWorkers"] = "PauseWorkers";
10122
+ IEventRequestCommand["ResumeWorkers"] = "ResumeWorkers";
10123
+ IEventRequestCommand["ExecuteWorkers"] = "ExecuteWorkers";
10124
+ IEventRequestCommand["ResetWorkers"] = "ResetWorkers";
10125
+ IEventRequestCommand["TerminateWorkers"] = "TerminateWorkers";
10126
+ IEventRequestCommand["UpdateWorkers"] = "UpdateWorkers";
10127
+ IEventRequestCommand["StartRunners"] = "StartRunners";
10128
+ IEventRequestCommand["StopRunners"] = "StopRunners";
10129
+ IEventRequestCommand["PauseRunners"] = "PauseRunners";
10130
+ IEventRequestCommand["ResumeRunners"] = "ResumeRunners";
10131
+ IEventRequestCommand["ExecuteRunners"] = "ExecuteRunners";
10132
+ IEventRequestCommand["ResetRunners"] = "ResetRunners";
10133
+ IEventRequestCommand["TerminateRunners"] = "TerminateRunners";
10134
+ IEventRequestCommand["UpdateRunners"] = "UpdateRunners";
10135
+ return IEventRequestCommand;
10136
+ }({});
10137
+ //#endregion
10138
+ //#region src/workerManagerProxy.ts
10139
+ var WorkerManagerProxy = class extends SocketIoClient {
10140
+ _options;
10141
+ _id = globalThis.crypto.randomUUID();
10142
+ _clientName = "";
10143
+ _wm;
10144
+ #debug = (message) => this._options.logger.debug(message);
10145
+ #error = (error) => this._options.logger.error(error);
10146
+ #info = (message) => this._options.logger.info(message);
10147
+ constructor(options) {
10148
+ super(options.name);
10149
+ this._options = options;
10150
+ this._clientName = options.name;
10151
+ this._wm = this._options.CreateSTSWorkerManager();
10152
+ this.#info(chalk.yellow(`Worker Manager ID: [${this._wm.id}]`));
10153
+ this._Start();
10154
+ }
10155
+ get workerManager() {
10156
+ return this._wm;
10157
+ }
10158
+ get id() {
10159
+ return this._id;
10160
+ }
10161
+ SocketConnectError(error) {}
10162
+ SocketDisconnect(reason) {}
10163
+ SocketConnect(socket) {
10164
+ this._OnSocketConnected(socket, this.name, []);
10165
+ }
10166
+ SocketError(error) {
10167
+ this.#error(`${this.name}: SetupClientSideSocket call back: [${error}]`);
10168
+ }
10169
+ SetupSocketEvents(socket) {
10170
+ this._RegisterSocketEvents(socket, this.name);
10171
+ }
10172
+ _GetKeyPayloadData = (eventRequestCommand, eventReturnValueBaseType) => {
10173
+ return {
10174
+ id: this._id,
10175
+ workerManagerId: this._wm.id,
10176
+ name: this._options.name,
10177
+ eventRequestCommand,
10178
+ type: eventReturnValueBaseType
10179
+ };
10180
+ };
10181
+ _LogPayloadEventRetVal = (retVal) => {
10182
+ return retVal;
10183
+ };
10184
+ _Start = async () => {
10185
+ this._EmitEvent("Starting", {});
10186
+ this.WithAddress(this._options.ststccendpoint).WithLogger(_nsshunt_stsutils.defaultLogger).WithSocketIoCustomPath("");
10187
+ if (this._options.agentManager) this.WithAgentManager(this._options.agentManager);
10188
+ this.#info(chalk.yellow(`STS Test Runner Service Instance.`));
10189
+ this.#info(chalk.yellow(`This service instance emulates instances of the ststestrunnernode service.`));
10190
+ this.#info(chalk.yellow(`Service Instance ID: [${this._id}]`));
10191
+ this.#info(chalk.yellow(`Service Instance Name: [${this._options.name}]`));
10192
+ this.#info(chalk.yellow(`Options: [${JSON.stringify(this._options)}]`));
10193
+ this.SetupSocket();
10194
+ const start = async () => {
10195
+ for (let i = 0; i < this._options.workers; i++) await this._AddWorker({
10196
+ tags: [""],
10197
+ userData: {},
10198
+ mocked: false,
10199
+ hostName: "host01",
10200
+ agentId: "agent01",
10201
+ userAgent: globalThis.crypto.randomUUID(),
10202
+ logLevel: 4
10203
+ });
10204
+ this._EmitEvent("Started", {});
10205
+ };
10206
+ await start();
10207
+ };
10208
+ Stop = async () => {
10209
+ this._EmitEvent("Stopping ...", {});
10210
+ this.#debug(chalk.magenta(`Stop(): Stopping Service.`));
10211
+ await this._wm.TerminateWorkers([]);
10212
+ this.#debug(`Stop(): Workers terminated`);
10213
+ if (this.socket) {
10214
+ this.#debug(`Stop(): Going to disconnect socket ...`);
10215
+ this.socket.disconnect();
10216
+ this.#debug(`Stop(): Socket disconnected.`);
10217
+ }
10218
+ this.#debug(`Stop(): Sleeping (500ms) ...`);
10219
+ await (0, _nsshunt_stsutils.Sleep)(500);
10220
+ this.#debug(chalk.magenta(`Stop(): Service Stopped.`));
10221
+ this._EmitEvent("Stopped", {});
10222
+ };
10223
+ _GetService = async () => {
10224
+ const raw = this._EmitEvent("GetService", this._LogPayloadEventRetVal({
10225
+ ...this._GetKeyPayloadData(IEventRequestCommand.GetService, IEventReturnValueBaseType.serviceDetails),
10226
+ serviceDetails: await this._options.GetServiceDetails()
10227
+ }));
10228
+ raw.serviceDetails = (0, fflate.gzipSync)((0, fflate.strToU8)(JSON.stringify(raw.serviceDetails)));
10229
+ return raw;
10230
+ };
10231
+ _GetServiceNoZip = async () => {
10232
+ return this._EmitEvent("GetService", this._LogPayloadEventRetVal({
10233
+ ...this._GetKeyPayloadData(IEventRequestCommand.GetService, IEventReturnValueBaseType.serviceDetails),
10234
+ serviceDetails: await this._options.GetServiceDetails()
10235
+ }));
10236
+ };
10237
+ _EmitStateChange = (runnerEx) => {
10238
+ this.#debug(chalk.rgb(10, 50, 200)(`WorkerManagerProxy:_EmitStateChange(): ==>> Runner State Change: WorkerId: [${runnerEx.workerId}] RunnerId: [${runnerEx.id}] State: [${runnerEx.state}]`));
10239
+ const stateChangeRetVal = {
10240
+ eventRequestCommand: "StateChange",
10241
+ type: IEventReturnValueBaseType.runner,
10242
+ workerManagerId: this._wm.id,
10243
+ id: this._id,
10244
+ name: this._options.name,
10245
+ runner: runnerEx.toRunner()
10246
+ };
10247
+ this._EmitEvent(`StateChange`, stateChangeRetVal);
10248
+ this.socket?.emit("StateChange", stateChangeRetVal);
10249
+ };
10250
+ _EmitTelemetry = (runnerEx) => {
10251
+ this.#debug(chalk.rgb(10, 50, 200)(`WorkerManagerProxy:_EmitTelemetry(): ==>> WorkerId: [${runnerEx.workerId}] RunnerId: [${runnerEx.id}] State: [${runnerEx.state}]`));
10252
+ const telemetryRetVal = {
10253
+ eventRequestCommand: "StateChange",
10254
+ type: IEventReturnValueBaseType.runner,
10255
+ workerManagerId: this._wm.id,
10256
+ id: this._id,
10257
+ name: this._options.name,
10258
+ runner: runnerEx.toRunner()
10259
+ };
10260
+ this._EmitEvent(`Telemetry`, telemetryRetVal);
10261
+ this.socket?.emit("Telemetry", telemetryRetVal);
10262
+ };
10263
+ _SetupRunnerEventHandlers = (runnerEx) => {
10264
+ runnerEx.on("StateChange", this._EmitStateChange);
10265
+ runnerEx.on("Telemetry", this._EmitTelemetry);
10266
+ };
10267
+ _OnSocketConnected = (socket, clientName, joinRooms) => {
10268
+ this.#debug(chalk.green(`${this._id} ${clientName}: --> connected`));
10269
+ this._EmitEvent("SocketConnected", {
10270
+ id: this._id,
10271
+ clientName,
10272
+ joinRooms: [
10273
+ ...joinRooms,
10274
+ "ststrnservices",
10275
+ this._id
10276
+ ]
10277
+ });
10278
+ if (joinRooms.length > 0) socket.emit("__STSjoinRoom", joinRooms);
10279
+ socket.emit("__STSjoinRoom", ["ststrnservices"]).emit("__STSjoinRoom", [this._id]);
10280
+ };
10281
+ _AddWorker = async (options) => {
10282
+ const workerEx = await this._wm.AddWorker(options);
10283
+ if (workerEx) return this._EmitEvent("AddWorker", this._LogPayloadEventRetVal({
10284
+ ...this._GetKeyPayloadData(IEventRequestCommand.AddWorker, IEventReturnValueBaseType.worker),
10285
+ worker: workerEx.toWorker()
10286
+ }));
10287
+ else return this._EmitEvent("AddWorker", this._LogPayloadEventRetVal({
10288
+ ...this._GetKeyPayloadData(IEventRequestCommand.AddWorker, IEventReturnValueBaseType.worker),
10289
+ worker: {}
10290
+ }));
10291
+ };
10292
+ _GetArchiveList = async (runnerSearchFilters) => {
10293
+ const raw = this._EmitEvent("GetArchiveList", this._LogPayloadEventRetVal({
10294
+ ...this._GetKeyPayloadData(IEventRequestCommand.GetArchiveList, IEventReturnValueBaseType.archiveList),
10295
+ archiveList: await this._wm.GetArchiveList(runnerSearchFilters)
10296
+ }));
10297
+ raw.archiveList = (0, fflate.gzipSync)((0, fflate.strToU8)(JSON.stringify(raw.archiveList)));
10298
+ return raw;
10299
+ };
10300
+ _GetArchiveListNoZip = async (runnerSearchFilters) => {
10301
+ return this._EmitEvent("GetArchiveList", this._LogPayloadEventRetVal({
10302
+ ...this._GetKeyPayloadData(IEventRequestCommand.GetArchiveList, IEventReturnValueBaseType.archiveList),
10303
+ archiveList: await this._wm.GetArchiveList(runnerSearchFilters)
10304
+ }));
10305
+ };
10306
+ _GetWorkers = async () => {
10307
+ const raw = this._EmitEvent("GetWorkers", this._LogPayloadEventRetVal({
10308
+ ...this._GetKeyPayloadData(IEventRequestCommand.GetWorkers, IEventReturnValueBaseType.workers),
10309
+ workers: await this._wm.GetWorkers()
10310
+ }));
10311
+ raw.workers = (0, fflate.gzipSync)((0, fflate.strToU8)(JSON.stringify(raw.workers)));
10312
+ return raw;
10313
+ };
10314
+ _GetWorkersNoZip = async () => {
10315
+ return this._EmitEvent("GetWorkers", this._LogPayloadEventRetVal({
10316
+ ...this._GetKeyPayloadData(IEventRequestCommand.GetWorkers, IEventReturnValueBaseType.workers),
10317
+ workers: await this._wm.GetWorkers()
10318
+ }));
10319
+ };
10320
+ _GetWorkersSmall = async (states) => {
10321
+ const raw = this._EmitEvent("GetWorkersSmall", this._LogPayloadEventRetVal({
10322
+ ...this._GetKeyPayloadData(IEventRequestCommand.GetWorkersSmall, IEventReturnValueBaseType.workers),
10323
+ workerCores: await this._wm.GetWorkersCore(states)
10324
+ }));
10325
+ raw.workers = (0, fflate.gzipSync)((0, fflate.strToU8)(JSON.stringify(raw.workers)));
10326
+ return raw;
10327
+ };
10328
+ _GetWorkersSmallNoZip = async (states) => {
10329
+ return this._EmitEvent("GetWorkersSmall", this._LogPayloadEventRetVal({
10330
+ ...this._GetKeyPayloadData(IEventRequestCommand.GetWorkersSmall, IEventReturnValueBaseType.workers),
10331
+ workerCores: await this._wm.GetWorkersCore(states)
10332
+ }));
10333
+ };
10334
+ _StartWorkers = async (workerIds) => {
10335
+ return this._EmitEvent("StartWorkers", this._LogPayloadEventRetVal({
10336
+ ...this._GetKeyPayloadData(IEventRequestCommand.StartWorkers, IEventReturnValueBaseType.executeWorkerActionResult),
10337
+ executeWorkerActionResult: await this._wm.StartWorkers(workerIds)
10338
+ }));
10339
+ };
10340
+ _StopWorkers = async (workerIds) => {
10341
+ return this._EmitEvent("StopWorkers", this._LogPayloadEventRetVal({
10342
+ ...this._GetKeyPayloadData(IEventRequestCommand.StopWorkers, IEventReturnValueBaseType.executeWorkerActionResult),
10343
+ executeWorkerActionResult: await this._wm.StopWorkers(workerIds)
10344
+ }));
10345
+ };
10346
+ _PauseWorkers = async (workerIds) => {
10347
+ return this._EmitEvent("PauseWorkers", this._LogPayloadEventRetVal({
10348
+ ...this._GetKeyPayloadData(IEventRequestCommand.PauseWorkers, IEventReturnValueBaseType.executeWorkerActionResult),
10349
+ executeWorkerActionResult: await this._wm.PauseWorkers(workerIds)
10350
+ }));
10351
+ };
10352
+ _ResumeWorkers = async (workerIds) => {
10353
+ return this._EmitEvent("ResumeWorkers", this._LogPayloadEventRetVal({
10354
+ ...this._GetKeyPayloadData(IEventRequestCommand.ResumeWorkers, IEventReturnValueBaseType.executeWorkerActionResult),
10355
+ executeWorkerActionResult: await this._wm.ResumeWorkers(workerIds)
10356
+ }));
10357
+ };
10358
+ _ExecuteWorkers = async (workerIds) => {
10359
+ return this._EmitEvent("ExecuteWorkers", this._LogPayloadEventRetVal({
10360
+ ...this._GetKeyPayloadData(IEventRequestCommand.ExecuteWorkers, IEventReturnValueBaseType.executeWorkerActionResult),
10361
+ executeWorkerActionResult: await this._wm.ExecuteWorkers(workerIds)
10362
+ }));
10363
+ };
10364
+ _ResetWorkers = async (workerIds) => {
10365
+ return this._EmitEvent("ResetWorkers", this._LogPayloadEventRetVal({
10366
+ ...this._GetKeyPayloadData(IEventRequestCommand.ResetWorkers, IEventReturnValueBaseType.executeWorkerActionResult),
10367
+ executeWorkerActionResult: await this._wm.ResetWorkers(workerIds)
10368
+ }));
10369
+ };
10370
+ _TerminateWorkers = async (workerIds) => {
10371
+ return this._EmitEvent("TerminateWorkers", this._LogPayloadEventRetVal({
10372
+ ...this._GetKeyPayloadData(IEventRequestCommand.TerminateWorkers, IEventReturnValueBaseType.executeWorkerActionResult),
10373
+ executeWorkerActionResult: await this._wm.TerminateWorkers(workerIds)
10374
+ }));
10375
+ };
10376
+ _UpdateWorkers = async (workerIds, options) => {
10377
+ return this._EmitEvent("UpdateWorkers", this._LogPayloadEventRetVal({
10378
+ ...this._GetKeyPayloadData(IEventRequestCommand.UpdateWorkers, IEventReturnValueBaseType.executeWorkerActionResult),
10379
+ executeWorkerActionResult: await this._wm.UpdateWorkers(workerIds, options)
10380
+ }));
10381
+ };
10382
+ _StopRunners = async (workerId, runnerIds) => {
10383
+ return this._EmitEvent("StopRunners", this._LogPayloadEventRetVal({
10384
+ ...this._GetKeyPayloadData(IEventRequestCommand.StopRunners, IEventReturnValueBaseType.executeRunnerActionResult),
10385
+ executeRunnerActionResult: await this._wm.StopRunners(workerId, runnerIds)
10386
+ }));
10387
+ };
10388
+ _StartRunners = async (workerId, runnerIds) => {
10389
+ return this._EmitEvent("StartRunners", this._LogPayloadEventRetVal({
10390
+ ...this._GetKeyPayloadData(IEventRequestCommand.StartRunners, IEventReturnValueBaseType.executeRunnerActionResult),
10391
+ executeRunnerActionResult: await this._wm.StartRunners(workerId, runnerIds)
10392
+ }));
10393
+ };
10394
+ _PauseRunners = async (workerId, runnerIds) => {
10395
+ return this._EmitEvent("PauseRunners", this._LogPayloadEventRetVal({
10396
+ ...this._GetKeyPayloadData(IEventRequestCommand.PauseRunners, IEventReturnValueBaseType.executeRunnerActionResult),
10397
+ executeRunnerActionResult: await this._wm.PauseRunners(workerId, runnerIds)
10398
+ }));
10399
+ };
10400
+ _ResumeRunners = async (workerId, runnerIds) => {
10401
+ return this._EmitEvent("ResumeRunners", this._LogPayloadEventRetVal({
10402
+ ...this._GetKeyPayloadData(IEventRequestCommand.ResumeRunners, IEventReturnValueBaseType.executeRunnerActionResult),
10403
+ executeRunnerActionResult: await this._wm.ResumeRunners(workerId, runnerIds)
10404
+ }));
10405
+ };
10406
+ _ExecuteRunners = async (workerId, runnerIds) => {
10407
+ return this._EmitEvent("ExecuteRunners", this._LogPayloadEventRetVal({
10408
+ ...this._GetKeyPayloadData(IEventRequestCommand.ExecuteRunners, IEventReturnValueBaseType.executeRunnerActionResult),
10409
+ executeRunnerActionResult: await this._wm.ExecuteRunners(workerId, runnerIds)
10410
+ }));
10411
+ };
10412
+ _ResetRunners = async (workerId, runnerIds) => {
10413
+ return this._EmitEvent("ResetRunners", this._LogPayloadEventRetVal({
10414
+ ...this._GetKeyPayloadData(IEventRequestCommand.ResetRunners, IEventReturnValueBaseType.executeRunnerActionResult),
10415
+ executeRunnerActionResult: await this._wm.ResetRunners(workerId, runnerIds)
10416
+ }));
10417
+ };
10418
+ _TerminateRunners = async (workerId, runnerIds) => {
10419
+ return this._EmitEvent("TerminateRunners", this._LogPayloadEventRetVal({
10420
+ ...this._GetKeyPayloadData(IEventRequestCommand.TerminateRunners, IEventReturnValueBaseType.executeRunnerActionResult),
10421
+ executeRunnerActionResult: await this._wm.TerminateRunners(workerId, runnerIds)
10422
+ }));
10423
+ };
10424
+ _UpdateRunners = async (workerId, runnerIds, options) => {
10425
+ return this._EmitEvent("UpdateRunners", this._LogPayloadEventRetVal({
10426
+ ...this._GetKeyPayloadData(IEventRequestCommand.UpdateRunners, IEventReturnValueBaseType.executeRunnerActionResult),
10427
+ executeRunnerActionResult: await this._wm.UpdateRunners(workerId, runnerIds, options)
10428
+ }));
10429
+ };
10430
+ _AddRunner = async (options) => {
10431
+ this.#debug(chalk.yellow(`${this._id} ${this._clientName}: --> AddRunner: [${JSON.stringify(options)}]`));
10432
+ const runnerEx = await this._wm.AddRunner(options);
10433
+ let runner = {};
10434
+ if (runnerEx) {
10435
+ this._SetupRunnerEventHandlers(runnerEx);
10436
+ this.#debug(chalk.yellow(`${this._clientName}: AddRunner: WorkerId: [${runnerEx.workerId}] RunnerId: [${runnerEx.id}]`));
10437
+ runner = runnerEx.toRunner();
10438
+ }
10439
+ return this._EmitEvent(IEventRequestCommand.AddRunner, this._LogPayloadEventRetVal({
10440
+ ...this._GetKeyPayloadData(IEventRequestCommand.AddRunner, IEventReturnValueBaseType.runner),
10441
+ runner
10442
+ }));
10443
+ };
10444
+ _AddRunnerToWorkerByWorkerId = async (workerId, options) => {
10445
+ this.#debug(chalk.yellow(`${this._id} ${this._clientName}: --> AddRunner: [${JSON.stringify(options)}]`));
10446
+ const runnerEx = await this._wm.AddRunnerToWorkerByWorkerId(workerId, options);
10447
+ let runner = {};
10448
+ if (runnerEx) {
10449
+ this._SetupRunnerEventHandlers(runnerEx);
10450
+ this.#debug(chalk.yellow(`${this._clientName}: AddRunnerToWorker: WorkerId: [${runnerEx.workerId}] RunnerId: [${runnerEx.id}]`));
10451
+ runner = runnerEx.toRunner();
10452
+ }
10453
+ return this._EmitEvent(IEventRequestCommand.AddRunnerToWorker, this._LogPayloadEventRetVal({
10454
+ ...this._GetKeyPayloadData(IEventRequestCommand.AddRunnerToWorker, IEventReturnValueBaseType.runner),
10455
+ runner
10456
+ }));
10457
+ };
10458
+ _RegisterSocketEvents = (socket, clientName) => {
10459
+ `${this._id}${clientName}`;
10460
+ const handlers = this._GetSocketEventHandlers(socket, clientName);
10461
+ for (const [event, handler] of Object.entries(handlers)) {
10462
+ const wrappedHandler = async (...args) => {
10463
+ return handler(...args);
10464
+ };
10465
+ socket.on(event, wrappedHandler);
10466
+ }
10467
+ };
10468
+ _EmitEvent = (eventName, data) => {
10469
+ this.emit(eventName, data);
10470
+ return data;
10471
+ };
10472
+ _GetSocketEventHandlers = (socket, clientName) => {
10473
+ const logPrefix = `${this._id} ${clientName}:`;
10474
+ return {
10475
+ "disconnect": (reason) => {
10476
+ this._EmitEvent("disconnect", reason);
10477
+ this.#error(`#disconnect(): [${reason}]`);
10478
+ },
10479
+ "connect_error": (error) => {
10480
+ this._EmitEvent("connect_error", error);
10481
+ if (!socket.active) this.#error(error.message);
10482
+ },
10483
+ "error": (error) => {
10484
+ this._EmitEvent("error", error);
10485
+ this.#error(`#GetSocketEventHandlers(): [${error}]`);
10486
+ },
10487
+ "__STSdisconnect": (reason) => {
10488
+ this._EmitEvent("__STSdisconnect", reason);
10489
+ this.#debug(chalk.magenta(`${logPrefix}: [${socket.id}] [${reason}]`));
10490
+ this.Stop();
10491
+ },
10492
+ "GetService": async (cb) => cb(await this._GetService()),
10493
+ "GetWorkers": async (cb) => cb(await this._GetWorkers()),
10494
+ "GetWorkersSmall": async (states, cb) => cb(await this._GetWorkersSmall(states)),
10495
+ "GetArchiveList": async (runnerSearchFilters, cb) => cb(await this._GetArchiveList(runnerSearchFilters)),
10496
+ "AddRunner": async (options, cb) => cb(await this._AddRunner(options)),
10497
+ "AddRunnerToWorkerByWorkerId": async (workerId, options, cb) => cb(await this._AddRunnerToWorkerByWorkerId(workerId, options)),
10498
+ "AddWorker": async (options, cb) => cb(await this._AddWorker(options)),
10499
+ "StartWorkers": async (workerIds, cb) => cb(await this._StartWorkers(workerIds)),
10500
+ "StopWorkers": async (workerIds, cb) => cb(await this._StopWorkers(workerIds)),
10501
+ "PauseWorkers": async (workerIds, cb) => cb(await this._PauseWorkers(workerIds)),
10502
+ "ResumeWorkers": async (workerIds, cb) => cb(await this._ResumeWorkers(workerIds)),
10503
+ "ExecuteWorkers": async (workerIds, cb) => cb(await this._ExecuteWorkers(workerIds)),
10504
+ "ResetWorkers": async (workerIds, cb) => cb(await this._ResetWorkers(workerIds)),
10505
+ "TerminateWorkers": async (workerIds, cb) => cb(await this._TerminateWorkers(workerIds)),
10506
+ "UpdateWorkers": async (workerIds, options, cb) => cb(await this._UpdateWorkers(workerIds, options)),
10507
+ "StartRunners": async (workerId, runnerIds, cb) => cb(await this._StartRunners(workerId, runnerIds)),
10508
+ "StopRunners": async (workerId, runnerIds, cb) => cb(await this._StopRunners(workerId, runnerIds)),
10509
+ "PauseRunners": async (workerId, runnerIds, cb) => cb(await this._PauseRunners(workerId, runnerIds)),
10510
+ "ResumeRunners": async (workerId, runnerIds, cb) => cb(await this._ResumeRunners(workerId, runnerIds)),
10511
+ "ExecuteRunners": async (workerId, runnerIds, cb) => cb(await this._ExecuteRunners(workerId, runnerIds)),
10512
+ "ResetRunners": async (workerId, runnerIds, cb) => cb(await this._ResetRunners(workerId, runnerIds)),
10513
+ "TerminateRunners": async (workerId, runnerIds, cb) => cb(await this._TerminateRunners(workerId, runnerIds)),
10514
+ "UpdateRunners": async (workerId, runnerIds, options, cb) => cb(await this._UpdateRunners(workerId, runnerIds, options))
10515
+ };
10516
+ };
10517
+ };
10518
+ //#endregion
6587
10519
  exports.AbstractRunnerExecutionWorker = AbstractRunnerExecutionWorker;
10520
+ exports.IEventRequestCommand = IEventRequestCommand;
10521
+ exports.IEventReturnValueBaseType = IEventReturnValueBaseType;
6588
10522
  exports.IRunnerState = IRunnerState;
6589
10523
  exports.IWorkerState = IWorkerState;
6590
10524
  exports.PublishMessageCommandsTestRunner = PublishMessageCommandsTestRunner;
6591
10525
  exports.STSWorkerManager = STSWorkerManager;
10526
+ exports.WorkerManagerProxy = WorkerManagerProxy;
6592
10527
  exports.eIWMessageCommands = eIWMessageCommands;
6593
10528
 
6594
10529
  //# sourceMappingURL=index.cjs.map