@busy-app/busy-lib 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { Client } from 'openapi-fetch';
1
+ import { Client as Client_2 } from 'openapi-fetch';
2
+ import Long_2 = require('long');
2
3
 
3
4
  export declare type AccountInfo = components['schemas']['AccountInfo'];
4
5
 
@@ -154,8 +155,117 @@ export declare interface AudioVolumeParams extends TimeoutOptions, AudioVolumeQu
154
155
 
155
156
  declare type AudioVolumeQuery = operations['setAudioVolume']['parameters']['query'];
156
157
 
158
+ /**
159
+ * Authentication progress (Handshake/Token refresh)
160
+ */
161
+ export declare enum AuthStatus {
162
+ UNAUTHENTICATED = "UNAUTHENTICATED",
163
+ AUTHENTICATING = "AUTHENTICATING",
164
+ AUTHENTICATED = "AUTHENTICATED",
165
+ FAILED = "FAILED"
166
+ }
167
+
157
168
  export declare type AutoUpdateSettings = components['schemas']['AutoupdateSettings'];
158
169
 
170
+ /**
171
+ * Base class for all StateStream connections.
172
+ * Orchestrates worker communication and callback management.
173
+ */
174
+ declare abstract class BaseStateStream {
175
+ protected addr: string;
176
+ protected token?: string;
177
+ protected isBinary: boolean;
178
+ protected connectTimeout: number;
179
+ protected dataTimeout: number;
180
+ protected abstract streamMode: StreamMode;
181
+ private worker;
182
+ private connectionTimer;
183
+ private dataTimer;
184
+ private _status;
185
+ get status(): StreamStatus;
186
+ /** Static map to deduplicate token refresh requests across all instances in this JS context */
187
+ private static tokenRefreshPromises;
188
+ protected dataCallback?: DataCallback;
189
+ protected rawDataCallback?: RawDataCallback;
190
+ protected errorCallback?: ErrorCallback_2;
191
+ protected statusCallback?: StatusCallback;
192
+ constructor(options: StreamOptions, config?: StreamConfig);
193
+ /**
194
+ * Transforms http/https to ws/wss and prefixes with auto-inferred protocol if no protocol present.
195
+ */
196
+ protected resolveProtocol(addr: string): string;
197
+ /**
198
+ * Starts the stream connection.
199
+ * Throws an error if already running.
200
+ */
201
+ start({ dataCallback, rawDataCallback, errorCallback, statusCallback }: {
202
+ dataCallback?: DataCallback;
203
+ rawDataCallback?: RawDataCallback;
204
+ errorCallback?: ErrorCallback_2;
205
+ statusCallback?: StatusCallback;
206
+ }): void;
207
+ /**
208
+ * Stops the stream connection.
209
+ */
210
+ stop(): void;
211
+ /**
212
+ * Cleans up all resources.
213
+ */
214
+ destroy(): void;
215
+ /**
216
+ * Clears all registered callbacks.
217
+ */
218
+ private clearCallbacks;
219
+ /**
220
+ * Sends a new token to the worker (for auth or token refresh).
221
+ */
222
+ protected sendToken(token: string): void;
223
+ /**
224
+ * Subclasses must provide their own URL normalization.
225
+ */
226
+ protected abstract normalizeUrl(addr: string): string;
227
+ /**
228
+ * Sends a command to the worker port.
229
+ */
230
+ protected sendCommand(cmd: WorkerCommand): void;
231
+ private ensureWorker;
232
+ /**
233
+ * Processes messages from the worker.
234
+ */
235
+ protected handleWorkerMessage(event: WorkerEvent): void;
236
+ /**
237
+ * Maps an error code to the corresponding status component
238
+ */
239
+ private mapErrorToStatus;
240
+ /**
241
+ * Updates a single component of the status and notifies listeners
242
+ */
243
+ private updateStatusComponent;
244
+ /**
245
+ * Safe timer cleanup
246
+ */
247
+ private clearConnectionTimer;
248
+ /**
249
+ * Reset the data inactivity timer
250
+ */
251
+ private resetDataTimer;
252
+ private clearDataTimer;
253
+ /**
254
+ * Normalizes the raw state from the worker into a ProcessedState for the UI.
255
+ * Extracts the 'state' key for each update and merges bar_id for remote mode.
256
+ */
257
+ private normalizeState;
258
+ /**
259
+ * Internally deduplicates token refresh requests for the same address.
260
+ */
261
+ private handleTokenExpiredInternal;
262
+ /**
263
+ * Hook for handling token expiration.
264
+ * Return a promise with the new token to enable deduplication.
265
+ */
266
+ protected onTokenExpired?(): Promise<string> | void;
267
+ }
268
+
159
269
  declare class BleMethods {
160
270
  /**
161
271
  * Enable BLE. Starts advertising.
@@ -195,6 +305,617 @@ export declare type BleStatusResponse = components['schemas']['BleStatusResponse
195
305
 
196
306
  declare type Brightness = number | 'auto';
197
307
 
308
+ /** Namespace BSB_Error. */
309
+ export declare namespace BSB_Error {
310
+
311
+ /** Cause enum. */
312
+ export enum Cause {
313
+ RESOURCE_LIMIT = 0
314
+ }
315
+
316
+ /** Severity enum. */
317
+ export enum Severity {
318
+ FATAL = 0,
319
+ ERROR = 1,
320
+ WARNING = 2
321
+ }
322
+
323
+ /** Properties of an Error. */
324
+ export interface Error {
325
+
326
+ /** Error cause */
327
+ cause?: (BSB_Error.Cause|null);
328
+
329
+ /** Error severity */
330
+ severity?: (BSB_Error.Severity|null);
331
+ }
332
+
333
+ }
334
+
335
+ /** Namespace BSB_Frame. */
336
+ export declare namespace BSB_Frame {
337
+
338
+ /** Encoding enum. */
339
+ export enum Encoding {
340
+ PLAIN = 0,
341
+ RUN_LENGTH = 1,
342
+ DEFLATE = 2,
343
+ DEFLATE_RUN_LENGTH = 3
344
+ }
345
+
346
+ /** PixelFormat enum. */
347
+ export enum PixelFormat {
348
+ RGB888 = 0,
349
+ L8 = 1,
350
+ L4 = 2
351
+ }
352
+
353
+ /** Screen enum. */
354
+ export enum Screen {
355
+ FRONT = 0,
356
+ BACK = 1
357
+ }
358
+
359
+ /** Properties of a Frame. */
360
+ export interface Frame {
361
+
362
+ /** Frame screen */
363
+ screen?: (BSB_Frame.Screen|null);
364
+
365
+ /** Frame width */
366
+ width?: (number|null);
367
+
368
+ /** Frame height */
369
+ height?: (number|null);
370
+
371
+ /** Frame encoding */
372
+ encoding?: (BSB_Frame.Encoding|null);
373
+
374
+ /** Frame pixelFormat */
375
+ pixelFormat?: (BSB_Frame.PixelFormat|null);
376
+
377
+ /** Frame data */
378
+ data?: (Uint8Array|null);
379
+ }
380
+
381
+ }
382
+
383
+ /** Namespace BSB_Input. */
384
+ export declare namespace BSB_Input {
385
+
386
+ /** Button enum. */
387
+ export enum Button {
388
+ OK = 0,
389
+ BACK = 1,
390
+ START = 2
391
+ }
392
+
393
+ /** ButtonAction enum. */
394
+ export enum ButtonAction {
395
+ PRESS = 0,
396
+ RELEASE = 1
397
+ }
398
+
399
+ /** SwitchPosition enum. */
400
+ export enum SwitchPosition {
401
+ BUSY = 0,
402
+ CUSTOM = 1,
403
+ OFF = 2,
404
+ APPS = 3,
405
+ SETTINGS = 4
406
+ }
407
+
408
+ /** Properties of a ButtonEvent. */
409
+ export interface ButtonEvent {
410
+
411
+ /** ButtonEvent button */
412
+ button?: (BSB_Input.Button|null);
413
+
414
+ /** ButtonEvent action */
415
+ action?: (BSB_Input.ButtonAction|null);
416
+ }
417
+
418
+
419
+ /** Properties of a SwitchEvent. */
420
+ export interface SwitchEvent {
421
+
422
+ /** SwitchEvent position */
423
+ position?: (BSB_Input.SwitchPosition|null);
424
+ }
425
+
426
+
427
+ /** Properties of an EncoderEvent. */
428
+ export interface EncoderEvent {
429
+
430
+ /** EncoderEvent delta */
431
+ delta?: (number|null);
432
+ }
433
+
434
+
435
+ /** Properties of an InputEvent. */
436
+ export interface InputEvent {
437
+
438
+ /** InputEvent buttonEvent */
439
+ buttonEvent?: (BSB_Input.ButtonEvent|null);
440
+
441
+ /** InputEvent switchEvent */
442
+ switchEvent?: (BSB_Input.SwitchEvent|null);
443
+
444
+ /** InputEvent encoderEvent */
445
+ encoderEvent?: (BSB_Input.EncoderEvent|null);
446
+ }
447
+
448
+ }
449
+
450
+ /** Namespace BSB_State. */
451
+ export declare namespace BSB_State {
452
+
453
+ /** Properties of a StateUpdate. */
454
+ export interface StateUpdate {
455
+
456
+ /** StateUpdate deviceName */
457
+ deviceName?: (BSB_State.DeviceName|null);
458
+
459
+ /** StateUpdate power */
460
+ power?: (BSB_State.Power|null);
461
+
462
+ /** StateUpdate brightness */
463
+ brightness?: (BSB_State.Brightness|null);
464
+
465
+ /** StateUpdate audioVolume */
466
+ audioVolume?: (BSB_State.AudioVolume|null);
467
+
468
+ /** StateUpdate wifi */
469
+ wifi?: (BSB_State.Wifi|null);
470
+
471
+ /** StateUpdate updateState */
472
+ updateState?: (BSB_Update.UpdateState|null);
473
+
474
+ /** StateUpdate updateCheck */
475
+ updateCheck?: (BSB_Update.CheckState|null);
476
+
477
+ /** StateUpdate timezone */
478
+ timezone?: (BSB_State.Timezone|null);
479
+
480
+ /** StateUpdate matter */
481
+ matter?: (BSB_State.Matter|null);
482
+
483
+ /** StateUpdate frame */
484
+ frame?: (BSB_Frame.Frame|null);
485
+
486
+ /** StateUpdate input */
487
+ input?: (BSB_Input.InputEvent|null);
488
+
489
+ /** StateUpdate timer */
490
+ timer?: (BSB_Timer.Timer|null);
491
+
492
+ /** StateUpdate ble */
493
+ ble?: (BSB_State.Ble.Ble|null);
494
+
495
+ /** StateUpdate autoUpdateState */
496
+ autoUpdateState?: (BSB_Update.AutoUpdateState|null);
497
+ }
498
+
499
+
500
+ /** Properties of a State. */
501
+ export interface State {
502
+
503
+ /** State timestamp */
504
+ timestamp?: (number|Long_2|null);
505
+
506
+ /** State updates */
507
+ updates?: (BSB_State.StateUpdate[]|null);
508
+
509
+ /** State error */
510
+ error?: (BSB_Error.Error|null);
511
+ }
512
+
513
+
514
+ /** Properties of a DeviceName. */
515
+ export interface DeviceName {
516
+
517
+ /** DeviceName name */
518
+ name?: (string|null);
519
+ }
520
+
521
+
522
+ /** Properties of a BrightnessAutomatic. */
523
+ export interface BrightnessAutomatic {
524
+ }
525
+
526
+
527
+ /** Properties of a BrightnessManual. */
528
+ export interface BrightnessManual {
529
+
530
+ /** BrightnessManual brightness */
531
+ brightness?: (number|null);
532
+ }
533
+
534
+
535
+ /** Properties of a Brightness. */
536
+ export interface Brightness {
537
+
538
+ /** Brightness automatic */
539
+ automatic?: (BSB_State.BrightnessAutomatic|null);
540
+
541
+ /** Brightness manual */
542
+ manual?: (BSB_State.BrightnessManual|null);
543
+
544
+ /** Brightness actualBrightness */
545
+ actualBrightness?: (number|null);
546
+ }
547
+
548
+
549
+ /** BatteryStatus enum. */
550
+ export enum BatteryStatus {
551
+ DISCHARGING = 0,
552
+ CHARGING = 1,
553
+ CHARGED = 2
554
+ }
555
+
556
+ /** Properties of an UnknownPowerState. */
557
+ export interface UnknownPowerState {
558
+ }
559
+
560
+
561
+ /** Properties of a PowerState. */
562
+ export interface PowerState {
563
+
564
+ /** PowerState batteryStatus */
565
+ batteryStatus?: (BSB_State.BatteryStatus|null);
566
+
567
+ /** PowerState batteryChargePercent */
568
+ batteryChargePercent?: (number|null);
569
+
570
+ /** PowerState batteryVoltageMv */
571
+ batteryVoltageMv?: (number|null);
572
+
573
+ /** PowerState batteryCurrentMa */
574
+ batteryCurrentMa?: (number|null);
575
+
576
+ /** PowerState usbVoltageMv */
577
+ usbVoltageMv?: (number|null);
578
+ }
579
+
580
+
581
+ /** Properties of a Power. */
582
+ export interface Power {
583
+
584
+ /** Power unknown */
585
+ unknown?: (BSB_State.UnknownPowerState|null);
586
+
587
+ /** Power known */
588
+ known?: (BSB_State.PowerState|null);
589
+ }
590
+
591
+
592
+ /** Properties of an AudioVolume. */
593
+ export interface AudioVolume {
594
+
595
+ /** AudioVolume volume */
596
+ volume?: (number|null);
597
+ }
598
+
599
+
600
+ /** WifiConnectionStatus enum. */
601
+ export enum WifiConnectionStatus {
602
+ CONNECTED = 0,
603
+ CONNECTING = 1,
604
+ DISCONNECTING = 2,
605
+ RECONNECTING = 3
606
+ }
607
+
608
+ /** WifiSecurity enum. */
609
+ export enum WifiSecurity {
610
+ UNKNOWN = 0,
611
+ OPEN = 1,
612
+ WPA = 2,
613
+ WPA2 = 3,
614
+ WEP = 4,
615
+ WPA_WPA2 = 5,
616
+ WPA3 = 6,
617
+ WPA2_WPA3 = 7
618
+ }
619
+
620
+ /** IpConfigurationMethod enum. */
621
+ export enum IpConfigurationMethod {
622
+ DHCP = 0,
623
+ STATIC = 1
624
+ }
625
+
626
+ /** IpProtocol enum. */
627
+ export enum IpProtocol {
628
+ IPV4 = 0,
629
+ IPV6 = 1
630
+ }
631
+
632
+ /** Properties of a WifiStateUnknown. */
633
+ export interface WifiStateUnknown {
634
+ }
635
+
636
+
637
+ /** Properties of a WifiStateDisconnected. */
638
+ export interface WifiStateDisconnected {
639
+ }
640
+
641
+
642
+ /** Properties of a WifiStateConnected. */
643
+ export interface WifiStateConnected {
644
+
645
+ /** WifiStateConnected status */
646
+ status?: (BSB_State.WifiConnectionStatus|null);
647
+
648
+ /** WifiStateConnected ssid */
649
+ ssid?: (string|null);
650
+
651
+ /** WifiStateConnected bssid */
652
+ bssid?: (string|null);
653
+
654
+ /** WifiStateConnected channel */
655
+ channel?: (number|null);
656
+
657
+ /** WifiStateConnected rssi */
658
+ rssi?: (number|null);
659
+
660
+ /** WifiStateConnected security */
661
+ security?: (BSB_State.WifiSecurity|null);
662
+ }
663
+
664
+
665
+ /** Properties of an IpAddress. */
666
+ export interface IpAddress {
667
+
668
+ /** IpAddress protocol */
669
+ protocol?: (BSB_State.IpProtocol|null);
670
+
671
+ /** IpAddress method */
672
+ method?: (BSB_State.IpConfigurationMethod|null);
673
+
674
+ /** IpAddress address */
675
+ address?: (string|null);
676
+
677
+ /** IpAddress gateway */
678
+ gateway?: (string|null);
679
+
680
+ /** IpAddress netmask */
681
+ netmask?: (string|null);
682
+ }
683
+
684
+
685
+ /** Properties of a Wifi. */
686
+ export interface Wifi {
687
+
688
+ /** Wifi unknown */
689
+ unknown?: (BSB_State.WifiStateUnknown|null);
690
+
691
+ /** Wifi disconnected */
692
+ disconnected?: (BSB_State.WifiStateDisconnected|null);
693
+
694
+ /** Wifi connected */
695
+ connected?: (BSB_State.WifiStateConnected|null);
696
+
697
+ /** Wifi ipAddresses */
698
+ ipAddresses?: (BSB_State.IpAddress[]|null);
699
+ }
700
+
701
+
702
+ /** Properties of a Timezone. */
703
+ export interface Timezone {
704
+
705
+ /** Timezone name */
706
+ name?: (string|null);
707
+
708
+ /** Timezone offset */
709
+ offset?: (number|null);
710
+
711
+ /** Timezone abbr */
712
+ abbr?: (string|null);
713
+ }
714
+
715
+
716
+ /** MatterCommissioningStatus enum. */
717
+ export enum MatterCommissioningStatus {
718
+ NEVER_STARTED = 0,
719
+ STARTED = 1,
720
+ COMPLETED_SUCCESSFULLY = 2,
721
+ FAILED = 3
722
+ }
723
+
724
+ /** Properties of a MatterCommissioningState. */
725
+ export interface MatterCommissioningState {
726
+
727
+ /** MatterCommissioningState status */
728
+ status?: (BSB_State.MatterCommissioningStatus|null);
729
+
730
+ /** MatterCommissioningState timestamp */
731
+ timestamp?: (number|Long_2|null);
732
+ }
733
+
734
+
735
+ /** Properties of a Matter. */
736
+ export interface Matter {
737
+
738
+ /** Matter fabricCount */
739
+ fabricCount?: (number|null);
740
+
741
+ /** Matter state */
742
+ state?: (BSB_State.MatterCommissioningState|null);
743
+ }
744
+
745
+
746
+ /** Namespace Ble. */
747
+ export namespace Ble {
748
+
749
+ /** ServiceStatus enum. */
750
+ export enum ServiceStatus {
751
+ RESET = 0,
752
+ INITIALIZATION = 1,
753
+ READY = 2,
754
+ ADVERTISING = 3,
755
+ CONNECTABLE = 4,
756
+ CONNECTED = 5,
757
+ ERROR = 6
758
+ }
759
+
760
+ /** Properties of a Ble. */
761
+ export interface Ble {
762
+
763
+ /** Ble status */
764
+ status?: (BSB_State.Ble.ServiceStatus|null);
765
+
766
+ /** Ble remoteAddress */
767
+ remoteAddress?: (string|null);
768
+ }
769
+
770
+ }
771
+ }
772
+
773
+ /** Namespace BSB_Timer. */
774
+ export declare namespace BSB_Timer {
775
+
776
+ /** Properties of a Timer. */
777
+ export interface Timer {
778
+
779
+ /** Timer json */
780
+ json?: (BSB_Util.Json|null);
781
+ }
782
+
783
+ }
784
+
785
+ /** Namespace BSB_Update. */
786
+ export declare namespace BSB_Update {
787
+
788
+ /** UpdateEvent enum. */
789
+ export enum UpdateEvent {
790
+ SESSION_START = 0,
791
+ SESSION_STOP = 1,
792
+ ACTION_BEGIN = 2,
793
+ ACTION_DONE = 3,
794
+ DETAIL_CHANGE = 4,
795
+ ACTION_PROGRESS = 5,
796
+ EVENT_NONE = 6
797
+ }
798
+
799
+ /** UpdateAction enum. */
800
+ export enum UpdateAction {
801
+ DOWNLOAD = 0,
802
+ SHA_VERIFICATION = 1,
803
+ UNPACK = 2,
804
+ INSTALLATION_PREPARE = 3,
805
+ INSTALLATION_APPLY = 4,
806
+ ACTION_NONE = 5
807
+ }
808
+
809
+ /** UpdateStatus enum. */
810
+ export enum UpdateStatus {
811
+ OK = 0,
812
+ BATTERY_LOW = 1,
813
+ BUSY = 2,
814
+ DOWNLOAD_FAILURE = 3,
815
+ DOWNLOAD_ABORT = 4,
816
+ SHA_MISMATCH = 5,
817
+ UNPACK_CREATE_STAGING_DIRECTORY_FAILURE = 6,
818
+ UNPACK_ARCHIVE_OPEN_FAILURE = 7,
819
+ UNPACK_ARCHIVE_UNPACK_FAILURE = 8,
820
+ INSTALLATION_PREPARE_MANIFEST_NOT_FOUND = 9,
821
+ INSTALLATION_PREPARE_MANIFEST_INVALID = 10,
822
+ INSTALLATION_PREPARE_SESSION_CONFIG_SETUP_FAILURE = 11,
823
+ INSTALLATION_PREPARE_POINTER_SETUP_FAILURE = 12,
824
+ UNKNOWN_FAILURE = 13
825
+ }
826
+
827
+ /** CheckError enum. */
828
+ export enum CheckError {
829
+ NOT_AVAILABLE = 0,
830
+ FAILURE = 1,
831
+ IDLE = 2
832
+ }
833
+
834
+ /** Properties of an UpdateAvailable. */
835
+ export interface UpdateAvailable {
836
+
837
+ /** UpdateAvailable version */
838
+ version?: (string|null);
839
+ }
840
+
841
+
842
+ /** Properties of an UpdateUnavailable. */
843
+ export interface UpdateUnavailable {
844
+
845
+ /** UpdateUnavailable reason */
846
+ reason?: (BSB_Update.CheckError|null);
847
+ }
848
+
849
+
850
+ /** Properties of an UpdateState. */
851
+ export interface UpdateState {
852
+
853
+ /** UpdateState event */
854
+ event?: (BSB_Update.UpdateEvent|null);
855
+
856
+ /** UpdateState action */
857
+ action?: (BSB_Update.UpdateAction|null);
858
+
859
+ /** UpdateState status */
860
+ status?: (BSB_Update.UpdateStatus|null);
861
+ }
862
+
863
+
864
+ /** Properties of a CheckState. */
865
+ export interface CheckState {
866
+
867
+ /** CheckState available */
868
+ available?: (BSB_Update.UpdateAvailable|null);
869
+
870
+ /** CheckState unavailable */
871
+ unavailable?: (BSB_Update.UpdateUnavailable|null);
872
+ }
873
+
874
+
875
+ /** Properties of an AutoUpdateInterval. */
876
+ export interface AutoUpdateInterval {
877
+
878
+ /** AutoUpdateInterval start */
879
+ start?: (number|null);
880
+
881
+ /** AutoUpdateInterval end */
882
+ end?: (number|null);
883
+ }
884
+
885
+
886
+ /** Properties of an AutoUpdateState. */
887
+ export interface AutoUpdateState {
888
+
889
+ /** AutoUpdateState enabled */
890
+ enabled?: (boolean|null);
891
+
892
+ /** AutoUpdateState interval */
893
+ interval?: (BSB_Update.AutoUpdateInterval|null);
894
+ }
895
+
896
+ }
897
+
898
+ /** Namespace BSB_Util. */
899
+ export declare namespace BSB_Util {
900
+
901
+ /** Compression enum. */
902
+ export enum Compression {
903
+ PLAIN = 0,
904
+ GZIP = 1
905
+ }
906
+
907
+ /** Properties of a Json. */
908
+ export interface Json {
909
+
910
+ /** Json compression */
911
+ compression?: (BSB_Util.Compression|null);
912
+
913
+ /** Json data */
914
+ data?: (Uint8Array|null);
915
+ }
916
+
917
+ }
918
+
198
919
  export declare interface BusyBar extends SystemMethods, UpdateMethods, TimeMethods, AccountMethods, DisplayMethods, AudioMethods, WifiMethods, StorageMethods, SettingsMethods, BleMethods, InputMethods, AssetsMethods, SmartHomeMethods {
199
920
  }
200
921
 
@@ -268,7 +989,7 @@ export declare class BusyBar {
268
989
  setToken(token: string): void;
269
990
  }
270
991
 
271
- declare type BusyBarClient = Client<paths, `${string}/${string}`>;
992
+ declare type BusyBarClient = Client_2<paths, `${string}/${string}`>;
272
993
 
273
994
  export declare type BusyBarConfig = {
274
995
  addr?: string;
@@ -1118,10 +1839,34 @@ declare interface components {
1118
1839
  pathItems: never;
1119
1840
  }
1120
1841
 
1842
+ /**
1843
+ * Detailed WebSocket connection state
1844
+ */
1845
+ export declare enum ConnectionStatus {
1846
+ DISCONNECTED = "DISCONNECTED",
1847
+ CONNECTING = "CONNECTING",
1848
+ CONNECTED = "CONNECTED",
1849
+ RECONNECTING = "RECONNECTING"
1850
+ }
1851
+
1121
1852
  export declare type CountdownElement = components['schemas']['CountdownElement'];
1122
1853
 
1854
+ /**
1855
+ * Callbacks for the main thread
1856
+ */
1857
+ export declare type DataCallback = (data: ProcessedState) => void;
1858
+
1123
1859
  declare type DataListener = (data: Uint8Array) => void;
1124
1860
 
1861
+ /**
1862
+ * Data throughput state
1863
+ */
1864
+ export declare enum DataStatus {
1865
+ NONE = "NONE",
1866
+ ACTIVE = "ACTIVE",
1867
+ STALE = "STALE"
1868
+ }
1869
+
1125
1870
  export declare enum DeviceScreen {
1126
1871
  FRONT = 0,
1127
1872
  BACK = 1
@@ -1196,6 +1941,9 @@ declare class DisplayMethods {
1196
1941
  declare type Error_2 = components['schemas']['Error'];
1197
1942
  export { Error_2 as Error }
1198
1943
 
1944
+ declare type ErrorCallback_2 = (error: StateStreamError) => void;
1945
+ export { ErrorCallback_2 as ErrorCallback }
1946
+
1199
1947
  declare type ErrorListener = (payload: ErrorPayload) => void;
1200
1948
 
1201
1949
  declare interface ErrorPayload {
@@ -1265,6 +2013,58 @@ export declare type KeyName = operations['setInputKey']['parameters']['query']['
1265
2013
 
1266
2014
  export declare type KeyValue = 1 | 0;
1267
2015
 
2016
+ export declare const LEDRenderer: LEDRenderer_2;
2017
+
2018
+ /**
2019
+ * LEDRenderer - A singleton WebGL2-based engine for rendering pixel grids.
2020
+ */
2021
+ declare class LEDRenderer_2 {
2022
+ private static instance;
2023
+ private gl;
2024
+ private program;
2025
+ private texture;
2026
+ private vs;
2027
+ private fs;
2028
+ constructor();
2029
+ /**
2030
+ * Lazily initializes the WebGL context and resources.
2031
+ * Only executes in a browser environment.
2032
+ */
2033
+ private init;
2034
+ /**
2035
+ * Internal WebGL rendering pass.
2036
+ */
2037
+ private render;
2038
+ /**
2039
+ * Public API: Renders the LED frame to a target 2D canvas.
2040
+ */
2041
+ renderFrame(targetCanvas: HTMLCanvasElement, data: Uint8Array | Uint8ClampedArray, width: number, height: number, options?: {
2042
+ pixelSize?: number;
2043
+ radius?: number;
2044
+ darkThreshold?: number;
2045
+ } | undefined): void;
2046
+ private createProgram;
2047
+ }
2048
+
2049
+ /**
2050
+ * Connection for local BUSY Bar devices via direct IP.
2051
+ * Uses ws:// and binary protobuf protocol.
2052
+ */
2053
+ export declare class LocalStateStream extends BaseStateStream {
2054
+ protected streamMode: StreamMode;
2055
+ constructor(options?: LocalStreamOptions, config?: StreamConfig);
2056
+ /**
2057
+ * Normalizes the address to use ws:// protocol and adds default path if missing.
2058
+ */
2059
+ protected normalizeUrl(addr: string): string;
2060
+ }
2061
+
2062
+ /**
2063
+ * Options for local device connections
2064
+ */
2065
+ export declare interface LocalStreamOptions extends StreamOptions {
2066
+ }
2067
+
1268
2068
  export declare type NameInfo = components['schemas']['NameInfo'];
1269
2069
 
1270
2070
  export declare interface NameParams extends TimeoutOptions, NameInfo {
@@ -4489,6 +5289,89 @@ declare interface paths {
4489
5289
  };
4490
5290
  }
4491
5291
 
5292
+ /**
5293
+ * Helper to force TypeScript to expand complex types in tooltips.
5294
+ * It maps over each property and "flattens" the type.
5295
+ */
5296
+ declare type Prettify<T> = {
5297
+ [K in keyof T]: T[K];
5298
+ } & {};
5299
+
5300
+ /**
5301
+ * Frame with RGBA support after worker processing
5302
+ */
5303
+ export declare type ProcessedFrame = Prettify<Omit<BSB_Frame.Frame, 'data'> & {
5304
+ data?: Uint8Array | Uint8ClampedArray | null;
5305
+ }>;
5306
+
5307
+ /**
5308
+ * Protobuf State with processed updates.
5309
+ */
5310
+ export declare type ProcessedSchemaState = Prettify<Omit<BSB_State.State, 'updates'> & {
5311
+ updates?: ProcessedUpdate[] | null;
5312
+ }>;
5313
+
5314
+ /**
5315
+ * Final state structure passed to callers.
5316
+ */
5317
+ export declare type ProcessedState = Prettify<ProcessedSchemaState & {
5318
+ bar_id?: string;
5319
+ }>;
5320
+
5321
+ /**
5322
+ * StateUpdate with an optional 'state' key identifying the active module.
5323
+ * Also uses our ProcessedFrame for the 'frame' field.
5324
+ */
5325
+ export declare type ProcessedUpdate = Prettify<Omit<BSB_State.StateUpdate, 'frame'> & {
5326
+ state?: StateUpdateKey;
5327
+ frame?: ProcessedFrame | null;
5328
+ }>;
5329
+
5330
+ export declare type RawDataCallback = (data: Uint8Array | string) => void;
5331
+
5332
+ /**
5333
+ * Wrapped structure for Remote mode
5334
+ */
5335
+ export declare type RemoteState = Prettify<{
5336
+ bar_id: string;
5337
+ state: ProcessedSchemaState;
5338
+ }>;
5339
+
5340
+ /**
5341
+ * Connection for remote BUSY Bar devices via Remote.
5342
+ * Uses wss:// and provides subscription management.
5343
+ */
5344
+ export declare class RemoteStateStream extends BaseStateStream {
5345
+ protected streamMode: StreamMode;
5346
+ private tokenProvider?;
5347
+ constructor(options: RemoteStreamOptions, config?: StreamConfig);
5348
+ /**
5349
+ * Subscribes to updates for a specific device GUID.
5350
+ */
5351
+ subscribe(guid: string): void;
5352
+ /**
5353
+ * Unsubscribes from updates for a specific device GUID.
5354
+ */
5355
+ unsubscribe(guid: string): void;
5356
+ /**
5357
+ * Standardizes the address to use wss:// or ws:// protocol.
5358
+ */
5359
+ protected normalizeUrl(addr: string): string;
5360
+ /**
5361
+ * Handles token expiration by invoking the tokenProvider.
5362
+ * Returns the promise for deduplication.
5363
+ */
5364
+ protected onTokenExpired(): Promise<string> | void;
5365
+ }
5366
+
5367
+ /**
5368
+ * Options for remote connections
5369
+ */
5370
+ export declare interface RemoteStreamOptions extends StreamOptions {
5371
+ addr: string;
5372
+ tokenProvider?: () => Promise<string>;
5373
+ }
5374
+
4492
5375
  declare type RequiredIpConfig = RequireKeys<NonNullable<WifiConnectRequestConfig['ip_config']>, 'ip_method'>;
4493
5376
 
4494
5377
  declare type RequireKeys<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;
@@ -4627,8 +5510,50 @@ export declare type SmartHomePairingPayload = components['schemas']['SmartHomePa
4627
5510
 
4628
5511
  export declare type SmartHomeSwitchState = components['schemas']['SmartHomeSwitchState'];
4629
5512
 
5513
+ /**
5514
+ * Custom error class for StateStream with machine-readable codes
5515
+ */
5516
+ export declare class StateStreamError extends Error {
5517
+ readonly code: StateStreamErrorCode;
5518
+ readonly data?: any | undefined;
5519
+ constructor(code: StateStreamErrorCode, message: string, data?: any | undefined);
5520
+ }
5521
+
5522
+ /**
5523
+ * Error codes for StateStream
5524
+ */
5525
+ export declare enum StateStreamErrorCode {
5526
+ CONNECTION_FAILED = "CONNECTION_FAILED",
5527
+ RECONNECT_FAILED = "RECONNECT_FAILED",
5528
+ CONNECTION_LOST = "CONNECTION_LOST",
5529
+ CONNECTION_TIMEOUT = "CONNECTION_TIMEOUT",
5530
+ AUTH_FAILED = "AUTH_FAILED",
5531
+ AUTH_REFRESH_FAILED = "AUTH_REFRESH_FAILED",
5532
+ DEVICE_ERROR = "DEVICE_ERROR",
5533
+ DECODE_ERROR = "DECODE_ERROR",
5534
+ FRAME_PROCESS_ERROR = "FRAME_PROCESS_ERROR",
5535
+ STREAM_ALREADY_STARTED = "STREAM_ALREADY_STARTED",
5536
+ WORKER_INIT_FAILED = "WORKER_INIT_FAILED",
5537
+ UNKNOWN_ERROR = "UNKNOWN_ERROR"
5538
+ }
5539
+
5540
+ /**
5541
+ * All possible keys in BSB_State.StateUpdate, automatically inferred from the schema.
5542
+ */
5543
+ export declare type StateUpdateKey = keyof BSB_State.StateUpdate & string;
5544
+
4630
5545
  export declare type Status = components['schemas']['Status'];
4631
5546
 
5547
+ export declare type StatusCallback = (status: StreamStatus) => void;
5548
+
5549
+ /**
5550
+ * Generic container for status and error, reused across components
5551
+ */
5552
+ export declare interface StatusComponent<E> {
5553
+ status: E;
5554
+ lastError?: StateStreamError;
5555
+ }
5556
+
4632
5557
  export declare type StatusDevice = components['schemas']['StatusDevice'];
4633
5558
 
4634
5559
  export declare type StatusFirmware = components['schemas']['StatusFirmware'];
@@ -4751,6 +5676,54 @@ export declare interface StorageUploadFileParams extends TimeoutOptions, Storage
4751
5676
 
4752
5677
  declare type StorageWriteQuery = operations['writeStorageFile']['parameters']['query'];
4753
5678
 
5679
+ /**
5680
+ * Global configuration for the stream behavior
5681
+ */
5682
+ export declare interface StreamConfig {
5683
+ /** Connection timeout in milliseconds. Default: 5000ms */
5684
+ timeout?: number;
5685
+ /** Data inactivity timeout in milliseconds. Default: 15000ms */
5686
+ dataTimeout?: number;
5687
+ }
5688
+
5689
+ /**
5690
+ * High-level lifecycle of the StateStream class instance
5691
+ */
5692
+ export declare enum StreamLifecycle {
5693
+ IDLE = "IDLE",
5694
+ STARTING = "STARTING",
5695
+ RUNNING = "RUNNING",
5696
+ STOPPED = "STOPPED",
5697
+ FAILED = "FAILED"
5698
+ }
5699
+
5700
+ /**
5701
+ * Generic container for status and error, reused across components
5702
+ */
5703
+ declare type StreamMode = 'local' | 'remote';
5704
+
5705
+ /**
5706
+ * Base internal options for connections
5707
+ */
5708
+ declare interface StreamOptions {
5709
+ addr?: string;
5710
+ token?: string;
5711
+ isBinary?: boolean;
5712
+ }
5713
+
5714
+ /**
5715
+ * The unified StateStream status object
5716
+ */
5717
+ export declare interface StreamStatus {
5718
+ main: StatusComponent<StreamLifecycle>;
5719
+ connection: StatusComponent<ConnectionStatus>;
5720
+ auth: StatusComponent<AuthStatus>;
5721
+ data: StatusComponent<DataStatus> & {
5722
+ lastActivity?: number;
5723
+ };
5724
+ worker: StatusComponent<WorkerStatus>;
5725
+ }
5726
+
4754
5727
  export declare type SuccessResponse = components['schemas']['SuccessResponse'];
4755
5728
 
4756
5729
  declare class SystemMethods {
@@ -5022,4 +5995,63 @@ export declare type WifiSecurityMethod = components['schemas']['WifiSecurityMeth
5022
5995
 
5023
5996
  export declare type WifiStatusResponse = components['schemas']['StatusResponse'];
5024
5997
 
5998
+ /**
5999
+ * Worker Commands (Sent from main thread to worker)
6000
+ */
6001
+ declare type WorkerCommand = {
6002
+ type: 'START';
6003
+ addr: string;
6004
+ token?: string;
6005
+ isBinary: boolean;
6006
+ mode: StreamMode;
6007
+ } | {
6008
+ type: 'STOP';
6009
+ } | {
6010
+ type: 'UPDATE_TOKEN';
6011
+ token: string;
6012
+ } | {
6013
+ type: 'SUBSCRIBE';
6014
+ guid: string;
6015
+ } | {
6016
+ type: 'UNSUBSCRIBE';
6017
+ guid: string;
6018
+ };
6019
+
6020
+ /**
6021
+ * Worker Events (Sent from worker to main thread)
6022
+ */
6023
+ declare type WorkerEvent = {
6024
+ type: 'CONNECTED';
6025
+ } | {
6026
+ type: 'DISCONNECTED';
6027
+ } | {
6028
+ type: 'TOKEN_EXPIRED';
6029
+ } | {
6030
+ type: 'ERROR';
6031
+ code: StateStreamErrorCode;
6032
+ message: string;
6033
+ data?: any;
6034
+ } | {
6035
+ type: 'RAW_DATA';
6036
+ data: Uint8Array | string;
6037
+ } | {
6038
+ type: 'DATA';
6039
+ data: ProcessedSchemaState | RemoteState;
6040
+ } | {
6041
+ type: 'STATUS_UPDATE';
6042
+ connection?: ConnectionStatus;
6043
+ auth?: AuthStatus;
6044
+ worker?: WorkerStatus;
6045
+ };
6046
+
6047
+ /**
6048
+ * Internal Worker/Infrastructure state
6049
+ */
6050
+ export declare enum WorkerStatus {
6051
+ OFF = "OFF",
6052
+ INITIALIZING = "INITIALIZING",
6053
+ READY = "READY",
6054
+ ERROR = "ERROR"
6055
+ }
6056
+
5025
6057
  export { }