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