nsd-ble 0.1.5 → 0.1.7

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.
@@ -0,0 +1,269 @@
1
+ import { SyncEvent } from "ts-events";
2
+
3
+ declare class Action {
4
+ target: Target;
5
+ constructor(target: Target);
6
+ format(): Uint8Array;
7
+ }
8
+
9
+ declare function bitswap(b: number): number;
10
+
11
+ declare class Break extends Action {
12
+ format(): Uint8Array;
13
+ }
14
+
15
+ declare class Broadcast extends Action {
16
+ format(): Uint8Array;
17
+ }
18
+
19
+ export declare class ButtonResult {
20
+ id: number;
21
+ data: string;
22
+ constructor(id: number, data: string);
23
+ }
24
+
25
+ declare function clear(standee: Standee): Promise<void>;
26
+
27
+ declare class Condition extends Action {
28
+ left: Target | number | string;
29
+ operator: number;
30
+ right: Target | number | string;
31
+ actions: Array<Action>;
32
+ constructor(
33
+ left: Target | number | string,
34
+ operator: number,
35
+ right: Target | number | string,
36
+ actions: Array<Action>
37
+ );
38
+ convertValue(value: Target | number | string): Uint8Array;
39
+ format(): Uint8Array;
40
+ }
41
+
42
+ declare function connect(): Promise<void>;
43
+
44
+ declare function createImage(url: string): Promise<HTMLImageElement>;
45
+
46
+ declare class DataType {
47
+ static UPLOAD: number;
48
+ static DRAW_IMAGE: number;
49
+ static DRAW_RECTANGLE: number;
50
+ static BUTTON_PRESS: number;
51
+ static DRAW_TEXT: number;
52
+ static ALL: number;
53
+ static CLEAR_GRAPHICS: number;
54
+ static ACTIONS: number;
55
+ static CLEAR_SCREEN: number;
56
+ static MESSAGE_DONE: number;
57
+ }
58
+
59
+ declare class Decrement extends Action {
60
+ format(): Uint8Array;
61
+ }
62
+
63
+ declare class DisplayElement {
64
+ id: number;
65
+ dirty: boolean;
66
+ _show: boolean;
67
+ _x: number;
68
+ _y: number;
69
+ _colorBlack: boolean;
70
+ constructor(x: number, y: number, show?: boolean, colorBlack?: boolean);
71
+ get x(): number;
72
+ get y(): number;
73
+ set x(x: number);
74
+ set y(y: number);
75
+ set show(show: boolean);
76
+ get show(): boolean;
77
+ set colorBlack(colorBlack: boolean);
78
+ get colorBlack(): boolean;
79
+ }
80
+
81
+ declare function draw(standee: Standee): Promise<void>;
82
+
83
+ declare function flattenUint8Arrays(
84
+ array: Uint8Array[]
85
+ ): Uint8Array<ArrayBuffer>;
86
+
87
+ declare function getImageData(image: HTMLImageElement): ImageData;
88
+
89
+ declare class Hide extends Action {
90
+ format(): Uint8Array;
91
+ }
92
+
93
+ declare function imageDataToPixels(data: ImageData): ImagePixels;
94
+
95
+ declare function imageToBytes(image_url: string): Promise<Uint8Array>;
96
+
97
+ declare class Increment extends Action {
98
+ format(): Uint8Array;
99
+ }
100
+
101
+ declare function map(
102
+ value: number,
103
+ start1: number,
104
+ stop1: number,
105
+ start2: number,
106
+ stop2: number
107
+ ): number;
108
+
109
+ declare class Map_2 extends Action {
110
+ fromLow: number;
111
+ fromHigh: number;
112
+ toLow: number;
113
+ toHigh: number;
114
+ value: Target;
115
+ constructor(
116
+ value: Target,
117
+ fromLow: number,
118
+ fromHigh: number,
119
+ toLow: number,
120
+ toHigh: number,
121
+ target: Target
122
+ );
123
+ format(): Uint8Array;
124
+ }
125
+
126
+ declare function pixelsToBytes(
127
+ pixels: number[],
128
+ width: number
129
+ ): Uint8Array<ArrayBuffer>;
130
+
131
+ declare class Set_2 extends Action {
132
+ value: number | string;
133
+ constructor(target: Target, value: number | string);
134
+ format(): Uint8Array;
135
+ dataType(): number;
136
+ convertValue(type: number): Uint8Array;
137
+ }
138
+
139
+ declare class Show extends Action {
140
+ format(): Uint8Array;
141
+ }
142
+
143
+ export declare class Standee {
144
+ id: number;
145
+ elements: Array<DisplayElement>;
146
+ onPlus: SyncEvent<void>;
147
+ onMin: SyncEvent<void>;
148
+ constructor(id: number);
149
+ name(): string;
150
+ }
151
+
152
+ declare function subscribe(): Promise<void>;
153
+
154
+ declare class Target {
155
+ element_id: number;
156
+ property: number;
157
+ constructor(element_id: number, property: number);
158
+ }
159
+
160
+ declare class Timer extends Action {
161
+ deciseconds: number;
162
+ resetable: boolean;
163
+ onComplete: Array<Action>;
164
+ constructor(
165
+ deciseconds: number,
166
+ resetable: boolean,
167
+ onComplete: Array<Action>
168
+ );
169
+ format(): Uint8Array;
170
+ }
171
+
172
+ export declare function useActions(): {
173
+ target(element_id: number, property: number): Target;
174
+ increment(target: Target): Increment;
175
+ decrement(target: Target): Decrement;
176
+ show(element_id: number): Show;
177
+ hide(element_id: number): Hide;
178
+ set(target: Target, value: number | string): Set_2;
179
+ broadcast(target?: Target): Broadcast;
180
+ timer(
181
+ milliseconds: number,
182
+ resetable: boolean,
183
+ onComplete: Array<Action>
184
+ ): Timer;
185
+ stop(): Break;
186
+ condition(
187
+ left: Target | number | string,
188
+ operator: number,
189
+ right: Target | number | string,
190
+ actions: Array<Action>
191
+ ): Condition;
192
+ map(
193
+ value: Target,
194
+ fromLow: number,
195
+ fromHigh: number,
196
+ toLow: number,
197
+ toHigh: number,
198
+ target: Target
199
+ ): Map_2;
200
+ };
201
+
202
+ export declare function useBinary(): {
203
+ pixelsToBytes: typeof pixelsToBytes;
204
+ bitswap: typeof bitswap;
205
+ flattenUint8Arrays: typeof flattenUint8Arrays;
206
+ };
207
+
208
+ export declare function useButtons(standee: Standee): {
209
+ setButton(button: number, actions: Array<Action>): Promise<void>;
210
+ };
211
+
212
+ export declare function useConverter(): {
213
+ imageToBytes: typeof imageToBytes;
214
+ };
215
+
216
+ export declare function useDisplay(): {
217
+ clear: typeof clear;
218
+ draw: typeof draw;
219
+ };
220
+
221
+ export declare function useImage(): {
222
+ createImage: typeof createImage;
223
+ getImageData: typeof getImageData;
224
+ imageDataToPixels: typeof imageDataToPixels;
225
+ };
226
+
227
+ export declare function useMesh(): {
228
+ connect: typeof connect;
229
+ onConnected: SyncEvent<DataView<ArrayBufferLike>>;
230
+ onDisconnected: SyncEvent<DataView<ArrayBufferLike>>;
231
+ };
232
+
233
+ export declare function useMeshUpload(target: number): {
234
+ upload: (id: number, image: Uint8Array) => Promise<void>;
235
+ clear: () => Promise<void>;
236
+ };
237
+
238
+ export declare function useMeshWriter(): {
239
+ write: typeof write;
240
+ };
241
+
242
+ export declare function useMessageCharacteristic(): {
243
+ subscribe: typeof subscribe;
244
+ onPlus: SyncEvent<ButtonResult>;
245
+ onMin: SyncEvent<ButtonResult>;
246
+ onEither: SyncEvent<ButtonResult>;
247
+ onMessageDone: SyncEvent<number>;
248
+ };
249
+
250
+ export declare function useStandeeElements(standee: Standee): {
251
+ add: <T>(element: DisplayElement) => T;
252
+ remove: (id: number) => void;
253
+ };
254
+
255
+ export declare function useStandees(): {
256
+ standees: Standee[];
257
+ };
258
+
259
+ export declare function useUtils(): {
260
+ map: typeof map;
261
+ };
262
+
263
+ declare function write(
264
+ type: DataType,
265
+ id: number,
266
+ data?: Uint8Array
267
+ ): Promise<void>;
268
+
269
+ export {};
package/dist/nsd-ble.js CHANGED
@@ -1447,6 +1447,7 @@ export {
1447
1447
  fe as useMesh,
1448
1448
  ln as useMeshUpload,
1449
1449
  rt as useMeshWriter,
1450
+ Pt as useMessageCharacteristic,
1450
1451
  vn as useStandeeElements,
1451
1452
  fn as useStandees,
1452
1453
  wn as useUtils
@@ -1 +1 @@
1
- (function(g,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(g=typeof globalThis<"u"?globalThis:g||self,w(g["nsd-ble"]={}))})(this,(function(g){"use strict";var w={},L={},at;function Q(){if(at)return L;at=1,Object.defineProperty(L,"__esModule",{value:!0}),L.BaseEvent=void 0;var t=(function(){function e(){}return e.prototype.attach=function(n,r){return this._attach(n,r,!1)},e.prototype.once=function(n,r){return this._attach(n,r,!0)},e.prototype._attach=function(n,r,f){var l=this,u,i,a,h;if(typeof n=="function")i=n,h=function(){return l.detach(i)};else if(!r&&typeof n.post=="function")a=n,h=function(){return l.detach(a)};else{if(typeof n!="object"||n===void 0)throw new Error("Expect a function or object as first argument");if(typeof r!="function")throw new Error("Expect a function as second argument");u=n,i=r,h=function(){return l.detach(u,i)}}return this._listeners?this._listeners=this._listeners.slice():this._listeners=[],this._listeners.push({deleted:!1,boundTo:u,handler:i,event:a,once:f}),h},e.prototype.detach=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];this._detach.apply(this,n)},e.prototype._detach=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];if(!(!this._listeners||this._listeners.length===0)){var f,l,u;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){return(typeof l>"u"||i.handler===l)&&(typeof u>"u"||i.event===u)&&(typeof f>"u"||i.boundTo===f)?(i.deleted=!0,!1):!0}),this._listeners.length===0&&delete this._listeners}},e.prototype.post=function(n){throw new Error("abstract")},e.prototype.listenerCount=function(){return this._listeners?this._listeners.length:0},e.prototype._call=function(n,r){this._listeners&&(n.deleted||(n.once&&(n.deleted=!0,this._listeners=this._listeners.filter(function(f){return f!==n}),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)))},e})();return L.BaseEvent=t,L}var A={},ut;function I(){if(ut)return A;ut=1;var t=A&&A.__extends||(function(){var l=function(u,i){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,h){a.__proto__=h}||function(a,h){for(var o in h)h.hasOwnProperty(o)&&(a[o]=h[o])},l(u,i)};return function(u,i){l(u,i);function a(){this.constructor=u}u.prototype=i===null?Object.create(i):(a.prototype=i.prototype,new a)}})();Object.defineProperty(A,"__esModule",{value:!0}),A.ErrorSyncEvent=A.VoidSyncEvent=A.SyncEvent=void 0;var e=Q(),n=(function(l){t(u,l);function u(){var i=l!==null&&l.apply(this,arguments)||this;return i._recursion=0,i}return Object.defineProperty(u.prototype,"evtListenersChanged",{get:function(){return this._listenersChanged||(this._listenersChanged=new r),this._listenersChanged},enumerable:!1,configurable:!0}),u.prototype.post=function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];if(!(!this._listeners||this._listeners.length===0)){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)throw new Error("event fired recursively");for(var h=this._listeners,o=0;o<h.length;++o){var s=h[o];this._call(s,i)}this._recursion--}},u.prototype._attach=function(i,a,h){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);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},u.prototype._detach=function(){for(var i,a,h,o,s=[],c=0;c<arguments.length;c++)s[c]=arguments[c];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);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},u.MAX_RECURSION_DEPTH=10,u})(e.BaseEvent);A.SyncEvent=n;var r=(function(l){t(u,l);function u(){return l!==null&&l.apply(this,arguments)||this}return u.prototype.post=function(){l.prototype.post.call(this,void 0)},u})(n);A.VoidSyncEvent=r;var f=(function(l){t(u,l);function u(){return l!==null&&l.apply(this,arguments)||this}return u.prototype.post=function(i){if(this.listenerCount()===0)throw new Error("error event posted while no listeners attached. Error: "+i.message);l.prototype.post.call(this,i)},u})(n);return A.ErrorSyncEvent=f,A}var m={},V={},ct;function Y(){if(ct)return V;ct=1,Object.defineProperty(V,"__esModule",{value:!0});var t=I(),e=(function(){function n(){this.evtFilled=new t.SyncEvent,this.evtDrained=new t.SyncEvent,this._queue=[],this._flushing=!1}return n.global=function(){return n._instance||n.resetGlobal(),n._instance},n.resetGlobal=function(){n._instance=new n},n.prototype.empty=function(){return this._queue.length===0},n.prototype.add=function(r){this._queue.push(r),this._queue.length===1&&!this._flushing&&this.evtFilled.post(this)},n.prototype.flushOnce=function(){var r=this._queue.length===0,f=this._flushing;this._flushing=!0;try{var l=this._queue;this._queue=[];for(var u=0;u<l.length;++u)l[u]()}finally{this._flushing=f,!r&&!f&&this._queue.length===0&&this.evtDrained.post(this)}},n.prototype.flush=function(r){r===void 0&&(r=10);var f=this._queue.length===0,l=this._flushing;this._flushing=!0;try{for(var u=0;this._queue.length>0;){if(typeof r=="number"&&u>=r)throw this._queue=[],new Error("unable to flush the queue due to recursively added event. Clearing queue now");this.flushOnce(),++u}}finally{this._flushing=l,!f&&!l&&this._queue.length===0&&this.evtDrained.post(this)}},n})();return V.default=e,V}var ht;function lt(){if(ht)return m;ht=1;var t=m&&m.__extends||(function(){var i=function(a,h){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,s){o.__proto__=s}||function(o,s){for(var c in s)s.hasOwnProperty(c)&&(o[c]=s[c])},i(a,h)};return function(a,h){i(a,h);function o(){this.constructor=a}a.prototype=h===null?Object.create(h):(o.prototype=h.prototype,new o)}})();Object.defineProperty(m,"__esModule",{value:!0}),m.ErrorQueuedEvent=m.VoidQueuedEvent=m.QueuedEvent=void 0;var e=Q(),n=Y(),r=I(),f=(function(i){t(a,i);function a(h){h===void 0&&(h={});var o=i.call(this)||this;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}return Object.defineProperty(a.prototype,"evtListenersChanged",{get:function(){return this._listenersChanged||(this._listenersChanged=new r.VoidSyncEvent),this._listenersChanged},enumerable:!1,configurable:!0}),a.prototype.post=function(){for(var h=this,o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];if(!(!this._listeners||this._listeners.length===0)){var c=this._queue?this._queue:n.default.global();if(this._condensed){if(this._queuedData=o,this._queuedListeners=this._listeners,this._queued)return;this._queued=!0,c.add(function(){h._queued=!1;for(var v=h._queuedData,y=h._queuedListeners,p=0;p<y.length;++p){var _=y[p];h._call(_,v)}})}else{var d=this._listeners;c.add(function(){for(var v=0;v<d.length;++v){var y=d[v];h._call(y,o)}})}}},a.prototype._attach=function(h,o,s){var c,d,v,y,p=(d=(c=this._listeners)===null||c===void 0?void 0:c.length)!==null&&d!==void 0?d:0,_=i.prototype._attach.call(this,h,o,s);return this.evtListenersChanged&&p!==((y=(v=this._listeners)===null||v===void 0?void 0:v.length)!==null&&y!==void 0?y:0)&&this.evtListenersChanged.post(),_},a.prototype._detach=function(){for(var h,o,s,c,d=[],v=0;v<arguments.length;v++)d[v]=arguments[v];var y=(o=(h=this._listeners)===null||h===void 0?void 0:h.length)!==null&&o!==void 0?o:0,p=i.prototype._detach.apply(this,d);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(),p},a})(e.BaseEvent);m.QueuedEvent=f;var l=(function(i){t(a,i);function a(){return i!==null&&i.apply(this,arguments)||this}return a.prototype.post=function(){i.prototype.post.call(this,void 0)},a})(f);m.VoidQueuedEvent=l;var u=(function(i){t(a,i);function a(){return i!==null&&i.apply(this,arguments)||this}return a.prototype.post=function(h){if(!this._listeners||this._listeners.length===0)throw new Error("error event posted while no listeners attached. Error: "+h.message);i.prototype.post.call(this,h)},a})(f);return m.ErrorQueuedEvent=u,m}var C={},ft;function dt(){if(ft)return C;ft=1;var t=C&&C.__extends||(function(){var u=function(i,a){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,o){h.__proto__=o}||function(h,o){for(var s in o)o.hasOwnProperty(s)&&(h[s]=o[s])},u(i,a)};return function(i,a){u(i,a);function h(){this.constructor=i}i.prototype=a===null?Object.create(a):(h.prototype=a.prototype,new h)}})();Object.defineProperty(C,"__esModule",{value:!0}),C.ErrorAsyncEvent=C.VoidAsyncEvent=C.AsyncEvent=void 0;var e=Q(),n=I(),r=(function(u){t(i,u);function i(a){a===void 0&&(a={});var h=u.call(this)||this;return h._queued=!1,h.options=a,typeof a.condensed=="boolean"?h._condensed=a.condensed:h._condensed=!1,h}return Object.defineProperty(i.prototype,"evtListenersChanged",{get:function(){return this._listenersChanged||(this._listenersChanged=new n.VoidSyncEvent),this._listenersChanged},enumerable:!1,configurable:!0}),i.defaultScheduler=function(a){typeof window<"u"?setTimeout(a,0):setImmediate(a)},i.setScheduler=function(a){i._scheduler=a},i.prototype.post=function(){for(var a=this,h=[],o=0;o<arguments.length;o++)h[o]=arguments[o];if(!(!this._listeners||this._listeners.length===0))if(this._condensed){if(this._queuedData=h,this._queuedListeners=this._listeners,this._queued)return;this._queued=!0,i._scheduler(function(){a._queued=!1;for(var c=a._queuedData,d=a._queuedListeners,v=0;v<d.length;++v){var y=d[v];a._call(y,c)}})}else{var s=this._listeners;i._scheduler(function(){for(var c=0;c<s.length;++c){var d=s[c];a._call(d,h)}})}},i.prototype._call=function(a,h){a.event&&a.event instanceof i?a.event._postDirect(h):u.prototype._call.call(this,a,h)},i.prototype._postDirect=function(a){if(!(!this._listeners||this._listeners.length===0))for(var h=this._listeners,o=0;o<h.length;++o){var s=h[o];this._call(s,a)}},i.prototype._attach=function(a,h,o){var s,c,d,v,y=(c=(s=this._listeners)===null||s===void 0?void 0:s.length)!==null&&c!==void 0?c:0,p=u.prototype._attach.call(this,a,h,o);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(),p},i.prototype._detach=function(){for(var a,h,o,s,c=[],d=0;d<arguments.length;d++)c[d]=arguments[d];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);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},i._scheduler=i.defaultScheduler,i})(e.BaseEvent);C.AsyncEvent=r;var f=(function(u){t(i,u);function i(){return u!==null&&u.apply(this,arguments)||this}return i.prototype.post=function(){u.prototype.post.call(this,void 0)},i})(r);C.VoidAsyncEvent=f;var l=(function(u){t(i,u);function i(){return u!==null&&u.apply(this,arguments)||this}return i.prototype.post=function(a){if(this.listenerCount()===0)throw new Error("error event posted while no listeners attached. Error: "+a.message);u.prototype.post.call(this,a)},i})(r);return C.ErrorAsyncEvent=l,C}var M={},R={},vt;function Ht(){if(vt)return R;vt=1,Object.defineProperty(R,"__esModule",{value:!0}),R.shallowEquals=void 0;function t(e,n){if(e===n)return!0;if(typeof e!=typeof n)return!1;switch(typeof e){case"boolean":case"number":case"string":case"function":case"symbol":case"undefined":return!1;case"object":if(e===null||n===null)return!1;if(Array.isArray(e)||Array.isArray(n)){if(!Array.isArray(e)||!Array.isArray(n)||e.length!==n.length)return!1;for(var r=0;r<e.length;++r)if(e[r]!==n[r])return!1;return!0}var f=[],l=[];for(var u in e)e.hasOwnProperty(u)&&f.push(u);for(var i in n)n.hasOwnProperty(i)&&l.push(i);if(f.sort(),l.sort(),f.join(",")!==l.join(","))return!1;for(var r=0;r<f.length;++r)if(e[f[r]]!==n[f[r]])return!1;return!0;default:return!1}}return R.shallowEquals=t,R}var yt;function kt(){return yt||(yt=1,(function(t){var e=M&&M.__extends||(function(){var o=function(s,c){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,v){d.__proto__=v}||function(d,v){for(var y in v)v.hasOwnProperty(y)&&(d[y]=v[y])},o(s,c)};return function(s,c){o(s,c);function d(){this.constructor=s}s.prototype=c===null?Object.create(c):(d.prototype=c.prototype,new d)}})();Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorAnyEvent=t.VoidAnyEvent=t.AnyEvent=t.EventType=void 0;var n=Ht(),r=I(),f=dt(),l=lt(),u;(function(o){o[o.Sync=0]="Sync",o[o.Async=1]="Async",o[o.Queued=2]="Queued"})(u=t.EventType||(t.EventType={}));var i=(function(){function o(s){this._events=[],s&&s.monitorAttach&&(this.evtFirstAttached=new a,this.evtLastDetached=new a)}return Object.defineProperty(o.prototype,"evtListenersChanged",{get:function(){return this._listenersChanged||(this._listenersChanged=new r.VoidSyncEvent),this._listenersChanged},enumerable:!1,configurable:!0}),o.prototype.attach=function(){for(var s=[],c=0;c<arguments.length;c++)s[c]=arguments[c];var d=u.Sync;s.length>0&&typeof s[0]=="number"&&(d=s.shift());var v=this,y,p,_;return typeof s[0]=="function"||s[0]&&typeof s[0]=="object"&&typeof s[0].post=="function"?(typeof s[0]=="function"?y=s[0]:_=s[0],p=s[1]):(v=s[0],y=s[1],p=s[2]),this._attach(d,v,y,_,p,!1)},o.prototype.once=function(){for(var s=[],c=0;c<arguments.length;c++)s[c]=arguments[c];var d=u.Sync;s.length>0&&typeof s[0]=="number"&&(d=s.shift());var v=this,y,p,_;return typeof s[0]=="function"||s[0]&&typeof s[0]=="object"&&typeof s[0].post=="function"?(typeof s[0]=="function"?y=s[0]:_=s[0],p=s[1]):(v=s[0],y=s[1],p=s[2]),this._attach(d,v,y,_,p,!0)},o.prototype._attach=function(s,c,d,v,y,p){var _=this,jt=this.evtFirstAttached?this.listenerCount():0,E;switch(s){case u.Sync:{for(var st=0,xt=this._events;st<xt.length;st++){var D=xt[st];D instanceof r.SyncEvent&&(E=D)}E||(E=new r.SyncEvent,this._events.push(E))}break;case u.Async:{for(var it=0,Qt=this._events;it<Qt.length;it++){var D=Qt[it];D instanceof f.AsyncEvent&&n.shallowEquals(D.options,y)&&(E=D)}E||(E=new f.AsyncEvent(y),this._events.push(E))}break;case u.Queued:{for(var ot=0,Vt=this._events;ot<Vt.length;ot++){var D=Vt[ot];D instanceof l.QueuedEvent&&n.shallowEquals(D.options,y)&&(E=D)}E||(E=new l.QueuedEvent(y),this._events.push(E))}break;default:throw new Error("unknown EventType")}var x;return p?v?x=E.once(v):x=E.once(c,d):v?x=E.attach(v):x=E.attach(c,d),this.evtFirstAttached&&jt===0&&this.evtFirstAttached.post(),this.evtListenersChanged&&jt!==this.listenerCount()&&this.evtListenersChanged.post(),function(){var $t=_.evtLastDetached?_.listenerCount():0;x(),_.evtLastDetached&&$t>0&&_.listenerCount()===0&&_.evtLastDetached.post(),_.evtListenersChanged&&$t!==_.listenerCount()&&_.evtListenersChanged.post()}},o.prototype.attachSync=function(){for(var s=[],c=0;c<arguments.length;c++)s[c]=arguments[c];return s.unshift(u.Sync),this.attach.apply(this,s)},o.prototype.onceSync=function(){for(var s=[],c=0;c<arguments.length;c++)s[c]=arguments[c];return s.unshift(u.Sync),this.once.apply(this,s)},o.prototype.attachAsync=function(){for(var s=[],c=0;c<arguments.length;c++)s[c]=arguments[c];return s.unshift(u.Async),this.attach.apply(this,s)},o.prototype.onceAsync=function(){for(var s=[],c=0;c<arguments.length;c++)s[c]=arguments[c];return s.unshift(u.Async),this.once.apply(this,s)},o.prototype.attachQueued=function(){for(var s=[],c=0;c<arguments.length;c++)s[c]=arguments[c];return s.unshift(u.Queued),this.attach.apply(this,s)},o.prototype.onceQueued=function(){for(var s=[],c=0;c<arguments.length;c++)s[c]=arguments[c];return s.unshift(u.Queued),this.once.apply(this,s)},o.prototype.detach=function(){for(var s=[],c=0;c<arguments.length;c++)s[c]=arguments[c];for(var d=this.listenerCount(),v=0;v<this._events.length;++v)this._events[v].detach.apply(this._events[v],s);this.evtListenersChanged&&d!==this.listenerCount()&&this.evtListenersChanged.post(),this.evtLastDetached&&d>0&&this.listenerCount()===0&&this.evtLastDetached.post()},o.prototype.post=function(s){for(var c=[],d=0;d<this._events.length;++d)c.push(this._events[d]);for(var d=0;d<c.length;++d)c[d].post(s)},o.prototype.listenerCount=function(){for(var s=0,c=0;c<this._events.length;++c)s+=this._events[c].listenerCount();return s},o})();t.AnyEvent=i;var a=(function(o){e(s,o);function s(){return o!==null&&o.apply(this,arguments)||this}return s.prototype.post=function(){o.prototype.post.call(this,void 0)},s})(i);t.VoidAnyEvent=a;var h=(function(o){e(s,o);function s(){return o!==null&&o.apply(this,arguments)||this}return s.prototype.post=function(c){if(this.listenerCount()===0)throw new Error("error event posted while no listeners attached. Error: "+c.message);o.prototype.post.call(this,c)},s})(i);t.ErrorAnyEvent=h})(M)),M}var gt;function Gt(){return gt||(gt=1,(function(t){var e=w&&w.__createBinding||(Object.create?(function(a,h,o,s){s===void 0&&(s=o),Object.defineProperty(a,s,{enumerable:!0,get:function(){return h[o]}})}):(function(a,h,o,s){s===void 0&&(s=o),a[s]=h[o]})),n=w&&w.__exportStar||function(a,h){for(var o in a)o!=="default"&&!h.hasOwnProperty(o)&&e(h,a,o)};Object.defineProperty(t,"__esModule",{value:!0}),t.flush=t.flushOnce=t.queue=void 0,n(Q(),t),n(I(),t),n(lt(),t),n(dt(),t),n(kt(),t);var r=Y(),f=Y();Object.defineProperty(t,"EventQueue",{enumerable:!0,get:function(){return f.default}});function l(){return r.default.global()}t.queue=l;function u(){r.default.global().flushOnce()}t.flushOnce=u;function i(a){a===void 0&&(a=10),r.default.global().flush(a)}t.flush=i})(w)),w}var U=Gt();class pt{id;elements=[];onPlus=new U.SyncEvent;onMin=new U.SyncEvent;constructor(e){this.id=e}name(){return this.id.toString(16).padStart(2,"0")}}let K=!1,$=[],H,_t,k=new Map;async function Wt(t){try{if(H=await navigator.bluetooth.requestDevice(t),H.gatt===void 0)throw new Error("Device does not support GATT");_t=await H.gatt.connect(),H.addEventListener("gattserverdisconnected",Ft),K=!0}catch(e){throw e}}function Ft(){k.clear(),K=!1,$.forEach(t=>t())}function Xt(t){$.push(t)}function Yt(t){$=$.filter(e=>e!==t)}async function z(t,e){if(k.has(e)){const f=k.get(e);if(f===void 0)throw new Error("Characteristic not found");return f}const r=await(await _t.getPrimaryService(t)).getCharacteristic(e);return k.set(e,r),r}async function Kt(t,e){return await(await z(t,e)).readValue()}async function zt(t,e,n){const r=new DataView(new ArrayBuffer(n.length));r.setUint8(0,n[0]),await(await z(t,e)).writeValue(r)}async function Zt(t,e,n){const r=await z(t,e);r.addEventListener("characteristicvaluechanged",f=>{let l=f.target.value;l===void 0&&(l=new DataView(new ArrayBuffer(0))),n(l)}),await r.startNotifications()}function G(){return{connected:K,connect:Wt,readCharacteristic:Kt,writeCharacteristic:zt,subscribe:Zt,setDisconnectCallback:Xt,removeDisconnectCallback:Yt}}class Et{static CONNECT=0;static DISCONNECT=1}class b{static UPLOAD=0;static DRAW_IMAGE=1;static DRAW_RECTANGLE=2;static BUTTON_PRESS=3;static DRAW_TEXT=4;static ALL=5;static CLEAR_GRAPHICS=6;static ACTIONS=7;static CLEAR_SCREEN=8;static MESSAGE_DONE=9}class q{static ID=0;static CACHE=1;static TTL=2;static POSITION=3;static DATA_SIZE=4;static TYPE=5;static DATA=6}class Z{static MINUS=0;static PLUS=1;static EITHER=2}class S{static INCREMENT=0;static DECREMENT=1;static SHOW=2;static HIDE=3;static SET=4;static BROADCAST=5;static TIMER=6;static CONDITION=7;static BREAK=8;static MAP=9}class P{static STRING=0;static NUMBER=1;static ELEMENT=2}const wt="19b10000-e8f2-537e-4f6c-d104768a1214",Jt="6b061bdc-9bc1-4952-a96f-c6ed551b2c3e",te="998ff920-81af-42a9-a915-f88025f9647d",ee={filters:[{namePrefix:"BLE-STANDEE"}],optionalServices:[wt]};function W(){return{serviceUuid:wt,messageCharUuid:Jt,handshakeCharUuid:te,options:ee}}class At{id;data;constructor(e,n){this.id=e,this.data=n}}const{serviceUuid:ne,messageCharUuid:re}=W(),mt=new U.SyncEvent,Ct=new U.SyncEvent,St=new U.SyncEvent,bt=new U.SyncEvent;function se(){return new Promise((t,e)=>{G().subscribe(ne,re,ie).then(()=>t()).catch(n=>e(n))})}function ie(t){t!==void 0&&(t.getUint8(q.TYPE)===b.BUTTON_PRESS&&oe(t),t.getUint8(q.TYPE)===b.MESSAGE_DONE&&bt.post(t.getUint8(q.DATA)))}function oe(t){const e=t.getUint8(q.DATA),n=new At(t.getUint8(q.ID),ae(t));e===Z.MINUS&&Ct.post(n),e===Z.PLUS&&mt.post(n),e===Z.EITHER&&St.post(n)}function ae(t){const e=t.buffer,n=7,r=t.byteLength-7;return Array.from(new Uint8Array(e,n,r)).map(f=>String.fromCharCode(f)).join("").replace(/\0/g,"").trim()}function Tt(){return{subscribe:se,onPlus:mt,onMin:Ct,onEither:St,onMessageDone:bt}}const{serviceUuid:ue,handshakeCharUuid:ce}=W(),Dt=new U.SyncEvent,Ut=new U.SyncEvent;function he(){return new Promise((t,e)=>{G().subscribe(ue,ce,le).then(()=>t()).catch(n=>e(n))})}function le(t){t.getUint8(q.TYPE)===Et.CONNECT&&Dt.post(t),t.getUint8(q.TYPE)===Et.DISCONNECT&&Ut.post(t)}function J(){return{subscribe:he,onConnected:Dt,onDisconnected:Ut}}const{onConnected:fe}=J(),{onDisconnected:de}=J();function ve(){return new Promise((t,e)=>{G().connect(W().options).then(()=>Promise.all([J().subscribe(),Tt().subscribe()]).then(()=>{t()})).catch(n=>e(n))})}function Ot(){return{connect:ve,onConnected:fe,onDisconnected:de}}const B=[];function ye(){let t=Math.floor(Math.random()*256);for(;B.includes(t);)t=Math.floor(Math.random()*256);return t}function ge(t){B.push(t),pe()}function pe(){B.length<=20||B.splice(0,B.length-20)}function _e(){const t=ye();return ge(t),t}function Ee(){return{create:_e}}const{serviceUuid:we,messageCharUuid:Ae}=W(),{onMessageDone:me}=Tt(),Ce=G(),qt=10,Pt=15,Lt=[],tt=new Map;let N=!1;me.attach(Te);function Se(t,e,n){const r=Ee().create();return be(r,t,e,n).forEach(l=>Lt.push(l)),new Promise(l=>{tt.set(r,l),N||et()})}function be(t,e,n,r){if(r==null)return[new Uint8Array([n,t,qt,0,2,e,0])];const f=new Uint8Array(2+r.length),l=r.length+2,u=[];f.set([e,l],0),f.set(r,2);for(let i=0;i<l;i+=Pt){const a=Math.min(Pt,l-i),h=new Uint8Array(a),o=[n,t,qt,i,l];h.set(f.subarray(i,i+a),0),u.push(new Uint8Array([...o,...h]))}return u}function et(){if(N)return;const t=Lt.shift();if(t==null){N=!1;return}N=!0,Ce.writeCharacteristic(we,Ae,t).catch(e=>console.log(e)).finally(()=>{N=!1,et()})}function Te(t){tt.get(t)?.(),tt.delete(t),et()}function F(){return{write:Se}}const{write:It}=F();function De(t){return{upload:(e,n)=>{const r=new Uint8Array(n.length+1);return r.set([e],0),r.set(n,1),It(b.UPLOAD,t,r)},clear:()=>It(b.CLEAR_GRAPHICS,t)}}const{onConnected:Ue,onDisconnected:Oe}=Ot();Ue.attach(qe),Oe.attach(Pe);const j=[];function qe(t){const e=new Uint8Array(t.buffer,6);for(const n of e)Le(n)}function Pe(t){const e=t.getUint8(2);Ie(e)}function Le(t){j.some(e=>e.id===t)||j.push(new pt(t))}function Ie(t){const e=j.findIndex(n=>n.id===t);e!==-1&&j.splice(e,1)}function Me(){return{standees:j}}class nt{id=0;dirty=!0;_show=!0;_x;_y;_colorBlack=!1;constructor(e,n,r=!0,f=!1){this._x=e,this._y=n,this._show=r,this._colorBlack=f}get x(){return this._x}get y(){return this._y}set x(e){this._x=e,this.dirty=!0}set y(e){this._y=e,this.dirty=!0}set show(e){this._show=e,this.dirty=!0}get show(){return this._show}set colorBlack(e){this._colorBlack=e,this.dirty=!0}get colorBlack(){return this._colorBlack}}class Re extends nt{_width;_height;_radius;_fill;constructor(e,n,r,f,l=0,u=!1,i=!0,a=!1){super(e,n,i,a),this._width=r,this._height=f,this._radius=l,this._fill=u}set width(e){this._width=e,this.dirty=!0}set height(e){this._height=e,this.dirty=!0}set radius(e){this._radius=e,this.dirty=!0}set fill(e){this._fill=e,this.dirty=!0}get width(){return this._width}get height(){return this._height}get radius(){return this._radius}get fill(){return this._fill}}let Be=class extends nt{_width;_height;_data;constructor(e,n,r,f,l,u=!0,i=!1){super(e,n,u,i),this._width=r,this._height=f,this._data=l}set width(e){this._width=e,this.dirty=!0}set height(e){this._height=e,this.dirty=!0}set data(e){this._data=e,this.dirty=!0}get width(){return this._width}get height(){return this._height}get data(){return this._data}};class Ne extends nt{_text;_font;_center;constructor(e,n,r,f,l=!1,u=!0,i=!1){super(e,n,u,i),this._text=r,this._font=f,this._center=l}set text(e){this._text=e,this.dirty=!0}set font(e){this._font=e,this.dirty=!0}get text(){return this._text}get font(){return this._font}get center(){return this._center}set center(e){this._center=e,this.dirty=!0}}function je(t){const e=()=>{let r=Math.floor(Math.random()*256);return n(r)?e():r},n=r=>t.some(f=>f.id===r);return{generate:e}}function xe(t){return{add:r=>(r.id=je(t.elements).generate(),t.elements.push(r),r),remove:r=>{t.elements=t.elements.filter(f=>f.id!==r)}}}const{write:Mt}=F();function Qe(t){return Mt(b.CLEAR_SCREEN,t.id)}function Ve(t){let e=new Uint8Array;for(const n of t.elements)n.dirty!==!1&&(n instanceof Be&&(e=rt(e,$e(n))),n instanceof Re&&(e=rt(e,He(n))),n instanceof Ne&&(e=rt(e,ke(n))),n.dirty=!1);return Mt(b.ALL,t.id,e)}function rt(t,e){const n=new Uint8Array(t.length+e.length);return n.set(t,0),n.set(e,t.length),n}function $e(t){return new Uint8Array([b.DRAW_IMAGE,7,t.id,t.show?1:0,t.x,t.y,t.width,t.height,t.data])}function He(t){return new Uint8Array([b.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 ke(t){const e=new TextEncoder().encode(t.text),n=new Uint8Array(9+e.length);return n.set([b.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 Ge(){return{clear:Qe,draw:Ve}}function We(t,e){const n=Math.ceil(t.length/e),r=Math.ceil(e/8),f=new Uint8Array(r*n);for(let l=0;l<n;l++)for(let u=0;u<r;u++){let i=0;for(let a=0;a<8;a++){const h=u*8+a,o=l*e+h;h<e&&o<t.length&&t[o]&&(i|=1<<7-a)}f[l*r+u]=Rt(i)}return f}function Rt(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 Fe(t){const e=t.reduce((f,l)=>f+l.length,0),n=new Uint8Array(e);let r=0;for(const f of t)n.set(f,r),r+=f.length;return n}function X(){return{pixelsToBytes:We,bitswap:Rt,flattenUint8Arrays:Fe}}const{flattenUint8Arrays:Bt}=X();class O{element_id;property;constructor(e,n){this.element_id=e,this.property=n}}class T{target;constructor(e){this.target=e}format(){return new Uint8Array}}class Xe extends T{format(){return new Uint8Array([S.INCREMENT,2,this.target.element_id,this.target.property])}}class Ye extends T{format(){return new Uint8Array([S.DECREMENT,2,this.target.element_id,this.target.property])}}class Ke extends T{format(){return new Uint8Array([S.SHOW,1,this.target.element_id])}}class ze extends T{format(){return new Uint8Array([S.HIDE,1,this.target.element_id])}}class Ze extends T{value;constructor(e,n){super(e),this.value=n}format(){const e=this.dataType(),n=this.convertValue(e),r=new Uint8Array(5+n.length),f=[S.SET,n.length+3,e,this.target.element_id,this.target.property];return r.set(f,0),r.set(n,5),r}dataType(){return typeof this.value==="string"?P.STRING:P.NUMBER}convertValue(e){return e===P.STRING?new TextEncoder().encode(this.value):e===P.NUMBER?new Uint8Array([this.value]):new Uint8Array}}class Je extends T{format(){return this.target.element_id!==0&&this.target.property!==0?new Uint8Array([S.BROADCAST,2,this.target.element_id,this.target.property]):new Uint8Array([S.BROADCAST,0])}}class tn extends T{format(){return new Uint8Array([S.BREAK,0])}}let en=class extends T{fromLow;fromHigh;toLow;toHigh;value;constructor(e,n,r,f,l,u){super(u),this.value=e,this.fromLow=n,this.fromHigh=r,this.toLow=f,this.toHigh=l}format(){return new Uint8Array([S.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 nn extends T{deciseconds;resetable;onComplete;constructor(e,n,r){super(new O(0,0)),this.deciseconds=e,this.resetable=n,this.onComplete=r}format(){const e=Bt(this.onComplete.map(f=>f.format())),n=new Uint8Array(4+e.length),r=[S.TIMER,e.length+2,this.resetable?1:0,this.deciseconds];return n.set(r,0),e.forEach((f,l)=>n.set([f],l+4)),n}}class rn extends T{left;operator;right;actions;constructor(e,n,r,f){super(new O(0,0)),this.actions=f,this.left=e,this.operator=n,this.right=r}convertValue(e){if(typeof e=="number")return new Uint8Array([P.NUMBER,1,e]);if(typeof e=="string"){const n=new TextEncoder().encode(e);return new Uint8Array([P.STRING,n.length,...n])}return e instanceof O?new Uint8Array([P.ELEMENT,2,e.element_id,e.property]):new Uint8Array}format(){const e=Bt(this.actions.map(i=>i.format())),n=this.convertValue(this.left),r=this.convertValue(this.right),f=4+n.length+r.length+e.length,l=new Uint8Array(f),u=[S.CONDITION,f-2,n.length+r.length+1];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}}function sn(){return{target(t,e){return new O(t,e)},increment(t){return new Xe(t)},decrement(t){return new Ye(t)},show(t){return new Ke(new O(t,0))},hide(t){return new ze(new O(t,0))},set(t,e){return new Ze(t,e)},broadcast(t){return new Je(t||new O(0,0))},timer(t,e,n){return new nn(t,e,n)},stop(){return new tn(new O(0,0))},condition(t,e,n,r){return new rn(t,e,n,r)},map(t,e,n,r,f,l){return new en(t,e,n,r,f,l)}}}const{write:on}=F(),{flattenUint8Arrays:an}=X();function un(t){return{setButton(e,n){const r=an(n.map(l=>l.format())),f=new Uint8Array(1+r.length);return f.set([e],0),r.forEach((l,u)=>f.set([l],u+1)),on(b.ACTIONS,t.id,f)}}}function cn(t){return new Promise((e,n)=>{const r=new Image;r.onload=()=>e(r),r.onerror=n,r.src=t})}function hn(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 ln(t){const e=[],n=t.data,r=t.width,f=t.height;for(let l=0;l<f;l++)for(let u=0;u<r;u++){const i=(l*r+u)*4,a=n[i],h=n[i+1],o=n[i+2],s=.2126*a+.7152*h+.0722*o;e.push(s<128?0:1)}return{width:r,height:f,pixels:e}}function Nt(){return{createImage:cn,getImageData:hn,imageDataToPixels:ln}}const{createImage:fn,getImageData:dn,imageDataToPixels:vn}=Nt(),{pixelsToBytes:yn}=X();function gn(t){return new Promise((e,n)=>{fn(t).then(r=>dn(r)).then(r=>vn(r)).then(r=>yn(r.pixels,r.width)).then(r=>e(r)).catch(r=>n(r))})}function pn(){return{imageToBytes:gn}}function _n(t,e,n,r,f){return(t-e)/(n-e)*(f-r)+r}function En(){return{map:_n}}g.ButtonResult=At,g.Standee=pt,g.useActions=sn,g.useBinary=X,g.useButtons=un,g.useConverter=pn,g.useDisplay=Ge,g.useImage=Nt,g.useMesh=Ot,g.useMeshUpload=De,g.useMeshWriter=F,g.useStandeeElements=xe,g.useStandees=Me,g.useUtils=En,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(g,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(g=typeof globalThis<"u"?globalThis:g||self,w(g["nsd-ble"]={}))})(this,(function(g){"use strict";var w={},L={},ut;function Q(){if(ut)return L;ut=1,Object.defineProperty(L,"__esModule",{value:!0}),L.BaseEvent=void 0;var t=(function(){function e(){}return e.prototype.attach=function(n,r){return this._attach(n,r,!1)},e.prototype.once=function(n,r){return this._attach(n,r,!0)},e.prototype._attach=function(n,r,f){var l=this,u,i,a,h;if(typeof n=="function")i=n,h=function(){return l.detach(i)};else if(!r&&typeof n.post=="function")a=n,h=function(){return l.detach(a)};else{if(typeof n!="object"||n===void 0)throw new Error("Expect a function or object as first argument");if(typeof r!="function")throw new Error("Expect a function as second argument");u=n,i=r,h=function(){return l.detach(u,i)}}return this._listeners?this._listeners=this._listeners.slice():this._listeners=[],this._listeners.push({deleted:!1,boundTo:u,handler:i,event:a,once:f}),h},e.prototype.detach=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];this._detach.apply(this,n)},e.prototype._detach=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];if(!(!this._listeners||this._listeners.length===0)){var f,l,u;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){return(typeof l>"u"||i.handler===l)&&(typeof u>"u"||i.event===u)&&(typeof f>"u"||i.boundTo===f)?(i.deleted=!0,!1):!0}),this._listeners.length===0&&delete this._listeners}},e.prototype.post=function(n){throw new Error("abstract")},e.prototype.listenerCount=function(){return this._listeners?this._listeners.length:0},e.prototype._call=function(n,r){this._listeners&&(n.deleted||(n.once&&(n.deleted=!0,this._listeners=this._listeners.filter(function(f){return f!==n}),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)))},e})();return L.BaseEvent=t,L}var A={},ct;function I(){if(ct)return A;ct=1;var t=A&&A.__extends||(function(){var l=function(u,i){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,h){a.__proto__=h}||function(a,h){for(var o in h)h.hasOwnProperty(o)&&(a[o]=h[o])},l(u,i)};return function(u,i){l(u,i);function a(){this.constructor=u}u.prototype=i===null?Object.create(i):(a.prototype=i.prototype,new a)}})();Object.defineProperty(A,"__esModule",{value:!0}),A.ErrorSyncEvent=A.VoidSyncEvent=A.SyncEvent=void 0;var e=Q(),n=(function(l){t(u,l);function u(){var i=l!==null&&l.apply(this,arguments)||this;return i._recursion=0,i}return Object.defineProperty(u.prototype,"evtListenersChanged",{get:function(){return this._listenersChanged||(this._listenersChanged=new r),this._listenersChanged},enumerable:!1,configurable:!0}),u.prototype.post=function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];if(!(!this._listeners||this._listeners.length===0)){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)throw new Error("event fired recursively");for(var h=this._listeners,o=0;o<h.length;++o){var s=h[o];this._call(s,i)}this._recursion--}},u.prototype._attach=function(i,a,h){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);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},u.prototype._detach=function(){for(var i,a,h,o,s=[],c=0;c<arguments.length;c++)s[c]=arguments[c];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);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},u.MAX_RECURSION_DEPTH=10,u})(e.BaseEvent);A.SyncEvent=n;var r=(function(l){t(u,l);function u(){return l!==null&&l.apply(this,arguments)||this}return u.prototype.post=function(){l.prototype.post.call(this,void 0)},u})(n);A.VoidSyncEvent=r;var f=(function(l){t(u,l);function u(){return l!==null&&l.apply(this,arguments)||this}return u.prototype.post=function(i){if(this.listenerCount()===0)throw new Error("error event posted while no listeners attached. Error: "+i.message);l.prototype.post.call(this,i)},u})(n);return A.ErrorSyncEvent=f,A}var m={},V={},ht;function Y(){if(ht)return V;ht=1,Object.defineProperty(V,"__esModule",{value:!0});var t=I(),e=(function(){function n(){this.evtFilled=new t.SyncEvent,this.evtDrained=new t.SyncEvent,this._queue=[],this._flushing=!1}return n.global=function(){return n._instance||n.resetGlobal(),n._instance},n.resetGlobal=function(){n._instance=new n},n.prototype.empty=function(){return this._queue.length===0},n.prototype.add=function(r){this._queue.push(r),this._queue.length===1&&!this._flushing&&this.evtFilled.post(this)},n.prototype.flushOnce=function(){var r=this._queue.length===0,f=this._flushing;this._flushing=!0;try{var l=this._queue;this._queue=[];for(var u=0;u<l.length;++u)l[u]()}finally{this._flushing=f,!r&&!f&&this._queue.length===0&&this.evtDrained.post(this)}},n.prototype.flush=function(r){r===void 0&&(r=10);var f=this._queue.length===0,l=this._flushing;this._flushing=!0;try{for(var u=0;this._queue.length>0;){if(typeof r=="number"&&u>=r)throw this._queue=[],new Error("unable to flush the queue due to recursively added event. Clearing queue now");this.flushOnce(),++u}}finally{this._flushing=l,!f&&!l&&this._queue.length===0&&this.evtDrained.post(this)}},n})();return V.default=e,V}var lt;function ft(){if(lt)return m;lt=1;var t=m&&m.__extends||(function(){var i=function(a,h){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,s){o.__proto__=s}||function(o,s){for(var c in s)s.hasOwnProperty(c)&&(o[c]=s[c])},i(a,h)};return function(a,h){i(a,h);function o(){this.constructor=a}a.prototype=h===null?Object.create(h):(o.prototype=h.prototype,new o)}})();Object.defineProperty(m,"__esModule",{value:!0}),m.ErrorQueuedEvent=m.VoidQueuedEvent=m.QueuedEvent=void 0;var e=Q(),n=Y(),r=I(),f=(function(i){t(a,i);function a(h){h===void 0&&(h={});var o=i.call(this)||this;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}return Object.defineProperty(a.prototype,"evtListenersChanged",{get:function(){return this._listenersChanged||(this._listenersChanged=new r.VoidSyncEvent),this._listenersChanged},enumerable:!1,configurable:!0}),a.prototype.post=function(){for(var h=this,o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];if(!(!this._listeners||this._listeners.length===0)){var c=this._queue?this._queue:n.default.global();if(this._condensed){if(this._queuedData=o,this._queuedListeners=this._listeners,this._queued)return;this._queued=!0,c.add(function(){h._queued=!1;for(var v=h._queuedData,y=h._queuedListeners,p=0;p<y.length;++p){var _=y[p];h._call(_,v)}})}else{var d=this._listeners;c.add(function(){for(var v=0;v<d.length;++v){var y=d[v];h._call(y,o)}})}}},a.prototype._attach=function(h,o,s){var c,d,v,y,p=(d=(c=this._listeners)===null||c===void 0?void 0:c.length)!==null&&d!==void 0?d:0,_=i.prototype._attach.call(this,h,o,s);return this.evtListenersChanged&&p!==((y=(v=this._listeners)===null||v===void 0?void 0:v.length)!==null&&y!==void 0?y:0)&&this.evtListenersChanged.post(),_},a.prototype._detach=function(){for(var h,o,s,c,d=[],v=0;v<arguments.length;v++)d[v]=arguments[v];var y=(o=(h=this._listeners)===null||h===void 0?void 0:h.length)!==null&&o!==void 0?o:0,p=i.prototype._detach.apply(this,d);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(),p},a})(e.BaseEvent);m.QueuedEvent=f;var l=(function(i){t(a,i);function a(){return i!==null&&i.apply(this,arguments)||this}return a.prototype.post=function(){i.prototype.post.call(this,void 0)},a})(f);m.VoidQueuedEvent=l;var u=(function(i){t(a,i);function a(){return i!==null&&i.apply(this,arguments)||this}return a.prototype.post=function(h){if(!this._listeners||this._listeners.length===0)throw new Error("error event posted while no listeners attached. Error: "+h.message);i.prototype.post.call(this,h)},a})(f);return m.ErrorQueuedEvent=u,m}var C={},dt;function vt(){if(dt)return C;dt=1;var t=C&&C.__extends||(function(){var u=function(i,a){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,o){h.__proto__=o}||function(h,o){for(var s in o)o.hasOwnProperty(s)&&(h[s]=o[s])},u(i,a)};return function(i,a){u(i,a);function h(){this.constructor=i}i.prototype=a===null?Object.create(a):(h.prototype=a.prototype,new h)}})();Object.defineProperty(C,"__esModule",{value:!0}),C.ErrorAsyncEvent=C.VoidAsyncEvent=C.AsyncEvent=void 0;var e=Q(),n=I(),r=(function(u){t(i,u);function i(a){a===void 0&&(a={});var h=u.call(this)||this;return h._queued=!1,h.options=a,typeof a.condensed=="boolean"?h._condensed=a.condensed:h._condensed=!1,h}return Object.defineProperty(i.prototype,"evtListenersChanged",{get:function(){return this._listenersChanged||(this._listenersChanged=new n.VoidSyncEvent),this._listenersChanged},enumerable:!1,configurable:!0}),i.defaultScheduler=function(a){typeof window<"u"?setTimeout(a,0):setImmediate(a)},i.setScheduler=function(a){i._scheduler=a},i.prototype.post=function(){for(var a=this,h=[],o=0;o<arguments.length;o++)h[o]=arguments[o];if(!(!this._listeners||this._listeners.length===0))if(this._condensed){if(this._queuedData=h,this._queuedListeners=this._listeners,this._queued)return;this._queued=!0,i._scheduler(function(){a._queued=!1;for(var c=a._queuedData,d=a._queuedListeners,v=0;v<d.length;++v){var y=d[v];a._call(y,c)}})}else{var s=this._listeners;i._scheduler(function(){for(var c=0;c<s.length;++c){var d=s[c];a._call(d,h)}})}},i.prototype._call=function(a,h){a.event&&a.event instanceof i?a.event._postDirect(h):u.prototype._call.call(this,a,h)},i.prototype._postDirect=function(a){if(!(!this._listeners||this._listeners.length===0))for(var h=this._listeners,o=0;o<h.length;++o){var s=h[o];this._call(s,a)}},i.prototype._attach=function(a,h,o){var s,c,d,v,y=(c=(s=this._listeners)===null||s===void 0?void 0:s.length)!==null&&c!==void 0?c:0,p=u.prototype._attach.call(this,a,h,o);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(),p},i.prototype._detach=function(){for(var a,h,o,s,c=[],d=0;d<arguments.length;d++)c[d]=arguments[d];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);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},i._scheduler=i.defaultScheduler,i})(e.BaseEvent);C.AsyncEvent=r;var f=(function(u){t(i,u);function i(){return u!==null&&u.apply(this,arguments)||this}return i.prototype.post=function(){u.prototype.post.call(this,void 0)},i})(r);C.VoidAsyncEvent=f;var l=(function(u){t(i,u);function i(){return u!==null&&u.apply(this,arguments)||this}return i.prototype.post=function(a){if(this.listenerCount()===0)throw new Error("error event posted while no listeners attached. Error: "+a.message);u.prototype.post.call(this,a)},i})(r);return C.ErrorAsyncEvent=l,C}var M={},R={},yt;function Ht(){if(yt)return R;yt=1,Object.defineProperty(R,"__esModule",{value:!0}),R.shallowEquals=void 0;function t(e,n){if(e===n)return!0;if(typeof e!=typeof n)return!1;switch(typeof e){case"boolean":case"number":case"string":case"function":case"symbol":case"undefined":return!1;case"object":if(e===null||n===null)return!1;if(Array.isArray(e)||Array.isArray(n)){if(!Array.isArray(e)||!Array.isArray(n)||e.length!==n.length)return!1;for(var r=0;r<e.length;++r)if(e[r]!==n[r])return!1;return!0}var f=[],l=[];for(var u in e)e.hasOwnProperty(u)&&f.push(u);for(var i in n)n.hasOwnProperty(i)&&l.push(i);if(f.sort(),l.sort(),f.join(",")!==l.join(","))return!1;for(var r=0;r<f.length;++r)if(e[f[r]]!==n[f[r]])return!1;return!0;default:return!1}}return R.shallowEquals=t,R}var gt;function kt(){return gt||(gt=1,(function(t){var e=M&&M.__extends||(function(){var o=function(s,c){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,v){d.__proto__=v}||function(d,v){for(var y in v)v.hasOwnProperty(y)&&(d[y]=v[y])},o(s,c)};return function(s,c){o(s,c);function d(){this.constructor=s}s.prototype=c===null?Object.create(c):(d.prototype=c.prototype,new d)}})();Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorAnyEvent=t.VoidAnyEvent=t.AnyEvent=t.EventType=void 0;var n=Ht(),r=I(),f=vt(),l=ft(),u;(function(o){o[o.Sync=0]="Sync",o[o.Async=1]="Async",o[o.Queued=2]="Queued"})(u=t.EventType||(t.EventType={}));var i=(function(){function o(s){this._events=[],s&&s.monitorAttach&&(this.evtFirstAttached=new a,this.evtLastDetached=new a)}return Object.defineProperty(o.prototype,"evtListenersChanged",{get:function(){return this._listenersChanged||(this._listenersChanged=new r.VoidSyncEvent),this._listenersChanged},enumerable:!1,configurable:!0}),o.prototype.attach=function(){for(var s=[],c=0;c<arguments.length;c++)s[c]=arguments[c];var d=u.Sync;s.length>0&&typeof s[0]=="number"&&(d=s.shift());var v=this,y,p,_;return typeof s[0]=="function"||s[0]&&typeof s[0]=="object"&&typeof s[0].post=="function"?(typeof s[0]=="function"?y=s[0]:_=s[0],p=s[1]):(v=s[0],y=s[1],p=s[2]),this._attach(d,v,y,_,p,!1)},o.prototype.once=function(){for(var s=[],c=0;c<arguments.length;c++)s[c]=arguments[c];var d=u.Sync;s.length>0&&typeof s[0]=="number"&&(d=s.shift());var v=this,y,p,_;return typeof s[0]=="function"||s[0]&&typeof s[0]=="object"&&typeof s[0].post=="function"?(typeof s[0]=="function"?y=s[0]:_=s[0],p=s[1]):(v=s[0],y=s[1],p=s[2]),this._attach(d,v,y,_,p,!0)},o.prototype._attach=function(s,c,d,v,y,p){var _=this,jt=this.evtFirstAttached?this.listenerCount():0,E;switch(s){case u.Sync:{for(var it=0,xt=this._events;it<xt.length;it++){var D=xt[it];D instanceof r.SyncEvent&&(E=D)}E||(E=new r.SyncEvent,this._events.push(E))}break;case u.Async:{for(var ot=0,Qt=this._events;ot<Qt.length;ot++){var D=Qt[ot];D instanceof f.AsyncEvent&&n.shallowEquals(D.options,y)&&(E=D)}E||(E=new f.AsyncEvent(y),this._events.push(E))}break;case u.Queued:{for(var at=0,Vt=this._events;at<Vt.length;at++){var D=Vt[at];D instanceof l.QueuedEvent&&n.shallowEquals(D.options,y)&&(E=D)}E||(E=new l.QueuedEvent(y),this._events.push(E))}break;default:throw new Error("unknown EventType")}var x;return p?v?x=E.once(v):x=E.once(c,d):v?x=E.attach(v):x=E.attach(c,d),this.evtFirstAttached&&jt===0&&this.evtFirstAttached.post(),this.evtListenersChanged&&jt!==this.listenerCount()&&this.evtListenersChanged.post(),function(){var $t=_.evtLastDetached?_.listenerCount():0;x(),_.evtLastDetached&&$t>0&&_.listenerCount()===0&&_.evtLastDetached.post(),_.evtListenersChanged&&$t!==_.listenerCount()&&_.evtListenersChanged.post()}},o.prototype.attachSync=function(){for(var s=[],c=0;c<arguments.length;c++)s[c]=arguments[c];return s.unshift(u.Sync),this.attach.apply(this,s)},o.prototype.onceSync=function(){for(var s=[],c=0;c<arguments.length;c++)s[c]=arguments[c];return s.unshift(u.Sync),this.once.apply(this,s)},o.prototype.attachAsync=function(){for(var s=[],c=0;c<arguments.length;c++)s[c]=arguments[c];return s.unshift(u.Async),this.attach.apply(this,s)},o.prototype.onceAsync=function(){for(var s=[],c=0;c<arguments.length;c++)s[c]=arguments[c];return s.unshift(u.Async),this.once.apply(this,s)},o.prototype.attachQueued=function(){for(var s=[],c=0;c<arguments.length;c++)s[c]=arguments[c];return s.unshift(u.Queued),this.attach.apply(this,s)},o.prototype.onceQueued=function(){for(var s=[],c=0;c<arguments.length;c++)s[c]=arguments[c];return s.unshift(u.Queued),this.once.apply(this,s)},o.prototype.detach=function(){for(var s=[],c=0;c<arguments.length;c++)s[c]=arguments[c];for(var d=this.listenerCount(),v=0;v<this._events.length;++v)this._events[v].detach.apply(this._events[v],s);this.evtListenersChanged&&d!==this.listenerCount()&&this.evtListenersChanged.post(),this.evtLastDetached&&d>0&&this.listenerCount()===0&&this.evtLastDetached.post()},o.prototype.post=function(s){for(var c=[],d=0;d<this._events.length;++d)c.push(this._events[d]);for(var d=0;d<c.length;++d)c[d].post(s)},o.prototype.listenerCount=function(){for(var s=0,c=0;c<this._events.length;++c)s+=this._events[c].listenerCount();return s},o})();t.AnyEvent=i;var a=(function(o){e(s,o);function s(){return o!==null&&o.apply(this,arguments)||this}return s.prototype.post=function(){o.prototype.post.call(this,void 0)},s})(i);t.VoidAnyEvent=a;var h=(function(o){e(s,o);function s(){return o!==null&&o.apply(this,arguments)||this}return s.prototype.post=function(c){if(this.listenerCount()===0)throw new Error("error event posted while no listeners attached. Error: "+c.message);o.prototype.post.call(this,c)},s})(i);t.ErrorAnyEvent=h})(M)),M}var pt;function Gt(){return pt||(pt=1,(function(t){var e=w&&w.__createBinding||(Object.create?(function(a,h,o,s){s===void 0&&(s=o),Object.defineProperty(a,s,{enumerable:!0,get:function(){return h[o]}})}):(function(a,h,o,s){s===void 0&&(s=o),a[s]=h[o]})),n=w&&w.__exportStar||function(a,h){for(var o in a)o!=="default"&&!h.hasOwnProperty(o)&&e(h,a,o)};Object.defineProperty(t,"__esModule",{value:!0}),t.flush=t.flushOnce=t.queue=void 0,n(Q(),t),n(I(),t),n(ft(),t),n(vt(),t),n(kt(),t);var r=Y(),f=Y();Object.defineProperty(t,"EventQueue",{enumerable:!0,get:function(){return f.default}});function l(){return r.default.global()}t.queue=l;function u(){r.default.global().flushOnce()}t.flushOnce=u;function i(a){a===void 0&&(a=10),r.default.global().flush(a)}t.flush=i})(w)),w}var U=Gt();class _t{id;elements=[];onPlus=new U.SyncEvent;onMin=new U.SyncEvent;constructor(e){this.id=e}name(){return this.id.toString(16).padStart(2,"0")}}let K=!1,$=[],H,Et,k=new Map;async function Wt(t){try{if(H=await navigator.bluetooth.requestDevice(t),H.gatt===void 0)throw new Error("Device does not support GATT");Et=await H.gatt.connect(),H.addEventListener("gattserverdisconnected",Ft),K=!0}catch(e){throw e}}function Ft(){k.clear(),K=!1,$.forEach(t=>t())}function Xt(t){$.push(t)}function Yt(t){$=$.filter(e=>e!==t)}async function z(t,e){if(k.has(e)){const f=k.get(e);if(f===void 0)throw new Error("Characteristic not found");return f}const r=await(await Et.getPrimaryService(t)).getCharacteristic(e);return k.set(e,r),r}async function Kt(t,e){return await(await z(t,e)).readValue()}async function zt(t,e,n){const r=new DataView(new ArrayBuffer(n.length));r.setUint8(0,n[0]),await(await z(t,e)).writeValue(r)}async function Zt(t,e,n){const r=await z(t,e);r.addEventListener("characteristicvaluechanged",f=>{let l=f.target.value;l===void 0&&(l=new DataView(new ArrayBuffer(0))),n(l)}),await r.startNotifications()}function G(){return{connected:K,connect:Wt,readCharacteristic:Kt,writeCharacteristic:zt,subscribe:Zt,setDisconnectCallback:Xt,removeDisconnectCallback:Yt}}class wt{static CONNECT=0;static DISCONNECT=1}class b{static UPLOAD=0;static DRAW_IMAGE=1;static DRAW_RECTANGLE=2;static BUTTON_PRESS=3;static DRAW_TEXT=4;static ALL=5;static CLEAR_GRAPHICS=6;static ACTIONS=7;static CLEAR_SCREEN=8;static MESSAGE_DONE=9}class q{static ID=0;static CACHE=1;static TTL=2;static POSITION=3;static DATA_SIZE=4;static TYPE=5;static DATA=6}class Z{static MINUS=0;static PLUS=1;static EITHER=2}class S{static INCREMENT=0;static DECREMENT=1;static SHOW=2;static HIDE=3;static SET=4;static BROADCAST=5;static TIMER=6;static CONDITION=7;static BREAK=8;static MAP=9}class P{static STRING=0;static NUMBER=1;static ELEMENT=2}const At="19b10000-e8f2-537e-4f6c-d104768a1214",Jt="6b061bdc-9bc1-4952-a96f-c6ed551b2c3e",te="998ff920-81af-42a9-a915-f88025f9647d",ee={filters:[{namePrefix:"BLE-STANDEE"}],optionalServices:[At]};function W(){return{serviceUuid:At,messageCharUuid:Jt,handshakeCharUuid:te,options:ee}}class mt{id;data;constructor(e,n){this.id=e,this.data=n}}const{serviceUuid:ne,messageCharUuid:re}=W(),Ct=new U.SyncEvent,St=new U.SyncEvent,bt=new U.SyncEvent,Tt=new U.SyncEvent;function se(){return new Promise((t,e)=>{G().subscribe(ne,re,ie).then(()=>t()).catch(n=>e(n))})}function ie(t){t!==void 0&&(t.getUint8(q.TYPE)===b.BUTTON_PRESS&&oe(t),t.getUint8(q.TYPE)===b.MESSAGE_DONE&&Tt.post(t.getUint8(q.DATA)))}function oe(t){const e=t.getUint8(q.DATA),n=new mt(t.getUint8(q.ID),ae(t));e===Z.MINUS&&St.post(n),e===Z.PLUS&&Ct.post(n),e===Z.EITHER&&bt.post(n)}function ae(t){const e=t.buffer,n=7,r=t.byteLength-7;return Array.from(new Uint8Array(e,n,r)).map(f=>String.fromCharCode(f)).join("").replace(/\0/g,"").trim()}function J(){return{subscribe:se,onPlus:Ct,onMin:St,onEither:bt,onMessageDone:Tt}}const{serviceUuid:ue,handshakeCharUuid:ce}=W(),Dt=new U.SyncEvent,Ut=new U.SyncEvent;function he(){return new Promise((t,e)=>{G().subscribe(ue,ce,le).then(()=>t()).catch(n=>e(n))})}function le(t){t.getUint8(q.TYPE)===wt.CONNECT&&Dt.post(t),t.getUint8(q.TYPE)===wt.DISCONNECT&&Ut.post(t)}function tt(){return{subscribe:he,onConnected:Dt,onDisconnected:Ut}}const{onConnected:fe}=tt(),{onDisconnected:de}=tt();function ve(){return new Promise((t,e)=>{G().connect(W().options).then(()=>Promise.all([tt().subscribe(),J().subscribe()]).then(()=>{t()})).catch(n=>e(n))})}function Ot(){return{connect:ve,onConnected:fe,onDisconnected:de}}const B=[];function ye(){let t=Math.floor(Math.random()*256);for(;B.includes(t);)t=Math.floor(Math.random()*256);return t}function ge(t){B.push(t),pe()}function pe(){B.length<=20||B.splice(0,B.length-20)}function _e(){const t=ye();return ge(t),t}function Ee(){return{create:_e}}const{serviceUuid:we,messageCharUuid:Ae}=W(),{onMessageDone:me}=J(),Ce=G(),qt=10,Pt=15,Lt=[],et=new Map;let N=!1;me.attach(Te);function Se(t,e,n){const r=Ee().create();return be(r,t,e,n).forEach(l=>Lt.push(l)),new Promise(l=>{et.set(r,l),N||nt()})}function be(t,e,n,r){if(r==null)return[new Uint8Array([n,t,qt,0,2,e,0])];const f=new Uint8Array(2+r.length),l=r.length+2,u=[];f.set([e,l],0),f.set(r,2);for(let i=0;i<l;i+=Pt){const a=Math.min(Pt,l-i),h=new Uint8Array(a),o=[n,t,qt,i,l];h.set(f.subarray(i,i+a),0),u.push(new Uint8Array([...o,...h]))}return u}function nt(){if(N)return;const t=Lt.shift();if(t==null){N=!1;return}N=!0,Ce.writeCharacteristic(we,Ae,t).catch(e=>console.log(e)).finally(()=>{N=!1,nt()})}function Te(t){et.get(t)?.(),et.delete(t),nt()}function F(){return{write:Se}}const{write:It}=F();function De(t){return{upload:(e,n)=>{const r=new Uint8Array(n.length+1);return r.set([e],0),r.set(n,1),It(b.UPLOAD,t,r)},clear:()=>It(b.CLEAR_GRAPHICS,t)}}const{onConnected:Ue,onDisconnected:Oe}=Ot();Ue.attach(qe),Oe.attach(Pe);const j=[];function qe(t){const e=new Uint8Array(t.buffer,6);for(const n of e)Le(n)}function Pe(t){const e=t.getUint8(2);Ie(e)}function Le(t){j.some(e=>e.id===t)||j.push(new _t(t))}function Ie(t){const e=j.findIndex(n=>n.id===t);e!==-1&&j.splice(e,1)}function Me(){return{standees:j}}class rt{id=0;dirty=!0;_show=!0;_x;_y;_colorBlack=!1;constructor(e,n,r=!0,f=!1){this._x=e,this._y=n,this._show=r,this._colorBlack=f}get x(){return this._x}get y(){return this._y}set x(e){this._x=e,this.dirty=!0}set y(e){this._y=e,this.dirty=!0}set show(e){this._show=e,this.dirty=!0}get show(){return this._show}set colorBlack(e){this._colorBlack=e,this.dirty=!0}get colorBlack(){return this._colorBlack}}class Re extends rt{_width;_height;_radius;_fill;constructor(e,n,r,f,l=0,u=!1,i=!0,a=!1){super(e,n,i,a),this._width=r,this._height=f,this._radius=l,this._fill=u}set width(e){this._width=e,this.dirty=!0}set height(e){this._height=e,this.dirty=!0}set radius(e){this._radius=e,this.dirty=!0}set fill(e){this._fill=e,this.dirty=!0}get width(){return this._width}get height(){return this._height}get radius(){return this._radius}get fill(){return this._fill}}let Be=class extends rt{_width;_height;_data;constructor(e,n,r,f,l,u=!0,i=!1){super(e,n,u,i),this._width=r,this._height=f,this._data=l}set width(e){this._width=e,this.dirty=!0}set height(e){this._height=e,this.dirty=!0}set data(e){this._data=e,this.dirty=!0}get width(){return this._width}get height(){return this._height}get data(){return this._data}};class Ne extends rt{_text;_font;_center;constructor(e,n,r,f,l=!1,u=!0,i=!1){super(e,n,u,i),this._text=r,this._font=f,this._center=l}set text(e){this._text=e,this.dirty=!0}set font(e){this._font=e,this.dirty=!0}get text(){return this._text}get font(){return this._font}get center(){return this._center}set center(e){this._center=e,this.dirty=!0}}function je(t){const e=()=>{let r=Math.floor(Math.random()*256);return n(r)?e():r},n=r=>t.some(f=>f.id===r);return{generate:e}}function xe(t){return{add:r=>(r.id=je(t.elements).generate(),t.elements.push(r),r),remove:r=>{t.elements=t.elements.filter(f=>f.id!==r)}}}const{write:Mt}=F();function Qe(t){return Mt(b.CLEAR_SCREEN,t.id)}function Ve(t){let e=new Uint8Array;for(const n of t.elements)n.dirty!==!1&&(n instanceof Be&&(e=st(e,$e(n))),n instanceof Re&&(e=st(e,He(n))),n instanceof Ne&&(e=st(e,ke(n))),n.dirty=!1);return Mt(b.ALL,t.id,e)}function st(t,e){const n=new Uint8Array(t.length+e.length);return n.set(t,0),n.set(e,t.length),n}function $e(t){return new Uint8Array([b.DRAW_IMAGE,7,t.id,t.show?1:0,t.x,t.y,t.width,t.height,t.data])}function He(t){return new Uint8Array([b.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 ke(t){const e=new TextEncoder().encode(t.text),n=new Uint8Array(9+e.length);return n.set([b.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 Ge(){return{clear:Qe,draw:Ve}}function We(t,e){const n=Math.ceil(t.length/e),r=Math.ceil(e/8),f=new Uint8Array(r*n);for(let l=0;l<n;l++)for(let u=0;u<r;u++){let i=0;for(let a=0;a<8;a++){const h=u*8+a,o=l*e+h;h<e&&o<t.length&&t[o]&&(i|=1<<7-a)}f[l*r+u]=Rt(i)}return f}function Rt(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 Fe(t){const e=t.reduce((f,l)=>f+l.length,0),n=new Uint8Array(e);let r=0;for(const f of t)n.set(f,r),r+=f.length;return n}function X(){return{pixelsToBytes:We,bitswap:Rt,flattenUint8Arrays:Fe}}const{flattenUint8Arrays:Bt}=X();class O{element_id;property;constructor(e,n){this.element_id=e,this.property=n}}class T{target;constructor(e){this.target=e}format(){return new Uint8Array}}class Xe extends T{format(){return new Uint8Array([S.INCREMENT,2,this.target.element_id,this.target.property])}}class Ye extends T{format(){return new Uint8Array([S.DECREMENT,2,this.target.element_id,this.target.property])}}class Ke extends T{format(){return new Uint8Array([S.SHOW,1,this.target.element_id])}}class ze extends T{format(){return new Uint8Array([S.HIDE,1,this.target.element_id])}}class Ze extends T{value;constructor(e,n){super(e),this.value=n}format(){const e=this.dataType(),n=this.convertValue(e),r=new Uint8Array(5+n.length),f=[S.SET,n.length+3,e,this.target.element_id,this.target.property];return r.set(f,0),r.set(n,5),r}dataType(){return typeof this.value==="string"?P.STRING:P.NUMBER}convertValue(e){return e===P.STRING?new TextEncoder().encode(this.value):e===P.NUMBER?new Uint8Array([this.value]):new Uint8Array}}class Je extends T{format(){return this.target.element_id!==0&&this.target.property!==0?new Uint8Array([S.BROADCAST,2,this.target.element_id,this.target.property]):new Uint8Array([S.BROADCAST,0])}}class tn extends T{format(){return new Uint8Array([S.BREAK,0])}}let en=class extends T{fromLow;fromHigh;toLow;toHigh;value;constructor(e,n,r,f,l,u){super(u),this.value=e,this.fromLow=n,this.fromHigh=r,this.toLow=f,this.toHigh=l}format(){return new Uint8Array([S.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 nn extends T{deciseconds;resetable;onComplete;constructor(e,n,r){super(new O(0,0)),this.deciseconds=e,this.resetable=n,this.onComplete=r}format(){const e=Bt(this.onComplete.map(f=>f.format())),n=new Uint8Array(4+e.length),r=[S.TIMER,e.length+2,this.resetable?1:0,this.deciseconds];return n.set(r,0),e.forEach((f,l)=>n.set([f],l+4)),n}}class rn extends T{left;operator;right;actions;constructor(e,n,r,f){super(new O(0,0)),this.actions=f,this.left=e,this.operator=n,this.right=r}convertValue(e){if(typeof e=="number")return new Uint8Array([P.NUMBER,1,e]);if(typeof e=="string"){const n=new TextEncoder().encode(e);return new Uint8Array([P.STRING,n.length,...n])}return e instanceof O?new Uint8Array([P.ELEMENT,2,e.element_id,e.property]):new Uint8Array}format(){const e=Bt(this.actions.map(i=>i.format())),n=this.convertValue(this.left),r=this.convertValue(this.right),f=4+n.length+r.length+e.length,l=new Uint8Array(f),u=[S.CONDITION,f-2,n.length+r.length+1];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}}function sn(){return{target(t,e){return new O(t,e)},increment(t){return new Xe(t)},decrement(t){return new Ye(t)},show(t){return new Ke(new O(t,0))},hide(t){return new ze(new O(t,0))},set(t,e){return new Ze(t,e)},broadcast(t){return new Je(t||new O(0,0))},timer(t,e,n){return new nn(t,e,n)},stop(){return new tn(new O(0,0))},condition(t,e,n,r){return new rn(t,e,n,r)},map(t,e,n,r,f,l){return new en(t,e,n,r,f,l)}}}const{write:on}=F(),{flattenUint8Arrays:an}=X();function un(t){return{setButton(e,n){const r=an(n.map(l=>l.format())),f=new Uint8Array(1+r.length);return f.set([e],0),r.forEach((l,u)=>f.set([l],u+1)),on(b.ACTIONS,t.id,f)}}}function cn(t){return new Promise((e,n)=>{const r=new Image;r.onload=()=>e(r),r.onerror=n,r.src=t})}function hn(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 ln(t){const e=[],n=t.data,r=t.width,f=t.height;for(let l=0;l<f;l++)for(let u=0;u<r;u++){const i=(l*r+u)*4,a=n[i],h=n[i+1],o=n[i+2],s=.2126*a+.7152*h+.0722*o;e.push(s<128?0:1)}return{width:r,height:f,pixels:e}}function Nt(){return{createImage:cn,getImageData:hn,imageDataToPixels:ln}}const{createImage:fn,getImageData:dn,imageDataToPixels:vn}=Nt(),{pixelsToBytes:yn}=X();function gn(t){return new Promise((e,n)=>{fn(t).then(r=>dn(r)).then(r=>vn(r)).then(r=>yn(r.pixels,r.width)).then(r=>e(r)).catch(r=>n(r))})}function pn(){return{imageToBytes:gn}}function _n(t,e,n,r,f){return(t-e)/(n-e)*(f-r)+r}function En(){return{map:_n}}g.ButtonResult=mt,g.Standee=_t,g.useActions=sn,g.useBinary=X,g.useButtons=un,g.useConverter=pn,g.useDisplay=Ge,g.useImage=Nt,g.useMesh=Ot,g.useMeshUpload=De,g.useMeshWriter=F,g.useMessageCharacteristic=J,g.useStandeeElements=xe,g.useStandees=Me,g.useUtils=En,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "nsd-ble",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
7
7
  ],
8
8
  "main": "./dist/nsd-ble.umd.cjs",
9
9
  "module": "./dist/nsd-ble.js",
10
- "types": "./dist/types/main.d.ts",
10
+ "types": "./dist/nsd-ble.d.ts",
11
11
  "exports": {
12
12
  ".": {
13
13
  "import": "./dist/nsd-ble.js",
@@ -1,73 +0,0 @@
1
- export declare class HandshakeType {
2
- static CONNECT: number;
3
- static DISCONNECT: number;
4
- }
5
- export declare class DataType {
6
- static UPLOAD: number;
7
- static DRAW_IMAGE: number;
8
- static DRAW_RECTANGLE: number;
9
- static BUTTON_PRESS: number;
10
- static DRAW_TEXT: number;
11
- static ALL: number;
12
- static CLEAR_GRAPHICS: number;
13
- static ACTIONS: number;
14
- static CLEAR_SCREEN: number;
15
- static MESSAGE_DONE: number;
16
- }
17
- export declare class Data {
18
- static ID: number;
19
- static CACHE: number;
20
- static TTL: number;
21
- static POSITION: number;
22
- static DATA_SIZE: number;
23
- static TYPE: number;
24
- static DATA: number;
25
- }
26
- export declare class Font {
27
- static u8g2_font_5x7_mf: number;
28
- static u8g2_font_inr33_t_cyrillic: number;
29
- static u8g2_font_10x20_tn: number;
30
- static u8g2_font_crox2c_tr: number;
31
- }
32
- export declare class Button {
33
- static MINUS: number;
34
- static PLUS: number;
35
- static EITHER: number;
36
- }
37
- export declare class ActionType {
38
- static INCREMENT: number;
39
- static DECREMENT: number;
40
- static SHOW: number;
41
- static HIDE: number;
42
- static SET: number;
43
- static BROADCAST: number;
44
- static TIMER: number;
45
- static CONDITION: number;
46
- static BREAK: number;
47
- static MAP: number;
48
- }
49
- export declare class ElementData {
50
- static TYPE: number;
51
- static ID: number;
52
- static SHOW: number;
53
- static X: number;
54
- static Y: number;
55
- static WIDTH: number;
56
- static HEIGHT: number;
57
- static RADIUS: number;
58
- static FILL: number;
59
- static DATA: number;
60
- static FONT: number;
61
- }
62
- export declare class ActionCondition {
63
- static EQUAL: number;
64
- static GREATER: number;
65
- static LESS: number;
66
- static GREATER_EQUAL: number;
67
- static LESS_EQUAL: number;
68
- }
69
- export declare class ActionDataType {
70
- static STRING: number;
71
- static NUMBER: number;
72
- static ELEMENT: number;
73
- }
@@ -1,16 +0,0 @@
1
- declare function connect(options: BluetoothOptions): Promise<void>;
2
- declare function setDisconnectCallback(callback: DisconnectedCallback): void;
3
- declare function removeDisconnectCallback(callback: DisconnectedCallback): void;
4
- declare function readCharacteristic(serviceUuid: string, charUuid: string): Promise<DataView<ArrayBufferLike> | undefined>;
5
- declare function writeCharacteristic(serviceUuid: string, charUuid: string, data: Uint8Array): Promise<void>;
6
- declare function subscribe(serviceUuid: string, charUuid: string, callback: characteristicCallback): Promise<void>;
7
- export declare function useBluetooth(): {
8
- connected: boolean;
9
- connect: typeof connect;
10
- readCharacteristic: typeof readCharacteristic;
11
- writeCharacteristic: typeof writeCharacteristic;
12
- subscribe: typeof subscribe;
13
- setDisconnectCallback: typeof setDisconnectCallback;
14
- removeDisconnectCallback: typeof removeDisconnectCallback;
15
- };
16
- export {};
@@ -1,5 +0,0 @@
1
- declare function create(): number;
2
- export declare function useCache(): {
3
- create: typeof create;
4
- };
5
- export {};
@@ -1,8 +0,0 @@
1
- import { SyncEvent } from 'ts-events';
2
- declare function subscribe(): Promise<void>;
3
- export declare function useHandshakeCharacteristic(): {
4
- subscribe: typeof subscribe;
5
- onConnected: SyncEvent<DataView<ArrayBufferLike>>;
6
- onDisconnected: SyncEvent<DataView<ArrayBufferLike>>;
7
- };
8
- export {};
@@ -1,7 +0,0 @@
1
- declare function connect(): Promise<void>;
2
- export declare function useMesh(): {
3
- connect: typeof connect;
4
- onConnected: import('ts-events').SyncEvent<DataView<ArrayBufferLike>>;
5
- onDisconnected: import('ts-events').SyncEvent<DataView<ArrayBufferLike>>;
6
- };
7
- export {};
@@ -1,4 +0,0 @@
1
- export declare function useMeshUpload(target: number): {
2
- upload: (id: number, image: Uint8Array) => Promise<void>;
3
- clear: () => Promise<void>;
4
- };
@@ -1,6 +0,0 @@
1
- import { DataType } from '../Enums.js';
2
- declare function write(type: DataType, id: number, data?: Uint8Array): Promise<void>;
3
- export declare function useMeshWriter(): {
4
- write: typeof write;
5
- };
6
- export {};
@@ -1,15 +0,0 @@
1
- import { SyncEvent } from 'ts-events';
2
- export declare class ButtonResult {
3
- id: number;
4
- data: string;
5
- constructor(id: number, data: string);
6
- }
7
- declare function subscribe(): Promise<void>;
8
- export declare function useMessageCharacteristic(): {
9
- subscribe: typeof subscribe;
10
- onPlus: SyncEvent<ButtonResult>;
11
- onMin: SyncEvent<ButtonResult>;
12
- onEither: SyncEvent<ButtonResult>;
13
- onMessageDone: SyncEvent<number>;
14
- };
15
- export {};
@@ -1,6 +0,0 @@
1
- export declare function useBluetoothSettings(): {
2
- serviceUuid: string;
3
- messageCharUuid: string;
4
- handshakeCharUuid: string;
5
- options: BluetoothOptions;
6
- };
@@ -1,9 +0,0 @@
1
- declare function pixelsToBytes(pixels: number[], width: number): Uint8Array<ArrayBuffer>;
2
- declare function bitswap(b: number): number;
3
- declare function flattenUint8Arrays(array: Uint8Array[]): Uint8Array<ArrayBuffer>;
4
- export declare function useBinary(): {
5
- pixelsToBytes: typeof pixelsToBytes;
6
- bitswap: typeof bitswap;
7
- flattenUint8Arrays: typeof flattenUint8Arrays;
8
- };
9
- export {};
@@ -1,5 +0,0 @@
1
- declare function imageToBytes(image_url: string): Promise<Uint8Array>;
2
- export declare function useConverter(): {
3
- imageToBytes: typeof imageToBytes;
4
- };
5
- export {};
@@ -1,4 +0,0 @@
1
- export declare function map(value: number, start1: number, stop1: number, start2: number, stop2: number): number;
2
- export declare function useUtils(): {
3
- map: typeof map;
4
- };
@@ -1,9 +0,0 @@
1
- declare function createImage(url: string): Promise<HTMLImageElement>;
2
- declare function getImageData(image: HTMLImageElement): ImageData;
3
- declare function imageDataToPixels(data: ImageData): ImagePixels;
4
- export declare function useImage(): {
5
- createImage: typeof createImage;
6
- getImageData: typeof getImageData;
7
- imageDataToPixels: typeof imageDataToPixels;
8
- };
9
- export {};
@@ -1,15 +0,0 @@
1
- import { default as Standee } from './standee/Standee';
2
- import { ButtonResult } from './ble/MessageCharacteristic';
3
- import { useMesh } from './ble/Mesh';
4
- import { useMeshWriter } from './ble/MeshWriter';
5
- import { useMeshUpload } from './ble/MeshUpload';
6
- import { useStandees } from './standee/Standees';
7
- import { useStandeeElements } from './standee/StandeeElements';
8
- import { useDisplay } from './standee/Display';
9
- import { useActions } from './standee/Actions';
10
- import { useButtons } from './standee/Button';
11
- import { useBinary } from './composable/Binary';
12
- import { useImage } from './composable/Image';
13
- import { useConverter } from './composable/Converter';
14
- import { useUtils } from './composable/DisplayUtils';
15
- export { Standee, ButtonResult, useMesh, useMeshWriter, useMeshUpload, useStandees, useStandeeElements, useDisplay, useActions, useButtons, useBinary, useImage, useConverter, useUtils, };
@@ -1,74 +0,0 @@
1
- declare class Target {
2
- element_id: number;
3
- property: number;
4
- constructor(element_id: number, property: number);
5
- }
6
- export declare class Action {
7
- target: Target;
8
- constructor(target: Target);
9
- format(): Uint8Array;
10
- }
11
- export declare class Increment extends Action {
12
- format(): Uint8Array;
13
- }
14
- export declare class Decrement extends Action {
15
- format(): Uint8Array;
16
- }
17
- export declare class Show extends Action {
18
- format(): Uint8Array;
19
- }
20
- export declare class Hide extends Action {
21
- format(): Uint8Array;
22
- }
23
- export declare class Set extends Action {
24
- value: number | string;
25
- constructor(target: Target, value: number | string);
26
- format(): Uint8Array;
27
- dataType(): number;
28
- convertValue(type: number): Uint8Array;
29
- }
30
- export declare class Broadcast extends Action {
31
- format(): Uint8Array;
32
- }
33
- export declare class Break extends Action {
34
- format(): Uint8Array;
35
- }
36
- export declare class Map extends Action {
37
- fromLow: number;
38
- fromHigh: number;
39
- toLow: number;
40
- toHigh: number;
41
- value: Target;
42
- constructor(value: Target, fromLow: number, fromHigh: number, toLow: number, toHigh: number, target: Target);
43
- format(): Uint8Array;
44
- }
45
- export declare class Timer extends Action {
46
- deciseconds: number;
47
- resetable: boolean;
48
- onComplete: Array<Action>;
49
- constructor(deciseconds: number, resetable: boolean, onComplete: Array<Action>);
50
- format(): Uint8Array;
51
- }
52
- export declare class Condition extends Action {
53
- left: Target | number | string;
54
- operator: number;
55
- right: Target | number | string;
56
- actions: Array<Action>;
57
- constructor(left: Target | number | string, operator: number, right: Target | number | string, actions: Array<Action>);
58
- convertValue(value: Target | number | string): Uint8Array;
59
- format(): Uint8Array;
60
- }
61
- export declare function useActions(): {
62
- target(element_id: number, property: number): Target;
63
- increment(target: Target): Increment;
64
- decrement(target: Target): Decrement;
65
- show(element_id: number): Show;
66
- hide(element_id: number): Hide;
67
- set(target: Target, value: number | string): Set;
68
- broadcast(target?: Target): Broadcast;
69
- timer(milliseconds: number, resetable: boolean, onComplete: Array<Action>): Timer;
70
- stop(): Break;
71
- condition(left: Target | number | string, operator: number, right: Target | number | string, actions: Array<Action>): Condition;
72
- map(value: Target, fromLow: number, fromHigh: number, toLow: number, toHigh: number, target: Target): Map;
73
- };
74
- export {};
@@ -1,6 +0,0 @@
1
- import { default as Standee } from './Standee';
2
- import { Action } from './Actions';
3
- declare function useButtons(standee: Standee): {
4
- setButton(button: number, actions: Array<Action>): Promise<void>;
5
- };
6
- export { useButtons };
@@ -1,8 +0,0 @@
1
- import { default as Standee } from './Standee';
2
- declare function clear(standee: Standee): Promise<void>;
3
- declare function draw(standee: Standee): Promise<void>;
4
- export declare function useDisplay(): {
5
- clear: typeof clear;
6
- draw: typeof draw;
7
- };
8
- export {};
@@ -1,57 +0,0 @@
1
- declare class DisplayElement {
2
- id: number;
3
- dirty: boolean;
4
- _show: boolean;
5
- _x: number;
6
- _y: number;
7
- _colorBlack: boolean;
8
- constructor(x: number, y: number, show?: boolean, colorBlack?: boolean);
9
- get x(): number;
10
- get y(): number;
11
- set x(x: number);
12
- set y(y: number);
13
- set show(show: boolean);
14
- get show(): boolean;
15
- set colorBlack(colorBlack: boolean);
16
- get colorBlack(): boolean;
17
- }
18
- declare class Rectangle extends DisplayElement {
19
- _width: number;
20
- _height: number;
21
- _radius: number;
22
- _fill: boolean;
23
- constructor(x: number, y: number, width: number, height: number, radius?: number, fill?: boolean, show?: boolean, colorBlack?: boolean);
24
- set width(width: number);
25
- set height(height: number);
26
- set radius(radius: number);
27
- set fill(fill: boolean);
28
- get width(): number;
29
- get height(): number;
30
- get radius(): number;
31
- get fill(): boolean;
32
- }
33
- declare class Image extends DisplayElement {
34
- _width: number;
35
- _height: number;
36
- _data: number;
37
- constructor(x: number, y: number, width: number, height: number, data: number, show?: boolean, colorBlack?: boolean);
38
- set width(width: number);
39
- set height(height: number);
40
- set data(data: number);
41
- get width(): number;
42
- get height(): number;
43
- get data(): number;
44
- }
45
- declare class Text extends DisplayElement {
46
- _text: string;
47
- _font: number;
48
- _center: boolean;
49
- constructor(x: number, y: number, text: string, font: number, center?: boolean, show?: boolean, colorBlack?: boolean);
50
- set text(text: string);
51
- set font(font: number);
52
- get text(): string;
53
- get font(): number;
54
- get center(): boolean;
55
- set center(center: boolean);
56
- }
57
- export { DisplayElement, Rectangle, Image, Text };
@@ -1,11 +0,0 @@
1
- import { DisplayElement } from './Elements.js';
2
- import { SyncEvent } from 'ts-events';
3
- declare class Standee {
4
- id: number;
5
- elements: Array<DisplayElement>;
6
- onPlus: SyncEvent<void>;
7
- onMin: SyncEvent<void>;
8
- constructor(id: number);
9
- name(): string;
10
- }
11
- export default Standee;
@@ -1,6 +0,0 @@
1
- import { DisplayElement } from './Elements.js';
2
- import { default as Standee } from './Standee.js';
3
- export declare function useStandeeElements(standee: Standee): {
4
- add: <T>(element: DisplayElement) => T;
5
- remove: (id: number) => void;
6
- };
@@ -1,4 +0,0 @@
1
- import { default as Standee } from './Standee';
2
- export declare function useStandees(): {
3
- standees: Standee[];
4
- };