@busy-app/busy-lib 0.8.0 → 0.8.1
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.cjs +1 -1
- package/dist/index.d.ts +33 -5
- package/dist/index.js +240 -177
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
var D = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var u = (e, t, n) =>
|
|
2
|
+
var U = (e, t, n) => t in e ? D(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var u = (e, t, n) => U(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import b from "openapi-fetch";
|
|
5
|
-
const
|
|
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 n;
|
|
9
9
|
return t && (t instanceof Headers ? n = t.get("Content-Type") ?? t.get("content-type") ?? void 0 : typeof t == "object" && (n = t["Content-Type"] ?? t["content-type"]), n === "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 m, h,
|
|
12
|
-
async function
|
|
11
|
+
let m, h, l = null;
|
|
12
|
+
async function A() {
|
|
13
13
|
if (!h) {
|
|
14
14
|
if (!m)
|
|
15
15
|
throw new Error("getApiVersionFn is not set");
|
|
16
|
-
|
|
16
|
+
l || (l = (async () => {
|
|
17
17
|
const e = await m();
|
|
18
18
|
if (!e.api_semver)
|
|
19
19
|
throw new Error("Empty API version");
|
|
20
20
|
h = e.api_semver;
|
|
21
21
|
})().finally(() => {
|
|
22
|
-
|
|
23
|
-
})), await
|
|
22
|
+
l = null;
|
|
23
|
+
})), await l;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
async function p(e) {
|
|
@@ -34,10 +34,14 @@ async function p(e) {
|
|
|
34
34
|
}
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
|
-
let
|
|
38
|
-
|
|
37
|
+
let T;
|
|
38
|
+
function C(e) {
|
|
39
|
+
T = e;
|
|
40
|
+
}
|
|
41
|
+
let w;
|
|
42
|
+
const I = {
|
|
39
43
|
async onRequest({ request: e, schemaPath: t }) {
|
|
40
|
-
return
|
|
44
|
+
return w && e.headers.set("Authorization", `Bearer ${w}`), t !== "/version" && (await A(), h && e.headers.set("X-API-Sem-Ver", h), T && e.headers.set("X-API-Token", T)), e;
|
|
41
45
|
},
|
|
42
46
|
async onResponse({ request: e, response: t, options: n, schemaPath: i }) {
|
|
43
47
|
if (t.ok)
|
|
@@ -46,7 +50,7 @@ const B = {
|
|
|
46
50
|
throw await p(t);
|
|
47
51
|
if (t.status !== 405)
|
|
48
52
|
throw await p(t);
|
|
49
|
-
h = void 0, await
|
|
53
|
+
h = void 0, await A(), h && e.headers.set("X-API-Sem-Ver", h), w && e.headers.set("Authorization", `Bearer ${w}`);
|
|
50
54
|
const r = await (n.fetch ?? fetch)(e);
|
|
51
55
|
if (r.ok)
|
|
52
56
|
return r;
|
|
@@ -54,11 +58,11 @@ const B = {
|
|
|
54
58
|
}
|
|
55
59
|
};
|
|
56
60
|
let S = null;
|
|
57
|
-
function
|
|
58
|
-
m = t,
|
|
61
|
+
function $(e, t, n) {
|
|
62
|
+
m = t, w = n ?? void 0, S = b({
|
|
59
63
|
baseUrl: e,
|
|
60
|
-
bodySerializer:
|
|
61
|
-
}), S.use(
|
|
64
|
+
bodySerializer: B
|
|
65
|
+
}), S.use(I);
|
|
62
66
|
}
|
|
63
67
|
function o() {
|
|
64
68
|
if (!S)
|
|
@@ -77,7 +81,7 @@ async function s(e, t = 3e3) {
|
|
|
77
81
|
clearTimeout(i);
|
|
78
82
|
}
|
|
79
83
|
}
|
|
80
|
-
async function
|
|
84
|
+
async function R(e) {
|
|
81
85
|
const t = o(), { data: n, error: i } = await s(
|
|
82
86
|
(r) => t.GET("/version", { signal: r }),
|
|
83
87
|
e == null ? void 0 : e.timeout
|
|
@@ -86,7 +90,7 @@ async function I(e) {
|
|
|
86
90
|
throw i;
|
|
87
91
|
return n;
|
|
88
92
|
}
|
|
89
|
-
async function
|
|
93
|
+
async function W(e) {
|
|
90
94
|
const t = o(), { data: n, error: i } = await s(
|
|
91
95
|
(r) => t.GET("/status", { signal: r }),
|
|
92
96
|
e == null ? void 0 : e.timeout
|
|
@@ -95,7 +99,7 @@ async function $(e) {
|
|
|
95
99
|
throw i;
|
|
96
100
|
return n;
|
|
97
101
|
}
|
|
98
|
-
async function
|
|
102
|
+
async function N(e) {
|
|
99
103
|
const t = o(), { data: n, error: i } = await s(
|
|
100
104
|
(r) => t.GET("/status/system", { signal: r }),
|
|
101
105
|
e == null ? void 0 : e.timeout
|
|
@@ -104,7 +108,7 @@ async function R(e) {
|
|
|
104
108
|
throw i;
|
|
105
109
|
return n;
|
|
106
110
|
}
|
|
107
|
-
async function
|
|
111
|
+
async function K(e) {
|
|
108
112
|
const t = o(), { data: n, error: i } = await s(
|
|
109
113
|
(r) => t.GET("/status/power", { signal: r }),
|
|
110
114
|
e == null ? void 0 : e.timeout
|
|
@@ -113,7 +117,7 @@ async function W(e) {
|
|
|
113
117
|
throw i;
|
|
114
118
|
return n;
|
|
115
119
|
}
|
|
116
|
-
class
|
|
120
|
+
class F {
|
|
117
121
|
/**
|
|
118
122
|
* Get API version information.
|
|
119
123
|
*
|
|
@@ -122,7 +126,7 @@ class N {
|
|
|
122
126
|
* @returns {Promise<VersionInfo>} A promise that resolves to an object containing the `api_semver` string.
|
|
123
127
|
*/
|
|
124
128
|
async SystemVersionGet(t) {
|
|
125
|
-
const n = await
|
|
129
|
+
const n = await R(t);
|
|
126
130
|
return this.apiSemver = n.api_semver, n;
|
|
127
131
|
}
|
|
128
132
|
/**
|
|
@@ -139,7 +143,7 @@ class N {
|
|
|
139
143
|
* @returns {Promise<Status>} Current status of the device.
|
|
140
144
|
*/
|
|
141
145
|
async SystemStatusGet(t) {
|
|
142
|
-
return await
|
|
146
|
+
return await W(t);
|
|
143
147
|
}
|
|
144
148
|
/**
|
|
145
149
|
* @deprecated Use `SystemStatusGet` instead. will be removed in the next release.
|
|
@@ -155,7 +159,7 @@ class N {
|
|
|
155
159
|
* @returns {Promise<StatusSystem>} Current system status.
|
|
156
160
|
*/
|
|
157
161
|
async SystemInfoGet(t) {
|
|
158
|
-
return await
|
|
162
|
+
return await N(t);
|
|
159
163
|
}
|
|
160
164
|
/**
|
|
161
165
|
* @deprecated Use `SystemInfoGet` instead. will be removed in the next release.
|
|
@@ -171,7 +175,7 @@ class N {
|
|
|
171
175
|
* @returns {Promise<StatusPower>} Current power status.
|
|
172
176
|
*/
|
|
173
177
|
async SystemStatusPowerGet(t) {
|
|
174
|
-
return await
|
|
178
|
+
return await K(t);
|
|
175
179
|
}
|
|
176
180
|
/**
|
|
177
181
|
* @deprecated Use `SystemStatusPowerGet` instead. will be removed in the next release.
|
|
@@ -181,6 +185,21 @@ class N {
|
|
|
181
185
|
}
|
|
182
186
|
}
|
|
183
187
|
async function M(e) {
|
|
188
|
+
const t = o(), { file: n } = e, { data: i, error: r } = await s(
|
|
189
|
+
(c) => t.POST("/update", {
|
|
190
|
+
headers: {
|
|
191
|
+
"Content-Type": "application/octet-stream"
|
|
192
|
+
},
|
|
193
|
+
body: n,
|
|
194
|
+
signal: c
|
|
195
|
+
}),
|
|
196
|
+
e.timeout
|
|
197
|
+
);
|
|
198
|
+
if (r)
|
|
199
|
+
throw r;
|
|
200
|
+
return i;
|
|
201
|
+
}
|
|
202
|
+
async function V(e) {
|
|
184
203
|
const t = o(), { data: n, error: i } = await s(
|
|
185
204
|
(r) => t.POST("/update/check", { signal: r }),
|
|
186
205
|
e == null ? void 0 : e.timeout
|
|
@@ -189,7 +208,7 @@ async function M(e) {
|
|
|
189
208
|
throw i;
|
|
190
209
|
return n;
|
|
191
210
|
}
|
|
192
|
-
async function
|
|
211
|
+
async function x(e) {
|
|
193
212
|
const t = o(), { data: n, error: i } = await s(
|
|
194
213
|
(r) => t.GET("/update/status", { signal: r }),
|
|
195
214
|
e == null ? void 0 : e.timeout
|
|
@@ -198,7 +217,7 @@ async function V(e) {
|
|
|
198
217
|
throw i;
|
|
199
218
|
return n;
|
|
200
219
|
}
|
|
201
|
-
async function
|
|
220
|
+
async function _(e) {
|
|
202
221
|
const t = o(), { version: n } = e, { data: i, error: r } = await s(
|
|
203
222
|
(c) => t.GET("/update/changelog", {
|
|
204
223
|
params: {
|
|
@@ -214,7 +233,7 @@ async function K(e) {
|
|
|
214
233
|
throw r;
|
|
215
234
|
return i;
|
|
216
235
|
}
|
|
217
|
-
async function
|
|
236
|
+
async function z(e) {
|
|
218
237
|
const t = o(), { version: n } = e, { data: i, error: r } = await s(
|
|
219
238
|
(c) => t.POST("/update/install", {
|
|
220
239
|
params: {
|
|
@@ -230,7 +249,7 @@ async function x(e) {
|
|
|
230
249
|
throw r;
|
|
231
250
|
return i;
|
|
232
251
|
}
|
|
233
|
-
async function
|
|
252
|
+
async function q(e) {
|
|
234
253
|
const t = o(), { data: n, error: i } = await s(
|
|
235
254
|
(r) => t.POST("/update/abort_download", { signal: r }),
|
|
236
255
|
e == null ? void 0 : e.timeout
|
|
@@ -239,7 +258,24 @@ async function _(e) {
|
|
|
239
258
|
throw i;
|
|
240
259
|
return n;
|
|
241
260
|
}
|
|
242
|
-
class
|
|
261
|
+
class j {
|
|
262
|
+
/**
|
|
263
|
+
* Upload firmware update package.
|
|
264
|
+
*
|
|
265
|
+
* @param {UpdateParams} params - Update parameters.
|
|
266
|
+
* @param {BusyFile} params.file - Firmware TAR file to upload.
|
|
267
|
+
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
268
|
+
* @returns {Promise<SuccessResponse>} A promise that resolves when upload is complete.
|
|
269
|
+
*/
|
|
270
|
+
async UpdateFromFile(t) {
|
|
271
|
+
return await M(t);
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* @deprecated Use `UpdateUpload` instead. will be removed in the next release.
|
|
275
|
+
*/
|
|
276
|
+
async SystemUpdate(t) {
|
|
277
|
+
return await this.UpdateFromFile(t);
|
|
278
|
+
}
|
|
243
279
|
/**
|
|
244
280
|
* Start firmware update check.
|
|
245
281
|
*
|
|
@@ -248,7 +284,7 @@ class F {
|
|
|
248
284
|
* @returns {Promise<SuccessResponse>} A promise that resolves to the update check result.
|
|
249
285
|
*/
|
|
250
286
|
async UpdateCheck(t) {
|
|
251
|
-
return await
|
|
287
|
+
return await V(t);
|
|
252
288
|
}
|
|
253
289
|
/**
|
|
254
290
|
* @deprecated Use `UpdateCheck` instead. will be removed in the next release.
|
|
@@ -264,7 +300,7 @@ class F {
|
|
|
264
300
|
* @returns {Promise<UpdateStatus>} A promise that resolves to the update status.
|
|
265
301
|
*/
|
|
266
302
|
async UpdateStatusGet(t) {
|
|
267
|
-
return await
|
|
303
|
+
return await x(t);
|
|
268
304
|
}
|
|
269
305
|
/**
|
|
270
306
|
* @deprecated Use `UpdateStatusGet` instead. will be removed in the next release.
|
|
@@ -281,7 +317,7 @@ class F {
|
|
|
281
317
|
* @returns {Promise<UpdateChangelog>} A promise that resolves to the changelog content.
|
|
282
318
|
*/
|
|
283
319
|
async UpdateChangelogGet(t) {
|
|
284
|
-
return await
|
|
320
|
+
return await _(t);
|
|
285
321
|
}
|
|
286
322
|
/**
|
|
287
323
|
* @deprecated Use `UpdateChangelogGet` instead. will be removed in the next release.
|
|
@@ -298,7 +334,7 @@ class F {
|
|
|
298
334
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful initiation.
|
|
299
335
|
*/
|
|
300
336
|
async UpdateInstall(t) {
|
|
301
|
-
return await
|
|
337
|
+
return await z(t);
|
|
302
338
|
}
|
|
303
339
|
/**
|
|
304
340
|
* Abort firmware update download.
|
|
@@ -308,10 +344,10 @@ class F {
|
|
|
308
344
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful abort.
|
|
309
345
|
*/
|
|
310
346
|
async UpdateAbort(t) {
|
|
311
|
-
return await
|
|
347
|
+
return await q(t);
|
|
312
348
|
}
|
|
313
349
|
}
|
|
314
|
-
async function
|
|
350
|
+
async function H(e) {
|
|
315
351
|
const t = o(), { data: n, error: i } = await s(
|
|
316
352
|
(r) => t.GET("/time", { signal: r }),
|
|
317
353
|
e == null ? void 0 : e.timeout
|
|
@@ -320,7 +356,7 @@ async function q(e) {
|
|
|
320
356
|
throw i;
|
|
321
357
|
return n;
|
|
322
358
|
}
|
|
323
|
-
async function
|
|
359
|
+
async function J(e) {
|
|
324
360
|
const t = o(), { data: n, error: i } = await s(
|
|
325
361
|
(r) => t.POST("/time/timestamp", {
|
|
326
362
|
params: {
|
|
@@ -334,7 +370,16 @@ async function j(e) {
|
|
|
334
370
|
throw i;
|
|
335
371
|
return n;
|
|
336
372
|
}
|
|
337
|
-
async function
|
|
373
|
+
async function X(e) {
|
|
374
|
+
const t = o(), { data: n, error: i } = await s(
|
|
375
|
+
(r) => t.GET("/time/timezone", { signal: r }),
|
|
376
|
+
e == null ? void 0 : e.timeout
|
|
377
|
+
);
|
|
378
|
+
if (i)
|
|
379
|
+
throw i;
|
|
380
|
+
return n;
|
|
381
|
+
}
|
|
382
|
+
async function Q(e) {
|
|
338
383
|
const t = o(), { data: n, error: i } = await s(
|
|
339
384
|
(r) => t.POST("/time/timezone", {
|
|
340
385
|
params: {
|
|
@@ -348,7 +393,7 @@ async function z(e) {
|
|
|
348
393
|
throw i;
|
|
349
394
|
return n;
|
|
350
395
|
}
|
|
351
|
-
async function
|
|
396
|
+
async function Y(e) {
|
|
352
397
|
const t = o(), { data: n, error: i } = await s(
|
|
353
398
|
(r) => t.GET("/time/tzlist", { signal: r }),
|
|
354
399
|
e == null ? void 0 : e.timeout
|
|
@@ -357,7 +402,7 @@ async function H(e) {
|
|
|
357
402
|
throw i;
|
|
358
403
|
return n;
|
|
359
404
|
}
|
|
360
|
-
class
|
|
405
|
+
class Z {
|
|
361
406
|
/**
|
|
362
407
|
* Get current timestamp info.
|
|
363
408
|
*
|
|
@@ -366,7 +411,7 @@ class J {
|
|
|
366
411
|
* @returns {Promise<TimestampInfo>} A promise that resolves to the timestamp information.
|
|
367
412
|
*/
|
|
368
413
|
async TimeGet(t) {
|
|
369
|
-
return await
|
|
414
|
+
return await H(t);
|
|
370
415
|
}
|
|
371
416
|
/**
|
|
372
417
|
* @deprecated Use `TimeGet` instead. will be removed in the next release.
|
|
@@ -383,7 +428,7 @@ class J {
|
|
|
383
428
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
384
429
|
*/
|
|
385
430
|
async TimeTimestampSet(t) {
|
|
386
|
-
return await
|
|
431
|
+
return await J(t);
|
|
387
432
|
}
|
|
388
433
|
/**
|
|
389
434
|
* @deprecated Use `TimeTimestampSet` instead. will be removed in the next release.
|
|
@@ -391,6 +436,16 @@ class J {
|
|
|
391
436
|
async SystemTimeTimestamp(t) {
|
|
392
437
|
return await this.TimeTimestampSet(t);
|
|
393
438
|
}
|
|
439
|
+
/**
|
|
440
|
+
* Get current timezone.
|
|
441
|
+
*
|
|
442
|
+
* @param {TimeoutOptions} [params] - Optional parameters.
|
|
443
|
+
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
444
|
+
* @returns {Promise<TimezoneInfo>} A promise that resolves to the timezone information.
|
|
445
|
+
*/
|
|
446
|
+
async TimeTimezoneGet(t) {
|
|
447
|
+
return await X(t);
|
|
448
|
+
}
|
|
394
449
|
/**
|
|
395
450
|
* Set system timezone.
|
|
396
451
|
*
|
|
@@ -400,7 +455,7 @@ class J {
|
|
|
400
455
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
401
456
|
*/
|
|
402
457
|
async TimeTimezoneSet(t) {
|
|
403
|
-
return await
|
|
458
|
+
return await Q(t);
|
|
404
459
|
}
|
|
405
460
|
/**
|
|
406
461
|
* @deprecated Use `TimeTimezoneSet` instead. will be removed in the next release.
|
|
@@ -416,7 +471,7 @@ class J {
|
|
|
416
471
|
* @returns {Promise<TimezoneList>} A promise that resolves to a list of timezone items.
|
|
417
472
|
*/
|
|
418
473
|
async TimeTzListGet(t) {
|
|
419
|
-
return await
|
|
474
|
+
return await Y(t);
|
|
420
475
|
}
|
|
421
476
|
/**
|
|
422
477
|
* @deprecated Use `TimeTzListGet` instead. will be removed in the next release.
|
|
@@ -425,7 +480,7 @@ class J {
|
|
|
425
480
|
return await this.TimeTzListGet(t);
|
|
426
481
|
}
|
|
427
482
|
}
|
|
428
|
-
async function
|
|
483
|
+
async function tt(e) {
|
|
429
484
|
const t = o(), { data: n, error: i } = await s(
|
|
430
485
|
(r) => t.GET("/account/status", { signal: r }),
|
|
431
486
|
e == null ? void 0 : e.timeout
|
|
@@ -434,7 +489,7 @@ async function X(e) {
|
|
|
434
489
|
throw i;
|
|
435
490
|
return n;
|
|
436
491
|
}
|
|
437
|
-
async function
|
|
492
|
+
async function et(e) {
|
|
438
493
|
const t = o(), { data: n, error: i } = await s(
|
|
439
494
|
(r) => t.GET("/account/info", { signal: r }),
|
|
440
495
|
e == null ? void 0 : e.timeout
|
|
@@ -443,7 +498,7 @@ async function Q(e) {
|
|
|
443
498
|
throw i;
|
|
444
499
|
return n;
|
|
445
500
|
}
|
|
446
|
-
async function
|
|
501
|
+
async function nt(e) {
|
|
447
502
|
const t = o(), { data: n, error: i } = await s(
|
|
448
503
|
(r) => t.GET("/account/profile", { signal: r }),
|
|
449
504
|
e == null ? void 0 : e.timeout
|
|
@@ -452,7 +507,7 @@ async function Y(e) {
|
|
|
452
507
|
throw i;
|
|
453
508
|
return n;
|
|
454
509
|
}
|
|
455
|
-
async function
|
|
510
|
+
async function it(e) {
|
|
456
511
|
const t = o(), { profile: n } = e, { data: i, error: r } = await s(
|
|
457
512
|
(c) => t.POST("/account/profile", {
|
|
458
513
|
params: {
|
|
@@ -468,7 +523,7 @@ async function Z(e) {
|
|
|
468
523
|
throw r;
|
|
469
524
|
return i;
|
|
470
525
|
}
|
|
471
|
-
async function
|
|
526
|
+
async function rt(e) {
|
|
472
527
|
const t = o(), { data: n, error: i } = await s(
|
|
473
528
|
(r) => t.DELETE("/account", { signal: r }),
|
|
474
529
|
e == null ? void 0 : e.timeout
|
|
@@ -477,7 +532,7 @@ async function tt(e) {
|
|
|
477
532
|
throw i;
|
|
478
533
|
return n;
|
|
479
534
|
}
|
|
480
|
-
async function
|
|
535
|
+
async function ot(e) {
|
|
481
536
|
const t = o(), { data: n, error: i } = await s(
|
|
482
537
|
(r) => t.POST("/account/link", { signal: r }),
|
|
483
538
|
e == null ? void 0 : e.timeout
|
|
@@ -486,7 +541,7 @@ async function et(e) {
|
|
|
486
541
|
throw i;
|
|
487
542
|
return n;
|
|
488
543
|
}
|
|
489
|
-
class
|
|
544
|
+
class st {
|
|
490
545
|
/**
|
|
491
546
|
* Get account info.
|
|
492
547
|
*
|
|
@@ -495,7 +550,7 @@ class nt {
|
|
|
495
550
|
* @returns {Promise<AccountInfo>} A promise that resolves to the account information.
|
|
496
551
|
*/
|
|
497
552
|
async AccountInfoGet(t) {
|
|
498
|
-
return await
|
|
553
|
+
return await et(t);
|
|
499
554
|
}
|
|
500
555
|
/**
|
|
501
556
|
* @deprecated Use `AccountInfoGet` instead. will be removed in the next release.
|
|
@@ -511,7 +566,7 @@ class nt {
|
|
|
511
566
|
* @returns {Promise<AccountState>} A promise that resolves to the account state.
|
|
512
567
|
*/
|
|
513
568
|
async AccountStateGet(t) {
|
|
514
|
-
return await
|
|
569
|
+
return await tt(t);
|
|
515
570
|
}
|
|
516
571
|
/**
|
|
517
572
|
* Get account profile.
|
|
@@ -521,7 +576,7 @@ class nt {
|
|
|
521
576
|
* @returns {Promise<AccountProfile>} A promise that resolves to the account profile.
|
|
522
577
|
*/
|
|
523
578
|
async AccountProfileGet(t) {
|
|
524
|
-
return await
|
|
579
|
+
return await nt(t);
|
|
525
580
|
}
|
|
526
581
|
/**
|
|
527
582
|
* Set account profile.
|
|
@@ -532,7 +587,7 @@ class nt {
|
|
|
532
587
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
533
588
|
*/
|
|
534
589
|
async AccountProfileSet(t) {
|
|
535
|
-
return await
|
|
590
|
+
return await it(t);
|
|
536
591
|
}
|
|
537
592
|
/**
|
|
538
593
|
* Unlink device from account. Removes association with the current account.
|
|
@@ -542,7 +597,7 @@ class nt {
|
|
|
542
597
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful unlinking.
|
|
543
598
|
*/
|
|
544
599
|
async AccountUnlink(t) {
|
|
545
|
-
return await
|
|
600
|
+
return await rt(t);
|
|
546
601
|
}
|
|
547
602
|
/**
|
|
548
603
|
* Link device to account. Requests account link PIN. Works only if device is connected to MQTT and is not linked to account.
|
|
@@ -552,10 +607,10 @@ class nt {
|
|
|
552
607
|
* @returns {Promise<AccountLink>} A promise that resolves to the link information (e.g., PIN).
|
|
553
608
|
*/
|
|
554
609
|
async AccountLink(t) {
|
|
555
|
-
return await
|
|
610
|
+
return await ot(t);
|
|
556
611
|
}
|
|
557
612
|
}
|
|
558
|
-
async function
|
|
613
|
+
async function ct(e) {
|
|
559
614
|
const t = o(), { appId: n, elements: i } = e, { data: r, error: c } = await s(
|
|
560
615
|
(a) => t.POST("/display/draw", {
|
|
561
616
|
body: {
|
|
@@ -570,7 +625,7 @@ async function it(e) {
|
|
|
570
625
|
throw c;
|
|
571
626
|
return r;
|
|
572
627
|
}
|
|
573
|
-
async function
|
|
628
|
+
async function at(e) {
|
|
574
629
|
const t = o(), { data: n, error: i } = await s(
|
|
575
630
|
(r) => t.DELETE("/display/draw", { signal: r }),
|
|
576
631
|
e == null ? void 0 : e.timeout
|
|
@@ -579,7 +634,7 @@ async function rt(e) {
|
|
|
579
634
|
throw i;
|
|
580
635
|
return n;
|
|
581
636
|
}
|
|
582
|
-
async function
|
|
637
|
+
async function ut(e) {
|
|
583
638
|
const t = o(), { display: n } = e, { data: i, error: r } = await s(
|
|
584
639
|
(c) => t.GET("/screen", {
|
|
585
640
|
params: {
|
|
@@ -596,7 +651,7 @@ async function ot(e) {
|
|
|
596
651
|
throw r;
|
|
597
652
|
return i;
|
|
598
653
|
}
|
|
599
|
-
async function
|
|
654
|
+
async function dt(e) {
|
|
600
655
|
const t = o(), { data: n, error: i } = await s(
|
|
601
656
|
(r) => t.GET("/display/brightness", { signal: r }),
|
|
602
657
|
e == null ? void 0 : e.timeout
|
|
@@ -605,7 +660,7 @@ async function st(e) {
|
|
|
605
660
|
throw i;
|
|
606
661
|
return n;
|
|
607
662
|
}
|
|
608
|
-
async function
|
|
663
|
+
async function ft(e) {
|
|
609
664
|
const t = o(), { front: n, back: i } = e, r = (d) => {
|
|
610
665
|
if (typeof d == "number") {
|
|
611
666
|
if (d < 0 || d > 100)
|
|
@@ -614,7 +669,7 @@ async function ct(e) {
|
|
|
614
669
|
}
|
|
615
670
|
if (d === "auto")
|
|
616
671
|
return "auto";
|
|
617
|
-
}, c = r(n), a = r(i), { data: f, error:
|
|
672
|
+
}, c = r(n), a = r(i), { data: f, error: y } = await s(
|
|
618
673
|
(d) => t.POST("/display/brightness", {
|
|
619
674
|
params: {
|
|
620
675
|
query: {
|
|
@@ -626,11 +681,11 @@ async function ct(e) {
|
|
|
626
681
|
}),
|
|
627
682
|
e.timeout
|
|
628
683
|
);
|
|
629
|
-
if (
|
|
630
|
-
throw
|
|
684
|
+
if (y)
|
|
685
|
+
throw y;
|
|
631
686
|
return f;
|
|
632
687
|
}
|
|
633
|
-
class
|
|
688
|
+
class ht {
|
|
634
689
|
/**
|
|
635
690
|
* Draw on display. Starts the Canvas application if not running.
|
|
636
691
|
*
|
|
@@ -641,7 +696,7 @@ class at {
|
|
|
641
696
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful draw command.
|
|
642
697
|
*/
|
|
643
698
|
async DisplayDraw(t) {
|
|
644
|
-
return await
|
|
699
|
+
return await ct(t);
|
|
645
700
|
}
|
|
646
701
|
/**
|
|
647
702
|
* Clear display. Clears the display and stops the Canvas application if running.
|
|
@@ -651,7 +706,7 @@ class at {
|
|
|
651
706
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful clear command.
|
|
652
707
|
*/
|
|
653
708
|
async DisplayClear(t) {
|
|
654
|
-
return await
|
|
709
|
+
return await at(t);
|
|
655
710
|
}
|
|
656
711
|
/**
|
|
657
712
|
* Get single frame for requested screen.
|
|
@@ -662,7 +717,7 @@ class at {
|
|
|
662
717
|
* @returns {Promise<Blob>} A promise that resolves to the screen frame as a Blob.
|
|
663
718
|
*/
|
|
664
719
|
async DisplayScreenFrameGet(t) {
|
|
665
|
-
return await
|
|
720
|
+
return await ut(t);
|
|
666
721
|
}
|
|
667
722
|
/**
|
|
668
723
|
* Get display brightness.
|
|
@@ -672,7 +727,7 @@ class at {
|
|
|
672
727
|
* @returns {Promise<DisplayBrightnessInfo>} A promise that resolves to the brightness information.
|
|
673
728
|
*/
|
|
674
729
|
async DisplayBrightnessGet(t) {
|
|
675
|
-
return await
|
|
730
|
+
return await dt(t);
|
|
676
731
|
}
|
|
677
732
|
/**
|
|
678
733
|
* @deprecated Use `DisplayBrightnessGet` instead. will be removed in the next release.
|
|
@@ -690,10 +745,10 @@ class at {
|
|
|
690
745
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
691
746
|
*/
|
|
692
747
|
async DisplayBrightnessSet(t) {
|
|
693
|
-
return await
|
|
748
|
+
return await ft(t);
|
|
694
749
|
}
|
|
695
750
|
}
|
|
696
|
-
async function
|
|
751
|
+
async function yt(e) {
|
|
697
752
|
const t = o(), { appId: n, path: i } = e, { data: r, error: c } = await s(
|
|
698
753
|
(a) => t.POST("/audio/play", {
|
|
699
754
|
params: {
|
|
@@ -710,7 +765,7 @@ async function ut(e) {
|
|
|
710
765
|
throw c;
|
|
711
766
|
return r;
|
|
712
767
|
}
|
|
713
|
-
async function
|
|
768
|
+
async function wt(e) {
|
|
714
769
|
const t = o(), { data: n, error: i } = await s(
|
|
715
770
|
(r) => t.DELETE("/audio/play", { signal: r }),
|
|
716
771
|
e == null ? void 0 : e.timeout
|
|
@@ -719,7 +774,7 @@ async function dt(e) {
|
|
|
719
774
|
throw i;
|
|
720
775
|
return n;
|
|
721
776
|
}
|
|
722
|
-
async function
|
|
777
|
+
async function lt(e) {
|
|
723
778
|
const t = o(), { data: n, error: i } = await s(
|
|
724
779
|
(r) => t.GET("/audio/volume", { signal: r }),
|
|
725
780
|
e == null ? void 0 : e.timeout
|
|
@@ -728,7 +783,7 @@ async function ft(e) {
|
|
|
728
783
|
throw i;
|
|
729
784
|
return n;
|
|
730
785
|
}
|
|
731
|
-
async function
|
|
786
|
+
async function St(e) {
|
|
732
787
|
const t = o(), { volume: n } = e;
|
|
733
788
|
if (typeof n != "number" || n < 0 || n > 100)
|
|
734
789
|
throw new Error("Volume must be a number between 0 and 100");
|
|
@@ -747,7 +802,7 @@ async function ht(e) {
|
|
|
747
802
|
throw r;
|
|
748
803
|
return i;
|
|
749
804
|
}
|
|
750
|
-
class
|
|
805
|
+
class pt {
|
|
751
806
|
/**
|
|
752
807
|
* Play audio file. Plays a file from internal storage.
|
|
753
808
|
*
|
|
@@ -758,7 +813,7 @@ class wt {
|
|
|
758
813
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful play command.
|
|
759
814
|
*/
|
|
760
815
|
async AudioPlay(t) {
|
|
761
|
-
return await
|
|
816
|
+
return await yt(t);
|
|
762
817
|
}
|
|
763
818
|
/**
|
|
764
819
|
* @deprecated Use `AudioPlay` instead. will be removed in the next release.
|
|
@@ -774,7 +829,7 @@ class wt {
|
|
|
774
829
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful stop command.
|
|
775
830
|
*/
|
|
776
831
|
async AudioStop(t) {
|
|
777
|
-
return await
|
|
832
|
+
return await wt(t);
|
|
778
833
|
}
|
|
779
834
|
/**
|
|
780
835
|
* Get audio volume.
|
|
@@ -784,7 +839,7 @@ class wt {
|
|
|
784
839
|
* @returns {Promise<AudioVolumeInfo>} A promise that resolves to the audio volume information.
|
|
785
840
|
*/
|
|
786
841
|
async AudioVolumeGet(t) {
|
|
787
|
-
return await
|
|
842
|
+
return await lt(t);
|
|
788
843
|
}
|
|
789
844
|
/**
|
|
790
845
|
* @deprecated Use `AudioVolumeGet` instead. will be removed in the next release.
|
|
@@ -801,10 +856,10 @@ class wt {
|
|
|
801
856
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
802
857
|
*/
|
|
803
858
|
async AudioVolumeSet(t) {
|
|
804
|
-
return await
|
|
859
|
+
return await St(t);
|
|
805
860
|
}
|
|
806
861
|
}
|
|
807
|
-
async function
|
|
862
|
+
async function mt(e) {
|
|
808
863
|
const t = o(), { data: n, error: i } = await s(
|
|
809
864
|
(r) => t.GET("/wifi/status", { signal: r }),
|
|
810
865
|
e == null ? void 0 : e.timeout
|
|
@@ -813,7 +868,7 @@ async function lt(e) {
|
|
|
813
868
|
throw i;
|
|
814
869
|
return n;
|
|
815
870
|
}
|
|
816
|
-
async function
|
|
871
|
+
async function Tt(e) {
|
|
817
872
|
const t = o(), { data: n, error: i } = await s(
|
|
818
873
|
(r) => t.POST("/wifi/connect", {
|
|
819
874
|
body: {
|
|
@@ -835,7 +890,7 @@ async function yt(e) {
|
|
|
835
890
|
throw i;
|
|
836
891
|
return n;
|
|
837
892
|
}
|
|
838
|
-
async function
|
|
893
|
+
async function Et(e) {
|
|
839
894
|
const t = o(), { data: n, error: i } = await s(
|
|
840
895
|
(r) => t.POST("/wifi/disconnect", { signal: r }),
|
|
841
896
|
e == null ? void 0 : e.timeout
|
|
@@ -844,7 +899,7 @@ async function St(e) {
|
|
|
844
899
|
throw i;
|
|
845
900
|
return n;
|
|
846
901
|
}
|
|
847
|
-
async function
|
|
902
|
+
async function gt(e) {
|
|
848
903
|
const t = o(), { data: n, error: i } = await s(
|
|
849
904
|
(r) => t.GET("/wifi/networks", { signal: r }),
|
|
850
905
|
e == null ? void 0 : e.timeout
|
|
@@ -853,7 +908,7 @@ async function pt(e) {
|
|
|
853
908
|
throw i;
|
|
854
909
|
return n;
|
|
855
910
|
}
|
|
856
|
-
class
|
|
911
|
+
class kt {
|
|
857
912
|
/**
|
|
858
913
|
* Returns current Wi-Fi status.
|
|
859
914
|
*
|
|
@@ -862,7 +917,7 @@ class mt {
|
|
|
862
917
|
* @returns {Promise<WifiStatusResponse>} A promise that resolves to the Wi-Fi status.
|
|
863
918
|
*/
|
|
864
919
|
async WifiStatusGet(t) {
|
|
865
|
-
return await
|
|
920
|
+
return await mt(t);
|
|
866
921
|
}
|
|
867
922
|
/**
|
|
868
923
|
* @deprecated Use `WifiStatusGet` instead. will be removed in the next release.
|
|
@@ -882,7 +937,7 @@ class mt {
|
|
|
882
937
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful connection initiation.
|
|
883
938
|
*/
|
|
884
939
|
async WifiConnect(t) {
|
|
885
|
-
return await
|
|
940
|
+
return await Tt(t);
|
|
886
941
|
}
|
|
887
942
|
/**
|
|
888
943
|
* Disconnects from Wi-Fi.
|
|
@@ -892,7 +947,7 @@ class mt {
|
|
|
892
947
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful disconnection.
|
|
893
948
|
*/
|
|
894
949
|
async WifiDisconnect(t) {
|
|
895
|
-
return await
|
|
950
|
+
return await Et(t);
|
|
896
951
|
}
|
|
897
952
|
/**
|
|
898
953
|
* Scans environment for available Wi-Fi networks.
|
|
@@ -902,7 +957,7 @@ class mt {
|
|
|
902
957
|
* @returns {Promise<WifiNetworkResponse>} A promise that resolves to a list of available networks.
|
|
903
958
|
*/
|
|
904
959
|
async WifiNetworksGet(t) {
|
|
905
|
-
return await
|
|
960
|
+
return await gt(t);
|
|
906
961
|
}
|
|
907
962
|
/**
|
|
908
963
|
* @deprecated Use `WifiNetworksGet` instead. will be removed in the next release.
|
|
@@ -911,7 +966,7 @@ class mt {
|
|
|
911
966
|
return this.WifiNetworksGet(t);
|
|
912
967
|
}
|
|
913
968
|
}
|
|
914
|
-
async function
|
|
969
|
+
async function Gt(e) {
|
|
915
970
|
const t = o(), { path: n, file: i } = e, { data: r, error: c } = await s(
|
|
916
971
|
(a) => t.POST("/storage/write", {
|
|
917
972
|
params: {
|
|
@@ -931,7 +986,7 @@ async function Tt(e) {
|
|
|
931
986
|
throw c;
|
|
932
987
|
return r;
|
|
933
988
|
}
|
|
934
|
-
async function
|
|
989
|
+
async function At(e) {
|
|
935
990
|
const t = o(), { path: n, asArrayBuffer: i } = e, { data: r, error: c } = await s(
|
|
936
991
|
(a) => t.GET("/storage/read", {
|
|
937
992
|
params: {
|
|
@@ -948,7 +1003,7 @@ async function Et(e) {
|
|
|
948
1003
|
throw c;
|
|
949
1004
|
return r;
|
|
950
1005
|
}
|
|
951
|
-
async function
|
|
1006
|
+
async function bt(e) {
|
|
952
1007
|
const t = o(), { path: n } = e, { data: i, error: r } = await s(
|
|
953
1008
|
(c) => t.GET("/storage/list", {
|
|
954
1009
|
params: {
|
|
@@ -964,7 +1019,7 @@ async function gt(e) {
|
|
|
964
1019
|
throw r;
|
|
965
1020
|
return i;
|
|
966
1021
|
}
|
|
967
|
-
async function
|
|
1022
|
+
async function Pt(e) {
|
|
968
1023
|
const t = o(), { path: n } = e, { data: i, error: r } = await s(
|
|
969
1024
|
(c) => t.DELETE("/storage/remove", {
|
|
970
1025
|
params: {
|
|
@@ -980,7 +1035,7 @@ async function kt(e) {
|
|
|
980
1035
|
throw r;
|
|
981
1036
|
return i;
|
|
982
1037
|
}
|
|
983
|
-
async function
|
|
1038
|
+
async function vt(e) {
|
|
984
1039
|
const t = o(), { path: n } = e, { data: i, error: r } = await s(
|
|
985
1040
|
(c) => t.POST("/storage/mkdir", {
|
|
986
1041
|
params: {
|
|
@@ -996,7 +1051,7 @@ async function Gt(e) {
|
|
|
996
1051
|
throw r;
|
|
997
1052
|
return i;
|
|
998
1053
|
}
|
|
999
|
-
async function
|
|
1054
|
+
async function Lt(e) {
|
|
1000
1055
|
const t = o(), { data: n, error: i } = await s(
|
|
1001
1056
|
(r) => t.GET("/storage/status", { signal: r }),
|
|
1002
1057
|
e == null ? void 0 : e.timeout
|
|
@@ -1005,7 +1060,7 @@ async function bt(e) {
|
|
|
1005
1060
|
throw i;
|
|
1006
1061
|
return n;
|
|
1007
1062
|
}
|
|
1008
|
-
class
|
|
1063
|
+
class Ot {
|
|
1009
1064
|
/**
|
|
1010
1065
|
* Upload file to internal storage. Uploads a file to a specified path.
|
|
1011
1066
|
*
|
|
@@ -1016,7 +1071,7 @@ class At {
|
|
|
1016
1071
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful upload.
|
|
1017
1072
|
*/
|
|
1018
1073
|
async StorageWrite(t) {
|
|
1019
|
-
return await
|
|
1074
|
+
return await Gt(t);
|
|
1020
1075
|
}
|
|
1021
1076
|
/**
|
|
1022
1077
|
* Download file from internal storage. Downloads a file from a specified path.
|
|
@@ -1028,7 +1083,7 @@ class At {
|
|
|
1028
1083
|
* @returns {Promise<StorageReadResponse>} A promise that resolves to the file content (Blob or ArrayBuffer).
|
|
1029
1084
|
*/
|
|
1030
1085
|
async StorageRead(t) {
|
|
1031
|
-
return await
|
|
1086
|
+
return await At(t);
|
|
1032
1087
|
}
|
|
1033
1088
|
/**
|
|
1034
1089
|
* List files on internal storage.
|
|
@@ -1039,7 +1094,7 @@ class At {
|
|
|
1039
1094
|
* @returns {Promise<StorageList>} A promise that resolves to a list of files and directories.
|
|
1040
1095
|
*/
|
|
1041
1096
|
async StorageListGet(t) {
|
|
1042
|
-
return await
|
|
1097
|
+
return await bt(t);
|
|
1043
1098
|
}
|
|
1044
1099
|
/**
|
|
1045
1100
|
* @deprecated Use `StorageListGet` instead. will be removed in the next release.
|
|
@@ -1056,7 +1111,7 @@ class At {
|
|
|
1056
1111
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful removal.
|
|
1057
1112
|
*/
|
|
1058
1113
|
async StorageRemove(t) {
|
|
1059
|
-
return await
|
|
1114
|
+
return await Pt(t);
|
|
1060
1115
|
}
|
|
1061
1116
|
/**
|
|
1062
1117
|
* Create a directory on internal storage. Creates a new directory with a specified path.
|
|
@@ -1067,7 +1122,7 @@ class At {
|
|
|
1067
1122
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful creation.
|
|
1068
1123
|
*/
|
|
1069
1124
|
async StorageMkdir(t) {
|
|
1070
|
-
return await
|
|
1125
|
+
return await vt(t);
|
|
1071
1126
|
}
|
|
1072
1127
|
/**
|
|
1073
1128
|
* Show storage usage.
|
|
@@ -1077,7 +1132,7 @@ class At {
|
|
|
1077
1132
|
* @returns {Promise<StorageStatus>} A promise that resolves to the storage status.
|
|
1078
1133
|
*/
|
|
1079
1134
|
async StorageStatusGet(t) {
|
|
1080
|
-
return await
|
|
1135
|
+
return await Lt(t);
|
|
1081
1136
|
}
|
|
1082
1137
|
/**
|
|
1083
1138
|
* @deprecated Use `StorageStatusGet` instead. will be removed in the next release.
|
|
@@ -1086,7 +1141,7 @@ class At {
|
|
|
1086
1141
|
return this.StorageStatusGet(t);
|
|
1087
1142
|
}
|
|
1088
1143
|
}
|
|
1089
|
-
async function
|
|
1144
|
+
async function Dt(e) {
|
|
1090
1145
|
const t = o(), { data: n, error: i } = await s(
|
|
1091
1146
|
(r) => t.GET("/access", { signal: r }),
|
|
1092
1147
|
e == null ? void 0 : e.timeout
|
|
@@ -1095,7 +1150,7 @@ async function vt(e) {
|
|
|
1095
1150
|
throw i;
|
|
1096
1151
|
return n;
|
|
1097
1152
|
}
|
|
1098
|
-
async function
|
|
1153
|
+
async function Ut(e) {
|
|
1099
1154
|
const t = o();
|
|
1100
1155
|
let { mode: n, key: i } = e;
|
|
1101
1156
|
if (i = i ?? "", String(i).trim() && !/^\d{4,10}$/.test(String(i)))
|
|
@@ -1116,7 +1171,7 @@ async function Pt(e) {
|
|
|
1116
1171
|
throw c;
|
|
1117
1172
|
return r;
|
|
1118
1173
|
}
|
|
1119
|
-
async function
|
|
1174
|
+
async function Bt(e) {
|
|
1120
1175
|
const t = o(), { data: n, error: i } = await s(
|
|
1121
1176
|
(r) => t.GET("/name", { signal: r }),
|
|
1122
1177
|
e == null ? void 0 : e.timeout
|
|
@@ -1125,7 +1180,7 @@ async function Lt(e) {
|
|
|
1125
1180
|
throw i;
|
|
1126
1181
|
return n;
|
|
1127
1182
|
}
|
|
1128
|
-
async function
|
|
1183
|
+
async function Ct(e) {
|
|
1129
1184
|
const t = o(), { data: n, error: i } = await s(
|
|
1130
1185
|
(r) => t.POST("/name", {
|
|
1131
1186
|
body: e,
|
|
@@ -1137,7 +1192,7 @@ async function Dt(e) {
|
|
|
1137
1192
|
throw i;
|
|
1138
1193
|
return n;
|
|
1139
1194
|
}
|
|
1140
|
-
class
|
|
1195
|
+
class It {
|
|
1141
1196
|
/**
|
|
1142
1197
|
* Get HTTP API access over Wi-Fi configuration.
|
|
1143
1198
|
*
|
|
@@ -1146,7 +1201,7 @@ class Ot {
|
|
|
1146
1201
|
* @returns {Promise<HttpAccessInfo>} A promise that resolves to the access configuration.
|
|
1147
1202
|
*/
|
|
1148
1203
|
async SettingsAccessGet(t) {
|
|
1149
|
-
return await
|
|
1204
|
+
return await Dt(t);
|
|
1150
1205
|
}
|
|
1151
1206
|
/**
|
|
1152
1207
|
* @deprecated Use `SettingsAccessGet` instead. will be removed in the next release.
|
|
@@ -1164,7 +1219,8 @@ class Ot {
|
|
|
1164
1219
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1165
1220
|
*/
|
|
1166
1221
|
async SettingsAccessSet(t) {
|
|
1167
|
-
|
|
1222
|
+
const n = await Ut(t);
|
|
1223
|
+
return t.mode === "key" && t.key && this.setApiKey(t.key), n;
|
|
1168
1224
|
}
|
|
1169
1225
|
/**
|
|
1170
1226
|
* Get current device name.
|
|
@@ -1174,7 +1230,7 @@ class Ot {
|
|
|
1174
1230
|
* @returns {Promise<NameInfo>} A promise that resolves to the device name.
|
|
1175
1231
|
*/
|
|
1176
1232
|
async SettingsNameGet(t) {
|
|
1177
|
-
return await
|
|
1233
|
+
return await Bt(t);
|
|
1178
1234
|
}
|
|
1179
1235
|
/**
|
|
1180
1236
|
* @deprecated Use `SettingsNameGet` instead. will be removed in the next release.
|
|
@@ -1191,10 +1247,10 @@ class Ot {
|
|
|
1191
1247
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1192
1248
|
*/
|
|
1193
1249
|
async SettingsNameSet(t) {
|
|
1194
|
-
return await
|
|
1250
|
+
return await Ct(t);
|
|
1195
1251
|
}
|
|
1196
1252
|
}
|
|
1197
|
-
async function
|
|
1253
|
+
async function $t(e) {
|
|
1198
1254
|
const t = o(), { data: n, error: i } = await s(
|
|
1199
1255
|
(r) => t.POST("/ble/enable", { signal: r }),
|
|
1200
1256
|
e == null ? void 0 : e.timeout
|
|
@@ -1203,7 +1259,7 @@ async function Ut(e) {
|
|
|
1203
1259
|
throw i;
|
|
1204
1260
|
return n;
|
|
1205
1261
|
}
|
|
1206
|
-
async function
|
|
1262
|
+
async function Rt(e) {
|
|
1207
1263
|
const t = o(), { data: n, error: i } = await s(
|
|
1208
1264
|
(r) => t.POST("/ble/disable", { signal: r }),
|
|
1209
1265
|
e == null ? void 0 : e.timeout
|
|
@@ -1212,7 +1268,7 @@ async function Bt(e) {
|
|
|
1212
1268
|
throw i;
|
|
1213
1269
|
return n;
|
|
1214
1270
|
}
|
|
1215
|
-
async function
|
|
1271
|
+
async function Wt(e) {
|
|
1216
1272
|
const t = o(), { data: n, error: i } = await s(
|
|
1217
1273
|
(r) => t.DELETE("/ble/pairing", { signal: r }),
|
|
1218
1274
|
e == null ? void 0 : e.timeout
|
|
@@ -1221,7 +1277,7 @@ async function Ct(e) {
|
|
|
1221
1277
|
throw i;
|
|
1222
1278
|
return n;
|
|
1223
1279
|
}
|
|
1224
|
-
async function
|
|
1280
|
+
async function Nt(e) {
|
|
1225
1281
|
const t = o(), { data: n, error: i } = await s(
|
|
1226
1282
|
(r) => t.GET("/ble/status", { signal: r }),
|
|
1227
1283
|
e == null ? void 0 : e.timeout
|
|
@@ -1230,7 +1286,7 @@ async function It(e) {
|
|
|
1230
1286
|
throw i;
|
|
1231
1287
|
return n;
|
|
1232
1288
|
}
|
|
1233
|
-
class
|
|
1289
|
+
class Kt {
|
|
1234
1290
|
/**
|
|
1235
1291
|
* Enable BLE. Starts advertising.
|
|
1236
1292
|
*
|
|
@@ -1239,7 +1295,7 @@ class $t {
|
|
|
1239
1295
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1240
1296
|
*/
|
|
1241
1297
|
async BleEnable(t) {
|
|
1242
|
-
return await
|
|
1298
|
+
return await $t(t);
|
|
1243
1299
|
}
|
|
1244
1300
|
/**
|
|
1245
1301
|
* Disable BLE. Stops advertising.
|
|
@@ -1249,7 +1305,7 @@ class $t {
|
|
|
1249
1305
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1250
1306
|
*/
|
|
1251
1307
|
async BleDisable(t) {
|
|
1252
|
-
return await
|
|
1308
|
+
return await Rt(t);
|
|
1253
1309
|
}
|
|
1254
1310
|
/**
|
|
1255
1311
|
* Remove pairing. Remove pairing with previous device.
|
|
@@ -1259,7 +1315,7 @@ class $t {
|
|
|
1259
1315
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1260
1316
|
*/
|
|
1261
1317
|
async BleUnpair(t) {
|
|
1262
|
-
return await
|
|
1318
|
+
return await Wt(t);
|
|
1263
1319
|
}
|
|
1264
1320
|
/**
|
|
1265
1321
|
* Returns current BLE status.
|
|
@@ -1269,10 +1325,10 @@ class $t {
|
|
|
1269
1325
|
* @returns {Promise<BleStatusResponse>} A promise that resolves to the BLE status.
|
|
1270
1326
|
*/
|
|
1271
1327
|
async BleStatusGet(t) {
|
|
1272
|
-
return await
|
|
1328
|
+
return await Nt(t);
|
|
1273
1329
|
}
|
|
1274
1330
|
}
|
|
1275
|
-
async function
|
|
1331
|
+
async function Ft(e) {
|
|
1276
1332
|
const t = o(), { keyName: n } = e, { data: i, error: r } = await s(
|
|
1277
1333
|
(c) => t.POST("/input", {
|
|
1278
1334
|
params: {
|
|
@@ -1288,7 +1344,7 @@ async function Rt(e) {
|
|
|
1288
1344
|
throw r;
|
|
1289
1345
|
return i;
|
|
1290
1346
|
}
|
|
1291
|
-
class
|
|
1347
|
+
class Mt {
|
|
1292
1348
|
/**
|
|
1293
1349
|
* Send input event. Send single key press event.
|
|
1294
1350
|
*
|
|
@@ -1298,10 +1354,10 @@ class Wt {
|
|
|
1298
1354
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1299
1355
|
*/
|
|
1300
1356
|
async InputSend(t) {
|
|
1301
|
-
return await
|
|
1357
|
+
return await Ft(t);
|
|
1302
1358
|
}
|
|
1303
1359
|
}
|
|
1304
|
-
async function
|
|
1360
|
+
async function Vt(e) {
|
|
1305
1361
|
const t = o(), { data: n, error: i } = await s(
|
|
1306
1362
|
(r) => t.GET("/matter/commissioning", { signal: r }),
|
|
1307
1363
|
e == null ? void 0 : e.timeout
|
|
@@ -1310,7 +1366,7 @@ async function Nt(e) {
|
|
|
1310
1366
|
throw i;
|
|
1311
1367
|
return n;
|
|
1312
1368
|
}
|
|
1313
|
-
async function
|
|
1369
|
+
async function xt(e) {
|
|
1314
1370
|
const t = o(), { data: n, error: i } = await s(
|
|
1315
1371
|
(r) => t.POST("/matter/commissioning", { signal: r }),
|
|
1316
1372
|
e == null ? void 0 : e.timeout
|
|
@@ -1319,7 +1375,7 @@ async function Mt(e) {
|
|
|
1319
1375
|
throw i;
|
|
1320
1376
|
return n;
|
|
1321
1377
|
}
|
|
1322
|
-
async function
|
|
1378
|
+
async function _t(e) {
|
|
1323
1379
|
const t = o(), { data: n, error: i } = await s(
|
|
1324
1380
|
(r) => t.DELETE("/matter/commissioning", { signal: r }),
|
|
1325
1381
|
e == null ? void 0 : e.timeout
|
|
@@ -1328,7 +1384,7 @@ async function Vt(e) {
|
|
|
1328
1384
|
throw i;
|
|
1329
1385
|
return n;
|
|
1330
1386
|
}
|
|
1331
|
-
class
|
|
1387
|
+
class zt {
|
|
1332
1388
|
/**
|
|
1333
1389
|
* Get Matter status.
|
|
1334
1390
|
*
|
|
@@ -1337,7 +1393,7 @@ class Kt {
|
|
|
1337
1393
|
* @returns {Promise<MatterStatus>} A promise that resolves to the Matter status.
|
|
1338
1394
|
*/
|
|
1339
1395
|
async MatterStatusGet(t) {
|
|
1340
|
-
return await
|
|
1396
|
+
return await Vt(t);
|
|
1341
1397
|
}
|
|
1342
1398
|
/**
|
|
1343
1399
|
* Pair Matter device.
|
|
@@ -1347,7 +1403,7 @@ class Kt {
|
|
|
1347
1403
|
* @returns {Promise<MatterPairingInfo>} A promise that resolves on success.
|
|
1348
1404
|
*/
|
|
1349
1405
|
async MatterPair(t) {
|
|
1350
|
-
return await
|
|
1406
|
+
return await xt(t);
|
|
1351
1407
|
}
|
|
1352
1408
|
/**
|
|
1353
1409
|
* Erase Matter devices.
|
|
@@ -1357,11 +1413,11 @@ class Kt {
|
|
|
1357
1413
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1358
1414
|
*/
|
|
1359
1415
|
async MatterErase(t) {
|
|
1360
|
-
return await
|
|
1416
|
+
return await _t(t);
|
|
1361
1417
|
}
|
|
1362
1418
|
}
|
|
1363
|
-
const
|
|
1364
|
-
function
|
|
1419
|
+
const g = "http://10.0.4.20", qt = "https://proxy.busy.app", jt = /^https?:\/\/proxy(?:\.(?:dev|test|stage))?\.busy\.app$/i;
|
|
1420
|
+
function k(e) {
|
|
1365
1421
|
const t = e.split(".");
|
|
1366
1422
|
if (t.length !== 4)
|
|
1367
1423
|
return !1;
|
|
@@ -1374,10 +1430,10 @@ function g(e) {
|
|
|
1374
1430
|
}
|
|
1375
1431
|
return !0;
|
|
1376
1432
|
}
|
|
1377
|
-
function
|
|
1433
|
+
function G(e) {
|
|
1378
1434
|
return /\.local$/i.test(e);
|
|
1379
1435
|
}
|
|
1380
|
-
class
|
|
1436
|
+
class Ht {
|
|
1381
1437
|
/**
|
|
1382
1438
|
* Creates an instance of BUSY Bar.
|
|
1383
1439
|
* Initializes the API client with the provided host address.
|
|
@@ -1420,16 +1476,16 @@ class Ft {
|
|
|
1420
1476
|
*/
|
|
1421
1477
|
u(this, "connectionType", "unknown");
|
|
1422
1478
|
if (!t || !t.addr && !t.token)
|
|
1423
|
-
this.addr =
|
|
1479
|
+
this.addr = g;
|
|
1424
1480
|
else if (!t.addr)
|
|
1425
|
-
this.addr =
|
|
1481
|
+
this.addr = qt;
|
|
1426
1482
|
else {
|
|
1427
1483
|
let n = t.addr.trim();
|
|
1428
|
-
if (/^https?:\/\//i.test(n) || (n = `http://${n}`),
|
|
1484
|
+
if (/^https?:\/\//i.test(n) || (n = `http://${n}`), jt.test(n) && !t.token)
|
|
1429
1485
|
throw new Error("Token is required. Please provide it.");
|
|
1430
1486
|
this.addr = n;
|
|
1431
1487
|
}
|
|
1432
|
-
this.apiSemver = "",
|
|
1488
|
+
this.apiSemver = "", $(
|
|
1433
1489
|
`${this.addr}/api/`,
|
|
1434
1490
|
this.SystemVersionGet.bind(this),
|
|
1435
1491
|
t == null ? void 0 : t.token
|
|
@@ -1441,7 +1497,7 @@ class Ft {
|
|
|
1441
1497
|
*/
|
|
1442
1498
|
async detectConnectionType() {
|
|
1443
1499
|
const t = new URL(this.addr).hostname;
|
|
1444
|
-
if (!
|
|
1500
|
+
if (!k(t) && !G(t)) {
|
|
1445
1501
|
this.connectionType = "wifi";
|
|
1446
1502
|
return;
|
|
1447
1503
|
}
|
|
@@ -1462,8 +1518,15 @@ class Ft {
|
|
|
1462
1518
|
throw i;
|
|
1463
1519
|
}
|
|
1464
1520
|
}
|
|
1521
|
+
/**
|
|
1522
|
+
* Sets API key for all subsequent requests.
|
|
1523
|
+
* @param {string} key - API key to use in "X-API-Token" header.
|
|
1524
|
+
*/
|
|
1525
|
+
setApiKey(t) {
|
|
1526
|
+
C(t);
|
|
1527
|
+
}
|
|
1465
1528
|
}
|
|
1466
|
-
function
|
|
1529
|
+
function Jt(e, t) {
|
|
1467
1530
|
t.forEach((n) => {
|
|
1468
1531
|
Object.getOwnPropertyNames(n.prototype).forEach((i) => {
|
|
1469
1532
|
Object.defineProperty(
|
|
@@ -1474,23 +1537,23 @@ function qt(e, t) {
|
|
|
1474
1537
|
});
|
|
1475
1538
|
});
|
|
1476
1539
|
}
|
|
1477
|
-
|
|
1478
|
-
N,
|
|
1540
|
+
Jt(Ht, [
|
|
1479
1541
|
F,
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1542
|
+
j,
|
|
1543
|
+
Z,
|
|
1544
|
+
st,
|
|
1545
|
+
ht,
|
|
1546
|
+
pt,
|
|
1547
|
+
kt,
|
|
1486
1548
|
Ot,
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1549
|
+
It,
|
|
1550
|
+
Kt,
|
|
1551
|
+
Mt,
|
|
1552
|
+
zt
|
|
1490
1553
|
]);
|
|
1491
|
-
var
|
|
1492
|
-
const
|
|
1493
|
-
function
|
|
1554
|
+
var E = /* @__PURE__ */ ((e) => (e[e.FRONT = 0] = "FRONT", e[e.BACK = 1] = "BACK", e))(E || {});
|
|
1555
|
+
const P = 3e3, v = /* @__PURE__ */ new Set([1001, 1006, 1012, 1013, 1014, 3008]);
|
|
1556
|
+
function L(e, t) {
|
|
1494
1557
|
if (t < 0 || t >= e.length)
|
|
1495
1558
|
throw new Error(`Index ${t} is out of bounds (0…${e.length - 1})`);
|
|
1496
1559
|
const n = e[t];
|
|
@@ -1498,11 +1561,11 @@ function P(e, t) {
|
|
|
1498
1561
|
throw new Error(`Unexpected undefined at index ${t}`);
|
|
1499
1562
|
return n;
|
|
1500
1563
|
}
|
|
1501
|
-
function
|
|
1564
|
+
function Xt(e, t) {
|
|
1502
1565
|
let n = 0;
|
|
1503
1566
|
const i = e.length, r = [];
|
|
1504
1567
|
for (; n < i; ) {
|
|
1505
|
-
const c =
|
|
1568
|
+
const c = L(e, n);
|
|
1506
1569
|
if (n += 1, (c & 128) !== 0) {
|
|
1507
1570
|
const a = c & 127;
|
|
1508
1571
|
for (let f = 0; f < a * t; f++)
|
|
@@ -1510,7 +1573,7 @@ function jt(e, t) {
|
|
|
1510
1573
|
n += a * t;
|
|
1511
1574
|
} else {
|
|
1512
1575
|
const a = c, f = e.slice(n, n + t);
|
|
1513
|
-
for (let
|
|
1576
|
+
for (let y = 0; y < a; y++)
|
|
1514
1577
|
for (let d = 0; d < t; d++)
|
|
1515
1578
|
r.push(f[d]);
|
|
1516
1579
|
n += t;
|
|
@@ -1518,17 +1581,17 @@ function jt(e, t) {
|
|
|
1518
1581
|
}
|
|
1519
1582
|
return new Uint8Array(r);
|
|
1520
1583
|
}
|
|
1521
|
-
function
|
|
1584
|
+
function Qt(e) {
|
|
1522
1585
|
const t = new Uint8Array(e.length * 2);
|
|
1523
1586
|
let n = 0, i = 0;
|
|
1524
1587
|
for (; n < e.length; ) {
|
|
1525
|
-
const r =
|
|
1588
|
+
const r = L(e, n), c = r & 15, a = r >> 4 & 15;
|
|
1526
1589
|
t[i] = c, t[i + 1] = a, n += 1, i += 2;
|
|
1527
1590
|
}
|
|
1528
1591
|
return t;
|
|
1529
1592
|
}
|
|
1530
|
-
const
|
|
1531
|
-
class
|
|
1593
|
+
const O = () => typeof window < "u" && typeof window.document < "u";
|
|
1594
|
+
class te {
|
|
1532
1595
|
constructor(t) {
|
|
1533
1596
|
u(this, "addr");
|
|
1534
1597
|
u(this, "connected", !1);
|
|
@@ -1540,16 +1603,16 @@ class Xt {
|
|
|
1540
1603
|
u(this, "stopListeners", []);
|
|
1541
1604
|
u(this, "errorListeners", []);
|
|
1542
1605
|
u(this, "socket", null);
|
|
1543
|
-
if (this.config = t, !
|
|
1606
|
+
if (this.config = t, !O())
|
|
1544
1607
|
throw new Error("not browser");
|
|
1545
1608
|
if (t.apiKey && (this.apiKey = t.apiKey), t.apiSemver && (this.apiSemver = t.apiSemver), !t || !t.addr)
|
|
1546
|
-
this.addr =
|
|
1609
|
+
this.addr = g;
|
|
1547
1610
|
else {
|
|
1548
1611
|
let n = t.addr.trim();
|
|
1549
1612
|
/^https?:\/\//i.test(n) || (n = `http://${n}`);
|
|
1550
1613
|
try {
|
|
1551
1614
|
const r = new URL(n).hostname;
|
|
1552
|
-
if (!
|
|
1615
|
+
if (!k(r) && !G(r))
|
|
1553
1616
|
throw new Error(
|
|
1554
1617
|
`Invalid address: "${t.addr}". Only IP addresses and mDNS names (ending in .local) are supported.`
|
|
1555
1618
|
);
|
|
@@ -1593,10 +1656,10 @@ class Xt {
|
|
|
1593
1656
|
return;
|
|
1594
1657
|
const i = new Uint8Array(n.data);
|
|
1595
1658
|
let r;
|
|
1596
|
-
const c = this.config.deviceScreen ===
|
|
1659
|
+
const c = this.config.deviceScreen === E.FRONT ? 3 : 2;
|
|
1597
1660
|
try {
|
|
1598
|
-
const a =
|
|
1599
|
-
this.config.deviceScreen ===
|
|
1661
|
+
const a = Xt(i, c);
|
|
1662
|
+
this.config.deviceScreen === E.BACK ? r = Qt(a) : r = a, this.emitData(r);
|
|
1600
1663
|
} catch {
|
|
1601
1664
|
this.emitData(i);
|
|
1602
1665
|
}
|
|
@@ -1611,7 +1674,7 @@ class Xt {
|
|
|
1611
1674
|
raw: n
|
|
1612
1675
|
}), this.emitStop();
|
|
1613
1676
|
}, this.socket.onclose = async (n) => {
|
|
1614
|
-
if (this.socket = null, this.connected = !1, n.code ===
|
|
1677
|
+
if (this.socket = null, this.connected = !1, n.code === P || v.has(n.code)) {
|
|
1615
1678
|
this.emitError({
|
|
1616
1679
|
code: n.code,
|
|
1617
1680
|
message: n.reason,
|
|
@@ -1630,7 +1693,7 @@ class Xt {
|
|
|
1630
1693
|
});
|
|
1631
1694
|
}
|
|
1632
1695
|
}
|
|
1633
|
-
class
|
|
1696
|
+
class ee {
|
|
1634
1697
|
constructor(t) {
|
|
1635
1698
|
u(this, "addr");
|
|
1636
1699
|
u(this, "connected", !1);
|
|
@@ -1643,16 +1706,16 @@ class Qt {
|
|
|
1643
1706
|
u(this, "stopListeners", []);
|
|
1644
1707
|
u(this, "errorListeners", []);
|
|
1645
1708
|
u(this, "socket", null);
|
|
1646
|
-
if (!
|
|
1709
|
+
if (!O())
|
|
1647
1710
|
throw new Error("not browser");
|
|
1648
1711
|
if (t != null && t.apiKey && (this.apiKey = t.apiKey), t != null && t.apiSemver && (this.apiSemver = t.apiSemver), !t || !t.addr)
|
|
1649
|
-
this.addr =
|
|
1712
|
+
this.addr = g;
|
|
1650
1713
|
else {
|
|
1651
1714
|
let n = t.addr.trim();
|
|
1652
1715
|
/^https?:\/\//i.test(n) || (n = `http://${n}`);
|
|
1653
1716
|
try {
|
|
1654
1717
|
const r = new URL(n).hostname;
|
|
1655
|
-
if (!
|
|
1718
|
+
if (!k(r) && !G(r))
|
|
1656
1719
|
throw new Error(
|
|
1657
1720
|
`Invalid address: "${t.addr}". Only IP addresses and mDNS names (ending in .local) are supported.`
|
|
1658
1721
|
);
|
|
@@ -1708,7 +1771,7 @@ class Qt {
|
|
|
1708
1771
|
raw: n
|
|
1709
1772
|
}), this.emitStop();
|
|
1710
1773
|
}, this.socket.onclose = async (n) => {
|
|
1711
|
-
if (this.socket = null, this.connected = !1, n.code ===
|
|
1774
|
+
if (this.socket = null, this.connected = !1, n.code === P || v.has(n.code)) {
|
|
1712
1775
|
this.emitError({
|
|
1713
1776
|
code: n.code,
|
|
1714
1777
|
message: n.reason,
|
|
@@ -1733,8 +1796,8 @@ class Qt {
|
|
|
1733
1796
|
}
|
|
1734
1797
|
}
|
|
1735
1798
|
export {
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1799
|
+
Ht as BusyBar,
|
|
1800
|
+
E as DeviceScreen,
|
|
1801
|
+
ee as Input,
|
|
1802
|
+
te as ScreenStream
|
|
1740
1803
|
};
|