@danidoble/webserial 4.4.7 → 4.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/pinpax.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./kernel-Di_61btz.cjs"),i=require("./relay-BG7CetDU.cjs");class p extends c.Kernel{__pinpax__={server:"DEV",businessId:null,encryptionKey:null,apiKey:null,asyncResponses:{voucher:null,sale:null},waiting:{voucher:!1,sale:!1,sale_init:"idle",sale_login:"idle"}};constructor({filters:t=null,config_port:e={baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:s=1,device_listen_on_channel:a=1,socket:n=!1}={filters:null,config_port:{baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:1,device_listen_on_channel:1,socket:!1}){if(super({filters:t,config_port:e,no_device:s,device_listen_on_channel:a,socket:n}),this.__internal__.device.type="pinpax",c.Devices.getCustom(this.typeDevice,s))throw new Error(`Device ${this.typeDevice} ${s} already exists`);this.__internal__.time.response_connection=4e3,this.__internal__.time.response_general=3e3,this.__internal__.serial.delay_first_connection=1e3,this.__internal__.serial.response.replacer="",this.__internal__.serial.response.limiter=`\r
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./kernel-DHq-6p9p.cjs"),i=require("./relay-BG7CetDU.cjs");class p extends c.Kernel{__pinpax__={server:"DEV",businessId:null,encryptionKey:null,apiKey:null,asyncResponses:{voucher:null,sale:null},waiting:{voucher:!1,sale:!1,sale_init:"idle",sale_login:"idle"}};constructor({filters:t=null,config_port:e={baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:s=1,device_listen_on_channel:a=1,socket:n=!1}={filters:null,config_port:{baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:1,device_listen_on_channel:1,socket:!1}){if(super({filters:t,config_port:e,no_device:s,device_listen_on_channel:a,socket:n}),this.__internal__.device.type="pinpax",c.Devices.getCustom(this.typeDevice,s))throw new Error(`Device ${this.typeDevice} ${s} already exists`);this.__internal__.time.response_connection=4e3,this.__internal__.time.response_general=3e3,this.__internal__.serial.delay_first_connection=1e3,this.__internal__.serial.response.replacer="",this.__internal__.serial.response.limiter=`\r
2
2
  `,this.#i(),c.Devices.add(this),this.getResponseAsString()}#i(){const t=["buttons-status","init-app","connectMessage","voucher","info","keep-alive","reset-app","get-config","payment","error","refund","login"];for(const e of t)this.serialRegisterAvailableListener(e)}set businessId(t){this.__pinpax__.businessId=t}get businessId(){return this.__pinpax__.businessId}set encryptionKey(t){this.__pinpax__.encryptionKey=t}get encryptionKey(){return this.__pinpax__.encryptionKey}set apiKey(t){this.__pinpax__.apiKey=t}get apiKey(){return this.__pinpax__.apiKey}set server(t){this.__pinpax__.server=t}get server(){return this.__pinpax__.server}serialMessage(t){let e=null;try{e=JSON.parse(t),e.request||(e.request=this.lastAction),e.name||(e.name=this.lastAction)}catch(s){console.error("Error parsing response",s,t),this.dispatch("serial:message",t);return}switch(e.response){case"INIT":this.dispatch("init",{name:"INIT",request:this.lastAction,status:"ok"}),this.__pinpax__.waiting.sale_init==="waiting"&&(this.__pinpax__.waiting.sale_init="received");break;case"INITAPP":this.dispatch("init-app",{name:"INITAPP",request:this.lastAction,status:"started"}),this.__pinpax__.waiting.sale_init==="waiting"?this.__pinpax__.waiting.sale_init="received":this.#n().then(()=>{});break;case"CONNECT":this.dispatch("connectMessage",{name:"CONNECT",request:this.lastAction,status:"connected"}),this.#r().then(()=>{});break;case"LOGIN":e.name||(e.name="LOGIN"),this.__pinpax__.waiting.sale_login==="waiting"&&(this.__pinpax__.waiting.sale_login="received"),this.dispatch("login",e);break;case"LASTVOUCHER":e.name||(e.name="LASTVOUCHER"),this.dispatch("voucher",e),this.__pinpax__.waiting.voucher&&(this.__pinpax__.asyncResponses.voucher=e,this.__pinpax__.waiting.voucher=!1);break;case"DEVICEINFO":e.name||(e.name="DEVICEINFO"),this.dispatch("info",e);break;case"KEEPALIVE":this.dispatch("keep-alive",{name:"KEEPALIVE",request:this.lastAction,status:"alive"});break;case"RESETAPP":this.dispatch("reset-app",{name:"RESETAPP",request:this.lastAction,status:"accepted"});break;case"GETCONFIG":e.name||(e.name="GETCONFIG"),this.dispatch("get-config",e);break;case"HIDEBUTTONS":this.dispatch("buttons-status",{name:"HIDEBUTTONS",request:this.lastAction,hidden:!0});break;case"SHOWBUTTONS":this.dispatch("buttons-status",{name:"SHOWBUTTONS",request:this.lastAction,hidden:!1});break;case"PAYMENT_PROCESS":e.name||(e.name="PAYMENT_PROCESS"),this.dispatch("payment",{name:"PAYMENT_PROCESS",request:this.lastAction,status:"starting",amount:e.amount,reference:e.referecence});break;case"INSERT_CARD":this.dispatch("payment",{name:"INSERT_CARD",request:this.lastAction,status:"insert card"});break;case"CARD_DATA":e.name||(e.name="CARD_DATA"),this.dispatch("payment",{name:"CARD_DATA",request:this.lastAction,status:"card data",amount:e.amount,cardHolderName:e.cardHolderName,ccMark:e.ccMark,ccType:e.ccType,currency:e.currency,maskedPan:e.maskedPan,readingType:e.readingType});break;case"MERCHANT":e.name||(e.name="MERCHANT"),this.dispatch("payment",{request:this.lastAction,status:"merchant",afiliation:e.afiliation,alias:e.alias,amountCashBackCommission:e.amountCashBackCommission,currency:e.currency,description:e.description,hasCashBack:e.hasCashBack,limitCashBackAmount:e.limitCashBackAmount,merchant:e.merchant,months:e.months,name:e.name});break;case"TRANSACTION_RESULT":e.name||(e.name="TRANSACTION_RESULT"),this.#o({status:"result",approved:e.approved,acquirer:e.acquirer,address:e.address,amount:e.amount,amountCashback:e.amountCashback,appIDLabel:e.appIDLabel,appId:e.appId,arqc:e.arqc,auth:e.auth,ccBin:e.ccBin,ccExpirationDate:e.ccExpirationDate,ccName:e.ccName,ccNumber:e.ccNumber,ccType:e.ccType,comissionCashback:e.comissionCashback,currency:e.currency,date:e.date,errorCode:e.errorCode,errorDescription:e.errorDescription,folio:e.folio,id:e.id,merchantName:e.merchantName,msiLabel:e.msiLabel,operation:e.operation,pin:e.pin,qps:e.qps,reference:e.reference,response:e.response,source:e.source,sourceLabel:e.sourceLabel,time:e.time});break;case"ERROR":e.name||(e.name="ERROR"),this.__pinpax__.waiting.sale&&(this.__pinpax__.asyncResponses.sale={status:"error",approved:!1,response:e}),this.dispatch("error",{name:"ERROR",request:this.lastAction,status:"error",response:e}),this.dispatch("payment",{name:"ERROR",request:this.lastAction,status:"error",response:e});break;case"CHECKINTERNET":this.dispatch("network",{name:"CHECKINTERNET",request:this.lastAction,hasInternet:e.internet,quality:e.quality});break;case"REFUND":this.dispatch("refund",{name:"ERROR",request:this.lastAction,status:"refund",response:e});break}this.dispatch("serial:message",e)}serialSetConnectionConstant(){return i.s.connection()}softReload(){super.softReload(),this.__pinpax__.waiting.sale=!1,this.__pinpax__.waiting.voucher=!1,this.__pinpax__.asyncResponses.sale=null,this.__pinpax__.asyncResponses.voucher=null}async sendCustomCode(t={}){if(typeof t!="object")throw new Error("Invalid object");if(t.constructor!==Object)throw new Error("Invalid object");if(Object.keys(t).length===0)throw new Error("Empty object");if(t.action===void 0||t.action===null)throw new Error("Invalid object add action");const e=JSON.stringify(t),s=this.parseStringToBytes(e,`\r
