nsd-ble 0.1.13 → 0.1.15

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.
@@ -1,5 +1,5 @@
1
1
  import { Data as L, DataType as z, Button as N } from "./enums.js";
2
- let F = !1, V = [], D, re, T = /* @__PURE__ */ new Map();
2
+ let F = !1, B = [], D, re, T = /* @__PURE__ */ new Map();
3
3
  async function le(a) {
4
4
  try {
5
5
  if (D = await navigator.bluetooth.requestDevice(a), D.gatt === void 0)
@@ -10,13 +10,13 @@ async function le(a) {
10
10
  }
11
11
  }
12
12
  function fe() {
13
- T.clear(), F = !1, V.forEach((a) => a());
13
+ T.clear(), F = !1, B.forEach((a) => a());
14
14
  }
15
15
  function ve(a) {
16
- V.push(a);
16
+ B.push(a);
17
17
  }
18
18
  function de(a) {
19
- V = V.filter((h) => h !== a);
19
+ B = B.filter((h) => h !== a);
20
20
  }
21
21
  async function H(a, h) {
22
22
  if (T.has(h)) {
@@ -31,17 +31,19 @@ async function H(a, h) {
31
31
  async function ye(a, h) {
32
32
  return await (await H(a, h)).readValue();
33
33
  }
34
- async function pe(a, h, s) {
35
- const c = new DataView(new ArrayBuffer(s.length));
36
- c.setUint8(0, s[0]), await (await H(a, h)).writeValue(c);
34
+ async function pe(a, h, r) {
35
+ const c = new DataView(new ArrayBuffer(r.length));
36
+ for (let l = 0; l < r.length; l++)
37
+ c.setUint8(l, r[l]);
38
+ await (await H(a, h)).writeValue(c);
37
39
  }
38
- async function ge(a, h, s) {
40
+ async function ge(a, h, r) {
39
41
  const c = await H(a, h);
40
42
  c.addEventListener(
41
43
  "characteristicvaluechanged",
42
44
  (d) => {
43
- let f = d.target.value;
44
- f === void 0 && (f = new DataView(new ArrayBuffer(0))), s(f);
45
+ let l = d.target.value;
46
+ l === void 0 && (l = new DataView(new ArrayBuffer(0))), r(l);
45
47
  }
46
48
  ), await c.startNotifications();
47
49
  }
@@ -69,7 +71,7 @@ function Ce() {
69
71
  };
70
72
  }
71
73
  var m = {}, q = {}, J;
72
- function B() {
74
+ function V() {
73
75
  if (J) return q;
74
76
  J = 1, Object.defineProperty(q, "__esModule", { value: !0 }), q.BaseEvent = void 0;
75
77
  var a = (
@@ -77,57 +79,57 @@ function B() {
77
79
  (function() {
78
80
  function h() {
79
81
  }
80
- return h.prototype.attach = function(s, c) {
81
- return this._attach(s, c, !1);
82
- }, h.prototype.once = function(s, c) {
83
- return this._attach(s, c, !0);
84
- }, h.prototype._attach = function(s, c, d) {
85
- var f = this, u, i, r, o;
86
- if (typeof s == "function")
87
- i = s, o = function() {
88
- return f.detach(i);
82
+ return h.prototype.attach = function(r, c) {
83
+ return this._attach(r, c, !1);
84
+ }, h.prototype.once = function(r, c) {
85
+ return this._attach(r, c, !0);
86
+ }, h.prototype._attach = function(r, c, d) {
87
+ var l = this, u, i, s, o;
88
+ if (typeof r == "function")
89
+ i = r, o = function() {
90
+ return l.detach(i);
89
91
  };
90
- else if (!c && typeof s.post == "function")
91
- r = s, o = function() {
92
- return f.detach(r);
92
+ else if (!c && typeof r.post == "function")
93
+ s = r, o = function() {
94
+ return l.detach(s);
93
95
  };
94
96
  else {
95
- if (typeof s != "object" || s === void 0)
97
+ if (typeof r != "object" || r === void 0)
96
98
  throw new Error("Expect a function or object as first argument");
97
99
  if (typeof c != "function")
98
100
  throw new Error("Expect a function as second argument");
99
- u = s, i = c, o = function() {
100
- return f.detach(u, i);
101
+ u = r, i = c, o = function() {
102
+ return l.detach(u, i);
101
103
  };
102
104
  }
103
105
  return this._listeners ? this._listeners = this._listeners.slice() : this._listeners = [], this._listeners.push({
104
106
  deleted: !1,
105
107
  boundTo: u,
106
108
  handler: i,
107
- event: r,
109
+ event: s,
108
110
  once: d
109
111
  }), o;
110
112
  }, h.prototype.detach = function() {
111
- for (var s = [], c = 0; c < arguments.length; c++)
112
- s[c] = arguments[c];
113
- this._detach.apply(this, s);
113
+ for (var r = [], c = 0; c < arguments.length; c++)
114
+ r[c] = arguments[c];
115
+ this._detach.apply(this, r);
114
116
  }, h.prototype._detach = function() {
115
- for (var s = [], c = 0; c < arguments.length; c++)
116
- s[c] = arguments[c];
117
+ for (var r = [], c = 0; c < arguments.length; c++)
118
+ r[c] = arguments[c];
117
119
  if (!(!this._listeners || this._listeners.length === 0)) {
118
- var d, f, u;
119
- s.length >= 1 && (typeof s[0] == "function" ? f = s[0] : s.length === 1 && typeof s[0].post == "function" ? u = s[0] : d = s[0]), s.length >= 2 && (f = s[1]), this._listeners = this._listeners.filter(function(i) {
120
- return (typeof f > "u" || i.handler === f) && (typeof u > "u" || i.event === u) && (typeof d > "u" || i.boundTo === d) ? (i.deleted = !0, !1) : !0;
120
+ var d, l, u;
121
+ r.length >= 1 && (typeof r[0] == "function" ? l = r[0] : r.length === 1 && typeof r[0].post == "function" ? u = r[0] : d = r[0]), r.length >= 2 && (l = r[1]), this._listeners = this._listeners.filter(function(i) {
122
+ return (typeof l > "u" || i.handler === l) && (typeof u > "u" || i.event === u) && (typeof d > "u" || i.boundTo === d) ? (i.deleted = !0, !1) : !0;
121
123
  }), this._listeners.length === 0 && delete this._listeners;
122
124
  }
123
- }, h.prototype.post = function(s) {
125
+ }, h.prototype.post = function(r) {
124
126
  throw new Error("abstract");
125
127
  }, h.prototype.listenerCount = function() {
126
128
  return this._listeners ? this._listeners.length : 0;
127
- }, h.prototype._call = function(s, c) {
128
- this._listeners && (s.deleted || (s.once && (s.deleted = !0, this._listeners = this._listeners.filter(function(d) {
129
- return d !== s;
130
- }), this._listeners.length === 0 && delete this._listeners), s.event ? s.event.post.apply(s.event, c) : s.handler && s.handler.apply(typeof s.boundTo == "object" ? s.boundTo : this, c)));
129
+ }, h.prototype._call = function(r, c) {
130
+ this._listeners && (r.deleted || (r.once && (r.deleted = !0, this._listeners = this._listeners.filter(function(d) {
131
+ return d !== r;
132
+ }), this._listeners.length === 0 && delete this._listeners), r.event ? r.event.post.apply(r.event, c) : r.handler && r.handler.apply(typeof r.boundTo == "object" ? r.boundTo : this, c)));
131
133
  }, h;
132
134
  })()
133
135
  );
@@ -138,28 +140,28 @@ function j() {
138
140
  if (K) return E;
139
141
  K = 1;
140
142
  var a = E && E.__extends || /* @__PURE__ */ (function() {
141
- var f = function(u, i) {
142
- return f = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(r, o) {
143
- r.__proto__ = o;
144
- } || function(r, o) {
145
- for (var t in o) o.hasOwnProperty(t) && (r[t] = o[t]);
146
- }, f(u, i);
143
+ var l = function(u, i) {
144
+ return l = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(s, o) {
145
+ s.__proto__ = o;
146
+ } || function(s, o) {
147
+ for (var t in o) o.hasOwnProperty(t) && (s[t] = o[t]);
148
+ }, l(u, i);
147
149
  };
148
150
  return function(u, i) {
149
- f(u, i);
150
- function r() {
151
+ l(u, i);
152
+ function s() {
151
153
  this.constructor = u;
152
154
  }
153
- u.prototype = i === null ? Object.create(i) : (r.prototype = i.prototype, new r());
155
+ u.prototype = i === null ? Object.create(i) : (s.prototype = i.prototype, new s());
154
156
  };
155
157
  })();
156
158
  Object.defineProperty(E, "__esModule", { value: !0 }), E.ErrorSyncEvent = E.VoidSyncEvent = E.SyncEvent = void 0;
157
- var h = B(), s = (
159
+ var h = V(), r = (
158
160
  /** @class */
159
- (function(f) {
160
- a(u, f);
161
+ (function(l) {
162
+ a(u, l);
161
163
  function u() {
162
- var i = f !== null && f.apply(this, arguments) || this;
164
+ var i = l !== null && l.apply(this, arguments) || this;
163
165
  return i._recursion = 0, i;
164
166
  }
165
167
  return Object.defineProperty(u.prototype, "evtListenersChanged", {
@@ -172,8 +174,8 @@ function j() {
172
174
  enumerable: !1,
173
175
  configurable: !0
174
176
  }), u.prototype.post = function() {
175
- for (var i = [], r = 0; r < arguments.length; r++)
176
- i[r] = arguments[r];
177
+ for (var i = [], s = 0; s < arguments.length; s++)
178
+ i[s] = arguments[s];
177
179
  if (!(!this._listeners || this._listeners.length === 0)) {
178
180
  if (this._recursion++, typeof u.MAX_RECURSION_DEPTH == "number" && Number.isInteger(u.MAX_RECURSION_DEPTH) && u.MAX_RECURSION_DEPTH > 0 && this._recursion > u.MAX_RECURSION_DEPTH)
179
181
  throw new Error("event fired recursively");
@@ -183,44 +185,44 @@ function j() {
183
185
  }
184
186
  this._recursion--;
185
187
  }
186
- }, u.prototype._attach = function(i, r, o) {
187
- var t, e, n, l, v = (e = (t = this._listeners) === null || t === void 0 ? void 0 : t.length) !== null && e !== void 0 ? e : 0, y = f.prototype._attach.call(this, i, r, o);
188
- return this.evtListenersChanged && v !== ((l = (n = this._listeners) === null || n === void 0 ? void 0 : n.length) !== null && l !== void 0 ? l : 0) && this.evtListenersChanged.post(), y;
188
+ }, u.prototype._attach = function(i, s, o) {
189
+ var t, e, n, f, v = (e = (t = this._listeners) === null || t === void 0 ? void 0 : t.length) !== null && e !== void 0 ? e : 0, y = l.prototype._attach.call(this, i, s, o);
190
+ return this.evtListenersChanged && v !== ((f = (n = this._listeners) === null || n === void 0 ? void 0 : n.length) !== null && f !== void 0 ? f : 0) && this.evtListenersChanged.post(), y;
189
191
  }, u.prototype._detach = function() {
190
- for (var i, r, o, t, e = [], n = 0; n < arguments.length; n++)
192
+ for (var i, s, o, t, e = [], n = 0; n < arguments.length; n++)
191
193
  e[n] = arguments[n];
192
- var l = (r = (i = this._listeners) === null || i === void 0 ? void 0 : i.length) !== null && r !== void 0 ? r : 0, v = f.prototype._detach.apply(this, e);
193
- return this.evtListenersChanged && l !== ((t = (o = this._listeners) === null || o === void 0 ? void 0 : o.length) !== null && t !== void 0 ? t : 0) && this.evtListenersChanged.post(), v;
194
+ var f = (s = (i = this._listeners) === null || i === void 0 ? void 0 : i.length) !== null && s !== void 0 ? s : 0, v = l.prototype._detach.apply(this, e);
195
+ return this.evtListenersChanged && f !== ((t = (o = this._listeners) === null || o === void 0 ? void 0 : o.length) !== null && t !== void 0 ? t : 0) && this.evtListenersChanged.post(), v;
194
196
  }, u.MAX_RECURSION_DEPTH = 10, u;
195
197
  })(h.BaseEvent)
196
198
  );
197
- E.SyncEvent = s;
199
+ E.SyncEvent = r;
198
200
  var c = (
199
201
  /** @class */
200
- (function(f) {
201
- a(u, f);
202
+ (function(l) {
203
+ a(u, l);
202
204
  function u() {
203
- return f !== null && f.apply(this, arguments) || this;
205
+ return l !== null && l.apply(this, arguments) || this;
204
206
  }
205
207
  return u.prototype.post = function() {
206
- f.prototype.post.call(this, void 0);
208
+ l.prototype.post.call(this, void 0);
207
209
  }, u;
208
- })(s)
210
+ })(r)
209
211
  );
210
212
  E.VoidSyncEvent = c;
211
213
  var d = (
212
214
  /** @class */
213
- (function(f) {
214
- a(u, f);
215
+ (function(l) {
216
+ a(u, l);
215
217
  function u() {
216
- return f !== null && f.apply(this, arguments) || this;
218
+ return l !== null && l.apply(this, arguments) || this;
217
219
  }
218
220
  return u.prototype.post = function(i) {
219
221
  if (this.listenerCount() === 0)
220
222
  throw new Error("error event posted while no listeners attached. Error: " + i.message);
221
- f.prototype.post.call(this, i);
223
+ l.prototype.post.call(this, i);
222
224
  }, u;
223
- })(s)
225
+ })(r)
224
226
  );
225
227
  return E.ErrorSyncEvent = d, E;
226
228
  }
@@ -231,31 +233,31 @@ function I() {
231
233
  var a = j(), h = (
232
234
  /** @class */
233
235
  (function() {
234
- function s() {
236
+ function r() {
235
237
  this.evtFilled = new a.SyncEvent(), this.evtDrained = new a.SyncEvent(), this._queue = [], this._flushing = !1;
236
238
  }
237
- return s.global = function() {
238
- return s._instance || s.resetGlobal(), s._instance;
239
- }, s.resetGlobal = function() {
240
- s._instance = new s();
241
- }, s.prototype.empty = function() {
239
+ return r.global = function() {
240
+ return r._instance || r.resetGlobal(), r._instance;
241
+ }, r.resetGlobal = function() {
242
+ r._instance = new r();
243
+ }, r.prototype.empty = function() {
242
244
  return this._queue.length === 0;
243
- }, s.prototype.add = function(c) {
245
+ }, r.prototype.add = function(c) {
244
246
  this._queue.push(c), this._queue.length === 1 && !this._flushing && this.evtFilled.post(this);
245
- }, s.prototype.flushOnce = function() {
247
+ }, r.prototype.flushOnce = function() {
246
248
  var c = this._queue.length === 0, d = this._flushing;
247
249
  this._flushing = !0;
248
250
  try {
249
- var f = this._queue;
251
+ var l = this._queue;
250
252
  this._queue = [];
251
- for (var u = 0; u < f.length; ++u)
252
- f[u]();
253
+ for (var u = 0; u < l.length; ++u)
254
+ l[u]();
253
255
  } finally {
254
256
  this._flushing = d, !c && !d && this._queue.length === 0 && this.evtDrained.post(this);
255
257
  }
256
- }, s.prototype.flush = function(c) {
258
+ }, r.prototype.flush = function(c) {
257
259
  c === void 0 && (c = 10);
258
- var d = this._queue.length === 0, f = this._flushing;
260
+ var d = this._queue.length === 0, l = this._flushing;
259
261
  this._flushing = !0;
260
262
  try {
261
263
  for (var u = 0; this._queue.length > 0; ) {
@@ -264,9 +266,9 @@ function I() {
264
266
  this.flushOnce(), ++u;
265
267
  }
266
268
  } finally {
267
- this._flushing = f, !d && !f && this._queue.length === 0 && this.evtDrained.post(this);
269
+ this._flushing = l, !d && !l && this._queue.length === 0 && this.evtDrained.post(this);
268
270
  }
269
- }, s;
271
+ }, r;
270
272
  })()
271
273
  );
272
274
  return Q.default = h, Q;
@@ -276,32 +278,32 @@ function ie() {
276
278
  if (Z) return w;
277
279
  Z = 1;
278
280
  var a = w && w.__extends || /* @__PURE__ */ (function() {
279
- var i = function(r, o) {
281
+ var i = function(s, o) {
280
282
  return i = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, e) {
281
283
  t.__proto__ = e;
282
284
  } || function(t, e) {
283
285
  for (var n in e) e.hasOwnProperty(n) && (t[n] = e[n]);
284
- }, i(r, o);
286
+ }, i(s, o);
285
287
  };
286
- return function(r, o) {
287
- i(r, o);
288
+ return function(s, o) {
289
+ i(s, o);
288
290
  function t() {
289
- this.constructor = r;
291
+ this.constructor = s;
290
292
  }
291
- r.prototype = o === null ? Object.create(o) : (t.prototype = o.prototype, new t());
293
+ s.prototype = o === null ? Object.create(o) : (t.prototype = o.prototype, new t());
292
294
  };
293
295
  })();
294
296
  Object.defineProperty(w, "__esModule", { value: !0 }), w.ErrorQueuedEvent = w.VoidQueuedEvent = w.QueuedEvent = void 0;
295
- var h = B(), s = I(), c = j(), d = (
297
+ var h = V(), r = I(), c = j(), d = (
296
298
  /** @class */
297
299
  (function(i) {
298
- a(r, i);
299
- function r(o) {
300
+ a(s, i);
301
+ function s(o) {
300
302
  o === void 0 && (o = {});
301
303
  var t = i.call(this) || this;
302
304
  return t._queued = !1, t.options = o, typeof o.condensed == "boolean" ? t._condensed = o.condensed : t._condensed = !1, typeof o.queue == "object" && o.queue !== null && (t._queue = o.queue), t;
303
305
  }
304
- return Object.defineProperty(r.prototype, "evtListenersChanged", {
306
+ return Object.defineProperty(s.prototype, "evtListenersChanged", {
305
307
  /**
306
308
  * Sent when someone attaches or detaches
307
309
  */
@@ -310,11 +312,11 @@ function ie() {
310
312
  },
311
313
  enumerable: !1,
312
314
  configurable: !0
313
- }), r.prototype.post = function() {
315
+ }), s.prototype.post = function() {
314
316
  for (var o = this, t = [], e = 0; e < arguments.length; e++)
315
317
  t[e] = arguments[e];
316
318
  if (!(!this._listeners || this._listeners.length === 0)) {
317
- var n = this._queue ? this._queue : s.default.global();
319
+ var n = this._queue ? this._queue : r.default.global();
318
320
  if (this._condensed) {
319
321
  if (this._queuedData = t, this._queuedListeners = this._listeners, this._queued)
320
322
  return;
@@ -326,52 +328,52 @@ function ie() {
326
328
  }
327
329
  });
328
330
  } else {
329
- var l = this._listeners;
331
+ var f = this._listeners;
330
332
  n.add(function() {
331
- for (var v = 0; v < l.length; ++v) {
332
- var y = l[v];
333
+ for (var v = 0; v < f.length; ++v) {
334
+ var y = f[v];
333
335
  o._call(y, t);
334
336
  }
335
337
  });
336
338
  }
337
339
  }
338
- }, r.prototype._attach = function(o, t, e) {
339
- var n, l, v, y, p = (l = (n = this._listeners) === null || n === void 0 ? void 0 : n.length) !== null && l !== void 0 ? l : 0, g = i.prototype._attach.call(this, o, t, e);
340
+ }, s.prototype._attach = function(o, t, e) {
341
+ var n, f, v, y, p = (f = (n = this._listeners) === null || n === void 0 ? void 0 : n.length) !== null && f !== void 0 ? f : 0, g = i.prototype._attach.call(this, o, t, e);
340
342
  return this.evtListenersChanged && p !== ((y = (v = this._listeners) === null || v === void 0 ? void 0 : v.length) !== null && y !== void 0 ? y : 0) && this.evtListenersChanged.post(), g;
341
- }, r.prototype._detach = function() {
342
- for (var o, t, e, n, l = [], v = 0; v < arguments.length; v++)
343
- l[v] = arguments[v];
344
- var y = (t = (o = this._listeners) === null || o === void 0 ? void 0 : o.length) !== null && t !== void 0 ? t : 0, p = i.prototype._detach.apply(this, l);
343
+ }, s.prototype._detach = function() {
344
+ for (var o, t, e, n, f = [], v = 0; v < arguments.length; v++)
345
+ f[v] = arguments[v];
346
+ var y = (t = (o = this._listeners) === null || o === void 0 ? void 0 : o.length) !== null && t !== void 0 ? t : 0, p = i.prototype._detach.apply(this, f);
345
347
  return this.evtListenersChanged && y !== ((n = (e = this._listeners) === null || e === void 0 ? void 0 : e.length) !== null && n !== void 0 ? n : 0) && this.evtListenersChanged.post(), p;
346
- }, r;
348
+ }, s;
347
349
  })(h.BaseEvent)
348
350
  );
349
351
  w.QueuedEvent = d;
350
- var f = (
352
+ var l = (
351
353
  /** @class */
352
354
  (function(i) {
353
- a(r, i);
354
- function r() {
355
+ a(s, i);
356
+ function s() {
355
357
  return i !== null && i.apply(this, arguments) || this;
356
358
  }
357
- return r.prototype.post = function() {
359
+ return s.prototype.post = function() {
358
360
  i.prototype.post.call(this, void 0);
359
- }, r;
361
+ }, s;
360
362
  })(d)
361
363
  );
362
- w.VoidQueuedEvent = f;
364
+ w.VoidQueuedEvent = l;
363
365
  var u = (
364
366
  /** @class */
365
367
  (function(i) {
366
- a(r, i);
367
- function r() {
368
+ a(s, i);
369
+ function s() {
368
370
  return i !== null && i.apply(this, arguments) || this;
369
371
  }
370
- return r.prototype.post = function(o) {
372
+ return s.prototype.post = function(o) {
371
373
  if (!this._listeners || this._listeners.length === 0)
372
374
  throw new Error("error event posted while no listeners attached. Error: " + o.message);
373
375
  i.prototype.post.call(this, o);
374
- }, r;
376
+ }, s;
375
377
  })(d)
376
378
  );
377
379
  return w.ErrorQueuedEvent = u, w;
@@ -381,82 +383,82 @@ function oe() {
381
383
  if (x) return b;
382
384
  x = 1;
383
385
  var a = b && b.__extends || /* @__PURE__ */ (function() {
384
- var u = function(i, r) {
386
+ var u = function(i, s) {
385
387
  return u = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(o, t) {
386
388
  o.__proto__ = t;
387
389
  } || function(o, t) {
388
390
  for (var e in t) t.hasOwnProperty(e) && (o[e] = t[e]);
389
- }, u(i, r);
391
+ }, u(i, s);
390
392
  };
391
- return function(i, r) {
392
- u(i, r);
393
+ return function(i, s) {
394
+ u(i, s);
393
395
  function o() {
394
396
  this.constructor = i;
395
397
  }
396
- i.prototype = r === null ? Object.create(r) : (o.prototype = r.prototype, new o());
398
+ i.prototype = s === null ? Object.create(s) : (o.prototype = s.prototype, new o());
397
399
  };
398
400
  })();
399
401
  Object.defineProperty(b, "__esModule", { value: !0 }), b.ErrorAsyncEvent = b.VoidAsyncEvent = b.AsyncEvent = void 0;
400
- var h = B(), s = j(), c = (
402
+ var h = V(), r = j(), c = (
401
403
  /** @class */
402
404
  (function(u) {
403
405
  a(i, u);
404
- function i(r) {
405
- r === void 0 && (r = {});
406
+ function i(s) {
407
+ s === void 0 && (s = {});
406
408
  var o = u.call(this) || this;
407
- return o._queued = !1, o.options = r, typeof r.condensed == "boolean" ? o._condensed = r.condensed : o._condensed = !1, o;
409
+ return o._queued = !1, o.options = s, typeof s.condensed == "boolean" ? o._condensed = s.condensed : o._condensed = !1, o;
408
410
  }
409
411
  return Object.defineProperty(i.prototype, "evtListenersChanged", {
410
412
  /**
411
413
  * Sent when someone attaches or detaches
412
414
  */
413
415
  get: function() {
414
- return this._listenersChanged || (this._listenersChanged = new s.VoidSyncEvent()), this._listenersChanged;
416
+ return this._listenersChanged || (this._listenersChanged = new r.VoidSyncEvent()), this._listenersChanged;
415
417
  },
416
418
  enumerable: !1,
417
419
  configurable: !0
418
- }), i.defaultScheduler = function(r) {
419
- typeof window < "u" ? setTimeout(r, 0) : setImmediate(r);
420
- }, i.setScheduler = function(r) {
421
- i._scheduler = r;
420
+ }), i.defaultScheduler = function(s) {
421
+ typeof window < "u" ? setTimeout(s, 0) : setImmediate(s);
422
+ }, i.setScheduler = function(s) {
423
+ i._scheduler = s;
422
424
  }, i.prototype.post = function() {
423
- for (var r = this, o = [], t = 0; t < arguments.length; t++)
425
+ for (var s = this, o = [], t = 0; t < arguments.length; t++)
424
426
  o[t] = arguments[t];
425
427
  if (!(!this._listeners || this._listeners.length === 0))
426
428
  if (this._condensed) {
427
429
  if (this._queuedData = o, this._queuedListeners = this._listeners, this._queued)
428
430
  return;
429
431
  this._queued = !0, i._scheduler(function() {
430
- r._queued = !1;
431
- for (var n = r._queuedData, l = r._queuedListeners, v = 0; v < l.length; ++v) {
432
- var y = l[v];
433
- r._call(y, n);
432
+ s._queued = !1;
433
+ for (var n = s._queuedData, f = s._queuedListeners, v = 0; v < f.length; ++v) {
434
+ var y = f[v];
435
+ s._call(y, n);
434
436
  }
435
437
  });
436
438
  } else {
437
439
  var e = this._listeners;
438
440
  i._scheduler(function() {
439
441
  for (var n = 0; n < e.length; ++n) {
440
- var l = e[n];
441
- r._call(l, o);
442
+ var f = e[n];
443
+ s._call(f, o);
442
444
  }
443
445
  });
444
446
  }
445
- }, i.prototype._call = function(r, o) {
446
- r.event && r.event instanceof i ? r.event._postDirect(o) : u.prototype._call.call(this, r, o);
447
- }, i.prototype._postDirect = function(r) {
447
+ }, i.prototype._call = function(s, o) {
448
+ s.event && s.event instanceof i ? s.event._postDirect(o) : u.prototype._call.call(this, s, o);
449
+ }, i.prototype._postDirect = function(s) {
448
450
  if (!(!this._listeners || this._listeners.length === 0))
449
451
  for (var o = this._listeners, t = 0; t < o.length; ++t) {
450
452
  var e = o[t];
451
- this._call(e, r);
453
+ this._call(e, s);
452
454
  }
453
- }, i.prototype._attach = function(r, o, t) {
454
- var e, n, l, v, y = (n = (e = this._listeners) === null || e === void 0 ? void 0 : e.length) !== null && n !== void 0 ? n : 0, p = u.prototype._attach.call(this, r, o, t);
455
- return this.evtListenersChanged && y !== ((v = (l = this._listeners) === null || l === void 0 ? void 0 : l.length) !== null && v !== void 0 ? v : 0) && this.evtListenersChanged.post(), p;
455
+ }, i.prototype._attach = function(s, o, t) {
456
+ var e, n, f, v, y = (n = (e = this._listeners) === null || e === void 0 ? void 0 : e.length) !== null && n !== void 0 ? n : 0, p = u.prototype._attach.call(this, s, o, t);
457
+ return this.evtListenersChanged && y !== ((v = (f = this._listeners) === null || f === void 0 ? void 0 : f.length) !== null && v !== void 0 ? v : 0) && this.evtListenersChanged.post(), p;
456
458
  }, i.prototype._detach = function() {
457
- for (var r, o, t, e, n = [], l = 0; l < arguments.length; l++)
458
- n[l] = arguments[l];
459
- var v = (o = (r = this._listeners) === null || r === void 0 ? void 0 : r.length) !== null && o !== void 0 ? o : 0, y = u.prototype._detach.apply(this, n);
459
+ for (var s, o, t, e, n = [], f = 0; f < arguments.length; f++)
460
+ n[f] = arguments[f];
461
+ var v = (o = (s = this._listeners) === null || s === void 0 ? void 0 : s.length) !== null && o !== void 0 ? o : 0, y = u.prototype._detach.apply(this, n);
460
462
  return this.evtListenersChanged && v !== ((e = (t = this._listeners) === null || t === void 0 ? void 0 : t.length) !== null && e !== void 0 ? e : 0) && this.evtListenersChanged.post(), y;
461
463
  }, i._scheduler = i.defaultScheduler, i;
462
464
  })(h.BaseEvent)
@@ -475,30 +477,30 @@ function oe() {
475
477
  })(c)
476
478
  );
477
479
  b.VoidAsyncEvent = d;
478
- var f = (
480
+ var l = (
479
481
  /** @class */
480
482
  (function(u) {
481
483
  a(i, u);
482
484
  function i() {
483
485
  return u !== null && u.apply(this, arguments) || this;
484
486
  }
485
- return i.prototype.post = function(r) {
487
+ return i.prototype.post = function(s) {
486
488
  if (this.listenerCount() === 0)
487
- throw new Error("error event posted while no listeners attached. Error: " + r.message);
488
- u.prototype.post.call(this, r);
489
+ throw new Error("error event posted while no listeners attached. Error: " + s.message);
490
+ u.prototype.post.call(this, s);
489
491
  }, i;
490
492
  })(c)
491
493
  );
492
- return b.ErrorAsyncEvent = f, b;
494
+ return b.ErrorAsyncEvent = l, b;
493
495
  }
494
496
  var O = {}, P = {}, ee;
495
497
  function me() {
496
498
  if (ee) return P;
497
499
  ee = 1, Object.defineProperty(P, "__esModule", { value: !0 }), P.shallowEquals = void 0;
498
- function a(h, s) {
499
- if (h === s)
500
+ function a(h, r) {
501
+ if (h === r)
500
502
  return !0;
501
- if (typeof h != typeof s)
503
+ if (typeof h != typeof r)
502
504
  return !1;
503
505
  switch (typeof h) {
504
506
  case "boolean":
@@ -509,25 +511,25 @@ function me() {
509
511
  case "undefined":
510
512
  return !1;
511
513
  case "object":
512
- if (h === null || s === null)
514
+ if (h === null || r === null)
513
515
  return !1;
514
- if (Array.isArray(h) || Array.isArray(s)) {
515
- if (!Array.isArray(h) || !Array.isArray(s) || h.length !== s.length)
516
+ if (Array.isArray(h) || Array.isArray(r)) {
517
+ if (!Array.isArray(h) || !Array.isArray(r) || h.length !== r.length)
516
518
  return !1;
517
519
  for (var c = 0; c < h.length; ++c)
518
- if (h[c] !== s[c])
520
+ if (h[c] !== r[c])
519
521
  return !1;
520
522
  return !0;
521
523
  }
522
- var d = [], f = [];
524
+ var d = [], l = [];
523
525
  for (var u in h)
524
526
  h.hasOwnProperty(u) && d.push(u);
525
- for (var i in s)
526
- s.hasOwnProperty(i) && f.push(i);
527
- if (d.sort(), f.sort(), d.join(",") !== f.join(","))
527
+ for (var i in r)
528
+ r.hasOwnProperty(i) && l.push(i);
529
+ if (d.sort(), l.sort(), d.join(",") !== l.join(","))
528
530
  return !1;
529
531
  for (var c = 0; c < d.length; ++c)
530
- if (h[d[c]] !== s[d[c]])
532
+ if (h[d[c]] !== r[d[c]])
531
533
  return !1;
532
534
  return !0;
533
535
  default:
@@ -541,22 +543,22 @@ function Ae() {
541
543
  return te || (te = 1, (function(a) {
542
544
  var h = O && O.__extends || /* @__PURE__ */ (function() {
543
545
  var t = function(e, n) {
544
- return t = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(l, v) {
545
- l.__proto__ = v;
546
- } || function(l, v) {
547
- for (var y in v) v.hasOwnProperty(y) && (l[y] = v[y]);
546
+ return t = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(f, v) {
547
+ f.__proto__ = v;
548
+ } || function(f, v) {
549
+ for (var y in v) v.hasOwnProperty(y) && (f[y] = v[y]);
548
550
  }, t(e, n);
549
551
  };
550
552
  return function(e, n) {
551
553
  t(e, n);
552
- function l() {
554
+ function f() {
553
555
  this.constructor = e;
554
556
  }
555
- e.prototype = n === null ? Object.create(n) : (l.prototype = n.prototype, new l());
557
+ e.prototype = n === null ? Object.create(n) : (f.prototype = n.prototype, new f());
556
558
  };
557
559
  })();
558
560
  Object.defineProperty(a, "__esModule", { value: !0 }), a.ErrorAnyEvent = a.VoidAnyEvent = a.AnyEvent = a.EventType = void 0;
559
- var s = me(), c = j(), d = oe(), f = ie(), u;
561
+ var r = me(), c = j(), d = oe(), l = ie(), u;
560
562
  (function(t) {
561
563
  t[t.Sync = 0] = "Sync", t[t.Async = 1] = "Async", t[t.Queued = 2] = "Queued";
562
564
  })(u = a.EventType || (a.EventType = {}));
@@ -564,7 +566,7 @@ function Ae() {
564
566
  /** @class */
565
567
  (function() {
566
568
  function t(e) {
567
- this._events = [], e && e.monitorAttach && (this.evtFirstAttached = new r(), this.evtLastDetached = new r());
569
+ this._events = [], e && e.monitorAttach && (this.evtFirstAttached = new s(), this.evtLastDetached = new s());
568
570
  }
569
571
  return Object.defineProperty(t.prototype, "evtListenersChanged", {
570
572
  /**
@@ -578,18 +580,18 @@ function Ae() {
578
580
  }), t.prototype.attach = function() {
579
581
  for (var e = [], n = 0; n < arguments.length; n++)
580
582
  e[n] = arguments[n];
581
- var l = u.Sync;
582
- e.length > 0 && typeof e[0] == "number" && (l = e.shift());
583
+ var f = u.Sync;
584
+ e.length > 0 && typeof e[0] == "number" && (f = e.shift());
583
585
  var v = this, y, p, g;
584
- return typeof e[0] == "function" || e[0] && typeof e[0] == "object" && typeof e[0].post == "function" ? (typeof e[0] == "function" ? y = e[0] : g = e[0], p = e[1]) : (v = e[0], y = e[1], p = e[2]), this._attach(l, v, y, g, p, !1);
586
+ return typeof e[0] == "function" || e[0] && typeof e[0] == "object" && typeof e[0].post == "function" ? (typeof e[0] == "function" ? y = e[0] : g = e[0], p = e[1]) : (v = e[0], y = e[1], p = e[2]), this._attach(f, v, y, g, p, !1);
585
587
  }, t.prototype.once = function() {
586
588
  for (var e = [], n = 0; n < arguments.length; n++)
587
589
  e[n] = arguments[n];
588
- var l = u.Sync;
589
- e.length > 0 && typeof e[0] == "number" && (l = e.shift());
590
+ var f = u.Sync;
591
+ e.length > 0 && typeof e[0] == "number" && (f = e.shift());
590
592
  var v = this, y, p, g;
591
- return typeof e[0] == "function" || e[0] && typeof e[0] == "object" && typeof e[0].post == "function" ? (typeof e[0] == "function" ? y = e[0] : g = e[0], p = e[1]) : (v = e[0], y = e[1], p = e[2]), this._attach(l, v, y, g, p, !0);
592
- }, t.prototype._attach = function(e, n, l, v, y, p) {
593
+ return typeof e[0] == "function" || e[0] && typeof e[0] == "object" && typeof e[0].post == "function" ? (typeof e[0] == "function" ? y = e[0] : g = e[0], p = e[1]) : (v = e[0], y = e[1], p = e[2]), this._attach(f, v, y, g, p, !0);
594
+ }, t.prototype._attach = function(e, n, f, v, y, p) {
593
595
  var g = this, X = this.evtFirstAttached ? this.listenerCount() : 0, _;
594
596
  switch (e) {
595
597
  case u.Sync:
@@ -605,7 +607,7 @@ function Ae() {
605
607
  {
606
608
  for (var U = 0, $ = this._events; U < $.length; U++) {
607
609
  var C = $[U];
608
- C instanceof d.AsyncEvent && s.shallowEquals(C.options, y) && (_ = C);
610
+ C instanceof d.AsyncEvent && r.shallowEquals(C.options, y) && (_ = C);
609
611
  }
610
612
  _ || (_ = new d.AsyncEvent(y), this._events.push(_));
611
613
  }
@@ -614,16 +616,16 @@ function Ae() {
614
616
  {
615
617
  for (var R = 0, k = this._events; R < k.length; R++) {
616
618
  var C = k[R];
617
- C instanceof f.QueuedEvent && s.shallowEquals(C.options, y) && (_ = C);
619
+ C instanceof l.QueuedEvent && r.shallowEquals(C.options, y) && (_ = C);
618
620
  }
619
- _ || (_ = new f.QueuedEvent(y), this._events.push(_));
621
+ _ || (_ = new l.QueuedEvent(y), this._events.push(_));
620
622
  }
621
623
  break;
622
624
  default:
623
625
  throw new Error("unknown EventType");
624
626
  }
625
627
  var S;
626
- return p ? v ? S = _.once(v) : S = _.once(n, l) : v ? S = _.attach(v) : S = _.attach(n, l), this.evtFirstAttached && X === 0 && this.evtFirstAttached.post(), this.evtListenersChanged && X !== this.listenerCount() && this.evtListenersChanged.post(), function() {
628
+ return p ? v ? S = _.once(v) : S = _.once(n, f) : v ? S = _.attach(v) : S = _.attach(n, f), this.evtFirstAttached && X === 0 && this.evtFirstAttached.post(), this.evtListenersChanged && X !== this.listenerCount() && this.evtListenersChanged.post(), function() {
627
629
  var Y = g.evtLastDetached ? g.listenerCount() : 0;
628
630
  S(), g.evtLastDetached && Y > 0 && g.listenerCount() === 0 && g.evtLastDetached.post(), g.evtListenersChanged && Y !== g.listenerCount() && g.evtListenersChanged.post();
629
631
  };
@@ -654,14 +656,14 @@ function Ae() {
654
656
  }, t.prototype.detach = function() {
655
657
  for (var e = [], n = 0; n < arguments.length; n++)
656
658
  e[n] = arguments[n];
657
- for (var l = this.listenerCount(), v = 0; v < this._events.length; ++v)
659
+ for (var f = this.listenerCount(), v = 0; v < this._events.length; ++v)
658
660
  this._events[v].detach.apply(this._events[v], e);
659
- this.evtListenersChanged && l !== this.listenerCount() && this.evtListenersChanged.post(), this.evtLastDetached && l > 0 && this.listenerCount() === 0 && this.evtLastDetached.post();
661
+ this.evtListenersChanged && f !== this.listenerCount() && this.evtListenersChanged.post(), this.evtLastDetached && f > 0 && this.listenerCount() === 0 && this.evtLastDetached.post();
660
662
  }, t.prototype.post = function(e) {
661
- for (var n = [], l = 0; l < this._events.length; ++l)
662
- n.push(this._events[l]);
663
- for (var l = 0; l < n.length; ++l)
664
- n[l].post(e);
663
+ for (var n = [], f = 0; f < this._events.length; ++f)
664
+ n.push(this._events[f]);
665
+ for (var f = 0; f < n.length; ++f)
666
+ n[f].post(e);
665
667
  }, t.prototype.listenerCount = function() {
666
668
  for (var e = 0, n = 0; n < this._events.length; ++n)
667
669
  e += this._events[n].listenerCount();
@@ -670,7 +672,7 @@ function Ae() {
670
672
  })()
671
673
  );
672
674
  a.AnyEvent = i;
673
- var r = (
675
+ var s = (
674
676
  /** @class */
675
677
  (function(t) {
676
678
  h(e, t);
@@ -682,7 +684,7 @@ function Ae() {
682
684
  }, e;
683
685
  })(i)
684
686
  );
685
- a.VoidAnyEvent = r;
687
+ a.VoidAnyEvent = s;
686
688
  var o = (
687
689
  /** @class */
688
690
  (function(t) {
@@ -703,30 +705,30 @@ function Ae() {
703
705
  var ne;
704
706
  function Se() {
705
707
  return ne || (ne = 1, (function(a) {
706
- var h = m && m.__createBinding || (Object.create ? (function(r, o, t, e) {
707
- e === void 0 && (e = t), Object.defineProperty(r, e, { enumerable: !0, get: function() {
708
+ var h = m && m.__createBinding || (Object.create ? (function(s, o, t, e) {
709
+ e === void 0 && (e = t), Object.defineProperty(s, e, { enumerable: !0, get: function() {
708
710
  return o[t];
709
711
  } });
710
- }) : (function(r, o, t, e) {
711
- e === void 0 && (e = t), r[e] = o[t];
712
- })), s = m && m.__exportStar || function(r, o) {
713
- for (var t in r) t !== "default" && !o.hasOwnProperty(t) && h(o, r, t);
712
+ }) : (function(s, o, t, e) {
713
+ e === void 0 && (e = t), s[e] = o[t];
714
+ })), r = m && m.__exportStar || function(s, o) {
715
+ for (var t in s) t !== "default" && !o.hasOwnProperty(t) && h(o, s, t);
714
716
  };
715
- Object.defineProperty(a, "__esModule", { value: !0 }), a.flush = a.flushOnce = a.queue = void 0, s(B(), a), s(j(), a), s(ie(), a), s(oe(), a), s(Ae(), a);
717
+ Object.defineProperty(a, "__esModule", { value: !0 }), a.flush = a.flushOnce = a.queue = void 0, r(V(), a), r(j(), a), r(ie(), a), r(oe(), a), r(Ae(), a);
716
718
  var c = I(), d = I();
717
719
  Object.defineProperty(a, "EventQueue", { enumerable: !0, get: function() {
718
720
  return d.default;
719
721
  } });
720
- function f() {
722
+ function l() {
721
723
  return c.default.global();
722
724
  }
723
- a.queue = f;
725
+ a.queue = l;
724
726
  function u() {
725
727
  c.default.global().flushOnce();
726
728
  }
727
729
  a.flushOnce = u;
728
- function i(r) {
729
- r === void 0 && (r = 10), c.default.global().flush(r);
730
+ function i(s) {
731
+ s === void 0 && (s = 10), c.default.global().flush(s);
730
732
  }
731
733
  a.flush = i;
732
734
  })(m)), m;
@@ -735,34 +737,40 @@ var A = Se();
735
737
  class qe {
736
738
  id;
737
739
  data;
738
- constructor(h, s) {
739
- this.id = h, this.data = s;
740
+ constructor(h, r) {
741
+ this.id = h, this.data = r;
740
742
  }
741
743
  }
742
744
  const { serviceUuid: Oe, messageCharUuid: Pe } = Ce(), ue = new A.SyncEvent(), ae = new A.SyncEvent(), ce = new A.SyncEvent(), he = new A.SyncEvent();
743
745
  function Le() {
744
746
  return new Promise((a, h) => {
745
- _e().subscribe(Oe, Pe, je).then(() => a()).catch((s) => h(s));
747
+ _e().subscribe(Oe, Pe, je).then(() => a()).catch((r) => h(r));
746
748
  });
747
749
  }
748
750
  function je(a) {
749
751
  a !== void 0 && (a.getUint8(L.TYPE) === z.BUTTON_PRESS && De(a), a.getUint8(L.TYPE) === z.MESSAGE_DONE && he.post(a.getUint8(L.DATA)));
750
752
  }
751
753
  function De(a) {
752
- const h = a.getUint8(L.DATA), s = new qe(
754
+ const h = a.getUint8(L.DATA), r = new qe(
753
755
  a.getUint8(L.ID),
754
756
  Qe(a)
755
757
  );
756
- h === N.MINUS && ae.post(s), h === N.PLUS && ue.post(s), h === N.EITHER && ce.post(s);
758
+ h === N.MINUS && ae.post(r), h === N.PLUS && ue.post(r), h === N.EITHER && ce.post(r);
757
759
  }
758
760
  function Qe(a) {
759
- const h = a.buffer, s = 7, c = a.byteLength - 7;
760
- return Array.from(new Uint8Array(h, s, c)).map((d) => String.fromCharCode(d)).join("").replace(/\0/g, "").trim();
761
+ const h = a.buffer, r = 7, c = a.byteLength - 7;
762
+ return Array.from(new Uint8Array(h, r, c)).map((d) => String.fromCharCode(d)).join("").replace(/\0/g, "").trim();
761
763
  }
762
- function Ve() {
763
- return { subscribe: Le, onPlus: ue, onMin: ae, onEither: ce, onMessageDone: he };
764
+ function Be() {
765
+ return {
766
+ subscribe: Le,
767
+ onPlusButton: ue,
768
+ onMinButton: ae,
769
+ onEitherButton: ce,
770
+ onMessageDone: he
771
+ };
764
772
  }
765
- class Be {
773
+ class Ve {
766
774
  id;
767
775
  elements = [];
768
776
  onPlus = new A.SyncEvent();
@@ -776,9 +784,9 @@ class Be {
776
784
  }
777
785
  export {
778
786
  qe as B,
779
- Be as S,
787
+ Ve as S,
780
788
  Ce as a,
781
- Ve as b,
789
+ Be as b,
782
790
  A as l,
783
791
  _e as u
784
792
  };