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