UNPKG

@nodecg/types

Version:

Dynamic broadcast graphics rendered in a browser

1,550 lines (1,529 loc) 105 kB
(function() { //#region rolldown:runtime var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __esm = (fn, res) => function() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; var __commonJS = (cb, mod) => function() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (all, symbols) => { let target = {}; for (var name in all) { __defProp(target, name, { get: all[name], enumerable: true }); } if (symbols) { __defProp(target, Symbol.toStringTag, { value: "Module" }); } return target; }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { key = keys[i]; if (!__hasOwnProp.call(to, key) && key !== except) { __defProp(to, key, { get: ((k) => from[k]).bind(null, key), enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } } } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); //#endregion //#region ../../node_modules/cookies-js/dist/cookies.js var require_cookies = /* @__PURE__ */ __commonJS({ "../../node_modules/cookies-js/dist/cookies.js": ((exports, module) => { (function(global, undefined$1) { "use strict"; var factory = function(window$1) { if (typeof window$1.document !== "object") throw new Error("Cookies.js requires a `window` with a `document` object"); var Cookies$1 = function(key, value$1, options) { return arguments.length === 1 ? Cookies$1.get(key) : Cookies$1.set(key, value$1, options); }; Cookies$1._document = window$1.document; Cookies$1._cacheKeyPrefix = "cookey."; Cookies$1._maxExpireDate = /* @__PURE__ */ new Date("Fri, 31 Dec 9999 23:59:59 UTC"); Cookies$1.defaults = { path: "/", secure: false }; Cookies$1.get = function(key) { if (Cookies$1._cachedDocumentCookie !== Cookies$1._document.cookie) Cookies$1._renewCache(); var value$1 = Cookies$1._cache[Cookies$1._cacheKeyPrefix + key]; return value$1 === undefined$1 ? undefined$1 : decodeURIComponent(value$1); }; Cookies$1.set = function(key, value$1, options) { options = Cookies$1._getExtendedOptions(options); options.expires = Cookies$1._getExpiresDate(value$1 === undefined$1 ? -1 : options.expires); Cookies$1._document.cookie = Cookies$1._generateCookieString(key, value$1, options); return Cookies$1; }; Cookies$1.expire = function(key, options) { return Cookies$1.set(key, undefined$1, options); }; Cookies$1._getExtendedOptions = function(options) { return { path: options && options.path || Cookies$1.defaults.path, domain: options && options.domain || Cookies$1.defaults.domain, expires: options && options.expires || Cookies$1.defaults.expires, secure: options && options.secure !== undefined$1 ? options.secure : Cookies$1.defaults.secure }; }; Cookies$1._isValidDate = function(date) { return Object.prototype.toString.call(date) === "[object Date]" && !isNaN(date.getTime()); }; Cookies$1._getExpiresDate = function(expires, now) { now = now || /* @__PURE__ */ new Date(); if (typeof expires === "number") expires = expires === Infinity ? Cookies$1._maxExpireDate : new Date(now.getTime() + expires * 1e3); else if (typeof expires === "string") expires = new Date(expires); if (expires && !Cookies$1._isValidDate(expires)) throw new Error("`expires` parameter cannot be converted to a valid Date instance"); return expires; }; Cookies$1._generateCookieString = function(key, value$1, options) { key = key.replace(/[^#$&+\^`|]/g, encodeURIComponent); key = key.replace(/\(/g, "%28").replace(/\)/g, "%29"); value$1 = (value$1 + "").replace(/[^!#$&-+\--:<-\[\]-~]/g, encodeURIComponent); options = options || {}; var cookieString = key + "=" + value$1; cookieString += options.path ? ";path=" + options.path : ""; cookieString += options.domain ? ";domain=" + options.domain : ""; cookieString += options.expires ? ";expires=" + options.expires.toUTCString() : ""; cookieString += options.secure ? ";secure" : ""; return cookieString; }; Cookies$1._getCacheFromString = function(documentCookie) { var cookieCache = {}; var cookiesArray = documentCookie ? documentCookie.split("; ") : []; for (var i = 0; i < cookiesArray.length; i++) { var cookieKvp = Cookies$1._getKeyValuePairFromCookieString(cookiesArray[i]); if (cookieCache[Cookies$1._cacheKeyPrefix + cookieKvp.key] === undefined$1) cookieCache[Cookies$1._cacheKeyPrefix + cookieKvp.key] = cookieKvp.value; } return cookieCache; }; Cookies$1._getKeyValuePairFromCookieString = function(cookieString) { var separatorIndex = cookieString.indexOf("="); separatorIndex = separatorIndex < 0 ? cookieString.length : separatorIndex; var key = cookieString.substr(0, separatorIndex); var decodedKey; try { decodedKey = decodeURIComponent(key); } catch (e) { if (console && typeof console.error === "function") console.error("Could not decode cookie with key \"" + key + "\"", e); } return { key: decodedKey, value: cookieString.substr(separatorIndex + 1) }; }; Cookies$1._renewCache = function() { Cookies$1._cache = Cookies$1._getCacheFromString(Cookies$1._document.cookie); Cookies$1._cachedDocumentCookie = Cookies$1._document.cookie; }; Cookies$1._areEnabled = function() { var testKey = "cookies.js"; var areEnabled = Cookies$1.set(testKey, 1).get(testKey) === "1"; Cookies$1.expire(testKey); return areEnabled; }; Cookies$1.enabled = Cookies$1._areEnabled(); return Cookies$1; }; var cookiesExport = global && typeof global.document === "object" ? factory(global) : factory; if (typeof define === "function" && define.amd) define(function() { return cookiesExport; }); else if (typeof exports === "object") { if (typeof module === "object" && typeof module.exports === "object") exports = module.exports = cookiesExport; exports.Cookies = cookiesExport; } else global.Cookies = cookiesExport; })(typeof window === "undefined" ? exports : window); }) }); //#endregion //#region ../../node_modules/engine.io-parser/build/esm/commons.js var PACKET_TYPES, PACKET_TYPES_REVERSE, ERROR_PACKET; var init_commons = __esm({ "../../node_modules/engine.io-parser/build/esm/commons.js": (() => { PACKET_TYPES = Object.create(null); PACKET_TYPES["open"] = "0"; PACKET_TYPES["close"] = "1"; PACKET_TYPES["ping"] = "2"; PACKET_TYPES["pong"] = "3"; PACKET_TYPES["message"] = "4"; PACKET_TYPES["upgrade"] = "5"; PACKET_TYPES["noop"] = "6"; PACKET_TYPES_REVERSE = Object.create(null); Object.keys(PACKET_TYPES).forEach((key) => { PACKET_TYPES_REVERSE[PACKET_TYPES[key]] = key; }); ERROR_PACKET = { type: "error", data: "parser error" }; }) }); //#endregion //#region ../../node_modules/engine.io-parser/build/esm/encodePacket.browser.js function toArray(data) { if (data instanceof Uint8Array) return data; else if (data instanceof ArrayBuffer) return new Uint8Array(data); else return new Uint8Array(data.buffer, data.byteOffset, data.byteLength); } function encodePacketToBinary(packet, callback) { if (withNativeBlob$1 && packet.data instanceof Blob) return packet.data.arrayBuffer().then(toArray).then(callback); else if (withNativeArrayBuffer$2 && (packet.data instanceof ArrayBuffer || isView$1(packet.data))) return callback(toArray(packet.data)); encodePacket(packet, false, (encoded) => { if (!TEXT_ENCODER) TEXT_ENCODER = new TextEncoder(); callback(TEXT_ENCODER.encode(encoded)); }); } var withNativeBlob$1, withNativeArrayBuffer$2, isView$1, encodePacket, encodeBlobAsBase64, TEXT_ENCODER; var init_encodePacket_browser = __esm({ "../../node_modules/engine.io-parser/build/esm/encodePacket.browser.js": (() => { init_commons(); withNativeBlob$1 = typeof Blob === "function" || typeof Blob !== "undefined" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]"; withNativeArrayBuffer$2 = typeof ArrayBuffer === "function"; isView$1 = (obj) => { return typeof ArrayBuffer.isView === "function" ? ArrayBuffer.isView(obj) : obj && obj.buffer instanceof ArrayBuffer; }; encodePacket = ({ type, data }, supportsBinary, callback) => { if (withNativeBlob$1 && data instanceof Blob) if (supportsBinary) return callback(data); else return encodeBlobAsBase64(data, callback); else if (withNativeArrayBuffer$2 && (data instanceof ArrayBuffer || isView$1(data))) if (supportsBinary) return callback(data); else return encodeBlobAsBase64(new Blob([data]), callback); return callback(PACKET_TYPES[type] + (data || "")); }; encodeBlobAsBase64 = (data, callback) => { const fileReader = new FileReader(); fileReader.onload = function() { const content = fileReader.result.split(",")[1]; callback("b" + (content || "")); }; return fileReader.readAsDataURL(data); }; ; }) }); //#endregion //#region ../../node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js var chars, lookup$1, decode$1; var init_base64_arraybuffer = __esm({ "../../node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js": (() => { chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; lookup$1 = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256); for (let i = 0; i < 64; i++) lookup$1[chars.charCodeAt(i)] = i; decode$1 = (base64) => { let bufferLength = base64.length * .75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4; if (base64[base64.length - 1] === "=") { bufferLength--; if (base64[base64.length - 2] === "=") bufferLength--; } const arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer); for (i = 0; i < len; i += 4) { encoded1 = lookup$1[base64.charCodeAt(i)]; encoded2 = lookup$1[base64.charCodeAt(i + 1)]; encoded3 = lookup$1[base64.charCodeAt(i + 2)]; encoded4 = lookup$1[base64.charCodeAt(i + 3)]; bytes[p++] = encoded1 << 2 | encoded2 >> 4; bytes[p++] = (encoded2 & 15) << 4 | encoded3 >> 2; bytes[p++] = (encoded3 & 3) << 6 | encoded4 & 63; } return arraybuffer; }; }) }); //#endregion //#region ../../node_modules/engine.io-parser/build/esm/decodePacket.browser.js var withNativeArrayBuffer$1, decodePacket, decodeBase64Packet, mapBinary; var init_decodePacket_browser = __esm({ "../../node_modules/engine.io-parser/build/esm/decodePacket.browser.js": (() => { init_commons(); init_base64_arraybuffer(); withNativeArrayBuffer$1 = typeof ArrayBuffer === "function"; decodePacket = (encodedPacket, binaryType) => { if (typeof encodedPacket !== "string") return { type: "message", data: mapBinary(encodedPacket, binaryType) }; const type = encodedPacket.charAt(0); if (type === "b") return { type: "message", data: decodeBase64Packet(encodedPacket.substring(1), binaryType) }; if (!PACKET_TYPES_REVERSE[type]) return ERROR_PACKET; return encodedPacket.length > 1 ? { type: PACKET_TYPES_REVERSE[type], data: encodedPacket.substring(1) } : { type: PACKET_TYPES_REVERSE[type] }; }; decodeBase64Packet = (data, binaryType) => { if (withNativeArrayBuffer$1) return mapBinary(decode$1(data), binaryType); else return { base64: true, data }; }; mapBinary = (data, binaryType) => { switch (binaryType) { case "blob": if (data instanceof Blob) return data; else return new Blob([data]); case "arraybuffer": default: if (data instanceof ArrayBuffer) return data; else return data.buffer; } }; }) }); //#endregion //#region ../../node_modules/engine.io-parser/build/esm/index.js function createPacketEncoderStream() { return new TransformStream({ transform(packet, controller) { encodePacketToBinary(packet, (encodedPacket) => { const payloadLength = encodedPacket.length; let header; if (payloadLength < 126) { header = new Uint8Array(1); new DataView(header.buffer).setUint8(0, payloadLength); } else if (payloadLength < 65536) { header = new Uint8Array(3); const view = new DataView(header.buffer); view.setUint8(0, 126); view.setUint16(1, payloadLength); } else { header = new Uint8Array(9); const view = new DataView(header.buffer); view.setUint8(0, 127); view.setBigUint64(1, BigInt(payloadLength)); } if (packet.data && typeof packet.data !== "string") header[0] |= 128; controller.enqueue(header); controller.enqueue(encodedPacket); }); } }); } function totalLength(chunks) { return chunks.reduce((acc, chunk) => acc + chunk.length, 0); } function concatChunks(chunks, size) { if (chunks[0].length === size) return chunks.shift(); const buffer = new Uint8Array(size); let j = 0; for (let i = 0; i < size; i++) { buffer[i] = chunks[0][j++]; if (j === chunks[0].length) { chunks.shift(); j = 0; } } if (chunks.length && j < chunks[0].length) chunks[0] = chunks[0].slice(j); return buffer; } function createPacketDecoderStream(maxPayload, binaryType) { if (!TEXT_DECODER) TEXT_DECODER = new TextDecoder(); const chunks = []; let state = 0; let expectedLength = -1; let isBinary$1 = false; return new TransformStream({ transform(chunk, controller) { chunks.push(chunk); while (true) { if (state === 0) { if (totalLength(chunks) < 1) break; const header = concatChunks(chunks, 1); isBinary$1 = (header[0] & 128) === 128; expectedLength = header[0] & 127; if (expectedLength < 126) state = 3; else if (expectedLength === 126) state = 1; else state = 2; } else if (state === 1) { if (totalLength(chunks) < 2) break; const headerArray = concatChunks(chunks, 2); expectedLength = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length).getUint16(0); state = 3; } else if (state === 2) { if (totalLength(chunks) < 8) break; const headerArray = concatChunks(chunks, 8); const view = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length); const n = view.getUint32(0); if (n > Math.pow(2, 21) - 1) { controller.enqueue(ERROR_PACKET); break; } expectedLength = n * Math.pow(2, 32) + view.getUint32(4); state = 3; } else { if (totalLength(chunks) < expectedLength) break; const data = concatChunks(chunks, expectedLength); controller.enqueue(decodePacket(isBinary$1 ? data : TEXT_DECODER.decode(data), binaryType)); state = 0; } if (expectedLength === 0 || expectedLength > maxPayload) { controller.enqueue(ERROR_PACKET); break; } } } }); } var SEPARATOR, encodePayload, decodePayload, TEXT_DECODER, protocol$2; var init_esm$3 = __esm({ "../../node_modules/engine.io-parser/build/esm/index.js": (() => { init_encodePacket_browser(); init_decodePacket_browser(); init_commons(); SEPARATOR = String.fromCharCode(30); encodePayload = (packets, callback) => { const length = packets.length; const encodedPackets = new Array(length); let count = 0; packets.forEach((packet, i) => { encodePacket(packet, false, (encodedPacket) => { encodedPackets[i] = encodedPacket; if (++count === length) callback(encodedPackets.join(SEPARATOR)); }); }); }; decodePayload = (encodedPayload, binaryType) => { const encodedPackets = encodedPayload.split(SEPARATOR); const packets = []; for (let i = 0; i < encodedPackets.length; i++) { const decodedPacket = decodePacket(encodedPackets[i], binaryType); packets.push(decodedPacket); if (decodedPacket.type === "error") break; } return packets; }; ; protocol$2 = 4; }) }); //#endregion //#region ../../node_modules/@socket.io/component-emitter/index.mjs /** * Initialize a new `Emitter`. * * @api public */ function Emitter(obj) { if (obj) return mixin(obj); } /** * Mixin the emitter properties. * * @param {Object} obj * @return {Object} * @api private */ function mixin(obj) { for (var key in Emitter.prototype) obj[key] = Emitter.prototype[key]; return obj; } var init_component_emitter = __esm({ "../../node_modules/@socket.io/component-emitter/index.mjs": (() => { /** * Listen on the given `event` with `fn`. * * @param {String} event * @param {Function} fn * @return {Emitter} * @api public */ Emitter.prototype.on = Emitter.prototype.addEventListener = function(event, fn) { this._callbacks = this._callbacks || {}; (this._callbacks["$" + event] = this._callbacks["$" + event] || []).push(fn); return this; }; /** * Adds an `event` listener that will be invoked a single * time then automatically removed. * * @param {String} event * @param {Function} fn * @return {Emitter} * @api public */ Emitter.prototype.once = function(event, fn) { function on$1() { this.off(event, on$1); fn.apply(this, arguments); } on$1.fn = fn; this.on(event, on$1); return this; }; /** * Remove the given callback for `event` or all * registered callbacks. * * @param {String} event * @param {Function} fn * @return {Emitter} * @api public */ Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.removeAllListeners = Emitter.prototype.removeEventListener = function(event, fn) { this._callbacks = this._callbacks || {}; if (0 == arguments.length) { this._callbacks = {}; return this; } var callbacks = this._callbacks["$" + event]; if (!callbacks) return this; if (1 == arguments.length) { delete this._callbacks["$" + event]; return this; } var cb; for (var i = 0; i < callbacks.length; i++) { cb = callbacks[i]; if (cb === fn || cb.fn === fn) { callbacks.splice(i, 1); break; } } if (callbacks.length === 0) delete this._callbacks["$" + event]; return this; }; /** * Emit `event` with the given args. * * @param {String} event * @param {Mixed} ... * @return {Emitter} */ Emitter.prototype.emit = function(event) { this._callbacks = this._callbacks || {}; var args = new Array(arguments.length - 1), callbacks = this._callbacks["$" + event]; for (var i = 1; i < arguments.length; i++) args[i - 1] = arguments[i]; if (callbacks) { callbacks = callbacks.slice(0); for (var i = 0, len = callbacks.length; i < len; ++i) callbacks[i].apply(this, args); } return this; }; Emitter.prototype.emitReserved = Emitter.prototype.emit; /** * Return array of callbacks for `event`. * * @param {String} event * @return {Array} * @api public */ Emitter.prototype.listeners = function(event) { this._callbacks = this._callbacks || {}; return this._callbacks["$" + event] || []; }; /** * Check if this emitter has `event` handlers. * * @param {String} event * @return {Boolean} * @api public */ Emitter.prototype.hasListeners = function(event) { return !!this.listeners(event).length; }; }) }); //#endregion //#region ../../node_modules/engine.io-client/build/esm/globals.js function createCookieJar() {} var nextTick, globalThisShim, defaultBinaryType; var init_globals = __esm({ "../../node_modules/engine.io-client/build/esm/globals.js": (() => { nextTick = (() => { if (typeof Promise === "function" && typeof Promise.resolve === "function") return (cb) => Promise.resolve().then(cb); else return (cb, setTimeoutFn) => setTimeoutFn(cb, 0); })(); globalThisShim = (() => { if (typeof self !== "undefined") return self; else if (typeof window !== "undefined") return window; else return Function("return this")(); })(); defaultBinaryType = "arraybuffer"; }) }); //#endregion //#region ../../node_modules/engine.io-client/build/esm/util.js function pick(obj, ...attr) { return attr.reduce((acc, k) => { if (obj.hasOwnProperty(k)) acc[k] = obj[k]; return acc; }, {}); } function installTimerFunctions(obj, opts) { if (opts.useNativeTimers) { obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globalThisShim); obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globalThisShim); } else { obj.setTimeoutFn = globalThisShim.setTimeout.bind(globalThisShim); obj.clearTimeoutFn = globalThisShim.clearTimeout.bind(globalThisShim); } } function byteLength(obj) { if (typeof obj === "string") return utf8Length(obj); return Math.ceil((obj.byteLength || obj.size) * BASE64_OVERHEAD); } function utf8Length(str) { let c = 0, length = 0; for (let i = 0, l = str.length; i < l; i++) { c = str.charCodeAt(i); if (c < 128) length += 1; else if (c < 2048) length += 2; else if (c < 55296 || c >= 57344) length += 3; else { i++; length += 4; } } return length; } /** * Generates a random 8-characters string. */ function randomString() { return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5); } var NATIVE_SET_TIMEOUT, NATIVE_CLEAR_TIMEOUT, BASE64_OVERHEAD; var init_util = __esm({ "../../node_modules/engine.io-client/build/esm/util.js": (() => { init_globals(); NATIVE_SET_TIMEOUT = globalThisShim.setTimeout; NATIVE_CLEAR_TIMEOUT = globalThisShim.clearTimeout; BASE64_OVERHEAD = 1.33; }) }); //#endregion //#region ../../node_modules/engine.io-client/build/esm/contrib/parseqs.js /** * Compiles a querystring * Returns string representation of the object * * @param {Object} * @api private */ function encode(obj) { let str = ""; for (let i in obj) if (obj.hasOwnProperty(i)) { if (str.length) str += "&"; str += encodeURIComponent(i) + "=" + encodeURIComponent(obj[i]); } return str; } /** * Parses a simple querystring into an object * * @param {String} qs * @api private */ function decode(qs) { let qry = {}; let pairs = qs.split("&"); for (let i = 0, l = pairs.length; i < l; i++) { let pair = pairs[i].split("="); qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); } return qry; } var init_parseqs = __esm({ "../../node_modules/engine.io-client/build/esm/contrib/parseqs.js": (() => {}) }); //#endregion //#region ../../node_modules/engine.io-client/build/esm/transport.js var TransportError, Transport; var init_transport = __esm({ "../../node_modules/engine.io-client/build/esm/transport.js": (() => { init_esm$3(); init_component_emitter(); init_util(); init_parseqs(); TransportError = class extends Error { constructor(reason, description, context) { super(reason); this.description = description; this.context = context; this.type = "TransportError"; } }; Transport = class extends Emitter { /** * Transport abstract constructor. * * @param {Object} opts - options * @protected */ constructor(opts) { super(); this.writable = false; installTimerFunctions(this, opts); this.opts = opts; this.query = opts.query; this.socket = opts.socket; this.supportsBinary = !opts.forceBase64; } /** * Emits an error. * * @param {String} reason * @param description * @param context - the error context * @return {Transport} for chaining * @protected */ onError(reason, description, context) { super.emitReserved("error", new TransportError(reason, description, context)); return this; } /** * Opens the transport. */ open() { this.readyState = "opening"; this.doOpen(); return this; } /** * Closes the transport. */ close() { if (this.readyState === "opening" || this.readyState === "open") { this.doClose(); this.onClose(); } return this; } /** * Sends multiple packets. * * @param {Array} packets */ send(packets) { if (this.readyState === "open") this.write(packets); } /** * Called upon open * * @protected */ onOpen() { this.readyState = "open"; this.writable = true; super.emitReserved("open"); } /** * Called with data. * * @param {String} data * @protected */ onData(data) { const packet = decodePacket(data, this.socket.binaryType); this.onPacket(packet); } /** * Called with a decoded packet. * * @protected */ onPacket(packet) { super.emitReserved("packet", packet); } /** * Called upon close. * * @protected */ onClose(details) { this.readyState = "closed"; super.emitReserved("close", details); } /** * Pauses the transport, in order not to lose packets during an upgrade. * * @param onPause */ pause(onPause) {} createUri(schema, query = {}) { return schema + "://" + this._hostname() + this._port() + this.opts.path + this._query(query); } _hostname() { const hostname = this.opts.hostname; return hostname.indexOf(":") === -1 ? hostname : "[" + hostname + "]"; } _port() { if (this.opts.port && (this.opts.secure && Number(this.opts.port !== 443) || !this.opts.secure && Number(this.opts.port) !== 80)) return ":" + this.opts.port; else return ""; } _query(query) { const encodedQuery = encode(query); return encodedQuery.length ? "?" + encodedQuery : ""; } }; }) }); //#endregion //#region ../../node_modules/engine.io-client/build/esm/transports/polling.js var Polling; var init_polling = __esm({ "../../node_modules/engine.io-client/build/esm/transports/polling.js": (() => { init_transport(); init_util(); init_esm$3(); Polling = class extends Transport { constructor() { super(...arguments); this._polling = false; } get name() { return "polling"; } /** * Opens the socket (triggers polling). We write a PING message to determine * when the transport is open. * * @protected */ doOpen() { this._poll(); } /** * Pauses polling. * * @param {Function} onPause - callback upon buffers are flushed and transport is paused * @package */ pause(onPause) { this.readyState = "pausing"; const pause = () => { this.readyState = "paused"; onPause(); }; if (this._polling || !this.writable) { let total = 0; if (this._polling) { total++; this.once("pollComplete", function() { --total || pause(); }); } if (!this.writable) { total++; this.once("drain", function() { --total || pause(); }); } } else pause(); } /** * Starts polling cycle. * * @private */ _poll() { this._polling = true; this.doPoll(); this.emitReserved("poll"); } /** * Overloads onData to detect payloads. * * @protected */ onData(data) { const callback = (packet) => { if ("opening" === this.readyState && packet.type === "open") this.onOpen(); if ("close" === packet.type) { this.onClose({ description: "transport closed by the server" }); return false; } this.onPacket(packet); }; decodePayload(data, this.socket.binaryType).forEach(callback); if ("closed" !== this.readyState) { this._polling = false; this.emitReserved("pollComplete"); if ("open" === this.readyState) this._poll(); } } /** * For polling, send a close packet. * * @protected */ doClose() { const close = () => { this.write([{ type: "close" }]); }; if ("open" === this.readyState) close(); else this.once("open", close); } /** * Writes a packets payload. * * @param {Array} packets - data packets * @protected */ write(packets) { this.writable = false; encodePayload(packets, (data) => { this.doWrite(data, () => { this.writable = true; this.emitReserved("drain"); }); }); } /** * Generates uri for connection. * * @private */ uri() { const schema = this.opts.secure ? "https" : "http"; const query = this.query || {}; if (false !== this.opts.timestampRequests) query[this.opts.timestampParam] = randomString(); if (!this.supportsBinary && !query.sid) query.b64 = 1; return this.createUri(schema, query); } }; }) }); //#endregion //#region ../../node_modules/engine.io-client/build/esm/contrib/has-cors.js var value, hasCORS; var init_has_cors = __esm({ "../../node_modules/engine.io-client/build/esm/contrib/has-cors.js": (() => { value = false; try { value = typeof XMLHttpRequest !== "undefined" && "withCredentials" in new XMLHttpRequest(); } catch (err) {} hasCORS = value; }) }); //#endregion //#region ../../node_modules/engine.io-client/build/esm/transports/polling-xhr.js function empty() {} function unloadHandler() { for (let i in Request.requests) if (Request.requests.hasOwnProperty(i)) Request.requests[i].abort(); } function newRequest(opts) { const xdomain = opts.xdomain; try { if ("undefined" !== typeof XMLHttpRequest && (!xdomain || hasCORS)) return new XMLHttpRequest(); } catch (e) {} if (!xdomain) try { return new globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP"); } catch (e) {} } var BaseXHR, Request, hasXHR2, XHR; var init_polling_xhr = __esm({ "../../node_modules/engine.io-client/build/esm/transports/polling-xhr.js": (() => { init_polling(); init_component_emitter(); init_util(); init_globals(); init_has_cors(); BaseXHR = class extends Polling { /** * XHR Polling constructor. * * @param {Object} opts * @package */ constructor(opts) { super(opts); if (typeof location !== "undefined") { const isSSL = "https:" === location.protocol; let port = location.port; if (!port) port = isSSL ? "443" : "80"; this.xd = typeof location !== "undefined" && opts.hostname !== location.hostname || port !== opts.port; } } /** * Sends data. * * @param {String} data to send. * @param {Function} called upon flush. * @private */ doWrite(data, fn) { const req = this.request({ method: "POST", data }); req.on("success", fn); req.on("error", (xhrStatus, context) => { this.onError("xhr post error", xhrStatus, context); }); } /** * Starts a poll cycle. * * @private */ doPoll() { const req = this.request(); req.on("data", this.onData.bind(this)); req.on("error", (xhrStatus, context) => { this.onError("xhr poll error", xhrStatus, context); }); this.pollXhr = req; } }; Request = class Request extends Emitter { /** * Request constructor * * @param {Object} options * @package */ constructor(createRequest, uri, opts) { super(); this.createRequest = createRequest; installTimerFunctions(this, opts); this._opts = opts; this._method = opts.method || "GET"; this._uri = uri; this._data = void 0 !== opts.data ? opts.data : null; this._create(); } /** * Creates the XHR object and sends the request. * * @private */ _create() { var _a; const opts = pick(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref"); opts.xdomain = !!this._opts.xd; const xhr = this._xhr = this.createRequest(opts); try { xhr.open(this._method, this._uri, true); try { if (this._opts.extraHeaders) { xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true); for (let i in this._opts.extraHeaders) if (this._opts.extraHeaders.hasOwnProperty(i)) xhr.setRequestHeader(i, this._opts.extraHeaders[i]); } } catch (e) {} if ("POST" === this._method) try { xhr.setRequestHeader("Content-type", "text/plain;charset=UTF-8"); } catch (e) {} try { xhr.setRequestHeader("Accept", "*/*"); } catch (e) {} (_a = this._opts.cookieJar) === null || _a === void 0 || _a.addCookies(xhr); if ("withCredentials" in xhr) xhr.withCredentials = this._opts.withCredentials; if (this._opts.requestTimeout) xhr.timeout = this._opts.requestTimeout; xhr.onreadystatechange = () => { var _a$1; if (xhr.readyState === 3) (_a$1 = this._opts.cookieJar) === null || _a$1 === void 0 || _a$1.parseCookies(xhr.getResponseHeader("set-cookie")); if (4 !== xhr.readyState) return; if (200 === xhr.status || 1223 === xhr.status) this._onLoad(); else this.setTimeoutFn(() => { this._onError(typeof xhr.status === "number" ? xhr.status : 0); }, 0); }; xhr.send(this._data); } catch (e) { this.setTimeoutFn(() => { this._onError(e); }, 0); return; } if (typeof document !== "undefined") { this._index = Request.requestsCount++; Request.requests[this._index] = this; } } /** * Called upon error. * * @private */ _onError(err) { this.emitReserved("error", err, this._xhr); this._cleanup(true); } /** * Cleans up house. * * @private */ _cleanup(fromError) { if ("undefined" === typeof this._xhr || null === this._xhr) return; this._xhr.onreadystatechange = empty; if (fromError) try { this._xhr.abort(); } catch (e) {} if (typeof document !== "undefined") delete Request.requests[this._index]; this._xhr = null; } /** * Called upon load. * * @private */ _onLoad() { const data = this._xhr.responseText; if (data !== null) { this.emitReserved("data", data); this.emitReserved("success"); this._cleanup(); } } /** * Aborts the request. * * @package */ abort() { this._cleanup(); } }; Request.requestsCount = 0; Request.requests = {}; /** * Aborts pending requests when unloading the window. This is needed to prevent * memory leaks (e.g. when using IE) and to ensure that no spurious error is * emitted. */ if (typeof document !== "undefined") { if (typeof attachEvent === "function") attachEvent("onunload", unloadHandler); else if (typeof addEventListener === "function") { const terminationEvent = "onpagehide" in globalThisShim ? "pagehide" : "unload"; addEventListener(terminationEvent, unloadHandler, false); } } hasXHR2 = (function() { const xhr = newRequest({ xdomain: false }); return xhr && xhr.responseType !== null; })(); XHR = class extends BaseXHR { constructor(opts) { super(opts); const forceBase64 = opts && opts.forceBase64; this.supportsBinary = hasXHR2 && !forceBase64; } request(opts = {}) { Object.assign(opts, { xd: this.xd }, this.opts); return new Request(newRequest, this.uri(), opts); } }; }) }); //#endregion //#region ../../node_modules/engine.io-client/build/esm/transports/websocket.js var isReactNative, BaseWS, WebSocketCtor, WS; var init_websocket = __esm({ "../../node_modules/engine.io-client/build/esm/transports/websocket.js": (() => { init_transport(); init_util(); init_esm$3(); init_globals(); isReactNative = typeof navigator !== "undefined" && typeof navigator.product === "string" && navigator.product.toLowerCase() === "reactnative"; BaseWS = class extends Transport { get name() { return "websocket"; } doOpen() { const uri = this.uri(); const protocols = this.opts.protocols; const opts = isReactNative ? {} : pick(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity"); if (this.opts.extraHeaders) opts.headers = this.opts.extraHeaders; try { this.ws = this.createSocket(uri, protocols, opts); } catch (err) { return this.emitReserved("error", err); } this.ws.binaryType = this.socket.binaryType; this.addEventListeners(); } /** * Adds event listeners to the socket * * @private */ addEventListeners() { this.ws.onopen = () => { if (this.opts.autoUnref) this.ws._socket.unref(); this.onOpen(); }; this.ws.onclose = (closeEvent) => this.onClose({ description: "websocket connection closed", context: closeEvent }); this.ws.onmessage = (ev) => this.onData(ev.data); this.ws.onerror = (e) => this.onError("websocket error", e); } write(packets) { this.writable = false; for (let i = 0; i < packets.length; i++) { const packet = packets[i]; const lastPacket = i === packets.length - 1; encodePacket(packet, this.supportsBinary, (data) => { try { this.doWrite(packet, data); } catch (e) {} if (lastPacket) nextTick(() => { this.writable = true; this.emitReserved("drain"); }, this.setTimeoutFn); }); } } doClose() { if (typeof this.ws !== "undefined") { this.ws.onerror = () => {}; this.ws.close(); this.ws = null; } } /** * Generates uri for connection. * * @private */ uri() { const schema = this.opts.secure ? "wss" : "ws"; const query = this.query || {}; if (this.opts.timestampRequests) query[this.opts.timestampParam] = randomString(); if (!this.supportsBinary) query.b64 = 1; return this.createUri(schema, query); } }; WebSocketCtor = globalThisShim.WebSocket || globalThisShim.MozWebSocket; WS = class extends BaseWS { createSocket(uri, protocols, opts) { return !isReactNative ? protocols ? new WebSocketCtor(uri, protocols) : new WebSocketCtor(uri) : new WebSocketCtor(uri, protocols, opts); } doWrite(_packet, data) { this.ws.send(data); } }; }) }); //#endregion //#region ../../node_modules/engine.io-client/build/esm/transports/webtransport.js var WT; var init_webtransport = __esm({ "../../node_modules/engine.io-client/build/esm/transports/webtransport.js": (() => { init_transport(); init_globals(); init_esm$3(); WT = class extends Transport { get name() { return "webtransport"; } doOpen() { try { this._transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]); } catch (err) { return this.emitReserved("error", err); } this._transport.closed.then(() => { this.onClose(); }).catch((err) => { this.onError("webtransport error", err); }); this._transport.ready.then(() => { this._transport.createBidirectionalStream().then((stream) => { const decoderStream = createPacketDecoderStream(Number.MAX_SAFE_INTEGER, this.socket.binaryType); const reader = stream.readable.pipeThrough(decoderStream).getReader(); const encoderStream = createPacketEncoderStream(); encoderStream.readable.pipeTo(stream.writable); this._writer = encoderStream.writable.getWriter(); const read = () => { reader.read().then(({ done, value: value$1 }) => { if (done) return; this.onPacket(value$1); read(); }).catch((err) => {}); }; read(); const packet = { type: "open" }; if (this.query.sid) packet.data = `{"sid":"${this.query.sid}"}`; this._writer.write(packet).then(() => this.onOpen()); }); }); } write(packets) { this.writable = false; for (let i = 0; i < packets.length; i++) { const packet = packets[i]; const lastPacket = i === packets.length - 1; this._writer.write(packet).then(() => { if (lastPacket) nextTick(() => { this.writable = true; this.emitReserved("drain"); }, this.setTimeoutFn); }); } } doClose() { var _a; (_a = this._transport) === null || _a === void 0 || _a.close(); } }; }) }); //#endregion //#region ../../node_modules/engine.io-client/build/esm/transports/index.js var transports; var init_transports = __esm({ "../../node_modules/engine.io-client/build/esm/transports/index.js": (() => { init_polling_xhr(); init_websocket(); init_webtransport(); transports = { websocket: WS, webtransport: WT, polling: XHR }; }) }); //#endregion //#region ../../node_modules/engine.io-client/build/esm/contrib/parseuri.js function parse(str) { if (str.length > 8e3) throw "URI too long"; const src = str, b = str.indexOf("["), e = str.indexOf("]"); if (b != -1 && e != -1) str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ";") + str.substring(e, str.length); let m = re.exec(str || ""), uri = {}, i = 14; while (i--) uri[parts[i]] = m[i] || ""; if (b != -1 && e != -1) { uri.source = src; uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ":"); uri.authority = uri.authority.replace("[", "").replace("]", "").replace(/;/g, ":"); uri.ipv6uri = true; } uri.pathNames = pathNames(uri, uri["path"]); uri.queryKey = queryKey(uri, uri["query"]); return uri; } function pathNames(obj, path) { const names = path.replace(/\/{2,9}/g, "/").split("/"); if (path.slice(0, 1) == "/" || path.length === 0) names.splice(0, 1); if (path.slice(-1) == "/") names.splice(names.length - 1, 1); return names; } function queryKey(uri, query) { const data = {}; query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function($0, $1, $2) { if ($1) data[$1] = $2; }); return data; } var re, parts; var init_parseuri = __esm({ "../../node_modules/engine.io-client/build/esm/contrib/parseuri.js": (() => { re = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/; parts = [ "source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor" ]; }) }); //#endregion //#region ../../node_modules/engine.io-client/build/esm/socket.js var withEventListeners, OFFLINE_EVENT_LISTENERS, SocketWithoutUpgrade, SocketWithUpgrade, Socket$1; var init_socket$1 = __esm({ "../../node_modules/engine.io-client/build/esm/socket.js": (() => { init_transports(); init_util(); init_parseqs(); init_parseuri(); init_component_emitter(); init_esm$3(); init_globals(); withEventListeners = typeof addEventListener === "function" && typeof removeEventListener === "function"; OFFLINE_EVENT_LISTENERS = []; if (withEventListeners) addEventListener("offline", () => { OFFLINE_EVENT_LISTENERS.forEach((listener) => listener()); }, false); SocketWithoutUpgrade = class SocketWithoutUpgrade extends Emitter { /** * Socket constructor. * * @param {String|Object} uri - uri or options * @param {Object} opts - options */ constructor(uri, opts) { super(); this.binaryType = defaultBinaryType; this.writeBuffer = []; this._prevBufferLen = 0; this._pingInterval = -1; this._pingTimeout = -1; this._maxPayload = -1; /** * The expiration timestamp of the {@link _pingTimeoutTimer} object is tracked, in case the timer is throttled and the * callback is not fired on time. This can happen for example when a laptop is suspended or when a phone is locked. */ this._pingTimeoutTime = Infinity; if (uri && "object" === typeof uri) { opts = uri; uri = null; } if (uri) { const parsedUri = parse(uri); opts.hostname = parsedUri.host; opts.secure = parsedUri.protocol === "https" || parsedUri.protocol === "wss"; opts.port = parsedUri.port; if (parsedUri.query) opts.query = parsedUri.query; } else if (opts.host) opts.hostname = parse(opts.host).host; installTimerFunctions(this, opts); this.secure = null != opts.secure ? opts.secure : typeof location !== "undefined" && "https:" === location.protocol; if (opts.hostname && !opts.port) opts.port = this.secure ? "443" : "80"; this.hostname = opts.hostname || (typeof location !== "undefined" ? location.hostname : "localhost"); this.port = opts.port || (typeof location !== "undefined" && location.port ? location.port : this.secure ? "443" : "80"); this.transports = []; this._transportsByName = {}; opts.transports.forEach((t) => { const transportName = t.prototype.name; this.transports.push(transportName); this._transportsByName[transportName] = t; }); this.opts = Object.assign({ path: "/engine.io", agent: false, withCredentials: false, upgrade: true, timestampParam: "t", rememberUpgrade: false, addTrailingSlash: true, rejectUnauthorized: true, perMessageDeflate: { threshold: 1024 }, transportOptions: {}, closeOnBeforeunload: false }, opts); this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""); if (typeof this.opts.query === "string") this.opts.query = decode(this.opts.query); if (withEventListeners) { if (this.opts.closeOnBeforeunload) { this._beforeunloadEventListener = () => { if (this.transport) { this.transport.removeAllListeners(); this.transport.close(); } }; addEventListener("beforeunload", this._beforeunloadEventListener, false); } if (this.hostname !== "localhost") { this._offlineEventListener = () => { this._onClose("transport close", { description: "network connection lost" }); }; OFFLINE_EVENT_LISTENERS.push(this._offlineEventListener); } } if (this.opts.withCredentials) this._cookieJar = /* @__PURE__ */ createCookieJar(); this._open(); } /** * Creates transport of the given type. * * @param {String} name - transport name * @return {Transport} * @private */ createTransport(name) { const query = Object.assign({}, this.opts.query); query.EIO = protocol$2; query.transport = name; if (this.id) query.sid = this.id; const opts = Object.assign({}, this.opts, { query, socket: this, hostname: this.hostname, secure: this.secure, port: this.port }, this.opts.transportOptions[name]); return new this._transportsByName[name](opts); } /** * Initializes transport to use and starts probe. * * @private */ _open() { if (this.transports.length === 0) { this.setTimeoutFn(() => { this.emitReserved("error", "No transports available"); }, 0); return; } const transportName = this.opts.rememberUpgrade && SocketWithoutUpgrade.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0]; this.readyState = "opening"; const transport = this.createTransport(transportName); transport.open(); this.setTransport(transport); } /** * Sets the current transport. Disables the existing one (if any). * * @private */ setTransport(transport) { if (this.transport) this.transport.removeAllListeners(); this.transport = transport; 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)); } /** * Called when connection is deemed open. * * @private */ onOpen() { this.readyState = "open"; SocketWithoutUpgrade.priorWebsocketSuccess = "websocket" === this.transport.name; this.emitReserved("open"); this.flush(); } /** * Handles a packet. * * @private */ _onPacket(packet) { if ("opening" === this.readyState || "open" === this.readyState || "closing" === this.readyState) { this.emitReserved("packet", packet); this.emitReserved("heartbeat"); switch (packet.type) { case "open": this.onHandshake(JSON.parse(packet.data)); break; case "ping": this._sendPacket("pong"); this.emitReserved("ping"); this.emitReserved("pong"); this._resetPingTimeout(); break; case "error": const err = /* @__PURE__ */ new Error("server error"); err.code = packet.data; this._onError(err); break; case "message": this.emitReserved("data", packet.data); this.emitReserved("message", packet.data); break; } } } /** * Called upon handshake completion. * * @param {Object} data - handshake obj * @private */ onHandshake(data) { this.emitReserved("handshake", data); this.id = data.sid; this.transport.query.sid = data.sid; this._pingInterval = data.pingInterval; this._pingTimeout = data.pingTimeout; this._maxPayload = data.maxPayload; this.onOpen(); if ("closed" === this.readyState) return; this._resetPingTimeout(); } /** * Sets and resets ping timeout timer based on server pings. * * @private */ _resetPingTimeout() { this.clearTimeoutFn(this._pingTimeoutTimer); const delay = this._pingInterval + this._pingTimeout; this._pingTimeoutTime = Date.now() + delay; this._pingTimeoutTimer = this.setTimeoutFn(() => { this._onClose("ping timeout"); }, delay); if (this.opts.autoUnref) this._pingTimeoutTimer.unref(); } /** * Called