@danidoble/webserial 4.2.16 → 4.3.0
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/arduino.cjs +1 -1
- package/dist/arduino.js +4 -3
- package/dist/boardroid.cjs +1 -1
- package/dist/boardroid.js +4 -3
- package/dist/hopper.cjs +2 -0
- package/dist/hopper.js +226 -0
- package/dist/jofemar.cjs +1 -1
- package/dist/jofemar.js +7 -6
- package/dist/kernel-Bd3IuxSw.cjs +1 -0
- package/dist/kernel-XY8jLkNB.js +875 -0
- package/dist/kernel.cjs +2 -2
- package/dist/kernel.js +4 -3
- package/dist/locker.cjs +1 -1
- package/dist/locker.js +14 -13
- package/dist/pinpad.cjs +12 -12
- package/dist/pinpad.js +26 -25
- package/dist/pinpax.cjs +4 -4
- package/dist/pinpax.js +4 -3
- package/dist/relay.cjs +1 -1
- package/dist/relay.js +8 -7
- package/dist/webserial-core-DGKQCs5a.js +776 -0
- package/dist/webserial-core-DlH0cFSH.cjs +4 -0
- package/dist/webserial.cjs +2 -2
- package/dist/webserial.js +25 -22
- package/package.json +4 -4
- package/dist/kernel-BxvweHTG.cjs +0 -4
- package/dist/kernel-C4PiwwCb.js +0 -1647
package/dist/pinpad.js
CHANGED
|
@@ -6,7 +6,8 @@ var bn = (n, i, t) => i in n ? yn(n, i, { enumerable: !0, configurable: !0, writ
|
|
|
6
6
|
var Ce = (n, i, t) => bn(n, typeof i != "symbol" ? i + "" : i, t), Pn = (n, i, t) => i.has(n) || Te("Cannot " + t);
|
|
7
7
|
var Ae = (n, i, t) => i.has(n) ? Te("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(n) : i.set(n, t);
|
|
8
8
|
var p = (n, i, t) => (Pn(n, i, "access private method"), t);
|
|
9
|
-
import { K as vn, a as wn,
|
|
9
|
+
import { K as vn, a as wn, i as G, b as Re, w as Oe } from "./kernel-XY8jLkNB.js";
|
|
10
|
+
import { h as xe } from "./webserial-core-DGKQCs5a.js";
|
|
10
11
|
var En = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
11
12
|
function $(n) {
|
|
12
13
|
return En.charAt(n);
|
|
@@ -3671,25 +3672,25 @@ A.getAdapter = Si.getAdapter;
|
|
|
3671
3672
|
A.HttpStatusCode = ae;
|
|
3672
3673
|
A.default = A;
|
|
3673
3674
|
const {
|
|
3674
|
-
Axios:
|
|
3675
|
-
AxiosError:
|
|
3676
|
-
CanceledError:
|
|
3677
|
-
isCancel:
|
|
3678
|
-
CancelToken:
|
|
3679
|
-
VERSION:
|
|
3680
|
-
all:
|
|
3681
|
-
Cancel:
|
|
3682
|
-
isAxiosError:
|
|
3683
|
-
spread:
|
|
3684
|
-
toFormData:
|
|
3685
|
-
AxiosHeaders:
|
|
3686
|
-
HttpStatusCode:
|
|
3687
|
-
formToJSON:
|
|
3688
|
-
getAdapter:
|
|
3689
|
-
mergeConfig:
|
|
3675
|
+
Axios: Rs,
|
|
3676
|
+
AxiosError: Os,
|
|
3677
|
+
CanceledError: xs,
|
|
3678
|
+
isCancel: Ds,
|
|
3679
|
+
CancelToken: Is,
|
|
3680
|
+
VERSION: Bs,
|
|
3681
|
+
all: Ns,
|
|
3682
|
+
Cancel: Vs,
|
|
3683
|
+
isAxiosError: Us,
|
|
3684
|
+
spread: Ls,
|
|
3685
|
+
toFormData: Ms,
|
|
3686
|
+
AxiosHeaders: ks,
|
|
3687
|
+
HttpStatusCode: Fs,
|
|
3688
|
+
formToJSON: js,
|
|
3689
|
+
getAdapter: qs,
|
|
3690
|
+
mergeConfig: Ks
|
|
3690
3691
|
} = A;
|
|
3691
3692
|
var h, Ri, Oi, xi, oe, Di, Ii, Bi, Ni, Vi, Ui, Li, Mi, ki, Fi, dt, _t, ji, gt, qi, tt, Ki, D, Hi, Wi, ce, Xi, zi, Gi, ue, he, mt, le, $i, j, q, Bt, fe, yt, pe, de, Ji, _e, ge, Qi, Zi, ot, me, Yi, tn, en, Nt, nn, rn, ye, sn, an, on, cn, un, hn, ln, fn, pn, be, Pe, dn, _n, gn;
|
|
3692
|
-
class
|
|
3693
|
+
class Hs extends vn {
|
|
3693
3694
|
constructor({
|
|
3694
3695
|
filters: t = null,
|
|
3695
3696
|
config_port: e = {
|
|
@@ -3870,7 +3871,7 @@ class Ks extends vn {
|
|
|
3870
3871
|
});
|
|
3871
3872
|
if (this.__internal__.device.type = "pinpad", !wn())
|
|
3872
3873
|
throw new Error("Crypto not supported in this browser");
|
|
3873
|
-
if (
|
|
3874
|
+
if (xe.getCustom(this.typeDevice, r))
|
|
3874
3875
|
throw new Error(`Device ${this.typeDevice} ${r} already exists`);
|
|
3875
3876
|
this.__internal__.time.response_connection = 3e3, this.__internal__.time.response_general = 5e3, this.__internal__.serial.delay_first_connection = 1e3, this.environment = c, a && (this.username = a), o && (this.password = o), p(this, h, Oi).call(this), p(this, h, Ri).call(this);
|
|
3876
3877
|
}
|
|
@@ -4023,7 +4024,7 @@ class Ks extends vn {
|
|
|
4023
4024
|
localStorage.removeItem("ppLoginResponse"), localStorage.removeItem("ppRSAKey"), localStorage.removeItem("ppPublicIP");
|
|
4024
4025
|
}
|
|
4025
4026
|
async checkPositionPermission() {
|
|
4026
|
-
if (!
|
|
4027
|
+
if (!Re())
|
|
4027
4028
|
throw new Error("Geolocation not supported");
|
|
4028
4029
|
return new Promise((t, e) => {
|
|
4029
4030
|
navigator.permissions.query({ name: "geolocation" }).then((r) => {
|
|
@@ -4183,7 +4184,7 @@ class Ks extends vn {
|
|
|
4183
4184
|
}
|
|
4184
4185
|
}
|
|
4185
4186
|
h = new WeakSet(), Ri = function() {
|
|
4186
|
-
|
|
4187
|
+
xe.add(this);
|
|
4187
4188
|
}, Oi = function() {
|
|
4188
4189
|
const t = [
|
|
4189
4190
|
"pp:processing-card",
|
|
@@ -4547,7 +4548,7 @@ qi = function(t, e, r = !1) {
|
|
|
4547
4548
|
const t = /* @__PURE__ */ new Date(), e = t.getHours().toString().padStart(2, "0"), r = t.getMinutes().toString().padStart(2, "0");
|
|
4548
4549
|
return e + r;
|
|
4549
4550
|
}, Qi = async function() {
|
|
4550
|
-
return this.__pinPad__.config.latitude && this.__pinPad__.config.longitude ? this.latitudeLongitude : (this.__pinPad__.config.latitude = null, this.__pinPad__.config.longitude = null,
|
|
4551
|
+
return this.__pinPad__.config.latitude && this.__pinPad__.config.longitude ? this.latitudeLongitude : (this.__pinPad__.config.latitude = null, this.__pinPad__.config.longitude = null, Re() ? new Promise((t) => {
|
|
4551
4552
|
navigator.geolocation.getCurrentPosition(
|
|
4552
4553
|
(e) => {
|
|
4553
4554
|
this.__pinPad__.config.latitude = e.coords.latitude, this.__pinPad__.config.longitude = e.coords.longitude, t(this.latitudeLongitude);
|
|
@@ -4738,7 +4739,7 @@ qi = function(t, e, r = !1) {
|
|
|
4738
4739
|
}, 500);
|
|
4739
4740
|
});
|
|
4740
4741
|
}, an = async function(t) {
|
|
4741
|
-
return await
|
|
4742
|
+
return await Oe(t * 1e3);
|
|
4742
4743
|
}, on = async function(t) {
|
|
4743
4744
|
let e = this.url + this.__pinPad__.constants.uris.consult;
|
|
4744
4745
|
return t > 1 && this.environment === "production" && (e = e.replace(
|
|
@@ -4994,7 +4995,7 @@ hn = function(t) {
|
|
|
4994
4995
|
this.dispatch("pp:response", this.__pinPad__.operation.ignore.responseGlobal);
|
|
4995
4996
|
else {
|
|
4996
4997
|
const t = this.parseStringToBytes(this.__pinPad__.operation.ignore.C93Global, "");
|
|
4997
|
-
await this.appendToQueue(t, "code93"), await
|
|
4998
|
+
await this.appendToQueue(t, "code93"), await Oe(1400), this.dispatch("pp:response", this.__pinPad__.operation.ignore.responseGlobal);
|
|
4998
4999
|
}
|
|
4999
5000
|
}, Pe = function(t) {
|
|
5000
5001
|
const e = {
|
|
@@ -5073,5 +5074,5 @@ hn = function(t) {
|
|
|
5073
5074
|
this.__pinPad__.config.read.AppId = "", this.__pinPad__.config.read.AppIdLabel = "", this.__pinPad__.config.read.Arqc = "", this.__pinPad__.config.read.ChipName = "", this.__pinPad__.config.read.ReadCTLS = "", this.__pinPad__.config.read.NB_Data = "", this.__pinPad__.config.read.NB_ksn = "", this.__pinPad__.config.read.PIN = "", this.__pinPad__.config.read.POSEM = "", this.__pinPad__.config.read.Tags = "", this.__pinPad__.config.read.Type = "", this.__pinPad__.config.read.Chip = "", this.__pinPad__.config.read.ChipNameEnc = "", this.__pinPad__.operation.ignore.error = "", this.__pinPad__.operation.ignore.C93Global = "", this.__pinPad__.operation.folio = "", this.__pinPad__.operation.authorization = "", this.__pinPad__.config.tokenizeTRX = !1;
|
|
5074
5075
|
};
|
|
5075
5076
|
export {
|
|
5076
|
-
|
|
5077
|
+
Hs as PinPad
|
|
5077
5078
|
};
|
package/dist/pinpax.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var R=Object.defineProperty;var
|
|
2
|
-
`,o(this,t,m).call(this),
|
|
3
|
-
`);await this.appendToQueue(this.stringArrayToUint8Array(a),"custom")}async connectMessage(){await this.appendToQueue(n.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=n.s.makeSale({amount:s,reference:e});this.__pinpax__.waiting.sale=!0,this.__pinpax__.asyncResponses.sale=null,this.queue.length>0&&await o(this,t,
|
|
4
|
-
`);await this.appendToQueue(e,"login")}}t=new WeakSet,m=function(){const s=["buttons-status","init-app","connectMessage","voucher","info","keep-alive","reset-app","get-config","payment","error","refund","login"];for(const e of s)this.serialRegisterAvailableListener(e)},
|
|
1
|
+
"use strict";var R=Object.defineProperty;var d=r=>{throw TypeError(r)};var E=(r,i,s)=>i in r?R(r,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[i]=s;var y=(r,i,s)=>E(r,typeof i!="symbol"?i+"":i,s),I=(r,i,s)=>i.has(r)||d("Cannot "+s);var f=(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);var o=(r,i,s)=>(I(r,i,"access private method"),s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("./kernel-Bd3IuxSw.cjs"),n=require("./relay-BsUsBpOv.cjs"),w=require("./webserial-core-DlH0cFSH.cjs");var t,m,_,l,g,v,b,x,T;class A extends C.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});f(this,t);y(this,"__pinpax__",{server:"DEV",bussinessId:null,encriptionKey:null,apiKey:null,asyncResponses:{voucher:null,sale:null},waiting:{voucher:!1,sale:!1}});if(this.__internal__.device.type="pinpax",w.h.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,m).call(this),w.h.add(this),this.getResponseAsString()}set bussinessId(s){this.__pinpax__.bussinessId=s}get bussinessId(){return this.__pinpax__.bussinessId}set encriptionKey(s){this.__pinpax__.encriptionKey=s}get encriptionKey(){return this.__pinpax__.encriptionKey}set apiKey(s){this.__pinpax__.apiKey=s}get apiKey(){return this.__pinpax__.apiKey}set server(s){this.__pinpax__.server=s}get server(){return this.__pinpax__.server}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,x).call(this).then(()=>{});break;case"LOGIN":this.dispatch("login",e);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,T).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 n.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(n.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=n.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 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=n.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 h=setTimeout(()=>{a.__pinpax__.waiting.voucher=!1,p("Timeout")},1e4),u=setInterval(()=>{if(a.__pinpax__.asyncResponses.voucher){const k=a.__pinpax__.asyncResponses.voucher;a.__pinpax__.asyncResponses.voucher=null,a.__pinpax__.waiting.voucher=!1,clearInterval(u),clearTimeout(h),c(k.voucher)}},100)})}async info(){await this.appendToQueue(n.s.info(),"info")}async keepAlive(){await this.appendToQueue(n.s.keepAlive(),"keep-alive")}async restartApp(){await this.appendToQueue(n.s.restartApp(),"reset-app")}async getConfig(){return await this.appendToQueue(n.s.getConfig(),"get-config")}async hideButtons(){return await this.appendToQueue(n.s.hideButtons(),"hide-buttons"),await o(this,t,g).call(this)}async showButtons(){return await this.appendToQueue(n.s.showButtons(),"show-buttons"),await o(this,t,v).call(this)}async demo(){return console.warn("RUNNING DEMO APP, BE CAREFUL"),await this.appendToQueue(n.s.demo(),"demo")}async refund({amount:s=0,folio:e=null,auth:a=null}={}){return await this.appendToQueue(n.s.refund({amount:s,folio:e,auth:a}),"refund")}async readProductionQR(){return await o(this,t,l).call(this,{type:"production"})}async readQualityAssuranceQR(){return o(this,t,l).call(this,{type:"QA"})}async exit(){return await this.appendToQueue(n.s.exit(),"exit-app")}async init(){await this.appendToQueue(n.s.init(),"init-app")}async login(){if(!this.apiKey||!this.bussinessId||!this.encriptionKey||!this.server)throw new Error("Invalid data to login check apiKey, bussinessId, encriptionKey, server");const s=JSON.stringify({action:"LOGIN_MIT",server:this.__pinpax__.server,bussiness_id:this.__pinpax__.bussinessId,encription_key:this.__pinpax__.encriptionKey,api_key:this.__pinpax__.apiKey}),e=this.parseStringToBytes(s,`\r
|
|
4
|
+
`);await this.appendToQueue(e,"login")}}t=new WeakSet,m=function(){const s=["buttons-status","init-app","connectMessage","voucher","info","keep-alive","reset-app","get-config","payment","error","refund","login"];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)})},l=async function({type:s="production"}={}){const e=n.s.readQR({type:s});return await this.appendToQueue(e,"read-qr")},g=async function(){await this.appendToQueue(n.s.forceHide(),"force-hide")},v=async function(){await this.appendToQueue(n.s.forceShow(),"force-show")},b=async function(){await this.connectMessage()},x=async function(){await this.hideButtons()},T=function(s){this.dispatch("payment",s),this.__pinpax__.waiting.sale&&(this.__pinpax__.asyncResponses.sale=s)};exports.PinPax=A;
|
package/dist/pinpax.js
CHANGED
|
@@ -6,10 +6,11 @@ var E = (r, i, s) => i in r ? R(r, i, { enumerable: !0, configurable: !0, writab
|
|
|
6
6
|
var y = (r, i, s) => E(r, typeof i != "symbol" ? i + "" : i, s), I = (r, i, s) => i.has(r) || d("Cannot " + s);
|
|
7
7
|
var f = (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
8
|
var o = (r, i, s) => (I(r, i, "access private method"), s);
|
|
9
|
-
import { K as C
|
|
9
|
+
import { K as C } from "./kernel-XY8jLkNB.js";
|
|
10
10
|
import { s as n } from "./relay-Dop4mFk-.js";
|
|
11
|
+
import { h as m } from "./webserial-core-DGKQCs5a.js";
|
|
11
12
|
var t, w, _, l, g, v, b, x, T;
|
|
12
|
-
class
|
|
13
|
+
class S extends C {
|
|
13
14
|
constructor({
|
|
14
15
|
filters: s = null,
|
|
15
16
|
config_port: e = {
|
|
@@ -363,5 +364,5 @@ t = new WeakSet(), w = function() {
|
|
|
363
364
|
this.dispatch("payment", s), this.__pinpax__.waiting.sale && (this.__pinpax__.asyncResponses.sale = s);
|
|
364
365
|
};
|
|
365
366
|
export {
|
|
366
|
-
|
|
367
|
+
S as PinPax
|
|
367
368
|
};
|
package/dist/relay.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./kernel-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./kernel-Bd3IuxSw.cjs"),i=require("./relay-BsUsBpOv.cjs"),r=require("./webserial-core-DlH0cFSH.cjs");class o extends a.Kernel{constructor({filters:t=null,config_port:e=null,no_device:n=1}={}){if(super({filters:t,config_port:e,no_device:n}),this.__internal__.device.type="relay",this.__internal__.auto_response=!0,r.h.getCustom(this.typeDevice,n))throw new Error(`Device ${this.typeDevice} ${n} already exists`);r.h.add(this)}serialMessage(t){const e={code:t,name:null,description:null,request:null,no_code:0};switch(t[1].toString()){case"dd":e.name="Connection with the serial device completed.",e.description="Your connection with the serial device was successfully completed.",e.request="connect",e.no_code=100;break;case"de":break;default: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;break}this.dispatch("serial:message",e)}serialRelaySumHex(t){let e=0;return t.forEach((n,s)=>{s!==3&&(e+=n)}),e}serialSetConnectionConstant(t=1){return i.e.connection(t)}async turnOn(){const t=i.e.activate();await this.appendToQueue(t,"relay:turn-on")}async turnOff(){const t=i.e.deactivate();await this.appendToQueue(t,"relay:turn-off")}async toggle({inverse:t=!1,ms:e=300}={}){if(!t){await this.turnOn(),await a.wait(e),await this.turnOff();return}await this.turnOff(),await a.wait(e),await this.turnOn()}}exports.Relay=o;
|
package/dist/relay.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { K as o,
|
|
1
|
+
import { K as o, w as i } from "./kernel-XY8jLkNB.js";
|
|
2
2
|
import { e as a } from "./relay-Dop4mFk-.js";
|
|
3
|
-
|
|
3
|
+
import { h as s } from "./webserial-core-DGKQCs5a.js";
|
|
4
|
+
class p extends o {
|
|
4
5
|
constructor({ filters: t = null, config_port: e = null, no_device: n = 1 } = {}) {
|
|
5
|
-
if (super({ filters: t, config_port: e, no_device: n }), this.__internal__.device.type = "relay", this.__internal__.auto_response = !0,
|
|
6
|
+
if (super({ filters: t, config_port: e, no_device: n }), this.__internal__.device.type = "relay", this.__internal__.auto_response = !0, s.getCustom(this.typeDevice, n))
|
|
6
7
|
throw new Error(`Device ${this.typeDevice} ${n} already exists`);
|
|
7
|
-
|
|
8
|
+
s.add(this);
|
|
8
9
|
}
|
|
9
10
|
serialMessage(t) {
|
|
10
11
|
const e = {
|
|
@@ -45,12 +46,12 @@ class d extends o {
|
|
|
45
46
|
}
|
|
46
47
|
async toggle({ inverse: t = !1, ms: e = 300 } = {}) {
|
|
47
48
|
if (!t) {
|
|
48
|
-
await this.turnOn(), await
|
|
49
|
+
await this.turnOn(), await i(e), await this.turnOff();
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
51
|
-
await this.turnOff(), await
|
|
52
|
+
await this.turnOff(), await i(e), await this.turnOn();
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
export {
|
|
55
|
-
|
|
56
|
+
p as Relay
|
|
56
57
|
};
|