nsd-ble 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Objects-CS29rf_8.cjs +1 -0
- package/dist/Objects-RyXOt964.js +867 -0
- package/dist/main.cjs +1 -1
- package/dist/main.js +143 -217
- package/dist/objects.cjs +1 -1
- package/dist/objects.js +4 -3
- package/dist/types/Objects.d.ts +2 -1
- package/package.json +1 -1
- package/dist/Objects-CmJJGRgZ.js +0 -792
- package/dist/Objects-DgZKSQY-.cjs +0 -1
package/dist/main.js
CHANGED
|
@@ -1,125 +1,51 @@
|
|
|
1
|
-
import { l as
|
|
2
|
-
import { Data as
|
|
3
|
-
import { Image as
|
|
4
|
-
const { serviceUuid:
|
|
5
|
-
function
|
|
1
|
+
import { l as A, u as I, a as D, b as B, B as w, S as b } from "./Objects-RyXOt964.js";
|
|
2
|
+
import { Data as T, HandshakeType as C, DataType as u, ActionType as a, ActionDataType as d } from "./enums.js";
|
|
3
|
+
import { Image as P, Rectangle as M, Text as L } from "./elements.js";
|
|
4
|
+
const { serviceUuid: k, handshakeCharUuid: H } = D(), R = new A.SyncEvent(), S = new A.SyncEvent();
|
|
5
|
+
function $() {
|
|
6
6
|
return new Promise((t, e) => {
|
|
7
|
-
|
|
7
|
+
I().subscribe(k, H, O).then(() => t()).catch((n) => e(n));
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
t.getUint8(
|
|
10
|
+
function O(t) {
|
|
11
|
+
t.getUint8(T.TYPE) === C.CONNECT && R.post(t), t.getUint8(T.TYPE) === C.DISCONNECT && S.post(t);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
return { subscribe:
|
|
13
|
+
function E() {
|
|
14
|
+
return { subscribe: $, onConnected: R, onDisconnected: S };
|
|
15
15
|
}
|
|
16
|
-
const { onConnected:
|
|
17
|
-
function
|
|
16
|
+
const { onConnected: G } = E(), { onDisconnected: V } = E(), { onPlusButton: W, onMinButton: Y, onEitherButton: z } = B();
|
|
17
|
+
function F() {
|
|
18
18
|
return new Promise((t, e) => {
|
|
19
|
-
|
|
19
|
+
I().connect(D().options).then(
|
|
20
20
|
() => Promise.all([
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
E().subscribe(),
|
|
22
|
+
B().subscribe()
|
|
23
23
|
]).then(() => {
|
|
24
24
|
t();
|
|
25
25
|
})
|
|
26
26
|
).catch((n) => e(n));
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function K() {
|
|
30
30
|
return {
|
|
31
|
-
connect:
|
|
32
|
-
onConnected:
|
|
33
|
-
onDisconnected:
|
|
34
|
-
onPlusButton:
|
|
35
|
-
onMinButton:
|
|
36
|
-
onEitherButton:
|
|
31
|
+
connect: F,
|
|
32
|
+
onConnected: G,
|
|
33
|
+
onDisconnected: V,
|
|
34
|
+
onPlusButton: W,
|
|
35
|
+
onMinButton: Y,
|
|
36
|
+
onEitherButton: z
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
function et() {
|
|
41
|
-
let t = Math.floor(Math.random() * 256);
|
|
42
|
-
for (; y.includes(t); ) t = Math.floor(Math.random() * 256);
|
|
43
|
-
return t;
|
|
44
|
-
}
|
|
45
|
-
function nt(t) {
|
|
46
|
-
y.push(t), rt();
|
|
47
|
-
}
|
|
48
|
-
function rt() {
|
|
49
|
-
y.length <= 20 || y.splice(0, y.length - 20);
|
|
50
|
-
}
|
|
51
|
-
function st() {
|
|
52
|
-
const t = et();
|
|
53
|
-
return nt(t), t;
|
|
54
|
-
}
|
|
55
|
-
function ot() {
|
|
56
|
-
return {
|
|
57
|
-
create: st
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
const { serviceUuid: it, messageCharUuid: at } = C(), { onMessageDone: ct } = D(), ut = x(), L = [], E = /* @__PURE__ */ new Map();
|
|
61
|
-
let p = !1;
|
|
62
|
-
ct.attach(dt);
|
|
63
|
-
function ht(t) {
|
|
64
|
-
return t.packets.forEach((e) => L.push(e)), new Promise((e) => {
|
|
65
|
-
E.set(t.cache, e), p || M();
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
function M() {
|
|
69
|
-
if (p)
|
|
70
|
-
return;
|
|
71
|
-
const t = L.shift();
|
|
72
|
-
if (t == null) {
|
|
73
|
-
p = !1;
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
p = !0, ut.writeCharacteristic(it, at, t).catch((e) => console.log(e)).finally(() => {
|
|
77
|
-
p = !1, M();
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
function dt(t) {
|
|
81
|
-
E.get(t)?.(), E.delete(t), M();
|
|
82
|
-
}
|
|
83
|
-
function lt() {
|
|
84
|
-
return { write: ht };
|
|
85
|
-
}
|
|
86
|
-
const _ = 10, P = 15;
|
|
87
|
-
function ft(t) {
|
|
88
|
-
if (t.data == null) {
|
|
89
|
-
let s = [t.id, t.cache, _, 0, 2, t.type, 0];
|
|
90
|
-
return [new Uint8Array(s)];
|
|
91
|
-
}
|
|
92
|
-
const e = new Uint8Array(2 + t.data.length), n = t.data.length + 2, r = [];
|
|
93
|
-
e.set([t.type, n], 0), e.set(t.data, 2);
|
|
94
|
-
for (let s = 0; s < n; s += P) {
|
|
95
|
-
const o = Math.min(P, n - s), i = new Uint8Array(o), c = [t.id, t.cache, _, s, n];
|
|
96
|
-
i.set(e.subarray(s, s + o), 0), r.push(new Uint8Array([...c, ...i]));
|
|
97
|
-
}
|
|
98
|
-
return r;
|
|
99
|
-
}
|
|
100
|
-
class w {
|
|
101
|
-
cache = ot().create();
|
|
102
|
-
type;
|
|
103
|
-
id;
|
|
104
|
-
data;
|
|
105
|
-
packets = [];
|
|
106
|
-
constructor(e, n, r) {
|
|
107
|
-
this.type = e, this.id = n, this.data = r, this.packets = ft(this);
|
|
108
|
-
}
|
|
109
|
-
send() {
|
|
110
|
-
return lt().write(this);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
function Qt(t) {
|
|
39
|
+
function bt(t) {
|
|
114
40
|
return {
|
|
115
41
|
upload: (e, n) => {
|
|
116
42
|
const r = new Uint8Array(n.length + 1);
|
|
117
|
-
return r.set([e], 0), r.set(n, 1), new w(
|
|
43
|
+
return r.set([e], 0), r.set(n, 1), new w(u.UPLOAD, t.id, r);
|
|
118
44
|
},
|
|
119
|
-
clear: () => new w(
|
|
45
|
+
clear: () => new w(u.CLEAR_GRAPHICS, t.id)
|
|
120
46
|
};
|
|
121
47
|
}
|
|
122
|
-
class
|
|
48
|
+
class X {
|
|
123
49
|
id;
|
|
124
50
|
buffers;
|
|
125
51
|
totalPackets = 0;
|
|
@@ -128,68 +54,68 @@ class gt {
|
|
|
128
54
|
}
|
|
129
55
|
async send() {
|
|
130
56
|
const e = new Uint8Array([this.totalPackets]);
|
|
131
|
-
await new w(
|
|
57
|
+
await new w(u.LOADER, this.id, e).send(), await Promise.all(this.buffers.map((r) => r.send()));
|
|
132
58
|
}
|
|
133
59
|
}
|
|
134
|
-
function
|
|
60
|
+
function Pt(t) {
|
|
135
61
|
return {
|
|
136
|
-
load: (e) => new
|
|
62
|
+
load: (e) => new X(e, t.id)
|
|
137
63
|
};
|
|
138
64
|
}
|
|
139
|
-
const { onConnected:
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
function
|
|
65
|
+
const { onConnected: j, onDisconnected: q } = K();
|
|
66
|
+
j.attach(J);
|
|
67
|
+
q.attach(Q);
|
|
68
|
+
const l = [], U = new A.SyncEvent();
|
|
69
|
+
function J(t) {
|
|
144
70
|
const e = new Uint8Array(t.buffer, 6);
|
|
145
71
|
for (const n of e)
|
|
146
|
-
|
|
147
|
-
|
|
72
|
+
Z(n);
|
|
73
|
+
U.post(l);
|
|
148
74
|
}
|
|
149
|
-
function
|
|
75
|
+
function Q(t) {
|
|
150
76
|
const e = t.getUint8(2);
|
|
151
|
-
|
|
77
|
+
tt(e), U.post(l);
|
|
152
78
|
}
|
|
153
|
-
function
|
|
154
|
-
|
|
79
|
+
function Z(t) {
|
|
80
|
+
l.some((e) => e.id === t) || l.push(new b(t));
|
|
155
81
|
}
|
|
156
|
-
function
|
|
157
|
-
const e =
|
|
158
|
-
e !== -1 &&
|
|
82
|
+
function tt(t) {
|
|
83
|
+
const e = l.findIndex((n) => n.id === t);
|
|
84
|
+
e !== -1 && l.splice(e, 1);
|
|
159
85
|
}
|
|
160
|
-
function
|
|
161
|
-
return { standees:
|
|
86
|
+
function Mt() {
|
|
87
|
+
return { standees: l, onChange: U };
|
|
162
88
|
}
|
|
163
|
-
function
|
|
89
|
+
function et(t) {
|
|
164
90
|
const e = () => {
|
|
165
91
|
let r = Math.floor(Math.random() * 256);
|
|
166
92
|
return n(r) ? e() : r;
|
|
167
93
|
}, n = (r) => t.some((s) => s.id === r);
|
|
168
94
|
return { generate: e };
|
|
169
95
|
}
|
|
170
|
-
function
|
|
171
|
-
return { add: (r) => (r.id =
|
|
96
|
+
function Lt(t) {
|
|
97
|
+
return { add: (r) => (r.id = et(t.elements).generate(), t.elements.push(r), r), remove: (r) => {
|
|
172
98
|
t.elements = t.elements.filter(
|
|
173
99
|
(s) => s.id !== r
|
|
174
100
|
);
|
|
175
101
|
} };
|
|
176
102
|
}
|
|
177
|
-
function
|
|
178
|
-
return new w(
|
|
103
|
+
function nt(t) {
|
|
104
|
+
return new w(u.CLEAR_SCREEN, t.id);
|
|
179
105
|
}
|
|
180
|
-
function
|
|
106
|
+
function rt(t) {
|
|
181
107
|
let e = new Uint8Array();
|
|
182
108
|
for (const n of t.elements)
|
|
183
|
-
n.dirty !== !1 && (n instanceof
|
|
184
|
-
return new w(
|
|
109
|
+
n.dirty !== !1 && (n instanceof P && (e = m(e, st(n))), n instanceof M && (e = m(e, ot(n))), n instanceof L && (e = m(e, it(n))), n.dirty = !1);
|
|
110
|
+
return new w(u.ALL, t.id, e);
|
|
185
111
|
}
|
|
186
|
-
function
|
|
112
|
+
function m(t, e) {
|
|
187
113
|
const n = new Uint8Array(t.length + e.length);
|
|
188
114
|
return n.set(t, 0), n.set(e, t.length), n;
|
|
189
115
|
}
|
|
190
|
-
function
|
|
116
|
+
function st(t) {
|
|
191
117
|
return new Uint8Array([
|
|
192
|
-
|
|
118
|
+
u.DRAW_IMAGE,
|
|
193
119
|
7,
|
|
194
120
|
t.id,
|
|
195
121
|
t.show ? 1 : 0,
|
|
@@ -200,9 +126,9 @@ function Ct(t) {
|
|
|
200
126
|
t.data
|
|
201
127
|
]);
|
|
202
128
|
}
|
|
203
|
-
function
|
|
129
|
+
function ot(t) {
|
|
204
130
|
return new Uint8Array([
|
|
205
|
-
|
|
131
|
+
u.DRAW_RECTANGLE,
|
|
206
132
|
9,
|
|
207
133
|
t.id,
|
|
208
134
|
t.show ? 1 : 0,
|
|
@@ -215,11 +141,11 @@ function Dt(t) {
|
|
|
215
141
|
t.colorBlack ? 0 : 1
|
|
216
142
|
]);
|
|
217
143
|
}
|
|
218
|
-
function
|
|
144
|
+
function it(t) {
|
|
219
145
|
const e = new TextEncoder().encode(t.text), n = new Uint8Array(9 + e.length);
|
|
220
146
|
return n.set(
|
|
221
147
|
[
|
|
222
|
-
|
|
148
|
+
u.DRAW_TEXT,
|
|
223
149
|
7 + e.length,
|
|
224
150
|
t.id,
|
|
225
151
|
t.show ? 1 : 0,
|
|
@@ -232,48 +158,48 @@ function It(t) {
|
|
|
232
158
|
0
|
|
233
159
|
), n.set(e, 9), n;
|
|
234
160
|
}
|
|
235
|
-
function
|
|
236
|
-
return { clear:
|
|
161
|
+
function kt() {
|
|
162
|
+
return { clear: nt, draw: rt };
|
|
237
163
|
}
|
|
238
|
-
function
|
|
164
|
+
function at(t, e) {
|
|
239
165
|
const n = Math.ceil(t.length / e), r = Math.ceil(e / 8), s = new Uint8Array(r * n);
|
|
240
166
|
for (let o = 0; o < n; o++)
|
|
241
167
|
for (let i = 0; i < r; i++) {
|
|
242
|
-
let
|
|
168
|
+
let h = 0;
|
|
243
169
|
for (let g = 0; g < 8; g++) {
|
|
244
|
-
const
|
|
245
|
-
|
|
170
|
+
const y = i * 8 + g, p = o * e + y;
|
|
171
|
+
y < e && p < t.length && t[p] && (h |= 1 << 7 - g);
|
|
246
172
|
}
|
|
247
|
-
s[o * r + i] =
|
|
173
|
+
s[o * r + i] = _(h);
|
|
248
174
|
}
|
|
249
175
|
return s;
|
|
250
176
|
}
|
|
251
|
-
function
|
|
177
|
+
function _(t) {
|
|
252
178
|
return t = (t & 240) >> 4 | (t & 15) << 4, t = (t & 204) >> 2 | (t & 51) << 2, t = (t & 170) >> 1 | (t & 85) << 1, t;
|
|
253
179
|
}
|
|
254
|
-
function
|
|
180
|
+
function ct(t) {
|
|
255
181
|
const e = t.reduce((s, o) => s + o.length, 0), n = new Uint8Array(e);
|
|
256
182
|
let r = 0;
|
|
257
183
|
for (const s of t)
|
|
258
184
|
n.set(s, r), r += s.length;
|
|
259
185
|
return n;
|
|
260
186
|
}
|
|
261
|
-
function
|
|
187
|
+
function x() {
|
|
262
188
|
return {
|
|
263
|
-
pixelsToBytes:
|
|
264
|
-
bitswap:
|
|
265
|
-
flattenUint8Arrays:
|
|
189
|
+
pixelsToBytes: at,
|
|
190
|
+
bitswap: _,
|
|
191
|
+
flattenUint8Arrays: ct
|
|
266
192
|
};
|
|
267
193
|
}
|
|
268
|
-
const { flattenUint8Arrays:
|
|
269
|
-
class
|
|
194
|
+
const { flattenUint8Arrays: v } = x();
|
|
195
|
+
class f {
|
|
270
196
|
element_id;
|
|
271
197
|
property;
|
|
272
198
|
constructor(e, n) {
|
|
273
199
|
this.element_id = e, this.property = n;
|
|
274
200
|
}
|
|
275
201
|
}
|
|
276
|
-
class
|
|
202
|
+
class c {
|
|
277
203
|
target;
|
|
278
204
|
constructor(e) {
|
|
279
205
|
this.target = e;
|
|
@@ -282,7 +208,7 @@ class u {
|
|
|
282
208
|
return new Uint8Array();
|
|
283
209
|
}
|
|
284
210
|
}
|
|
285
|
-
class
|
|
211
|
+
class ut extends c {
|
|
286
212
|
format() {
|
|
287
213
|
return new Uint8Array([
|
|
288
214
|
a.INCREMENT,
|
|
@@ -292,7 +218,7 @@ class Bt extends u {
|
|
|
292
218
|
]);
|
|
293
219
|
}
|
|
294
220
|
}
|
|
295
|
-
class
|
|
221
|
+
class ht extends c {
|
|
296
222
|
format() {
|
|
297
223
|
return new Uint8Array([
|
|
298
224
|
a.DECREMENT,
|
|
@@ -302,17 +228,17 @@ class St extends u {
|
|
|
302
228
|
]);
|
|
303
229
|
}
|
|
304
230
|
}
|
|
305
|
-
class
|
|
231
|
+
class ft extends c {
|
|
306
232
|
format() {
|
|
307
233
|
return new Uint8Array([a.SHOW, 1, this.target.element_id]);
|
|
308
234
|
}
|
|
309
235
|
}
|
|
310
|
-
class
|
|
236
|
+
class dt extends c {
|
|
311
237
|
format() {
|
|
312
238
|
return new Uint8Array([a.HIDE, 1, this.target.element_id]);
|
|
313
239
|
}
|
|
314
240
|
}
|
|
315
|
-
class
|
|
241
|
+
class lt extends c {
|
|
316
242
|
value;
|
|
317
243
|
constructor(e, n) {
|
|
318
244
|
super(e), this.value = n;
|
|
@@ -328,13 +254,13 @@ class Pt extends u {
|
|
|
328
254
|
return r.set(s, 0), r.set(n, 5), r;
|
|
329
255
|
}
|
|
330
256
|
dataType() {
|
|
331
|
-
return typeof this.value === "string" ?
|
|
257
|
+
return typeof this.value === "string" ? d.STRING : d.NUMBER;
|
|
332
258
|
}
|
|
333
259
|
convertValue(e) {
|
|
334
|
-
return e ===
|
|
260
|
+
return e === d.STRING ? new TextEncoder().encode(this.value) : e === d.NUMBER ? new Uint8Array([this.value]) : new Uint8Array();
|
|
335
261
|
}
|
|
336
262
|
}
|
|
337
|
-
class
|
|
263
|
+
class gt extends c {
|
|
338
264
|
format() {
|
|
339
265
|
return this.target.element_id !== 0 && this.target.property !== 0 ? new Uint8Array([
|
|
340
266
|
a.BROADCAST,
|
|
@@ -344,12 +270,12 @@ class Nt extends u {
|
|
|
344
270
|
]) : new Uint8Array([a.BROADCAST, 0]);
|
|
345
271
|
}
|
|
346
272
|
}
|
|
347
|
-
class
|
|
273
|
+
class wt extends c {
|
|
348
274
|
format() {
|
|
349
275
|
return new Uint8Array([a.BREAK, 0]);
|
|
350
276
|
}
|
|
351
277
|
}
|
|
352
|
-
|
|
278
|
+
class yt extends c {
|
|
353
279
|
fromLow;
|
|
354
280
|
fromHigh;
|
|
355
281
|
toLow;
|
|
@@ -372,16 +298,16 @@ let Lt = class extends u {
|
|
|
372
298
|
this.target.property
|
|
373
299
|
]);
|
|
374
300
|
}
|
|
375
|
-
}
|
|
376
|
-
class
|
|
301
|
+
}
|
|
302
|
+
class pt extends c {
|
|
377
303
|
deciseconds;
|
|
378
304
|
resetable;
|
|
379
305
|
onComplete;
|
|
380
306
|
constructor(e, n, r) {
|
|
381
|
-
super(new
|
|
307
|
+
super(new f(0, 0)), this.deciseconds = e, this.resetable = n, this.onComplete = r;
|
|
382
308
|
}
|
|
383
309
|
format() {
|
|
384
|
-
const e =
|
|
310
|
+
const e = v(
|
|
385
311
|
this.onComplete.map((s) => s.format())
|
|
386
312
|
), n = new Uint8Array(4 + e.length), r = [
|
|
387
313
|
a.TIMER,
|
|
@@ -394,35 +320,35 @@ class bt extends u {
|
|
|
394
320
|
), n;
|
|
395
321
|
}
|
|
396
322
|
}
|
|
397
|
-
class
|
|
323
|
+
class mt extends c {
|
|
398
324
|
left;
|
|
399
325
|
operator;
|
|
400
326
|
right;
|
|
401
327
|
actions;
|
|
402
328
|
constructor(e, n, r, s) {
|
|
403
|
-
super(new
|
|
329
|
+
super(new f(0, 0)), this.actions = s, this.left = e, this.operator = n, this.right = r;
|
|
404
330
|
}
|
|
405
331
|
convertValue(e) {
|
|
406
332
|
if (typeof e == "number")
|
|
407
|
-
return new Uint8Array([
|
|
333
|
+
return new Uint8Array([d.NUMBER, 1, e]);
|
|
408
334
|
if (typeof e == "string") {
|
|
409
335
|
const n = new TextEncoder().encode(e);
|
|
410
336
|
return new Uint8Array([
|
|
411
|
-
|
|
337
|
+
d.STRING,
|
|
412
338
|
n.length,
|
|
413
339
|
...n
|
|
414
340
|
]);
|
|
415
341
|
}
|
|
416
|
-
return e instanceof
|
|
417
|
-
|
|
342
|
+
return e instanceof f ? new Uint8Array([
|
|
343
|
+
d.ELEMENT,
|
|
418
344
|
2,
|
|
419
345
|
e.element_id,
|
|
420
346
|
e.property
|
|
421
347
|
]) : new Uint8Array();
|
|
422
348
|
}
|
|
423
349
|
format() {
|
|
424
|
-
const e =
|
|
425
|
-
this.actions.map((
|
|
350
|
+
const e = v(
|
|
351
|
+
this.actions.map((h) => h.format())
|
|
426
352
|
), n = this.convertValue(this.left), r = this.convertValue(this.right), s = 4 + n.length + r.length + e.length, o = new Uint8Array(s), i = [
|
|
427
353
|
a.CONDITION,
|
|
428
354
|
s - 2,
|
|
@@ -431,74 +357,74 @@ class $t extends u {
|
|
|
431
357
|
return o.set(i, 0), o.set([this.operator], 3), o.set(n, 4), o.set(r, 4 + n.length), o.set(e, 4 + n.length + r.length), o;
|
|
432
358
|
}
|
|
433
359
|
}
|
|
434
|
-
function
|
|
360
|
+
function Ht() {
|
|
435
361
|
return {
|
|
436
362
|
target(t, e) {
|
|
437
|
-
return new
|
|
363
|
+
return new f(t, e);
|
|
438
364
|
},
|
|
439
365
|
increment(t) {
|
|
440
|
-
return new
|
|
366
|
+
return new ut(t);
|
|
441
367
|
},
|
|
442
368
|
decrement(t) {
|
|
443
|
-
return new
|
|
369
|
+
return new ht(t);
|
|
444
370
|
},
|
|
445
371
|
show(t) {
|
|
446
|
-
return new
|
|
372
|
+
return new ft(new f(t, 0));
|
|
447
373
|
},
|
|
448
374
|
hide(t) {
|
|
449
|
-
return new
|
|
375
|
+
return new dt(new f(t, 0));
|
|
450
376
|
},
|
|
451
377
|
set(t, e) {
|
|
452
|
-
return new
|
|
378
|
+
return new lt(t, e);
|
|
453
379
|
},
|
|
454
380
|
broadcast(t) {
|
|
455
|
-
return new
|
|
381
|
+
return new gt(t || new f(0, 0));
|
|
456
382
|
},
|
|
457
383
|
timer(t, e, n) {
|
|
458
|
-
return new
|
|
384
|
+
return new pt(t, e, n);
|
|
459
385
|
},
|
|
460
386
|
stop() {
|
|
461
|
-
return new
|
|
387
|
+
return new wt(new f(0, 0));
|
|
462
388
|
},
|
|
463
389
|
condition(t, e, n, r) {
|
|
464
|
-
return new
|
|
390
|
+
return new mt(t, e, n, r);
|
|
465
391
|
},
|
|
466
392
|
map(t, e, n, r, s, o) {
|
|
467
|
-
return new
|
|
393
|
+
return new yt(t, e, n, r, s, o);
|
|
468
394
|
}
|
|
469
395
|
};
|
|
470
396
|
}
|
|
471
|
-
const { flattenUint8Arrays:
|
|
472
|
-
function
|
|
397
|
+
const { flattenUint8Arrays: At } = x();
|
|
398
|
+
function $t(t) {
|
|
473
399
|
return {
|
|
474
400
|
setButton(e, n) {
|
|
475
|
-
const r =
|
|
401
|
+
const r = At(
|
|
476
402
|
n.map((o) => o.format())
|
|
477
403
|
), s = new Uint8Array(1 + r.length);
|
|
478
404
|
return s.set([e], 0), r.forEach(
|
|
479
405
|
(o, i) => s.set([o], i + 1)
|
|
480
|
-
), new w(
|
|
406
|
+
), new w(u.ACTIONS, t.id, s);
|
|
481
407
|
}
|
|
482
408
|
};
|
|
483
409
|
}
|
|
484
|
-
function
|
|
410
|
+
function Et(t) {
|
|
485
411
|
return new Promise((e, n) => {
|
|
486
412
|
const r = new Image();
|
|
487
413
|
r.onload = () => e(r), r.onerror = n, r.src = t;
|
|
488
414
|
});
|
|
489
415
|
}
|
|
490
|
-
function
|
|
416
|
+
function Ut(t) {
|
|
491
417
|
const e = document.createElement("canvas"), n = e.getContext("2d");
|
|
492
418
|
if (e.width = t.width, e.height = t.height, !n)
|
|
493
419
|
throw new Error("Failed to get 2D context for image data.");
|
|
494
420
|
return n.drawImage(t, 0, 0), n.getImageData(0, 0, t.width, t.height);
|
|
495
421
|
}
|
|
496
|
-
function
|
|
422
|
+
function xt(t) {
|
|
497
423
|
const e = [], n = t.data, r = t.width, s = t.height;
|
|
498
424
|
for (let o = 0; o < s; o++)
|
|
499
425
|
for (let i = 0; i < r; i++) {
|
|
500
|
-
const
|
|
501
|
-
e.push(
|
|
426
|
+
const h = (o * r + i) * 4, g = n[h], y = n[h + 1], p = n[h + 2], N = 0.2126 * g + 0.7152 * y + 0.0722 * p;
|
|
427
|
+
e.push(N < 128 ? 0 : 1);
|
|
502
428
|
}
|
|
503
429
|
return {
|
|
504
430
|
width: r,
|
|
@@ -506,41 +432,41 @@ function Vt(t) {
|
|
|
506
432
|
pixels: e
|
|
507
433
|
};
|
|
508
434
|
}
|
|
509
|
-
function
|
|
435
|
+
function Tt() {
|
|
510
436
|
return {
|
|
511
|
-
createImage:
|
|
512
|
-
getImageData:
|
|
513
|
-
imageDataToPixels:
|
|
437
|
+
createImage: Et,
|
|
438
|
+
getImageData: Ut,
|
|
439
|
+
imageDataToPixels: xt
|
|
514
440
|
};
|
|
515
441
|
}
|
|
516
|
-
const { createImage:
|
|
517
|
-
function
|
|
442
|
+
const { createImage: Ct, getImageData: It, imageDataToPixels: Dt } = Tt(), { pixelsToBytes: Bt } = x();
|
|
443
|
+
function Rt(t) {
|
|
518
444
|
return new Promise((e, n) => {
|
|
519
|
-
|
|
445
|
+
Ct(t).then((r) => It(r)).then((r) => Dt(r)).then((r) => Bt(r.pixels, r.width)).then((r) => e(r)).catch((r) => n(r));
|
|
520
446
|
});
|
|
521
447
|
}
|
|
522
|
-
function
|
|
448
|
+
function Ot() {
|
|
523
449
|
return {
|
|
524
|
-
imageToBytes:
|
|
450
|
+
imageToBytes: Rt
|
|
525
451
|
};
|
|
526
452
|
}
|
|
527
|
-
function
|
|
453
|
+
function St(t, e, n, r, s) {
|
|
528
454
|
return (t - e) / (n - e) * (s - r) + r;
|
|
529
455
|
}
|
|
530
|
-
function
|
|
531
|
-
return { map:
|
|
456
|
+
function Gt() {
|
|
457
|
+
return { map: St };
|
|
532
458
|
}
|
|
533
459
|
export {
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
460
|
+
Ht as useActions,
|
|
461
|
+
x as useBinary,
|
|
462
|
+
$t as useButtons,
|
|
463
|
+
Ot as useConverter,
|
|
464
|
+
kt as useDisplay,
|
|
465
|
+
bt as useGraphics,
|
|
466
|
+
Tt as useImage,
|
|
467
|
+
Pt as useLoader,
|
|
468
|
+
K as useMesh,
|
|
469
|
+
Lt as useStandeeElements,
|
|
470
|
+
Mt as useStandees,
|
|
471
|
+
Gt as useUtils
|
|
546
472
|
};
|
package/dist/objects.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Objects-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Objects-CS29rf_8.cjs");exports.Buffer=e.Buffer;exports.ButtonResult=e.ButtonResult;exports.Standee=e.Standee;
|
package/dist/objects.js
CHANGED
package/dist/types/Objects.d.ts
CHANGED