3
3
  `);await this.appendToQueue(this.stringArrayToUint8Array(s),"custom")}async connectMessage(){await this.appendToQueue(i.s.connect(),"connect:message")}async#e(){if(this.isDisconnected)throw new Error("Device is disconnected");return this.queue.length===0?!0:new Promise(t=>{const e=setInterval(()=>{this.queue.length===0&&(clearInterval(e),t(!0))},500)})}async#t({type:t="production"}={}){const e=i.s.readQR({type:t});return await this.appendToQueue(e,"read-qr")}async#s(){await this.appendToQueue(i.s.forceHide(),"force-hide")}async#a(){await this.appendToQueue(i.s.forceShow(),"force-show")}async#n(){await this.connectMessage()}async#r(){await this.hideButtons()}#o(t){this.dispatch("payment",t),this.__pinpax__.waiting.sale&&(this.__pinpax__.asyncResponses.sale=t)}cancelSaleRequestInProcess(){this.__pinpax__.waiting.sale&&(this.__pinpax__.asyncResponses.sale={status:"error",approved:!1,response:{}})}async#c(){return new Promise((t,e)=>{const s=setTimeout(()=>{this.__pinpax__.waiting.sale_login==="waiting"&&(this.__pinpax__.waiting.sale_login="timeout",e(new Error("Login timeout")))},1e4),a=setInterval(()=>{this.__pinpax__.waiting.sale_login==="received"&&(clearTimeout(s),clearInterval(a),t(!0))},100)})}async#p(){return new Promise((t,e)=>{const s=setTimeout(()=>{this.__pinpax__.waiting.sale_init==="waiting"&&(this.__pinpax__.waiting.sale_init="timeout",e(new Error("Init timeout")))},1e4),a=setInterval(()=>{this.__pinpax__.waiting.sale_init==="received"&&(clearTimeout(s),clearInterval(a),t(!0))},100)})}async makeSale({amount:t=0,reference:e=null}={amount:0,reference:null}){if(this.isDisconnected)throw new Error("Device is disconnected");if(this.__pinpax__.waiting.sale)throw new Error("Already waiting for sale response");const s=i.s.makeSale({amount:t,reference:e});this.__pinpax__.waiting.sale=!0,this.__pinpax__.asyncResponses.sale=null,this.queue.length>0&&await this.#e();let a=!1;try{this.__pinpax__.waiting.sale_login="waiting",await this.login(),await this.#c(),this.__pinpax__.waiting.sale_login="idle",this.__pinpax__.waiting.sale_init="waiting",await this.init(),await this.#p(),this.__pinpax__.waiting.sale_init="idle"}catch(n){a=!0,this.__pinpax__.waiting.sale_login="idle",this.__pinpax__.waiting.sale_init="idle",this.__pinpax__.waiting.sale=!1,this.dispatch("error",{name:"ERROR",request:this.lastAction,status:"error",response:"Error during login/init before sale",error:n})}return a?!1:(await this.appendToQueue(s,"make-sale"),new Promise(n=>{const r=setInterval(()=>{if(this.__pinpax__.asyncResponses.sale){const o=this.__pinpax__.asyncResponses.sale;this.__pinpax__.asyncResponses.sale=null,this.__pinpax__.waiting.sale=!1,clearInterval(r),n(o.approved)}},100)}))}async getVoucher({folio:t=null}={}){if(this.isDisconnected)throw new Error("Device is disconnected");if(this.__pinpax__.waiting.voucher)throw new Error("Already waiting for voucher");if(!t)throw new Error("Folio is required");this.__pinpax__.waiting.voucher=!0,this.__pinpax__.asyncResponses.voucher=null;const e=i.s.getVoucher({folio:t});return this.queue.length>0&&await this.#e(),await this.appendToQueue(e,"get-voucher"),new Promise((s,a)=>{const n=setTimeout(()=>{this.__pinpax__.waiting.voucher=!1,a("Timeout")},1e4),r=setInterval(()=>{if(this.__pinpax__.asyncResponses.voucher){const o=this.__pinpax__.asyncResponses.voucher;this.__pinpax__.asyncResponses.voucher=null,this.__pinpax__.waiting.voucher=!1,clearInterval(r),clearTimeout(n),s(o.voucher)}},100)})}async info(){await this.appendToQueue(i.s.info(),"info")}async keepAlive(){await this.appendToQueue(i.s.keepAlive(),"keep-alive")}async restartApp(){await this.appendToQueue(i.s.restartApp(),"reset-app")}async getConfig(){return await this.appendToQueue(i.s.getConfig(),"get-config")}async hideButtons(){return await this.appendToQueue(i.s.hideButtons(),"hide-buttons"),await this.#s()}async showButtons(){return await this.appendToQueue(i.s.showButtons(),"show-buttons"),await this.#a()}async demo(){return console.warn("RUNNING DEMO APP, BE CAREFUL"),await this.appendToQueue(i.s.demo(),"demo")}async refund({amount:t=0,folio:e=null,auth:s=null}={}){return await this.appendToQueue(i.s.refund({amount:t,folio:e,auth:s}),"refund")}async readProductionQR(){return await this.#t({type:"production"})}async readQualityAssuranceQR(){return this.#t({type:"QA"})}async exit(){return await this.appendToQueue(i.s.exit(),"exit-app")}async init(){await this.appendToQueue(i.s.init(),"init-app")}async login(){if(!this.apiKey||!this.businessId||!this.encryptionKey||!this.server)throw new Error("Invalid data to login check apiKey, businessId, encryptionKey, server");const t=JSON.stringify({action:"LOGIN_MIT",server:this.__pinpax__.server,business_id:this.__pinpax__.businessId,encryption_key:this.__pinpax__.encryptionKey,api_key:this.__pinpax__.apiKey}),e=this.parseStringToBytes(t,`\r
