@danidoble/webserial 4.2.2 → 4.2.4
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 -0
- package/dist/arduino.js +77 -0
- package/dist/boardroid.cjs +1 -0
- package/dist/boardroid.js +729 -0
- package/dist/jofemar.cjs +1 -0
- package/dist/jofemar.js +1107 -0
- package/dist/kernel-BFXQSiNz.js +1510 -0
- package/dist/kernel-C0epz_jB.cjs +4 -0
- package/dist/kernel.cjs +9 -0
- package/dist/kernel.js +16 -0
- package/dist/locker.cjs +1 -0
- package/dist/locker.js +180 -0
- package/dist/pinpad.cjs +31 -0
- package/dist/pinpad.js +5075 -0
- package/dist/pinpax.cjs +20 -0
- package/dist/pinpax.js +355 -0
- package/dist/relay.cjs +1 -0
- package/dist/relay.js +69 -0
- package/dist/webserial.cjs +9 -0
- package/dist/webserial.js +26 -9063
- package/package.json +41 -9
- package/dist/webserial.umd.cjs +0 -57
|
@@ -0,0 +1,1510 @@
|
|
|
1
|
+
var ce = Object.defineProperty;
|
|
2
|
+
var W = (l) => {
|
|
3
|
+
throw TypeError(l);
|
|
4
|
+
};
|
|
5
|
+
var ue = (l, e, t) => e in l ? ce(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
|
|
6
|
+
var N = (l, e, t) => ue(l, typeof e != "symbol" ? e + "" : e, t), F = (l, e, t) => e.has(l) || W("Cannot " + t);
|
|
7
|
+
var w = (l, e, t) => (F(l, e, "read from private field"), t ? t.call(l) : e.get(l)), U = (l, e, t) => e.has(l) ? W("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(l) : e.set(l, t), j = (l, e, t, n) => (F(l, e, "write to private field"), n ? n.call(l, t) : e.set(l, t), t), a = (l, e, t) => (F(l, e, "access private method"), t);
|
|
8
|
+
function _e(l = 100) {
|
|
9
|
+
return new Promise((e) => setTimeout(() => e(), l));
|
|
10
|
+
}
|
|
11
|
+
function ve() {
|
|
12
|
+
return "serial" in navigator;
|
|
13
|
+
}
|
|
14
|
+
function ke() {
|
|
15
|
+
return "geolocation" in navigator;
|
|
16
|
+
}
|
|
17
|
+
function Ce() {
|
|
18
|
+
return "crypto" in window;
|
|
19
|
+
}
|
|
20
|
+
function De(l = 1) {
|
|
21
|
+
return l * 1e3;
|
|
22
|
+
}
|
|
23
|
+
function Se(l) {
|
|
24
|
+
return l == null || l === "";
|
|
25
|
+
}
|
|
26
|
+
var v, S, s, Y, Z, c, q, p, d, I, o, $, T;
|
|
27
|
+
const r = class r {
|
|
28
|
+
static status(e = null) {
|
|
29
|
+
var n, i;
|
|
30
|
+
if (!a(n = r, s, c).call(n, e)) return !1;
|
|
31
|
+
let t = [];
|
|
32
|
+
switch (w(r, v)) {
|
|
33
|
+
case "locker":
|
|
34
|
+
t = ["0", "8"];
|
|
35
|
+
break;
|
|
36
|
+
case "boardroid":
|
|
37
|
+
t = ["2", (5 + w(r, S)).toString(16).toUpperCase()];
|
|
38
|
+
break;
|
|
39
|
+
case "jofemar":
|
|
40
|
+
t = ["6"];
|
|
41
|
+
break;
|
|
42
|
+
default:
|
|
43
|
+
return !1;
|
|
44
|
+
}
|
|
45
|
+
a(i = r, s, o).call(i, t);
|
|
46
|
+
}
|
|
47
|
+
static dispensed(e = null) {
|
|
48
|
+
var n, i;
|
|
49
|
+
if (!a(n = r, s, c).call(n, e)) return !1;
|
|
50
|
+
let t = [];
|
|
51
|
+
switch (w(r, v)) {
|
|
52
|
+
case "locker":
|
|
53
|
+
t = ["0", "7", "4", "4", "4"];
|
|
54
|
+
break;
|
|
55
|
+
case "boardroid":
|
|
56
|
+
t = ["2", "D7", "A", "0", "0", "0", "0", "0", "0", "0", "0", "0", "F2"];
|
|
57
|
+
break;
|
|
58
|
+
case "jofemar":
|
|
59
|
+
t = ["6", "30"];
|
|
60
|
+
break;
|
|
61
|
+
default:
|
|
62
|
+
return !1;
|
|
63
|
+
}
|
|
64
|
+
a(i = r, s, o).call(i, t);
|
|
65
|
+
}
|
|
66
|
+
static notDispensed(e = null) {
|
|
67
|
+
var n, i;
|
|
68
|
+
if (!a(n = r, s, c).call(n, e)) return !1;
|
|
69
|
+
let t = [];
|
|
70
|
+
switch (w(r, v)) {
|
|
71
|
+
case "locker":
|
|
72
|
+
t = ["0", "7", "5", "5", "5"];
|
|
73
|
+
break;
|
|
74
|
+
case "boardroid":
|
|
75
|
+
t = ["2", "D7", "A", "0", "0", "1", "0", "0", "0", "0", "0", "0", "F2"];
|
|
76
|
+
break;
|
|
77
|
+
case "jofemar":
|
|
78
|
+
t = ["6", "34"];
|
|
79
|
+
break;
|
|
80
|
+
default:
|
|
81
|
+
return !1;
|
|
82
|
+
}
|
|
83
|
+
a(i = r, s, o).call(i, t);
|
|
84
|
+
}
|
|
85
|
+
static gateInactive(e = null) {
|
|
86
|
+
var t;
|
|
87
|
+
if (!a(t = r, s, c).call(t, e) || !a(this, s, q).call(this)) return !1;
|
|
88
|
+
a(this, s, o).call(this, ["0", "7", "5", "5", "5"]);
|
|
89
|
+
}
|
|
90
|
+
static gateConfigured(e = null) {
|
|
91
|
+
var t;
|
|
92
|
+
if (!a(t = r, s, c).call(t, e) || !a(this, s, q).call(this)) return !1;
|
|
93
|
+
a(this, s, o).call(this, ["0", "6"]);
|
|
94
|
+
}
|
|
95
|
+
static keyPressed(e = null) {
|
|
96
|
+
var u, g, f;
|
|
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, S)).toString(16), i = Math.floor(Math.random() * 15);
|
|
99
|
+
a(f = r, s, o).call(f, ["2", n, "54", t[i]]);
|
|
100
|
+
}
|
|
101
|
+
static doorOpened(e = null) {
|
|
102
|
+
var i, u;
|
|
103
|
+
if (!a(i = r, s, c).call(i, e) || !a(this, s, I).call(this)) return !1;
|
|
104
|
+
let t = [];
|
|
105
|
+
const n = (128 + w(r, S)).toString(16);
|
|
106
|
+
switch (w(r, v)) {
|
|
107
|
+
case "boardroid":
|
|
108
|
+
t = ["2", "D8", "dc"];
|
|
109
|
+
break;
|
|
110
|
+
case "jofemar":
|
|
111
|
+
t = ["2", n, "50", "4F"];
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
a(u = r, s, o).call(u, t);
|
|
115
|
+
}
|
|
116
|
+
static doorClosed(e = null) {
|
|
117
|
+
var i, u;
|
|
118
|
+
if (!a(i = r, s, c).call(i, e) || !a(this, s, I).call(this)) return !1;
|
|
119
|
+
let t = [];
|
|
120
|
+
const n = (128 + w(r, S)).toString(16);
|
|
121
|
+
switch (w(r, v)) {
|
|
122
|
+
case "boardroid":
|
|
123
|
+
t = ["2", "D8", "db"];
|
|
124
|
+
break;
|
|
125
|
+
case "jofemar":
|
|
126
|
+
t = ["2", n, "50", "43"];
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
a(u = r, s, o).call(u, t);
|
|
130
|
+
}
|
|
131
|
+
static channelDisconnected(e = null) {
|
|
132
|
+
var n, i, u;
|
|
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, S)).toString(16);
|
|
135
|
+
a(u = r, s, o).call(u, ["2", t, "43", "43", "43", "FD"]);
|
|
136
|
+
}
|
|
137
|
+
static channelConnected(e = null) {
|
|
138
|
+
var n, i, u;
|
|
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, S)).toString(16);
|
|
141
|
+
a(u = r, s, o).call(u, ["2", t, "43", "43", "43", "FC"]);
|
|
142
|
+
}
|
|
143
|
+
static channelEmpty(e = null) {
|
|
144
|
+
var n, i, u;
|
|
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, S)).toString(16);
|
|
147
|
+
a(u = r, s, o).call(u, ["2", t, "43", "43", "43", "FF"]);
|
|
148
|
+
}
|
|
149
|
+
static workingTemperature(e = null) {
|
|
150
|
+
var n, i, u;
|
|
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, S)).toString(16);
|
|
153
|
+
a(u = r, s, o).call(u, ["2", t, "43", "54", "16"]);
|
|
154
|
+
}
|
|
155
|
+
static currentTemperature(e = null) {
|
|
156
|
+
var i, u, g;
|
|
157
|
+
if (!a(i = r, s, c).call(i, e) || !a(u = r, s, I).call(u)) return !1;
|
|
158
|
+
let t = [];
|
|
159
|
+
const n = (128 + w(r, S)).toString(16);
|
|
160
|
+
switch (w(r, v)) {
|
|
161
|
+
case "boardroid":
|
|
162
|
+
t = ["2", "D9", "44", "30"];
|
|
163
|
+
break;
|
|
164
|
+
case "jofemar":
|
|
165
|
+
t = ["2", n, "43", "74", "2B", "30", "39", "2E", "31", "7F", "43"];
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
a(g = r, s, o).call(g, t);
|
|
169
|
+
}
|
|
170
|
+
static ready(e = null) {
|
|
171
|
+
var t, n, i;
|
|
172
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
173
|
+
a(i = r, s, o).call(i, ["6", "30"]);
|
|
174
|
+
}
|
|
175
|
+
static busy(e = null) {
|
|
176
|
+
var t, n, i;
|
|
177
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
178
|
+
a(i = r, s, o).call(i, ["6", "31"]);
|
|
179
|
+
}
|
|
180
|
+
static invalidTray(e = null) {
|
|
181
|
+
var t, n, i;
|
|
182
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
183
|
+
a(i = r, s, o).call(i, ["6", "32"]);
|
|
184
|
+
}
|
|
185
|
+
static invalidChannel(e = null) {
|
|
186
|
+
var t, n, i;
|
|
187
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
188
|
+
a(i = r, s, o).call(i, ["6", "33"]);
|
|
189
|
+
}
|
|
190
|
+
static emptyChannel(e = null) {
|
|
191
|
+
var t, n, i;
|
|
192
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
193
|
+
a(i = r, s, o).call(i, ["6", "34"]);
|
|
194
|
+
}
|
|
195
|
+
static elevatorJam(e = null) {
|
|
196
|
+
var t, n, i;
|
|
197
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
198
|
+
a(i = r, s, o).call(i, ["6", "35"]);
|
|
199
|
+
}
|
|
200
|
+
static elevatorMalfunction(e = null) {
|
|
201
|
+
var t, n, i;
|
|
202
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
203
|
+
a(i = r, s, o).call(i, ["6", "36"]);
|
|
204
|
+
}
|
|
205
|
+
static phototransistorFailure(e = null) {
|
|
206
|
+
var t, n, i;
|
|
207
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
208
|
+
a(i = r, s, o).call(i, ["6", "37"]);
|
|
209
|
+
}
|
|
210
|
+
static allChannelsEmpty(e = null) {
|
|
211
|
+
var t, n, i;
|
|
212
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
213
|
+
a(i = r, s, o).call(i, ["6", "38"]);
|
|
214
|
+
}
|
|
215
|
+
static productDetectorFailure(e = null) {
|
|
216
|
+
var t, n, i;
|
|
217
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
218
|
+
a(i = r, s, o).call(i, ["6", "39"]);
|
|
219
|
+
}
|
|
220
|
+
static displayDisconnected(e = null) {
|
|
221
|
+
var t, n, i;
|
|
222
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
223
|
+
a(i = r, s, o).call(i, ["6", "41"]);
|
|
224
|
+
}
|
|
225
|
+
static productUnderElevator(e = null) {
|
|
226
|
+
var t, n, i;
|
|
227
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
228
|
+
a(i = r, s, o).call(i, ["6", "42"]);
|
|
229
|
+
}
|
|
230
|
+
static elevatorSettingAlarm(e = null) {
|
|
231
|
+
var t, n, i;
|
|
232
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
233
|
+
a(i = r, s, o).call(i, ["6", "43"]);
|
|
234
|
+
}
|
|
235
|
+
static buttonPanelFailure(e = null) {
|
|
236
|
+
var t, n, i;
|
|
237
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
238
|
+
a(i = r, s, o).call(i, ["6", "44"]);
|
|
239
|
+
}
|
|
240
|
+
static errorWritingEeprom(e = null) {
|
|
241
|
+
var t, n, i;
|
|
242
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
243
|
+
a(i = r, s, o).call(i, ["6", "45"]);
|
|
244
|
+
}
|
|
245
|
+
static errorControlTemperature(e = null) {
|
|
246
|
+
var t, n, i;
|
|
247
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
248
|
+
a(i = r, s, o).call(i, ["6", "46"]);
|
|
249
|
+
}
|
|
250
|
+
static thermometerDisconnected(e = null) {
|
|
251
|
+
var t, n, i;
|
|
252
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
253
|
+
a(i = r, s, o).call(i, ["6", "47"]);
|
|
254
|
+
}
|
|
255
|
+
static thermometerMisconfigured(e = null) {
|
|
256
|
+
var t, n, i;
|
|
257
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
258
|
+
a(i = r, s, o).call(i, ["6", "48"]);
|
|
259
|
+
}
|
|
260
|
+
static thermometerFailure(e = null) {
|
|
261
|
+
var t, n, i;
|
|
262
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
263
|
+
a(i = r, s, o).call(i, ["6", "49"]);
|
|
264
|
+
}
|
|
265
|
+
static errorExtractorConsumption(e = null) {
|
|
266
|
+
var t, n, i;
|
|
267
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
268
|
+
a(i = r, s, o).call(i, ["6", "4A"]);
|
|
269
|
+
}
|
|
270
|
+
static channelSearchError(e = null) {
|
|
271
|
+
var t, n, i;
|
|
272
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
273
|
+
a(i = r, s, o).call(i, ["6", "4B"]);
|
|
274
|
+
}
|
|
275
|
+
static productExitMouthSearchError(e = null) {
|
|
276
|
+
var t, n, i;
|
|
277
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
278
|
+
a(i = r, s, o).call(i, ["6", "4C"]);
|
|
279
|
+
}
|
|
280
|
+
static elevatorInteriorLocked(e = null) {
|
|
281
|
+
var t, n, i;
|
|
282
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
283
|
+
a(i = r, s, o).call(i, ["6", "4D"]);
|
|
284
|
+
}
|
|
285
|
+
static productDetectorVerifierError(e = null) {
|
|
286
|
+
var t, n, i;
|
|
287
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
288
|
+
a(i = r, s, o).call(i, ["6", "4E"]);
|
|
289
|
+
}
|
|
290
|
+
static waitingForProductRecall(e = null) {
|
|
291
|
+
var t, n, i;
|
|
292
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
293
|
+
a(i = r, s, o).call(i, ["6", "4F"]);
|
|
294
|
+
}
|
|
295
|
+
static productExpiredByTemperature(e = null) {
|
|
296
|
+
var t, n, i;
|
|
297
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
298
|
+
a(i = r, s, o).call(i, ["6", "50"]);
|
|
299
|
+
}
|
|
300
|
+
static faultyAutomaticDoor(e = null) {
|
|
301
|
+
var t, n, i;
|
|
302
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
303
|
+
a(i = r, s, o).call(i, ["6", "51"]);
|
|
304
|
+
}
|
|
305
|
+
static rejectLever(e = null) {
|
|
306
|
+
var t, n, i;
|
|
307
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
308
|
+
a(i = r, s, o).call(i, ["2", "A0", "1"]);
|
|
309
|
+
}
|
|
310
|
+
static resetCoinPurse(e = null) {
|
|
311
|
+
var t, n, i;
|
|
312
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
313
|
+
a(i = r, s, o).call(i, ["2", "A0", "2"]);
|
|
314
|
+
}
|
|
315
|
+
static coinInsertedBox(e = null, t = null) {
|
|
316
|
+
var u, g, f, h;
|
|
317
|
+
if (!a(u = r, s, c).call(u, e) || !a(g = r, s, p).call(g)) return !1;
|
|
318
|
+
const n = ["40", "41", "42", "43", "44", "45"], i = a(f = r, s, $).call(f, n, t);
|
|
319
|
+
a(h = r, s, o).call(h, ["2", "A0", i]);
|
|
320
|
+
}
|
|
321
|
+
static coinInsertedTube(e = null, t = null) {
|
|
322
|
+
var u, g, f, h;
|
|
323
|
+
if (!a(u = r, s, c).call(u, e) || !a(g = r, s, p).call(g)) return !1;
|
|
324
|
+
const n = ["50", "51", "52", "53", "54", "55"], i = a(f = r, s, $).call(f, n, t);
|
|
325
|
+
a(h = r, s, o).call(h, ["2", "A0", i]);
|
|
326
|
+
}
|
|
327
|
+
static banknoteInsertedStacker(e = null, t = null) {
|
|
328
|
+
var u, g, f, h;
|
|
329
|
+
if (!a(u = r, s, c).call(u, e) || !a(g = r, s, p).call(g)) return !1;
|
|
330
|
+
const n = ["80", "81", "82", "83", "84"], i = a(f = r, s, T).call(f, n, t);
|
|
331
|
+
a(h = r, s, o).call(h, ["2", "B0", i]);
|
|
332
|
+
}
|
|
333
|
+
static banknoteInsertedEscrow(e = null, t = null) {
|
|
334
|
+
var u, g, f, h;
|
|
335
|
+
if (!a(u = r, s, c).call(u, e) || !a(g = r, s, p).call(g)) return !1;
|
|
336
|
+
const n = ["90", "91", "92", "93", "94"], i = a(f = r, s, T).call(f, n, t);
|
|
337
|
+
a(h = r, s, o).call(h, ["2", "B0", i]);
|
|
338
|
+
}
|
|
339
|
+
static banknoteEjected(e = null, t = null) {
|
|
340
|
+
var u, g, f, h;
|
|
341
|
+
if (!a(u = r, s, c).call(u, e) || !a(g = r, s, p).call(g)) return !1;
|
|
342
|
+
const n = ["A0", "A1", "A2", "A3", "A4"], i = a(f = r, s, T).call(f, n, t);
|
|
343
|
+
a(h = r, s, o).call(h, ["2", "B0", i]);
|
|
344
|
+
}
|
|
345
|
+
static banknoteInsertedRecycler(e = null, t = null) {
|
|
346
|
+
var u, g, f, h;
|
|
347
|
+
if (!a(u = r, s, c).call(u, e) || !a(g = r, s, p).call(g)) return !1;
|
|
348
|
+
const n = ["B0", "B1", "B2", "B3", "B4"], i = a(f = r, s, T).call(f, n, t);
|
|
349
|
+
a(h = r, s, o).call(h, ["2", "B0", i]);
|
|
350
|
+
}
|
|
351
|
+
static banknoteTaken(e = null) {
|
|
352
|
+
var t, n, i;
|
|
353
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
354
|
+
a(i = r, s, o).call(i, ["2", "B0", "2a"]);
|
|
355
|
+
}
|
|
356
|
+
static coinPurseEnabled(e = null) {
|
|
357
|
+
var t, n, i;
|
|
358
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
359
|
+
a(i = r, s, o).call(i, ["2", "D0", "1"]);
|
|
360
|
+
}
|
|
361
|
+
static coinPurseDisabled(e = null) {
|
|
362
|
+
var t, n, i;
|
|
363
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
364
|
+
a(i = r, s, o).call(i, ["2", "D0", "0"]);
|
|
365
|
+
}
|
|
366
|
+
static billPurseDisabled(e = null) {
|
|
367
|
+
var t, n, i;
|
|
368
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
369
|
+
a(i = r, s, o).call(i, ["2", "D1", "0", "0"]);
|
|
370
|
+
}
|
|
371
|
+
static billPurseEnabled(e = null) {
|
|
372
|
+
var t, n, i;
|
|
373
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
374
|
+
a(i = r, s, o).call(i, ["2", "D1", "1", "1"]);
|
|
375
|
+
}
|
|
376
|
+
static readTubes(e = null) {
|
|
377
|
+
var k, C, D;
|
|
378
|
+
if (!a(k = r, s, c).call(k, e) || !a(C = r, s, p).call(C)) return !1;
|
|
379
|
+
const t = [
|
|
380
|
+
"0",
|
|
381
|
+
"1",
|
|
382
|
+
"2",
|
|
383
|
+
"3",
|
|
384
|
+
"4",
|
|
385
|
+
"5",
|
|
386
|
+
"6",
|
|
387
|
+
"7",
|
|
388
|
+
"8",
|
|
389
|
+
"9",
|
|
390
|
+
"a",
|
|
391
|
+
"b",
|
|
392
|
+
"c",
|
|
393
|
+
"d",
|
|
394
|
+
"e",
|
|
395
|
+
"f",
|
|
396
|
+
"10",
|
|
397
|
+
"11",
|
|
398
|
+
"12",
|
|
399
|
+
"13",
|
|
400
|
+
"14",
|
|
401
|
+
"15",
|
|
402
|
+
"16",
|
|
403
|
+
"17",
|
|
404
|
+
"18",
|
|
405
|
+
"19",
|
|
406
|
+
"1a",
|
|
407
|
+
"1b",
|
|
408
|
+
"1c",
|
|
409
|
+
"1d",
|
|
410
|
+
"1e",
|
|
411
|
+
"1f"
|
|
412
|
+
], [n, i, u, g, f, h] = [
|
|
413
|
+
t[Math.floor(Math.random() * 30)],
|
|
414
|
+
t[Math.floor(Math.random() * 30)],
|
|
415
|
+
t[Math.floor(Math.random() * 30)],
|
|
416
|
+
t[Math.floor(Math.random() * 30)],
|
|
417
|
+
t[Math.floor(Math.random() * 30)],
|
|
418
|
+
t[Math.floor(Math.random() * 30)]
|
|
419
|
+
];
|
|
420
|
+
a(D = r, s, o).call(D, ["2", "D2", n, i, u, g, f, h]);
|
|
421
|
+
}
|
|
422
|
+
static readBillPurse(e = null, t = null) {
|
|
423
|
+
var i, u, g, f;
|
|
424
|
+
if (!a(i = r, s, c).call(i, e) || !a(u = r, s, p).call(u)) return !1;
|
|
425
|
+
let n = [
|
|
426
|
+
"0",
|
|
427
|
+
"1",
|
|
428
|
+
"2",
|
|
429
|
+
"3",
|
|
430
|
+
"4",
|
|
431
|
+
"5",
|
|
432
|
+
"6",
|
|
433
|
+
"7",
|
|
434
|
+
"8",
|
|
435
|
+
"9",
|
|
436
|
+
"a",
|
|
437
|
+
"b",
|
|
438
|
+
"c",
|
|
439
|
+
"d",
|
|
440
|
+
"e",
|
|
441
|
+
"f",
|
|
442
|
+
"10",
|
|
443
|
+
"11",
|
|
444
|
+
"12",
|
|
445
|
+
"13",
|
|
446
|
+
"14",
|
|
447
|
+
"15",
|
|
448
|
+
"16",
|
|
449
|
+
"17",
|
|
450
|
+
"18",
|
|
451
|
+
"19",
|
|
452
|
+
"1a",
|
|
453
|
+
"1b",
|
|
454
|
+
"1c"
|
|
455
|
+
];
|
|
456
|
+
if (e._recycler.ict) {
|
|
457
|
+
const h = n[Math.floor(Math.random() * 31)];
|
|
458
|
+
let k = "0", C = "0", D = "0", A = "0", M = "0";
|
|
459
|
+
if (t !== null && !isNaN(parseInt(t)))
|
|
460
|
+
switch (t.toString()) {
|
|
461
|
+
case "20":
|
|
462
|
+
k = h;
|
|
463
|
+
break;
|
|
464
|
+
case "50":
|
|
465
|
+
C = h;
|
|
466
|
+
break;
|
|
467
|
+
case "100":
|
|
468
|
+
D = h;
|
|
469
|
+
break;
|
|
470
|
+
case "200":
|
|
471
|
+
A = h;
|
|
472
|
+
break;
|
|
473
|
+
case "500":
|
|
474
|
+
M = h;
|
|
475
|
+
break;
|
|
476
|
+
}
|
|
477
|
+
else
|
|
478
|
+
switch (e._recycler.bill) {
|
|
479
|
+
case 0:
|
|
480
|
+
k = h;
|
|
481
|
+
break;
|
|
482
|
+
case 1:
|
|
483
|
+
C = h;
|
|
484
|
+
break;
|
|
485
|
+
case 2:
|
|
486
|
+
D = h;
|
|
487
|
+
break;
|
|
488
|
+
case 3:
|
|
489
|
+
A = h;
|
|
490
|
+
break;
|
|
491
|
+
case 4:
|
|
492
|
+
M = h;
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
a(g = r, s, o).call(g, ["2", "D3", k, C, D, A, M, "0"]);
|
|
496
|
+
} else {
|
|
497
|
+
const [h, k, C, D, A, M] = [
|
|
498
|
+
n[Math.floor(Math.random() * 30)],
|
|
499
|
+
n[Math.floor(Math.random() * 30)],
|
|
500
|
+
n[Math.floor(Math.random() * 30)],
|
|
501
|
+
n[Math.floor(Math.random() * 2)],
|
|
502
|
+
n[Math.floor(Math.random())],
|
|
503
|
+
n[Math.floor(Math.random())]
|
|
504
|
+
];
|
|
505
|
+
a(f = r, s, o).call(f, ["2", "D3", h, k, C, D, A, M]);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
static banknoteAccepted(e = null) {
|
|
509
|
+
var t, n, i;
|
|
510
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
511
|
+
a(i = r, s, o).call(i, ["2", "D4", "1"]);
|
|
512
|
+
}
|
|
513
|
+
static banknoteRejected(e = null) {
|
|
514
|
+
var t, n, i;
|
|
515
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
516
|
+
a(i = r, s, o).call(i, ["2", "D4", "0"]);
|
|
517
|
+
}
|
|
518
|
+
static banknotesDispensed(e = null) {
|
|
519
|
+
var n, i, u, g;
|
|
520
|
+
if (!a(n = r, s, c).call(n, e) || !a(i = r, s, p).call(i)) return !1;
|
|
521
|
+
let t = [
|
|
522
|
+
"1",
|
|
523
|
+
"2",
|
|
524
|
+
"3",
|
|
525
|
+
"4",
|
|
526
|
+
"5",
|
|
527
|
+
"6",
|
|
528
|
+
"7",
|
|
529
|
+
"8",
|
|
530
|
+
"9",
|
|
531
|
+
"a",
|
|
532
|
+
"b",
|
|
533
|
+
"c",
|
|
534
|
+
"d",
|
|
535
|
+
"e",
|
|
536
|
+
"f",
|
|
537
|
+
"10",
|
|
538
|
+
"11",
|
|
539
|
+
"12",
|
|
540
|
+
"13",
|
|
541
|
+
"14",
|
|
542
|
+
"15",
|
|
543
|
+
"16",
|
|
544
|
+
"17",
|
|
545
|
+
"18",
|
|
546
|
+
"19",
|
|
547
|
+
"1a",
|
|
548
|
+
"1b",
|
|
549
|
+
"1c"
|
|
550
|
+
];
|
|
551
|
+
if (e._recycler.ict) {
|
|
552
|
+
const f = t[Math.floor(Math.random() * 30)];
|
|
553
|
+
let h = "0", k = "0", C = "0", D = "0", A = "0";
|
|
554
|
+
switch (e._recycler.bill) {
|
|
555
|
+
case 0:
|
|
556
|
+
h = f;
|
|
557
|
+
break;
|
|
558
|
+
case 1:
|
|
559
|
+
k = f;
|
|
560
|
+
break;
|
|
561
|
+
case 2:
|
|
562
|
+
C = f;
|
|
563
|
+
break;
|
|
564
|
+
case 3:
|
|
565
|
+
D = f;
|
|
566
|
+
break;
|
|
567
|
+
case 4:
|
|
568
|
+
A = f;
|
|
569
|
+
break;
|
|
570
|
+
}
|
|
571
|
+
a(u = r, s, o).call(u, ["2", "D5", h, k, C, D, A, "0"]);
|
|
572
|
+
} else {
|
|
573
|
+
const [f, h, k, C, D, A] = [
|
|
574
|
+
t[Math.floor(Math.random() * 30)],
|
|
575
|
+
t[Math.floor(Math.random() * 30)],
|
|
576
|
+
t[Math.floor(Math.random() * 30)],
|
|
577
|
+
t[Math.floor(Math.random() * 2)],
|
|
578
|
+
t[Math.floor(Math.random())],
|
|
579
|
+
t[Math.floor(Math.random())]
|
|
580
|
+
];
|
|
581
|
+
a(g = r, s, o).call(g, ["2", "D5", f, h, k, C, D, A]);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
static coinsDispensed(e = null) {
|
|
585
|
+
var t, n, i;
|
|
586
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
587
|
+
a(i = r, s, o).call(i, ["2", "D6"]);
|
|
588
|
+
}
|
|
589
|
+
static relayOn(e = null) {
|
|
590
|
+
var t, n, i;
|
|
591
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
592
|
+
a(i = r, s, o).call(i, ["2", "DA", "1"]);
|
|
593
|
+
}
|
|
594
|
+
static relayOff(e = null) {
|
|
595
|
+
var t, n, i;
|
|
596
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
597
|
+
a(i = r, s, o).call(i, ["2", "DA", "0"]);
|
|
598
|
+
}
|
|
599
|
+
static nayaxEnabled(e = null) {
|
|
600
|
+
var t, n, i;
|
|
601
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
602
|
+
a(i = r, s, o).call(i, ["2", "DD", "1"]);
|
|
603
|
+
}
|
|
604
|
+
static nayaxDisabled(e = null) {
|
|
605
|
+
var t, n, i;
|
|
606
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
607
|
+
a(i = r, s, o).call(i, ["2", "DD", "0"]);
|
|
608
|
+
}
|
|
609
|
+
static nayaxPreCreditAuthorized(e = null) {
|
|
610
|
+
var t, n, i;
|
|
611
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
612
|
+
a(i = r, s, o).call(i, ["2", "DD", "3"]);
|
|
613
|
+
}
|
|
614
|
+
static nayaxCancelRequest(e = null) {
|
|
615
|
+
var t, n, i;
|
|
616
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
617
|
+
a(i = r, s, o).call(i, ["2", "DD", "4"]);
|
|
618
|
+
}
|
|
619
|
+
static nayaxSellApproved(e = null) {
|
|
620
|
+
var t, n, i;
|
|
621
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
622
|
+
a(i = r, s, o).call(i, ["2", "DD", "5"]);
|
|
623
|
+
}
|
|
624
|
+
static nayaxSellDenied(e = null) {
|
|
625
|
+
var t, n, i;
|
|
626
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
627
|
+
a(i = r, s, o).call(i, ["2", "DD", "6"]);
|
|
628
|
+
}
|
|
629
|
+
static nayaxEndSession(e = null) {
|
|
630
|
+
var t, n, i;
|
|
631
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
632
|
+
a(i = r, s, o).call(i, ["2", "DD", "7"]);
|
|
633
|
+
}
|
|
634
|
+
static nayaxCancelled(e = null) {
|
|
635
|
+
var t, n, i;
|
|
636
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
637
|
+
a(i = r, s, o).call(i, ["2", "DD", "8"]);
|
|
638
|
+
}
|
|
639
|
+
static nayaxDispensed(e = null) {
|
|
640
|
+
var t, n, i;
|
|
641
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
642
|
+
a(i = r, s, o).call(i, ["2", "DD", "A", "0"]);
|
|
643
|
+
}
|
|
644
|
+
static nayaxNotDispensed(e = null) {
|
|
645
|
+
var t, n, i;
|
|
646
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, p).call(n)) return !1;
|
|
647
|
+
a(i = r, s, o).call(i, ["2", "DD", "A", "1"]);
|
|
648
|
+
}
|
|
649
|
+
static fullTray(e = null) {
|
|
650
|
+
var t, n, i;
|
|
651
|
+
if (!a(t = r, s, c).call(t, e) || !a(n = r, s, d).call(n)) return !1;
|
|
652
|
+
a(i = r, s, o).call(i, ["6", "4F"]);
|
|
653
|
+
}
|
|
654
|
+
static setConnection(e = null) {
|
|
655
|
+
var t;
|
|
656
|
+
if (!a(t = r, s, c).call(t, e)) return !1;
|
|
657
|
+
e.__internal__.serial.connected = !0;
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
v = new WeakMap(), S = new WeakMap(), s = new WeakSet(), Y = function() {
|
|
661
|
+
if (r.enable === !1) throw new Error("Emulator is disabled");
|
|
662
|
+
return r.enable;
|
|
663
|
+
}, Z = function(e) {
|
|
664
|
+
if (typeof e != "object" || !(e instanceof ye))
|
|
665
|
+
throw new Error(`Type ${e.typeDevice} is not supported`);
|
|
666
|
+
return r.instance = e, j(r, v, e.typeDevice), j(r, S, e.deviceNumber), !0;
|
|
667
|
+
}, c = function(e = null) {
|
|
668
|
+
var t, n;
|
|
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
|
+
}, q = function() {
|
|
671
|
+
if (w(r, v) !== "locker") throw new Error("This function is only available for Locker devices");
|
|
672
|
+
return !0;
|
|
673
|
+
}, p = function() {
|
|
674
|
+
if (w(r, v) !== "boardroid")
|
|
675
|
+
throw new Error("This function is only available for Boardroid devices");
|
|
676
|
+
return !0;
|
|
677
|
+
}, d = function() {
|
|
678
|
+
if (w(r, v) !== "jofemar") throw new Error("This function is only available for Jofemar devices");
|
|
679
|
+
return !0;
|
|
680
|
+
}, I = function() {
|
|
681
|
+
if (w(r, v) === "locker") throw new Error("This function is not available for Locker devices");
|
|
682
|
+
return !0;
|
|
683
|
+
}, o = function(e) {
|
|
684
|
+
r.instance.__emulate({ code: e });
|
|
685
|
+
}, $ = function(e, t = null) {
|
|
686
|
+
let n = e[Math.floor(Math.random() * 5)];
|
|
687
|
+
if (t !== null && !isNaN(parseFloat(t)))
|
|
688
|
+
switch (t.toString()) {
|
|
689
|
+
case "0.5":
|
|
690
|
+
n = e[1];
|
|
691
|
+
break;
|
|
692
|
+
case "1":
|
|
693
|
+
n = e[2];
|
|
694
|
+
break;
|
|
695
|
+
case "2":
|
|
696
|
+
n = e[3];
|
|
697
|
+
break;
|
|
698
|
+
case "5":
|
|
699
|
+
n = e[4];
|
|
700
|
+
break;
|
|
701
|
+
case "10":
|
|
702
|
+
n = e[5];
|
|
703
|
+
break;
|
|
704
|
+
}
|
|
705
|
+
return n;
|
|
706
|
+
}, T = function(e, t = null) {
|
|
707
|
+
let n = e[Math.floor(Math.random() * 4)];
|
|
708
|
+
if (t !== null && !isNaN(parseFloat(t)))
|
|
709
|
+
switch (t.toString()) {
|
|
710
|
+
case "20":
|
|
711
|
+
n = e[0];
|
|
712
|
+
break;
|
|
713
|
+
case "50":
|
|
714
|
+
n = e[1];
|
|
715
|
+
break;
|
|
716
|
+
case "100":
|
|
717
|
+
n = e[2];
|
|
718
|
+
break;
|
|
719
|
+
case "200":
|
|
720
|
+
n = e[3];
|
|
721
|
+
break;
|
|
722
|
+
case "500":
|
|
723
|
+
n = e[4];
|
|
724
|
+
break;
|
|
725
|
+
}
|
|
726
|
+
return n;
|
|
727
|
+
}, U(r, s), N(r, "enable", !1), N(r, "instance", null), U(r, v, null), U(r, S, 1);
|
|
728
|
+
let O = r;
|
|
729
|
+
var he = Object.defineProperty, ee = (l) => {
|
|
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), y = (l, e, t) => (fe(l, e, "access private method"), t);
|
|
732
|
+
class Q extends CustomEvent {
|
|
733
|
+
constructor(e, t) {
|
|
734
|
+
super(e, t);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
class te extends EventTarget {
|
|
738
|
+
constructor() {
|
|
739
|
+
super(...arguments), B(this, "__listeners__", {
|
|
740
|
+
debug: !1
|
|
741
|
+
}), B(this, "__debug__", !1);
|
|
742
|
+
}
|
|
743
|
+
dispatch(e, t = null) {
|
|
744
|
+
const n = new Q(e, { detail: t });
|
|
745
|
+
this.dispatchEvent(n), this.__debug__ && this.dispatchEvent(new Q("debug", { detail: { type: e, data: t } }));
|
|
746
|
+
}
|
|
747
|
+
dispatchAsync(e, t = null, n = 100) {
|
|
748
|
+
const i = this;
|
|
749
|
+
setTimeout(() => {
|
|
750
|
+
i.dispatch(e, t);
|
|
751
|
+
}, n);
|
|
752
|
+
}
|
|
753
|
+
on(e, t) {
|
|
754
|
+
typeof this.__listeners__[e] < "u" && !this.__listeners__[e] && (this.__listeners__[e] = !0), this.addEventListener(e, t);
|
|
755
|
+
}
|
|
756
|
+
off(e, t) {
|
|
757
|
+
this.removeEventListener(e, t);
|
|
758
|
+
}
|
|
759
|
+
serialRegisterAvailableListener(e) {
|
|
760
|
+
this.__listeners__[e] || (this.__listeners__[e] = !1);
|
|
761
|
+
}
|
|
762
|
+
get availableListeners() {
|
|
763
|
+
return Object.keys(this.__listeners__).sort().map((e) => ({
|
|
764
|
+
type: e,
|
|
765
|
+
listening: this.__listeners__[e]
|
|
766
|
+
}));
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
const R = class m extends te {
|
|
770
|
+
constructor() {
|
|
771
|
+
super(), ["change"].forEach((e) => {
|
|
772
|
+
this.serialRegisterAvailableListener(e);
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
static $dispatchChange(e = null) {
|
|
776
|
+
e && e.$checkAndDispatchConnection(), m.instance.dispatch("change", { devices: m.devices, dispatcher: e });
|
|
777
|
+
}
|
|
778
|
+
static typeError(e) {
|
|
779
|
+
const t = new Error();
|
|
780
|
+
throw t.message = `Type ${e} is not supported`, t.name = "DeviceTypeError", t;
|
|
781
|
+
}
|
|
782
|
+
static registerType(e) {
|
|
783
|
+
typeof m.devices[e] > "u" && (m.devices[e] = {});
|
|
784
|
+
}
|
|
785
|
+
static add(e) {
|
|
786
|
+
const t = e.typeDevice;
|
|
787
|
+
typeof m.devices[t] > "u" && (m.devices[t] = {});
|
|
788
|
+
const n = e.uuid;
|
|
789
|
+
if (typeof m.devices[t] > "u" && m.typeError(t), m.devices[t][n])
|
|
790
|
+
throw new Error(`Device with id ${n} already exists`);
|
|
791
|
+
return m.devices[t][n] = e, m.$dispatchChange(e), Object.keys(m.devices[t]).indexOf(n);
|
|
792
|
+
}
|
|
793
|
+
static get(e, t) {
|
|
794
|
+
return typeof m.devices[e] > "u" && (m.devices[e] = {}), typeof m.devices[e] > "u" && m.typeError(e), m.devices[e][t];
|
|
795
|
+
}
|
|
796
|
+
static getAll(e = null) {
|
|
797
|
+
return e === null ? m.devices : (typeof m.devices[e] > "u" && m.typeError(e), m.devices[e]);
|
|
798
|
+
}
|
|
799
|
+
static getList() {
|
|
800
|
+
return Object.values(m.devices).map((e) => Object.values(e)).flat();
|
|
801
|
+
}
|
|
802
|
+
static getByNumber(e, t) {
|
|
803
|
+
return typeof m.devices[e] > "u" && m.typeError(e), Object.values(m.devices[e]).find((n) => n.deviceNumber === t) ?? null;
|
|
804
|
+
}
|
|
805
|
+
static getCustom(e, t = 1) {
|
|
806
|
+
return typeof m.devices[e] > "u" && m.typeError(e), Object.values(m.devices[e]).find((n) => n.deviceNumber === t) ?? null;
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
B(R, "instance"), B(R, "devices", {});
|
|
810
|
+
let _ = R;
|
|
811
|
+
_.instance || (_.instance = new _());
|
|
812
|
+
function J(l = 100) {
|
|
813
|
+
return new Promise(
|
|
814
|
+
(e) => setTimeout(() => e(), l)
|
|
815
|
+
);
|
|
816
|
+
}
|
|
817
|
+
function ge() {
|
|
818
|
+
return "serial" in navigator;
|
|
819
|
+
}
|
|
820
|
+
const L = {
|
|
821
|
+
baudRate: 9600,
|
|
822
|
+
dataBits: 8,
|
|
823
|
+
stopBits: 1,
|
|
824
|
+
parity: "none",
|
|
825
|
+
bufferSize: 32768,
|
|
826
|
+
flowControl: "none"
|
|
827
|
+
};
|
|
828
|
+
var b, E, P, H, x, ne, V, z, K, re, ie, se, ae, G, X, le, oe;
|
|
829
|
+
class be extends te {
|
|
830
|
+
constructor({
|
|
831
|
+
filters: e = null,
|
|
832
|
+
config_port: t = L,
|
|
833
|
+
no_device: n = 1,
|
|
834
|
+
device_listen_on_channel: i = 1
|
|
835
|
+
} = {
|
|
836
|
+
filters: null,
|
|
837
|
+
config_port: L,
|
|
838
|
+
no_device: 1,
|
|
839
|
+
device_listen_on_channel: 1
|
|
840
|
+
}) {
|
|
841
|
+
if (super(), pe(this, b), B(this, "__internal__", {
|
|
842
|
+
auto_response: !1,
|
|
843
|
+
device_number: 1,
|
|
844
|
+
aux_port_connector: 0,
|
|
845
|
+
last_error: {
|
|
846
|
+
message: null,
|
|
847
|
+
action: null,
|
|
848
|
+
code: null,
|
|
849
|
+
no_code: 0
|
|
850
|
+
},
|
|
851
|
+
serial: {
|
|
852
|
+
connected: !1,
|
|
853
|
+
port: null,
|
|
854
|
+
last_action: null,
|
|
855
|
+
response: {
|
|
856
|
+
length: null,
|
|
857
|
+
buffer: new Uint8Array([]),
|
|
858
|
+
as: "hex",
|
|
859
|
+
replacer: /[\n\r]+/g,
|
|
860
|
+
limiter: null
|
|
861
|
+
},
|
|
862
|
+
reader: null,
|
|
863
|
+
input_done: null,
|
|
864
|
+
output_done: null,
|
|
865
|
+
input_stream: null,
|
|
866
|
+
output_stream: null,
|
|
867
|
+
keep_reading: !0,
|
|
868
|
+
time_until_send_bytes: void 0,
|
|
869
|
+
delay_first_connection: 200,
|
|
870
|
+
bytes_connection: null,
|
|
871
|
+
filters: [],
|
|
872
|
+
config_port: L,
|
|
873
|
+
queue: [],
|
|
874
|
+
auto_response: ["DD", "DD"]
|
|
875
|
+
},
|
|
876
|
+
device: {
|
|
877
|
+
type: "unknown",
|
|
878
|
+
id: window.crypto.randomUUID(),
|
|
879
|
+
listen_on_port: null
|
|
880
|
+
},
|
|
881
|
+
time: {
|
|
882
|
+
response_connection: 500,
|
|
883
|
+
response_general: 2e3
|
|
884
|
+
},
|
|
885
|
+
timeout: {
|
|
886
|
+
until_response: 0
|
|
887
|
+
},
|
|
888
|
+
interval: {
|
|
889
|
+
reconnection: 0
|
|
890
|
+
}
|
|
891
|
+
}), !("serial" in navigator))
|
|
892
|
+
throw new Error("Web Serial not supported");
|
|
893
|
+
e && (this.serialFilters = e), t && (this.serialConfigPort = t), n && y(this, b, le).call(this, n), i && ["number", "string"].includes(typeof i) && (this.listenOnChannel = i), y(this, b, se).call(this), y(this, b, ae).call(this);
|
|
894
|
+
}
|
|
895
|
+
set listenOnChannel(e) {
|
|
896
|
+
if (typeof e == "string" && (e = parseInt(e)), isNaN(e) || e < 1 || e > 255)
|
|
897
|
+
throw new Error("Invalid port number");
|
|
898
|
+
this.__internal__.device.listen_on_port = e, this.__internal__.serial.bytes_connection = this.serialSetConnectionConstant(e);
|
|
899
|
+
}
|
|
900
|
+
get lastAction() {
|
|
901
|
+
return this.__internal__.serial.last_action;
|
|
902
|
+
}
|
|
903
|
+
get listenOnChannel() {
|
|
904
|
+
return this.__internal__.device.listen_on_port ?? 1;
|
|
905
|
+
}
|
|
906
|
+
set serialFilters(e) {
|
|
907
|
+
this.__internal__.serial.filters = e;
|
|
908
|
+
}
|
|
909
|
+
get serialFilters() {
|
|
910
|
+
return this.__internal__.serial.filters;
|
|
911
|
+
}
|
|
912
|
+
set serialConfigPort(e) {
|
|
913
|
+
this.__internal__.serial.config_port = e;
|
|
914
|
+
}
|
|
915
|
+
get serialConfigPort() {
|
|
916
|
+
return this.__internal__.serial.config_port;
|
|
917
|
+
}
|
|
918
|
+
get isConnected() {
|
|
919
|
+
const e = this.__internal__.serial.connected, t = y(this, b, E).call(this, this.__internal__.serial.port);
|
|
920
|
+
return e && !t && y(this, b, P).call(this, { error: "Port is closed, not readable or writable." }), this.__internal__.serial.connected = t, this.__internal__.serial.connected;
|
|
921
|
+
}
|
|
922
|
+
get isDisconnected() {
|
|
923
|
+
const e = this.__internal__.serial.connected, t = y(this, b, E).call(this, this.__internal__.serial.port);
|
|
924
|
+
return !e && t && (this.dispatch("serial:connected"), _.$dispatchChange(this)), this.__internal__.serial.connected = t, !this.__internal__.serial.connected;
|
|
925
|
+
}
|
|
926
|
+
get deviceNumber() {
|
|
927
|
+
return this.__internal__.device_number;
|
|
928
|
+
}
|
|
929
|
+
get uuid() {
|
|
930
|
+
return this.__internal__.device.id;
|
|
931
|
+
}
|
|
932
|
+
get typeDevice() {
|
|
933
|
+
return this.__internal__.device.type;
|
|
934
|
+
}
|
|
935
|
+
get queue() {
|
|
936
|
+
return this.__internal__.serial.queue;
|
|
937
|
+
}
|
|
938
|
+
async timeout(e, t) {
|
|
939
|
+
this.__internal__.last_error.message = "Operation response timed out.", this.__internal__.last_error.action = t, this.__internal__.last_error.code = e, this.__internal__.timeout.until_response && (clearTimeout(this.__internal__.timeout.until_response), this.__internal__.timeout.until_response = 0), t === "connect" ? (this.__internal__.serial.connected = !1, this.dispatch("serial:reconnect", {}), _.$dispatchChange(this)) : t === "connection:start" && (await this.serialDisconnect(), this.__internal__.serial.connected = !1, this.__internal__.aux_port_connector += 1, _.$dispatchChange(this), await this.serialConnect()), this.dispatch("serial:timeout", {
|
|
940
|
+
...this.__internal__.last_error,
|
|
941
|
+
bytes: e,
|
|
942
|
+
action: t
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
async disconnect(e = null) {
|
|
946
|
+
await this.serialDisconnect(), y(this, b, P).call(this, e);
|
|
947
|
+
}
|
|
948
|
+
async connect() {
|
|
949
|
+
return new Promise((e, t) => {
|
|
950
|
+
ge() || t("Web Serial not supported"), setTimeout(async () => {
|
|
951
|
+
await J(499), await this.serialConnect(), this.isConnected ? e(`${this.typeDevice} device ${this.deviceNumber} connected`) : t(`${this.typeDevice} device ${this.deviceNumber} not connected`);
|
|
952
|
+
}, 1);
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
async serialDisconnect() {
|
|
956
|
+
try {
|
|
957
|
+
const e = this.__internal__.serial.reader, t = this.__internal__.serial.output_stream;
|
|
958
|
+
e && (await e.cancel().catch((n) => this.serialErrors(n)), await this.__internal__.serial.input_done), t && (await t.getWriter().close(), await this.__internal__.serial.output_done), this.__internal__.serial.connected && this.__internal__.serial && this.__internal__.serial.port && await this.__internal__.serial.port.close();
|
|
959
|
+
} catch (e) {
|
|
960
|
+
this.serialErrors(e);
|
|
961
|
+
} finally {
|
|
962
|
+
this.__internal__.serial.reader = null, this.__internal__.serial.input_done = null, this.__internal__.serial.output_stream = null, this.__internal__.serial.output_done = null, this.__internal__.serial.connected = !1, this.__internal__.serial.port = null, _.$dispatchChange(this);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
getResponseAsArrayBuffer() {
|
|
966
|
+
this.__internal__.serial.response.as = "arraybuffer";
|
|
967
|
+
}
|
|
968
|
+
getResponseAsArrayHex() {
|
|
969
|
+
this.__internal__.serial.response.as = "hex";
|
|
970
|
+
}
|
|
971
|
+
getResponseAsUint8Array() {
|
|
972
|
+
this.__internal__.serial.response.as = "uint8";
|
|
973
|
+
}
|
|
974
|
+
getResponseAsString() {
|
|
975
|
+
this.__internal__.serial.response.as = "string";
|
|
976
|
+
}
|
|
977
|
+
async serialPortsSaved(e) {
|
|
978
|
+
const t = this.serialFilters;
|
|
979
|
+
if (this.__internal__.aux_port_connector < e.length) {
|
|
980
|
+
const n = this.__internal__.aux_port_connector;
|
|
981
|
+
this.__internal__.serial.port = e[n];
|
|
982
|
+
} else
|
|
983
|
+
this.__internal__.aux_port_connector = 0, this.__internal__.serial.port = await navigator.serial.requestPort({
|
|
984
|
+
filters: t
|
|
985
|
+
});
|
|
986
|
+
if (!this.__internal__.serial.port)
|
|
987
|
+
throw new Error("Select another port please");
|
|
988
|
+
}
|
|
989
|
+
serialErrors(e) {
|
|
990
|
+
const t = e.toString().toLowerCase();
|
|
991
|
+
switch (!0) {
|
|
992
|
+
case t.includes("must be handling a user gesture to show a permission request"):
|
|
993
|
+
case t.includes("the port is closed."):
|
|
994
|
+
case t.includes("the port is closed or is not writable"):
|
|
995
|
+
case t.includes("the port is closed or is not readable"):
|
|
996
|
+
case t.includes("the port is closed or is not readable/writable"):
|
|
997
|
+
case t.includes("select another port please"):
|
|
998
|
+
case t.includes("no port selected by the user"):
|
|
999
|
+
case t.includes(
|
|
1000
|
+
"this readable stream reader has been released and cannot be used to cancel its previous owner stream"
|
|
1001
|
+
):
|
|
1002
|
+
this.dispatch("serial:need-permission", {}), _.$dispatchChange(this);
|
|
1003
|
+
break;
|
|
1004
|
+
case t.includes("the port is already open."):
|
|
1005
|
+
case t.includes("failed to open serial port"):
|
|
1006
|
+
this.serialDisconnect().then(async () => {
|
|
1007
|
+
this.__internal__.aux_port_connector += 1, await this.serialConnect();
|
|
1008
|
+
});
|
|
1009
|
+
break;
|
|
1010
|
+
case t.includes("cannot read properties of undefined (reading 'writable')"):
|
|
1011
|
+
case t.includes("cannot read properties of null (reading 'writable')"):
|
|
1012
|
+
case t.includes("cannot read property 'writable' of null"):
|
|
1013
|
+
case t.includes("cannot read property 'writable' of undefined"):
|
|
1014
|
+
this.serialDisconnect().then(async () => {
|
|
1015
|
+
await this.serialConnect();
|
|
1016
|
+
});
|
|
1017
|
+
break;
|
|
1018
|
+
case t.includes("'close' on 'serialport': a call to close() is already in progress."):
|
|
1019
|
+
break;
|
|
1020
|
+
case t.includes("failed to execute 'open' on 'serialport': a call to open() is already in progress."):
|
|
1021
|
+
break;
|
|
1022
|
+
case t.includes("the port is already closed."):
|
|
1023
|
+
break;
|
|
1024
|
+
case t.includes("the device has been lost"):
|
|
1025
|
+
this.dispatch("serial:lost", {}), _.$dispatchChange(this);
|
|
1026
|
+
break;
|
|
1027
|
+
case t.includes("navigator.serial is undefined"):
|
|
1028
|
+
this.dispatch("serial:unsupported", {});
|
|
1029
|
+
break;
|
|
1030
|
+
default:
|
|
1031
|
+
console.error(e);
|
|
1032
|
+
break;
|
|
1033
|
+
}
|
|
1034
|
+
this.dispatch("serial:error", e);
|
|
1035
|
+
}
|
|
1036
|
+
async serialConnect() {
|
|
1037
|
+
try {
|
|
1038
|
+
this.dispatch("serial:connecting", {});
|
|
1039
|
+
const e = await y(this, b, ne).call(this);
|
|
1040
|
+
if (e.length > 0)
|
|
1041
|
+
await this.serialPortsSaved(e);
|
|
1042
|
+
else {
|
|
1043
|
+
const i = this.serialFilters;
|
|
1044
|
+
this.__internal__.serial.port = await navigator.serial.requestPort({
|
|
1045
|
+
filters: i
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
const t = this.__internal__.serial.port;
|
|
1049
|
+
if (!t)
|
|
1050
|
+
throw new Error("No port selected by the user");
|
|
1051
|
+
await t.open(this.serialConfigPort);
|
|
1052
|
+
const n = this;
|
|
1053
|
+
t.onconnect = (i) => {
|
|
1054
|
+
console.log(i), n.dispatch("serial:connected", i), _.$dispatchChange(this), n.__internal__.serial.queue.length > 0 && n.dispatch("internal:queue", {});
|
|
1055
|
+
}, t.ondisconnect = async () => {
|
|
1056
|
+
await n.disconnect();
|
|
1057
|
+
}, await J(this.__internal__.serial.delay_first_connection), this.__internal__.timeout.until_response = setTimeout(async () => {
|
|
1058
|
+
await n.timeout(n.__internal__.serial.bytes_connection ?? [], "connection:start");
|
|
1059
|
+
}, this.__internal__.time.response_connection), this.__internal__.serial.last_action = "connect", await y(this, b, H).call(this, this.__internal__.serial.bytes_connection ?? []), this.dispatch("serial:sent", {
|
|
1060
|
+
action: "connect",
|
|
1061
|
+
bytes: this.__internal__.serial.bytes_connection
|
|
1062
|
+
}), this.__internal__.auto_response && y(this, b, x).call(this, this.__internal__.serial.auto_response, null), await y(this, b, re).call(this);
|
|
1063
|
+
} catch (e) {
|
|
1064
|
+
this.serialErrors(e);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
async serialForget() {
|
|
1068
|
+
return await y(this, b, ie).call(this);
|
|
1069
|
+
}
|
|
1070
|
+
decToHex(e) {
|
|
1071
|
+
return typeof e == "string" && (e = parseInt(e, 10)), e.toString(16);
|
|
1072
|
+
}
|
|
1073
|
+
hexToDec(e) {
|
|
1074
|
+
return parseInt(e, 16);
|
|
1075
|
+
}
|
|
1076
|
+
hexMaker(e = "00", t = 2) {
|
|
1077
|
+
return e.toString().padStart(t, "0").toLowerCase();
|
|
1078
|
+
}
|
|
1079
|
+
add0x(e) {
|
|
1080
|
+
const t = [];
|
|
1081
|
+
return e.forEach((n, i) => {
|
|
1082
|
+
t[i] = "0x" + n;
|
|
1083
|
+
}), t;
|
|
1084
|
+
}
|
|
1085
|
+
bytesToHex(e) {
|
|
1086
|
+
return this.add0x(Array.from(e, (t) => this.hexMaker(t)));
|
|
1087
|
+
}
|
|
1088
|
+
async appendToQueue(e, t) {
|
|
1089
|
+
const n = this.bytesToHex(e);
|
|
1090
|
+
if (["connect", "connection:start"].includes(t)) {
|
|
1091
|
+
if (this.__internal__.serial.connected) return;
|
|
1092
|
+
await this.serialConnect();
|
|
1093
|
+
return;
|
|
1094
|
+
}
|
|
1095
|
+
this.__internal__.serial.queue.push({ bytes: n, action: t }), this.dispatch("internal:queue", {});
|
|
1096
|
+
}
|
|
1097
|
+
serialSetConnectionConstant(e = 1) {
|
|
1098
|
+
throw new Error(`Method not implemented 'serialSetConnectionConstant' to listen on channel ${e}`);
|
|
1099
|
+
}
|
|
1100
|
+
serialMessage(e) {
|
|
1101
|
+
throw console.log(e), new Error("Method not implemented 'serialMessage'");
|
|
1102
|
+
}
|
|
1103
|
+
serialCorruptMessage(e, t) {
|
|
1104
|
+
throw console.log(e, t), new Error("Method not implemented 'serialCorruptMessage'");
|
|
1105
|
+
}
|
|
1106
|
+
clearSerialQueue() {
|
|
1107
|
+
this.__internal__.serial.queue = [];
|
|
1108
|
+
}
|
|
1109
|
+
sumHex(e) {
|
|
1110
|
+
let t = 0;
|
|
1111
|
+
return e.forEach((n) => {
|
|
1112
|
+
t += parseInt(n, 16);
|
|
1113
|
+
}), t.toString(16);
|
|
1114
|
+
}
|
|
1115
|
+
toString() {
|
|
1116
|
+
return JSON.stringify({
|
|
1117
|
+
__class: this.typeDevice,
|
|
1118
|
+
device_number: this.deviceNumber,
|
|
1119
|
+
uuid: this.uuid,
|
|
1120
|
+
connected: this.isConnected,
|
|
1121
|
+
connection: this.__internal__.serial.bytes_connection
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
softReload() {
|
|
1125
|
+
y(this, b, oe).call(this), this.dispatch("serial:soft-reload", {});
|
|
1126
|
+
}
|
|
1127
|
+
async sendConnect() {
|
|
1128
|
+
if (!this.__internal__.serial.bytes_connection)
|
|
1129
|
+
throw new Error("No connection bytes defined");
|
|
1130
|
+
await this.appendToQueue(this.__internal__.serial.bytes_connection, "connect");
|
|
1131
|
+
}
|
|
1132
|
+
// @ts-expect-error code is required but can be empty
|
|
1133
|
+
async sendCustomCode({ code: e = [] } = { code: [] }) {
|
|
1134
|
+
if (e === null || e.length === 0)
|
|
1135
|
+
throw new Error("No data to send");
|
|
1136
|
+
await this.appendToQueue(e, "custom");
|
|
1137
|
+
}
|
|
1138
|
+
stringToArrayHex(e) {
|
|
1139
|
+
return Array.from(e).map((t) => t.charCodeAt(0).toString(16));
|
|
1140
|
+
}
|
|
1141
|
+
stringToArrayBuffer(e, t = `
|
|
1142
|
+
`) {
|
|
1143
|
+
return this.parseStringToTextEncoder(e, t).buffer;
|
|
1144
|
+
}
|
|
1145
|
+
parseStringToTextEncoder(e = "", t = `
|
|
1146
|
+
`) {
|
|
1147
|
+
const n = new TextEncoder();
|
|
1148
|
+
return e += t, n.encode(e);
|
|
1149
|
+
}
|
|
1150
|
+
parseStringToBytes(e = "", t = `
|
|
1151
|
+
`) {
|
|
1152
|
+
const n = this.parseStringToTextEncoder(e, t);
|
|
1153
|
+
return Array.from(n).map((i) => i.toString(16));
|
|
1154
|
+
}
|
|
1155
|
+
parseUint8ToHex(e) {
|
|
1156
|
+
return Array.from(e).map((t) => t.toString(16));
|
|
1157
|
+
}
|
|
1158
|
+
parseHexToUint8(e) {
|
|
1159
|
+
return new Uint8Array(e.map((t) => parseInt(t, 16)));
|
|
1160
|
+
}
|
|
1161
|
+
stringArrayToUint8Array(e) {
|
|
1162
|
+
const t = [];
|
|
1163
|
+
return e.forEach((n) => {
|
|
1164
|
+
const i = n.replace("0x", "");
|
|
1165
|
+
t.push(parseInt(i, 16));
|
|
1166
|
+
}), new Uint8Array(t);
|
|
1167
|
+
}
|
|
1168
|
+
parseUint8ArrayToString(e) {
|
|
1169
|
+
const t = this.stringArrayToUint8Array(e);
|
|
1170
|
+
e = this.parseUint8ToHex(t);
|
|
1171
|
+
const n = e.map((i) => parseInt(i, 16));
|
|
1172
|
+
return this.__internal__.serial.response.replacer ? String.fromCharCode(...n).replace(this.__internal__.serial.response.replacer, "") : String.fromCharCode(...n);
|
|
1173
|
+
}
|
|
1174
|
+
hexToAscii(e) {
|
|
1175
|
+
const t = e.toString();
|
|
1176
|
+
let n = "";
|
|
1177
|
+
for (let i = 0; i < t.length; i += 2)
|
|
1178
|
+
n += String.fromCharCode(parseInt(t.substring(i, 2), 16));
|
|
1179
|
+
return n;
|
|
1180
|
+
}
|
|
1181
|
+
asciiToHex(e) {
|
|
1182
|
+
const t = [];
|
|
1183
|
+
for (let n = 0, i = e.length; n < i; n++) {
|
|
1184
|
+
const u = Number(e.charCodeAt(n)).toString(16);
|
|
1185
|
+
t.push(u);
|
|
1186
|
+
}
|
|
1187
|
+
return t.join("");
|
|
1188
|
+
}
|
|
1189
|
+
$checkAndDispatchConnection() {
|
|
1190
|
+
return this.isConnected;
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
b = /* @__PURE__ */ new WeakSet(), E = function(l) {
|
|
1194
|
+
return !!(l && l.readable && l.writable);
|
|
1195
|
+
}, P = function(l = null) {
|
|
1196
|
+
this.__internal__.serial.connected = !1, this.__internal__.aux_port_connector = 0, this.dispatch("serial:disconnected", l), _.$dispatchChange(this);
|
|
1197
|
+
}, H = async function(l) {
|
|
1198
|
+
const e = this.__internal__.serial.port;
|
|
1199
|
+
if (!e || e && (!e.readable || !e.writable))
|
|
1200
|
+
throw y(this, b, P).call(this, { error: "Port is closed, not readable or writable." }), new Error("The port is closed or is not readable/writable");
|
|
1201
|
+
const t = this.stringArrayToUint8Array(l);
|
|
1202
|
+
if (e.writable === null) return;
|
|
1203
|
+
const n = e.writable.getWriter();
|
|
1204
|
+
await n.write(t), n.releaseLock();
|
|
1205
|
+
}, x = function(l = [], e = null) {
|
|
1206
|
+
if (l && l.length > 0) {
|
|
1207
|
+
const t = this.__internal__.serial.connected;
|
|
1208
|
+
this.__internal__.serial.connected = y(this, b, E).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);
|
|
1209
|
+
const n = [];
|
|
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);
|
|
1214
|
+
else if (this.__internal__.serial.response.as === "uint8")
|
|
1215
|
+
this.serialMessage(this.parseHexToUint8(this.add0x(n)));
|
|
1216
|
+
else if (this.__internal__.serial.response.as === "string")
|
|
1217
|
+
if (this.__internal__.serial.response.limiter !== null) {
|
|
1218
|
+
const i = this.parseUint8ArrayToString(this.add0x(n)).split(this.__internal__.serial.response.limiter);
|
|
1219
|
+
for (const u in i)
|
|
1220
|
+
i[u] && this.serialMessage(i[u]);
|
|
1221
|
+
} else
|
|
1222
|
+
this.serialMessage(this.parseUint8ArrayToString(this.add0x(n)));
|
|
1223
|
+
else {
|
|
1224
|
+
const i = this.stringToArrayBuffer(
|
|
1225
|
+
this.parseUint8ArrayToString(this.add0x(n))
|
|
1226
|
+
);
|
|
1227
|
+
this.serialMessage(i);
|
|
1228
|
+
}
|
|
1229
|
+
} else
|
|
1230
|
+
this.serialCorruptMessage(l, e);
|
|
1231
|
+
this.__internal__.serial.queue.length !== 0 && this.dispatch("internal:queue", {});
|
|
1232
|
+
}, ne = async function() {
|
|
1233
|
+
const l = this.serialFilters, e = await navigator.serial.getPorts({ filters: l });
|
|
1234
|
+
return l.length === 0 ? e : e.filter((t) => {
|
|
1235
|
+
const n = t.getInfo();
|
|
1236
|
+
return l.some((i) => n.usbProductId === i.usbProductId && n.usbVendorId === i.usbVendorId);
|
|
1237
|
+
}).filter((t) => !y(this, b, E).call(this, t));
|
|
1238
|
+
}, V = function(l) {
|
|
1239
|
+
if (l) {
|
|
1240
|
+
const e = this.__internal__.serial.response.buffer, t = new Uint8Array(e.length + l.byteLength);
|
|
1241
|
+
t.set(e, 0), t.set(new Uint8Array(l), e.length), this.__internal__.serial.response.buffer = t;
|
|
1242
|
+
}
|
|
1243
|
+
}, z = async function() {
|
|
1244
|
+
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
|
+
const l = [];
|
|
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);
|
|
1249
|
+
}, 400);
|
|
1250
|
+
}, K = async function() {
|
|
1251
|
+
if (this.__internal__.serial.response.length !== null) {
|
|
1252
|
+
if (this.__internal__.serial.response.length === this.__internal__.serial.response.buffer.length) {
|
|
1253
|
+
const l = [];
|
|
1254
|
+
for (const e in this.__internal__.serial.response.buffer)
|
|
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
|
+
let l = new Uint8Array(0);
|
|
1259
|
+
for (let t = 0; t < this.__internal__.serial.response.length; t++)
|
|
1260
|
+
l[t] = this.__internal__.serial.response.buffer[t];
|
|
1261
|
+
if (l.length === this.__internal__.serial.response.length) {
|
|
1262
|
+
const t = [];
|
|
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);
|
|
1266
|
+
return;
|
|
1267
|
+
}
|
|
1268
|
+
l = new Uint8Array(0);
|
|
1269
|
+
const e = this.__internal__.serial.response.length * 2;
|
|
1270
|
+
if (this.__internal__.serial.response.buffer.length === e) {
|
|
1271
|
+
for (let t = 14; t < e; t++)
|
|
1272
|
+
l[t - this.__internal__.serial.response.length] = this.__internal__.serial.response.buffer[t];
|
|
1273
|
+
if (l.length === this.__internal__.serial.response.length) {
|
|
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
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
}, re = async function() {
|
|
1283
|
+
const l = this.__internal__.serial.port;
|
|
1284
|
+
if (!l || !l.readable) throw new Error("Port is not readable");
|
|
1285
|
+
for (; l.readable && this.__internal__.serial.keep_reading; ) {
|
|
1286
|
+
const e = l.readable.getReader();
|
|
1287
|
+
this.__internal__.serial.reader = e;
|
|
1288
|
+
try {
|
|
1289
|
+
let t = !0;
|
|
1290
|
+
for (; t; ) {
|
|
1291
|
+
const { value: n, done: i } = await e.read();
|
|
1292
|
+
if (i) {
|
|
1293
|
+
e.releaseLock(), this.__internal__.serial.keep_reading = !1, t = !1;
|
|
1294
|
+
break;
|
|
1295
|
+
}
|
|
1296
|
+
y(this, b, V).call(this, n), this.__internal__.serial.response.length === null ? await y(this, b, z).call(this) : await y(this, b, K).call(this);
|
|
1297
|
+
}
|
|
1298
|
+
} catch (t) {
|
|
1299
|
+
this.serialErrors(t);
|
|
1300
|
+
} finally {
|
|
1301
|
+
e.releaseLock();
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
this.__internal__.serial.keep_reading = !0, this.__internal__.serial.port && await this.__internal__.serial.port.close();
|
|
1305
|
+
}, ie = async function() {
|
|
1306
|
+
return typeof window > "u" ? !1 : "serial" in navigator && "forget" in SerialPort.prototype && this.__internal__.serial.port ? (await this.__internal__.serial.port.forget(), !0) : !1;
|
|
1307
|
+
}, se = function() {
|
|
1308
|
+
[
|
|
1309
|
+
"serial:connected",
|
|
1310
|
+
"serial:connecting",
|
|
1311
|
+
"serial:reconnect",
|
|
1312
|
+
"serial:timeout",
|
|
1313
|
+
"serial:disconnected",
|
|
1314
|
+
"serial:sent",
|
|
1315
|
+
"serial:soft-reload",
|
|
1316
|
+
"serial:message",
|
|
1317
|
+
"unknown",
|
|
1318
|
+
"serial:need-permission",
|
|
1319
|
+
"serial:lost",
|
|
1320
|
+
"serial:unsupported",
|
|
1321
|
+
"serial:error",
|
|
1322
|
+
"debug"
|
|
1323
|
+
].forEach((l) => {
|
|
1324
|
+
this.serialRegisterAvailableListener(l);
|
|
1325
|
+
});
|
|
1326
|
+
}, ae = function() {
|
|
1327
|
+
const l = this;
|
|
1328
|
+
this.on("internal:queue", async () => {
|
|
1329
|
+
var e;
|
|
1330
|
+
await y(e = l, b, X).call(e);
|
|
1331
|
+
}), y(this, b, G).call(this);
|
|
1332
|
+
}, G = function() {
|
|
1333
|
+
const l = this;
|
|
1334
|
+
navigator.serial.addEventListener("connect", async () => {
|
|
1335
|
+
l.isDisconnected && await l.serialConnect().catch(() => {
|
|
1336
|
+
});
|
|
1337
|
+
});
|
|
1338
|
+
}, X = async function() {
|
|
1339
|
+
if (!y(this, b, E).call(this, this.__internal__.serial.port)) {
|
|
1340
|
+
y(this, b, P).call(this, { error: "Port is closed, not readable or writable." }), await this.serialConnect();
|
|
1341
|
+
return;
|
|
1342
|
+
}
|
|
1343
|
+
if (this.__internal__.timeout.until_response || this.__internal__.serial.queue.length === 0) return;
|
|
1344
|
+
const l = this.__internal__.serial.queue[0];
|
|
1345
|
+
let e = this.__internal__.time.response_general;
|
|
1346
|
+
l.action === "connect" && (e = this.__internal__.time.response_connection), this.__internal__.timeout.until_response = setTimeout(async () => {
|
|
1347
|
+
await this.timeout(l.bytes, l.action);
|
|
1348
|
+
}, e), this.__internal__.serial.last_action = l.action ?? "unknown", await y(this, b, H).call(this, l.bytes), this.dispatch("serial:sent", {
|
|
1349
|
+
action: l.action,
|
|
1350
|
+
bytes: l.bytes
|
|
1351
|
+
}), this.__internal__.auto_response && y(this, b, x).call(this, this.__internal__.serial.auto_response, null);
|
|
1352
|
+
const t = [...this.__internal__.serial.queue];
|
|
1353
|
+
this.__internal__.serial.queue = t.splice(1);
|
|
1354
|
+
}, le = function(l = 1) {
|
|
1355
|
+
this.__internal__.device_number = l, this.__internal__.serial.bytes_connection = this.serialSetConnectionConstant(l);
|
|
1356
|
+
}, oe = function() {
|
|
1357
|
+
this.__internal__.last_error = {
|
|
1358
|
+
message: null,
|
|
1359
|
+
action: null,
|
|
1360
|
+
code: null,
|
|
1361
|
+
no_code: 0
|
|
1362
|
+
};
|
|
1363
|
+
};
|
|
1364
|
+
_.instance || (_.instance = new _());
|
|
1365
|
+
const me = {
|
|
1366
|
+
relay: [],
|
|
1367
|
+
locker: [],
|
|
1368
|
+
jofemar: [],
|
|
1369
|
+
boardroid: [],
|
|
1370
|
+
arduino: [],
|
|
1371
|
+
pinpad: [],
|
|
1372
|
+
pinpax: []
|
|
1373
|
+
};
|
|
1374
|
+
_.devices = { ..._.devices, ...me };
|
|
1375
|
+
_.addCustom = (l, e) => {
|
|
1376
|
+
_.registerType(l), _.add(e);
|
|
1377
|
+
};
|
|
1378
|
+
_.getCustomByUuid = (l, e) => _.get(l, e);
|
|
1379
|
+
_.getJofemarByUuid = (l) => _.get("jofemar", l);
|
|
1380
|
+
_.getLockerByUuid = (l) => _.get("locker", l);
|
|
1381
|
+
_.getRelayByUuid = (l) => _.get("relay", l);
|
|
1382
|
+
_.getBoardroidByUuid = (l) => _.get("boardroid", l);
|
|
1383
|
+
_.getArduinoByUuid = (l) => _.get("arduino", l);
|
|
1384
|
+
_.getPinPadByUuid = (l) => _.get("pinpad", l);
|
|
1385
|
+
_.getPinPaxByUuid = (l) => _.get("pinpax", l);
|
|
1386
|
+
_.getJofemar = (l = 1) => _.getByNumber("jofemar", l);
|
|
1387
|
+
_.getBoardroid = (l = 1) => _.getByNumber("boardroid", l);
|
|
1388
|
+
_.getLocker = (l = 1) => _.getByNumber("locker", l);
|
|
1389
|
+
_.getRelay = (l = 1) => _.getByNumber("relay", l);
|
|
1390
|
+
_.getArduino = (l = 1) => _.getByNumber("arduino", l);
|
|
1391
|
+
_.getPinPad = (l = 1) => _.getByNumber("pinpad", l);
|
|
1392
|
+
_.getPinPax = (l = 1) => _.getByNumber("pinpax", l);
|
|
1393
|
+
class ye extends be {
|
|
1394
|
+
constructor(e) {
|
|
1395
|
+
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
|
+
must_response: !1,
|
|
1397
|
+
dispensing: !1,
|
|
1398
|
+
status: null,
|
|
1399
|
+
counter: 0,
|
|
1400
|
+
limit_counter: 20,
|
|
1401
|
+
custom_limit_counter: null,
|
|
1402
|
+
backup_dispense: {}
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
get isDoorOpen() {
|
|
1406
|
+
return this.__internal__.device.door_open;
|
|
1407
|
+
}
|
|
1408
|
+
get isDispensing() {
|
|
1409
|
+
return this.__internal__.interval.waiting_sense || this.__internal__.dispense.dispensing;
|
|
1410
|
+
}
|
|
1411
|
+
async timeout(e, t) {
|
|
1412
|
+
await super.timeout(e, t), t === "dispense" && (this.__internal__.dispense.status = "no-response");
|
|
1413
|
+
}
|
|
1414
|
+
async serialPortsSaved(e) {
|
|
1415
|
+
const t = this.serialFilters;
|
|
1416
|
+
if (this.__internal__.aux_port_connector < e.length) {
|
|
1417
|
+
const n = this.__internal__.aux_port_connector;
|
|
1418
|
+
this.__internal__.serial.port = e[n];
|
|
1419
|
+
} else
|
|
1420
|
+
this.__internal__.aux_port_connector = 0, this.__internal__.serial.port = await navigator.serial.requestPort({ filters: t });
|
|
1421
|
+
if (!this.__internal__.serial.port)
|
|
1422
|
+
throw new Error("Select another port please");
|
|
1423
|
+
}
|
|
1424
|
+
internalClearSensing() {
|
|
1425
|
+
this.__internal__.interval.waiting_sense && clearInterval(this.__internal__.interval.waiting_sense), this.__internal__.interval.waiting_sense = 0, this.__internal__.dispense.status = null, this.__internal__.dispense.counter = 0, this.__internal__.dispense.dispensing = !1;
|
|
1426
|
+
}
|
|
1427
|
+
internalDispensingProcess() {
|
|
1428
|
+
let e = this.__internal__.dispense.limit_counter;
|
|
1429
|
+
return this.__internal__.dispense.custom_limit_counter && (e = this.__internal__.dispense.custom_limit_counter), e += Math.ceil(e * 0.6), this.__internal__.dispense.counter >= e ? (this.internalClearSensing(), this.__internal__.dispense.status = !1, this.__internal__.dispense.dispensing = !1, !1) : (this.__internal__.dispense.counter = parseFloat((0.1 + this.__internal__.dispense.counter).toFixed(1)), this.__internal__.dispense.counter % 1 === 0 && this.dispatch("dispensing", {
|
|
1430
|
+
status: this.__internal__.dispense.status,
|
|
1431
|
+
counter: this.__internal__.dispense.counter,
|
|
1432
|
+
limit: e
|
|
1433
|
+
}), null);
|
|
1434
|
+
}
|
|
1435
|
+
async internalDispenseStatus() {
|
|
1436
|
+
if (this.__internal__.dispense.must_response && (await _e(this.__internal__.time.response_engines + 10), this.__internal__.dispense.status === "no-response"))
|
|
1437
|
+
return this.internalClearSensing(), this.__internal__.dispense.status = !1, this.dispatch("not-dispensed", { reason: "no-response" }), { status: !1, error: "no-response" };
|
|
1438
|
+
this.__internal__.dispense.status = null, this.__internal__.dispense.dispensing = !0, this.dispatch("internal:dispense:running", {});
|
|
1439
|
+
const e = this;
|
|
1440
|
+
return new Promise((t) => {
|
|
1441
|
+
this.__internal__.interval.waiting_sense = setInterval(() => {
|
|
1442
|
+
switch (e.__internal__.dispense.status) {
|
|
1443
|
+
case null:
|
|
1444
|
+
e.internalDispensingProcess() === !1 && (e.internalClearSensing(), e.dispatch("not-dispensed", { reason: "timeout" }), t({ status: !1, error: "timeout" }));
|
|
1445
|
+
break;
|
|
1446
|
+
case !0:
|
|
1447
|
+
e.internalClearSensing(), e.__internal__.dispense.status = !0, e.dispatch("dispensed", {}), t({ status: !0, error: null });
|
|
1448
|
+
break;
|
|
1449
|
+
case !1:
|
|
1450
|
+
e.internalClearSensing(), e.__internal__.dispense.status = !1, e.dispatch("not-dispensed", { reason: "no-stock" }), t({ status: !1, error: null });
|
|
1451
|
+
break;
|
|
1452
|
+
case "elevator-locked":
|
|
1453
|
+
e.internalClearSensing(), e.__internal__.dispense.status = !1, e.dispatch("not-dispensed", { reason: "elevator-locked" }), t({ status: !1, error: "elevator-locked" });
|
|
1454
|
+
break;
|
|
1455
|
+
case "no-response":
|
|
1456
|
+
e.internalClearSensing(), e.__internal__.dispense.status = !1, e.dispatch("not-dispensed", { reason: "no-response" }), t({ status: !1, error: "no-response" });
|
|
1457
|
+
break;
|
|
1458
|
+
}
|
|
1459
|
+
}, this.__internal__.time.sense);
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1462
|
+
async internalDispense(e) {
|
|
1463
|
+
if (this.isDispensing) throw new Error("Another dispensing process is running");
|
|
1464
|
+
if (!O.enable && !this.__internal__.serial.connected && (await this.serialConnect(), !this.__internal__.serial.connected))
|
|
1465
|
+
throw new Error("Serial device not connected");
|
|
1466
|
+
return this.__internal__.serial.queue.length === 0 ? (await this.appendToQueue(e, "dispense"), await this.internalDispenseStatus()) : new Promise((t) => {
|
|
1467
|
+
const n = setInterval(async () => {
|
|
1468
|
+
if (this.__internal__.serial.queue.length > 0) return;
|
|
1469
|
+
clearInterval(n), await this.appendToQueue(e, "dispense");
|
|
1470
|
+
const i = await this.internalDispenseStatus();
|
|
1471
|
+
t(i);
|
|
1472
|
+
}, 100);
|
|
1473
|
+
});
|
|
1474
|
+
}
|
|
1475
|
+
__emulate(e) {
|
|
1476
|
+
if (typeof e.code != "object") {
|
|
1477
|
+
console.error("Invalid data to make an emulation");
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
this.__internal__.serial.connected || (this.__internal__.serial.connected = !0, this.dispatch("serial:connected"), _.instance.dispatch("change"), 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);
|
|
1481
|
+
const t = [];
|
|
1482
|
+
for (const n in e.code)
|
|
1483
|
+
t.push(e.code[n].toString().padStart(2, "0").toLowerCase());
|
|
1484
|
+
this.serialMessage(t);
|
|
1485
|
+
}
|
|
1486
|
+
/**
|
|
1487
|
+
* @deprecated Use listenOnChannel instead
|
|
1488
|
+
* @param {string|number} channel
|
|
1489
|
+
*/
|
|
1490
|
+
set listenOnPort(e) {
|
|
1491
|
+
this.listenOnChannel = e;
|
|
1492
|
+
}
|
|
1493
|
+
/**
|
|
1494
|
+
* @deprecated Use listenOnChannel instead
|
|
1495
|
+
*/
|
|
1496
|
+
get listenOnPort() {
|
|
1497
|
+
return this.__internal__.device.listen_on_port ?? 1;
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
export {
|
|
1501
|
+
O as E,
|
|
1502
|
+
ye as K,
|
|
1503
|
+
_,
|
|
1504
|
+
Ce as a,
|
|
1505
|
+
ke as b,
|
|
1506
|
+
De as g,
|
|
1507
|
+
Se as i,
|
|
1508
|
+
ve as s,
|
|
1509
|
+
_e as w
|
|
1510
|
+
};
|