nsd-ble 0.3.0 → 0.3.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-CyxYK6wR.js → Objects-CQCepRPp.js} +191 -180
- package/dist/Objects-DT94mt5c.cjs +1 -0
- package/dist/main.cjs +1 -1
- package/dist/main.js +114 -101
- package/dist/objects.cjs +1 -1
- package/dist/objects.js +1 -1
- package/dist/types/ble/Bluetooth.d.ts +2 -0
- package/dist/types/ble/Mesh.d.ts +2 -0
- package/package.json +1 -1
- package/dist/Objects-wXbKCjWg.cjs +0 -1
|
@@ -1,43 +1,53 @@
|
|
|
1
|
-
import { Data as
|
|
2
|
-
let
|
|
3
|
-
async function
|
|
1
|
+
import { Data as j, DataType as x, Button as $ } from "./enums.js";
|
|
2
|
+
let M = !1, V = [], A, G, B = /* @__PURE__ */ new Map();
|
|
3
|
+
async function Ce(t) {
|
|
4
4
|
try {
|
|
5
|
-
if (
|
|
5
|
+
if (A = await navigator.bluetooth.requestDevice(t), A.gatt === void 0)
|
|
6
6
|
throw new Error("Device does not support GATT");
|
|
7
|
-
|
|
7
|
+
G = await A.gatt.connect(), A.addEventListener("gattserverdisconnected", he), M = !0;
|
|
8
8
|
} catch (c) {
|
|
9
9
|
throw c;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
12
|
+
async function Ae() {
|
|
13
|
+
if (M)
|
|
14
|
+
return;
|
|
15
|
+
const t = await navigator.bluetooth.getDevices();
|
|
16
|
+
if (t.length === 0)
|
|
17
|
+
throw new Error("No devices found");
|
|
18
|
+
if (A = t[0], A.gatt === void 0)
|
|
19
|
+
throw new Error("Device does not support GATT");
|
|
20
|
+
G = await A.gatt.connect(), A.addEventListener("gattserverdisconnected", he), M = !0;
|
|
21
|
+
}
|
|
22
|
+
function he() {
|
|
23
|
+
B.clear(), M = !1, V.forEach((t) => t());
|
|
14
24
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
25
|
+
function be(t) {
|
|
26
|
+
V.push(t);
|
|
17
27
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
28
|
+
function Se(t) {
|
|
29
|
+
V = V.filter((c) => c !== t);
|
|
20
30
|
}
|
|
21
31
|
async function X(t, c) {
|
|
22
|
-
if (
|
|
23
|
-
const d =
|
|
32
|
+
if (B.has(c)) {
|
|
33
|
+
const d = B.get(c);
|
|
24
34
|
if (d === void 0)
|
|
25
35
|
throw new Error("Characteristic not found");
|
|
26
36
|
return d;
|
|
27
37
|
}
|
|
28
|
-
const h = await (await
|
|
29
|
-
return
|
|
38
|
+
const h = await (await G.getPrimaryService(t)).getCharacteristic(c);
|
|
39
|
+
return B.set(c, h), h;
|
|
30
40
|
}
|
|
31
|
-
async function
|
|
41
|
+
async function qe(t, c) {
|
|
32
42
|
return await (await X(t, c)).readValue();
|
|
33
43
|
}
|
|
34
|
-
async function
|
|
44
|
+
async function Oe(t, c, r) {
|
|
35
45
|
const h = new DataView(new ArrayBuffer(r.length));
|
|
36
46
|
for (let l = 0; l < r.length; l++)
|
|
37
47
|
h.setUint8(l, r[l]);
|
|
38
48
|
await (await X(t, c)).writeValue(h);
|
|
39
49
|
}
|
|
40
|
-
async function
|
|
50
|
+
async function De(t, c, r) {
|
|
41
51
|
const h = await X(t, c);
|
|
42
52
|
h.addEventListener(
|
|
43
53
|
"characteristicvaluechanged",
|
|
@@ -47,33 +57,34 @@ async function qe(t, c, r) {
|
|
|
47
57
|
}
|
|
48
58
|
), await h.startNotifications();
|
|
49
59
|
}
|
|
50
|
-
function
|
|
60
|
+
function le() {
|
|
51
61
|
return {
|
|
52
|
-
connected:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
connected: M,
|
|
63
|
+
reconnect: Ae,
|
|
64
|
+
connect: Ce,
|
|
65
|
+
readCharacteristic: qe,
|
|
66
|
+
writeCharacteristic: Oe,
|
|
67
|
+
subscribe: De,
|
|
68
|
+
setDisconnectCallback: be,
|
|
69
|
+
removeDisconnectCallback: Se
|
|
59
70
|
};
|
|
60
71
|
}
|
|
61
|
-
const
|
|
72
|
+
const fe = "19b10000-e8f2-537e-4f6c-d104768a1214", Pe = "6b061bdc-9bc1-4952-a96f-c6ed551b2c3e", Le = "998ff920-81af-42a9-a915-f88025f9647d", je = {
|
|
62
73
|
filters: [{ namePrefix: "BLE-STANDEE" }],
|
|
63
|
-
optionalServices: [
|
|
74
|
+
optionalServices: [fe]
|
|
64
75
|
};
|
|
65
|
-
function
|
|
76
|
+
function ve() {
|
|
66
77
|
return {
|
|
67
|
-
serviceUuid:
|
|
68
|
-
messageCharUuid:
|
|
69
|
-
handshakeCharUuid:
|
|
70
|
-
options:
|
|
78
|
+
serviceUuid: fe,
|
|
79
|
+
messageCharUuid: Pe,
|
|
80
|
+
handshakeCharUuid: Le,
|
|
81
|
+
options: je
|
|
71
82
|
};
|
|
72
83
|
}
|
|
73
|
-
var
|
|
74
|
-
function
|
|
75
|
-
if (
|
|
76
|
-
|
|
84
|
+
var b = {}, O = {}, ee;
|
|
85
|
+
function R() {
|
|
86
|
+
if (ee) return O;
|
|
87
|
+
ee = 1, Object.defineProperty(O, "__esModule", { value: !0 }), O.BaseEvent = void 0;
|
|
77
88
|
var t = (
|
|
78
89
|
/** @class */
|
|
79
90
|
(function() {
|
|
@@ -133,12 +144,12 @@ function V() {
|
|
|
133
144
|
}, c;
|
|
134
145
|
})()
|
|
135
146
|
);
|
|
136
|
-
return
|
|
147
|
+
return O.BaseEvent = t, O;
|
|
137
148
|
}
|
|
138
|
-
var E = {},
|
|
139
|
-
function
|
|
140
|
-
if (
|
|
141
|
-
|
|
149
|
+
var E = {}, te;
|
|
150
|
+
function T() {
|
|
151
|
+
if (te) return E;
|
|
152
|
+
te = 1;
|
|
142
153
|
var t = E && E.__extends || /* @__PURE__ */ (function() {
|
|
143
154
|
var l = function(u, o) {
|
|
144
155
|
return l = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(i, a) {
|
|
@@ -156,7 +167,7 @@ function Q() {
|
|
|
156
167
|
};
|
|
157
168
|
})();
|
|
158
169
|
Object.defineProperty(E, "__esModule", { value: !0 }), E.ErrorSyncEvent = E.VoidSyncEvent = E.SyncEvent = void 0;
|
|
159
|
-
var c =
|
|
170
|
+
var c = R(), r = (
|
|
160
171
|
/** @class */
|
|
161
172
|
(function(l) {
|
|
162
173
|
t(u, l);
|
|
@@ -186,8 +197,8 @@ function Q() {
|
|
|
186
197
|
this._recursion--;
|
|
187
198
|
}
|
|
188
199
|
}, 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,
|
|
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(),
|
|
200
|
+
var n, e, s, f, v = (e = (n = this._listeners) === null || n === void 0 ? void 0 : n.length) !== null && e !== void 0 ? e : 0, p = l.prototype._attach.call(this, o, i, a);
|
|
201
|
+
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(), p;
|
|
191
202
|
}, u.prototype._detach = function() {
|
|
192
203
|
for (var o, i, a, n, e = [], s = 0; s < arguments.length; s++)
|
|
193
204
|
e[s] = arguments[s];
|
|
@@ -226,11 +237,11 @@ function Q() {
|
|
|
226
237
|
);
|
|
227
238
|
return E.ErrorSyncEvent = d, E;
|
|
228
239
|
}
|
|
229
|
-
var w = {},
|
|
230
|
-
function
|
|
231
|
-
if (
|
|
232
|
-
|
|
233
|
-
var t =
|
|
240
|
+
var w = {}, U = {}, ne;
|
|
241
|
+
function F() {
|
|
242
|
+
if (ne) return U;
|
|
243
|
+
ne = 1, Object.defineProperty(U, "__esModule", { value: !0 });
|
|
244
|
+
var t = T(), c = (
|
|
234
245
|
/** @class */
|
|
235
246
|
(function() {
|
|
236
247
|
function r() {
|
|
@@ -271,12 +282,12 @@ function $() {
|
|
|
271
282
|
}, r;
|
|
272
283
|
})()
|
|
273
284
|
);
|
|
274
|
-
return
|
|
285
|
+
return U.default = c, U;
|
|
275
286
|
}
|
|
276
|
-
var
|
|
277
|
-
function
|
|
278
|
-
if (
|
|
279
|
-
|
|
287
|
+
var re;
|
|
288
|
+
function de() {
|
|
289
|
+
if (re) return w;
|
|
290
|
+
re = 1;
|
|
280
291
|
var t = w && w.__extends || /* @__PURE__ */ (function() {
|
|
281
292
|
var o = function(i, a) {
|
|
282
293
|
return o = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, e) {
|
|
@@ -294,7 +305,7 @@ function ve() {
|
|
|
294
305
|
};
|
|
295
306
|
})();
|
|
296
307
|
Object.defineProperty(w, "__esModule", { value: !0 }), w.ErrorQueuedEvent = w.VoidQueuedEvent = w.QueuedEvent = void 0;
|
|
297
|
-
var c =
|
|
308
|
+
var c = R(), r = F(), h = T(), d = (
|
|
298
309
|
/** @class */
|
|
299
310
|
(function(o) {
|
|
300
311
|
t(i, o);
|
|
@@ -322,8 +333,8 @@ function ve() {
|
|
|
322
333
|
return;
|
|
323
334
|
this._queued = !0, s.add(function() {
|
|
324
335
|
a._queued = !1;
|
|
325
|
-
for (var v = a._queuedData,
|
|
326
|
-
var g = y
|
|
336
|
+
for (var v = a._queuedData, p = a._queuedListeners, y = 0; y < p.length; ++y) {
|
|
337
|
+
var g = p[y];
|
|
327
338
|
a._call(g, v);
|
|
328
339
|
}
|
|
329
340
|
});
|
|
@@ -331,20 +342,20 @@ function ve() {
|
|
|
331
342
|
var f = this._listeners;
|
|
332
343
|
s.add(function() {
|
|
333
344
|
for (var v = 0; v < f.length; ++v) {
|
|
334
|
-
var
|
|
335
|
-
a._call(
|
|
345
|
+
var p = f[v];
|
|
346
|
+
a._call(p, n);
|
|
336
347
|
}
|
|
337
348
|
});
|
|
338
349
|
}
|
|
339
350
|
}
|
|
340
351
|
}, i.prototype._attach = function(a, n, e) {
|
|
341
|
-
var s, f, v,
|
|
342
|
-
return this.evtListenersChanged &&
|
|
352
|
+
var s, f, v, p, y = (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);
|
|
353
|
+
return this.evtListenersChanged && y !== ((p = (v = this._listeners) === null || v === void 0 ? void 0 : v.length) !== null && p !== void 0 ? p : 0) && this.evtListenersChanged.post(), g;
|
|
343
354
|
}, i.prototype._detach = function() {
|
|
344
355
|
for (var a, n, e, s, f = [], v = 0; v < arguments.length; v++)
|
|
345
356
|
f[v] = arguments[v];
|
|
346
|
-
var
|
|
347
|
-
return this.evtListenersChanged &&
|
|
357
|
+
var p = (n = (a = this._listeners) === null || a === void 0 ? void 0 : a.length) !== null && n !== void 0 ? n : 0, y = o.prototype._detach.apply(this, f);
|
|
358
|
+
return this.evtListenersChanged && p !== ((s = (e = this._listeners) === null || e === void 0 ? void 0 : e.length) !== null && s !== void 0 ? s : 0) && this.evtListenersChanged.post(), y;
|
|
348
359
|
}, i;
|
|
349
360
|
})(c.BaseEvent)
|
|
350
361
|
);
|
|
@@ -378,10 +389,10 @@ function ve() {
|
|
|
378
389
|
);
|
|
379
390
|
return w.ErrorQueuedEvent = u, w;
|
|
380
391
|
}
|
|
381
|
-
var m = {},
|
|
382
|
-
function
|
|
383
|
-
if (
|
|
384
|
-
|
|
392
|
+
var m = {}, se;
|
|
393
|
+
function pe() {
|
|
394
|
+
if (se) return m;
|
|
395
|
+
se = 1;
|
|
385
396
|
var t = m && m.__extends || /* @__PURE__ */ (function() {
|
|
386
397
|
var u = function(o, i) {
|
|
387
398
|
return u = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(a, n) {
|
|
@@ -399,7 +410,7 @@ function de() {
|
|
|
399
410
|
};
|
|
400
411
|
})();
|
|
401
412
|
Object.defineProperty(m, "__esModule", { value: !0 }), m.ErrorAsyncEvent = m.VoidAsyncEvent = m.AsyncEvent = void 0;
|
|
402
|
-
var c =
|
|
413
|
+
var c = R(), r = T(), h = (
|
|
403
414
|
/** @class */
|
|
404
415
|
(function(u) {
|
|
405
416
|
t(o, u);
|
|
@@ -431,8 +442,8 @@ function de() {
|
|
|
431
442
|
this._queued = !0, o._scheduler(function() {
|
|
432
443
|
i._queued = !1;
|
|
433
444
|
for (var s = i._queuedData, f = i._queuedListeners, v = 0; v < f.length; ++v) {
|
|
434
|
-
var
|
|
435
|
-
i._call(
|
|
445
|
+
var p = f[v];
|
|
446
|
+
i._call(p, s);
|
|
436
447
|
}
|
|
437
448
|
});
|
|
438
449
|
} else {
|
|
@@ -453,13 +464,13 @@ function de() {
|
|
|
453
464
|
this._call(e, i);
|
|
454
465
|
}
|
|
455
466
|
}, o.prototype._attach = function(i, a, n) {
|
|
456
|
-
var e, s, f, v,
|
|
457
|
-
return this.evtListenersChanged &&
|
|
467
|
+
var e, s, f, v, p = (s = (e = this._listeners) === null || e === void 0 ? void 0 : e.length) !== null && s !== void 0 ? s : 0, y = u.prototype._attach.call(this, i, a, n);
|
|
468
|
+
return this.evtListenersChanged && p !== ((v = (f = this._listeners) === null || f === void 0 ? void 0 : f.length) !== null && v !== void 0 ? v : 0) && this.evtListenersChanged.post(), y;
|
|
458
469
|
}, o.prototype._detach = function() {
|
|
459
470
|
for (var i, a, n, e, s = [], f = 0; f < arguments.length; f++)
|
|
460
471
|
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,
|
|
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(),
|
|
472
|
+
var v = (a = (i = this._listeners) === null || i === void 0 ? void 0 : i.length) !== null && a !== void 0 ? a : 0, p = u.prototype._detach.apply(this, s);
|
|
473
|
+
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(), p;
|
|
463
474
|
}, o._scheduler = o.defaultScheduler, o;
|
|
464
475
|
})(c.BaseEvent)
|
|
465
476
|
);
|
|
@@ -493,10 +504,10 @@ function de() {
|
|
|
493
504
|
);
|
|
494
505
|
return m.ErrorAsyncEvent = l, m;
|
|
495
506
|
}
|
|
496
|
-
var
|
|
497
|
-
function
|
|
498
|
-
if (
|
|
499
|
-
|
|
507
|
+
var D = {}, P = {}, ie;
|
|
508
|
+
function Qe() {
|
|
509
|
+
if (ie) return P;
|
|
510
|
+
ie = 1, Object.defineProperty(P, "__esModule", { value: !0 }), P.shallowEquals = void 0;
|
|
500
511
|
function t(c, r) {
|
|
501
512
|
if (c === r)
|
|
502
513
|
return !0;
|
|
@@ -538,15 +549,15 @@ function Le() {
|
|
|
538
549
|
}
|
|
539
550
|
return P.shallowEquals = t, P;
|
|
540
551
|
}
|
|
541
|
-
var
|
|
542
|
-
function
|
|
543
|
-
return
|
|
544
|
-
var c =
|
|
552
|
+
var oe;
|
|
553
|
+
function Me() {
|
|
554
|
+
return oe || (oe = 1, (function(t) {
|
|
555
|
+
var c = D && D.__extends || /* @__PURE__ */ (function() {
|
|
545
556
|
var n = function(e, s) {
|
|
546
557
|
return n = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(f, v) {
|
|
547
558
|
f.__proto__ = v;
|
|
548
559
|
} || function(f, v) {
|
|
549
|
-
for (var
|
|
560
|
+
for (var p in v) v.hasOwnProperty(p) && (f[p] = v[p]);
|
|
550
561
|
}, n(e, s);
|
|
551
562
|
};
|
|
552
563
|
return function(e, s) {
|
|
@@ -558,7 +569,7 @@ function je() {
|
|
|
558
569
|
};
|
|
559
570
|
})();
|
|
560
571
|
Object.defineProperty(t, "__esModule", { value: !0 }), t.ErrorAnyEvent = t.VoidAnyEvent = t.AnyEvent = t.EventType = void 0;
|
|
561
|
-
var r =
|
|
572
|
+
var r = Qe(), h = T(), d = pe(), l = de(), u;
|
|
562
573
|
(function(n) {
|
|
563
574
|
n[n.Sync = 0] = "Sync", n[n.Async = 1] = "Async", n[n.Queued = 2] = "Queued";
|
|
564
575
|
})(u = t.EventType || (t.EventType = {}));
|
|
@@ -582,22 +593,22 @@ function je() {
|
|
|
582
593
|
e[s] = arguments[s];
|
|
583
594
|
var f = u.Sync;
|
|
584
595
|
e.length > 0 && typeof e[0] == "number" && (f = e.shift());
|
|
585
|
-
var v = this,
|
|
586
|
-
return typeof e[0] == "function" || e[0] && typeof e[0] == "object" && typeof e[0].post == "function" ? (typeof e[0] == "function" ?
|
|
596
|
+
var v = this, p, y, g;
|
|
597
|
+
return typeof e[0] == "function" || e[0] && typeof e[0] == "object" && typeof e[0].post == "function" ? (typeof e[0] == "function" ? p = e[0] : g = e[0], y = e[1]) : (v = e[0], p = e[1], y = e[2]), this._attach(f, v, p, g, y, !1);
|
|
587
598
|
}, n.prototype.once = function() {
|
|
588
599
|
for (var e = [], s = 0; s < arguments.length; s++)
|
|
589
600
|
e[s] = arguments[s];
|
|
590
601
|
var f = u.Sync;
|
|
591
602
|
e.length > 0 && typeof e[0] == "number" && (f = e.shift());
|
|
592
|
-
var v = this,
|
|
593
|
-
return typeof e[0] == "function" || e[0] && typeof e[0] == "object" && typeof e[0].post == "function" ? (typeof e[0] == "function" ?
|
|
594
|
-
}, n.prototype._attach = function(e, s, f, v,
|
|
595
|
-
var g = this,
|
|
603
|
+
var v = this, p, y, g;
|
|
604
|
+
return typeof e[0] == "function" || e[0] && typeof e[0] == "object" && typeof e[0].post == "function" ? (typeof e[0] == "function" ? p = e[0] : g = e[0], y = e[1]) : (v = e[0], p = e[1], y = e[2]), this._attach(f, v, p, g, y, !0);
|
|
605
|
+
}, n.prototype._attach = function(e, s, f, v, p, y) {
|
|
606
|
+
var g = this, z = this.evtFirstAttached ? this.listenerCount() : 0, _;
|
|
596
607
|
switch (e) {
|
|
597
608
|
case u.Sync:
|
|
598
609
|
{
|
|
599
|
-
for (var
|
|
600
|
-
var C =
|
|
610
|
+
for (var I = 0, K = this._events; I < K.length; I++) {
|
|
611
|
+
var C = K[I];
|
|
601
612
|
C instanceof h.SyncEvent && (_ = C);
|
|
602
613
|
}
|
|
603
614
|
_ || (_ = new h.SyncEvent(), this._events.push(_));
|
|
@@ -605,29 +616,29 @@ function je() {
|
|
|
605
616
|
break;
|
|
606
617
|
case u.Async:
|
|
607
618
|
{
|
|
608
|
-
for (var
|
|
609
|
-
var C =
|
|
610
|
-
C instanceof d.AsyncEvent && r.shallowEquals(C.options,
|
|
619
|
+
for (var N = 0, W = this._events; N < W.length; N++) {
|
|
620
|
+
var C = W[N];
|
|
621
|
+
C instanceof d.AsyncEvent && r.shallowEquals(C.options, p) && (_ = C);
|
|
611
622
|
}
|
|
612
|
-
_ || (_ = new d.AsyncEvent(
|
|
623
|
+
_ || (_ = new d.AsyncEvent(p), this._events.push(_));
|
|
613
624
|
}
|
|
614
625
|
break;
|
|
615
626
|
case u.Queued:
|
|
616
627
|
{
|
|
617
|
-
for (var
|
|
618
|
-
var C =
|
|
619
|
-
C instanceof l.QueuedEvent && r.shallowEquals(C.options,
|
|
628
|
+
for (var k = 0, Z = this._events; k < Z.length; k++) {
|
|
629
|
+
var C = Z[k];
|
|
630
|
+
C instanceof l.QueuedEvent && r.shallowEquals(C.options, p) && (_ = C);
|
|
620
631
|
}
|
|
621
|
-
_ || (_ = new l.QueuedEvent(
|
|
632
|
+
_ || (_ = new l.QueuedEvent(p), this._events.push(_));
|
|
622
633
|
}
|
|
623
634
|
break;
|
|
624
635
|
default:
|
|
625
636
|
throw new Error("unknown EventType");
|
|
626
637
|
}
|
|
627
|
-
var
|
|
628
|
-
return
|
|
629
|
-
var
|
|
630
|
-
|
|
638
|
+
var q;
|
|
639
|
+
return y ? v ? q = _.once(v) : q = _.once(s, f) : v ? q = _.attach(v) : q = _.attach(s, f), this.evtFirstAttached && z === 0 && this.evtFirstAttached.post(), this.evtListenersChanged && z !== this.listenerCount() && this.evtListenersChanged.post(), function() {
|
|
640
|
+
var J = g.evtLastDetached ? g.listenerCount() : 0;
|
|
641
|
+
q(), g.evtLastDetached && J > 0 && g.listenerCount() === 0 && g.evtLastDetached.post(), g.evtListenersChanged && J !== g.listenerCount() && g.evtListenersChanged.post();
|
|
631
642
|
};
|
|
632
643
|
}, n.prototype.attachSync = function() {
|
|
633
644
|
for (var e = [], s = 0; s < arguments.length; s++)
|
|
@@ -700,22 +711,22 @@ function je() {
|
|
|
700
711
|
})(o)
|
|
701
712
|
);
|
|
702
713
|
t.ErrorAnyEvent = a;
|
|
703
|
-
})(
|
|
714
|
+
})(D)), D;
|
|
704
715
|
}
|
|
705
|
-
var
|
|
706
|
-
function
|
|
707
|
-
return
|
|
708
|
-
var c =
|
|
716
|
+
var ae;
|
|
717
|
+
function Te() {
|
|
718
|
+
return ae || (ae = 1, (function(t) {
|
|
719
|
+
var c = b && b.__createBinding || (Object.create ? (function(i, a, n, e) {
|
|
709
720
|
e === void 0 && (e = n), Object.defineProperty(i, e, { enumerable: !0, get: function() {
|
|
710
721
|
return a[n];
|
|
711
722
|
} });
|
|
712
723
|
}) : (function(i, a, n, e) {
|
|
713
724
|
e === void 0 && (e = n), i[e] = a[n];
|
|
714
|
-
})), r =
|
|
725
|
+
})), r = b && b.__exportStar || function(i, a) {
|
|
715
726
|
for (var n in i) n !== "default" && !a.hasOwnProperty(n) && c(a, i, n);
|
|
716
727
|
};
|
|
717
|
-
Object.defineProperty(t, "__esModule", { value: !0 }), t.flush = t.flushOnce = t.queue = void 0, r(
|
|
718
|
-
var h =
|
|
728
|
+
Object.defineProperty(t, "__esModule", { value: !0 }), t.flush = t.flushOnce = t.queue = void 0, r(R(), t), r(T(), t), r(de(), t), r(pe(), t), r(Me(), t);
|
|
729
|
+
var h = F(), d = F();
|
|
719
730
|
Object.defineProperty(t, "EventQueue", { enumerable: !0, get: function() {
|
|
720
731
|
return d.default;
|
|
721
732
|
} });
|
|
@@ -731,130 +742,130 @@ function Qe() {
|
|
|
731
742
|
i === void 0 && (i = 10), h.default.global().flush(i);
|
|
732
743
|
}
|
|
733
744
|
t.flush = o;
|
|
734
|
-
})(
|
|
745
|
+
})(b)), b;
|
|
735
746
|
}
|
|
736
|
-
var
|
|
737
|
-
class
|
|
747
|
+
var S = Te();
|
|
748
|
+
class Ue {
|
|
738
749
|
id;
|
|
739
750
|
data;
|
|
740
751
|
constructor(c, r) {
|
|
741
752
|
this.id = c, this.data = r;
|
|
742
753
|
}
|
|
743
754
|
}
|
|
744
|
-
const { serviceUuid:
|
|
745
|
-
function
|
|
755
|
+
const { serviceUuid: Be, messageCharUuid: Ve } = ve(), ye = new S.SyncEvent(), ge = new S.SyncEvent(), _e = new S.SyncEvent(), Ee = new S.SyncEvent();
|
|
756
|
+
function Re() {
|
|
746
757
|
return new Promise((t, c) => {
|
|
747
|
-
|
|
758
|
+
le().subscribe(Be, Ve, Ie).then(() => t()).catch((r) => c(r));
|
|
748
759
|
});
|
|
749
760
|
}
|
|
750
|
-
function
|
|
751
|
-
t !== void 0 && (t.getUint8(
|
|
761
|
+
function Ie(t) {
|
|
762
|
+
t !== void 0 && (t.getUint8(j.TYPE) === x.BUTTON_PRESS && Ne(t), t.getUint8(j.TYPE) === x.MESSAGE_DONE && Ee.post(t.getUint8(j.DATA)));
|
|
752
763
|
}
|
|
753
|
-
function
|
|
754
|
-
const c = t.getUint8(
|
|
755
|
-
t.getUint8(
|
|
756
|
-
|
|
764
|
+
function Ne(t) {
|
|
765
|
+
const c = t.getUint8(j.DATA), r = new Ue(
|
|
766
|
+
t.getUint8(j.ID),
|
|
767
|
+
ke(t)
|
|
757
768
|
);
|
|
758
|
-
c ===
|
|
769
|
+
c === $.MINUS && ge.post(r), c === $.PLUS && ye.post(r), c === $.EITHER && _e.post(r);
|
|
759
770
|
}
|
|
760
|
-
function
|
|
771
|
+
function ke(t) {
|
|
761
772
|
const c = t.buffer, r = 7, h = t.byteLength - 7;
|
|
762
773
|
return Array.from(new Uint8Array(c, r, h)).map((d) => String.fromCharCode(d)).join("").replace(/\0/g, "").trim();
|
|
763
774
|
}
|
|
764
|
-
function
|
|
775
|
+
function $e() {
|
|
765
776
|
return {
|
|
766
|
-
subscribe:
|
|
777
|
+
subscribe: Re,
|
|
767
778
|
onPlusButton: ye,
|
|
768
|
-
onMinButton:
|
|
769
|
-
onEitherButton:
|
|
770
|
-
onMessageDone:
|
|
779
|
+
onMinButton: ge,
|
|
780
|
+
onEitherButton: _e,
|
|
781
|
+
onMessageDone: Ee
|
|
771
782
|
};
|
|
772
783
|
}
|
|
773
|
-
const
|
|
774
|
-
function
|
|
784
|
+
const Q = [];
|
|
785
|
+
function Fe() {
|
|
775
786
|
let t = Math.floor(Math.random() * 256);
|
|
776
|
-
for (;
|
|
787
|
+
for (; Q.includes(t); ) t = Math.floor(Math.random() * 256);
|
|
777
788
|
return t;
|
|
778
789
|
}
|
|
779
|
-
function
|
|
780
|
-
|
|
781
|
-
}
|
|
782
|
-
function Fe() {
|
|
783
|
-
j.length <= 20 || j.splice(0, j.length - 20);
|
|
790
|
+
function He(t) {
|
|
791
|
+
Q.push(t), Ge();
|
|
784
792
|
}
|
|
785
|
-
function
|
|
786
|
-
|
|
787
|
-
return $e(t), t;
|
|
793
|
+
function Ge() {
|
|
794
|
+
Q.length <= 20 || Q.splice(0, Q.length - 20);
|
|
788
795
|
}
|
|
789
796
|
function Xe() {
|
|
797
|
+
const t = Fe();
|
|
798
|
+
return He(t), t;
|
|
799
|
+
}
|
|
800
|
+
function Ye() {
|
|
790
801
|
return {
|
|
791
|
-
create:
|
|
802
|
+
create: Xe
|
|
792
803
|
};
|
|
793
804
|
}
|
|
794
|
-
const { serviceUuid:
|
|
795
|
-
let
|
|
796
|
-
|
|
797
|
-
function
|
|
798
|
-
return t.packets.forEach((c) =>
|
|
799
|
-
|
|
805
|
+
const { serviceUuid: ze, messageCharUuid: Ke } = ve(), { onMessageDone: We } = $e(), Ze = le(), we = [], H = /* @__PURE__ */ new Map(), me = /* @__PURE__ */ new Map();
|
|
806
|
+
let L = !1;
|
|
807
|
+
We.attach(xe);
|
|
808
|
+
function Je(t) {
|
|
809
|
+
return t.packets.forEach((c) => we.push(c)), me.set(t.cache, t.packets), new Promise((c) => {
|
|
810
|
+
H.set(t.cache, () => {
|
|
800
811
|
t.resolve?.(), c();
|
|
801
|
-
}),
|
|
812
|
+
}), L || Y();
|
|
802
813
|
});
|
|
803
814
|
}
|
|
804
|
-
function
|
|
805
|
-
if (
|
|
815
|
+
function Y() {
|
|
816
|
+
if (L)
|
|
806
817
|
return;
|
|
807
|
-
const t =
|
|
818
|
+
const t = we.shift();
|
|
808
819
|
if (t == null) {
|
|
809
|
-
|
|
820
|
+
L = !1;
|
|
810
821
|
return;
|
|
811
822
|
}
|
|
812
|
-
|
|
813
|
-
|
|
823
|
+
L = !0, Ze.writeCharacteristic(ze, Ke, t).catch((c) => console.log(c)).finally(() => {
|
|
824
|
+
L = !1, Y();
|
|
814
825
|
});
|
|
815
826
|
}
|
|
816
|
-
function
|
|
817
|
-
|
|
827
|
+
function xe(t) {
|
|
828
|
+
H.get(t)?.(), H.delete(t), me.delete(t), Y();
|
|
818
829
|
}
|
|
819
|
-
function
|
|
820
|
-
return { write:
|
|
830
|
+
function et() {
|
|
831
|
+
return { write: Je };
|
|
821
832
|
}
|
|
822
|
-
const
|
|
823
|
-
function
|
|
833
|
+
const ue = 10, ce = 15;
|
|
834
|
+
function tt(t) {
|
|
824
835
|
if (t.data == null) {
|
|
825
|
-
let d = [t.id, t.cache,
|
|
836
|
+
let d = [t.id, t.cache, ue, 0, 2, t.type, 0];
|
|
826
837
|
return [new Uint8Array(d)];
|
|
827
838
|
}
|
|
828
839
|
const c = new Uint8Array(2 + t.data.length), r = t.data.length + 2, h = [];
|
|
829
840
|
c.set([t.type, r], 0), c.set(t.data, 2);
|
|
830
|
-
for (let d = 0; d < r; d +=
|
|
831
|
-
const l = Math.min(
|
|
841
|
+
for (let d = 0; d < r; d += ce) {
|
|
842
|
+
const l = Math.min(ce, r - d), u = new Uint8Array(l), o = [t.id, t.cache, ue, d, r];
|
|
832
843
|
u.set(c.subarray(d, d + l), 0), h.push(new Uint8Array([...o, ...u]));
|
|
833
844
|
}
|
|
834
845
|
return h;
|
|
835
846
|
}
|
|
836
|
-
class
|
|
837
|
-
cache =
|
|
847
|
+
class rt {
|
|
848
|
+
cache = Ye().create();
|
|
838
849
|
type;
|
|
839
850
|
id;
|
|
840
851
|
data;
|
|
841
852
|
packets = [];
|
|
842
853
|
resolve;
|
|
843
854
|
constructor(c, r, h) {
|
|
844
|
-
this.type = c, this.id = r, this.data = h, this.packets =
|
|
855
|
+
this.type = c, this.id = r, this.data = h, this.packets = tt(this);
|
|
845
856
|
}
|
|
846
857
|
send() {
|
|
847
|
-
return
|
|
858
|
+
return et().write(this);
|
|
848
859
|
}
|
|
849
860
|
then(c) {
|
|
850
861
|
return this.resolve = c, this;
|
|
851
862
|
}
|
|
852
863
|
}
|
|
853
|
-
class
|
|
864
|
+
class st {
|
|
854
865
|
id;
|
|
855
866
|
elements = [];
|
|
856
|
-
onPlus = new
|
|
857
|
-
onMin = new
|
|
867
|
+
onPlus = new S.SyncEvent();
|
|
868
|
+
onMin = new S.SyncEvent();
|
|
858
869
|
constructor(c) {
|
|
859
870
|
this.id = c;
|
|
860
871
|
}
|
|
@@ -863,11 +874,11 @@ class nt {
|
|
|
863
874
|
}
|
|
864
875
|
}
|
|
865
876
|
export {
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
877
|
+
rt as B,
|
|
878
|
+
st as S,
|
|
879
|
+
ve as a,
|
|
880
|
+
$e as b,
|
|
881
|
+
Ue as c,
|
|
882
|
+
S as l,
|
|
883
|
+
le as u
|
|
873
884
|
};
|