@danidoble/webserial 4.4.0-beta.1 → 4.4.0-beta.3
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 +106 -101
- package/dist/hopper.cjs +2 -2
- package/dist/hopper.js +66 -51
- package/dist/jofemar.cjs +1 -1
- package/dist/jofemar.js +62 -144
- package/dist/kernel-C1HLYiV1.cjs +1 -0
- package/dist/kernel-C8ISUhzV.cjs +1 -0
- package/dist/kernel-CQcZ_OiG.js +831 -0
- package/dist/{kernel-505KqpPU.js → kernel-DkC7Kj3m.js} +151 -125
- package/dist/kernel-DtXV8d8B.js +831 -0
- package/dist/kernel-DyNuXvtW.cjs +1 -0
- package/dist/kernel-aqBCxtkj.js +831 -0
- package/dist/kernel-pO_elWba.cjs +1 -0
- package/dist/kernel.cjs +2 -2
- package/dist/kernel.d.ts +14 -0
- package/dist/kernel.d.ts.map +1 -0
- package/dist/kernel.js +3 -4
- package/dist/locker.cjs +1 -1
- package/dist/locker.js +33 -26
- package/dist/main.d.ts +28 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/pinpad.cjs +15 -20
- package/dist/pinpad.js +1405 -1259
- package/dist/pinpax.cjs +4 -4
- package/dist/pinpax.js +68 -68
- package/dist/{relay-CsdB0FSa.js → relay-DP8PLsDP.js} +2 -2
- package/dist/{relay-DGFymXOw.cjs → relay-E3NCcSjS.cjs} +1 -1
- package/dist/relay.cjs +1 -1
- package/dist/relay.js +11 -29
- package/dist/serial/boardroid.d.ts +206 -0
- package/dist/serial/boardroid.d.ts.map +1 -0
- package/dist/serial/hopper.d.ts +85 -0
- package/dist/serial/hopper.d.ts.map +1 -0
- package/dist/serial/jofemar.d.ts +218 -0
- package/dist/serial/jofemar.d.ts.map +1 -0
- package/dist/serial/kernel.d.ts +137 -0
- package/dist/serial/kernel.d.ts.map +1 -0
- package/dist/serial/locker.d.ts +33 -0
- package/dist/serial/locker.d.ts.map +1 -0
- package/dist/serial/pinpad.d.ts +263 -0
- package/dist/serial/pinpad.d.ts.map +1 -0
- package/dist/serial/pinpax.d.ts +60 -0
- package/dist/serial/pinpax.d.ts.map +1 -0
- package/dist/serial/relay.d.ts +13 -0
- package/dist/serial/relay.d.ts.map +1 -0
- package/dist/utils/devices.d.ts +26 -0
- package/dist/utils/devices.d.ts.map +1 -0
- package/dist/utils/dispatcher.d.ts +17 -0
- package/dist/utils/dispatcher.d.ts.map +1 -0
- package/dist/utils/emulator.d.ts +80 -0
- package/dist/utils/emulator.d.ts.map +1 -0
- package/dist/utils/utils.d.ts +7 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/{webserial-core-C0ZbaNYy.js → webserial-core-CH2Xov2y.js} +943 -933
- package/dist/webserial-core-Cj_EZjAU.cjs +4 -0
- package/dist/webserial-core-D3luFguv.js +3325 -0
- package/dist/webserial-core-YjdXyVOx.cjs +4 -0
- package/dist/webserial.cjs +2 -2
- package/dist/webserial.js +19 -19
- package/package.json +17 -14
- package/dist/kernel-Dq3Fv1y8.cjs +0 -1
- package/dist/webserial-core-B7vfLzGH.cjs +0 -4
|
@@ -1,124 +1,124 @@
|
|
|
1
1
|
class Y extends CustomEvent {
|
|
2
|
-
constructor(
|
|
3
|
-
super(
|
|
2
|
+
constructor(e, t) {
|
|
3
|
+
super(e, t);
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
|
-
class
|
|
6
|
+
class te extends EventTarget {
|
|
7
7
|
__listeners__ = {
|
|
8
8
|
debug: !1
|
|
9
9
|
};
|
|
10
10
|
__debug__ = !1;
|
|
11
11
|
__listenersCallbacks__ = [];
|
|
12
|
-
dispatch(
|
|
13
|
-
const n = new Y(
|
|
14
|
-
this.dispatchEvent(n), this.__debug__ && this.dispatchEvent(new Y("debug", { detail: { type:
|
|
12
|
+
dispatch(e, t = null) {
|
|
13
|
+
const n = new Y(e, { detail: t });
|
|
14
|
+
this.dispatchEvent(n), this.__debug__ && this.dispatchEvent(new Y("debug", { detail: { type: e, data: t } }));
|
|
15
15
|
}
|
|
16
|
-
dispatchAsync(
|
|
16
|
+
dispatchAsync(e, t = null, n = 100) {
|
|
17
17
|
const r = this;
|
|
18
18
|
setTimeout(() => {
|
|
19
|
-
r.dispatch(
|
|
19
|
+
r.dispatch(e, t);
|
|
20
20
|
}, n);
|
|
21
21
|
}
|
|
22
|
-
on(
|
|
23
|
-
typeof this.__listeners__[
|
|
22
|
+
on(e, t) {
|
|
23
|
+
typeof this.__listeners__[e] < "u" && !this.__listeners__[e] && (this.__listeners__[e] = !0), this.__listenersCallbacks__.push({ key: e, callback: t }), this.addEventListener(e, t);
|
|
24
24
|
}
|
|
25
|
-
off(
|
|
26
|
-
this.__listenersCallbacks__ = this.__listenersCallbacks__.filter((n) => !(n.key ===
|
|
25
|
+
off(e, t) {
|
|
26
|
+
this.__listenersCallbacks__ = this.__listenersCallbacks__.filter((n) => !(n.key === e && n.callback === t)), this.removeEventListener(e, t);
|
|
27
27
|
}
|
|
28
|
-
serialRegisterAvailableListener(
|
|
29
|
-
this.__listeners__[
|
|
28
|
+
serialRegisterAvailableListener(e) {
|
|
29
|
+
this.__listeners__[e] || (this.__listeners__[e] = !1);
|
|
30
30
|
}
|
|
31
31
|
get availableListeners() {
|
|
32
|
-
return Object.keys(this.__listeners__).sort().map((
|
|
33
|
-
type:
|
|
34
|
-
listening: this.__listeners__[
|
|
32
|
+
return Object.keys(this.__listeners__).sort().map((e) => ({
|
|
33
|
+
type: e,
|
|
34
|
+
listening: this.__listeners__[e]
|
|
35
35
|
}));
|
|
36
36
|
}
|
|
37
37
|
removeAllListeners() {
|
|
38
|
-
for (const
|
|
39
|
-
["internal:queue"].includes(
|
|
40
|
-
for (const
|
|
41
|
-
this.__listeners__[
|
|
38
|
+
for (const e of this.__listenersCallbacks__)
|
|
39
|
+
["internal:queue"].includes(e.key) || (this.__listenersCallbacks__ = this.__listenersCallbacks__.filter((t) => !(t.key === e.key && t.callback === e.callback)), this.removeEventListener(e.key, e.callback));
|
|
40
|
+
for (const e of Object.keys(this.__listeners__))
|
|
41
|
+
this.__listeners__[e] = !1;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
class a extends
|
|
44
|
+
class a extends te {
|
|
45
45
|
static instance;
|
|
46
46
|
static devices = {};
|
|
47
47
|
constructor() {
|
|
48
|
-
super(), ["change"].forEach((
|
|
49
|
-
this.serialRegisterAvailableListener(
|
|
48
|
+
super(), ["change"].forEach((e) => {
|
|
49
|
+
this.serialRegisterAvailableListener(e);
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
static $dispatchChange(
|
|
53
|
-
|
|
52
|
+
static $dispatchChange(e = null) {
|
|
53
|
+
e && e.$checkAndDispatchConnection(), a.instance.dispatch("change", { devices: a.devices, dispatcher: e });
|
|
54
54
|
}
|
|
55
|
-
static typeError(
|
|
56
|
-
const
|
|
57
|
-
throw
|
|
55
|
+
static typeError(e) {
|
|
56
|
+
const t = new Error();
|
|
57
|
+
throw t.message = `Type ${e} is not supported`, t.name = "DeviceTypeError", t;
|
|
58
58
|
}
|
|
59
|
-
static registerType(
|
|
60
|
-
typeof a.devices[
|
|
59
|
+
static registerType(e) {
|
|
60
|
+
typeof a.devices[e] > "u" && (a.devices = { ...a.devices, [e]: {} });
|
|
61
61
|
}
|
|
62
|
-
static add(
|
|
63
|
-
const
|
|
64
|
-
typeof a.devices[
|
|
65
|
-
const n =
|
|
66
|
-
if (typeof a.devices[
|
|
62
|
+
static add(e) {
|
|
63
|
+
const t = e.typeDevice;
|
|
64
|
+
typeof a.devices[t] > "u" && a.registerType(t);
|
|
65
|
+
const n = e.uuid;
|
|
66
|
+
if (typeof a.devices[t] > "u" && a.typeError(t), a.devices[t][n])
|
|
67
67
|
throw new Error(`Device with id ${n} already exists`);
|
|
68
|
-
return a.devices[
|
|
68
|
+
return a.devices[t][n] = e, a.$dispatchChange(e), Object.keys(a.devices[t]).indexOf(n);
|
|
69
69
|
}
|
|
70
|
-
static get(
|
|
71
|
-
return typeof a.devices[
|
|
70
|
+
static get(e, t) {
|
|
71
|
+
return typeof a.devices[e] > "u" && a.registerType(e), typeof a.devices[e] > "u" && a.typeError(e), a.devices[e][t];
|
|
72
72
|
}
|
|
73
|
-
static getAll(
|
|
74
|
-
return
|
|
73
|
+
static getAll(e = null) {
|
|
74
|
+
return e === null ? a.devices : (typeof a.devices[e] > "u" && a.typeError(e), a.devices[e]);
|
|
75
75
|
}
|
|
76
76
|
static getList() {
|
|
77
|
-
return Object.values(a.devices).map((
|
|
77
|
+
return Object.values(a.devices).map((e) => Object.values(e)).flat();
|
|
78
78
|
}
|
|
79
|
-
static getByNumber(
|
|
80
|
-
return typeof a.devices[
|
|
79
|
+
static getByNumber(e, t) {
|
|
80
|
+
return typeof a.devices[e] > "u" && a.typeError(e), Object.values(a.devices[e]).find((n) => n.deviceNumber === t) ?? null;
|
|
81
81
|
}
|
|
82
|
-
static getCustom(
|
|
83
|
-
return typeof a.devices[
|
|
82
|
+
static getCustom(e, t = 1) {
|
|
83
|
+
return typeof a.devices[e] > "u" && a.typeError(e), Object.values(a.devices[e]).find((n) => n.deviceNumber === t) ?? null;
|
|
84
84
|
}
|
|
85
85
|
static async connectToAll() {
|
|
86
|
-
const
|
|
87
|
-
for (const
|
|
88
|
-
|
|
86
|
+
const e = a.getList();
|
|
87
|
+
for (const t of e)
|
|
88
|
+
t.isConnected || await t.connect().catch(console.warn);
|
|
89
89
|
return Promise.resolve(a.areAllConnected());
|
|
90
90
|
}
|
|
91
91
|
static async disconnectAll() {
|
|
92
|
-
const
|
|
93
|
-
for (const
|
|
94
|
-
|
|
92
|
+
const e = a.getList();
|
|
93
|
+
for (const t of e)
|
|
94
|
+
t.isDisconnected || await t.disconnect().catch(console.warn);
|
|
95
95
|
return Promise.resolve(a.areAllDisconnected());
|
|
96
96
|
}
|
|
97
97
|
static async areAllConnected() {
|
|
98
|
-
const
|
|
99
|
-
for (const
|
|
100
|
-
if (!
|
|
98
|
+
const e = a.getList();
|
|
99
|
+
for (const t of e)
|
|
100
|
+
if (!t.isConnected) return Promise.resolve(!1);
|
|
101
101
|
return Promise.resolve(!0);
|
|
102
102
|
}
|
|
103
103
|
static async areAllDisconnected() {
|
|
104
|
-
const
|
|
105
|
-
for (const
|
|
106
|
-
if (!
|
|
104
|
+
const e = a.getList();
|
|
105
|
+
for (const t of e)
|
|
106
|
+
if (!t.isDisconnected) return Promise.resolve(!1);
|
|
107
107
|
return Promise.resolve(!0);
|
|
108
108
|
}
|
|
109
109
|
static async getAllConnected() {
|
|
110
|
-
const
|
|
111
|
-
return Promise.resolve(
|
|
110
|
+
const e = a.getList();
|
|
111
|
+
return Promise.resolve(e.filter((t) => t.isConnected));
|
|
112
112
|
}
|
|
113
113
|
static async getAllDisconnected() {
|
|
114
|
-
const
|
|
115
|
-
return Promise.resolve(
|
|
114
|
+
const e = a.getList();
|
|
115
|
+
return Promise.resolve(e.filter((t) => t.isDisconnected));
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
a.instance || (a.instance = new a());
|
|
119
119
|
function J(s = 100) {
|
|
120
120
|
return new Promise(
|
|
121
|
-
(
|
|
121
|
+
(e) => setTimeout(() => e(), s)
|
|
122
122
|
);
|
|
123
123
|
}
|
|
124
124
|
const m = /* @__PURE__ */ Object.create(null);
|
|
@@ -133,88 +133,88 @@ const x = /* @__PURE__ */ Object.create(null);
|
|
|
133
133
|
Object.keys(m).forEach((s) => {
|
|
134
134
|
x[m[s]] = s;
|
|
135
135
|
});
|
|
136
|
-
const
|
|
137
|
-
const
|
|
138
|
-
return
|
|
139
|
-
const n =
|
|
140
|
-
|
|
141
|
-
},
|
|
136
|
+
const D = { type: "error", data: "parser error" }, se = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", ne = typeof ArrayBuffer == "function", re = (s) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(s) : s && s.buffer instanceof ArrayBuffer, V = ({ type: s, data: e }, t, n) => se && e instanceof Blob ? t ? n(e) : Q(e, n) : ne && (e instanceof ArrayBuffer || re(e)) ? t ? n(e) : Q(new Blob([e]), n) : n(m[s] + (e || "")), Q = (s, e) => {
|
|
137
|
+
const t = new FileReader();
|
|
138
|
+
return t.onload = function() {
|
|
139
|
+
const n = t.result.split(",")[1];
|
|
140
|
+
e("b" + (n || ""));
|
|
141
|
+
}, t.readAsDataURL(s);
|
|
142
142
|
};
|
|
143
143
|
function X(s) {
|
|
144
144
|
return s instanceof Uint8Array ? s : s instanceof ArrayBuffer ? new Uint8Array(s) : new Uint8Array(s.buffer, s.byteOffset, s.byteLength);
|
|
145
145
|
}
|
|
146
146
|
let P;
|
|
147
|
-
function
|
|
148
|
-
if (
|
|
149
|
-
return s.data.arrayBuffer().then(X).then(
|
|
150
|
-
if (
|
|
151
|
-
return
|
|
152
|
-
V(s, !1, (
|
|
153
|
-
P || (P = new TextEncoder()),
|
|
147
|
+
function fe(s, e) {
|
|
148
|
+
if (se && s.data instanceof Blob)
|
|
149
|
+
return s.data.arrayBuffer().then(X).then(e);
|
|
150
|
+
if (ne && (s.data instanceof ArrayBuffer || re(s.data)))
|
|
151
|
+
return e(X(s.data));
|
|
152
|
+
V(s, !1, (t) => {
|
|
153
|
+
P || (P = new TextEncoder()), e(P.encode(t));
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
const G = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", E = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
|
|
157
157
|
for (let s = 0; s < G.length; s++)
|
|
158
158
|
E[G.charCodeAt(s)] = s;
|
|
159
|
-
const
|
|
160
|
-
let
|
|
161
|
-
s[s.length - 1] === "=" && (
|
|
162
|
-
const p = new ArrayBuffer(
|
|
163
|
-
for (n = 0; n <
|
|
159
|
+
const ye = (s) => {
|
|
160
|
+
let e = s.length * 0.75, t = s.length, n, r = 0, i, o, h, c;
|
|
161
|
+
s[s.length - 1] === "=" && (e--, s[s.length - 2] === "=" && e--);
|
|
162
|
+
const p = new ArrayBuffer(e), u = new Uint8Array(p);
|
|
163
|
+
for (n = 0; n < t; n += 4)
|
|
164
164
|
i = E[s.charCodeAt(n)], o = E[s.charCodeAt(n + 1)], h = E[s.charCodeAt(n + 2)], c = E[s.charCodeAt(n + 3)], u[r++] = i << 2 | o >> 4, u[r++] = (o & 15) << 4 | h >> 2, u[r++] = (h & 3) << 6 | c & 63;
|
|
165
165
|
return p;
|
|
166
|
-
},
|
|
166
|
+
}, ge = typeof ArrayBuffer == "function", H = (s, e) => {
|
|
167
167
|
if (typeof s != "string")
|
|
168
168
|
return {
|
|
169
169
|
type: "message",
|
|
170
|
-
data:
|
|
170
|
+
data: ie(s, e)
|
|
171
171
|
};
|
|
172
|
-
const
|
|
173
|
-
return
|
|
172
|
+
const t = s.charAt(0);
|
|
173
|
+
return t === "b" ? {
|
|
174
174
|
type: "message",
|
|
175
|
-
data:
|
|
176
|
-
} : x[
|
|
177
|
-
type: x[
|
|
175
|
+
data: me(s.substring(1), e)
|
|
176
|
+
} : x[t] ? s.length > 1 ? {
|
|
177
|
+
type: x[t],
|
|
178
178
|
data: s.substring(1)
|
|
179
179
|
} : {
|
|
180
|
-
type: x[
|
|
181
|
-
} :
|
|
182
|
-
},
|
|
183
|
-
if (
|
|
184
|
-
const
|
|
185
|
-
return
|
|
180
|
+
type: x[t]
|
|
181
|
+
} : D;
|
|
182
|
+
}, me = (s, e) => {
|
|
183
|
+
if (ge) {
|
|
184
|
+
const t = ye(s);
|
|
185
|
+
return ie(t, e);
|
|
186
186
|
} else
|
|
187
187
|
return { base64: !0, data: s };
|
|
188
|
-
},
|
|
189
|
-
switch (
|
|
188
|
+
}, ie = (s, e) => {
|
|
189
|
+
switch (e) {
|
|
190
190
|
case "blob":
|
|
191
191
|
return s instanceof Blob ? s : new Blob([s]);
|
|
192
192
|
case "arraybuffer":
|
|
193
193
|
default:
|
|
194
194
|
return s instanceof ArrayBuffer ? s : s.buffer;
|
|
195
195
|
}
|
|
196
|
-
},
|
|
197
|
-
const
|
|
196
|
+
}, oe = "", be = (s, e) => {
|
|
197
|
+
const t = s.length, n = new Array(t);
|
|
198
198
|
let r = 0;
|
|
199
199
|
s.forEach((i, o) => {
|
|
200
200
|
V(i, !1, (h) => {
|
|
201
|
-
n[o] = h, ++r ===
|
|
201
|
+
n[o] = h, ++r === t && e(n.join(oe));
|
|
202
202
|
});
|
|
203
203
|
});
|
|
204
|
-
},
|
|
205
|
-
const
|
|
206
|
-
for (let r = 0; r <
|
|
207
|
-
const i = H(
|
|
204
|
+
}, we = (s, e) => {
|
|
205
|
+
const t = s.split(oe), n = [];
|
|
206
|
+
for (let r = 0; r < t.length; r++) {
|
|
207
|
+
const i = H(t[r], e);
|
|
208
208
|
if (n.push(i), i.type === "error")
|
|
209
209
|
break;
|
|
210
210
|
}
|
|
211
211
|
return n;
|
|
212
212
|
};
|
|
213
|
-
function
|
|
213
|
+
function ve() {
|
|
214
214
|
return new TransformStream({
|
|
215
|
-
transform(s,
|
|
216
|
-
|
|
217
|
-
const n =
|
|
215
|
+
transform(s, e) {
|
|
216
|
+
fe(s, (t) => {
|
|
217
|
+
const n = t.length;
|
|
218
218
|
let r;
|
|
219
219
|
if (n < 126)
|
|
220
220
|
r = new Uint8Array(1), new DataView(r.buffer).setUint8(0, n);
|
|
@@ -227,104 +227,104 @@ function vt() {
|
|
|
227
227
|
const i = new DataView(r.buffer);
|
|
228
228
|
i.setUint8(0, 127), i.setBigUint64(1, BigInt(n));
|
|
229
229
|
}
|
|
230
|
-
s.data && typeof s.data != "string" && (r[0] |= 128),
|
|
230
|
+
s.data && typeof s.data != "string" && (r[0] |= 128), e.enqueue(r), e.enqueue(t);
|
|
231
231
|
});
|
|
232
232
|
}
|
|
233
233
|
});
|
|
234
234
|
}
|
|
235
235
|
let N;
|
|
236
236
|
function C(s) {
|
|
237
|
-
return s.reduce((
|
|
237
|
+
return s.reduce((e, t) => e + t.length, 0);
|
|
238
238
|
}
|
|
239
|
-
function T(s,
|
|
240
|
-
if (s[0].length ===
|
|
239
|
+
function T(s, e) {
|
|
240
|
+
if (s[0].length === e)
|
|
241
241
|
return s.shift();
|
|
242
|
-
const
|
|
242
|
+
const t = new Uint8Array(e);
|
|
243
243
|
let n = 0;
|
|
244
|
-
for (let r = 0; r <
|
|
245
|
-
|
|
246
|
-
return s.length && n < s[0].length && (s[0] = s[0].slice(n)),
|
|
244
|
+
for (let r = 0; r < e; r++)
|
|
245
|
+
t[r] = s[0][n++], n === s[0].length && (s.shift(), n = 0);
|
|
246
|
+
return s.length && n < s[0].length && (s[0] = s[0].slice(n)), t;
|
|
247
247
|
}
|
|
248
|
-
function
|
|
248
|
+
function ke(s, e) {
|
|
249
249
|
N || (N = new TextDecoder());
|
|
250
|
-
const
|
|
250
|
+
const t = [];
|
|
251
251
|
let n = 0, r = -1, i = !1;
|
|
252
252
|
return new TransformStream({
|
|
253
253
|
transform(o, h) {
|
|
254
|
-
for (
|
|
254
|
+
for (t.push(o); ; ) {
|
|
255
255
|
if (n === 0) {
|
|
256
|
-
if (C(
|
|
256
|
+
if (C(t) < 1)
|
|
257
257
|
break;
|
|
258
|
-
const c = T(
|
|
258
|
+
const c = T(t, 1);
|
|
259
259
|
i = (c[0] & 128) === 128, r = c[0] & 127, r < 126 ? n = 3 : r === 126 ? n = 1 : n = 2;
|
|
260
260
|
} else if (n === 1) {
|
|
261
|
-
if (C(
|
|
261
|
+
if (C(t) < 2)
|
|
262
262
|
break;
|
|
263
|
-
const c = T(
|
|
263
|
+
const c = T(t, 2);
|
|
264
264
|
r = new DataView(c.buffer, c.byteOffset, c.length).getUint16(0), n = 3;
|
|
265
265
|
} else if (n === 2) {
|
|
266
|
-
if (C(
|
|
266
|
+
if (C(t) < 8)
|
|
267
267
|
break;
|
|
268
|
-
const c = T(
|
|
268
|
+
const c = T(t, 8), p = new DataView(c.buffer, c.byteOffset, c.length), u = p.getUint32(0);
|
|
269
269
|
if (u > Math.pow(2, 21) - 1) {
|
|
270
|
-
h.enqueue(
|
|
270
|
+
h.enqueue(D);
|
|
271
271
|
break;
|
|
272
272
|
}
|
|
273
273
|
r = u * Math.pow(2, 32) + p.getUint32(4), n = 3;
|
|
274
274
|
} else {
|
|
275
|
-
if (C(
|
|
275
|
+
if (C(t) < r)
|
|
276
276
|
break;
|
|
277
|
-
const c = T(
|
|
278
|
-
h.enqueue(H(i ? c : N.decode(c),
|
|
277
|
+
const c = T(t, r);
|
|
278
|
+
h.enqueue(H(i ? c : N.decode(c), e)), n = 0;
|
|
279
279
|
}
|
|
280
280
|
if (r === 0 || r > s) {
|
|
281
|
-
h.enqueue(
|
|
281
|
+
h.enqueue(D);
|
|
282
282
|
break;
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
286
|
});
|
|
287
287
|
}
|
|
288
|
-
const
|
|
288
|
+
const ae = 4;
|
|
289
289
|
function _(s) {
|
|
290
|
-
if (s) return
|
|
290
|
+
if (s) return Ee(s);
|
|
291
291
|
}
|
|
292
|
-
function
|
|
293
|
-
for (var
|
|
294
|
-
s[
|
|
292
|
+
function Ee(s) {
|
|
293
|
+
for (var e in _.prototype)
|
|
294
|
+
s[e] = _.prototype[e];
|
|
295
295
|
return s;
|
|
296
296
|
}
|
|
297
|
-
_.prototype.on = _.prototype.addEventListener = function(s,
|
|
298
|
-
return this._callbacks = this._callbacks || {}, (this._callbacks["$" + s] = this._callbacks["$" + s] || []).push(
|
|
297
|
+
_.prototype.on = _.prototype.addEventListener = function(s, e) {
|
|
298
|
+
return this._callbacks = this._callbacks || {}, (this._callbacks["$" + s] = this._callbacks["$" + s] || []).push(e), this;
|
|
299
299
|
};
|
|
300
|
-
_.prototype.once = function(s,
|
|
301
|
-
function
|
|
302
|
-
this.off(s,
|
|
300
|
+
_.prototype.once = function(s, e) {
|
|
301
|
+
function t() {
|
|
302
|
+
this.off(s, t), e.apply(this, arguments);
|
|
303
303
|
}
|
|
304
|
-
return
|
|
304
|
+
return t.fn = e, this.on(s, t), this;
|
|
305
305
|
};
|
|
306
|
-
_.prototype.off = _.prototype.removeListener = _.prototype.removeAllListeners = _.prototype.removeEventListener = function(s,
|
|
306
|
+
_.prototype.off = _.prototype.removeListener = _.prototype.removeAllListeners = _.prototype.removeEventListener = function(s, e) {
|
|
307
307
|
if (this._callbacks = this._callbacks || {}, arguments.length == 0)
|
|
308
308
|
return this._callbacks = {}, this;
|
|
309
|
-
var
|
|
310
|
-
if (!
|
|
309
|
+
var t = this._callbacks["$" + s];
|
|
310
|
+
if (!t) return this;
|
|
311
311
|
if (arguments.length == 1)
|
|
312
312
|
return delete this._callbacks["$" + s], this;
|
|
313
|
-
for (var n, r = 0; r <
|
|
314
|
-
if (n =
|
|
315
|
-
|
|
313
|
+
for (var n, r = 0; r < t.length; r++)
|
|
314
|
+
if (n = t[r], n === e || n.fn === e) {
|
|
315
|
+
t.splice(r, 1);
|
|
316
316
|
break;
|
|
317
317
|
}
|
|
318
|
-
return
|
|
318
|
+
return t.length === 0 && delete this._callbacks["$" + s], this;
|
|
319
319
|
};
|
|
320
320
|
_.prototype.emit = function(s) {
|
|
321
321
|
this._callbacks = this._callbacks || {};
|
|
322
|
-
for (var
|
|
323
|
-
|
|
324
|
-
if (
|
|
325
|
-
|
|
326
|
-
for (var n = 0, r =
|
|
327
|
-
|
|
322
|
+
for (var e = new Array(arguments.length - 1), t = this._callbacks["$" + s], n = 1; n < arguments.length; n++)
|
|
323
|
+
e[n - 1] = arguments[n];
|
|
324
|
+
if (t) {
|
|
325
|
+
t = t.slice(0);
|
|
326
|
+
for (var n = 0, r = t.length; n < r; ++n)
|
|
327
|
+
t[n].apply(this, e);
|
|
328
328
|
}
|
|
329
329
|
return this;
|
|
330
330
|
};
|
|
@@ -335,44 +335,44 @@ _.prototype.listeners = function(s) {
|
|
|
335
335
|
_.prototype.hasListeners = function(s) {
|
|
336
336
|
return !!this.listeners(s).length;
|
|
337
337
|
};
|
|
338
|
-
const O = typeof Promise == "function" && typeof Promise.resolve == "function" ? (s) => Promise.resolve().then(s) : (s,
|
|
339
|
-
function
|
|
340
|
-
return
|
|
338
|
+
const O = typeof Promise == "function" && typeof Promise.resolve == "function" ? (s) => Promise.resolve().then(s) : (s, e) => e(s, 0), d = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), Ce = "arraybuffer";
|
|
339
|
+
function ce(s, ...e) {
|
|
340
|
+
return e.reduce((t, n) => (s.hasOwnProperty(n) && (t[n] = s[n]), t), {});
|
|
341
341
|
}
|
|
342
|
-
const
|
|
343
|
-
function L(s,
|
|
344
|
-
|
|
342
|
+
const Te = d.setTimeout, Ae = d.clearTimeout;
|
|
343
|
+
function L(s, e) {
|
|
344
|
+
e.useNativeTimers ? (s.setTimeoutFn = Te.bind(d), s.clearTimeoutFn = Ae.bind(d)) : (s.setTimeoutFn = d.setTimeout.bind(d), s.clearTimeoutFn = d.clearTimeout.bind(d));
|
|
345
345
|
}
|
|
346
|
-
const
|
|
347
|
-
function
|
|
348
|
-
return typeof s == "string" ?
|
|
346
|
+
const xe = 1.33;
|
|
347
|
+
function Se(s) {
|
|
348
|
+
return typeof s == "string" ? Re(s) : Math.ceil((s.byteLength || s.size) * xe);
|
|
349
349
|
}
|
|
350
|
-
function
|
|
351
|
-
let
|
|
350
|
+
function Re(s) {
|
|
351
|
+
let e = 0, t = 0;
|
|
352
352
|
for (let n = 0, r = s.length; n < r; n++)
|
|
353
|
-
|
|
354
|
-
return
|
|
353
|
+
e = s.charCodeAt(n), e < 128 ? t += 1 : e < 2048 ? t += 2 : e < 55296 || e >= 57344 ? t += 3 : (n++, t += 4);
|
|
354
|
+
return t;
|
|
355
355
|
}
|
|
356
|
-
function
|
|
356
|
+
function le() {
|
|
357
357
|
return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
|
|
358
358
|
}
|
|
359
|
-
function
|
|
360
|
-
let
|
|
361
|
-
for (let
|
|
362
|
-
s.hasOwnProperty(
|
|
363
|
-
return
|
|
359
|
+
function Be(s) {
|
|
360
|
+
let e = "";
|
|
361
|
+
for (let t in s)
|
|
362
|
+
s.hasOwnProperty(t) && (e.length && (e += "&"), e += encodeURIComponent(t) + "=" + encodeURIComponent(s[t]));
|
|
363
|
+
return e;
|
|
364
364
|
}
|
|
365
|
-
function
|
|
366
|
-
let
|
|
367
|
-
for (let n = 0, r =
|
|
368
|
-
let i =
|
|
369
|
-
|
|
365
|
+
function Oe(s) {
|
|
366
|
+
let e = {}, t = s.split("&");
|
|
367
|
+
for (let n = 0, r = t.length; n < r; n++) {
|
|
368
|
+
let i = t[n].split("=");
|
|
369
|
+
e[decodeURIComponent(i[0])] = decodeURIComponent(i[1]);
|
|
370
370
|
}
|
|
371
|
-
return
|
|
371
|
+
return e;
|
|
372
372
|
}
|
|
373
|
-
class
|
|
374
|
-
constructor(
|
|
375
|
-
super(
|
|
373
|
+
class Le extends Error {
|
|
374
|
+
constructor(e, t, n) {
|
|
375
|
+
super(e), this.description = t, this.context = n, this.type = "TransportError";
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
378
|
class W extends _ {
|
|
@@ -382,8 +382,8 @@ class W extends _ {
|
|
|
382
382
|
* @param {Object} opts - options
|
|
383
383
|
* @protected
|
|
384
384
|
*/
|
|
385
|
-
constructor(
|
|
386
|
-
super(), this.writable = !1, L(this,
|
|
385
|
+
constructor(e) {
|
|
386
|
+
super(), this.writable = !1, L(this, e), this.opts = e, this.query = e.query, this.socket = e.socket, this.supportsBinary = !e.forceBase64;
|
|
387
387
|
}
|
|
388
388
|
/**
|
|
389
389
|
* Emits an error.
|
|
@@ -394,8 +394,8 @@ class W extends _ {
|
|
|
394
394
|
* @return {Transport} for chaining
|
|
395
395
|
* @protected
|
|
396
396
|
*/
|
|
397
|
-
onError(
|
|
398
|
-
return super.emitReserved("error", new
|
|
397
|
+
onError(e, t, n) {
|
|
398
|
+
return super.emitReserved("error", new Le(e, t, n)), this;
|
|
399
399
|
}
|
|
400
400
|
/**
|
|
401
401
|
* Opens the transport.
|
|
@@ -414,8 +414,8 @@ class W extends _ {
|
|
|
414
414
|
*
|
|
415
415
|
* @param {Array} packets
|
|
416
416
|
*/
|
|
417
|
-
send(
|
|
418
|
-
this.readyState === "open" && this.write(
|
|
417
|
+
send(e) {
|
|
418
|
+
this.readyState === "open" && this.write(e);
|
|
419
419
|
}
|
|
420
420
|
/**
|
|
421
421
|
* Called upon open
|
|
@@ -431,49 +431,49 @@ class W extends _ {
|
|
|
431
431
|
* @param {String} data
|
|
432
432
|
* @protected
|
|
433
433
|
*/
|
|
434
|
-
onData(
|
|
435
|
-
const
|
|
436
|
-
this.onPacket(
|
|
434
|
+
onData(e) {
|
|
435
|
+
const t = H(e, this.socket.binaryType);
|
|
436
|
+
this.onPacket(t);
|
|
437
437
|
}
|
|
438
438
|
/**
|
|
439
439
|
* Called with a decoded packet.
|
|
440
440
|
*
|
|
441
441
|
* @protected
|
|
442
442
|
*/
|
|
443
|
-
onPacket(
|
|
444
|
-
super.emitReserved("packet",
|
|
443
|
+
onPacket(e) {
|
|
444
|
+
super.emitReserved("packet", e);
|
|
445
445
|
}
|
|
446
446
|
/**
|
|
447
447
|
* Called upon close.
|
|
448
448
|
*
|
|
449
449
|
* @protected
|
|
450
450
|
*/
|
|
451
|
-
onClose(
|
|
452
|
-
this.readyState = "closed", super.emitReserved("close",
|
|
451
|
+
onClose(e) {
|
|
452
|
+
this.readyState = "closed", super.emitReserved("close", e);
|
|
453
453
|
}
|
|
454
454
|
/**
|
|
455
455
|
* Pauses the transport, in order not to lose packets during an upgrade.
|
|
456
456
|
*
|
|
457
457
|
* @param onPause
|
|
458
458
|
*/
|
|
459
|
-
pause(
|
|
459
|
+
pause(e) {
|
|
460
460
|
}
|
|
461
|
-
createUri(
|
|
462
|
-
return
|
|
461
|
+
createUri(e, t = {}) {
|
|
462
|
+
return e + "://" + this._hostname() + this._port() + this.opts.path + this._query(t);
|
|
463
463
|
}
|
|
464
464
|
_hostname() {
|
|
465
|
-
const
|
|
466
|
-
return
|
|
465
|
+
const e = this.opts.hostname;
|
|
466
|
+
return e.indexOf(":") === -1 ? e : "[" + e + "]";
|
|
467
467
|
}
|
|
468
468
|
_port() {
|
|
469
469
|
return this.opts.port && (this.opts.secure && +(this.opts.port !== 443) || !this.opts.secure && Number(this.opts.port) !== 80) ? ":" + this.opts.port : "";
|
|
470
470
|
}
|
|
471
|
-
_query(
|
|
472
|
-
const
|
|
473
|
-
return
|
|
471
|
+
_query(e) {
|
|
472
|
+
const t = Be(e);
|
|
473
|
+
return t.length ? "?" + t : "";
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
|
-
class
|
|
476
|
+
class Pe extends W {
|
|
477
477
|
constructor() {
|
|
478
478
|
super(...arguments), this._polling = !1;
|
|
479
479
|
}
|
|
@@ -495,20 +495,20 @@ class Pt extends W {
|
|
|
495
495
|
* @param {Function} onPause - callback upon buffers are flushed and transport is paused
|
|
496
496
|
* @package
|
|
497
497
|
*/
|
|
498
|
-
pause(
|
|
498
|
+
pause(e) {
|
|
499
499
|
this.readyState = "pausing";
|
|
500
|
-
const
|
|
501
|
-
this.readyState = "paused",
|
|
500
|
+
const t = () => {
|
|
501
|
+
this.readyState = "paused", e();
|
|
502
502
|
};
|
|
503
503
|
if (this._polling || !this.writable) {
|
|
504
504
|
let n = 0;
|
|
505
505
|
this._polling && (n++, this.once("pollComplete", function() {
|
|
506
|
-
--n ||
|
|
506
|
+
--n || t();
|
|
507
507
|
})), this.writable || (n++, this.once("drain", function() {
|
|
508
|
-
--n ||
|
|
508
|
+
--n || t();
|
|
509
509
|
}));
|
|
510
510
|
} else
|
|
511
|
-
|
|
511
|
+
t();
|
|
512
512
|
}
|
|
513
513
|
/**
|
|
514
514
|
* Starts polling cycle.
|
|
@@ -523,13 +523,13 @@ class Pt extends W {
|
|
|
523
523
|
*
|
|
524
524
|
* @protected
|
|
525
525
|
*/
|
|
526
|
-
onData(
|
|
527
|
-
const
|
|
526
|
+
onData(e) {
|
|
527
|
+
const t = (n) => {
|
|
528
528
|
if (this.readyState === "opening" && n.type === "open" && this.onOpen(), n.type === "close")
|
|
529
529
|
return this.onClose({ description: "transport closed by the server" }), !1;
|
|
530
530
|
this.onPacket(n);
|
|
531
531
|
};
|
|
532
|
-
|
|
532
|
+
we(e, this.socket.binaryType).forEach(t), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
|
|
533
533
|
}
|
|
534
534
|
/**
|
|
535
535
|
* For polling, send a close packet.
|
|
@@ -537,10 +537,10 @@ class Pt extends W {
|
|
|
537
537
|
* @protected
|
|
538
538
|
*/
|
|
539
539
|
doClose() {
|
|
540
|
-
const
|
|
540
|
+
const e = () => {
|
|
541
541
|
this.write([{ type: "close" }]);
|
|
542
542
|
};
|
|
543
|
-
this.readyState === "open" ?
|
|
543
|
+
this.readyState === "open" ? e() : this.once("open", e);
|
|
544
544
|
}
|
|
545
545
|
/**
|
|
546
546
|
* Writes a packets payload.
|
|
@@ -548,9 +548,9 @@ class Pt extends W {
|
|
|
548
548
|
* @param {Array} packets - data packets
|
|
549
549
|
* @protected
|
|
550
550
|
*/
|
|
551
|
-
write(
|
|
552
|
-
this.writable = !1,
|
|
553
|
-
this.doWrite(
|
|
551
|
+
write(e) {
|
|
552
|
+
this.writable = !1, be(e, (t) => {
|
|
553
|
+
this.doWrite(t, () => {
|
|
554
554
|
this.writable = !0, this.emitReserved("drain");
|
|
555
555
|
});
|
|
556
556
|
});
|
|
@@ -561,30 +561,30 @@ class Pt extends W {
|
|
|
561
561
|
* @private
|
|
562
562
|
*/
|
|
563
563
|
uri() {
|
|
564
|
-
const
|
|
565
|
-
return this.opts.timestampRequests !== !1 && (
|
|
564
|
+
const e = this.opts.secure ? "https" : "http", t = this.query || {};
|
|
565
|
+
return this.opts.timestampRequests !== !1 && (t[this.opts.timestampParam] = le()), !this.supportsBinary && !t.sid && (t.b64 = 1), this.createUri(e, t);
|
|
566
566
|
}
|
|
567
567
|
}
|
|
568
|
-
let
|
|
568
|
+
let he = !1;
|
|
569
569
|
try {
|
|
570
|
-
|
|
570
|
+
he = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
|
|
571
571
|
} catch {
|
|
572
572
|
}
|
|
573
|
-
const
|
|
574
|
-
function
|
|
573
|
+
const Ne = he;
|
|
574
|
+
function Ie() {
|
|
575
575
|
}
|
|
576
|
-
class
|
|
576
|
+
class qe extends Pe {
|
|
577
577
|
/**
|
|
578
578
|
* XHR Polling constructor.
|
|
579
579
|
*
|
|
580
580
|
* @param {Object} opts
|
|
581
581
|
* @package
|
|
582
582
|
*/
|
|
583
|
-
constructor(
|
|
584
|
-
if (super(
|
|
585
|
-
const
|
|
583
|
+
constructor(e) {
|
|
584
|
+
if (super(e), typeof location < "u") {
|
|
585
|
+
const t = location.protocol === "https:";
|
|
586
586
|
let n = location.port;
|
|
587
|
-
n || (n =
|
|
587
|
+
n || (n = t ? "443" : "80"), this.xd = typeof location < "u" && e.hostname !== location.hostname || n !== e.port;
|
|
588
588
|
}
|
|
589
589
|
}
|
|
590
590
|
/**
|
|
@@ -594,12 +594,12 @@ class Dt extends Pt {
|
|
|
594
594
|
* @param {Function} called upon flush.
|
|
595
595
|
* @private
|
|
596
596
|
*/
|
|
597
|
-
doWrite(
|
|
597
|
+
doWrite(e, t) {
|
|
598
598
|
const n = this.request({
|
|
599
599
|
method: "POST",
|
|
600
|
-
data:
|
|
600
|
+
data: e
|
|
601
601
|
});
|
|
602
|
-
n.on("success",
|
|
602
|
+
n.on("success", t), n.on("error", (r, i) => {
|
|
603
603
|
this.onError("xhr post error", r, i);
|
|
604
604
|
});
|
|
605
605
|
}
|
|
@@ -609,10 +609,10 @@ class Dt extends Pt {
|
|
|
609
609
|
* @private
|
|
610
610
|
*/
|
|
611
611
|
doPoll() {
|
|
612
|
-
const
|
|
613
|
-
|
|
614
|
-
this.onError("xhr poll error",
|
|
615
|
-
}), this.pollXhr =
|
|
612
|
+
const e = this.request();
|
|
613
|
+
e.on("data", this.onData.bind(this)), e.on("error", (t, n) => {
|
|
614
|
+
this.onError("xhr poll error", t, n);
|
|
615
|
+
}), this.pollXhr = e;
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
618
|
class g extends _ {
|
|
@@ -622,8 +622,8 @@ class g extends _ {
|
|
|
622
622
|
* @param {Object} options
|
|
623
623
|
* @package
|
|
624
624
|
*/
|
|
625
|
-
constructor(
|
|
626
|
-
super(), this.createRequest =
|
|
625
|
+
constructor(e, t, n) {
|
|
626
|
+
super(), this.createRequest = e, L(this, n), this._opts = n, this._method = n.method || "GET", this._uri = t, this._data = n.data !== void 0 ? n.data : null, this._create();
|
|
627
627
|
}
|
|
628
628
|
/**
|
|
629
629
|
* Creates the XHR object and sends the request.
|
|
@@ -631,10 +631,10 @@ class g extends _ {
|
|
|
631
631
|
* @private
|
|
632
632
|
*/
|
|
633
633
|
_create() {
|
|
634
|
-
var
|
|
635
|
-
const
|
|
636
|
-
|
|
637
|
-
const n = this._xhr = this.createRequest(
|
|
634
|
+
var e;
|
|
635
|
+
const t = ce(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
|
|
636
|
+
t.xdomain = !!this._opts.xd;
|
|
637
|
+
const n = this._xhr = this.createRequest(t);
|
|
638
638
|
try {
|
|
639
639
|
n.open(this._method, this._uri, !0);
|
|
640
640
|
try {
|
|
@@ -654,7 +654,7 @@ class g extends _ {
|
|
|
654
654
|
n.setRequestHeader("Accept", "*/*");
|
|
655
655
|
} catch {
|
|
656
656
|
}
|
|
657
|
-
(
|
|
657
|
+
(e = this._opts.cookieJar) === null || e === void 0 || e.addCookies(n), "withCredentials" in n && (n.withCredentials = this._opts.withCredentials), this._opts.requestTimeout && (n.timeout = this._opts.requestTimeout), n.onreadystatechange = () => {
|
|
658
658
|
var r;
|
|
659
659
|
n.readyState === 3 && ((r = this._opts.cookieJar) === null || r === void 0 || r.parseCookies(
|
|
660
660
|
// @ts-ignore
|
|
@@ -676,17 +676,17 @@ class g extends _ {
|
|
|
676
676
|
*
|
|
677
677
|
* @private
|
|
678
678
|
*/
|
|
679
|
-
_onError(
|
|
680
|
-
this.emitReserved("error",
|
|
679
|
+
_onError(e) {
|
|
680
|
+
this.emitReserved("error", e, this._xhr), this._cleanup(!0);
|
|
681
681
|
}
|
|
682
682
|
/**
|
|
683
683
|
* Cleans up house.
|
|
684
684
|
*
|
|
685
685
|
* @private
|
|
686
686
|
*/
|
|
687
|
-
_cleanup(
|
|
687
|
+
_cleanup(e) {
|
|
688
688
|
if (!(typeof this._xhr > "u" || this._xhr === null)) {
|
|
689
|
-
if (this._xhr.onreadystatechange =
|
|
689
|
+
if (this._xhr.onreadystatechange = Ie, e)
|
|
690
690
|
try {
|
|
691
691
|
this._xhr.abort();
|
|
692
692
|
} catch {
|
|
@@ -700,8 +700,8 @@ class g extends _ {
|
|
|
700
700
|
* @private
|
|
701
701
|
*/
|
|
702
702
|
_onLoad() {
|
|
703
|
-
const
|
|
704
|
-
|
|
703
|
+
const e = this._xhr.responseText;
|
|
704
|
+
e !== null && (this.emitReserved("data", e), this.emitReserved("success"), this._cleanup());
|
|
705
705
|
}
|
|
706
706
|
/**
|
|
707
707
|
* Aborts the request.
|
|
@@ -726,45 +726,45 @@ function Z() {
|
|
|
726
726
|
for (let s in g.requests)
|
|
727
727
|
g.requests.hasOwnProperty(s) && g.requests[s].abort();
|
|
728
728
|
}
|
|
729
|
-
const
|
|
730
|
-
const s =
|
|
729
|
+
const De = function() {
|
|
730
|
+
const s = ue({
|
|
731
731
|
xdomain: !1
|
|
732
732
|
});
|
|
733
733
|
return s && s.responseType !== null;
|
|
734
734
|
}();
|
|
735
|
-
class
|
|
736
|
-
constructor(
|
|
737
|
-
super(
|
|
738
|
-
const
|
|
739
|
-
this.supportsBinary =
|
|
735
|
+
class Ue extends qe {
|
|
736
|
+
constructor(e) {
|
|
737
|
+
super(e);
|
|
738
|
+
const t = e && e.forceBase64;
|
|
739
|
+
this.supportsBinary = De && !t;
|
|
740
740
|
}
|
|
741
|
-
request(
|
|
742
|
-
return Object.assign(
|
|
741
|
+
request(e = {}) {
|
|
742
|
+
return Object.assign(e, { xd: this.xd }, this.opts), new g(ue, this.uri(), e);
|
|
743
743
|
}
|
|
744
744
|
}
|
|
745
|
-
function
|
|
746
|
-
const
|
|
745
|
+
function ue(s) {
|
|
746
|
+
const e = s.xdomain;
|
|
747
747
|
try {
|
|
748
|
-
if (typeof XMLHttpRequest < "u" && (!
|
|
748
|
+
if (typeof XMLHttpRequest < "u" && (!e || Ne))
|
|
749
749
|
return new XMLHttpRequest();
|
|
750
750
|
} catch {
|
|
751
751
|
}
|
|
752
|
-
if (!
|
|
752
|
+
if (!e)
|
|
753
753
|
try {
|
|
754
754
|
return new d[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
|
|
755
755
|
} catch {
|
|
756
756
|
}
|
|
757
757
|
}
|
|
758
|
-
const
|
|
759
|
-
class
|
|
758
|
+
const _e = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
|
|
759
|
+
class je extends W {
|
|
760
760
|
get name() {
|
|
761
761
|
return "websocket";
|
|
762
762
|
}
|
|
763
763
|
doOpen() {
|
|
764
|
-
const
|
|
764
|
+
const e = this.uri(), t = this.opts.protocols, n = _e ? {} : ce(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
|
|
765
765
|
this.opts.extraHeaders && (n.headers = this.opts.extraHeaders);
|
|
766
766
|
try {
|
|
767
|
-
this.ws = this.createSocket(
|
|
767
|
+
this.ws = this.createSocket(e, t, n);
|
|
768
768
|
} catch (r) {
|
|
769
769
|
return this.emitReserved("error", r);
|
|
770
770
|
}
|
|
@@ -778,15 +778,15 @@ class jt extends W {
|
|
|
778
778
|
addEventListeners() {
|
|
779
779
|
this.ws.onopen = () => {
|
|
780
780
|
this.opts.autoUnref && this.ws._socket.unref(), this.onOpen();
|
|
781
|
-
}, this.ws.onclose = (
|
|
781
|
+
}, this.ws.onclose = (e) => this.onClose({
|
|
782
782
|
description: "websocket connection closed",
|
|
783
|
-
context:
|
|
784
|
-
}), this.ws.onmessage = (
|
|
783
|
+
context: e
|
|
784
|
+
}), this.ws.onmessage = (e) => this.onData(e.data), this.ws.onerror = (e) => this.onError("websocket error", e);
|
|
785
785
|
}
|
|
786
|
-
write(
|
|
786
|
+
write(e) {
|
|
787
787
|
this.writable = !1;
|
|
788
|
-
for (let
|
|
789
|
-
const n = t
|
|
788
|
+
for (let t = 0; t < e.length; t++) {
|
|
789
|
+
const n = e[t], r = t === e.length - 1;
|
|
790
790
|
V(n, this.supportsBinary, (i) => {
|
|
791
791
|
try {
|
|
792
792
|
this.doWrite(n, i);
|
|
@@ -808,37 +808,37 @@ class jt extends W {
|
|
|
808
808
|
* @private
|
|
809
809
|
*/
|
|
810
810
|
uri() {
|
|
811
|
-
const
|
|
812
|
-
return this.opts.timestampRequests && (
|
|
811
|
+
const e = this.opts.secure ? "wss" : "ws", t = this.query || {};
|
|
812
|
+
return this.opts.timestampRequests && (t[this.opts.timestampParam] = le()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
|
|
813
813
|
}
|
|
814
814
|
}
|
|
815
815
|
const I = d.WebSocket || d.MozWebSocket;
|
|
816
|
-
class
|
|
817
|
-
createSocket(
|
|
818
|
-
return
|
|
816
|
+
class Me extends je {
|
|
817
|
+
createSocket(e, t, n) {
|
|
818
|
+
return _e ? new I(e, t, n) : t ? new I(e, t) : new I(e);
|
|
819
819
|
}
|
|
820
|
-
doWrite(
|
|
821
|
-
this.ws.send(
|
|
820
|
+
doWrite(e, t) {
|
|
821
|
+
this.ws.send(t);
|
|
822
822
|
}
|
|
823
823
|
}
|
|
824
|
-
class
|
|
824
|
+
class Fe extends W {
|
|
825
825
|
get name() {
|
|
826
826
|
return "webtransport";
|
|
827
827
|
}
|
|
828
828
|
doOpen() {
|
|
829
829
|
try {
|
|
830
830
|
this._transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]);
|
|
831
|
-
} catch (
|
|
832
|
-
return this.emitReserved("error",
|
|
831
|
+
} catch (e) {
|
|
832
|
+
return this.emitReserved("error", e);
|
|
833
833
|
}
|
|
834
834
|
this._transport.closed.then(() => {
|
|
835
835
|
this.onClose();
|
|
836
|
-
}).catch((
|
|
837
|
-
this.onError("webtransport error",
|
|
836
|
+
}).catch((e) => {
|
|
837
|
+
this.onError("webtransport error", e);
|
|
838
838
|
}), this._transport.ready.then(() => {
|
|
839
|
-
this._transport.createBidirectionalStream().then((
|
|
840
|
-
const
|
|
841
|
-
r.readable.pipeTo(
|
|
839
|
+
this._transport.createBidirectionalStream().then((e) => {
|
|
840
|
+
const t = ke(Number.MAX_SAFE_INTEGER, this.socket.binaryType), n = e.readable.pipeThrough(t).getReader(), r = ve();
|
|
841
|
+
r.readable.pipeTo(e.writable), this._writer = r.writable.getWriter();
|
|
842
842
|
const i = () => {
|
|
843
843
|
n.read().then(({ done: h, value: c }) => {
|
|
844
844
|
h || (this.onPacket(c), i());
|
|
@@ -851,10 +851,10 @@ class Ft extends W {
|
|
|
851
851
|
});
|
|
852
852
|
});
|
|
853
853
|
}
|
|
854
|
-
write(
|
|
854
|
+
write(e) {
|
|
855
855
|
this.writable = !1;
|
|
856
|
-
for (let
|
|
857
|
-
const n = t
|
|
856
|
+
for (let t = 0; t < e.length; t++) {
|
|
857
|
+
const n = e[t], r = t === e.length - 1;
|
|
858
858
|
this._writer.write(n).then(() => {
|
|
859
859
|
r && O(() => {
|
|
860
860
|
this.writable = !0, this.emitReserved("drain");
|
|
@@ -863,15 +863,15 @@ class Ft extends W {
|
|
|
863
863
|
}
|
|
864
864
|
}
|
|
865
865
|
doClose() {
|
|
866
|
-
var
|
|
867
|
-
(
|
|
866
|
+
var e;
|
|
867
|
+
(e = this._transport) === null || e === void 0 || e.close();
|
|
868
868
|
}
|
|
869
869
|
}
|
|
870
|
-
const $
|
|
871
|
-
websocket:
|
|
872
|
-
webtransport:
|
|
873
|
-
polling:
|
|
874
|
-
},
|
|
870
|
+
const $e = {
|
|
871
|
+
websocket: Me,
|
|
872
|
+
webtransport: Fe,
|
|
873
|
+
polling: Ue
|
|
874
|
+
}, Ve = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, He = [
|
|
875
875
|
"source",
|
|
876
876
|
"protocol",
|
|
877
877
|
"authority",
|
|
@@ -890,22 +890,22 @@ const $t = {
|
|
|
890
890
|
function U(s) {
|
|
891
891
|
if (s.length > 8e3)
|
|
892
892
|
throw "URI too long";
|
|
893
|
-
const
|
|
894
|
-
|
|
895
|
-
let r =
|
|
893
|
+
const e = s, t = s.indexOf("["), n = s.indexOf("]");
|
|
894
|
+
t != -1 && n != -1 && (s = s.substring(0, t) + s.substring(t, n).replace(/:/g, ";") + s.substring(n, s.length));
|
|
895
|
+
let r = Ve.exec(s || ""), i = {}, o = 14;
|
|
896
896
|
for (; o--; )
|
|
897
|
-
i[
|
|
898
|
-
return
|
|
897
|
+
i[He[o]] = r[o] || "";
|
|
898
|
+
return t != -1 && n != -1 && (i.source = e, i.host = i.host.substring(1, i.host.length - 1).replace(/;/g, ":"), i.authority = i.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), i.ipv6uri = !0), i.pathNames = We(i, i.path), i.queryKey = ze(i, i.query), i;
|
|
899
899
|
}
|
|
900
|
-
function
|
|
901
|
-
const
|
|
902
|
-
return (
|
|
900
|
+
function We(s, e) {
|
|
901
|
+
const t = /\/{2,9}/g, n = e.replace(t, "/").split("/");
|
|
902
|
+
return (e.slice(0, 1) == "/" || e.length === 0) && n.splice(0, 1), e.slice(-1) == "/" && n.splice(n.length - 1, 1), n;
|
|
903
903
|
}
|
|
904
|
-
function
|
|
905
|
-
const
|
|
906
|
-
return
|
|
907
|
-
r && (
|
|
908
|
-
}),
|
|
904
|
+
function ze(s, e) {
|
|
905
|
+
const t = {};
|
|
906
|
+
return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(n, r, i) {
|
|
907
|
+
r && (t[r] = i);
|
|
908
|
+
}), t;
|
|
909
909
|
}
|
|
910
910
|
const j = typeof addEventListener == "function" && typeof removeEventListener == "function", S = [];
|
|
911
911
|
j && addEventListener("offline", () => {
|
|
@@ -918,12 +918,12 @@ class b extends _ {
|
|
|
918
918
|
* @param {String|Object} uri - uri or options
|
|
919
919
|
* @param {Object} opts - options
|
|
920
920
|
*/
|
|
921
|
-
constructor(
|
|
922
|
-
if (super(), this.binaryType =
|
|
923
|
-
const n = U(
|
|
924
|
-
|
|
925
|
-
} else
|
|
926
|
-
L(this,
|
|
921
|
+
constructor(e, t) {
|
|
922
|
+
if (super(), this.binaryType = Ce, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = 1 / 0, e && typeof e == "object" && (t = e, e = null), e) {
|
|
923
|
+
const n = U(e);
|
|
924
|
+
t.hostname = n.host, t.secure = n.protocol === "https" || n.protocol === "wss", t.port = n.port, n.query && (t.query = n.query);
|
|
925
|
+
} else t.host && (t.hostname = U(t.host).host);
|
|
926
|
+
L(this, t), this.secure = t.secure != null ? t.secure : typeof location < "u" && location.protocol === "https:", t.hostname && !t.port && (t.port = this.secure ? "443" : "80"), this.hostname = t.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = t.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, t.transports.forEach((n) => {
|
|
927
927
|
const r = n.prototype.name;
|
|
928
928
|
this.transports.push(r), this._transportsByName[r] = n;
|
|
929
929
|
}), this.opts = Object.assign({
|
|
@@ -940,7 +940,7 @@ class b extends _ {
|
|
|
940
940
|
},
|
|
941
941
|
transportOptions: {},
|
|
942
942
|
closeOnBeforeunload: !1
|
|
943
|
-
},
|
|
943
|
+
}, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = Oe(this.opts.query)), j && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
|
|
944
944
|
this.transport && (this.transport.removeAllListeners(), this.transport.close());
|
|
945
945
|
}, addEventListener("beforeunload", this._beforeunloadEventListener, !1)), this.hostname !== "localhost" && (this._offlineEventListener = () => {
|
|
946
946
|
this._onClose("transport close", {
|
|
@@ -955,17 +955,17 @@ class b extends _ {
|
|
|
955
955
|
* @return {Transport}
|
|
956
956
|
* @private
|
|
957
957
|
*/
|
|
958
|
-
createTransport(
|
|
959
|
-
const
|
|
960
|
-
|
|
958
|
+
createTransport(e) {
|
|
959
|
+
const t = Object.assign({}, this.opts.query);
|
|
960
|
+
t.EIO = ae, t.transport = e, this.id && (t.sid = this.id);
|
|
961
961
|
const n = Object.assign({}, this.opts, {
|
|
962
|
-
query:
|
|
962
|
+
query: t,
|
|
963
963
|
socket: this,
|
|
964
964
|
hostname: this.hostname,
|
|
965
965
|
secure: this.secure,
|
|
966
966
|
port: this.port
|
|
967
|
-
}, this.opts.transportOptions[
|
|
968
|
-
return new this._transportsByName[
|
|
967
|
+
}, this.opts.transportOptions[e]);
|
|
968
|
+
return new this._transportsByName[e](n);
|
|
969
969
|
}
|
|
970
970
|
/**
|
|
971
971
|
* Initializes transport to use and starts probe.
|
|
@@ -979,18 +979,18 @@ class b extends _ {
|
|
|
979
979
|
}, 0);
|
|
980
980
|
return;
|
|
981
981
|
}
|
|
982
|
-
const
|
|
982
|
+
const e = this.opts.rememberUpgrade && b.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
|
|
983
983
|
this.readyState = "opening";
|
|
984
|
-
const
|
|
985
|
-
|
|
984
|
+
const t = this.createTransport(e);
|
|
985
|
+
t.open(), this.setTransport(t);
|
|
986
986
|
}
|
|
987
987
|
/**
|
|
988
988
|
* Sets the current transport. Disables the existing one (if any).
|
|
989
989
|
*
|
|
990
990
|
* @private
|
|
991
991
|
*/
|
|
992
|
-
setTransport(
|
|
993
|
-
this.transport && this.transport.removeAllListeners(), this.transport =
|
|
992
|
+
setTransport(e) {
|
|
993
|
+
this.transport && this.transport.removeAllListeners(), this.transport = e, e.on("drain", this._onDrain.bind(this)).on("packet", this._onPacket.bind(this)).on("error", this._onError.bind(this)).on("close", (t) => this._onClose("transport close", t));
|
|
994
994
|
}
|
|
995
995
|
/**
|
|
996
996
|
* Called when connection is deemed open.
|
|
@@ -1005,21 +1005,21 @@ class b extends _ {
|
|
|
1005
1005
|
*
|
|
1006
1006
|
* @private
|
|
1007
1007
|
*/
|
|
1008
|
-
_onPacket(
|
|
1008
|
+
_onPacket(e) {
|
|
1009
1009
|
if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing")
|
|
1010
|
-
switch (this.emitReserved("packet",
|
|
1010
|
+
switch (this.emitReserved("packet", e), this.emitReserved("heartbeat"), e.type) {
|
|
1011
1011
|
case "open":
|
|
1012
|
-
this.onHandshake(JSON.parse(
|
|
1012
|
+
this.onHandshake(JSON.parse(e.data));
|
|
1013
1013
|
break;
|
|
1014
1014
|
case "ping":
|
|
1015
1015
|
this._sendPacket("pong"), this.emitReserved("ping"), this.emitReserved("pong"), this._resetPingTimeout();
|
|
1016
1016
|
break;
|
|
1017
1017
|
case "error":
|
|
1018
|
-
const
|
|
1019
|
-
|
|
1018
|
+
const t = new Error("server error");
|
|
1019
|
+
t.code = e.data, this._onError(t);
|
|
1020
1020
|
break;
|
|
1021
1021
|
case "message":
|
|
1022
|
-
this.emitReserved("data",
|
|
1022
|
+
this.emitReserved("data", e.data), this.emitReserved("message", e.data);
|
|
1023
1023
|
break;
|
|
1024
1024
|
}
|
|
1025
1025
|
}
|
|
@@ -1029,8 +1029,8 @@ class b extends _ {
|
|
|
1029
1029
|
* @param {Object} data - handshake obj
|
|
1030
1030
|
* @private
|
|
1031
1031
|
*/
|
|
1032
|
-
onHandshake(
|
|
1033
|
-
this.emitReserved("handshake",
|
|
1032
|
+
onHandshake(e) {
|
|
1033
|
+
this.emitReserved("handshake", e), this.id = e.sid, this.transport.query.sid = e.sid, this._pingInterval = e.pingInterval, this._pingTimeout = e.pingTimeout, this._maxPayload = e.maxPayload, this.onOpen(), this.readyState !== "closed" && this._resetPingTimeout();
|
|
1034
1034
|
}
|
|
1035
1035
|
/**
|
|
1036
1036
|
* Sets and resets ping timeout timer based on server pings.
|
|
@@ -1039,10 +1039,10 @@ class b extends _ {
|
|
|
1039
1039
|
*/
|
|
1040
1040
|
_resetPingTimeout() {
|
|
1041
1041
|
this.clearTimeoutFn(this._pingTimeoutTimer);
|
|
1042
|
-
const
|
|
1043
|
-
this._pingTimeoutTime = Date.now() +
|
|
1042
|
+
const e = this._pingInterval + this._pingTimeout;
|
|
1043
|
+
this._pingTimeoutTime = Date.now() + e, this._pingTimeoutTimer = this.setTimeoutFn(() => {
|
|
1044
1044
|
this._onClose("ping timeout");
|
|
1045
|
-
},
|
|
1045
|
+
}, e), this.opts.autoUnref && this._pingTimeoutTimer.unref();
|
|
1046
1046
|
}
|
|
1047
1047
|
/**
|
|
1048
1048
|
* Called on `drain` event
|
|
@@ -1059,8 +1059,8 @@ class b extends _ {
|
|
|
1059
1059
|
*/
|
|
1060
1060
|
flush() {
|
|
1061
1061
|
if (this.readyState !== "closed" && this.transport.writable && !this.upgrading && this.writeBuffer.length) {
|
|
1062
|
-
const
|
|
1063
|
-
this.transport.send(
|
|
1062
|
+
const e = this._getWritablePackets();
|
|
1063
|
+
this.transport.send(e), this._prevBufferLen = e.length, this.emitReserved("flush");
|
|
1064
1064
|
}
|
|
1065
1065
|
}
|
|
1066
1066
|
/**
|
|
@@ -1072,12 +1072,12 @@ class b extends _ {
|
|
|
1072
1072
|
_getWritablePackets() {
|
|
1073
1073
|
if (!(this._maxPayload && this.transport.name === "polling" && this.writeBuffer.length > 1))
|
|
1074
1074
|
return this.writeBuffer;
|
|
1075
|
-
let
|
|
1076
|
-
for (let
|
|
1077
|
-
const n = this.writeBuffer[
|
|
1078
|
-
if (n && (
|
|
1079
|
-
return this.writeBuffer.slice(0,
|
|
1080
|
-
|
|
1075
|
+
let e = 1;
|
|
1076
|
+
for (let t = 0; t < this.writeBuffer.length; t++) {
|
|
1077
|
+
const n = this.writeBuffer[t].data;
|
|
1078
|
+
if (n && (e += Se(n)), t > 0 && e > this._maxPayload)
|
|
1079
|
+
return this.writeBuffer.slice(0, t);
|
|
1080
|
+
e += 2;
|
|
1081
1081
|
}
|
|
1082
1082
|
return this.writeBuffer;
|
|
1083
1083
|
}
|
|
@@ -1094,10 +1094,10 @@ class b extends _ {
|
|
|
1094
1094
|
_hasPingExpired() {
|
|
1095
1095
|
if (!this._pingTimeoutTime)
|
|
1096
1096
|
return !0;
|
|
1097
|
-
const
|
|
1098
|
-
return
|
|
1097
|
+
const e = Date.now() > this._pingTimeoutTime;
|
|
1098
|
+
return e && (this._pingTimeoutTime = 0, O(() => {
|
|
1099
1099
|
this._onClose("ping timeout");
|
|
1100
|
-
}, this.setTimeoutFn)),
|
|
1100
|
+
}, this.setTimeoutFn)), e;
|
|
1101
1101
|
}
|
|
1102
1102
|
/**
|
|
1103
1103
|
* Sends a message.
|
|
@@ -1107,8 +1107,8 @@ class b extends _ {
|
|
|
1107
1107
|
* @param {Function} fn - callback function.
|
|
1108
1108
|
* @return {Socket} for chaining.
|
|
1109
1109
|
*/
|
|
1110
|
-
write(
|
|
1111
|
-
return this._sendPacket("message",
|
|
1110
|
+
write(e, t, n) {
|
|
1111
|
+
return this._sendPacket("message", e, t, n), this;
|
|
1112
1112
|
}
|
|
1113
1113
|
/**
|
|
1114
1114
|
* Sends a message. Alias of {@link Socket#write}.
|
|
@@ -1118,8 +1118,8 @@ class b extends _ {
|
|
|
1118
1118
|
* @param {Function} fn - callback function.
|
|
1119
1119
|
* @return {Socket} for chaining.
|
|
1120
1120
|
*/
|
|
1121
|
-
send(
|
|
1122
|
-
return this._sendPacket("message",
|
|
1121
|
+
send(e, t, n) {
|
|
1122
|
+
return this._sendPacket("message", e, t, n), this;
|
|
1123
1123
|
}
|
|
1124
1124
|
/**
|
|
1125
1125
|
* Sends a packet.
|
|
@@ -1130,13 +1130,13 @@ class b extends _ {
|
|
|
1130
1130
|
* @param {Function} fn - callback function.
|
|
1131
1131
|
* @private
|
|
1132
1132
|
*/
|
|
1133
|
-
_sendPacket(
|
|
1134
|
-
if (typeof
|
|
1133
|
+
_sendPacket(e, t, n, r) {
|
|
1134
|
+
if (typeof t == "function" && (r = t, t = void 0), typeof n == "function" && (r = n, n = null), this.readyState === "closing" || this.readyState === "closed")
|
|
1135
1135
|
return;
|
|
1136
1136
|
n = n || {}, n.compress = n.compress !== !1;
|
|
1137
1137
|
const i = {
|
|
1138
|
-
type:
|
|
1139
|
-
data:
|
|
1138
|
+
type: e,
|
|
1139
|
+
data: t,
|
|
1140
1140
|
options: n
|
|
1141
1141
|
};
|
|
1142
1142
|
this.emitReserved("packetCreate", i), this.writeBuffer.push(i), r && this.once("flush", r), this.flush();
|
|
@@ -1145,51 +1145,51 @@ class b extends _ {
|
|
|
1145
1145
|
* Closes the connection.
|
|
1146
1146
|
*/
|
|
1147
1147
|
close() {
|
|
1148
|
-
const
|
|
1148
|
+
const e = () => {
|
|
1149
1149
|
this._onClose("forced close"), this.transport.close();
|
|
1150
|
-
},
|
|
1151
|
-
this.off("upgrade",
|
|
1150
|
+
}, t = () => {
|
|
1151
|
+
this.off("upgrade", t), this.off("upgradeError", t), e();
|
|
1152
1152
|
}, n = () => {
|
|
1153
|
-
this.once("upgrade",
|
|
1153
|
+
this.once("upgrade", t), this.once("upgradeError", t);
|
|
1154
1154
|
};
|
|
1155
1155
|
return (this.readyState === "opening" || this.readyState === "open") && (this.readyState = "closing", this.writeBuffer.length ? this.once("drain", () => {
|
|
1156
|
-
this.upgrading ? n() :
|
|
1157
|
-
}) : this.upgrading ? n() :
|
|
1156
|
+
this.upgrading ? n() : e();
|
|
1157
|
+
}) : this.upgrading ? n() : e()), this;
|
|
1158
1158
|
}
|
|
1159
1159
|
/**
|
|
1160
1160
|
* Called upon transport error
|
|
1161
1161
|
*
|
|
1162
1162
|
* @private
|
|
1163
1163
|
*/
|
|
1164
|
-
_onError(
|
|
1164
|
+
_onError(e) {
|
|
1165
1165
|
if (b.priorWebsocketSuccess = !1, this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening")
|
|
1166
1166
|
return this.transports.shift(), this._open();
|
|
1167
|
-
this.emitReserved("error",
|
|
1167
|
+
this.emitReserved("error", e), this._onClose("transport error", e);
|
|
1168
1168
|
}
|
|
1169
1169
|
/**
|
|
1170
1170
|
* Called upon transport close.
|
|
1171
1171
|
*
|
|
1172
1172
|
* @private
|
|
1173
1173
|
*/
|
|
1174
|
-
_onClose(
|
|
1174
|
+
_onClose(e, t) {
|
|
1175
1175
|
if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") {
|
|
1176
1176
|
if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), j && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
|
|
1177
1177
|
const n = S.indexOf(this._offlineEventListener);
|
|
1178
1178
|
n !== -1 && S.splice(n, 1);
|
|
1179
1179
|
}
|
|
1180
|
-
this.readyState = "closed", this.id = null, this.emitReserved("close",
|
|
1180
|
+
this.readyState = "closed", this.id = null, this.emitReserved("close", e, t), this.writeBuffer = [], this._prevBufferLen = 0;
|
|
1181
1181
|
}
|
|
1182
1182
|
}
|
|
1183
1183
|
}
|
|
1184
|
-
b.protocol =
|
|
1185
|
-
class
|
|
1184
|
+
b.protocol = ae;
|
|
1185
|
+
class Ke extends b {
|
|
1186
1186
|
constructor() {
|
|
1187
1187
|
super(...arguments), this._upgrades = [];
|
|
1188
1188
|
}
|
|
1189
1189
|
onOpen() {
|
|
1190
1190
|
if (super.onOpen(), this.readyState === "open" && this.opts.upgrade)
|
|
1191
|
-
for (let
|
|
1192
|
-
this._probe(this._upgrades[
|
|
1191
|
+
for (let e = 0; e < this._upgrades.length; e++)
|
|
1192
|
+
this._probe(this._upgrades[e]);
|
|
1193
1193
|
}
|
|
1194
1194
|
/**
|
|
1195
1195
|
* Probes a transport.
|
|
@@ -1197,30 +1197,30 @@ class Kt extends b {
|
|
|
1197
1197
|
* @param {String} name - transport name
|
|
1198
1198
|
* @private
|
|
1199
1199
|
*/
|
|
1200
|
-
_probe(
|
|
1201
|
-
let
|
|
1200
|
+
_probe(e) {
|
|
1201
|
+
let t = this.createTransport(e), n = !1;
|
|
1202
1202
|
b.priorWebsocketSuccess = !1;
|
|
1203
1203
|
const r = () => {
|
|
1204
|
-
n || (
|
|
1204
|
+
n || (t.send([{ type: "ping", data: "probe" }]), t.once("packet", (y) => {
|
|
1205
1205
|
if (!n)
|
|
1206
1206
|
if (y.type === "pong" && y.data === "probe") {
|
|
1207
|
-
if (this.upgrading = !0, this.emitReserved("upgrading",
|
|
1207
|
+
if (this.upgrading = !0, this.emitReserved("upgrading", t), !t)
|
|
1208
1208
|
return;
|
|
1209
|
-
b.priorWebsocketSuccess =
|
|
1210
|
-
n || this.readyState !== "closed" && (u(), this.setTransport(
|
|
1209
|
+
b.priorWebsocketSuccess = t.name === "websocket", this.transport.pause(() => {
|
|
1210
|
+
n || this.readyState !== "closed" && (u(), this.setTransport(t), t.send([{ type: "upgrade" }]), this.emitReserved("upgrade", t), t = null, this.upgrading = !1, this.flush());
|
|
1211
1211
|
});
|
|
1212
1212
|
} else {
|
|
1213
1213
|
const v = new Error("probe error");
|
|
1214
|
-
v.transport =
|
|
1214
|
+
v.transport = t.name, this.emitReserved("upgradeError", v);
|
|
1215
1215
|
}
|
|
1216
1216
|
}));
|
|
1217
1217
|
};
|
|
1218
1218
|
function i() {
|
|
1219
|
-
n || (n = !0, u(),
|
|
1219
|
+
n || (n = !0, u(), t.close(), t = null);
|
|
1220
1220
|
}
|
|
1221
1221
|
const o = (y) => {
|
|
1222
1222
|
const v = new Error("probe error: " + y);
|
|
1223
|
-
v.transport =
|
|
1223
|
+
v.transport = t.name, i(), this.emitReserved("upgradeError", v);
|
|
1224
1224
|
};
|
|
1225
1225
|
function h() {
|
|
1226
1226
|
o("transport closed");
|
|
@@ -1229,17 +1229,17 @@ class Kt extends b {
|
|
|
1229
1229
|
o("socket closed");
|
|
1230
1230
|
}
|
|
1231
1231
|
function p(y) {
|
|
1232
|
-
|
|
1232
|
+
t && y.name !== t.name && i();
|
|
1233
1233
|
}
|
|
1234
1234
|
const u = () => {
|
|
1235
|
-
|
|
1235
|
+
t.removeListener("open", r), t.removeListener("error", o), t.removeListener("close", h), this.off("close", c), this.off("upgrading", p);
|
|
1236
1236
|
};
|
|
1237
|
-
|
|
1238
|
-
n ||
|
|
1239
|
-
}, 200) :
|
|
1237
|
+
t.once("open", r), t.once("error", o), t.once("close", h), this.once("close", c), this.once("upgrading", p), this._upgrades.indexOf("webtransport") !== -1 && e !== "webtransport" ? this.setTimeoutFn(() => {
|
|
1238
|
+
n || t.open();
|
|
1239
|
+
}, 200) : t.open();
|
|
1240
1240
|
}
|
|
1241
|
-
onHandshake(
|
|
1242
|
-
this._upgrades = this._filterUpgrades(
|
|
1241
|
+
onHandshake(e) {
|
|
1242
|
+
this._upgrades = this._filterUpgrades(e.upgrades), super.onHandshake(e);
|
|
1243
1243
|
}
|
|
1244
1244
|
/**
|
|
1245
1245
|
* Filters upgrades, returning only those matching client transports.
|
|
@@ -1247,35 +1247,35 @@ class Kt extends b {
|
|
|
1247
1247
|
* @param {Array} upgrades - server upgrades
|
|
1248
1248
|
* @private
|
|
1249
1249
|
*/
|
|
1250
|
-
_filterUpgrades(
|
|
1251
|
-
const
|
|
1252
|
-
for (let n = 0; n <
|
|
1253
|
-
~this.transports.indexOf(
|
|
1254
|
-
return
|
|
1250
|
+
_filterUpgrades(e) {
|
|
1251
|
+
const t = [];
|
|
1252
|
+
for (let n = 0; n < e.length; n++)
|
|
1253
|
+
~this.transports.indexOf(e[n]) && t.push(e[n]);
|
|
1254
|
+
return t;
|
|
1255
1255
|
}
|
|
1256
1256
|
}
|
|
1257
|
-
let
|
|
1258
|
-
constructor(s,
|
|
1259
|
-
const
|
|
1260
|
-
(!
|
|
1257
|
+
let Ye = class extends Ke {
|
|
1258
|
+
constructor(s, e = {}) {
|
|
1259
|
+
const t = typeof s == "object" ? s : e;
|
|
1260
|
+
(!t.transports || t.transports && typeof t.transports[0] == "string") && (t.transports = (t.transports || ["polling", "websocket", "webtransport"]).map((n) => $e[n]).filter((n) => !!n)), super(s, t);
|
|
1261
1261
|
}
|
|
1262
1262
|
};
|
|
1263
|
-
function
|
|
1263
|
+
function Je(s, e = "", t) {
|
|
1264
1264
|
let n = s;
|
|
1265
|
-
|
|
1265
|
+
t = t || typeof location < "u" && location, s == null && (s = t.protocol + "//" + t.host), typeof s == "string" && (s.charAt(0) === "/" && (s.charAt(1) === "/" ? s = t.protocol + s : s = t.host + s), /^(https?|wss?):\/\//.test(s) || (typeof t < "u" ? s = t.protocol + "//" + s : s = "https://" + s), n = U(s)), n.port || (/^(http|ws)$/.test(n.protocol) ? n.port = "80" : /^(http|ws)s$/.test(n.protocol) && (n.port = "443")), n.path = n.path || "/";
|
|
1266
1266
|
const r = n.host.indexOf(":") !== -1 ? "[" + n.host + "]" : n.host;
|
|
1267
|
-
return n.id = n.protocol + "://" + r + ":" + n.port +
|
|
1267
|
+
return n.id = n.protocol + "://" + r + ":" + n.port + e, n.href = n.protocol + "://" + r + (t && t.port === n.port ? "" : ":" + n.port), n;
|
|
1268
1268
|
}
|
|
1269
|
-
const
|
|
1269
|
+
const Qe = typeof ArrayBuffer == "function", Xe = (s) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(s) : s.buffer instanceof ArrayBuffer, pe = Object.prototype.toString, Ge = typeof Blob == "function" || typeof Blob < "u" && pe.call(Blob) === "[object BlobConstructor]", Ze = typeof File == "function" || typeof File < "u" && pe.call(File) === "[object FileConstructor]";
|
|
1270
1270
|
function z(s) {
|
|
1271
|
-
return
|
|
1271
|
+
return Qe && (s instanceof ArrayBuffer || Xe(s)) || Ge && s instanceof Blob || Ze && s instanceof File;
|
|
1272
1272
|
}
|
|
1273
|
-
function R(s,
|
|
1273
|
+
function R(s, e) {
|
|
1274
1274
|
if (!s || typeof s != "object")
|
|
1275
1275
|
return !1;
|
|
1276
1276
|
if (Array.isArray(s)) {
|
|
1277
|
-
for (let
|
|
1278
|
-
if (R(s[
|
|
1277
|
+
for (let t = 0, n = s.length; t < n; t++)
|
|
1278
|
+
if (R(s[t]))
|
|
1279
1279
|
return !0;
|
|
1280
1280
|
return !1;
|
|
1281
1281
|
}
|
|
@@ -1283,53 +1283,53 @@ function R(s, t) {
|
|
|
1283
1283
|
return !0;
|
|
1284
1284
|
if (s.toJSON && typeof s.toJSON == "function" && arguments.length === 1)
|
|
1285
1285
|
return R(s.toJSON(), !0);
|
|
1286
|
-
for (const
|
|
1287
|
-
if (Object.prototype.hasOwnProperty.call(s,
|
|
1286
|
+
for (const t in s)
|
|
1287
|
+
if (Object.prototype.hasOwnProperty.call(s, t) && R(s[t]))
|
|
1288
1288
|
return !0;
|
|
1289
1289
|
return !1;
|
|
1290
1290
|
}
|
|
1291
|
-
function
|
|
1292
|
-
const
|
|
1293
|
-
return n.data = M(
|
|
1291
|
+
function et(s) {
|
|
1292
|
+
const e = [], t = s.data, n = s;
|
|
1293
|
+
return n.data = M(t, e), n.attachments = e.length, { packet: n, buffers: e };
|
|
1294
1294
|
}
|
|
1295
|
-
function M(s,
|
|
1295
|
+
function M(s, e) {
|
|
1296
1296
|
if (!s)
|
|
1297
1297
|
return s;
|
|
1298
1298
|
if (z(s)) {
|
|
1299
|
-
const
|
|
1300
|
-
return
|
|
1299
|
+
const t = { _placeholder: !0, num: e.length };
|
|
1300
|
+
return e.push(s), t;
|
|
1301
1301
|
} else if (Array.isArray(s)) {
|
|
1302
|
-
const
|
|
1302
|
+
const t = new Array(s.length);
|
|
1303
1303
|
for (let n = 0; n < s.length; n++)
|
|
1304
|
-
|
|
1305
|
-
return
|
|
1304
|
+
t[n] = M(s[n], e);
|
|
1305
|
+
return t;
|
|
1306
1306
|
} else if (typeof s == "object" && !(s instanceof Date)) {
|
|
1307
|
-
const
|
|
1307
|
+
const t = {};
|
|
1308
1308
|
for (const n in s)
|
|
1309
|
-
Object.prototype.hasOwnProperty.call(s, n) && (
|
|
1310
|
-
return
|
|
1309
|
+
Object.prototype.hasOwnProperty.call(s, n) && (t[n] = M(s[n], e));
|
|
1310
|
+
return t;
|
|
1311
1311
|
}
|
|
1312
1312
|
return s;
|
|
1313
1313
|
}
|
|
1314
|
-
function
|
|
1315
|
-
return s.data = F(s.data,
|
|
1314
|
+
function tt(s, e) {
|
|
1315
|
+
return s.data = F(s.data, e), delete s.attachments, s;
|
|
1316
1316
|
}
|
|
1317
|
-
function F(s,
|
|
1317
|
+
function F(s, e) {
|
|
1318
1318
|
if (!s)
|
|
1319
1319
|
return s;
|
|
1320
1320
|
if (s && s._placeholder === !0) {
|
|
1321
|
-
if (typeof s.num == "number" && s.num >= 0 && s.num <
|
|
1322
|
-
return
|
|
1321
|
+
if (typeof s.num == "number" && s.num >= 0 && s.num < e.length)
|
|
1322
|
+
return e[s.num];
|
|
1323
1323
|
throw new Error("illegal attachments");
|
|
1324
1324
|
} else if (Array.isArray(s))
|
|
1325
|
-
for (let
|
|
1326
|
-
s[
|
|
1325
|
+
for (let t = 0; t < s.length; t++)
|
|
1326
|
+
s[t] = F(s[t], e);
|
|
1327
1327
|
else if (typeof s == "object")
|
|
1328
|
-
for (const
|
|
1329
|
-
Object.prototype.hasOwnProperty.call(s,
|
|
1328
|
+
for (const t in s)
|
|
1329
|
+
Object.prototype.hasOwnProperty.call(s, t) && (s[t] = F(s[t], e));
|
|
1330
1330
|
return s;
|
|
1331
1331
|
}
|
|
1332
|
-
const
|
|
1332
|
+
const st = [
|
|
1333
1333
|
"connect",
|
|
1334
1334
|
"connect_error",
|
|
1335
1335
|
"disconnect",
|
|
@@ -1337,19 +1337,19 @@ const se = [
|
|
|
1337
1337
|
"newListener",
|
|
1338
1338
|
"removeListener"
|
|
1339
1339
|
// used by the Node.js EventEmitter
|
|
1340
|
-
],
|
|
1340
|
+
], nt = 5;
|
|
1341
1341
|
var l;
|
|
1342
1342
|
(function(s) {
|
|
1343
1343
|
s[s.CONNECT = 0] = "CONNECT", s[s.DISCONNECT = 1] = "DISCONNECT", s[s.EVENT = 2] = "EVENT", s[s.ACK = 3] = "ACK", s[s.CONNECT_ERROR = 4] = "CONNECT_ERROR", s[s.BINARY_EVENT = 5] = "BINARY_EVENT", s[s.BINARY_ACK = 6] = "BINARY_ACK";
|
|
1344
1344
|
})(l || (l = {}));
|
|
1345
|
-
class
|
|
1345
|
+
class rt {
|
|
1346
1346
|
/**
|
|
1347
1347
|
* Encoder constructor
|
|
1348
1348
|
*
|
|
1349
1349
|
* @param {function} replacer - custom replacer to pass down to JSON.parse
|
|
1350
1350
|
*/
|
|
1351
|
-
constructor(
|
|
1352
|
-
this.replacer =
|
|
1351
|
+
constructor(e) {
|
|
1352
|
+
this.replacer = e;
|
|
1353
1353
|
}
|
|
1354
1354
|
/**
|
|
1355
1355
|
* Encode a packet as a single string if non-binary, or as a
|
|
@@ -1357,32 +1357,32 @@ class re {
|
|
|
1357
1357
|
*
|
|
1358
1358
|
* @param {Object} obj - packet object
|
|
1359
1359
|
*/
|
|
1360
|
-
encode(
|
|
1361
|
-
return (
|
|
1362
|
-
type:
|
|
1363
|
-
nsp:
|
|
1364
|
-
data:
|
|
1365
|
-
id:
|
|
1366
|
-
}) : [this.encodeAsString(
|
|
1360
|
+
encode(e) {
|
|
1361
|
+
return (e.type === l.EVENT || e.type === l.ACK) && R(e) ? this.encodeAsBinary({
|
|
1362
|
+
type: e.type === l.EVENT ? l.BINARY_EVENT : l.BINARY_ACK,
|
|
1363
|
+
nsp: e.nsp,
|
|
1364
|
+
data: e.data,
|
|
1365
|
+
id: e.id
|
|
1366
|
+
}) : [this.encodeAsString(e)];
|
|
1367
1367
|
}
|
|
1368
1368
|
/**
|
|
1369
1369
|
* Encode packet as string.
|
|
1370
1370
|
*/
|
|
1371
|
-
encodeAsString(
|
|
1372
|
-
let
|
|
1373
|
-
return (
|
|
1371
|
+
encodeAsString(e) {
|
|
1372
|
+
let t = "" + e.type;
|
|
1373
|
+
return (e.type === l.BINARY_EVENT || e.type === l.BINARY_ACK) && (t += e.attachments + "-"), e.nsp && e.nsp !== "/" && (t += e.nsp + ","), e.id != null && (t += e.id), e.data != null && (t += JSON.stringify(e.data, this.replacer)), t;
|
|
1374
1374
|
}
|
|
1375
1375
|
/**
|
|
1376
1376
|
* Encode packet as 'buffer sequence' by removing blobs, and
|
|
1377
1377
|
* deconstructing packet into object with placeholders and
|
|
1378
1378
|
* a list of buffers.
|
|
1379
1379
|
*/
|
|
1380
|
-
encodeAsBinary(
|
|
1381
|
-
const
|
|
1380
|
+
encodeAsBinary(e) {
|
|
1381
|
+
const t = et(e), n = this.encodeAsString(t.packet), r = t.buffers;
|
|
1382
1382
|
return r.unshift(n), r;
|
|
1383
1383
|
}
|
|
1384
1384
|
}
|
|
1385
|
-
function
|
|
1385
|
+
function ee(s) {
|
|
1386
1386
|
return Object.prototype.toString.call(s) === "[object Object]";
|
|
1387
1387
|
}
|
|
1388
1388
|
class K extends _ {
|
|
@@ -1391,29 +1391,29 @@ class K extends _ {
|
|
|
1391
1391
|
*
|
|
1392
1392
|
* @param {function} reviver - custom reviver to pass down to JSON.stringify
|
|
1393
1393
|
*/
|
|
1394
|
-
constructor(
|
|
1395
|
-
super(), this.reviver =
|
|
1394
|
+
constructor(e) {
|
|
1395
|
+
super(), this.reviver = e;
|
|
1396
1396
|
}
|
|
1397
1397
|
/**
|
|
1398
1398
|
* Decodes an encoded packet string into packet JSON.
|
|
1399
1399
|
*
|
|
1400
1400
|
* @param {String} obj - encoded packet
|
|
1401
1401
|
*/
|
|
1402
|
-
add(
|
|
1403
|
-
let
|
|
1404
|
-
if (typeof
|
|
1402
|
+
add(e) {
|
|
1403
|
+
let t;
|
|
1404
|
+
if (typeof e == "string") {
|
|
1405
1405
|
if (this.reconstructor)
|
|
1406
1406
|
throw new Error("got plaintext data when reconstructing a packet");
|
|
1407
|
-
|
|
1408
|
-
const n =
|
|
1409
|
-
n ||
|
|
1410
|
-
} else if (z(
|
|
1407
|
+
t = this.decodeString(e);
|
|
1408
|
+
const n = t.type === l.BINARY_EVENT;
|
|
1409
|
+
n || t.type === l.BINARY_ACK ? (t.type = n ? l.EVENT : l.ACK, this.reconstructor = new it(t), t.attachments === 0 && super.emitReserved("decoded", t)) : super.emitReserved("decoded", t);
|
|
1410
|
+
} else if (z(e) || e.base64)
|
|
1411
1411
|
if (this.reconstructor)
|
|
1412
|
-
|
|
1412
|
+
t = this.reconstructor.takeBinaryData(e), t && (this.reconstructor = null, super.emitReserved("decoded", t));
|
|
1413
1413
|
else
|
|
1414
1414
|
throw new Error("got binary data when not reconstructing a packet");
|
|
1415
1415
|
else
|
|
1416
|
-
throw new Error("Unknown type: " +
|
|
1416
|
+
throw new Error("Unknown type: " + e);
|
|
1417
1417
|
}
|
|
1418
1418
|
/**
|
|
1419
1419
|
* Decode a packet String (JSON data)
|
|
@@ -1421,45 +1421,45 @@ class K extends _ {
|
|
|
1421
1421
|
* @param {String} str
|
|
1422
1422
|
* @return {Object} packet
|
|
1423
1423
|
*/
|
|
1424
|
-
decodeString(
|
|
1425
|
-
let
|
|
1424
|
+
decodeString(e) {
|
|
1425
|
+
let t = 0;
|
|
1426
1426
|
const n = {
|
|
1427
|
-
type: Number(
|
|
1427
|
+
type: Number(e.charAt(0))
|
|
1428
1428
|
};
|
|
1429
1429
|
if (l[n.type] === void 0)
|
|
1430
1430
|
throw new Error("unknown packet type " + n.type);
|
|
1431
1431
|
if (n.type === l.BINARY_EVENT || n.type === l.BINARY_ACK) {
|
|
1432
|
-
const i =
|
|
1433
|
-
for (;
|
|
1432
|
+
const i = t + 1;
|
|
1433
|
+
for (; e.charAt(++t) !== "-" && t != e.length; )
|
|
1434
1434
|
;
|
|
1435
|
-
const o =
|
|
1436
|
-
if (o != Number(o) ||
|
|
1435
|
+
const o = e.substring(i, t);
|
|
1436
|
+
if (o != Number(o) || e.charAt(t) !== "-")
|
|
1437
1437
|
throw new Error("Illegal attachments");
|
|
1438
1438
|
n.attachments = Number(o);
|
|
1439
1439
|
}
|
|
1440
|
-
if (
|
|
1441
|
-
const i =
|
|
1442
|
-
for (; ++
|
|
1440
|
+
if (e.charAt(t + 1) === "/") {
|
|
1441
|
+
const i = t + 1;
|
|
1442
|
+
for (; ++t && !(e.charAt(t) === "," || t === e.length); )
|
|
1443
1443
|
;
|
|
1444
|
-
n.nsp =
|
|
1444
|
+
n.nsp = e.substring(i, t);
|
|
1445
1445
|
} else
|
|
1446
1446
|
n.nsp = "/";
|
|
1447
|
-
const r =
|
|
1447
|
+
const r = e.charAt(t + 1);
|
|
1448
1448
|
if (r !== "" && Number(r) == r) {
|
|
1449
|
-
const i =
|
|
1450
|
-
for (; ++
|
|
1451
|
-
const o =
|
|
1449
|
+
const i = t + 1;
|
|
1450
|
+
for (; ++t; ) {
|
|
1451
|
+
const o = e.charAt(t);
|
|
1452
1452
|
if (o == null || Number(o) != o) {
|
|
1453
|
-
--
|
|
1453
|
+
--t;
|
|
1454
1454
|
break;
|
|
1455
1455
|
}
|
|
1456
|
-
if (
|
|
1456
|
+
if (t === e.length)
|
|
1457
1457
|
break;
|
|
1458
1458
|
}
|
|
1459
|
-
n.id = Number(
|
|
1459
|
+
n.id = Number(e.substring(i, t + 1));
|
|
1460
1460
|
}
|
|
1461
|
-
if (
|
|
1462
|
-
const i = this.tryParse(
|
|
1461
|
+
if (e.charAt(++t)) {
|
|
1462
|
+
const i = this.tryParse(e.substr(t));
|
|
1463
1463
|
if (K.isPayloadValid(n.type, i))
|
|
1464
1464
|
n.data = i;
|
|
1465
1465
|
else
|
|
@@ -1467,27 +1467,27 @@ class K extends _ {
|
|
|
1467
1467
|
}
|
|
1468
1468
|
return n;
|
|
1469
1469
|
}
|
|
1470
|
-
tryParse(
|
|
1470
|
+
tryParse(e) {
|
|
1471
1471
|
try {
|
|
1472
|
-
return JSON.parse(
|
|
1472
|
+
return JSON.parse(e, this.reviver);
|
|
1473
1473
|
} catch {
|
|
1474
1474
|
return !1;
|
|
1475
1475
|
}
|
|
1476
1476
|
}
|
|
1477
|
-
static isPayloadValid(
|
|
1478
|
-
switch (
|
|
1477
|
+
static isPayloadValid(e, t) {
|
|
1478
|
+
switch (e) {
|
|
1479
1479
|
case l.CONNECT:
|
|
1480
|
-
return
|
|
1480
|
+
return ee(t);
|
|
1481
1481
|
case l.DISCONNECT:
|
|
1482
|
-
return
|
|
1482
|
+
return t === void 0;
|
|
1483
1483
|
case l.CONNECT_ERROR:
|
|
1484
|
-
return typeof
|
|
1484
|
+
return typeof t == "string" || ee(t);
|
|
1485
1485
|
case l.EVENT:
|
|
1486
1486
|
case l.BINARY_EVENT:
|
|
1487
|
-
return Array.isArray(
|
|
1487
|
+
return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && st.indexOf(t[0]) === -1);
|
|
1488
1488
|
case l.ACK:
|
|
1489
1489
|
case l.BINARY_ACK:
|
|
1490
|
-
return Array.isArray(
|
|
1490
|
+
return Array.isArray(t);
|
|
1491
1491
|
}
|
|
1492
1492
|
}
|
|
1493
1493
|
/**
|
|
@@ -1497,9 +1497,9 @@ class K extends _ {
|
|
|
1497
1497
|
this.reconstructor && (this.reconstructor.finishedReconstruction(), this.reconstructor = null);
|
|
1498
1498
|
}
|
|
1499
1499
|
}
|
|
1500
|
-
class
|
|
1501
|
-
constructor(
|
|
1502
|
-
this.packet =
|
|
1500
|
+
class it {
|
|
1501
|
+
constructor(e) {
|
|
1502
|
+
this.packet = e, this.buffers = [], this.reconPack = e;
|
|
1503
1503
|
}
|
|
1504
1504
|
/**
|
|
1505
1505
|
* Method to be called when binary data received from connection
|
|
@@ -1509,10 +1509,10 @@ class ie {
|
|
|
1509
1509
|
* @return {null | Object} returns null if more binary data is expected or
|
|
1510
1510
|
* a reconstructed packet object if all buffers have been received.
|
|
1511
1511
|
*/
|
|
1512
|
-
takeBinaryData(
|
|
1513
|
-
if (this.buffers.push(
|
|
1514
|
-
const
|
|
1515
|
-
return this.finishedReconstruction(),
|
|
1512
|
+
takeBinaryData(e) {
|
|
1513
|
+
if (this.buffers.push(e), this.buffers.length === this.reconPack.attachments) {
|
|
1514
|
+
const t = tt(this.reconPack, this.buffers);
|
|
1515
|
+
return this.finishedReconstruction(), t;
|
|
1516
1516
|
}
|
|
1517
1517
|
return null;
|
|
1518
1518
|
}
|
|
@@ -1523,21 +1523,21 @@ class ie {
|
|
|
1523
1523
|
this.reconPack = null, this.buffers = [];
|
|
1524
1524
|
}
|
|
1525
1525
|
}
|
|
1526
|
-
const
|
|
1526
|
+
const ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1527
1527
|
__proto__: null,
|
|
1528
1528
|
Decoder: K,
|
|
1529
|
-
Encoder:
|
|
1529
|
+
Encoder: rt,
|
|
1530
1530
|
get PacketType() {
|
|
1531
1531
|
return l;
|
|
1532
1532
|
},
|
|
1533
|
-
protocol:
|
|
1533
|
+
protocol: nt
|
|
1534
1534
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1535
|
-
function f(s,
|
|
1536
|
-
return s.on(
|
|
1537
|
-
s.off(
|
|
1535
|
+
function f(s, e, t) {
|
|
1536
|
+
return s.on(e, t), function() {
|
|
1537
|
+
s.off(e, t);
|
|
1538
1538
|
};
|
|
1539
1539
|
}
|
|
1540
|
-
const
|
|
1540
|
+
const at = Object.freeze({
|
|
1541
1541
|
connect: 1,
|
|
1542
1542
|
connect_error: 1,
|
|
1543
1543
|
disconnect: 1,
|
|
@@ -1546,12 +1546,12 @@ const ae = Object.freeze({
|
|
|
1546
1546
|
newListener: 1,
|
|
1547
1547
|
removeListener: 1
|
|
1548
1548
|
});
|
|
1549
|
-
let
|
|
1549
|
+
let de = class extends _ {
|
|
1550
1550
|
/**
|
|
1551
1551
|
* `Socket` constructor.
|
|
1552
1552
|
*/
|
|
1553
|
-
constructor(s,
|
|
1554
|
-
super(), this.connected = !1, this.recovered = !1, this.receiveBuffer = [], this.sendBuffer = [], this._queue = [], this._queueSeq = 0, this.ids = 0, this.acks = {}, this.flags = {}, this.io = s, this.nsp =
|
|
1553
|
+
constructor(s, e, t) {
|
|
1554
|
+
super(), this.connected = !1, this.recovered = !1, this.receiveBuffer = [], this.sendBuffer = [], this._queue = [], this._queueSeq = 0, this.ids = 0, this.acks = {}, this.flags = {}, this.io = s, this.nsp = e, t && t.auth && (this.auth = t.auth), this._opts = Object.assign({}, t), this.io._autoConnect && this.open();
|
|
1555
1555
|
}
|
|
1556
1556
|
/**
|
|
1557
1557
|
* Whether the socket is currently disconnected
|
|
@@ -1660,40 +1660,40 @@ let dt = class extends _ {
|
|
|
1660
1660
|
*
|
|
1661
1661
|
* @return self
|
|
1662
1662
|
*/
|
|
1663
|
-
emit(s, ...
|
|
1664
|
-
var
|
|
1665
|
-
if (
|
|
1663
|
+
emit(s, ...e) {
|
|
1664
|
+
var t, n, r;
|
|
1665
|
+
if (at.hasOwnProperty(s))
|
|
1666
1666
|
throw new Error('"' + s.toString() + '" is a reserved event name');
|
|
1667
|
-
if (
|
|
1668
|
-
return this._addToQueue(
|
|
1667
|
+
if (e.unshift(s), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
|
|
1668
|
+
return this._addToQueue(e), this;
|
|
1669
1669
|
const i = {
|
|
1670
1670
|
type: l.EVENT,
|
|
1671
|
-
data:
|
|
1671
|
+
data: e
|
|
1672
1672
|
};
|
|
1673
|
-
if (i.options = {}, i.options.compress = this.flags.compress !== !1, typeof
|
|
1674
|
-
const c = this.ids++, p =
|
|
1673
|
+
if (i.options = {}, i.options.compress = this.flags.compress !== !1, typeof e[e.length - 1] == "function") {
|
|
1674
|
+
const c = this.ids++, p = e.pop();
|
|
1675
1675
|
this._registerAckCallback(c, p), i.id = c;
|
|
1676
1676
|
}
|
|
1677
|
-
const o = (n = (
|
|
1677
|
+
const o = (n = (t = this.io.engine) === null || t === void 0 ? void 0 : t.transport) === null || n === void 0 ? void 0 : n.writable, h = this.connected && !(!((r = this.io.engine) === null || r === void 0) && r._hasPingExpired());
|
|
1678
1678
|
return this.flags.volatile && !o || (h ? (this.notifyOutgoingListeners(i), this.packet(i)) : this.sendBuffer.push(i)), this.flags = {}, this;
|
|
1679
1679
|
}
|
|
1680
1680
|
/**
|
|
1681
1681
|
* @private
|
|
1682
1682
|
*/
|
|
1683
|
-
_registerAckCallback(s,
|
|
1684
|
-
var
|
|
1685
|
-
const n = (
|
|
1683
|
+
_registerAckCallback(s, e) {
|
|
1684
|
+
var t;
|
|
1685
|
+
const n = (t = this.flags.timeout) !== null && t !== void 0 ? t : this._opts.ackTimeout;
|
|
1686
1686
|
if (n === void 0) {
|
|
1687
|
-
this.acks[s] =
|
|
1687
|
+
this.acks[s] = e;
|
|
1688
1688
|
return;
|
|
1689
1689
|
}
|
|
1690
1690
|
const r = this.io.setTimeoutFn(() => {
|
|
1691
1691
|
delete this.acks[s];
|
|
1692
1692
|
for (let o = 0; o < this.sendBuffer.length; o++)
|
|
1693
1693
|
this.sendBuffer[o].id === s && this.sendBuffer.splice(o, 1);
|
|
1694
|
-
|
|
1694
|
+
e.call(this, new Error("operation has timed out"));
|
|
1695
1695
|
}, n), i = (...o) => {
|
|
1696
|
-
this.io.clearTimeoutFn(r),
|
|
1696
|
+
this.io.clearTimeoutFn(r), e.apply(this, o);
|
|
1697
1697
|
};
|
|
1698
1698
|
i.withError = !0, this.acks[s] = i;
|
|
1699
1699
|
}
|
|
@@ -1713,10 +1713,10 @@ let dt = class extends _ {
|
|
|
1713
1713
|
*
|
|
1714
1714
|
* @return a Promise that will be fulfilled when the server acknowledges the event
|
|
1715
1715
|
*/
|
|
1716
|
-
emitWithAck(s, ...
|
|
1717
|
-
return new Promise((
|
|
1718
|
-
const r = (i, o) => i ? n(i) :
|
|
1719
|
-
r.withError = !0,
|
|
1716
|
+
emitWithAck(s, ...e) {
|
|
1717
|
+
return new Promise((t, n) => {
|
|
1718
|
+
const r = (i, o) => i ? n(i) : t(o);
|
|
1719
|
+
r.withError = !0, e.push(r), this.emit(s, ...e);
|
|
1720
1720
|
});
|
|
1721
1721
|
}
|
|
1722
1722
|
/**
|
|
@@ -1725,16 +1725,16 @@ let dt = class extends _ {
|
|
|
1725
1725
|
* @private
|
|
1726
1726
|
*/
|
|
1727
1727
|
_addToQueue(s) {
|
|
1728
|
-
let
|
|
1729
|
-
typeof s[s.length - 1] == "function" && (
|
|
1730
|
-
const
|
|
1728
|
+
let e;
|
|
1729
|
+
typeof s[s.length - 1] == "function" && (e = s.pop());
|
|
1730
|
+
const t = {
|
|
1731
1731
|
id: this._queueSeq++,
|
|
1732
1732
|
tryCount: 0,
|
|
1733
1733
|
pending: !1,
|
|
1734
1734
|
args: s,
|
|
1735
1735
|
flags: Object.assign({ fromQueue: !0 }, this.flags)
|
|
1736
1736
|
};
|
|
1737
|
-
s.push((n, ...r) =>
|
|
1737
|
+
s.push((n, ...r) => t !== this._queue[0] ? void 0 : (n !== null ? t.tryCount > this._opts.retries && (this._queue.shift(), e && e(n)) : (this._queue.shift(), e && e(null, ...r)), t.pending = !1, this._drainQueue())), this._queue.push(t), this._drainQueue();
|
|
1738
1738
|
}
|
|
1739
1739
|
/**
|
|
1740
1740
|
* Send the first packet of the queue, and wait for an acknowledgement from the server.
|
|
@@ -1745,8 +1745,8 @@ let dt = class extends _ {
|
|
|
1745
1745
|
_drainQueue(s = !1) {
|
|
1746
1746
|
if (!this.connected || this._queue.length === 0)
|
|
1747
1747
|
return;
|
|
1748
|
-
const
|
|
1749
|
-
|
|
1748
|
+
const e = this._queue[0];
|
|
1749
|
+
e.pending && !s || (e.pending = !0, e.tryCount++, this.flags = e.flags, this.emit.apply(this, e.args));
|
|
1750
1750
|
}
|
|
1751
1751
|
/**
|
|
1752
1752
|
* Sends a packet.
|
|
@@ -1795,8 +1795,8 @@ let dt = class extends _ {
|
|
|
1795
1795
|
* @param description
|
|
1796
1796
|
* @private
|
|
1797
1797
|
*/
|
|
1798
|
-
onclose(s,
|
|
1799
|
-
this.connected = !1, delete this.id, this.emitReserved("disconnect", s,
|
|
1798
|
+
onclose(s, e) {
|
|
1799
|
+
this.connected = !1, delete this.id, this.emitReserved("disconnect", s, e), this._clearAcks();
|
|
1800
1800
|
}
|
|
1801
1801
|
/**
|
|
1802
1802
|
* Clears the acknowledgement handlers upon disconnection, since the client will never receive an acknowledgement from
|
|
@@ -1806,9 +1806,9 @@ let dt = class extends _ {
|
|
|
1806
1806
|
*/
|
|
1807
1807
|
_clearAcks() {
|
|
1808
1808
|
Object.keys(this.acks).forEach((s) => {
|
|
1809
|
-
if (!this.sendBuffer.some((
|
|
1810
|
-
const
|
|
1811
|
-
delete this.acks[s],
|
|
1809
|
+
if (!this.sendBuffer.some((e) => String(e.id) === s)) {
|
|
1810
|
+
const e = this.acks[s];
|
|
1811
|
+
delete this.acks[s], e.withError && e.call(this, new Error("socket has been disconnected"));
|
|
1812
1812
|
}
|
|
1813
1813
|
});
|
|
1814
1814
|
}
|
|
@@ -1837,8 +1837,8 @@ let dt = class extends _ {
|
|
|
1837
1837
|
break;
|
|
1838
1838
|
case l.CONNECT_ERROR:
|
|
1839
1839
|
this.destroy();
|
|
1840
|
-
const
|
|
1841
|
-
|
|
1840
|
+
const e = new Error(s.data.message);
|
|
1841
|
+
e.data = s.data.data, this.emitReserved("connect_error", e);
|
|
1842
1842
|
break;
|
|
1843
1843
|
}
|
|
1844
1844
|
}
|
|
@@ -1849,14 +1849,14 @@ let dt = class extends _ {
|
|
|
1849
1849
|
* @private
|
|
1850
1850
|
*/
|
|
1851
1851
|
onevent(s) {
|
|
1852
|
-
const
|
|
1853
|
-
s.id != null &&
|
|
1852
|
+
const e = s.data || [];
|
|
1853
|
+
s.id != null && e.push(this.ack(s.id)), this.connected ? this.emitEvent(e) : this.receiveBuffer.push(Object.freeze(e));
|
|
1854
1854
|
}
|
|
1855
1855
|
emitEvent(s) {
|
|
1856
1856
|
if (this._anyListeners && this._anyListeners.length) {
|
|
1857
|
-
const
|
|
1858
|
-
for (const
|
|
1859
|
-
|
|
1857
|
+
const e = this._anyListeners.slice();
|
|
1858
|
+
for (const t of e)
|
|
1859
|
+
t.apply(this, s);
|
|
1860
1860
|
}
|
|
1861
1861
|
super.emit.apply(this, s), this._pid && s.length && typeof s[s.length - 1] == "string" && (this._lastOffset = s[s.length - 1]);
|
|
1862
1862
|
}
|
|
@@ -1866,10 +1866,10 @@ let dt = class extends _ {
|
|
|
1866
1866
|
* @private
|
|
1867
1867
|
*/
|
|
1868
1868
|
ack(s) {
|
|
1869
|
-
const
|
|
1870
|
-
let
|
|
1869
|
+
const e = this;
|
|
1870
|
+
let t = !1;
|
|
1871
1871
|
return function(...n) {
|
|
1872
|
-
|
|
1872
|
+
t || (t = !0, e.packet({
|
|
1873
1873
|
type: l.ACK,
|
|
1874
1874
|
id: s,
|
|
1875
1875
|
data: n
|
|
@@ -1883,16 +1883,16 @@ let dt = class extends _ {
|
|
|
1883
1883
|
* @private
|
|
1884
1884
|
*/
|
|
1885
1885
|
onack(s) {
|
|
1886
|
-
const
|
|
1887
|
-
typeof
|
|
1886
|
+
const e = this.acks[s.id];
|
|
1887
|
+
typeof e == "function" && (delete this.acks[s.id], e.withError && s.data.unshift(null), e.apply(this, s.data));
|
|
1888
1888
|
}
|
|
1889
1889
|
/**
|
|
1890
1890
|
* Called upon server connect.
|
|
1891
1891
|
*
|
|
1892
1892
|
* @private
|
|
1893
1893
|
*/
|
|
1894
|
-
onconnect(s,
|
|
1895
|
-
this.id = s, this.recovered =
|
|
1894
|
+
onconnect(s, e) {
|
|
1895
|
+
this.id = s, this.recovered = e && this._pid === e, this._pid = e, this.connected = !0, this.emitBuffered(), this.emitReserved("connect"), this._drainQueue(!0);
|
|
1896
1896
|
}
|
|
1897
1897
|
/**
|
|
1898
1898
|
* Emit buffered events (received and emitted).
|
|
@@ -2039,10 +2039,10 @@ let dt = class extends _ {
|
|
|
2039
2039
|
if (!this._anyListeners)
|
|
2040
2040
|
return this;
|
|
2041
2041
|
if (s) {
|
|
2042
|
-
const
|
|
2043
|
-
for (let
|
|
2044
|
-
if (s === t
|
|
2045
|
-
return
|
|
2042
|
+
const e = this._anyListeners;
|
|
2043
|
+
for (let t = 0; t < e.length; t++)
|
|
2044
|
+
if (s === e[t])
|
|
2045
|
+
return e.splice(t, 1), this;
|
|
2046
2046
|
} else
|
|
2047
2047
|
this._anyListeners = [];
|
|
2048
2048
|
return this;
|
|
@@ -2108,10 +2108,10 @@ let dt = class extends _ {
|
|
|
2108
2108
|
if (!this._anyOutgoingListeners)
|
|
2109
2109
|
return this;
|
|
2110
2110
|
if (s) {
|
|
2111
|
-
const
|
|
2112
|
-
for (let
|
|
2113
|
-
if (s === t
|
|
2114
|
-
return
|
|
2111
|
+
const e = this._anyOutgoingListeners;
|
|
2112
|
+
for (let t = 0; t < e.length; t++)
|
|
2113
|
+
if (s === e[t])
|
|
2114
|
+
return e.splice(t, 1), this;
|
|
2115
2115
|
} else
|
|
2116
2116
|
this._anyOutgoingListeners = [];
|
|
2117
2117
|
return this;
|
|
@@ -2132,9 +2132,9 @@ let dt = class extends _ {
|
|
|
2132
2132
|
*/
|
|
2133
2133
|
notifyOutgoingListeners(s) {
|
|
2134
2134
|
if (this._anyOutgoingListeners && this._anyOutgoingListeners.length) {
|
|
2135
|
-
const
|
|
2136
|
-
for (const
|
|
2137
|
-
|
|
2135
|
+
const e = this._anyOutgoingListeners.slice();
|
|
2136
|
+
for (const t of e)
|
|
2137
|
+
t.apply(this, s.data);
|
|
2138
2138
|
}
|
|
2139
2139
|
}
|
|
2140
2140
|
};
|
|
@@ -2144,8 +2144,8 @@ function w(s) {
|
|
|
2144
2144
|
w.prototype.duration = function() {
|
|
2145
2145
|
var s = this.ms * Math.pow(this.factor, this.attempts++);
|
|
2146
2146
|
if (this.jitter) {
|
|
2147
|
-
var
|
|
2148
|
-
s = (Math.floor(
|
|
2147
|
+
var e = Math.random(), t = Math.floor(e * this.jitter * s);
|
|
2148
|
+
s = (Math.floor(e * 10) & 1) == 0 ? s - t : s + t;
|
|
2149
2149
|
}
|
|
2150
2150
|
return Math.min(s, this.max) | 0;
|
|
2151
2151
|
};
|
|
@@ -2162,36 +2162,36 @@ w.prototype.setJitter = function(s) {
|
|
|
2162
2162
|
this.jitter = s;
|
|
2163
2163
|
};
|
|
2164
2164
|
class $ extends _ {
|
|
2165
|
-
constructor(
|
|
2165
|
+
constructor(e, t) {
|
|
2166
2166
|
var n;
|
|
2167
|
-
super(), this.nsps = {}, this.subs = [],
|
|
2167
|
+
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((n = t.randomizationFactor) !== null && n !== void 0 ? n : 0.5), this.backoff = new w({
|
|
2168
2168
|
min: this.reconnectionDelay(),
|
|
2169
2169
|
max: this.reconnectionDelayMax(),
|
|
2170
2170
|
jitter: this.randomizationFactor()
|
|
2171
|
-
}), this.timeout(
|
|
2172
|
-
const r =
|
|
2173
|
-
this.encoder = new r.Encoder(), this.decoder = new r.Decoder(), this._autoConnect =
|
|
2171
|
+
}), this.timeout(t.timeout == null ? 2e4 : t.timeout), this._readyState = "closed", this.uri = e;
|
|
2172
|
+
const r = t.parser || ot;
|
|
2173
|
+
this.encoder = new r.Encoder(), this.decoder = new r.Decoder(), this._autoConnect = t.autoConnect !== !1, this._autoConnect && this.open();
|
|
2174
2174
|
}
|
|
2175
|
-
reconnection(
|
|
2176
|
-
return arguments.length ? (this._reconnection = !!
|
|
2175
|
+
reconnection(e) {
|
|
2176
|
+
return arguments.length ? (this._reconnection = !!e, e || (this.skipReconnect = !0), this) : this._reconnection;
|
|
2177
2177
|
}
|
|
2178
|
-
reconnectionAttempts(
|
|
2179
|
-
return
|
|
2178
|
+
reconnectionAttempts(e) {
|
|
2179
|
+
return e === void 0 ? this._reconnectionAttempts : (this._reconnectionAttempts = e, this);
|
|
2180
2180
|
}
|
|
2181
|
-
reconnectionDelay(
|
|
2182
|
-
var
|
|
2183
|
-
return
|
|
2181
|
+
reconnectionDelay(e) {
|
|
2182
|
+
var t;
|
|
2183
|
+
return e === void 0 ? this._reconnectionDelay : (this._reconnectionDelay = e, (t = this.backoff) === null || t === void 0 || t.setMin(e), this);
|
|
2184
2184
|
}
|
|
2185
|
-
randomizationFactor(
|
|
2186
|
-
var
|
|
2187
|
-
return
|
|
2185
|
+
randomizationFactor(e) {
|
|
2186
|
+
var t;
|
|
2187
|
+
return e === void 0 ? this._randomizationFactor : (this._randomizationFactor = e, (t = this.backoff) === null || t === void 0 || t.setJitter(e), this);
|
|
2188
2188
|
}
|
|
2189
|
-
reconnectionDelayMax(
|
|
2190
|
-
var
|
|
2191
|
-
return
|
|
2189
|
+
reconnectionDelayMax(e) {
|
|
2190
|
+
var t;
|
|
2191
|
+
return e === void 0 ? this._reconnectionDelayMax : (this._reconnectionDelayMax = e, (t = this.backoff) === null || t === void 0 || t.setMax(e), this);
|
|
2192
2192
|
}
|
|
2193
|
-
timeout(
|
|
2194
|
-
return arguments.length ? (this._timeout =
|
|
2193
|
+
timeout(e) {
|
|
2194
|
+
return arguments.length ? (this._timeout = e, this) : this._timeout;
|
|
2195
2195
|
}
|
|
2196
2196
|
/**
|
|
2197
2197
|
* Starts trying to reconnect if reconnection is enabled and we have not
|
|
@@ -2209,20 +2209,20 @@ class $ extends _ {
|
|
|
2209
2209
|
* @return self
|
|
2210
2210
|
* @public
|
|
2211
2211
|
*/
|
|
2212
|
-
open(
|
|
2212
|
+
open(e) {
|
|
2213
2213
|
if (~this._readyState.indexOf("open"))
|
|
2214
2214
|
return this;
|
|
2215
|
-
this.engine = new
|
|
2216
|
-
const
|
|
2215
|
+
this.engine = new Ye(this.uri, this.opts);
|
|
2216
|
+
const t = this.engine, n = this;
|
|
2217
2217
|
this._readyState = "opening", this.skipReconnect = !1;
|
|
2218
|
-
const r = f(
|
|
2219
|
-
n.onopen(),
|
|
2218
|
+
const r = f(t, "open", function() {
|
|
2219
|
+
n.onopen(), e && e();
|
|
2220
2220
|
}), i = (h) => {
|
|
2221
|
-
this.cleanup(), this._readyState = "closed", this.emitReserved("error", h),
|
|
2222
|
-
}, o = f(
|
|
2221
|
+
this.cleanup(), this._readyState = "closed", this.emitReserved("error", h), e ? e(h) : this.maybeReconnectOnOpen();
|
|
2222
|
+
}, o = f(t, "error", i);
|
|
2223
2223
|
if (this._timeout !== !1) {
|
|
2224
2224
|
const h = this._timeout, c = this.setTimeoutFn(() => {
|
|
2225
|
-
r(), i(new Error("timeout")),
|
|
2225
|
+
r(), i(new Error("timeout")), t.close();
|
|
2226
2226
|
}, h);
|
|
2227
2227
|
this.opts.autoUnref && c.unref(), this.subs.push(() => {
|
|
2228
2228
|
this.clearTimeoutFn(c);
|
|
@@ -2236,8 +2236,8 @@ class $ extends _ {
|
|
|
2236
2236
|
* @return self
|
|
2237
2237
|
* @public
|
|
2238
2238
|
*/
|
|
2239
|
-
connect(
|
|
2240
|
-
return this.open(
|
|
2239
|
+
connect(e) {
|
|
2240
|
+
return this.open(e);
|
|
2241
2241
|
}
|
|
2242
2242
|
/**
|
|
2243
2243
|
* Called upon transport open.
|
|
@@ -2246,12 +2246,12 @@ class $ extends _ {
|
|
|
2246
2246
|
*/
|
|
2247
2247
|
onopen() {
|
|
2248
2248
|
this.cleanup(), this._readyState = "open", this.emitReserved("open");
|
|
2249
|
-
const
|
|
2249
|
+
const e = this.engine;
|
|
2250
2250
|
this.subs.push(
|
|
2251
|
-
f(
|
|
2252
|
-
f(
|
|
2253
|
-
f(
|
|
2254
|
-
f(
|
|
2251
|
+
f(e, "ping", this.onping.bind(this)),
|
|
2252
|
+
f(e, "data", this.ondata.bind(this)),
|
|
2253
|
+
f(e, "error", this.onerror.bind(this)),
|
|
2254
|
+
f(e, "close", this.onclose.bind(this)),
|
|
2255
2255
|
// @ts-ignore
|
|
2256
2256
|
f(this.decoder, "decoded", this.ondecoded.bind(this))
|
|
2257
2257
|
);
|
|
@@ -2269,11 +2269,11 @@ class $ extends _ {
|
|
|
2269
2269
|
*
|
|
2270
2270
|
* @private
|
|
2271
2271
|
*/
|
|
2272
|
-
ondata(
|
|
2272
|
+
ondata(e) {
|
|
2273
2273
|
try {
|
|
2274
|
-
this.decoder.add(
|
|
2275
|
-
} catch (
|
|
2276
|
-
this.onclose("parse error",
|
|
2274
|
+
this.decoder.add(e);
|
|
2275
|
+
} catch (t) {
|
|
2276
|
+
this.onclose("parse error", t);
|
|
2277
2277
|
}
|
|
2278
2278
|
}
|
|
2279
2279
|
/**
|
|
@@ -2281,9 +2281,9 @@ class $ extends _ {
|
|
|
2281
2281
|
*
|
|
2282
2282
|
* @private
|
|
2283
2283
|
*/
|
|
2284
|
-
ondecoded(
|
|
2284
|
+
ondecoded(e) {
|
|
2285
2285
|
O(() => {
|
|
2286
|
-
this.emitReserved("packet",
|
|
2286
|
+
this.emitReserved("packet", e);
|
|
2287
2287
|
}, this.setTimeoutFn);
|
|
2288
2288
|
}
|
|
2289
2289
|
/**
|
|
@@ -2291,8 +2291,8 @@ class $ extends _ {
|
|
|
2291
2291
|
*
|
|
2292
2292
|
* @private
|
|
2293
2293
|
*/
|
|
2294
|
-
onerror(
|
|
2295
|
-
this.emitReserved("error",
|
|
2294
|
+
onerror(e) {
|
|
2295
|
+
this.emitReserved("error", e);
|
|
2296
2296
|
}
|
|
2297
2297
|
/**
|
|
2298
2298
|
* Creates a new socket for the given `nsp`.
|
|
@@ -2300,9 +2300,9 @@ class $ extends _ {
|
|
|
2300
2300
|
* @return {Socket}
|
|
2301
2301
|
* @public
|
|
2302
2302
|
*/
|
|
2303
|
-
socket(
|
|
2304
|
-
let n = this.nsps[
|
|
2305
|
-
return n ? this._autoConnect && !n.active && n.connect() : (n = new
|
|
2303
|
+
socket(e, t) {
|
|
2304
|
+
let n = this.nsps[e];
|
|
2305
|
+
return n ? this._autoConnect && !n.active && n.connect() : (n = new de(this, e, t), this.nsps[e] = n), n;
|
|
2306
2306
|
}
|
|
2307
2307
|
/**
|
|
2308
2308
|
* Called upon a socket close.
|
|
@@ -2310,9 +2310,9 @@ class $ extends _ {
|
|
|
2310
2310
|
* @param socket
|
|
2311
2311
|
* @private
|
|
2312
2312
|
*/
|
|
2313
|
-
_destroy(
|
|
2314
|
-
const
|
|
2315
|
-
for (const n of
|
|
2313
|
+
_destroy(e) {
|
|
2314
|
+
const t = Object.keys(this.nsps);
|
|
2315
|
+
for (const n of t)
|
|
2316
2316
|
if (this.nsps[n].active)
|
|
2317
2317
|
return;
|
|
2318
2318
|
this._close();
|
|
@@ -2323,10 +2323,10 @@ class $ extends _ {
|
|
|
2323
2323
|
* @param packet
|
|
2324
2324
|
* @private
|
|
2325
2325
|
*/
|
|
2326
|
-
_packet(
|
|
2327
|
-
const
|
|
2328
|
-
for (let n = 0; n <
|
|
2329
|
-
this.engine.write(
|
|
2326
|
+
_packet(e) {
|
|
2327
|
+
const t = this.encoder.encode(e);
|
|
2328
|
+
for (let n = 0; n < t.length; n++)
|
|
2329
|
+
this.engine.write(t[n], e.options);
|
|
2330
2330
|
}
|
|
2331
2331
|
/**
|
|
2332
2332
|
* Clean up transport subscriptions and packet buffer.
|
|
@@ -2334,7 +2334,7 @@ class $ extends _ {
|
|
|
2334
2334
|
* @private
|
|
2335
2335
|
*/
|
|
2336
2336
|
cleanup() {
|
|
2337
|
-
this.subs.forEach((
|
|
2337
|
+
this.subs.forEach((e) => e()), this.subs.length = 0, this.decoder.destroy();
|
|
2338
2338
|
}
|
|
2339
2339
|
/**
|
|
2340
2340
|
* Close the current socket.
|
|
@@ -2361,9 +2361,9 @@ class $ extends _ {
|
|
|
2361
2361
|
*
|
|
2362
2362
|
* @private
|
|
2363
2363
|
*/
|
|
2364
|
-
onclose(
|
|
2364
|
+
onclose(e, t) {
|
|
2365
2365
|
var n;
|
|
2366
|
-
this.cleanup(), (n = this.engine) === null || n === void 0 || n.close(), this.backoff.reset(), this._readyState = "closed", this.emitReserved("close",
|
|
2366
|
+
this.cleanup(), (n = this.engine) === null || n === void 0 || n.close(), this.backoff.reset(), this._readyState = "closed", this.emitReserved("close", e, t), this._reconnection && !this.skipReconnect && this.reconnect();
|
|
2367
2367
|
}
|
|
2368
2368
|
/**
|
|
2369
2369
|
* Attempt a reconnection.
|
|
@@ -2373,17 +2373,17 @@ class $ extends _ {
|
|
|
2373
2373
|
reconnect() {
|
|
2374
2374
|
if (this._reconnecting || this.skipReconnect)
|
|
2375
2375
|
return this;
|
|
2376
|
-
const
|
|
2376
|
+
const e = this;
|
|
2377
2377
|
if (this.backoff.attempts >= this._reconnectionAttempts)
|
|
2378
2378
|
this.backoff.reset(), this.emitReserved("reconnect_failed"), this._reconnecting = !1;
|
|
2379
2379
|
else {
|
|
2380
|
-
const
|
|
2380
|
+
const t = this.backoff.duration();
|
|
2381
2381
|
this._reconnecting = !0;
|
|
2382
2382
|
const n = this.setTimeoutFn(() => {
|
|
2383
|
-
|
|
2384
|
-
r ? (
|
|
2383
|
+
e.skipReconnect || (this.emitReserved("reconnect_attempt", e.backoff.attempts), !e.skipReconnect && e.open((r) => {
|
|
2384
|
+
r ? (e._reconnecting = !1, e.reconnect(), this.emitReserved("reconnect_error", r)) : e.onreconnect();
|
|
2385
2385
|
}));
|
|
2386
|
-
},
|
|
2386
|
+
}, t);
|
|
2387
2387
|
this.opts.autoUnref && n.unref(), this.subs.push(() => {
|
|
2388
2388
|
this.clearTimeoutFn(n);
|
|
2389
2389
|
});
|
|
@@ -2395,44 +2395,44 @@ class $ extends _ {
|
|
|
2395
2395
|
* @private
|
|
2396
2396
|
*/
|
|
2397
2397
|
onreconnect() {
|
|
2398
|
-
const
|
|
2399
|
-
this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect",
|
|
2398
|
+
const e = this.backoff.attempts;
|
|
2399
|
+
this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", e);
|
|
2400
2400
|
}
|
|
2401
2401
|
}
|
|
2402
2402
|
const k = {};
|
|
2403
|
-
function B(s,
|
|
2404
|
-
typeof s == "object" && (
|
|
2405
|
-
const
|
|
2403
|
+
function B(s, e) {
|
|
2404
|
+
typeof s == "object" && (e = s, s = void 0), e = e || {};
|
|
2405
|
+
const t = Je(s, e.path || "/socket.io"), n = t.source, r = t.id, i = t.path, o = k[r] && i in k[r].nsps, h = e.forceNew || e["force new connection"] || e.multiplex === !1 || o;
|
|
2406
2406
|
let c;
|
|
2407
|
-
return h ? c = new $(n,
|
|
2407
|
+
return h ? c = new $(n, e) : (k[r] || (k[r] = new $(n, e)), c = k[r]), t.query && !e.query && (e.query = t.queryKey), c.socket(t.path, e);
|
|
2408
2408
|
}
|
|
2409
2409
|
Object.assign(B, {
|
|
2410
2410
|
Manager: $,
|
|
2411
|
-
Socket:
|
|
2411
|
+
Socket: de,
|
|
2412
2412
|
io: B,
|
|
2413
2413
|
connect: B
|
|
2414
2414
|
});
|
|
2415
|
-
class
|
|
2416
|
-
#
|
|
2415
|
+
class ct {
|
|
2416
|
+
#t = "http://localhost:3000";
|
|
2417
2417
|
#s = {
|
|
2418
2418
|
transports: ["websocket"]
|
|
2419
2419
|
};
|
|
2420
|
-
#
|
|
2420
|
+
#e;
|
|
2421
2421
|
#i = !1;
|
|
2422
2422
|
#o = {};
|
|
2423
|
-
set uri(
|
|
2424
|
-
const
|
|
2425
|
-
if (!["http:", "https:", "ws:", "wss:"].includes(
|
|
2423
|
+
set uri(e) {
|
|
2424
|
+
const t = new URL(e);
|
|
2425
|
+
if (!["http:", "https:", "ws:", "wss:"].includes(t.protocol))
|
|
2426
2426
|
throw new Error("URI must start with http://, https://, ws://, or wss://");
|
|
2427
|
-
this.#
|
|
2427
|
+
this.#t = e;
|
|
2428
2428
|
}
|
|
2429
2429
|
get uri() {
|
|
2430
|
-
return this.#
|
|
2430
|
+
return this.#t;
|
|
2431
2431
|
}
|
|
2432
|
-
set options(
|
|
2433
|
-
if (typeof
|
|
2432
|
+
set options(e) {
|
|
2433
|
+
if (typeof e != "object")
|
|
2434
2434
|
throw new Error("Options must be an object");
|
|
2435
|
-
this.#s =
|
|
2435
|
+
this.#s = e;
|
|
2436
2436
|
}
|
|
2437
2437
|
get options() {
|
|
2438
2438
|
return this.#s;
|
|
@@ -2441,29 +2441,29 @@ class ce {
|
|
|
2441
2441
|
this.#o.onResponse = this.onResponse.bind(this);
|
|
2442
2442
|
}
|
|
2443
2443
|
disconnect() {
|
|
2444
|
-
this.#
|
|
2444
|
+
this.#e && (this.#e.off("response", this.#o.onResponse), this.#e.disconnect(), this.#e = null), this.#i = !1;
|
|
2445
2445
|
}
|
|
2446
2446
|
prepare() {
|
|
2447
|
-
this.#i || (this.#
|
|
2447
|
+
this.#i || (this.#e = B(this.#t, this.#s), this.#i = !0, this.#e.on("response", this.#o.onResponse));
|
|
2448
2448
|
}
|
|
2449
|
-
connectDevice(
|
|
2450
|
-
this.#
|
|
2449
|
+
connectDevice(e) {
|
|
2450
|
+
this.#e.emit("connectDevice", { config: e });
|
|
2451
2451
|
}
|
|
2452
|
-
disconnectDevice(
|
|
2453
|
-
this.#
|
|
2452
|
+
disconnectDevice(e) {
|
|
2453
|
+
this.#e.emit("disconnectDevice", { config: e });
|
|
2454
2454
|
}
|
|
2455
2455
|
disconnectAllDevices() {
|
|
2456
|
-
this.#
|
|
2456
|
+
this.#e.emit("disconnectAll");
|
|
2457
2457
|
}
|
|
2458
|
-
write(
|
|
2459
|
-
this.#
|
|
2458
|
+
write(e) {
|
|
2459
|
+
this.#e.emit("cmd", e);
|
|
2460
2460
|
}
|
|
2461
|
-
onResponse(
|
|
2462
|
-
let
|
|
2463
|
-
|
|
2461
|
+
onResponse(e) {
|
|
2462
|
+
let t = a.get(e.name, e.uuid);
|
|
2463
|
+
t || (t = a.getByNumber(e.name, e.deviceNumber)), t && t.socketResponse(e);
|
|
2464
2464
|
}
|
|
2465
2465
|
}
|
|
2466
|
-
const A = new
|
|
2466
|
+
const A = new ct(), q = {
|
|
2467
2467
|
baudRate: 9600,
|
|
2468
2468
|
dataBits: 8,
|
|
2469
2469
|
stopBits: 1,
|
|
@@ -2471,7 +2471,7 @@ const A = new ce(), D = {
|
|
|
2471
2471
|
bufferSize: 32768,
|
|
2472
2472
|
flowControl: "none"
|
|
2473
2473
|
};
|
|
2474
|
-
class
|
|
2474
|
+
class lt extends te {
|
|
2475
2475
|
__internal__ = {
|
|
2476
2476
|
bypassSerialBytesConnection: !1,
|
|
2477
2477
|
auto_response: !1,
|
|
@@ -2519,8 +2519,9 @@ class le extends et {
|
|
|
2519
2519
|
delay_first_connection: 200,
|
|
2520
2520
|
bytes_connection: null,
|
|
2521
2521
|
filters: [],
|
|
2522
|
-
config_port:
|
|
2522
|
+
config_port: q,
|
|
2523
2523
|
queue: [],
|
|
2524
|
+
running_queue: !1,
|
|
2524
2525
|
auto_response: null,
|
|
2525
2526
|
free_timeout_ms: 50,
|
|
2526
2527
|
// In previous versions 400 was used
|
|
@@ -2544,17 +2545,17 @@ class le extends et {
|
|
|
2544
2545
|
reconnection: 0
|
|
2545
2546
|
}
|
|
2546
2547
|
};
|
|
2547
|
-
#
|
|
2548
|
+
#t = null;
|
|
2548
2549
|
constructor({
|
|
2549
|
-
filters:
|
|
2550
|
-
config_port:
|
|
2550
|
+
filters: e = null,
|
|
2551
|
+
config_port: t = q,
|
|
2551
2552
|
no_device: n = 1,
|
|
2552
2553
|
device_listen_on_channel: r = 1,
|
|
2553
2554
|
bypassSerialBytesConnection: i = !1,
|
|
2554
2555
|
socket: o = !1
|
|
2555
2556
|
} = {
|
|
2556
2557
|
filters: null,
|
|
2557
|
-
config_port:
|
|
2558
|
+
config_port: q,
|
|
2558
2559
|
no_device: 1,
|
|
2559
2560
|
device_listen_on_channel: 1,
|
|
2560
2561
|
bypassSerialBytesConnection: !1,
|
|
@@ -2562,12 +2563,12 @@ class le extends et {
|
|
|
2562
2563
|
}) {
|
|
2563
2564
|
if (super(), !("serial" in navigator))
|
|
2564
2565
|
throw new Error("Web Serial not supported");
|
|
2565
|
-
|
|
2566
|
+
e && (this.serialFilters = e), t && (this.serialConfigPort = t), i && (this.__internal__.bypassSerialBytesConnection = i), n && this.#w(n), r && ["number", "string"].includes(typeof r) && (this.listenOnChannel = r), this.__internal__.serial.socket = o, this.#y(), this.#g();
|
|
2566
2567
|
}
|
|
2567
|
-
set listenOnChannel(
|
|
2568
|
-
if (typeof
|
|
2568
|
+
set listenOnChannel(e) {
|
|
2569
|
+
if (typeof e == "string" && (e = parseInt(e)), isNaN(e) || e < 1 || e > 255)
|
|
2569
2570
|
throw new Error("Invalid port number");
|
|
2570
|
-
this.__internal__.device.listen_on_port =
|
|
2571
|
+
this.__internal__.device.listen_on_port = e, !this.__internal__.bypassSerialBytesConnection && (this.__internal__.serial.bytes_connection = this.serialSetConnectionConstant(e));
|
|
2571
2572
|
}
|
|
2572
2573
|
get lastAction() {
|
|
2573
2574
|
return this.__internal__.serial.last_action;
|
|
@@ -2575,16 +2576,16 @@ class le extends et {
|
|
|
2575
2576
|
get listenOnChannel() {
|
|
2576
2577
|
return this.__internal__.device.listen_on_port ?? 1;
|
|
2577
2578
|
}
|
|
2578
|
-
set serialFilters(
|
|
2579
|
+
set serialFilters(e) {
|
|
2579
2580
|
if (this.isConnected) throw new Error("Cannot change serial filters while connected");
|
|
2580
|
-
this.__internal__.serial.filters =
|
|
2581
|
+
this.__internal__.serial.filters = e;
|
|
2581
2582
|
}
|
|
2582
2583
|
get serialFilters() {
|
|
2583
2584
|
return this.__internal__.serial.filters;
|
|
2584
2585
|
}
|
|
2585
|
-
set serialConfigPort(
|
|
2586
|
+
set serialConfigPort(e) {
|
|
2586
2587
|
if (this.isConnected) throw new Error("Cannot change serial filters while connected");
|
|
2587
|
-
this.__internal__.serial.config_port =
|
|
2588
|
+
this.__internal__.serial.config_port = e;
|
|
2588
2589
|
}
|
|
2589
2590
|
get serialConfigPort() {
|
|
2590
2591
|
return this.__internal__.serial.config_port;
|
|
@@ -2592,19 +2593,19 @@ class le extends et {
|
|
|
2592
2593
|
get useRTSCTS() {
|
|
2593
2594
|
return this.__internal__.serial.useRTSCTS;
|
|
2594
2595
|
}
|
|
2595
|
-
set useRTSCTS(
|
|
2596
|
-
this.__internal__.serial.useRTSCTS =
|
|
2596
|
+
set useRTSCTS(e) {
|
|
2597
|
+
this.__internal__.serial.useRTSCTS = e;
|
|
2597
2598
|
}
|
|
2598
2599
|
get isConnected() {
|
|
2599
|
-
const
|
|
2600
|
-
return
|
|
2600
|
+
const e = this.__internal__.serial.connected, t = this.#s(this.__internal__.serial.port);
|
|
2601
|
+
return e && !t && this.#e({ error: "Port is closed, not readable or writable." }), this.__internal__.serial.connected = t, this.__internal__.serial.connected;
|
|
2601
2602
|
}
|
|
2602
2603
|
get isConnecting() {
|
|
2603
2604
|
return this.__internal__.serial.connecting;
|
|
2604
2605
|
}
|
|
2605
2606
|
get isDisconnected() {
|
|
2606
|
-
const
|
|
2607
|
-
return !
|
|
2607
|
+
const e = this.__internal__.serial.connected, t = this.#s(this.__internal__.serial.port);
|
|
2608
|
+
return !e && t && (this.dispatch("serial:connected"), this.#r(!1), a.$dispatchChange(this)), this.__internal__.serial.connected = t, !this.__internal__.serial.connected;
|
|
2608
2609
|
}
|
|
2609
2610
|
get deviceNumber() {
|
|
2610
2611
|
return this.__internal__.device_number;
|
|
@@ -2621,113 +2622,113 @@ class le extends et {
|
|
|
2621
2622
|
get responseDelimited() {
|
|
2622
2623
|
return this.__internal__.serial.response.delimited;
|
|
2623
2624
|
}
|
|
2624
|
-
set responseDelimited(
|
|
2625
|
-
if (typeof
|
|
2625
|
+
set responseDelimited(e) {
|
|
2626
|
+
if (typeof e != "boolean")
|
|
2626
2627
|
throw new Error("responseDelimited must be a boolean");
|
|
2627
|
-
this.__internal__.serial.response.delimited =
|
|
2628
|
+
this.__internal__.serial.response.delimited = e;
|
|
2628
2629
|
}
|
|
2629
2630
|
get responsePrefixLimited() {
|
|
2630
2631
|
return this.__internal__.serial.response.prefixLimiter;
|
|
2631
2632
|
}
|
|
2632
|
-
set responsePrefixLimited(
|
|
2633
|
-
if (typeof
|
|
2633
|
+
set responsePrefixLimited(e) {
|
|
2634
|
+
if (typeof e != "boolean")
|
|
2634
2635
|
throw new Error("responsePrefixLimited must be a boolean");
|
|
2635
|
-
this.__internal__.serial.response.prefixLimiter =
|
|
2636
|
+
this.__internal__.serial.response.prefixLimiter = e;
|
|
2636
2637
|
}
|
|
2637
2638
|
get responseSufixLimited() {
|
|
2638
2639
|
return this.__internal__.serial.response.sufixLimiter;
|
|
2639
2640
|
}
|
|
2640
|
-
set responseSufixLimited(
|
|
2641
|
-
if (typeof
|
|
2641
|
+
set responseSufixLimited(e) {
|
|
2642
|
+
if (typeof e != "boolean")
|
|
2642
2643
|
throw new Error("responseSufixLimited must be a boolean");
|
|
2643
|
-
this.__internal__.serial.response.sufixLimiter =
|
|
2644
|
+
this.__internal__.serial.response.sufixLimiter = e;
|
|
2644
2645
|
}
|
|
2645
2646
|
get responseLimiter() {
|
|
2646
2647
|
return this.__internal__.serial.response.limiter;
|
|
2647
2648
|
}
|
|
2648
|
-
set responseLimiter(
|
|
2649
|
-
if (typeof
|
|
2649
|
+
set responseLimiter(e) {
|
|
2650
|
+
if (typeof e != "string" && !(e instanceof RegExp))
|
|
2650
2651
|
throw new Error("responseLimiter must be a string or a RegExp");
|
|
2651
|
-
this.__internal__.serial.response.limiter =
|
|
2652
|
+
this.__internal__.serial.response.limiter = e;
|
|
2652
2653
|
}
|
|
2653
2654
|
get fixedBytesMessage() {
|
|
2654
2655
|
return this.__internal__.serial.response.length;
|
|
2655
2656
|
}
|
|
2656
|
-
set fixedBytesMessage(
|
|
2657
|
-
if (
|
|
2657
|
+
set fixedBytesMessage(e) {
|
|
2658
|
+
if (e !== null && (typeof e != "number" || e < 1))
|
|
2658
2659
|
throw new Error("Invalid length for fixed bytes message");
|
|
2659
|
-
this.__internal__.serial.response.length =
|
|
2660
|
+
this.__internal__.serial.response.length = e;
|
|
2660
2661
|
}
|
|
2661
2662
|
get timeoutBeforeResponseBytes() {
|
|
2662
2663
|
return this.__internal__.serial.free_timeout_ms || 50;
|
|
2663
2664
|
}
|
|
2664
|
-
set timeoutBeforeResponseBytes(
|
|
2665
|
-
if (
|
|
2665
|
+
set timeoutBeforeResponseBytes(e) {
|
|
2666
|
+
if (e !== void 0 && (typeof e != "number" || e < 1))
|
|
2666
2667
|
throw new Error("Invalid timeout for response bytes");
|
|
2667
|
-
this.__internal__.serial.free_timeout_ms =
|
|
2668
|
+
this.__internal__.serial.free_timeout_ms = e ?? 50;
|
|
2668
2669
|
}
|
|
2669
2670
|
get bypassSerialBytesConnection() {
|
|
2670
2671
|
return this.__internal__.bypassSerialBytesConnection;
|
|
2671
2672
|
}
|
|
2672
|
-
set bypassSerialBytesConnection(
|
|
2673
|
-
if (typeof
|
|
2673
|
+
set bypassSerialBytesConnection(e) {
|
|
2674
|
+
if (typeof e != "boolean")
|
|
2674
2675
|
throw new Error("bypassSerialBytesConnection must be a boolean");
|
|
2675
|
-
this.__internal__.bypassSerialBytesConnection =
|
|
2676
|
+
this.__internal__.bypassSerialBytesConnection = e;
|
|
2676
2677
|
}
|
|
2677
2678
|
get useSocket() {
|
|
2678
2679
|
return this.__internal__.serial.socket;
|
|
2679
2680
|
}
|
|
2680
2681
|
get connectionBytes() {
|
|
2681
|
-
const
|
|
2682
|
-
return
|
|
2682
|
+
const e = this.__internal__.serial.bytes_connection;
|
|
2683
|
+
return e instanceof Uint8Array ? e : typeof e == "string" ? this.stringArrayToUint8Array(this.parseStringToBytes(e, "")) : Array.isArray(e) && typeof e[0] == "string" ? this.stringArrayToUint8Array(e) : Array.isArray(e) && typeof e[0] == "number" ? new Uint8Array(e) : new Uint8Array([]);
|
|
2683
2684
|
}
|
|
2684
|
-
set portPath(
|
|
2685
|
+
set portPath(e) {
|
|
2685
2686
|
if (this.isConnected) throw new Error("Cannot change port path while connected");
|
|
2686
|
-
if (typeof
|
|
2687
|
+
if (typeof e != "string" && e !== null)
|
|
2687
2688
|
throw new TypeError("vendorId must be string or null");
|
|
2688
|
-
this.__internal__.serial.portInfo.path =
|
|
2689
|
+
this.__internal__.serial.portInfo.path = e;
|
|
2689
2690
|
}
|
|
2690
2691
|
get portPath() {
|
|
2691
2692
|
return this.__internal__.serial.portInfo.path;
|
|
2692
2693
|
}
|
|
2693
|
-
set portVendorId(
|
|
2694
|
+
set portVendorId(e) {
|
|
2694
2695
|
if (this.isConnected) throw new Error("Cannot change port vendorId while connected");
|
|
2695
|
-
if (typeof
|
|
2696
|
+
if (typeof e == "number" && typeof e != "string" && e !== null)
|
|
2696
2697
|
throw new TypeError("vendorId must be a number, string or null");
|
|
2697
|
-
this.__internal__.serial.portInfo.vendorId =
|
|
2698
|
+
this.__internal__.serial.portInfo.vendorId = e;
|
|
2698
2699
|
}
|
|
2699
2700
|
get portVendorId() {
|
|
2700
2701
|
return this.__internal__.serial.portInfo.vendorId;
|
|
2701
2702
|
}
|
|
2702
|
-
set portProductId(
|
|
2703
|
+
set portProductId(e) {
|
|
2703
2704
|
if (this.isConnected) throw new Error("Cannot change port productId while connected");
|
|
2704
|
-
if (typeof
|
|
2705
|
+
if (typeof e == "number" && typeof e != "string" && e !== null)
|
|
2705
2706
|
throw new TypeError("productId must be a number, string or null");
|
|
2706
|
-
this.__internal__.serial.portInfo.productId =
|
|
2707
|
+
this.__internal__.serial.portInfo.productId = e;
|
|
2707
2708
|
}
|
|
2708
2709
|
get portProductId() {
|
|
2709
2710
|
return this.__internal__.serial.portInfo.productId;
|
|
2710
2711
|
}
|
|
2711
|
-
set socketPortParser(
|
|
2712
|
-
if (["byte-length", "inter-byte-timeout"].includes(
|
|
2712
|
+
set socketPortParser(e) {
|
|
2713
|
+
if (["byte-length", "inter-byte-timeout"].includes(e))
|
|
2713
2714
|
throw new TypeError("socketPortParser must be a string, either 'byte-length' or 'inter-byte-timeout'");
|
|
2714
|
-
this.__internal__.serial.portInfo.parser.name =
|
|
2715
|
+
this.__internal__.serial.portInfo.parser.name = e;
|
|
2715
2716
|
}
|
|
2716
2717
|
get socketPortParser() {
|
|
2717
2718
|
return this.__internal__.serial.portInfo.parser.name;
|
|
2718
2719
|
}
|
|
2719
|
-
set socketPortParserInterval(
|
|
2720
|
-
if (typeof
|
|
2720
|
+
set socketPortParserInterval(e) {
|
|
2721
|
+
if (typeof e != "number" || e < 1)
|
|
2721
2722
|
throw new TypeError("Interval must be a positive number");
|
|
2722
|
-
this.__internal__.serial.portInfo.parser.interval =
|
|
2723
|
+
this.__internal__.serial.portInfo.parser.interval = e;
|
|
2723
2724
|
}
|
|
2724
2725
|
get socketPortParserInterval() {
|
|
2725
2726
|
return this.__internal__.serial.portInfo.parser.interval || 50;
|
|
2726
2727
|
}
|
|
2727
|
-
set socketPortParserLength(
|
|
2728
|
-
if (typeof
|
|
2728
|
+
set socketPortParserLength(e) {
|
|
2729
|
+
if (typeof e != "number" || e < 1)
|
|
2729
2730
|
throw new TypeError("Length must be a positive number or null");
|
|
2730
|
-
this.__internal__.serial.portInfo.parser.length =
|
|
2731
|
+
this.__internal__.serial.portInfo.parser.length = e;
|
|
2731
2732
|
}
|
|
2732
2733
|
get socketPortParserLength() {
|
|
2733
2734
|
return this.__internal__.serial.portInfo.parser.length || 14;
|
|
@@ -2777,40 +2778,40 @@ class le extends et {
|
|
|
2777
2778
|
}
|
|
2778
2779
|
};
|
|
2779
2780
|
}
|
|
2780
|
-
#s(
|
|
2781
|
-
return this.useSocket ? this.__internal__.serial.connected : !!(
|
|
2781
|
+
#s(e) {
|
|
2782
|
+
return this.useSocket ? this.__internal__.serial.connected : !!(e && e.readable && e.writable);
|
|
2782
2783
|
}
|
|
2783
|
-
async timeout(
|
|
2784
|
-
this.__internal__.last_error.message = "Operation response timed out.", this.__internal__.last_error.action =
|
|
2784
|
+
async timeout(e, t) {
|
|
2785
|
+
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", {
|
|
2785
2786
|
...this.__internal__.last_error,
|
|
2786
|
-
bytes:
|
|
2787
|
-
action:
|
|
2787
|
+
bytes: e,
|
|
2788
|
+
action: t
|
|
2788
2789
|
});
|
|
2789
2790
|
}
|
|
2790
|
-
async disconnect(
|
|
2791
|
-
await this.serialDisconnect(), this.#
|
|
2791
|
+
async disconnect(e = null) {
|
|
2792
|
+
await this.serialDisconnect(), this.#e(e);
|
|
2792
2793
|
}
|
|
2793
|
-
#
|
|
2794
|
-
this.__internal__.serial.connected = !1, this.__internal__.aux_port_connector = 0, this.dispatch("serial:disconnected",
|
|
2794
|
+
#e(e = null) {
|
|
2795
|
+
this.__internal__.serial.connected = !1, this.__internal__.aux_port_connector = 0, this.dispatch("serial:disconnected", e), a.$dispatchChange(this);
|
|
2795
2796
|
}
|
|
2796
|
-
#i(
|
|
2797
|
-
this.__internal__.serial.aux_connecting =
|
|
2797
|
+
#i(e) {
|
|
2798
|
+
this.__internal__.serial.aux_connecting = e.detail.active ? "connecting" : "finished";
|
|
2798
2799
|
}
|
|
2799
|
-
socketResponse(
|
|
2800
|
-
const
|
|
2801
|
-
if (
|
|
2802
|
-
this.#n(new Uint8Array(
|
|
2803
|
-
else if (
|
|
2800
|
+
socketResponse(e) {
|
|
2801
|
+
const t = this.__internal__.serial.connected;
|
|
2802
|
+
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.#r(!1)), e.type === "success")
|
|
2803
|
+
this.#n(new Uint8Array(e.data));
|
|
2804
|
+
else if (e.type === "error") {
|
|
2804
2805
|
const n = new Error("The port is closed or is not readable/writable");
|
|
2805
2806
|
this.serialErrors(n);
|
|
2806
|
-
} else
|
|
2807
|
+
} else e.type === "timeout" && this.timeout(e.data.bytes ?? [], this.lastAction || "unknown");
|
|
2807
2808
|
this.__internal__.serial.last_action = null;
|
|
2808
2809
|
}
|
|
2809
2810
|
async connect() {
|
|
2810
|
-
return this.isConnected ? !0 : (this.__internal__.serial.aux_connecting = "idle", new Promise((
|
|
2811
|
-
this.#
|
|
2811
|
+
return this.isConnected ? !0 : (this.__internal__.serial.aux_connecting = "idle", new Promise((e, t) => {
|
|
2812
|
+
this.#t || (this.#t = this.#i.bind(this)), this.on("internal:connecting", this.#t);
|
|
2812
2813
|
const n = setInterval(() => {
|
|
2813
|
-
this.__internal__.serial.aux_connecting === "finished" ? (clearInterval(n), this.__internal__.serial.aux_connecting = "idle", this.#
|
|
2814
|
+
this.__internal__.serial.aux_connecting === "finished" ? (clearInterval(n), this.__internal__.serial.aux_connecting = "idle", this.#t !== null && this.off("internal:connecting", this.#t), 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 }));
|
|
2814
2815
|
}, 100);
|
|
2815
2816
|
this.serialConnect();
|
|
2816
2817
|
}));
|
|
@@ -2820,65 +2821,69 @@ class le extends et {
|
|
|
2820
2821
|
if (this.useSocket)
|
|
2821
2822
|
A.disconnectDevice(this.configDeviceSocket);
|
|
2822
2823
|
else {
|
|
2823
|
-
const
|
|
2824
|
-
|
|
2824
|
+
const e = this.__internal__.serial.reader, t = this.__internal__.serial.output_stream;
|
|
2825
|
+
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();
|
|
2825
2826
|
}
|
|
2826
|
-
} catch (
|
|
2827
|
-
this.serialErrors(
|
|
2827
|
+
} catch (e) {
|
|
2828
|
+
this.serialErrors(e);
|
|
2828
2829
|
} finally {
|
|
2829
2830
|
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);
|
|
2830
2831
|
}
|
|
2831
2832
|
}
|
|
2832
|
-
async #o(
|
|
2833
|
+
async #o(e) {
|
|
2833
2834
|
if (this.isDisconnected)
|
|
2834
|
-
throw this.#
|
|
2835
|
-
const
|
|
2836
|
-
A.write({ config: this.configDeviceSocket, bytes: Array.from(
|
|
2835
|
+
throw this.#e({ error: "Port is closed, not readable or writable." }), new Error("The port is closed or is not readable/writable");
|
|
2836
|
+
const t = this.validateBytes(e);
|
|
2837
|
+
A.write({ config: this.configDeviceSocket, bytes: Array.from(t) });
|
|
2837
2838
|
}
|
|
2838
|
-
async #a(
|
|
2839
|
+
async #a(e) {
|
|
2839
2840
|
if (this.useSocket) {
|
|
2840
|
-
await this.#o(
|
|
2841
|
+
await this.#o(e);
|
|
2841
2842
|
return;
|
|
2842
2843
|
}
|
|
2843
|
-
const
|
|
2844
|
-
if (!
|
|
2845
|
-
throw this.#
|
|
2846
|
-
const n = this.validateBytes(
|
|
2847
|
-
if (this.useRTSCTS && await this.#c(
|
|
2848
|
-
const r =
|
|
2844
|
+
const t = this.__internal__.serial.port;
|
|
2845
|
+
if (!t || t && (!t.readable || !t.writable))
|
|
2846
|
+
throw this.#e({ error: "Port is closed, not readable or writable." }), new Error("The port is closed or is not readable/writable");
|
|
2847
|
+
const n = this.validateBytes(e);
|
|
2848
|
+
if (this.useRTSCTS && await this.#c(t, 5e3), t.writable === null) return;
|
|
2849
|
+
const r = t.writable.getWriter();
|
|
2849
2850
|
await r.write(n), r.releaseLock();
|
|
2850
2851
|
}
|
|
2851
|
-
async #c(
|
|
2852
|
+
async #c(e, t = 5e3) {
|
|
2852
2853
|
const n = Date.now();
|
|
2853
2854
|
for (; ; ) {
|
|
2854
|
-
if (Date.now() - n >
|
|
2855
|
+
if (Date.now() - n > t)
|
|
2855
2856
|
throw new Error("Timeout waiting for clearToSend signal");
|
|
2856
|
-
const { clearToSend: r } = await
|
|
2857
|
+
const { clearToSend: r } = await e.getSignals();
|
|
2857
2858
|
if (r) return;
|
|
2858
2859
|
await J(100);
|
|
2859
2860
|
}
|
|
2860
2861
|
}
|
|
2861
|
-
#n(
|
|
2862
|
-
if (
|
|
2862
|
+
#n(e = new Uint8Array([]), t = !1) {
|
|
2863
|
+
if (e && e.length > 0) {
|
|
2863
2864
|
const n = this.__internal__.serial.connected;
|
|
2864
2865
|
if (this.__internal__.serial.connected = this.#s(this.__internal__.serial.port), a.$dispatchChange(this), !n && this.__internal__.serial.connected && (this.dispatch("serial:connected"), this.#r(!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")
|
|
2865
|
-
|
|
2866
|
+
t ? this.serialCorruptMessage(this.parseUint8ToHex(e)) : this.serialMessage(this.parseUint8ToHex(e));
|
|
2866
2867
|
else if (this.__internal__.serial.response.as === "uint8")
|
|
2867
|
-
|
|
2868
|
+
t ? this.serialCorruptMessage(e) : this.serialMessage(e);
|
|
2868
2869
|
else if (this.__internal__.serial.response.as === "string") {
|
|
2869
|
-
const r = this.parseUint8ArrayToString(
|
|
2870
|
+
const r = this.parseUint8ArrayToString(e);
|
|
2870
2871
|
if (this.__internal__.serial.response.limiter !== null) {
|
|
2871
2872
|
const i = r.split(this.__internal__.serial.response.limiter);
|
|
2872
2873
|
for (const o in i)
|
|
2873
|
-
i[o] && (
|
|
2874
|
+
i[o] && (t ? this.serialCorruptMessage(i[o]) : this.serialMessage(i[o]));
|
|
2874
2875
|
} else
|
|
2875
|
-
|
|
2876
|
+
t ? this.serialCorruptMessage(r) : this.serialMessage(r);
|
|
2876
2877
|
} else {
|
|
2877
|
-
const r = this.stringToArrayBuffer(this.parseUint8ArrayToString(
|
|
2878
|
-
|
|
2878
|
+
const r = this.stringToArrayBuffer(this.parseUint8ArrayToString(e));
|
|
2879
|
+
t ? this.serialCorruptMessage(r) : this.serialMessage(r);
|
|
2879
2880
|
}
|
|
2880
2881
|
}
|
|
2881
|
-
this.__internal__.serial.queue.length
|
|
2882
|
+
if (this.__internal__.serial.queue.length === 0) {
|
|
2883
|
+
this.__internal__.serial.running_queue = !1;
|
|
2884
|
+
return;
|
|
2885
|
+
}
|
|
2886
|
+
this.dispatch("internal:queue", {});
|
|
2882
2887
|
}
|
|
2883
2888
|
getResponseAsArrayBuffer() {
|
|
2884
2889
|
this.__internal__.serial.response.as = "arraybuffer";
|
|
@@ -2893,75 +2898,75 @@ class le extends et {
|
|
|
2893
2898
|
this.__internal__.serial.response.as = "string";
|
|
2894
2899
|
}
|
|
2895
2900
|
async #l() {
|
|
2896
|
-
const
|
|
2897
|
-
return
|
|
2901
|
+
const e = this.serialFilters, t = await navigator.serial.getPorts({ filters: e });
|
|
2902
|
+
return e.length === 0 ? t : t.filter((n) => {
|
|
2898
2903
|
const r = n.getInfo();
|
|
2899
|
-
return
|
|
2904
|
+
return e.some((i) => r.usbProductId === i.usbProductId && r.usbVendorId === i.usbVendorId);
|
|
2900
2905
|
}).filter((n) => !this.#s(n));
|
|
2901
2906
|
}
|
|
2902
|
-
async serialPortsSaved(
|
|
2903
|
-
const
|
|
2904
|
-
if (this.__internal__.aux_port_connector <
|
|
2907
|
+
async serialPortsSaved(e) {
|
|
2908
|
+
const t = this.serialFilters;
|
|
2909
|
+
if (this.__internal__.aux_port_connector < e.length) {
|
|
2905
2910
|
const n = this.__internal__.aux_port_connector;
|
|
2906
|
-
this.__internal__.serial.port =
|
|
2911
|
+
this.__internal__.serial.port = e[n];
|
|
2907
2912
|
} else
|
|
2908
2913
|
this.__internal__.aux_port_connector = 0, this.__internal__.serial.port = await navigator.serial.requestPort({
|
|
2909
|
-
filters:
|
|
2914
|
+
filters: t
|
|
2910
2915
|
});
|
|
2911
2916
|
if (!this.__internal__.serial.port)
|
|
2912
2917
|
throw new Error("Select another port please");
|
|
2913
2918
|
}
|
|
2914
|
-
serialErrors(
|
|
2915
|
-
const
|
|
2919
|
+
serialErrors(e) {
|
|
2920
|
+
const t = e.toString().toLowerCase();
|
|
2916
2921
|
switch (!0) {
|
|
2917
|
-
case
|
|
2918
|
-
case
|
|
2919
|
-
case
|
|
2920
|
-
case
|
|
2921
|
-
case
|
|
2922
|
-
case
|
|
2923
|
-
case
|
|
2924
|
-
case
|
|
2922
|
+
case t.includes("must be handling a user gesture to show a permission request"):
|
|
2923
|
+
case t.includes("the port is closed."):
|
|
2924
|
+
case t.includes("the port is closed or is not writable"):
|
|
2925
|
+
case t.includes("the port is closed or is not readable"):
|
|
2926
|
+
case t.includes("the port is closed or is not readable/writable"):
|
|
2927
|
+
case t.includes("select another port please"):
|
|
2928
|
+
case t.includes("no port selected by the user"):
|
|
2929
|
+
case t.includes(
|
|
2925
2930
|
"this readable stream reader has been released and cannot be used to cancel its previous owner stream"
|
|
2926
2931
|
):
|
|
2927
2932
|
this.dispatch("serial:need-permission", {}), a.$dispatchChange(this);
|
|
2928
2933
|
break;
|
|
2929
|
-
case
|
|
2930
|
-
case
|
|
2934
|
+
case t.includes("the port is already open."):
|
|
2935
|
+
case t.includes("failed to open serial port"):
|
|
2931
2936
|
this.serialDisconnect().then(async () => {
|
|
2932
2937
|
this.__internal__.aux_port_connector += 1, await this.serialConnect();
|
|
2933
2938
|
});
|
|
2934
2939
|
break;
|
|
2935
|
-
case
|
|
2936
|
-
case
|
|
2937
|
-
case
|
|
2938
|
-
case
|
|
2940
|
+
case t.includes("cannot read properties of undefined (reading 'writable')"):
|
|
2941
|
+
case t.includes("cannot read properties of null (reading 'writable')"):
|
|
2942
|
+
case t.includes("cannot read property 'writable' of null"):
|
|
2943
|
+
case t.includes("cannot read property 'writable' of undefined"):
|
|
2939
2944
|
this.serialDisconnect().then(async () => {
|
|
2940
2945
|
await this.serialConnect();
|
|
2941
2946
|
});
|
|
2942
2947
|
break;
|
|
2943
|
-
case
|
|
2948
|
+
case t.includes("'close' on 'serialport': a call to close() is already in progress."):
|
|
2944
2949
|
break;
|
|
2945
|
-
case
|
|
2950
|
+
case t.includes("failed to execute 'open' on 'serialport': a call to open() is already in progress."):
|
|
2946
2951
|
break;
|
|
2947
|
-
case
|
|
2952
|
+
case t.includes("the port is already closed."):
|
|
2948
2953
|
break;
|
|
2949
|
-
case
|
|
2954
|
+
case t.includes("the device has been lost"):
|
|
2950
2955
|
this.dispatch("serial:lost", {}), a.$dispatchChange(this);
|
|
2951
2956
|
break;
|
|
2952
|
-
case
|
|
2957
|
+
case t.includes("navigator.serial is undefined"):
|
|
2953
2958
|
this.dispatch("serial:unsupported", {});
|
|
2954
2959
|
break;
|
|
2955
2960
|
default:
|
|
2956
|
-
console.error(
|
|
2961
|
+
console.error(e);
|
|
2957
2962
|
break;
|
|
2958
2963
|
}
|
|
2959
|
-
this.dispatch("serial:error",
|
|
2964
|
+
this.dispatch("serial:error", e);
|
|
2960
2965
|
}
|
|
2961
|
-
#h(
|
|
2962
|
-
if (
|
|
2963
|
-
const
|
|
2964
|
-
n.set(
|
|
2966
|
+
#h(e) {
|
|
2967
|
+
if (e) {
|
|
2968
|
+
const t = this.__internal__.serial.response.buffer, n = new Uint8Array(t.length + e.byteLength);
|
|
2969
|
+
n.set(t, 0), n.set(new Uint8Array(e), t.length), this.__internal__.serial.response.buffer = n;
|
|
2965
2970
|
}
|
|
2966
2971
|
}
|
|
2967
2972
|
async #u() {
|
|
@@ -2970,58 +2975,58 @@ class le extends et {
|
|
|
2970
2975
|
}, this.__internal__.serial.free_timeout_ms || 50);
|
|
2971
2976
|
}
|
|
2972
2977
|
async #_() {
|
|
2973
|
-
const
|
|
2974
|
-
let
|
|
2975
|
-
if (this.__internal__.serial.time_until_send_bytes && (clearTimeout(this.__internal__.serial.time_until_send_bytes), this.__internal__.serial.time_until_send_bytes = 0), !(
|
|
2976
|
-
for (;
|
|
2977
|
-
const n =
|
|
2978
|
-
this.#n(n),
|
|
2978
|
+
const e = this.__internal__.serial.response.length;
|
|
2979
|
+
let t = this.__internal__.serial.response.buffer;
|
|
2980
|
+
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)) {
|
|
2981
|
+
for (; t.length >= e; ) {
|
|
2982
|
+
const n = t.slice(0, e);
|
|
2983
|
+
this.#n(n), t = t.slice(e);
|
|
2979
2984
|
}
|
|
2980
|
-
this.__internal__.serial.response.buffer =
|
|
2985
|
+
this.__internal__.serial.response.buffer = t, t.length > 0 && (this.__internal__.serial.time_until_send_bytes = setTimeout(() => {
|
|
2981
2986
|
this.#n(this.__internal__.serial.response.buffer, !0);
|
|
2982
2987
|
}, this.__internal__.serial.free_timeout_ms || 50));
|
|
2983
2988
|
}
|
|
2984
2989
|
}
|
|
2985
2990
|
async #p() {
|
|
2986
2991
|
const {
|
|
2987
|
-
limiter:
|
|
2988
|
-
prefixLimiter:
|
|
2992
|
+
limiter: e,
|
|
2993
|
+
prefixLimiter: t = !1,
|
|
2989
2994
|
sufixLimiter: n = !0
|
|
2990
2995
|
} = this.__internal__.serial.response;
|
|
2991
|
-
if (!
|
|
2996
|
+
if (!e)
|
|
2992
2997
|
throw new Error("No limiter defined for delimited serial response");
|
|
2993
2998
|
const r = this.__internal__.serial.response.buffer;
|
|
2994
|
-
if (!
|
|
2999
|
+
if (!e || !r || r.length === 0) return;
|
|
2995
3000
|
this.__internal__.serial.time_until_send_bytes && (clearTimeout(this.__internal__.serial.time_until_send_bytes), this.__internal__.serial.time_until_send_bytes = 0);
|
|
2996
3001
|
let i = new TextDecoder().decode(r);
|
|
2997
3002
|
const o = [];
|
|
2998
|
-
if (typeof
|
|
3003
|
+
if (typeof e == "string") {
|
|
2999
3004
|
let c;
|
|
3000
|
-
if (
|
|
3001
|
-
c = new RegExp(`${
|
|
3002
|
-
else if (
|
|
3003
|
-
c = new RegExp(`${
|
|
3005
|
+
if (t && n)
|
|
3006
|
+
c = new RegExp(`${e}([^${e}]+)${e}`, "g");
|
|
3007
|
+
else if (t)
|
|
3008
|
+
c = new RegExp(`${e}([^${e}]*)`, "g");
|
|
3004
3009
|
else if (n)
|
|
3005
|
-
c = new RegExp(`([^${
|
|
3010
|
+
c = new RegExp(`([^${e}]+)${e}`, "g");
|
|
3006
3011
|
else
|
|
3007
3012
|
return;
|
|
3008
3013
|
let p, u = 0;
|
|
3009
3014
|
for (; (p = c.exec(i)) !== null; )
|
|
3010
3015
|
o.push(new TextEncoder().encode(p[1])), u = c.lastIndex;
|
|
3011
3016
|
i = i.slice(u);
|
|
3012
|
-
} else if (
|
|
3017
|
+
} else if (e instanceof RegExp) {
|
|
3013
3018
|
let c, p = 0;
|
|
3014
|
-
if (
|
|
3015
|
-
const u = new RegExp(`${
|
|
3019
|
+
if (t && n) {
|
|
3020
|
+
const u = new RegExp(`${e.source}(.*?)${e.source}`, "g");
|
|
3016
3021
|
for (; (c = u.exec(i)) !== null; )
|
|
3017
3022
|
o.push(new TextEncoder().encode(c[1])), p = u.lastIndex;
|
|
3018
3023
|
} else if (n)
|
|
3019
|
-
for (; (c =
|
|
3024
|
+
for (; (c = e.exec(i)) !== null; ) {
|
|
3020
3025
|
const u = c.index, y = i.slice(p, u);
|
|
3021
|
-
o.push(new TextEncoder().encode(y)), p =
|
|
3026
|
+
o.push(new TextEncoder().encode(y)), p = e.lastIndex;
|
|
3022
3027
|
}
|
|
3023
|
-
else if (
|
|
3024
|
-
const u = i.split(
|
|
3028
|
+
else if (t) {
|
|
3029
|
+
const u = i.split(e);
|
|
3025
3030
|
u.shift();
|
|
3026
3031
|
for (const y of u)
|
|
3027
3032
|
o.push(new TextEncoder().encode(y));
|
|
@@ -3037,24 +3042,24 @@ class le extends et {
|
|
|
3037
3042
|
}, this.__internal__.serial.free_timeout_ms ?? 50));
|
|
3038
3043
|
}
|
|
3039
3044
|
async #d() {
|
|
3040
|
-
const
|
|
3041
|
-
if (!
|
|
3042
|
-
const
|
|
3043
|
-
this.__internal__.serial.reader =
|
|
3045
|
+
const e = this.__internal__.serial.port;
|
|
3046
|
+
if (!e || !e.readable) throw new Error("Port is not readable");
|
|
3047
|
+
const t = e.readable.getReader();
|
|
3048
|
+
this.__internal__.serial.reader = t;
|
|
3044
3049
|
try {
|
|
3045
3050
|
for (; this.__internal__.serial.keep_reading; ) {
|
|
3046
|
-
const { value: n, done: r } = await
|
|
3051
|
+
const { value: n, done: r } = await t.read();
|
|
3047
3052
|
if (r) break;
|
|
3048
3053
|
this.#h(n), this.__internal__.serial.response.delimited ? await this.#p() : this.__internal__.serial.response.length === null ? await this.#u() : await this.#_();
|
|
3049
3054
|
}
|
|
3050
3055
|
} catch (n) {
|
|
3051
3056
|
this.serialErrors(n);
|
|
3052
3057
|
} finally {
|
|
3053
|
-
|
|
3058
|
+
t.releaseLock(), this.__internal__.serial.keep_reading = !0, this.__internal__.serial.port && await this.__internal__.serial.port.close();
|
|
3054
3059
|
}
|
|
3055
3060
|
}
|
|
3056
|
-
#r(
|
|
3057
|
-
|
|
3061
|
+
#r(e) {
|
|
3062
|
+
e !== this.__internal__.serial.connecting && (this.__internal__.serial.connecting = e, this.dispatch("serial:connecting", { active: e }), this.dispatch("internal:connecting", { active: e }));
|
|
3058
3063
|
}
|
|
3059
3064
|
async serialConnect() {
|
|
3060
3065
|
try {
|
|
@@ -3066,23 +3071,23 @@ class le extends et {
|
|
|
3066
3071
|
bytes: this.__internal__.serial.bytes_connection
|
|
3067
3072
|
});
|
|
3068
3073
|
else {
|
|
3069
|
-
const
|
|
3070
|
-
if (
|
|
3071
|
-
await this.serialPortsSaved(
|
|
3074
|
+
const e = await this.#l();
|
|
3075
|
+
if (e.length > 0)
|
|
3076
|
+
await this.serialPortsSaved(e);
|
|
3072
3077
|
else {
|
|
3073
3078
|
const r = this.serialFilters;
|
|
3074
3079
|
this.__internal__.serial.port = await navigator.serial.requestPort({
|
|
3075
3080
|
filters: r
|
|
3076
3081
|
});
|
|
3077
3082
|
}
|
|
3078
|
-
const
|
|
3079
|
-
if (!
|
|
3083
|
+
const t = this.__internal__.serial.port;
|
|
3084
|
+
if (!t)
|
|
3080
3085
|
throw new Error("No port selected by the user");
|
|
3081
|
-
await
|
|
3086
|
+
await t.open(this.serialConfigPort);
|
|
3082
3087
|
const n = this;
|
|
3083
|
-
|
|
3084
|
-
n.dispatch("serial:connected", r), n.#r(!1), a.$dispatchChange(this), n.__internal__.serial.queue.length > 0
|
|
3085
|
-
},
|
|
3088
|
+
t.onconnect = (r) => {
|
|
3089
|
+
n.dispatch("serial:connected", r), n.#r(!1), a.$dispatchChange(this), n.__internal__.serial.queue.length > 0 ? n.dispatch("internal:queue", {}) : n.__internal__.serial.running_queue = !1;
|
|
3090
|
+
}, t.ondisconnect = async () => {
|
|
3086
3091
|
await n.disconnect();
|
|
3087
3092
|
}, await J(this.__internal__.serial.delay_first_connection), this.__internal__.timeout.until_response = setTimeout(async () => {
|
|
3088
3093
|
await n.timeout(n.__internal__.serial.bytes_connection ?? [], "connection:start");
|
|
@@ -3091,8 +3096,8 @@ class le extends et {
|
|
|
3091
3096
|
bytes: this.__internal__.serial.bytes_connection
|
|
3092
3097
|
}), this.__internal__.auto_response && this.#n(this.__internal__.serial.auto_response), await this.#d();
|
|
3093
3098
|
}
|
|
3094
|
-
} catch (
|
|
3095
|
-
this.#r(!1), this.serialErrors(
|
|
3099
|
+
} catch (e) {
|
|
3100
|
+
this.#r(!1), this.serialErrors(e);
|
|
3096
3101
|
}
|
|
3097
3102
|
}
|
|
3098
3103
|
async #f() {
|
|
@@ -3101,23 +3106,23 @@ class le extends et {
|
|
|
3101
3106
|
async serialForget() {
|
|
3102
3107
|
return await this.#f();
|
|
3103
3108
|
}
|
|
3104
|
-
decToHex(
|
|
3105
|
-
return typeof
|
|
3109
|
+
decToHex(e) {
|
|
3110
|
+
return typeof e == "string" && (e = parseInt(e, 10)), e.toString(16);
|
|
3106
3111
|
}
|
|
3107
|
-
hexToDec(
|
|
3108
|
-
return parseInt(
|
|
3112
|
+
hexToDec(e) {
|
|
3113
|
+
return parseInt(e, 16);
|
|
3109
3114
|
}
|
|
3110
|
-
hexMaker(
|
|
3111
|
-
return
|
|
3115
|
+
hexMaker(e = "00", t = 2) {
|
|
3116
|
+
return e.toString().padStart(t, "0").toLowerCase();
|
|
3112
3117
|
}
|
|
3113
|
-
add0x(
|
|
3114
|
-
const
|
|
3115
|
-
return
|
|
3116
|
-
|
|
3117
|
-
}),
|
|
3118
|
+
add0x(e) {
|
|
3119
|
+
const t = [];
|
|
3120
|
+
return e.forEach((n, r) => {
|
|
3121
|
+
t[r] = "0x" + n;
|
|
3122
|
+
}), t;
|
|
3118
3123
|
}
|
|
3119
|
-
bytesToHex(
|
|
3120
|
-
return this.add0x(Array.from(
|
|
3124
|
+
bytesToHex(e) {
|
|
3125
|
+
return this.add0x(Array.from(e, (t) => this.hexMaker(t)));
|
|
3121
3126
|
}
|
|
3122
3127
|
#y() {
|
|
3123
3128
|
[
|
|
@@ -3136,36 +3141,41 @@ class le extends et {
|
|
|
3136
3141
|
"serial:unsupported",
|
|
3137
3142
|
"serial:error",
|
|
3138
3143
|
"debug"
|
|
3139
|
-
].forEach((
|
|
3140
|
-
this.serialRegisterAvailableListener(
|
|
3144
|
+
].forEach((e) => {
|
|
3145
|
+
this.serialRegisterAvailableListener(e);
|
|
3141
3146
|
});
|
|
3142
3147
|
}
|
|
3143
3148
|
#g() {
|
|
3144
|
-
const
|
|
3149
|
+
const e = this;
|
|
3145
3150
|
this.on("internal:queue", async () => {
|
|
3146
|
-
await
|
|
3151
|
+
await e.#b();
|
|
3147
3152
|
}), this.#m();
|
|
3148
3153
|
}
|
|
3149
3154
|
#m() {
|
|
3150
|
-
const
|
|
3155
|
+
const e = this;
|
|
3151
3156
|
navigator.serial.addEventListener("connect", async () => {
|
|
3152
|
-
|
|
3157
|
+
e.isDisconnected && await e.serialConnect().catch(() => {
|
|
3153
3158
|
});
|
|
3154
3159
|
});
|
|
3155
3160
|
}
|
|
3156
3161
|
async #b() {
|
|
3157
3162
|
if (!this.#s(this.__internal__.serial.port)) {
|
|
3158
|
-
this.#
|
|
3163
|
+
this.#e({ error: "Port is closed, not readable or writable." }), await this.serialConnect();
|
|
3164
|
+
return;
|
|
3165
|
+
}
|
|
3166
|
+
if (this.__internal__.timeout.until_response) return;
|
|
3167
|
+
if (this.__internal__.serial.queue.length === 0) {
|
|
3168
|
+
this.__internal__.serial.running_queue = !1;
|
|
3159
3169
|
return;
|
|
3160
3170
|
}
|
|
3161
|
-
|
|
3162
|
-
const
|
|
3163
|
-
let
|
|
3164
|
-
if (
|
|
3165
|
-
await this.timeout(
|
|
3166
|
-
},
|
|
3167
|
-
action:
|
|
3168
|
-
bytes:
|
|
3171
|
+
this.__internal__.serial.running_queue = !0;
|
|
3172
|
+
const e = this.__internal__.serial.queue[0];
|
|
3173
|
+
let t = this.__internal__.time.response_general;
|
|
3174
|
+
if (e.action === "connect" && (t = this.__internal__.time.response_connection), this.__internal__.timeout.until_response = setTimeout(async () => {
|
|
3175
|
+
await this.timeout(e.bytes, e.action);
|
|
3176
|
+
}, t), this.__internal__.serial.last_action = e.action ?? "unknown", await this.#a(e.bytes), this.dispatch("serial:sent", {
|
|
3177
|
+
action: e.action,
|
|
3178
|
+
bytes: e.bytes
|
|
3169
3179
|
}), this.__internal__.auto_response) {
|
|
3170
3180
|
let r = new Uint8Array(0);
|
|
3171
3181
|
try {
|
|
@@ -3176,43 +3186,43 @@ class le extends et {
|
|
|
3176
3186
|
this.#n(r);
|
|
3177
3187
|
}
|
|
3178
3188
|
const n = [...this.__internal__.serial.queue];
|
|
3179
|
-
this.__internal__.serial.queue = n.splice(1);
|
|
3180
|
-
}
|
|
3181
|
-
validateBytes(
|
|
3182
|
-
let
|
|
3183
|
-
if (
|
|
3184
|
-
|
|
3185
|
-
else if (typeof
|
|
3186
|
-
|
|
3187
|
-
else if (Array.isArray(
|
|
3188
|
-
|
|
3189
|
-
else if (Array.isArray(
|
|
3190
|
-
|
|
3189
|
+
this.__internal__.serial.queue = n.splice(1), this.__internal__.serial.queue.length > 0 && (this.__internal__.serial.running_queue = !0);
|
|
3190
|
+
}
|
|
3191
|
+
validateBytes(e) {
|
|
3192
|
+
let t = new Uint8Array(0);
|
|
3193
|
+
if (e instanceof Uint8Array)
|
|
3194
|
+
t = e;
|
|
3195
|
+
else if (typeof e == "string")
|
|
3196
|
+
t = this.parseStringToTextEncoder(e);
|
|
3197
|
+
else if (Array.isArray(e) && typeof e[0] == "string")
|
|
3198
|
+
t = this.stringArrayToUint8Array(e);
|
|
3199
|
+
else if (Array.isArray(e) && typeof e[0] == "number")
|
|
3200
|
+
t = new Uint8Array(e);
|
|
3191
3201
|
else
|
|
3192
3202
|
throw new Error("Invalid data type");
|
|
3193
|
-
return
|
|
3203
|
+
return t;
|
|
3194
3204
|
}
|
|
3195
|
-
async appendToQueue(
|
|
3196
|
-
const n = this.validateBytes(
|
|
3197
|
-
if (["connect", "connection:start"].includes(
|
|
3205
|
+
async appendToQueue(e, t) {
|
|
3206
|
+
const n = this.validateBytes(e);
|
|
3207
|
+
if (["connect", "connection:start"].includes(t)) {
|
|
3198
3208
|
if (this.__internal__.serial.connected) return;
|
|
3199
3209
|
await this.serialConnect();
|
|
3200
3210
|
return;
|
|
3201
3211
|
}
|
|
3202
|
-
this.__internal__.serial.queue.push({ bytes: n, action:
|
|
3212
|
+
this.__internal__.serial.queue.push({ bytes: n, action: t }), this.dispatch("internal:queue", {});
|
|
3203
3213
|
}
|
|
3204
|
-
#w(
|
|
3205
|
-
this.__internal__.device_number =
|
|
3214
|
+
#w(e = 1) {
|
|
3215
|
+
this.__internal__.device_number = e, !this.__internal__.bypassSerialBytesConnection && (this.__internal__.serial.bytes_connection = this.serialSetConnectionConstant(e));
|
|
3206
3216
|
}
|
|
3207
|
-
serialSetConnectionConstant(
|
|
3217
|
+
serialSetConnectionConstant(e = 1) {
|
|
3208
3218
|
if (this.__internal__.bypassSerialBytesConnection) return this.__internal__.serial.bytes_connection;
|
|
3209
|
-
throw new Error(`Method not implemented 'serialSetConnectionConstant' to listen on channel ${
|
|
3219
|
+
throw new Error(`Method not implemented 'serialSetConnectionConstant' to listen on channel ${e}`);
|
|
3210
3220
|
}
|
|
3211
|
-
serialMessage(
|
|
3212
|
-
throw console.log(
|
|
3221
|
+
serialMessage(e) {
|
|
3222
|
+
throw console.log(e), this.dispatch("serial:message", { code: e }), new Error("Method not implemented 'serialMessage'");
|
|
3213
3223
|
}
|
|
3214
|
-
serialCorruptMessage(
|
|
3215
|
-
throw console.log(
|
|
3224
|
+
serialCorruptMessage(e) {
|
|
3225
|
+
throw console.log(e), this.dispatch("serial:corrupt-message", { code: e }), new Error("Method not implemented 'serialCorruptMessage'");
|
|
3216
3226
|
}
|
|
3217
3227
|
#v() {
|
|
3218
3228
|
this.__internal__.last_error = {
|
|
@@ -3225,11 +3235,11 @@ class le extends et {
|
|
|
3225
3235
|
clearSerialQueue() {
|
|
3226
3236
|
this.__internal__.serial.queue = [];
|
|
3227
3237
|
}
|
|
3228
|
-
sumHex(
|
|
3229
|
-
let
|
|
3230
|
-
return
|
|
3231
|
-
|
|
3232
|
-
}),
|
|
3238
|
+
sumHex(e) {
|
|
3239
|
+
let t = 0;
|
|
3240
|
+
return e.forEach((n) => {
|
|
3241
|
+
t += parseInt(n, 16);
|
|
3242
|
+
}), t.toString(16);
|
|
3233
3243
|
}
|
|
3234
3244
|
toString() {
|
|
3235
3245
|
return JSON.stringify({
|
|
@@ -3248,61 +3258,61 @@ class le extends et {
|
|
|
3248
3258
|
throw new Error("No connection bytes defined");
|
|
3249
3259
|
await this.appendToQueue(this.__internal__.serial.bytes_connection, "connect");
|
|
3250
3260
|
}
|
|
3251
|
-
async sendCustomCode({ code:
|
|
3252
|
-
if (!
|
|
3261
|
+
async sendCustomCode({ code: e = [] } = { code: [] }) {
|
|
3262
|
+
if (!e)
|
|
3253
3263
|
throw new Error("No data to send");
|
|
3254
|
-
this.__internal__.bypassSerialBytesConnection && (this.__internal__.serial.bytes_connection = this.validateBytes(
|
|
3264
|
+
this.__internal__.bypassSerialBytesConnection && (this.__internal__.serial.bytes_connection = this.validateBytes(e)), await this.appendToQueue(e, "custom");
|
|
3255
3265
|
}
|
|
3256
|
-
stringToArrayHex(
|
|
3257
|
-
return Array.from(
|
|
3266
|
+
stringToArrayHex(e) {
|
|
3267
|
+
return Array.from(e).map((t) => t.charCodeAt(0).toString(16));
|
|
3258
3268
|
}
|
|
3259
|
-
stringToArrayBuffer(
|
|
3269
|
+
stringToArrayBuffer(e, t = `
|
|
3260
3270
|
`) {
|
|
3261
|
-
return this.parseStringToTextEncoder(
|
|
3271
|
+
return this.parseStringToTextEncoder(e, t).buffer;
|
|
3262
3272
|
}
|
|
3263
|
-
parseStringToTextEncoder(
|
|
3273
|
+
parseStringToTextEncoder(e = "", t = `
|
|
3264
3274
|
`) {
|
|
3265
3275
|
const n = new TextEncoder();
|
|
3266
|
-
return
|
|
3276
|
+
return e += t, n.encode(e);
|
|
3267
3277
|
}
|
|
3268
|
-
parseStringToBytes(
|
|
3278
|
+
parseStringToBytes(e = "", t = `
|
|
3269
3279
|
`) {
|
|
3270
|
-
const n = this.parseStringToTextEncoder(
|
|
3280
|
+
const n = this.parseStringToTextEncoder(e, t);
|
|
3271
3281
|
return Array.from(n).map((r) => r.toString(16));
|
|
3272
3282
|
}
|
|
3273
|
-
parseUint8ToHex(
|
|
3274
|
-
return Array.from(
|
|
3283
|
+
parseUint8ToHex(e) {
|
|
3284
|
+
return Array.from(e).map((t) => t.toString(16).padStart(2, "0").toLowerCase());
|
|
3275
3285
|
}
|
|
3276
|
-
parseHexToUint8(
|
|
3277
|
-
return new Uint8Array(
|
|
3286
|
+
parseHexToUint8(e) {
|
|
3287
|
+
return new Uint8Array(e.map((t) => parseInt(t, 16)));
|
|
3278
3288
|
}
|
|
3279
|
-
stringArrayToUint8Array(
|
|
3280
|
-
const
|
|
3281
|
-
return typeof
|
|
3289
|
+
stringArrayToUint8Array(e) {
|
|
3290
|
+
const t = [];
|
|
3291
|
+
return typeof e == "string" ? this.parseStringToTextEncoder(e).buffer : (e.forEach((n) => {
|
|
3282
3292
|
const r = n.replace("0x", "");
|
|
3283
|
-
|
|
3284
|
-
}), new Uint8Array(
|
|
3293
|
+
t.push(parseInt(r, 16));
|
|
3294
|
+
}), new Uint8Array(t));
|
|
3285
3295
|
}
|
|
3286
|
-
parseUint8ArrayToString(
|
|
3287
|
-
let
|
|
3288
|
-
|
|
3289
|
-
const n =
|
|
3296
|
+
parseUint8ArrayToString(e) {
|
|
3297
|
+
let t = new Uint8Array(0);
|
|
3298
|
+
e instanceof Uint8Array ? t = e : t = this.stringArrayToUint8Array(e), e = this.parseUint8ToHex(t);
|
|
3299
|
+
const n = e.map((r) => parseInt(r, 16));
|
|
3290
3300
|
return this.__internal__.serial.response.replacer ? String.fromCharCode(...n).replace(this.__internal__.serial.response.replacer, "") : String.fromCharCode(...n);
|
|
3291
3301
|
}
|
|
3292
|
-
hexToAscii(
|
|
3293
|
-
const
|
|
3302
|
+
hexToAscii(e) {
|
|
3303
|
+
const t = e.toString();
|
|
3294
3304
|
let n = "";
|
|
3295
|
-
for (let r = 0; r <
|
|
3296
|
-
n += String.fromCharCode(parseInt(
|
|
3305
|
+
for (let r = 0; r < t.length; r += 2)
|
|
3306
|
+
n += String.fromCharCode(parseInt(t.substring(r, 2), 16));
|
|
3297
3307
|
return n;
|
|
3298
3308
|
}
|
|
3299
|
-
asciiToHex(
|
|
3300
|
-
const
|
|
3301
|
-
for (let n = 0, r =
|
|
3302
|
-
const i = Number(
|
|
3303
|
-
|
|
3309
|
+
asciiToHex(e) {
|
|
3310
|
+
const t = [];
|
|
3311
|
+
for (let n = 0, r = e.length; n < r; n++) {
|
|
3312
|
+
const i = Number(e.charCodeAt(n)).toString(16);
|
|
3313
|
+
t.push(i);
|
|
3304
3314
|
}
|
|
3305
|
-
return
|
|
3315
|
+
return t.join("");
|
|
3306
3316
|
}
|
|
3307
3317
|
$checkAndDispatchConnection() {
|
|
3308
3318
|
return this.isConnected;
|
|
@@ -3311,5 +3321,5 @@ class le extends et {
|
|
|
3311
3321
|
export {
|
|
3312
3322
|
A,
|
|
3313
3323
|
a,
|
|
3314
|
-
|
|
3324
|
+
lt as u
|
|
3315
3325
|
};
|