@danidoble/webserial 4.2.4 → 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-BFXQSiNz.js → kernel-Bquzoyqh.js} +119 -116
- package/dist/kernel-DSUxKxea.cjs +4 -0
- package/dist/kernel.cjs +1 -1
- package/dist/kernel.js +1 -1
- package/dist/locker.cjs +1 -1
- package/dist/locker.js +85 -123
- package/dist/pinpad.cjs +1 -1
- package/dist/pinpad.js +1 -1
- 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 +1 -1
- package/dist/webserial.js +2 -2
- package/package.json +32 -32
- package/dist/kernel-C0epz_jB.cjs +0 -4
|
@@ -20,10 +20,10 @@ function Ce() {
|
|
|
20
20
|
function De(l = 1) {
|
|
21
21
|
return l * 1e3;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function Ae(l) {
|
|
24
24
|
return l == null || l === "";
|
|
25
25
|
}
|
|
26
|
-
var v,
|
|
26
|
+
var v, A, s, Y, Z, c, O, p, d, I, o, $, T;
|
|
27
27
|
const r = class r {
|
|
28
28
|
static status(e = null) {
|
|
29
29
|
var n, i;
|
|
@@ -34,7 +34,7 @@ const r = class r {
|
|
|
34
34
|
t = ["0", "8"];
|
|
35
35
|
break;
|
|
36
36
|
case "boardroid":
|
|
37
|
-
t = ["2", (5 + w(r,
|
|
37
|
+
t = ["2", (5 + w(r, A)).toString(16).toUpperCase()];
|
|
38
38
|
break;
|
|
39
39
|
case "jofemar":
|
|
40
40
|
t = ["6"];
|
|
@@ -84,25 +84,25 @@ const r = class r {
|
|
|
84
84
|
}
|
|
85
85
|
static gateInactive(e = null) {
|
|
86
86
|
var t;
|
|
87
|
-
if (!a(t = r, s, c).call(t, e) || !a(this, s,
|
|
87
|
+
if (!a(t = r, s, c).call(t, e) || !a(this, s, O).call(this)) return !1;
|
|
88
88
|
a(this, s, o).call(this, ["0", "7", "5", "5", "5"]);
|
|
89
89
|
}
|
|
90
90
|
static gateConfigured(e = null) {
|
|
91
91
|
var t;
|
|
92
|
-
if (!a(t = r, s, c).call(t, e) || !a(this, s,
|
|
92
|
+
if (!a(t = r, s, c).call(t, e) || !a(this, s, O).call(this)) return !1;
|
|
93
93
|
a(this, s, o).call(this, ["0", "6"]);
|
|
94
94
|
}
|
|
95
95
|
static keyPressed(e = null) {
|
|
96
96
|
var u, g, f;
|
|
97
97
|
if (!a(u = r, s, c).call(u, e) || !a(g = r, s, d).call(g)) return !1;
|
|
98
|
-
const t = ["30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "2A", "23", "41", "42", "43", "44"], n = (128 + w(r,
|
|
98
|
+
const t = ["30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "2A", "23", "41", "42", "43", "44"], n = (128 + w(r, A)).toString(16), i = Math.floor(Math.random() * 15);
|
|
99
99
|
a(f = r, s, o).call(f, ["2", n, "54", t[i]]);
|
|
100
100
|
}
|
|
101
101
|
static doorOpened(e = null) {
|
|
102
102
|
var i, u;
|
|
103
103
|
if (!a(i = r, s, c).call(i, e) || !a(this, s, I).call(this)) return !1;
|
|
104
104
|
let t = [];
|
|
105
|
-
const n = (128 + w(r,
|
|
105
|
+
const n = (128 + w(r, A)).toString(16);
|
|
106
106
|
switch (w(r, v)) {
|
|
107
107
|
case "boardroid":
|
|
108
108
|
t = ["2", "D8", "dc"];
|
|
@@ -117,7 +117,7 @@ const r = class r {
|
|
|
117
117
|
var i, u;
|
|
118
118
|
if (!a(i = r, s, c).call(i, e) || !a(this, s, I).call(this)) return !1;
|
|
119
119
|
let t = [];
|
|
120
|
-
const n = (128 + w(r,
|
|
120
|
+
const n = (128 + w(r, A)).toString(16);
|
|
121
121
|
switch (w(r, v)) {
|
|
122
122
|
case "boardroid":
|
|
123
123
|
t = ["2", "D8", "db"];
|
|
@@ -131,32 +131,32 @@ const r = class r {
|
|
|
131
131
|
static channelDisconnected(e = null) {
|
|
132
132
|
var n, i, u;
|
|
133
133
|
if (!a(n = r, s, c).call(n, e) || !a(i = r, s, d).call(i)) return !1;
|
|
134
|
-
const t = (128 + w(r,
|
|
134
|
+
const t = (128 + w(r, A)).toString(16);
|
|
135
135
|
a(u = r, s, o).call(u, ["2", t, "43", "43", "43", "FD"]);
|
|
136
136
|
}
|
|
137
137
|
static channelConnected(e = null) {
|
|
138
138
|
var n, i, u;
|
|
139
139
|
if (!a(n = r, s, c).call(n, e) || !a(i = r, s, d).call(i)) return !1;
|
|
140
|
-
const t = (128 + w(r,
|
|
140
|
+
const t = (128 + w(r, A)).toString(16);
|
|
141
141
|
a(u = r, s, o).call(u, ["2", t, "43", "43", "43", "FC"]);
|
|
142
142
|
}
|
|
143
143
|
static channelEmpty(e = null) {
|
|
144
144
|
var n, i, u;
|
|
145
145
|
if (!a(n = r, s, c).call(n, e) || !a(i = r, s, d).call(i)) return !1;
|
|
146
|
-
const t = (128 + w(r,
|
|
146
|
+
const t = (128 + w(r, A)).toString(16);
|
|
147
147
|
a(u = r, s, o).call(u, ["2", t, "43", "43", "43", "FF"]);
|
|
148
148
|
}
|
|
149
149
|
static workingTemperature(e = null) {
|
|
150
150
|
var n, i, u;
|
|
151
151
|
if (!a(n = r, s, c).call(n, e) || !a(i = r, s, d).call(i)) return !1;
|
|
152
|
-
const t = (128 + w(r,
|
|
152
|
+
const t = (128 + w(r, A)).toString(16);
|
|
153
153
|
a(u = r, s, o).call(u, ["2", t, "43", "54", "16"]);
|
|
154
154
|
}
|
|
155
155
|
static currentTemperature(e = null) {
|
|
156
156
|
var i, u, g;
|
|
157
157
|
if (!a(i = r, s, c).call(i, e) || !a(u = r, s, I).call(u)) return !1;
|
|
158
158
|
let t = [];
|
|
159
|
-
const n = (128 + w(r,
|
|
159
|
+
const n = (128 + w(r, A)).toString(16);
|
|
160
160
|
switch (w(r, v)) {
|
|
161
161
|
case "boardroid":
|
|
162
162
|
t = ["2", "D9", "44", "30"];
|
|
@@ -455,7 +455,7 @@ const r = class r {
|
|
|
455
455
|
];
|
|
456
456
|
if (e._recycler.ict) {
|
|
457
457
|
const h = n[Math.floor(Math.random() * 31)];
|
|
458
|
-
let k = "0", C = "0", D = "0",
|
|
458
|
+
let k = "0", C = "0", D = "0", S = "0", M = "0";
|
|
459
459
|
if (t !== null && !isNaN(parseInt(t)))
|
|
460
460
|
switch (t.toString()) {
|
|
461
461
|
case "20":
|
|
@@ -468,7 +468,7 @@ const r = class r {
|
|
|
468
468
|
D = h;
|
|
469
469
|
break;
|
|
470
470
|
case "200":
|
|
471
|
-
|
|
471
|
+
S = h;
|
|
472
472
|
break;
|
|
473
473
|
case "500":
|
|
474
474
|
M = h;
|
|
@@ -486,15 +486,15 @@ const r = class r {
|
|
|
486
486
|
D = h;
|
|
487
487
|
break;
|
|
488
488
|
case 3:
|
|
489
|
-
|
|
489
|
+
S = h;
|
|
490
490
|
break;
|
|
491
491
|
case 4:
|
|
492
492
|
M = h;
|
|
493
493
|
break;
|
|
494
494
|
}
|
|
495
|
-
a(g = r, s, o).call(g, ["2", "D3", k, C, D,
|
|
495
|
+
a(g = r, s, o).call(g, ["2", "D3", k, C, D, S, M, "0"]);
|
|
496
496
|
} else {
|
|
497
|
-
const [h, k, C, D,
|
|
497
|
+
const [h, k, C, D, S, M] = [
|
|
498
498
|
n[Math.floor(Math.random() * 30)],
|
|
499
499
|
n[Math.floor(Math.random() * 30)],
|
|
500
500
|
n[Math.floor(Math.random() * 30)],
|
|
@@ -502,7 +502,7 @@ const r = class r {
|
|
|
502
502
|
n[Math.floor(Math.random())],
|
|
503
503
|
n[Math.floor(Math.random())]
|
|
504
504
|
];
|
|
505
|
-
a(f = r, s, o).call(f, ["2", "D3", h, k, C, D,
|
|
505
|
+
a(f = r, s, o).call(f, ["2", "D3", h, k, C, D, S, M]);
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
508
|
static banknoteAccepted(e = null) {
|
|
@@ -550,7 +550,7 @@ const r = class r {
|
|
|
550
550
|
];
|
|
551
551
|
if (e._recycler.ict) {
|
|
552
552
|
const f = t[Math.floor(Math.random() * 30)];
|
|
553
|
-
let h = "0", k = "0", C = "0", D = "0",
|
|
553
|
+
let h = "0", k = "0", C = "0", D = "0", S = "0";
|
|
554
554
|
switch (e._recycler.bill) {
|
|
555
555
|
case 0:
|
|
556
556
|
h = f;
|
|
@@ -565,12 +565,12 @@ const r = class r {
|
|
|
565
565
|
D = f;
|
|
566
566
|
break;
|
|
567
567
|
case 4:
|
|
568
|
-
|
|
568
|
+
S = f;
|
|
569
569
|
break;
|
|
570
570
|
}
|
|
571
|
-
a(u = r, s, o).call(u, ["2", "D5", h, k, C, D,
|
|
571
|
+
a(u = r, s, o).call(u, ["2", "D5", h, k, C, D, S, "0"]);
|
|
572
572
|
} else {
|
|
573
|
-
const [f, h, k, C, D,
|
|
573
|
+
const [f, h, k, C, D, S] = [
|
|
574
574
|
t[Math.floor(Math.random() * 30)],
|
|
575
575
|
t[Math.floor(Math.random() * 30)],
|
|
576
576
|
t[Math.floor(Math.random() * 30)],
|
|
@@ -578,7 +578,7 @@ const r = class r {
|
|
|
578
578
|
t[Math.floor(Math.random())],
|
|
579
579
|
t[Math.floor(Math.random())]
|
|
580
580
|
];
|
|
581
|
-
a(g = r, s, o).call(g, ["2", "D5", f, h, k, C, D,
|
|
581
|
+
a(g = r, s, o).call(g, ["2", "D5", f, h, k, C, D, S]);
|
|
582
582
|
}
|
|
583
583
|
}
|
|
584
584
|
static coinsDispensed(e = null) {
|
|
@@ -657,17 +657,17 @@ const r = class r {
|
|
|
657
657
|
e.__internal__.serial.connected = !0;
|
|
658
658
|
}
|
|
659
659
|
};
|
|
660
|
-
v = new WeakMap(),
|
|
660
|
+
v = new WeakMap(), A = new WeakMap(), s = new WeakSet(), Y = function() {
|
|
661
661
|
if (r.enable === !1) throw new Error("Emulator is disabled");
|
|
662
662
|
return r.enable;
|
|
663
663
|
}, Z = function(e) {
|
|
664
|
-
if (typeof e != "object" || !(e instanceof
|
|
664
|
+
if (typeof e != "object" || !(e instanceof me))
|
|
665
665
|
throw new Error(`Type ${e.typeDevice} is not supported`);
|
|
666
|
-
return r.instance = e, j(r, v, e.typeDevice), j(r,
|
|
666
|
+
return r.instance = e, j(r, v, e.typeDevice), j(r, A, e.deviceNumber), !0;
|
|
667
667
|
}, c = function(e = null) {
|
|
668
668
|
var t, n;
|
|
669
669
|
return !a(t = r, s, Y).call(t) || e === null && r.instance === null ? !1 : (r.instance === null && a(n = r, s, Z).call(n, e), !0);
|
|
670
|
-
},
|
|
670
|
+
}, O = function() {
|
|
671
671
|
if (w(r, v) !== "locker") throw new Error("This function is only available for Locker devices");
|
|
672
672
|
return !0;
|
|
673
673
|
}, p = function() {
|
|
@@ -724,11 +724,11 @@ v = new WeakMap(), S = new WeakMap(), s = new WeakSet(), Y = function() {
|
|
|
724
724
|
break;
|
|
725
725
|
}
|
|
726
726
|
return n;
|
|
727
|
-
}, U(r, s), N(r, "enable", !1), N(r, "instance", null), U(r, v, null), U(r,
|
|
728
|
-
let
|
|
727
|
+
}, U(r, s), N(r, "enable", !1), N(r, "instance", null), U(r, v, null), U(r, A, 1);
|
|
728
|
+
let L = r;
|
|
729
729
|
var he = Object.defineProperty, ee = (l) => {
|
|
730
730
|
throw TypeError(l);
|
|
731
|
-
}, de = (l, e, t) => e in l ? he(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t, B = (l, e, t) => de(l, typeof e != "symbol" ? e + "" : e, t), fe = (l, e, t) => e.has(l) || ee("Cannot " + t), pe = (l, e, t) => e.has(l) ? ee("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(l) : e.set(l, t),
|
|
731
|
+
}, de = (l, e, t) => e in l ? he(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t, B = (l, e, t) => de(l, typeof e != "symbol" ? e + "" : e, t), fe = (l, e, t) => e.has(l) || ee("Cannot " + t), pe = (l, e, t) => e.has(l) ? ee("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(l) : e.set(l, t), m = (l, e, t) => (fe(l, e, "access private method"), t);
|
|
732
732
|
class Q extends CustomEvent {
|
|
733
733
|
constructor(e, t) {
|
|
734
734
|
super(e, t);
|
|
@@ -766,44 +766,44 @@ class te extends EventTarget {
|
|
|
766
766
|
}));
|
|
767
767
|
}
|
|
768
768
|
}
|
|
769
|
-
const R = class
|
|
769
|
+
const R = class y extends te {
|
|
770
770
|
constructor() {
|
|
771
771
|
super(), ["change"].forEach((e) => {
|
|
772
772
|
this.serialRegisterAvailableListener(e);
|
|
773
773
|
});
|
|
774
774
|
}
|
|
775
775
|
static $dispatchChange(e = null) {
|
|
776
|
-
e && e.$checkAndDispatchConnection(),
|
|
776
|
+
e && e.$checkAndDispatchConnection(), y.instance.dispatch("change", { devices: y.devices, dispatcher: e });
|
|
777
777
|
}
|
|
778
778
|
static typeError(e) {
|
|
779
779
|
const t = new Error();
|
|
780
780
|
throw t.message = `Type ${e} is not supported`, t.name = "DeviceTypeError", t;
|
|
781
781
|
}
|
|
782
782
|
static registerType(e) {
|
|
783
|
-
typeof
|
|
783
|
+
typeof y.devices[e] > "u" && (y.devices[e] = {});
|
|
784
784
|
}
|
|
785
785
|
static add(e) {
|
|
786
786
|
const t = e.typeDevice;
|
|
787
|
-
typeof
|
|
787
|
+
typeof y.devices[t] > "u" && (y.devices[t] = {});
|
|
788
788
|
const n = e.uuid;
|
|
789
|
-
if (typeof
|
|
789
|
+
if (typeof y.devices[t] > "u" && y.typeError(t), y.devices[t][n])
|
|
790
790
|
throw new Error(`Device with id ${n} already exists`);
|
|
791
|
-
return
|
|
791
|
+
return y.devices[t][n] = e, y.$dispatchChange(e), Object.keys(y.devices[t]).indexOf(n);
|
|
792
792
|
}
|
|
793
793
|
static get(e, t) {
|
|
794
|
-
return typeof
|
|
794
|
+
return typeof y.devices[e] > "u" && (y.devices[e] = {}), typeof y.devices[e] > "u" && y.typeError(e), y.devices[e][t];
|
|
795
795
|
}
|
|
796
796
|
static getAll(e = null) {
|
|
797
|
-
return e === null ?
|
|
797
|
+
return e === null ? y.devices : (typeof y.devices[e] > "u" && y.typeError(e), y.devices[e]);
|
|
798
798
|
}
|
|
799
799
|
static getList() {
|
|
800
|
-
return Object.values(
|
|
800
|
+
return Object.values(y.devices).map((e) => Object.values(e)).flat();
|
|
801
801
|
}
|
|
802
802
|
static getByNumber(e, t) {
|
|
803
|
-
return typeof
|
|
803
|
+
return typeof y.devices[e] > "u" && y.typeError(e), Object.values(y.devices[e]).find((n) => n.deviceNumber === t) ?? null;
|
|
804
804
|
}
|
|
805
805
|
static getCustom(e, t = 1) {
|
|
806
|
-
return typeof
|
|
806
|
+
return typeof y.devices[e] > "u" && y.typeError(e), Object.values(y.devices[e]).find((n) => n.deviceNumber === t) ?? null;
|
|
807
807
|
}
|
|
808
808
|
};
|
|
809
809
|
B(R, "instance"), B(R, "devices", {});
|
|
@@ -817,7 +817,7 @@ function J(l = 100) {
|
|
|
817
817
|
function ge() {
|
|
818
818
|
return "serial" in navigator;
|
|
819
819
|
}
|
|
820
|
-
const
|
|
820
|
+
const q = {
|
|
821
821
|
baudRate: 9600,
|
|
822
822
|
dataBits: 8,
|
|
823
823
|
stopBits: 1,
|
|
@@ -825,16 +825,16 @@ const L = {
|
|
|
825
825
|
bufferSize: 32768,
|
|
826
826
|
flowControl: "none"
|
|
827
827
|
};
|
|
828
|
-
var b,
|
|
828
|
+
var b, x, P, H, E, ne, V, z, K, re, ie, se, ae, G, X, le, oe;
|
|
829
829
|
class be extends te {
|
|
830
830
|
constructor({
|
|
831
831
|
filters: e = null,
|
|
832
|
-
config_port: t =
|
|
832
|
+
config_port: t = q,
|
|
833
833
|
no_device: n = 1,
|
|
834
834
|
device_listen_on_channel: i = 1
|
|
835
835
|
} = {
|
|
836
836
|
filters: null,
|
|
837
|
-
config_port:
|
|
837
|
+
config_port: q,
|
|
838
838
|
no_device: 1,
|
|
839
839
|
device_listen_on_channel: 1
|
|
840
840
|
}) {
|
|
@@ -855,7 +855,7 @@ class be extends te {
|
|
|
855
855
|
response: {
|
|
856
856
|
length: null,
|
|
857
857
|
buffer: new Uint8Array([]),
|
|
858
|
-
as: "
|
|
858
|
+
as: "uint8",
|
|
859
859
|
replacer: /[\n\r]+/g,
|
|
860
860
|
limiter: null
|
|
861
861
|
},
|
|
@@ -869,7 +869,7 @@ class be extends te {
|
|
|
869
869
|
delay_first_connection: 200,
|
|
870
870
|
bytes_connection: null,
|
|
871
871
|
filters: [],
|
|
872
|
-
config_port:
|
|
872
|
+
config_port: q,
|
|
873
873
|
queue: [],
|
|
874
874
|
auto_response: ["DD", "DD"]
|
|
875
875
|
},
|
|
@@ -890,7 +890,7 @@ class be extends te {
|
|
|
890
890
|
}
|
|
891
891
|
}), !("serial" in navigator))
|
|
892
892
|
throw new Error("Web Serial not supported");
|
|
893
|
-
e && (this.serialFilters = e), t && (this.serialConfigPort = t), n &&
|
|
893
|
+
e && (this.serialFilters = e), t && (this.serialConfigPort = t), n && m(this, b, le).call(this, n), i && ["number", "string"].includes(typeof i) && (this.listenOnChannel = i), m(this, b, se).call(this), m(this, b, ae).call(this);
|
|
894
894
|
}
|
|
895
895
|
set listenOnChannel(e) {
|
|
896
896
|
if (typeof e == "string" && (e = parseInt(e)), isNaN(e) || e < 1 || e > 255)
|
|
@@ -916,11 +916,11 @@ class be extends te {
|
|
|
916
916
|
return this.__internal__.serial.config_port;
|
|
917
917
|
}
|
|
918
918
|
get isConnected() {
|
|
919
|
-
const e = this.__internal__.serial.connected, t =
|
|
920
|
-
return e && !t &&
|
|
919
|
+
const e = this.__internal__.serial.connected, t = m(this, b, x).call(this, this.__internal__.serial.port);
|
|
920
|
+
return e && !t && m(this, b, P).call(this, { error: "Port is closed, not readable or writable." }), this.__internal__.serial.connected = t, this.__internal__.serial.connected;
|
|
921
921
|
}
|
|
922
922
|
get isDisconnected() {
|
|
923
|
-
const e = this.__internal__.serial.connected, t =
|
|
923
|
+
const e = this.__internal__.serial.connected, t = m(this, b, x).call(this, this.__internal__.serial.port);
|
|
924
924
|
return !e && t && (this.dispatch("serial:connected"), _.$dispatchChange(this)), this.__internal__.serial.connected = t, !this.__internal__.serial.connected;
|
|
925
925
|
}
|
|
926
926
|
get deviceNumber() {
|
|
@@ -943,7 +943,7 @@ class be extends te {
|
|
|
943
943
|
});
|
|
944
944
|
}
|
|
945
945
|
async disconnect(e = null) {
|
|
946
|
-
await this.serialDisconnect(),
|
|
946
|
+
await this.serialDisconnect(), m(this, b, P).call(this, e);
|
|
947
947
|
}
|
|
948
948
|
async connect() {
|
|
949
949
|
return new Promise((e, t) => {
|
|
@@ -1036,7 +1036,7 @@ class be extends te {
|
|
|
1036
1036
|
async serialConnect() {
|
|
1037
1037
|
try {
|
|
1038
1038
|
this.dispatch("serial:connecting", {});
|
|
1039
|
-
const e = await
|
|
1039
|
+
const e = await m(this, b, ne).call(this);
|
|
1040
1040
|
if (e.length > 0)
|
|
1041
1041
|
await this.serialPortsSaved(e);
|
|
1042
1042
|
else {
|
|
@@ -1056,16 +1056,16 @@ class be extends te {
|
|
|
1056
1056
|
await n.disconnect();
|
|
1057
1057
|
}, await J(this.__internal__.serial.delay_first_connection), this.__internal__.timeout.until_response = setTimeout(async () => {
|
|
1058
1058
|
await n.timeout(n.__internal__.serial.bytes_connection ?? [], "connection:start");
|
|
1059
|
-
}, this.__internal__.time.response_connection), this.__internal__.serial.last_action = "connect", await
|
|
1059
|
+
}, this.__internal__.time.response_connection), this.__internal__.serial.last_action = "connect", await m(this, b, H).call(this, this.__internal__.serial.bytes_connection ?? []), this.dispatch("serial:sent", {
|
|
1060
1060
|
action: "connect",
|
|
1061
1061
|
bytes: this.__internal__.serial.bytes_connection
|
|
1062
|
-
}), this.__internal__.auto_response &&
|
|
1062
|
+
}), this.__internal__.auto_response && m(this, b, E).call(this, this.__internal__.serial.auto_response, null), await m(this, b, re).call(this);
|
|
1063
1063
|
} catch (e) {
|
|
1064
1064
|
this.serialErrors(e);
|
|
1065
1065
|
}
|
|
1066
1066
|
}
|
|
1067
1067
|
async serialForget() {
|
|
1068
|
-
return await
|
|
1068
|
+
return await m(this, b, ie).call(this);
|
|
1069
1069
|
}
|
|
1070
1070
|
decToHex(e) {
|
|
1071
1071
|
return typeof e == "string" && (e = parseInt(e, 10)), e.toString(16);
|
|
@@ -1085,8 +1085,22 @@ class be extends te {
|
|
|
1085
1085
|
bytesToHex(e) {
|
|
1086
1086
|
return this.add0x(Array.from(e, (t) => this.hexMaker(t)));
|
|
1087
1087
|
}
|
|
1088
|
+
validateBytes(e) {
|
|
1089
|
+
let t = new Uint8Array(0);
|
|
1090
|
+
if (e instanceof Uint8Array)
|
|
1091
|
+
t = e;
|
|
1092
|
+
else if (typeof e == "string")
|
|
1093
|
+
t = this.parseStringToTextEncoder(e);
|
|
1094
|
+
else if (Array.isArray(e) && typeof e[0] == "string")
|
|
1095
|
+
t = this.stringArrayToUint8Array(e);
|
|
1096
|
+
else if (Array.isArray(e) && typeof e[0] == "number")
|
|
1097
|
+
t = new Uint8Array(e);
|
|
1098
|
+
else
|
|
1099
|
+
throw new Error("Invalid data type");
|
|
1100
|
+
return t;
|
|
1101
|
+
}
|
|
1088
1102
|
async appendToQueue(e, t) {
|
|
1089
|
-
const n = this.
|
|
1103
|
+
const n = this.validateBytes(e);
|
|
1090
1104
|
if (["connect", "connection:start"].includes(t)) {
|
|
1091
1105
|
if (this.__internal__.serial.connected) return;
|
|
1092
1106
|
await this.serialConnect();
|
|
@@ -1122,7 +1136,7 @@ class be extends te {
|
|
|
1122
1136
|
});
|
|
1123
1137
|
}
|
|
1124
1138
|
softReload() {
|
|
1125
|
-
|
|
1139
|
+
m(this, b, oe).call(this), this.dispatch("serial:soft-reload", {});
|
|
1126
1140
|
}
|
|
1127
1141
|
async sendConnect() {
|
|
1128
1142
|
if (!this.__internal__.serial.bytes_connection)
|
|
@@ -1166,8 +1180,8 @@ class be extends te {
|
|
|
1166
1180
|
}), new Uint8Array(t);
|
|
1167
1181
|
}
|
|
1168
1182
|
parseUint8ArrayToString(e) {
|
|
1169
|
-
|
|
1170
|
-
e = this.parseUint8ToHex(t);
|
|
1183
|
+
let t = new Uint8Array(0);
|
|
1184
|
+
e instanceof Uint8Array ? t = e : t = this.stringArrayToUint8Array(e), e = this.parseUint8ToHex(t);
|
|
1171
1185
|
const n = e.map((i) => parseInt(i, 16));
|
|
1172
1186
|
return this.__internal__.serial.response.replacer ? String.fromCharCode(...n).replace(this.__internal__.serial.response.replacer, "") : String.fromCharCode(...n);
|
|
1173
1187
|
}
|
|
@@ -1190,41 +1204,36 @@ class be extends te {
|
|
|
1190
1204
|
return this.isConnected;
|
|
1191
1205
|
}
|
|
1192
1206
|
}
|
|
1193
|
-
b = /* @__PURE__ */ new WeakSet(),
|
|
1207
|
+
b = /* @__PURE__ */ new WeakSet(), x = function(l) {
|
|
1194
1208
|
return !!(l && l.readable && l.writable);
|
|
1195
1209
|
}, P = function(l = null) {
|
|
1196
1210
|
this.__internal__.serial.connected = !1, this.__internal__.aux_port_connector = 0, this.dispatch("serial:disconnected", l), _.$dispatchChange(this);
|
|
1197
1211
|
}, H = async function(l) {
|
|
1198
1212
|
const e = this.__internal__.serial.port;
|
|
1199
1213
|
if (!e || e && (!e.readable || !e.writable))
|
|
1200
|
-
throw
|
|
1201
|
-
const t = this.
|
|
1214
|
+
throw m(this, b, P).call(this, { error: "Port is closed, not readable or writable." }), new Error("The port is closed or is not readable/writable");
|
|
1215
|
+
const t = this.validateBytes(l);
|
|
1202
1216
|
if (e.writable === null) return;
|
|
1203
1217
|
const n = e.writable.getWriter();
|
|
1204
1218
|
await n.write(t), n.releaseLock();
|
|
1205
|
-
},
|
|
1219
|
+
}, E = function(l = new Uint8Array([]), e = null) {
|
|
1206
1220
|
if (l && l.length > 0) {
|
|
1207
1221
|
const t = this.__internal__.serial.connected;
|
|
1208
|
-
this.__internal__.serial.connected =
|
|
1209
|
-
|
|
1210
|
-
for (const i in l)
|
|
1211
|
-
n.push(l[i].toString().padStart(2, "0").toLowerCase());
|
|
1212
|
-
if (this.__internal__.serial.response.as === "hex")
|
|
1213
|
-
this.serialMessage(n);
|
|
1222
|
+
if (this.__internal__.serial.connected = m(this, b, x).call(this, this.__internal__.serial.port), _.$dispatchChange(this), !t && this.__internal__.serial.connected && this.dispatch("serial:connected"), this.__internal__.interval.reconnection && (clearInterval(this.__internal__.interval.reconnection), this.__internal__.interval.reconnection = 0), this.__internal__.timeout.until_response && (clearTimeout(this.__internal__.timeout.until_response), this.__internal__.timeout.until_response = 0), this.__internal__.serial.response.as === "hex")
|
|
1223
|
+
this.serialMessage(this.parseUint8ToHex(l));
|
|
1214
1224
|
else if (this.__internal__.serial.response.as === "uint8")
|
|
1215
|
-
this.serialMessage(
|
|
1216
|
-
else if (this.__internal__.serial.response.as === "string")
|
|
1225
|
+
this.serialMessage(l);
|
|
1226
|
+
else if (this.__internal__.serial.response.as === "string") {
|
|
1227
|
+
const n = this.parseUint8ArrayToString(l);
|
|
1217
1228
|
if (this.__internal__.serial.response.limiter !== null) {
|
|
1218
|
-
const i =
|
|
1229
|
+
const i = n.split(this.__internal__.serial.response.limiter);
|
|
1219
1230
|
for (const u in i)
|
|
1220
1231
|
i[u] && this.serialMessage(i[u]);
|
|
1221
1232
|
} else
|
|
1222
|
-
this.serialMessage(
|
|
1223
|
-
else {
|
|
1224
|
-
const
|
|
1225
|
-
|
|
1226
|
-
);
|
|
1227
|
-
this.serialMessage(i);
|
|
1233
|
+
this.serialMessage(n);
|
|
1234
|
+
} else {
|
|
1235
|
+
const n = this.stringToArrayBuffer(this.parseUint8ArrayToString(l));
|
|
1236
|
+
this.serialMessage(n);
|
|
1228
1237
|
}
|
|
1229
1238
|
} else
|
|
1230
1239
|
this.serialCorruptMessage(l, e);
|
|
@@ -1234,7 +1243,7 @@ b = /* @__PURE__ */ new WeakSet(), E = function(l) {
|
|
|
1234
1243
|
return l.length === 0 ? e : e.filter((t) => {
|
|
1235
1244
|
const n = t.getInfo();
|
|
1236
1245
|
return l.some((i) => n.usbProductId === i.usbProductId && n.usbVendorId === i.usbVendorId);
|
|
1237
|
-
}).filter((t) => !
|
|
1246
|
+
}).filter((t) => !m(this, b, x).call(this, t));
|
|
1238
1247
|
}, V = function(l) {
|
|
1239
1248
|
if (l) {
|
|
1240
1249
|
const e = this.__internal__.serial.response.buffer, t = new Uint8Array(e.length + l.byteLength);
|
|
@@ -1242,27 +1251,18 @@ b = /* @__PURE__ */ new WeakSet(), E = function(l) {
|
|
|
1242
1251
|
}
|
|
1243
1252
|
}, z = async function() {
|
|
1244
1253
|
this.__internal__.serial.time_until_send_bytes && (clearTimeout(this.__internal__.serial.time_until_send_bytes), this.__internal__.serial.time_until_send_bytes = 0), this.__internal__.serial.time_until_send_bytes = setTimeout(() => {
|
|
1245
|
-
|
|
1246
|
-
for (const e in this.__internal__.serial.response.buffer)
|
|
1247
|
-
l.push(this.__internal__.serial.response.buffer[e].toString(16));
|
|
1248
|
-
this.__internal__.serial.response.buffer && y(this, b, x).call(this, l), this.__internal__.serial.response.buffer = new Uint8Array(0);
|
|
1254
|
+
this.__internal__.serial.response.buffer && m(this, b, E).call(this, this.__internal__.serial.response.buffer), this.__internal__.serial.response.buffer = new Uint8Array(0);
|
|
1249
1255
|
}, 400);
|
|
1250
1256
|
}, K = async function() {
|
|
1251
1257
|
if (this.__internal__.serial.response.length !== null) {
|
|
1252
|
-
if (this.__internal__.serial.response.length === this.__internal__.serial.response.buffer.length)
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
l.push(this.__internal__.serial.response.buffer[e].toString(16));
|
|
1256
|
-
y(this, b, x).call(this, l), this.__internal__.serial.response.buffer = new Uint8Array(0);
|
|
1257
|
-
} else if (this.__internal__.serial.response.length < this.__internal__.serial.response.buffer.length) {
|
|
1258
|
+
if (this.__internal__.serial.response.length === this.__internal__.serial.response.buffer.length)
|
|
1259
|
+
m(this, b, E).call(this, this.__internal__.serial.response.buffer), this.__internal__.serial.response.buffer = new Uint8Array(0);
|
|
1260
|
+
else if (this.__internal__.serial.response.length < this.__internal__.serial.response.buffer.length) {
|
|
1258
1261
|
let l = new Uint8Array(0);
|
|
1259
1262
|
for (let t = 0; t < this.__internal__.serial.response.length; t++)
|
|
1260
1263
|
l[t] = this.__internal__.serial.response.buffer[t];
|
|
1261
1264
|
if (l.length === this.__internal__.serial.response.length) {
|
|
1262
|
-
|
|
1263
|
-
for (const n in l)
|
|
1264
|
-
t.push(l[n].toString(16));
|
|
1265
|
-
y(this, b, x).call(this, t), this.__internal__.serial.response.buffer = new Uint8Array(0);
|
|
1265
|
+
m(this, b, E).call(this, l), this.__internal__.serial.response.buffer = new Uint8Array(0);
|
|
1266
1266
|
return;
|
|
1267
1267
|
}
|
|
1268
1268
|
l = new Uint8Array(0);
|
|
@@ -1270,12 +1270,7 @@ b = /* @__PURE__ */ new WeakSet(), E = function(l) {
|
|
|
1270
1270
|
if (this.__internal__.serial.response.buffer.length === e) {
|
|
1271
1271
|
for (let t = 14; t < e; t++)
|
|
1272
1272
|
l[t - this.__internal__.serial.response.length] = this.__internal__.serial.response.buffer[t];
|
|
1273
|
-
|
|
1274
|
-
const t = [];
|
|
1275
|
-
for (const n in l)
|
|
1276
|
-
t.push(l[n].toString(16));
|
|
1277
|
-
y(this, b, x).call(this, t), this.__internal__.serial.response.buffer = new Uint8Array(0);
|
|
1278
|
-
}
|
|
1273
|
+
l.length === this.__internal__.serial.response.length && (m(this, b, E).call(this, l), this.__internal__.serial.response.buffer = new Uint8Array(0));
|
|
1279
1274
|
}
|
|
1280
1275
|
}
|
|
1281
1276
|
}
|
|
@@ -1293,7 +1288,7 @@ b = /* @__PURE__ */ new WeakSet(), E = function(l) {
|
|
|
1293
1288
|
e.releaseLock(), this.__internal__.serial.keep_reading = !1, t = !1;
|
|
1294
1289
|
break;
|
|
1295
1290
|
}
|
|
1296
|
-
|
|
1291
|
+
m(this, b, V).call(this, n), this.__internal__.serial.response.length === null ? await m(this, b, z).call(this) : await m(this, b, K).call(this);
|
|
1297
1292
|
}
|
|
1298
1293
|
} catch (t) {
|
|
1299
1294
|
this.serialErrors(t);
|
|
@@ -1327,8 +1322,8 @@ b = /* @__PURE__ */ new WeakSet(), E = function(l) {
|
|
|
1327
1322
|
const l = this;
|
|
1328
1323
|
this.on("internal:queue", async () => {
|
|
1329
1324
|
var e;
|
|
1330
|
-
await
|
|
1331
|
-
}),
|
|
1325
|
+
await m(e = l, b, X).call(e);
|
|
1326
|
+
}), m(this, b, G).call(this);
|
|
1332
1327
|
}, G = function() {
|
|
1333
1328
|
const l = this;
|
|
1334
1329
|
navigator.serial.addEventListener("connect", async () => {
|
|
@@ -1336,19 +1331,27 @@ b = /* @__PURE__ */ new WeakSet(), E = function(l) {
|
|
|
1336
1331
|
});
|
|
1337
1332
|
});
|
|
1338
1333
|
}, X = async function() {
|
|
1339
|
-
if (!
|
|
1340
|
-
|
|
1334
|
+
if (!m(this, b, x).call(this, this.__internal__.serial.port)) {
|
|
1335
|
+
m(this, b, P).call(this, { error: "Port is closed, not readable or writable." }), await this.serialConnect();
|
|
1341
1336
|
return;
|
|
1342
1337
|
}
|
|
1343
1338
|
if (this.__internal__.timeout.until_response || this.__internal__.serial.queue.length === 0) return;
|
|
1344
1339
|
const l = this.__internal__.serial.queue[0];
|
|
1345
1340
|
let e = this.__internal__.time.response_general;
|
|
1346
|
-
l.action === "connect" && (e = this.__internal__.time.response_connection), this.__internal__.timeout.until_response = setTimeout(async () => {
|
|
1341
|
+
if (l.action === "connect" && (e = this.__internal__.time.response_connection), this.__internal__.timeout.until_response = setTimeout(async () => {
|
|
1347
1342
|
await this.timeout(l.bytes, l.action);
|
|
1348
|
-
}, e), this.__internal__.serial.last_action = l.action ?? "unknown", await
|
|
1343
|
+
}, e), this.__internal__.serial.last_action = l.action ?? "unknown", await m(this, b, H).call(this, l.bytes), this.dispatch("serial:sent", {
|
|
1349
1344
|
action: l.action,
|
|
1350
1345
|
bytes: l.bytes
|
|
1351
|
-
}), this.__internal__.auto_response
|
|
1346
|
+
}), this.__internal__.auto_response) {
|
|
1347
|
+
let n = new Uint8Array(0);
|
|
1348
|
+
try {
|
|
1349
|
+
n = this.validateBytes(this.__internal__.serial.auto_response);
|
|
1350
|
+
} catch (i) {
|
|
1351
|
+
this.serialErrors(i);
|
|
1352
|
+
}
|
|
1353
|
+
m(this, b, E).call(this, n, null);
|
|
1354
|
+
}
|
|
1352
1355
|
const t = [...this.__internal__.serial.queue];
|
|
1353
1356
|
this.__internal__.serial.queue = t.splice(1);
|
|
1354
1357
|
}, le = function(l = 1) {
|
|
@@ -1362,7 +1365,7 @@ b = /* @__PURE__ */ new WeakSet(), E = function(l) {
|
|
|
1362
1365
|
};
|
|
1363
1366
|
};
|
|
1364
1367
|
_.instance || (_.instance = new _());
|
|
1365
|
-
const
|
|
1368
|
+
const ye = {
|
|
1366
1369
|
relay: [],
|
|
1367
1370
|
locker: [],
|
|
1368
1371
|
jofemar: [],
|
|
@@ -1371,7 +1374,7 @@ const me = {
|
|
|
1371
1374
|
pinpad: [],
|
|
1372
1375
|
pinpax: []
|
|
1373
1376
|
};
|
|
1374
|
-
_.devices = { ..._.devices, ...
|
|
1377
|
+
_.devices = { ..._.devices, ...ye };
|
|
1375
1378
|
_.addCustom = (l, e) => {
|
|
1376
1379
|
_.registerType(l), _.add(e);
|
|
1377
1380
|
};
|
|
@@ -1390,7 +1393,7 @@ _.getRelay = (l = 1) => _.getByNumber("relay", l);
|
|
|
1390
1393
|
_.getArduino = (l = 1) => _.getByNumber("arduino", l);
|
|
1391
1394
|
_.getPinPad = (l = 1) => _.getByNumber("pinpad", l);
|
|
1392
1395
|
_.getPinPax = (l = 1) => _.getByNumber("pinpax", l);
|
|
1393
|
-
class
|
|
1396
|
+
class me extends be {
|
|
1394
1397
|
constructor(e) {
|
|
1395
1398
|
super(e), this.__internal__ = structuredClone(this.__internal__), this.getResponseAsArrayHex(), this.__internal__.device.door_open = !1, this.__internal__.time.response_engines = 2e3, this.__internal__.time.sense = 100, this.__internal__.interval.waiting_sense = 0, this.__internal__.dispense = {
|
|
1396
1399
|
must_response: !1,
|
|
@@ -1461,7 +1464,7 @@ class ye extends be {
|
|
|
1461
1464
|
}
|
|
1462
1465
|
async internalDispense(e) {
|
|
1463
1466
|
if (this.isDispensing) throw new Error("Another dispensing process is running");
|
|
1464
|
-
if (!
|
|
1467
|
+
if (!L.enable && !this.__internal__.serial.connected && (await this.serialConnect(), !this.__internal__.serial.connected))
|
|
1465
1468
|
throw new Error("Serial device not connected");
|
|
1466
1469
|
return this.__internal__.serial.queue.length === 0 ? (await this.appendToQueue(e, "dispense"), await this.internalDispenseStatus()) : new Promise((t) => {
|
|
1467
1470
|
const n = setInterval(async () => {
|
|
@@ -1498,13 +1501,13 @@ class ye extends be {
|
|
|
1498
1501
|
}
|
|
1499
1502
|
}
|
|
1500
1503
|
export {
|
|
1501
|
-
|
|
1502
|
-
|
|
1504
|
+
L as E,
|
|
1505
|
+
me as K,
|
|
1503
1506
|
_,
|
|
1504
1507
|
Ce as a,
|
|
1505
1508
|
ke as b,
|
|
1506
1509
|
De as g,
|
|
1507
|
-
|
|
1510
|
+
Ae as i,
|
|
1508
1511
|
ve as s,
|
|
1509
1512
|
_e as w
|
|
1510
1513
|
};
|