@busy-app/busy-lib 0.4.0 → 0.6.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.js CHANGED
@@ -1,20 +1,20 @@
1
- var k = Object.defineProperty;
2
- var P = (e, t, i) => t in e ? k(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
1
+ var T = Object.defineProperty;
2
+ var P = (e, t, i) => t in e ? T(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
3
3
  var o = (e, t, i) => P(e, typeof t != "symbol" ? t + "" : t, i);
4
- import T from "openapi-fetch";
4
+ import v from "openapi-fetch";
5
5
  const b = (e, t) => {
6
6
  if (typeof FormData < "u" && e instanceof FormData || typeof Buffer < "u" && typeof Buffer.isBuffer == "function" && Buffer.isBuffer(e) || typeof File < "u" && e instanceof File || typeof Blob < "u" && e instanceof Blob || typeof ArrayBuffer < "u" && e instanceof ArrayBuffer || typeof ArrayBuffer < "u" && ArrayBuffer.isView && ArrayBuffer.isView(e))
7
7
  return e;
8
8
  let i;
9
9
  return t && (t instanceof Headers ? i = t.get("Content-Type") ?? t.get("content-type") ?? void 0 : typeof t == "object" && (i = t["Content-Type"] ?? t["content-type"]), i === "application/x-www-form-urlencoded") ? e && typeof e == "object" && !(e instanceof URLSearchParams) ? new URLSearchParams(e).toString() : String(e) : JSON.stringify(e);
10
10
  };
11
- let p, w, h = null;
12
- async function E() {
11
+ let y, w, h = null;
12
+ async function A() {
13
13
  if (!w) {
14
- if (!p)
14
+ if (!y)
15
15
  throw new Error("getApiVersionFn is not set");
16
16
  h || (h = (async () => {
17
- const e = await p();
17
+ const e = await y();
18
18
  if (!e.api_semver)
19
19
  throw new Error("Empty API version");
20
20
  w = e.api_semver;
@@ -23,7 +23,7 @@ async function E() {
23
23
  })), await h;
24
24
  }
25
25
  }
26
- async function d(e) {
26
+ async function p(e) {
27
27
  const n = (e.headers.get("content-type") || "").includes("application/json") ? await e.clone().json() : await e.clone().text(), s = typeof n == "object" && n !== null ? n.error || n.message : typeof n == "string" ? n : void 0;
28
28
  return Object.assign(
29
29
  new Error(s || `HTTP ${e.status} ${e.statusText}`),
@@ -34,41 +34,61 @@ async function d(e) {
34
34
  }
35
35
  );
36
36
  }
37
- let y;
37
+ let m;
38
38
  function I(e) {
39
- y = e;
39
+ m = e;
40
40
  }
41
- const v = {
41
+ let d;
42
+ const B = {
42
43
  async onRequest({ request: e, schemaPath: t }) {
43
- if (t !== "/version") {
44
- if (await E(), w)
45
- return e.headers.set("X-API-Sem-Ver", w);
46
- y && e.headers.set("X-API-Token", y);
47
- }
48
- return e;
44
+ return d && e.headers.set("Authorization", `Bearer ${d}`), t !== "/version" && (await A(), w && e.headers.set("X-API-Sem-Ver", w), m && e.headers.set("X-API-Token", m)), e;
49
45
  },
50
46
  async onResponse({ request: e, response: t, options: i, schemaPath: n }) {
51
47
  if (t.ok)
52
48
  return t;
53
49
  if (n === "/version")
54
- throw await d(t);
50
+ throw await p(t);
55
51
  if (t.status !== 405)
56
- throw await d(t);
57
- w = void 0, await E(), w && e.headers.set("X-API-Sem-Ver", w);
52
+ throw await p(t);
53
+ w = void 0, await A(), w && e.headers.set("X-API-Sem-Ver", w), d && e.headers.set("Authorization", `Bearer ${d}`);
58
54
  const s = await (i.fetch ?? fetch)(e);
59
55
  if (s.ok)
60
56
  return s;
61
- throw await d(s);
57
+ throw await p(s);
62
58
  }
63
59
  };
64
60
  let r = null;
65
- function B(e, t) {
66
- p = t, r = T({
61
+ function z(e, t, i) {
62
+ y = t, d = i ?? void 0, r = v({
67
63
  baseUrl: e,
68
64
  bodySerializer: b
69
- }), r.use(v);
65
+ }), r.use(B);
70
66
  }
71
- async function L(e) {
67
+ async function L() {
68
+ if (!r)
69
+ throw new Error("API client is not initialized");
70
+ const { data: e, error: t } = await r.GET("/account");
71
+ if (t)
72
+ throw t;
73
+ return e;
74
+ }
75
+ async function D() {
76
+ if (!r)
77
+ throw new Error("API client is not initialized");
78
+ const { data: e, error: t } = await r.DELETE("/account");
79
+ if (t)
80
+ throw t;
81
+ return e;
82
+ }
83
+ async function O() {
84
+ if (!r)
85
+ throw new Error("API client is not initialized");
86
+ const { data: e, error: t } = await r.POST("/account/link");
87
+ if (t)
88
+ throw t;
89
+ return e;
90
+ }
91
+ async function W(e) {
72
92
  const { appId: t, fileName: i, file: n } = e;
73
93
  if (!r)
74
94
  throw new Error("API client is not initialized");
@@ -88,7 +108,7 @@ async function L(e) {
88
108
  throw a;
89
109
  return s;
90
110
  }
91
- async function z(e) {
111
+ async function C(e) {
92
112
  const { appId: t } = e;
93
113
  if (!r)
94
114
  throw new Error("API client is not initialized");
@@ -103,23 +123,18 @@ async function z(e) {
103
123
  throw n;
104
124
  return i;
105
125
  }
106
- const D = { timeout: 5, x: 0, y: 0, display: "front" };
107
- function O(e) {
108
- return { ...D, ...e };
109
- }
110
- async function K(e) {
111
- const { appId: t, elements: i } = e;
126
+ async function R(e) {
112
127
  if (!r)
113
128
  throw new Error("API client is not initialized");
114
- const n = i.map(O), { data: s, error: a } = await r.POST("/display/draw", {
129
+ const { appId: t, elements: i } = e, { data: n, error: s } = await r.POST("/display/draw", {
115
130
  body: {
116
131
  app_id: t,
117
- elements: n
132
+ elements: i
118
133
  }
119
134
  });
120
- if (a)
121
- throw a;
122
- return s;
135
+ if (s)
136
+ throw s;
137
+ return n;
123
138
  }
124
139
  async function U() {
125
140
  if (!r)
@@ -129,7 +144,7 @@ async function U() {
129
144
  throw t;
130
145
  return e;
131
146
  }
132
- async function C(e) {
147
+ async function K(e) {
133
148
  const { appId: t, path: i } = e;
134
149
  if (!r)
135
150
  throw new Error("API client is not initialized");
@@ -145,31 +160,15 @@ async function C(e) {
145
160
  throw s;
146
161
  return n;
147
162
  }
148
- async function W() {
149
- if (!r)
150
- throw new Error("API client is not initialized");
151
- const { data: e, error: t } = await r.DELETE("/audio/play");
152
- if (t)
153
- throw t;
154
- return e;
155
- }
156
163
  async function $() {
157
164
  if (!r)
158
165
  throw new Error("API client is not initialized");
159
- const { data: e, error: t } = await r.POST("/wifi/enable");
160
- if (t)
161
- throw t;
162
- return e;
163
- }
164
- async function F() {
165
- if (!r)
166
- throw new Error("API client is not initialized");
167
- const { data: e, error: t } = await r.POST("/wifi/disable");
166
+ const { data: e, error: t } = await r.DELETE("/audio/play");
168
167
  if (t)
169
168
  throw t;
170
169
  return e;
171
170
  }
172
- async function R() {
171
+ async function _() {
173
172
  if (!r)
174
173
  throw new Error("API client is not initialized");
175
174
  const { data: e, error: t } = await r.GET("/wifi/status");
@@ -177,7 +176,7 @@ async function R() {
177
176
  throw t;
178
177
  return e;
179
178
  }
180
- async function V(e) {
179
+ async function F(e) {
181
180
  if (!r)
182
181
  throw new Error("API client is not initialized");
183
182
  const { data: t, error: i } = await r.POST("/wifi/connect", {
@@ -187,7 +186,6 @@ async function V(e) {
187
186
  security: e.security,
188
187
  ip_config: {
189
188
  ip_method: e.ipConfig.ipMethod,
190
- ip_type: e.ipConfig.ipType,
191
189
  address: e.ipConfig.address,
192
190
  mask: e.ipConfig.mask,
193
191
  gateway: e.ipConfig.gateway
@@ -198,7 +196,7 @@ async function V(e) {
198
196
  throw i;
199
197
  return t;
200
198
  }
201
- async function x() {
199
+ async function G() {
202
200
  if (!r)
203
201
  throw new Error("API client is not initialized");
204
202
  const { data: e, error: t } = await r.POST("/wifi/disconnect");
@@ -206,7 +204,7 @@ async function x() {
206
204
  throw t;
207
205
  return e;
208
206
  }
209
- async function _() {
207
+ async function N() {
210
208
  if (!r)
211
209
  throw new Error("API client is not initialized");
212
210
  const { data: e, error: t } = await r.GET("/wifi/networks");
@@ -214,15 +212,7 @@ async function _() {
214
212
  throw t;
215
213
  return e;
216
214
  }
217
- async function q() {
218
- if (!r)
219
- throw new Error("API client is not initialized");
220
- const { data: e, error: t } = await r.POST("/wifi/forget");
221
- if (t)
222
- throw t;
223
- return e;
224
- }
225
- async function G(e) {
215
+ async function V(e) {
226
216
  if (!r)
227
217
  throw new Error("API client is not initialized");
228
218
  const { path: t, file: i } = e, { data: n, error: s } = await r.POST("/storage/write", {
@@ -240,7 +230,7 @@ async function G(e) {
240
230
  throw s;
241
231
  return n;
242
232
  }
243
- async function N(e) {
233
+ async function q(e) {
244
234
  if (!r)
245
235
  throw new Error("API client is not initialized");
246
236
  const { path: t, asArrayBuffer: i } = e, { data: n, error: s } = await r.GET("/storage/read", {
@@ -255,7 +245,7 @@ async function N(e) {
255
245
  throw s;
256
246
  return n;
257
247
  }
258
- async function j(e) {
248
+ async function x(e) {
259
249
  if (!r)
260
250
  throw new Error("API client is not initialized");
261
251
  const { path: t } = e, { data: i, error: n } = await r.GET("/storage/list", {
@@ -269,7 +259,7 @@ async function j(e) {
269
259
  throw n;
270
260
  return i;
271
261
  }
272
- async function H(e) {
262
+ async function j(e) {
273
263
  if (!r)
274
264
  throw new Error("API client is not initialized");
275
265
  const { path: t } = e, { data: i, error: n } = await r.DELETE("/storage/remove", {
@@ -283,7 +273,7 @@ async function H(e) {
283
273
  throw n;
284
274
  return i;
285
275
  }
286
- async function J(e) {
276
+ async function H(e) {
287
277
  if (!r)
288
278
  throw new Error("API client is not initialized");
289
279
  const { path: t } = e, { data: i, error: n } = await r.POST("/storage/mkdir", {
@@ -297,6 +287,14 @@ async function J(e) {
297
287
  throw n;
298
288
  return i;
299
289
  }
290
+ async function J() {
291
+ if (!r)
292
+ throw new Error("API client is not initialized");
293
+ const { data: e, error: t } = await r.GET("/storage/status");
294
+ if (t)
295
+ throw t;
296
+ return e;
297
+ }
300
298
  async function X() {
301
299
  if (!r)
302
300
  throw new Error("API client is not initialized");
@@ -305,7 +303,7 @@ async function X() {
305
303
  throw t;
306
304
  return e;
307
305
  }
308
- async function Q(e) {
306
+ async function M(e) {
309
307
  if (!r)
310
308
  throw new Error("API client is not initialized");
311
309
  const { name: t, file: i } = e, { data: n, error: s } = await r.POST("/update", {
@@ -323,7 +321,7 @@ async function Q(e) {
323
321
  throw s;
324
322
  return n;
325
323
  }
326
- async function M() {
324
+ async function Q() {
327
325
  if (!r)
328
326
  throw new Error("API client is not initialized");
329
327
  const { data: e, error: t } = await r.GET("/status");
@@ -350,12 +348,44 @@ async function Z() {
350
348
  async function tt() {
351
349
  if (!r)
352
350
  throw new Error("API client is not initialized");
353
- const { data: e, error: t } = await r.GET("/display/brightness");
351
+ const { data: e, error: t } = await r.GET("/time");
354
352
  if (t)
355
353
  throw t;
356
354
  return e;
357
355
  }
358
356
  async function et(e) {
357
+ if (!r)
358
+ throw new Error("API client is not initialized");
359
+ const { data: t, error: i } = await r.POST("/time/timestamp", {
360
+ params: {
361
+ query: e
362
+ }
363
+ });
364
+ if (i)
365
+ throw i;
366
+ return t;
367
+ }
368
+ async function it(e) {
369
+ if (!r)
370
+ throw new Error("API client is not initialized");
371
+ const { data: t, error: i } = await r.POST("/time/timezone", {
372
+ params: {
373
+ query: e
374
+ }
375
+ });
376
+ if (i)
377
+ throw i;
378
+ return t;
379
+ }
380
+ async function rt() {
381
+ if (!r)
382
+ throw new Error("API client is not initialized");
383
+ const { data: e, error: t } = await r.GET("/display/brightness");
384
+ if (t)
385
+ throw t;
386
+ return e;
387
+ }
388
+ async function nt(e) {
359
389
  if (!r)
360
390
  throw new Error("API client is not initialized");
361
391
  const { front: t, back: i } = e, n = (u) => {
@@ -378,7 +408,7 @@ async function et(e) {
378
408
  throw f;
379
409
  return c;
380
410
  }
381
- async function it() {
411
+ async function st() {
382
412
  if (!r)
383
413
  throw new Error("API client is not initialized");
384
414
  const { data: e, error: t } = await r.GET("/audio/volume");
@@ -386,7 +416,7 @@ async function it() {
386
416
  throw t;
387
417
  return e;
388
418
  }
389
- async function rt(e) {
419
+ async function ot(e) {
390
420
  if (!r)
391
421
  throw new Error("API client is not initialized");
392
422
  const { volume: t } = e;
@@ -403,7 +433,7 @@ async function rt(e) {
403
433
  throw n;
404
434
  return i;
405
435
  }
406
- async function nt() {
436
+ async function at() {
407
437
  if (!r)
408
438
  throw new Error("API client is not initialized");
409
439
  const { data: e, error: t } = await r.GET("/access");
@@ -411,7 +441,7 @@ async function nt() {
411
441
  throw t;
412
442
  return e;
413
443
  }
414
- async function st(e) {
444
+ async function ct(e) {
415
445
  if (!r)
416
446
  throw new Error("API client is not initialized");
417
447
  const { mode: t, key: i } = e;
@@ -429,7 +459,25 @@ async function st(e) {
429
459
  throw s;
430
460
  return n;
431
461
  }
432
- async function ot() {
462
+ async function ft() {
463
+ if (!r)
464
+ throw new Error("API client is not initialized");
465
+ const { data: e, error: t } = await r.GET("/name");
466
+ if (t)
467
+ throw t;
468
+ return e;
469
+ }
470
+ async function ut(e) {
471
+ if (!r)
472
+ throw new Error("API client is not initialized");
473
+ const { data: t, error: i } = await r.POST("/name", {
474
+ body: e
475
+ });
476
+ if (i)
477
+ throw i;
478
+ return t;
479
+ }
480
+ async function wt() {
433
481
  if (!r)
434
482
  throw new Error("API client is not initialized");
435
483
  const { data: e, error: t } = await r.POST("/ble/enable");
@@ -437,7 +485,7 @@ async function ot() {
437
485
  throw t;
438
486
  return e;
439
487
  }
440
- async function at() {
488
+ async function dt() {
441
489
  if (!r)
442
490
  throw new Error("API client is not initialized");
443
491
  const { data: e, error: t } = await r.POST("/ble/disable");
@@ -445,7 +493,23 @@ async function at() {
445
493
  throw t;
446
494
  return e;
447
495
  }
448
- async function ct(e) {
496
+ async function ht() {
497
+ if (!r)
498
+ throw new Error("API client is not initialized");
499
+ const { data: e, error: t } = await r.DELETE("/ble/pairing");
500
+ if (t)
501
+ throw t;
502
+ return e;
503
+ }
504
+ async function lt() {
505
+ if (!r)
506
+ throw new Error("API client is not initialized");
507
+ const { data: e, error: t } = await r.GET("/ble/status");
508
+ if (t)
509
+ throw t;
510
+ return e;
511
+ }
512
+ async function pt(e) {
449
513
  if (!r)
450
514
  throw new Error("API client is not initialized");
451
515
  const { keyName: t } = e, { data: i, error: n } = await r.POST("/input", {
@@ -459,12 +523,29 @@ async function ct(e) {
459
523
  throw n;
460
524
  return i;
461
525
  }
462
- class lt {
526
+ const yt = "http://10.0.4.20", mt = "https://proxy.busy.app", Et = /^https?:\/\/proxy(?:\.(?:dev|test|stage))?\.busy\.app$/i;
527
+ class Tt {
463
528
  /**
464
529
  * Creates an instance of BUSY Bar.
465
530
  * Initializes the API client with the provided host address.
466
531
  *
467
- * @param {BusyBarConfig} config - The host address of the device (IP or mDNS).
532
+ * @param {BusyBarConfig} config - BUSY Bar connection configuration
533
+ * @param {BusyBarConfig['addr']} config.addr -
534
+ * The device address or proxy endpoint.
535
+ *
536
+ * Can be:
537
+ * - An IP address (e.g. `192.168.0.10`)
538
+ * - An mDNS hostname (e.g. `busybar.local`)
539
+ * - A domain name
540
+ * - A full URL (`http://` or `https://`)
541
+ *
542
+ * If no protocol is specified, `http://` will be automatically added.
543
+ *
544
+ * @param {BusyBarConfig['token']} config.token -
545
+ * Optional authentication token.
546
+ *
547
+ * Must be provided when `addr` points to a secured proxy endpoint
548
+ * such as `https://proxy.busy.app`.
468
549
  */
469
550
  constructor(t) {
470
551
  /**
@@ -472,13 +553,27 @@ class lt {
472
553
  * @type {BusyBarConfig['host']}
473
554
  * @readonly
474
555
  */
475
- o(this, "host");
556
+ o(this, "addr");
476
557
  /**
477
558
  * Current API semantic version.
478
559
  * @type {ApiSemver}
479
560
  */
480
561
  o(this, "apiSemver");
481
- this.host = t.host, this.apiSemver = "", B(`http://${this.host}/api/`, this.getApiVersion.bind(this));
562
+ if (!t || !t.addr && !t.token)
563
+ this.addr = yt;
564
+ else if (!t.addr)
565
+ this.addr = mt;
566
+ else {
567
+ let i = t.addr.trim();
568
+ if (/^https?:\/\//i.test(i) || (i = `http://${i}`), Et.test(i) && !t.token)
569
+ throw new Error("Token is required. Please provide it.");
570
+ this.addr = i;
571
+ }
572
+ this.apiSemver = "", z(
573
+ `${this.addr}/api/`,
574
+ this.getApiVersion.bind(this),
575
+ t == null ? void 0 : t.token
576
+ );
482
577
  }
483
578
  /**
484
579
  * Retrieves the API semantic version.
@@ -498,7 +593,7 @@ class lt {
498
593
  * @returns {Promise<SuccessResponse>} Result of the update operation.
499
594
  */
500
595
  async updateFirmware(t) {
501
- return await Q(t);
596
+ return await M(t);
502
597
  }
503
598
  /**
504
599
  * Gets the current status of the device, including system and power information.
@@ -506,7 +601,7 @@ class lt {
506
601
  * @returns {Promise<Status>} Current status of the device.
507
602
  */
508
603
  async deviceStatus() {
509
- return await M();
604
+ return await Q();
510
605
  }
511
606
  /**
512
607
  * Gets the current system status.
@@ -524,6 +619,58 @@ class lt {
524
619
  async powerStatus() {
525
620
  return await Z();
526
621
  }
622
+ /**
623
+ * Gets current device timestamp with timezone.
624
+ *
625
+ * @returns {Promise<TimestampInfo>} Current device timestamp as an ISO 8601 string.
626
+ */
627
+ async getTime() {
628
+ return await tt();
629
+ }
630
+ /**
631
+ * Sets the current device timestamp.
632
+ *
633
+ * @param {SetTimestampParams} params - The parameters for setting the timestamp.
634
+ * @param {SetTimestampParams['timestamp']} params.timestamp - The new timestamp (ISO 8601 string).
635
+ * @returns {Promise<SuccessResponse>} A success response if the timestamp was set.
636
+ */
637
+ async setTimestamp(t) {
638
+ return await et(t);
639
+ }
640
+ /**
641
+ * Sets the device timezone.
642
+ *
643
+ * @param {SetTimezoneParams} params - The parameters for setting the timezone.
644
+ * @param {SetTimezoneParams['timezone']} params.timezone - The new timezone identifier (IANA TZ string).
645
+ * @returns {Promise<SuccessResponse>} A success response if the timezone was set.
646
+ */
647
+ async setTimezone(t) {
648
+ return await it(t);
649
+ }
650
+ /**
651
+ * Gets the status of the MQTT account linked to the device.
652
+ *
653
+ * @returns {Promise<AccountInfo>} Information about the current MQTT account status.
654
+ */
655
+ async getMqttStatus() {
656
+ return await L();
657
+ }
658
+ /**
659
+ * Unlinks the current account from the device.
660
+ *
661
+ * @returns {Promise<SuccessResponse>} Result of the account unlink operation.
662
+ */
663
+ async unlinkAccount() {
664
+ return await D();
665
+ }
666
+ /**
667
+ * Links an account to the device.
668
+ *
669
+ * @returns {Promise<AccountLink>} Information about the account link operation.
670
+ */
671
+ async linkAccount() {
672
+ return await O();
673
+ }
527
674
  /**
528
675
  * Uploads an asset to the device.
529
676
  *
@@ -534,7 +681,7 @@ class lt {
534
681
  * @returns {Promise<SuccessResponse>} Result of the upload operation.
535
682
  */
536
683
  async uploadAsset(t) {
537
- return await L(t);
684
+ return await W(t);
538
685
  }
539
686
  /**
540
687
  * Deletes all assets for a specific application from the device.
@@ -544,7 +691,7 @@ class lt {
544
691
  * @returns {Promise<SuccessResponse>} Result of the delete operation.
545
692
  */
546
693
  async deleteAssets(t) {
547
- return await z(t);
694
+ return await C(t);
548
695
  }
549
696
  /**
550
697
  * Draws elements on the device display.
@@ -555,7 +702,7 @@ class lt {
555
702
  * @returns {Promise<SuccessResponse>} Result of the draw operation.
556
703
  */
557
704
  async drawDisplay(t) {
558
- return await K(t);
705
+ return await R(t);
559
706
  }
560
707
  /**
561
708
  * Clears the device display and stops the Canvas application if running.
@@ -574,7 +721,7 @@ class lt {
574
721
  * @returns {Promise<SuccessResponse>} Result of the play operation.
575
722
  */
576
723
  async playSound(t) {
577
- return await C(t);
724
+ return await K(t);
578
725
  }
579
726
  /**
580
727
  * Stops any currently playing audio on the device.
@@ -582,23 +729,35 @@ class lt {
582
729
  * @returns {Promise<SuccessResponse>} Result of the stop operation.
583
730
  */
584
731
  async stopSound() {
585
- return await W();
732
+ return await $();
586
733
  }
587
734
  /**
588
- * Enables the device's Wi-Fi module.
735
+ * @deprecated since 0.5.0 will be removed in 0.7.0.
589
736
  *
590
- * @returns {Promise<SuccessResponse>} Result of the enable operation.
737
+ * This method is no longer supported and does nothing.
738
+ *
739
+ * Works only with BusyLib v0.5.0 and device firmware v0.3.0.
740
+ *
741
+ * Always throws an error.
591
742
  */
592
743
  async enableWifi() {
593
- return await $();
744
+ throw new Error(
745
+ "[DEPRECATED] BusyBar.enableWifi: This method is deprecated since v0.5.0 and will be removed in v0.7.0. It is no longer supported and does nothing. Works only with BusyLib v0.5.0 and device firmware v0.3.0."
746
+ );
594
747
  }
595
748
  /**
596
- * Disables the device's Wi-Fi module.
749
+ * @deprecated since 0.5.0 will be removed in 0.7.0.
597
750
  *
598
- * @returns {Promise<SuccessResponse>} Result of the disable operation.
751
+ * This method is no longer supported and does nothing.
752
+ *
753
+ * Works only with BusyLib v0.5.0 and device firmware v0.3.0.
754
+ *
755
+ * Always throws an error.
599
756
  */
600
757
  async disableWifi() {
601
- return await F();
758
+ throw new Error(
759
+ "[DEPRECATED] BusyBar.disableWifi: This method is deprecated since v0.5.0 and will be removed in v0.7.0. It is no longer supported and does nothing. Works only with BusyLib v0.5.0 and device firmware v0.3.0."
760
+ );
602
761
  }
603
762
  /**
604
763
  * Gets the current status of the Wi-Fi module.
@@ -606,7 +765,7 @@ class lt {
606
765
  * @returns {Promise<WifiStatusResponse>} Current Wi-Fi status.
607
766
  */
608
767
  async statusWifi() {
609
- return await R();
768
+ return await _();
610
769
  }
611
770
  /**
612
771
  * Connects the device to a Wi-Fi network with the specified parameters.
@@ -624,7 +783,7 @@ class lt {
624
783
  * @returns {Promise<SuccessResponse>} Result of the connect operation.
625
784
  */
626
785
  async connectWifi(t) {
627
- return await V(t);
786
+ return await F(t);
628
787
  }
629
788
  /**
630
789
  * Disconnects the device from the current Wi-Fi network.
@@ -632,7 +791,7 @@ class lt {
632
791
  * @returns {Promise<SuccessResponse>} Result of the disconnect operation.
633
792
  */
634
793
  async disconnectWifi() {
635
- return await x();
794
+ return await G();
636
795
  }
637
796
  /**
638
797
  * Scans for available Wi-Fi networks near your device.
@@ -640,15 +799,21 @@ class lt {
640
799
  * @returns {Promise<WifiNetworkResponse>} List of discovered networks.
641
800
  */
642
801
  async networksWifi() {
643
- return await _();
802
+ return await N();
644
803
  }
645
804
  /**
646
- * Removes the saved Wi-Fi configuration (forgets the network).
805
+ * @deprecated since 0.5.0 will be removed in 0.7.0.
806
+ *
807
+ * This method is no longer supported and does nothing.
647
808
  *
648
- * @returns {Promise<never>} Result of the forget operation.
809
+ * Works only with BusyLib v0.5.0 and device firmware v0.3.0.
810
+ *
811
+ * Always throws an error.
649
812
  */
650
813
  async forgetWifi() {
651
- return await q();
814
+ throw new Error(
815
+ "[DEPRECATED] BusyBar.forgetWifi: This method is deprecated since v0.5.0 and will be removed in v0.7.0. It is no longer supported and does nothing. Works only with BusyLib v0.5.0 and device firmware v0.3.0."
816
+ );
652
817
  }
653
818
  /**
654
819
  * Uploads a file to the device's internal storage.
@@ -659,7 +824,7 @@ class lt {
659
824
  * @returns {Promise<SuccessResponse>} Result of the upload operation.
660
825
  */
661
826
  async uploadFile(t) {
662
- return await G(t);
827
+ return await V(t);
663
828
  }
664
829
  /**
665
830
  * Downloads a file from the device's internal storage.
@@ -670,7 +835,7 @@ class lt {
670
835
  * @returns {Promise<StorageReadResponse>} The file data.
671
836
  */
672
837
  async downloadFile(t) {
673
- return await N(t);
838
+ return await q(t);
674
839
  }
675
840
  /**
676
841
  * Reads the contents of a directory (files and subdirectories) at the specified path.
@@ -680,7 +845,7 @@ class lt {
680
845
  * @returns {Promise<StorageList>} List of files and directories.
681
846
  */
682
847
  async readDirectory(t) {
683
- return await j(t);
848
+ return await x(t);
684
849
  }
685
850
  /**
686
851
  * Removes a file or a directory from the device's internal storage.
@@ -690,7 +855,7 @@ class lt {
690
855
  * @returns {Promise<SuccessResponse>} Result of the remove operation.
691
856
  */
692
857
  async removeResource(t) {
693
- return await H(t);
858
+ return await j(t);
694
859
  }
695
860
  /**
696
861
  * Creates a new directory in the device's internal storage.
@@ -700,7 +865,15 @@ class lt {
700
865
  * @returns {Promise<SuccessResponse>} Result of the create operation.
701
866
  */
702
867
  async createDirectory(t) {
703
- return await J(t);
868
+ return await H(t);
869
+ }
870
+ /**
871
+ * Gets the current status of the device's internal storage.
872
+ *
873
+ * @returns {Promise<StorageStatus>} Current storage status information.
874
+ */
875
+ async statusStorage() {
876
+ return await J();
704
877
  }
705
878
  /**
706
879
  * Gets the current display brightness settings for the device.
@@ -708,7 +881,7 @@ class lt {
708
881
  * @returns {Promise<DisplayBrightnessInfo>} Current brightness information for front and back panels.
709
882
  */
710
883
  async getDisplayBrightness() {
711
- return await tt();
884
+ return await rt();
712
885
  }
713
886
  /**
714
887
  * Sets the display brightness for the device.
@@ -720,7 +893,7 @@ class lt {
720
893
  * @throws {Error} If brightness value is outside the range 0-100 or not "auto".
721
894
  */
722
895
  async setDisplayBrightness(t) {
723
- return await et(t);
896
+ return await nt(t);
724
897
  }
725
898
  /**
726
899
  * Gets the current audio volume value.
@@ -728,7 +901,7 @@ class lt {
728
901
  * @returns {Promise<AudioVolumeInfo>} Current audio volume (0-100).
729
902
  */
730
903
  async getAudioVolume() {
731
- return await it();
904
+ return await st();
732
905
  }
733
906
  /**
734
907
  * Sets the audio volume value.
@@ -739,7 +912,7 @@ class lt {
739
912
  * @throws {Error} If volume is outside the range 0-100 or request fails.
740
913
  */
741
914
  async setAudioVolume(t) {
742
- return await rt(t);
915
+ return await ot(t);
743
916
  }
744
917
  /**
745
918
  * Gets the current HTTP API access configuration.
@@ -747,7 +920,7 @@ class lt {
747
920
  * @returns {Promise<HttpAccessInfo>} Current HTTP access info.
748
921
  */
749
922
  async getHttpAccess() {
750
- return await nt();
923
+ return await at();
751
924
  }
752
925
  /**
753
926
  * Sets the HTTP API access configuration.
@@ -758,9 +931,27 @@ class lt {
758
931
  * @returns {Promise<SuccessResponse>} Result of the set operation.
759
932
  */
760
933
  async setHttpAccess(t) {
761
- const i = await st(t);
934
+ const i = await ct(t);
762
935
  return t.mode === "key" && t.key && this.setApiKey(t.key), i;
763
936
  }
937
+ /**
938
+ * Gets the current device name.
939
+ *
940
+ * @returns {Promise<NameInfo>} The current device name information.
941
+ */
942
+ async getName() {
943
+ return await ft();
944
+ }
945
+ /**
946
+ * Sets the device name.
947
+ *
948
+ * @param {NameParams} params - The parameters for setting the device name.
949
+ * @param {NameParams['name']} params.name - The new device name.
950
+ * @returns {Promise<SuccessResponse>} Result of setting the device name.
951
+ */
952
+ async setName(t) {
953
+ return await ut(t);
954
+ }
764
955
  /**
765
956
  * Sets API key for all subsequent requests.
766
957
  * @param {string} key - API key to use in "X-API-Token" header.
@@ -773,14 +964,30 @@ class lt {
773
964
  * @returns {Promise<SuccessResponse>} Result of the enable operation.
774
965
  */
775
966
  async enableBle() {
776
- return await ot();
967
+ return await wt();
777
968
  }
778
969
  /**
779
970
  * Disables BLE module.
780
971
  * @returns {Promise<SuccessResponse>} Result of the disable operation.
781
972
  */
782
973
  async disableBle() {
783
- return await at();
974
+ return await dt();
975
+ }
976
+ /**
977
+ * Removes all BLE pairings from the device.
978
+ *
979
+ * @returns {Promise<SuccessResponse>} Result of the BLE pairing removal operation.
980
+ */
981
+ async pairingBle() {
982
+ return await ht();
983
+ }
984
+ /**
985
+ * Gets the current BLE module status.
986
+ *
987
+ * @returns {Promise<BleStatusResponse>} Current BLE status information.
988
+ */
989
+ async statusBle() {
990
+ return await lt();
784
991
  }
785
992
  /**
786
993
  * Sends a button press.
@@ -794,12 +1001,12 @@ class lt {
794
1001
  * @returns {Promise<SuccessResponse>} Result of pressing the button.
795
1002
  */
796
1003
  async pressButton(t) {
797
- return await ct(t);
1004
+ return await pt(t);
798
1005
  }
799
1006
  }
800
- var m = /* @__PURE__ */ ((e) => (e[e.FRONT = 0] = "FRONT", e[e.BACK = 1] = "BACK", e))(m || {});
801
- const g = 3e3, S = /* @__PURE__ */ new Set([1001, 1006, 1012, 1013, 1014, 3008]);
802
- function A(e, t) {
1007
+ var E = /* @__PURE__ */ ((e) => (e[e.FRONT = 0] = "FRONT", e[e.BACK = 1] = "BACK", e))(E || {});
1008
+ const g = 3e3, k = /* @__PURE__ */ new Set([1001, 1006, 1012, 1013, 1014, 3008]);
1009
+ function S(e, t) {
803
1010
  if (t < 0 || t >= e.length)
804
1011
  throw new Error(`Index ${t} is out of bounds (0…${e.length - 1})`);
805
1012
  const i = e[t];
@@ -807,11 +1014,11 @@ function A(e, t) {
807
1014
  throw new Error(`Unexpected undefined at index ${t}`);
808
1015
  return i;
809
1016
  }
810
- function ft(e, t) {
1017
+ function At(e, t) {
811
1018
  let i = 0;
812
1019
  const n = e.length, s = [];
813
1020
  for (; i < n; ) {
814
- const a = A(e, i);
1021
+ const a = S(e, i);
815
1022
  if (i += 1, (a & 128) !== 0) {
816
1023
  const c = a & 127;
817
1024
  for (let f = 0; f < c * t; f++)
@@ -827,16 +1034,16 @@ function ft(e, t) {
827
1034
  }
828
1035
  return new Uint8Array(s);
829
1036
  }
830
- function ut(e) {
1037
+ function gt(e) {
831
1038
  const t = new Uint8Array(e.length * 2);
832
1039
  let i = 0, n = 0;
833
1040
  for (; i < e.length; ) {
834
- const s = A(e, i), a = s & 15, c = s >> 4 & 15;
1041
+ const s = S(e, i), a = s & 15, c = s >> 4 & 15;
835
1042
  t[n] = a, t[n + 1] = c, i += 1, n += 2;
836
1043
  }
837
1044
  return t;
838
1045
  }
839
- class dt {
1046
+ class Pt {
840
1047
  constructor(t) {
841
1048
  o(this, "connected", !1);
842
1049
  // @ts-ignore
@@ -893,10 +1100,10 @@ class dt {
893
1100
  this.emitData(n);
894
1101
  else if (this.config.mode === "local") {
895
1102
  let s;
896
- const a = this.config.deviceScreen === m.FRONT ? 3 : 2;
1103
+ const a = this.config.deviceScreen === E.FRONT ? 3 : 2;
897
1104
  try {
898
- const c = ft(n, a);
899
- this.config.deviceScreen === m.BACK ? s = ut(c) : s = c, this.emitData(s);
1105
+ const c = At(n, a);
1106
+ this.config.deviceScreen === E.BACK ? s = gt(c) : s = c, this.emitData(s);
900
1107
  } catch {
901
1108
  this.emitData(n);
902
1109
  }
@@ -912,7 +1119,7 @@ class dt {
912
1119
  raw: i
913
1120
  }), this.emitStop();
914
1121
  }, this.socket.onclose = async (i) => {
915
- if (this.socket = null, this.connected = !1, i.code === g || S.has(i.code)) {
1122
+ if (this.socket = null, this.connected = !1, i.code === g || k.has(i.code)) {
916
1123
  this.emitError({
917
1124
  code: i.code,
918
1125
  message: i.reason,
@@ -931,7 +1138,7 @@ class dt {
931
1138
  });
932
1139
  }
933
1140
  }
934
- class pt {
1141
+ class vt {
935
1142
  constructor(t) {
936
1143
  o(this, "connected", !1);
937
1144
  // @ts-ignore
@@ -992,7 +1199,7 @@ class pt {
992
1199
  raw: i
993
1200
  }), this.emitStop();
994
1201
  }, this.socket.onclose = async (i) => {
995
- if (this.socket = null, this.connected = !1, i.code === g || S.has(i.code)) {
1202
+ if (this.socket = null, this.connected = !1, i.code === g || k.has(i.code)) {
996
1203
  this.emitError({
997
1204
  code: i.code,
998
1205
  message: i.reason,
@@ -1017,8 +1224,8 @@ class pt {
1017
1224
  }
1018
1225
  }
1019
1226
  export {
1020
- lt as BusyBar,
1021
- m as DeviceScreen,
1022
- pt as Input,
1023
- dt as ScreenStream
1227
+ Tt as BusyBar,
1228
+ E as DeviceScreen,
1229
+ vt as Input,
1230
+ Pt as ScreenStream
1024
1231
  };