@busy-app/busy-lib 0.11.0 → 0.12.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.cjs +1 -1
- package/dist/index.d.ts +362 -250
- package/dist/index.js +568 -511
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
1
|
var G = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
const
|
|
2
|
+
var v = (n, t, e) => t in n ? G(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var u = (n, t, e) => v(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import E from "openapi-fetch";
|
|
5
|
+
const O = (n, t) => {
|
|
6
6
|
if (typeof FormData < "u" && n instanceof FormData || typeof Buffer < "u" && typeof Buffer.isBuffer == "function" && Buffer.isBuffer(n) || typeof File < "u" && n instanceof File || typeof Blob < "u" && n instanceof Blob || typeof ArrayBuffer < "u" && n instanceof ArrayBuffer || typeof ArrayBuffer < "u" && ArrayBuffer.isView && ArrayBuffer.isView(n))
|
|
7
7
|
return n;
|
|
8
|
-
let
|
|
9
|
-
return t && (t instanceof Headers ?
|
|
8
|
+
let e;
|
|
9
|
+
return t && (t instanceof Headers ? e = t.get("Content-Type") ?? t.get("content-type") ?? void 0 : typeof t == "object" && (e = t["Content-Type"] ?? t["content-type"]), e === "application/x-www-form-urlencoded") ? n && typeof n == "object" && !(n instanceof URLSearchParams) ? new URLSearchParams(n).toString() : String(n) : JSON.stringify(n);
|
|
10
10
|
};
|
|
11
11
|
async function y(n) {
|
|
12
|
-
const
|
|
12
|
+
const i = (n.headers.get("content-type") || "").includes("application/json") ? await n.clone().json() : await n.clone().text(), r = typeof i == "object" && i !== null ? i.error || i.message : typeof i == "string" ? i : void 0;
|
|
13
13
|
return Object.assign(new Error(r || `HTTP ${n.status} ${n.statusText}`), {
|
|
14
14
|
status: n.status,
|
|
15
15
|
statusText: n.statusText,
|
|
16
|
-
body:
|
|
16
|
+
body: i
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
async function s(n, t = 3e3) {
|
|
20
20
|
if (t <= 0)
|
|
21
21
|
return await n();
|
|
22
|
-
const
|
|
22
|
+
const e = new AbortController(), i = setTimeout(() => e.abort(), t);
|
|
23
23
|
try {
|
|
24
|
-
return await n(
|
|
24
|
+
return await n(e.signal);
|
|
25
25
|
} catch (r) {
|
|
26
26
|
throw r instanceof DOMException && r.name === "AbortError" ? new Error(`Request timed out after ${t}ms`) : r;
|
|
27
27
|
} finally {
|
|
28
|
-
clearTimeout(
|
|
28
|
+
clearTimeout(i);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
let
|
|
33
|
-
const
|
|
34
|
-
|
|
31
|
+
function L(n, t, e) {
|
|
32
|
+
let i, r = e ?? void 0, o, a = null;
|
|
33
|
+
const c = async () => {
|
|
34
|
+
i || (a || (a = (async () => {
|
|
35
35
|
const h = await t();
|
|
36
36
|
if (!h.api_semver)
|
|
37
37
|
throw new Error("Empty API version");
|
|
38
|
-
|
|
38
|
+
i = h.api_semver;
|
|
39
39
|
})().finally(() => {
|
|
40
40
|
a = null;
|
|
41
41
|
})), await a);
|
|
42
|
-
},
|
|
43
|
-
async onRequest({ request: h, schemaPath:
|
|
44
|
-
return r && h.headers.set("Authorization", `Bearer ${r}`),
|
|
42
|
+
}, d = {
|
|
43
|
+
async onRequest({ request: h, schemaPath: w }) {
|
|
44
|
+
return r && h.headers.set("Authorization", `Bearer ${r}`), w !== "/version" && (await c(), i && h.headers.set("X-API-Sem-Ver", i), o && h.headers.set("X-API-Token", o)), h;
|
|
45
45
|
},
|
|
46
|
-
async onResponse({ request: h, response:
|
|
47
|
-
if (
|
|
48
|
-
return
|
|
49
|
-
if (
|
|
50
|
-
throw await y(
|
|
51
|
-
if (
|
|
52
|
-
throw await y(
|
|
53
|
-
|
|
46
|
+
async onResponse({ request: h, response: w, options: b, schemaPath: P }) {
|
|
47
|
+
if (w.ok)
|
|
48
|
+
return w;
|
|
49
|
+
if (P === "/version")
|
|
50
|
+
throw await y(w);
|
|
51
|
+
if (w.status !== 405)
|
|
52
|
+
throw await y(w);
|
|
53
|
+
i = void 0, await c(), i && h.headers.set("X-API-Sem-Ver", i), r && h.headers.set("Authorization", `Bearer ${r}`);
|
|
54
54
|
const l = await (b.fetch ?? fetch)(h);
|
|
55
55
|
if (l.ok)
|
|
56
56
|
return l;
|
|
57
57
|
throw await y(l);
|
|
58
58
|
}
|
|
59
|
-
}, f =
|
|
59
|
+
}, f = E({
|
|
60
60
|
baseUrl: n,
|
|
61
|
-
bodySerializer:
|
|
61
|
+
bodySerializer: O
|
|
62
62
|
});
|
|
63
|
-
return f.use(
|
|
63
|
+
return f.use(d), {
|
|
64
64
|
client: f,
|
|
65
65
|
setApiKey: (h) => {
|
|
66
66
|
o = h;
|
|
@@ -71,42 +71,42 @@ function O(n, t, i) {
|
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
async function D(n, t) {
|
|
74
|
-
const { data:
|
|
75
|
-
if (
|
|
76
|
-
throw
|
|
77
|
-
return
|
|
74
|
+
const { data: e, error: i } = await s((r) => n.GET("/version", { signal: r }), t == null ? void 0 : t.timeout);
|
|
75
|
+
if (i)
|
|
76
|
+
throw i;
|
|
77
|
+
return e;
|
|
78
78
|
}
|
|
79
79
|
async function U(n, t) {
|
|
80
|
-
const { data:
|
|
81
|
-
if (
|
|
82
|
-
throw
|
|
83
|
-
return
|
|
80
|
+
const { data: e, error: i } = await s((r) => n.GET("/status", { signal: r }), t == null ? void 0 : t.timeout);
|
|
81
|
+
if (i)
|
|
82
|
+
throw i;
|
|
83
|
+
return e;
|
|
84
84
|
}
|
|
85
85
|
async function B(n, t) {
|
|
86
|
-
const { data:
|
|
87
|
-
if (
|
|
88
|
-
throw
|
|
89
|
-
return
|
|
86
|
+
const { data: e, error: i } = await s((r) => n.GET("/status/system", { signal: r }), t == null ? void 0 : t.timeout);
|
|
87
|
+
if (i)
|
|
88
|
+
throw i;
|
|
89
|
+
return e;
|
|
90
90
|
}
|
|
91
|
-
async function
|
|
92
|
-
const { data:
|
|
93
|
-
if (
|
|
94
|
-
throw
|
|
95
|
-
return
|
|
91
|
+
async function _(n, t) {
|
|
92
|
+
const { data: e, error: i } = await s((r) => n.GET("/status/power", { signal: r }), t == null ? void 0 : t.timeout);
|
|
93
|
+
if (i)
|
|
94
|
+
throw i;
|
|
95
|
+
return e;
|
|
96
96
|
}
|
|
97
97
|
async function $(n, t) {
|
|
98
|
-
const { data:
|
|
99
|
-
if (
|
|
100
|
-
throw
|
|
101
|
-
return
|
|
98
|
+
const { data: e, error: i } = await s((r) => n.GET("/status/device", { signal: r }), t == null ? void 0 : t.timeout);
|
|
99
|
+
if (i)
|
|
100
|
+
throw i;
|
|
101
|
+
return e;
|
|
102
102
|
}
|
|
103
|
-
async function
|
|
104
|
-
const { data:
|
|
105
|
-
if (
|
|
106
|
-
throw
|
|
107
|
-
return
|
|
103
|
+
async function I(n, t) {
|
|
104
|
+
const { data: e, error: i } = await s((r) => n.GET("/status/firmware", { signal: r }), t == null ? void 0 : t.timeout);
|
|
105
|
+
if (i)
|
|
106
|
+
throw i;
|
|
107
|
+
return e;
|
|
108
108
|
}
|
|
109
|
-
class
|
|
109
|
+
class R {
|
|
110
110
|
/**
|
|
111
111
|
* Get API version information.
|
|
112
112
|
*
|
|
@@ -115,8 +115,8 @@ class K {
|
|
|
115
115
|
* @returns {Promise<VersionInfo>} A promise that resolves to an object containing the `api_semver` string.
|
|
116
116
|
*/
|
|
117
117
|
async SystemVersionGet(t) {
|
|
118
|
-
const
|
|
119
|
-
return this.apiSemver =
|
|
118
|
+
const e = await D(this.apiClient, t);
|
|
119
|
+
return this.apiSemver = e.api_semver, e;
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
122
|
* Get full status.
|
|
@@ -146,7 +146,7 @@ class K {
|
|
|
146
146
|
* @returns {Promise<StatusPower>} Current power status.
|
|
147
147
|
*/
|
|
148
148
|
async SystemStatusPowerGet(t) {
|
|
149
|
-
return await
|
|
149
|
+
return await _(this.apiClient, t);
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
152
|
* Get device status.
|
|
@@ -166,42 +166,42 @@ class K {
|
|
|
166
166
|
* @returns {Promise<StatusFirmware>} Current firmware status.
|
|
167
167
|
*/
|
|
168
168
|
async SystemStatusFirmwareGet(t) {
|
|
169
|
-
return await
|
|
169
|
+
return await I(this.apiClient, t);
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
-
async function
|
|
173
|
-
const { file:
|
|
172
|
+
async function K(n, t) {
|
|
173
|
+
const { file: e } = t, { data: i, error: r } = await s(
|
|
174
174
|
(o) => n.POST("/update", {
|
|
175
175
|
headers: {
|
|
176
176
|
"Content-Type": "application/octet-stream"
|
|
177
177
|
},
|
|
178
|
-
body:
|
|
178
|
+
body: e,
|
|
179
179
|
signal: o
|
|
180
180
|
}),
|
|
181
181
|
t.timeout
|
|
182
182
|
);
|
|
183
183
|
if (r)
|
|
184
184
|
throw r;
|
|
185
|
-
return e;
|
|
186
|
-
}
|
|
187
|
-
async function _(n, t) {
|
|
188
|
-
const { data: i, error: e } = await s((r) => n.POST("/update/check", { signal: r }), t == null ? void 0 : t.timeout);
|
|
189
|
-
if (e)
|
|
190
|
-
throw e;
|
|
191
185
|
return i;
|
|
192
186
|
}
|
|
187
|
+
async function F(n, t) {
|
|
188
|
+
const { data: e, error: i } = await s((r) => n.POST("/update/check", { signal: r }), t == null ? void 0 : t.timeout);
|
|
189
|
+
if (i)
|
|
190
|
+
throw i;
|
|
191
|
+
return e;
|
|
192
|
+
}
|
|
193
193
|
async function W(n, t) {
|
|
194
|
-
const { data:
|
|
195
|
-
if (
|
|
196
|
-
throw
|
|
197
|
-
return
|
|
194
|
+
const { data: e, error: i } = await s((r) => n.GET("/update/status", { signal: r }), t == null ? void 0 : t.timeout);
|
|
195
|
+
if (i)
|
|
196
|
+
throw i;
|
|
197
|
+
return e;
|
|
198
198
|
}
|
|
199
199
|
async function M(n, t) {
|
|
200
|
-
const { version:
|
|
200
|
+
const { version: e } = t, { data: i, error: r } = await s(
|
|
201
201
|
(o) => n.GET("/update/changelog", {
|
|
202
202
|
params: {
|
|
203
203
|
query: {
|
|
204
|
-
version:
|
|
204
|
+
version: e
|
|
205
205
|
}
|
|
206
206
|
},
|
|
207
207
|
signal: o
|
|
@@ -210,14 +210,14 @@ async function M(n, t) {
|
|
|
210
210
|
);
|
|
211
211
|
if (r)
|
|
212
212
|
throw r;
|
|
213
|
-
return
|
|
213
|
+
return i;
|
|
214
214
|
}
|
|
215
|
-
async function
|
|
216
|
-
const { version:
|
|
215
|
+
async function q(n, t) {
|
|
216
|
+
const { version: e } = t, { data: i, error: r } = await s(
|
|
217
217
|
(o) => n.POST("/update/install", {
|
|
218
218
|
params: {
|
|
219
219
|
query: {
|
|
220
|
-
version:
|
|
220
|
+
version: e
|
|
221
221
|
}
|
|
222
222
|
},
|
|
223
223
|
signal: o
|
|
@@ -226,25 +226,25 @@ async function N(n, t) {
|
|
|
226
226
|
);
|
|
227
227
|
if (r)
|
|
228
228
|
throw r;
|
|
229
|
-
return e;
|
|
230
|
-
}
|
|
231
|
-
async function q(n, t) {
|
|
232
|
-
const { data: i, error: e } = await s((r) => n.POST("/update/abort_download", { signal: r }), t == null ? void 0 : t.timeout);
|
|
233
|
-
if (e)
|
|
234
|
-
throw e;
|
|
235
229
|
return i;
|
|
236
230
|
}
|
|
231
|
+
async function N(n, t) {
|
|
232
|
+
const { data: e, error: i } = await s((r) => n.POST("/update/abort_download", { signal: r }), t == null ? void 0 : t.timeout);
|
|
233
|
+
if (i)
|
|
234
|
+
throw i;
|
|
235
|
+
return e;
|
|
236
|
+
}
|
|
237
237
|
async function x(n, t) {
|
|
238
|
-
const { data:
|
|
239
|
-
if (
|
|
240
|
-
throw
|
|
241
|
-
return
|
|
238
|
+
const { data: e, error: i } = await s((r) => n.GET("/update/autoupdate", { signal: r }), t == null ? void 0 : t.timeout);
|
|
239
|
+
if (i)
|
|
240
|
+
throw i;
|
|
241
|
+
return e;
|
|
242
242
|
}
|
|
243
|
-
async function
|
|
244
|
-
const { is_enabled:
|
|
245
|
-
(
|
|
246
|
-
body: { is_enabled:
|
|
247
|
-
signal:
|
|
243
|
+
async function H(n, t) {
|
|
244
|
+
const { is_enabled: e, interval_start: i, interval_end: r } = t, { data: o, error: a } = await s(
|
|
245
|
+
(c) => n.POST("/update/autoupdate", {
|
|
246
|
+
body: { is_enabled: e, interval_start: i, interval_end: r },
|
|
247
|
+
signal: c
|
|
248
248
|
}),
|
|
249
249
|
t.timeout
|
|
250
250
|
);
|
|
@@ -252,7 +252,7 @@ async function V(n, t) {
|
|
|
252
252
|
throw a;
|
|
253
253
|
return o;
|
|
254
254
|
}
|
|
255
|
-
class
|
|
255
|
+
class V {
|
|
256
256
|
/**
|
|
257
257
|
* Upload firmware update package.
|
|
258
258
|
*
|
|
@@ -262,7 +262,7 @@ class j {
|
|
|
262
262
|
* @returns {Promise<SuccessResponse>} A promise that resolves when upload is complete.
|
|
263
263
|
*/
|
|
264
264
|
async UpdateFromFile(t) {
|
|
265
|
-
return await
|
|
265
|
+
return await K(this.apiClient, t);
|
|
266
266
|
}
|
|
267
267
|
/**
|
|
268
268
|
* Start firmware update check.
|
|
@@ -272,7 +272,7 @@ class j {
|
|
|
272
272
|
* @returns {Promise<SuccessResponse>} A promise that resolves to the update check result.
|
|
273
273
|
*/
|
|
274
274
|
async UpdateCheck(t) {
|
|
275
|
-
return await
|
|
275
|
+
return await F(this.apiClient, t);
|
|
276
276
|
}
|
|
277
277
|
/**
|
|
278
278
|
* Get firmware update status.
|
|
@@ -304,7 +304,7 @@ class j {
|
|
|
304
304
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful initiation.
|
|
305
305
|
*/
|
|
306
306
|
async UpdateInstall(t) {
|
|
307
|
-
return await
|
|
307
|
+
return await q(this.apiClient, t);
|
|
308
308
|
}
|
|
309
309
|
/**
|
|
310
310
|
* Abort firmware update download.
|
|
@@ -314,7 +314,7 @@ class j {
|
|
|
314
314
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful abort.
|
|
315
315
|
*/
|
|
316
316
|
async UpdateAbort(t) {
|
|
317
|
-
return await
|
|
317
|
+
return await N(this.apiClient, t);
|
|
318
318
|
}
|
|
319
319
|
/**
|
|
320
320
|
* Get current auto-update settings.
|
|
@@ -337,54 +337,54 @@ class j {
|
|
|
337
337
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful update of settings.
|
|
338
338
|
*/
|
|
339
339
|
async UpdateAutoUpdateSet(t) {
|
|
340
|
-
return await
|
|
340
|
+
return await H(this.apiClient, t);
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
|
-
async function
|
|
344
|
-
const { data:
|
|
345
|
-
if (
|
|
346
|
-
throw
|
|
347
|
-
return
|
|
343
|
+
async function j(n, t) {
|
|
344
|
+
const { data: e, error: i } = await s((r) => n.GET("/time", { signal: r }), t == null ? void 0 : t.timeout);
|
|
345
|
+
if (i)
|
|
346
|
+
throw i;
|
|
347
|
+
return e;
|
|
348
348
|
}
|
|
349
|
-
async function
|
|
350
|
-
const { data: i, error:
|
|
351
|
-
(
|
|
349
|
+
async function z(n, t) {
|
|
350
|
+
const { timestamp: e } = t, { data: i, error: r } = await s(
|
|
351
|
+
(o) => n.POST("/time/timestamp", {
|
|
352
352
|
params: {
|
|
353
|
-
query: {
|
|
353
|
+
query: { timestamp: e }
|
|
354
354
|
},
|
|
355
|
-
signal:
|
|
355
|
+
signal: o
|
|
356
356
|
}),
|
|
357
357
|
t.timeout
|
|
358
358
|
);
|
|
359
|
-
if (
|
|
360
|
-
throw
|
|
359
|
+
if (r)
|
|
360
|
+
throw r;
|
|
361
361
|
return i;
|
|
362
362
|
}
|
|
363
363
|
async function J(n, t) {
|
|
364
|
-
const { data:
|
|
365
|
-
if (
|
|
366
|
-
throw
|
|
367
|
-
return
|
|
364
|
+
const { data: e, error: i } = await s((r) => n.GET("/time/timezone", { signal: r }), t == null ? void 0 : t.timeout);
|
|
365
|
+
if (i)
|
|
366
|
+
throw i;
|
|
367
|
+
return e;
|
|
368
368
|
}
|
|
369
369
|
async function X(n, t) {
|
|
370
|
-
const { data: i, error:
|
|
371
|
-
(
|
|
370
|
+
const { timezone: e } = t, { data: i, error: r } = await s(
|
|
371
|
+
(o) => n.POST("/time/timezone", {
|
|
372
372
|
params: {
|
|
373
|
-
query: {
|
|
373
|
+
query: { timezone: e }
|
|
374
374
|
},
|
|
375
|
-
signal:
|
|
375
|
+
signal: o
|
|
376
376
|
}),
|
|
377
377
|
t.timeout
|
|
378
378
|
);
|
|
379
|
-
if (
|
|
380
|
-
throw
|
|
379
|
+
if (r)
|
|
380
|
+
throw r;
|
|
381
381
|
return i;
|
|
382
382
|
}
|
|
383
383
|
async function Y(n, t) {
|
|
384
|
-
const { data:
|
|
385
|
-
if (
|
|
386
|
-
throw
|
|
387
|
-
return
|
|
384
|
+
const { data: e, error: i } = await s((r) => n.GET("/time/tzlist", { signal: r }), t == null ? void 0 : t.timeout);
|
|
385
|
+
if (i)
|
|
386
|
+
throw i;
|
|
387
|
+
return e;
|
|
388
388
|
}
|
|
389
389
|
class Q {
|
|
390
390
|
/**
|
|
@@ -395,7 +395,7 @@ class Q {
|
|
|
395
395
|
* @returns {Promise<TimestampInfo>} A promise that resolves to the timestamp information.
|
|
396
396
|
*/
|
|
397
397
|
async TimeGet(t) {
|
|
398
|
-
return await
|
|
398
|
+
return await j(this.apiClient, t);
|
|
399
399
|
}
|
|
400
400
|
/**
|
|
401
401
|
* Set system timestamp.
|
|
@@ -406,7 +406,7 @@ class Q {
|
|
|
406
406
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
407
407
|
*/
|
|
408
408
|
async TimeTimestampSet(t) {
|
|
409
|
-
return await
|
|
409
|
+
return await z(this.apiClient, t);
|
|
410
410
|
}
|
|
411
411
|
/**
|
|
412
412
|
* Get current timezone.
|
|
@@ -441,50 +441,51 @@ class Q {
|
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
443
|
async function Z(n, t) {
|
|
444
|
-
const { data:
|
|
445
|
-
if (
|
|
446
|
-
throw
|
|
447
|
-
return
|
|
444
|
+
const { data: e, error: i } = await s((r) => n.GET("/account/status", { signal: r }), t == null ? void 0 : t.timeout);
|
|
445
|
+
if (i)
|
|
446
|
+
throw i;
|
|
447
|
+
return e;
|
|
448
448
|
}
|
|
449
449
|
async function tt(n, t) {
|
|
450
|
-
const { data:
|
|
451
|
-
if (
|
|
452
|
-
throw
|
|
453
|
-
return
|
|
450
|
+
const { data: e, error: i } = await s((r) => n.GET("/account/info", { signal: r }), t == null ? void 0 : t.timeout);
|
|
451
|
+
if (i)
|
|
452
|
+
throw i;
|
|
453
|
+
return e;
|
|
454
454
|
}
|
|
455
455
|
async function et(n, t) {
|
|
456
|
-
const { data:
|
|
457
|
-
if (
|
|
458
|
-
throw
|
|
459
|
-
return
|
|
456
|
+
const { data: e, error: i } = await s((r) => n.GET("/account/profile", { signal: r }), t == null ? void 0 : t.timeout);
|
|
457
|
+
if (i)
|
|
458
|
+
throw i;
|
|
459
|
+
return e;
|
|
460
460
|
}
|
|
461
461
|
async function it(n, t) {
|
|
462
|
-
const { profile: i } = t, { data:
|
|
463
|
-
(
|
|
462
|
+
const { profile: e, custom_url: i } = t, { data: r, error: o } = await s(
|
|
463
|
+
(a) => n.POST("/account/profile", {
|
|
464
464
|
params: {
|
|
465
465
|
query: {
|
|
466
|
-
profile:
|
|
466
|
+
profile: e,
|
|
467
|
+
custom_url: i
|
|
467
468
|
}
|
|
468
469
|
},
|
|
469
|
-
signal:
|
|
470
|
+
signal: a
|
|
470
471
|
}),
|
|
471
472
|
t.timeout
|
|
472
473
|
);
|
|
473
|
-
if (
|
|
474
|
-
throw
|
|
475
|
-
return
|
|
474
|
+
if (o)
|
|
475
|
+
throw o;
|
|
476
|
+
return r;
|
|
476
477
|
}
|
|
477
478
|
async function nt(n, t) {
|
|
478
|
-
const { data:
|
|
479
|
-
if (
|
|
480
|
-
throw
|
|
481
|
-
return
|
|
479
|
+
const { data: e, error: i } = await s((r) => n.DELETE("/account", { signal: r }), t == null ? void 0 : t.timeout);
|
|
480
|
+
if (i)
|
|
481
|
+
throw i;
|
|
482
|
+
return e;
|
|
482
483
|
}
|
|
483
484
|
async function rt(n, t) {
|
|
484
|
-
const { data:
|
|
485
|
-
if (
|
|
486
|
-
throw
|
|
487
|
-
return
|
|
485
|
+
const { data: e, error: i } = await s((r) => n.POST("/account/link", { signal: r }), t == null ? void 0 : t.timeout);
|
|
486
|
+
if (i)
|
|
487
|
+
throw i;
|
|
488
|
+
return e;
|
|
488
489
|
}
|
|
489
490
|
class ot {
|
|
490
491
|
/**
|
|
@@ -502,7 +503,7 @@ class ot {
|
|
|
502
503
|
*
|
|
503
504
|
* @param {TimeoutOptions} [params] - Optional parameters.
|
|
504
505
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
505
|
-
* @returns {Promise<
|
|
506
|
+
* @returns {Promise<AccountStatus>} A promise that resolves to the account state.
|
|
506
507
|
*/
|
|
507
508
|
async AccountStateGet(t) {
|
|
508
509
|
return await Z(this.apiClient, t);
|
|
@@ -521,7 +522,8 @@ class ot {
|
|
|
521
522
|
* Set account profile.
|
|
522
523
|
*
|
|
523
524
|
* @param {SetAccountProfileParams} params - Parameters for setting the account profile.
|
|
524
|
-
* @param {string} params.profile - Profile
|
|
525
|
+
* @param {string} params.profile - Profile name.
|
|
526
|
+
* @param {string} [params.custom_url] - Custom profile URL.
|
|
525
527
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
526
528
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
527
529
|
*/
|
|
@@ -550,67 +552,76 @@ class ot {
|
|
|
550
552
|
}
|
|
551
553
|
}
|
|
552
554
|
async function st(n, t) {
|
|
553
|
-
const {
|
|
554
|
-
(
|
|
555
|
+
const { application_name: e, elements: i, priority: r = 50, timeout: o } = t, { data: a, error: c } = await s(
|
|
556
|
+
(d) => n.POST("/display/draw", {
|
|
555
557
|
body: {
|
|
556
|
-
|
|
558
|
+
application_name: e,
|
|
557
559
|
priority: r,
|
|
558
|
-
elements:
|
|
560
|
+
elements: i
|
|
559
561
|
},
|
|
560
|
-
signal:
|
|
562
|
+
signal: d
|
|
561
563
|
}),
|
|
562
|
-
|
|
564
|
+
o
|
|
563
565
|
);
|
|
564
|
-
if (
|
|
565
|
-
throw
|
|
566
|
-
return
|
|
566
|
+
if (c)
|
|
567
|
+
throw c;
|
|
568
|
+
return a;
|
|
567
569
|
}
|
|
568
570
|
async function at(n, t) {
|
|
569
|
-
const { data:
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
571
|
+
const { data: e, error: i } = await s(
|
|
572
|
+
(r) => n.DELETE("/display/draw", {
|
|
573
|
+
params: {
|
|
574
|
+
query: {
|
|
575
|
+
application_name: t == null ? void 0 : t.application_name
|
|
576
|
+
}
|
|
577
|
+
},
|
|
578
|
+
signal: r
|
|
579
|
+
}),
|
|
580
|
+
t == null ? void 0 : t.timeout
|
|
581
|
+
);
|
|
582
|
+
if (i)
|
|
583
|
+
throw i;
|
|
584
|
+
return e;
|
|
573
585
|
}
|
|
574
586
|
async function ct(n, t) {
|
|
575
|
-
const { display: i } = t, { data:
|
|
576
|
-
(
|
|
587
|
+
const { display: e, timeout: i } = t, { data: r, error: o } = await s(
|
|
588
|
+
(a) => n.GET("/screen", {
|
|
577
589
|
params: {
|
|
578
590
|
query: {
|
|
579
|
-
display:
|
|
591
|
+
display: e
|
|
580
592
|
}
|
|
581
593
|
},
|
|
582
594
|
parseAs: "blob",
|
|
583
|
-
signal:
|
|
595
|
+
signal: a
|
|
584
596
|
}),
|
|
585
|
-
|
|
597
|
+
i
|
|
586
598
|
);
|
|
587
|
-
if (
|
|
588
|
-
throw
|
|
589
|
-
return
|
|
599
|
+
if (o)
|
|
600
|
+
throw o;
|
|
601
|
+
return r;
|
|
590
602
|
}
|
|
591
603
|
async function ut(n, t) {
|
|
592
|
-
const { data:
|
|
593
|
-
if (
|
|
594
|
-
throw
|
|
595
|
-
return
|
|
604
|
+
const { data: e, error: i } = await s((r) => n.GET("/display/brightness", { signal: r }), t == null ? void 0 : t.timeout);
|
|
605
|
+
if (i)
|
|
606
|
+
throw i;
|
|
607
|
+
return e;
|
|
596
608
|
}
|
|
597
609
|
async function ht(n, t) {
|
|
598
|
-
const { value:
|
|
599
|
-
if (typeof
|
|
600
|
-
if (
|
|
610
|
+
const { value: e } = t, r = ((c) => {
|
|
611
|
+
if (typeof c == "number") {
|
|
612
|
+
if (c < 0 || c > 100)
|
|
601
613
|
throw new Error("Brightness value must be between 0 and 100 or 'auto'");
|
|
602
|
-
return String(
|
|
614
|
+
return String(c);
|
|
603
615
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
(u) => n.POST("/display/brightness", {
|
|
616
|
+
return "auto";
|
|
617
|
+
})(e), { data: o, error: a } = await s(
|
|
618
|
+
(c) => n.POST("/display/brightness", {
|
|
608
619
|
params: {
|
|
609
620
|
query: {
|
|
610
621
|
value: r
|
|
611
622
|
}
|
|
612
623
|
},
|
|
613
|
-
signal:
|
|
624
|
+
signal: c
|
|
614
625
|
}),
|
|
615
626
|
t.timeout
|
|
616
627
|
);
|
|
@@ -620,12 +631,12 @@ async function ht(n, t) {
|
|
|
620
631
|
}
|
|
621
632
|
class dt {
|
|
622
633
|
/**
|
|
623
|
-
* Draw on display.
|
|
634
|
+
* Draw on display. Sends drawing data to the display. Supports JSON-defined display elements.
|
|
624
635
|
*
|
|
625
636
|
* @param {DrawParams} params - Parameters for the draw operation.
|
|
626
|
-
* @param {
|
|
627
|
-
* @param {
|
|
628
|
-
* @param {
|
|
637
|
+
* @param {string} params.application_name - Application ID for organizing assets.
|
|
638
|
+
* @param {Array} params.elements - Display elements to draw.
|
|
639
|
+
* @param {number} [params.priority=50] - Draw priority in the range [1, 100].
|
|
629
640
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
630
641
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful draw command.
|
|
631
642
|
*/
|
|
@@ -633,9 +644,11 @@ class dt {
|
|
|
633
644
|
return await st(this.apiClient, t);
|
|
634
645
|
}
|
|
635
646
|
/**
|
|
636
|
-
* Clear display.
|
|
647
|
+
* Clear display. Deletes display elements drawn by the Canvas application.
|
|
648
|
+
* If application_name is specified, only elements for that app are removed.
|
|
637
649
|
*
|
|
638
|
-
* @param {
|
|
650
|
+
* @param {ClearParams} [params] - Optional parameters.
|
|
651
|
+
* @param {string} [params.application_name] - Application identifier.
|
|
639
652
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
640
653
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful clear command.
|
|
641
654
|
*/
|
|
@@ -646,7 +659,7 @@ class dt {
|
|
|
646
659
|
* Get single frame for requested screen.
|
|
647
660
|
*
|
|
648
661
|
* @param {GetScreenFrameParams} params - Parameters for the frame request.
|
|
649
|
-
* @param {
|
|
662
|
+
* @param {number} params.display - Type of the display (Front = 0, Back = 1).
|
|
650
663
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
651
664
|
* @returns {Promise<Blob>} A promise that resolves to the screen frame as a Blob.
|
|
652
665
|
*/
|
|
@@ -666,8 +679,8 @@ class dt {
|
|
|
666
679
|
/**
|
|
667
680
|
* Set display brightness.
|
|
668
681
|
*
|
|
669
|
-
* @param {BrightnessParams} params - Brightness parameters
|
|
670
|
-
* @param {
|
|
682
|
+
* @param {BrightnessParams} params - Brightness parameters.
|
|
683
|
+
* @param {number | 'auto'} params.value - Brightness (0-100 or "auto").
|
|
671
684
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
672
685
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
673
686
|
*/
|
|
@@ -675,13 +688,13 @@ class dt {
|
|
|
675
688
|
return await ht(this.apiClient, t);
|
|
676
689
|
}
|
|
677
690
|
}
|
|
678
|
-
async function
|
|
679
|
-
const {
|
|
691
|
+
async function wt(n, t) {
|
|
692
|
+
const { application_name: e, path: i } = t, { data: r, error: o } = await s(
|
|
680
693
|
(a) => n.POST("/audio/play", {
|
|
681
694
|
params: {
|
|
682
695
|
query: {
|
|
683
|
-
|
|
684
|
-
path:
|
|
696
|
+
application_name: e,
|
|
697
|
+
path: i
|
|
685
698
|
}
|
|
686
699
|
},
|
|
687
700
|
signal: a
|
|
@@ -692,27 +705,27 @@ async function ft(n, t) {
|
|
|
692
705
|
throw o;
|
|
693
706
|
return r;
|
|
694
707
|
}
|
|
695
|
-
async function
|
|
696
|
-
const { data:
|
|
697
|
-
if (
|
|
698
|
-
throw
|
|
699
|
-
return
|
|
708
|
+
async function ft(n, t) {
|
|
709
|
+
const { data: e, error: i } = await s((r) => n.DELETE("/audio/play", { signal: r }), t == null ? void 0 : t.timeout);
|
|
710
|
+
if (i)
|
|
711
|
+
throw i;
|
|
712
|
+
return e;
|
|
700
713
|
}
|
|
701
714
|
async function lt(n, t) {
|
|
702
|
-
const { data:
|
|
703
|
-
if (
|
|
704
|
-
throw
|
|
705
|
-
return
|
|
715
|
+
const { data: e, error: i } = await s((r) => n.GET("/audio/volume", { signal: r }), t == null ? void 0 : t.timeout);
|
|
716
|
+
if (i)
|
|
717
|
+
throw i;
|
|
718
|
+
return e;
|
|
706
719
|
}
|
|
707
720
|
async function yt(n, t) {
|
|
708
|
-
const { volume:
|
|
709
|
-
if (typeof
|
|
721
|
+
const { volume: e } = t;
|
|
722
|
+
if (typeof e != "number" || e < 0 || e > 100)
|
|
710
723
|
throw new Error("Volume must be a number between 0 and 100");
|
|
711
|
-
const { data:
|
|
724
|
+
const { data: i, error: r } = await s(
|
|
712
725
|
(o) => n.POST("/audio/volume", {
|
|
713
726
|
params: {
|
|
714
727
|
query: {
|
|
715
|
-
volume:
|
|
728
|
+
volume: e
|
|
716
729
|
}
|
|
717
730
|
},
|
|
718
731
|
signal: o
|
|
@@ -721,20 +734,20 @@ async function yt(n, t) {
|
|
|
721
734
|
);
|
|
722
735
|
if (r)
|
|
723
736
|
throw r;
|
|
724
|
-
return
|
|
737
|
+
return i;
|
|
725
738
|
}
|
|
726
739
|
class pt {
|
|
727
740
|
/**
|
|
728
741
|
* Play audio file. Plays a file from internal storage.
|
|
729
742
|
*
|
|
730
743
|
* @param {AudioPlayParams} params - Parameters for audio playback.
|
|
731
|
-
* @param {string} params.
|
|
744
|
+
* @param {string} params.application_name - Application name.
|
|
732
745
|
* @param {string} params.path - Path to the audio file.
|
|
733
746
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
734
747
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful play command.
|
|
735
748
|
*/
|
|
736
749
|
async AudioPlay(t) {
|
|
737
|
-
return await
|
|
750
|
+
return await wt(this.apiClient, t);
|
|
738
751
|
}
|
|
739
752
|
/**
|
|
740
753
|
* Stop audio playback. Stops any currently playing audio.
|
|
@@ -744,7 +757,7 @@ class pt {
|
|
|
744
757
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful stop command.
|
|
745
758
|
*/
|
|
746
759
|
async AudioStop(t) {
|
|
747
|
-
return await
|
|
760
|
+
return await ft(this.apiClient, t);
|
|
748
761
|
}
|
|
749
762
|
/**
|
|
750
763
|
* Get audio volume.
|
|
@@ -769,44 +782,39 @@ class pt {
|
|
|
769
782
|
}
|
|
770
783
|
}
|
|
771
784
|
async function St(n, t) {
|
|
772
|
-
const { data:
|
|
773
|
-
if (
|
|
774
|
-
throw
|
|
775
|
-
return
|
|
785
|
+
const { data: e, error: i } = await s((r) => n.GET("/wifi/status", { signal: r }), t == null ? void 0 : t.timeout);
|
|
786
|
+
if (i)
|
|
787
|
+
throw i;
|
|
788
|
+
return e;
|
|
776
789
|
}
|
|
777
|
-
async function
|
|
778
|
-
const {
|
|
779
|
-
(
|
|
790
|
+
async function mt(n, t) {
|
|
791
|
+
const { ssid: e, password: i, security: r, ip_config: o } = t, { data: a, error: c } = await s(
|
|
792
|
+
(d) => n.POST("/wifi/connect", {
|
|
780
793
|
body: {
|
|
781
|
-
ssid:
|
|
782
|
-
password:
|
|
783
|
-
security:
|
|
784
|
-
ip_config:
|
|
785
|
-
ip_method: t.ipConfig.ipMethod,
|
|
786
|
-
address: t.ipConfig.address,
|
|
787
|
-
mask: t.ipConfig.mask,
|
|
788
|
-
gateway: t.ipConfig.gateway
|
|
789
|
-
}
|
|
794
|
+
ssid: e,
|
|
795
|
+
password: i,
|
|
796
|
+
security: r,
|
|
797
|
+
ip_config: o
|
|
790
798
|
},
|
|
791
|
-
signal:
|
|
799
|
+
signal: d
|
|
792
800
|
}),
|
|
793
801
|
t.timeout
|
|
794
802
|
);
|
|
795
|
-
if (
|
|
796
|
-
throw
|
|
797
|
-
return
|
|
803
|
+
if (c)
|
|
804
|
+
throw c;
|
|
805
|
+
return a;
|
|
798
806
|
}
|
|
799
|
-
async function
|
|
800
|
-
const { data:
|
|
801
|
-
if (
|
|
802
|
-
throw
|
|
803
|
-
return
|
|
807
|
+
async function Tt(n, t) {
|
|
808
|
+
const { data: e, error: i } = await s((r) => n.POST("/wifi/disconnect", { signal: r }), t == null ? void 0 : t.timeout);
|
|
809
|
+
if (i)
|
|
810
|
+
throw i;
|
|
811
|
+
return e;
|
|
804
812
|
}
|
|
805
|
-
async function
|
|
806
|
-
const { data:
|
|
807
|
-
if (
|
|
808
|
-
throw
|
|
809
|
-
return
|
|
813
|
+
async function Et(n, t) {
|
|
814
|
+
const { data: e, error: i } = await s((r) => n.GET("/wifi/networks", { signal: r }), t == null ? void 0 : t.timeout);
|
|
815
|
+
if (i)
|
|
816
|
+
throw i;
|
|
817
|
+
return e;
|
|
810
818
|
}
|
|
811
819
|
class Ct {
|
|
812
820
|
/**
|
|
@@ -826,12 +834,12 @@ class Ct {
|
|
|
826
834
|
* @param {string} params.ssid - Network SSID.
|
|
827
835
|
* @param {string} params.password - Network password.
|
|
828
836
|
* @param {WifiSecurityMethod} params.security - Security method.
|
|
829
|
-
* @param {object} params.
|
|
837
|
+
* @param {object} [params.ip_config] - IP configuration.
|
|
830
838
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
831
839
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful connection initiation.
|
|
832
840
|
*/
|
|
833
841
|
async WifiConnect(t) {
|
|
834
|
-
return await
|
|
842
|
+
return await mt(this.apiClient, t);
|
|
835
843
|
}
|
|
836
844
|
/**
|
|
837
845
|
* Disconnects from Wi-Fi.
|
|
@@ -841,7 +849,7 @@ class Ct {
|
|
|
841
849
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful disconnection.
|
|
842
850
|
*/
|
|
843
851
|
async WifiDisconnect(t) {
|
|
844
|
-
return await
|
|
852
|
+
return await Tt(this.apiClient, t);
|
|
845
853
|
}
|
|
846
854
|
/**
|
|
847
855
|
* Scans environment for available Wi-Fi networks.
|
|
@@ -851,21 +859,21 @@ class Ct {
|
|
|
851
859
|
* @returns {Promise<WifiNetworkResponse>} A promise that resolves to a list of available networks.
|
|
852
860
|
*/
|
|
853
861
|
async WifiNetworksGet(t) {
|
|
854
|
-
return await
|
|
862
|
+
return await Et(this.apiClient, t);
|
|
855
863
|
}
|
|
856
864
|
}
|
|
857
865
|
async function kt(n, t) {
|
|
858
|
-
const { path:
|
|
866
|
+
const { path: e, file: i } = t, { data: r, error: o } = await s(
|
|
859
867
|
(a) => n.POST("/storage/write", {
|
|
860
868
|
params: {
|
|
861
869
|
query: {
|
|
862
|
-
path:
|
|
870
|
+
path: e
|
|
863
871
|
}
|
|
864
872
|
},
|
|
865
873
|
headers: {
|
|
866
874
|
"Content-Type": "application/octet-stream"
|
|
867
875
|
},
|
|
868
|
-
body:
|
|
876
|
+
body: i,
|
|
869
877
|
signal: a
|
|
870
878
|
}),
|
|
871
879
|
t.timeout
|
|
@@ -875,14 +883,14 @@ async function kt(n, t) {
|
|
|
875
883
|
return r;
|
|
876
884
|
}
|
|
877
885
|
async function gt(n, t) {
|
|
878
|
-
const { path:
|
|
886
|
+
const { path: e, as_array_buffer: i } = t, { data: r, error: o } = await s(
|
|
879
887
|
(a) => n.GET("/storage/read", {
|
|
880
888
|
params: {
|
|
881
889
|
query: {
|
|
882
|
-
path:
|
|
890
|
+
path: e
|
|
883
891
|
}
|
|
884
892
|
},
|
|
885
|
-
parseAs:
|
|
893
|
+
parseAs: i ? "arrayBuffer" : "blob",
|
|
886
894
|
signal: a
|
|
887
895
|
}),
|
|
888
896
|
t.timeout
|
|
@@ -892,11 +900,11 @@ async function gt(n, t) {
|
|
|
892
900
|
return r;
|
|
893
901
|
}
|
|
894
902
|
async function At(n, t) {
|
|
895
|
-
const { path:
|
|
903
|
+
const { path: e } = t, { data: i, error: r } = await s(
|
|
896
904
|
(o) => n.GET("/storage/list", {
|
|
897
905
|
params: {
|
|
898
906
|
query: {
|
|
899
|
-
path:
|
|
907
|
+
path: e
|
|
900
908
|
}
|
|
901
909
|
},
|
|
902
910
|
signal: o
|
|
@@ -905,14 +913,14 @@ async function At(n, t) {
|
|
|
905
913
|
);
|
|
906
914
|
if (r)
|
|
907
915
|
throw r;
|
|
908
|
-
return
|
|
916
|
+
return i;
|
|
909
917
|
}
|
|
910
918
|
async function bt(n, t) {
|
|
911
|
-
const { path:
|
|
919
|
+
const { path: e } = t, { data: i, error: r } = await s(
|
|
912
920
|
(o) => n.DELETE("/storage/remove", {
|
|
913
921
|
params: {
|
|
914
922
|
query: {
|
|
915
|
-
path:
|
|
923
|
+
path: e
|
|
916
924
|
}
|
|
917
925
|
},
|
|
918
926
|
signal: o
|
|
@@ -921,14 +929,14 @@ async function bt(n, t) {
|
|
|
921
929
|
);
|
|
922
930
|
if (r)
|
|
923
931
|
throw r;
|
|
924
|
-
return
|
|
932
|
+
return i;
|
|
925
933
|
}
|
|
926
|
-
async function
|
|
927
|
-
const { path:
|
|
934
|
+
async function Pt(n, t) {
|
|
935
|
+
const { path: e } = t, { data: i, error: r } = await s(
|
|
928
936
|
(o) => n.POST("/storage/mkdir", {
|
|
929
937
|
params: {
|
|
930
938
|
query: {
|
|
931
|
-
path:
|
|
939
|
+
path: e
|
|
932
940
|
}
|
|
933
941
|
},
|
|
934
942
|
signal: o
|
|
@@ -937,21 +945,21 @@ async function vt(n, t) {
|
|
|
937
945
|
);
|
|
938
946
|
if (r)
|
|
939
947
|
throw r;
|
|
940
|
-
return
|
|
948
|
+
return i;
|
|
941
949
|
}
|
|
942
950
|
async function Gt(n, t) {
|
|
943
|
-
const { data:
|
|
944
|
-
if (
|
|
945
|
-
throw
|
|
946
|
-
return
|
|
951
|
+
const { data: e, error: i } = await s((r) => n.GET("/storage/status", { signal: r }), t == null ? void 0 : t.timeout);
|
|
952
|
+
if (i)
|
|
953
|
+
throw i;
|
|
954
|
+
return e;
|
|
947
955
|
}
|
|
948
|
-
async function
|
|
949
|
-
const { path:
|
|
956
|
+
async function vt(n, t) {
|
|
957
|
+
const { path: e, new_path: i } = t, { data: r, error: o } = await s(
|
|
950
958
|
(a) => n.POST("/storage/rename", {
|
|
951
959
|
params: {
|
|
952
960
|
query: {
|
|
953
|
-
path:
|
|
954
|
-
new_path:
|
|
961
|
+
path: e,
|
|
962
|
+
new_path: i
|
|
955
963
|
}
|
|
956
964
|
},
|
|
957
965
|
signal: a
|
|
@@ -962,7 +970,7 @@ async function Pt(n, t) {
|
|
|
962
970
|
throw o;
|
|
963
971
|
return r;
|
|
964
972
|
}
|
|
965
|
-
class
|
|
973
|
+
class Ot {
|
|
966
974
|
/**
|
|
967
975
|
* Upload file to internal storage. Uploads a file to a specified path.
|
|
968
976
|
*
|
|
@@ -980,7 +988,7 @@ class Lt {
|
|
|
980
988
|
*
|
|
981
989
|
* @param {DownloadFileParams} params - Download parameters:
|
|
982
990
|
* @param {string} params.path - Path to the file.
|
|
983
|
-
* @param {boolean} [params.
|
|
991
|
+
* @param {boolean} [params.as_array_buffer] - Whether to return ArrayBuffer instead of Blob.
|
|
984
992
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
985
993
|
* @returns {Promise<StorageReadResponse>} A promise that resolves to the file content (Blob or ArrayBuffer).
|
|
986
994
|
*/
|
|
@@ -1018,7 +1026,7 @@ class Lt {
|
|
|
1018
1026
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful creation.
|
|
1019
1027
|
*/
|
|
1020
1028
|
async StorageMkdir(t) {
|
|
1021
|
-
return await
|
|
1029
|
+
return await Pt(this.apiClient, t);
|
|
1022
1030
|
}
|
|
1023
1031
|
/**
|
|
1024
1032
|
* Show storage usage.
|
|
@@ -1040,54 +1048,54 @@ class Lt {
|
|
|
1040
1048
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful rename.
|
|
1041
1049
|
*/
|
|
1042
1050
|
async StorageRename(t) {
|
|
1043
|
-
return await
|
|
1051
|
+
return await vt(this.apiClient, t);
|
|
1044
1052
|
}
|
|
1045
1053
|
}
|
|
1046
|
-
async function
|
|
1047
|
-
const { data:
|
|
1048
|
-
if (
|
|
1049
|
-
throw
|
|
1050
|
-
return
|
|
1054
|
+
async function Lt(n, t) {
|
|
1055
|
+
const { data: e, error: i } = await s((r) => n.GET("/access", { signal: r }), t == null ? void 0 : t.timeout);
|
|
1056
|
+
if (i)
|
|
1057
|
+
throw i;
|
|
1058
|
+
return e;
|
|
1051
1059
|
}
|
|
1052
1060
|
async function Dt(n, t) {
|
|
1053
|
-
|
|
1054
|
-
if (
|
|
1061
|
+
const { mode: e, key: i } = t, r = i ?? "";
|
|
1062
|
+
if (String(r).trim() && !/^\d{4,10}$/.test(String(r)))
|
|
1055
1063
|
throw new Error("Key must be a string of 4 to 10 digits");
|
|
1056
|
-
const { data:
|
|
1057
|
-
(
|
|
1064
|
+
const { data: o, error: a } = await s(
|
|
1065
|
+
(c) => n.POST("/access", {
|
|
1058
1066
|
params: {
|
|
1059
1067
|
query: {
|
|
1060
|
-
mode:
|
|
1061
|
-
key:
|
|
1068
|
+
mode: e,
|
|
1069
|
+
key: r
|
|
1062
1070
|
}
|
|
1063
1071
|
},
|
|
1064
|
-
signal:
|
|
1072
|
+
signal: c
|
|
1065
1073
|
}),
|
|
1066
1074
|
t.timeout
|
|
1067
1075
|
);
|
|
1068
|
-
if (
|
|
1069
|
-
throw
|
|
1070
|
-
return
|
|
1076
|
+
if (a)
|
|
1077
|
+
throw a;
|
|
1078
|
+
return o;
|
|
1071
1079
|
}
|
|
1072
1080
|
async function Ut(n, t) {
|
|
1073
|
-
const { data:
|
|
1074
|
-
if (
|
|
1075
|
-
throw
|
|
1076
|
-
return
|
|
1081
|
+
const { data: e, error: i } = await s((r) => n.GET("/name", { signal: r }), t == null ? void 0 : t.timeout);
|
|
1082
|
+
if (i)
|
|
1083
|
+
throw i;
|
|
1084
|
+
return e;
|
|
1077
1085
|
}
|
|
1078
1086
|
async function Bt(n, t) {
|
|
1079
|
-
const { data: i, error:
|
|
1080
|
-
(
|
|
1081
|
-
body:
|
|
1082
|
-
signal:
|
|
1087
|
+
const { name: e } = t, { data: i, error: r } = await s(
|
|
1088
|
+
(o) => n.POST("/name", {
|
|
1089
|
+
body: { name: e },
|
|
1090
|
+
signal: o
|
|
1083
1091
|
}),
|
|
1084
1092
|
t.timeout
|
|
1085
1093
|
);
|
|
1086
|
-
if (
|
|
1087
|
-
throw
|
|
1094
|
+
if (r)
|
|
1095
|
+
throw r;
|
|
1088
1096
|
return i;
|
|
1089
1097
|
}
|
|
1090
|
-
class
|
|
1098
|
+
class _t {
|
|
1091
1099
|
/**
|
|
1092
1100
|
* Get HTTP API access over Wi-Fi configuration.
|
|
1093
1101
|
*
|
|
@@ -1096,20 +1104,20 @@ class It {
|
|
|
1096
1104
|
* @returns {Promise<HttpAccessInfo>} A promise that resolves to the access configuration.
|
|
1097
1105
|
*/
|
|
1098
1106
|
async SettingsAccessGet(t) {
|
|
1099
|
-
return await
|
|
1107
|
+
return await Lt(this.apiClient, t);
|
|
1100
1108
|
}
|
|
1101
1109
|
/**
|
|
1102
1110
|
* Set HTTP API access over Wi-Fi configuration.
|
|
1103
1111
|
*
|
|
1104
1112
|
* @param {HttpAccessParams} params - Access parameters:
|
|
1105
1113
|
* @param {boolean} params.mode - Enable/disable access.
|
|
1106
|
-
* @param {string} params.key - Access key (4-10 digits).
|
|
1114
|
+
* @param {string} [params.key] - Access key (4-10 digits).
|
|
1107
1115
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1108
1116
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1109
1117
|
*/
|
|
1110
1118
|
async SettingsAccessSet(t) {
|
|
1111
|
-
const
|
|
1112
|
-
return t.mode === "key" && t.key && this.setApiKey(t.key),
|
|
1119
|
+
const e = await Dt(this.apiClient, t);
|
|
1120
|
+
return t.mode === "key" && t.key && this.setApiKey(t.key), e;
|
|
1113
1121
|
}
|
|
1114
1122
|
/**
|
|
1115
1123
|
* Get current device name.
|
|
@@ -1134,30 +1142,30 @@ class It {
|
|
|
1134
1142
|
}
|
|
1135
1143
|
}
|
|
1136
1144
|
async function $t(n, t) {
|
|
1137
|
-
const { data:
|
|
1138
|
-
if (
|
|
1139
|
-
throw
|
|
1140
|
-
return
|
|
1145
|
+
const { data: e, error: i } = await s((r) => n.POST("/ble/enable", { signal: r }), t == null ? void 0 : t.timeout);
|
|
1146
|
+
if (i)
|
|
1147
|
+
throw i;
|
|
1148
|
+
return e;
|
|
1149
|
+
}
|
|
1150
|
+
async function It(n, t) {
|
|
1151
|
+
const { data: e, error: i } = await s((r) => n.POST("/ble/disable", { signal: r }), t == null ? void 0 : t.timeout);
|
|
1152
|
+
if (i)
|
|
1153
|
+
throw i;
|
|
1154
|
+
return e;
|
|
1141
1155
|
}
|
|
1142
1156
|
async function Rt(n, t) {
|
|
1143
|
-
const { data:
|
|
1144
|
-
if (
|
|
1145
|
-
throw
|
|
1146
|
-
return
|
|
1157
|
+
const { data: e, error: i } = await s((r) => n.DELETE("/ble/pairing", { signal: r }), t == null ? void 0 : t.timeout);
|
|
1158
|
+
if (i)
|
|
1159
|
+
throw i;
|
|
1160
|
+
return e;
|
|
1147
1161
|
}
|
|
1148
1162
|
async function Kt(n, t) {
|
|
1149
|
-
const { data:
|
|
1150
|
-
if (
|
|
1151
|
-
throw
|
|
1152
|
-
return
|
|
1153
|
-
}
|
|
1154
|
-
async function Ft(n, t) {
|
|
1155
|
-
const { data: i, error: e } = await s((r) => n.GET("/ble/status", { signal: r }), t == null ? void 0 : t.timeout);
|
|
1156
|
-
if (e)
|
|
1157
|
-
throw e;
|
|
1158
|
-
return i;
|
|
1163
|
+
const { data: e, error: i } = await s((r) => n.GET("/ble/status", { signal: r }), t == null ? void 0 : t.timeout);
|
|
1164
|
+
if (i)
|
|
1165
|
+
throw i;
|
|
1166
|
+
return e;
|
|
1159
1167
|
}
|
|
1160
|
-
class
|
|
1168
|
+
class Ft {
|
|
1161
1169
|
/**
|
|
1162
1170
|
* Enable BLE. Starts advertising.
|
|
1163
1171
|
*
|
|
@@ -1176,7 +1184,7 @@ class _t {
|
|
|
1176
1184
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1177
1185
|
*/
|
|
1178
1186
|
async BleDisable(t) {
|
|
1179
|
-
return await
|
|
1187
|
+
return await It(this.apiClient, t);
|
|
1180
1188
|
}
|
|
1181
1189
|
/**
|
|
1182
1190
|
* Remove pairing. Remove pairing with previous device.
|
|
@@ -1186,7 +1194,7 @@ class _t {
|
|
|
1186
1194
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1187
1195
|
*/
|
|
1188
1196
|
async BleUnpair(t) {
|
|
1189
|
-
return await
|
|
1197
|
+
return await Rt(this.apiClient, t);
|
|
1190
1198
|
}
|
|
1191
1199
|
/**
|
|
1192
1200
|
* Returns current BLE status.
|
|
@@ -1196,15 +1204,15 @@ class _t {
|
|
|
1196
1204
|
* @returns {Promise<BleStatusResponse>} A promise that resolves to the BLE status.
|
|
1197
1205
|
*/
|
|
1198
1206
|
async BleStatusGet(t) {
|
|
1199
|
-
return await
|
|
1207
|
+
return await Kt(this.apiClient, t);
|
|
1200
1208
|
}
|
|
1201
1209
|
}
|
|
1202
1210
|
async function Wt(n, t) {
|
|
1203
|
-
const {
|
|
1211
|
+
const { key: e } = t, { data: i, error: r } = await s(
|
|
1204
1212
|
(o) => n.POST("/input", {
|
|
1205
1213
|
params: {
|
|
1206
1214
|
query: {
|
|
1207
|
-
key:
|
|
1215
|
+
key: e
|
|
1208
1216
|
}
|
|
1209
1217
|
},
|
|
1210
1218
|
signal: o
|
|
@@ -1213,14 +1221,14 @@ async function Wt(n, t) {
|
|
|
1213
1221
|
);
|
|
1214
1222
|
if (r)
|
|
1215
1223
|
throw r;
|
|
1216
|
-
return
|
|
1224
|
+
return i;
|
|
1217
1225
|
}
|
|
1218
1226
|
class Mt {
|
|
1219
1227
|
/**
|
|
1220
1228
|
* Send input event. Send single key press event.
|
|
1221
1229
|
*
|
|
1222
1230
|
* @param {InputKeyParams} params - Button press parameters:
|
|
1223
|
-
* @param {KeyName} params.
|
|
1231
|
+
* @param {KeyName} params.key - Key name.
|
|
1224
1232
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1225
1233
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1226
1234
|
*/
|
|
@@ -1228,70 +1236,119 @@ class Mt {
|
|
|
1228
1236
|
return await Wt(this.apiClient, t);
|
|
1229
1237
|
}
|
|
1230
1238
|
}
|
|
1231
|
-
async function Nt(n, t) {
|
|
1232
|
-
const { data: i, error: e } = await s((r) => n.GET("/matter/commissioning", { signal: r }), t == null ? void 0 : t.timeout);
|
|
1233
|
-
if (e)
|
|
1234
|
-
throw e;
|
|
1235
|
-
return i;
|
|
1236
|
-
}
|
|
1237
1239
|
async function qt(n, t) {
|
|
1238
|
-
const { data:
|
|
1239
|
-
if (
|
|
1240
|
-
throw
|
|
1241
|
-
return
|
|
1240
|
+
const { data: e, error: i } = await s((r) => n.GET("/smart_home/pairing", { signal: r }), t == null ? void 0 : t.timeout);
|
|
1241
|
+
if (i)
|
|
1242
|
+
throw i;
|
|
1243
|
+
return e;
|
|
1244
|
+
}
|
|
1245
|
+
async function Nt(n, t) {
|
|
1246
|
+
const { data: e, error: i } = await s((r) => n.POST("/smart_home/pairing", { signal: r }), t == null ? void 0 : t.timeout);
|
|
1247
|
+
if (i)
|
|
1248
|
+
throw i;
|
|
1249
|
+
return e;
|
|
1242
1250
|
}
|
|
1243
1251
|
async function xt(n, t) {
|
|
1244
|
-
const { data:
|
|
1245
|
-
if (
|
|
1246
|
-
throw
|
|
1247
|
-
return
|
|
1252
|
+
const { data: e, error: i } = await s((r) => n.DELETE("/smart_home/pairing", { signal: r }), t == null ? void 0 : t.timeout);
|
|
1253
|
+
if (i)
|
|
1254
|
+
throw i;
|
|
1255
|
+
return e;
|
|
1256
|
+
}
|
|
1257
|
+
async function Ht(n, t) {
|
|
1258
|
+
const { data: e, error: i } = await s((r) => n.GET("/smart_home/switch", { signal: r }), t == null ? void 0 : t.timeout);
|
|
1259
|
+
if (i)
|
|
1260
|
+
throw i;
|
|
1261
|
+
return e;
|
|
1262
|
+
}
|
|
1263
|
+
async function Vt(n, t) {
|
|
1264
|
+
const { timeout: e, ...i } = t, { data: r, error: o } = await s((a) => n.POST("/smart_home/switch", { body: i, signal: a }), e);
|
|
1265
|
+
if (o)
|
|
1266
|
+
throw o;
|
|
1267
|
+
return r;
|
|
1248
1268
|
}
|
|
1249
|
-
class
|
|
1269
|
+
class jt {
|
|
1250
1270
|
/**
|
|
1251
|
-
*
|
|
1271
|
+
* Smart home commissioning status.
|
|
1252
1272
|
*
|
|
1253
1273
|
* @param {TimeoutOptions} [params] - Optional parameters.
|
|
1254
1274
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1255
|
-
* @returns {Promise<
|
|
1275
|
+
* @returns {Promise<SmartHomePairingInfo>} A promise that resolves to the pairing info.
|
|
1256
1276
|
*/
|
|
1257
|
-
async
|
|
1277
|
+
async SmartHomePairingGet(t) {
|
|
1278
|
+
return await qt(this.apiClient, t);
|
|
1279
|
+
}
|
|
1280
|
+
/**
|
|
1281
|
+
* Link device to a smart home.
|
|
1282
|
+
*
|
|
1283
|
+
* @param {TimeoutOptions} [params] - Optional timeout.
|
|
1284
|
+
* @returns {Promise<SmartHomePairingPayload>} A promise that resolves to the pairing payload.
|
|
1285
|
+
*/
|
|
1286
|
+
async SmartHomePair(t) {
|
|
1258
1287
|
return await Nt(this.apiClient, t);
|
|
1259
1288
|
}
|
|
1260
1289
|
/**
|
|
1261
|
-
*
|
|
1290
|
+
* Erase all smart home links.
|
|
1262
1291
|
*
|
|
1263
1292
|
* @param {TimeoutOptions} [params] - Optional parameters.
|
|
1264
1293
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1265
|
-
* @returns {Promise<
|
|
1294
|
+
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1266
1295
|
*/
|
|
1267
|
-
async
|
|
1268
|
-
return await
|
|
1296
|
+
async SmartHomeErase(t) {
|
|
1297
|
+
return await xt(this.apiClient, t);
|
|
1269
1298
|
}
|
|
1270
1299
|
/**
|
|
1271
|
-
*
|
|
1300
|
+
* Get state of emulated smart home switch.
|
|
1272
1301
|
*
|
|
1273
1302
|
* @param {TimeoutOptions} [params] - Optional parameters.
|
|
1274
1303
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1304
|
+
* @returns {Promise<SmartHomeSwitchState>} A promise that resolves to the switch state.
|
|
1305
|
+
*/
|
|
1306
|
+
async SmartHomeSwitchStateGet(t) {
|
|
1307
|
+
return await Ht(this.apiClient, t);
|
|
1308
|
+
}
|
|
1309
|
+
/**
|
|
1310
|
+
* Set state of emulated smart home switch.
|
|
1311
|
+
*
|
|
1312
|
+
* @param {SmartHomeSwitchState & TimeoutOptions} params - Switch state and optional timeout.
|
|
1275
1313
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1276
1314
|
*/
|
|
1315
|
+
async SmartHomeSwitchStateSet(t) {
|
|
1316
|
+
return await Vt(this.apiClient, t);
|
|
1317
|
+
}
|
|
1318
|
+
// ALIASES for backward compatibility (Matter -> SmartHome)
|
|
1319
|
+
/**
|
|
1320
|
+
* @deprecated Use SmartHomePairingGet instead.
|
|
1321
|
+
*/
|
|
1322
|
+
async MatterStatusGet(t) {
|
|
1323
|
+
return await this.SmartHomePairingGet(t);
|
|
1324
|
+
}
|
|
1325
|
+
/**
|
|
1326
|
+
* @deprecated Use SmartHomePair instead.
|
|
1327
|
+
*/
|
|
1328
|
+
async MatterPair(t) {
|
|
1329
|
+
return await this.SmartHomePair(t);
|
|
1330
|
+
}
|
|
1331
|
+
/**
|
|
1332
|
+
* @deprecated Use SmartHomeErase instead.
|
|
1333
|
+
*/
|
|
1277
1334
|
async MatterErase(t) {
|
|
1278
|
-
return await
|
|
1335
|
+
return await this.SmartHomeErase(t);
|
|
1279
1336
|
}
|
|
1280
1337
|
}
|
|
1281
|
-
async function
|
|
1282
|
-
const {
|
|
1283
|
-
(
|
|
1338
|
+
async function zt(n, t) {
|
|
1339
|
+
const { application_name: e, file: i, data: r } = t, { data: o, error: a } = await s(
|
|
1340
|
+
(c) => n.POST("/assets/upload", {
|
|
1284
1341
|
params: {
|
|
1285
1342
|
query: {
|
|
1286
|
-
|
|
1287
|
-
file:
|
|
1343
|
+
application_name: e,
|
|
1344
|
+
file: i
|
|
1288
1345
|
}
|
|
1289
1346
|
},
|
|
1290
1347
|
headers: {
|
|
1291
1348
|
"Content-Type": "application/octet-stream"
|
|
1292
1349
|
},
|
|
1293
1350
|
body: r,
|
|
1294
|
-
signal:
|
|
1351
|
+
signal: c
|
|
1295
1352
|
}),
|
|
1296
1353
|
t.timeout
|
|
1297
1354
|
);
|
|
@@ -1299,12 +1356,12 @@ async function jt(n, t) {
|
|
|
1299
1356
|
throw a;
|
|
1300
1357
|
return o;
|
|
1301
1358
|
}
|
|
1302
|
-
async function
|
|
1303
|
-
const {
|
|
1359
|
+
async function Jt(n, t) {
|
|
1360
|
+
const { application_name: e } = t, { data: i, error: r } = await s(
|
|
1304
1361
|
(o) => n.DELETE("/assets/upload", {
|
|
1305
1362
|
params: {
|
|
1306
1363
|
query: {
|
|
1307
|
-
|
|
1364
|
+
application_name: e
|
|
1308
1365
|
}
|
|
1309
1366
|
},
|
|
1310
1367
|
signal: o
|
|
@@ -1313,52 +1370,52 @@ async function zt(n, t) {
|
|
|
1313
1370
|
);
|
|
1314
1371
|
if (r)
|
|
1315
1372
|
throw r;
|
|
1316
|
-
return
|
|
1373
|
+
return i;
|
|
1317
1374
|
}
|
|
1318
|
-
class
|
|
1375
|
+
class Xt {
|
|
1319
1376
|
/**
|
|
1320
1377
|
* Upload asset file with app ID. Uploads a file to a specific app's assets directory.
|
|
1321
1378
|
*
|
|
1322
1379
|
* @param {UploadParams} params - Parameters for the upload.
|
|
1323
|
-
* @param {
|
|
1324
|
-
* @param {
|
|
1325
|
-
* @param {
|
|
1326
|
-
* @param {
|
|
1380
|
+
* @param {string} params.application_name - Application name for organizing assets.
|
|
1381
|
+
* @param {string} params.file - Filename for the uploaded asset.
|
|
1382
|
+
* @param {BusyFile} params.data - File data to upload.
|
|
1383
|
+
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1327
1384
|
* @returns {Promise<SuccessResponse>} Result of the upload operation.
|
|
1328
1385
|
*/
|
|
1329
1386
|
async AssetsUpload(t) {
|
|
1330
|
-
return await
|
|
1387
|
+
return await zt(this.apiClient, t);
|
|
1331
1388
|
}
|
|
1332
1389
|
/**
|
|
1333
1390
|
* Delete app assets. Deletes all assets for a specific app ID.
|
|
1334
1391
|
*
|
|
1335
1392
|
* @param {DeleteParams} params - Parameters for the delete.
|
|
1336
|
-
* @param {
|
|
1337
|
-
* @param {
|
|
1393
|
+
* @param {string} params.application_name - Application name whose assets should be deleted.
|
|
1394
|
+
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1338
1395
|
* @returns {Promise<SuccessResponse>} Result of the delete operation.
|
|
1339
1396
|
*/
|
|
1340
1397
|
async AssetsDelete(t) {
|
|
1341
|
-
return await
|
|
1398
|
+
return await Jt(this.apiClient, t);
|
|
1342
1399
|
}
|
|
1343
1400
|
}
|
|
1344
|
-
const S = "http://10.0.4.20",
|
|
1345
|
-
function
|
|
1401
|
+
const S = "http://10.0.4.20", Yt = "https://proxy.busy.app", Qt = /^https?:\/\/proxy(?:\.(?:dev|test|stage))?\.busy\.app$/i;
|
|
1402
|
+
function m(n) {
|
|
1346
1403
|
const t = n.split(".");
|
|
1347
1404
|
if (t.length !== 4)
|
|
1348
1405
|
return !1;
|
|
1349
|
-
for (const
|
|
1350
|
-
if (
|
|
1406
|
+
for (const e of t) {
|
|
1407
|
+
if (e.length === 0 || e.length > 1 && e[0] === "0" || !/^\d+$/.test(e))
|
|
1351
1408
|
return !1;
|
|
1352
|
-
const
|
|
1353
|
-
if (
|
|
1409
|
+
const i = Number(e);
|
|
1410
|
+
if (i < 0 || i > 255)
|
|
1354
1411
|
return !1;
|
|
1355
1412
|
}
|
|
1356
1413
|
return !0;
|
|
1357
1414
|
}
|
|
1358
|
-
function
|
|
1415
|
+
function T(n) {
|
|
1359
1416
|
return /\.local$/i.test(n);
|
|
1360
1417
|
}
|
|
1361
|
-
class
|
|
1418
|
+
class Zt {
|
|
1362
1419
|
/**
|
|
1363
1420
|
* Creates an instance of BUSY Bar.
|
|
1364
1421
|
* Initializes the API client with the provided host address.
|
|
@@ -1387,38 +1444,38 @@ class Yt {
|
|
|
1387
1444
|
* @type {BusyBarConfig['host']}
|
|
1388
1445
|
* @readonly
|
|
1389
1446
|
*/
|
|
1390
|
-
|
|
1447
|
+
u(this, "addr");
|
|
1391
1448
|
/**
|
|
1392
1449
|
* Current API semantic version.
|
|
1393
1450
|
* @type {ApiSemver}
|
|
1394
1451
|
*/
|
|
1395
|
-
|
|
1452
|
+
u(this, "apiSemver");
|
|
1396
1453
|
/**
|
|
1397
1454
|
* API Client instance.
|
|
1398
1455
|
*/
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1456
|
+
u(this, "apiClient");
|
|
1457
|
+
u(this, "setApiKeyFn");
|
|
1458
|
+
u(this, "setTokenFn");
|
|
1402
1459
|
/**
|
|
1403
1460
|
* Detected connection type based on auth requirements.
|
|
1404
1461
|
* - "wifi": Device requires authentication (returned 401/403).
|
|
1405
1462
|
* - "usb": Device allows access without token (returned 200).
|
|
1406
1463
|
* - "unknown": Detection failed or not yet completed.
|
|
1407
1464
|
*/
|
|
1408
|
-
|
|
1465
|
+
u(this, "connectionType", "unknown");
|
|
1409
1466
|
if (!t || !t.addr && !t.token)
|
|
1410
1467
|
this.addr = S;
|
|
1411
1468
|
else if (!t.addr)
|
|
1412
|
-
this.addr =
|
|
1469
|
+
this.addr = Yt;
|
|
1413
1470
|
else {
|
|
1414
1471
|
let o = t.addr.trim();
|
|
1415
|
-
if (/^https?:\/\//i.test(o) || (o = `http://${o}`),
|
|
1472
|
+
if (/^https?:\/\//i.test(o) || (o = `http://${o}`), Qt.test(o) && !t.token)
|
|
1416
1473
|
throw new Error("Token is required. Please provide it.");
|
|
1417
1474
|
this.addr = o;
|
|
1418
1475
|
}
|
|
1419
1476
|
this.apiSemver = "";
|
|
1420
|
-
const { client:
|
|
1421
|
-
this.apiClient =
|
|
1477
|
+
const { client: e, setApiKey: i, setToken: r } = L(`${this.addr}/api/`, this.SystemVersionGet.bind(this), t == null ? void 0 : t.token);
|
|
1478
|
+
this.apiClient = e, this.setApiKeyFn = i, this.setTokenFn = r, this.detectConnectionType();
|
|
1422
1479
|
}
|
|
1423
1480
|
/**
|
|
1424
1481
|
* Probes the device to determine connection type.
|
|
@@ -1426,23 +1483,23 @@ class Yt {
|
|
|
1426
1483
|
*/
|
|
1427
1484
|
async detectConnectionType() {
|
|
1428
1485
|
const t = new URL(this.addr).hostname;
|
|
1429
|
-
if (!
|
|
1486
|
+
if (!m(t) && !T(t)) {
|
|
1430
1487
|
this.connectionType = "wifi";
|
|
1431
1488
|
return;
|
|
1432
1489
|
}
|
|
1433
|
-
const
|
|
1490
|
+
const e = E({
|
|
1434
1491
|
baseUrl: `${this.addr}/api/`
|
|
1435
1492
|
});
|
|
1436
1493
|
try {
|
|
1437
|
-
const { response:
|
|
1438
|
-
if (
|
|
1494
|
+
const { response: i } = await e.GET("/name");
|
|
1495
|
+
if (i.status === 401 || i.status === 403)
|
|
1439
1496
|
this.connectionType = "wifi";
|
|
1440
|
-
else if (
|
|
1497
|
+
else if (i.ok)
|
|
1441
1498
|
this.connectionType = "usb";
|
|
1442
1499
|
else
|
|
1443
|
-
throw new Error(`Failed to detect connection type. Status: ${
|
|
1444
|
-
} catch (
|
|
1445
|
-
throw
|
|
1500
|
+
throw new Error(`Failed to detect connection type. Status: ${i.status}`);
|
|
1501
|
+
} catch (i) {
|
|
1502
|
+
throw i;
|
|
1446
1503
|
}
|
|
1447
1504
|
}
|
|
1448
1505
|
/**
|
|
@@ -1460,95 +1517,95 @@ class Yt {
|
|
|
1460
1517
|
this.setTokenFn(t);
|
|
1461
1518
|
}
|
|
1462
1519
|
}
|
|
1463
|
-
function
|
|
1464
|
-
t.forEach((
|
|
1465
|
-
Object.getOwnPropertyNames(
|
|
1466
|
-
Object.defineProperty(n.prototype,
|
|
1520
|
+
function te(n, t) {
|
|
1521
|
+
t.forEach((e) => {
|
|
1522
|
+
Object.getOwnPropertyNames(e.prototype).forEach((i) => {
|
|
1523
|
+
Object.defineProperty(n.prototype, i, Object.getOwnPropertyDescriptor(e.prototype, i) || /* @__PURE__ */ Object.create(null));
|
|
1467
1524
|
});
|
|
1468
1525
|
});
|
|
1469
1526
|
}
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1527
|
+
te(Zt, [
|
|
1528
|
+
R,
|
|
1529
|
+
V,
|
|
1473
1530
|
Q,
|
|
1474
1531
|
ot,
|
|
1475
1532
|
dt,
|
|
1476
1533
|
pt,
|
|
1477
1534
|
Ct,
|
|
1478
|
-
|
|
1479
|
-
It,
|
|
1535
|
+
Ot,
|
|
1480
1536
|
_t,
|
|
1537
|
+
Ft,
|
|
1481
1538
|
Mt,
|
|
1482
|
-
|
|
1483
|
-
|
|
1539
|
+
jt,
|
|
1540
|
+
Xt
|
|
1484
1541
|
]);
|
|
1485
1542
|
var p = /* @__PURE__ */ ((n) => (n[n.FRONT = 0] = "FRONT", n[n.BACK = 1] = "BACK", n))(p || {});
|
|
1486
1543
|
const C = 3e3, k = /* @__PURE__ */ new Set([1001, 1006, 1012, 1013, 1014, 3008]);
|
|
1487
1544
|
function g(n, t) {
|
|
1488
1545
|
if (t < 0 || t >= n.length)
|
|
1489
1546
|
throw new Error(`Index ${t} is out of bounds (0…${n.length - 1})`);
|
|
1490
|
-
const
|
|
1491
|
-
if (
|
|
1547
|
+
const e = n[t];
|
|
1548
|
+
if (e === void 0)
|
|
1492
1549
|
throw new Error(`Unexpected undefined at index ${t}`);
|
|
1493
|
-
return
|
|
1550
|
+
return e;
|
|
1494
1551
|
}
|
|
1495
|
-
function
|
|
1496
|
-
let
|
|
1497
|
-
const
|
|
1498
|
-
for (;
|
|
1499
|
-
const o = g(n,
|
|
1500
|
-
if (
|
|
1552
|
+
function ee(n, t) {
|
|
1553
|
+
let e = 0;
|
|
1554
|
+
const i = n.length, r = [];
|
|
1555
|
+
for (; e < i; ) {
|
|
1556
|
+
const o = g(n, e);
|
|
1557
|
+
if (e += 1, (o & 128) !== 0) {
|
|
1501
1558
|
const a = o & 127;
|
|
1502
|
-
for (let
|
|
1503
|
-
r.push(n[
|
|
1504
|
-
|
|
1559
|
+
for (let c = 0; c < a * t; c++)
|
|
1560
|
+
r.push(n[e + c]);
|
|
1561
|
+
e += a * t;
|
|
1505
1562
|
} else {
|
|
1506
|
-
const a = o,
|
|
1507
|
-
for (let
|
|
1563
|
+
const a = o, c = n.slice(e, e + t);
|
|
1564
|
+
for (let d = 0; d < a; d++)
|
|
1508
1565
|
for (let f = 0; f < t; f++)
|
|
1509
|
-
r.push(
|
|
1510
|
-
|
|
1566
|
+
r.push(c[f]);
|
|
1567
|
+
e += t;
|
|
1511
1568
|
}
|
|
1512
1569
|
}
|
|
1513
1570
|
return new Uint8Array(r);
|
|
1514
1571
|
}
|
|
1515
|
-
function
|
|
1572
|
+
function ie(n) {
|
|
1516
1573
|
const t = new Uint8Array(n.length * 2);
|
|
1517
|
-
let
|
|
1518
|
-
for (;
|
|
1519
|
-
const r = g(n,
|
|
1520
|
-
t[
|
|
1574
|
+
let e = 0, i = 0;
|
|
1575
|
+
for (; e < n.length; ) {
|
|
1576
|
+
const r = g(n, e), o = r & 15, a = r >> 4 & 15;
|
|
1577
|
+
t[i] = o, t[i + 1] = a, e += 1, i += 2;
|
|
1521
1578
|
}
|
|
1522
1579
|
return t;
|
|
1523
1580
|
}
|
|
1524
1581
|
const A = () => typeof window < "u" && typeof window.document < "u";
|
|
1525
|
-
class
|
|
1582
|
+
class oe {
|
|
1526
1583
|
constructor(t) {
|
|
1527
|
-
|
|
1528
|
-
|
|
1584
|
+
u(this, "addr");
|
|
1585
|
+
u(this, "connected", !1);
|
|
1529
1586
|
// @ts-ignore
|
|
1530
|
-
|
|
1587
|
+
u(this, "apiKey");
|
|
1531
1588
|
// @ts-ignore
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1589
|
+
u(this, "apiSemver");
|
|
1590
|
+
u(this, "dataListeners", []);
|
|
1591
|
+
u(this, "stopListeners", []);
|
|
1592
|
+
u(this, "errorListeners", []);
|
|
1593
|
+
u(this, "socket", null);
|
|
1537
1594
|
if (this.config = t, !A())
|
|
1538
1595
|
throw new Error("not browser");
|
|
1539
1596
|
if (t.apiKey && (this.apiKey = t.apiKey), t.apiSemver && (this.apiSemver = t.apiSemver), !t || !t.addr)
|
|
1540
1597
|
this.addr = S;
|
|
1541
1598
|
else {
|
|
1542
|
-
let
|
|
1543
|
-
/^https?:\/\//i.test(
|
|
1599
|
+
let e = t.addr.trim();
|
|
1600
|
+
/^https?:\/\//i.test(e) || (e = `http://${e}`);
|
|
1544
1601
|
try {
|
|
1545
|
-
const r = new URL(
|
|
1546
|
-
if (!
|
|
1602
|
+
const r = new URL(e).hostname;
|
|
1603
|
+
if (!m(r) && !T(r))
|
|
1547
1604
|
throw new Error(`Invalid address: "${t.addr}". Only IP addresses and mDNS names (ending in .local) are supported.`);
|
|
1548
|
-
} catch (
|
|
1549
|
-
throw
|
|
1605
|
+
} catch (i) {
|
|
1606
|
+
throw i instanceof Error && i.message.startsWith("Invalid address") ? i : new Error(`Invalid URL format: "${t.addr}"`);
|
|
1550
1607
|
}
|
|
1551
|
-
this.addr =
|
|
1608
|
+
this.addr = e;
|
|
1552
1609
|
}
|
|
1553
1610
|
}
|
|
1554
1611
|
onData(t) {
|
|
@@ -1561,16 +1618,16 @@ class ne {
|
|
|
1561
1618
|
this.errorListeners.push(t);
|
|
1562
1619
|
}
|
|
1563
1620
|
emitData(t) {
|
|
1564
|
-
for (const
|
|
1565
|
-
|
|
1621
|
+
for (const e of this.dataListeners)
|
|
1622
|
+
e(t);
|
|
1566
1623
|
}
|
|
1567
1624
|
emitStop() {
|
|
1568
1625
|
for (const t of this.stopListeners)
|
|
1569
1626
|
t();
|
|
1570
1627
|
}
|
|
1571
1628
|
emitError(t) {
|
|
1572
|
-
for (const
|
|
1573
|
-
|
|
1629
|
+
for (const e of this.errorListeners)
|
|
1630
|
+
e(t);
|
|
1574
1631
|
}
|
|
1575
1632
|
async openWebsocket() {
|
|
1576
1633
|
this.socket && await this.closeWebsocket();
|
|
@@ -1579,35 +1636,35 @@ class ne {
|
|
|
1579
1636
|
throw new Error("The WebSocket URL is not specified");
|
|
1580
1637
|
this.socket = new WebSocket(t), this.socket.onopen = () => {
|
|
1581
1638
|
this.socket && (this.socket.send(JSON.stringify({ display: this.config.deviceScreen })), this.connected = !0);
|
|
1582
|
-
}, this.socket.binaryType = "arraybuffer", this.socket.onmessage = (
|
|
1639
|
+
}, this.socket.binaryType = "arraybuffer", this.socket.onmessage = (e) => {
|
|
1583
1640
|
try {
|
|
1584
|
-
if (typeof
|
|
1641
|
+
if (typeof e.data == "string")
|
|
1585
1642
|
return;
|
|
1586
|
-
const
|
|
1643
|
+
const i = new Uint8Array(e.data);
|
|
1587
1644
|
let r;
|
|
1588
1645
|
const o = this.config.deviceScreen === p.FRONT ? 3 : 2;
|
|
1589
1646
|
try {
|
|
1590
|
-
const a =
|
|
1591
|
-
this.config.deviceScreen === p.BACK ? r =
|
|
1647
|
+
const a = ee(i, o);
|
|
1648
|
+
this.config.deviceScreen === p.BACK ? r = ie(a) : r = a, this.emitData(r);
|
|
1592
1649
|
} catch {
|
|
1593
|
-
this.emitData(
|
|
1650
|
+
this.emitData(i);
|
|
1594
1651
|
}
|
|
1595
1652
|
} catch {
|
|
1596
1653
|
this.connected = !1, this.emitStop();
|
|
1597
1654
|
}
|
|
1598
|
-
}, this.socket.onerror = (
|
|
1655
|
+
}, this.socket.onerror = (e) => {
|
|
1599
1656
|
this.connected = !1, this.emitError({
|
|
1600
1657
|
code: 1006,
|
|
1601
1658
|
// Standard «abnormal closure» code per RFC-6455
|
|
1602
1659
|
message: "WebSocket error occurred",
|
|
1603
|
-
raw:
|
|
1660
|
+
raw: e
|
|
1604
1661
|
}), this.emitStop();
|
|
1605
|
-
}, this.socket.onclose = async (
|
|
1606
|
-
if (this.socket = null, this.connected = !1,
|
|
1662
|
+
}, this.socket.onclose = async (e) => {
|
|
1663
|
+
if (this.socket = null, this.connected = !1, e.code === C || k.has(e.code)) {
|
|
1607
1664
|
this.emitError({
|
|
1608
|
-
code:
|
|
1609
|
-
message:
|
|
1610
|
-
raw:
|
|
1665
|
+
code: e.code,
|
|
1666
|
+
message: e.reason,
|
|
1667
|
+
raw: e
|
|
1611
1668
|
});
|
|
1612
1669
|
return;
|
|
1613
1670
|
}
|
|
@@ -1622,34 +1679,34 @@ class ne {
|
|
|
1622
1679
|
});
|
|
1623
1680
|
}
|
|
1624
1681
|
}
|
|
1625
|
-
class
|
|
1682
|
+
class se {
|
|
1626
1683
|
constructor(t) {
|
|
1627
|
-
|
|
1628
|
-
|
|
1684
|
+
u(this, "addr");
|
|
1685
|
+
u(this, "connected", !1);
|
|
1629
1686
|
// @ts-ignore
|
|
1630
|
-
|
|
1687
|
+
u(this, "apiKey");
|
|
1631
1688
|
// @ts-ignore
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1689
|
+
u(this, "apiSemver");
|
|
1690
|
+
u(this, "inputEvent");
|
|
1691
|
+
u(this, "dataListeners", []);
|
|
1692
|
+
u(this, "stopListeners", []);
|
|
1693
|
+
u(this, "errorListeners", []);
|
|
1694
|
+
u(this, "socket", null);
|
|
1638
1695
|
if (!A())
|
|
1639
1696
|
throw new Error("not browser");
|
|
1640
1697
|
if (t != null && t.apiKey && (this.apiKey = t.apiKey), t != null && t.apiSemver && (this.apiSemver = t.apiSemver), !t || !t.addr)
|
|
1641
1698
|
this.addr = S;
|
|
1642
1699
|
else {
|
|
1643
|
-
let
|
|
1644
|
-
/^https?:\/\//i.test(
|
|
1700
|
+
let e = t.addr.trim();
|
|
1701
|
+
/^https?:\/\//i.test(e) || (e = `http://${e}`);
|
|
1645
1702
|
try {
|
|
1646
|
-
const r = new URL(
|
|
1647
|
-
if (!
|
|
1703
|
+
const r = new URL(e).hostname;
|
|
1704
|
+
if (!m(r) && !T(r))
|
|
1648
1705
|
throw new Error(`Invalid address: "${t.addr}". Only IP addresses and mDNS names (ending in .local) are supported.`);
|
|
1649
|
-
} catch (
|
|
1650
|
-
throw
|
|
1706
|
+
} catch (i) {
|
|
1707
|
+
throw i instanceof Error && i.message.startsWith("Invalid address") ? i : new Error(`Invalid URL format: "${t.addr}"`);
|
|
1651
1708
|
}
|
|
1652
|
-
this.addr =
|
|
1709
|
+
this.addr = e;
|
|
1653
1710
|
}
|
|
1654
1711
|
this.inputEvent = {};
|
|
1655
1712
|
}
|
|
@@ -1663,16 +1720,16 @@ class re {
|
|
|
1663
1720
|
this.errorListeners.push(t);
|
|
1664
1721
|
}
|
|
1665
1722
|
emitData(t) {
|
|
1666
|
-
for (const
|
|
1667
|
-
|
|
1723
|
+
for (const e of this.dataListeners)
|
|
1724
|
+
e(t);
|
|
1668
1725
|
}
|
|
1669
1726
|
emitStop() {
|
|
1670
1727
|
for (const t of this.stopListeners)
|
|
1671
1728
|
t();
|
|
1672
1729
|
}
|
|
1673
1730
|
emitError(t) {
|
|
1674
|
-
for (const
|
|
1675
|
-
|
|
1731
|
+
for (const e of this.errorListeners)
|
|
1732
|
+
e(t);
|
|
1676
1733
|
}
|
|
1677
1734
|
async openWebsocket() {
|
|
1678
1735
|
this.socket && await this.closeWebsocket();
|
|
@@ -1681,38 +1738,38 @@ class re {
|
|
|
1681
1738
|
throw new Error("The WebSocket URL is not specified");
|
|
1682
1739
|
this.socket = new WebSocket(t), this.socket.onopen = () => {
|
|
1683
1740
|
this.socket && (this.connected = !0);
|
|
1684
|
-
}, this.socket.binaryType = "arraybuffer", this.socket.onmessage = (
|
|
1741
|
+
}, this.socket.binaryType = "arraybuffer", this.socket.onmessage = (e) => {
|
|
1685
1742
|
try {
|
|
1686
|
-
if (typeof
|
|
1743
|
+
if (typeof e.data == "string")
|
|
1687
1744
|
return;
|
|
1688
|
-
const
|
|
1689
|
-
this.emitData(
|
|
1745
|
+
const i = new Uint8Array(e.data);
|
|
1746
|
+
this.emitData(i);
|
|
1690
1747
|
} catch {
|
|
1691
1748
|
this.connected = !1, this.emitStop();
|
|
1692
1749
|
}
|
|
1693
|
-
}, this.socket.onerror = (
|
|
1750
|
+
}, this.socket.onerror = (e) => {
|
|
1694
1751
|
this.connected = !1, this.emitError({
|
|
1695
1752
|
code: 1006,
|
|
1696
1753
|
// Standard «abnormal closure» code per RFC-6455
|
|
1697
1754
|
message: "WebSocket error occurred",
|
|
1698
|
-
raw:
|
|
1755
|
+
raw: e
|
|
1699
1756
|
}), this.emitStop();
|
|
1700
|
-
}, this.socket.onclose = async (
|
|
1701
|
-
if (this.socket = null, this.connected = !1,
|
|
1757
|
+
}, this.socket.onclose = async (e) => {
|
|
1758
|
+
if (this.socket = null, this.connected = !1, e.code === C || k.has(e.code)) {
|
|
1702
1759
|
this.emitError({
|
|
1703
|
-
code:
|
|
1704
|
-
message:
|
|
1705
|
-
raw:
|
|
1760
|
+
code: e.code,
|
|
1761
|
+
message: e.reason,
|
|
1762
|
+
raw: e
|
|
1706
1763
|
});
|
|
1707
1764
|
return;
|
|
1708
1765
|
}
|
|
1709
1766
|
this.emitStop();
|
|
1710
1767
|
};
|
|
1711
1768
|
}
|
|
1712
|
-
sendInput({ keyName: t, value:
|
|
1769
|
+
sendInput({ keyName: t, value: e }) {
|
|
1713
1770
|
if (!this.socket || !this.connected)
|
|
1714
1771
|
throw new Error("WebSocket: Not connected");
|
|
1715
|
-
this.inputEvent[t] =
|
|
1772
|
+
this.inputEvent[t] = e, this.socket.send(JSON.stringify(this.inputEvent)), e === 0 && delete this.inputEvent[t];
|
|
1716
1773
|
}
|
|
1717
1774
|
closeWebsocket() {
|
|
1718
1775
|
return this.connected = !1, new Promise((t) => {
|
|
@@ -1723,8 +1780,8 @@ class re {
|
|
|
1723
1780
|
}
|
|
1724
1781
|
}
|
|
1725
1782
|
export {
|
|
1726
|
-
|
|
1783
|
+
Zt as BusyBar,
|
|
1727
1784
|
p as DeviceScreen,
|
|
1728
|
-
|
|
1729
|
-
|
|
1785
|
+
se as Input,
|
|
1786
|
+
oe as ScreenStream
|
|
1730
1787
|
};
|