@danidoble/webserial 4.4.5 → 4.5.0-alpha.1
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/boardroid.cjs +1 -1
- package/dist/boardroid.js +4 -3
- package/dist/devices-BndwHuvP.cjs +1 -0
- package/dist/devices-CHc7K4eY.js +67 -0
- package/dist/hopper.cjs +1 -1
- package/dist/hopper.js +1 -1
- package/dist/jofemar.cjs +1 -1
- package/dist/jofemar.js +7 -6
- package/dist/jsd.cjs +1 -0
- package/dist/jsd.js +2505 -0
- package/dist/kernel-As0xv_MS.cjs +1 -0
- package/dist/{kernel-DAorOZat.js → kernel-CFxkp4Nz.js} +147 -204
- package/dist/kernel.cjs +1 -1
- package/dist/kernel.js +4 -3
- package/dist/locker.cjs +1 -1
- package/dist/locker.js +12 -11
- package/dist/pinpad.cjs +11 -11
- package/dist/pinpad.js +684 -639
- package/dist/pinpax.cjs +2 -2
- package/dist/pinpax.js +4 -3
- package/dist/relay.cjs +1 -1
- package/dist/relay.js +8 -7
- package/dist/types/lib/commands/jsd/applications/licensing.d.ts +51 -0
- package/dist/types/lib/commands/jsd/applications/licensing.d.ts.map +1 -0
- package/dist/types/lib/commands/jsd/applications/manifest.d.ts +73 -0
- package/dist/types/lib/commands/jsd/applications/manifest.d.ts.map +1 -0
- package/dist/types/lib/commands/jsd/applications/vision.d.ts +444 -0
- package/dist/types/lib/commands/jsd/applications/vision.d.ts.map +1 -0
- package/dist/types/lib/commands/jsd/frames/licensing/licensingClient.d.ts +34 -0
- package/dist/types/lib/commands/jsd/frames/licensing/licensingClient.d.ts.map +1 -0
- package/dist/types/lib/commands/jsd/frames/licensing/opCodes.d.ts +28 -0
- package/dist/types/lib/commands/jsd/frames/licensing/opCodes.d.ts.map +1 -0
- package/dist/types/lib/commands/jsd/frames/manifest/manifestClient.d.ts +40 -0
- package/dist/types/lib/commands/jsd/frames/manifest/manifestClient.d.ts.map +1 -0
- package/dist/types/lib/commands/jsd/frames/manifest/opCodes.d.ts +28 -0
- package/dist/types/lib/commands/jsd/frames/manifest/opCodes.d.ts.map +1 -0
- package/dist/types/lib/commands/jsd/frames/vision/opCodes.d.ts +72 -0
- package/dist/types/lib/commands/jsd/frames/vision/opCodes.d.ts.map +1 -0
- package/dist/types/lib/commands/jsd/frames/vision/visionClient.d.ts +336 -0
- package/dist/types/lib/commands/jsd/frames/vision/visionClient.d.ts.map +1 -0
- package/dist/types/lib/commands/jsd/protocol/crc16.d.ts +37 -0
- package/dist/types/lib/commands/jsd/protocol/crc16.d.ts.map +1 -0
- package/dist/types/lib/commands/jsd/protocol/responseHandler.d.ts +38 -0
- package/dist/types/lib/commands/jsd/protocol/responseHandler.d.ts.map +1 -0
- package/dist/types/lib/commands/jsd/protocol/rs232Strategy.d.ts +23 -0
- package/dist/types/lib/commands/jsd/protocol/rs232Strategy.d.ts.map +1 -0
- package/dist/types/lib/commands/jsd/protocol/tcpIpStrategy.d.ts +49 -0
- package/dist/types/lib/commands/jsd/protocol/tcpIpStrategy.d.ts.map +1 -0
- package/dist/types/lib/commands/jsd/types/LicensingClient.d.ts +32 -0
- package/dist/types/lib/commands/jsd/types/LicensingClient.d.ts.map +1 -0
- package/dist/types/lib/commands/jsd/types/jsd.types.d.ts +140 -0
- package/dist/types/lib/commands/jsd/types/jsd.types.d.ts.map +1 -0
- package/dist/types/lib/commands/jsd/types/manifestClient.d.ts +40 -0
- package/dist/types/lib/commands/jsd/types/manifestClient.d.ts.map +1 -0
- package/dist/types/lib/commands/jsd/types/transport.types.d.ts +29 -0
- package/dist/types/lib/commands/jsd/types/transport.types.d.ts.map +1 -0
- package/dist/types/lib/commands/jsd/types/visionClient.types.d.ts +368 -0
- package/dist/types/lib/commands/jsd/types/visionClient.types.d.ts.map +1 -0
- package/dist/types/lib/commands/jsd/utils/aplications.d.ts +48 -0
- package/dist/types/lib/commands/jsd/utils/aplications.d.ts.map +1 -0
- package/dist/types/lib/commands/jsd/utils/helpers.d.ts +15 -0
- package/dist/types/lib/commands/jsd/utils/helpers.d.ts.map +1 -0
- package/dist/types/lib/kernel.d.ts.map +1 -0
- package/dist/types/{main.d.ts → lib/main.d.ts} +6 -0
- package/dist/types/lib/main.d.ts.map +1 -0
- package/dist/types/lib/parsers/delimiterTransformer.d.ts +29 -0
- package/dist/types/lib/parsers/delimiterTransformer.d.ts.map +1 -0
- package/dist/types/lib/serial/boardroid.d.ts.map +1 -0
- package/dist/types/lib/serial/hopper.d.ts.map +1 -0
- package/dist/types/lib/serial/jofemar.d.ts.map +1 -0
- package/dist/types/lib/serial/jsd.d.ts +41 -0
- package/dist/types/lib/serial/jsd.d.ts.map +1 -0
- package/dist/types/{serial → lib/serial}/kernel.d.ts +1 -0
- package/dist/types/{serial → lib/serial}/kernel.d.ts.map +1 -1
- package/dist/types/lib/serial/locker.d.ts.map +1 -0
- package/dist/types/lib/serial/pinpad.d.ts.map +1 -0
- package/dist/types/lib/serial/pinpax.d.ts.map +1 -0
- package/dist/types/lib/serial/relay.d.ts.map +1 -0
- package/dist/types/{utils → lib/utils}/devices.d.ts +2 -0
- package/dist/types/lib/utils/devices.d.ts.map +1 -0
- package/dist/types/lib/utils/dispatcher.d.ts.map +1 -0
- package/dist/types/lib/utils/emulator.d.ts.map +1 -0
- package/dist/types/lib/utils/utils.d.ts.map +1 -0
- package/dist/types/test/t.d.ts +2 -0
- package/dist/types/test/t.d.ts.map +1 -0
- package/dist/webserial-core-3UL91lxi.cjs +4 -0
- package/dist/{webserial-core-CiU9IcKf.js → webserial-core-DSv1dX3s.js} +160 -140
- package/dist/webserial.cjs +1 -1
- package/dist/webserial.js +29 -23
- package/package.json +13 -8
- package/dist/kernel-g4zSg1Ll.cjs +0 -1
- package/dist/types/kernel.d.ts.map +0 -1
- package/dist/types/main.d.ts.map +0 -1
- package/dist/types/serial/boardroid.d.ts.map +0 -1
- package/dist/types/serial/hopper.d.ts.map +0 -1
- package/dist/types/serial/jofemar.d.ts.map +0 -1
- package/dist/types/serial/locker.d.ts.map +0 -1
- package/dist/types/serial/pinpad.d.ts.map +0 -1
- package/dist/types/serial/pinpax.d.ts.map +0 -1
- package/dist/types/serial/relay.d.ts.map +0 -1
- package/dist/types/utils/devices.d.ts.map +0 -1
- package/dist/types/utils/dispatcher.d.ts.map +0 -1
- package/dist/types/utils/emulator.d.ts.map +0 -1
- package/dist/types/utils/utils.d.ts.map +0 -1
- package/dist/webserial-core-D49c459A.cjs +0 -4
- /package/dist/types/{kernel.d.ts → lib/kernel.d.ts} +0 -0
- /package/dist/types/{serial → lib/serial}/boardroid.d.ts +0 -0
- /package/dist/types/{serial → lib/serial}/hopper.d.ts +0 -0
- /package/dist/types/{serial → lib/serial}/jofemar.d.ts +0 -0
- /package/dist/types/{serial → lib/serial}/locker.d.ts +0 -0
- /package/dist/types/{serial → lib/serial}/pinpad.d.ts +0 -0
- /package/dist/types/{serial → lib/serial}/pinpax.d.ts +0 -0
- /package/dist/types/{serial → lib/serial}/relay.d.ts +0 -0
- /package/dist/types/{utils → lib/utils}/dispatcher.d.ts +0 -0
- /package/dist/types/{utils → lib/utils}/emulator.d.ts +0 -0
- /package/dist/types/{utils → lib/utils}/utils.d.ts +0 -0
|
@@ -36,9 +36,9 @@ for (let n = 0; n < X.length; n++)
|
|
|
36
36
|
const ye = (n) => {
|
|
37
37
|
let e = n.length * 0.75, t = n.length, s, i = 0, r, o, l, c;
|
|
38
38
|
n[n.length - 1] === "=" && (e--, n[n.length - 2] === "=" && e--);
|
|
39
|
-
const f = new ArrayBuffer(e),
|
|
39
|
+
const f = new ArrayBuffer(e), _ = new Uint8Array(f);
|
|
40
40
|
for (s = 0; s < t; s += 4)
|
|
41
|
-
r = C[n.charCodeAt(s)], o = C[n.charCodeAt(s + 1)], l = C[n.charCodeAt(s + 2)], c = C[n.charCodeAt(s + 3)],
|
|
41
|
+
r = C[n.charCodeAt(s)], o = C[n.charCodeAt(s + 1)], l = C[n.charCodeAt(s + 2)], c = C[n.charCodeAt(s + 3)], _[i++] = r << 2 | o >> 4, _[i++] = (o & 15) << 4 | l >> 2, _[i++] = (l & 3) << 6 | c & 63;
|
|
42
42
|
return f;
|
|
43
43
|
}, ge = typeof ArrayBuffer == "function", W = (n, e) => {
|
|
44
44
|
if (typeof n != "string")
|
|
@@ -62,7 +62,7 @@ const ye = (n) => {
|
|
|
62
62
|
return ie(t, e);
|
|
63
63
|
} else
|
|
64
64
|
return { base64: !0, data: n };
|
|
65
|
-
}, ie = (n, e) => e === "blob" ? n instanceof Blob ? n : new Blob([n]) : n instanceof ArrayBuffer ? n : n.buffer, re = "",
|
|
65
|
+
}, ie = (n, e) => e === "blob" ? n instanceof Blob ? n : new Blob([n]) : n instanceof ArrayBuffer ? n : n.buffer, re = "", be = (n, e) => {
|
|
66
66
|
const t = n.length, s = new Array(t);
|
|
67
67
|
let i = 0;
|
|
68
68
|
n.forEach((r, o) => {
|
|
@@ -70,7 +70,7 @@ const ye = (n) => {
|
|
|
70
70
|
s[o] = l, ++i === t && e(s.join(re));
|
|
71
71
|
});
|
|
72
72
|
});
|
|
73
|
-
},
|
|
73
|
+
}, we = (n, e) => {
|
|
74
74
|
const t = n.split(re), s = [];
|
|
75
75
|
for (let i = 0; i < t.length; i++) {
|
|
76
76
|
const r = W(t[i], e);
|
|
@@ -134,12 +134,12 @@ function Ee(n, e) {
|
|
|
134
134
|
} else if (s === 2) {
|
|
135
135
|
if (T(t) < 8)
|
|
136
136
|
break;
|
|
137
|
-
const c = A(t, 8), f = new DataView(c.buffer, c.byteOffset, c.length),
|
|
138
|
-
if (
|
|
137
|
+
const c = A(t, 8), f = new DataView(c.buffer, c.byteOffset, c.length), _ = f.getUint32(0);
|
|
138
|
+
if (_ > Math.pow(2, 21) - 1) {
|
|
139
139
|
l.enqueue(q);
|
|
140
140
|
break;
|
|
141
141
|
}
|
|
142
|
-
i =
|
|
142
|
+
i = _ * Math.pow(2, 32) + f.getUint32(4), s = 3;
|
|
143
143
|
} else {
|
|
144
144
|
if (T(t) < i)
|
|
145
145
|
break;
|
|
@@ -155,24 +155,24 @@ function Ee(n, e) {
|
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
const oe = 4;
|
|
158
|
-
function
|
|
158
|
+
function u(n) {
|
|
159
159
|
if (n) return ke(n);
|
|
160
160
|
}
|
|
161
161
|
function ke(n) {
|
|
162
|
-
for (var e in
|
|
163
|
-
n[e] =
|
|
162
|
+
for (var e in u.prototype)
|
|
163
|
+
n[e] = u.prototype[e];
|
|
164
164
|
return n;
|
|
165
165
|
}
|
|
166
|
-
|
|
166
|
+
u.prototype.on = u.prototype.addEventListener = function(n, e) {
|
|
167
167
|
return this._callbacks = this._callbacks || {}, (this._callbacks["$" + n] = this._callbacks["$" + n] || []).push(e), this;
|
|
168
168
|
};
|
|
169
|
-
|
|
169
|
+
u.prototype.once = function(n, e) {
|
|
170
170
|
function t() {
|
|
171
171
|
this.off(n, t), e.apply(this, arguments);
|
|
172
172
|
}
|
|
173
173
|
return t.fn = e, this.on(n, t), this;
|
|
174
174
|
};
|
|
175
|
-
|
|
175
|
+
u.prototype.off = u.prototype.removeListener = u.prototype.removeAllListeners = u.prototype.removeEventListener = function(n, e) {
|
|
176
176
|
if (this._callbacks = this._callbacks || {}, arguments.length == 0)
|
|
177
177
|
return this._callbacks = {}, this;
|
|
178
178
|
var t = this._callbacks["$" + n];
|
|
@@ -186,7 +186,7 @@ _.prototype.off = _.prototype.removeListener = _.prototype.removeAllListeners =
|
|
|
186
186
|
}
|
|
187
187
|
return t.length === 0 && delete this._callbacks["$" + n], this;
|
|
188
188
|
};
|
|
189
|
-
|
|
189
|
+
u.prototype.emit = function(n) {
|
|
190
190
|
this._callbacks = this._callbacks || {};
|
|
191
191
|
for (var e = new Array(arguments.length - 1), t = this._callbacks["$" + n], s = 1; s < arguments.length; s++)
|
|
192
192
|
e[s - 1] = arguments[s];
|
|
@@ -197,11 +197,11 @@ _.prototype.emit = function(n) {
|
|
|
197
197
|
}
|
|
198
198
|
return this;
|
|
199
199
|
};
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
u.prototype.emitReserved = u.prototype.emit;
|
|
201
|
+
u.prototype.listeners = function(n) {
|
|
202
202
|
return this._callbacks = this._callbacks || {}, this._callbacks["$" + n] || [];
|
|
203
203
|
};
|
|
204
|
-
|
|
204
|
+
u.prototype.hasListeners = function(n) {
|
|
205
205
|
return !!this.listeners(n).length;
|
|
206
206
|
};
|
|
207
207
|
const O = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), p = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), Ce = "arraybuffer";
|
|
@@ -244,7 +244,7 @@ class Le extends Error {
|
|
|
244
244
|
super(e), this.description = t, this.context = s, this.type = "TransportError";
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
-
class K extends
|
|
247
|
+
class K extends u {
|
|
248
248
|
/**
|
|
249
249
|
* Transport abstract constructor.
|
|
250
250
|
*
|
|
@@ -335,7 +335,7 @@ class K extends _ {
|
|
|
335
335
|
return e.indexOf(":") === -1 ? e : "[" + e + "]";
|
|
336
336
|
}
|
|
337
337
|
_port() {
|
|
338
|
-
return this.opts.port && (this.opts.secure &&
|
|
338
|
+
return this.opts.port && (this.opts.secure && Number(this.opts.port) !== 443 || !this.opts.secure && Number(this.opts.port) !== 80) ? ":" + this.opts.port : "";
|
|
339
339
|
}
|
|
340
340
|
_query(e) {
|
|
341
341
|
const t = Be(e);
|
|
@@ -398,7 +398,7 @@ class Pe extends K {
|
|
|
398
398
|
return this.onClose({ description: "transport closed by the server" }), !1;
|
|
399
399
|
this.onPacket(s);
|
|
400
400
|
};
|
|
401
|
-
|
|
401
|
+
we(e, this.socket.binaryType).forEach(t), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
|
|
402
402
|
}
|
|
403
403
|
/**
|
|
404
404
|
* For polling, send a close packet.
|
|
@@ -418,7 +418,7 @@ class Pe extends K {
|
|
|
418
418
|
* @protected
|
|
419
419
|
*/
|
|
420
420
|
write(e) {
|
|
421
|
-
this.writable = !1,
|
|
421
|
+
this.writable = !1, be(e, (t) => {
|
|
422
422
|
this.doWrite(t, () => {
|
|
423
423
|
this.writable = !0, this.emitReserved("drain");
|
|
424
424
|
});
|
|
@@ -484,7 +484,7 @@ class De extends Pe {
|
|
|
484
484
|
}), this.pollXhr = e;
|
|
485
485
|
}
|
|
486
486
|
}
|
|
487
|
-
class g extends
|
|
487
|
+
class g extends u {
|
|
488
488
|
/**
|
|
489
489
|
* Request constructor
|
|
490
490
|
*
|
|
@@ -624,13 +624,13 @@ function he(n) {
|
|
|
624
624
|
} catch {
|
|
625
625
|
}
|
|
626
626
|
}
|
|
627
|
-
const
|
|
627
|
+
const _e = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
|
|
628
628
|
class Me extends K {
|
|
629
629
|
get name() {
|
|
630
630
|
return "websocket";
|
|
631
631
|
}
|
|
632
632
|
doOpen() {
|
|
633
|
-
const e = this.uri(), t = this.opts.protocols, s =
|
|
633
|
+
const e = this.uri(), t = this.opts.protocols, s = _e ? {} : ae(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
|
|
634
634
|
this.opts.extraHeaders && (s.headers = this.opts.extraHeaders);
|
|
635
635
|
try {
|
|
636
636
|
this.ws = this.createSocket(e, t, s);
|
|
@@ -684,7 +684,7 @@ class Me extends K {
|
|
|
684
684
|
const I = p.WebSocket || p.MozWebSocket;
|
|
685
685
|
class Fe extends Me {
|
|
686
686
|
createSocket(e, t, s) {
|
|
687
|
-
return
|
|
687
|
+
return _e ? new I(e, t, s) : t ? new I(e, t) : new I(e);
|
|
688
688
|
}
|
|
689
689
|
doWrite(e, t) {
|
|
690
690
|
this.ws.send(t);
|
|
@@ -780,7 +780,7 @@ const M = typeof addEventListener == "function" && typeof removeEventListener ==
|
|
|
780
780
|
M && addEventListener("offline", () => {
|
|
781
781
|
x.forEach((n) => n());
|
|
782
782
|
}, !1);
|
|
783
|
-
class
|
|
783
|
+
class w extends u {
|
|
784
784
|
/**
|
|
785
785
|
* Socket constructor.
|
|
786
786
|
*
|
|
@@ -848,7 +848,7 @@ class b extends _ {
|
|
|
848
848
|
}, 0);
|
|
849
849
|
return;
|
|
850
850
|
}
|
|
851
|
-
const e = this.opts.rememberUpgrade &&
|
|
851
|
+
const e = this.opts.rememberUpgrade && w.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
|
|
852
852
|
this.readyState = "opening";
|
|
853
853
|
const t = this.createTransport(e);
|
|
854
854
|
t.open(), this.setTransport(t);
|
|
@@ -867,7 +867,7 @@ class b extends _ {
|
|
|
867
867
|
* @private
|
|
868
868
|
*/
|
|
869
869
|
onOpen() {
|
|
870
|
-
this.readyState = "open",
|
|
870
|
+
this.readyState = "open", w.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush();
|
|
871
871
|
}
|
|
872
872
|
/**
|
|
873
873
|
* Handles a packet.
|
|
@@ -1031,7 +1031,7 @@ class b extends _ {
|
|
|
1031
1031
|
* @private
|
|
1032
1032
|
*/
|
|
1033
1033
|
_onError(e) {
|
|
1034
|
-
if (
|
|
1034
|
+
if (w.priorWebsocketSuccess = !1, this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening")
|
|
1035
1035
|
return this.transports.shift(), this._open();
|
|
1036
1036
|
this.emitReserved("error", e), this._onClose("transport error", e);
|
|
1037
1037
|
}
|
|
@@ -1050,8 +1050,8 @@ class b extends _ {
|
|
|
1050
1050
|
}
|
|
1051
1051
|
}
|
|
1052
1052
|
}
|
|
1053
|
-
|
|
1054
|
-
class Ye extends
|
|
1053
|
+
w.protocol = oe;
|
|
1054
|
+
class Ye extends w {
|
|
1055
1055
|
constructor() {
|
|
1056
1056
|
super(...arguments), this._upgrades = [];
|
|
1057
1057
|
}
|
|
@@ -1068,15 +1068,15 @@ class Ye extends b {
|
|
|
1068
1068
|
*/
|
|
1069
1069
|
_probe(e) {
|
|
1070
1070
|
let t = this.createTransport(e), s = !1;
|
|
1071
|
-
|
|
1071
|
+
w.priorWebsocketSuccess = !1;
|
|
1072
1072
|
const i = () => {
|
|
1073
1073
|
s || (t.send([{ type: "ping", data: "probe" }]), t.once("packet", (d) => {
|
|
1074
1074
|
if (!s)
|
|
1075
1075
|
if (d.type === "pong" && d.data === "probe") {
|
|
1076
1076
|
if (this.upgrading = !0, this.emitReserved("upgrading", t), !t)
|
|
1077
1077
|
return;
|
|
1078
|
-
|
|
1079
|
-
s || this.readyState !== "closed" && (
|
|
1078
|
+
w.priorWebsocketSuccess = t.name === "websocket", this.transport.pause(() => {
|
|
1079
|
+
s || this.readyState !== "closed" && (_(), this.setTransport(t), t.send([{ type: "upgrade" }]), this.emitReserved("upgrade", t), t = null, this.upgrading = !1, this.flush());
|
|
1080
1080
|
});
|
|
1081
1081
|
} else {
|
|
1082
1082
|
const E = new Error("probe error");
|
|
@@ -1085,7 +1085,7 @@ class Ye extends b {
|
|
|
1085
1085
|
}));
|
|
1086
1086
|
};
|
|
1087
1087
|
function r() {
|
|
1088
|
-
s || (s = !0,
|
|
1088
|
+
s || (s = !0, _(), t.close(), t = null);
|
|
1089
1089
|
}
|
|
1090
1090
|
const o = (d) => {
|
|
1091
1091
|
const E = new Error("probe error: " + d);
|
|
@@ -1100,7 +1100,7 @@ class Ye extends b {
|
|
|
1100
1100
|
function f(d) {
|
|
1101
1101
|
t && d.name !== t.name && r();
|
|
1102
1102
|
}
|
|
1103
|
-
const
|
|
1103
|
+
const _ = () => {
|
|
1104
1104
|
t.removeListener("open", i), t.removeListener("error", o), t.removeListener("close", l), this.off("close", c), this.off("upgrading", f);
|
|
1105
1105
|
};
|
|
1106
1106
|
t.once("open", i), t.once("error", o), t.once("close", l), this.once("close", c), this.once("upgrading", f), this._upgrades.indexOf("webtransport") !== -1 && e !== "webtransport" ? this.setTimeoutFn(() => {
|
|
@@ -1135,7 +1135,7 @@ function Qe(n, e = "", t) {
|
|
|
1135
1135
|
const r = s.host.indexOf(":") !== -1 ? "[" + s.host + "]" : s.host;
|
|
1136
1136
|
return s.id = s.protocol + "://" + r + ":" + s.port + e, s.href = s.protocol + "://" + r + (t && t.port === s.port ? "" : ":" + s.port), s;
|
|
1137
1137
|
}
|
|
1138
|
-
const Xe = typeof ArrayBuffer == "function", je = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer,
|
|
1138
|
+
const Xe = typeof ArrayBuffer == "function", je = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer, ue = Object.prototype.toString, Ge = typeof Blob == "function" || typeof Blob < "u" && ue.call(Blob) === "[object BlobConstructor]", Ze = typeof File == "function" || typeof File < "u" && ue.call(File) === "[object FileConstructor]";
|
|
1139
1139
|
function z(n) {
|
|
1140
1140
|
return Xe && (n instanceof ArrayBuffer || je(n)) || Ge && n instanceof Blob || Ze && n instanceof File;
|
|
1141
1141
|
}
|
|
@@ -1200,18 +1200,23 @@ function $(n, e) {
|
|
|
1200
1200
|
}
|
|
1201
1201
|
const st = [
|
|
1202
1202
|
"connect",
|
|
1203
|
+
// used on the client side
|
|
1203
1204
|
"connect_error",
|
|
1205
|
+
// used on the client side
|
|
1204
1206
|
"disconnect",
|
|
1207
|
+
// used on both sides
|
|
1205
1208
|
"disconnecting",
|
|
1209
|
+
// used on the server side
|
|
1206
1210
|
"newListener",
|
|
1211
|
+
// used by the Node.js EventEmitter
|
|
1207
1212
|
"removeListener"
|
|
1208
1213
|
// used by the Node.js EventEmitter
|
|
1209
|
-
]
|
|
1214
|
+
];
|
|
1210
1215
|
var h;
|
|
1211
1216
|
(function(n) {
|
|
1212
1217
|
n[n.CONNECT = 0] = "CONNECT", n[n.DISCONNECT = 1] = "DISCONNECT", n[n.EVENT = 2] = "EVENT", n[n.ACK = 3] = "ACK", n[n.CONNECT_ERROR = 4] = "CONNECT_ERROR", n[n.BINARY_EVENT = 5] = "BINARY_EVENT", n[n.BINARY_ACK = 6] = "BINARY_ACK";
|
|
1213
1218
|
})(h || (h = {}));
|
|
1214
|
-
class
|
|
1219
|
+
class nt {
|
|
1215
1220
|
/**
|
|
1216
1221
|
* Encoder constructor
|
|
1217
1222
|
*
|
|
@@ -1251,10 +1256,7 @@ class it {
|
|
|
1251
1256
|
return i.unshift(s), i;
|
|
1252
1257
|
}
|
|
1253
1258
|
}
|
|
1254
|
-
|
|
1255
|
-
return Object.prototype.toString.call(n) === "[object Object]";
|
|
1256
|
-
}
|
|
1257
|
-
class Y extends _ {
|
|
1259
|
+
class Y extends u {
|
|
1258
1260
|
/**
|
|
1259
1261
|
* Decoder constructor
|
|
1260
1262
|
*
|
|
@@ -1275,7 +1277,7 @@ class Y extends _ {
|
|
|
1275
1277
|
throw new Error("got plaintext data when reconstructing a packet");
|
|
1276
1278
|
t = this.decodeString(e);
|
|
1277
1279
|
const s = t.type === h.BINARY_EVENT;
|
|
1278
|
-
s || t.type === h.BINARY_ACK ? (t.type = s ? h.EVENT : h.ACK, this.reconstructor = new
|
|
1280
|
+
s || t.type === h.BINARY_ACK ? (t.type = s ? h.EVENT : h.ACK, this.reconstructor = new it(t), t.attachments === 0 && super.emitReserved("decoded", t)) : super.emitReserved("decoded", t);
|
|
1279
1281
|
} else if (z(e) || e.base64)
|
|
1280
1282
|
if (this.reconstructor)
|
|
1281
1283
|
t = this.reconstructor.takeBinaryData(e), t && (this.reconstructor = null, super.emitReserved("decoded", t));
|
|
@@ -1366,7 +1368,7 @@ class Y extends _ {
|
|
|
1366
1368
|
this.reconstructor && (this.reconstructor.finishedReconstruction(), this.reconstructor = null);
|
|
1367
1369
|
}
|
|
1368
1370
|
}
|
|
1369
|
-
class
|
|
1371
|
+
class it {
|
|
1370
1372
|
constructor(e) {
|
|
1371
1373
|
this.packet = e, this.buffers = [], this.reconPack = e;
|
|
1372
1374
|
}
|
|
@@ -1392,21 +1394,23 @@ class rt {
|
|
|
1392
1394
|
this.reconPack = null, this.buffers = [];
|
|
1393
1395
|
}
|
|
1394
1396
|
}
|
|
1395
|
-
|
|
1397
|
+
function G(n) {
|
|
1398
|
+
return Object.prototype.toString.call(n) === "[object Object]";
|
|
1399
|
+
}
|
|
1400
|
+
const rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1396
1401
|
__proto__: null,
|
|
1397
1402
|
Decoder: Y,
|
|
1398
|
-
Encoder:
|
|
1403
|
+
Encoder: nt,
|
|
1399
1404
|
get PacketType() {
|
|
1400
1405
|
return h;
|
|
1401
|
-
}
|
|
1402
|
-
protocol: nt
|
|
1406
|
+
}
|
|
1403
1407
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1404
1408
|
function y(n, e, t) {
|
|
1405
1409
|
return n.on(e, t), function() {
|
|
1406
1410
|
n.off(e, t);
|
|
1407
1411
|
};
|
|
1408
1412
|
}
|
|
1409
|
-
const
|
|
1413
|
+
const ot = Object.freeze({
|
|
1410
1414
|
connect: 1,
|
|
1411
1415
|
connect_error: 1,
|
|
1412
1416
|
disconnect: 1,
|
|
@@ -1415,7 +1419,7 @@ const at = Object.freeze({
|
|
|
1415
1419
|
newListener: 1,
|
|
1416
1420
|
removeListener: 1
|
|
1417
1421
|
});
|
|
1418
|
-
class fe extends
|
|
1422
|
+
class fe extends u {
|
|
1419
1423
|
/**
|
|
1420
1424
|
* `Socket` constructor.
|
|
1421
1425
|
*/
|
|
@@ -1531,7 +1535,7 @@ class fe extends _ {
|
|
|
1531
1535
|
*/
|
|
1532
1536
|
emit(e, ...t) {
|
|
1533
1537
|
var s, i, r;
|
|
1534
|
-
if (
|
|
1538
|
+
if (ot.hasOwnProperty(e))
|
|
1535
1539
|
throw new Error('"' + e.toString() + '" is a reserved event name');
|
|
1536
1540
|
if (t.unshift(e), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
|
|
1537
1541
|
return this._addToQueue(t), this;
|
|
@@ -1540,8 +1544,8 @@ class fe extends _ {
|
|
|
1540
1544
|
data: t
|
|
1541
1545
|
};
|
|
1542
1546
|
if (o.options = {}, o.options.compress = this.flags.compress !== !1, typeof t[t.length - 1] == "function") {
|
|
1543
|
-
const
|
|
1544
|
-
this._registerAckCallback(
|
|
1547
|
+
const _ = this.ids++, d = t.pop();
|
|
1548
|
+
this._registerAckCallback(_, d), o.id = _;
|
|
1545
1549
|
}
|
|
1546
1550
|
const l = (i = (s = this.io.engine) === null || s === void 0 ? void 0 : s.transport) === null || i === void 0 ? void 0 : i.writable, c = this.connected && !(!((r = this.io.engine) === null || r === void 0) && r._hasPingExpired());
|
|
1547
1551
|
return this.flags.volatile && !l || (c ? (this.notifyOutgoingListeners(o), this.packet(o)) : this.sendBuffer.push(o)), this.flags = {}, this;
|
|
@@ -1603,7 +1607,7 @@ class fe extends _ {
|
|
|
1603
1607
|
args: e,
|
|
1604
1608
|
flags: Object.assign({ fromQueue: !0 }, this.flags)
|
|
1605
1609
|
};
|
|
1606
|
-
e.push((i, ...r) =>
|
|
1610
|
+
e.push((i, ...r) => (this._queue[0], i !== null ? s.tryCount > this._opts.retries && (this._queue.shift(), t && t(i)) : (this._queue.shift(), t && t(null, ...r)), s.pending = !1, this._drainQueue())), this._queue.push(s), this._drainQueue();
|
|
1607
1611
|
}
|
|
1608
1612
|
/**
|
|
1609
1613
|
* Send the first packet of the queue, and wait for an acknowledgement from the server.
|
|
@@ -1761,7 +1765,7 @@ class fe extends _ {
|
|
|
1761
1765
|
* @private
|
|
1762
1766
|
*/
|
|
1763
1767
|
onconnect(e, t) {
|
|
1764
|
-
this.id = e, this.recovered = t && this._pid === t, this._pid = t, this.connected = !0, this.emitBuffered(), this.
|
|
1768
|
+
this.id = e, this.recovered = t && this._pid === t, this._pid = t, this.connected = !0, this.emitBuffered(), this._drainQueue(!0), this.emitReserved("connect");
|
|
1765
1769
|
}
|
|
1766
1770
|
/**
|
|
1767
1771
|
* Emit buffered events (received and emitted).
|
|
@@ -2030,7 +2034,7 @@ v.prototype.setMax = function(n) {
|
|
|
2030
2034
|
v.prototype.setJitter = function(n) {
|
|
2031
2035
|
this.jitter = n;
|
|
2032
2036
|
};
|
|
2033
|
-
class V extends
|
|
2037
|
+
class V extends u {
|
|
2034
2038
|
constructor(e, t) {
|
|
2035
2039
|
var s;
|
|
2036
2040
|
super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t = t || {}, t.path = t.path || "/socket.io", this.opts = t, L(this, t), this.reconnection(t.reconnection !== !1), this.reconnectionAttempts(t.reconnectionAttempts || 1 / 0), this.reconnectionDelay(t.reconnectionDelay || 1e3), this.reconnectionDelayMax(t.reconnectionDelayMax || 5e3), this.randomizationFactor((s = t.randomizationFactor) !== null && s !== void 0 ? s : 0.5), this.backoff = new v({
|
|
@@ -2038,7 +2042,7 @@ class V extends _ {
|
|
|
2038
2042
|
max: this.reconnectionDelayMax(),
|
|
2039
2043
|
jitter: this.randomizationFactor()
|
|
2040
2044
|
}), this.timeout(t.timeout == null ? 2e4 : t.timeout), this._readyState = "closed", this.uri = e;
|
|
2041
|
-
const i = t.parser ||
|
|
2045
|
+
const i = t.parser || rt;
|
|
2042
2046
|
this.encoder = new i.Encoder(), this.decoder = new i.Decoder(), this._autoConnect = t.autoConnect !== !1, this._autoConnect && this.open();
|
|
2043
2047
|
}
|
|
2044
2048
|
reconnection(e) {
|
|
@@ -2494,17 +2498,17 @@ function ee(n = 100) {
|
|
|
2494
2498
|
(e) => setTimeout(() => e(), n)
|
|
2495
2499
|
);
|
|
2496
2500
|
}
|
|
2497
|
-
class
|
|
2498
|
-
#
|
|
2499
|
-
#
|
|
2501
|
+
class at {
|
|
2502
|
+
#n = "http://localhost:3001";
|
|
2503
|
+
#t = {
|
|
2500
2504
|
transports: ["websocket"]
|
|
2501
2505
|
};
|
|
2502
2506
|
#e = null;
|
|
2503
2507
|
#i = !1;
|
|
2504
|
-
#
|
|
2505
|
-
#
|
|
2506
|
-
constructor() {
|
|
2507
|
-
this.#t = {
|
|
2508
|
+
#o = !1;
|
|
2509
|
+
#s;
|
|
2510
|
+
constructor(e, t) {
|
|
2511
|
+
e && (this.#n = e), t && (this.#t = { ...this.#t, ...t }), this.#s = {
|
|
2508
2512
|
onResponse: this.onResponse.bind(this),
|
|
2509
2513
|
onDisconnect: () => {
|
|
2510
2514
|
this.#i = !1, window.dispatchEvent(new Event("serial:socket:disconnected"));
|
|
@@ -2512,8 +2516,8 @@ class ct {
|
|
|
2512
2516
|
onConnect: () => {
|
|
2513
2517
|
this.#i = !0, window.dispatchEvent(new Event("serial:socket:connected"));
|
|
2514
2518
|
},
|
|
2515
|
-
onConnectError: (
|
|
2516
|
-
console.debug("Socket connection error",
|
|
2519
|
+
onConnectError: (s) => {
|
|
2520
|
+
console.debug("Socket connection error", s), this.#i = !1, window.dispatchEvent(new Event("serial:socket:disconnected"));
|
|
2517
2521
|
}
|
|
2518
2522
|
};
|
|
2519
2523
|
}
|
|
@@ -2521,27 +2525,32 @@ class ct {
|
|
|
2521
2525
|
const t = new URL(e);
|
|
2522
2526
|
if (!["http:", "https:", "ws:", "wss:"].includes(t.protocol))
|
|
2523
2527
|
throw new Error("URI must start with http://, https://, ws://, or wss://");
|
|
2524
|
-
this.#
|
|
2528
|
+
this.#n = e;
|
|
2525
2529
|
}
|
|
2526
2530
|
get uri() {
|
|
2527
|
-
return this.#
|
|
2531
|
+
return this.#n;
|
|
2528
2532
|
}
|
|
2529
2533
|
set options(e) {
|
|
2530
2534
|
if (typeof e != "object")
|
|
2531
2535
|
throw new Error("Options must be an object");
|
|
2532
|
-
this.#
|
|
2536
|
+
this.#t = e;
|
|
2533
2537
|
}
|
|
2534
2538
|
get options() {
|
|
2535
|
-
return this.#
|
|
2539
|
+
return this.#t;
|
|
2536
2540
|
}
|
|
2537
2541
|
get socketId() {
|
|
2538
2542
|
return this.#e && this.#e.id ? this.#e.id : null;
|
|
2539
2543
|
}
|
|
2544
|
+
configure(e, t) {
|
|
2545
|
+
if (this.#o)
|
|
2546
|
+
throw new Error("Cannot configure socket after it has been initialized. Call configure() before prepare().");
|
|
2547
|
+
e && (this.uri = e), t && (this.#t = { ...this.#t, ...t });
|
|
2548
|
+
}
|
|
2540
2549
|
disconnect() {
|
|
2541
|
-
this.#e && (this.#e.off("response", this.#
|
|
2550
|
+
this.#e && (this.#e.off("response", this.#s.onResponse), this.#e.off("disconnect", this.#s.onDisconnect), this.#e.off("connect", this.#s.onConnect), this.#e.off("connect_error", this.#s.onConnectError), this.#e.disconnect(), this.#e = null, this.#o = !1), this.#i = !1;
|
|
2542
2551
|
}
|
|
2543
2552
|
prepare() {
|
|
2544
|
-
this.#i || this.#
|
|
2553
|
+
this.#i || this.#o || (this.#e = B(this.#n, this.#t), this.#o = !0, this.#e.on("disconnect", this.#s.onDisconnect), this.#e.on("response", this.#s.onResponse), this.#e.on("connect", this.#s.onConnect), this.#e.on("connect_error", this.#s.onConnectError));
|
|
2545
2554
|
}
|
|
2546
2555
|
connectDevice(e) {
|
|
2547
2556
|
if (!this.#e)
|
|
@@ -2574,7 +2583,7 @@ class ct {
|
|
|
2574
2583
|
return !this.#i;
|
|
2575
2584
|
}
|
|
2576
2585
|
}
|
|
2577
|
-
const
|
|
2586
|
+
const b = new at(), D = {
|
|
2578
2587
|
baudRate: 9600,
|
|
2579
2588
|
dataBits: 8,
|
|
2580
2589
|
stopBits: 1,
|
|
@@ -2582,7 +2591,7 @@ const w = new ct(), D = {
|
|
|
2582
2591
|
bufferSize: 32768,
|
|
2583
2592
|
flowControl: "none"
|
|
2584
2593
|
};
|
|
2585
|
-
class
|
|
2594
|
+
class lt extends de {
|
|
2586
2595
|
__internal__ = {
|
|
2587
2596
|
bypassSerialBytesConnection: !1,
|
|
2588
2597
|
auto_response: !1,
|
|
@@ -2595,6 +2604,7 @@ class ht extends de {
|
|
|
2595
2604
|
no_code: 0
|
|
2596
2605
|
},
|
|
2597
2606
|
serial: {
|
|
2607
|
+
transformStream: !1,
|
|
2598
2608
|
socket: !1,
|
|
2599
2609
|
portInfo: {
|
|
2600
2610
|
path: null,
|
|
@@ -2656,25 +2666,27 @@ class ht extends de {
|
|
|
2656
2666
|
reconnection: 0
|
|
2657
2667
|
}
|
|
2658
2668
|
};
|
|
2659
|
-
#
|
|
2669
|
+
#n = null;
|
|
2660
2670
|
constructor({
|
|
2661
2671
|
filters: e = null,
|
|
2662
2672
|
config_port: t = D,
|
|
2663
2673
|
no_device: s = 1,
|
|
2664
2674
|
device_listen_on_channel: i = 1,
|
|
2665
2675
|
bypassSerialBytesConnection: r = !1,
|
|
2666
|
-
socket: o = !1
|
|
2676
|
+
socket: o = !1,
|
|
2677
|
+
transformStream: l = !1
|
|
2667
2678
|
} = {
|
|
2668
2679
|
filters: null,
|
|
2669
2680
|
config_port: D,
|
|
2670
2681
|
no_device: 1,
|
|
2671
2682
|
device_listen_on_channel: 1,
|
|
2672
2683
|
bypassSerialBytesConnection: !1,
|
|
2673
|
-
socket: !1
|
|
2684
|
+
socket: !1,
|
|
2685
|
+
transformStream: !1
|
|
2674
2686
|
}) {
|
|
2675
2687
|
if (super(), !("serial" in navigator))
|
|
2676
2688
|
throw new Error("Web Serial not supported");
|
|
2677
|
-
e && (this.serialFilters = e), t && (this.serialConfigPort = t), r && (this.__internal__.bypassSerialBytesConnection = r), s && this.#
|
|
2689
|
+
e && (this.serialFilters = e), t && (this.serialConfigPort = t), r && (this.__internal__.bypassSerialBytesConnection = r), s && this.#v(s), i && ["number", "string"].includes(typeof i) && (this.listenOnChannel = i), this.__internal__.serial.socket = o, this.__internal__.serial.transformStream = l, this.#g(), this.#m();
|
|
2678
2690
|
}
|
|
2679
2691
|
set listenOnChannel(e) {
|
|
2680
2692
|
if (typeof e == "string" && (e = parseInt(e)), isNaN(e) || e < 1 || e > 255)
|
|
@@ -2708,15 +2720,15 @@ class ht extends de {
|
|
|
2708
2720
|
this.__internal__.serial.useRTSCTS = e;
|
|
2709
2721
|
}
|
|
2710
2722
|
get isConnected() {
|
|
2711
|
-
const e = this.__internal__.serial.connected, t = this.#
|
|
2723
|
+
const e = this.__internal__.serial.connected, t = this.#t(this.__internal__.serial.port);
|
|
2712
2724
|
return e && !t && this.#e({ error: "Port is closed, not readable or writable." }), this.__internal__.serial.connected = t, this.__internal__.serial.connected;
|
|
2713
2725
|
}
|
|
2714
2726
|
get isConnecting() {
|
|
2715
2727
|
return this.__internal__.serial.connecting;
|
|
2716
2728
|
}
|
|
2717
2729
|
get isDisconnected() {
|
|
2718
|
-
const e = this.__internal__.serial.connected, t = this.#
|
|
2719
|
-
return !e && t && (this.dispatch("serial:connected"), this.#
|
|
2730
|
+
const e = this.__internal__.serial.connected, t = this.#t(this.__internal__.serial.port);
|
|
2731
|
+
return !e && t && (this.dispatch("serial:connected"), this.#a(!1), a.$dispatchChange(this)), this.__internal__.serial.connected = t, !this.__internal__.serial.connected;
|
|
2720
2732
|
}
|
|
2721
2733
|
get deviceNumber() {
|
|
2722
2734
|
return this.__internal__.device_number;
|
|
@@ -2889,8 +2901,8 @@ class ht extends de {
|
|
|
2889
2901
|
}
|
|
2890
2902
|
};
|
|
2891
2903
|
}
|
|
2892
|
-
#
|
|
2893
|
-
return this.useSocket ? this.__internal__.serial.connected &&
|
|
2904
|
+
#t(e) {
|
|
2905
|
+
return this.useSocket ? this.__internal__.serial.connected && b.isConnected() : !!(e && e.readable && e.writable);
|
|
2894
2906
|
}
|
|
2895
2907
|
async timeout(e, t) {
|
|
2896
2908
|
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", {}), a.$dispatchChange(this)) : t === "connection:start" && (await this.serialDisconnect(), this.__internal__.serial.connected = !1, this.__internal__.aux_port_connector += 1, a.$dispatchChange(this), await this.serialConnect()), this.__internal__.serial.queue.length > 0 && this.dispatch("internal:queue", {}), this.dispatch("serial:timeout", {
|
|
@@ -2910,7 +2922,7 @@ class ht extends de {
|
|
|
2910
2922
|
}
|
|
2911
2923
|
socketResponse(e) {
|
|
2912
2924
|
const t = this.__internal__.serial.connected;
|
|
2913
|
-
if (e.type === "disconnect" || e.type === "error" && e.data === "DISCONNECTED" ? this.__internal__.serial.connected = !1 : e.type === "success" && (this.__internal__.serial.connected = !0), a.$dispatchChange(this), !t && this.__internal__.serial.connected && (this.dispatch("serial:connected"), this.#
|
|
2925
|
+
if (e.type === "disconnect" || e.type === "error" && e.data === "DISCONNECTED" ? this.__internal__.serial.connected = !1 : e.type === "success" && (this.__internal__.serial.connected = !0), a.$dispatchChange(this), !t && this.__internal__.serial.connected && (this.dispatch("serial:connected"), this.#a(!1)), e.type === "success")
|
|
2914
2926
|
this.#r(new Uint8Array(e.data));
|
|
2915
2927
|
else if (e.type === "error") {
|
|
2916
2928
|
const s = new Error("The port is closed or is not readable/writable");
|
|
@@ -2920,9 +2932,9 @@ class ht extends de {
|
|
|
2920
2932
|
}
|
|
2921
2933
|
async connect() {
|
|
2922
2934
|
return this.isConnected ? !0 : (this.__internal__.serial.aux_connecting = "idle", new Promise((e, t) => {
|
|
2923
|
-
this.#
|
|
2935
|
+
this.#n || (this.#n = this.#i.bind(this)), this.on("internal:connecting", this.#n);
|
|
2924
2936
|
const s = setInterval(() => {
|
|
2925
|
-
this.__internal__.serial.aux_connecting === "finished" ? (clearInterval(s), this.__internal__.serial.aux_connecting = "idle", this.#
|
|
2937
|
+
this.__internal__.serial.aux_connecting === "finished" ? (clearInterval(s), this.__internal__.serial.aux_connecting = "idle", this.#n !== null && this.off("internal:connecting", this.#n), this.isConnected ? e(!0) : t(`${this.typeDevice} device ${this.deviceNumber} not connected`)) : this.__internal__.serial.aux_connecting === "connecting" && (this.__internal__.serial.aux_connecting = "idle", this.dispatch("internal:connecting", { active: !0 }), this.dispatch("serial:connecting", { active: !0 }));
|
|
2926
2938
|
}, 100);
|
|
2927
2939
|
this.serialConnect();
|
|
2928
2940
|
}));
|
|
@@ -2930,10 +2942,15 @@ class ht extends de {
|
|
|
2930
2942
|
async serialDisconnect() {
|
|
2931
2943
|
try {
|
|
2932
2944
|
if (this.useSocket)
|
|
2933
|
-
|
|
2945
|
+
b.isConnected() && b.disconnectDevice(this.configDeviceSocket);
|
|
2934
2946
|
else {
|
|
2947
|
+
this.__internal__.serial.keep_reading = !1;
|
|
2935
2948
|
const e = this.__internal__.serial.reader, t = this.__internal__.serial.output_stream;
|
|
2936
|
-
e && (await e.cancel().catch((s) => this.serialErrors(s)),
|
|
2949
|
+
if (e && (await e.cancel().catch((s) => this.serialErrors(s)), this.__internal__.serial.input_done && await this.__internal__.serial.input_done), t) {
|
|
2950
|
+
const s = t.getWriter();
|
|
2951
|
+
await s.close(), s.releaseLock(), this.__internal__.serial.output_done && await this.__internal__.serial.output_done;
|
|
2952
|
+
}
|
|
2953
|
+
this.__internal__.serial && this.__internal__.serial.connected && this.__internal__.serial.port && await this.__internal__.serial.port.close();
|
|
2937
2954
|
}
|
|
2938
2955
|
} catch (e) {
|
|
2939
2956
|
this.serialErrors(e);
|
|
@@ -2941,17 +2958,17 @@ class ht extends de {
|
|
|
2941
2958
|
this.__internal__.serial.reader = null, this.__internal__.serial.input_done = null, this.__internal__.serial.output_stream = null, this.__internal__.serial.output_done = null, this.__internal__.serial.connected = !1, this.__internal__.serial.port = null, a.$dispatchChange(this);
|
|
2942
2959
|
}
|
|
2943
2960
|
}
|
|
2944
|
-
async #
|
|
2945
|
-
if (
|
|
2961
|
+
async #o(e) {
|
|
2962
|
+
if (b.isDisconnected())
|
|
2946
2963
|
throw this.#e({ error: "Socket is disconnected." }), new Error("The socket is disconnected");
|
|
2947
2964
|
if (this.isDisconnected)
|
|
2948
2965
|
throw this.#e({ error: "Port is closed, not readable or writable." }), new Error("The port is closed or is not readable/writable");
|
|
2949
2966
|
const t = this.validateBytes(e);
|
|
2950
|
-
|
|
2967
|
+
b.write({ config: this.configDeviceSocket, bytes: Array.from(t) });
|
|
2951
2968
|
}
|
|
2952
|
-
async #
|
|
2969
|
+
async #s(e) {
|
|
2953
2970
|
if (this.useSocket) {
|
|
2954
|
-
await this.#
|
|
2971
|
+
await this.#o(e);
|
|
2955
2972
|
return;
|
|
2956
2973
|
}
|
|
2957
2974
|
const t = this.__internal__.serial.port;
|
|
@@ -2975,7 +2992,7 @@ class ht extends de {
|
|
|
2975
2992
|
#r(e = new Uint8Array([]), t = !1) {
|
|
2976
2993
|
if (e && e.length > 0) {
|
|
2977
2994
|
const s = this.__internal__.serial.connected;
|
|
2978
|
-
if (this.__internal__.serial.connected = this.#
|
|
2995
|
+
if (this.__internal__.serial.connected = this.#t(this.__internal__.serial.port), a.$dispatchChange(this), !s && this.__internal__.serial.connected && (this.dispatch("serial:connected"), this.#a(!1)), 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")
|
|
2979
2996
|
t ? this.serialCorruptMessage(this.parseUint8ToHex(e)) : this.serialMessage(this.parseUint8ToHex(e));
|
|
2980
2997
|
else if (this.__internal__.serial.response.as === "uint8")
|
|
2981
2998
|
t ? this.serialCorruptMessage(e) : this.serialMessage(e);
|
|
@@ -3015,7 +3032,7 @@ class ht extends de {
|
|
|
3015
3032
|
return e.length === 0 ? t : t.filter((s) => {
|
|
3016
3033
|
const i = s.getInfo();
|
|
3017
3034
|
return e.some((r) => i.usbProductId === r.usbProductId && i.usbVendorId === r.usbVendorId);
|
|
3018
|
-
}).filter((s) => !this.#
|
|
3035
|
+
}).filter((s) => !this.#t(s));
|
|
3019
3036
|
}
|
|
3020
3037
|
async serialPortsSaved(e) {
|
|
3021
3038
|
const t = this.serialFilters;
|
|
@@ -3082,12 +3099,15 @@ class ht extends de {
|
|
|
3082
3099
|
s.set(t, 0), s.set(new Uint8Array(e), t.length), this.__internal__.serial.response.buffer = s;
|
|
3083
3100
|
}
|
|
3084
3101
|
}
|
|
3102
|
+
async #_() {
|
|
3103
|
+
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.response.buffer && this.#r(this.__internal__.serial.response.buffer), this.__internal__.serial.response.buffer = new Uint8Array(0);
|
|
3104
|
+
}
|
|
3085
3105
|
async #u() {
|
|
3086
3106
|
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(() => {
|
|
3087
3107
|
this.__internal__.serial.response.buffer && this.#r(this.__internal__.serial.response.buffer), this.__internal__.serial.response.buffer = new Uint8Array(0);
|
|
3088
3108
|
}, this.__internal__.serial.free_timeout_ms || 50);
|
|
3089
3109
|
}
|
|
3090
|
-
async #
|
|
3110
|
+
async #f() {
|
|
3091
3111
|
const e = this.__internal__.serial.response.length;
|
|
3092
3112
|
let t = this.__internal__.serial.response.buffer;
|
|
3093
3113
|
if (this.__internal__.serial.time_until_send_bytes && (clearTimeout(this.__internal__.serial.time_until_send_bytes), this.__internal__.serial.time_until_send_bytes = 0), !(e === null || !t || t.length === 0)) {
|
|
@@ -3100,7 +3120,7 @@ class ht extends de {
|
|
|
3100
3120
|
}, this.__internal__.serial.free_timeout_ms || 50));
|
|
3101
3121
|
}
|
|
3102
3122
|
}
|
|
3103
|
-
async #
|
|
3123
|
+
async #d() {
|
|
3104
3124
|
const {
|
|
3105
3125
|
limiter: e,
|
|
3106
3126
|
prefixLimiter: t = !1,
|
|
@@ -3123,25 +3143,25 @@ class ht extends de {
|
|
|
3123
3143
|
c = new RegExp(`([^${e}]+)${e}`, "g");
|
|
3124
3144
|
else
|
|
3125
3145
|
return;
|
|
3126
|
-
let f,
|
|
3146
|
+
let f, _ = 0;
|
|
3127
3147
|
for (; (f = c.exec(r)) !== null; )
|
|
3128
|
-
o.push(new TextEncoder().encode(f[1])),
|
|
3129
|
-
r = r.slice(
|
|
3148
|
+
o.push(new TextEncoder().encode(f[1])), _ = c.lastIndex;
|
|
3149
|
+
r = r.slice(_);
|
|
3130
3150
|
} else if (e instanceof RegExp) {
|
|
3131
3151
|
let c, f = 0;
|
|
3132
3152
|
if (t && s) {
|
|
3133
|
-
const
|
|
3134
|
-
for (; (c =
|
|
3135
|
-
o.push(new TextEncoder().encode(c[1])), f =
|
|
3153
|
+
const _ = new RegExp(`${e.source}(.*?)${e.source}`, "g");
|
|
3154
|
+
for (; (c = _.exec(r)) !== null; )
|
|
3155
|
+
o.push(new TextEncoder().encode(c[1])), f = _.lastIndex;
|
|
3136
3156
|
} else if (s)
|
|
3137
3157
|
for (; (c = e.exec(r)) !== null; ) {
|
|
3138
|
-
const
|
|
3158
|
+
const _ = c.index, d = r.slice(f, _);
|
|
3139
3159
|
o.push(new TextEncoder().encode(d)), f = e.lastIndex;
|
|
3140
3160
|
}
|
|
3141
3161
|
else if (t) {
|
|
3142
|
-
const
|
|
3143
|
-
|
|
3144
|
-
for (const d of
|
|
3162
|
+
const _ = r.split(e);
|
|
3163
|
+
_.shift();
|
|
3164
|
+
for (const d of _)
|
|
3145
3165
|
o.push(new TextEncoder().encode(d));
|
|
3146
3166
|
r = "";
|
|
3147
3167
|
}
|
|
@@ -3154,34 +3174,34 @@ class ht extends de {
|
|
|
3154
3174
|
this.#r(this.__internal__.serial.response.buffer, !0), this.__internal__.serial.response.buffer = new Uint8Array(0);
|
|
3155
3175
|
}, this.__internal__.serial.free_timeout_ms ?? 50));
|
|
3156
3176
|
}
|
|
3157
|
-
async #
|
|
3177
|
+
async #p() {
|
|
3158
3178
|
const e = this.__internal__.serial.port;
|
|
3159
3179
|
if (!e || !e.readable) throw new Error("Port is not readable");
|
|
3160
|
-
const t = e.readable.getReader();
|
|
3161
|
-
this.__internal__.serial.reader =
|
|
3180
|
+
const t = this.__internal__.serial.transformStream ? this.__internal__.serial.transformStream : null, s = t ? e.readable.pipeThrough(t).getReader() : e.readable.getReader();
|
|
3181
|
+
this.__internal__.serial.reader = s;
|
|
3162
3182
|
try {
|
|
3163
3183
|
for (; this.__internal__.serial.keep_reading; ) {
|
|
3164
|
-
const { value:
|
|
3165
|
-
if (
|
|
3166
|
-
this.#h(
|
|
3184
|
+
const { value: i, done: r } = await s.read();
|
|
3185
|
+
if (r) break;
|
|
3186
|
+
this.#h(i), this.__internal__.serial.transformStream ? await this.#_() : this.__internal__.serial.response.delimited ? await this.#d() : this.__internal__.serial.response.length === null ? await this.#u() : await this.#f();
|
|
3167
3187
|
}
|
|
3168
|
-
} catch (
|
|
3169
|
-
this.serialErrors(
|
|
3188
|
+
} catch (i) {
|
|
3189
|
+
this.serialErrors(i);
|
|
3170
3190
|
} finally {
|
|
3171
|
-
|
|
3191
|
+
s.releaseLock(), this.__internal__.serial.reader = null, this.__internal__.serial.keep_reading = !0;
|
|
3172
3192
|
}
|
|
3173
3193
|
}
|
|
3174
|
-
#
|
|
3194
|
+
#a(e) {
|
|
3175
3195
|
e !== this.__internal__.serial.connecting && (this.__internal__.serial.connecting = e, this.dispatch("serial:connecting", { active: e }), this.dispatch("internal:connecting", { active: e }));
|
|
3176
3196
|
}
|
|
3177
3197
|
async serialConnect() {
|
|
3178
3198
|
try {
|
|
3179
|
-
if (this.#
|
|
3180
|
-
if (
|
|
3199
|
+
if (this.#a(!0), this.useSocket) {
|
|
3200
|
+
if (b.prepare(), this.__internal__.serial.last_action = "connect", this.__internal__.timeout.until_response = setTimeout(async () => {
|
|
3181
3201
|
await this.timeout(this.__internal__.serial.bytes_connection ?? [], "connection:start");
|
|
3182
|
-
}, this.__internal__.time.response_connection),
|
|
3202
|
+
}, this.__internal__.time.response_connection), b.isDisconnected())
|
|
3183
3203
|
return;
|
|
3184
|
-
|
|
3204
|
+
b.connectDevice(this.configDeviceSocket), this.dispatch("serial:sent", {
|
|
3185
3205
|
action: "connect",
|
|
3186
3206
|
bytes: this.__internal__.serial.bytes_connection
|
|
3187
3207
|
});
|
|
@@ -3201,25 +3221,25 @@ class ht extends de {
|
|
|
3201
3221
|
await t.open(this.serialConfigPort);
|
|
3202
3222
|
const s = this;
|
|
3203
3223
|
t.onconnect = (i) => {
|
|
3204
|
-
s.dispatch("serial:connected", i), s.#
|
|
3224
|
+
s.dispatch("serial:connected", i), s.#a(!1), a.$dispatchChange(this), s.__internal__.serial.queue.length > 0 ? s.dispatch("internal:queue", {}) : s.__internal__.serial.running_queue = !1;
|
|
3205
3225
|
}, t.ondisconnect = async () => {
|
|
3206
3226
|
await s.disconnect();
|
|
3207
3227
|
}, await ee(this.__internal__.serial.delay_first_connection), this.__internal__.timeout.until_response = setTimeout(async () => {
|
|
3208
3228
|
await s.timeout(s.__internal__.serial.bytes_connection ?? [], "connection:start");
|
|
3209
|
-
}, this.__internal__.time.response_connection), this.__internal__.serial.last_action = "connect", await this.#
|
|
3229
|
+
}, this.__internal__.time.response_connection), this.__internal__.serial.last_action = "connect", await this.#s(this.__internal__.serial.bytes_connection ?? []), this.dispatch("serial:sent", {
|
|
3210
3230
|
action: "connect",
|
|
3211
3231
|
bytes: this.__internal__.serial.bytes_connection
|
|
3212
|
-
}), this.__internal__.auto_response && this.#r(this.__internal__.serial.auto_response), await this.#
|
|
3232
|
+
}), this.__internal__.auto_response && this.#r(this.__internal__.serial.auto_response), await this.#p();
|
|
3213
3233
|
}
|
|
3214
3234
|
} catch (e) {
|
|
3215
|
-
this.#
|
|
3235
|
+
this.#a(!1), this.serialErrors(e);
|
|
3216
3236
|
}
|
|
3217
3237
|
}
|
|
3218
|
-
async #
|
|
3238
|
+
async #y() {
|
|
3219
3239
|
return typeof window > "u" ? !1 : "serial" in navigator && "forget" in SerialPort.prototype && this.__internal__.serial.port ? (await this.__internal__.serial.port.forget(), !0) : !1;
|
|
3220
3240
|
}
|
|
3221
3241
|
async serialForget() {
|
|
3222
|
-
return await this.#
|
|
3242
|
+
return await this.#y();
|
|
3223
3243
|
}
|
|
3224
3244
|
decToHex(e) {
|
|
3225
3245
|
return typeof e == "string" && (e = parseInt(e, 10)), e.toString(16);
|
|
@@ -3239,7 +3259,7 @@ class ht extends de {
|
|
|
3239
3259
|
bytesToHex(e) {
|
|
3240
3260
|
return this.add0x(Array.from(e, (t) => this.hexMaker(t)));
|
|
3241
3261
|
}
|
|
3242
|
-
#
|
|
3262
|
+
#g() {
|
|
3243
3263
|
[
|
|
3244
3264
|
"serial:connected",
|
|
3245
3265
|
"serial:connecting",
|
|
@@ -3260,7 +3280,7 @@ class ht extends de {
|
|
|
3260
3280
|
this.serialRegisterAvailableListener(e);
|
|
3261
3281
|
});
|
|
3262
3282
|
}
|
|
3263
|
-
#
|
|
3283
|
+
#m() {
|
|
3264
3284
|
const e = this;
|
|
3265
3285
|
this.on("internal:queue", async () => {
|
|
3266
3286
|
await e.#w();
|
|
@@ -3271,9 +3291,9 @@ class ht extends de {
|
|
|
3271
3291
|
e.isDisconnected && !e.isConnecting && e.serialConnect().catch(() => {
|
|
3272
3292
|
});
|
|
3273
3293
|
};
|
|
3274
|
-
this.useSocket && (window.addEventListener("serial:socket:disconnected", t), window.addEventListener("serial:socket:connected", s)), this.#
|
|
3294
|
+
this.useSocket && (window.addEventListener("serial:socket:disconnected", t), window.addEventListener("serial:socket:connected", s)), this.#b();
|
|
3275
3295
|
}
|
|
3276
|
-
#
|
|
3296
|
+
#b() {
|
|
3277
3297
|
const e = this;
|
|
3278
3298
|
navigator.serial.addEventListener("connect", async () => {
|
|
3279
3299
|
e.isDisconnected && await e.serialConnect().catch(() => {
|
|
@@ -3281,9 +3301,9 @@ class ht extends de {
|
|
|
3281
3301
|
});
|
|
3282
3302
|
}
|
|
3283
3303
|
async #w() {
|
|
3284
|
-
if (this.useSocket &&
|
|
3304
|
+
if (this.useSocket && b.isDisconnected())
|
|
3285
3305
|
return;
|
|
3286
|
-
if (!this.#
|
|
3306
|
+
if (!this.#t(this.__internal__.serial.port)) {
|
|
3287
3307
|
this.#e({ error: "Port is closed, not readable or writable." }), await this.serialConnect();
|
|
3288
3308
|
return;
|
|
3289
3309
|
}
|
|
@@ -3297,7 +3317,7 @@ class ht extends de {
|
|
|
3297
3317
|
let t = this.__internal__.time.response_general;
|
|
3298
3318
|
if (e.action === "connect" && (t = this.__internal__.time.response_connection), this.__internal__.timeout.until_response = setTimeout(async () => {
|
|
3299
3319
|
await this.timeout(e.bytes, e.action);
|
|
3300
|
-
}, t), this.__internal__.serial.last_action = e.action ?? "unknown", await this.#
|
|
3320
|
+
}, t), this.__internal__.serial.last_action = e.action ?? "unknown", await this.#s(e.bytes), this.dispatch("serial:sent", {
|
|
3301
3321
|
action: e.action,
|
|
3302
3322
|
bytes: e.bytes
|
|
3303
3323
|
}), this.__internal__.auto_response) {
|
|
@@ -3335,7 +3355,7 @@ class ht extends de {
|
|
|
3335
3355
|
}
|
|
3336
3356
|
this.__internal__.serial.queue.push({ bytes: s, action: t }), this.dispatch("internal:queue", {});
|
|
3337
3357
|
}
|
|
3338
|
-
#
|
|
3358
|
+
#v(e = 1) {
|
|
3339
3359
|
this.__internal__.device_number = e, !this.__internal__.bypassSerialBytesConnection && (this.__internal__.serial.bytes_connection = this.serialSetConnectionConstant(e));
|
|
3340
3360
|
}
|
|
3341
3361
|
serialSetConnectionConstant(e = 1) {
|
|
@@ -3348,7 +3368,7 @@ class ht extends de {
|
|
|
3348
3368
|
serialCorruptMessage(e) {
|
|
3349
3369
|
throw console.log(e), this.dispatch("serial:corrupt-message", { code: e }), new Error("Method not implemented 'serialCorruptMessage'");
|
|
3350
3370
|
}
|
|
3351
|
-
#
|
|
3371
|
+
#E() {
|
|
3352
3372
|
this.__internal__.last_error = {
|
|
3353
3373
|
message: null,
|
|
3354
3374
|
action: null,
|
|
@@ -3375,7 +3395,7 @@ class ht extends de {
|
|
|
3375
3395
|
});
|
|
3376
3396
|
}
|
|
3377
3397
|
softReload() {
|
|
3378
|
-
this.#
|
|
3398
|
+
this.#E(), this.dispatch("serial:soft-reload", {});
|
|
3379
3399
|
}
|
|
3380
3400
|
async sendConnect() {
|
|
3381
3401
|
if (!this.__internal__.serial.bytes_connection)
|
|
@@ -3443,7 +3463,7 @@ class ht extends de {
|
|
|
3443
3463
|
}
|
|
3444
3464
|
}
|
|
3445
3465
|
export {
|
|
3446
|
-
|
|
3447
|
-
|
|
3466
|
+
lt as T,
|
|
3467
|
+
b as c,
|
|
3448
3468
|
a as s
|
|
3449
3469
|
};
|