4
4
  `);await this.appendToQueue(e,"login")}async stop(){await this.appendToQueue(i.s.stop(),"stop")}async verifyNetwork(){await this.appendToQueue(i.s.verifyNetwork(),"verify-network")}}exports.PinPax=p;
package/dist/pinpax.js CHANGED
@@ -1,4 +1,4 @@
1
- import { K as p, D as c } from "./kernel-Cm9N-fc9.js";
1
+ import { K as p, D as c } from "./kernel-BRG-vva2.js";
2
2
  import { s as i } from "./relay-C71zVBZv.js";
3
3
  class l extends p {
4
4
  __pinpax__ = {
package/dist/relay.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./kernel-Di_61btz.cjs"),a=require("./relay-BG7CetDU.cjs");class r extends n.Kernel{constructor({filters:t=null,config_port:e,no_device:s=1,socket:i=!1}={}){if(super({filters:t,config_port:e,no_device:s,socket:i}),this.__internal__.device.type="relay",this.__internal__.auto_response=!1,this.__internal__.serial.auto_response=[2,6,221,221,240,207,3],n.Devices.getCustom(this.typeDevice,s))throw new Error(`Device ${this.typeDevice} ${s} already exists`);n.Devices.add(this)}serialMessage(t){t=this.fixHexArray(t);const e={code:t,name:null,description:null,request:null,no_code:0};t[0]==="a0"&&t[2]=="00"?(e.name="Relay turned off",e.description="The relay has been turned off successfully.",e.request=this.lastAction,e.no_code=101):t[0]==="a0"&&t[2]=="01"?(e.name="Relay turned on",e.description="The relay has been turned on successfully.",e.request=this.lastAction,e.no_code=102):(e.name="Unrecognized response",e.description="The response of application was received, but dont identify with any of current parameters",e.request="undefined",e.no_code=400),this.dispatch("serial:message",e)}serialSetConnectionConstant(t=1){return a.e.connection(t)}async turnOn(){const t=a.e.activate();await this.appendToQueue(t,"relay:turn-on")}async turnOff(){const t=a.e.deactivate();await this.appendToQueue(t,"relay:turn-off")}async toggle({inverse:t=!1,ms:e=300}={}){if(!t){await this.turnOn(),await n.wait(e),await this.turnOff();return}await this.turnOff(),await n.wait(e),await this.turnOn()}}exports.Relay=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./kernel-DHq-6p9p.cjs"),a=require("./relay-BG7CetDU.cjs");class r extends n.Kernel{constructor({filters:t=null,config_port:e,no_device:s=1,socket:i=!1}={}){if(super({filters:t,config_port:e,no_device:s,socket:i}),this.__internal__.device.type="relay",this.__internal__.auto_response=!1,this.__internal__.serial.auto_response=[2,6,221,221,240,207,3],n.Devices.getCustom(this.typeDevice,s))throw new Error(`Device ${this.typeDevice} ${s} already exists`);n.Devices.add(this)}serialMessage(t){t=this.fixHexArray(t);const e={code:t,name:null,description:null,request:null,no_code:0};t[0]==="a0"&&t[2]=="00"?(e.name="Relay turned off",e.description="The relay has been turned off successfully.",e.request=this.lastAction,e.no_code=101):t[0]==="a0"&&t[2]=="01"?(e.name="Relay turned on",e.description="The relay has been turned on successfully.",e.request=this.lastAction,e.no_code=102):(e.name="Unrecognized response",e.description="The response of application was received, but dont identify with any of current parameters",e.request="undefined",e.no_code=400),this.dispatch("serial:message",e)}serialSetConnectionConstant(t=1){return a.e.connection(t)}async turnOn(){const t=a.e.activate();await this.appendToQueue(t,"relay:turn-on")}async turnOff(){const t=a.e.deactivate();await this.appendToQueue(t,"relay:turn-off")}async toggle({inverse:t=!1,ms:e=300}={}){if(!t){await this.turnOn(),await n.wait(e),await this.turnOff();return}await this.turnOff(),await n.wait(e),await this.turnOn()}}exports.Relay=r;
package/dist/relay.js CHANGED
@@ -1,4 +1,4 @@
1
- import { K as o, D as a, w as i } from "./kernel-Cm9N-fc9.js";
1
+ import { K as o, D as a, w as i } from "./kernel-BRG-vva2.js";
2
2
  import { e as n } from "./relay-C71zVBZv.js";
3
3
  class f extends o {
4
4
  constructor({ filters: t = null, config_port: e, no_device: s = 1, socket: r = !1 } = {}) {
@@ -17,28 +17,28 @@ const q = { type: "error", data: "parser error" }, te = typeof Blob == "function
17
17
  e("b" + (s || ""));
18
18
  }, t.readAsDataURL(n);
19
19
  };
20
- function j(n) {
20
+ function Q(n) {
21
21
  return n instanceof Uint8Array ? n : n instanceof ArrayBuffer ? new Uint8Array(n) : new Uint8Array(n.buffer, n.byteOffset, n.byteLength);
22
22
  }
23
23
  let P;
24
24
  function de(n, e) {
25
25
  if (te && n.data instanceof Blob)
26
- return n.data.arrayBuffer().then(j).then(e);
26
+ return n.data.arrayBuffer().then(Q).then(e);
27
27
  if (se && (n.data instanceof ArrayBuffer || ne(n.data)))
28
- return e(j(n.data));
28
+ return e(Q(n.data));
29
29
  H(n, !1, (t) => {
30
30
  P || (P = new TextEncoder()), e(P.encode(t));
31
31
  });
32
32
  }
33
- const Q = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", C = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
34
- for (let n = 0; n < Q.length; n++)
35
- C[Q.charCodeAt(n)] = n;
33
+ const X = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", C = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
34
+ for (let n = 0; n < X.length; n++)
35
+ C[X.charCodeAt(n)] = n;
36
36
  const ye = (n) => {
37
- let e = n.length * 0.75, t = n.length, s, i = 0, r, o, c, l;
37
+ let e = n.length * 0.75, t = n.length, s, i = 0, r, o, l, c;
38
38
  n[n.length - 1] === "=" && (e--, n[n.length - 2] === "=" && e--);
39
39
  const f = new ArrayBuffer(e), _ = new Uint8Array(f);
40
40
  for (s = 0; s < t; s += 4)
41
- r = C[n.charCodeAt(s)], o = C[n.charCodeAt(s + 1)], c = C[n.charCodeAt(s + 2)], l = C[n.charCodeAt(s + 3)], _[i++] = r << 2 | o >> 4, _[i++] = (o & 15) << 4 | c >> 2, _[i++] = (c & 3) << 6 | l & 63;
41
+ r = C[n.charCodeAt(s)], o = C[n.charCodeAt(s + 1)], l = C[n.charCodeAt(s + 2)], c = C[n.charCodeAt(s + 3)], _[i++] = r << 2 | o >> 4, _[i++] = (o & 15) << 4 | l >> 2, _[i++] = (l & 3) << 6 | c & 63;
42
42
  return f;
43
43
  }, ge = typeof ArrayBuffer == "function", W = (n, e) => {
44
44
  if (typeof n != "string")
@@ -66,8 +66,8 @@ const ye = (n) => {
66
66
  const t = n.length, s = new Array(t);
67
67
  let i = 0;
68
68
  n.forEach((r, o) => {
69
- H(r, !1, (c) => {
70
- s[o] = c, ++i === t && e(s.join(re));
69
+ H(r, !1, (l) => {
70
+ s[o] = l, ++i === t && e(s.join(re));
71
71
  });
72
72
  });
73
73
  }, be = (n, e) => {
@@ -119,35 +119,35 @@ function Ee(n, e) {
119
119
  const t = [];
120
120
  let s = 0, i = -1, r = !1;
121
121
  return new TransformStream({
122
- transform(o, c) {
122
+ transform(o, l) {
123
123
  for (t.push(o); ; ) {
124
124
  if (s === 0) {
125
125
  if (T(t) < 1)
126
126
  break;
127
- const l = A(t, 1);
128
- r = (l[0] & 128) === 128, i = l[0] & 127, i < 126 ? s = 3 : i === 126 ? s = 1 : s = 2;
127
+ const c = A(t, 1);
128
+ r = (c[0] & 128) === 128, i = c[0] & 127, i < 126 ? s = 3 : i === 126 ? s = 1 : s = 2;
129
129
  } else if (s === 1) {
130
130
  if (T(t) < 2)
131
131
  break;
132
- const l = A(t, 2);
133
- i = new DataView(l.buffer, l.byteOffset, l.length).getUint16(0), s = 3;
132
+ const c = A(t, 2);
133
+ i = new DataView(c.buffer, c.byteOffset, c.length).getUint16(0), s = 3;
134
134
  } else if (s === 2) {
135
135
  if (T(t) < 8)
136
136
  break;
137
- const l = A(t, 8), f = new DataView(l.buffer, l.byteOffset, l.length), _ = f.getUint32(0);
137
+ const c = A(t, 8), f = new DataView(c.buffer, c.byteOffset, c.length), _ = f.getUint32(0);
138
138
  if (_ > Math.pow(2, 21) - 1) {
139
- c.enqueue(q);
139
+ l.enqueue(q);
140
140
  break;
141
141
  }
142
142
  i = _ * Math.pow(2, 32) + f.getUint32(4), s = 3;
143
143
  } else {
144
144
  if (T(t) < i)
145
145
  break;
146
- const l = A(t, i);
147
- c.enqueue(W(r ? l : N.decode(l), e)), s = 0;
146
+ const c = A(t, i);
147
+ l.enqueue(W(r ? c : N.decode(c), e)), s = 0;
148
148
  }
149
149
  if (i === 0 || i > n) {
150
- c.enqueue(q);
150
+ l.enqueue(q);
151
151
  break;
152
152
  }
153
153
  }
@@ -335,7 +335,7 @@ class K extends u {
335
335
  return e.indexOf(":") === -1 ? e : "[" + e + "]";
336
336
  }
337
337
  _port() {
338
- return this.opts.port && (this.opts.secure && Number(this.opts.port) !== 443 || !this.opts.secure && Number(this.opts.port) !== 80) ? ":" + this.opts.port : "";
338
+ return this.opts.port && (this.opts.secure && +(this.opts.port !== 443) || !this.opts.secure && Number(this.opts.port) !== 80) ? ":" + this.opts.port : "";
339
339
  }
340
340
  _query(e) {
341
341
  const t = Be(e);
@@ -585,13 +585,13 @@ g.requestsCount = 0;
585
585
  g.requests = {};
586
586
  if (typeof document < "u") {
587
587
  if (typeof attachEvent == "function")
588
- attachEvent("onunload", X);
588
+ attachEvent("onunload", j);
589
589
  else if (typeof addEventListener == "function") {
590
590
  const n = "onpagehide" in d ? "pagehide" : "unload";
591
- addEventListener(n, X, !1);
591
+ addEventListener(n, j, !1);
592
592
  }
593
593
  }
594
- function X() {
594
+ function j() {
595
595
  for (let n in g.requests)
596
596
  g.requests.hasOwnProperty(n) && g.requests[n].abort();
597
597
  }
@@ -709,9 +709,9 @@ class $e extends K {
709
709
  const t = Ee(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = e.readable.pipeThrough(t).getReader(), i = ve();
710
710
  i.readable.pipeTo(e.writable), this._writer = i.writable.getWriter();
711
711
  const r = () => {
712
- s.read().then(({ done: c, value: l }) => {
713
- c || (this.onPacket(l), r());
714
- }).catch((c) => {
712
+ s.read().then(({ done: l, value: c }) => {
713
+ l || (this.onPacket(c), r());
714
+ }).catch((l) => {
715
715
  });
716
716
  };
717
717
  r();
@@ -1091,19 +1091,19 @@ class Ye extends b {
1091
1091
  const E = new Error("probe error: " + p);
1092
1092
  E.transport = t.name, r(), this.emitReserved("upgradeError", E);
1093
1093
  };
1094
- function c() {
1094
+ function l() {
1095
1095
  o("transport closed");
1096
1096
  }
1097
- function l() {
1097
+ function c() {
1098
1098
  o("socket closed");
1099
1099
  }
1100
1100
  function f(p) {
1101
1101
  t && p.name !== t.name && r();
1102
1102
  }
1103
1103
  const _ = () => {
1104
- t.removeListener("open", i), t.removeListener("error", o), t.removeListener("close", c), this.off("close", l), this.off("upgrading", f);
1104
+ t.removeListener("open", i), t.removeListener("error", o), t.removeListener("close", l), this.off("close", c), this.off("upgrading", f);
1105
1105
  };
1106
- t.once("open", i), t.once("error", o), t.once("close", c), this.once("close", l), this.once("upgrading", f), this._upgrades.indexOf("webtransport") !== -1 && e !== "webtransport" ? this.setTimeoutFn(() => {
1106
+ t.once("open", i), t.once("error", o), t.once("close", l), this.once("close", c), this.once("upgrading", f), this._upgrades.indexOf("webtransport") !== -1 && e !== "webtransport" ? this.setTimeoutFn(() => {
1107
1107
  s || t.open();
1108
1108
  }, 200) : t.open();
1109
1109
  }
@@ -1129,15 +1129,15 @@ let Je = class extends Ye {
1129
1129
  (!s.transports || s.transports && typeof s.transports[0] == "string") && (s.transports = (s.transports || ["polling", "websocket", "webtransport"]).map((i) => Ve[i]).filter((i) => !!i)), super(e, s);
1130
1130
  }
1131
1131
  };
1132
- function je(n, e = "", t) {
1132
+ function Qe(n, e = "", t) {
1133
1133
  let s = n;
1134
1134
  t = t || typeof location < "u" && location, n == null && (n = t.protocol + "//" + t.host), typeof n == "string" && (n.charAt(0) === "/" && (n.charAt(1) === "/" ? n = t.protocol + n : n = t.host + n), /^(https?|wss?):\/\//.test(n) || (typeof t < "u" ? n = t.protocol + "//" + n : n = "https://" + n), s = U(n)), s.port || (/^(http|ws)$/.test(s.protocol) ? s.port = "80" : /^(http|ws)s$/.test(s.protocol) && (s.port = "443")), s.path = s.path || "/";
1135
1135
  const r = s.host.indexOf(":") !== -1 ? "[" + s.host + "]" : s.host;
1136
1136
  return s.id = s.protocol + "://" + r + ":" + s.port + e, s.href = s.protocol + "://" + r + (t && t.port === s.port ? "" : ":" + s.port), s;
1137
1137
  }
1138
- const Qe = typeof ArrayBuffer == "function", Xe = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer, ue = Object.prototype.toString, Ge = typeof Blob == "function" || typeof Blob < "u" && ue.call(Blob) === "[object BlobConstructor]", Ze = typeof File == "function" || typeof File < "u" && ue.call(File) === "[object FileConstructor]";
1138
+ const Xe = typeof ArrayBuffer == "function", je = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer, ue = Object.prototype.toString, Ge = typeof Blob == "function" || typeof Blob < "u" && ue.call(Blob) === "[object BlobConstructor]", Ze = typeof File == "function" || typeof File < "u" && ue.call(File) === "[object FileConstructor]";
1139
1139
  function z(n) {
1140
- return Qe && (n instanceof ArrayBuffer || Xe(n)) || Ge && n instanceof Blob || Ze && n instanceof File;
1140
+ return Xe && (n instanceof ArrayBuffer || je(n)) || Ge && n instanceof Blob || Ze && n instanceof File;
1141
1141
  }
1142
1142
  function R(n, e) {
1143
1143
  if (!n || typeof n != "object")
@@ -1200,23 +1200,18 @@ function $(n, e) {
1200
1200
  }
1201
1201
  const st = [
1202
1202
  "connect",
1203
- // used on the client side
1204
1203
  "connect_error",
1205
- // used on the client side
1206
1204
  "disconnect",
1207
- // used on both sides
1208
1205
  "disconnecting",
1209
- // used on the server side
1210
1206
  "newListener",
1211
- // used by the Node.js EventEmitter
1212
1207
  "removeListener"
1213
1208
  // used by the Node.js EventEmitter
1214
- ];
1209
+ ], nt = 5;
1215
1210
  var h;
1216
1211
  (function(n) {
1217
1212
  n[n.CONNECT = 0] = "CONNECT", n[n.DISCONNECT = 1] = "DISCONNECT", n[n.EVENT = 2] = "EVENT", n[n.ACK = 3] = "ACK", n[n.CONNECT_ERROR = 4] = "CONNECT_ERROR", n[n.BINARY_EVENT = 5] = "BINARY_EVENT", n[n.BINARY_ACK = 6] = "BINARY_ACK";
1218
1213
  })(h || (h = {}));
1219
- class nt {
1214
+ class it {
1220
1215
  /**
1221
1216
  * Encoder constructor
1222
1217
  *
@@ -1256,15 +1251,17 @@ class nt {
1256
1251
  return i.unshift(s), i;
1257
1252
  }
1258
1253
  }
1254
+ function G(n) {
1255
+ return Object.prototype.toString.call(n) === "[object Object]";
1256
+ }
1259
1257
  class Y extends u {
1260
1258
  /**
1261
1259
  * Decoder constructor
1260
+ *
1261
+ * @param {function} reviver - custom reviver to pass down to JSON.stringify
1262
1262
  */
1263
1263
  constructor(e) {
1264
- super(), this.opts = Object.assign({
1265
- reviver: void 0,
1266
- maxAttachments: 10
1267
- }, typeof e == "function" ? { reviver: e } : e);
1264
+ super(), this.reviver = e;
1268
1265
  }
1269
1266
  /**
1270
1267
  * Decodes an encoded packet string into packet JSON.
@@ -1278,7 +1275,7 @@ class Y extends u {
1278
1275
  throw new Error("got plaintext data when reconstructing a packet");
1279
1276
  t = this.decodeString(e);
1280
1277
  const s = t.type === h.BINARY_EVENT;
1281
- s || t.type === h.BINARY_ACK ? (t.type = s ? h.EVENT : h.ACK, this.reconstructor = new it(t), t.attachments === 0 && super.emitReserved("decoded", t)) : super.emitReserved("decoded", t);
1278
+ s || t.type === h.BINARY_ACK ? (t.type = s ? h.EVENT : h.ACK, this.reconstructor = new rt(t), t.attachments === 0 && super.emitReserved("decoded", t)) : super.emitReserved("decoded", t);
1282
1279
  } else if (z(e) || e.base64)
1283
1280
  if (this.reconstructor)
1284
1281
  t = this.reconstructor.takeBinaryData(e), t && (this.reconstructor = null, super.emitReserved("decoded", t));
@@ -1307,12 +1304,7 @@ class Y extends u {
1307
1304
  const o = e.substring(r, t);
1308
1305
  if (o != Number(o) || e.charAt(t) !== "-")
1309
1306
  throw new Error("Illegal attachments");
1310
- const c = Number(o);
1311
- if (!rt(c) || c < 0)
1312
- throw new Error("Illegal attachments");
1313
- if (c > this.opts.maxAttachments)
1314
- throw new Error("too many attachments");
1315
- s.attachments = c;
1307
+ s.attachments = Number(o);
1316
1308
  }
1317
1309
  if (e.charAt(t + 1) === "/") {
1318
1310
  const r = t + 1;
@@ -1346,7 +1338,7 @@ class Y extends u {
1346
1338
  }
1347
1339
  tryParse(e) {
1348
1340
  try {
1349
- return JSON.parse(e, this.opts.reviver);
1341
+ return JSON.parse(e, this.reviver);
1350
1342
  } catch {
1351
1343
  return !1;
1352
1344
  }
@@ -1374,7 +1366,7 @@ class Y extends u {
1374
1366
  this.reconstructor && (this.reconstructor.finishedReconstruction(), this.reconstructor = null);
1375
1367
  }
1376
1368
  }
1377
- class it {
1369
+ class rt {
1378
1370
  constructor(e) {
1379
1371
  this.packet = e, this.buffers = [], this.reconPack = e;
1380
1372
  }
@@ -1400,19 +1392,14 @@ class it {
1400
1392
  this.reconPack = null, this.buffers = [];
1401
1393
  }
1402
1394
  }
1403
- const rt = Number.isInteger || function(n) {
1404
- return typeof n == "number" && isFinite(n) && Math.floor(n) === n;
1405
- };
1406
- function G(n) {
1407
- return Object.prototype.toString.call(n) === "[object Object]";
1408
- }
1409
1395
  const ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1410
1396
  __proto__: null,
1411
1397
  Decoder: Y,
1412
- Encoder: nt,
1398
+ Encoder: it,
1413
1399
  get PacketType() {
1414
1400
  return h;
1415
- }
1401
+ },
1402
+ protocol: nt
1416
1403
  }, Symbol.toStringTag, { value: "Module" }));
1417
1404
  function y(n, e, t) {
1418
1405
  return n.on(e, t), function() {
@@ -1556,8 +1543,8 @@ class fe extends u {
1556
1543
  const _ = this.ids++, p = t.pop();
1557
1544
  this._registerAckCallback(_, p), o.id = _;
1558
1545
  }
1559
- const c = (i = (s = this.io.engine) === null || s === void 0 ? void 0 : s.transport) === null || i === void 0 ? void 0 : i.writable, l = this.connected && !(!((r = this.io.engine) === null || r === void 0) && r._hasPingExpired());
1560
- return this.flags.volatile && !c || (l ? (this.notifyOutgoingListeners(o), this.packet(o)) : this.sendBuffer.push(o)), this.flags = {}, this;
1546
+ const l = (i = (s = this.io.engine) === null || s === void 0 ? void 0 : s.transport) === null || i === void 0 ? void 0 : i.writable, c = this.connected && !(!((r = this.io.engine) === null || r === void 0) && r._hasPingExpired());
1547
+ return this.flags.volatile && !l || (c ? (this.notifyOutgoingListeners(o), this.packet(o)) : this.sendBuffer.push(o)), this.flags = {}, this;
1561
1548
  }
1562
1549
  /**
1563
1550
  * @private
@@ -1571,11 +1558,11 @@ class fe extends u {
1571
1558
  }
1572
1559
  const r = this.io.setTimeoutFn(() => {
1573
1560
  delete this.acks[e];
1574
- for (let c = 0; c < this.sendBuffer.length; c++)
1575
- this.sendBuffer[c].id === e && this.sendBuffer.splice(c, 1);
1561
+ for (let l = 0; l < this.sendBuffer.length; l++)
1562
+ this.sendBuffer[l].id === e && this.sendBuffer.splice(l, 1);
1576
1563
  t.call(this, new Error("operation has timed out"));
1577
- }, i), o = (...c) => {
1578
- this.io.clearTimeoutFn(r), t.apply(this, c);
1564
+ }, i), o = (...l) => {
1565
+ this.io.clearTimeoutFn(r), t.apply(this, l);
1579
1566
  };
1580
1567
  o.withError = !0, this.acks[e] = o;
1581
1568
  }
@@ -1597,7 +1584,7 @@ class fe extends u {
1597
1584
  */
1598
1585
  emitWithAck(e, ...t) {
1599
1586
  return new Promise((s, i) => {
1600
- const r = (o, c) => o ? i(o) : s(c);
1587
+ const r = (o, l) => o ? i(o) : s(l);
1601
1588
  r.withError = !0, t.push(r), this.emit(e, ...t);
1602
1589
  });
1603
1590
  }
@@ -1616,7 +1603,7 @@ class fe extends u {
1616
1603
  args: e,
1617
1604
  flags: Object.assign({ fromQueue: !0 }, this.flags)
1618
1605
  };
1619
- e.push((i, ...r) => (this._queue[0], i !== null ? s.tryCount > this._opts.retries && (this._queue.shift(), t && t(i)) : (this._queue.shift(), t && t(null, ...r)), s.pending = !1, this._drainQueue())), this._queue.push(s), this._drainQueue();
1606
+ e.push((i, ...r) => s !== this._queue[0] ? void 0 : (i !== null ? s.tryCount > this._opts.retries && (this._queue.shift(), t && t(i)) : (this._queue.shift(), t && t(null, ...r)), s.pending = !1, this._drainQueue())), this._queue.push(s), this._drainQueue();
1620
1607
  }
1621
1608
  /**
1622
1609
  * Send the first packet of the queue, and wait for an acknowledgement from the server.
@@ -1774,7 +1761,7 @@ class fe extends u {
1774
1761
  * @private
1775
1762
  */
1776
1763
  onconnect(e, t) {
1777
- this.id = e, this.recovered = t && this._pid === t, this._pid = t, this.connected = !0, this.emitBuffered(), this._drainQueue(!0), this.emitReserved("connect");
1764
+ this.id = e, this.recovered = t && this._pid === t, this._pid = t, this.connected = !0, this.emitBuffered(), this.emitReserved("connect"), this._drainQueue(!0);
1778
1765
  }
1779
1766
  /**
1780
1767
  * Emit buffered events (received and emitted).
@@ -2099,15 +2086,15 @@ class V extends u {
2099
2086
  this._readyState = "opening", this.skipReconnect = !1;
2100
2087
  const i = y(t, "open", function() {
2101
2088
  s.onopen(), e && e();
2102
- }), r = (c) => {
2103
- this.cleanup(), this._readyState = "closed", this.emitReserved("error", c), e ? e(c) : this.maybeReconnectOnOpen();
2089
+ }), r = (l) => {
2090
+ this.cleanup(), this._readyState = "closed", this.emitReserved("error", l), e ? e(l) : this.maybeReconnectOnOpen();
2104
2091
  }, o = y(t, "error", r);
2105
2092
  if (this._timeout !== !1) {
2106
- const c = this._timeout, l = this.setTimeoutFn(() => {
2093
+ const l = this._timeout, c = this.setTimeoutFn(() => {
2107
2094
  i(), r(new Error("timeout")), t.close();
2108
- }, c);
2109
- this.opts.autoUnref && l.unref(), this.subs.push(() => {
2110
- this.clearTimeoutFn(l);
2095
+ }, l);
2096
+ this.opts.autoUnref && c.unref(), this.subs.push(() => {
2097
+ this.clearTimeoutFn(c);
2111
2098
  });
2112
2099
  }
2113
2100
  return this.subs.push(i), this.subs.push(o), this;
@@ -2284,9 +2271,9 @@ class V extends u {
2284
2271
  const k = {};
2285
2272
  function B(n, e) {
2286
2273
  typeof n == "object" && (e = n, n = void 0), e = e || {};
2287
- const t = je(n, e.path || "/socket.io"), s = t.source, i = t.id, r = t.path, o = k[i] && r in k[i].nsps, c = e.forceNew || e["force new connection"] || e.multiplex === !1 || o;
2288
- let l;
2289
- return c ? l = new V(s, e) : (k[i] || (k[i] = new V(s, e)), l = k[i]), t.query && !e.query && (e.query = t.queryKey), l.socket(t.path, e);
2274
+ const t = Qe(n, e.path || "/socket.io"), s = t.source, i = t.id, r = t.path, o = k[i] && r in k[i].nsps, l = e.forceNew || e["force new connection"] || e.multiplex === !1 || o;
2275
+ let c;
2276
+ return l ? c = new V(s, e) : (k[i] || (k[i] = new V(s, e)), c = k[i]), t.query && !e.query && (e.query = t.queryKey), c.socket(t.path, e);
2290
2277
  }
2291
2278
  Object.assign(B, {
2292
2279
  Manager: V,
@@ -2686,7 +2673,7 @@ class ht extends pe {
2686
2673
  device_listen_on_channel: i = 1,
2687
2674
  bypassSerialBytesConnection: r = !1,
2688
2675
  socket: o = !1,
2689
- transformStream: c = !1
2676
+ transformStream: l = !1
2690
2677
  } = {
2691
2678
  filters: null,
2692
2679
  config_port: D,
@@ -2698,11 +2685,11 @@ class ht extends pe {
2698
2685
  }) {
2699
2686
  if (super(), !("serial" in navigator))
2700
2687
  throw new Error("Web Serial not supported");
2701
- if (e && (this.serialFilters = e), t && (this.serialConfigPort = t), r && (this.__internal__.bypassSerialBytesConnection = r), s && this.#v(s), i && ["number", "string"].includes(typeof i) && (this.listenOnChannel = i), this.__internal__.serial.socket = o, typeof c == "function")
2702
- this.__internal__.serial.transformStream = c;
2703
- else if (c) {
2704
- const l = c;
2705
- this.__internal__.serial.transformStream = () => l;
2688
+ if (e && (this.serialFilters = e), t && (this.serialConfigPort = t), r && (this.__internal__.bypassSerialBytesConnection = r), s && this.#v(s), i && ["number", "string"].includes(typeof i) && (this.listenOnChannel = i), this.__internal__.serial.socket = o, typeof l == "function")
2689
+ this.__internal__.serial.transformStream = l;
2690
+ else if (l) {
2691
+ const c = l;
2692
+ this.__internal__.serial.transformStream = () => c;
2706
2693
  } else
2707
2694
  this.__internal__.serial.transformStream = !1;
2708
2695
  this.#g(), this.#m();
@@ -2983,7 +2970,7 @@ class ht extends pe {
2983
2970
  } catch (e) {
2984
2971
  console.error(e), this.serialErrors(e);
2985
2972
  } finally {
2986
- this.__internal__.serial.reader = null, this.__internal__.serial.input_done = null, this.__internal__.serial.output_stream = null, this.__internal__.serial.output_done = null, this.__internal__.serial.connected = !1, this.__internal__.serial.port = null, a.$dispatchChange(this);
2973
+ this.__internal__.serial.reader = null, this.__internal__.serial.input_done = null, this.__internal__.serial.output_stream = null, this.__internal__.serial.output_done = null, this.__internal__.serial.keep_reading = !0, this.__internal__.serial.connected = !1, this.__internal__.serial.port = null, a.$dispatchChange(this);
2987
2974
  }
2988
2975
  }
2989
2976
  async #o(e) {
@@ -3162,28 +3149,28 @@ class ht extends pe {
3162
3149
  let r = new TextDecoder().decode(i);
3163
3150
  const o = [];
3164
3151
  if (typeof e == "string") {
3165
- let l;
3152
+ let c;
3166
3153
  if (t && s)
3167
- l = new RegExp(`${e}([^${e}]+)${e}`, "g");
3154
+ c = new RegExp(`${e}([^${e}]+)${e}`, "g");
3168
3155
  else if (t)
3169
- l = new RegExp(`${e}([^${e}]*)`, "g");
3156
+ c = new RegExp(`${e}([^${e}]*)`, "g");
3170
3157
  else if (s)
3171
- l = new RegExp(`([^${e}]+)${e}`, "g");
3158
+ c = new RegExp(`([^${e}]+)${e}`, "g");
3172
3159
  else
3173
3160
  return;
3174
3161
  let f, _ = 0;
3175
- for (; (f = l.exec(r)) !== null; )
3176
- o.push(new TextEncoder().encode(f[1])), _ = l.lastIndex;
3162
+ for (; (f = c.exec(r)) !== null; )
3163
+ o.push(new TextEncoder().encode(f[1])), _ = c.lastIndex;
3177
3164
  r = r.slice(_);
3178
3165
  } else if (e instanceof RegExp) {
3179
- let l, f = 0;
3166
+ let c, f = 0;
3180
3167
  if (t && s) {
3181
3168
  const _ = new RegExp(`${e.source}(.*?)${e.source}`, "g");
3182
- for (; (l = _.exec(r)) !== null; )
3183
- o.push(new TextEncoder().encode(l[1])), f = _.lastIndex;
3169
+ for (; (c = _.exec(r)) !== null; )
3170
+ o.push(new TextEncoder().encode(c[1])), f = _.lastIndex;
3184
3171
  } else if (s)
3185
- for (; (l = e.exec(r)) !== null; ) {
3186
- const _ = l.index, p = r.slice(f, _);
3172
+ for (; (c = e.exec(r)) !== null; ) {
3173
+ const _ = c.index, p = r.slice(f, _);
3187
3174
  o.push(new TextEncoder().encode(p)), f = e.lastIndex;
3188
3175
  }
3189
3176
  else if (t) {
@@ -3195,10 +3182,10 @@ class ht extends pe {
3195
3182
  }
3196
3183
  r = r.slice(f);
3197
3184
  }
3198
- for (const l of o)
3199
- this.#r(l);
3200
- const c = new TextEncoder().encode(r);
3201
- this.__internal__.serial.response.buffer = c, c.length > 0 && (this.__internal__.serial.time_until_send_bytes = setTimeout(() => {
3185
+ for (const c of o)
3186
+ this.#r(c);
3187
+ const l = new TextEncoder().encode(r);
3188
+ this.__internal__.serial.response.buffer = l, l.length > 0 && (this.__internal__.serial.time_until_send_bytes = setTimeout(() => {
3202
3189
  this.#r(this.__internal__.serial.response.buffer, !0), this.__internal__.serial.response.buffer = new Uint8Array(0);
3203
3190
  }, this.__internal__.serial.free_timeout_ms ?? 50));
3204
3191
  }
@@ -3214,9 +3201,9 @@ class ht extends pe {
3214
3201
  this.__internal__.serial.pipeDone = (async () => {
3215
3202
  try {
3216
3203
  for (; ; ) {
3217
- const { value: c, done: l } = await r.read();
3218
- if (l) break;
3219
- await o.write(c);
3204
+ const { value: l, done: c } = await r.read();
3205
+ if (c) break;
3206
+ await o.write(l);
3220
3207
  }
3221
3208
  } catch {
3222
3209
  } finally {