nsd-ble 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/standee-ble.js +1452 -0
- package/dist/standee-ble.umd.cjs +1 -0
- package/dist/types/Enums.d.ts +73 -0
- package/dist/types/ble/Bluetooth.d.ts +16 -0
- package/dist/types/ble/Cache.d.ts +5 -0
- package/dist/types/ble/HandshakeCharacteristic.d.ts +8 -0
- package/dist/types/ble/Mesh.d.ts +7 -0
- package/dist/types/ble/MeshUpload.d.ts +4 -0
- package/dist/types/ble/MeshWriter.d.ts +6 -0
- package/dist/types/ble/MessageCharacteristic.d.ts +15 -0
- package/dist/types/ble/Settings.d.ts +6 -0
- package/dist/types/composable/Binary.d.ts +9 -0
- package/dist/types/composable/Converter.d.ts +5 -0
- package/dist/types/composable/DisplayUtils.d.ts +4 -0
- package/dist/types/composable/Image.d.ts +9 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/main.d.ts +14 -0
- package/dist/types/standee/Actions.d.ts +74 -0
- package/dist/types/standee/Button.d.ts +6 -0
- package/dist/types/standee/Display.d.ts +8 -0
- package/dist/types/standee/Elements.d.ts +57 -0
- package/dist/types/standee/Standee.d.ts +11 -0
- package/dist/types/standee/StandeeElements.d.ts +6 -0
- package/dist/types/standee/Standees.d.ts +4 -0
- package/package.json +30 -0
|
@@ -0,0 +1,1452 @@
|
|
|
1
|
+
var U = {}, L = {}, lt;
|
|
2
|
+
function H() {
|
|
3
|
+
if (lt) return L;
|
|
4
|
+
lt = 1, Object.defineProperty(L, "__esModule", { value: !0 }), L.BaseEvent = void 0;
|
|
5
|
+
var t = (
|
|
6
|
+
/** @class */
|
|
7
|
+
(function() {
|
|
8
|
+
function e() {
|
|
9
|
+
}
|
|
10
|
+
return e.prototype.attach = function(n, r) {
|
|
11
|
+
return this._attach(n, r, !1);
|
|
12
|
+
}, e.prototype.once = function(n, r) {
|
|
13
|
+
return this._attach(n, r, !0);
|
|
14
|
+
}, e.prototype._attach = function(n, r, f) {
|
|
15
|
+
var l = this, u, i, a, h;
|
|
16
|
+
if (typeof n == "function")
|
|
17
|
+
i = n, h = function() {
|
|
18
|
+
return l.detach(i);
|
|
19
|
+
};
|
|
20
|
+
else if (!r && typeof n.post == "function")
|
|
21
|
+
a = n, h = function() {
|
|
22
|
+
return l.detach(a);
|
|
23
|
+
};
|
|
24
|
+
else {
|
|
25
|
+
if (typeof n != "object" || n === void 0)
|
|
26
|
+
throw new Error("Expect a function or object as first argument");
|
|
27
|
+
if (typeof r != "function")
|
|
28
|
+
throw new Error("Expect a function as second argument");
|
|
29
|
+
u = n, i = r, h = function() {
|
|
30
|
+
return l.detach(u, i);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return this._listeners ? this._listeners = this._listeners.slice() : this._listeners = [], this._listeners.push({
|
|
34
|
+
deleted: !1,
|
|
35
|
+
boundTo: u,
|
|
36
|
+
handler: i,
|
|
37
|
+
event: a,
|
|
38
|
+
once: f
|
|
39
|
+
}), h;
|
|
40
|
+
}, e.prototype.detach = function() {
|
|
41
|
+
for (var n = [], r = 0; r < arguments.length; r++)
|
|
42
|
+
n[r] = arguments[r];
|
|
43
|
+
this._detach.apply(this, n);
|
|
44
|
+
}, e.prototype._detach = function() {
|
|
45
|
+
for (var n = [], r = 0; r < arguments.length; r++)
|
|
46
|
+
n[r] = arguments[r];
|
|
47
|
+
if (!(!this._listeners || this._listeners.length === 0)) {
|
|
48
|
+
var f, l, u;
|
|
49
|
+
n.length >= 1 && (typeof n[0] == "function" ? l = n[0] : n.length === 1 && typeof n[0].post == "function" ? u = n[0] : f = n[0]), n.length >= 2 && (l = n[1]), this._listeners = this._listeners.filter(function(i) {
|
|
50
|
+
return (typeof l > "u" || i.handler === l) && (typeof u > "u" || i.event === u) && (typeof f > "u" || i.boundTo === f) ? (i.deleted = !0, !1) : !0;
|
|
51
|
+
}), this._listeners.length === 0 && delete this._listeners;
|
|
52
|
+
}
|
|
53
|
+
}, e.prototype.post = function(n) {
|
|
54
|
+
throw new Error("abstract");
|
|
55
|
+
}, e.prototype.listenerCount = function() {
|
|
56
|
+
return this._listeners ? this._listeners.length : 0;
|
|
57
|
+
}, e.prototype._call = function(n, r) {
|
|
58
|
+
this._listeners && (n.deleted || (n.once && (n.deleted = !0, this._listeners = this._listeners.filter(function(f) {
|
|
59
|
+
return f !== n;
|
|
60
|
+
}), this._listeners.length === 0 && delete this._listeners), n.event ? n.event.post.apply(n.event, r) : n.handler && n.handler.apply(typeof n.boundTo == "object" ? n.boundTo : this, r)));
|
|
61
|
+
}, e;
|
|
62
|
+
})()
|
|
63
|
+
);
|
|
64
|
+
return L.BaseEvent = t, L;
|
|
65
|
+
}
|
|
66
|
+
var E = {}, ft;
|
|
67
|
+
function x() {
|
|
68
|
+
if (ft) return E;
|
|
69
|
+
ft = 1;
|
|
70
|
+
var t = E && E.__extends || /* @__PURE__ */ (function() {
|
|
71
|
+
var l = function(u, i) {
|
|
72
|
+
return l = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(a, h) {
|
|
73
|
+
a.__proto__ = h;
|
|
74
|
+
} || function(a, h) {
|
|
75
|
+
for (var o in h) h.hasOwnProperty(o) && (a[o] = h[o]);
|
|
76
|
+
}, l(u, i);
|
|
77
|
+
};
|
|
78
|
+
return function(u, i) {
|
|
79
|
+
l(u, i);
|
|
80
|
+
function a() {
|
|
81
|
+
this.constructor = u;
|
|
82
|
+
}
|
|
83
|
+
u.prototype = i === null ? Object.create(i) : (a.prototype = i.prototype, new a());
|
|
84
|
+
};
|
|
85
|
+
})();
|
|
86
|
+
Object.defineProperty(E, "__esModule", { value: !0 }), E.ErrorSyncEvent = E.VoidSyncEvent = E.SyncEvent = void 0;
|
|
87
|
+
var e = H(), n = (
|
|
88
|
+
/** @class */
|
|
89
|
+
(function(l) {
|
|
90
|
+
t(u, l);
|
|
91
|
+
function u() {
|
|
92
|
+
var i = l !== null && l.apply(this, arguments) || this;
|
|
93
|
+
return i._recursion = 0, i;
|
|
94
|
+
}
|
|
95
|
+
return Object.defineProperty(u.prototype, "evtListenersChanged", {
|
|
96
|
+
/**
|
|
97
|
+
* Sent when someone attaches or detaches
|
|
98
|
+
*/
|
|
99
|
+
get: function() {
|
|
100
|
+
return this._listenersChanged || (this._listenersChanged = new r()), this._listenersChanged;
|
|
101
|
+
},
|
|
102
|
+
enumerable: !1,
|
|
103
|
+
configurable: !0
|
|
104
|
+
}), u.prototype.post = function() {
|
|
105
|
+
for (var i = [], a = 0; a < arguments.length; a++)
|
|
106
|
+
i[a] = arguments[a];
|
|
107
|
+
if (!(!this._listeners || this._listeners.length === 0)) {
|
|
108
|
+
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)
|
|
109
|
+
throw new Error("event fired recursively");
|
|
110
|
+
for (var h = this._listeners, o = 0; o < h.length; ++o) {
|
|
111
|
+
var s = h[o];
|
|
112
|
+
this._call(s, i);
|
|
113
|
+
}
|
|
114
|
+
this._recursion--;
|
|
115
|
+
}
|
|
116
|
+
}, u.prototype._attach = function(i, a, h) {
|
|
117
|
+
var o, s, c, d, v = (s = (o = this._listeners) === null || o === void 0 ? void 0 : o.length) !== null && s !== void 0 ? s : 0, y = l.prototype._attach.call(this, i, a, h);
|
|
118
|
+
return this.evtListenersChanged && v !== ((d = (c = this._listeners) === null || c === void 0 ? void 0 : c.length) !== null && d !== void 0 ? d : 0) && this.evtListenersChanged.post(), y;
|
|
119
|
+
}, u.prototype._detach = function() {
|
|
120
|
+
for (var i, a, h, o, s = [], c = 0; c < arguments.length; c++)
|
|
121
|
+
s[c] = arguments[c];
|
|
122
|
+
var d = (a = (i = this._listeners) === null || i === void 0 ? void 0 : i.length) !== null && a !== void 0 ? a : 0, v = l.prototype._detach.apply(this, s);
|
|
123
|
+
return this.evtListenersChanged && d !== ((o = (h = this._listeners) === null || h === void 0 ? void 0 : h.length) !== null && o !== void 0 ? o : 0) && this.evtListenersChanged.post(), v;
|
|
124
|
+
}, u.MAX_RECURSION_DEPTH = 10, u;
|
|
125
|
+
})(e.BaseEvent)
|
|
126
|
+
);
|
|
127
|
+
E.SyncEvent = n;
|
|
128
|
+
var r = (
|
|
129
|
+
/** @class */
|
|
130
|
+
(function(l) {
|
|
131
|
+
t(u, l);
|
|
132
|
+
function u() {
|
|
133
|
+
return l !== null && l.apply(this, arguments) || this;
|
|
134
|
+
}
|
|
135
|
+
return u.prototype.post = function() {
|
|
136
|
+
l.prototype.post.call(this, void 0);
|
|
137
|
+
}, u;
|
|
138
|
+
})(n)
|
|
139
|
+
);
|
|
140
|
+
E.VoidSyncEvent = r;
|
|
141
|
+
var f = (
|
|
142
|
+
/** @class */
|
|
143
|
+
(function(l) {
|
|
144
|
+
t(u, l);
|
|
145
|
+
function u() {
|
|
146
|
+
return l !== null && l.apply(this, arguments) || this;
|
|
147
|
+
}
|
|
148
|
+
return u.prototype.post = function(i) {
|
|
149
|
+
if (this.listenerCount() === 0)
|
|
150
|
+
throw new Error("error event posted while no listeners attached. Error: " + i.message);
|
|
151
|
+
l.prototype.post.call(this, i);
|
|
152
|
+
}, u;
|
|
153
|
+
})(n)
|
|
154
|
+
);
|
|
155
|
+
return E.ErrorSyncEvent = f, E;
|
|
156
|
+
}
|
|
157
|
+
var w = {}, j = {}, dt;
|
|
158
|
+
function z() {
|
|
159
|
+
if (dt) return j;
|
|
160
|
+
dt = 1, Object.defineProperty(j, "__esModule", { value: !0 });
|
|
161
|
+
var t = x(), e = (
|
|
162
|
+
/** @class */
|
|
163
|
+
(function() {
|
|
164
|
+
function n() {
|
|
165
|
+
this.evtFilled = new t.SyncEvent(), this.evtDrained = new t.SyncEvent(), this._queue = [], this._flushing = !1;
|
|
166
|
+
}
|
|
167
|
+
return n.global = function() {
|
|
168
|
+
return n._instance || n.resetGlobal(), n._instance;
|
|
169
|
+
}, n.resetGlobal = function() {
|
|
170
|
+
n._instance = new n();
|
|
171
|
+
}, n.prototype.empty = function() {
|
|
172
|
+
return this._queue.length === 0;
|
|
173
|
+
}, n.prototype.add = function(r) {
|
|
174
|
+
this._queue.push(r), this._queue.length === 1 && !this._flushing && this.evtFilled.post(this);
|
|
175
|
+
}, n.prototype.flushOnce = function() {
|
|
176
|
+
var r = this._queue.length === 0, f = this._flushing;
|
|
177
|
+
this._flushing = !0;
|
|
178
|
+
try {
|
|
179
|
+
var l = this._queue;
|
|
180
|
+
this._queue = [];
|
|
181
|
+
for (var u = 0; u < l.length; ++u)
|
|
182
|
+
l[u]();
|
|
183
|
+
} finally {
|
|
184
|
+
this._flushing = f, !r && !f && this._queue.length === 0 && this.evtDrained.post(this);
|
|
185
|
+
}
|
|
186
|
+
}, n.prototype.flush = function(r) {
|
|
187
|
+
r === void 0 && (r = 10);
|
|
188
|
+
var f = this._queue.length === 0, l = this._flushing;
|
|
189
|
+
this._flushing = !0;
|
|
190
|
+
try {
|
|
191
|
+
for (var u = 0; this._queue.length > 0; ) {
|
|
192
|
+
if (typeof r == "number" && u >= r)
|
|
193
|
+
throw this._queue = [], new Error("unable to flush the queue due to recursively added event. Clearing queue now");
|
|
194
|
+
this.flushOnce(), ++u;
|
|
195
|
+
}
|
|
196
|
+
} finally {
|
|
197
|
+
this._flushing = l, !f && !l && this._queue.length === 0 && this.evtDrained.post(this);
|
|
198
|
+
}
|
|
199
|
+
}, n;
|
|
200
|
+
})()
|
|
201
|
+
);
|
|
202
|
+
return j.default = e, j;
|
|
203
|
+
}
|
|
204
|
+
var vt;
|
|
205
|
+
function Ct() {
|
|
206
|
+
if (vt) return w;
|
|
207
|
+
vt = 1;
|
|
208
|
+
var t = w && w.__extends || /* @__PURE__ */ (function() {
|
|
209
|
+
var i = function(a, h) {
|
|
210
|
+
return i = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(o, s) {
|
|
211
|
+
o.__proto__ = s;
|
|
212
|
+
} || function(o, s) {
|
|
213
|
+
for (var c in s) s.hasOwnProperty(c) && (o[c] = s[c]);
|
|
214
|
+
}, i(a, h);
|
|
215
|
+
};
|
|
216
|
+
return function(a, h) {
|
|
217
|
+
i(a, h);
|
|
218
|
+
function o() {
|
|
219
|
+
this.constructor = a;
|
|
220
|
+
}
|
|
221
|
+
a.prototype = h === null ? Object.create(h) : (o.prototype = h.prototype, new o());
|
|
222
|
+
};
|
|
223
|
+
})();
|
|
224
|
+
Object.defineProperty(w, "__esModule", { value: !0 }), w.ErrorQueuedEvent = w.VoidQueuedEvent = w.QueuedEvent = void 0;
|
|
225
|
+
var e = H(), n = z(), r = x(), f = (
|
|
226
|
+
/** @class */
|
|
227
|
+
(function(i) {
|
|
228
|
+
t(a, i);
|
|
229
|
+
function a(h) {
|
|
230
|
+
h === void 0 && (h = {});
|
|
231
|
+
var o = i.call(this) || this;
|
|
232
|
+
return o._queued = !1, o.options = h, typeof h.condensed == "boolean" ? o._condensed = h.condensed : o._condensed = !1, typeof h.queue == "object" && h.queue !== null && (o._queue = h.queue), o;
|
|
233
|
+
}
|
|
234
|
+
return Object.defineProperty(a.prototype, "evtListenersChanged", {
|
|
235
|
+
/**
|
|
236
|
+
* Sent when someone attaches or detaches
|
|
237
|
+
*/
|
|
238
|
+
get: function() {
|
|
239
|
+
return this._listenersChanged || (this._listenersChanged = new r.VoidSyncEvent()), this._listenersChanged;
|
|
240
|
+
},
|
|
241
|
+
enumerable: !1,
|
|
242
|
+
configurable: !0
|
|
243
|
+
}), a.prototype.post = function() {
|
|
244
|
+
for (var h = this, o = [], s = 0; s < arguments.length; s++)
|
|
245
|
+
o[s] = arguments[s];
|
|
246
|
+
if (!(!this._listeners || this._listeners.length === 0)) {
|
|
247
|
+
var c = this._queue ? this._queue : n.default.global();
|
|
248
|
+
if (this._condensed) {
|
|
249
|
+
if (this._queuedData = o, this._queuedListeners = this._listeners, this._queued)
|
|
250
|
+
return;
|
|
251
|
+
this._queued = !0, c.add(function() {
|
|
252
|
+
h._queued = !1;
|
|
253
|
+
for (var v = h._queuedData, y = h._queuedListeners, g = 0; g < y.length; ++g) {
|
|
254
|
+
var p = y[g];
|
|
255
|
+
h._call(p, v);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
} else {
|
|
259
|
+
var d = this._listeners;
|
|
260
|
+
c.add(function() {
|
|
261
|
+
for (var v = 0; v < d.length; ++v) {
|
|
262
|
+
var y = d[v];
|
|
263
|
+
h._call(y, o);
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}, a.prototype._attach = function(h, o, s) {
|
|
269
|
+
var c, d, v, y, g = (d = (c = this._listeners) === null || c === void 0 ? void 0 : c.length) !== null && d !== void 0 ? d : 0, p = i.prototype._attach.call(this, h, o, s);
|
|
270
|
+
return this.evtListenersChanged && g !== ((y = (v = this._listeners) === null || v === void 0 ? void 0 : v.length) !== null && y !== void 0 ? y : 0) && this.evtListenersChanged.post(), p;
|
|
271
|
+
}, a.prototype._detach = function() {
|
|
272
|
+
for (var h, o, s, c, d = [], v = 0; v < arguments.length; v++)
|
|
273
|
+
d[v] = arguments[v];
|
|
274
|
+
var y = (o = (h = this._listeners) === null || h === void 0 ? void 0 : h.length) !== null && o !== void 0 ? o : 0, g = i.prototype._detach.apply(this, d);
|
|
275
|
+
return this.evtListenersChanged && y !== ((c = (s = this._listeners) === null || s === void 0 ? void 0 : s.length) !== null && c !== void 0 ? c : 0) && this.evtListenersChanged.post(), g;
|
|
276
|
+
}, a;
|
|
277
|
+
})(e.BaseEvent)
|
|
278
|
+
);
|
|
279
|
+
w.QueuedEvent = f;
|
|
280
|
+
var l = (
|
|
281
|
+
/** @class */
|
|
282
|
+
(function(i) {
|
|
283
|
+
t(a, i);
|
|
284
|
+
function a() {
|
|
285
|
+
return i !== null && i.apply(this, arguments) || this;
|
|
286
|
+
}
|
|
287
|
+
return a.prototype.post = function() {
|
|
288
|
+
i.prototype.post.call(this, void 0);
|
|
289
|
+
}, a;
|
|
290
|
+
})(f)
|
|
291
|
+
);
|
|
292
|
+
w.VoidQueuedEvent = l;
|
|
293
|
+
var u = (
|
|
294
|
+
/** @class */
|
|
295
|
+
(function(i) {
|
|
296
|
+
t(a, i);
|
|
297
|
+
function a() {
|
|
298
|
+
return i !== null && i.apply(this, arguments) || this;
|
|
299
|
+
}
|
|
300
|
+
return a.prototype.post = function(h) {
|
|
301
|
+
if (!this._listeners || this._listeners.length === 0)
|
|
302
|
+
throw new Error("error event posted while no listeners attached. Error: " + h.message);
|
|
303
|
+
i.prototype.post.call(this, h);
|
|
304
|
+
}, a;
|
|
305
|
+
})(f)
|
|
306
|
+
);
|
|
307
|
+
return w.ErrorQueuedEvent = u, w;
|
|
308
|
+
}
|
|
309
|
+
var A = {}, yt;
|
|
310
|
+
function St() {
|
|
311
|
+
if (yt) return A;
|
|
312
|
+
yt = 1;
|
|
313
|
+
var t = A && A.__extends || /* @__PURE__ */ (function() {
|
|
314
|
+
var u = function(i, a) {
|
|
315
|
+
return u = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(h, o) {
|
|
316
|
+
h.__proto__ = o;
|
|
317
|
+
} || function(h, o) {
|
|
318
|
+
for (var s in o) o.hasOwnProperty(s) && (h[s] = o[s]);
|
|
319
|
+
}, u(i, a);
|
|
320
|
+
};
|
|
321
|
+
return function(i, a) {
|
|
322
|
+
u(i, a);
|
|
323
|
+
function h() {
|
|
324
|
+
this.constructor = i;
|
|
325
|
+
}
|
|
326
|
+
i.prototype = a === null ? Object.create(a) : (h.prototype = a.prototype, new h());
|
|
327
|
+
};
|
|
328
|
+
})();
|
|
329
|
+
Object.defineProperty(A, "__esModule", { value: !0 }), A.ErrorAsyncEvent = A.VoidAsyncEvent = A.AsyncEvent = void 0;
|
|
330
|
+
var e = H(), n = x(), r = (
|
|
331
|
+
/** @class */
|
|
332
|
+
(function(u) {
|
|
333
|
+
t(i, u);
|
|
334
|
+
function i(a) {
|
|
335
|
+
a === void 0 && (a = {});
|
|
336
|
+
var h = u.call(this) || this;
|
|
337
|
+
return h._queued = !1, h.options = a, typeof a.condensed == "boolean" ? h._condensed = a.condensed : h._condensed = !1, h;
|
|
338
|
+
}
|
|
339
|
+
return Object.defineProperty(i.prototype, "evtListenersChanged", {
|
|
340
|
+
/**
|
|
341
|
+
* Sent when someone attaches or detaches
|
|
342
|
+
*/
|
|
343
|
+
get: function() {
|
|
344
|
+
return this._listenersChanged || (this._listenersChanged = new n.VoidSyncEvent()), this._listenersChanged;
|
|
345
|
+
},
|
|
346
|
+
enumerable: !1,
|
|
347
|
+
configurable: !0
|
|
348
|
+
}), i.defaultScheduler = function(a) {
|
|
349
|
+
typeof window < "u" ? setTimeout(a, 0) : setImmediate(a);
|
|
350
|
+
}, i.setScheduler = function(a) {
|
|
351
|
+
i._scheduler = a;
|
|
352
|
+
}, i.prototype.post = function() {
|
|
353
|
+
for (var a = this, h = [], o = 0; o < arguments.length; o++)
|
|
354
|
+
h[o] = arguments[o];
|
|
355
|
+
if (!(!this._listeners || this._listeners.length === 0))
|
|
356
|
+
if (this._condensed) {
|
|
357
|
+
if (this._queuedData = h, this._queuedListeners = this._listeners, this._queued)
|
|
358
|
+
return;
|
|
359
|
+
this._queued = !0, i._scheduler(function() {
|
|
360
|
+
a._queued = !1;
|
|
361
|
+
for (var c = a._queuedData, d = a._queuedListeners, v = 0; v < d.length; ++v) {
|
|
362
|
+
var y = d[v];
|
|
363
|
+
a._call(y, c);
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
} else {
|
|
367
|
+
var s = this._listeners;
|
|
368
|
+
i._scheduler(function() {
|
|
369
|
+
for (var c = 0; c < s.length; ++c) {
|
|
370
|
+
var d = s[c];
|
|
371
|
+
a._call(d, h);
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
}, i.prototype._call = function(a, h) {
|
|
376
|
+
a.event && a.event instanceof i ? a.event._postDirect(h) : u.prototype._call.call(this, a, h);
|
|
377
|
+
}, i.prototype._postDirect = function(a) {
|
|
378
|
+
if (!(!this._listeners || this._listeners.length === 0))
|
|
379
|
+
for (var h = this._listeners, o = 0; o < h.length; ++o) {
|
|
380
|
+
var s = h[o];
|
|
381
|
+
this._call(s, a);
|
|
382
|
+
}
|
|
383
|
+
}, i.prototype._attach = function(a, h, o) {
|
|
384
|
+
var s, c, d, v, y = (c = (s = this._listeners) === null || s === void 0 ? void 0 : s.length) !== null && c !== void 0 ? c : 0, g = u.prototype._attach.call(this, a, h, o);
|
|
385
|
+
return this.evtListenersChanged && y !== ((v = (d = this._listeners) === null || d === void 0 ? void 0 : d.length) !== null && v !== void 0 ? v : 0) && this.evtListenersChanged.post(), g;
|
|
386
|
+
}, i.prototype._detach = function() {
|
|
387
|
+
for (var a, h, o, s, c = [], d = 0; d < arguments.length; d++)
|
|
388
|
+
c[d] = arguments[d];
|
|
389
|
+
var v = (h = (a = this._listeners) === null || a === void 0 ? void 0 : a.length) !== null && h !== void 0 ? h : 0, y = u.prototype._detach.apply(this, c);
|
|
390
|
+
return this.evtListenersChanged && v !== ((s = (o = this._listeners) === null || o === void 0 ? void 0 : o.length) !== null && s !== void 0 ? s : 0) && this.evtListenersChanged.post(), y;
|
|
391
|
+
}, i._scheduler = i.defaultScheduler, i;
|
|
392
|
+
})(e.BaseEvent)
|
|
393
|
+
);
|
|
394
|
+
A.AsyncEvent = r;
|
|
395
|
+
var f = (
|
|
396
|
+
/** @class */
|
|
397
|
+
(function(u) {
|
|
398
|
+
t(i, u);
|
|
399
|
+
function i() {
|
|
400
|
+
return u !== null && u.apply(this, arguments) || this;
|
|
401
|
+
}
|
|
402
|
+
return i.prototype.post = function() {
|
|
403
|
+
u.prototype.post.call(this, void 0);
|
|
404
|
+
}, i;
|
|
405
|
+
})(r)
|
|
406
|
+
);
|
|
407
|
+
A.VoidAsyncEvent = f;
|
|
408
|
+
var l = (
|
|
409
|
+
/** @class */
|
|
410
|
+
(function(u) {
|
|
411
|
+
t(i, u);
|
|
412
|
+
function i() {
|
|
413
|
+
return u !== null && u.apply(this, arguments) || this;
|
|
414
|
+
}
|
|
415
|
+
return i.prototype.post = function(a) {
|
|
416
|
+
if (this.listenerCount() === 0)
|
|
417
|
+
throw new Error("error event posted while no listeners attached. Error: " + a.message);
|
|
418
|
+
u.prototype.post.call(this, a);
|
|
419
|
+
}, i;
|
|
420
|
+
})(r)
|
|
421
|
+
);
|
|
422
|
+
return A.ErrorAsyncEvent = l, A;
|
|
423
|
+
}
|
|
424
|
+
var I = {}, M = {}, gt;
|
|
425
|
+
function xt() {
|
|
426
|
+
if (gt) return M;
|
|
427
|
+
gt = 1, Object.defineProperty(M, "__esModule", { value: !0 }), M.shallowEquals = void 0;
|
|
428
|
+
function t(e, n) {
|
|
429
|
+
if (e === n)
|
|
430
|
+
return !0;
|
|
431
|
+
if (typeof e != typeof n)
|
|
432
|
+
return !1;
|
|
433
|
+
switch (typeof e) {
|
|
434
|
+
case "boolean":
|
|
435
|
+
case "number":
|
|
436
|
+
case "string":
|
|
437
|
+
case "function":
|
|
438
|
+
case "symbol":
|
|
439
|
+
case "undefined":
|
|
440
|
+
return !1;
|
|
441
|
+
case "object":
|
|
442
|
+
if (e === null || n === null)
|
|
443
|
+
return !1;
|
|
444
|
+
if (Array.isArray(e) || Array.isArray(n)) {
|
|
445
|
+
if (!Array.isArray(e) || !Array.isArray(n) || e.length !== n.length)
|
|
446
|
+
return !1;
|
|
447
|
+
for (var r = 0; r < e.length; ++r)
|
|
448
|
+
if (e[r] !== n[r])
|
|
449
|
+
return !1;
|
|
450
|
+
return !0;
|
|
451
|
+
}
|
|
452
|
+
var f = [], l = [];
|
|
453
|
+
for (var u in e)
|
|
454
|
+
e.hasOwnProperty(u) && f.push(u);
|
|
455
|
+
for (var i in n)
|
|
456
|
+
n.hasOwnProperty(i) && l.push(i);
|
|
457
|
+
if (f.sort(), l.sort(), f.join(",") !== l.join(","))
|
|
458
|
+
return !1;
|
|
459
|
+
for (var r = 0; r < f.length; ++r)
|
|
460
|
+
if (e[f[r]] !== n[f[r]])
|
|
461
|
+
return !1;
|
|
462
|
+
return !0;
|
|
463
|
+
default:
|
|
464
|
+
return !1;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
return M.shallowEquals = t, M;
|
|
468
|
+
}
|
|
469
|
+
var pt;
|
|
470
|
+
function jt() {
|
|
471
|
+
return pt || (pt = 1, (function(t) {
|
|
472
|
+
var e = I && I.__extends || /* @__PURE__ */ (function() {
|
|
473
|
+
var o = function(s, c) {
|
|
474
|
+
return o = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, v) {
|
|
475
|
+
d.__proto__ = v;
|
|
476
|
+
} || function(d, v) {
|
|
477
|
+
for (var y in v) v.hasOwnProperty(y) && (d[y] = v[y]);
|
|
478
|
+
}, o(s, c);
|
|
479
|
+
};
|
|
480
|
+
return function(s, c) {
|
|
481
|
+
o(s, c);
|
|
482
|
+
function d() {
|
|
483
|
+
this.constructor = s;
|
|
484
|
+
}
|
|
485
|
+
s.prototype = c === null ? Object.create(c) : (d.prototype = c.prototype, new d());
|
|
486
|
+
};
|
|
487
|
+
})();
|
|
488
|
+
Object.defineProperty(t, "__esModule", { value: !0 }), t.ErrorAnyEvent = t.VoidAnyEvent = t.AnyEvent = t.EventType = void 0;
|
|
489
|
+
var n = xt(), r = x(), f = St(), l = Ct(), u;
|
|
490
|
+
(function(o) {
|
|
491
|
+
o[o.Sync = 0] = "Sync", o[o.Async = 1] = "Async", o[o.Queued = 2] = "Queued";
|
|
492
|
+
})(u = t.EventType || (t.EventType = {}));
|
|
493
|
+
var i = (
|
|
494
|
+
/** @class */
|
|
495
|
+
(function() {
|
|
496
|
+
function o(s) {
|
|
497
|
+
this._events = [], s && s.monitorAttach && (this.evtFirstAttached = new a(), this.evtLastDetached = new a());
|
|
498
|
+
}
|
|
499
|
+
return Object.defineProperty(o.prototype, "evtListenersChanged", {
|
|
500
|
+
/**
|
|
501
|
+
* Sent when someone attaches or detaches
|
|
502
|
+
*/
|
|
503
|
+
get: function() {
|
|
504
|
+
return this._listenersChanged || (this._listenersChanged = new r.VoidSyncEvent()), this._listenersChanged;
|
|
505
|
+
},
|
|
506
|
+
enumerable: !1,
|
|
507
|
+
configurable: !0
|
|
508
|
+
}), o.prototype.attach = function() {
|
|
509
|
+
for (var s = [], c = 0; c < arguments.length; c++)
|
|
510
|
+
s[c] = arguments[c];
|
|
511
|
+
var d = u.Sync;
|
|
512
|
+
s.length > 0 && typeof s[0] == "number" && (d = s.shift());
|
|
513
|
+
var v = this, y, g, p;
|
|
514
|
+
return typeof s[0] == "function" || s[0] && typeof s[0] == "object" && typeof s[0].post == "function" ? (typeof s[0] == "function" ? y = s[0] : p = s[0], g = s[1]) : (v = s[0], y = s[1], g = s[2]), this._attach(d, v, y, p, g, !1);
|
|
515
|
+
}, o.prototype.once = function() {
|
|
516
|
+
for (var s = [], c = 0; c < arguments.length; c++)
|
|
517
|
+
s[c] = arguments[c];
|
|
518
|
+
var d = u.Sync;
|
|
519
|
+
s.length > 0 && typeof s[0] == "number" && (d = s.shift());
|
|
520
|
+
var v = this, y, g, p;
|
|
521
|
+
return typeof s[0] == "function" || s[0] && typeof s[0] == "object" && typeof s[0].post == "function" ? (typeof s[0] == "function" ? y = s[0] : p = s[0], g = s[1]) : (v = s[0], y = s[1], g = s[2]), this._attach(d, v, y, p, g, !0);
|
|
522
|
+
}, o.prototype._attach = function(s, c, d, v, y, g) {
|
|
523
|
+
var p = this, ot = this.evtFirstAttached ? this.listenerCount() : 0, _;
|
|
524
|
+
switch (s) {
|
|
525
|
+
case u.Sync:
|
|
526
|
+
{
|
|
527
|
+
for (var W = 0, at = this._events; W < at.length; W++) {
|
|
528
|
+
var C = at[W];
|
|
529
|
+
C instanceof r.SyncEvent && (_ = C);
|
|
530
|
+
}
|
|
531
|
+
_ || (_ = new r.SyncEvent(), this._events.push(_));
|
|
532
|
+
}
|
|
533
|
+
break;
|
|
534
|
+
case u.Async:
|
|
535
|
+
{
|
|
536
|
+
for (var F = 0, ut = this._events; F < ut.length; F++) {
|
|
537
|
+
var C = ut[F];
|
|
538
|
+
C instanceof f.AsyncEvent && n.shallowEquals(C.options, y) && (_ = C);
|
|
539
|
+
}
|
|
540
|
+
_ || (_ = new f.AsyncEvent(y), this._events.push(_));
|
|
541
|
+
}
|
|
542
|
+
break;
|
|
543
|
+
case u.Queued:
|
|
544
|
+
{
|
|
545
|
+
for (var X = 0, ct = this._events; X < ct.length; X++) {
|
|
546
|
+
var C = ct[X];
|
|
547
|
+
C instanceof l.QueuedEvent && n.shallowEquals(C.options, y) && (_ = C);
|
|
548
|
+
}
|
|
549
|
+
_ || (_ = new l.QueuedEvent(y), this._events.push(_));
|
|
550
|
+
}
|
|
551
|
+
break;
|
|
552
|
+
default:
|
|
553
|
+
throw new Error("unknown EventType");
|
|
554
|
+
}
|
|
555
|
+
var P;
|
|
556
|
+
return g ? v ? P = _.once(v) : P = _.once(c, d) : v ? P = _.attach(v) : P = _.attach(c, d), this.evtFirstAttached && ot === 0 && this.evtFirstAttached.post(), this.evtListenersChanged && ot !== this.listenerCount() && this.evtListenersChanged.post(), function() {
|
|
557
|
+
var ht = p.evtLastDetached ? p.listenerCount() : 0;
|
|
558
|
+
P(), p.evtLastDetached && ht > 0 && p.listenerCount() === 0 && p.evtLastDetached.post(), p.evtListenersChanged && ht !== p.listenerCount() && p.evtListenersChanged.post();
|
|
559
|
+
};
|
|
560
|
+
}, o.prototype.attachSync = function() {
|
|
561
|
+
for (var s = [], c = 0; c < arguments.length; c++)
|
|
562
|
+
s[c] = arguments[c];
|
|
563
|
+
return s.unshift(u.Sync), this.attach.apply(this, s);
|
|
564
|
+
}, o.prototype.onceSync = function() {
|
|
565
|
+
for (var s = [], c = 0; c < arguments.length; c++)
|
|
566
|
+
s[c] = arguments[c];
|
|
567
|
+
return s.unshift(u.Sync), this.once.apply(this, s);
|
|
568
|
+
}, o.prototype.attachAsync = function() {
|
|
569
|
+
for (var s = [], c = 0; c < arguments.length; c++)
|
|
570
|
+
s[c] = arguments[c];
|
|
571
|
+
return s.unshift(u.Async), this.attach.apply(this, s);
|
|
572
|
+
}, o.prototype.onceAsync = function() {
|
|
573
|
+
for (var s = [], c = 0; c < arguments.length; c++)
|
|
574
|
+
s[c] = arguments[c];
|
|
575
|
+
return s.unshift(u.Async), this.once.apply(this, s);
|
|
576
|
+
}, o.prototype.attachQueued = function() {
|
|
577
|
+
for (var s = [], c = 0; c < arguments.length; c++)
|
|
578
|
+
s[c] = arguments[c];
|
|
579
|
+
return s.unshift(u.Queued), this.attach.apply(this, s);
|
|
580
|
+
}, o.prototype.onceQueued = function() {
|
|
581
|
+
for (var s = [], c = 0; c < arguments.length; c++)
|
|
582
|
+
s[c] = arguments[c];
|
|
583
|
+
return s.unshift(u.Queued), this.once.apply(this, s);
|
|
584
|
+
}, o.prototype.detach = function() {
|
|
585
|
+
for (var s = [], c = 0; c < arguments.length; c++)
|
|
586
|
+
s[c] = arguments[c];
|
|
587
|
+
for (var d = this.listenerCount(), v = 0; v < this._events.length; ++v)
|
|
588
|
+
this._events[v].detach.apply(this._events[v], s);
|
|
589
|
+
this.evtListenersChanged && d !== this.listenerCount() && this.evtListenersChanged.post(), this.evtLastDetached && d > 0 && this.listenerCount() === 0 && this.evtLastDetached.post();
|
|
590
|
+
}, o.prototype.post = function(s) {
|
|
591
|
+
for (var c = [], d = 0; d < this._events.length; ++d)
|
|
592
|
+
c.push(this._events[d]);
|
|
593
|
+
for (var d = 0; d < c.length; ++d)
|
|
594
|
+
c[d].post(s);
|
|
595
|
+
}, o.prototype.listenerCount = function() {
|
|
596
|
+
for (var s = 0, c = 0; c < this._events.length; ++c)
|
|
597
|
+
s += this._events[c].listenerCount();
|
|
598
|
+
return s;
|
|
599
|
+
}, o;
|
|
600
|
+
})()
|
|
601
|
+
);
|
|
602
|
+
t.AnyEvent = i;
|
|
603
|
+
var a = (
|
|
604
|
+
/** @class */
|
|
605
|
+
(function(o) {
|
|
606
|
+
e(s, o);
|
|
607
|
+
function s() {
|
|
608
|
+
return o !== null && o.apply(this, arguments) || this;
|
|
609
|
+
}
|
|
610
|
+
return s.prototype.post = function() {
|
|
611
|
+
o.prototype.post.call(this, void 0);
|
|
612
|
+
}, s;
|
|
613
|
+
})(i)
|
|
614
|
+
);
|
|
615
|
+
t.VoidAnyEvent = a;
|
|
616
|
+
var h = (
|
|
617
|
+
/** @class */
|
|
618
|
+
(function(o) {
|
|
619
|
+
e(s, o);
|
|
620
|
+
function s() {
|
|
621
|
+
return o !== null && o.apply(this, arguments) || this;
|
|
622
|
+
}
|
|
623
|
+
return s.prototype.post = function(c) {
|
|
624
|
+
if (this.listenerCount() === 0)
|
|
625
|
+
throw new Error("error event posted while no listeners attached. Error: " + c.message);
|
|
626
|
+
o.prototype.post.call(this, c);
|
|
627
|
+
}, s;
|
|
628
|
+
})(i)
|
|
629
|
+
);
|
|
630
|
+
t.ErrorAnyEvent = h;
|
|
631
|
+
})(I)), I;
|
|
632
|
+
}
|
|
633
|
+
var _t;
|
|
634
|
+
function Qt() {
|
|
635
|
+
return _t || (_t = 1, (function(t) {
|
|
636
|
+
var e = U && U.__createBinding || (Object.create ? (function(a, h, o, s) {
|
|
637
|
+
s === void 0 && (s = o), Object.defineProperty(a, s, { enumerable: !0, get: function() {
|
|
638
|
+
return h[o];
|
|
639
|
+
} });
|
|
640
|
+
}) : (function(a, h, o, s) {
|
|
641
|
+
s === void 0 && (s = o), a[s] = h[o];
|
|
642
|
+
})), n = U && U.__exportStar || function(a, h) {
|
|
643
|
+
for (var o in a) o !== "default" && !h.hasOwnProperty(o) && e(h, a, o);
|
|
644
|
+
};
|
|
645
|
+
Object.defineProperty(t, "__esModule", { value: !0 }), t.flush = t.flushOnce = t.queue = void 0, n(H(), t), n(x(), t), n(Ct(), t), n(St(), t), n(jt(), t);
|
|
646
|
+
var r = z(), f = z();
|
|
647
|
+
Object.defineProperty(t, "EventQueue", { enumerable: !0, get: function() {
|
|
648
|
+
return f.default;
|
|
649
|
+
} });
|
|
650
|
+
function l() {
|
|
651
|
+
return r.default.global();
|
|
652
|
+
}
|
|
653
|
+
t.queue = l;
|
|
654
|
+
function u() {
|
|
655
|
+
r.default.global().flushOnce();
|
|
656
|
+
}
|
|
657
|
+
t.flushOnce = u;
|
|
658
|
+
function i(a) {
|
|
659
|
+
a === void 0 && (a = 10), r.default.global().flush(a);
|
|
660
|
+
}
|
|
661
|
+
t.flush = i;
|
|
662
|
+
})(U)), U;
|
|
663
|
+
}
|
|
664
|
+
var D = Qt();
|
|
665
|
+
class Vt {
|
|
666
|
+
id;
|
|
667
|
+
elements = [];
|
|
668
|
+
onPlus = new D.SyncEvent();
|
|
669
|
+
onMin = new D.SyncEvent();
|
|
670
|
+
constructor(e) {
|
|
671
|
+
this.id = e;
|
|
672
|
+
}
|
|
673
|
+
name() {
|
|
674
|
+
return this.id.toString(16).padStart(2, "0");
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
let J = !1, $ = [], Q, bt, V = /* @__PURE__ */ new Map();
|
|
678
|
+
async function $t(t) {
|
|
679
|
+
try {
|
|
680
|
+
if (Q = await navigator.bluetooth.requestDevice(t), Q.gatt === void 0)
|
|
681
|
+
throw new Error("Device does not support GATT");
|
|
682
|
+
bt = await Q.gatt.connect(), Q.addEventListener("gattserverdisconnected", Ht), J = !0;
|
|
683
|
+
} catch (e) {
|
|
684
|
+
throw e;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
function Ht() {
|
|
688
|
+
V.clear(), J = !1, $.forEach((t) => t());
|
|
689
|
+
}
|
|
690
|
+
function kt(t) {
|
|
691
|
+
$.push(t);
|
|
692
|
+
}
|
|
693
|
+
function Gt(t) {
|
|
694
|
+
$ = $.filter((e) => e !== t);
|
|
695
|
+
}
|
|
696
|
+
async function tt(t, e) {
|
|
697
|
+
if (V.has(e)) {
|
|
698
|
+
const f = V.get(e);
|
|
699
|
+
if (f === void 0)
|
|
700
|
+
throw new Error("Characteristic not found");
|
|
701
|
+
return f;
|
|
702
|
+
}
|
|
703
|
+
const r = await (await bt.getPrimaryService(t)).getCharacteristic(e);
|
|
704
|
+
return V.set(e, r), r;
|
|
705
|
+
}
|
|
706
|
+
async function Wt(t, e) {
|
|
707
|
+
return await (await tt(t, e)).readValue();
|
|
708
|
+
}
|
|
709
|
+
async function Ft(t, e, n) {
|
|
710
|
+
const r = new DataView(new ArrayBuffer(n.length));
|
|
711
|
+
r.setUint8(0, n[0]), await (await tt(t, e)).writeValue(r);
|
|
712
|
+
}
|
|
713
|
+
async function Xt(t, e, n) {
|
|
714
|
+
const r = await tt(t, e);
|
|
715
|
+
r.addEventListener(
|
|
716
|
+
"characteristicvaluechanged",
|
|
717
|
+
(f) => {
|
|
718
|
+
let l = f.target.value;
|
|
719
|
+
l === void 0 && (l = new DataView(new ArrayBuffer(0))), n(l);
|
|
720
|
+
}
|
|
721
|
+
), await r.startNotifications();
|
|
722
|
+
}
|
|
723
|
+
function k() {
|
|
724
|
+
return {
|
|
725
|
+
connected: J,
|
|
726
|
+
connect: $t,
|
|
727
|
+
readCharacteristic: Wt,
|
|
728
|
+
writeCharacteristic: Ft,
|
|
729
|
+
subscribe: Xt,
|
|
730
|
+
setDisconnectCallback: kt,
|
|
731
|
+
removeDisconnectCallback: Gt
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
const Tt = "19b10000-e8f2-537e-4f6c-d104768a1214", Yt = "6b061bdc-9bc1-4952-a96f-c6ed551b2c3e", Kt = "998ff920-81af-42a9-a915-f88025f9647d", zt = {
|
|
735
|
+
filters: [{ namePrefix: "BLE-STANDEE" }],
|
|
736
|
+
optionalServices: [Tt]
|
|
737
|
+
};
|
|
738
|
+
function G() {
|
|
739
|
+
return {
|
|
740
|
+
serviceUuid: Tt,
|
|
741
|
+
messageCharUuid: Yt,
|
|
742
|
+
handshakeCharUuid: Kt,
|
|
743
|
+
options: zt
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
class Et {
|
|
747
|
+
static CONNECT = 0;
|
|
748
|
+
static DISCONNECT = 1;
|
|
749
|
+
}
|
|
750
|
+
class S {
|
|
751
|
+
static UPLOAD = 0;
|
|
752
|
+
static DRAW_IMAGE = 1;
|
|
753
|
+
static DRAW_RECTANGLE = 2;
|
|
754
|
+
static BUTTON_PRESS = 3;
|
|
755
|
+
static DRAW_TEXT = 4;
|
|
756
|
+
static ALL = 5;
|
|
757
|
+
static CLEAR_GRAPHICS = 6;
|
|
758
|
+
static ACTIONS = 7;
|
|
759
|
+
static CLEAR_SCREEN = 8;
|
|
760
|
+
static MESSAGE_DONE = 9;
|
|
761
|
+
}
|
|
762
|
+
class q {
|
|
763
|
+
static ID = 0;
|
|
764
|
+
static CACHE = 1;
|
|
765
|
+
static TTL = 2;
|
|
766
|
+
static POSITION = 3;
|
|
767
|
+
static DATA_SIZE = 4;
|
|
768
|
+
static TYPE = 5;
|
|
769
|
+
static DATA = 6;
|
|
770
|
+
}
|
|
771
|
+
class Y {
|
|
772
|
+
static MINUS = 0;
|
|
773
|
+
static PLUS = 1;
|
|
774
|
+
static EITHER = 2;
|
|
775
|
+
}
|
|
776
|
+
class m {
|
|
777
|
+
static INCREMENT = 0;
|
|
778
|
+
static DECREMENT = 1;
|
|
779
|
+
static SHOW = 2;
|
|
780
|
+
static HIDE = 3;
|
|
781
|
+
static SET = 4;
|
|
782
|
+
static BROADCAST = 5;
|
|
783
|
+
static TIMER = 6;
|
|
784
|
+
static CONDITION = 7;
|
|
785
|
+
static BREAK = 8;
|
|
786
|
+
static MAP = 9;
|
|
787
|
+
}
|
|
788
|
+
class O {
|
|
789
|
+
static STRING = 0;
|
|
790
|
+
static NUMBER = 1;
|
|
791
|
+
static ELEMENT = 2;
|
|
792
|
+
}
|
|
793
|
+
const { serviceUuid: Zt, handshakeCharUuid: Jt } = G(), Dt = new D.SyncEvent(), Ut = new D.SyncEvent();
|
|
794
|
+
function te() {
|
|
795
|
+
return new Promise((t, e) => {
|
|
796
|
+
k().subscribe(Zt, Jt, ee).then(() => t()).catch((n) => e(n));
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
function ee(t) {
|
|
800
|
+
t.getUint8(q.TYPE) === Et.CONNECT && Dt.post(t), t.getUint8(q.TYPE) === Et.DISCONNECT && Ut.post(t);
|
|
801
|
+
}
|
|
802
|
+
function et() {
|
|
803
|
+
return { subscribe: te, onConnected: Dt, onDisconnected: Ut };
|
|
804
|
+
}
|
|
805
|
+
class ne {
|
|
806
|
+
id;
|
|
807
|
+
data;
|
|
808
|
+
constructor(e, n) {
|
|
809
|
+
this.id = e, this.data = n;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
const { serviceUuid: re, messageCharUuid: se } = G(), Ot = new D.SyncEvent(), qt = new D.SyncEvent(), Pt = new D.SyncEvent(), Lt = new D.SyncEvent();
|
|
813
|
+
function ie() {
|
|
814
|
+
return new Promise((t, e) => {
|
|
815
|
+
k().subscribe(re, se, oe).then(() => t()).catch((n) => e(n));
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
function oe(t) {
|
|
819
|
+
t !== void 0 && (t.getUint8(q.TYPE) === S.BUTTON_PRESS && ae(t), t.getUint8(q.TYPE) === S.MESSAGE_DONE && Lt.post(t.getUint8(q.DATA)));
|
|
820
|
+
}
|
|
821
|
+
function ae(t) {
|
|
822
|
+
const e = t.getUint8(q.DATA), n = new ne(
|
|
823
|
+
t.getUint8(q.ID),
|
|
824
|
+
ue(t)
|
|
825
|
+
);
|
|
826
|
+
e === Y.MINUS && qt.post(n), e === Y.PLUS && Ot.post(n), e === Y.EITHER && Pt.post(n);
|
|
827
|
+
}
|
|
828
|
+
function ue(t) {
|
|
829
|
+
const e = t.buffer, n = 7, r = t.byteLength - 7;
|
|
830
|
+
return Array.from(new Uint8Array(e, n, r)).map((f) => String.fromCharCode(f)).join("").replace(/\0/g, "").trim();
|
|
831
|
+
}
|
|
832
|
+
function It() {
|
|
833
|
+
return { subscribe: ie, onPlus: Ot, onMin: qt, onEither: Pt, onMessageDone: Lt };
|
|
834
|
+
}
|
|
835
|
+
const { onConnected: ce } = et(), { onDisconnected: he } = et();
|
|
836
|
+
function le() {
|
|
837
|
+
return new Promise((t, e) => {
|
|
838
|
+
k().connect(G().options).then(
|
|
839
|
+
() => Promise.all([
|
|
840
|
+
et().subscribe(),
|
|
841
|
+
It().subscribe()
|
|
842
|
+
]).then(() => {
|
|
843
|
+
t();
|
|
844
|
+
})
|
|
845
|
+
).catch((n) => e(n));
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
function fe() {
|
|
849
|
+
return {
|
|
850
|
+
connect: le,
|
|
851
|
+
onConnected: ce,
|
|
852
|
+
onDisconnected: he
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
const N = [];
|
|
856
|
+
function de() {
|
|
857
|
+
let t = Math.floor(Math.random() * 256);
|
|
858
|
+
for (; N.includes(t); ) t = Math.floor(Math.random() * 256);
|
|
859
|
+
return t;
|
|
860
|
+
}
|
|
861
|
+
function ve(t) {
|
|
862
|
+
N.push(t), ye();
|
|
863
|
+
}
|
|
864
|
+
function ye() {
|
|
865
|
+
N.length <= 20 || N.splice(0, N.length - 20);
|
|
866
|
+
}
|
|
867
|
+
function ge() {
|
|
868
|
+
const t = de();
|
|
869
|
+
return ve(t), t;
|
|
870
|
+
}
|
|
871
|
+
function pe() {
|
|
872
|
+
return {
|
|
873
|
+
create: ge
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
const { serviceUuid: _e, messageCharUuid: Ee } = G(), { onMessageDone: we } = It(), Ae = k(), wt = 10, At = 15, Mt = [], Z = /* @__PURE__ */ new Map();
|
|
877
|
+
let R = !1;
|
|
878
|
+
we.attach(Se);
|
|
879
|
+
function me(t, e, n) {
|
|
880
|
+
const r = pe().create();
|
|
881
|
+
return Ce(r, t, e, n).forEach((l) => Mt.push(l)), new Promise((l) => {
|
|
882
|
+
Z.set(r, l), R || nt();
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
function Ce(t, e, n, r) {
|
|
886
|
+
if (r == null)
|
|
887
|
+
return [new Uint8Array([n, t, wt, 0, 2, e, 0])];
|
|
888
|
+
const f = new Uint8Array(2 + r.length), l = r.length + 2, u = [];
|
|
889
|
+
f.set([e, l], 0), f.set(r, 2);
|
|
890
|
+
for (let i = 0; i < l; i += At) {
|
|
891
|
+
const a = Math.min(At, l - i), h = new Uint8Array(a), o = [n, t, wt, i, l];
|
|
892
|
+
h.set(f.subarray(i, i + a), 0), u.push(new Uint8Array([...o, ...h]));
|
|
893
|
+
}
|
|
894
|
+
return u;
|
|
895
|
+
}
|
|
896
|
+
function nt() {
|
|
897
|
+
if (R)
|
|
898
|
+
return;
|
|
899
|
+
const t = Mt.shift();
|
|
900
|
+
if (t == null) {
|
|
901
|
+
R = !1;
|
|
902
|
+
return;
|
|
903
|
+
}
|
|
904
|
+
R = !0, Ae.writeCharacteristic(_e, Ee, t).catch((e) => console.log(e)).finally(() => {
|
|
905
|
+
R = !1, nt();
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
function Se(t) {
|
|
909
|
+
Z.get(t)?.(), Z.delete(t), nt();
|
|
910
|
+
}
|
|
911
|
+
function rt() {
|
|
912
|
+
return { write: me };
|
|
913
|
+
}
|
|
914
|
+
const { write: mt } = rt();
|
|
915
|
+
function ln(t) {
|
|
916
|
+
return {
|
|
917
|
+
upload: (e, n) => {
|
|
918
|
+
const r = new Uint8Array(n.length + 1);
|
|
919
|
+
return r.set([e], 0), r.set(n, 1), mt(S.UPLOAD, t, r);
|
|
920
|
+
},
|
|
921
|
+
clear: () => mt(S.CLEAR_GRAPHICS, t)
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
const { onConnected: be, onDisconnected: Te } = fe();
|
|
925
|
+
be.attach(De);
|
|
926
|
+
Te.attach(Ue);
|
|
927
|
+
const B = [];
|
|
928
|
+
function De(t) {
|
|
929
|
+
const e = new Uint8Array(t.buffer, 6);
|
|
930
|
+
for (const n of e)
|
|
931
|
+
Oe(n);
|
|
932
|
+
}
|
|
933
|
+
function Ue(t) {
|
|
934
|
+
const e = t.getUint8(2);
|
|
935
|
+
qe(e);
|
|
936
|
+
}
|
|
937
|
+
function Oe(t) {
|
|
938
|
+
B.some((e) => e.id === t) || B.push(new Vt(t));
|
|
939
|
+
}
|
|
940
|
+
function qe(t) {
|
|
941
|
+
const e = B.findIndex((n) => n.id === t);
|
|
942
|
+
e !== -1 && B.splice(e, 1);
|
|
943
|
+
}
|
|
944
|
+
function fn() {
|
|
945
|
+
return { standees: B };
|
|
946
|
+
}
|
|
947
|
+
class st {
|
|
948
|
+
id = 0;
|
|
949
|
+
dirty = !0;
|
|
950
|
+
_show = !0;
|
|
951
|
+
_x;
|
|
952
|
+
_y;
|
|
953
|
+
_colorBlack = !1;
|
|
954
|
+
constructor(e, n, r = !0, f = !1) {
|
|
955
|
+
this._x = e, this._y = n, this._show = r, this._colorBlack = f;
|
|
956
|
+
}
|
|
957
|
+
get x() {
|
|
958
|
+
return this._x;
|
|
959
|
+
}
|
|
960
|
+
get y() {
|
|
961
|
+
return this._y;
|
|
962
|
+
}
|
|
963
|
+
set x(e) {
|
|
964
|
+
this._x = e, this.dirty = !0;
|
|
965
|
+
}
|
|
966
|
+
set y(e) {
|
|
967
|
+
this._y = e, this.dirty = !0;
|
|
968
|
+
}
|
|
969
|
+
set show(e) {
|
|
970
|
+
this._show = e, this.dirty = !0;
|
|
971
|
+
}
|
|
972
|
+
get show() {
|
|
973
|
+
return this._show;
|
|
974
|
+
}
|
|
975
|
+
set colorBlack(e) {
|
|
976
|
+
this._colorBlack = e, this.dirty = !0;
|
|
977
|
+
}
|
|
978
|
+
get colorBlack() {
|
|
979
|
+
return this._colorBlack;
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
class Pe extends st {
|
|
983
|
+
_width;
|
|
984
|
+
_height;
|
|
985
|
+
_radius;
|
|
986
|
+
_fill;
|
|
987
|
+
constructor(e, n, r, f, l = 0, u = !1, i = !0, a = !1) {
|
|
988
|
+
super(e, n, i, a), this._width = r, this._height = f, this._radius = l, this._fill = u;
|
|
989
|
+
}
|
|
990
|
+
set width(e) {
|
|
991
|
+
this._width = e, this.dirty = !0;
|
|
992
|
+
}
|
|
993
|
+
set height(e) {
|
|
994
|
+
this._height = e, this.dirty = !0;
|
|
995
|
+
}
|
|
996
|
+
set radius(e) {
|
|
997
|
+
this._radius = e, this.dirty = !0;
|
|
998
|
+
}
|
|
999
|
+
set fill(e) {
|
|
1000
|
+
this._fill = e, this.dirty = !0;
|
|
1001
|
+
}
|
|
1002
|
+
get width() {
|
|
1003
|
+
return this._width;
|
|
1004
|
+
}
|
|
1005
|
+
get height() {
|
|
1006
|
+
return this._height;
|
|
1007
|
+
}
|
|
1008
|
+
get radius() {
|
|
1009
|
+
return this._radius;
|
|
1010
|
+
}
|
|
1011
|
+
get fill() {
|
|
1012
|
+
return this._fill;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
let Le = class extends st {
|
|
1016
|
+
_width;
|
|
1017
|
+
_height;
|
|
1018
|
+
_data;
|
|
1019
|
+
constructor(e, n, r, f, l, u = !0, i = !1) {
|
|
1020
|
+
super(e, n, u, i), this._width = r, this._height = f, this._data = l;
|
|
1021
|
+
}
|
|
1022
|
+
set width(e) {
|
|
1023
|
+
this._width = e, this.dirty = !0;
|
|
1024
|
+
}
|
|
1025
|
+
set height(e) {
|
|
1026
|
+
this._height = e, this.dirty = !0;
|
|
1027
|
+
}
|
|
1028
|
+
set data(e) {
|
|
1029
|
+
this._data = e, this.dirty = !0;
|
|
1030
|
+
}
|
|
1031
|
+
get width() {
|
|
1032
|
+
return this._width;
|
|
1033
|
+
}
|
|
1034
|
+
get height() {
|
|
1035
|
+
return this._height;
|
|
1036
|
+
}
|
|
1037
|
+
get data() {
|
|
1038
|
+
return this._data;
|
|
1039
|
+
}
|
|
1040
|
+
};
|
|
1041
|
+
class Ie extends st {
|
|
1042
|
+
_text;
|
|
1043
|
+
_font;
|
|
1044
|
+
_center;
|
|
1045
|
+
constructor(e, n, r, f, l = !1, u = !0, i = !1) {
|
|
1046
|
+
super(e, n, u, i), this._text = r, this._font = f, this._center = l;
|
|
1047
|
+
}
|
|
1048
|
+
set text(e) {
|
|
1049
|
+
this._text = e, this.dirty = !0;
|
|
1050
|
+
}
|
|
1051
|
+
set font(e) {
|
|
1052
|
+
this._font = e, this.dirty = !0;
|
|
1053
|
+
}
|
|
1054
|
+
get text() {
|
|
1055
|
+
return this._text;
|
|
1056
|
+
}
|
|
1057
|
+
get font() {
|
|
1058
|
+
return this._font;
|
|
1059
|
+
}
|
|
1060
|
+
get center() {
|
|
1061
|
+
return this._center;
|
|
1062
|
+
}
|
|
1063
|
+
set center(e) {
|
|
1064
|
+
this._center = e, this.dirty = !0;
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
function Me(t) {
|
|
1068
|
+
const e = () => {
|
|
1069
|
+
let r = Math.floor(Math.random() * 256);
|
|
1070
|
+
return n(r) ? e() : r;
|
|
1071
|
+
}, n = (r) => t.some((f) => f.id === r);
|
|
1072
|
+
return { generate: e };
|
|
1073
|
+
}
|
|
1074
|
+
function vn(t) {
|
|
1075
|
+
return { add: (r) => (r.id = Me(t.elements).generate(), t.elements.push(r), r), remove: (r) => {
|
|
1076
|
+
t.elements = t.elements.filter(
|
|
1077
|
+
(f) => f.id !== r
|
|
1078
|
+
);
|
|
1079
|
+
} };
|
|
1080
|
+
}
|
|
1081
|
+
const { write: Rt } = rt();
|
|
1082
|
+
function Re(t) {
|
|
1083
|
+
return Rt(S.CLEAR_SCREEN, t.id);
|
|
1084
|
+
}
|
|
1085
|
+
function Ne(t) {
|
|
1086
|
+
let e = new Uint8Array();
|
|
1087
|
+
for (const n of t.elements)
|
|
1088
|
+
n.dirty !== !1 && (n instanceof Le && (e = K(e, Be(n))), n instanceof Pe && (e = K(e, xe(n))), n instanceof Ie && (e = K(e, je(n))), n.dirty = !1);
|
|
1089
|
+
return Rt(S.ALL, t.id, e);
|
|
1090
|
+
}
|
|
1091
|
+
function K(t, e) {
|
|
1092
|
+
const n = new Uint8Array(t.length + e.length);
|
|
1093
|
+
return n.set(t, 0), n.set(e, t.length), n;
|
|
1094
|
+
}
|
|
1095
|
+
function Be(t) {
|
|
1096
|
+
return new Uint8Array([
|
|
1097
|
+
S.DRAW_IMAGE,
|
|
1098
|
+
7,
|
|
1099
|
+
t.id,
|
|
1100
|
+
t.show ? 1 : 0,
|
|
1101
|
+
t.x,
|
|
1102
|
+
t.y,
|
|
1103
|
+
t.width,
|
|
1104
|
+
t.height,
|
|
1105
|
+
t.data
|
|
1106
|
+
]);
|
|
1107
|
+
}
|
|
1108
|
+
function xe(t) {
|
|
1109
|
+
return new Uint8Array([
|
|
1110
|
+
S.DRAW_RECTANGLE,
|
|
1111
|
+
9,
|
|
1112
|
+
t.id,
|
|
1113
|
+
t.show ? 1 : 0,
|
|
1114
|
+
t.x,
|
|
1115
|
+
t.y,
|
|
1116
|
+
t.width,
|
|
1117
|
+
t.height,
|
|
1118
|
+
t.radius,
|
|
1119
|
+
t.fill ? 1 : 0,
|
|
1120
|
+
t.colorBlack ? 0 : 1
|
|
1121
|
+
]);
|
|
1122
|
+
}
|
|
1123
|
+
function je(t) {
|
|
1124
|
+
const e = new TextEncoder().encode(t.text), n = new Uint8Array(9 + e.length);
|
|
1125
|
+
return n.set(
|
|
1126
|
+
[
|
|
1127
|
+
S.DRAW_TEXT,
|
|
1128
|
+
7 + e.length,
|
|
1129
|
+
t.id,
|
|
1130
|
+
t.show ? 1 : 0,
|
|
1131
|
+
t.x,
|
|
1132
|
+
t.y,
|
|
1133
|
+
t.font,
|
|
1134
|
+
t.colorBlack ? 0 : 1,
|
|
1135
|
+
t.center ? 1 : 0
|
|
1136
|
+
],
|
|
1137
|
+
0
|
|
1138
|
+
), n.set(e, 9), n;
|
|
1139
|
+
}
|
|
1140
|
+
function yn() {
|
|
1141
|
+
return { clear: Re, draw: Ne };
|
|
1142
|
+
}
|
|
1143
|
+
function Qe(t, e) {
|
|
1144
|
+
const n = Math.ceil(t.length / e), r = Math.ceil(e / 8), f = new Uint8Array(r * n);
|
|
1145
|
+
for (let l = 0; l < n; l++)
|
|
1146
|
+
for (let u = 0; u < r; u++) {
|
|
1147
|
+
let i = 0;
|
|
1148
|
+
for (let a = 0; a < 8; a++) {
|
|
1149
|
+
const h = u * 8 + a, o = l * e + h;
|
|
1150
|
+
h < e && o < t.length && t[o] && (i |= 1 << 7 - a);
|
|
1151
|
+
}
|
|
1152
|
+
f[l * r + u] = Nt(i);
|
|
1153
|
+
}
|
|
1154
|
+
return f;
|
|
1155
|
+
}
|
|
1156
|
+
function Nt(t) {
|
|
1157
|
+
return t = (t & 240) >> 4 | (t & 15) << 4, t = (t & 204) >> 2 | (t & 51) << 2, t = (t & 170) >> 1 | (t & 85) << 1, t;
|
|
1158
|
+
}
|
|
1159
|
+
function Ve(t) {
|
|
1160
|
+
const e = t.reduce((f, l) => f + l.length, 0), n = new Uint8Array(e);
|
|
1161
|
+
let r = 0;
|
|
1162
|
+
for (const f of t)
|
|
1163
|
+
n.set(f, r), r += f.length;
|
|
1164
|
+
return n;
|
|
1165
|
+
}
|
|
1166
|
+
function it() {
|
|
1167
|
+
return {
|
|
1168
|
+
pixelsToBytes: Qe,
|
|
1169
|
+
bitswap: Nt,
|
|
1170
|
+
flattenUint8Arrays: Ve
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
const { flattenUint8Arrays: Bt } = it();
|
|
1174
|
+
class T {
|
|
1175
|
+
element_id;
|
|
1176
|
+
property;
|
|
1177
|
+
constructor(e, n) {
|
|
1178
|
+
this.element_id = e, this.property = n;
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
class b {
|
|
1182
|
+
target;
|
|
1183
|
+
constructor(e) {
|
|
1184
|
+
this.target = e;
|
|
1185
|
+
}
|
|
1186
|
+
format() {
|
|
1187
|
+
return new Uint8Array();
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
class $e extends b {
|
|
1191
|
+
format() {
|
|
1192
|
+
return new Uint8Array([
|
|
1193
|
+
m.INCREMENT,
|
|
1194
|
+
2,
|
|
1195
|
+
this.target.element_id,
|
|
1196
|
+
this.target.property
|
|
1197
|
+
]);
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
class He extends b {
|
|
1201
|
+
format() {
|
|
1202
|
+
return new Uint8Array([
|
|
1203
|
+
m.DECREMENT,
|
|
1204
|
+
2,
|
|
1205
|
+
this.target.element_id,
|
|
1206
|
+
this.target.property
|
|
1207
|
+
]);
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
class ke extends b {
|
|
1211
|
+
format() {
|
|
1212
|
+
return new Uint8Array([m.SHOW, 1, this.target.element_id]);
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
class Ge extends b {
|
|
1216
|
+
format() {
|
|
1217
|
+
return new Uint8Array([m.HIDE, 1, this.target.element_id]);
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
class We extends b {
|
|
1221
|
+
value;
|
|
1222
|
+
constructor(e, n) {
|
|
1223
|
+
super(e), this.value = n;
|
|
1224
|
+
}
|
|
1225
|
+
format() {
|
|
1226
|
+
const e = this.dataType(), n = this.convertValue(e), r = new Uint8Array(5 + n.length), f = [
|
|
1227
|
+
m.SET,
|
|
1228
|
+
n.length + 3,
|
|
1229
|
+
e,
|
|
1230
|
+
this.target.element_id,
|
|
1231
|
+
this.target.property
|
|
1232
|
+
];
|
|
1233
|
+
return r.set(f, 0), r.set(n, 5), r;
|
|
1234
|
+
}
|
|
1235
|
+
dataType() {
|
|
1236
|
+
return typeof this.value === "string" ? O.STRING : O.NUMBER;
|
|
1237
|
+
}
|
|
1238
|
+
convertValue(e) {
|
|
1239
|
+
return e === O.STRING ? new TextEncoder().encode(this.value) : e === O.NUMBER ? new Uint8Array([this.value]) : new Uint8Array();
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
class Fe extends b {
|
|
1243
|
+
format() {
|
|
1244
|
+
return this.target.element_id !== 0 && this.target.property !== 0 ? new Uint8Array([
|
|
1245
|
+
m.BROADCAST,
|
|
1246
|
+
2,
|
|
1247
|
+
this.target.element_id,
|
|
1248
|
+
this.target.property
|
|
1249
|
+
]) : new Uint8Array([m.BROADCAST, 0]);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
class Xe extends b {
|
|
1253
|
+
format() {
|
|
1254
|
+
return new Uint8Array([m.BREAK, 0]);
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
let Ye = class extends b {
|
|
1258
|
+
fromLow;
|
|
1259
|
+
fromHigh;
|
|
1260
|
+
toLow;
|
|
1261
|
+
toHigh;
|
|
1262
|
+
value;
|
|
1263
|
+
constructor(e, n, r, f, l, u) {
|
|
1264
|
+
super(u), this.value = e, this.fromLow = n, this.fromHigh = r, this.toLow = f, this.toHigh = l;
|
|
1265
|
+
}
|
|
1266
|
+
format() {
|
|
1267
|
+
return new Uint8Array([
|
|
1268
|
+
m.MAP,
|
|
1269
|
+
8,
|
|
1270
|
+
this.value.element_id,
|
|
1271
|
+
this.value.property,
|
|
1272
|
+
this.fromLow,
|
|
1273
|
+
this.fromHigh,
|
|
1274
|
+
this.toLow,
|
|
1275
|
+
this.toHigh,
|
|
1276
|
+
this.target.element_id,
|
|
1277
|
+
this.target.property
|
|
1278
|
+
]);
|
|
1279
|
+
}
|
|
1280
|
+
};
|
|
1281
|
+
class Ke extends b {
|
|
1282
|
+
deciseconds;
|
|
1283
|
+
resetable;
|
|
1284
|
+
onComplete;
|
|
1285
|
+
constructor(e, n, r) {
|
|
1286
|
+
super(new T(0, 0)), this.deciseconds = e, this.resetable = n, this.onComplete = r;
|
|
1287
|
+
}
|
|
1288
|
+
format() {
|
|
1289
|
+
const e = Bt(
|
|
1290
|
+
this.onComplete.map((f) => f.format())
|
|
1291
|
+
), n = new Uint8Array(4 + e.length), r = [
|
|
1292
|
+
m.TIMER,
|
|
1293
|
+
e.length + 2,
|
|
1294
|
+
this.resetable ? 1 : 0,
|
|
1295
|
+
this.deciseconds
|
|
1296
|
+
];
|
|
1297
|
+
return n.set(r, 0), e.forEach(
|
|
1298
|
+
(f, l) => n.set([f], l + 4)
|
|
1299
|
+
), n;
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
class ze extends b {
|
|
1303
|
+
left;
|
|
1304
|
+
operator;
|
|
1305
|
+
right;
|
|
1306
|
+
actions;
|
|
1307
|
+
constructor(e, n, r, f) {
|
|
1308
|
+
super(new T(0, 0)), this.actions = f, this.left = e, this.operator = n, this.right = r;
|
|
1309
|
+
}
|
|
1310
|
+
convertValue(e) {
|
|
1311
|
+
if (typeof e == "number")
|
|
1312
|
+
return new Uint8Array([O.NUMBER, 1, e]);
|
|
1313
|
+
if (typeof e == "string") {
|
|
1314
|
+
const n = new TextEncoder().encode(e);
|
|
1315
|
+
return new Uint8Array([
|
|
1316
|
+
O.STRING,
|
|
1317
|
+
n.length,
|
|
1318
|
+
...n
|
|
1319
|
+
]);
|
|
1320
|
+
}
|
|
1321
|
+
return e instanceof T ? new Uint8Array([
|
|
1322
|
+
O.ELEMENT,
|
|
1323
|
+
2,
|
|
1324
|
+
e.element_id,
|
|
1325
|
+
e.property
|
|
1326
|
+
]) : new Uint8Array();
|
|
1327
|
+
}
|
|
1328
|
+
format() {
|
|
1329
|
+
const e = Bt(
|
|
1330
|
+
this.actions.map((i) => i.format())
|
|
1331
|
+
), n = this.convertValue(this.left), r = this.convertValue(this.right), f = 4 + n.length + r.length + e.length, l = new Uint8Array(f), u = [
|
|
1332
|
+
m.CONDITION,
|
|
1333
|
+
f - 2,
|
|
1334
|
+
n.length + r.length + 1
|
|
1335
|
+
];
|
|
1336
|
+
return l.set(u, 0), l.set([this.operator], 3), l.set(n, 4), l.set(r, 4 + n.length), l.set(e, 4 + n.length + r.length), l;
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
function pn() {
|
|
1340
|
+
return {
|
|
1341
|
+
target(t, e) {
|
|
1342
|
+
return new T(t, e);
|
|
1343
|
+
},
|
|
1344
|
+
increment(t) {
|
|
1345
|
+
return new $e(t);
|
|
1346
|
+
},
|
|
1347
|
+
decrement(t) {
|
|
1348
|
+
return new He(t);
|
|
1349
|
+
},
|
|
1350
|
+
show(t) {
|
|
1351
|
+
return new ke(new T(t, 0));
|
|
1352
|
+
},
|
|
1353
|
+
hide(t) {
|
|
1354
|
+
return new Ge(new T(t, 0));
|
|
1355
|
+
},
|
|
1356
|
+
set(t, e) {
|
|
1357
|
+
return new We(t, e);
|
|
1358
|
+
},
|
|
1359
|
+
broadcast(t) {
|
|
1360
|
+
return new Fe(t || new T(0, 0));
|
|
1361
|
+
},
|
|
1362
|
+
timer(t, e, n) {
|
|
1363
|
+
return new Ke(t, e, n);
|
|
1364
|
+
},
|
|
1365
|
+
stop() {
|
|
1366
|
+
return new Xe(new T(0, 0));
|
|
1367
|
+
},
|
|
1368
|
+
condition(t, e, n, r) {
|
|
1369
|
+
return new ze(t, e, n, r);
|
|
1370
|
+
},
|
|
1371
|
+
map(t, e, n, r, f, l) {
|
|
1372
|
+
return new Ye(t, e, n, r, f, l);
|
|
1373
|
+
}
|
|
1374
|
+
};
|
|
1375
|
+
}
|
|
1376
|
+
const { write: Ze } = rt(), { flattenUint8Arrays: Je } = it();
|
|
1377
|
+
function _n(t) {
|
|
1378
|
+
return {
|
|
1379
|
+
setButton(e, n) {
|
|
1380
|
+
const r = Je(
|
|
1381
|
+
n.map((l) => l.format())
|
|
1382
|
+
), f = new Uint8Array(1 + r.length);
|
|
1383
|
+
return f.set([e], 0), r.forEach(
|
|
1384
|
+
(l, u) => f.set([l], u + 1)
|
|
1385
|
+
), Ze(S.ACTIONS, t.id, f);
|
|
1386
|
+
}
|
|
1387
|
+
};
|
|
1388
|
+
}
|
|
1389
|
+
function tn(t) {
|
|
1390
|
+
return new Promise((e, n) => {
|
|
1391
|
+
const r = new Image();
|
|
1392
|
+
r.onload = () => e(r), r.onerror = n, r.src = t;
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1395
|
+
function en(t) {
|
|
1396
|
+
const e = document.createElement("canvas"), n = e.getContext("2d");
|
|
1397
|
+
if (e.width = t.width, e.height = t.height, !n)
|
|
1398
|
+
throw new Error("Failed to get 2D context for image data.");
|
|
1399
|
+
return n.drawImage(t, 0, 0), n.getImageData(0, 0, t.width, t.height);
|
|
1400
|
+
}
|
|
1401
|
+
function nn(t) {
|
|
1402
|
+
const e = [], n = t.data, r = t.width, f = t.height;
|
|
1403
|
+
for (let l = 0; l < f; l++)
|
|
1404
|
+
for (let u = 0; u < r; u++) {
|
|
1405
|
+
const i = (l * r + u) * 4, a = n[i], h = n[i + 1], o = n[i + 2], s = 0.2126 * a + 0.7152 * h + 0.0722 * o;
|
|
1406
|
+
e.push(s < 128 ? 0 : 1);
|
|
1407
|
+
}
|
|
1408
|
+
return {
|
|
1409
|
+
width: r,
|
|
1410
|
+
height: f,
|
|
1411
|
+
pixels: e
|
|
1412
|
+
};
|
|
1413
|
+
}
|
|
1414
|
+
function rn() {
|
|
1415
|
+
return {
|
|
1416
|
+
createImage: tn,
|
|
1417
|
+
getImageData: en,
|
|
1418
|
+
imageDataToPixels: nn
|
|
1419
|
+
};
|
|
1420
|
+
}
|
|
1421
|
+
const { createImage: sn, getImageData: on, imageDataToPixels: an } = rn(), { pixelsToBytes: un } = it();
|
|
1422
|
+
function cn(t) {
|
|
1423
|
+
return new Promise((e, n) => {
|
|
1424
|
+
sn(t).then((r) => on(r)).then((r) => an(r)).then((r) => un(r.pixels, r.width)).then((r) => e(r)).catch((r) => n(r));
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
function En() {
|
|
1428
|
+
return {
|
|
1429
|
+
imageToBytes: cn
|
|
1430
|
+
};
|
|
1431
|
+
}
|
|
1432
|
+
function hn(t, e, n, r, f) {
|
|
1433
|
+
return (t - e) / (n - e) * (f - r) + r;
|
|
1434
|
+
}
|
|
1435
|
+
function wn() {
|
|
1436
|
+
return { map: hn };
|
|
1437
|
+
}
|
|
1438
|
+
export {
|
|
1439
|
+
Vt as Standee,
|
|
1440
|
+
pn as useActions,
|
|
1441
|
+
it as useBinary,
|
|
1442
|
+
_n as useButtons,
|
|
1443
|
+
En as useConverter,
|
|
1444
|
+
yn as useDisplay,
|
|
1445
|
+
rn as useImage,
|
|
1446
|
+
fe as useMesh,
|
|
1447
|
+
ln as useMeshUpload,
|
|
1448
|
+
rt as useMeshWriter,
|
|
1449
|
+
vn as useStandeeElements,
|
|
1450
|
+
fn as useStandees,
|
|
1451
|
+
wn as useUtils
|
|
1452
|
+
};
|