nsd-ble 0.1.12 → 0.1.13
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/main.cjs +1 -1
- package/dist/main.js +147 -146
- package/dist/types/standee/Standees.d.ts +2 -0
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./Objects-BSn950q-.cjs"),i=require("./enums.cjs"),T=require("./elements.cjs"),{serviceUuid:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./Objects-BSn950q-.cjs"),i=require("./enums.cjs"),T=require("./elements.cjs"),{serviceUuid:H,handshakeCharUuid:k}=u.useBluetoothSettings(),v=new u.libExports.SyncEvent,B=new u.libExports.SyncEvent;function O(){return new Promise((t,e)=>{u.useBluetooth().subscribe(H,k,G).then(()=>t()).catch(n=>e(n))})}function G(t){t.getUint8(i.Data.TYPE)===i.HandshakeType.CONNECT&&v.post(t),t.getUint8(i.Data.TYPE)===i.HandshakeType.DISCONNECT&&B.post(t)}function D(){return{subscribe:O,onConnected:v,onDisconnected:B}}const{onConnected:W}=D(),{onDisconnected:V}=D();function q(){return new Promise((t,e)=>{u.useBluetooth().connect(u.useBluetoothSettings().options).then(()=>Promise.all([D().subscribe(),u.useMessageCharacteristic().subscribe()]).then(()=>{t()})).catch(n=>e(n))})}function b(){return{connect:q,onConnected:W,onDisconnected:V}}const w=[];function j(){let t=Math.floor(Math.random()*256);for(;w.includes(t);)t=Math.floor(Math.random()*256);return t}function z(t){w.push(t),K()}function K(){w.length<=20||w.splice(0,w.length-20)}function Y(){const t=j();return z(t),t}function F(){return{create:Y}}const{serviceUuid:X,messageCharUuid:Z}=u.useBluetoothSettings(),{onMessageDone:J}=u.useMessageCharacteristic(),Q=u.useBluetooth(),I=10,M=15,R=[],E=new Map;let p=!1;J.attach(nt);function tt(t,e,n){const r=F().create();return et(r,t,e,n).forEach(o=>R.push(o)),new Promise(o=>{E.set(r,o),p||x()})}function et(t,e,n,r){if(r==null)return[new Uint8Array([n,t,I,0,2,e,0])];const s=new Uint8Array(2+r.length),o=r.length+2,a=[];s.set([e,o],0),s.set(r,2);for(let c=0;c<o;c+=M){const l=Math.min(M,o-c),d=new Uint8Array(l),y=[n,t,I,c,o];d.set(s.subarray(c,c+l),0),a.push(new Uint8Array([...y,...d]))}return a}function x(){if(p)return;const t=R.shift();if(t==null){p=!1;return}p=!0,Q.writeCharacteristic(X,Z,t).catch(e=>console.log(e)).finally(()=>{p=!1,x()})}function nt(t){E.get(t)?.(),E.delete(t),x()}function A(){return{write:tt}}const{write:S}=A();function rt(t){return{upload:(e,n)=>{const r=new Uint8Array(n.length+1);return r.set([e],0),r.set(n,1),S(i.DataType.UPLOAD,t,r)},clear:()=>S(i.DataType.CLEAR_GRAPHICS,t)}}const{onConnected:st,onDisconnected:ot}=b();st.attach(it);ot.attach(at);const g=[],C=new u.libExports.SyncEvent;function it(t){const e=new Uint8Array(t.buffer,6);for(const n of e)ct(n);C.post(g)}function at(t){const e=t.getUint8(2);ut(e),C.post(g)}function ct(t){g.some(e=>e.id===t)||g.push(new u.Standee(t))}function ut(t){const e=g.findIndex(n=>n.id===t);e!==-1&&g.splice(e,1)}function ht(){return{standees:g,onChange:C}}function lt(t){const e=()=>{let r=Math.floor(Math.random()*256);return n(r)?e():r},n=r=>t.some(s=>s.id===r);return{generate:e}}function ft(t){return{add:r=>(r.id=lt(t.elements).generate(),t.elements.push(r),r),remove:r=>{t.elements=t.elements.filter(s=>s.id!==r)}}}const{write:_}=A();function dt(t){return _(i.DataType.CLEAR_SCREEN,t.id)}function gt(t){let e=new Uint8Array;for(const n of t.elements)n.dirty!==!1&&(n instanceof T.Image&&(e=U(e,yt(n))),n instanceof T.Rectangle&&(e=U(e,pt(n))),n instanceof T.Text&&(e=U(e,wt(n))),n.dirty=!1);return _(i.DataType.ALL,t.id,e)}function U(t,e){const n=new Uint8Array(t.length+e.length);return n.set(t,0),n.set(e,t.length),n}function yt(t){return new Uint8Array([i.DataType.DRAW_IMAGE,7,t.id,t.show?1:0,t.x,t.y,t.width,t.height,t.data])}function pt(t){return new Uint8Array([i.DataType.DRAW_RECTANGLE,9,t.id,t.show?1:0,t.x,t.y,t.width,t.height,t.radius,t.fill?1:0,t.colorBlack?0:1])}function wt(t){const e=new TextEncoder().encode(t.text),n=new Uint8Array(9+e.length);return n.set([i.DataType.DRAW_TEXT,7+e.length,t.id,t.show?1:0,t.x,t.y,t.font,t.colorBlack?0:1,t.center?1:0],0),n.set(e,9),n}function At(){return{clear:dt,draw:gt}}function mt(t,e){const n=Math.ceil(t.length/e),r=Math.ceil(e/8),s=new Uint8Array(r*n);for(let o=0;o<n;o++)for(let a=0;a<r;a++){let c=0;for(let l=0;l<8;l++){const d=a*8+l,y=o*e+d;d<e&&y<t.length&&t[y]&&(c|=1<<7-l)}s[o*r+a]=N(c)}return s}function N(t){return t=(t&240)>>4|(t&15)<<4,t=(t&204)>>2|(t&51)<<2,t=(t&170)>>1|(t&85)<<1,t}function Tt(t){const e=t.reduce((s,o)=>s+o.length,0),n=new Uint8Array(e);let r=0;for(const s of t)n.set(s,r),r+=s.length;return n}function m(){return{pixelsToBytes:mt,bitswap:N,flattenUint8Arrays:Tt}}const{flattenUint8Arrays:P}=m();class f{element_id;property;constructor(e,n){this.element_id=e,this.property=n}}class h{target;constructor(e){this.target=e}format(){return new Uint8Array}}class Ut extends h{format(){return new Uint8Array([i.ActionType.INCREMENT,2,this.target.element_id,this.target.property])}}class Et extends h{format(){return new Uint8Array([i.ActionType.DECREMENT,2,this.target.element_id,this.target.property])}}class Dt extends h{format(){return new Uint8Array([i.ActionType.SHOW,1,this.target.element_id])}}class xt extends h{format(){return new Uint8Array([i.ActionType.HIDE,1,this.target.element_id])}}class Ct extends h{value;constructor(e,n){super(e),this.value=n}format(){const e=this.dataType(),n=this.convertValue(e),r=new Uint8Array(5+n.length),s=[i.ActionType.SET,n.length+3,e,this.target.element_id,this.target.property];return r.set(s,0),r.set(n,5),r}dataType(){return typeof this.value==="string"?i.ActionDataType.STRING:i.ActionDataType.NUMBER}convertValue(e){return e===i.ActionDataType.STRING?new TextEncoder().encode(this.value):e===i.ActionDataType.NUMBER?new Uint8Array([this.value]):new Uint8Array}}class It extends h{format(){return this.target.element_id!==0&&this.target.property!==0?new Uint8Array([i.ActionType.BROADCAST,2,this.target.element_id,this.target.property]):new Uint8Array([i.ActionType.BROADCAST,0])}}class Mt extends h{format(){return new Uint8Array([i.ActionType.BREAK,0])}}let St=class extends h{fromLow;fromHigh;toLow;toHigh;value;constructor(e,n,r,s,o,a){super(a),this.value=e,this.fromLow=n,this.fromHigh=r,this.toLow=s,this.toHigh=o}format(){return new Uint8Array([i.ActionType.MAP,8,this.value.element_id,this.value.property,this.fromLow,this.fromHigh,this.toLow,this.toHigh,this.target.element_id,this.target.property])}};class vt extends h{deciseconds;resetable;onComplete;constructor(e,n,r){super(new f(0,0)),this.deciseconds=e,this.resetable=n,this.onComplete=r}format(){const e=P(this.onComplete.map(s=>s.format())),n=new Uint8Array(4+e.length),r=[i.ActionType.TIMER,e.length+2,this.resetable?1:0,this.deciseconds];return n.set(r,0),e.forEach((s,o)=>n.set([s],o+4)),n}}class Bt extends h{left;operator;right;actions;constructor(e,n,r,s){super(new f(0,0)),this.actions=s,this.left=e,this.operator=n,this.right=r}convertValue(e){if(typeof e=="number")return new Uint8Array([i.ActionDataType.NUMBER,1,e]);if(typeof e=="string"){const n=new TextEncoder().encode(e);return new Uint8Array([i.ActionDataType.STRING,n.length,...n])}return e instanceof f?new Uint8Array([i.ActionDataType.ELEMENT,2,e.element_id,e.property]):new Uint8Array}format(){const e=P(this.actions.map(c=>c.format())),n=this.convertValue(this.left),r=this.convertValue(this.right),s=4+n.length+r.length+e.length,o=new Uint8Array(s),a=[i.ActionType.CONDITION,s-2,n.length+r.length+1];return o.set(a,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}}function bt(){return{target(t,e){return new f(t,e)},increment(t){return new Ut(t)},decrement(t){return new Et(t)},show(t){return new Dt(new f(t,0))},hide(t){return new xt(new f(t,0))},set(t,e){return new Ct(t,e)},broadcast(t){return new It(t||new f(0,0))},timer(t,e,n){return new vt(t,e,n)},stop(){return new Mt(new f(0,0))},condition(t,e,n,r){return new Bt(t,e,n,r)},map(t,e,n,r,s,o){return new St(t,e,n,r,s,o)}}}const{write:Rt}=A(),{flattenUint8Arrays:_t}=m();function Nt(t){return{setButton(e,n){const r=_t(n.map(o=>o.format())),s=new Uint8Array(1+r.length);return s.set([e],0),r.forEach((o,a)=>s.set([o],a+1)),Rt(i.DataType.ACTIONS,t.id,s)}}}function Pt(t){return new Promise((e,n)=>{const r=new Image;r.onload=()=>e(r),r.onerror=n,r.src=t})}function $t(t){const e=document.createElement("canvas"),n=e.getContext("2d");if(e.width=t.width,e.height=t.height,!n)throw new Error("Failed to get 2D context for image data.");return n.drawImage(t,0,0),n.getImageData(0,0,t.width,t.height)}function Lt(t){const e=[],n=t.data,r=t.width,s=t.height;for(let o=0;o<s;o++)for(let a=0;a<r;a++){const c=(o*r+a)*4,l=n[c],d=n[c+1],y=n[c+2],L=.2126*l+.7152*d+.0722*y;e.push(L<128?0:1)}return{width:r,height:s,pixels:e}}function $(){return{createImage:Pt,getImageData:$t,imageDataToPixels:Lt}}const{createImage:Ht,getImageData:kt,imageDataToPixels:Ot}=$(),{pixelsToBytes:Gt}=m();function Wt(t){return new Promise((e,n)=>{Ht(t).then(r=>kt(r)).then(r=>Ot(r)).then(r=>Gt(r.pixels,r.width)).then(r=>e(r)).catch(r=>n(r))})}function Vt(){return{imageToBytes:Wt}}function qt(t,e,n,r,s){return(t-e)/(n-e)*(s-r)+r}function jt(){return{map:qt}}exports.useMessageCharacteristic=u.useMessageCharacteristic;exports.useActions=bt;exports.useBinary=m;exports.useButtons=Nt;exports.useConverter=Vt;exports.useDisplay=At;exports.useImage=$;exports.useMesh=b;exports.useMeshUpload=rt;exports.useMeshWriter=A;exports.useStandeeElements=ft;exports.useStandees=ht;exports.useUtils=jt;
|
package/dist/main.js
CHANGED
|
@@ -1,159 +1,160 @@
|
|
|
1
|
-
import { l as
|
|
2
|
-
import { Data as
|
|
3
|
-
import { Image as
|
|
4
|
-
const { serviceUuid:
|
|
5
|
-
function
|
|
1
|
+
import { l as E, u as T, a as x, b as N, S as V } from "./Objects-CmsxYIVs.js";
|
|
2
|
+
import { Data as S, HandshakeType as R, DataType as l, ActionType as c, ActionDataType as g } from "./enums.js";
|
|
3
|
+
import { Image as W, Rectangle as z, Text as K } from "./elements.js";
|
|
4
|
+
const { serviceUuid: Y, handshakeCharUuid: q } = x(), P = new E.SyncEvent(), $ = new E.SyncEvent();
|
|
5
|
+
function F() {
|
|
6
6
|
return new Promise((t, e) => {
|
|
7
|
-
|
|
7
|
+
T().subscribe(Y, q, X).then(() => t()).catch((n) => e(n));
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
t.getUint8(
|
|
10
|
+
function X(t) {
|
|
11
|
+
t.getUint8(S.TYPE) === R.CONNECT && P.post(t), t.getUint8(S.TYPE) === R.DISCONNECT && $.post(t);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
return { subscribe:
|
|
13
|
+
function C() {
|
|
14
|
+
return { subscribe: F, onConnected: P, onDisconnected: $ };
|
|
15
15
|
}
|
|
16
|
-
const { onConnected:
|
|
17
|
-
function
|
|
16
|
+
const { onConnected: Z } = C(), { onDisconnected: j } = C();
|
|
17
|
+
function J() {
|
|
18
18
|
return new Promise((t, e) => {
|
|
19
|
-
|
|
19
|
+
T().connect(x().options).then(
|
|
20
20
|
() => Promise.all([
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
C().subscribe(),
|
|
22
|
+
N().subscribe()
|
|
23
23
|
]).then(() => {
|
|
24
24
|
t();
|
|
25
25
|
})
|
|
26
26
|
).catch((n) => e(n));
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function Q() {
|
|
30
30
|
return {
|
|
31
|
-
connect:
|
|
32
|
-
onConnected:
|
|
33
|
-
onDisconnected:
|
|
31
|
+
connect: J,
|
|
32
|
+
onConnected: Z,
|
|
33
|
+
onDisconnected: j
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
const
|
|
37
|
-
function
|
|
36
|
+
const m = [];
|
|
37
|
+
function tt() {
|
|
38
38
|
let t = Math.floor(Math.random() * 256);
|
|
39
|
-
for (;
|
|
39
|
+
for (; m.includes(t); ) t = Math.floor(Math.random() * 256);
|
|
40
40
|
return t;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
function et() {
|
|
46
|
-
p.length <= 20 || p.splice(0, p.length - 20);
|
|
42
|
+
function et(t) {
|
|
43
|
+
m.push(t), nt();
|
|
47
44
|
}
|
|
48
45
|
function nt() {
|
|
49
|
-
|
|
50
|
-
return tt(t), t;
|
|
46
|
+
m.length <= 20 || m.splice(0, m.length - 20);
|
|
51
47
|
}
|
|
52
48
|
function rt() {
|
|
49
|
+
const t = tt();
|
|
50
|
+
return et(t), t;
|
|
51
|
+
}
|
|
52
|
+
function st() {
|
|
53
53
|
return {
|
|
54
|
-
create:
|
|
54
|
+
create: rt
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
const { serviceUuid:
|
|
57
|
+
const { serviceUuid: ot, messageCharUuid: it } = x(), { onMessageDone: at } = N(), ct = T(), _ = 10, B = 15, L = [], U = /* @__PURE__ */ new Map();
|
|
58
58
|
let y = !1;
|
|
59
|
-
|
|
60
|
-
function
|
|
61
|
-
const r =
|
|
62
|
-
return
|
|
63
|
-
U.set(r, o), y ||
|
|
59
|
+
at.attach(ft);
|
|
60
|
+
function ut(t, e, n) {
|
|
61
|
+
const r = st().create();
|
|
62
|
+
return ht(r, t, e, n).forEach((o) => L.push(o)), new Promise((o) => {
|
|
63
|
+
U.set(r, o), y || I();
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function ht(t, e, n, r) {
|
|
67
67
|
if (r == null)
|
|
68
|
-
return [new Uint8Array([n, t,
|
|
68
|
+
return [new Uint8Array([n, t, _, 0, 2, e, 0])];
|
|
69
69
|
const s = new Uint8Array(2 + r.length), o = r.length + 2, i = [];
|
|
70
70
|
s.set([e, o], 0), s.set(r, 2);
|
|
71
|
-
for (let a = 0; a < o; a +=
|
|
72
|
-
const h = Math.min(
|
|
73
|
-
d.set(s.subarray(a, a + h), 0), i.push(new Uint8Array([...
|
|
71
|
+
for (let a = 0; a < o; a += B) {
|
|
72
|
+
const h = Math.min(B, o - a), d = new Uint8Array(h), p = [n, t, _, a, o];
|
|
73
|
+
d.set(s.subarray(a, a + h), 0), i.push(new Uint8Array([...p, ...d]));
|
|
74
74
|
}
|
|
75
75
|
return i;
|
|
76
76
|
}
|
|
77
|
-
function
|
|
77
|
+
function I() {
|
|
78
78
|
if (y)
|
|
79
79
|
return;
|
|
80
|
-
const t =
|
|
80
|
+
const t = L.shift();
|
|
81
81
|
if (t == null) {
|
|
82
82
|
y = !1;
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
|
-
y = !0,
|
|
86
|
-
y = !1,
|
|
85
|
+
y = !0, ct.writeCharacteristic(ot, it, t).catch((e) => console.log(e)).finally(() => {
|
|
86
|
+
y = !1, I();
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
|
-
function
|
|
90
|
-
U.get(t)?.(), U.delete(t),
|
|
89
|
+
function ft(t) {
|
|
90
|
+
U.get(t)?.(), U.delete(t), I();
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
return { write:
|
|
92
|
+
function D() {
|
|
93
|
+
return { write: ut };
|
|
94
94
|
}
|
|
95
|
-
const { write:
|
|
96
|
-
function
|
|
95
|
+
const { write: b } = D();
|
|
96
|
+
function jt(t) {
|
|
97
97
|
return {
|
|
98
98
|
upload: (e, n) => {
|
|
99
99
|
const r = new Uint8Array(n.length + 1);
|
|
100
|
-
return r.set([e], 0), r.set(n, 1),
|
|
100
|
+
return r.set([e], 0), r.set(n, 1), b(l.UPLOAD, t, r);
|
|
101
101
|
},
|
|
102
|
-
clear: () =>
|
|
102
|
+
clear: () => b(l.CLEAR_GRAPHICS, t)
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
|
-
const { onConnected:
|
|
106
|
-
ft.attach(dt);
|
|
105
|
+
const { onConnected: lt, onDisconnected: dt } = Q();
|
|
107
106
|
lt.attach(gt);
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
dt.attach(wt);
|
|
108
|
+
const w = [], M = new E.SyncEvent();
|
|
109
|
+
function gt(t) {
|
|
110
110
|
const e = new Uint8Array(t.buffer, 6);
|
|
111
111
|
for (const n of e)
|
|
112
|
-
|
|
112
|
+
pt(n);
|
|
113
|
+
M.post(w);
|
|
113
114
|
}
|
|
114
|
-
function
|
|
115
|
+
function wt(t) {
|
|
115
116
|
const e = t.getUint8(2);
|
|
116
|
-
yt(e);
|
|
117
|
+
yt(e), M.post(w);
|
|
117
118
|
}
|
|
118
|
-
function
|
|
119
|
-
|
|
119
|
+
function pt(t) {
|
|
120
|
+
w.some((e) => e.id === t) || w.push(new V(t));
|
|
120
121
|
}
|
|
121
122
|
function yt(t) {
|
|
122
|
-
const e =
|
|
123
|
-
e !== -1 &&
|
|
123
|
+
const e = w.findIndex((n) => n.id === t);
|
|
124
|
+
e !== -1 && w.splice(e, 1);
|
|
124
125
|
}
|
|
125
|
-
function
|
|
126
|
-
return { standees:
|
|
126
|
+
function Jt() {
|
|
127
|
+
return { standees: w, onChange: M };
|
|
127
128
|
}
|
|
128
|
-
function
|
|
129
|
+
function mt(t) {
|
|
129
130
|
const e = () => {
|
|
130
131
|
let r = Math.floor(Math.random() * 256);
|
|
131
132
|
return n(r) ? e() : r;
|
|
132
133
|
}, n = (r) => t.some((s) => s.id === r);
|
|
133
134
|
return { generate: e };
|
|
134
135
|
}
|
|
135
|
-
function
|
|
136
|
-
return { add: (r) => (r.id =
|
|
136
|
+
function Qt(t) {
|
|
137
|
+
return { add: (r) => (r.id = mt(t.elements).generate(), t.elements.push(r), r), remove: (r) => {
|
|
137
138
|
t.elements = t.elements.filter(
|
|
138
139
|
(s) => s.id !== r
|
|
139
140
|
);
|
|
140
141
|
} };
|
|
141
142
|
}
|
|
142
|
-
const { write:
|
|
143
|
-
function mt(t) {
|
|
144
|
-
return L(l.CLEAR_SCREEN, t.id);
|
|
145
|
-
}
|
|
143
|
+
const { write: H } = D();
|
|
146
144
|
function At(t) {
|
|
145
|
+
return H(l.CLEAR_SCREEN, t.id);
|
|
146
|
+
}
|
|
147
|
+
function Ut(t) {
|
|
147
148
|
let e = new Uint8Array();
|
|
148
149
|
for (const n of t.elements)
|
|
149
|
-
n.dirty !== !1 && (n instanceof
|
|
150
|
-
return
|
|
150
|
+
n.dirty !== !1 && (n instanceof W && (e = A(e, Et(n))), n instanceof z && (e = A(e, Tt(n))), n instanceof K && (e = A(e, xt(n))), n.dirty = !1);
|
|
151
|
+
return H(l.ALL, t.id, e);
|
|
151
152
|
}
|
|
152
153
|
function A(t, e) {
|
|
153
154
|
const n = new Uint8Array(t.length + e.length);
|
|
154
155
|
return n.set(t, 0), n.set(e, t.length), n;
|
|
155
156
|
}
|
|
156
|
-
function
|
|
157
|
+
function Et(t) {
|
|
157
158
|
return new Uint8Array([
|
|
158
159
|
l.DRAW_IMAGE,
|
|
159
160
|
7,
|
|
@@ -166,7 +167,7 @@ function Ut(t) {
|
|
|
166
167
|
t.data
|
|
167
168
|
]);
|
|
168
169
|
}
|
|
169
|
-
function
|
|
170
|
+
function Tt(t) {
|
|
170
171
|
return new Uint8Array([
|
|
171
172
|
l.DRAW_RECTANGLE,
|
|
172
173
|
9,
|
|
@@ -181,7 +182,7 @@ function Et(t) {
|
|
|
181
182
|
t.colorBlack ? 0 : 1
|
|
182
183
|
]);
|
|
183
184
|
}
|
|
184
|
-
function
|
|
185
|
+
function xt(t) {
|
|
185
186
|
const e = new TextEncoder().encode(t.text), n = new Uint8Array(9 + e.length);
|
|
186
187
|
return n.set(
|
|
187
188
|
[
|
|
@@ -198,40 +199,40 @@ function Tt(t) {
|
|
|
198
199
|
0
|
|
199
200
|
), n.set(e, 9), n;
|
|
200
201
|
}
|
|
201
|
-
function
|
|
202
|
-
return { clear:
|
|
202
|
+
function te() {
|
|
203
|
+
return { clear: At, draw: Ut };
|
|
203
204
|
}
|
|
204
|
-
function
|
|
205
|
+
function Ct(t, e) {
|
|
205
206
|
const n = Math.ceil(t.length / e), r = Math.ceil(e / 8), s = new Uint8Array(r * n);
|
|
206
207
|
for (let o = 0; o < n; o++)
|
|
207
208
|
for (let i = 0; i < r; i++) {
|
|
208
209
|
let a = 0;
|
|
209
210
|
for (let h = 0; h < 8; h++) {
|
|
210
|
-
const d = i * 8 + h,
|
|
211
|
-
d < e &&
|
|
211
|
+
const d = i * 8 + h, p = o * e + d;
|
|
212
|
+
d < e && p < t.length && t[p] && (a |= 1 << 7 - h);
|
|
212
213
|
}
|
|
213
|
-
s[o * r + i] =
|
|
214
|
+
s[o * r + i] = k(a);
|
|
214
215
|
}
|
|
215
216
|
return s;
|
|
216
217
|
}
|
|
217
|
-
function
|
|
218
|
+
function k(t) {
|
|
218
219
|
return t = (t & 240) >> 4 | (t & 15) << 4, t = (t & 204) >> 2 | (t & 51) << 2, t = (t & 170) >> 1 | (t & 85) << 1, t;
|
|
219
220
|
}
|
|
220
|
-
function
|
|
221
|
+
function It(t) {
|
|
221
222
|
const e = t.reduce((s, o) => s + o.length, 0), n = new Uint8Array(e);
|
|
222
223
|
let r = 0;
|
|
223
224
|
for (const s of t)
|
|
224
225
|
n.set(s, r), r += s.length;
|
|
225
226
|
return n;
|
|
226
227
|
}
|
|
227
|
-
function
|
|
228
|
+
function v() {
|
|
228
229
|
return {
|
|
229
|
-
pixelsToBytes:
|
|
230
|
-
bitswap:
|
|
231
|
-
flattenUint8Arrays:
|
|
230
|
+
pixelsToBytes: Ct,
|
|
231
|
+
bitswap: k,
|
|
232
|
+
flattenUint8Arrays: It
|
|
232
233
|
};
|
|
233
234
|
}
|
|
234
|
-
const { flattenUint8Arrays:
|
|
235
|
+
const { flattenUint8Arrays: O } = v();
|
|
235
236
|
class f {
|
|
236
237
|
element_id;
|
|
237
238
|
property;
|
|
@@ -248,7 +249,7 @@ class u {
|
|
|
248
249
|
return new Uint8Array();
|
|
249
250
|
}
|
|
250
251
|
}
|
|
251
|
-
class
|
|
252
|
+
class Dt extends u {
|
|
252
253
|
format() {
|
|
253
254
|
return new Uint8Array([
|
|
254
255
|
c.INCREMENT,
|
|
@@ -258,7 +259,7 @@ class It extends u {
|
|
|
258
259
|
]);
|
|
259
260
|
}
|
|
260
261
|
}
|
|
261
|
-
class
|
|
262
|
+
class Mt extends u {
|
|
262
263
|
format() {
|
|
263
264
|
return new Uint8Array([
|
|
264
265
|
c.DECREMENT,
|
|
@@ -268,17 +269,17 @@ class Dt extends u {
|
|
|
268
269
|
]);
|
|
269
270
|
}
|
|
270
271
|
}
|
|
271
|
-
class
|
|
272
|
+
class vt extends u {
|
|
272
273
|
format() {
|
|
273
274
|
return new Uint8Array([c.SHOW, 1, this.target.element_id]);
|
|
274
275
|
}
|
|
275
276
|
}
|
|
276
|
-
class
|
|
277
|
+
class St extends u {
|
|
277
278
|
format() {
|
|
278
279
|
return new Uint8Array([c.HIDE, 1, this.target.element_id]);
|
|
279
280
|
}
|
|
280
281
|
}
|
|
281
|
-
class
|
|
282
|
+
class Rt extends u {
|
|
282
283
|
value;
|
|
283
284
|
constructor(e, n) {
|
|
284
285
|
super(e), this.value = n;
|
|
@@ -300,7 +301,7 @@ class St extends u {
|
|
|
300
301
|
return e === g.STRING ? new TextEncoder().encode(this.value) : e === g.NUMBER ? new Uint8Array([this.value]) : new Uint8Array();
|
|
301
302
|
}
|
|
302
303
|
}
|
|
303
|
-
class
|
|
304
|
+
class _t extends u {
|
|
304
305
|
format() {
|
|
305
306
|
return this.target.element_id !== 0 && this.target.property !== 0 ? new Uint8Array([
|
|
306
307
|
c.BROADCAST,
|
|
@@ -310,7 +311,7 @@ class Rt extends u {
|
|
|
310
311
|
]) : new Uint8Array([c.BROADCAST, 0]);
|
|
311
312
|
}
|
|
312
313
|
}
|
|
313
|
-
class
|
|
314
|
+
class Bt extends u {
|
|
314
315
|
format() {
|
|
315
316
|
return new Uint8Array([c.BREAK, 0]);
|
|
316
317
|
}
|
|
@@ -339,7 +340,7 @@ let bt = class extends u {
|
|
|
339
340
|
]);
|
|
340
341
|
}
|
|
341
342
|
};
|
|
342
|
-
class
|
|
343
|
+
class Nt extends u {
|
|
343
344
|
deciseconds;
|
|
344
345
|
resetable;
|
|
345
346
|
onComplete;
|
|
@@ -347,7 +348,7 @@ class Bt extends u {
|
|
|
347
348
|
super(new f(0, 0)), this.deciseconds = e, this.resetable = n, this.onComplete = r;
|
|
348
349
|
}
|
|
349
350
|
format() {
|
|
350
|
-
const e =
|
|
351
|
+
const e = O(
|
|
351
352
|
this.onComplete.map((s) => s.format())
|
|
352
353
|
), n = new Uint8Array(4 + e.length), r = [
|
|
353
354
|
c.TIMER,
|
|
@@ -360,7 +361,7 @@ class Bt extends u {
|
|
|
360
361
|
), n;
|
|
361
362
|
}
|
|
362
363
|
}
|
|
363
|
-
class
|
|
364
|
+
class Pt extends u {
|
|
364
365
|
left;
|
|
365
366
|
operator;
|
|
366
367
|
right;
|
|
@@ -387,7 +388,7 @@ class Nt extends u {
|
|
|
387
388
|
]) : new Uint8Array();
|
|
388
389
|
}
|
|
389
390
|
format() {
|
|
390
|
-
const e =
|
|
391
|
+
const e = O(
|
|
391
392
|
this.actions.map((a) => a.format())
|
|
392
393
|
), n = this.convertValue(this.left), r = this.convertValue(this.right), s = 4 + n.length + r.length + e.length, o = new Uint8Array(s), i = [
|
|
393
394
|
c.CONDITION,
|
|
@@ -397,74 +398,74 @@ class Nt extends u {
|
|
|
397
398
|
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;
|
|
398
399
|
}
|
|
399
400
|
}
|
|
400
|
-
function
|
|
401
|
+
function ne() {
|
|
401
402
|
return {
|
|
402
403
|
target(t, e) {
|
|
403
404
|
return new f(t, e);
|
|
404
405
|
},
|
|
405
406
|
increment(t) {
|
|
406
|
-
return new
|
|
407
|
+
return new Dt(t);
|
|
407
408
|
},
|
|
408
409
|
decrement(t) {
|
|
409
|
-
return new
|
|
410
|
+
return new Mt(t);
|
|
410
411
|
},
|
|
411
412
|
show(t) {
|
|
412
|
-
return new
|
|
413
|
+
return new vt(new f(t, 0));
|
|
413
414
|
},
|
|
414
415
|
hide(t) {
|
|
415
|
-
return new
|
|
416
|
+
return new St(new f(t, 0));
|
|
416
417
|
},
|
|
417
418
|
set(t, e) {
|
|
418
|
-
return new
|
|
419
|
+
return new Rt(t, e);
|
|
419
420
|
},
|
|
420
421
|
broadcast(t) {
|
|
421
|
-
return new
|
|
422
|
+
return new _t(t || new f(0, 0));
|
|
422
423
|
},
|
|
423
424
|
timer(t, e, n) {
|
|
424
|
-
return new
|
|
425
|
+
return new Nt(t, e, n);
|
|
425
426
|
},
|
|
426
427
|
stop() {
|
|
427
|
-
return new
|
|
428
|
+
return new Bt(new f(0, 0));
|
|
428
429
|
},
|
|
429
430
|
condition(t, e, n, r) {
|
|
430
|
-
return new
|
|
431
|
+
return new Pt(t, e, n, r);
|
|
431
432
|
},
|
|
432
433
|
map(t, e, n, r, s, o) {
|
|
433
434
|
return new bt(t, e, n, r, s, o);
|
|
434
435
|
}
|
|
435
436
|
};
|
|
436
437
|
}
|
|
437
|
-
const { write:
|
|
438
|
-
function
|
|
438
|
+
const { write: $t } = D(), { flattenUint8Arrays: Lt } = v();
|
|
439
|
+
function re(t) {
|
|
439
440
|
return {
|
|
440
441
|
setButton(e, n) {
|
|
441
|
-
const r =
|
|
442
|
+
const r = Lt(
|
|
442
443
|
n.map((o) => o.format())
|
|
443
444
|
), s = new Uint8Array(1 + r.length);
|
|
444
445
|
return s.set([e], 0), r.forEach(
|
|
445
446
|
(o, i) => s.set([o], i + 1)
|
|
446
|
-
),
|
|
447
|
+
), $t(l.ACTIONS, t.id, s);
|
|
447
448
|
}
|
|
448
449
|
};
|
|
449
450
|
}
|
|
450
|
-
function
|
|
451
|
+
function Ht(t) {
|
|
451
452
|
return new Promise((e, n) => {
|
|
452
453
|
const r = new Image();
|
|
453
454
|
r.onload = () => e(r), r.onerror = n, r.src = t;
|
|
454
455
|
});
|
|
455
456
|
}
|
|
456
|
-
function
|
|
457
|
+
function kt(t) {
|
|
457
458
|
const e = document.createElement("canvas"), n = e.getContext("2d");
|
|
458
459
|
if (e.width = t.width, e.height = t.height, !n)
|
|
459
460
|
throw new Error("Failed to get 2D context for image data.");
|
|
460
461
|
return n.drawImage(t, 0, 0), n.getImageData(0, 0, t.width, t.height);
|
|
461
462
|
}
|
|
462
|
-
function
|
|
463
|
+
function Ot(t) {
|
|
463
464
|
const e = [], n = t.data, r = t.width, s = t.height;
|
|
464
465
|
for (let o = 0; o < s; o++)
|
|
465
466
|
for (let i = 0; i < r; i++) {
|
|
466
|
-
const a = (o * r + i) * 4, h = n[a], d = n[a + 1],
|
|
467
|
-
e.push(
|
|
467
|
+
const a = (o * r + i) * 4, h = n[a], d = n[a + 1], p = n[a + 2], G = 0.2126 * h + 0.7152 * d + 0.0722 * p;
|
|
468
|
+
e.push(G < 128 ? 0 : 1);
|
|
468
469
|
}
|
|
469
470
|
return {
|
|
470
471
|
width: r,
|
|
@@ -472,42 +473,42 @@ function kt(t) {
|
|
|
472
473
|
pixels: e
|
|
473
474
|
};
|
|
474
475
|
}
|
|
475
|
-
function
|
|
476
|
+
function Gt() {
|
|
476
477
|
return {
|
|
477
|
-
createImage:
|
|
478
|
-
getImageData:
|
|
479
|
-
imageDataToPixels:
|
|
478
|
+
createImage: Ht,
|
|
479
|
+
getImageData: kt,
|
|
480
|
+
imageDataToPixels: Ot
|
|
480
481
|
};
|
|
481
482
|
}
|
|
482
|
-
const { createImage:
|
|
483
|
-
function
|
|
483
|
+
const { createImage: Vt, getImageData: Wt, imageDataToPixels: zt } = Gt(), { pixelsToBytes: Kt } = v();
|
|
484
|
+
function Yt(t) {
|
|
484
485
|
return new Promise((e, n) => {
|
|
485
|
-
|
|
486
|
+
Vt(t).then((r) => Wt(r)).then((r) => zt(r)).then((r) => Kt(r.pixels, r.width)).then((r) => e(r)).catch((r) => n(r));
|
|
486
487
|
});
|
|
487
488
|
}
|
|
488
|
-
function
|
|
489
|
+
function se() {
|
|
489
490
|
return {
|
|
490
|
-
imageToBytes:
|
|
491
|
+
imageToBytes: Yt
|
|
491
492
|
};
|
|
492
493
|
}
|
|
493
|
-
function
|
|
494
|
+
function qt(t, e, n, r, s) {
|
|
494
495
|
return (t - e) / (n - e) * (s - r) + r;
|
|
495
496
|
}
|
|
496
|
-
function
|
|
497
|
-
return { map:
|
|
497
|
+
function oe() {
|
|
498
|
+
return { map: qt };
|
|
498
499
|
}
|
|
499
500
|
export {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
501
|
+
ne as useActions,
|
|
502
|
+
v as useBinary,
|
|
503
|
+
re as useButtons,
|
|
504
|
+
se as useConverter,
|
|
505
|
+
te as useDisplay,
|
|
506
|
+
Gt as useImage,
|
|
507
|
+
Q as useMesh,
|
|
508
|
+
jt as useMeshUpload,
|
|
509
|
+
D as useMeshWriter,
|
|
510
|
+
N as useMessageCharacteristic,
|
|
511
|
+
Qt as useStandeeElements,
|
|
512
|
+
Jt as useStandees,
|
|
513
|
+
oe as useUtils
|
|
513
514
|
};
|