nsd-ble 0.2.1 → 0.2.2
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/Objects-CS29rf_8.cjs +1 -0
- package/dist/Objects-RyXOt964.js +867 -0
- package/dist/main.cjs +1 -1
- package/dist/main.js +143 -217
- package/dist/objects.cjs +1 -1
- package/dist/objects.js +4 -3
- package/dist/types/Objects.d.ts +2 -1
- package/package.json +1 -1
- package/dist/Objects-CmJJGRgZ.js +0 -792
- package/dist/Objects-DgZKSQY-.cjs +0 -1
|
@@ -0,0 +1,867 @@
|
|
|
1
|
+
import { Data as L, DataType as J, Button as k } from "./enums.js";
|
|
2
|
+
let H = !1, B = [], M, ce, U = /* @__PURE__ */ new Map();
|
|
3
|
+
async function we(t) {
|
|
4
|
+
try {
|
|
5
|
+
if (M = await navigator.bluetooth.requestDevice(t), M.gatt === void 0)
|
|
6
|
+
throw new Error("Device does not support GATT");
|
|
7
|
+
ce = await M.gatt.connect(), M.addEventListener("gattserverdisconnected", me), H = !0;
|
|
8
|
+
} catch (c) {
|
|
9
|
+
throw c;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function me() {
|
|
13
|
+
U.clear(), H = !1, B.forEach((t) => t());
|
|
14
|
+
}
|
|
15
|
+
function Ce(t) {
|
|
16
|
+
B.push(t);
|
|
17
|
+
}
|
|
18
|
+
function Ae(t) {
|
|
19
|
+
B = B.filter((c) => c !== t);
|
|
20
|
+
}
|
|
21
|
+
async function X(t, c) {
|
|
22
|
+
if (U.has(c)) {
|
|
23
|
+
const d = U.get(c);
|
|
24
|
+
if (d === void 0)
|
|
25
|
+
throw new Error("Characteristic not found");
|
|
26
|
+
return d;
|
|
27
|
+
}
|
|
28
|
+
const h = await (await ce.getPrimaryService(t)).getCharacteristic(c);
|
|
29
|
+
return U.set(c, h), h;
|
|
30
|
+
}
|
|
31
|
+
async function be(t, c) {
|
|
32
|
+
return await (await X(t, c)).readValue();
|
|
33
|
+
}
|
|
34
|
+
async function Se(t, c, r) {
|
|
35
|
+
const h = new DataView(new ArrayBuffer(r.length));
|
|
36
|
+
for (let l = 0; l < r.length; l++)
|
|
37
|
+
h.setUint8(l, r[l]);
|
|
38
|
+
await (await X(t, c)).writeValue(h);
|
|
39
|
+
}
|
|
40
|
+
async function qe(t, c, r) {
|
|
41
|
+
const h = await X(t, c);
|
|
42
|
+
h.addEventListener(
|
|
43
|
+
"characteristicvaluechanged",
|
|
44
|
+
(d) => {
|
|
45
|
+
let l = d.target.value;
|
|
46
|
+
l === void 0 && (l = new DataView(new ArrayBuffer(0))), r(l);
|
|
47
|
+
}
|
|
48
|
+
), await h.startNotifications();
|
|
49
|
+
}
|
|
50
|
+
function he() {
|
|
51
|
+
return {
|
|
52
|
+
connected: H,
|
|
53
|
+
connect: we,
|
|
54
|
+
readCharacteristic: be,
|
|
55
|
+
writeCharacteristic: Se,
|
|
56
|
+
subscribe: qe,
|
|
57
|
+
setDisconnectCallback: Ce,
|
|
58
|
+
removeDisconnectCallback: Ae
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const le = "19b10000-e8f2-537e-4f6c-d104768a1214", Oe = "6b061bdc-9bc1-4952-a96f-c6ed551b2c3e", Pe = "998ff920-81af-42a9-a915-f88025f9647d", De = {
|
|
62
|
+
filters: [{ namePrefix: "BLE-STANDEE" }],
|
|
63
|
+
optionalServices: [le]
|
|
64
|
+
};
|
|
65
|
+
function fe() {
|
|
66
|
+
return {
|
|
67
|
+
serviceUuid: le,
|
|
68
|
+
messageCharUuid: Oe,
|
|
69
|
+
handshakeCharUuid: Pe,
|
|
70
|
+
options: De
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
var A = {}, q = {}, x;
|
|
74
|
+
function V() {
|
|
75
|
+
if (x) return q;
|
|
76
|
+
x = 1, Object.defineProperty(q, "__esModule", { value: !0 }), q.BaseEvent = void 0;
|
|
77
|
+
var t = (
|
|
78
|
+
/** @class */
|
|
79
|
+
(function() {
|
|
80
|
+
function c() {
|
|
81
|
+
}
|
|
82
|
+
return c.prototype.attach = function(r, h) {
|
|
83
|
+
return this._attach(r, h, !1);
|
|
84
|
+
}, c.prototype.once = function(r, h) {
|
|
85
|
+
return this._attach(r, h, !0);
|
|
86
|
+
}, c.prototype._attach = function(r, h, d) {
|
|
87
|
+
var l = this, u, o, i, a;
|
|
88
|
+
if (typeof r == "function")
|
|
89
|
+
o = r, a = function() {
|
|
90
|
+
return l.detach(o);
|
|
91
|
+
};
|
|
92
|
+
else if (!h && typeof r.post == "function")
|
|
93
|
+
i = r, a = function() {
|
|
94
|
+
return l.detach(i);
|
|
95
|
+
};
|
|
96
|
+
else {
|
|
97
|
+
if (typeof r != "object" || r === void 0)
|
|
98
|
+
throw new Error("Expect a function or object as first argument");
|
|
99
|
+
if (typeof h != "function")
|
|
100
|
+
throw new Error("Expect a function as second argument");
|
|
101
|
+
u = r, o = h, a = function() {
|
|
102
|
+
return l.detach(u, o);
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
return this._listeners ? this._listeners = this._listeners.slice() : this._listeners = [], this._listeners.push({
|
|
106
|
+
deleted: !1,
|
|
107
|
+
boundTo: u,
|
|
108
|
+
handler: o,
|
|
109
|
+
event: i,
|
|
110
|
+
once: d
|
|
111
|
+
}), a;
|
|
112
|
+
}, c.prototype.detach = function() {
|
|
113
|
+
for (var r = [], h = 0; h < arguments.length; h++)
|
|
114
|
+
r[h] = arguments[h];
|
|
115
|
+
this._detach.apply(this, r);
|
|
116
|
+
}, c.prototype._detach = function() {
|
|
117
|
+
for (var r = [], h = 0; h < arguments.length; h++)
|
|
118
|
+
r[h] = arguments[h];
|
|
119
|
+
if (!(!this._listeners || this._listeners.length === 0)) {
|
|
120
|
+
var d, l, u;
|
|
121
|
+
r.length >= 1 && (typeof r[0] == "function" ? l = r[0] : r.length === 1 && typeof r[0].post == "function" ? u = r[0] : d = r[0]), r.length >= 2 && (l = r[1]), this._listeners = this._listeners.filter(function(o) {
|
|
122
|
+
return (typeof l > "u" || o.handler === l) && (typeof u > "u" || o.event === u) && (typeof d > "u" || o.boundTo === d) ? (o.deleted = !0, !1) : !0;
|
|
123
|
+
}), this._listeners.length === 0 && delete this._listeners;
|
|
124
|
+
}
|
|
125
|
+
}, c.prototype.post = function(r) {
|
|
126
|
+
throw new Error("abstract");
|
|
127
|
+
}, c.prototype.listenerCount = function() {
|
|
128
|
+
return this._listeners ? this._listeners.length : 0;
|
|
129
|
+
}, c.prototype._call = function(r, h) {
|
|
130
|
+
this._listeners && (r.deleted || (r.once && (r.deleted = !0, this._listeners = this._listeners.filter(function(d) {
|
|
131
|
+
return d !== r;
|
|
132
|
+
}), this._listeners.length === 0 && delete this._listeners), r.event ? r.event.post.apply(r.event, h) : r.handler && r.handler.apply(typeof r.boundTo == "object" ? r.boundTo : this, h)));
|
|
133
|
+
}, c;
|
|
134
|
+
})()
|
|
135
|
+
);
|
|
136
|
+
return q.BaseEvent = t, q;
|
|
137
|
+
}
|
|
138
|
+
var E = {}, ee;
|
|
139
|
+
function Q() {
|
|
140
|
+
if (ee) return E;
|
|
141
|
+
ee = 1;
|
|
142
|
+
var t = E && E.__extends || /* @__PURE__ */ (function() {
|
|
143
|
+
var l = function(u, o) {
|
|
144
|
+
return l = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(i, a) {
|
|
145
|
+
i.__proto__ = a;
|
|
146
|
+
} || function(i, a) {
|
|
147
|
+
for (var n in a) a.hasOwnProperty(n) && (i[n] = a[n]);
|
|
148
|
+
}, l(u, o);
|
|
149
|
+
};
|
|
150
|
+
return function(u, o) {
|
|
151
|
+
l(u, o);
|
|
152
|
+
function i() {
|
|
153
|
+
this.constructor = u;
|
|
154
|
+
}
|
|
155
|
+
u.prototype = o === null ? Object.create(o) : (i.prototype = o.prototype, new i());
|
|
156
|
+
};
|
|
157
|
+
})();
|
|
158
|
+
Object.defineProperty(E, "__esModule", { value: !0 }), E.ErrorSyncEvent = E.VoidSyncEvent = E.SyncEvent = void 0;
|
|
159
|
+
var c = V(), r = (
|
|
160
|
+
/** @class */
|
|
161
|
+
(function(l) {
|
|
162
|
+
t(u, l);
|
|
163
|
+
function u() {
|
|
164
|
+
var o = l !== null && l.apply(this, arguments) || this;
|
|
165
|
+
return o._recursion = 0, o;
|
|
166
|
+
}
|
|
167
|
+
return Object.defineProperty(u.prototype, "evtListenersChanged", {
|
|
168
|
+
/**
|
|
169
|
+
* Sent when someone attaches or detaches
|
|
170
|
+
*/
|
|
171
|
+
get: function() {
|
|
172
|
+
return this._listenersChanged || (this._listenersChanged = new h()), this._listenersChanged;
|
|
173
|
+
},
|
|
174
|
+
enumerable: !1,
|
|
175
|
+
configurable: !0
|
|
176
|
+
}), u.prototype.post = function() {
|
|
177
|
+
for (var o = [], i = 0; i < arguments.length; i++)
|
|
178
|
+
o[i] = arguments[i];
|
|
179
|
+
if (!(!this._listeners || this._listeners.length === 0)) {
|
|
180
|
+
if (this._recursion++, typeof u.MAX_RECURSION_DEPTH == "number" && Number.isInteger(u.MAX_RECURSION_DEPTH) && u.MAX_RECURSION_DEPTH > 0 && this._recursion > u.MAX_RECURSION_DEPTH)
|
|
181
|
+
throw new Error("event fired recursively");
|
|
182
|
+
for (var a = this._listeners, n = 0; n < a.length; ++n) {
|
|
183
|
+
var e = a[n];
|
|
184
|
+
this._call(e, o);
|
|
185
|
+
}
|
|
186
|
+
this._recursion--;
|
|
187
|
+
}
|
|
188
|
+
}, u.prototype._attach = function(o, i, a) {
|
|
189
|
+
var n, e, s, f, v = (e = (n = this._listeners) === null || n === void 0 ? void 0 : n.length) !== null && e !== void 0 ? e : 0, y = l.prototype._attach.call(this, o, i, a);
|
|
190
|
+
return this.evtListenersChanged && v !== ((f = (s = this._listeners) === null || s === void 0 ? void 0 : s.length) !== null && f !== void 0 ? f : 0) && this.evtListenersChanged.post(), y;
|
|
191
|
+
}, u.prototype._detach = function() {
|
|
192
|
+
for (var o, i, a, n, e = [], s = 0; s < arguments.length; s++)
|
|
193
|
+
e[s] = arguments[s];
|
|
194
|
+
var f = (i = (o = this._listeners) === null || o === void 0 ? void 0 : o.length) !== null && i !== void 0 ? i : 0, v = l.prototype._detach.apply(this, e);
|
|
195
|
+
return this.evtListenersChanged && f !== ((n = (a = this._listeners) === null || a === void 0 ? void 0 : a.length) !== null && n !== void 0 ? n : 0) && this.evtListenersChanged.post(), v;
|
|
196
|
+
}, u.MAX_RECURSION_DEPTH = 10, u;
|
|
197
|
+
})(c.BaseEvent)
|
|
198
|
+
);
|
|
199
|
+
E.SyncEvent = r;
|
|
200
|
+
var h = (
|
|
201
|
+
/** @class */
|
|
202
|
+
(function(l) {
|
|
203
|
+
t(u, l);
|
|
204
|
+
function u() {
|
|
205
|
+
return l !== null && l.apply(this, arguments) || this;
|
|
206
|
+
}
|
|
207
|
+
return u.prototype.post = function() {
|
|
208
|
+
l.prototype.post.call(this, void 0);
|
|
209
|
+
}, u;
|
|
210
|
+
})(r)
|
|
211
|
+
);
|
|
212
|
+
E.VoidSyncEvent = h;
|
|
213
|
+
var d = (
|
|
214
|
+
/** @class */
|
|
215
|
+
(function(l) {
|
|
216
|
+
t(u, l);
|
|
217
|
+
function u() {
|
|
218
|
+
return l !== null && l.apply(this, arguments) || this;
|
|
219
|
+
}
|
|
220
|
+
return u.prototype.post = function(o) {
|
|
221
|
+
if (this.listenerCount() === 0)
|
|
222
|
+
throw new Error("error event posted while no listeners attached. Error: " + o.message);
|
|
223
|
+
l.prototype.post.call(this, o);
|
|
224
|
+
}, u;
|
|
225
|
+
})(r)
|
|
226
|
+
);
|
|
227
|
+
return E.ErrorSyncEvent = d, E;
|
|
228
|
+
}
|
|
229
|
+
var w = {}, T = {}, te;
|
|
230
|
+
function $() {
|
|
231
|
+
if (te) return T;
|
|
232
|
+
te = 1, Object.defineProperty(T, "__esModule", { value: !0 });
|
|
233
|
+
var t = Q(), c = (
|
|
234
|
+
/** @class */
|
|
235
|
+
(function() {
|
|
236
|
+
function r() {
|
|
237
|
+
this.evtFilled = new t.SyncEvent(), this.evtDrained = new t.SyncEvent(), this._queue = [], this._flushing = !1;
|
|
238
|
+
}
|
|
239
|
+
return r.global = function() {
|
|
240
|
+
return r._instance || r.resetGlobal(), r._instance;
|
|
241
|
+
}, r.resetGlobal = function() {
|
|
242
|
+
r._instance = new r();
|
|
243
|
+
}, r.prototype.empty = function() {
|
|
244
|
+
return this._queue.length === 0;
|
|
245
|
+
}, r.prototype.add = function(h) {
|
|
246
|
+
this._queue.push(h), this._queue.length === 1 && !this._flushing && this.evtFilled.post(this);
|
|
247
|
+
}, r.prototype.flushOnce = function() {
|
|
248
|
+
var h = this._queue.length === 0, d = this._flushing;
|
|
249
|
+
this._flushing = !0;
|
|
250
|
+
try {
|
|
251
|
+
var l = this._queue;
|
|
252
|
+
this._queue = [];
|
|
253
|
+
for (var u = 0; u < l.length; ++u)
|
|
254
|
+
l[u]();
|
|
255
|
+
} finally {
|
|
256
|
+
this._flushing = d, !h && !d && this._queue.length === 0 && this.evtDrained.post(this);
|
|
257
|
+
}
|
|
258
|
+
}, r.prototype.flush = function(h) {
|
|
259
|
+
h === void 0 && (h = 10);
|
|
260
|
+
var d = this._queue.length === 0, l = this._flushing;
|
|
261
|
+
this._flushing = !0;
|
|
262
|
+
try {
|
|
263
|
+
for (var u = 0; this._queue.length > 0; ) {
|
|
264
|
+
if (typeof h == "number" && u >= h)
|
|
265
|
+
throw this._queue = [], new Error("unable to flush the queue due to recursively added event. Clearing queue now");
|
|
266
|
+
this.flushOnce(), ++u;
|
|
267
|
+
}
|
|
268
|
+
} finally {
|
|
269
|
+
this._flushing = l, !d && !l && this._queue.length === 0 && this.evtDrained.post(this);
|
|
270
|
+
}
|
|
271
|
+
}, r;
|
|
272
|
+
})()
|
|
273
|
+
);
|
|
274
|
+
return T.default = c, T;
|
|
275
|
+
}
|
|
276
|
+
var ne;
|
|
277
|
+
function ve() {
|
|
278
|
+
if (ne) return w;
|
|
279
|
+
ne = 1;
|
|
280
|
+
var t = w && w.__extends || /* @__PURE__ */ (function() {
|
|
281
|
+
var o = function(i, a) {
|
|
282
|
+
return o = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, e) {
|
|
283
|
+
n.__proto__ = e;
|
|
284
|
+
} || function(n, e) {
|
|
285
|
+
for (var s in e) e.hasOwnProperty(s) && (n[s] = e[s]);
|
|
286
|
+
}, o(i, a);
|
|
287
|
+
};
|
|
288
|
+
return function(i, a) {
|
|
289
|
+
o(i, a);
|
|
290
|
+
function n() {
|
|
291
|
+
this.constructor = i;
|
|
292
|
+
}
|
|
293
|
+
i.prototype = a === null ? Object.create(a) : (n.prototype = a.prototype, new n());
|
|
294
|
+
};
|
|
295
|
+
})();
|
|
296
|
+
Object.defineProperty(w, "__esModule", { value: !0 }), w.ErrorQueuedEvent = w.VoidQueuedEvent = w.QueuedEvent = void 0;
|
|
297
|
+
var c = V(), r = $(), h = Q(), d = (
|
|
298
|
+
/** @class */
|
|
299
|
+
(function(o) {
|
|
300
|
+
t(i, o);
|
|
301
|
+
function i(a) {
|
|
302
|
+
a === void 0 && (a = {});
|
|
303
|
+
var n = o.call(this) || this;
|
|
304
|
+
return n._queued = !1, n.options = a, typeof a.condensed == "boolean" ? n._condensed = a.condensed : n._condensed = !1, typeof a.queue == "object" && a.queue !== null && (n._queue = a.queue), n;
|
|
305
|
+
}
|
|
306
|
+
return Object.defineProperty(i.prototype, "evtListenersChanged", {
|
|
307
|
+
/**
|
|
308
|
+
* Sent when someone attaches or detaches
|
|
309
|
+
*/
|
|
310
|
+
get: function() {
|
|
311
|
+
return this._listenersChanged || (this._listenersChanged = new h.VoidSyncEvent()), this._listenersChanged;
|
|
312
|
+
},
|
|
313
|
+
enumerable: !1,
|
|
314
|
+
configurable: !0
|
|
315
|
+
}), i.prototype.post = function() {
|
|
316
|
+
for (var a = this, n = [], e = 0; e < arguments.length; e++)
|
|
317
|
+
n[e] = arguments[e];
|
|
318
|
+
if (!(!this._listeners || this._listeners.length === 0)) {
|
|
319
|
+
var s = this._queue ? this._queue : r.default.global();
|
|
320
|
+
if (this._condensed) {
|
|
321
|
+
if (this._queuedData = n, this._queuedListeners = this._listeners, this._queued)
|
|
322
|
+
return;
|
|
323
|
+
this._queued = !0, s.add(function() {
|
|
324
|
+
a._queued = !1;
|
|
325
|
+
for (var v = a._queuedData, y = a._queuedListeners, p = 0; p < y.length; ++p) {
|
|
326
|
+
var g = y[p];
|
|
327
|
+
a._call(g, v);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
} else {
|
|
331
|
+
var f = this._listeners;
|
|
332
|
+
s.add(function() {
|
|
333
|
+
for (var v = 0; v < f.length; ++v) {
|
|
334
|
+
var y = f[v];
|
|
335
|
+
a._call(y, n);
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}, i.prototype._attach = function(a, n, e) {
|
|
341
|
+
var s, f, v, y, p = (f = (s = this._listeners) === null || s === void 0 ? void 0 : s.length) !== null && f !== void 0 ? f : 0, g = o.prototype._attach.call(this, a, n, e);
|
|
342
|
+
return this.evtListenersChanged && p !== ((y = (v = this._listeners) === null || v === void 0 ? void 0 : v.length) !== null && y !== void 0 ? y : 0) && this.evtListenersChanged.post(), g;
|
|
343
|
+
}, i.prototype._detach = function() {
|
|
344
|
+
for (var a, n, e, s, f = [], v = 0; v < arguments.length; v++)
|
|
345
|
+
f[v] = arguments[v];
|
|
346
|
+
var y = (n = (a = this._listeners) === null || a === void 0 ? void 0 : a.length) !== null && n !== void 0 ? n : 0, p = o.prototype._detach.apply(this, f);
|
|
347
|
+
return this.evtListenersChanged && y !== ((s = (e = this._listeners) === null || e === void 0 ? void 0 : e.length) !== null && s !== void 0 ? s : 0) && this.evtListenersChanged.post(), p;
|
|
348
|
+
}, i;
|
|
349
|
+
})(c.BaseEvent)
|
|
350
|
+
);
|
|
351
|
+
w.QueuedEvent = d;
|
|
352
|
+
var l = (
|
|
353
|
+
/** @class */
|
|
354
|
+
(function(o) {
|
|
355
|
+
t(i, o);
|
|
356
|
+
function i() {
|
|
357
|
+
return o !== null && o.apply(this, arguments) || this;
|
|
358
|
+
}
|
|
359
|
+
return i.prototype.post = function() {
|
|
360
|
+
o.prototype.post.call(this, void 0);
|
|
361
|
+
}, i;
|
|
362
|
+
})(d)
|
|
363
|
+
);
|
|
364
|
+
w.VoidQueuedEvent = l;
|
|
365
|
+
var u = (
|
|
366
|
+
/** @class */
|
|
367
|
+
(function(o) {
|
|
368
|
+
t(i, o);
|
|
369
|
+
function i() {
|
|
370
|
+
return o !== null && o.apply(this, arguments) || this;
|
|
371
|
+
}
|
|
372
|
+
return i.prototype.post = function(a) {
|
|
373
|
+
if (!this._listeners || this._listeners.length === 0)
|
|
374
|
+
throw new Error("error event posted while no listeners attached. Error: " + a.message);
|
|
375
|
+
o.prototype.post.call(this, a);
|
|
376
|
+
}, i;
|
|
377
|
+
})(d)
|
|
378
|
+
);
|
|
379
|
+
return w.ErrorQueuedEvent = u, w;
|
|
380
|
+
}
|
|
381
|
+
var m = {}, re;
|
|
382
|
+
function de() {
|
|
383
|
+
if (re) return m;
|
|
384
|
+
re = 1;
|
|
385
|
+
var t = m && m.__extends || /* @__PURE__ */ (function() {
|
|
386
|
+
var u = function(o, i) {
|
|
387
|
+
return u = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(a, n) {
|
|
388
|
+
a.__proto__ = n;
|
|
389
|
+
} || function(a, n) {
|
|
390
|
+
for (var e in n) n.hasOwnProperty(e) && (a[e] = n[e]);
|
|
391
|
+
}, u(o, i);
|
|
392
|
+
};
|
|
393
|
+
return function(o, i) {
|
|
394
|
+
u(o, i);
|
|
395
|
+
function a() {
|
|
396
|
+
this.constructor = o;
|
|
397
|
+
}
|
|
398
|
+
o.prototype = i === null ? Object.create(i) : (a.prototype = i.prototype, new a());
|
|
399
|
+
};
|
|
400
|
+
})();
|
|
401
|
+
Object.defineProperty(m, "__esModule", { value: !0 }), m.ErrorAsyncEvent = m.VoidAsyncEvent = m.AsyncEvent = void 0;
|
|
402
|
+
var c = V(), r = Q(), h = (
|
|
403
|
+
/** @class */
|
|
404
|
+
(function(u) {
|
|
405
|
+
t(o, u);
|
|
406
|
+
function o(i) {
|
|
407
|
+
i === void 0 && (i = {});
|
|
408
|
+
var a = u.call(this) || this;
|
|
409
|
+
return a._queued = !1, a.options = i, typeof i.condensed == "boolean" ? a._condensed = i.condensed : a._condensed = !1, a;
|
|
410
|
+
}
|
|
411
|
+
return Object.defineProperty(o.prototype, "evtListenersChanged", {
|
|
412
|
+
/**
|
|
413
|
+
* Sent when someone attaches or detaches
|
|
414
|
+
*/
|
|
415
|
+
get: function() {
|
|
416
|
+
return this._listenersChanged || (this._listenersChanged = new r.VoidSyncEvent()), this._listenersChanged;
|
|
417
|
+
},
|
|
418
|
+
enumerable: !1,
|
|
419
|
+
configurable: !0
|
|
420
|
+
}), o.defaultScheduler = function(i) {
|
|
421
|
+
typeof window < "u" ? setTimeout(i, 0) : setImmediate(i);
|
|
422
|
+
}, o.setScheduler = function(i) {
|
|
423
|
+
o._scheduler = i;
|
|
424
|
+
}, o.prototype.post = function() {
|
|
425
|
+
for (var i = this, a = [], n = 0; n < arguments.length; n++)
|
|
426
|
+
a[n] = arguments[n];
|
|
427
|
+
if (!(!this._listeners || this._listeners.length === 0))
|
|
428
|
+
if (this._condensed) {
|
|
429
|
+
if (this._queuedData = a, this._queuedListeners = this._listeners, this._queued)
|
|
430
|
+
return;
|
|
431
|
+
this._queued = !0, o._scheduler(function() {
|
|
432
|
+
i._queued = !1;
|
|
433
|
+
for (var s = i._queuedData, f = i._queuedListeners, v = 0; v < f.length; ++v) {
|
|
434
|
+
var y = f[v];
|
|
435
|
+
i._call(y, s);
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
} else {
|
|
439
|
+
var e = this._listeners;
|
|
440
|
+
o._scheduler(function() {
|
|
441
|
+
for (var s = 0; s < e.length; ++s) {
|
|
442
|
+
var f = e[s];
|
|
443
|
+
i._call(f, a);
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
}, o.prototype._call = function(i, a) {
|
|
448
|
+
i.event && i.event instanceof o ? i.event._postDirect(a) : u.prototype._call.call(this, i, a);
|
|
449
|
+
}, o.prototype._postDirect = function(i) {
|
|
450
|
+
if (!(!this._listeners || this._listeners.length === 0))
|
|
451
|
+
for (var a = this._listeners, n = 0; n < a.length; ++n) {
|
|
452
|
+
var e = a[n];
|
|
453
|
+
this._call(e, i);
|
|
454
|
+
}
|
|
455
|
+
}, o.prototype._attach = function(i, a, n) {
|
|
456
|
+
var e, s, f, v, y = (s = (e = this._listeners) === null || e === void 0 ? void 0 : e.length) !== null && s !== void 0 ? s : 0, p = u.prototype._attach.call(this, i, a, n);
|
|
457
|
+
return this.evtListenersChanged && y !== ((v = (f = this._listeners) === null || f === void 0 ? void 0 : f.length) !== null && v !== void 0 ? v : 0) && this.evtListenersChanged.post(), p;
|
|
458
|
+
}, o.prototype._detach = function() {
|
|
459
|
+
for (var i, a, n, e, s = [], f = 0; f < arguments.length; f++)
|
|
460
|
+
s[f] = arguments[f];
|
|
461
|
+
var v = (a = (i = this._listeners) === null || i === void 0 ? void 0 : i.length) !== null && a !== void 0 ? a : 0, y = u.prototype._detach.apply(this, s);
|
|
462
|
+
return this.evtListenersChanged && v !== ((e = (n = this._listeners) === null || n === void 0 ? void 0 : n.length) !== null && e !== void 0 ? e : 0) && this.evtListenersChanged.post(), y;
|
|
463
|
+
}, o._scheduler = o.defaultScheduler, o;
|
|
464
|
+
})(c.BaseEvent)
|
|
465
|
+
);
|
|
466
|
+
m.AsyncEvent = h;
|
|
467
|
+
var d = (
|
|
468
|
+
/** @class */
|
|
469
|
+
(function(u) {
|
|
470
|
+
t(o, u);
|
|
471
|
+
function o() {
|
|
472
|
+
return u !== null && u.apply(this, arguments) || this;
|
|
473
|
+
}
|
|
474
|
+
return o.prototype.post = function() {
|
|
475
|
+
u.prototype.post.call(this, void 0);
|
|
476
|
+
}, o;
|
|
477
|
+
})(h)
|
|
478
|
+
);
|
|
479
|
+
m.VoidAsyncEvent = d;
|
|
480
|
+
var l = (
|
|
481
|
+
/** @class */
|
|
482
|
+
(function(u) {
|
|
483
|
+
t(o, u);
|
|
484
|
+
function o() {
|
|
485
|
+
return u !== null && u.apply(this, arguments) || this;
|
|
486
|
+
}
|
|
487
|
+
return o.prototype.post = function(i) {
|
|
488
|
+
if (this.listenerCount() === 0)
|
|
489
|
+
throw new Error("error event posted while no listeners attached. Error: " + i.message);
|
|
490
|
+
u.prototype.post.call(this, i);
|
|
491
|
+
}, o;
|
|
492
|
+
})(h)
|
|
493
|
+
);
|
|
494
|
+
return m.ErrorAsyncEvent = l, m;
|
|
495
|
+
}
|
|
496
|
+
var O = {}, P = {}, se;
|
|
497
|
+
function Le() {
|
|
498
|
+
if (se) return P;
|
|
499
|
+
se = 1, Object.defineProperty(P, "__esModule", { value: !0 }), P.shallowEquals = void 0;
|
|
500
|
+
function t(c, r) {
|
|
501
|
+
if (c === r)
|
|
502
|
+
return !0;
|
|
503
|
+
if (typeof c != typeof r)
|
|
504
|
+
return !1;
|
|
505
|
+
switch (typeof c) {
|
|
506
|
+
case "boolean":
|
|
507
|
+
case "number":
|
|
508
|
+
case "string":
|
|
509
|
+
case "function":
|
|
510
|
+
case "symbol":
|
|
511
|
+
case "undefined":
|
|
512
|
+
return !1;
|
|
513
|
+
case "object":
|
|
514
|
+
if (c === null || r === null)
|
|
515
|
+
return !1;
|
|
516
|
+
if (Array.isArray(c) || Array.isArray(r)) {
|
|
517
|
+
if (!Array.isArray(c) || !Array.isArray(r) || c.length !== r.length)
|
|
518
|
+
return !1;
|
|
519
|
+
for (var h = 0; h < c.length; ++h)
|
|
520
|
+
if (c[h] !== r[h])
|
|
521
|
+
return !1;
|
|
522
|
+
return !0;
|
|
523
|
+
}
|
|
524
|
+
var d = [], l = [];
|
|
525
|
+
for (var u in c)
|
|
526
|
+
c.hasOwnProperty(u) && d.push(u);
|
|
527
|
+
for (var o in r)
|
|
528
|
+
r.hasOwnProperty(o) && l.push(o);
|
|
529
|
+
if (d.sort(), l.sort(), d.join(",") !== l.join(","))
|
|
530
|
+
return !1;
|
|
531
|
+
for (var h = 0; h < d.length; ++h)
|
|
532
|
+
if (c[d[h]] !== r[d[h]])
|
|
533
|
+
return !1;
|
|
534
|
+
return !0;
|
|
535
|
+
default:
|
|
536
|
+
return !1;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
return P.shallowEquals = t, P;
|
|
540
|
+
}
|
|
541
|
+
var ie;
|
|
542
|
+
function je() {
|
|
543
|
+
return ie || (ie = 1, (function(t) {
|
|
544
|
+
var c = O && O.__extends || /* @__PURE__ */ (function() {
|
|
545
|
+
var n = function(e, s) {
|
|
546
|
+
return n = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(f, v) {
|
|
547
|
+
f.__proto__ = v;
|
|
548
|
+
} || function(f, v) {
|
|
549
|
+
for (var y in v) v.hasOwnProperty(y) && (f[y] = v[y]);
|
|
550
|
+
}, n(e, s);
|
|
551
|
+
};
|
|
552
|
+
return function(e, s) {
|
|
553
|
+
n(e, s);
|
|
554
|
+
function f() {
|
|
555
|
+
this.constructor = e;
|
|
556
|
+
}
|
|
557
|
+
e.prototype = s === null ? Object.create(s) : (f.prototype = s.prototype, new f());
|
|
558
|
+
};
|
|
559
|
+
})();
|
|
560
|
+
Object.defineProperty(t, "__esModule", { value: !0 }), t.ErrorAnyEvent = t.VoidAnyEvent = t.AnyEvent = t.EventType = void 0;
|
|
561
|
+
var r = Le(), h = Q(), d = de(), l = ve(), u;
|
|
562
|
+
(function(n) {
|
|
563
|
+
n[n.Sync = 0] = "Sync", n[n.Async = 1] = "Async", n[n.Queued = 2] = "Queued";
|
|
564
|
+
})(u = t.EventType || (t.EventType = {}));
|
|
565
|
+
var o = (
|
|
566
|
+
/** @class */
|
|
567
|
+
(function() {
|
|
568
|
+
function n(e) {
|
|
569
|
+
this._events = [], e && e.monitorAttach && (this.evtFirstAttached = new i(), this.evtLastDetached = new i());
|
|
570
|
+
}
|
|
571
|
+
return Object.defineProperty(n.prototype, "evtListenersChanged", {
|
|
572
|
+
/**
|
|
573
|
+
* Sent when someone attaches or detaches
|
|
574
|
+
*/
|
|
575
|
+
get: function() {
|
|
576
|
+
return this._listenersChanged || (this._listenersChanged = new h.VoidSyncEvent()), this._listenersChanged;
|
|
577
|
+
},
|
|
578
|
+
enumerable: !1,
|
|
579
|
+
configurable: !0
|
|
580
|
+
}), n.prototype.attach = function() {
|
|
581
|
+
for (var e = [], s = 0; s < arguments.length; s++)
|
|
582
|
+
e[s] = arguments[s];
|
|
583
|
+
var f = u.Sync;
|
|
584
|
+
e.length > 0 && typeof e[0] == "number" && (f = e.shift());
|
|
585
|
+
var v = this, y, p, g;
|
|
586
|
+
return typeof e[0] == "function" || e[0] && typeof e[0] == "object" && typeof e[0].post == "function" ? (typeof e[0] == "function" ? y = e[0] : g = e[0], p = e[1]) : (v = e[0], y = e[1], p = e[2]), this._attach(f, v, y, g, p, !1);
|
|
587
|
+
}, n.prototype.once = function() {
|
|
588
|
+
for (var e = [], s = 0; s < arguments.length; s++)
|
|
589
|
+
e[s] = arguments[s];
|
|
590
|
+
var f = u.Sync;
|
|
591
|
+
e.length > 0 && typeof e[0] == "number" && (f = e.shift());
|
|
592
|
+
var v = this, y, p, g;
|
|
593
|
+
return typeof e[0] == "function" || e[0] && typeof e[0] == "object" && typeof e[0].post == "function" ? (typeof e[0] == "function" ? y = e[0] : g = e[0], p = e[1]) : (v = e[0], y = e[1], p = e[2]), this._attach(f, v, y, g, p, !0);
|
|
594
|
+
}, n.prototype._attach = function(e, s, f, v, y, p) {
|
|
595
|
+
var g = this, Y = this.evtFirstAttached ? this.listenerCount() : 0, _;
|
|
596
|
+
switch (e) {
|
|
597
|
+
case u.Sync:
|
|
598
|
+
{
|
|
599
|
+
for (var R = 0, z = this._events; R < z.length; R++) {
|
|
600
|
+
var C = z[R];
|
|
601
|
+
C instanceof h.SyncEvent && (_ = C);
|
|
602
|
+
}
|
|
603
|
+
_ || (_ = new h.SyncEvent(), this._events.push(_));
|
|
604
|
+
}
|
|
605
|
+
break;
|
|
606
|
+
case u.Async:
|
|
607
|
+
{
|
|
608
|
+
for (var I = 0, K = this._events; I < K.length; I++) {
|
|
609
|
+
var C = K[I];
|
|
610
|
+
C instanceof d.AsyncEvent && r.shallowEquals(C.options, y) && (_ = C);
|
|
611
|
+
}
|
|
612
|
+
_ || (_ = new d.AsyncEvent(y), this._events.push(_));
|
|
613
|
+
}
|
|
614
|
+
break;
|
|
615
|
+
case u.Queued:
|
|
616
|
+
{
|
|
617
|
+
for (var N = 0, W = this._events; N < W.length; N++) {
|
|
618
|
+
var C = W[N];
|
|
619
|
+
C instanceof l.QueuedEvent && r.shallowEquals(C.options, y) && (_ = C);
|
|
620
|
+
}
|
|
621
|
+
_ || (_ = new l.QueuedEvent(y), this._events.push(_));
|
|
622
|
+
}
|
|
623
|
+
break;
|
|
624
|
+
default:
|
|
625
|
+
throw new Error("unknown EventType");
|
|
626
|
+
}
|
|
627
|
+
var S;
|
|
628
|
+
return p ? v ? S = _.once(v) : S = _.once(s, f) : v ? S = _.attach(v) : S = _.attach(s, f), this.evtFirstAttached && Y === 0 && this.evtFirstAttached.post(), this.evtListenersChanged && Y !== this.listenerCount() && this.evtListenersChanged.post(), function() {
|
|
629
|
+
var Z = g.evtLastDetached ? g.listenerCount() : 0;
|
|
630
|
+
S(), g.evtLastDetached && Z > 0 && g.listenerCount() === 0 && g.evtLastDetached.post(), g.evtListenersChanged && Z !== g.listenerCount() && g.evtListenersChanged.post();
|
|
631
|
+
};
|
|
632
|
+
}, n.prototype.attachSync = function() {
|
|
633
|
+
for (var e = [], s = 0; s < arguments.length; s++)
|
|
634
|
+
e[s] = arguments[s];
|
|
635
|
+
return e.unshift(u.Sync), this.attach.apply(this, e);
|
|
636
|
+
}, n.prototype.onceSync = function() {
|
|
637
|
+
for (var e = [], s = 0; s < arguments.length; s++)
|
|
638
|
+
e[s] = arguments[s];
|
|
639
|
+
return e.unshift(u.Sync), this.once.apply(this, e);
|
|
640
|
+
}, n.prototype.attachAsync = function() {
|
|
641
|
+
for (var e = [], s = 0; s < arguments.length; s++)
|
|
642
|
+
e[s] = arguments[s];
|
|
643
|
+
return e.unshift(u.Async), this.attach.apply(this, e);
|
|
644
|
+
}, n.prototype.onceAsync = function() {
|
|
645
|
+
for (var e = [], s = 0; s < arguments.length; s++)
|
|
646
|
+
e[s] = arguments[s];
|
|
647
|
+
return e.unshift(u.Async), this.once.apply(this, e);
|
|
648
|
+
}, n.prototype.attachQueued = function() {
|
|
649
|
+
for (var e = [], s = 0; s < arguments.length; s++)
|
|
650
|
+
e[s] = arguments[s];
|
|
651
|
+
return e.unshift(u.Queued), this.attach.apply(this, e);
|
|
652
|
+
}, n.prototype.onceQueued = function() {
|
|
653
|
+
for (var e = [], s = 0; s < arguments.length; s++)
|
|
654
|
+
e[s] = arguments[s];
|
|
655
|
+
return e.unshift(u.Queued), this.once.apply(this, e);
|
|
656
|
+
}, n.prototype.detach = function() {
|
|
657
|
+
for (var e = [], s = 0; s < arguments.length; s++)
|
|
658
|
+
e[s] = arguments[s];
|
|
659
|
+
for (var f = this.listenerCount(), v = 0; v < this._events.length; ++v)
|
|
660
|
+
this._events[v].detach.apply(this._events[v], e);
|
|
661
|
+
this.evtListenersChanged && f !== this.listenerCount() && this.evtListenersChanged.post(), this.evtLastDetached && f > 0 && this.listenerCount() === 0 && this.evtLastDetached.post();
|
|
662
|
+
}, n.prototype.post = function(e) {
|
|
663
|
+
for (var s = [], f = 0; f < this._events.length; ++f)
|
|
664
|
+
s.push(this._events[f]);
|
|
665
|
+
for (var f = 0; f < s.length; ++f)
|
|
666
|
+
s[f].post(e);
|
|
667
|
+
}, n.prototype.listenerCount = function() {
|
|
668
|
+
for (var e = 0, s = 0; s < this._events.length; ++s)
|
|
669
|
+
e += this._events[s].listenerCount();
|
|
670
|
+
return e;
|
|
671
|
+
}, n;
|
|
672
|
+
})()
|
|
673
|
+
);
|
|
674
|
+
t.AnyEvent = o;
|
|
675
|
+
var i = (
|
|
676
|
+
/** @class */
|
|
677
|
+
(function(n) {
|
|
678
|
+
c(e, n);
|
|
679
|
+
function e() {
|
|
680
|
+
return n !== null && n.apply(this, arguments) || this;
|
|
681
|
+
}
|
|
682
|
+
return e.prototype.post = function() {
|
|
683
|
+
n.prototype.post.call(this, void 0);
|
|
684
|
+
}, e;
|
|
685
|
+
})(o)
|
|
686
|
+
);
|
|
687
|
+
t.VoidAnyEvent = i;
|
|
688
|
+
var a = (
|
|
689
|
+
/** @class */
|
|
690
|
+
(function(n) {
|
|
691
|
+
c(e, n);
|
|
692
|
+
function e() {
|
|
693
|
+
return n !== null && n.apply(this, arguments) || this;
|
|
694
|
+
}
|
|
695
|
+
return e.prototype.post = function(s) {
|
|
696
|
+
if (this.listenerCount() === 0)
|
|
697
|
+
throw new Error("error event posted while no listeners attached. Error: " + s.message);
|
|
698
|
+
n.prototype.post.call(this, s);
|
|
699
|
+
}, e;
|
|
700
|
+
})(o)
|
|
701
|
+
);
|
|
702
|
+
t.ErrorAnyEvent = a;
|
|
703
|
+
})(O)), O;
|
|
704
|
+
}
|
|
705
|
+
var oe;
|
|
706
|
+
function Qe() {
|
|
707
|
+
return oe || (oe = 1, (function(t) {
|
|
708
|
+
var c = A && A.__createBinding || (Object.create ? (function(i, a, n, e) {
|
|
709
|
+
e === void 0 && (e = n), Object.defineProperty(i, e, { enumerable: !0, get: function() {
|
|
710
|
+
return a[n];
|
|
711
|
+
} });
|
|
712
|
+
}) : (function(i, a, n, e) {
|
|
713
|
+
e === void 0 && (e = n), i[e] = a[n];
|
|
714
|
+
})), r = A && A.__exportStar || function(i, a) {
|
|
715
|
+
for (var n in i) n !== "default" && !a.hasOwnProperty(n) && c(a, i, n);
|
|
716
|
+
};
|
|
717
|
+
Object.defineProperty(t, "__esModule", { value: !0 }), t.flush = t.flushOnce = t.queue = void 0, r(V(), t), r(Q(), t), r(ve(), t), r(de(), t), r(je(), t);
|
|
718
|
+
var h = $(), d = $();
|
|
719
|
+
Object.defineProperty(t, "EventQueue", { enumerable: !0, get: function() {
|
|
720
|
+
return d.default;
|
|
721
|
+
} });
|
|
722
|
+
function l() {
|
|
723
|
+
return h.default.global();
|
|
724
|
+
}
|
|
725
|
+
t.queue = l;
|
|
726
|
+
function u() {
|
|
727
|
+
h.default.global().flushOnce();
|
|
728
|
+
}
|
|
729
|
+
t.flushOnce = u;
|
|
730
|
+
function o(i) {
|
|
731
|
+
i === void 0 && (i = 10), h.default.global().flush(i);
|
|
732
|
+
}
|
|
733
|
+
t.flush = o;
|
|
734
|
+
})(A)), A;
|
|
735
|
+
}
|
|
736
|
+
var b = Qe();
|
|
737
|
+
class Me {
|
|
738
|
+
id;
|
|
739
|
+
data;
|
|
740
|
+
constructor(c, r) {
|
|
741
|
+
this.id = c, this.data = r;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
const { serviceUuid: Te, messageCharUuid: Ue } = fe(), ye = new b.SyncEvent(), pe = new b.SyncEvent(), ge = new b.SyncEvent(), _e = new b.SyncEvent();
|
|
745
|
+
function Be() {
|
|
746
|
+
return new Promise((t, c) => {
|
|
747
|
+
he().subscribe(Te, Ue, Ve).then(() => t()).catch((r) => c(r));
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
function Ve(t) {
|
|
751
|
+
t !== void 0 && (t.getUint8(L.TYPE) === J.BUTTON_PRESS && Re(t), t.getUint8(L.TYPE) === J.MESSAGE_DONE && _e.post(t.getUint8(L.DATA)));
|
|
752
|
+
}
|
|
753
|
+
function Re(t) {
|
|
754
|
+
const c = t.getUint8(L.DATA), r = new Me(
|
|
755
|
+
t.getUint8(L.ID),
|
|
756
|
+
Ie(t)
|
|
757
|
+
);
|
|
758
|
+
c === k.MINUS && pe.post(r), c === k.PLUS && ye.post(r), c === k.EITHER && ge.post(r);
|
|
759
|
+
}
|
|
760
|
+
function Ie(t) {
|
|
761
|
+
const c = t.buffer, r = 7, h = t.byteLength - 7;
|
|
762
|
+
return Array.from(new Uint8Array(c, r, h)).map((d) => String.fromCharCode(d)).join("").replace(/\0/g, "").trim();
|
|
763
|
+
}
|
|
764
|
+
function Ne() {
|
|
765
|
+
return {
|
|
766
|
+
subscribe: Be,
|
|
767
|
+
onPlusButton: ye,
|
|
768
|
+
onMinButton: pe,
|
|
769
|
+
onEitherButton: ge,
|
|
770
|
+
onMessageDone: _e
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
const j = [];
|
|
774
|
+
function ke() {
|
|
775
|
+
let t = Math.floor(Math.random() * 256);
|
|
776
|
+
for (; j.includes(t); ) t = Math.floor(Math.random() * 256);
|
|
777
|
+
return t;
|
|
778
|
+
}
|
|
779
|
+
function $e(t) {
|
|
780
|
+
j.push(t), Fe();
|
|
781
|
+
}
|
|
782
|
+
function Fe() {
|
|
783
|
+
j.length <= 20 || j.splice(0, j.length - 20);
|
|
784
|
+
}
|
|
785
|
+
function He() {
|
|
786
|
+
const t = ke();
|
|
787
|
+
return $e(t), t;
|
|
788
|
+
}
|
|
789
|
+
function Xe() {
|
|
790
|
+
return {
|
|
791
|
+
create: He
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
const { serviceUuid: Ge, messageCharUuid: Ye } = fe(), { onMessageDone: ze } = Ne(), Ke = he(), Ee = [], F = /* @__PURE__ */ new Map();
|
|
795
|
+
let D = !1;
|
|
796
|
+
ze.attach(Ze);
|
|
797
|
+
function We(t) {
|
|
798
|
+
return t.packets.forEach((c) => Ee.push(c)), new Promise((c) => {
|
|
799
|
+
F.set(t.cache, c), D || G();
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
function G() {
|
|
803
|
+
if (D)
|
|
804
|
+
return;
|
|
805
|
+
const t = Ee.shift();
|
|
806
|
+
if (t == null) {
|
|
807
|
+
D = !1;
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
D = !0, Ke.writeCharacteristic(Ge, Ye, t).catch((c) => console.log(c)).finally(() => {
|
|
811
|
+
D = !1, G();
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
function Ze(t) {
|
|
815
|
+
F.get(t)?.(), F.delete(t), G();
|
|
816
|
+
}
|
|
817
|
+
function Je() {
|
|
818
|
+
return { write: We };
|
|
819
|
+
}
|
|
820
|
+
const ae = 10, ue = 15;
|
|
821
|
+
function xe(t) {
|
|
822
|
+
if (t.data == null) {
|
|
823
|
+
let d = [t.id, t.cache, ae, 0, 2, t.type, 0];
|
|
824
|
+
return [new Uint8Array(d)];
|
|
825
|
+
}
|
|
826
|
+
const c = new Uint8Array(2 + t.data.length), r = t.data.length + 2, h = [];
|
|
827
|
+
c.set([t.type, r], 0), c.set(t.data, 2);
|
|
828
|
+
for (let d = 0; d < r; d += ue) {
|
|
829
|
+
const l = Math.min(ue, r - d), u = new Uint8Array(l), o = [t.id, t.cache, ae, d, r];
|
|
830
|
+
u.set(c.subarray(d, d + l), 0), h.push(new Uint8Array([...o, ...u]));
|
|
831
|
+
}
|
|
832
|
+
return h;
|
|
833
|
+
}
|
|
834
|
+
class tt {
|
|
835
|
+
cache = Xe().create();
|
|
836
|
+
type;
|
|
837
|
+
id;
|
|
838
|
+
data;
|
|
839
|
+
packets = [];
|
|
840
|
+
constructor(c, r, h) {
|
|
841
|
+
this.type = c, this.id = r, this.data = h, this.packets = xe(this);
|
|
842
|
+
}
|
|
843
|
+
send() {
|
|
844
|
+
return Je().write(this);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
class nt {
|
|
848
|
+
id;
|
|
849
|
+
elements = [];
|
|
850
|
+
onPlus = new b.SyncEvent();
|
|
851
|
+
onMin = new b.SyncEvent();
|
|
852
|
+
constructor(c) {
|
|
853
|
+
this.id = c;
|
|
854
|
+
}
|
|
855
|
+
name() {
|
|
856
|
+
return this.id.toString(16).padStart(2, "0");
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
export {
|
|
860
|
+
tt as B,
|
|
861
|
+
nt as S,
|
|
862
|
+
fe as a,
|
|
863
|
+
Ne as b,
|
|
864
|
+
Me as c,
|
|
865
|
+
b as l,
|
|
866
|
+
he as u
|
|
867
|
+
};
|