nsd-ble 0.4.1 → 0.4.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/README.md +45 -1
- package/dist/{Objects-Zntmn07s.cjs → Objects-CQULDdkF.cjs} +1 -1
- package/dist/{Objects-ulh5Kfet.js → Objects-Cmxbmb24.js} +69 -74
- package/dist/main.cjs +1 -1
- package/dist/main.js +172 -172
- package/dist/objects.cjs +1 -1
- package/dist/objects.js +1 -1
- package/dist/types/ble/MessageCharacteristic.d.ts +1 -0
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { l as I, u as x, a as
|
|
2
|
-
import { Data as i, DataType as f, ActionType as A, ActionDataType as
|
|
3
|
-
import { Image as
|
|
4
|
-
class
|
|
1
|
+
import { l as I, u as x, a as k, b as Z, c as Q, d as tt, B, S as pt, s as et } from "./Objects-Cmxbmb24.js";
|
|
2
|
+
import { Data as i, DataType as f, ActionType as A, ActionDataType as C, FloodTypes as P, Button as G } from "./enums.js";
|
|
3
|
+
import { Image as mt, Rectangle as yt, Text as Et } from "./elements.js";
|
|
4
|
+
class Tt {
|
|
5
5
|
data = [];
|
|
6
6
|
size = 0;
|
|
7
7
|
total = 0;
|
|
8
8
|
}
|
|
9
9
|
const j = 7, _ = /* @__PURE__ */ new Map();
|
|
10
|
-
function
|
|
10
|
+
function Dt(t) {
|
|
11
11
|
return _.get(t);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function It(t) {
|
|
14
14
|
_.delete(t);
|
|
15
15
|
}
|
|
16
16
|
function Ct(t) {
|
|
17
17
|
const e = t.getUint8(i.CACHE), o = t.getUint16(i.DATA_SIZE, !0), n = t.getUint16(i.POSITION, !0), r = t.byteLength - j;
|
|
18
18
|
if (!_.has(e)) {
|
|
19
|
-
const a = new
|
|
19
|
+
const a = new Tt();
|
|
20
20
|
a.size = o, _.set(e, a);
|
|
21
21
|
}
|
|
22
22
|
const s = _.get(e);
|
|
@@ -24,26 +24,26 @@ function Ct(t) {
|
|
|
24
24
|
s.data[a + n] = t.getUint8(j + a);
|
|
25
25
|
s.total += r;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function Ut(t) {
|
|
28
28
|
const e = _.get(t);
|
|
29
29
|
return e.total == e.size || e.size == 0;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
return { add: Ct, get:
|
|
31
|
+
function St() {
|
|
32
|
+
return { add: Ct, get: Dt, remove: It, isDone: Ut };
|
|
33
33
|
}
|
|
34
|
-
const { serviceUuid:
|
|
35
|
-
function
|
|
34
|
+
const { serviceUuid: bt, handshakeCharUuid: _t } = k(), nt = new I.SyncEvent(), { add: Nt, get: Rt, remove: xt, isDone: Bt } = St();
|
|
35
|
+
function Pt() {
|
|
36
36
|
return new Promise((t, e) => {
|
|
37
|
-
x().subscribe(
|
|
37
|
+
x().subscribe(bt, _t, Lt).then(() => t()).catch((o) => e(o));
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function Lt(t) {
|
|
41
41
|
console.log(t, t.buffer.byteLength);
|
|
42
42
|
const e = t.getUint8(i.CACHE);
|
|
43
|
-
|
|
43
|
+
Nt(t), Bt(e) && (nt.post(Mt(e)), xt(e));
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
const e =
|
|
45
|
+
function Mt(t) {
|
|
46
|
+
const e = Rt(t), o = /* @__PURE__ */ new Map();
|
|
47
47
|
let n = 1;
|
|
48
48
|
for (; n < e.size; ) {
|
|
49
49
|
const r = e.data[n++], s = e.data[n++], a = [];
|
|
@@ -54,23 +54,23 @@ function Ot(t) {
|
|
|
54
54
|
return o;
|
|
55
55
|
}
|
|
56
56
|
function ot() {
|
|
57
|
-
return { subscribe:
|
|
57
|
+
return { subscribe: Pt, onNodes: nt };
|
|
58
58
|
}
|
|
59
|
-
const { onNodes: vt } = ot(), { onMessageDone:
|
|
60
|
-
connect:
|
|
59
|
+
const { onNodes: vt } = ot(), { onMessageDone: Ot, onNode: kt, onNodeLost: $t } = Z(), { onPlusButton: zt, onMinButton: Ht, onEitherButton: Ft } = Q(), {
|
|
60
|
+
connect: Gt,
|
|
61
61
|
reconnect: rt,
|
|
62
|
-
onConnect:
|
|
62
|
+
onConnect: Wt,
|
|
63
63
|
onDisconnect: st
|
|
64
64
|
} = x(), it = new I.SyncEvent(), at = new I.SyncEvent();
|
|
65
|
-
let
|
|
65
|
+
let $ = !1, b = !1, N = !1;
|
|
66
66
|
st.attach(() => {
|
|
67
|
-
|
|
67
|
+
$ && !b && (tt().abortAll(new Error("BLE disconnected")), Yt());
|
|
68
68
|
});
|
|
69
|
-
async function
|
|
70
|
-
N = !0, await
|
|
69
|
+
async function Vt() {
|
|
70
|
+
N = !0, await Gt(k().options), await Y(), $ = !0;
|
|
71
71
|
}
|
|
72
|
-
async function
|
|
73
|
-
N = !0, await rt(), await Y(),
|
|
72
|
+
async function Zt() {
|
|
73
|
+
N = !0, await rt(), await Y(), $ = !0;
|
|
74
74
|
}
|
|
75
75
|
function Y() {
|
|
76
76
|
return Promise.all([
|
|
@@ -80,15 +80,15 @@ function Y() {
|
|
|
80
80
|
]).then(() => {
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
-
async function
|
|
84
|
-
const { RECONNECT_DELAY: t, RECONNECT_MAX_RETRIES: e } =
|
|
83
|
+
async function Yt() {
|
|
84
|
+
const { RECONNECT_DELAY: t, RECONNECT_MAX_RETRIES: e } = k();
|
|
85
85
|
b = !0, N = !1;
|
|
86
86
|
for (let o = 1; o <= e; o++) {
|
|
87
87
|
const n = Math.min(
|
|
88
88
|
t * Math.pow(2, o - 1),
|
|
89
89
|
3e4
|
|
90
90
|
);
|
|
91
|
-
if (it.post({ attempt: o, maxRetries: e, delay: n }), await
|
|
91
|
+
if (it.post({ attempt: o, maxRetries: e, delay: n }), await Kt(n), N) {
|
|
92
92
|
b = !1, N = !1;
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
@@ -104,28 +104,28 @@ async function Kt() {
|
|
|
104
104
|
}
|
|
105
105
|
b = !1, at.post();
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function Kt(t) {
|
|
108
108
|
return new Promise((e) => setTimeout(e, t));
|
|
109
109
|
}
|
|
110
|
-
function
|
|
111
|
-
|
|
110
|
+
function qt() {
|
|
111
|
+
$ = !1, b = !1, N = !1;
|
|
112
112
|
}
|
|
113
|
-
function
|
|
113
|
+
function Xt() {
|
|
114
114
|
return {
|
|
115
|
-
connect:
|
|
116
|
-
onConnect:
|
|
115
|
+
connect: Vt,
|
|
116
|
+
onConnect: Wt,
|
|
117
117
|
onDisconnect: st,
|
|
118
118
|
onReconnecting: it,
|
|
119
119
|
onReconnectFailed: at,
|
|
120
|
-
reconnect:
|
|
120
|
+
reconnect: Zt,
|
|
121
121
|
onNodes: vt,
|
|
122
|
-
onNode:
|
|
123
|
-
onNodeLost:
|
|
124
|
-
onPlusButton:
|
|
125
|
-
onMinButton:
|
|
126
|
-
onEitherButton:
|
|
127
|
-
onMessageDone:
|
|
128
|
-
_resetForTesting:
|
|
122
|
+
onNode: kt,
|
|
123
|
+
onNodeLost: $t,
|
|
124
|
+
onPlusButton: zt,
|
|
125
|
+
onMinButton: Ht,
|
|
126
|
+
onEitherButton: Ft,
|
|
127
|
+
onMessageDone: Ot,
|
|
128
|
+
_resetForTesting: qt
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
131
|
function hn(t) {
|
|
@@ -137,7 +137,7 @@ function hn(t) {
|
|
|
137
137
|
clear: () => new B(f.CLEAR_GRAPHICS, t.id)
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
|
-
class
|
|
140
|
+
class jt {
|
|
141
141
|
id;
|
|
142
142
|
buffers;
|
|
143
143
|
totalPackets = 0;
|
|
@@ -169,39 +169,39 @@ class Jt {
|
|
|
169
169
|
}
|
|
170
170
|
function gn(t) {
|
|
171
171
|
return {
|
|
172
|
-
load: (e) => new
|
|
172
|
+
load: (e) => new jt(e, t.id)
|
|
173
173
|
};
|
|
174
174
|
}
|
|
175
|
-
const { onNodes:
|
|
175
|
+
const { onNodes: Jt, onNode: Qt, onNodeLost: te } = Xt();
|
|
176
|
+
Jt.attach(ee);
|
|
176
177
|
Qt.attach(ne);
|
|
177
178
|
te.attach(oe);
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
function ne(t) {
|
|
179
|
+
const w = [], z = new I.SyncEvent();
|
|
180
|
+
function ee(t) {
|
|
181
181
|
console.log("standees", t);
|
|
182
182
|
for (const [e, o] of t)
|
|
183
183
|
ct(e), w.find((n) => n.id === e).neighbors = o;
|
|
184
|
-
|
|
184
|
+
z.post(w);
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function ne(t) {
|
|
187
187
|
console.log("nodes", t);
|
|
188
188
|
const e = t.keys().next().value, o = t.get(e);
|
|
189
|
-
ct(e), w.find((n) => n.id === e).neighbors = o,
|
|
189
|
+
ct(e), w.find((n) => n.id === e).neighbors = o, z.post(w);
|
|
190
190
|
}
|
|
191
|
-
function
|
|
192
|
-
|
|
191
|
+
function oe(t) {
|
|
192
|
+
re(t), z.post(w);
|
|
193
193
|
}
|
|
194
194
|
function ct(t) {
|
|
195
|
-
w.some((e) => e.id === t) || w.push(new
|
|
195
|
+
w.some((e) => e.id === t) || w.push(new pt(t));
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function re(t) {
|
|
198
198
|
const e = w.findIndex((o) => o.id === t);
|
|
199
199
|
e !== -1 && w.splice(e, 1);
|
|
200
200
|
}
|
|
201
201
|
function An() {
|
|
202
|
-
return { standees: w, onChange:
|
|
202
|
+
return { standees: w, onChange: z };
|
|
203
203
|
}
|
|
204
|
-
function
|
|
204
|
+
function se(t) {
|
|
205
205
|
const e = () => {
|
|
206
206
|
let n = Math.floor(Math.random() * 256);
|
|
207
207
|
return o(n) ? e() : n;
|
|
@@ -209,26 +209,26 @@ function ie(t) {
|
|
|
209
209
|
return { generate: e };
|
|
210
210
|
}
|
|
211
211
|
function wn(t) {
|
|
212
|
-
return { add: (n) => (n.id =
|
|
212
|
+
return { add: (n) => (n.id = se(t.elements).generate(), t.elements.push(n), n), remove: (n) => {
|
|
213
213
|
t.elements = t.elements.filter(
|
|
214
214
|
(r) => r.id !== n
|
|
215
215
|
);
|
|
216
216
|
} };
|
|
217
217
|
}
|
|
218
|
-
function
|
|
218
|
+
function ie(t) {
|
|
219
219
|
return new B(f.CLEAR_SCREEN, t.id);
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function ae(t) {
|
|
222
222
|
let e = new Uint8Array();
|
|
223
223
|
for (const o of t.elements)
|
|
224
|
-
o.dirty !== !1 && (o instanceof
|
|
224
|
+
o.dirty !== !1 && (o instanceof mt && (e = W(e, ce(o))), o instanceof yt && (e = W(e, ue(o))), o instanceof Et && (e = W(e, fe(o))), o.dirty = !1);
|
|
225
225
|
return new B(f.ALL, t.id, e);
|
|
226
226
|
}
|
|
227
227
|
function W(t, e) {
|
|
228
228
|
const o = new Uint8Array(t.length + e.length);
|
|
229
229
|
return o.set(t, 0), o.set(e, t.length), o;
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function ce(t) {
|
|
232
232
|
return new Uint8Array([
|
|
233
233
|
f.DRAW_IMAGE,
|
|
234
234
|
7,
|
|
@@ -241,7 +241,7 @@ function ue(t) {
|
|
|
241
241
|
t.data
|
|
242
242
|
]);
|
|
243
243
|
}
|
|
244
|
-
function
|
|
244
|
+
function ue(t) {
|
|
245
245
|
return new Uint8Array([
|
|
246
246
|
f.DRAW_RECTANGLE,
|
|
247
247
|
9,
|
|
@@ -256,7 +256,7 @@ function fe(t) {
|
|
|
256
256
|
t.colorBlack ? 0 : 1
|
|
257
257
|
]);
|
|
258
258
|
}
|
|
259
|
-
function
|
|
259
|
+
function fe(t) {
|
|
260
260
|
const e = new TextEncoder().encode(t.text), o = new Uint8Array(9 + e.length);
|
|
261
261
|
return o.set(
|
|
262
262
|
[
|
|
@@ -274,9 +274,9 @@ function le(t) {
|
|
|
274
274
|
), o.set(e, 9), o;
|
|
275
275
|
}
|
|
276
276
|
function pn() {
|
|
277
|
-
return { clear:
|
|
277
|
+
return { clear: ie, draw: ae };
|
|
278
278
|
}
|
|
279
|
-
function
|
|
279
|
+
function le(t, e) {
|
|
280
280
|
const o = Math.ceil(t.length / e), n = Math.ceil(e / 8), r = new Uint8Array(n * o);
|
|
281
281
|
for (let s = 0; s < o; s++)
|
|
282
282
|
for (let a = 0; a < n; a++) {
|
|
@@ -292,7 +292,7 @@ function de(t, e) {
|
|
|
292
292
|
function ut(t) {
|
|
293
293
|
return t = (t & 240) >> 4 | (t & 15) << 4, t = (t & 204) >> 2 | (t & 51) << 2, t = (t & 170) >> 1 | (t & 85) << 1, t;
|
|
294
294
|
}
|
|
295
|
-
function
|
|
295
|
+
function de(t) {
|
|
296
296
|
const e = t.reduce((r, s) => r + s.length, 0), o = new Uint8Array(e);
|
|
297
297
|
let n = 0;
|
|
298
298
|
for (const r of t)
|
|
@@ -301,9 +301,9 @@ function he(t) {
|
|
|
301
301
|
}
|
|
302
302
|
function K() {
|
|
303
303
|
return {
|
|
304
|
-
pixelsToBytes:
|
|
304
|
+
pixelsToBytes: le,
|
|
305
305
|
bitswap: ut,
|
|
306
|
-
flattenUint8Arrays:
|
|
306
|
+
flattenUint8Arrays: de
|
|
307
307
|
};
|
|
308
308
|
}
|
|
309
309
|
const { flattenUint8Arrays: ft } = K();
|
|
@@ -323,7 +323,7 @@ class p {
|
|
|
323
323
|
return new Uint8Array();
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
|
-
class
|
|
326
|
+
class he extends p {
|
|
327
327
|
format() {
|
|
328
328
|
return new Uint8Array([
|
|
329
329
|
A.INCREMENT,
|
|
@@ -333,7 +333,7 @@ class ge extends p {
|
|
|
333
333
|
]);
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
class
|
|
336
|
+
class ge extends p {
|
|
337
337
|
format() {
|
|
338
338
|
return new Uint8Array([
|
|
339
339
|
A.DECREMENT,
|
|
@@ -343,17 +343,17 @@ class Ae extends p {
|
|
|
343
343
|
]);
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
|
-
class
|
|
346
|
+
class Ae extends p {
|
|
347
347
|
format() {
|
|
348
348
|
return new Uint8Array([A.SHOW, 1, this.target.element_id]);
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
|
-
class
|
|
351
|
+
class we extends p {
|
|
352
352
|
format() {
|
|
353
353
|
return new Uint8Array([A.HIDE, 1, this.target.element_id]);
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
|
-
let
|
|
356
|
+
let pe = class extends p {
|
|
357
357
|
value;
|
|
358
358
|
constructor(e, o) {
|
|
359
359
|
super(e), this.value = o;
|
|
@@ -369,13 +369,13 @@ let me = class extends p {
|
|
|
369
369
|
return n.set(r, 0), n.set(o, 5), n;
|
|
370
370
|
}
|
|
371
371
|
dataType() {
|
|
372
|
-
return typeof this.value === "string" ?
|
|
372
|
+
return typeof this.value === "string" ? C.STRING : C.NUMBER;
|
|
373
373
|
}
|
|
374
374
|
convertValue(e) {
|
|
375
|
-
return e ===
|
|
375
|
+
return e === C.STRING ? new TextEncoder().encode(this.value) : e === C.NUMBER ? new Uint8Array([this.value]) : new Uint8Array();
|
|
376
376
|
}
|
|
377
377
|
};
|
|
378
|
-
class
|
|
378
|
+
class me extends p {
|
|
379
379
|
format() {
|
|
380
380
|
return this.target.element_id !== 0 && this.target.property !== 0 ? new Uint8Array([
|
|
381
381
|
A.BROADCAST,
|
|
@@ -385,12 +385,12 @@ class ye extends p {
|
|
|
385
385
|
]) : new Uint8Array([A.BROADCAST, 0]);
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
|
-
class
|
|
388
|
+
class ye extends p {
|
|
389
389
|
format() {
|
|
390
390
|
return new Uint8Array([A.BREAK, 0]);
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
|
-
let
|
|
393
|
+
let Ee = class extends p {
|
|
394
394
|
fromLow;
|
|
395
395
|
fromHigh;
|
|
396
396
|
toLow;
|
|
@@ -414,7 +414,7 @@ let Te = class extends p {
|
|
|
414
414
|
]);
|
|
415
415
|
}
|
|
416
416
|
};
|
|
417
|
-
class
|
|
417
|
+
class Te extends p {
|
|
418
418
|
deciseconds;
|
|
419
419
|
resetable;
|
|
420
420
|
onComplete;
|
|
@@ -435,7 +435,7 @@ class De extends p {
|
|
|
435
435
|
), o;
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
|
-
class
|
|
438
|
+
class De extends p {
|
|
439
439
|
left;
|
|
440
440
|
operator;
|
|
441
441
|
right;
|
|
@@ -445,17 +445,17 @@ class Ie extends p {
|
|
|
445
445
|
}
|
|
446
446
|
convertValue(e) {
|
|
447
447
|
if (typeof e == "number")
|
|
448
|
-
return new Uint8Array([
|
|
448
|
+
return new Uint8Array([C.NUMBER, 1, e]);
|
|
449
449
|
if (typeof e == "string") {
|
|
450
450
|
const o = new TextEncoder().encode(e);
|
|
451
451
|
return new Uint8Array([
|
|
452
|
-
|
|
452
|
+
C.STRING,
|
|
453
453
|
o.length,
|
|
454
454
|
...o
|
|
455
455
|
]);
|
|
456
456
|
}
|
|
457
457
|
return e instanceof T ? new Uint8Array([
|
|
458
|
-
|
|
458
|
+
C.ELEMENT,
|
|
459
459
|
2,
|
|
460
460
|
e.element_id,
|
|
461
461
|
e.property
|
|
@@ -478,42 +478,42 @@ function En() {
|
|
|
478
478
|
return new T(t, e);
|
|
479
479
|
},
|
|
480
480
|
increment(t) {
|
|
481
|
-
return new
|
|
481
|
+
return new he(t);
|
|
482
482
|
},
|
|
483
483
|
decrement(t) {
|
|
484
|
-
return new
|
|
484
|
+
return new ge(t);
|
|
485
485
|
},
|
|
486
486
|
show(t) {
|
|
487
|
-
return new
|
|
487
|
+
return new Ae(new T(t, 0));
|
|
488
488
|
},
|
|
489
489
|
hide(t) {
|
|
490
|
-
return new
|
|
490
|
+
return new we(new T(t, 0));
|
|
491
491
|
},
|
|
492
492
|
set(t, e) {
|
|
493
|
-
return new
|
|
493
|
+
return new pe(t, e);
|
|
494
494
|
},
|
|
495
495
|
broadcast(t) {
|
|
496
|
-
return new
|
|
496
|
+
return new me(t || new T(0, 0));
|
|
497
497
|
},
|
|
498
498
|
timer(t, e, o) {
|
|
499
|
-
return new
|
|
499
|
+
return new Te(t, e, o);
|
|
500
500
|
},
|
|
501
501
|
stop() {
|
|
502
|
-
return new
|
|
502
|
+
return new ye(new T(0, 0));
|
|
503
503
|
},
|
|
504
504
|
condition(t, e, o, n) {
|
|
505
|
-
return new
|
|
505
|
+
return new De(t, e, o, n);
|
|
506
506
|
},
|
|
507
507
|
map(t, e, o, n, r, s) {
|
|
508
|
-
return new
|
|
508
|
+
return new Ee(t, e, o, n, r, s);
|
|
509
509
|
}
|
|
510
510
|
};
|
|
511
511
|
}
|
|
512
|
-
const { flattenUint8Arrays:
|
|
512
|
+
const { flattenUint8Arrays: Ie } = K();
|
|
513
513
|
function Tn(t) {
|
|
514
514
|
return {
|
|
515
515
|
setButton(e, o) {
|
|
516
|
-
const n =
|
|
516
|
+
const n = Ie(
|
|
517
517
|
o.map((s) => s.format())
|
|
518
518
|
), r = new Uint8Array(1 + n.length);
|
|
519
519
|
return r.set([e], 0), n.forEach(
|
|
@@ -528,13 +528,13 @@ function Ce(t) {
|
|
|
528
528
|
n.onload = () => e(n), n.onerror = o, n.src = t;
|
|
529
529
|
});
|
|
530
530
|
}
|
|
531
|
-
function
|
|
531
|
+
function Ue(t) {
|
|
532
532
|
const e = document.createElement("canvas"), o = e.getContext("2d");
|
|
533
533
|
if (e.width = t.width, e.height = t.height, !o)
|
|
534
534
|
throw new Error("Failed to get 2D context for image data.");
|
|
535
535
|
return o.drawImage(t, 0, 0), o.getImageData(0, 0, t.width, t.height);
|
|
536
536
|
}
|
|
537
|
-
function
|
|
537
|
+
function Se(t) {
|
|
538
538
|
const e = [], o = t.data, n = t.width, r = t.height;
|
|
539
539
|
for (let s = 0; s < r; s++)
|
|
540
540
|
for (let a = 0; a < n; a++) {
|
|
@@ -547,34 +547,34 @@ function be(t) {
|
|
|
547
547
|
pixels: e
|
|
548
548
|
};
|
|
549
549
|
}
|
|
550
|
-
function
|
|
550
|
+
function be() {
|
|
551
551
|
return {
|
|
552
552
|
createImage: Ce,
|
|
553
|
-
getImageData:
|
|
554
|
-
imageDataToPixels:
|
|
553
|
+
getImageData: Ue,
|
|
554
|
+
imageDataToPixels: Se
|
|
555
555
|
};
|
|
556
556
|
}
|
|
557
|
-
const { createImage:
|
|
558
|
-
function
|
|
557
|
+
const { createImage: _e, getImageData: Ne, imageDataToPixels: Re } = be(), { pixelsToBytes: xe } = K();
|
|
558
|
+
function Be(t) {
|
|
559
559
|
return new Promise((e, o) => {
|
|
560
|
-
|
|
560
|
+
_e(t).then((n) => Ne(n)).then((n) => Re(n)).then((n) => xe(n.pixels, n.width)).then((n) => e(n)).catch((n) => o(n));
|
|
561
561
|
});
|
|
562
562
|
}
|
|
563
563
|
function Dn() {
|
|
564
564
|
return {
|
|
565
|
-
imageToBytes:
|
|
565
|
+
imageToBytes: Be
|
|
566
566
|
};
|
|
567
567
|
}
|
|
568
|
-
function
|
|
568
|
+
function Pe(t, e, o, n, r) {
|
|
569
569
|
return (t - e) / (o - e) * (r - n) + n;
|
|
570
570
|
}
|
|
571
571
|
function In() {
|
|
572
|
-
return { map:
|
|
572
|
+
return { map: Pe };
|
|
573
573
|
}
|
|
574
574
|
let d = !1;
|
|
575
|
-
const
|
|
576
|
-
let
|
|
577
|
-
const lt = new I.SyncEvent(),
|
|
575
|
+
const U = [], y = /* @__PURE__ */ new Map();
|
|
576
|
+
let M = 500, V = !1;
|
|
577
|
+
const lt = new I.SyncEvent(), v = new I.SyncEvent(), dt = /* @__PURE__ */ new Map([
|
|
578
578
|
[f.UPLOAD, "UPLOAD"],
|
|
579
579
|
[f.DRAW_IMAGE, "DRAW_IMAGE"],
|
|
580
580
|
[f.DRAW_RECTANGLE, "DRAW_RECTANGLE"],
|
|
@@ -586,31 +586,31 @@ const lt = new I.SyncEvent(), L = new I.SyncEvent(), dt = /* @__PURE__ */ new Ma
|
|
|
586
586
|
[f.CLEAR_SCREEN, "CLEAR_SCREEN"],
|
|
587
587
|
[f.LOADER, "LOADER"]
|
|
588
588
|
]);
|
|
589
|
-
function
|
|
590
|
-
d = !0, V || (
|
|
589
|
+
function Le() {
|
|
590
|
+
d = !0, V || (We(), V = !0);
|
|
591
591
|
}
|
|
592
|
-
function
|
|
592
|
+
function Me() {
|
|
593
593
|
d = !1;
|
|
594
594
|
}
|
|
595
595
|
function ve() {
|
|
596
596
|
return d;
|
|
597
597
|
}
|
|
598
|
-
function
|
|
599
|
-
|
|
598
|
+
function Oe(t) {
|
|
599
|
+
M = t, ht();
|
|
600
600
|
}
|
|
601
|
-
function
|
|
602
|
-
return
|
|
601
|
+
function ke() {
|
|
602
|
+
return U;
|
|
603
603
|
}
|
|
604
|
-
function
|
|
604
|
+
function $e() {
|
|
605
605
|
return Array.from(y.values());
|
|
606
606
|
}
|
|
607
|
-
function
|
|
607
|
+
function ze(t) {
|
|
608
608
|
return y.get(t);
|
|
609
609
|
}
|
|
610
|
-
function
|
|
611
|
-
|
|
610
|
+
function He() {
|
|
611
|
+
U.length = 0, y.clear();
|
|
612
612
|
}
|
|
613
|
-
function
|
|
613
|
+
function Fe(t) {
|
|
614
614
|
const e = t.length > i.TYPE ? t[i.TYPE] : 0;
|
|
615
615
|
return {
|
|
616
616
|
cacheId: t[i.CACHE],
|
|
@@ -631,17 +631,17 @@ function g(t, e) {
|
|
|
631
631
|
timestamp: Date.now(),
|
|
632
632
|
data: e
|
|
633
633
|
};
|
|
634
|
-
|
|
634
|
+
U.push(o), ht(), lt.post(o);
|
|
635
635
|
}
|
|
636
636
|
function ht() {
|
|
637
|
-
|
|
637
|
+
U.length > M && U.splice(0, U.length - M);
|
|
638
638
|
}
|
|
639
|
-
function
|
|
639
|
+
function Ge(t, e) {
|
|
640
640
|
if (!d) return;
|
|
641
641
|
const o = y.get(t);
|
|
642
|
-
o && (Object.assign(o, e), o.completedAt && o.queuedAt && (o.latencyMs = o.completedAt - o.queuedAt),
|
|
642
|
+
o && (Object.assign(o, e), o.completedAt && o.queuedAt && (o.latencyMs = o.completedAt - o.queuedAt), v.post(o));
|
|
643
643
|
}
|
|
644
|
-
function
|
|
644
|
+
function We() {
|
|
645
645
|
const t = tt(), e = Z(), o = x();
|
|
646
646
|
t.onMessageQueued.attach((n) => {
|
|
647
647
|
d && (y.set(n.cacheId, {
|
|
@@ -673,7 +673,7 @@ function Ve() {
|
|
|
673
673
|
}), t.onRetransmit.attach((n) => {
|
|
674
674
|
if (!d) return;
|
|
675
675
|
const r = y.get(n.cacheId);
|
|
676
|
-
r && (r.retransmitCount++,
|
|
676
|
+
r && (r.retransmitCount++, v.post(r)), g("retransmit", {
|
|
677
677
|
cacheId: n.cacheId,
|
|
678
678
|
packetCount: n.packetCount,
|
|
679
679
|
reason: n.reason
|
|
@@ -681,14 +681,14 @@ function Ve() {
|
|
|
681
681
|
}), t.onTimeout.attach((n) => {
|
|
682
682
|
if (!d) return;
|
|
683
683
|
const r = y.get(n.cacheId);
|
|
684
|
-
r && (r.timeoutCount++,
|
|
684
|
+
r && (r.timeoutCount++, v.post(r)), g("timeout", {
|
|
685
685
|
cacheId: n.cacheId,
|
|
686
686
|
retryCount: n.retryCount,
|
|
687
687
|
maxRetries: n.maxRetries,
|
|
688
688
|
willRetry: n.willRetry
|
|
689
689
|
});
|
|
690
690
|
}), t.onMessageComplete.attach((n) => {
|
|
691
|
-
d && (
|
|
691
|
+
d && (Ge(n.cacheId, {
|
|
692
692
|
completedAt: n.timestamp
|
|
693
693
|
}), g("message_complete", {
|
|
694
694
|
cacheId: n.cacheId
|
|
@@ -711,26 +711,26 @@ function Ve() {
|
|
|
711
711
|
d && g("disconnected", {});
|
|
712
712
|
});
|
|
713
713
|
}
|
|
714
|
-
function
|
|
715
|
-
d = !1,
|
|
714
|
+
function Ve() {
|
|
715
|
+
d = !1, U.length = 0, y.clear(), V = !1, M = 500;
|
|
716
716
|
}
|
|
717
|
-
function
|
|
717
|
+
function Cn() {
|
|
718
718
|
return {
|
|
719
|
-
enable:
|
|
720
|
-
disable:
|
|
719
|
+
enable: Le,
|
|
720
|
+
disable: Me,
|
|
721
721
|
isEnabled: ve,
|
|
722
|
-
clear:
|
|
723
|
-
getLog:
|
|
724
|
-
getTimings:
|
|
725
|
-
getTimingForCache:
|
|
726
|
-
setMaxLogSize:
|
|
727
|
-
decodePacket:
|
|
722
|
+
clear: He,
|
|
723
|
+
getLog: ke,
|
|
724
|
+
getTimings: $e,
|
|
725
|
+
getTimingForCache: ze,
|
|
726
|
+
setMaxLogSize: Oe,
|
|
727
|
+
decodePacket: Fe,
|
|
728
728
|
onDebugEvent: lt,
|
|
729
|
-
onTimingUpdate:
|
|
730
|
-
_resetForTesting:
|
|
729
|
+
onTimingUpdate: v,
|
|
730
|
+
_resetForTesting: Ve
|
|
731
731
|
};
|
|
732
732
|
}
|
|
733
|
-
const { messageCharUuid:
|
|
733
|
+
const { messageCharUuid: Ze, messageFloodCharUuid: L, handshakeCharUuid: gt, BATCH_SIZE: Ye, PACKET_SIZE: O } = k();
|
|
734
734
|
let q = !1, R = !1, H = !0, h = { standees: [] };
|
|
735
735
|
const m = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Map();
|
|
736
736
|
let S = 0;
|
|
@@ -743,7 +743,7 @@ function Ke(t) {
|
|
|
743
743
|
...t
|
|
744
744
|
}, q = !0, R = !1, H = !0, m.clear(), D.clear(), S = 0, et(rn);
|
|
745
745
|
}
|
|
746
|
-
function
|
|
746
|
+
function At() {
|
|
747
747
|
q = !1, R = !1, H = !0, m.clear(), D.clear(), S = 0, et(null);
|
|
748
748
|
}
|
|
749
749
|
function qe() {
|
|
@@ -756,22 +756,22 @@ function je(t) {
|
|
|
756
756
|
h = { ...h, ...t };
|
|
757
757
|
}
|
|
758
758
|
function Je(t, e, o) {
|
|
759
|
-
const n = m.get(
|
|
759
|
+
const n = m.get(L);
|
|
760
760
|
if (!n) return;
|
|
761
761
|
const r = e === "plus" ? G.PLUS : e === "minus" ? G.MINUS : G.EITHER, s = o ? new TextEncoder().encode(o) : new Uint8Array(0), a = i.DATA + 1 + s.length, c = new ArrayBuffer(a), u = new DataView(c);
|
|
762
|
-
u.setUint8(i.ID, t), u.setUint8(i.TYPE,
|
|
762
|
+
u.setUint8(i.ID, t), u.setUint8(i.TYPE, P.DATA_FEEDBACK), u.setUint8(i.DATA, r);
|
|
763
763
|
for (let l = 0; l < s.length; l++)
|
|
764
764
|
u.setUint8(i.DATA + 1 + l, s[l]);
|
|
765
765
|
n(u);
|
|
766
766
|
}
|
|
767
767
|
function Qe(t) {
|
|
768
|
-
const e = m.get(
|
|
768
|
+
const e = m.get(L);
|
|
769
769
|
if (!e) return;
|
|
770
770
|
const o = new ArrayBuffer(i.DATA + 1), n = new DataView(o);
|
|
771
|
-
n.setUint8(i.ID, t), n.setUint8(i.TYPE,
|
|
771
|
+
n.setUint8(i.ID, t), n.setUint8(i.TYPE, P.LOST_NODE), n.setUint8(i.DATA, t), e(n);
|
|
772
772
|
}
|
|
773
773
|
function tn(t) {
|
|
774
|
-
const e = m.get(
|
|
774
|
+
const e = m.get(L);
|
|
775
775
|
e && e(cn(t));
|
|
776
776
|
}
|
|
777
777
|
function en() {
|
|
@@ -781,7 +781,7 @@ function nn(t) {
|
|
|
781
781
|
H = t;
|
|
782
782
|
}
|
|
783
783
|
function on() {
|
|
784
|
-
|
|
784
|
+
At();
|
|
785
785
|
}
|
|
786
786
|
const rn = {
|
|
787
787
|
async connect(t) {
|
|
@@ -795,7 +795,7 @@ const rn = {
|
|
|
795
795
|
async readCharacteristic(t, e) {
|
|
796
796
|
},
|
|
797
797
|
async writeCharacteristic(t, e, o) {
|
|
798
|
-
if (!R || e !==
|
|
798
|
+
if (!R || e !== Ze || h.dropRate !== void 0 && h.dropRate > 0 && Math.random() < h.dropRate)
|
|
799
799
|
return;
|
|
800
800
|
const n = o[i.CACHE], r = o[i.POSITION] | o[i.POSITION + 1] << 8, s = o[i.DATA_SIZE] | o[i.DATA_SIZE + 1] << 8;
|
|
801
801
|
D.has(n) || D.set(n, {
|
|
@@ -804,7 +804,7 @@ const rn = {
|
|
|
804
804
|
});
|
|
805
805
|
const a = D.get(n);
|
|
806
806
|
a.received.add(r), S++;
|
|
807
|
-
const c = Math.ceil(s /
|
|
807
|
+
const c = Math.ceil(s / O);
|
|
808
808
|
if (a.received.size >= c) {
|
|
809
809
|
const l = h.responseDelay ?? 10;
|
|
810
810
|
setTimeout(() => {
|
|
@@ -818,58 +818,58 @@ const rn = {
|
|
|
818
818
|
setTimeout(() => {
|
|
819
819
|
const E = [];
|
|
820
820
|
for (const [F, X] of D) {
|
|
821
|
-
const
|
|
822
|
-
X.received.size <
|
|
821
|
+
const wt = Math.ceil(X.dataSize / O);
|
|
822
|
+
X.received.size < wt && E.push(F);
|
|
823
823
|
}
|
|
824
824
|
E.length > 0 && an(E);
|
|
825
825
|
}, l);
|
|
826
826
|
}
|
|
827
827
|
},
|
|
828
828
|
async subscribe(t, e, o) {
|
|
829
|
-
m.set(e, o), e ===
|
|
829
|
+
m.set(e, o), e === gt && un();
|
|
830
830
|
}
|
|
831
831
|
};
|
|
832
832
|
function sn(t) {
|
|
833
|
-
const e = m.get(
|
|
833
|
+
const e = m.get(L);
|
|
834
834
|
if (!e) return;
|
|
835
835
|
const o = new ArrayBuffer(i.DATA + 1), n = new DataView(o);
|
|
836
|
-
n.setUint8(i.TYPE,
|
|
836
|
+
n.setUint8(i.TYPE, P.MESSAGE_DONE), n.setUint8(i.DATA, t), D.delete(t), S = 0, e(n);
|
|
837
837
|
}
|
|
838
838
|
function an(t) {
|
|
839
|
-
const e = m.get(
|
|
839
|
+
const e = m.get(L);
|
|
840
840
|
if (!e) return;
|
|
841
841
|
const o = new ArrayBuffer(i.DATA + t.length), n = new DataView(o);
|
|
842
|
-
n.setUint8(i.TYPE,
|
|
842
|
+
n.setUint8(i.TYPE, P.DATA_FEEDBACK);
|
|
843
843
|
for (let r = 0; r < t.length; r++)
|
|
844
844
|
n.setUint8(i.DATA + r, t[r]);
|
|
845
845
|
e(n);
|
|
846
846
|
}
|
|
847
847
|
function cn(t) {
|
|
848
848
|
const e = i.DATA + 1 + t.neighbors.length, o = new ArrayBuffer(e), n = new DataView(o);
|
|
849
|
-
n.setUint8(i.TYPE,
|
|
849
|
+
n.setUint8(i.TYPE, P.NODES), n.setUint8(i.DATA, t.id);
|
|
850
850
|
for (let r = 0; r < t.neighbors.length; r++)
|
|
851
851
|
n.setUint8(i.DATA + 1 + r, t.neighbors[r]);
|
|
852
852
|
return n;
|
|
853
853
|
}
|
|
854
854
|
function un() {
|
|
855
|
-
const t = m.get(
|
|
855
|
+
const t = m.get(gt);
|
|
856
856
|
if (!t || h.standees.length === 0) return;
|
|
857
857
|
const e = [h.standees.length];
|
|
858
858
|
for (const r of h.standees)
|
|
859
859
|
e.push(r.id, r.neighbors.length, ...r.neighbors);
|
|
860
860
|
const o = 200, n = e.length;
|
|
861
|
-
for (let r = 0; r < n; r +=
|
|
862
|
-
const s = Math.min(
|
|
861
|
+
for (let r = 0; r < n; r += O) {
|
|
862
|
+
const s = Math.min(O, n - r), a = J + s, c = new ArrayBuffer(a), u = new DataView(c);
|
|
863
863
|
u.setUint8(i.ID, 0), u.setUint8(i.CACHE, o), u.setUint8(i.TTL, 10), u.setUint16(i.POSITION, r, !0), u.setUint16(i.DATA_SIZE, n, !0);
|
|
864
864
|
for (let l = 0; l < s; l++)
|
|
865
865
|
u.setUint8(J + l, e[r + l]);
|
|
866
866
|
t(u);
|
|
867
867
|
}
|
|
868
868
|
}
|
|
869
|
-
function
|
|
869
|
+
function Un() {
|
|
870
870
|
return {
|
|
871
871
|
activate: Ke,
|
|
872
|
-
deactivate:
|
|
872
|
+
deactivate: At,
|
|
873
873
|
isActive: qe,
|
|
874
874
|
getConfig: Xe,
|
|
875
875
|
updateConfig: je,
|
|
@@ -886,13 +886,13 @@ export {
|
|
|
886
886
|
K as useBinary,
|
|
887
887
|
Tn as useButtons,
|
|
888
888
|
Dn as useConverter,
|
|
889
|
-
|
|
889
|
+
Cn as useDebug,
|
|
890
890
|
pn as useDisplay,
|
|
891
891
|
hn as useGraphics,
|
|
892
|
-
|
|
892
|
+
be as useImage,
|
|
893
893
|
gn as useLoader,
|
|
894
|
-
|
|
895
|
-
|
|
894
|
+
Xt as useMesh,
|
|
895
|
+
Un as useMockBluetooth,
|
|
896
896
|
wn as useStandeeElements,
|
|
897
897
|
An as useStandees,
|
|
898
898
|
In as useUtils
|