@danidoble/webserial 4.2.3 → 4.2.5
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/LICENSE +21 -0
- package/dist/arduino.cjs +1 -1
- package/dist/arduino.js +36 -42
- package/dist/boardroid.cjs +1 -1
- package/dist/boardroid.js +350 -384
- package/dist/jofemar.cjs +1 -1
- package/dist/jofemar.js +688 -560
- package/dist/{kernel-B15wfB2x.js → kernel-Bquzoyqh.js} +413 -437
- package/dist/kernel-DSUxKxea.cjs +4 -0
- package/dist/kernel.cjs +2 -2
- package/dist/kernel.js +3 -3
- package/dist/locker.cjs +1 -1
- package/dist/locker.js +85 -123
- package/dist/pinpad.cjs +13 -13
- package/dist/pinpad.js +569 -560
- package/dist/pinpax.cjs +3 -20
- package/dist/pinpax.js +76 -109
- package/dist/relay-BsUsBpOv.cjs +3 -0
- package/dist/relay-Dop4mFk-.js +1341 -0
- package/dist/relay.cjs +1 -1
- package/dist/relay.js +32 -45
- package/dist/webserial.cjs +2 -2
- package/dist/webserial.js +3 -3
- package/package.json +32 -32
- package/dist/kernel-CtyQRsMI.cjs +0 -4
package/dist/pinpax.cjs
CHANGED
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`,
|
|
3
|
-
`))}
|
|
4
|
-
`);await this.appendToQueue(e,"custom")}async connectMessage(){const s=JSON.stringify({action:"CONNECT"}),e=this.parseStringToBytes(s,`\r
|
|
5
|
-
`);await this.appendToQueue(e,"connect:message")}async makeSale({amount:s=0,reference:e=null}={}){if(this.isDisconnected)throw new Error("Device is disconnected");if(this.__pinpax__.waiting.sale)throw new Error("Already waiting for sale response");if(s<=0)throw new Error("Invalid amount");if(s=parseFloat(s),isNaN(s))throw new Error("Invalid amount");if(!e&&!r(this,t,R).call(this,e))throw new Error("Reference must be alphanumeric and the only symbol allowed is midlescore or underscore (- _) or null");s=s.toFixed(2);const i=JSON.stringify({action:"PAYMENT",amount:s,reference:e}),o=this.parseStringToBytes(i,`\r
|
|
6
|
-
`);this.__pinpax__.waiting.sale=!0,this.__pinpax__.asyncResponses.sale=null,this.queue.length>0&&await r(this,t,_).call(this);const c=this;return await this.appendToQueue(o,"make-sale"),new Promise(p=>{const h=setInterval(()=>{if(c.__pinpax__.asyncResponses.sale){const u=c.__pinpax__.asyncResponses.sale;c.__pinpax__.asyncResponses.sale=null,c.__pinpax__.waiting.sale=!1,clearInterval(h),p(u.approved)}},100)})}async getVoucher({folio:s=null}={}){if(this.isDisconnected)throw new Error("Device is disconnected");if(this.__pinpax__.waiting.voucher)throw new Error("Already waiting for voucher");if(!s)throw new Error("Folio is required");this.__pinpax__.waiting.voucher=!0,this.__pinpax__.asyncResponses.voucher=null;const e=JSON.stringify({action:"GETVOUCHER",folio:s}),i=this.parseStringToBytes(e,`\r
|
|
7
|
-
`);this.queue.length>0&&await r(this,t,_).call(this),await this.appendToQueue(i,"get-voucher");const o=this;return new Promise((c,p)=>{const h=setTimeout(()=>{o.__pinpax__.waiting.voucher=!1,p("Timeout")},1e4),u=setInterval(()=>{if(o.__pinpax__.asyncResponses.voucher){const b=o.__pinpax__.asyncResponses.voucher;o.__pinpax__.asyncResponses.voucher=null,o.__pinpax__.waiting.voucher=!1,clearInterval(u),clearTimeout(h),c(b.voucher)}},100)})}async info(){const s=JSON.stringify({action:"DEVICEINFO"}),e=this.parseStringToBytes(s,`\r
|
|
8
|
-
`);await this.appendToQueue(e,"info")}async keepAlive(){const s=JSON.stringify({action:"KEEPALIVE"}),e=this.parseStringToBytes(s,`\r
|
|
9
|
-
`);await this.appendToQueue(e,"keep-alive")}async restartApp(){const s=JSON.stringify({action:"RESETAPP"}),e=this.parseStringToBytes(s,`\r
|
|
10
|
-
`);await this.appendToQueue(e,"reset-app")}async getConfig(){const s=JSON.stringify({action:"GETCONFIG"}),e=this.parseStringToBytes(s,`\r
|
|
11
|
-
`);return await this.appendToQueue(e,"get-config")}async hideButtons(){const s=JSON.stringify({action:"HIDEBUTTONS"}),e=this.parseStringToBytes(s,`\r
|
|
12
|
-
`);return await this.appendToQueue(e,"hide-buttons"),await r(this,t,T).call(this)}async showButtons(){const s=JSON.stringify({action:"SHOWBUTTONS"}),e=this.parseStringToBytes(s,`\r
|
|
13
|
-
`);return await this.appendToQueue(e,"show-buttons"),await r(this,t,S).call(this)}async demo(){console.warn("RUNNING DEMO APP BE CAREFUL");const s=JSON.stringify({action:"DEMO"}),e=this.parseStringToBytes(s,`\r
|
|
14
|
-
`);return await this.appendToQueue(e,"demo")}async refund({amount:s=0,folio:e=null,auth:i=null}={}){const o=JSON.stringify({action:"REFUND",amount:s,folio:e,auth:i}),c=this.parseStringToBytes(o,`\r
|
|
15
|
-
`);return await this.appendToQueue(c,"refund")}async readProductionQR(){return await r(this,t,d).call(this,{type:"production"})}async readQualityAssuranceQR(){return r(this,t,d).call(this,{type:"QA"})}async exit(){const s=JSON.stringify({action:"EXIT"}),e=this.parseStringToBytes(s,`\r
|
|
16
|
-
`);return await this.appendToQueue(e,"exit-app")}async init(){const s=JSON.stringify({action:"INIT"}),e=this.parseStringToBytes(s,`\r
|
|
17
|
-
`);await this.appendToQueue(e,"init-app")}}t=new WeakSet,m=function(){l.c.add(this)},w=function(){const s=["buttons-status","init-app","connectMessage","voucher","info","keep-alive","reset-app","get-config","payment","error","refund"];for(const e of s)this.serialRegisterAvailableListener(e)},_=async function(){if(this.isDisconnected)throw new Error("Device is disconnected");if(this.queue.length===0)return!0;const s=this;return new Promise(e=>{let i=setInterval(()=>{s.queue.length===0&&(clearInterval(i),e(!0))},500)})},d=async function({type:s="production"}={}){const e=JSON.stringify({action:"READQR",server:s==="production"?"PROD":"QA"}),i=this.parseStringToBytes(e,`\r
|
|
18
|
-
`);return await this.appendToQueue(i,"read-qr")},T=async function(){const s=JSON.stringify({action:"FORCEHIDE"}),e=this.parseStringToBytes(s,`\r
|
|
19
|
-
`);await this.appendToQueue(e,"force-hide")},S=async function(){const s=JSON.stringify({action:"FORCESHOW"}),e=this.parseStringToBytes(s,`\r
|
|
20
|
-
`);await this.appendToQueue(e,"force-show")},E=async function(){await this.connectMessage()},v=async function(){await this.hideButtons()},N=function(s){this.dispatch("payment",s),this.__pinpax__.waiting.sale&&(this.__pinpax__.asyncResponses.sale=s)},R=function(s){return/^[A-Z-a-z0-9_\s]+$/g.test(s)};exports.PinPax=k;
|
|
1
|
+
"use strict";var E=Object.defineProperty;var y=r=>{throw TypeError(r)};var x=(r,n,s)=>n in r?E(r,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[n]=s;var f=(r,n,s)=>x(r,typeof n!="symbol"?n+"":n,s),C=(r,n,s)=>n.has(r)||y("Cannot "+s);var m=(r,n,s)=>n.has(r)?y("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(r):n.set(r,s);var o=(r,n,s)=>(C(r,n,"access private method"),s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./kernel-DSUxKxea.cjs"),i=require("./relay-BsUsBpOv.cjs");var t,w,_,d,g,v,b,T,k;class A extends l.Kernel{constructor({filters:s=null,config_port:e={baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:a=1,device_listen_on_channel:c=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}){super({filters:s,config_port:e,no_device:a,device_listen_on_channel:c});m(this,t);f(this,"__pinpax__",{asyncResponses:{voucher:null,sale:null},waiting:{voucher:!1,sale:!1}});if(this.__internal__.device.type="pinpax",l._.getCustom(this.typeDevice,a))throw new Error(`Device ${this.typeDevice} ${a} 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
|
+
`,o(this,t,w).call(this),l._.add(this),this.getResponseAsString()}serialMessage(s){let e=null;try{e=JSON.parse(s)}catch(a){console.error("Error parsing response",a,s),this.dispatch("serial:message",s);return}switch(e.response){case"INITAPP":this.dispatch("init-app",{status:"started"}),o(this,t,b).call(this).then(()=>{});break;case"CONNECT":this.dispatch("connectMessage",{status:"connected"}),o(this,t,T).call(this).then(()=>{});break;case"LASTVOUCHER":this.dispatch("voucher",e),this.__pinpax__.waiting.voucher&&(this.__pinpax__.asyncResponses.voucher=e,this.__pinpax__.waiting.voucher=!1);break;case"DEVICEINFO":this.dispatch("info",e);break;case"KEEPALIVE":this.dispatch("keep-alive",{status:"alive"});break;case"RESETAPP":this.dispatch("reset-app",{status:"accepted"});break;case"GETCONFIG":this.dispatch("get-config",e);break;case"HIDEBUTTONS":this.dispatch("buttons-status",{hidden:!0});break;case"SHOWBUTTONS":this.dispatch("buttons-status",{hidden:!1});break;case"PAYMENT_PROCESS":this.dispatch("payment",{status:"starting",amount:e.amount,reference:e.referecence});break;case"INSERT_CARD":this.dispatch("payment",{status:"insert card"});break;case"CARD_DATA":this.dispatch("payment",{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":this.dispatch("payment",{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":o(this,t,k).call(this,{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":this.__pinpax__.waiting.sale&&(this.__pinpax__.asyncResponses.sale={status:"error",approved:!1,response:e}),this.dispatch("error",{status:"error",response:e}),this.dispatch("payment",{status:"error",response:e});break;case"REFUND":this.dispatch("refund",{status:"refund",response:e});break}this.dispatch("serial:message",e)}serialSetConnectionConstant(s=1){return i.s.connection(s)}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(s={}){if(typeof s!="object")throw new Error("Invalid object");if(s.constructor!==Object)throw new Error("Invalid object");if(Object.keys(s).length===0)throw new Error("Empty object");if(s.action===void 0||s.action===null)throw new Error("Invalid object add action");const e=JSON.stringify(s),a=this.parseStringToBytes(e,`\r
|
|
3
|
+
`);await this.appendToQueue(this.stringArrayToUint8Array(a),"custom")}async connectMessage(){await this.appendToQueue(i.s.connect(),"connect:message")}async makeSale({amount:s=0,reference:e=null}={}){if(this.isDisconnected)throw new Error("Device is disconnected");if(this.__pinpax__.waiting.sale)throw new Error("Already waiting for sale response");const a=i.s.makeSale({amount:s,reference:e});this.__pinpax__.waiting.sale=!0,this.__pinpax__.asyncResponses.sale=null,this.queue.length>0&&await o(this,t,_).call(this);const c=this;return await this.appendToQueue(a,"make-sale"),new Promise(p=>{const u=setInterval(()=>{if(c.__pinpax__.asyncResponses.sale){const h=c.__pinpax__.asyncResponses.sale;c.__pinpax__.asyncResponses.sale=null,c.__pinpax__.waiting.sale=!1,clearInterval(u),p(h.approved)}},100)})}async getVoucher({folio:s=null}={}){if(this.isDisconnected)throw new Error("Device is disconnected");if(this.__pinpax__.waiting.voucher)throw new Error("Already waiting for voucher");if(!s)throw new Error("Folio is required");this.__pinpax__.waiting.voucher=!0,this.__pinpax__.asyncResponses.voucher=null;const e=i.s.getVoucher({folio:s});this.queue.length>0&&await o(this,t,_).call(this),await this.appendToQueue(e,"get-voucher");const a=this;return new Promise((c,p)=>{const u=setTimeout(()=>{a.__pinpax__.waiting.voucher=!1,p("Timeout")},1e4),h=setInterval(()=>{if(a.__pinpax__.asyncResponses.voucher){const R=a.__pinpax__.asyncResponses.voucher;a.__pinpax__.asyncResponses.voucher=null,a.__pinpax__.waiting.voucher=!1,clearInterval(h),clearTimeout(u),c(R.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 o(this,t,g).call(this)}async showButtons(){return await this.appendToQueue(i.s.showButtons(),"show-buttons"),await o(this,t,v).call(this)}async demo(){return console.warn("RUNNING DEMO APP, BE CAREFUL"),await this.appendToQueue(i.s.demo(),"demo")}async refund({amount:s=0,folio:e=null,auth:a=null}={}){return await this.appendToQueue(i.s.refund({amount:s,folio:e,auth:a}),"refund")}async readProductionQR(){return await o(this,t,d).call(this,{type:"production"})}async readQualityAssuranceQR(){return o(this,t,d).call(this,{type:"QA"})}async exit(){return await this.appendToQueue(i.s.exit(),"exit-app")}async init(){await this.appendToQueue(i.s.init(),"init-app")}}t=new WeakSet,w=function(){const s=["buttons-status","init-app","connectMessage","voucher","info","keep-alive","reset-app","get-config","payment","error","refund"];for(const e of s)this.serialRegisterAvailableListener(e)},_=async function(){if(this.isDisconnected)throw new Error("Device is disconnected");if(this.queue.length===0)return!0;const s=this;return new Promise(e=>{let a=setInterval(()=>{s.queue.length===0&&(clearInterval(a),e(!0))},500)})},d=async function({type:s="production"}={}){const e=i.s.readQR({type:s});return await this.appendToQueue(e,"read-qr")},g=async function(){await this.appendToQueue(i.s.forceHide(),"force-hide")},v=async function(){await this.appendToQueue(i.s.forceShow(),"force-show")},b=async function(){await this.connectMessage()},T=async function(){await this.hideButtons()},k=function(s){this.dispatch("payment",s),this.__pinpax__.waiting.sale&&(this.__pinpax__.asyncResponses.sale=s)};exports.PinPax=A;
|
package/dist/pinpax.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var d = (
|
|
3
|
-
throw TypeError(
|
|
1
|
+
var E = Object.defineProperty;
|
|
2
|
+
var d = (r) => {
|
|
3
|
+
throw TypeError(r);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
import { K as
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
var x = (r, i, s) => i in r ? E(r, i, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[i] = s;
|
|
6
|
+
var f = (r, i, s) => x(r, typeof i != "symbol" ? i + "" : i, s), C = (r, i, s) => i.has(r) || d("Cannot " + s);
|
|
7
|
+
var m = (r, i, s) => i.has(r) ? d("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(r) : i.set(r, s);
|
|
8
|
+
var o = (r, i, s) => (C(r, i, "access private method"), s);
|
|
9
|
+
import { K as A, _ as y } from "./kernel-Bquzoyqh.js";
|
|
10
|
+
import { s as n } from "./relay-Dop4mFk-.js";
|
|
11
|
+
var t, w, l, _, g, v, b, T, R;
|
|
12
|
+
class D extends A {
|
|
12
13
|
constructor({
|
|
13
14
|
filters: s = null,
|
|
14
15
|
config_port: e = {
|
|
@@ -19,8 +20,8 @@ class A extends x {
|
|
|
19
20
|
bufferSize: 32768,
|
|
20
21
|
flowControl: "none"
|
|
21
22
|
},
|
|
22
|
-
no_device:
|
|
23
|
-
device_listen_on_channel:
|
|
23
|
+
no_device: a = 1,
|
|
24
|
+
device_listen_on_channel: c = 1
|
|
24
25
|
} = {
|
|
25
26
|
filters: null,
|
|
26
27
|
config_port: {
|
|
@@ -34,9 +35,9 @@ class A extends x {
|
|
|
34
35
|
no_device: 1,
|
|
35
36
|
device_listen_on_channel: 1
|
|
36
37
|
}) {
|
|
37
|
-
super({ filters: s, config_port: e, no_device:
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
super({ filters: s, config_port: e, no_device: a, device_listen_on_channel: c });
|
|
39
|
+
m(this, t);
|
|
40
|
+
f(this, "__pinpax__", {
|
|
40
41
|
asyncResponses: {
|
|
41
42
|
voucher: null,
|
|
42
43
|
sale: null
|
|
@@ -46,26 +47,26 @@ class A extends x {
|
|
|
46
47
|
sale: !1
|
|
47
48
|
}
|
|
48
49
|
});
|
|
49
|
-
if (this.__internal__.device.type = "pinpax",
|
|
50
|
-
throw new Error(`Device ${this.typeDevice} ${
|
|
50
|
+
if (this.__internal__.device.type = "pinpax", y.getCustom(this.typeDevice, a))
|
|
51
|
+
throw new Error(`Device ${this.typeDevice} ${a} already exists`);
|
|
51
52
|
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
|
|
52
|
-
`,
|
|
53
|
+
`, o(this, t, w).call(this), y.add(this), this.getResponseAsString();
|
|
53
54
|
}
|
|
54
55
|
serialMessage(s) {
|
|
55
56
|
let e = null;
|
|
56
57
|
try {
|
|
57
58
|
e = JSON.parse(s);
|
|
58
|
-
} catch (
|
|
59
|
-
console.error("Error parsing response",
|
|
59
|
+
} catch (a) {
|
|
60
|
+
console.error("Error parsing response", a, s), this.dispatch("serial:message", s);
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
62
63
|
switch (e.response) {
|
|
63
64
|
case "INITAPP":
|
|
64
|
-
this.dispatch("init-app", { status: "started" }),
|
|
65
|
+
this.dispatch("init-app", { status: "started" }), o(this, t, b).call(this).then(() => {
|
|
65
66
|
});
|
|
66
67
|
break;
|
|
67
68
|
case "CONNECT":
|
|
68
|
-
this.dispatch("connectMessage", { status: "connected" }),
|
|
69
|
+
this.dispatch("connectMessage", { status: "connected" }), o(this, t, T).call(this).then(() => {
|
|
69
70
|
});
|
|
70
71
|
break;
|
|
71
72
|
case "LASTVOUCHER":
|
|
@@ -127,7 +128,7 @@ class A extends x {
|
|
|
127
128
|
});
|
|
128
129
|
break;
|
|
129
130
|
case "TRANSACTION_RESULT":
|
|
130
|
-
|
|
131
|
+
o(this, t, R).call(this, {
|
|
131
132
|
status: "result",
|
|
132
133
|
approved: e.approved,
|
|
133
134
|
acquirer: e.acquirer,
|
|
@@ -181,41 +182,31 @@ class A extends x {
|
|
|
181
182
|
}
|
|
182
183
|
this.dispatch("serial:message", e);
|
|
183
184
|
}
|
|
184
|
-
// eslint-disable-next-line no-unused-vars
|
|
185
185
|
serialSetConnectionConstant(s = 1) {
|
|
186
|
-
|
|
187
|
-
return this.add0x(this.parseStringToBytes(e, `\r
|
|
188
|
-
`));
|
|
186
|
+
return n.connection(s);
|
|
189
187
|
}
|
|
190
188
|
softReload() {
|
|
191
189
|
super.softReload(), this.__pinpax__.waiting.sale = !1, this.__pinpax__.waiting.voucher = !1, this.__pinpax__.asyncResponses.sale = null, this.__pinpax__.asyncResponses.voucher = null;
|
|
192
190
|
}
|
|
193
|
-
async sendCustomCode(
|
|
194
|
-
if (typeof s != "
|
|
195
|
-
|
|
191
|
+
async sendCustomCode(s = {}) {
|
|
192
|
+
if (typeof s != "object") throw new Error("Invalid object");
|
|
193
|
+
if (s.constructor !== Object) throw new Error("Invalid object");
|
|
194
|
+
if (Object.keys(s).length === 0) throw new Error("Empty object");
|
|
195
|
+
if (s.action === void 0 || s.action === null) throw new Error("Invalid object add action");
|
|
196
|
+
const e = JSON.stringify(s), a = this.parseStringToBytes(e, `\r
|
|
196
197
|
`);
|
|
197
|
-
await this.appendToQueue(
|
|
198
|
+
await this.appendToQueue(this.stringArrayToUint8Array(a), "custom");
|
|
198
199
|
}
|
|
199
200
|
async connectMessage() {
|
|
200
|
-
|
|
201
|
-
`);
|
|
202
|
-
await this.appendToQueue(e, "connect:message");
|
|
201
|
+
await this.appendToQueue(n.connect(), "connect:message");
|
|
203
202
|
}
|
|
204
203
|
async makeSale({ amount: s = 0, reference: e = null } = {}) {
|
|
205
204
|
if (this.isDisconnected) throw new Error("Device is disconnected");
|
|
206
205
|
if (this.__pinpax__.waiting.sale) throw new Error("Already waiting for sale response");
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (!e && !r(this, t, R).call(this, e))
|
|
210
|
-
throw new Error(
|
|
211
|
-
"Reference must be alphanumeric and the only symbol allowed is midlescore or underscore (- _) or null"
|
|
212
|
-
);
|
|
213
|
-
s = s.toFixed(2);
|
|
214
|
-
const i = JSON.stringify({ action: "PAYMENT", amount: s, reference: e }), o = this.parseStringToBytes(i, `\r
|
|
215
|
-
`);
|
|
216
|
-
this.__pinpax__.waiting.sale = !0, this.__pinpax__.asyncResponses.sale = null, this.queue.length > 0 && await r(this, t, l).call(this);
|
|
206
|
+
const a = n.makeSale({ amount: s, reference: e });
|
|
207
|
+
this.__pinpax__.waiting.sale = !0, this.__pinpax__.asyncResponses.sale = null, this.queue.length > 0 && await o(this, t, l).call(this);
|
|
217
208
|
const c = this;
|
|
218
|
-
return await this.appendToQueue(
|
|
209
|
+
return await this.appendToQueue(a, "make-sale"), new Promise((p) => {
|
|
219
210
|
const h = setInterval(() => {
|
|
220
211
|
if (c.__pinpax__.asyncResponses.sale) {
|
|
221
212
|
const u = c.__pinpax__.asyncResponses.sale;
|
|
@@ -229,82 +220,65 @@ class A extends x {
|
|
|
229
220
|
if (this.__pinpax__.waiting.voucher) throw new Error("Already waiting for voucher");
|
|
230
221
|
if (!s) throw new Error("Folio is required");
|
|
231
222
|
this.__pinpax__.waiting.voucher = !0, this.__pinpax__.asyncResponses.voucher = null;
|
|
232
|
-
const e =
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
const o = this;
|
|
223
|
+
const e = n.getVoucher({ folio: s });
|
|
224
|
+
this.queue.length > 0 && await o(this, t, l).call(this), await this.appendToQueue(e, "get-voucher");
|
|
225
|
+
const a = this;
|
|
236
226
|
return new Promise((c, p) => {
|
|
237
227
|
const h = setTimeout(() => {
|
|
238
|
-
|
|
228
|
+
a.__pinpax__.waiting.voucher = !1, p("Timeout");
|
|
239
229
|
}, 1e4), u = setInterval(() => {
|
|
240
|
-
if (
|
|
241
|
-
const
|
|
242
|
-
|
|
230
|
+
if (a.__pinpax__.asyncResponses.voucher) {
|
|
231
|
+
const k = a.__pinpax__.asyncResponses.voucher;
|
|
232
|
+
a.__pinpax__.asyncResponses.voucher = null, a.__pinpax__.waiting.voucher = !1, clearInterval(u), clearTimeout(h), c(k.voucher);
|
|
243
233
|
}
|
|
244
234
|
}, 100);
|
|
245
235
|
});
|
|
246
236
|
}
|
|
247
237
|
async info() {
|
|
248
|
-
|
|
249
|
-
`);
|
|
250
|
-
await this.appendToQueue(e, "info");
|
|
238
|
+
await this.appendToQueue(n.info(), "info");
|
|
251
239
|
}
|
|
252
240
|
async keepAlive() {
|
|
253
|
-
|
|
254
|
-
`);
|
|
255
|
-
await this.appendToQueue(e, "keep-alive");
|
|
241
|
+
await this.appendToQueue(n.keepAlive(), "keep-alive");
|
|
256
242
|
}
|
|
257
243
|
async restartApp() {
|
|
258
|
-
|
|
259
|
-
`);
|
|
260
|
-
await this.appendToQueue(e, "reset-app");
|
|
244
|
+
await this.appendToQueue(n.restartApp(), "reset-app");
|
|
261
245
|
}
|
|
262
246
|
async getConfig() {
|
|
263
|
-
|
|
264
|
-
`);
|
|
265
|
-
return await this.appendToQueue(e, "get-config");
|
|
247
|
+
return await this.appendToQueue(n.getConfig(), "get-config");
|
|
266
248
|
}
|
|
267
249
|
async hideButtons() {
|
|
268
|
-
|
|
269
|
-
`);
|
|
270
|
-
return await this.appendToQueue(e, "hide-buttons"), await r(this, t, T).call(this);
|
|
250
|
+
return await this.appendToQueue(n.hideButtons(), "hide-buttons"), await o(this, t, g).call(this);
|
|
271
251
|
}
|
|
272
252
|
async showButtons() {
|
|
273
|
-
|
|
274
|
-
`);
|
|
275
|
-
return await this.appendToQueue(e, "show-buttons"), await r(this, t, E).call(this);
|
|
253
|
+
return await this.appendToQueue(n.showButtons(), "show-buttons"), await o(this, t, v).call(this);
|
|
276
254
|
}
|
|
277
255
|
async demo() {
|
|
278
|
-
console.warn("RUNNING DEMO APP BE CAREFUL");
|
|
279
|
-
const s = JSON.stringify({ action: "DEMO" }), e = this.parseStringToBytes(s, `\r
|
|
280
|
-
`);
|
|
281
|
-
return await this.appendToQueue(e, "demo");
|
|
256
|
+
return console.warn("RUNNING DEMO APP, BE CAREFUL"), await this.appendToQueue(n.demo(), "demo");
|
|
282
257
|
}
|
|
283
|
-
async refund({ amount: s = 0, folio: e = null, auth:
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
258
|
+
async refund({ amount: s = 0, folio: e = null, auth: a = null } = {}) {
|
|
259
|
+
return await this.appendToQueue(
|
|
260
|
+
n.refund({
|
|
261
|
+
amount: s,
|
|
262
|
+
folio: e,
|
|
263
|
+
auth: a
|
|
264
|
+
}),
|
|
265
|
+
"refund"
|
|
266
|
+
);
|
|
287
267
|
}
|
|
288
268
|
async readProductionQR() {
|
|
289
|
-
return await
|
|
269
|
+
return await o(this, t, _).call(this, { type: "production" });
|
|
290
270
|
}
|
|
291
271
|
async readQualityAssuranceQR() {
|
|
292
|
-
return
|
|
272
|
+
return o(this, t, _).call(this, { type: "QA" });
|
|
293
273
|
}
|
|
294
274
|
async exit() {
|
|
295
|
-
|
|
296
|
-
`);
|
|
297
|
-
return await this.appendToQueue(e, "exit-app");
|
|
275
|
+
return await this.appendToQueue(n.exit(), "exit-app");
|
|
298
276
|
}
|
|
299
277
|
async init() {
|
|
300
|
-
|
|
301
|
-
`);
|
|
302
|
-
await this.appendToQueue(e, "init-app");
|
|
278
|
+
await this.appendToQueue(n.init(), "init-app");
|
|
303
279
|
}
|
|
304
280
|
}
|
|
305
|
-
t = new WeakSet(),
|
|
306
|
-
f.add(this);
|
|
307
|
-
}, w = function() {
|
|
281
|
+
t = new WeakSet(), w = function() {
|
|
308
282
|
const s = [
|
|
309
283
|
"buttons-status",
|
|
310
284
|
"init-app",
|
|
@@ -325,31 +299,24 @@ t = new WeakSet(), m = function() {
|
|
|
325
299
|
if (this.queue.length === 0) return !0;
|
|
326
300
|
const s = this;
|
|
327
301
|
return new Promise((e) => {
|
|
328
|
-
let
|
|
329
|
-
s.queue.length === 0 && (clearInterval(
|
|
302
|
+
let a = setInterval(() => {
|
|
303
|
+
s.queue.length === 0 && (clearInterval(a), e(!0));
|
|
330
304
|
}, 500);
|
|
331
305
|
});
|
|
332
306
|
}, _ = async function({ type: s = "production" } = {}) {
|
|
333
|
-
const e =
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}, E = async function() {
|
|
341
|
-
const s = JSON.stringify({ action: "FORCESHOW" }), e = this.parseStringToBytes(s, `\r
|
|
342
|
-
`);
|
|
343
|
-
await this.appendToQueue(e, "force-show");
|
|
344
|
-
}, S = async function() {
|
|
307
|
+
const e = n.readQR({ type: s });
|
|
308
|
+
return await this.appendToQueue(e, "read-qr");
|
|
309
|
+
}, g = async function() {
|
|
310
|
+
await this.appendToQueue(n.forceHide(), "force-hide");
|
|
311
|
+
}, v = async function() {
|
|
312
|
+
await this.appendToQueue(n.forceShow(), "force-show");
|
|
313
|
+
}, b = async function() {
|
|
345
314
|
await this.connectMessage();
|
|
346
|
-
},
|
|
315
|
+
}, T = async function() {
|
|
347
316
|
await this.hideButtons();
|
|
348
|
-
}, v = function(s) {
|
|
349
|
-
this.dispatch("payment", s), this.__pinpax__.waiting.sale && (this.__pinpax__.asyncResponses.sale = s);
|
|
350
317
|
}, R = function(s) {
|
|
351
|
-
|
|
318
|
+
this.dispatch("payment", s), this.__pinpax__.waiting.sale && (this.__pinpax__.asyncResponses.sale = s);
|
|
352
319
|
};
|
|
353
320
|
export {
|
|
354
|
-
|
|
321
|
+
D as PinPax
|
|
355
322
|
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";const g=i=>{if(i instanceof Uint8Array)return i;if(Array.isArray(i))return new Uint8Array(i);if(typeof i=="string")return new TextEncoder().encode(i);if(i instanceof ArrayBuffer)return new Uint8Array(i);throw new Error("Unsupported data type")},P=({data:i,asString:e=!0})=>e?Array.from(i).map(n=>n.toString(16).padStart(2,"0")).join(" "):Array.from(i).map(n=>n.toString(16).padStart(2,"0"));var F=Object.defineProperty,L=(i,e,n)=>e in i?F(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,T=(i,e,n)=>L(i,typeof e!="symbol"?e+"":e,n);const f=class d{build(e){return g(e+d.append)}static connection(){return d.instance.build("CONNECT")}static connect(){return d.connection()}static credits(){return d.instance.build("CREDITS")}static hi(){return d.instance.build("HI")}static ara(){return d.instance.build("ARA")}static custom(e){return d.instance.build(e)}};T(f,"append",`
|
|
2
|
+
`),T(f,"instance");let b=f;b.instance=new b;var H=Object.defineProperty,B=(i,e,n)=>e in i?H(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,$=(i,e,n)=>B(i,typeof e!="symbol"?e+"":e,n);const w=class c{build(e){return c.asHex?P({data:e,asString:!1}):g(e)}serialBoardroidSumHex(e){let n=0;for(let a=0;a<e.length;a++)a===0||a===11||(n+=e[a]);return n}boardroidCheckSum(e){return e[11]=this.serialBoardroidSumHex(e),e}static connection({channel:e=1}={}){const n=c.instance.boardroidCheckSum(new Uint8Array([241,5+e,0,0,0,0,0,0,0,0,242,248]));return c.instance.build(n)}static coinPurseConfiguration({enable:e=!1,high:n=255,low:a=255}={}){const t=c.instance.boardroidCheckSum(new Uint8Array([241,193,e?1:0,n,a,0,0,0,0,0,242,0]));return c.instance.build(t)}static coinPurseDispense({$50c:e=0,$1:n=0,$2:a=0,$5:t=0,$10:s=0}={}){if([e,n,a,t,s].some(u=>isNaN(u)||typeof u=="string"))throw new Error("One of the values is not a number");if(e<1&&n<1&&a<1&&t<1&&s<1)throw new Error("No coins to dispense");const o=c.instance.boardroidCheckSum(new Uint8Array([241,198,e,n,a,t,s,0,0,0,242,0]));return c.instance.build(o)}static coinPurseReadTubes(){const e=c.instance.boardroidCheckSum(new Uint8Array([241,194,0,0,0,0,0,0,0,0,242,0]));return c.instance.build(e)}static banknotePurseICTConfigure({enable:e=!1,scrow:n=!1}={}){const a=e?255:0,t=n?255:0,s=c.instance.boardroidCheckSum(new Uint8Array([241,192,a,a,t,t,0,0,0,0,242,0]));return c.instance.build(s)}static banknotePurseOtherConfigure({enable:e=!1,scrow:n=!1}={}){const a=e?1:0,t=n?1:0,s=c.instance.boardroidCheckSum(new Uint8Array([241,192,a,t,0,0,0,0,0,0,242,0]));return c.instance.build(s)}static banknotePurseICTDispense({quantity:e=1,denomination:n=20}){if(e<1)throw new Error("No banknotes to dispense");if([20,50,100,200,500].indexOf(n)===-1)throw new Error("Invalid denomination");const a=[20,50,100,200,500].indexOf(n),t=c.instance.boardroidCheckSum(new Uint8Array([241,197,a,e,0,0,0,0,0,0,242,0]));return c.instance.build(t)}static banknotePurseOtherDispense({$20:e=0,$50:n=0,$100:a=0,$200:t=0,$500:s=0,$1000:o=0}={}){if([e,n,a,t,s,o].some(m=>isNaN(m)||typeof m=="string"))throw new Error("One of the values is not a number");if(e<1&&n<1&&a<1&&t<1&&s<1&&o<1)throw new Error("No banknotes to dispense");const u=c.instance.boardroidCheckSum(new Uint8Array([241,197,e,n,a,t,s,o,0,0,242,0]));return c.instance.build(u)}static banknotePurseAcceptInScrow(){const e=c.instance.boardroidCheckSum(new Uint8Array([241,196,1,0,0,0,0,0,0,0,242,0]));return c.instance.build(e)}static banknotePurseRejectInScrow(){const e=c.instance.boardroidCheckSum(new Uint8Array([241,196,0,0,0,0,0,0,0,0,242,0]));return c.instance.build(e)}static banknotePurseSaveMemory({channel:e=null,$20:n=null,$50:a=null,$100:t=null,$200:s=null,$500:o=null,$1000:u=null}={channel:null,$20:null,$50:null,$100:null,$200:null,$500:null,$1000:null}){if(e===null||n===null||a===null||t===null||s===null||o===null||u===null)throw new Error("One of the values is not defined: "+JSON.stringify({channel:e,$20:n,$50:a,$100:t,$200:s,$500:o,$1000:u}));const m=c.instance.boardroidCheckSum(new Uint8Array([241,200,e,0,n,a,t,s,o,u,242,0]));return c.instance.build(m)}static banknotePurseReadRecycler(){const e=c.instance.boardroidCheckSum(new Uint8Array([241,195,0,0,0,0,0,0,0,0,242,181]));return c.instance.build(e)}static cardReaderDisable(){const e=c.instance.boardroidCheckSum(new Uint8Array([241,205,0,0,0,0,0,0,0,0,242,0]));return c.instance.build(e)}static cardReaderDispense({selection:e=1,second_selection:n=null,sensor:a=!0,seconds:t=null,price:s=0}={selection:1,second_selection:null,sensor:!0,seconds:null,price:0}){const o=s/256,u=s%256,m=e+9;let p=0;n&&(p=n+9);let D=0;a||(t||(t=1.5),D=Math.round(t*6.2));const M=c.instance.boardroidCheckSum(new Uint8Array([241,205,1,m,p,D,o,u,0,0,242,0]));return c.instance.build(M)}static coolingRelayConfigure({enable:e=!0}={}){const n=c.instance.boardroidCheckSum(new Uint8Array([241,204,e?1:0,0,0,0,0,0,0,0,242,0]));return c.instance.build(n)}static readTemperature(){const e=c.instance.boardroidCheckSum(new Uint8Array([241,203,0,0,0,0,0,0,0,0,242,0]));return c.instance.build(e)}static dispense({selection:e=1,second_selection:n=null,sensor:a=!0,seconds:t=null}={selection:1,second_selection:null,sensor:!0,seconds:null}){e+=9;const s=e;let o=0;n&&(n+=9,o=n);let u=0;a||(t||(t=1.5),u=Math.round(t*6.2));const m=c.instance.boardroidCheckSum(new Uint8Array([241,199,s,o,u,0,0,0,0,0,242,0]));return c.instance.build(m)}static customCode(e){typeof e[0]=="string"&&(e=e.map(a=>parseInt(a,16)));const n=c.instance.boardroidCheckSum(new Uint8Array(e));return c.instance.build(n)}};$(w,"asHex",!1),$(w,"instance");let y=w;y.instance=new y;var J=Object.defineProperty,G=(i,e,n)=>e in i?J(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,O=(i,e,n)=>G(i,typeof e!="symbol"?e+"":e,n);const v=class r{build(e){const n=this.jofemarCheckSum(e);return r.asHex?P({data:new Uint8Array(n),asString:!1}):g(n)}calcCheckSums(e){const n=[];return n.push(e&255|240),n.push(e&255|15),n}jofemarCheckSum(e){let n=0;for(let t=0;t<e.length;t++)n+=e[t];const a=this.calcCheckSums(n);return e.push(a[0]),e.push(a[1]),e.push(3),new Uint8Array(e)}getTrayAndChannelBySelection(e){if(e=parseInt(e)+109,e=e.toString(),e.length!==3)throw new Error("Invalid selection");const n=(parseInt(e.substring(0,2))+128).toString(16).padStart(2,"0"),a=(parseInt(e.substring(2,3))+128).toString(16).padStart(2,"0");return{channel:parseInt(a,16),tray:parseInt(n,16)}}makeDisplayMessage(e=""){e=e.padEnd(32," ");const n=[];for(let a=0;a<32;a++)n.push(e.charCodeAt(a));return n}makeTimeFormat(e){if(!(e instanceof Date))throw new Error("Invalid date, must be an instance of Date");const n=e.getHours().toString().padStart(2,"0"),a=e.getMinutes().toString().padStart(2,"0"),t=e.getDate().toString().padStart(2,"0"),s=(e.getMonth()+1).toString().padStart(2,"0"),o=e.getFullYear().toString().substring(2,4),u=`${n}:${a} ${t}-${s}-${o}`,m=[];for(let p=0;p<14;p++)m.push(u.charCodeAt(p));return m}static connection({channel:e=1}={}){return r.instance.build([2,48,48,128+e,83,255,255])}static dispense({machineChannel:e=1,selection:n=1,cart:a=!1}={machineChannel:1,selection:1,cart:!1}){if(n=parseInt(n),isNaN(n)||n<1||n>130)throw new Error("Invalid selection");const{channel:t,tray:s}=r.instance.getTrayAndChannelBySelection(n);return r.instance.build([2,48,48,128+e,a?77:86,s,t])}static endCartDispense({machineChannel:e=1}={}){return r.instance.build([2,48,48,128+e,77,128,128])}static collect({machineChannel:e=1}={}){return r.instance.build([2,48,48,128+e,78,255,255])}static reset({machineChannel:e=1,type:n="soldOut"}={}){let a=128;return n==="waiting"?a=129:n==="machine"&&(a=255),r.instance.build([2,48,48,128+e,82,a,255])}static status({machineChannel:e=1}={}){return r.instance.build([2,48,48,128+e,83,255,255])}static lights({machineChannel:e=1,type:n="on"}={}){const a=n==="on"?129:128;return r.instance.build([2,48,48,128+e,76,a,255])}static program({machineChannel:e=1,param1:n=255,param2:a=255}={}){return r.instance.build([2,48,48,128+e,80,n,a])}static programDisplayLanguage({machineChannel:e=1,language:n="spanish"}={}){const a={spanish:48,english:49,french:50};if(!a[n])throw new Error("Invalid language");return r.program({machineChannel:e,param1:73,param2:a[n]})}static programBeeper({machineChannel:e=1,enable:n=!0}){return r.program({machineChannel:e,param1:90,param2:n?49:48})}static programDisableWorkingTemperature({machineChannel:e=1}){return r.program({machineChannel:e,param1:84,param2:128})}static programDisableThermometer({machineChannel:e=1}){return r.programDisableWorkingTemperature({machineChannel:e})}static programWorkingTemperature({machineChannel:e=1,degrees:n=.5,machineType:a="esplus"}={}){typeof n=="string"&&(n=parseFloat(n));const t=a==="iceplus"?6.5:32,s=a==="iceplus"?-25:.5;if(isNaN(n)||n<s||n>t||n%.5!==0)throw new Error("Invalid degrees, must be a multiple of 0.5 and between 0.5 and 32");let o=n*2+128;return a==="iceplus"&&(o+=51),o=Math.ceil(o),r.program({param1:84,param2:o,machineChannel:e})}static programIsolationTray({machineChannel:e=1,tray:n=0}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<0||n>12)throw new Error("Invalid tray, valid range is 0 to 12");const a=n===0?128:n+139;return r.program({param1:66,param2:a,machineChannel:e})}static programTimeToStandbyAfterCollect({machineChannel:e=1,seconds:n=15}={}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<15||n>120)throw new Error("Invalid seconds, valid range is 15 to 120");const a=128+n;return r.program({param1:70,param2:a,machineChannel:e})}static programTimeToStandbyWithoutCollect({machineChannel:e=1,minutes:n=1}={}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>10)throw new Error("Invalid minutes, valid range is 1 to 10");const a=128+n;return r.program({param1:72,param2:a,machineChannel:e})}static programElevatorSpeed({machineChannel:e=1,speed:n="high"}={}){const a={high:49,low:48};if(!a[n])throw new Error("Invalid speed, valid speeds are 'high' and 'low'");return r.program({param1:118,param2:a[n],machineChannel:e})}static programTemperatureExpiration({machineChannel:e=1,enable:n=!1}){return r.program({machineChannel:e,param1:99,param2:n?49:48})}static programMachineAddress({machineChannel:e=1,address:n=1}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>31)throw new Error("Invalid address, valid range is 1 to 31");return r.program({param1:100,param2:128+n,machineChannel:e})}static programTemperatureBeforeExpiration({machineChannel:e=1,degrees:n=.5}){if(typeof n=="string"&&(n=parseFloat(n)),isNaN(n)||n<.5||n>30||n%.5!==0)throw new Error("Invalid degrees, must be a multiple of 0.5 and valid range is 0.5 to 30");const a=128+n*2;return r.program({param1:101,param2:a,machineChannel:e})}static programTimeBeforeExpirationByTemperature({machineChannel:e=1,minutes:n=1}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>120)throw new Error("Invalid minutes, valid range is 1 to 120");const a=128+n;return r.program({param1:102,param2:a,machineChannel:e})}static programTemperatureScale({machineChannel:e=1,scale:n="celsius"}={}){const a={celsius:67,fahrenheit:70};if(!a[n])throw new Error("Invalid scale, valid scales are 'celsius' and 'fahrenheit'");return r.program({param1:103,param2:a[n],machineChannel:e})}static programVoltageEngine({machineChannel:e=1,selection:n=1,voltage:a=5}={}){if(typeof a=="string"&&(a=parseFloat(a)),typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>130)throw new Error("Invalid selection, valid range is 1 to 130");if(isNaN(a)||a<5||a>9.5||a%.5!==0)throw new Error("Invalid voltage, valid range is 5 to 9.5");const t=109+n,s=128+(a-5)*2;return r.instance.build([2,48,48,128+e,71,t,s])}static programPushOverProducts({machineChannel:e=1,selection:n=1,enable:a=!0}={}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>130)throw new Error("Invalid selection, valid range is 1 to 130");const t=109+n,s=a?49:48;return r.instance.build([2,48,48,128+e,79,t,s])}static programChannelRunningAfterDispense({machineChannel:e=1,selection:n=1,seconds:a=0}={}){if(typeof n=="string"&&(n=parseInt(n)),typeof a=="string"&&(a=parseFloat(a)),isNaN(n)||n<1||n>130)throw new Error("Invalid selection, valid range is 1 to 130");if(isNaN(a)||a<0||a>10||a%.1!==0)throw new Error("Invalid seconds, valid range is 0.0 to 10.0 with a step of 0.1");const t=109+n;a=10*parseFloat(a.toFixed(1));const s=128+a;return r.instance.build([2,48,48,128+e,69,t,s])}static checkData({machineChannel:e=1,type:n=255,aux:a=255}){return r.instance.build([2,48,48,128+e,67,n,a])}static getDisplayLanguage({machineChannel:e=1}){return r.checkData({machineChannel:e,type:73})}static getBeeper({machineChannel:e=1}){return r.checkData({machineChannel:e,type:90})}static getWorkingTemperature({machineChannel:e=1}){return r.checkData({machineChannel:e,type:84})}static getIsolationTray({machineChannel:e=1}){return r.checkData({machineChannel:e,type:66})}static getProgramVersion({machineChannel:e=1}){return r.checkData({machineChannel:e,type:80})}static getFaults({machineChannel:e=1}){return r.checkData({machineChannel:e,type:83})}static getMachineId({machineChannel:e=1}){return r.checkData({machineChannel:e,type:78})}static getCurrentTemperature({machineChannel:e=1}){return r.checkData({machineChannel:e,type:116})}static getTimeToStandbyAfterCollect({machineChannel:e=1}){return r.checkData({machineChannel:e,type:70})}static getTimeToStandbyWithoutCollect({machineChannel:e=1}){return r.checkData({machineChannel:e,type:72})}static getElevatorSpeed({machineChannel:e=1}){return r.checkData({machineChannel:e,type:118})}static getTemperatureExpiration({machineChannel:e=1}){return r.checkData({machineChannel:e,type:99})}static getTemperatureBeforeExpiration({machineChannel:e=1}){return r.checkData({machineChannel:e,type:101})}static getTimeBeforeExpirationByTemperature({machineChannel:e=1}){return r.checkData({machineChannel:e,type:102})}static getTemperatureScale({machineChannel:e=1}){return r.checkData({machineChannel:e,type:103})}static getClockRegisters({machineChannel:e=1}){return r.checkData({machineChannel:e,type:114})}static getMachineActivity({machineChannel:e=1}){return r.checkData({machineChannel:e,type:65})}static getVoltageEngine({machineChannel:e=1,selection:n=1}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>130)throw new Error("Invalid selection, valid range is 1 to 130");return r.checkData({machineChannel:e,type:71,aux:109+n})}static getChannelPresence({machineChannel:e=1,selection:n=1}={}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>130)throw new Error("Invalid selection, valid range is 1 to 130");return r.checkData({machineChannel:e,type:67,aux:109+n})}static getPushOverProducts({machineChannel:e=1,selection:n=1}={}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>130)throw new Error("Invalid selection, valid range is 1 to 130");return r.checkData({machineChannel:e,type:79,aux:109+n})}static getChannelRunningAfterDispense({machineChannel:e=1,selection:n=1}={}){if(typeof n=="string"&&(n=parseInt(n)),isNaN(n)||n<1||n>130)throw new Error("Invalid selection, valid range is 1 to 130");return r.checkData({machineChannel:e,type:69,aux:109+n})}static displayConfig({machineChannel:e=1,type:n=128,param2:a=[]}={}){return r.instance.build([2,48,48,128+e,68,n,...a])}static setDisplayStandbyMessage({machineChannel:e=1,message:n=""}={}){n=n.substring(0,32);const a=r.instance.makeDisplayMessage(n);return r.displayConfig({machineChannel:e,type:128,param2:a})}static setDisplayMessageTemporarily({machineChannel:e=1,message:n="",seconds:a=1}){if(n=n.substring(0,32),typeof a=="string"&&(a=parseInt(a)),isNaN(a)||a<1||a>125)throw new Error("Invalid seconds, valid range is 1 to 125");const t=r.instance.makeDisplayMessage(n),s=128+a;return r.displayConfig({machineChannel:e,type:s,param2:t})}static setDisplayMessageUnlimited({machineChannel:e=1,message:n=""}){n=n.substring(0,32);const a=r.instance.makeDisplayMessage(n);return r.displayConfig({machineChannel:e,type:255,param2:a})}static programClock({machineChannel:e=1,date:n=new Date}={}){if(!(n instanceof Date))throw new Error("Invalid date, must be an instance of Date");return r.instance.build([2,48,48,128+e,114,...r.instance.makeTimeFormat(n)])}static eventsConfig({machineChannel:e=1,event:n=null,enable:a=!0}={}){if(n===null)throw new Error("Invalid event");const t=a?49:48;return r.instance.build([2,48,48,128+e,65,n,t])}static eventEnable({machineChannel:e=1,event:n=null}={}){if(n===null)throw new Error("Invalid event");const a=parseInt(n,16);if(isNaN(a)||a<38||a>100)throw new Error("Invalid event");return r.eventsConfig({machineChannel:e,event:n,enable:!0})}static eventDisable({machineChannel:e=1,event:n=null}={}){if(n===null)throw new Error("Invalid event");const a=parseInt(n,16);if(isNaN(a)||a<38||a>100)throw new Error("Invalid event");return r.eventsConfig({machineChannel:e,event:n,enable:!1})}static sendCustomCode({code:e=[]}={}){if(e.length<5)throw new Error("Invalid code, minimum length is 5");return r.instance.build(e)}};O(v,"asHex",!1),O(v,"instance");let E=v;E.instance=new E;var j=Object.defineProperty,W=(i,e,n)=>e in i?j(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,U=(i,e,n)=>W(i,typeof e!="symbol"?e+"":e,n);const S=class h{serialLockerCmdMaker(e){let n;try{n=new Uint8Array(e.length+8),n.set(e,2),n[0]=2,n[1]=e.length+4,n[n.length-2]=3;let a=0;for(let o=1;o<e.length;o++)a+=e[o],a*=parseInt(Math.pow(2,o-1).toString());n[e.length+2]=a%256,n[e.length+3]=666*3%256,n[e.length+4]=666*8%256;let t=0;for(let o=3;o<e.length+5;o++)t+=n[o];n[e.length+5]=t%256;let s=0;for(let o=0;o<n.length-1;o++)s^=n[o];n[n.length-1]=s}catch(a){throw n=new Uint8Array(0),a instanceof Error?new Error(`Error generating command: ${a.message}`):new Error("Error generating command: Unknown error")}return n}serialLockerHexCmd(e){const n=this.serialLockerCmdMaker(e),a=[];for(let t=0;t<n.length;t++){const s=n[t].toString(16).padStart(2,"0");a.push(s)}return a}validateCell(e=1){let n;if(typeof e=="string"?n=parseInt(e):n=e,isNaN(n)||n<1||n>90)throw new Error("Invalid cell number");return n}serialLockerGetStatusCellCmd({cell:e=1,channel:n=1}={}){return e=this.validateCell(e),this.build(new Uint8Array([16,n,e]))}serialLockerGetLightScanCmd({since:e=0,until:n=10,channel:a=1}={}){return this.build(new Uint8Array([32,a,e,n]))}parseCellToColumnRow(e){const n=Math.floor((e-1)/10)+1;let a=e%8;return a===0&&(a=8),[n,a]}serialLockerGetConfigureCellCmd({enable:e=!0,column:n=0,row:a=10,channel:t=1}={}){if(n<0||n>8)throw new Error("Invalid column number");if(a<0||a>10)throw new Error("Invalid row number");let s=1;return e||(s=0),this.build(new Uint8Array([48,t,n,a,s]))}serialLockerGetOpenCmd({cell:e=1,channel:n=1}={}){e=this.validateCell(e);const a=666,t=a%256,s=Math.floor(a/3)%256;return this.build(new Uint8Array([64,n,e,t,s]))}build(e){return h.asHex?this.serialLockerHexCmd(e):g(this.serialLockerCmdMaker(e))}static connection({channel:e=1}={}){return h.instance.build(new Uint8Array([0,e]))}static openCell({cell:e=1,channel:n=1}={}){return e=h.instance.validateCell(e),h.instance.serialLockerGetOpenCmd({cell:e,channel:n})}static statusCell({cell:e=1,channel:n=1}={}){return e=h.instance.validateCell(e),h.instance.serialLockerGetStatusCellCmd({cell:e,channel:n})}static lightScan({since:e=0,until:n=10,channel:a=1}={}){if(e<0||e>10)throw new Error("Invalid since number");if(n<0||n>10)throw new Error("Invalid until number");return h.instance.serialLockerGetLightScanCmd({since:e,until:n,channel:a})}static enableCell({cell:e=1,channel:n=1}={}){e=h.instance.validateCell(e);const[a,t]=h.instance.parseCellToColumnRow(e);return h.instance.serialLockerGetConfigureCellCmd({enable:!0,column:a,row:t,channel:n})}static disableCell({cell:e=1,channel:n=1}={}){e=h.instance.validateCell(e);const[a,t]=h.instance.parseCellToColumnRow(e);return h.instance.serialLockerGetConfigureCellCmd({enable:!1,column:a,row:t,channel:n})}};U(S,"asHex",!1),U(S,"instance");let k=S;k.instance=new k;var V=Object.defineProperty,Q=(i,e,n)=>e in i?V(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,x=(i,e,n)=>Q(i,typeof e!="symbol"?e+"":e,n);const I=class l{build(e){return g(e+l.append)}static connection(){const e=JSON.stringify({action:"CONNECT"});return l.instance.build(e)}static connect(){return l.connection()}static custom(e){if(typeof e!="string")throw new Error("Invalid string");return l.instance.build(e)}static readQR({type:e="production"}={type:"production"}){const n=JSON.stringify({action:"READQR",server:e==="production"?"PROD":"QA"});return l.instance.build(n)}static forceHide(){const e=JSON.stringify({action:"FORCEHIDE"});return l.instance.build(e)}static forceShow(){const e=JSON.stringify({action:"FORCESHOW"});return l.instance.build(e)}static makeSale({amount:e=0,reference:n=null}={}){if(e<=0)throw new Error("Invalid amount");if(typeof e!="number"&&(e=parseFloat(e)),isNaN(e))throw new Error("Invalid amount");if(n&&!/^[A-Z-a-z0-9_\s]+$/g.test(n))throw new Error("Reference must be alphanumeric and the only symbol allowed is midlescore or underscore (- _) or null");const a=e.toFixed(2),t=JSON.stringify({action:"PAYMENT",amount:a,reference:n});return l.instance.build(t)}static getVoucher({folio:e=null}={}){if(!e)throw new Error("Folio must be a number");const n=JSON.stringify({action:"GETVOUCHER",folio:e});return l.instance.build(n)}static info(){const e=JSON.stringify({action:"DEVICEINFO"});return l.instance.build(e)}static keepAlive(){const e=JSON.stringify({action:"KEEPALIVE"});return l.instance.build(e)}static restartApp(){const e=JSON.stringify({action:"RESETAPP"});return l.instance.build(e)}static getConfig(){const e=JSON.stringify({action:"GETCONFIG"});return l.instance.build(e)}static hideButtons(){const e=JSON.stringify({action:"HIDEBUTTONS"});return l.instance.build(e)}static showButtons(){const e=JSON.stringify({action:"SHOWBUTTONS"});return l.instance.build(e)}static demo(){const e=JSON.stringify({action:"DEMO"});return l.instance.build(e)}static refund({amount:e=0,folio:n=null,auth:a=null}={}){if(e<=0)throw new Error("Invalid amount");if(typeof e!="number"&&(e=parseFloat(e)),isNaN(e))throw new Error("Invalid amount");if(!n)throw new Error("Folio must be a number");if(!a)throw new Error("Auth must be a number");const t=e.toFixed(2),s=JSON.stringify({action:"REFUND",amount:t,folio:n,auth:a});return l.instance.build(s)}static exit(){const e=JSON.stringify({action:"EXIT"});return l.instance.build(e)}static init(){const e=JSON.stringify({action:"INIT"});return l.instance.build(e)}};x(I,"append",`\r
|
|
3
|
+
`),x(I,"instance");let N=I;N.instance=new N;var Y=Object.defineProperty,q=(i,e,n)=>e in i?Y(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,z=(i,e,n)=>q(i,e+"",n);const R=class C{build(e){return e[3]=this.withChecksum(e),g(e)}withChecksum(e){let n=0;return e.forEach((a,t)=>{t!==3&&(n+=a)}),n}static connection(e=1){return C.instance.build([160,e,0,161])}static deactivate(e=1){return C.connection(e)}static activate(){return C.instance.build([160,1,1,162])}static custom(e){return C.instance.build(e)}};z(R,"instance");let A=R;A.instance=new A;exports.e=A;exports.i=b;exports.l=y;exports.o=E;exports.s=N;exports.u=k;
|