uniapp,h5

socket__io-client.js 90KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376
  1. var __defProp = Object.defineProperty;
  2. var __export = (target, all) => {
  3. for (var name in all)
  4. __defProp(target, name, { get: all[name], enumerable: true });
  5. };
  6. // ../../../../Newweb/starter/node_modules/engine.io-parser/build/esm/commons.js
  7. var PACKET_TYPES = /* @__PURE__ */ Object.create(null);
  8. PACKET_TYPES["open"] = "0";
  9. PACKET_TYPES["close"] = "1";
  10. PACKET_TYPES["ping"] = "2";
  11. PACKET_TYPES["pong"] = "3";
  12. PACKET_TYPES["message"] = "4";
  13. PACKET_TYPES["upgrade"] = "5";
  14. PACKET_TYPES["noop"] = "6";
  15. var PACKET_TYPES_REVERSE = /* @__PURE__ */ Object.create(null);
  16. Object.keys(PACKET_TYPES).forEach((key) => {
  17. PACKET_TYPES_REVERSE[PACKET_TYPES[key]] = key;
  18. });
  19. var ERROR_PACKET = { type: "error", data: "parser error" };
  20. // ../../../../Newweb/starter/node_modules/engine.io-parser/build/esm/encodePacket.browser.js
  21. var withNativeBlob = typeof Blob === "function" || typeof Blob !== "undefined" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]";
  22. var withNativeArrayBuffer = typeof ArrayBuffer === "function";
  23. var isView = (obj) => {
  24. return typeof ArrayBuffer.isView === "function" ? ArrayBuffer.isView(obj) : obj && obj.buffer instanceof ArrayBuffer;
  25. };
  26. var encodePacket = ({ type, data }, supportsBinary, callback) => {
  27. if (withNativeBlob && data instanceof Blob) {
  28. if (supportsBinary) {
  29. return callback(data);
  30. } else {
  31. return encodeBlobAsBase64(data, callback);
  32. }
  33. } else if (withNativeArrayBuffer && (data instanceof ArrayBuffer || isView(data))) {
  34. if (supportsBinary) {
  35. return callback(data);
  36. } else {
  37. return encodeBlobAsBase64(new Blob([data]), callback);
  38. }
  39. }
  40. return callback(PACKET_TYPES[type] + (data || ""));
  41. };
  42. var encodeBlobAsBase64 = (data, callback) => {
  43. const fileReader = new FileReader();
  44. fileReader.onload = function() {
  45. const content = fileReader.result.split(",")[1];
  46. callback("b" + (content || ""));
  47. };
  48. return fileReader.readAsDataURL(data);
  49. };
  50. function toArray(data) {
  51. if (data instanceof Uint8Array) {
  52. return data;
  53. } else if (data instanceof ArrayBuffer) {
  54. return new Uint8Array(data);
  55. } else {
  56. return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
  57. }
  58. }
  59. var TEXT_ENCODER;
  60. function encodePacketToBinary(packet, callback) {
  61. if (withNativeBlob && packet.data instanceof Blob) {
  62. return packet.data.arrayBuffer().then(toArray).then(callback);
  63. } else if (withNativeArrayBuffer && (packet.data instanceof ArrayBuffer || isView(packet.data))) {
  64. return callback(toArray(packet.data));
  65. }
  66. encodePacket(packet, false, (encoded) => {
  67. if (!TEXT_ENCODER) {
  68. TEXT_ENCODER = new TextEncoder();
  69. }
  70. callback(TEXT_ENCODER.encode(encoded));
  71. });
  72. }
  73. // ../../../../Newweb/starter/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js
  74. var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  75. var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
  76. for (let i = 0; i < chars.length; i++) {
  77. lookup[chars.charCodeAt(i)] = i;
  78. }
  79. var decode = (base64) => {
  80. let bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;
  81. if (base64[base64.length - 1] === "=") {
  82. bufferLength--;
  83. if (base64[base64.length - 2] === "=") {
  84. bufferLength--;
  85. }
  86. }
  87. const arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);
  88. for (i = 0; i < len; i += 4) {
  89. encoded1 = lookup[base64.charCodeAt(i)];
  90. encoded2 = lookup[base64.charCodeAt(i + 1)];
  91. encoded3 = lookup[base64.charCodeAt(i + 2)];
  92. encoded4 = lookup[base64.charCodeAt(i + 3)];
  93. bytes[p++] = encoded1 << 2 | encoded2 >> 4;
  94. bytes[p++] = (encoded2 & 15) << 4 | encoded3 >> 2;
  95. bytes[p++] = (encoded3 & 3) << 6 | encoded4 & 63;
  96. }
  97. return arraybuffer;
  98. };
  99. // ../../../../Newweb/starter/node_modules/engine.io-parser/build/esm/decodePacket.browser.js
  100. var withNativeArrayBuffer2 = typeof ArrayBuffer === "function";
  101. var decodePacket = (encodedPacket, binaryType) => {
  102. if (typeof encodedPacket !== "string") {
  103. return {
  104. type: "message",
  105. data: mapBinary(encodedPacket, binaryType)
  106. };
  107. }
  108. const type = encodedPacket.charAt(0);
  109. if (type === "b") {
  110. return {
  111. type: "message",
  112. data: decodeBase64Packet(encodedPacket.substring(1), binaryType)
  113. };
  114. }
  115. const packetType = PACKET_TYPES_REVERSE[type];
  116. if (!packetType) {
  117. return ERROR_PACKET;
  118. }
  119. return encodedPacket.length > 1 ? {
  120. type: PACKET_TYPES_REVERSE[type],
  121. data: encodedPacket.substring(1)
  122. } : {
  123. type: PACKET_TYPES_REVERSE[type]
  124. };
  125. };
  126. var decodeBase64Packet = (data, binaryType) => {
  127. if (withNativeArrayBuffer2) {
  128. const decoded = decode(data);
  129. return mapBinary(decoded, binaryType);
  130. } else {
  131. return { base64: true, data };
  132. }
  133. };
  134. var mapBinary = (data, binaryType) => {
  135. switch (binaryType) {
  136. case "blob":
  137. if (data instanceof Blob) {
  138. return data;
  139. } else {
  140. return new Blob([data]);
  141. }
  142. case "arraybuffer":
  143. default:
  144. if (data instanceof ArrayBuffer) {
  145. return data;
  146. } else {
  147. return data.buffer;
  148. }
  149. }
  150. };
  151. // ../../../../Newweb/starter/node_modules/engine.io-parser/build/esm/index.js
  152. var SEPARATOR = String.fromCharCode(30);
  153. var encodePayload = (packets, callback) => {
  154. const length = packets.length;
  155. const encodedPackets = new Array(length);
  156. let count = 0;
  157. packets.forEach((packet, i) => {
  158. encodePacket(packet, false, (encodedPacket) => {
  159. encodedPackets[i] = encodedPacket;
  160. if (++count === length) {
  161. callback(encodedPackets.join(SEPARATOR));
  162. }
  163. });
  164. });
  165. };
  166. var decodePayload = (encodedPayload, binaryType) => {
  167. const encodedPackets = encodedPayload.split(SEPARATOR);
  168. const packets = [];
  169. for (let i = 0; i < encodedPackets.length; i++) {
  170. const decodedPacket = decodePacket(encodedPackets[i], binaryType);
  171. packets.push(decodedPacket);
  172. if (decodedPacket.type === "error") {
  173. break;
  174. }
  175. }
  176. return packets;
  177. };
  178. function createPacketEncoderStream() {
  179. return new TransformStream({
  180. transform(packet, controller) {
  181. encodePacketToBinary(packet, (encodedPacket) => {
  182. const payloadLength = encodedPacket.length;
  183. let header;
  184. if (payloadLength < 126) {
  185. header = new Uint8Array(1);
  186. new DataView(header.buffer).setUint8(0, payloadLength);
  187. } else if (payloadLength < 65536) {
  188. header = new Uint8Array(3);
  189. const view = new DataView(header.buffer);
  190. view.setUint8(0, 126);
  191. view.setUint16(1, payloadLength);
  192. } else {
  193. header = new Uint8Array(9);
  194. const view = new DataView(header.buffer);
  195. view.setUint8(0, 127);
  196. view.setBigUint64(1, BigInt(payloadLength));
  197. }
  198. if (packet.data && typeof packet.data !== "string") {
  199. header[0] |= 128;
  200. }
  201. controller.enqueue(header);
  202. controller.enqueue(encodedPacket);
  203. });
  204. }
  205. });
  206. }
  207. var TEXT_DECODER;
  208. function totalLength(chunks) {
  209. return chunks.reduce((acc, chunk) => acc + chunk.length, 0);
  210. }
  211. function concatChunks(chunks, size) {
  212. if (chunks[0].length === size) {
  213. return chunks.shift();
  214. }
  215. const buffer = new Uint8Array(size);
  216. let j = 0;
  217. for (let i = 0; i < size; i++) {
  218. buffer[i] = chunks[0][j++];
  219. if (j === chunks[0].length) {
  220. chunks.shift();
  221. j = 0;
  222. }
  223. }
  224. if (chunks.length && j < chunks[0].length) {
  225. chunks[0] = chunks[0].slice(j);
  226. }
  227. return buffer;
  228. }
  229. function createPacketDecoderStream(maxPayload, binaryType) {
  230. if (!TEXT_DECODER) {
  231. TEXT_DECODER = new TextDecoder();
  232. }
  233. const chunks = [];
  234. let state = 0;
  235. let expectedLength = -1;
  236. let isBinary2 = false;
  237. return new TransformStream({
  238. transform(chunk, controller) {
  239. chunks.push(chunk);
  240. while (true) {
  241. if (state === 0) {
  242. if (totalLength(chunks) < 1) {
  243. break;
  244. }
  245. const header = concatChunks(chunks, 1);
  246. isBinary2 = (header[0] & 128) === 128;
  247. expectedLength = header[0] & 127;
  248. if (expectedLength < 126) {
  249. state = 3;
  250. } else if (expectedLength === 126) {
  251. state = 1;
  252. } else {
  253. state = 2;
  254. }
  255. } else if (state === 1) {
  256. if (totalLength(chunks) < 2) {
  257. break;
  258. }
  259. const headerArray = concatChunks(chunks, 2);
  260. expectedLength = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length).getUint16(0);
  261. state = 3;
  262. } else if (state === 2) {
  263. if (totalLength(chunks) < 8) {
  264. break;
  265. }
  266. const headerArray = concatChunks(chunks, 8);
  267. const view = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length);
  268. const n = view.getUint32(0);
  269. if (n > Math.pow(2, 53 - 32) - 1) {
  270. controller.enqueue(ERROR_PACKET);
  271. break;
  272. }
  273. expectedLength = n * Math.pow(2, 32) + view.getUint32(4);
  274. state = 3;
  275. } else {
  276. if (totalLength(chunks) < expectedLength) {
  277. break;
  278. }
  279. const data = concatChunks(chunks, expectedLength);
  280. controller.enqueue(decodePacket(isBinary2 ? data : TEXT_DECODER.decode(data), binaryType));
  281. state = 0;
  282. }
  283. if (expectedLength === 0 || expectedLength > maxPayload) {
  284. controller.enqueue(ERROR_PACKET);
  285. break;
  286. }
  287. }
  288. }
  289. });
  290. }
  291. var protocol = 4;
  292. // ../../../../Newweb/starter/node_modules/@socket.io/component-emitter/lib/esm/index.js
  293. function Emitter(obj) {
  294. if (obj)
  295. return mixin(obj);
  296. }
  297. function mixin(obj) {
  298. for (var key in Emitter.prototype) {
  299. obj[key] = Emitter.prototype[key];
  300. }
  301. return obj;
  302. }
  303. Emitter.prototype.on = Emitter.prototype.addEventListener = function(event, fn) {
  304. this._callbacks = this._callbacks || {};
  305. (this._callbacks["$" + event] = this._callbacks["$" + event] || []).push(fn);
  306. return this;
  307. };
  308. Emitter.prototype.once = function(event, fn) {
  309. function on2() {
  310. this.off(event, on2);
  311. fn.apply(this, arguments);
  312. }
  313. on2.fn = fn;
  314. this.on(event, on2);
  315. return this;
  316. };
  317. Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.removeAllListeners = Emitter.prototype.removeEventListener = function(event, fn) {
  318. this._callbacks = this._callbacks || {};
  319. if (0 == arguments.length) {
  320. this._callbacks = {};
  321. return this;
  322. }
  323. var callbacks = this._callbacks["$" + event];
  324. if (!callbacks)
  325. return this;
  326. if (1 == arguments.length) {
  327. delete this._callbacks["$" + event];
  328. return this;
  329. }
  330. var cb;
  331. for (var i = 0; i < callbacks.length; i++) {
  332. cb = callbacks[i];
  333. if (cb === fn || cb.fn === fn) {
  334. callbacks.splice(i, 1);
  335. break;
  336. }
  337. }
  338. if (callbacks.length === 0) {
  339. delete this._callbacks["$" + event];
  340. }
  341. return this;
  342. };
  343. Emitter.prototype.emit = function(event) {
  344. this._callbacks = this._callbacks || {};
  345. var args = new Array(arguments.length - 1), callbacks = this._callbacks["$" + event];
  346. for (var i = 1; i < arguments.length; i++) {
  347. args[i - 1] = arguments[i];
  348. }
  349. if (callbacks) {
  350. callbacks = callbacks.slice(0);
  351. for (var i = 0, len = callbacks.length; i < len; ++i) {
  352. callbacks[i].apply(this, args);
  353. }
  354. }
  355. return this;
  356. };
  357. Emitter.prototype.emitReserved = Emitter.prototype.emit;
  358. Emitter.prototype.listeners = function(event) {
  359. this._callbacks = this._callbacks || {};
  360. return this._callbacks["$" + event] || [];
  361. };
  362. Emitter.prototype.hasListeners = function(event) {
  363. return !!this.listeners(event).length;
  364. };
  365. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/globals.js
  366. var nextTick = (() => {
  367. const isPromiseAvailable = typeof Promise === "function" && typeof Promise.resolve === "function";
  368. if (isPromiseAvailable) {
  369. return (cb) => Promise.resolve().then(cb);
  370. } else {
  371. return (cb, setTimeoutFn) => setTimeoutFn(cb, 0);
  372. }
  373. })();
  374. var globalThisShim = (() => {
  375. if (typeof self !== "undefined") {
  376. return self;
  377. } else if (typeof window !== "undefined") {
  378. return window;
  379. } else {
  380. return Function("return this")();
  381. }
  382. })();
  383. var defaultBinaryType = "arraybuffer";
  384. function createCookieJar() {
  385. }
  386. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/util.js
  387. function pick(obj, ...attr) {
  388. return attr.reduce((acc, k) => {
  389. if (obj.hasOwnProperty(k)) {
  390. acc[k] = obj[k];
  391. }
  392. return acc;
  393. }, {});
  394. }
  395. var NATIVE_SET_TIMEOUT = globalThisShim.setTimeout;
  396. var NATIVE_CLEAR_TIMEOUT = globalThisShim.clearTimeout;
  397. function installTimerFunctions(obj, opts) {
  398. if (opts.useNativeTimers) {
  399. obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globalThisShim);
  400. obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globalThisShim);
  401. } else {
  402. obj.setTimeoutFn = globalThisShim.setTimeout.bind(globalThisShim);
  403. obj.clearTimeoutFn = globalThisShim.clearTimeout.bind(globalThisShim);
  404. }
  405. }
  406. var BASE64_OVERHEAD = 1.33;
  407. function byteLength(obj) {
  408. if (typeof obj === "string") {
  409. return utf8Length(obj);
  410. }
  411. return Math.ceil((obj.byteLength || obj.size) * BASE64_OVERHEAD);
  412. }
  413. function utf8Length(str) {
  414. let c = 0, length = 0;
  415. for (let i = 0, l = str.length; i < l; i++) {
  416. c = str.charCodeAt(i);
  417. if (c < 128) {
  418. length += 1;
  419. } else if (c < 2048) {
  420. length += 2;
  421. } else if (c < 55296 || c >= 57344) {
  422. length += 3;
  423. } else {
  424. i++;
  425. length += 4;
  426. }
  427. }
  428. return length;
  429. }
  430. function randomString() {
  431. return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
  432. }
  433. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/contrib/parseqs.js
  434. function encode(obj) {
  435. let str = "";
  436. for (let i in obj) {
  437. if (obj.hasOwnProperty(i)) {
  438. if (str.length)
  439. str += "&";
  440. str += encodeURIComponent(i) + "=" + encodeURIComponent(obj[i]);
  441. }
  442. }
  443. return str;
  444. }
  445. function decode2(qs) {
  446. let qry = {};
  447. let pairs = qs.split("&");
  448. for (let i = 0, l = pairs.length; i < l; i++) {
  449. let pair = pairs[i].split("=");
  450. qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
  451. }
  452. return qry;
  453. }
  454. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/transport.js
  455. var TransportError = class extends Error {
  456. constructor(reason, description, context) {
  457. super(reason);
  458. this.description = description;
  459. this.context = context;
  460. this.type = "TransportError";
  461. }
  462. };
  463. var Transport = class extends Emitter {
  464. /**
  465. * Transport abstract constructor.
  466. *
  467. * @param {Object} opts - options
  468. * @protected
  469. */
  470. constructor(opts) {
  471. super();
  472. this.writable = false;
  473. installTimerFunctions(this, opts);
  474. this.opts = opts;
  475. this.query = opts.query;
  476. this.socket = opts.socket;
  477. this.supportsBinary = !opts.forceBase64;
  478. }
  479. /**
  480. * Emits an error.
  481. *
  482. * @param {String} reason
  483. * @param description
  484. * @param context - the error context
  485. * @return {Transport} for chaining
  486. * @protected
  487. */
  488. onError(reason, description, context) {
  489. super.emitReserved("error", new TransportError(reason, description, context));
  490. return this;
  491. }
  492. /**
  493. * Opens the transport.
  494. */
  495. open() {
  496. this.readyState = "opening";
  497. this.doOpen();
  498. return this;
  499. }
  500. /**
  501. * Closes the transport.
  502. */
  503. close() {
  504. if (this.readyState === "opening" || this.readyState === "open") {
  505. this.doClose();
  506. this.onClose();
  507. }
  508. return this;
  509. }
  510. /**
  511. * Sends multiple packets.
  512. *
  513. * @param {Array} packets
  514. */
  515. send(packets) {
  516. if (this.readyState === "open") {
  517. this.write(packets);
  518. } else {
  519. }
  520. }
  521. /**
  522. * Called upon open
  523. *
  524. * @protected
  525. */
  526. onOpen() {
  527. this.readyState = "open";
  528. this.writable = true;
  529. super.emitReserved("open");
  530. }
  531. /**
  532. * Called with data.
  533. *
  534. * @param {String} data
  535. * @protected
  536. */
  537. onData(data) {
  538. const packet = decodePacket(data, this.socket.binaryType);
  539. this.onPacket(packet);
  540. }
  541. /**
  542. * Called with a decoded packet.
  543. *
  544. * @protected
  545. */
  546. onPacket(packet) {
  547. super.emitReserved("packet", packet);
  548. }
  549. /**
  550. * Called upon close.
  551. *
  552. * @protected
  553. */
  554. onClose(details) {
  555. this.readyState = "closed";
  556. super.emitReserved("close", details);
  557. }
  558. /**
  559. * Pauses the transport, in order not to lose packets during an upgrade.
  560. *
  561. * @param onPause
  562. */
  563. pause(onPause) {
  564. }
  565. createUri(schema, query = {}) {
  566. return schema + "://" + this._hostname() + this._port() + this.opts.path + this._query(query);
  567. }
  568. _hostname() {
  569. const hostname = this.opts.hostname;
  570. return hostname.indexOf(":") === -1 ? hostname : "[" + hostname + "]";
  571. }
  572. _port() {
  573. if (this.opts.port && (this.opts.secure && Number(this.opts.port !== 443) || !this.opts.secure && Number(this.opts.port) !== 80)) {
  574. return ":" + this.opts.port;
  575. } else {
  576. return "";
  577. }
  578. }
  579. _query(query) {
  580. const encodedQuery = encode(query);
  581. return encodedQuery.length ? "?" + encodedQuery : "";
  582. }
  583. };
  584. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/transports/polling.js
  585. var Polling = class extends Transport {
  586. constructor() {
  587. super(...arguments);
  588. this._polling = false;
  589. }
  590. get name() {
  591. return "polling";
  592. }
  593. /**
  594. * Opens the socket (triggers polling). We write a PING message to determine
  595. * when the transport is open.
  596. *
  597. * @protected
  598. */
  599. doOpen() {
  600. this._poll();
  601. }
  602. /**
  603. * Pauses polling.
  604. *
  605. * @param {Function} onPause - callback upon buffers are flushed and transport is paused
  606. * @package
  607. */
  608. pause(onPause) {
  609. this.readyState = "pausing";
  610. const pause = () => {
  611. this.readyState = "paused";
  612. onPause();
  613. };
  614. if (this._polling || !this.writable) {
  615. let total = 0;
  616. if (this._polling) {
  617. total++;
  618. this.once("pollComplete", function() {
  619. --total || pause();
  620. });
  621. }
  622. if (!this.writable) {
  623. total++;
  624. this.once("drain", function() {
  625. --total || pause();
  626. });
  627. }
  628. } else {
  629. pause();
  630. }
  631. }
  632. /**
  633. * Starts polling cycle.
  634. *
  635. * @private
  636. */
  637. _poll() {
  638. this._polling = true;
  639. this.doPoll();
  640. this.emitReserved("poll");
  641. }
  642. /**
  643. * Overloads onData to detect payloads.
  644. *
  645. * @protected
  646. */
  647. onData(data) {
  648. const callback = (packet) => {
  649. if ("opening" === this.readyState && packet.type === "open") {
  650. this.onOpen();
  651. }
  652. if ("close" === packet.type) {
  653. this.onClose({ description: "transport closed by the server" });
  654. return false;
  655. }
  656. this.onPacket(packet);
  657. };
  658. decodePayload(data, this.socket.binaryType).forEach(callback);
  659. if ("closed" !== this.readyState) {
  660. this._polling = false;
  661. this.emitReserved("pollComplete");
  662. if ("open" === this.readyState) {
  663. this._poll();
  664. } else {
  665. }
  666. }
  667. }
  668. /**
  669. * For polling, send a close packet.
  670. *
  671. * @protected
  672. */
  673. doClose() {
  674. const close = () => {
  675. this.write([{ type: "close" }]);
  676. };
  677. if ("open" === this.readyState) {
  678. close();
  679. } else {
  680. this.once("open", close);
  681. }
  682. }
  683. /**
  684. * Writes a packets payload.
  685. *
  686. * @param {Array} packets - data packets
  687. * @protected
  688. */
  689. write(packets) {
  690. this.writable = false;
  691. encodePayload(packets, (data) => {
  692. this.doWrite(data, () => {
  693. this.writable = true;
  694. this.emitReserved("drain");
  695. });
  696. });
  697. }
  698. /**
  699. * Generates uri for connection.
  700. *
  701. * @private
  702. */
  703. uri() {
  704. const schema = this.opts.secure ? "https" : "http";
  705. const query = this.query || {};
  706. if (false !== this.opts.timestampRequests) {
  707. query[this.opts.timestampParam] = randomString();
  708. }
  709. if (!this.supportsBinary && !query.sid) {
  710. query.b64 = 1;
  711. }
  712. return this.createUri(schema, query);
  713. }
  714. };
  715. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/contrib/has-cors.js
  716. var value = false;
  717. try {
  718. value = typeof XMLHttpRequest !== "undefined" && "withCredentials" in new XMLHttpRequest();
  719. } catch (err) {
  720. }
  721. var hasCORS = value;
  722. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/transports/polling-xhr.js
  723. function empty() {
  724. }
  725. var BaseXHR = class extends Polling {
  726. /**
  727. * XHR Polling constructor.
  728. *
  729. * @param {Object} opts
  730. * @package
  731. */
  732. constructor(opts) {
  733. super(opts);
  734. if (typeof location !== "undefined") {
  735. const isSSL = "https:" === location.protocol;
  736. let port = location.port;
  737. if (!port) {
  738. port = isSSL ? "443" : "80";
  739. }
  740. this.xd = typeof location !== "undefined" && opts.hostname !== location.hostname || port !== opts.port;
  741. }
  742. }
  743. /**
  744. * Sends data.
  745. *
  746. * @param {String} data to send.
  747. * @param {Function} called upon flush.
  748. * @private
  749. */
  750. doWrite(data, fn) {
  751. const req = this.request({
  752. method: "POST",
  753. data
  754. });
  755. req.on("success", fn);
  756. req.on("error", (xhrStatus, context) => {
  757. this.onError("xhr post error", xhrStatus, context);
  758. });
  759. }
  760. /**
  761. * Starts a poll cycle.
  762. *
  763. * @private
  764. */
  765. doPoll() {
  766. const req = this.request();
  767. req.on("data", this.onData.bind(this));
  768. req.on("error", (xhrStatus, context) => {
  769. this.onError("xhr poll error", xhrStatus, context);
  770. });
  771. this.pollXhr = req;
  772. }
  773. };
  774. var Request = class _Request extends Emitter {
  775. /**
  776. * Request constructor
  777. *
  778. * @param {Object} options
  779. * @package
  780. */
  781. constructor(createRequest, uri, opts) {
  782. super();
  783. this.createRequest = createRequest;
  784. installTimerFunctions(this, opts);
  785. this._opts = opts;
  786. this._method = opts.method || "GET";
  787. this._uri = uri;
  788. this._data = void 0 !== opts.data ? opts.data : null;
  789. this._create();
  790. }
  791. /**
  792. * Creates the XHR object and sends the request.
  793. *
  794. * @private
  795. */
  796. _create() {
  797. var _a;
  798. const opts = pick(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
  799. opts.xdomain = !!this._opts.xd;
  800. const xhr = this._xhr = this.createRequest(opts);
  801. try {
  802. xhr.open(this._method, this._uri, true);
  803. try {
  804. if (this._opts.extraHeaders) {
  805. xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true);
  806. for (let i in this._opts.extraHeaders) {
  807. if (this._opts.extraHeaders.hasOwnProperty(i)) {
  808. xhr.setRequestHeader(i, this._opts.extraHeaders[i]);
  809. }
  810. }
  811. }
  812. } catch (e) {
  813. }
  814. if ("POST" === this._method) {
  815. try {
  816. xhr.setRequestHeader("Content-type", "text/plain;charset=UTF-8");
  817. } catch (e) {
  818. }
  819. }
  820. try {
  821. xhr.setRequestHeader("Accept", "*/*");
  822. } catch (e) {
  823. }
  824. (_a = this._opts.cookieJar) === null || _a === void 0 ? void 0 : _a.addCookies(xhr);
  825. if ("withCredentials" in xhr) {
  826. xhr.withCredentials = this._opts.withCredentials;
  827. }
  828. if (this._opts.requestTimeout) {
  829. xhr.timeout = this._opts.requestTimeout;
  830. }
  831. xhr.onreadystatechange = () => {
  832. var _a2;
  833. if (xhr.readyState === 3) {
  834. (_a2 = this._opts.cookieJar) === null || _a2 === void 0 ? void 0 : _a2.parseCookies(
  835. // @ts-ignore
  836. xhr.getResponseHeader("set-cookie")
  837. );
  838. }
  839. if (4 !== xhr.readyState)
  840. return;
  841. if (200 === xhr.status || 1223 === xhr.status) {
  842. this._onLoad();
  843. } else {
  844. this.setTimeoutFn(() => {
  845. this._onError(typeof xhr.status === "number" ? xhr.status : 0);
  846. }, 0);
  847. }
  848. };
  849. xhr.send(this._data);
  850. } catch (e) {
  851. this.setTimeoutFn(() => {
  852. this._onError(e);
  853. }, 0);
  854. return;
  855. }
  856. if (typeof document !== "undefined") {
  857. this._index = _Request.requestsCount++;
  858. _Request.requests[this._index] = this;
  859. }
  860. }
  861. /**
  862. * Called upon error.
  863. *
  864. * @private
  865. */
  866. _onError(err) {
  867. this.emitReserved("error", err, this._xhr);
  868. this._cleanup(true);
  869. }
  870. /**
  871. * Cleans up house.
  872. *
  873. * @private
  874. */
  875. _cleanup(fromError) {
  876. if ("undefined" === typeof this._xhr || null === this._xhr) {
  877. return;
  878. }
  879. this._xhr.onreadystatechange = empty;
  880. if (fromError) {
  881. try {
  882. this._xhr.abort();
  883. } catch (e) {
  884. }
  885. }
  886. if (typeof document !== "undefined") {
  887. delete _Request.requests[this._index];
  888. }
  889. this._xhr = null;
  890. }
  891. /**
  892. * Called upon load.
  893. *
  894. * @private
  895. */
  896. _onLoad() {
  897. const data = this._xhr.responseText;
  898. if (data !== null) {
  899. this.emitReserved("data", data);
  900. this.emitReserved("success");
  901. this._cleanup();
  902. }
  903. }
  904. /**
  905. * Aborts the request.
  906. *
  907. * @package
  908. */
  909. abort() {
  910. this._cleanup();
  911. }
  912. };
  913. Request.requestsCount = 0;
  914. Request.requests = {};
  915. if (typeof document !== "undefined") {
  916. if (typeof attachEvent === "function") {
  917. attachEvent("onunload", unloadHandler);
  918. } else if (typeof addEventListener === "function") {
  919. const terminationEvent = "onpagehide" in globalThisShim ? "pagehide" : "unload";
  920. addEventListener(terminationEvent, unloadHandler, false);
  921. }
  922. }
  923. function unloadHandler() {
  924. for (let i in Request.requests) {
  925. if (Request.requests.hasOwnProperty(i)) {
  926. Request.requests[i].abort();
  927. }
  928. }
  929. }
  930. var hasXHR2 = function() {
  931. const xhr = newRequest({
  932. xdomain: false
  933. });
  934. return xhr && xhr.responseType !== null;
  935. }();
  936. var XHR = class extends BaseXHR {
  937. constructor(opts) {
  938. super(opts);
  939. const forceBase64 = opts && opts.forceBase64;
  940. this.supportsBinary = hasXHR2 && !forceBase64;
  941. }
  942. request(opts = {}) {
  943. Object.assign(opts, { xd: this.xd }, this.opts);
  944. return new Request(newRequest, this.uri(), opts);
  945. }
  946. };
  947. function newRequest(opts) {
  948. const xdomain = opts.xdomain;
  949. try {
  950. if ("undefined" !== typeof XMLHttpRequest && (!xdomain || hasCORS)) {
  951. return new XMLHttpRequest();
  952. }
  953. } catch (e) {
  954. }
  955. if (!xdomain) {
  956. try {
  957. return new globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
  958. } catch (e) {
  959. }
  960. }
  961. }
  962. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/transports/websocket.js
  963. var isReactNative = typeof navigator !== "undefined" && typeof navigator.product === "string" && navigator.product.toLowerCase() === "reactnative";
  964. var BaseWS = class extends Transport {
  965. get name() {
  966. return "websocket";
  967. }
  968. doOpen() {
  969. const uri = this.uri();
  970. const protocols = this.opts.protocols;
  971. const opts = isReactNative ? {} : pick(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
  972. if (this.opts.extraHeaders) {
  973. opts.headers = this.opts.extraHeaders;
  974. }
  975. try {
  976. this.ws = this.createSocket(uri, protocols, opts);
  977. } catch (err) {
  978. return this.emitReserved("error", err);
  979. }
  980. this.ws.binaryType = this.socket.binaryType;
  981. this.addEventListeners();
  982. }
  983. /**
  984. * Adds event listeners to the socket
  985. *
  986. * @private
  987. */
  988. addEventListeners() {
  989. this.ws.onopen = () => {
  990. if (this.opts.autoUnref) {
  991. this.ws._socket.unref();
  992. }
  993. this.onOpen();
  994. };
  995. this.ws.onclose = (closeEvent) => this.onClose({
  996. description: "websocket connection closed",
  997. context: closeEvent
  998. });
  999. this.ws.onmessage = (ev) => this.onData(ev.data);
  1000. this.ws.onerror = (e) => this.onError("websocket error", e);
  1001. }
  1002. write(packets) {
  1003. this.writable = false;
  1004. for (let i = 0; i < packets.length; i++) {
  1005. const packet = packets[i];
  1006. const lastPacket = i === packets.length - 1;
  1007. encodePacket(packet, this.supportsBinary, (data) => {
  1008. try {
  1009. this.doWrite(packet, data);
  1010. } catch (e) {
  1011. }
  1012. if (lastPacket) {
  1013. nextTick(() => {
  1014. this.writable = true;
  1015. this.emitReserved("drain");
  1016. }, this.setTimeoutFn);
  1017. }
  1018. });
  1019. }
  1020. }
  1021. doClose() {
  1022. if (typeof this.ws !== "undefined") {
  1023. this.ws.close();
  1024. this.ws = null;
  1025. }
  1026. }
  1027. /**
  1028. * Generates uri for connection.
  1029. *
  1030. * @private
  1031. */
  1032. uri() {
  1033. const schema = this.opts.secure ? "wss" : "ws";
  1034. const query = this.query || {};
  1035. if (this.opts.timestampRequests) {
  1036. query[this.opts.timestampParam] = randomString();
  1037. }
  1038. if (!this.supportsBinary) {
  1039. query.b64 = 1;
  1040. }
  1041. return this.createUri(schema, query);
  1042. }
  1043. };
  1044. var WebSocketCtor = globalThisShim.WebSocket || globalThisShim.MozWebSocket;
  1045. var WS = class extends BaseWS {
  1046. createSocket(uri, protocols, opts) {
  1047. return !isReactNative ? protocols ? new WebSocketCtor(uri, protocols) : new WebSocketCtor(uri) : new WebSocketCtor(uri, protocols, opts);
  1048. }
  1049. doWrite(_packet, data) {
  1050. this.ws.send(data);
  1051. }
  1052. };
  1053. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/transports/webtransport.js
  1054. var WT = class extends Transport {
  1055. get name() {
  1056. return "webtransport";
  1057. }
  1058. doOpen() {
  1059. try {
  1060. this._transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]);
  1061. } catch (err) {
  1062. return this.emitReserved("error", err);
  1063. }
  1064. this._transport.closed.then(() => {
  1065. this.onClose();
  1066. }).catch((err) => {
  1067. this.onError("webtransport error", err);
  1068. });
  1069. this._transport.ready.then(() => {
  1070. this._transport.createBidirectionalStream().then((stream) => {
  1071. const decoderStream = createPacketDecoderStream(Number.MAX_SAFE_INTEGER, this.socket.binaryType);
  1072. const reader = stream.readable.pipeThrough(decoderStream).getReader();
  1073. const encoderStream = createPacketEncoderStream();
  1074. encoderStream.readable.pipeTo(stream.writable);
  1075. this._writer = encoderStream.writable.getWriter();
  1076. const read = () => {
  1077. reader.read().then(({ done, value: value2 }) => {
  1078. if (done) {
  1079. return;
  1080. }
  1081. this.onPacket(value2);
  1082. read();
  1083. }).catch((err) => {
  1084. });
  1085. };
  1086. read();
  1087. const packet = { type: "open" };
  1088. if (this.query.sid) {
  1089. packet.data = `{"sid":"${this.query.sid}"}`;
  1090. }
  1091. this._writer.write(packet).then(() => this.onOpen());
  1092. });
  1093. });
  1094. }
  1095. write(packets) {
  1096. this.writable = false;
  1097. for (let i = 0; i < packets.length; i++) {
  1098. const packet = packets[i];
  1099. const lastPacket = i === packets.length - 1;
  1100. this._writer.write(packet).then(() => {
  1101. if (lastPacket) {
  1102. nextTick(() => {
  1103. this.writable = true;
  1104. this.emitReserved("drain");
  1105. }, this.setTimeoutFn);
  1106. }
  1107. });
  1108. }
  1109. }
  1110. doClose() {
  1111. var _a;
  1112. (_a = this._transport) === null || _a === void 0 ? void 0 : _a.close();
  1113. }
  1114. };
  1115. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/transports/index.js
  1116. var transports = {
  1117. websocket: WS,
  1118. webtransport: WT,
  1119. polling: XHR
  1120. };
  1121. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/contrib/parseuri.js
  1122. var re = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
  1123. var parts = [
  1124. "source",
  1125. "protocol",
  1126. "authority",
  1127. "userInfo",
  1128. "user",
  1129. "password",
  1130. "host",
  1131. "port",
  1132. "relative",
  1133. "path",
  1134. "directory",
  1135. "file",
  1136. "query",
  1137. "anchor"
  1138. ];
  1139. function parse(str) {
  1140. if (str.length > 8e3) {
  1141. throw "URI too long";
  1142. }
  1143. const src = str, b = str.indexOf("["), e = str.indexOf("]");
  1144. if (b != -1 && e != -1) {
  1145. str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ";") + str.substring(e, str.length);
  1146. }
  1147. let m = re.exec(str || ""), uri = {}, i = 14;
  1148. while (i--) {
  1149. uri[parts[i]] = m[i] || "";
  1150. }
  1151. if (b != -1 && e != -1) {
  1152. uri.source = src;
  1153. uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ":");
  1154. uri.authority = uri.authority.replace("[", "").replace("]", "").replace(/;/g, ":");
  1155. uri.ipv6uri = true;
  1156. }
  1157. uri.pathNames = pathNames(uri, uri["path"]);
  1158. uri.queryKey = queryKey(uri, uri["query"]);
  1159. return uri;
  1160. }
  1161. function pathNames(obj, path) {
  1162. const regx = /\/{2,9}/g, names = path.replace(regx, "/").split("/");
  1163. if (path.slice(0, 1) == "/" || path.length === 0) {
  1164. names.splice(0, 1);
  1165. }
  1166. if (path.slice(-1) == "/") {
  1167. names.splice(names.length - 1, 1);
  1168. }
  1169. return names;
  1170. }
  1171. function queryKey(uri, query) {
  1172. const data = {};
  1173. query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function($0, $1, $2) {
  1174. if ($1) {
  1175. data[$1] = $2;
  1176. }
  1177. });
  1178. return data;
  1179. }
  1180. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/socket.js
  1181. var withEventListeners = typeof addEventListener === "function" && typeof removeEventListener === "function";
  1182. var OFFLINE_EVENT_LISTENERS = [];
  1183. if (withEventListeners) {
  1184. addEventListener("offline", () => {
  1185. OFFLINE_EVENT_LISTENERS.forEach((listener) => listener());
  1186. }, false);
  1187. }
  1188. var SocketWithoutUpgrade = class _SocketWithoutUpgrade extends Emitter {
  1189. /**
  1190. * Socket constructor.
  1191. *
  1192. * @param {String|Object} uri - uri or options
  1193. * @param {Object} opts - options
  1194. */
  1195. constructor(uri, opts) {
  1196. super();
  1197. this.binaryType = defaultBinaryType;
  1198. this.writeBuffer = [];
  1199. this._prevBufferLen = 0;
  1200. this._pingInterval = -1;
  1201. this._pingTimeout = -1;
  1202. this._maxPayload = -1;
  1203. this._pingTimeoutTime = Infinity;
  1204. if (uri && "object" === typeof uri) {
  1205. opts = uri;
  1206. uri = null;
  1207. }
  1208. if (uri) {
  1209. const parsedUri = parse(uri);
  1210. opts.hostname = parsedUri.host;
  1211. opts.secure = parsedUri.protocol === "https" || parsedUri.protocol === "wss";
  1212. opts.port = parsedUri.port;
  1213. if (parsedUri.query)
  1214. opts.query = parsedUri.query;
  1215. } else if (opts.host) {
  1216. opts.hostname = parse(opts.host).host;
  1217. }
  1218. installTimerFunctions(this, opts);
  1219. this.secure = null != opts.secure ? opts.secure : typeof location !== "undefined" && "https:" === location.protocol;
  1220. if (opts.hostname && !opts.port) {
  1221. opts.port = this.secure ? "443" : "80";
  1222. }
  1223. this.hostname = opts.hostname || (typeof location !== "undefined" ? location.hostname : "localhost");
  1224. this.port = opts.port || (typeof location !== "undefined" && location.port ? location.port : this.secure ? "443" : "80");
  1225. this.transports = [];
  1226. this._transportsByName = {};
  1227. opts.transports.forEach((t) => {
  1228. const transportName = t.prototype.name;
  1229. this.transports.push(transportName);
  1230. this._transportsByName[transportName] = t;
  1231. });
  1232. this.opts = Object.assign({
  1233. path: "/engine.io",
  1234. agent: false,
  1235. withCredentials: false,
  1236. upgrade: true,
  1237. timestampParam: "t",
  1238. rememberUpgrade: false,
  1239. addTrailingSlash: true,
  1240. rejectUnauthorized: true,
  1241. perMessageDeflate: {
  1242. threshold: 1024
  1243. },
  1244. transportOptions: {},
  1245. closeOnBeforeunload: false
  1246. }, opts);
  1247. this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : "");
  1248. if (typeof this.opts.query === "string") {
  1249. this.opts.query = decode2(this.opts.query);
  1250. }
  1251. if (withEventListeners) {
  1252. if (this.opts.closeOnBeforeunload) {
  1253. this._beforeunloadEventListener = () => {
  1254. if (this.transport) {
  1255. this.transport.removeAllListeners();
  1256. this.transport.close();
  1257. }
  1258. };
  1259. addEventListener("beforeunload", this._beforeunloadEventListener, false);
  1260. }
  1261. if (this.hostname !== "localhost") {
  1262. this._offlineEventListener = () => {
  1263. this._onClose("transport close", {
  1264. description: "network connection lost"
  1265. });
  1266. };
  1267. OFFLINE_EVENT_LISTENERS.push(this._offlineEventListener);
  1268. }
  1269. }
  1270. if (this.opts.withCredentials) {
  1271. this._cookieJar = createCookieJar();
  1272. }
  1273. this._open();
  1274. }
  1275. /**
  1276. * Creates transport of the given type.
  1277. *
  1278. * @param {String} name - transport name
  1279. * @return {Transport}
  1280. * @private
  1281. */
  1282. createTransport(name) {
  1283. const query = Object.assign({}, this.opts.query);
  1284. query.EIO = protocol;
  1285. query.transport = name;
  1286. if (this.id)
  1287. query.sid = this.id;
  1288. const opts = Object.assign({}, this.opts, {
  1289. query,
  1290. socket: this,
  1291. hostname: this.hostname,
  1292. secure: this.secure,
  1293. port: this.port
  1294. }, this.opts.transportOptions[name]);
  1295. return new this._transportsByName[name](opts);
  1296. }
  1297. /**
  1298. * Initializes transport to use and starts probe.
  1299. *
  1300. * @private
  1301. */
  1302. _open() {
  1303. if (this.transports.length === 0) {
  1304. this.setTimeoutFn(() => {
  1305. this.emitReserved("error", "No transports available");
  1306. }, 0);
  1307. return;
  1308. }
  1309. const transportName = this.opts.rememberUpgrade && _SocketWithoutUpgrade.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
  1310. this.readyState = "opening";
  1311. const transport = this.createTransport(transportName);
  1312. transport.open();
  1313. this.setTransport(transport);
  1314. }
  1315. /**
  1316. * Sets the current transport. Disables the existing one (if any).
  1317. *
  1318. * @private
  1319. */
  1320. setTransport(transport) {
  1321. if (this.transport) {
  1322. this.transport.removeAllListeners();
  1323. }
  1324. this.transport = transport;
  1325. 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));
  1326. }
  1327. /**
  1328. * Called when connection is deemed open.
  1329. *
  1330. * @private
  1331. */
  1332. onOpen() {
  1333. this.readyState = "open";
  1334. _SocketWithoutUpgrade.priorWebsocketSuccess = "websocket" === this.transport.name;
  1335. this.emitReserved("open");
  1336. this.flush();
  1337. }
  1338. /**
  1339. * Handles a packet.
  1340. *
  1341. * @private
  1342. */
  1343. _onPacket(packet) {
  1344. if ("opening" === this.readyState || "open" === this.readyState || "closing" === this.readyState) {
  1345. this.emitReserved("packet", packet);
  1346. this.emitReserved("heartbeat");
  1347. switch (packet.type) {
  1348. case "open":
  1349. this.onHandshake(JSON.parse(packet.data));
  1350. break;
  1351. case "ping":
  1352. this._sendPacket("pong");
  1353. this.emitReserved("ping");
  1354. this.emitReserved("pong");
  1355. this._resetPingTimeout();
  1356. break;
  1357. case "error":
  1358. const err = new Error("server error");
  1359. err.code = packet.data;
  1360. this._onError(err);
  1361. break;
  1362. case "message":
  1363. this.emitReserved("data", packet.data);
  1364. this.emitReserved("message", packet.data);
  1365. break;
  1366. }
  1367. } else {
  1368. }
  1369. }
  1370. /**
  1371. * Called upon handshake completion.
  1372. *
  1373. * @param {Object} data - handshake obj
  1374. * @private
  1375. */
  1376. onHandshake(data) {
  1377. this.emitReserved("handshake", data);
  1378. this.id = data.sid;
  1379. this.transport.query.sid = data.sid;
  1380. this._pingInterval = data.pingInterval;
  1381. this._pingTimeout = data.pingTimeout;
  1382. this._maxPayload = data.maxPayload;
  1383. this.onOpen();
  1384. if ("closed" === this.readyState)
  1385. return;
  1386. this._resetPingTimeout();
  1387. }
  1388. /**
  1389. * Sets and resets ping timeout timer based on server pings.
  1390. *
  1391. * @private
  1392. */
  1393. _resetPingTimeout() {
  1394. this.clearTimeoutFn(this._pingTimeoutTimer);
  1395. const delay = this._pingInterval + this._pingTimeout;
  1396. this._pingTimeoutTime = Date.now() + delay;
  1397. this._pingTimeoutTimer = this.setTimeoutFn(() => {
  1398. this._onClose("ping timeout");
  1399. }, delay);
  1400. if (this.opts.autoUnref) {
  1401. this._pingTimeoutTimer.unref();
  1402. }
  1403. }
  1404. /**
  1405. * Called on `drain` event
  1406. *
  1407. * @private
  1408. */
  1409. _onDrain() {
  1410. this.writeBuffer.splice(0, this._prevBufferLen);
  1411. this._prevBufferLen = 0;
  1412. if (0 === this.writeBuffer.length) {
  1413. this.emitReserved("drain");
  1414. } else {
  1415. this.flush();
  1416. }
  1417. }
  1418. /**
  1419. * Flush write buffers.
  1420. *
  1421. * @private
  1422. */
  1423. flush() {
  1424. if ("closed" !== this.readyState && this.transport.writable && !this.upgrading && this.writeBuffer.length) {
  1425. const packets = this._getWritablePackets();
  1426. this.transport.send(packets);
  1427. this._prevBufferLen = packets.length;
  1428. this.emitReserved("flush");
  1429. }
  1430. }
  1431. /**
  1432. * Ensure the encoded size of the writeBuffer is below the maxPayload value sent by the server (only for HTTP
  1433. * long-polling)
  1434. *
  1435. * @private
  1436. */
  1437. _getWritablePackets() {
  1438. const shouldCheckPayloadSize = this._maxPayload && this.transport.name === "polling" && this.writeBuffer.length > 1;
  1439. if (!shouldCheckPayloadSize) {
  1440. return this.writeBuffer;
  1441. }
  1442. let payloadSize = 1;
  1443. for (let i = 0; i < this.writeBuffer.length; i++) {
  1444. const data = this.writeBuffer[i].data;
  1445. if (data) {
  1446. payloadSize += byteLength(data);
  1447. }
  1448. if (i > 0 && payloadSize > this._maxPayload) {
  1449. return this.writeBuffer.slice(0, i);
  1450. }
  1451. payloadSize += 2;
  1452. }
  1453. return this.writeBuffer;
  1454. }
  1455. /**
  1456. * Checks whether the heartbeat timer has expired but the socket has not yet been notified.
  1457. *
  1458. * Note: this method is private for now because it does not really fit the WebSocket API, but if we put it in the
  1459. * `write()` method then the message would not be buffered by the Socket.IO client.
  1460. *
  1461. * @return {boolean}
  1462. * @private
  1463. */
  1464. /* private */
  1465. _hasPingExpired() {
  1466. if (!this._pingTimeoutTime)
  1467. return true;
  1468. const hasExpired = Date.now() > this._pingTimeoutTime;
  1469. if (hasExpired) {
  1470. this._pingTimeoutTime = 0;
  1471. nextTick(() => {
  1472. this._onClose("ping timeout");
  1473. }, this.setTimeoutFn);
  1474. }
  1475. return hasExpired;
  1476. }
  1477. /**
  1478. * Sends a message.
  1479. *
  1480. * @param {String} msg - message.
  1481. * @param {Object} options.
  1482. * @param {Function} fn - callback function.
  1483. * @return {Socket} for chaining.
  1484. */
  1485. write(msg, options, fn) {
  1486. this._sendPacket("message", msg, options, fn);
  1487. return this;
  1488. }
  1489. /**
  1490. * Sends a message. Alias of {@link Socket#write}.
  1491. *
  1492. * @param {String} msg - message.
  1493. * @param {Object} options.
  1494. * @param {Function} fn - callback function.
  1495. * @return {Socket} for chaining.
  1496. */
  1497. send(msg, options, fn) {
  1498. this._sendPacket("message", msg, options, fn);
  1499. return this;
  1500. }
  1501. /**
  1502. * Sends a packet.
  1503. *
  1504. * @param {String} type: packet type.
  1505. * @param {String} data.
  1506. * @param {Object} options.
  1507. * @param {Function} fn - callback function.
  1508. * @private
  1509. */
  1510. _sendPacket(type, data, options, fn) {
  1511. if ("function" === typeof data) {
  1512. fn = data;
  1513. data = void 0;
  1514. }
  1515. if ("function" === typeof options) {
  1516. fn = options;
  1517. options = null;
  1518. }
  1519. if ("closing" === this.readyState || "closed" === this.readyState) {
  1520. return;
  1521. }
  1522. options = options || {};
  1523. options.compress = false !== options.compress;
  1524. const packet = {
  1525. type,
  1526. data,
  1527. options
  1528. };
  1529. this.emitReserved("packetCreate", packet);
  1530. this.writeBuffer.push(packet);
  1531. if (fn)
  1532. this.once("flush", fn);
  1533. this.flush();
  1534. }
  1535. /**
  1536. * Closes the connection.
  1537. */
  1538. close() {
  1539. const close = () => {
  1540. this._onClose("forced close");
  1541. this.transport.close();
  1542. };
  1543. const cleanupAndClose = () => {
  1544. this.off("upgrade", cleanupAndClose);
  1545. this.off("upgradeError", cleanupAndClose);
  1546. close();
  1547. };
  1548. const waitForUpgrade = () => {
  1549. this.once("upgrade", cleanupAndClose);
  1550. this.once("upgradeError", cleanupAndClose);
  1551. };
  1552. if ("opening" === this.readyState || "open" === this.readyState) {
  1553. this.readyState = "closing";
  1554. if (this.writeBuffer.length) {
  1555. this.once("drain", () => {
  1556. if (this.upgrading) {
  1557. waitForUpgrade();
  1558. } else {
  1559. close();
  1560. }
  1561. });
  1562. } else if (this.upgrading) {
  1563. waitForUpgrade();
  1564. } else {
  1565. close();
  1566. }
  1567. }
  1568. return this;
  1569. }
  1570. /**
  1571. * Called upon transport error
  1572. *
  1573. * @private
  1574. */
  1575. _onError(err) {
  1576. _SocketWithoutUpgrade.priorWebsocketSuccess = false;
  1577. if (this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening") {
  1578. this.transports.shift();
  1579. return this._open();
  1580. }
  1581. this.emitReserved("error", err);
  1582. this._onClose("transport error", err);
  1583. }
  1584. /**
  1585. * Called upon transport close.
  1586. *
  1587. * @private
  1588. */
  1589. _onClose(reason, description) {
  1590. if ("opening" === this.readyState || "open" === this.readyState || "closing" === this.readyState) {
  1591. this.clearTimeoutFn(this._pingTimeoutTimer);
  1592. this.transport.removeAllListeners("close");
  1593. this.transport.close();
  1594. this.transport.removeAllListeners();
  1595. if (withEventListeners) {
  1596. if (this._beforeunloadEventListener) {
  1597. removeEventListener("beforeunload", this._beforeunloadEventListener, false);
  1598. }
  1599. if (this._offlineEventListener) {
  1600. const i = OFFLINE_EVENT_LISTENERS.indexOf(this._offlineEventListener);
  1601. if (i !== -1) {
  1602. OFFLINE_EVENT_LISTENERS.splice(i, 1);
  1603. }
  1604. }
  1605. }
  1606. this.readyState = "closed";
  1607. this.id = null;
  1608. this.emitReserved("close", reason, description);
  1609. this.writeBuffer = [];
  1610. this._prevBufferLen = 0;
  1611. }
  1612. }
  1613. };
  1614. SocketWithoutUpgrade.protocol = protocol;
  1615. var SocketWithUpgrade = class extends SocketWithoutUpgrade {
  1616. constructor() {
  1617. super(...arguments);
  1618. this._upgrades = [];
  1619. }
  1620. onOpen() {
  1621. super.onOpen();
  1622. if ("open" === this.readyState && this.opts.upgrade) {
  1623. for (let i = 0; i < this._upgrades.length; i++) {
  1624. this._probe(this._upgrades[i]);
  1625. }
  1626. }
  1627. }
  1628. /**
  1629. * Probes a transport.
  1630. *
  1631. * @param {String} name - transport name
  1632. * @private
  1633. */
  1634. _probe(name) {
  1635. let transport = this.createTransport(name);
  1636. let failed = false;
  1637. SocketWithoutUpgrade.priorWebsocketSuccess = false;
  1638. const onTransportOpen = () => {
  1639. if (failed)
  1640. return;
  1641. transport.send([{ type: "ping", data: "probe" }]);
  1642. transport.once("packet", (msg) => {
  1643. if (failed)
  1644. return;
  1645. if ("pong" === msg.type && "probe" === msg.data) {
  1646. this.upgrading = true;
  1647. this.emitReserved("upgrading", transport);
  1648. if (!transport)
  1649. return;
  1650. SocketWithoutUpgrade.priorWebsocketSuccess = "websocket" === transport.name;
  1651. this.transport.pause(() => {
  1652. if (failed)
  1653. return;
  1654. if ("closed" === this.readyState)
  1655. return;
  1656. cleanup();
  1657. this.setTransport(transport);
  1658. transport.send([{ type: "upgrade" }]);
  1659. this.emitReserved("upgrade", transport);
  1660. transport = null;
  1661. this.upgrading = false;
  1662. this.flush();
  1663. });
  1664. } else {
  1665. const err = new Error("probe error");
  1666. err.transport = transport.name;
  1667. this.emitReserved("upgradeError", err);
  1668. }
  1669. });
  1670. };
  1671. function freezeTransport() {
  1672. if (failed)
  1673. return;
  1674. failed = true;
  1675. cleanup();
  1676. transport.close();
  1677. transport = null;
  1678. }
  1679. const onerror = (err) => {
  1680. const error = new Error("probe error: " + err);
  1681. error.transport = transport.name;
  1682. freezeTransport();
  1683. this.emitReserved("upgradeError", error);
  1684. };
  1685. function onTransportClose() {
  1686. onerror("transport closed");
  1687. }
  1688. function onclose() {
  1689. onerror("socket closed");
  1690. }
  1691. function onupgrade(to) {
  1692. if (transport && to.name !== transport.name) {
  1693. freezeTransport();
  1694. }
  1695. }
  1696. const cleanup = () => {
  1697. transport.removeListener("open", onTransportOpen);
  1698. transport.removeListener("error", onerror);
  1699. transport.removeListener("close", onTransportClose);
  1700. this.off("close", onclose);
  1701. this.off("upgrading", onupgrade);
  1702. };
  1703. transport.once("open", onTransportOpen);
  1704. transport.once("error", onerror);
  1705. transport.once("close", onTransportClose);
  1706. this.once("close", onclose);
  1707. this.once("upgrading", onupgrade);
  1708. if (this._upgrades.indexOf("webtransport") !== -1 && name !== "webtransport") {
  1709. this.setTimeoutFn(() => {
  1710. if (!failed) {
  1711. transport.open();
  1712. }
  1713. }, 200);
  1714. } else {
  1715. transport.open();
  1716. }
  1717. }
  1718. onHandshake(data) {
  1719. this._upgrades = this._filterUpgrades(data.upgrades);
  1720. super.onHandshake(data);
  1721. }
  1722. /**
  1723. * Filters upgrades, returning only those matching client transports.
  1724. *
  1725. * @param {Array} upgrades - server upgrades
  1726. * @private
  1727. */
  1728. _filterUpgrades(upgrades) {
  1729. const filteredUpgrades = [];
  1730. for (let i = 0; i < upgrades.length; i++) {
  1731. if (~this.transports.indexOf(upgrades[i]))
  1732. filteredUpgrades.push(upgrades[i]);
  1733. }
  1734. return filteredUpgrades;
  1735. }
  1736. };
  1737. var Socket = class extends SocketWithUpgrade {
  1738. constructor(uri, opts = {}) {
  1739. const o = typeof uri === "object" ? uri : opts;
  1740. if (!o.transports || o.transports && typeof o.transports[0] === "string") {
  1741. o.transports = (o.transports || ["polling", "websocket", "webtransport"]).map((transportName) => transports[transportName]).filter((t) => !!t);
  1742. }
  1743. super(uri, o);
  1744. }
  1745. };
  1746. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/index.js
  1747. var protocol2 = Socket.protocol;
  1748. // ../../../../Newweb/starter/node_modules/socket.io-client/build/esm/url.js
  1749. function url(uri, path = "", loc) {
  1750. let obj = uri;
  1751. loc = loc || typeof location !== "undefined" && location;
  1752. if (null == uri)
  1753. uri = loc.protocol + "//" + loc.host;
  1754. if (typeof uri === "string") {
  1755. if ("/" === uri.charAt(0)) {
  1756. if ("/" === uri.charAt(1)) {
  1757. uri = loc.protocol + uri;
  1758. } else {
  1759. uri = loc.host + uri;
  1760. }
  1761. }
  1762. if (!/^(https?|wss?):\/\//.test(uri)) {
  1763. if ("undefined" !== typeof loc) {
  1764. uri = loc.protocol + "//" + uri;
  1765. } else {
  1766. uri = "https://" + uri;
  1767. }
  1768. }
  1769. obj = parse(uri);
  1770. }
  1771. if (!obj.port) {
  1772. if (/^(http|ws)$/.test(obj.protocol)) {
  1773. obj.port = "80";
  1774. } else if (/^(http|ws)s$/.test(obj.protocol)) {
  1775. obj.port = "443";
  1776. }
  1777. }
  1778. obj.path = obj.path || "/";
  1779. const ipv6 = obj.host.indexOf(":") !== -1;
  1780. const host = ipv6 ? "[" + obj.host + "]" : obj.host;
  1781. obj.id = obj.protocol + "://" + host + ":" + obj.port + path;
  1782. obj.href = obj.protocol + "://" + host + (loc && loc.port === obj.port ? "" : ":" + obj.port);
  1783. return obj;
  1784. }
  1785. // ../../../../Newweb/starter/node_modules/socket.io-parser/build/esm/index.js
  1786. var esm_exports = {};
  1787. __export(esm_exports, {
  1788. Decoder: () => Decoder,
  1789. Encoder: () => Encoder,
  1790. PacketType: () => PacketType,
  1791. protocol: () => protocol3
  1792. });
  1793. // ../../../../Newweb/starter/node_modules/socket.io-parser/build/esm/is-binary.js
  1794. var withNativeArrayBuffer3 = typeof ArrayBuffer === "function";
  1795. var isView2 = (obj) => {
  1796. return typeof ArrayBuffer.isView === "function" ? ArrayBuffer.isView(obj) : obj.buffer instanceof ArrayBuffer;
  1797. };
  1798. var toString = Object.prototype.toString;
  1799. var withNativeBlob2 = typeof Blob === "function" || typeof Blob !== "undefined" && toString.call(Blob) === "[object BlobConstructor]";
  1800. var withNativeFile = typeof File === "function" || typeof File !== "undefined" && toString.call(File) === "[object FileConstructor]";
  1801. function isBinary(obj) {
  1802. return withNativeArrayBuffer3 && (obj instanceof ArrayBuffer || isView2(obj)) || withNativeBlob2 && obj instanceof Blob || withNativeFile && obj instanceof File;
  1803. }
  1804. function hasBinary(obj, toJSON) {
  1805. if (!obj || typeof obj !== "object") {
  1806. return false;
  1807. }
  1808. if (Array.isArray(obj)) {
  1809. for (let i = 0, l = obj.length; i < l; i++) {
  1810. if (hasBinary(obj[i])) {
  1811. return true;
  1812. }
  1813. }
  1814. return false;
  1815. }
  1816. if (isBinary(obj)) {
  1817. return true;
  1818. }
  1819. if (obj.toJSON && typeof obj.toJSON === "function" && arguments.length === 1) {
  1820. return hasBinary(obj.toJSON(), true);
  1821. }
  1822. for (const key in obj) {
  1823. if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) {
  1824. return true;
  1825. }
  1826. }
  1827. return false;
  1828. }
  1829. // ../../../../Newweb/starter/node_modules/socket.io-parser/build/esm/binary.js
  1830. function deconstructPacket(packet) {
  1831. const buffers = [];
  1832. const packetData = packet.data;
  1833. const pack = packet;
  1834. pack.data = _deconstructPacket(packetData, buffers);
  1835. pack.attachments = buffers.length;
  1836. return { packet: pack, buffers };
  1837. }
  1838. function _deconstructPacket(data, buffers) {
  1839. if (!data)
  1840. return data;
  1841. if (isBinary(data)) {
  1842. const placeholder = { _placeholder: true, num: buffers.length };
  1843. buffers.push(data);
  1844. return placeholder;
  1845. } else if (Array.isArray(data)) {
  1846. const newData = new Array(data.length);
  1847. for (let i = 0; i < data.length; i++) {
  1848. newData[i] = _deconstructPacket(data[i], buffers);
  1849. }
  1850. return newData;
  1851. } else if (typeof data === "object" && !(data instanceof Date)) {
  1852. const newData = {};
  1853. for (const key in data) {
  1854. if (Object.prototype.hasOwnProperty.call(data, key)) {
  1855. newData[key] = _deconstructPacket(data[key], buffers);
  1856. }
  1857. }
  1858. return newData;
  1859. }
  1860. return data;
  1861. }
  1862. function reconstructPacket(packet, buffers) {
  1863. packet.data = _reconstructPacket(packet.data, buffers);
  1864. delete packet.attachments;
  1865. return packet;
  1866. }
  1867. function _reconstructPacket(data, buffers) {
  1868. if (!data)
  1869. return data;
  1870. if (data && data._placeholder === true) {
  1871. const isIndexValid = typeof data.num === "number" && data.num >= 0 && data.num < buffers.length;
  1872. if (isIndexValid) {
  1873. return buffers[data.num];
  1874. } else {
  1875. throw new Error("illegal attachments");
  1876. }
  1877. } else if (Array.isArray(data)) {
  1878. for (let i = 0; i < data.length; i++) {
  1879. data[i] = _reconstructPacket(data[i], buffers);
  1880. }
  1881. } else if (typeof data === "object") {
  1882. for (const key in data) {
  1883. if (Object.prototype.hasOwnProperty.call(data, key)) {
  1884. data[key] = _reconstructPacket(data[key], buffers);
  1885. }
  1886. }
  1887. }
  1888. return data;
  1889. }
  1890. // ../../../../Newweb/starter/node_modules/socket.io-parser/build/esm/index.js
  1891. var RESERVED_EVENTS = [
  1892. "connect",
  1893. "connect_error",
  1894. "disconnect",
  1895. "disconnecting",
  1896. "newListener",
  1897. "removeListener"
  1898. // used by the Node.js EventEmitter
  1899. ];
  1900. var protocol3 = 5;
  1901. var PacketType;
  1902. (function(PacketType2) {
  1903. PacketType2[PacketType2["CONNECT"] = 0] = "CONNECT";
  1904. PacketType2[PacketType2["DISCONNECT"] = 1] = "DISCONNECT";
  1905. PacketType2[PacketType2["EVENT"] = 2] = "EVENT";
  1906. PacketType2[PacketType2["ACK"] = 3] = "ACK";
  1907. PacketType2[PacketType2["CONNECT_ERROR"] = 4] = "CONNECT_ERROR";
  1908. PacketType2[PacketType2["BINARY_EVENT"] = 5] = "BINARY_EVENT";
  1909. PacketType2[PacketType2["BINARY_ACK"] = 6] = "BINARY_ACK";
  1910. })(PacketType || (PacketType = {}));
  1911. var Encoder = class {
  1912. /**
  1913. * Encoder constructor
  1914. *
  1915. * @param {function} replacer - custom replacer to pass down to JSON.parse
  1916. */
  1917. constructor(replacer) {
  1918. this.replacer = replacer;
  1919. }
  1920. /**
  1921. * Encode a packet as a single string if non-binary, or as a
  1922. * buffer sequence, depending on packet type.
  1923. *
  1924. * @param {Object} obj - packet object
  1925. */
  1926. encode(obj) {
  1927. if (obj.type === PacketType.EVENT || obj.type === PacketType.ACK) {
  1928. if (hasBinary(obj)) {
  1929. return this.encodeAsBinary({
  1930. type: obj.type === PacketType.EVENT ? PacketType.BINARY_EVENT : PacketType.BINARY_ACK,
  1931. nsp: obj.nsp,
  1932. data: obj.data,
  1933. id: obj.id
  1934. });
  1935. }
  1936. }
  1937. return [this.encodeAsString(obj)];
  1938. }
  1939. /**
  1940. * Encode packet as string.
  1941. */
  1942. encodeAsString(obj) {
  1943. let str = "" + obj.type;
  1944. if (obj.type === PacketType.BINARY_EVENT || obj.type === PacketType.BINARY_ACK) {
  1945. str += obj.attachments + "-";
  1946. }
  1947. if (obj.nsp && "/" !== obj.nsp) {
  1948. str += obj.nsp + ",";
  1949. }
  1950. if (null != obj.id) {
  1951. str += obj.id;
  1952. }
  1953. if (null != obj.data) {
  1954. str += JSON.stringify(obj.data, this.replacer);
  1955. }
  1956. return str;
  1957. }
  1958. /**
  1959. * Encode packet as 'buffer sequence' by removing blobs, and
  1960. * deconstructing packet into object with placeholders and
  1961. * a list of buffers.
  1962. */
  1963. encodeAsBinary(obj) {
  1964. const deconstruction = deconstructPacket(obj);
  1965. const pack = this.encodeAsString(deconstruction.packet);
  1966. const buffers = deconstruction.buffers;
  1967. buffers.unshift(pack);
  1968. return buffers;
  1969. }
  1970. };
  1971. function isObject(value2) {
  1972. return Object.prototype.toString.call(value2) === "[object Object]";
  1973. }
  1974. var Decoder = class _Decoder extends Emitter {
  1975. /**
  1976. * Decoder constructor
  1977. *
  1978. * @param {function} reviver - custom reviver to pass down to JSON.stringify
  1979. */
  1980. constructor(reviver) {
  1981. super();
  1982. this.reviver = reviver;
  1983. }
  1984. /**
  1985. * Decodes an encoded packet string into packet JSON.
  1986. *
  1987. * @param {String} obj - encoded packet
  1988. */
  1989. add(obj) {
  1990. let packet;
  1991. if (typeof obj === "string") {
  1992. if (this.reconstructor) {
  1993. throw new Error("got plaintext data when reconstructing a packet");
  1994. }
  1995. packet = this.decodeString(obj);
  1996. const isBinaryEvent = packet.type === PacketType.BINARY_EVENT;
  1997. if (isBinaryEvent || packet.type === PacketType.BINARY_ACK) {
  1998. packet.type = isBinaryEvent ? PacketType.EVENT : PacketType.ACK;
  1999. this.reconstructor = new BinaryReconstructor(packet);
  2000. if (packet.attachments === 0) {
  2001. super.emitReserved("decoded", packet);
  2002. }
  2003. } else {
  2004. super.emitReserved("decoded", packet);
  2005. }
  2006. } else if (isBinary(obj) || obj.base64) {
  2007. if (!this.reconstructor) {
  2008. throw new Error("got binary data when not reconstructing a packet");
  2009. } else {
  2010. packet = this.reconstructor.takeBinaryData(obj);
  2011. if (packet) {
  2012. this.reconstructor = null;
  2013. super.emitReserved("decoded", packet);
  2014. }
  2015. }
  2016. } else {
  2017. throw new Error("Unknown type: " + obj);
  2018. }
  2019. }
  2020. /**
  2021. * Decode a packet String (JSON data)
  2022. *
  2023. * @param {String} str
  2024. * @return {Object} packet
  2025. */
  2026. decodeString(str) {
  2027. let i = 0;
  2028. const p = {
  2029. type: Number(str.charAt(0))
  2030. };
  2031. if (PacketType[p.type] === void 0) {
  2032. throw new Error("unknown packet type " + p.type);
  2033. }
  2034. if (p.type === PacketType.BINARY_EVENT || p.type === PacketType.BINARY_ACK) {
  2035. const start = i + 1;
  2036. while (str.charAt(++i) !== "-" && i != str.length) {
  2037. }
  2038. const buf = str.substring(start, i);
  2039. if (buf != Number(buf) || str.charAt(i) !== "-") {
  2040. throw new Error("Illegal attachments");
  2041. }
  2042. p.attachments = Number(buf);
  2043. }
  2044. if ("/" === str.charAt(i + 1)) {
  2045. const start = i + 1;
  2046. while (++i) {
  2047. const c = str.charAt(i);
  2048. if ("," === c)
  2049. break;
  2050. if (i === str.length)
  2051. break;
  2052. }
  2053. p.nsp = str.substring(start, i);
  2054. } else {
  2055. p.nsp = "/";
  2056. }
  2057. const next = str.charAt(i + 1);
  2058. if ("" !== next && Number(next) == next) {
  2059. const start = i + 1;
  2060. while (++i) {
  2061. const c = str.charAt(i);
  2062. if (null == c || Number(c) != c) {
  2063. --i;
  2064. break;
  2065. }
  2066. if (i === str.length)
  2067. break;
  2068. }
  2069. p.id = Number(str.substring(start, i + 1));
  2070. }
  2071. if (str.charAt(++i)) {
  2072. const payload = this.tryParse(str.substr(i));
  2073. if (_Decoder.isPayloadValid(p.type, payload)) {
  2074. p.data = payload;
  2075. } else {
  2076. throw new Error("invalid payload");
  2077. }
  2078. }
  2079. return p;
  2080. }
  2081. tryParse(str) {
  2082. try {
  2083. return JSON.parse(str, this.reviver);
  2084. } catch (e) {
  2085. return false;
  2086. }
  2087. }
  2088. static isPayloadValid(type, payload) {
  2089. switch (type) {
  2090. case PacketType.CONNECT:
  2091. return isObject(payload);
  2092. case PacketType.DISCONNECT:
  2093. return payload === void 0;
  2094. case PacketType.CONNECT_ERROR:
  2095. return typeof payload === "string" || isObject(payload);
  2096. case PacketType.EVENT:
  2097. case PacketType.BINARY_EVENT:
  2098. return Array.isArray(payload) && (typeof payload[0] === "number" || typeof payload[0] === "string" && RESERVED_EVENTS.indexOf(payload[0]) === -1);
  2099. case PacketType.ACK:
  2100. case PacketType.BINARY_ACK:
  2101. return Array.isArray(payload);
  2102. }
  2103. }
  2104. /**
  2105. * Deallocates a parser's resources
  2106. */
  2107. destroy() {
  2108. if (this.reconstructor) {
  2109. this.reconstructor.finishedReconstruction();
  2110. this.reconstructor = null;
  2111. }
  2112. }
  2113. };
  2114. var BinaryReconstructor = class {
  2115. constructor(packet) {
  2116. this.packet = packet;
  2117. this.buffers = [];
  2118. this.reconPack = packet;
  2119. }
  2120. /**
  2121. * Method to be called when binary data received from connection
  2122. * after a BINARY_EVENT packet.
  2123. *
  2124. * @param {Buffer | ArrayBuffer} binData - the raw binary data received
  2125. * @return {null | Object} returns null if more binary data is expected or
  2126. * a reconstructed packet object if all buffers have been received.
  2127. */
  2128. takeBinaryData(binData) {
  2129. this.buffers.push(binData);
  2130. if (this.buffers.length === this.reconPack.attachments) {
  2131. const packet = reconstructPacket(this.reconPack, this.buffers);
  2132. this.finishedReconstruction();
  2133. return packet;
  2134. }
  2135. return null;
  2136. }
  2137. /**
  2138. * Cleans up binary packet reconstruction variables.
  2139. */
  2140. finishedReconstruction() {
  2141. this.reconPack = null;
  2142. this.buffers = [];
  2143. }
  2144. };
  2145. // ../../../../Newweb/starter/node_modules/socket.io-client/build/esm/on.js
  2146. function on(obj, ev, fn) {
  2147. obj.on(ev, fn);
  2148. return function subDestroy() {
  2149. obj.off(ev, fn);
  2150. };
  2151. }
  2152. // ../../../../Newweb/starter/node_modules/socket.io-client/build/esm/socket.js
  2153. var RESERVED_EVENTS2 = Object.freeze({
  2154. connect: 1,
  2155. connect_error: 1,
  2156. disconnect: 1,
  2157. disconnecting: 1,
  2158. // EventEmitter reserved events: https://nodejs.org/api/events.html#events_event_newlistener
  2159. newListener: 1,
  2160. removeListener: 1
  2161. });
  2162. var Socket2 = class extends Emitter {
  2163. /**
  2164. * `Socket` constructor.
  2165. */
  2166. constructor(io, nsp, opts) {
  2167. super();
  2168. this.connected = false;
  2169. this.recovered = false;
  2170. this.receiveBuffer = [];
  2171. this.sendBuffer = [];
  2172. this._queue = [];
  2173. this._queueSeq = 0;
  2174. this.ids = 0;
  2175. this.acks = {};
  2176. this.flags = {};
  2177. this.io = io;
  2178. this.nsp = nsp;
  2179. if (opts && opts.auth) {
  2180. this.auth = opts.auth;
  2181. }
  2182. this._opts = Object.assign({}, opts);
  2183. if (this.io._autoConnect)
  2184. this.open();
  2185. }
  2186. /**
  2187. * Whether the socket is currently disconnected
  2188. *
  2189. * @example
  2190. * const socket = io();
  2191. *
  2192. * socket.on("connect", () => {
  2193. * console.log(socket.disconnected); // false
  2194. * });
  2195. *
  2196. * socket.on("disconnect", () => {
  2197. * console.log(socket.disconnected); // true
  2198. * });
  2199. */
  2200. get disconnected() {
  2201. return !this.connected;
  2202. }
  2203. /**
  2204. * Subscribe to open, close and packet events
  2205. *
  2206. * @private
  2207. */
  2208. subEvents() {
  2209. if (this.subs)
  2210. return;
  2211. const io = this.io;
  2212. this.subs = [
  2213. on(io, "open", this.onopen.bind(this)),
  2214. on(io, "packet", this.onpacket.bind(this)),
  2215. on(io, "error", this.onerror.bind(this)),
  2216. on(io, "close", this.onclose.bind(this))
  2217. ];
  2218. }
  2219. /**
  2220. * Whether the Socket will try to reconnect when its Manager connects or reconnects.
  2221. *
  2222. * @example
  2223. * const socket = io();
  2224. *
  2225. * console.log(socket.active); // true
  2226. *
  2227. * socket.on("disconnect", (reason) => {
  2228. * if (reason === "io server disconnect") {
  2229. * // the disconnection was initiated by the server, you need to manually reconnect
  2230. * console.log(socket.active); // false
  2231. * }
  2232. * // else the socket will automatically try to reconnect
  2233. * console.log(socket.active); // true
  2234. * });
  2235. */
  2236. get active() {
  2237. return !!this.subs;
  2238. }
  2239. /**
  2240. * "Opens" the socket.
  2241. *
  2242. * @example
  2243. * const socket = io({
  2244. * autoConnect: false
  2245. * });
  2246. *
  2247. * socket.connect();
  2248. */
  2249. connect() {
  2250. if (this.connected)
  2251. return this;
  2252. this.subEvents();
  2253. if (!this.io["_reconnecting"])
  2254. this.io.open();
  2255. if ("open" === this.io._readyState)
  2256. this.onopen();
  2257. return this;
  2258. }
  2259. /**
  2260. * Alias for {@link connect()}.
  2261. */
  2262. open() {
  2263. return this.connect();
  2264. }
  2265. /**
  2266. * Sends a `message` event.
  2267. *
  2268. * This method mimics the WebSocket.send() method.
  2269. *
  2270. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send
  2271. *
  2272. * @example
  2273. * socket.send("hello");
  2274. *
  2275. * // this is equivalent to
  2276. * socket.emit("message", "hello");
  2277. *
  2278. * @return self
  2279. */
  2280. send(...args) {
  2281. args.unshift("message");
  2282. this.emit.apply(this, args);
  2283. return this;
  2284. }
  2285. /**
  2286. * Override `emit`.
  2287. * If the event is in `events`, it's emitted normally.
  2288. *
  2289. * @example
  2290. * socket.emit("hello", "world");
  2291. *
  2292. * // all serializable datastructures are supported (no need to call JSON.stringify)
  2293. * socket.emit("hello", 1, "2", { 3: ["4"], 5: Uint8Array.from([6]) });
  2294. *
  2295. * // with an acknowledgement from the server
  2296. * socket.emit("hello", "world", (val) => {
  2297. * // ...
  2298. * });
  2299. *
  2300. * @return self
  2301. */
  2302. emit(ev, ...args) {
  2303. var _a, _b, _c;
  2304. if (RESERVED_EVENTS2.hasOwnProperty(ev)) {
  2305. throw new Error('"' + ev.toString() + '" is a reserved event name');
  2306. }
  2307. args.unshift(ev);
  2308. if (this._opts.retries && !this.flags.fromQueue && !this.flags.volatile) {
  2309. this._addToQueue(args);
  2310. return this;
  2311. }
  2312. const packet = {
  2313. type: PacketType.EVENT,
  2314. data: args
  2315. };
  2316. packet.options = {};
  2317. packet.options.compress = this.flags.compress !== false;
  2318. if ("function" === typeof args[args.length - 1]) {
  2319. const id = this.ids++;
  2320. const ack = args.pop();
  2321. this._registerAckCallback(id, ack);
  2322. packet.id = id;
  2323. }
  2324. const isTransportWritable = (_b = (_a = this.io.engine) === null || _a === void 0 ? void 0 : _a.transport) === null || _b === void 0 ? void 0 : _b.writable;
  2325. const isConnected = this.connected && !((_c = this.io.engine) === null || _c === void 0 ? void 0 : _c._hasPingExpired());
  2326. const discardPacket = this.flags.volatile && !isTransportWritable;
  2327. if (discardPacket) {
  2328. } else if (isConnected) {
  2329. this.notifyOutgoingListeners(packet);
  2330. this.packet(packet);
  2331. } else {
  2332. this.sendBuffer.push(packet);
  2333. }
  2334. this.flags = {};
  2335. return this;
  2336. }
  2337. /**
  2338. * @private
  2339. */
  2340. _registerAckCallback(id, ack) {
  2341. var _a;
  2342. const timeout = (_a = this.flags.timeout) !== null && _a !== void 0 ? _a : this._opts.ackTimeout;
  2343. if (timeout === void 0) {
  2344. this.acks[id] = ack;
  2345. return;
  2346. }
  2347. const timer = this.io.setTimeoutFn(() => {
  2348. delete this.acks[id];
  2349. for (let i = 0; i < this.sendBuffer.length; i++) {
  2350. if (this.sendBuffer[i].id === id) {
  2351. this.sendBuffer.splice(i, 1);
  2352. }
  2353. }
  2354. ack.call(this, new Error("operation has timed out"));
  2355. }, timeout);
  2356. const fn = (...args) => {
  2357. this.io.clearTimeoutFn(timer);
  2358. ack.apply(this, args);
  2359. };
  2360. fn.withError = true;
  2361. this.acks[id] = fn;
  2362. }
  2363. /**
  2364. * Emits an event and waits for an acknowledgement
  2365. *
  2366. * @example
  2367. * // without timeout
  2368. * const response = await socket.emitWithAck("hello", "world");
  2369. *
  2370. * // with a specific timeout
  2371. * try {
  2372. * const response = await socket.timeout(1000).emitWithAck("hello", "world");
  2373. * } catch (err) {
  2374. * // the server did not acknowledge the event in the given delay
  2375. * }
  2376. *
  2377. * @return a Promise that will be fulfilled when the server acknowledges the event
  2378. */
  2379. emitWithAck(ev, ...args) {
  2380. return new Promise((resolve, reject) => {
  2381. const fn = (arg1, arg2) => {
  2382. return arg1 ? reject(arg1) : resolve(arg2);
  2383. };
  2384. fn.withError = true;
  2385. args.push(fn);
  2386. this.emit(ev, ...args);
  2387. });
  2388. }
  2389. /**
  2390. * Add the packet to the queue.
  2391. * @param args
  2392. * @private
  2393. */
  2394. _addToQueue(args) {
  2395. let ack;
  2396. if (typeof args[args.length - 1] === "function") {
  2397. ack = args.pop();
  2398. }
  2399. const packet = {
  2400. id: this._queueSeq++,
  2401. tryCount: 0,
  2402. pending: false,
  2403. args,
  2404. flags: Object.assign({ fromQueue: true }, this.flags)
  2405. };
  2406. args.push((err, ...responseArgs) => {
  2407. if (packet !== this._queue[0]) {
  2408. return;
  2409. }
  2410. const hasError = err !== null;
  2411. if (hasError) {
  2412. if (packet.tryCount > this._opts.retries) {
  2413. this._queue.shift();
  2414. if (ack) {
  2415. ack(err);
  2416. }
  2417. }
  2418. } else {
  2419. this._queue.shift();
  2420. if (ack) {
  2421. ack(null, ...responseArgs);
  2422. }
  2423. }
  2424. packet.pending = false;
  2425. return this._drainQueue();
  2426. });
  2427. this._queue.push(packet);
  2428. this._drainQueue();
  2429. }
  2430. /**
  2431. * Send the first packet of the queue, and wait for an acknowledgement from the server.
  2432. * @param force - whether to resend a packet that has not been acknowledged yet
  2433. *
  2434. * @private
  2435. */
  2436. _drainQueue(force = false) {
  2437. if (!this.connected || this._queue.length === 0) {
  2438. return;
  2439. }
  2440. const packet = this._queue[0];
  2441. if (packet.pending && !force) {
  2442. return;
  2443. }
  2444. packet.pending = true;
  2445. packet.tryCount++;
  2446. this.flags = packet.flags;
  2447. this.emit.apply(this, packet.args);
  2448. }
  2449. /**
  2450. * Sends a packet.
  2451. *
  2452. * @param packet
  2453. * @private
  2454. */
  2455. packet(packet) {
  2456. packet.nsp = this.nsp;
  2457. this.io._packet(packet);
  2458. }
  2459. /**
  2460. * Called upon engine `open`.
  2461. *
  2462. * @private
  2463. */
  2464. onopen() {
  2465. if (typeof this.auth == "function") {
  2466. this.auth((data) => {
  2467. this._sendConnectPacket(data);
  2468. });
  2469. } else {
  2470. this._sendConnectPacket(this.auth);
  2471. }
  2472. }
  2473. /**
  2474. * Sends a CONNECT packet to initiate the Socket.IO session.
  2475. *
  2476. * @param data
  2477. * @private
  2478. */
  2479. _sendConnectPacket(data) {
  2480. this.packet({
  2481. type: PacketType.CONNECT,
  2482. data: this._pid ? Object.assign({ pid: this._pid, offset: this._lastOffset }, data) : data
  2483. });
  2484. }
  2485. /**
  2486. * Called upon engine or manager `error`.
  2487. *
  2488. * @param err
  2489. * @private
  2490. */
  2491. onerror(err) {
  2492. if (!this.connected) {
  2493. this.emitReserved("connect_error", err);
  2494. }
  2495. }
  2496. /**
  2497. * Called upon engine `close`.
  2498. *
  2499. * @param reason
  2500. * @param description
  2501. * @private
  2502. */
  2503. onclose(reason, description) {
  2504. this.connected = false;
  2505. delete this.id;
  2506. this.emitReserved("disconnect", reason, description);
  2507. this._clearAcks();
  2508. }
  2509. /**
  2510. * Clears the acknowledgement handlers upon disconnection, since the client will never receive an acknowledgement from
  2511. * the server.
  2512. *
  2513. * @private
  2514. */
  2515. _clearAcks() {
  2516. Object.keys(this.acks).forEach((id) => {
  2517. const isBuffered = this.sendBuffer.some((packet) => String(packet.id) === id);
  2518. if (!isBuffered) {
  2519. const ack = this.acks[id];
  2520. delete this.acks[id];
  2521. if (ack.withError) {
  2522. ack.call(this, new Error("socket has been disconnected"));
  2523. }
  2524. }
  2525. });
  2526. }
  2527. /**
  2528. * Called with socket packet.
  2529. *
  2530. * @param packet
  2531. * @private
  2532. */
  2533. onpacket(packet) {
  2534. const sameNamespace = packet.nsp === this.nsp;
  2535. if (!sameNamespace)
  2536. return;
  2537. switch (packet.type) {
  2538. case PacketType.CONNECT:
  2539. if (packet.data && packet.data.sid) {
  2540. this.onconnect(packet.data.sid, packet.data.pid);
  2541. } else {
  2542. this.emitReserved("connect_error", new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));
  2543. }
  2544. break;
  2545. case PacketType.EVENT:
  2546. case PacketType.BINARY_EVENT:
  2547. this.onevent(packet);
  2548. break;
  2549. case PacketType.ACK:
  2550. case PacketType.BINARY_ACK:
  2551. this.onack(packet);
  2552. break;
  2553. case PacketType.DISCONNECT:
  2554. this.ondisconnect();
  2555. break;
  2556. case PacketType.CONNECT_ERROR:
  2557. this.destroy();
  2558. const err = new Error(packet.data.message);
  2559. err.data = packet.data.data;
  2560. this.emitReserved("connect_error", err);
  2561. break;
  2562. }
  2563. }
  2564. /**
  2565. * Called upon a server event.
  2566. *
  2567. * @param packet
  2568. * @private
  2569. */
  2570. onevent(packet) {
  2571. const args = packet.data || [];
  2572. if (null != packet.id) {
  2573. args.push(this.ack(packet.id));
  2574. }
  2575. if (this.connected) {
  2576. this.emitEvent(args);
  2577. } else {
  2578. this.receiveBuffer.push(Object.freeze(args));
  2579. }
  2580. }
  2581. emitEvent(args) {
  2582. if (this._anyListeners && this._anyListeners.length) {
  2583. const listeners = this._anyListeners.slice();
  2584. for (const listener of listeners) {
  2585. listener.apply(this, args);
  2586. }
  2587. }
  2588. super.emit.apply(this, args);
  2589. if (this._pid && args.length && typeof args[args.length - 1] === "string") {
  2590. this._lastOffset = args[args.length - 1];
  2591. }
  2592. }
  2593. /**
  2594. * Produces an ack callback to emit with an event.
  2595. *
  2596. * @private
  2597. */
  2598. ack(id) {
  2599. const self2 = this;
  2600. let sent = false;
  2601. return function(...args) {
  2602. if (sent)
  2603. return;
  2604. sent = true;
  2605. self2.packet({
  2606. type: PacketType.ACK,
  2607. id,
  2608. data: args
  2609. });
  2610. };
  2611. }
  2612. /**
  2613. * Called upon a server acknowledgement.
  2614. *
  2615. * @param packet
  2616. * @private
  2617. */
  2618. onack(packet) {
  2619. const ack = this.acks[packet.id];
  2620. if (typeof ack !== "function") {
  2621. return;
  2622. }
  2623. delete this.acks[packet.id];
  2624. if (ack.withError) {
  2625. packet.data.unshift(null);
  2626. }
  2627. ack.apply(this, packet.data);
  2628. }
  2629. /**
  2630. * Called upon server connect.
  2631. *
  2632. * @private
  2633. */
  2634. onconnect(id, pid) {
  2635. this.id = id;
  2636. this.recovered = pid && this._pid === pid;
  2637. this._pid = pid;
  2638. this.connected = true;
  2639. this.emitBuffered();
  2640. this.emitReserved("connect");
  2641. this._drainQueue(true);
  2642. }
  2643. /**
  2644. * Emit buffered events (received and emitted).
  2645. *
  2646. * @private
  2647. */
  2648. emitBuffered() {
  2649. this.receiveBuffer.forEach((args) => this.emitEvent(args));
  2650. this.receiveBuffer = [];
  2651. this.sendBuffer.forEach((packet) => {
  2652. this.notifyOutgoingListeners(packet);
  2653. this.packet(packet);
  2654. });
  2655. this.sendBuffer = [];
  2656. }
  2657. /**
  2658. * Called upon server disconnect.
  2659. *
  2660. * @private
  2661. */
  2662. ondisconnect() {
  2663. this.destroy();
  2664. this.onclose("io server disconnect");
  2665. }
  2666. /**
  2667. * Called upon forced client/server side disconnections,
  2668. * this method ensures the manager stops tracking us and
  2669. * that reconnections don't get triggered for this.
  2670. *
  2671. * @private
  2672. */
  2673. destroy() {
  2674. if (this.subs) {
  2675. this.subs.forEach((subDestroy) => subDestroy());
  2676. this.subs = void 0;
  2677. }
  2678. this.io["_destroy"](this);
  2679. }
  2680. /**
  2681. * Disconnects the socket manually. In that case, the socket will not try to reconnect.
  2682. *
  2683. * If this is the last active Socket instance of the {@link Manager}, the low-level connection will be closed.
  2684. *
  2685. * @example
  2686. * const socket = io();
  2687. *
  2688. * socket.on("disconnect", (reason) => {
  2689. * // console.log(reason); prints "io client disconnect"
  2690. * });
  2691. *
  2692. * socket.disconnect();
  2693. *
  2694. * @return self
  2695. */
  2696. disconnect() {
  2697. if (this.connected) {
  2698. this.packet({ type: PacketType.DISCONNECT });
  2699. }
  2700. this.destroy();
  2701. if (this.connected) {
  2702. this.onclose("io client disconnect");
  2703. }
  2704. return this;
  2705. }
  2706. /**
  2707. * Alias for {@link disconnect()}.
  2708. *
  2709. * @return self
  2710. */
  2711. close() {
  2712. return this.disconnect();
  2713. }
  2714. /**
  2715. * Sets the compress flag.
  2716. *
  2717. * @example
  2718. * socket.compress(false).emit("hello");
  2719. *
  2720. * @param compress - if `true`, compresses the sending data
  2721. * @return self
  2722. */
  2723. compress(compress) {
  2724. this.flags.compress = compress;
  2725. return this;
  2726. }
  2727. /**
  2728. * Sets a modifier for a subsequent event emission that the event message will be dropped when this socket is not
  2729. * ready to send messages.
  2730. *
  2731. * @example
  2732. * socket.volatile.emit("hello"); // the server may or may not receive it
  2733. *
  2734. * @returns self
  2735. */
  2736. get volatile() {
  2737. this.flags.volatile = true;
  2738. return this;
  2739. }
  2740. /**
  2741. * Sets a modifier for a subsequent event emission that the callback will be called with an error when the
  2742. * given number of milliseconds have elapsed without an acknowledgement from the server:
  2743. *
  2744. * @example
  2745. * socket.timeout(5000).emit("my-event", (err) => {
  2746. * if (err) {
  2747. * // the server did not acknowledge the event in the given delay
  2748. * }
  2749. * });
  2750. *
  2751. * @returns self
  2752. */
  2753. timeout(timeout) {
  2754. this.flags.timeout = timeout;
  2755. return this;
  2756. }
  2757. /**
  2758. * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
  2759. * callback.
  2760. *
  2761. * @example
  2762. * socket.onAny((event, ...args) => {
  2763. * console.log(`got ${event}`);
  2764. * });
  2765. *
  2766. * @param listener
  2767. */
  2768. onAny(listener) {
  2769. this._anyListeners = this._anyListeners || [];
  2770. this._anyListeners.push(listener);
  2771. return this;
  2772. }
  2773. /**
  2774. * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
  2775. * callback. The listener is added to the beginning of the listeners array.
  2776. *
  2777. * @example
  2778. * socket.prependAny((event, ...args) => {
  2779. * console.log(`got event ${event}`);
  2780. * });
  2781. *
  2782. * @param listener
  2783. */
  2784. prependAny(listener) {
  2785. this._anyListeners = this._anyListeners || [];
  2786. this._anyListeners.unshift(listener);
  2787. return this;
  2788. }
  2789. /**
  2790. * Removes the listener that will be fired when any event is emitted.
  2791. *
  2792. * @example
  2793. * const catchAllListener = (event, ...args) => {
  2794. * console.log(`got event ${event}`);
  2795. * }
  2796. *
  2797. * socket.onAny(catchAllListener);
  2798. *
  2799. * // remove a specific listener
  2800. * socket.offAny(catchAllListener);
  2801. *
  2802. * // or remove all listeners
  2803. * socket.offAny();
  2804. *
  2805. * @param listener
  2806. */
  2807. offAny(listener) {
  2808. if (!this._anyListeners) {
  2809. return this;
  2810. }
  2811. if (listener) {
  2812. const listeners = this._anyListeners;
  2813. for (let i = 0; i < listeners.length; i++) {
  2814. if (listener === listeners[i]) {
  2815. listeners.splice(i, 1);
  2816. return this;
  2817. }
  2818. }
  2819. } else {
  2820. this._anyListeners = [];
  2821. }
  2822. return this;
  2823. }
  2824. /**
  2825. * Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,
  2826. * e.g. to remove listeners.
  2827. */
  2828. listenersAny() {
  2829. return this._anyListeners || [];
  2830. }
  2831. /**
  2832. * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
  2833. * callback.
  2834. *
  2835. * Note: acknowledgements sent to the server are not included.
  2836. *
  2837. * @example
  2838. * socket.onAnyOutgoing((event, ...args) => {
  2839. * console.log(`sent event ${event}`);
  2840. * });
  2841. *
  2842. * @param listener
  2843. */
  2844. onAnyOutgoing(listener) {
  2845. this._anyOutgoingListeners = this._anyOutgoingListeners || [];
  2846. this._anyOutgoingListeners.push(listener);
  2847. return this;
  2848. }
  2849. /**
  2850. * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
  2851. * callback. The listener is added to the beginning of the listeners array.
  2852. *
  2853. * Note: acknowledgements sent to the server are not included.
  2854. *
  2855. * @example
  2856. * socket.prependAnyOutgoing((event, ...args) => {
  2857. * console.log(`sent event ${event}`);
  2858. * });
  2859. *
  2860. * @param listener
  2861. */
  2862. prependAnyOutgoing(listener) {
  2863. this._anyOutgoingListeners = this._anyOutgoingListeners || [];
  2864. this._anyOutgoingListeners.unshift(listener);
  2865. return this;
  2866. }
  2867. /**
  2868. * Removes the listener that will be fired when any event is emitted.
  2869. *
  2870. * @example
  2871. * const catchAllListener = (event, ...args) => {
  2872. * console.log(`sent event ${event}`);
  2873. * }
  2874. *
  2875. * socket.onAnyOutgoing(catchAllListener);
  2876. *
  2877. * // remove a specific listener
  2878. * socket.offAnyOutgoing(catchAllListener);
  2879. *
  2880. * // or remove all listeners
  2881. * socket.offAnyOutgoing();
  2882. *
  2883. * @param [listener] - the catch-all listener (optional)
  2884. */
  2885. offAnyOutgoing(listener) {
  2886. if (!this._anyOutgoingListeners) {
  2887. return this;
  2888. }
  2889. if (listener) {
  2890. const listeners = this._anyOutgoingListeners;
  2891. for (let i = 0; i < listeners.length; i++) {
  2892. if (listener === listeners[i]) {
  2893. listeners.splice(i, 1);
  2894. return this;
  2895. }
  2896. }
  2897. } else {
  2898. this._anyOutgoingListeners = [];
  2899. }
  2900. return this;
  2901. }
  2902. /**
  2903. * Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,
  2904. * e.g. to remove listeners.
  2905. */
  2906. listenersAnyOutgoing() {
  2907. return this._anyOutgoingListeners || [];
  2908. }
  2909. /**
  2910. * Notify the listeners for each packet sent
  2911. *
  2912. * @param packet
  2913. *
  2914. * @private
  2915. */
  2916. notifyOutgoingListeners(packet) {
  2917. if (this._anyOutgoingListeners && this._anyOutgoingListeners.length) {
  2918. const listeners = this._anyOutgoingListeners.slice();
  2919. for (const listener of listeners) {
  2920. listener.apply(this, packet.data);
  2921. }
  2922. }
  2923. }
  2924. };
  2925. // ../../../../Newweb/starter/node_modules/socket.io-client/build/esm/contrib/backo2.js
  2926. function Backoff(opts) {
  2927. opts = opts || {};
  2928. this.ms = opts.min || 100;
  2929. this.max = opts.max || 1e4;
  2930. this.factor = opts.factor || 2;
  2931. this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;
  2932. this.attempts = 0;
  2933. }
  2934. Backoff.prototype.duration = function() {
  2935. var ms = this.ms * Math.pow(this.factor, this.attempts++);
  2936. if (this.jitter) {
  2937. var rand = Math.random();
  2938. var deviation = Math.floor(rand * this.jitter * ms);
  2939. ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;
  2940. }
  2941. return Math.min(ms, this.max) | 0;
  2942. };
  2943. Backoff.prototype.reset = function() {
  2944. this.attempts = 0;
  2945. };
  2946. Backoff.prototype.setMin = function(min) {
  2947. this.ms = min;
  2948. };
  2949. Backoff.prototype.setMax = function(max) {
  2950. this.max = max;
  2951. };
  2952. Backoff.prototype.setJitter = function(jitter) {
  2953. this.jitter = jitter;
  2954. };
  2955. // ../../../../Newweb/starter/node_modules/socket.io-client/build/esm/manager.js
  2956. var Manager = class extends Emitter {
  2957. constructor(uri, opts) {
  2958. var _a;
  2959. super();
  2960. this.nsps = {};
  2961. this.subs = [];
  2962. if (uri && "object" === typeof uri) {
  2963. opts = uri;
  2964. uri = void 0;
  2965. }
  2966. opts = opts || {};
  2967. opts.path = opts.path || "/socket.io";
  2968. this.opts = opts;
  2969. installTimerFunctions(this, opts);
  2970. this.reconnection(opts.reconnection !== false);
  2971. this.reconnectionAttempts(opts.reconnectionAttempts || Infinity);
  2972. this.reconnectionDelay(opts.reconnectionDelay || 1e3);
  2973. this.reconnectionDelayMax(opts.reconnectionDelayMax || 5e3);
  2974. this.randomizationFactor((_a = opts.randomizationFactor) !== null && _a !== void 0 ? _a : 0.5);
  2975. this.backoff = new Backoff({
  2976. min: this.reconnectionDelay(),
  2977. max: this.reconnectionDelayMax(),
  2978. jitter: this.randomizationFactor()
  2979. });
  2980. this.timeout(null == opts.timeout ? 2e4 : opts.timeout);
  2981. this._readyState = "closed";
  2982. this.uri = uri;
  2983. const _parser = opts.parser || esm_exports;
  2984. this.encoder = new _parser.Encoder();
  2985. this.decoder = new _parser.Decoder();
  2986. this._autoConnect = opts.autoConnect !== false;
  2987. if (this._autoConnect)
  2988. this.open();
  2989. }
  2990. reconnection(v) {
  2991. if (!arguments.length)
  2992. return this._reconnection;
  2993. this._reconnection = !!v;
  2994. if (!v) {
  2995. this.skipReconnect = true;
  2996. }
  2997. return this;
  2998. }
  2999. reconnectionAttempts(v) {
  3000. if (v === void 0)
  3001. return this._reconnectionAttempts;
  3002. this._reconnectionAttempts = v;
  3003. return this;
  3004. }
  3005. reconnectionDelay(v) {
  3006. var _a;
  3007. if (v === void 0)
  3008. return this._reconnectionDelay;
  3009. this._reconnectionDelay = v;
  3010. (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMin(v);
  3011. return this;
  3012. }
  3013. randomizationFactor(v) {
  3014. var _a;
  3015. if (v === void 0)
  3016. return this._randomizationFactor;
  3017. this._randomizationFactor = v;
  3018. (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setJitter(v);
  3019. return this;
  3020. }
  3021. reconnectionDelayMax(v) {
  3022. var _a;
  3023. if (v === void 0)
  3024. return this._reconnectionDelayMax;
  3025. this._reconnectionDelayMax = v;
  3026. (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMax(v);
  3027. return this;
  3028. }
  3029. timeout(v) {
  3030. if (!arguments.length)
  3031. return this._timeout;
  3032. this._timeout = v;
  3033. return this;
  3034. }
  3035. /**
  3036. * Starts trying to reconnect if reconnection is enabled and we have not
  3037. * started reconnecting yet
  3038. *
  3039. * @private
  3040. */
  3041. maybeReconnectOnOpen() {
  3042. if (!this._reconnecting && this._reconnection && this.backoff.attempts === 0) {
  3043. this.reconnect();
  3044. }
  3045. }
  3046. /**
  3047. * Sets the current transport `socket`.
  3048. *
  3049. * @param {Function} fn - optional, callback
  3050. * @return self
  3051. * @public
  3052. */
  3053. open(fn) {
  3054. if (~this._readyState.indexOf("open"))
  3055. return this;
  3056. this.engine = new Socket(this.uri, this.opts);
  3057. const socket = this.engine;
  3058. const self2 = this;
  3059. this._readyState = "opening";
  3060. this.skipReconnect = false;
  3061. const openSubDestroy = on(socket, "open", function() {
  3062. self2.onopen();
  3063. fn && fn();
  3064. });
  3065. const onError = (err) => {
  3066. this.cleanup();
  3067. this._readyState = "closed";
  3068. this.emitReserved("error", err);
  3069. if (fn) {
  3070. fn(err);
  3071. } else {
  3072. this.maybeReconnectOnOpen();
  3073. }
  3074. };
  3075. const errorSub = on(socket, "error", onError);
  3076. if (false !== this._timeout) {
  3077. const timeout = this._timeout;
  3078. const timer = this.setTimeoutFn(() => {
  3079. openSubDestroy();
  3080. onError(new Error("timeout"));
  3081. socket.close();
  3082. }, timeout);
  3083. if (this.opts.autoUnref) {
  3084. timer.unref();
  3085. }
  3086. this.subs.push(() => {
  3087. this.clearTimeoutFn(timer);
  3088. });
  3089. }
  3090. this.subs.push(openSubDestroy);
  3091. this.subs.push(errorSub);
  3092. return this;
  3093. }
  3094. /**
  3095. * Alias for open()
  3096. *
  3097. * @return self
  3098. * @public
  3099. */
  3100. connect(fn) {
  3101. return this.open(fn);
  3102. }
  3103. /**
  3104. * Called upon transport open.
  3105. *
  3106. * @private
  3107. */
  3108. onopen() {
  3109. this.cleanup();
  3110. this._readyState = "open";
  3111. this.emitReserved("open");
  3112. const socket = this.engine;
  3113. this.subs.push(
  3114. on(socket, "ping", this.onping.bind(this)),
  3115. on(socket, "data", this.ondata.bind(this)),
  3116. on(socket, "error", this.onerror.bind(this)),
  3117. on(socket, "close", this.onclose.bind(this)),
  3118. // @ts-ignore
  3119. on(this.decoder, "decoded", this.ondecoded.bind(this))
  3120. );
  3121. }
  3122. /**
  3123. * Called upon a ping.
  3124. *
  3125. * @private
  3126. */
  3127. onping() {
  3128. this.emitReserved("ping");
  3129. }
  3130. /**
  3131. * Called with data.
  3132. *
  3133. * @private
  3134. */
  3135. ondata(data) {
  3136. try {
  3137. this.decoder.add(data);
  3138. } catch (e) {
  3139. this.onclose("parse error", e);
  3140. }
  3141. }
  3142. /**
  3143. * Called when parser fully decodes a packet.
  3144. *
  3145. * @private
  3146. */
  3147. ondecoded(packet) {
  3148. nextTick(() => {
  3149. this.emitReserved("packet", packet);
  3150. }, this.setTimeoutFn);
  3151. }
  3152. /**
  3153. * Called upon socket error.
  3154. *
  3155. * @private
  3156. */
  3157. onerror(err) {
  3158. this.emitReserved("error", err);
  3159. }
  3160. /**
  3161. * Creates a new socket for the given `nsp`.
  3162. *
  3163. * @return {Socket}
  3164. * @public
  3165. */
  3166. socket(nsp, opts) {
  3167. let socket = this.nsps[nsp];
  3168. if (!socket) {
  3169. socket = new Socket2(this, nsp, opts);
  3170. this.nsps[nsp] = socket;
  3171. } else if (this._autoConnect && !socket.active) {
  3172. socket.connect();
  3173. }
  3174. return socket;
  3175. }
  3176. /**
  3177. * Called upon a socket close.
  3178. *
  3179. * @param socket
  3180. * @private
  3181. */
  3182. _destroy(socket) {
  3183. const nsps = Object.keys(this.nsps);
  3184. for (const nsp of nsps) {
  3185. const socket2 = this.nsps[nsp];
  3186. if (socket2.active) {
  3187. return;
  3188. }
  3189. }
  3190. this._close();
  3191. }
  3192. /**
  3193. * Writes a packet.
  3194. *
  3195. * @param packet
  3196. * @private
  3197. */
  3198. _packet(packet) {
  3199. const encodedPackets = this.encoder.encode(packet);
  3200. for (let i = 0; i < encodedPackets.length; i++) {
  3201. this.engine.write(encodedPackets[i], packet.options);
  3202. }
  3203. }
  3204. /**
  3205. * Clean up transport subscriptions and packet buffer.
  3206. *
  3207. * @private
  3208. */
  3209. cleanup() {
  3210. this.subs.forEach((subDestroy) => subDestroy());
  3211. this.subs.length = 0;
  3212. this.decoder.destroy();
  3213. }
  3214. /**
  3215. * Close the current socket.
  3216. *
  3217. * @private
  3218. */
  3219. _close() {
  3220. this.skipReconnect = true;
  3221. this._reconnecting = false;
  3222. this.onclose("forced close");
  3223. }
  3224. /**
  3225. * Alias for close()
  3226. *
  3227. * @private
  3228. */
  3229. disconnect() {
  3230. return this._close();
  3231. }
  3232. /**
  3233. * Called when:
  3234. *
  3235. * - the low-level engine is closed
  3236. * - the parser encountered a badly formatted packet
  3237. * - all sockets are disconnected
  3238. *
  3239. * @private
  3240. */
  3241. onclose(reason, description) {
  3242. var _a;
  3243. this.cleanup();
  3244. (_a = this.engine) === null || _a === void 0 ? void 0 : _a.close();
  3245. this.backoff.reset();
  3246. this._readyState = "closed";
  3247. this.emitReserved("close", reason, description);
  3248. if (this._reconnection && !this.skipReconnect) {
  3249. this.reconnect();
  3250. }
  3251. }
  3252. /**
  3253. * Attempt a reconnection.
  3254. *
  3255. * @private
  3256. */
  3257. reconnect() {
  3258. if (this._reconnecting || this.skipReconnect)
  3259. return this;
  3260. const self2 = this;
  3261. if (this.backoff.attempts >= this._reconnectionAttempts) {
  3262. this.backoff.reset();
  3263. this.emitReserved("reconnect_failed");
  3264. this._reconnecting = false;
  3265. } else {
  3266. const delay = this.backoff.duration();
  3267. this._reconnecting = true;
  3268. const timer = this.setTimeoutFn(() => {
  3269. if (self2.skipReconnect)
  3270. return;
  3271. this.emitReserved("reconnect_attempt", self2.backoff.attempts);
  3272. if (self2.skipReconnect)
  3273. return;
  3274. self2.open((err) => {
  3275. if (err) {
  3276. self2._reconnecting = false;
  3277. self2.reconnect();
  3278. this.emitReserved("reconnect_error", err);
  3279. } else {
  3280. self2.onreconnect();
  3281. }
  3282. });
  3283. }, delay);
  3284. if (this.opts.autoUnref) {
  3285. timer.unref();
  3286. }
  3287. this.subs.push(() => {
  3288. this.clearTimeoutFn(timer);
  3289. });
  3290. }
  3291. }
  3292. /**
  3293. * Called upon successful reconnect.
  3294. *
  3295. * @private
  3296. */
  3297. onreconnect() {
  3298. const attempt = this.backoff.attempts;
  3299. this._reconnecting = false;
  3300. this.backoff.reset();
  3301. this.emitReserved("reconnect", attempt);
  3302. }
  3303. };
  3304. // ../../../../Newweb/starter/node_modules/socket.io-client/build/esm/index.js
  3305. var cache = {};
  3306. function lookup2(uri, opts) {
  3307. if (typeof uri === "object") {
  3308. opts = uri;
  3309. uri = void 0;
  3310. }
  3311. opts = opts || {};
  3312. const parsed = url(uri, opts.path || "/socket.io");
  3313. const source = parsed.source;
  3314. const id = parsed.id;
  3315. const path = parsed.path;
  3316. const sameNamespace = cache[id] && path in cache[id]["nsps"];
  3317. const newConnection = opts.forceNew || opts["force new connection"] || false === opts.multiplex || sameNamespace;
  3318. let io;
  3319. if (newConnection) {
  3320. io = new Manager(source, opts);
  3321. } else {
  3322. if (!cache[id]) {
  3323. cache[id] = new Manager(source, opts);
  3324. }
  3325. io = cache[id];
  3326. }
  3327. if (parsed.query && !opts.query) {
  3328. opts.query = parsed.queryKey;
  3329. }
  3330. return io.socket(parsed.path, opts);
  3331. }
  3332. Object.assign(lookup2, {
  3333. Manager,
  3334. Socket: Socket2,
  3335. io: lookup2,
  3336. connect: lookup2
  3337. });
  3338. export {
  3339. Manager,
  3340. Socket2 as Socket,
  3341. lookup2 as connect,
  3342. lookup2 as default,
  3343. lookup2 as io,
  3344. protocol3 as protocol
  3345. };
  3346. //# sourceMappingURL=socket__io-client.js.map