@busy-app/busy-lib 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +41 -1
- package/dist/index.d.ts +1034 -2
- package/dist/index.js +875 -446
- package/dist/index.worker.cjs +11 -0
- package/dist/index.worker.d.ts +1 -0
- package/dist/index.worker.js +4025 -0
- package/dist/types.status-BeqxtQVd.cjs +1 -0
- package/dist/types.status-gCPe7MrJ.js +16 -0
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -1,112 +1,113 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var u = (
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
var B = Object.defineProperty;
|
|
2
|
+
var F = (r, t, e) => t in r ? B(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
+
var u = (r, t, e) => F(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import O from "openapi-fetch";
|
|
5
|
+
import { W as S, D as C, A as k, C as E, S as f, a as y, b as d } from "./types.status-gCPe7MrJ.js";
|
|
6
|
+
const W = (r, t) => {
|
|
7
|
+
if (typeof FormData < "u" && r instanceof FormData || typeof Buffer < "u" && typeof Buffer.isBuffer == "function" && Buffer.isBuffer(r) || typeof File < "u" && r instanceof File || typeof Blob < "u" && r instanceof Blob || typeof ArrayBuffer < "u" && r instanceof ArrayBuffer || typeof ArrayBuffer < "u" && ArrayBuffer.isView && ArrayBuffer.isView(r))
|
|
8
|
+
return r;
|
|
8
9
|
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") ?
|
|
10
|
+
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") ? r && typeof r == "object" && !(r instanceof URLSearchParams) ? new URLSearchParams(r).toString() : String(r) : JSON.stringify(r);
|
|
10
11
|
};
|
|
11
|
-
async function
|
|
12
|
-
const i = (
|
|
13
|
-
return Object.assign(new Error(
|
|
14
|
-
status:
|
|
15
|
-
statusText:
|
|
12
|
+
async function b(r) {
|
|
13
|
+
const i = (r.headers.get("content-type") || "").includes("application/json") ? await r.clone().json() : await r.clone().text(), n = typeof i == "object" && i !== null ? i.error || i.message : typeof i == "string" ? i : void 0;
|
|
14
|
+
return Object.assign(new Error(n || `HTTP ${r.status} ${r.statusText}`), {
|
|
15
|
+
status: r.status,
|
|
16
|
+
statusText: r.statusText,
|
|
16
17
|
body: i
|
|
17
18
|
});
|
|
18
19
|
}
|
|
19
|
-
async function
|
|
20
|
+
async function a(r, t = 3e3) {
|
|
20
21
|
if (t <= 0)
|
|
21
|
-
return await
|
|
22
|
+
return await r();
|
|
22
23
|
const e = new AbortController(), i = setTimeout(() => e.abort(), t);
|
|
23
24
|
try {
|
|
24
|
-
return await
|
|
25
|
-
} catch (
|
|
26
|
-
throw
|
|
25
|
+
return await r(e.signal);
|
|
26
|
+
} catch (n) {
|
|
27
|
+
throw n instanceof DOMException && n.name === "AbortError" ? new Error(`Request timed out after ${t}ms`) : n;
|
|
27
28
|
} finally {
|
|
28
29
|
clearTimeout(i);
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
|
-
function
|
|
32
|
-
let i,
|
|
33
|
-
const
|
|
34
|
-
i || (
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
32
|
+
function M(r, t, e) {
|
|
33
|
+
let i, n = e ?? void 0, s, o = null;
|
|
34
|
+
const h = async () => {
|
|
35
|
+
i || (o || (o = (async () => {
|
|
36
|
+
const l = await t();
|
|
37
|
+
if (!l.api_semver)
|
|
37
38
|
throw new Error("Empty API version");
|
|
38
|
-
i =
|
|
39
|
+
i = l.api_semver;
|
|
39
40
|
})().finally(() => {
|
|
40
|
-
|
|
41
|
-
})), await
|
|
42
|
-
},
|
|
43
|
-
async onRequest({ request:
|
|
44
|
-
return
|
|
41
|
+
o = null;
|
|
42
|
+
})), await o);
|
|
43
|
+
}, c = {
|
|
44
|
+
async onRequest({ request: l, schemaPath: w }) {
|
|
45
|
+
return n && l.headers.set("Authorization", `Bearer ${n}`), w !== "/version" && (await h(), i && l.headers.set("X-API-Sem-Ver", i), s && l.headers.set("X-API-Token", s)), l;
|
|
45
46
|
},
|
|
46
|
-
async onResponse({ request:
|
|
47
|
+
async onResponse({ request: l, response: w, options: G, schemaPath: x }) {
|
|
47
48
|
if (w.ok)
|
|
48
49
|
return w;
|
|
49
|
-
if (
|
|
50
|
-
throw await
|
|
50
|
+
if (x === "/version")
|
|
51
|
+
throw await b(w);
|
|
51
52
|
if (w.status !== 405)
|
|
52
|
-
throw await
|
|
53
|
-
i = void 0, await
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
return
|
|
57
|
-
throw await
|
|
53
|
+
throw await b(w);
|
|
54
|
+
i = void 0, await h(), i && l.headers.set("X-API-Sem-Ver", i), n && l.headers.set("Authorization", `Bearer ${n}`);
|
|
55
|
+
const A = await (G.fetch ?? fetch)(l);
|
|
56
|
+
if (A.ok)
|
|
57
|
+
return A;
|
|
58
|
+
throw await b(A);
|
|
58
59
|
}
|
|
59
|
-
},
|
|
60
|
-
baseUrl:
|
|
61
|
-
bodySerializer:
|
|
60
|
+
}, p = O({
|
|
61
|
+
baseUrl: r,
|
|
62
|
+
bodySerializer: W
|
|
62
63
|
});
|
|
63
|
-
return
|
|
64
|
-
client:
|
|
65
|
-
setApiKey: (
|
|
66
|
-
|
|
64
|
+
return p.use(c), {
|
|
65
|
+
client: p,
|
|
66
|
+
setApiKey: (l) => {
|
|
67
|
+
s = l;
|
|
67
68
|
},
|
|
68
|
-
setToken: (
|
|
69
|
-
|
|
69
|
+
setToken: (l) => {
|
|
70
|
+
n = l;
|
|
70
71
|
}
|
|
71
72
|
};
|
|
72
73
|
}
|
|
73
|
-
async function
|
|
74
|
-
const { data: e, error: i } = await
|
|
74
|
+
async function $(r, t) {
|
|
75
|
+
const { data: e, error: i } = await a((n) => r.GET("/version", { signal: n }), t == null ? void 0 : t.timeout);
|
|
75
76
|
if (i)
|
|
76
77
|
throw i;
|
|
77
78
|
return e;
|
|
78
79
|
}
|
|
79
|
-
async function
|
|
80
|
-
const { data: e, error: i } = await
|
|
80
|
+
async function K(r, t) {
|
|
81
|
+
const { data: e, error: i } = await a((n) => r.GET("/status", { signal: n }), t == null ? void 0 : t.timeout);
|
|
81
82
|
if (i)
|
|
82
83
|
throw i;
|
|
83
84
|
return e;
|
|
84
85
|
}
|
|
85
|
-
async function
|
|
86
|
-
const { data: e, error: i } = await
|
|
86
|
+
async function z(r, t) {
|
|
87
|
+
const { data: e, error: i } = await a((n) => r.GET("/status/system", { signal: n }), t == null ? void 0 : t.timeout);
|
|
87
88
|
if (i)
|
|
88
89
|
throw i;
|
|
89
90
|
return e;
|
|
90
91
|
}
|
|
91
|
-
async function
|
|
92
|
-
const { data: e, error: i } = await
|
|
92
|
+
async function H(r, t) {
|
|
93
|
+
const { data: e, error: i } = await a((n) => r.GET("/status/power", { signal: n }), t == null ? void 0 : t.timeout);
|
|
93
94
|
if (i)
|
|
94
95
|
throw i;
|
|
95
96
|
return e;
|
|
96
97
|
}
|
|
97
|
-
async function
|
|
98
|
-
const { data: e, error: i } = await
|
|
98
|
+
async function q(r, t) {
|
|
99
|
+
const { data: e, error: i } = await a((n) => r.GET("/status/device", { signal: n }), t == null ? void 0 : t.timeout);
|
|
99
100
|
if (i)
|
|
100
101
|
throw i;
|
|
101
102
|
return e;
|
|
102
103
|
}
|
|
103
|
-
async function
|
|
104
|
-
const { data: e, error: i } = await
|
|
104
|
+
async function V(r, t) {
|
|
105
|
+
const { data: e, error: i } = await a((n) => r.GET("/status/firmware", { signal: n }), t == null ? void 0 : t.timeout);
|
|
105
106
|
if (i)
|
|
106
107
|
throw i;
|
|
107
108
|
return e;
|
|
108
109
|
}
|
|
109
|
-
class
|
|
110
|
+
class X {
|
|
110
111
|
/**
|
|
111
112
|
* Get API version information.
|
|
112
113
|
*
|
|
@@ -115,7 +116,7 @@ class R {
|
|
|
115
116
|
* @returns {Promise<VersionInfo>} A promise that resolves to an object containing the `api_semver` string.
|
|
116
117
|
*/
|
|
117
118
|
async SystemVersionGet(t) {
|
|
118
|
-
const e = await
|
|
119
|
+
const e = await $(this.apiClient, t);
|
|
119
120
|
return this.apiSemver = e.api_semver, e;
|
|
120
121
|
}
|
|
121
122
|
/**
|
|
@@ -126,7 +127,7 @@ class R {
|
|
|
126
127
|
* @returns {Promise<Status>} Current status of the device.
|
|
127
128
|
*/
|
|
128
129
|
async SystemStatusGet(t) {
|
|
129
|
-
return await
|
|
130
|
+
return await K(this.apiClient, t);
|
|
130
131
|
}
|
|
131
132
|
/**
|
|
132
133
|
* Get system status.
|
|
@@ -136,7 +137,7 @@ class R {
|
|
|
136
137
|
* @returns {Promise<StatusSystem>} Current system status.
|
|
137
138
|
*/
|
|
138
139
|
async SystemInfoGet(t) {
|
|
139
|
-
return await
|
|
140
|
+
return await z(this.apiClient, t);
|
|
140
141
|
}
|
|
141
142
|
/**
|
|
142
143
|
* Get power status.
|
|
@@ -146,7 +147,7 @@ class R {
|
|
|
146
147
|
* @returns {Promise<StatusPower>} Current power status.
|
|
147
148
|
*/
|
|
148
149
|
async SystemStatusPowerGet(t) {
|
|
149
|
-
return await
|
|
150
|
+
return await H(this.apiClient, t);
|
|
150
151
|
}
|
|
151
152
|
/**
|
|
152
153
|
* Get device status.
|
|
@@ -156,7 +157,7 @@ class R {
|
|
|
156
157
|
* @returns {Promise<StatusDevice>} Current device status.
|
|
157
158
|
*/
|
|
158
159
|
async SystemStatusDeviceGet(t) {
|
|
159
|
-
return await
|
|
160
|
+
return await q(this.apiClient, t);
|
|
160
161
|
}
|
|
161
162
|
/**
|
|
162
163
|
* Get firmware status.
|
|
@@ -166,93 +167,93 @@ class R {
|
|
|
166
167
|
* @returns {Promise<StatusFirmware>} Current firmware status.
|
|
167
168
|
*/
|
|
168
169
|
async SystemStatusFirmwareGet(t) {
|
|
169
|
-
return await
|
|
170
|
+
return await V(this.apiClient, t);
|
|
170
171
|
}
|
|
171
172
|
}
|
|
172
|
-
async function
|
|
173
|
-
const { file: e } = t, { data: i, error:
|
|
174
|
-
(
|
|
173
|
+
async function j(r, t) {
|
|
174
|
+
const { file: e } = t, { data: i, error: n } = await a(
|
|
175
|
+
(s) => r.POST("/update", {
|
|
175
176
|
headers: {
|
|
176
177
|
"Content-Type": "application/octet-stream"
|
|
177
178
|
},
|
|
178
179
|
body: e,
|
|
179
|
-
signal:
|
|
180
|
+
signal: s
|
|
180
181
|
}),
|
|
181
182
|
t.timeout
|
|
182
183
|
);
|
|
183
|
-
if (
|
|
184
|
-
throw
|
|
184
|
+
if (n)
|
|
185
|
+
throw n;
|
|
185
186
|
return i;
|
|
186
187
|
}
|
|
187
|
-
async function
|
|
188
|
-
const { data: e, error: i } = await
|
|
188
|
+
async function Y(r, t) {
|
|
189
|
+
const { data: e, error: i } = await a((n) => r.POST("/update/check", { signal: n }), t == null ? void 0 : t.timeout);
|
|
189
190
|
if (i)
|
|
190
191
|
throw i;
|
|
191
192
|
return e;
|
|
192
193
|
}
|
|
193
|
-
async function
|
|
194
|
-
const { data: e, error: i } = await
|
|
194
|
+
async function J(r, t) {
|
|
195
|
+
const { data: e, error: i } = await a((n) => r.GET("/update/status", { signal: n }), t == null ? void 0 : t.timeout);
|
|
195
196
|
if (i)
|
|
196
197
|
throw i;
|
|
197
198
|
return e;
|
|
198
199
|
}
|
|
199
|
-
async function
|
|
200
|
-
const { version: e } = t, { data: i, error:
|
|
201
|
-
(
|
|
200
|
+
async function Q(r, t) {
|
|
201
|
+
const { version: e } = t, { data: i, error: n } = await a(
|
|
202
|
+
(s) => r.GET("/update/changelog", {
|
|
202
203
|
params: {
|
|
203
204
|
query: {
|
|
204
205
|
version: e
|
|
205
206
|
}
|
|
206
207
|
},
|
|
207
|
-
signal:
|
|
208
|
+
signal: s
|
|
208
209
|
}),
|
|
209
210
|
t.timeout
|
|
210
211
|
);
|
|
211
|
-
if (
|
|
212
|
-
throw
|
|
212
|
+
if (n)
|
|
213
|
+
throw n;
|
|
213
214
|
return i;
|
|
214
215
|
}
|
|
215
|
-
async function
|
|
216
|
-
const { version: e } = t, { data: i, error:
|
|
217
|
-
(
|
|
216
|
+
async function Z(r, t) {
|
|
217
|
+
const { version: e } = t, { data: i, error: n } = await a(
|
|
218
|
+
(s) => r.POST("/update/install", {
|
|
218
219
|
params: {
|
|
219
220
|
query: {
|
|
220
221
|
version: e
|
|
221
222
|
}
|
|
222
223
|
},
|
|
223
|
-
signal:
|
|
224
|
+
signal: s
|
|
224
225
|
}),
|
|
225
226
|
t.timeout
|
|
226
227
|
);
|
|
227
|
-
if (
|
|
228
|
-
throw
|
|
228
|
+
if (n)
|
|
229
|
+
throw n;
|
|
229
230
|
return i;
|
|
230
231
|
}
|
|
231
|
-
async function
|
|
232
|
-
const { data: e, error: i } = await
|
|
232
|
+
async function tt(r, t) {
|
|
233
|
+
const { data: e, error: i } = await a((n) => r.POST("/update/abort_download", { signal: n }), t == null ? void 0 : t.timeout);
|
|
233
234
|
if (i)
|
|
234
235
|
throw i;
|
|
235
236
|
return e;
|
|
236
237
|
}
|
|
237
|
-
async function
|
|
238
|
-
const { data: e, error: i } = await
|
|
238
|
+
async function et(r, t) {
|
|
239
|
+
const { data: e, error: i } = await a((n) => r.GET("/update/autoupdate", { signal: n }), t == null ? void 0 : t.timeout);
|
|
239
240
|
if (i)
|
|
240
241
|
throw i;
|
|
241
242
|
return e;
|
|
242
243
|
}
|
|
243
|
-
async function
|
|
244
|
-
const { is_enabled: e, interval_start: i, interval_end:
|
|
245
|
-
(
|
|
246
|
-
body: { is_enabled: e, interval_start: i, interval_end:
|
|
247
|
-
signal:
|
|
244
|
+
async function it(r, t) {
|
|
245
|
+
const { is_enabled: e, interval_start: i, interval_end: n } = t, { data: s, error: o } = await a(
|
|
246
|
+
(h) => r.POST("/update/autoupdate", {
|
|
247
|
+
body: { is_enabled: e, interval_start: i, interval_end: n },
|
|
248
|
+
signal: h
|
|
248
249
|
}),
|
|
249
250
|
t.timeout
|
|
250
251
|
);
|
|
251
|
-
if (
|
|
252
|
-
throw
|
|
253
|
-
return
|
|
252
|
+
if (o)
|
|
253
|
+
throw o;
|
|
254
|
+
return s;
|
|
254
255
|
}
|
|
255
|
-
class
|
|
256
|
+
class rt {
|
|
256
257
|
/**
|
|
257
258
|
* Upload firmware update package.
|
|
258
259
|
*
|
|
@@ -262,7 +263,7 @@ class V {
|
|
|
262
263
|
* @returns {Promise<SuccessResponse>} A promise that resolves when upload is complete.
|
|
263
264
|
*/
|
|
264
265
|
async UpdateFromFile(t) {
|
|
265
|
-
return await
|
|
266
|
+
return await j(this.apiClient, t);
|
|
266
267
|
}
|
|
267
268
|
/**
|
|
268
269
|
* Start firmware update check.
|
|
@@ -272,7 +273,7 @@ class V {
|
|
|
272
273
|
* @returns {Promise<SuccessResponse>} A promise that resolves to the update check result.
|
|
273
274
|
*/
|
|
274
275
|
async UpdateCheck(t) {
|
|
275
|
-
return await
|
|
276
|
+
return await Y(this.apiClient, t);
|
|
276
277
|
}
|
|
277
278
|
/**
|
|
278
279
|
* Get firmware update status.
|
|
@@ -282,7 +283,7 @@ class V {
|
|
|
282
283
|
* @returns {Promise<UpdateStatus>} A promise that resolves to the update status.
|
|
283
284
|
*/
|
|
284
285
|
async UpdateStatusGet(t) {
|
|
285
|
-
return await
|
|
286
|
+
return await J(this.apiClient, t);
|
|
286
287
|
}
|
|
287
288
|
/**
|
|
288
289
|
* Get firmware update changelog.
|
|
@@ -293,7 +294,7 @@ class V {
|
|
|
293
294
|
* @returns {Promise<UpdateChangelog>} A promise that resolves to the changelog content.
|
|
294
295
|
*/
|
|
295
296
|
async UpdateChangelogGet(t) {
|
|
296
|
-
return await
|
|
297
|
+
return await Q(this.apiClient, t);
|
|
297
298
|
}
|
|
298
299
|
/**
|
|
299
300
|
* Start firmware update installation.
|
|
@@ -304,7 +305,7 @@ class V {
|
|
|
304
305
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful initiation.
|
|
305
306
|
*/
|
|
306
307
|
async UpdateInstall(t) {
|
|
307
|
-
return await
|
|
308
|
+
return await Z(this.apiClient, t);
|
|
308
309
|
}
|
|
309
310
|
/**
|
|
310
311
|
* Abort firmware update download.
|
|
@@ -314,7 +315,7 @@ class V {
|
|
|
314
315
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful abort.
|
|
315
316
|
*/
|
|
316
317
|
async UpdateAbort(t) {
|
|
317
|
-
return await
|
|
318
|
+
return await tt(this.apiClient, t);
|
|
318
319
|
}
|
|
319
320
|
/**
|
|
320
321
|
* Get current auto-update settings.
|
|
@@ -324,7 +325,7 @@ class V {
|
|
|
324
325
|
* @returns {Promise<AutoUpdateSettings>} A promise that resolves to the current auto-update settings.
|
|
325
326
|
*/
|
|
326
327
|
async UpdateAutoUpdateGet(t) {
|
|
327
|
-
return await
|
|
328
|
+
return await et(this.apiClient, t);
|
|
328
329
|
}
|
|
329
330
|
/**
|
|
330
331
|
* Set auto-update settings.
|
|
@@ -337,56 +338,56 @@ class V {
|
|
|
337
338
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful update of settings.
|
|
338
339
|
*/
|
|
339
340
|
async UpdateAutoUpdateSet(t) {
|
|
340
|
-
return await
|
|
341
|
+
return await it(this.apiClient, t);
|
|
341
342
|
}
|
|
342
343
|
}
|
|
343
|
-
async function
|
|
344
|
-
const { data: e, error: i } = await
|
|
344
|
+
async function nt(r, t) {
|
|
345
|
+
const { data: e, error: i } = await a((n) => r.GET("/time", { signal: n }), t == null ? void 0 : t.timeout);
|
|
345
346
|
if (i)
|
|
346
347
|
throw i;
|
|
347
348
|
return e;
|
|
348
349
|
}
|
|
349
|
-
async function
|
|
350
|
-
const { timestamp: e } = t, { data: i, error:
|
|
351
|
-
(
|
|
350
|
+
async function st(r, t) {
|
|
351
|
+
const { timestamp: e } = t, { data: i, error: n } = await a(
|
|
352
|
+
(s) => r.POST("/time/timestamp", {
|
|
352
353
|
params: {
|
|
353
354
|
query: { timestamp: e }
|
|
354
355
|
},
|
|
355
|
-
signal:
|
|
356
|
+
signal: s
|
|
356
357
|
}),
|
|
357
358
|
t.timeout
|
|
358
359
|
);
|
|
359
|
-
if (
|
|
360
|
-
throw
|
|
360
|
+
if (n)
|
|
361
|
+
throw n;
|
|
361
362
|
return i;
|
|
362
363
|
}
|
|
363
|
-
async function
|
|
364
|
-
const { data: e, error: i } = await
|
|
364
|
+
async function at(r, t) {
|
|
365
|
+
const { data: e, error: i } = await a((n) => r.GET("/time/timezone", { signal: n }), t == null ? void 0 : t.timeout);
|
|
365
366
|
if (i)
|
|
366
367
|
throw i;
|
|
367
368
|
return e;
|
|
368
369
|
}
|
|
369
|
-
async function
|
|
370
|
-
const { timezone: e } = t, { data: i, error:
|
|
371
|
-
(
|
|
370
|
+
async function ot(r, t) {
|
|
371
|
+
const { timezone: e } = t, { data: i, error: n } = await a(
|
|
372
|
+
(s) => r.POST("/time/timezone", {
|
|
372
373
|
params: {
|
|
373
374
|
query: { timezone: e }
|
|
374
375
|
},
|
|
375
|
-
signal:
|
|
376
|
+
signal: s
|
|
376
377
|
}),
|
|
377
378
|
t.timeout
|
|
378
379
|
);
|
|
379
|
-
if (
|
|
380
|
-
throw
|
|
380
|
+
if (n)
|
|
381
|
+
throw n;
|
|
381
382
|
return i;
|
|
382
383
|
}
|
|
383
|
-
async function
|
|
384
|
-
const { data: e, error: i } = await
|
|
384
|
+
async function ct(r, t) {
|
|
385
|
+
const { data: e, error: i } = await a((n) => r.GET("/time/tzlist", { signal: n }), t == null ? void 0 : t.timeout);
|
|
385
386
|
if (i)
|
|
386
387
|
throw i;
|
|
387
388
|
return e;
|
|
388
389
|
}
|
|
389
|
-
class
|
|
390
|
+
class ut {
|
|
390
391
|
/**
|
|
391
392
|
* Get current timestamp info.
|
|
392
393
|
*
|
|
@@ -395,7 +396,7 @@ class Q {
|
|
|
395
396
|
* @returns {Promise<TimestampInfo>} A promise that resolves to the timestamp information.
|
|
396
397
|
*/
|
|
397
398
|
async TimeGet(t) {
|
|
398
|
-
return await
|
|
399
|
+
return await nt(this.apiClient, t);
|
|
399
400
|
}
|
|
400
401
|
/**
|
|
401
402
|
* Set system timestamp.
|
|
@@ -406,7 +407,7 @@ class Q {
|
|
|
406
407
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
407
408
|
*/
|
|
408
409
|
async TimeTimestampSet(t) {
|
|
409
|
-
return await
|
|
410
|
+
return await st(this.apiClient, t);
|
|
410
411
|
}
|
|
411
412
|
/**
|
|
412
413
|
* Get current timezone.
|
|
@@ -416,7 +417,7 @@ class Q {
|
|
|
416
417
|
* @returns {Promise<TimezoneInfo>} A promise that resolves to the timezone information.
|
|
417
418
|
*/
|
|
418
419
|
async TimeTimezoneGet(t) {
|
|
419
|
-
return await
|
|
420
|
+
return await at(this.apiClient, t);
|
|
420
421
|
}
|
|
421
422
|
/**
|
|
422
423
|
* Set system timezone.
|
|
@@ -427,7 +428,7 @@ class Q {
|
|
|
427
428
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
428
429
|
*/
|
|
429
430
|
async TimeTimezoneSet(t) {
|
|
430
|
-
return await
|
|
431
|
+
return await ot(this.apiClient, t);
|
|
431
432
|
}
|
|
432
433
|
/**
|
|
433
434
|
* Get list of supported timezones.
|
|
@@ -437,57 +438,57 @@ class Q {
|
|
|
437
438
|
* @returns {Promise<TimezoneList>} A promise that resolves to a list of timezone items.
|
|
438
439
|
*/
|
|
439
440
|
async TimeTzListGet(t) {
|
|
440
|
-
return await
|
|
441
|
+
return await ct(this.apiClient, t);
|
|
441
442
|
}
|
|
442
443
|
}
|
|
443
|
-
async function
|
|
444
|
-
const { data: e, error: i } = await
|
|
444
|
+
async function ht(r, t) {
|
|
445
|
+
const { data: e, error: i } = await a((n) => r.GET("/account/status", { signal: n }), t == null ? void 0 : t.timeout);
|
|
445
446
|
if (i)
|
|
446
447
|
throw i;
|
|
447
448
|
return e;
|
|
448
449
|
}
|
|
449
|
-
async function
|
|
450
|
-
const { data: e, error: i } = await
|
|
450
|
+
async function lt(r, t) {
|
|
451
|
+
const { data: e, error: i } = await a((n) => r.GET("/account/info", { signal: n }), t == null ? void 0 : t.timeout);
|
|
451
452
|
if (i)
|
|
452
453
|
throw i;
|
|
453
454
|
return e;
|
|
454
455
|
}
|
|
455
|
-
async function
|
|
456
|
-
const { data: e, error: i } = await
|
|
456
|
+
async function dt(r, t) {
|
|
457
|
+
const { data: e, error: i } = await a((n) => r.GET("/account/profile", { signal: n }), t == null ? void 0 : t.timeout);
|
|
457
458
|
if (i)
|
|
458
459
|
throw i;
|
|
459
460
|
return e;
|
|
460
461
|
}
|
|
461
|
-
async function
|
|
462
|
-
const { profile: e, custom_url: i } = t, { data:
|
|
463
|
-
(
|
|
462
|
+
async function ft(r, t) {
|
|
463
|
+
const { profile: e, custom_url: i } = t, { data: n, error: s } = await a(
|
|
464
|
+
(o) => r.POST("/account/profile", {
|
|
464
465
|
params: {
|
|
465
466
|
query: {
|
|
466
467
|
profile: e,
|
|
467
468
|
custom_url: i
|
|
468
469
|
}
|
|
469
470
|
},
|
|
470
|
-
signal:
|
|
471
|
+
signal: o
|
|
471
472
|
}),
|
|
472
473
|
t.timeout
|
|
473
474
|
);
|
|
474
|
-
if (
|
|
475
|
-
throw
|
|
476
|
-
return
|
|
475
|
+
if (s)
|
|
476
|
+
throw s;
|
|
477
|
+
return n;
|
|
477
478
|
}
|
|
478
|
-
async function
|
|
479
|
-
const { data: e, error: i } = await
|
|
479
|
+
async function wt(r, t) {
|
|
480
|
+
const { data: e, error: i } = await a((n) => r.DELETE("/account", { signal: n }), t == null ? void 0 : t.timeout);
|
|
480
481
|
if (i)
|
|
481
482
|
throw i;
|
|
482
483
|
return e;
|
|
483
484
|
}
|
|
484
|
-
async function
|
|
485
|
-
const { data: e, error: i } = await
|
|
485
|
+
async function yt(r, t) {
|
|
486
|
+
const { data: e, error: i } = await a((n) => r.POST("/account/link", { signal: n }), t == null ? void 0 : t.timeout);
|
|
486
487
|
if (i)
|
|
487
488
|
throw i;
|
|
488
489
|
return e;
|
|
489
490
|
}
|
|
490
|
-
class
|
|
491
|
+
class pt {
|
|
491
492
|
/**
|
|
492
493
|
* Get account info.
|
|
493
494
|
*
|
|
@@ -496,7 +497,7 @@ class ot {
|
|
|
496
497
|
* @returns {Promise<AccountInfo>} A promise that resolves to the account information.
|
|
497
498
|
*/
|
|
498
499
|
async AccountInfoGet(t) {
|
|
499
|
-
return await
|
|
500
|
+
return await lt(this.apiClient, t);
|
|
500
501
|
}
|
|
501
502
|
/**
|
|
502
503
|
* Get account state.
|
|
@@ -506,7 +507,7 @@ class ot {
|
|
|
506
507
|
* @returns {Promise<AccountStatus>} A promise that resolves to the account state.
|
|
507
508
|
*/
|
|
508
509
|
async AccountStateGet(t) {
|
|
509
|
-
return await
|
|
510
|
+
return await ht(this.apiClient, t);
|
|
510
511
|
}
|
|
511
512
|
/**
|
|
512
513
|
* Get account profile.
|
|
@@ -516,7 +517,7 @@ class ot {
|
|
|
516
517
|
* @returns {Promise<AccountProfile>} A promise that resolves to the account profile.
|
|
517
518
|
*/
|
|
518
519
|
async AccountProfileGet(t) {
|
|
519
|
-
return await
|
|
520
|
+
return await dt(this.apiClient, t);
|
|
520
521
|
}
|
|
521
522
|
/**
|
|
522
523
|
* Set account profile.
|
|
@@ -528,7 +529,7 @@ class ot {
|
|
|
528
529
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
529
530
|
*/
|
|
530
531
|
async AccountProfileSet(t) {
|
|
531
|
-
return await
|
|
532
|
+
return await ft(this.apiClient, t);
|
|
532
533
|
}
|
|
533
534
|
/**
|
|
534
535
|
* Unlink device from account. Removes association with the current account.
|
|
@@ -538,7 +539,7 @@ class ot {
|
|
|
538
539
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful unlinking.
|
|
539
540
|
*/
|
|
540
541
|
async AccountUnlink(t) {
|
|
541
|
-
return await
|
|
542
|
+
return await wt(this.apiClient, t);
|
|
542
543
|
}
|
|
543
544
|
/**
|
|
544
545
|
* Link device to account. Requests account link PIN. Works only if device is connected to MQTT and is not linked to account.
|
|
@@ -548,34 +549,34 @@ class ot {
|
|
|
548
549
|
* @returns {Promise<AccountLink>} A promise that resolves to the link information (e.g., PIN).
|
|
549
550
|
*/
|
|
550
551
|
async AccountLink(t) {
|
|
551
|
-
return await
|
|
552
|
+
return await yt(this.apiClient, t);
|
|
552
553
|
}
|
|
553
554
|
}
|
|
554
|
-
async function
|
|
555
|
-
const { application_name: e, elements: i, priority:
|
|
556
|
-
(
|
|
555
|
+
async function mt(r, t) {
|
|
556
|
+
const { application_name: e, elements: i, priority: n = 50, timeout: s } = t, { data: o, error: h } = await a(
|
|
557
|
+
(c) => r.POST("/display/draw", {
|
|
557
558
|
body: {
|
|
558
559
|
application_name: e,
|
|
559
|
-
priority:
|
|
560
|
+
priority: n,
|
|
560
561
|
elements: i
|
|
561
562
|
},
|
|
562
|
-
signal:
|
|
563
|
+
signal: c
|
|
563
564
|
}),
|
|
564
|
-
|
|
565
|
+
s
|
|
565
566
|
);
|
|
566
|
-
if (
|
|
567
|
-
throw
|
|
568
|
-
return
|
|
567
|
+
if (h)
|
|
568
|
+
throw h;
|
|
569
|
+
return o;
|
|
569
570
|
}
|
|
570
|
-
async function
|
|
571
|
-
const { data: e, error: i } = await
|
|
572
|
-
(
|
|
571
|
+
async function Tt(r, t) {
|
|
572
|
+
const { data: e, error: i } = await a(
|
|
573
|
+
(n) => r.DELETE("/display/draw", {
|
|
573
574
|
params: {
|
|
574
575
|
query: {
|
|
575
576
|
application_name: t == null ? void 0 : t.application_name
|
|
576
577
|
}
|
|
577
578
|
},
|
|
578
|
-
signal:
|
|
579
|
+
signal: n
|
|
579
580
|
}),
|
|
580
581
|
t == null ? void 0 : t.timeout
|
|
581
582
|
);
|
|
@@ -583,53 +584,53 @@ async function at(n, t) {
|
|
|
583
584
|
throw i;
|
|
584
585
|
return e;
|
|
585
586
|
}
|
|
586
|
-
async function
|
|
587
|
-
const { display: e, timeout: i } = t, { data:
|
|
588
|
-
(
|
|
587
|
+
async function Et(r, t) {
|
|
588
|
+
const { display: e, timeout: i } = t, { data: n, error: s } = await a(
|
|
589
|
+
(o) => r.GET("/screen", {
|
|
589
590
|
params: {
|
|
590
591
|
query: {
|
|
591
592
|
display: e
|
|
592
593
|
}
|
|
593
594
|
},
|
|
594
595
|
parseAs: "blob",
|
|
595
|
-
signal:
|
|
596
|
+
signal: o
|
|
596
597
|
}),
|
|
597
598
|
i
|
|
598
599
|
);
|
|
599
|
-
if (
|
|
600
|
-
throw
|
|
601
|
-
return
|
|
600
|
+
if (s)
|
|
601
|
+
throw s;
|
|
602
|
+
return n;
|
|
602
603
|
}
|
|
603
|
-
async function
|
|
604
|
-
const { data: e, error: i } = await
|
|
604
|
+
async function St(r, t) {
|
|
605
|
+
const { data: e, error: i } = await a((n) => r.GET("/display/brightness", { signal: n }), t == null ? void 0 : t.timeout);
|
|
605
606
|
if (i)
|
|
606
607
|
throw i;
|
|
607
608
|
return e;
|
|
608
609
|
}
|
|
609
|
-
async function
|
|
610
|
-
const { value: e } = t,
|
|
611
|
-
if (typeof
|
|
612
|
-
if (
|
|
610
|
+
async function Ct(r, t) {
|
|
611
|
+
const { value: e } = t, n = ((h) => {
|
|
612
|
+
if (typeof h == "number") {
|
|
613
|
+
if (h < 0 || h > 100)
|
|
613
614
|
throw new Error("Brightness value must be between 0 and 100 or 'auto'");
|
|
614
|
-
return String(
|
|
615
|
+
return String(h);
|
|
615
616
|
}
|
|
616
617
|
return "auto";
|
|
617
|
-
})(e), { data:
|
|
618
|
-
(
|
|
618
|
+
})(e), { data: s, error: o } = await a(
|
|
619
|
+
(h) => r.POST("/display/brightness", {
|
|
619
620
|
params: {
|
|
620
621
|
query: {
|
|
621
|
-
value:
|
|
622
|
+
value: n
|
|
622
623
|
}
|
|
623
624
|
},
|
|
624
|
-
signal:
|
|
625
|
+
signal: h
|
|
625
626
|
}),
|
|
626
627
|
t.timeout
|
|
627
628
|
);
|
|
628
|
-
if (
|
|
629
|
-
throw
|
|
630
|
-
return
|
|
629
|
+
if (o)
|
|
630
|
+
throw o;
|
|
631
|
+
return s;
|
|
631
632
|
}
|
|
632
|
-
class
|
|
633
|
+
class kt {
|
|
633
634
|
/**
|
|
634
635
|
* Draw on display. Sends drawing data to the display. Supports JSON-defined display elements.
|
|
635
636
|
*
|
|
@@ -641,7 +642,7 @@ class dt {
|
|
|
641
642
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful draw command.
|
|
642
643
|
*/
|
|
643
644
|
async DisplayDraw(t) {
|
|
644
|
-
return await
|
|
645
|
+
return await mt(this.apiClient, t);
|
|
645
646
|
}
|
|
646
647
|
/**
|
|
647
648
|
* Clear display. Deletes display elements drawn by the Canvas application.
|
|
@@ -653,7 +654,7 @@ class dt {
|
|
|
653
654
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful clear command.
|
|
654
655
|
*/
|
|
655
656
|
async DisplayClear(t) {
|
|
656
|
-
return await
|
|
657
|
+
return await Tt(this.apiClient, t);
|
|
657
658
|
}
|
|
658
659
|
/**
|
|
659
660
|
* Get single frame for requested screen.
|
|
@@ -664,7 +665,7 @@ class dt {
|
|
|
664
665
|
* @returns {Promise<Blob>} A promise that resolves to the screen frame as a Blob.
|
|
665
666
|
*/
|
|
666
667
|
async DisplayScreenFrameGet(t) {
|
|
667
|
-
return await
|
|
668
|
+
return await Et(this.apiClient, t);
|
|
668
669
|
}
|
|
669
670
|
/**
|
|
670
671
|
* Get display brightness.
|
|
@@ -674,7 +675,7 @@ class dt {
|
|
|
674
675
|
* @returns {Promise<DisplayBrightnessInfo>} A promise that resolves to the brightness information.
|
|
675
676
|
*/
|
|
676
677
|
async DisplayBrightnessGet(t) {
|
|
677
|
-
return await
|
|
678
|
+
return await St(this.apiClient, t);
|
|
678
679
|
}
|
|
679
680
|
/**
|
|
680
681
|
* Set display brightness.
|
|
@@ -685,58 +686,58 @@ class dt {
|
|
|
685
686
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
686
687
|
*/
|
|
687
688
|
async DisplayBrightnessSet(t) {
|
|
688
|
-
return await
|
|
689
|
+
return await Ct(this.apiClient, t);
|
|
689
690
|
}
|
|
690
691
|
}
|
|
691
|
-
async function
|
|
692
|
-
const { application_name: e, path: i } = t, { data:
|
|
693
|
-
(
|
|
692
|
+
async function gt(r, t) {
|
|
693
|
+
const { application_name: e, path: i } = t, { data: n, error: s } = await a(
|
|
694
|
+
(o) => r.POST("/audio/play", {
|
|
694
695
|
params: {
|
|
695
696
|
query: {
|
|
696
697
|
application_name: e,
|
|
697
698
|
path: i
|
|
698
699
|
}
|
|
699
700
|
},
|
|
700
|
-
signal:
|
|
701
|
+
signal: o
|
|
701
702
|
}),
|
|
702
703
|
t.timeout
|
|
703
704
|
);
|
|
704
|
-
if (
|
|
705
|
-
throw
|
|
706
|
-
return
|
|
705
|
+
if (s)
|
|
706
|
+
throw s;
|
|
707
|
+
return n;
|
|
707
708
|
}
|
|
708
|
-
async function
|
|
709
|
-
const { data: e, error: i } = await
|
|
709
|
+
async function At(r, t) {
|
|
710
|
+
const { data: e, error: i } = await a((n) => r.DELETE("/audio/play", { signal: n }), t == null ? void 0 : t.timeout);
|
|
710
711
|
if (i)
|
|
711
712
|
throw i;
|
|
712
713
|
return e;
|
|
713
714
|
}
|
|
714
|
-
async function
|
|
715
|
-
const { data: e, error: i } = await
|
|
715
|
+
async function bt(r, t) {
|
|
716
|
+
const { data: e, error: i } = await a((n) => r.GET("/audio/volume", { signal: n }), t == null ? void 0 : t.timeout);
|
|
716
717
|
if (i)
|
|
717
718
|
throw i;
|
|
718
719
|
return e;
|
|
719
720
|
}
|
|
720
|
-
async function
|
|
721
|
+
async function _t(r, t) {
|
|
721
722
|
const { volume: e } = t;
|
|
722
723
|
if (typeof e != "number" || e < 0 || e > 100)
|
|
723
724
|
throw new Error("Volume must be a number between 0 and 100");
|
|
724
|
-
const { data: i, error:
|
|
725
|
-
(
|
|
725
|
+
const { data: i, error: n } = await a(
|
|
726
|
+
(s) => r.POST("/audio/volume", {
|
|
726
727
|
params: {
|
|
727
728
|
query: {
|
|
728
729
|
volume: e
|
|
729
730
|
}
|
|
730
731
|
},
|
|
731
|
-
signal:
|
|
732
|
+
signal: s
|
|
732
733
|
}),
|
|
733
734
|
t.timeout
|
|
734
735
|
);
|
|
735
|
-
if (
|
|
736
|
-
throw
|
|
736
|
+
if (n)
|
|
737
|
+
throw n;
|
|
737
738
|
return i;
|
|
738
739
|
}
|
|
739
|
-
class
|
|
740
|
+
class Rt {
|
|
740
741
|
/**
|
|
741
742
|
* Play audio file. Plays a file from internal storage.
|
|
742
743
|
*
|
|
@@ -747,7 +748,7 @@ class pt {
|
|
|
747
748
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful play command.
|
|
748
749
|
*/
|
|
749
750
|
async AudioPlay(t) {
|
|
750
|
-
return await
|
|
751
|
+
return await gt(this.apiClient, t);
|
|
751
752
|
}
|
|
752
753
|
/**
|
|
753
754
|
* Stop audio playback. Stops any currently playing audio.
|
|
@@ -757,7 +758,7 @@ class pt {
|
|
|
757
758
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful stop command.
|
|
758
759
|
*/
|
|
759
760
|
async AudioStop(t) {
|
|
760
|
-
return await
|
|
761
|
+
return await At(this.apiClient, t);
|
|
761
762
|
}
|
|
762
763
|
/**
|
|
763
764
|
* Get audio volume.
|
|
@@ -767,7 +768,7 @@ class pt {
|
|
|
767
768
|
* @returns {Promise<AudioVolumeInfo>} A promise that resolves to the audio volume information.
|
|
768
769
|
*/
|
|
769
770
|
async AudioVolumeGet(t) {
|
|
770
|
-
return await
|
|
771
|
+
return await bt(this.apiClient, t);
|
|
771
772
|
}
|
|
772
773
|
/**
|
|
773
774
|
* Set audio volume.
|
|
@@ -778,45 +779,45 @@ class pt {
|
|
|
778
779
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
779
780
|
*/
|
|
780
781
|
async AudioVolumeSet(t) {
|
|
781
|
-
return await
|
|
782
|
+
return await _t(this.apiClient, t);
|
|
782
783
|
}
|
|
783
784
|
}
|
|
784
|
-
async function
|
|
785
|
-
const { data: e, error: i } = await
|
|
785
|
+
async function Dt(r, t) {
|
|
786
|
+
const { data: e, error: i } = await a((n) => r.GET("/wifi/status", { signal: n }), t == null ? void 0 : t.timeout);
|
|
786
787
|
if (i)
|
|
787
788
|
throw i;
|
|
788
789
|
return e;
|
|
789
790
|
}
|
|
790
|
-
async function
|
|
791
|
-
const { ssid: e, password: i, security:
|
|
792
|
-
(
|
|
791
|
+
async function vt(r, t) {
|
|
792
|
+
const { ssid: e, password: i, security: n, ip_config: s } = t, { data: o, error: h } = await a(
|
|
793
|
+
(c) => r.POST("/wifi/connect", {
|
|
793
794
|
body: {
|
|
794
795
|
ssid: e,
|
|
795
796
|
password: i,
|
|
796
|
-
security:
|
|
797
|
-
ip_config:
|
|
797
|
+
security: n,
|
|
798
|
+
ip_config: s
|
|
798
799
|
},
|
|
799
|
-
signal:
|
|
800
|
+
signal: c
|
|
800
801
|
}),
|
|
801
802
|
t.timeout
|
|
802
803
|
);
|
|
803
|
-
if (
|
|
804
|
-
throw
|
|
805
|
-
return
|
|
804
|
+
if (h)
|
|
805
|
+
throw h;
|
|
806
|
+
return o;
|
|
806
807
|
}
|
|
807
|
-
async function
|
|
808
|
-
const { data: e, error: i } = await
|
|
808
|
+
async function Pt(r, t) {
|
|
809
|
+
const { data: e, error: i } = await a((n) => r.POST("/wifi/disconnect", { signal: n }), t == null ? void 0 : t.timeout);
|
|
809
810
|
if (i)
|
|
810
811
|
throw i;
|
|
811
812
|
return e;
|
|
812
813
|
}
|
|
813
|
-
async function
|
|
814
|
-
const { data: e, error: i } = await
|
|
814
|
+
async function Ot(r, t) {
|
|
815
|
+
const { data: e, error: i } = await a((n) => r.GET("/wifi/networks", { signal: n }), t == null ? void 0 : t.timeout);
|
|
815
816
|
if (i)
|
|
816
817
|
throw i;
|
|
817
818
|
return e;
|
|
818
819
|
}
|
|
819
|
-
class
|
|
820
|
+
class Ut {
|
|
820
821
|
/**
|
|
821
822
|
* Returns current Wi-Fi status.
|
|
822
823
|
*
|
|
@@ -825,7 +826,7 @@ class Ct {
|
|
|
825
826
|
* @returns {Promise<WifiStatusResponse>} A promise that resolves to the Wi-Fi status.
|
|
826
827
|
*/
|
|
827
828
|
async WifiStatusGet(t) {
|
|
828
|
-
return await
|
|
829
|
+
return await Dt(this.apiClient, t);
|
|
829
830
|
}
|
|
830
831
|
/**
|
|
831
832
|
* Connects to Wi-Fi network.
|
|
@@ -839,7 +840,7 @@ class Ct {
|
|
|
839
840
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful connection initiation.
|
|
840
841
|
*/
|
|
841
842
|
async WifiConnect(t) {
|
|
842
|
-
return await
|
|
843
|
+
return await vt(this.apiClient, t);
|
|
843
844
|
}
|
|
844
845
|
/**
|
|
845
846
|
* Disconnects from Wi-Fi.
|
|
@@ -849,7 +850,7 @@ class Ct {
|
|
|
849
850
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful disconnection.
|
|
850
851
|
*/
|
|
851
852
|
async WifiDisconnect(t) {
|
|
852
|
-
return await
|
|
853
|
+
return await Pt(this.apiClient, t);
|
|
853
854
|
}
|
|
854
855
|
/**
|
|
855
856
|
* Scans environment for available Wi-Fi networks.
|
|
@@ -859,12 +860,12 @@ class Ct {
|
|
|
859
860
|
* @returns {Promise<WifiNetworkResponse>} A promise that resolves to a list of available networks.
|
|
860
861
|
*/
|
|
861
862
|
async WifiNetworksGet(t) {
|
|
862
|
-
return await
|
|
863
|
+
return await Ot(this.apiClient, t);
|
|
863
864
|
}
|
|
864
865
|
}
|
|
865
|
-
async function
|
|
866
|
-
const { path: e, file: i } = t, { data:
|
|
867
|
-
(
|
|
866
|
+
async function It(r, t) {
|
|
867
|
+
const { path: e, file: i } = t, { data: n, error: s } = await a(
|
|
868
|
+
(o) => r.POST("/storage/write", {
|
|
868
869
|
params: {
|
|
869
870
|
query: {
|
|
870
871
|
path: e
|
|
@@ -874,103 +875,103 @@ async function kt(n, t) {
|
|
|
874
875
|
"Content-Type": "application/octet-stream"
|
|
875
876
|
},
|
|
876
877
|
body: i,
|
|
877
|
-
signal:
|
|
878
|
+
signal: o
|
|
878
879
|
}),
|
|
879
880
|
t.timeout
|
|
880
881
|
);
|
|
881
|
-
if (
|
|
882
|
-
throw
|
|
883
|
-
return
|
|
882
|
+
if (s)
|
|
883
|
+
throw s;
|
|
884
|
+
return n;
|
|
884
885
|
}
|
|
885
|
-
async function
|
|
886
|
-
const { path: e, as_array_buffer: i } = t, { data:
|
|
887
|
-
(
|
|
886
|
+
async function Lt(r, t) {
|
|
887
|
+
const { path: e, as_array_buffer: i } = t, { data: n, error: s } = await a(
|
|
888
|
+
(o) => r.GET("/storage/read", {
|
|
888
889
|
params: {
|
|
889
890
|
query: {
|
|
890
891
|
path: e
|
|
891
892
|
}
|
|
892
893
|
},
|
|
893
894
|
parseAs: i ? "arrayBuffer" : "blob",
|
|
894
|
-
signal:
|
|
895
|
+
signal: o
|
|
895
896
|
}),
|
|
896
897
|
t.timeout
|
|
897
898
|
);
|
|
898
|
-
if (
|
|
899
|
-
throw
|
|
900
|
-
return
|
|
899
|
+
if (s)
|
|
900
|
+
throw s;
|
|
901
|
+
return n;
|
|
901
902
|
}
|
|
902
|
-
async function
|
|
903
|
-
const { path: e } = t, { data: i, error:
|
|
904
|
-
(
|
|
903
|
+
async function Nt(r, t) {
|
|
904
|
+
const { path: e } = t, { data: i, error: n } = await a(
|
|
905
|
+
(s) => r.GET("/storage/list", {
|
|
905
906
|
params: {
|
|
906
907
|
query: {
|
|
907
908
|
path: e
|
|
908
909
|
}
|
|
909
910
|
},
|
|
910
|
-
signal:
|
|
911
|
+
signal: s
|
|
911
912
|
}),
|
|
912
913
|
t.timeout
|
|
913
914
|
);
|
|
914
|
-
if (
|
|
915
|
-
throw
|
|
915
|
+
if (n)
|
|
916
|
+
throw n;
|
|
916
917
|
return i;
|
|
917
918
|
}
|
|
918
|
-
async function
|
|
919
|
-
const { path: e } = t, { data: i, error:
|
|
920
|
-
(
|
|
919
|
+
async function Gt(r, t) {
|
|
920
|
+
const { path: e } = t, { data: i, error: n } = await a(
|
|
921
|
+
(s) => r.DELETE("/storage/remove", {
|
|
921
922
|
params: {
|
|
922
923
|
query: {
|
|
923
924
|
path: e
|
|
924
925
|
}
|
|
925
926
|
},
|
|
926
|
-
signal:
|
|
927
|
+
signal: s
|
|
927
928
|
}),
|
|
928
929
|
t.timeout
|
|
929
930
|
);
|
|
930
|
-
if (
|
|
931
|
-
throw
|
|
931
|
+
if (n)
|
|
932
|
+
throw n;
|
|
932
933
|
return i;
|
|
933
934
|
}
|
|
934
|
-
async function
|
|
935
|
-
const { path: e } = t, { data: i, error:
|
|
936
|
-
(
|
|
935
|
+
async function xt(r, t) {
|
|
936
|
+
const { path: e } = t, { data: i, error: n } = await a(
|
|
937
|
+
(s) => r.POST("/storage/mkdir", {
|
|
937
938
|
params: {
|
|
938
939
|
query: {
|
|
939
940
|
path: e
|
|
940
941
|
}
|
|
941
942
|
},
|
|
942
|
-
signal:
|
|
943
|
+
signal: s
|
|
943
944
|
}),
|
|
944
945
|
t.timeout
|
|
945
946
|
);
|
|
946
|
-
if (
|
|
947
|
-
throw
|
|
947
|
+
if (n)
|
|
948
|
+
throw n;
|
|
948
949
|
return i;
|
|
949
950
|
}
|
|
950
|
-
async function
|
|
951
|
-
const { data: e, error: i } = await
|
|
951
|
+
async function Bt(r, t) {
|
|
952
|
+
const { data: e, error: i } = await a((n) => r.GET("/storage/status", { signal: n }), t == null ? void 0 : t.timeout);
|
|
952
953
|
if (i)
|
|
953
954
|
throw i;
|
|
954
955
|
return e;
|
|
955
956
|
}
|
|
956
|
-
async function
|
|
957
|
-
const { path: e, new_path: i } = t, { data:
|
|
958
|
-
(
|
|
957
|
+
async function Ft(r, t) {
|
|
958
|
+
const { path: e, new_path: i } = t, { data: n, error: s } = await a(
|
|
959
|
+
(o) => r.POST("/storage/rename", {
|
|
959
960
|
params: {
|
|
960
961
|
query: {
|
|
961
962
|
path: e,
|
|
962
963
|
new_path: i
|
|
963
964
|
}
|
|
964
965
|
},
|
|
965
|
-
signal:
|
|
966
|
+
signal: o
|
|
966
967
|
}),
|
|
967
968
|
t.timeout
|
|
968
969
|
);
|
|
969
|
-
if (
|
|
970
|
-
throw
|
|
971
|
-
return
|
|
970
|
+
if (s)
|
|
971
|
+
throw s;
|
|
972
|
+
return n;
|
|
972
973
|
}
|
|
973
|
-
class
|
|
974
|
+
class Wt {
|
|
974
975
|
/**
|
|
975
976
|
* Upload file to internal storage. Uploads a file to a specified path.
|
|
976
977
|
*
|
|
@@ -981,7 +982,7 @@ class Ot {
|
|
|
981
982
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful upload.
|
|
982
983
|
*/
|
|
983
984
|
async StorageWrite(t) {
|
|
984
|
-
return await
|
|
985
|
+
return await It(this.apiClient, t);
|
|
985
986
|
}
|
|
986
987
|
/**
|
|
987
988
|
* Download file from internal storage. Downloads a file from a specified path.
|
|
@@ -993,7 +994,7 @@ class Ot {
|
|
|
993
994
|
* @returns {Promise<StorageReadResponse>} A promise that resolves to the file content (Blob or ArrayBuffer).
|
|
994
995
|
*/
|
|
995
996
|
async StorageRead(t) {
|
|
996
|
-
return await
|
|
997
|
+
return await Lt(this.apiClient, t);
|
|
997
998
|
}
|
|
998
999
|
/**
|
|
999
1000
|
* List files on internal storage.
|
|
@@ -1004,7 +1005,7 @@ class Ot {
|
|
|
1004
1005
|
* @returns {Promise<StorageList>} A promise that resolves to a list of files and directories.
|
|
1005
1006
|
*/
|
|
1006
1007
|
async StorageListGet(t) {
|
|
1007
|
-
return await
|
|
1008
|
+
return await Nt(this.apiClient, t);
|
|
1008
1009
|
}
|
|
1009
1010
|
/**
|
|
1010
1011
|
* Remove a file on internal storage. Removes a file with a specified path.
|
|
@@ -1015,7 +1016,7 @@ class Ot {
|
|
|
1015
1016
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful removal.
|
|
1016
1017
|
*/
|
|
1017
1018
|
async StorageRemove(t) {
|
|
1018
|
-
return await
|
|
1019
|
+
return await Gt(this.apiClient, t);
|
|
1019
1020
|
}
|
|
1020
1021
|
/**
|
|
1021
1022
|
* Create a directory on internal storage. Creates a new directory with a specified path.
|
|
@@ -1026,7 +1027,7 @@ class Ot {
|
|
|
1026
1027
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful creation.
|
|
1027
1028
|
*/
|
|
1028
1029
|
async StorageMkdir(t) {
|
|
1029
|
-
return await
|
|
1030
|
+
return await xt(this.apiClient, t);
|
|
1030
1031
|
}
|
|
1031
1032
|
/**
|
|
1032
1033
|
* Show storage usage.
|
|
@@ -1036,7 +1037,7 @@ class Ot {
|
|
|
1036
1037
|
* @returns {Promise<StorageStatus>} A promise that resolves to the storage status.
|
|
1037
1038
|
*/
|
|
1038
1039
|
async StorageStatusGet(t) {
|
|
1039
|
-
return await
|
|
1040
|
+
return await Bt(this.apiClient, t);
|
|
1040
1041
|
}
|
|
1041
1042
|
/**
|
|
1042
1043
|
* Rename/move a file. Moves a file to a new location.
|
|
@@ -1048,54 +1049,54 @@ class Ot {
|
|
|
1048
1049
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful rename.
|
|
1049
1050
|
*/
|
|
1050
1051
|
async StorageRename(t) {
|
|
1051
|
-
return await
|
|
1052
|
+
return await Ft(this.apiClient, t);
|
|
1052
1053
|
}
|
|
1053
1054
|
}
|
|
1054
|
-
async function
|
|
1055
|
-
const { data: e, error: i } = await
|
|
1055
|
+
async function Mt(r, t) {
|
|
1056
|
+
const { data: e, error: i } = await a((n) => r.GET("/access", { signal: n }), t == null ? void 0 : t.timeout);
|
|
1056
1057
|
if (i)
|
|
1057
1058
|
throw i;
|
|
1058
1059
|
return e;
|
|
1059
1060
|
}
|
|
1060
|
-
async function
|
|
1061
|
-
const { mode: e, key: i } = t,
|
|
1062
|
-
if (String(
|
|
1061
|
+
async function $t(r, t) {
|
|
1062
|
+
const { mode: e, key: i } = t, n = i ?? "";
|
|
1063
|
+
if (String(n).trim() && !/^\d{4,10}$/.test(String(n)))
|
|
1063
1064
|
throw new Error("Key must be a string of 4 to 10 digits");
|
|
1064
|
-
const { data:
|
|
1065
|
-
(
|
|
1065
|
+
const { data: s, error: o } = await a(
|
|
1066
|
+
(h) => r.POST("/access", {
|
|
1066
1067
|
params: {
|
|
1067
1068
|
query: {
|
|
1068
1069
|
mode: e,
|
|
1069
|
-
key:
|
|
1070
|
+
key: n
|
|
1070
1071
|
}
|
|
1071
1072
|
},
|
|
1072
|
-
signal:
|
|
1073
|
+
signal: h
|
|
1073
1074
|
}),
|
|
1074
1075
|
t.timeout
|
|
1075
1076
|
);
|
|
1076
|
-
if (
|
|
1077
|
-
throw
|
|
1078
|
-
return
|
|
1077
|
+
if (o)
|
|
1078
|
+
throw o;
|
|
1079
|
+
return s;
|
|
1079
1080
|
}
|
|
1080
|
-
async function
|
|
1081
|
-
const { data: e, error: i } = await
|
|
1081
|
+
async function Kt(r, t) {
|
|
1082
|
+
const { data: e, error: i } = await a((n) => r.GET("/name", { signal: n }), t == null ? void 0 : t.timeout);
|
|
1082
1083
|
if (i)
|
|
1083
1084
|
throw i;
|
|
1084
1085
|
return e;
|
|
1085
1086
|
}
|
|
1086
|
-
async function
|
|
1087
|
-
const { name: e } = t, { data: i, error:
|
|
1088
|
-
(
|
|
1087
|
+
async function zt(r, t) {
|
|
1088
|
+
const { name: e } = t, { data: i, error: n } = await a(
|
|
1089
|
+
(s) => r.POST("/name", {
|
|
1089
1090
|
body: { name: e },
|
|
1090
|
-
signal:
|
|
1091
|
+
signal: s
|
|
1091
1092
|
}),
|
|
1092
1093
|
t.timeout
|
|
1093
1094
|
);
|
|
1094
|
-
if (
|
|
1095
|
-
throw
|
|
1095
|
+
if (n)
|
|
1096
|
+
throw n;
|
|
1096
1097
|
return i;
|
|
1097
1098
|
}
|
|
1098
|
-
class
|
|
1099
|
+
class Ht {
|
|
1099
1100
|
/**
|
|
1100
1101
|
* Get HTTP API access over Wi-Fi configuration.
|
|
1101
1102
|
*
|
|
@@ -1104,7 +1105,7 @@ class _t {
|
|
|
1104
1105
|
* @returns {Promise<HttpAccessInfo>} A promise that resolves to the access configuration.
|
|
1105
1106
|
*/
|
|
1106
1107
|
async SettingsAccessGet(t) {
|
|
1107
|
-
return await
|
|
1108
|
+
return await Mt(this.apiClient, t);
|
|
1108
1109
|
}
|
|
1109
1110
|
/**
|
|
1110
1111
|
* Set HTTP API access over Wi-Fi configuration.
|
|
@@ -1116,7 +1117,7 @@ class _t {
|
|
|
1116
1117
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1117
1118
|
*/
|
|
1118
1119
|
async SettingsAccessSet(t) {
|
|
1119
|
-
const e = await
|
|
1120
|
+
const e = await $t(this.apiClient, t);
|
|
1120
1121
|
return t.mode === "key" && t.key && this.setApiKey(t.key), e;
|
|
1121
1122
|
}
|
|
1122
1123
|
/**
|
|
@@ -1127,7 +1128,7 @@ class _t {
|
|
|
1127
1128
|
* @returns {Promise<NameInfo>} A promise that resolves to the device name.
|
|
1128
1129
|
*/
|
|
1129
1130
|
async SettingsNameGet(t) {
|
|
1130
|
-
return await
|
|
1131
|
+
return await Kt(this.apiClient, t);
|
|
1131
1132
|
}
|
|
1132
1133
|
/**
|
|
1133
1134
|
* Set device name.
|
|
@@ -1138,34 +1139,34 @@ class _t {
|
|
|
1138
1139
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1139
1140
|
*/
|
|
1140
1141
|
async SettingsNameSet(t) {
|
|
1141
|
-
return await
|
|
1142
|
+
return await zt(this.apiClient, t);
|
|
1142
1143
|
}
|
|
1143
1144
|
}
|
|
1144
|
-
async function
|
|
1145
|
-
const { data: e, error: i } = await
|
|
1145
|
+
async function qt(r, t) {
|
|
1146
|
+
const { data: e, error: i } = await a((n) => r.POST("/ble/enable", { signal: n }), t == null ? void 0 : t.timeout);
|
|
1146
1147
|
if (i)
|
|
1147
1148
|
throw i;
|
|
1148
1149
|
return e;
|
|
1149
1150
|
}
|
|
1150
|
-
async function
|
|
1151
|
-
const { data: e, error: i } = await
|
|
1151
|
+
async function Vt(r, t) {
|
|
1152
|
+
const { data: e, error: i } = await a((n) => r.POST("/ble/disable", { signal: n }), t == null ? void 0 : t.timeout);
|
|
1152
1153
|
if (i)
|
|
1153
1154
|
throw i;
|
|
1154
1155
|
return e;
|
|
1155
1156
|
}
|
|
1156
|
-
async function
|
|
1157
|
-
const { data: e, error: i } = await
|
|
1157
|
+
async function Xt(r, t) {
|
|
1158
|
+
const { data: e, error: i } = await a((n) => r.DELETE("/ble/pairing", { signal: n }), t == null ? void 0 : t.timeout);
|
|
1158
1159
|
if (i)
|
|
1159
1160
|
throw i;
|
|
1160
1161
|
return e;
|
|
1161
1162
|
}
|
|
1162
|
-
async function
|
|
1163
|
-
const { data: e, error: i } = await
|
|
1163
|
+
async function jt(r, t) {
|
|
1164
|
+
const { data: e, error: i } = await a((n) => r.GET("/ble/status", { signal: n }), t == null ? void 0 : t.timeout);
|
|
1164
1165
|
if (i)
|
|
1165
1166
|
throw i;
|
|
1166
1167
|
return e;
|
|
1167
1168
|
}
|
|
1168
|
-
class
|
|
1169
|
+
class Yt {
|
|
1169
1170
|
/**
|
|
1170
1171
|
* Enable BLE. Starts advertising.
|
|
1171
1172
|
*
|
|
@@ -1174,7 +1175,7 @@ class Ft {
|
|
|
1174
1175
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1175
1176
|
*/
|
|
1176
1177
|
async BleEnable(t) {
|
|
1177
|
-
return await
|
|
1178
|
+
return await qt(this.apiClient, t);
|
|
1178
1179
|
}
|
|
1179
1180
|
/**
|
|
1180
1181
|
* Disable BLE. Stops advertising.
|
|
@@ -1184,7 +1185,7 @@ class Ft {
|
|
|
1184
1185
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1185
1186
|
*/
|
|
1186
1187
|
async BleDisable(t) {
|
|
1187
|
-
return await
|
|
1188
|
+
return await Vt(this.apiClient, t);
|
|
1188
1189
|
}
|
|
1189
1190
|
/**
|
|
1190
1191
|
* Remove pairing. Remove pairing with previous device.
|
|
@@ -1194,7 +1195,7 @@ class Ft {
|
|
|
1194
1195
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1195
1196
|
*/
|
|
1196
1197
|
async BleUnpair(t) {
|
|
1197
|
-
return await
|
|
1198
|
+
return await Xt(this.apiClient, t);
|
|
1198
1199
|
}
|
|
1199
1200
|
/**
|
|
1200
1201
|
* Returns current BLE status.
|
|
@@ -1204,26 +1205,26 @@ class Ft {
|
|
|
1204
1205
|
* @returns {Promise<BleStatusResponse>} A promise that resolves to the BLE status.
|
|
1205
1206
|
*/
|
|
1206
1207
|
async BleStatusGet(t) {
|
|
1207
|
-
return await
|
|
1208
|
+
return await jt(this.apiClient, t);
|
|
1208
1209
|
}
|
|
1209
1210
|
}
|
|
1210
|
-
async function
|
|
1211
|
-
const { key: e } = t, { data: i, error:
|
|
1212
|
-
(
|
|
1211
|
+
async function Jt(r, t) {
|
|
1212
|
+
const { key: e } = t, { data: i, error: n } = await a(
|
|
1213
|
+
(s) => r.POST("/input", {
|
|
1213
1214
|
params: {
|
|
1214
1215
|
query: {
|
|
1215
1216
|
key: e
|
|
1216
1217
|
}
|
|
1217
1218
|
},
|
|
1218
|
-
signal:
|
|
1219
|
+
signal: s
|
|
1219
1220
|
}),
|
|
1220
1221
|
t.timeout
|
|
1221
1222
|
);
|
|
1222
|
-
if (
|
|
1223
|
-
throw
|
|
1223
|
+
if (n)
|
|
1224
|
+
throw n;
|
|
1224
1225
|
return i;
|
|
1225
1226
|
}
|
|
1226
|
-
class
|
|
1227
|
+
class Qt {
|
|
1227
1228
|
/**
|
|
1228
1229
|
* Send input event. Send single key press event.
|
|
1229
1230
|
*
|
|
@@ -1233,40 +1234,40 @@ class Mt {
|
|
|
1233
1234
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1234
1235
|
*/
|
|
1235
1236
|
async InputSend(t) {
|
|
1236
|
-
return await
|
|
1237
|
+
return await Jt(this.apiClient, t);
|
|
1237
1238
|
}
|
|
1238
1239
|
}
|
|
1239
|
-
async function
|
|
1240
|
-
const { data: e, error: i } = await
|
|
1240
|
+
async function Zt(r, t) {
|
|
1241
|
+
const { data: e, error: i } = await a((n) => r.GET("/smart_home/pairing", { signal: n }), t == null ? void 0 : t.timeout);
|
|
1241
1242
|
if (i)
|
|
1242
1243
|
throw i;
|
|
1243
1244
|
return e;
|
|
1244
1245
|
}
|
|
1245
|
-
async function
|
|
1246
|
-
const { data: e, error: i } = await
|
|
1246
|
+
async function te(r, t) {
|
|
1247
|
+
const { data: e, error: i } = await a((n) => r.POST("/smart_home/pairing", { signal: n }), t == null ? void 0 : t.timeout);
|
|
1247
1248
|
if (i)
|
|
1248
1249
|
throw i;
|
|
1249
1250
|
return e;
|
|
1250
1251
|
}
|
|
1251
|
-
async function
|
|
1252
|
-
const { data: e, error: i } = await
|
|
1252
|
+
async function ee(r, t) {
|
|
1253
|
+
const { data: e, error: i } = await a((n) => r.DELETE("/smart_home/pairing", { signal: n }), t == null ? void 0 : t.timeout);
|
|
1253
1254
|
if (i)
|
|
1254
1255
|
throw i;
|
|
1255
1256
|
return e;
|
|
1256
1257
|
}
|
|
1257
|
-
async function
|
|
1258
|
-
const { data: e, error: i } = await
|
|
1258
|
+
async function ie(r, t) {
|
|
1259
|
+
const { data: e, error: i } = await a((n) => r.GET("/smart_home/switch", { signal: n }), t == null ? void 0 : t.timeout);
|
|
1259
1260
|
if (i)
|
|
1260
1261
|
throw i;
|
|
1261
1262
|
return e;
|
|
1262
1263
|
}
|
|
1263
|
-
async function
|
|
1264
|
-
const { timeout: e, ...i } = t, { data:
|
|
1265
|
-
if (
|
|
1266
|
-
throw
|
|
1267
|
-
return
|
|
1264
|
+
async function re(r, t) {
|
|
1265
|
+
const { timeout: e, ...i } = t, { data: n, error: s } = await a((o) => r.POST("/smart_home/switch", { body: i, signal: o }), e);
|
|
1266
|
+
if (s)
|
|
1267
|
+
throw s;
|
|
1268
|
+
return n;
|
|
1268
1269
|
}
|
|
1269
|
-
class
|
|
1270
|
+
class ne {
|
|
1270
1271
|
/**
|
|
1271
1272
|
* Smart home commissioning status.
|
|
1272
1273
|
*
|
|
@@ -1275,7 +1276,7 @@ class jt {
|
|
|
1275
1276
|
* @returns {Promise<SmartHomePairingInfo>} A promise that resolves to the pairing info.
|
|
1276
1277
|
*/
|
|
1277
1278
|
async SmartHomePairingGet(t) {
|
|
1278
|
-
return await
|
|
1279
|
+
return await Zt(this.apiClient, t);
|
|
1279
1280
|
}
|
|
1280
1281
|
/**
|
|
1281
1282
|
* Link device to a smart home.
|
|
@@ -1284,7 +1285,7 @@ class jt {
|
|
|
1284
1285
|
* @returns {Promise<SmartHomePairingPayload>} A promise that resolves to the pairing payload.
|
|
1285
1286
|
*/
|
|
1286
1287
|
async SmartHomePair(t) {
|
|
1287
|
-
return await
|
|
1288
|
+
return await te(this.apiClient, t);
|
|
1288
1289
|
}
|
|
1289
1290
|
/**
|
|
1290
1291
|
* Erase all smart home links.
|
|
@@ -1294,7 +1295,7 @@ class jt {
|
|
|
1294
1295
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1295
1296
|
*/
|
|
1296
1297
|
async SmartHomeErase(t) {
|
|
1297
|
-
return await
|
|
1298
|
+
return await ee(this.apiClient, t);
|
|
1298
1299
|
}
|
|
1299
1300
|
/**
|
|
1300
1301
|
* Get state of emulated smart home switch.
|
|
@@ -1304,7 +1305,7 @@ class jt {
|
|
|
1304
1305
|
* @returns {Promise<SmartHomeSwitchState>} A promise that resolves to the switch state.
|
|
1305
1306
|
*/
|
|
1306
1307
|
async SmartHomeSwitchStateGet(t) {
|
|
1307
|
-
return await
|
|
1308
|
+
return await ie(this.apiClient, t);
|
|
1308
1309
|
}
|
|
1309
1310
|
/**
|
|
1310
1311
|
* Set state of emulated smart home switch.
|
|
@@ -1313,7 +1314,7 @@ class jt {
|
|
|
1313
1314
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1314
1315
|
*/
|
|
1315
1316
|
async SmartHomeSwitchStateSet(t) {
|
|
1316
|
-
return await
|
|
1317
|
+
return await re(this.apiClient, t);
|
|
1317
1318
|
}
|
|
1318
1319
|
// ALIASES for backward compatibility (Matter -> SmartHome)
|
|
1319
1320
|
/**
|
|
@@ -1335,9 +1336,9 @@ class jt {
|
|
|
1335
1336
|
return await this.SmartHomeErase(t);
|
|
1336
1337
|
}
|
|
1337
1338
|
}
|
|
1338
|
-
async function
|
|
1339
|
-
const { application_name: e, file: i, data:
|
|
1340
|
-
(
|
|
1339
|
+
async function se(r, t) {
|
|
1340
|
+
const { application_name: e, file: i, data: n } = t, { data: s, error: o } = await a(
|
|
1341
|
+
(h) => r.POST("/assets/upload", {
|
|
1341
1342
|
params: {
|
|
1342
1343
|
query: {
|
|
1343
1344
|
application_name: e,
|
|
@@ -1347,32 +1348,32 @@ async function zt(n, t) {
|
|
|
1347
1348
|
headers: {
|
|
1348
1349
|
"Content-Type": "application/octet-stream"
|
|
1349
1350
|
},
|
|
1350
|
-
body:
|
|
1351
|
-
signal:
|
|
1351
|
+
body: n,
|
|
1352
|
+
signal: h
|
|
1352
1353
|
}),
|
|
1353
1354
|
t.timeout
|
|
1354
1355
|
);
|
|
1355
|
-
if (
|
|
1356
|
-
throw
|
|
1357
|
-
return
|
|
1356
|
+
if (o)
|
|
1357
|
+
throw o;
|
|
1358
|
+
return s;
|
|
1358
1359
|
}
|
|
1359
|
-
async function
|
|
1360
|
-
const { application_name: e } = t, { data: i, error:
|
|
1361
|
-
(
|
|
1360
|
+
async function ae(r, t) {
|
|
1361
|
+
const { application_name: e } = t, { data: i, error: n } = await a(
|
|
1362
|
+
(s) => r.DELETE("/assets/upload", {
|
|
1362
1363
|
params: {
|
|
1363
1364
|
query: {
|
|
1364
1365
|
application_name: e
|
|
1365
1366
|
}
|
|
1366
1367
|
},
|
|
1367
|
-
signal:
|
|
1368
|
+
signal: s
|
|
1368
1369
|
}),
|
|
1369
1370
|
t.timeout
|
|
1370
1371
|
);
|
|
1371
|
-
if (
|
|
1372
|
-
throw
|
|
1372
|
+
if (n)
|
|
1373
|
+
throw n;
|
|
1373
1374
|
return i;
|
|
1374
1375
|
}
|
|
1375
|
-
class
|
|
1376
|
+
class oe {
|
|
1376
1377
|
/**
|
|
1377
1378
|
* Upload asset file with app ID. Uploads a file to a specific app's assets directory.
|
|
1378
1379
|
*
|
|
@@ -1384,7 +1385,7 @@ class Xt {
|
|
|
1384
1385
|
* @returns {Promise<SuccessResponse>} Result of the upload operation.
|
|
1385
1386
|
*/
|
|
1386
1387
|
async AssetsUpload(t) {
|
|
1387
|
-
return await
|
|
1388
|
+
return await se(this.apiClient, t);
|
|
1388
1389
|
}
|
|
1389
1390
|
/**
|
|
1390
1391
|
* Delete app assets. Deletes all assets for a specific app ID.
|
|
@@ -1395,12 +1396,12 @@ class Xt {
|
|
|
1395
1396
|
* @returns {Promise<SuccessResponse>} Result of the delete operation.
|
|
1396
1397
|
*/
|
|
1397
1398
|
async AssetsDelete(t) {
|
|
1398
|
-
return await
|
|
1399
|
+
return await ae(this.apiClient, t);
|
|
1399
1400
|
}
|
|
1400
1401
|
}
|
|
1401
|
-
const
|
|
1402
|
-
function
|
|
1403
|
-
const t =
|
|
1402
|
+
const D = "http://10.0.4.20", ce = "https://proxy.busy.app", ue = /^https?:\/\/proxy(?:\.(?:dev|test|stage))?\.busy\.app$/i;
|
|
1403
|
+
function v(r) {
|
|
1404
|
+
const t = r.split(".");
|
|
1404
1405
|
if (t.length !== 4)
|
|
1405
1406
|
return !1;
|
|
1406
1407
|
for (const e of t) {
|
|
@@ -1412,10 +1413,10 @@ function m(n) {
|
|
|
1412
1413
|
}
|
|
1413
1414
|
return !0;
|
|
1414
1415
|
}
|
|
1415
|
-
function
|
|
1416
|
-
return /\.local$/i.test(
|
|
1416
|
+
function P(r) {
|
|
1417
|
+
return /\.local$/i.test(r);
|
|
1417
1418
|
}
|
|
1418
|
-
class
|
|
1419
|
+
class he {
|
|
1419
1420
|
/**
|
|
1420
1421
|
* Creates an instance of BUSY Bar.
|
|
1421
1422
|
* Initializes the API client with the provided host address.
|
|
@@ -1464,18 +1465,18 @@ class Zt {
|
|
|
1464
1465
|
*/
|
|
1465
1466
|
u(this, "connectionType", "unknown");
|
|
1466
1467
|
if (!t || !t.addr && !t.token)
|
|
1467
|
-
this.addr =
|
|
1468
|
+
this.addr = D;
|
|
1468
1469
|
else if (!t.addr)
|
|
1469
|
-
this.addr =
|
|
1470
|
+
this.addr = ce;
|
|
1470
1471
|
else {
|
|
1471
|
-
let
|
|
1472
|
-
if (/^https?:\/\//i.test(
|
|
1472
|
+
let s = t.addr.trim();
|
|
1473
|
+
if (/^https?:\/\//i.test(s) || (s = `http://${s}`), ue.test(s) && !t.token)
|
|
1473
1474
|
throw new Error("Token is required. Please provide it.");
|
|
1474
|
-
this.addr =
|
|
1475
|
+
this.addr = s;
|
|
1475
1476
|
}
|
|
1476
1477
|
this.apiSemver = "";
|
|
1477
|
-
const { client: e, setApiKey: i, setToken:
|
|
1478
|
-
this.apiClient = e, this.setApiKeyFn = i, this.setTokenFn =
|
|
1478
|
+
const { client: e, setApiKey: i, setToken: n } = M(`${this.addr}/api/`, this.SystemVersionGet.bind(this), t == null ? void 0 : t.token);
|
|
1479
|
+
this.apiClient = e, this.setApiKeyFn = i, this.setTokenFn = n, this.detectConnectionType();
|
|
1479
1480
|
}
|
|
1480
1481
|
/**
|
|
1481
1482
|
* Probes the device to determine connection type.
|
|
@@ -1483,11 +1484,11 @@ class Zt {
|
|
|
1483
1484
|
*/
|
|
1484
1485
|
async detectConnectionType() {
|
|
1485
1486
|
const t = new URL(this.addr).hostname;
|
|
1486
|
-
if (!
|
|
1487
|
+
if (!v(t) && !P(t)) {
|
|
1487
1488
|
this.connectionType = "wifi";
|
|
1488
1489
|
return;
|
|
1489
1490
|
}
|
|
1490
|
-
const e =
|
|
1491
|
+
const e = O({
|
|
1491
1492
|
baseUrl: `${this.addr}/api/`
|
|
1492
1493
|
});
|
|
1493
1494
|
try {
|
|
@@ -1517,69 +1518,69 @@ class Zt {
|
|
|
1517
1518
|
this.setTokenFn(t);
|
|
1518
1519
|
}
|
|
1519
1520
|
}
|
|
1520
|
-
function
|
|
1521
|
+
function le(r, t) {
|
|
1521
1522
|
t.forEach((e) => {
|
|
1522
1523
|
Object.getOwnPropertyNames(e.prototype).forEach((i) => {
|
|
1523
|
-
Object.defineProperty(
|
|
1524
|
+
Object.defineProperty(r.prototype, i, Object.getOwnPropertyDescriptor(e.prototype, i) || /* @__PURE__ */ Object.create(null));
|
|
1524
1525
|
});
|
|
1525
1526
|
});
|
|
1526
1527
|
}
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
ot,
|
|
1532
|
-
dt,
|
|
1528
|
+
le(he, [
|
|
1529
|
+
X,
|
|
1530
|
+
rt,
|
|
1531
|
+
ut,
|
|
1533
1532
|
pt,
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1533
|
+
kt,
|
|
1534
|
+
Rt,
|
|
1535
|
+
Ut,
|
|
1536
|
+
Wt,
|
|
1537
|
+
Ht,
|
|
1538
|
+
Yt,
|
|
1539
|
+
Qt,
|
|
1540
|
+
ne,
|
|
1541
|
+
oe
|
|
1541
1542
|
]);
|
|
1542
|
-
var
|
|
1543
|
-
const
|
|
1544
|
-
function
|
|
1545
|
-
if (t < 0 || t >=
|
|
1546
|
-
throw new Error(`Index ${t} is out of bounds (0…${
|
|
1547
|
-
const e =
|
|
1543
|
+
var _ = /* @__PURE__ */ ((r) => (r[r.FRONT = 0] = "FRONT", r[r.BACK = 1] = "BACK", r))(_ || {});
|
|
1544
|
+
const U = 3e3, I = /* @__PURE__ */ new Set([1001, 1006, 1012, 1013, 1014, 3008]);
|
|
1545
|
+
function L(r, t) {
|
|
1546
|
+
if (t < 0 || t >= r.length)
|
|
1547
|
+
throw new Error(`Index ${t} is out of bounds (0…${r.length - 1})`);
|
|
1548
|
+
const e = r[t];
|
|
1548
1549
|
if (e === void 0)
|
|
1549
1550
|
throw new Error(`Unexpected undefined at index ${t}`);
|
|
1550
1551
|
return e;
|
|
1551
1552
|
}
|
|
1552
|
-
function
|
|
1553
|
+
function de(r, t) {
|
|
1553
1554
|
let e = 0;
|
|
1554
|
-
const i =
|
|
1555
|
+
const i = r.length, n = [];
|
|
1555
1556
|
for (; e < i; ) {
|
|
1556
|
-
const
|
|
1557
|
-
if (e += 1, (
|
|
1558
|
-
const
|
|
1559
|
-
for (let
|
|
1560
|
-
|
|
1561
|
-
e +=
|
|
1557
|
+
const s = L(r, e);
|
|
1558
|
+
if (e += 1, (s & 128) !== 0) {
|
|
1559
|
+
const o = s & 127;
|
|
1560
|
+
for (let h = 0; h < o * t; h++)
|
|
1561
|
+
n.push(r[e + h]);
|
|
1562
|
+
e += o * t;
|
|
1562
1563
|
} else {
|
|
1563
|
-
const
|
|
1564
|
-
for (let
|
|
1565
|
-
for (let
|
|
1566
|
-
|
|
1564
|
+
const o = s, h = r.slice(e, e + t);
|
|
1565
|
+
for (let c = 0; c < o; c++)
|
|
1566
|
+
for (let p = 0; p < t; p++)
|
|
1567
|
+
n.push(h[p]);
|
|
1567
1568
|
e += t;
|
|
1568
1569
|
}
|
|
1569
1570
|
}
|
|
1570
|
-
return new Uint8Array(
|
|
1571
|
+
return new Uint8Array(n);
|
|
1571
1572
|
}
|
|
1572
|
-
function
|
|
1573
|
-
const t = new Uint8Array(
|
|
1573
|
+
function fe(r) {
|
|
1574
|
+
const t = new Uint8Array(r.length * 2);
|
|
1574
1575
|
let e = 0, i = 0;
|
|
1575
|
-
for (; e <
|
|
1576
|
-
const
|
|
1577
|
-
t[i] =
|
|
1576
|
+
for (; e < r.length; ) {
|
|
1577
|
+
const n = L(r, e), s = n & 15, o = n >> 4 & 15;
|
|
1578
|
+
t[i] = s, t[i + 1] = o, e += 1, i += 2;
|
|
1578
1579
|
}
|
|
1579
1580
|
return t;
|
|
1580
1581
|
}
|
|
1581
|
-
const
|
|
1582
|
-
class
|
|
1582
|
+
const N = () => typeof window < "u" && typeof window.document < "u";
|
|
1583
|
+
class me {
|
|
1583
1584
|
constructor(t) {
|
|
1584
1585
|
u(this, "addr");
|
|
1585
1586
|
u(this, "connected", !1);
|
|
@@ -1591,16 +1592,16 @@ class oe {
|
|
|
1591
1592
|
u(this, "stopListeners", []);
|
|
1592
1593
|
u(this, "errorListeners", []);
|
|
1593
1594
|
u(this, "socket", null);
|
|
1594
|
-
if (this.config = t, !
|
|
1595
|
+
if (this.config = t, !N())
|
|
1595
1596
|
throw new Error("not browser");
|
|
1596
1597
|
if (t.apiKey && (this.apiKey = t.apiKey), t.apiSemver && (this.apiSemver = t.apiSemver), !t || !t.addr)
|
|
1597
|
-
this.addr =
|
|
1598
|
+
this.addr = D;
|
|
1598
1599
|
else {
|
|
1599
1600
|
let e = t.addr.trim();
|
|
1600
1601
|
/^https?:\/\//i.test(e) || (e = `http://${e}`);
|
|
1601
1602
|
try {
|
|
1602
|
-
const
|
|
1603
|
-
if (!
|
|
1603
|
+
const n = new URL(e).hostname;
|
|
1604
|
+
if (!v(n) && !P(n))
|
|
1604
1605
|
throw new Error(`Invalid address: "${t.addr}". Only IP addresses and mDNS names (ending in .local) are supported.`);
|
|
1605
1606
|
} catch (i) {
|
|
1606
1607
|
throw i instanceof Error && i.message.startsWith("Invalid address") ? i : new Error(`Invalid URL format: "${t.addr}"`);
|
|
@@ -1641,11 +1642,11 @@ class oe {
|
|
|
1641
1642
|
if (typeof e.data == "string")
|
|
1642
1643
|
return;
|
|
1643
1644
|
const i = new Uint8Array(e.data);
|
|
1644
|
-
let
|
|
1645
|
-
const
|
|
1645
|
+
let n;
|
|
1646
|
+
const s = this.config.deviceScreen === _.FRONT ? 3 : 2;
|
|
1646
1647
|
try {
|
|
1647
|
-
const
|
|
1648
|
-
this.config.deviceScreen ===
|
|
1648
|
+
const o = de(i, s);
|
|
1649
|
+
this.config.deviceScreen === _.BACK ? n = fe(o) : n = o, this.emitData(n);
|
|
1649
1650
|
} catch {
|
|
1650
1651
|
this.emitData(i);
|
|
1651
1652
|
}
|
|
@@ -1660,7 +1661,7 @@ class oe {
|
|
|
1660
1661
|
raw: e
|
|
1661
1662
|
}), this.emitStop();
|
|
1662
1663
|
}, this.socket.onclose = async (e) => {
|
|
1663
|
-
if (this.socket = null, this.connected = !1, e.code ===
|
|
1664
|
+
if (this.socket = null, this.connected = !1, e.code === U || I.has(e.code)) {
|
|
1664
1665
|
this.emitError({
|
|
1665
1666
|
code: e.code,
|
|
1666
1667
|
message: e.reason,
|
|
@@ -1679,7 +1680,7 @@ class oe {
|
|
|
1679
1680
|
});
|
|
1680
1681
|
}
|
|
1681
1682
|
}
|
|
1682
|
-
class
|
|
1683
|
+
class Te {
|
|
1683
1684
|
constructor(t) {
|
|
1684
1685
|
u(this, "addr");
|
|
1685
1686
|
u(this, "connected", !1);
|
|
@@ -1692,16 +1693,16 @@ class se {
|
|
|
1692
1693
|
u(this, "stopListeners", []);
|
|
1693
1694
|
u(this, "errorListeners", []);
|
|
1694
1695
|
u(this, "socket", null);
|
|
1695
|
-
if (!
|
|
1696
|
+
if (!N())
|
|
1696
1697
|
throw new Error("not browser");
|
|
1697
1698
|
if (t != null && t.apiKey && (this.apiKey = t.apiKey), t != null && t.apiSemver && (this.apiSemver = t.apiSemver), !t || !t.addr)
|
|
1698
|
-
this.addr =
|
|
1699
|
+
this.addr = D;
|
|
1699
1700
|
else {
|
|
1700
1701
|
let e = t.addr.trim();
|
|
1701
1702
|
/^https?:\/\//i.test(e) || (e = `http://${e}`);
|
|
1702
1703
|
try {
|
|
1703
|
-
const
|
|
1704
|
-
if (!
|
|
1704
|
+
const n = new URL(e).hostname;
|
|
1705
|
+
if (!v(n) && !P(n))
|
|
1705
1706
|
throw new Error(`Invalid address: "${t.addr}". Only IP addresses and mDNS names (ending in .local) are supported.`);
|
|
1706
1707
|
} catch (i) {
|
|
1707
1708
|
throw i instanceof Error && i.message.startsWith("Invalid address") ? i : new Error(`Invalid URL format: "${t.addr}"`);
|
|
@@ -1755,7 +1756,7 @@ class se {
|
|
|
1755
1756
|
raw: e
|
|
1756
1757
|
}), this.emitStop();
|
|
1757
1758
|
}, this.socket.onclose = async (e) => {
|
|
1758
|
-
if (this.socket = null, this.connected = !1, e.code ===
|
|
1759
|
+
if (this.socket = null, this.connected = !1, e.code === U || I.has(e.code)) {
|
|
1759
1760
|
this.emitError({
|
|
1760
1761
|
code: e.code,
|
|
1761
1762
|
message: e.reason,
|
|
@@ -1779,9 +1780,437 @@ class se {
|
|
|
1779
1780
|
});
|
|
1780
1781
|
}
|
|
1781
1782
|
}
|
|
1783
|
+
const m = class m {
|
|
1784
|
+
constructor(t, e) {
|
|
1785
|
+
u(this, "addr");
|
|
1786
|
+
u(this, "token");
|
|
1787
|
+
u(this, "isBinary");
|
|
1788
|
+
u(this, "connectTimeout");
|
|
1789
|
+
u(this, "dataTimeout");
|
|
1790
|
+
u(this, "worker", null);
|
|
1791
|
+
u(this, "connectionTimer", null);
|
|
1792
|
+
u(this, "dataTimer", null);
|
|
1793
|
+
u(this, "_status");
|
|
1794
|
+
// Callbacks
|
|
1795
|
+
u(this, "dataCallback");
|
|
1796
|
+
u(this, "rawDataCallback");
|
|
1797
|
+
u(this, "errorCallback");
|
|
1798
|
+
u(this, "statusCallback");
|
|
1799
|
+
this.addr = t.addr || "", this.token = t.token, this.isBinary = t.isBinary ?? !0, this.connectTimeout = (e == null ? void 0 : e.timeout) ?? 5e3, this.dataTimeout = (e == null ? void 0 : e.dataTimeout) ?? 15e3, this._status = {
|
|
1800
|
+
main: { status: f.IDLE },
|
|
1801
|
+
connection: { status: E.DISCONNECTED },
|
|
1802
|
+
auth: { status: k.UNAUTHENTICATED },
|
|
1803
|
+
data: { status: C.NONE },
|
|
1804
|
+
worker: { status: S.OFF }
|
|
1805
|
+
};
|
|
1806
|
+
}
|
|
1807
|
+
get status() {
|
|
1808
|
+
return this._status;
|
|
1809
|
+
}
|
|
1810
|
+
/**
|
|
1811
|
+
* Transforms http/https to ws/wss and prefixes with auto-inferred protocol if no protocol present.
|
|
1812
|
+
*/
|
|
1813
|
+
resolveProtocol(t) {
|
|
1814
|
+
let e = t.trim();
|
|
1815
|
+
if (e.startsWith("https://"))
|
|
1816
|
+
return e.replace("https://", "wss://");
|
|
1817
|
+
if (e.startsWith("http://"))
|
|
1818
|
+
return e.replace("http://", "ws://");
|
|
1819
|
+
if (e.startsWith("wss://") || e.startsWith("ws://"))
|
|
1820
|
+
return e;
|
|
1821
|
+
let i = "ws:";
|
|
1822
|
+
return typeof window < "u" && window.location.protocol === "https:" && (i = "wss:"), `${i}//${e}`;
|
|
1823
|
+
}
|
|
1824
|
+
/**
|
|
1825
|
+
* Starts the stream connection.
|
|
1826
|
+
* Throws an error if already running.
|
|
1827
|
+
*/
|
|
1828
|
+
start({
|
|
1829
|
+
dataCallback: t,
|
|
1830
|
+
rawDataCallback: e,
|
|
1831
|
+
errorCallback: i,
|
|
1832
|
+
statusCallback: n
|
|
1833
|
+
}) {
|
|
1834
|
+
if (this._status.main.status === f.STARTING || this._status.main.status === f.RUNNING) {
|
|
1835
|
+
const s = new y(d.STREAM_ALREADY_STARTED, "StateStream is already running. Call stop() before starting again.");
|
|
1836
|
+
if (n && n({
|
|
1837
|
+
...this._status,
|
|
1838
|
+
main: { ...this._status.main, lastError: s }
|
|
1839
|
+
}), i)
|
|
1840
|
+
i(s);
|
|
1841
|
+
else
|
|
1842
|
+
throw s;
|
|
1843
|
+
return;
|
|
1844
|
+
}
|
|
1845
|
+
this.dataCallback = t, this.rawDataCallback = e, this.errorCallback = i, this.statusCallback = n, this.updateStatusComponent("main", { status: f.STARTING, lastError: void 0 });
|
|
1846
|
+
try {
|
|
1847
|
+
this.ensureWorker(), this.sendCommand({
|
|
1848
|
+
type: "START",
|
|
1849
|
+
addr: this.normalizeUrl(this.addr),
|
|
1850
|
+
token: this.token,
|
|
1851
|
+
isBinary: this.isBinary,
|
|
1852
|
+
mode: this.streamMode
|
|
1853
|
+
}), this.clearConnectionTimer(), this.connectionTimer = setTimeout(() => {
|
|
1854
|
+
const s = new y(d.CONNECTION_TIMEOUT, `Connection timed out after ${this.connectTimeout}ms`);
|
|
1855
|
+
this.mapErrorToStatus(s), this.errorCallback && this.errorCallback(s), this.stop();
|
|
1856
|
+
}, this.connectTimeout);
|
|
1857
|
+
} catch (s) {
|
|
1858
|
+
const o = s instanceof y ? s : new y(d.UNKNOWN_ERROR, String(s));
|
|
1859
|
+
this.errorCallback && this.errorCallback(o);
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
/**
|
|
1863
|
+
* Stops the stream connection.
|
|
1864
|
+
*/
|
|
1865
|
+
stop() {
|
|
1866
|
+
this.clearConnectionTimer(), this.clearDataTimer(), !(this._status.main.status === f.IDLE || this._status.main.status === f.STOPPED) && (this.updateStatusComponent("main", { status: f.STOPPED }), this.updateStatusComponent("connection", { status: E.DISCONNECTED }), this.sendCommand({ type: "STOP" }), this.clearCallbacks());
|
|
1867
|
+
}
|
|
1868
|
+
/**
|
|
1869
|
+
* Cleans up all resources.
|
|
1870
|
+
*/
|
|
1871
|
+
destroy() {
|
|
1872
|
+
this.stop(), this.worker && (this.worker.terminate ? this.worker.terminate() : "close" in this.worker.port && this.worker.port.close(), this.worker = null);
|
|
1873
|
+
}
|
|
1874
|
+
/**
|
|
1875
|
+
* Clears all registered callbacks.
|
|
1876
|
+
*/
|
|
1877
|
+
clearCallbacks() {
|
|
1878
|
+
this.dataCallback = void 0, this.rawDataCallback = void 0, this.errorCallback = void 0, this.statusCallback = void 0;
|
|
1879
|
+
}
|
|
1880
|
+
/**
|
|
1881
|
+
* Sends a new token to the worker (for auth or token refresh).
|
|
1882
|
+
*/
|
|
1883
|
+
sendToken(t) {
|
|
1884
|
+
this.token = t, this.sendCommand({ type: "UPDATE_TOKEN", token: t });
|
|
1885
|
+
}
|
|
1886
|
+
/**
|
|
1887
|
+
* Sends a command to the worker port.
|
|
1888
|
+
*/
|
|
1889
|
+
sendCommand(t) {
|
|
1890
|
+
this.worker && this.worker.port.postMessage(t);
|
|
1891
|
+
}
|
|
1892
|
+
ensureWorker() {
|
|
1893
|
+
if (this.worker || typeof window > "u") return;
|
|
1894
|
+
const t = btoa(this.addr);
|
|
1895
|
+
try {
|
|
1896
|
+
this.updateStatusComponent("worker", { status: S.INITIALIZING, lastError: void 0 });
|
|
1897
|
+
const e = new URL(
|
|
1898
|
+
/* @vite-ignore */
|
|
1899
|
+
"./index.worker.js",
|
|
1900
|
+
import.meta.url
|
|
1901
|
+
);
|
|
1902
|
+
if (window.SharedWorker) {
|
|
1903
|
+
const i = new SharedWorker(e, {
|
|
1904
|
+
name: t,
|
|
1905
|
+
type: "module"
|
|
1906
|
+
});
|
|
1907
|
+
this.worker = {
|
|
1908
|
+
port: i.port
|
|
1909
|
+
}, i.port.onmessage = (n) => {
|
|
1910
|
+
this.handleWorkerMessage(n.data);
|
|
1911
|
+
}, i.port.start();
|
|
1912
|
+
} else {
|
|
1913
|
+
const i = new Worker(e, { type: "module" });
|
|
1914
|
+
this.worker = {
|
|
1915
|
+
port: i,
|
|
1916
|
+
terminate: () => i.terminate()
|
|
1917
|
+
}, i.onmessage = (n) => {
|
|
1918
|
+
this.handleWorkerMessage(n.data);
|
|
1919
|
+
};
|
|
1920
|
+
}
|
|
1921
|
+
this.updateStatusComponent("worker", { status: S.READY });
|
|
1922
|
+
} catch (e) {
|
|
1923
|
+
const i = new y(d.WORKER_INIT_FAILED, `Failed to initialize worker: ${String(e)}`);
|
|
1924
|
+
throw this.updateStatusComponent("worker", { status: S.ERROR, lastError: i }), this.updateStatusComponent("main", { status: f.FAILED, lastError: i }), i;
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
/**
|
|
1928
|
+
* Processes messages from the worker.
|
|
1929
|
+
*/
|
|
1930
|
+
handleWorkerMessage(t) {
|
|
1931
|
+
switch (t.type) {
|
|
1932
|
+
case "DATA":
|
|
1933
|
+
this.resetDataTimer(), this.dataCallback && this.dataCallback(this.normalizeState(t.data));
|
|
1934
|
+
break;
|
|
1935
|
+
case "RAW_DATA":
|
|
1936
|
+
this.resetDataTimer(), this.rawDataCallback && this.rawDataCallback(t.data);
|
|
1937
|
+
break;
|
|
1938
|
+
case "CONNECTED":
|
|
1939
|
+
this.clearConnectionTimer(), this.updateStatusComponent("connection", { status: E.CONNECTED }), this.streamMode === "local" && this.updateStatusComponent("main", { status: f.RUNNING });
|
|
1940
|
+
break;
|
|
1941
|
+
case "STATUS_UPDATE":
|
|
1942
|
+
t.connection && this.updateStatusComponent("connection", { status: t.connection }), t.auth && (this.updateStatusComponent("auth", { status: t.auth }), t.auth === k.AUTHENTICATED && this.updateStatusComponent("main", { status: f.RUNNING }));
|
|
1943
|
+
break;
|
|
1944
|
+
case "ERROR": {
|
|
1945
|
+
this.clearConnectionTimer();
|
|
1946
|
+
const e = new y(t.code, t.message, t.data);
|
|
1947
|
+
this.mapErrorToStatus(e), this.errorCallback && this.errorCallback(e);
|
|
1948
|
+
break;
|
|
1949
|
+
}
|
|
1950
|
+
case "TOKEN_EXPIRED":
|
|
1951
|
+
this.updateStatusComponent("auth", { status: k.AUTHENTICATING }), this.handleTokenExpiredInternal();
|
|
1952
|
+
break;
|
|
1953
|
+
case "DISCONNECTED":
|
|
1954
|
+
this.updateStatusComponent("connection", { status: E.DISCONNECTED });
|
|
1955
|
+
break;
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
/**
|
|
1959
|
+
* Maps an error code to the corresponding status component
|
|
1960
|
+
*/
|
|
1961
|
+
mapErrorToStatus(t) {
|
|
1962
|
+
const e = t.code;
|
|
1963
|
+
(e === d.CONNECTION_FAILED || e === d.CONNECTION_LOST || e === d.RECONNECT_FAILED || e === d.CONNECTION_TIMEOUT) && (this.updateStatusComponent("connection", { status: E.DISCONNECTED, lastError: t }), this.updateStatusComponent("main", { status: f.FAILED, lastError: t })), (e === d.AUTH_FAILED || e === d.AUTH_REFRESH_FAILED) && (this.updateStatusComponent("auth", { status: k.FAILED, lastError: t }), this.updateStatusComponent("main", { status: f.FAILED, lastError: t })), (e === d.DEVICE_ERROR || e === d.DECODE_ERROR) && this.updateStatusComponent("main", { lastError: t });
|
|
1964
|
+
}
|
|
1965
|
+
/**
|
|
1966
|
+
* Updates a single component of the status and notifies listeners
|
|
1967
|
+
*/
|
|
1968
|
+
updateStatusComponent(t, e) {
|
|
1969
|
+
const i = this._status[t];
|
|
1970
|
+
this._status[t] = { ...i, ...e }, this.statusCallback && this.statusCallback({ ...this._status });
|
|
1971
|
+
}
|
|
1972
|
+
/**
|
|
1973
|
+
* Safe timer cleanup
|
|
1974
|
+
*/
|
|
1975
|
+
clearConnectionTimer() {
|
|
1976
|
+
this.connectionTimer && (clearTimeout(this.connectionTimer), this.connectionTimer = null);
|
|
1977
|
+
}
|
|
1978
|
+
/**
|
|
1979
|
+
* Reset the data inactivity timer
|
|
1980
|
+
*/
|
|
1981
|
+
resetDataTimer() {
|
|
1982
|
+
this.clearDataTimer(), this._status.data.status !== C.ACTIVE ? this.updateStatusComponent("data", {
|
|
1983
|
+
status: C.ACTIVE,
|
|
1984
|
+
lastActivity: Date.now()
|
|
1985
|
+
}) : this._status.data.lastActivity = Date.now(), this.dataTimer = setTimeout(() => {
|
|
1986
|
+
this.updateStatusComponent("data", { status: C.STALE });
|
|
1987
|
+
}, this.dataTimeout);
|
|
1988
|
+
}
|
|
1989
|
+
clearDataTimer() {
|
|
1990
|
+
this.dataTimer && (clearTimeout(this.dataTimer), this.dataTimer = null);
|
|
1991
|
+
}
|
|
1992
|
+
/**
|
|
1993
|
+
* Normalizes the raw state from the worker into a ProcessedState for the UI.
|
|
1994
|
+
* Extracts the 'state' key for each update and merges bar_id for remote mode.
|
|
1995
|
+
*/
|
|
1996
|
+
normalizeState(t) {
|
|
1997
|
+
let e, i;
|
|
1998
|
+
"bar_id" in t && "state" in t ? (e = t.state, i = t.bar_id) : e = t;
|
|
1999
|
+
let n = e.updates;
|
|
2000
|
+
return n && (n = n.map((s) => {
|
|
2001
|
+
const o = Object.keys(s).find((h) => s[h] != null);
|
|
2002
|
+
return {
|
|
2003
|
+
...s,
|
|
2004
|
+
state: o
|
|
2005
|
+
};
|
|
2006
|
+
})), {
|
|
2007
|
+
...e,
|
|
2008
|
+
updates: n,
|
|
2009
|
+
bar_id: i
|
|
2010
|
+
};
|
|
2011
|
+
}
|
|
2012
|
+
/**
|
|
2013
|
+
* Internally deduplicates token refresh requests for the same address.
|
|
2014
|
+
*/
|
|
2015
|
+
async handleTokenExpiredInternal() {
|
|
2016
|
+
const t = this.addr;
|
|
2017
|
+
let e = m.tokenRefreshPromises.get(t);
|
|
2018
|
+
if (!e && this.onTokenExpired && (e = (async () => {
|
|
2019
|
+
try {
|
|
2020
|
+
const n = this.onTokenExpired();
|
|
2021
|
+
return n instanceof Promise ? await n : "";
|
|
2022
|
+
} finally {
|
|
2023
|
+
m.tokenRefreshPromises.delete(t);
|
|
2024
|
+
}
|
|
2025
|
+
})(), m.tokenRefreshPromises.set(t, e)), e) {
|
|
2026
|
+
const i = await e;
|
|
2027
|
+
i && this.sendToken(i);
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
};
|
|
2031
|
+
/** Static map to deduplicate token refresh requests across all instances in this JS context */
|
|
2032
|
+
u(m, "tokenRefreshPromises", /* @__PURE__ */ new Map());
|
|
2033
|
+
let g = m;
|
|
2034
|
+
class Ee extends g {
|
|
2035
|
+
constructor(e = {}, i) {
|
|
2036
|
+
let n = e.addr;
|
|
2037
|
+
n || (typeof window < "u" ? n = window.location.origin : n = "10.0.4.20");
|
|
2038
|
+
super(
|
|
2039
|
+
{
|
|
2040
|
+
isBinary: !0,
|
|
2041
|
+
// Default for local is binary
|
|
2042
|
+
...e,
|
|
2043
|
+
addr: n
|
|
2044
|
+
},
|
|
2045
|
+
i
|
|
2046
|
+
);
|
|
2047
|
+
u(this, "streamMode", "local");
|
|
2048
|
+
}
|
|
2049
|
+
/**
|
|
2050
|
+
* Normalizes the address to use ws:// protocol and adds default path if missing.
|
|
2051
|
+
*/
|
|
2052
|
+
normalizeUrl(e) {
|
|
2053
|
+
const i = this.resolveProtocol(e), n = new URL(i);
|
|
2054
|
+
return (n.pathname === "/" || !n.pathname) && (n.pathname = "/api/status/ws"), n.toString();
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
class Se extends g {
|
|
2058
|
+
constructor(e, i) {
|
|
2059
|
+
super(
|
|
2060
|
+
{
|
|
2061
|
+
isBinary: !1,
|
|
2062
|
+
// Default for remote is JSON
|
|
2063
|
+
...e
|
|
2064
|
+
},
|
|
2065
|
+
i
|
|
2066
|
+
);
|
|
2067
|
+
u(this, "streamMode", "remote");
|
|
2068
|
+
u(this, "tokenProvider");
|
|
2069
|
+
this.tokenProvider = e.tokenProvider;
|
|
2070
|
+
}
|
|
2071
|
+
/**
|
|
2072
|
+
* Subscribes to updates for a specific device GUID.
|
|
2073
|
+
*/
|
|
2074
|
+
subscribe(e) {
|
|
2075
|
+
this.sendCommand({ type: "SUBSCRIBE", guid: e });
|
|
2076
|
+
}
|
|
2077
|
+
/**
|
|
2078
|
+
* Unsubscribes from updates for a specific device GUID.
|
|
2079
|
+
*/
|
|
2080
|
+
unsubscribe(e) {
|
|
2081
|
+
this.sendCommand({ type: "UNSUBSCRIBE", guid: e });
|
|
2082
|
+
}
|
|
2083
|
+
/**
|
|
2084
|
+
* Standardizes the address to use wss:// or ws:// protocol.
|
|
2085
|
+
*/
|
|
2086
|
+
normalizeUrl(e) {
|
|
2087
|
+
return this.resolveProtocol(e);
|
|
2088
|
+
}
|
|
2089
|
+
/**
|
|
2090
|
+
* Handles token expiration by invoking the tokenProvider.
|
|
2091
|
+
* Returns the promise for deduplication.
|
|
2092
|
+
*/
|
|
2093
|
+
onTokenExpired() {
|
|
2094
|
+
if (this.tokenProvider)
|
|
2095
|
+
return this.tokenProvider().then((e) => (this.sendToken(e), e)).catch((e) => {
|
|
2096
|
+
const i = `Failed to refresh token: ${e.message}`;
|
|
2097
|
+
throw this.errorCallback && this.errorCallback(new y(d.AUTH_REFRESH_FAILED, i)), e;
|
|
2098
|
+
});
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
const T = class T {
|
|
2102
|
+
constructor() {
|
|
2103
|
+
u(this, "gl", null);
|
|
2104
|
+
u(this, "program", null);
|
|
2105
|
+
u(this, "texture", null);
|
|
2106
|
+
u(this, "vs", `#version 300 es
|
|
2107
|
+
in vec2 position;
|
|
2108
|
+
out vec2 v_uv;
|
|
2109
|
+
void main() {
|
|
2110
|
+
v_uv = position * 0.5 + 0.5;
|
|
2111
|
+
v_uv.y = 1.0 - v_uv.y;
|
|
2112
|
+
gl_Position = vec4(position, 0, 1);
|
|
2113
|
+
}
|
|
2114
|
+
`);
|
|
2115
|
+
u(this, "fs", `#version 300 es
|
|
2116
|
+
precision highp float;
|
|
2117
|
+
in vec2 v_uv;
|
|
2118
|
+
out vec4 outColor;
|
|
2119
|
+
uniform sampler2D u_texture;
|
|
2120
|
+
uniform vec2 u_dataRes;
|
|
2121
|
+
uniform vec2 u_canvasRes;
|
|
2122
|
+
uniform float u_pixelSize;
|
|
2123
|
+
uniform float u_radius;
|
|
2124
|
+
uniform float u_darkThreshold;
|
|
2125
|
+
void main() {
|
|
2126
|
+
vec2 gridPos = v_uv * u_dataRes;
|
|
2127
|
+
vec2 localUv = fract(gridPos);
|
|
2128
|
+
vec2 cellCoords = (floor(gridPos) + 0.5) / u_dataRes;
|
|
2129
|
+
vec4 color = texture(u_texture, cellCoords);
|
|
2130
|
+
if (dot(color.rgb, vec3(1.0)) < u_darkThreshold) discard;
|
|
2131
|
+
float halfSize = u_pixelSize * 0.5;
|
|
2132
|
+
float visualRadius = sqrt(clamp(u_radius, 0.0, 1.0));
|
|
2133
|
+
float r = visualRadius * halfSize;
|
|
2134
|
+
vec2 q = abs(localUv - 0.5) - (halfSize - r);
|
|
2135
|
+
float dist = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - r;
|
|
2136
|
+
float unitsPerPixel = (u_dataRes.y / u_canvasRes.y);
|
|
2137
|
+
float delta = unitsPerPixel * 1.5;
|
|
2138
|
+
float effectRes = (1.0 - u_pixelSize) + u_radius;
|
|
2139
|
+
float effectStrength = smoothstep(0.0, 0.02, effectRes);
|
|
2140
|
+
float edgeOffset = mix(0.0, -delta, effectStrength);
|
|
2141
|
+
float mask = 1.0 - smoothstep(edgeOffset, edgeOffset + delta * 2.0, dist);
|
|
2142
|
+
float vignette = smoothstep(0.7, 0.3, length(localUv - 0.5));
|
|
2143
|
+
vec3 finalColor = color.rgb * (1.0 - (0.15 * effectStrength * (1.0 - vignette)));
|
|
2144
|
+
if (mask < 0.001) discard;
|
|
2145
|
+
outColor = vec4(finalColor, color.a * mask);
|
|
2146
|
+
}
|
|
2147
|
+
`);
|
|
2148
|
+
if (T.instance)
|
|
2149
|
+
return T.instance;
|
|
2150
|
+
T.instance = this;
|
|
2151
|
+
}
|
|
2152
|
+
/**
|
|
2153
|
+
* Lazily initializes the WebGL context and resources.
|
|
2154
|
+
* Only executes in a browser environment.
|
|
2155
|
+
*/
|
|
2156
|
+
init() {
|
|
2157
|
+
if (this.gl || typeof window > "u")
|
|
2158
|
+
return;
|
|
2159
|
+
const e = document.createElement("canvas").getContext("webgl2", {
|
|
2160
|
+
antialias: !0,
|
|
2161
|
+
alpha: !0,
|
|
2162
|
+
preserveDrawingBuffer: !0
|
|
2163
|
+
});
|
|
2164
|
+
if (!e)
|
|
2165
|
+
throw new Error("WebGL 2.0 not supported");
|
|
2166
|
+
this.gl = e, this.program = this.createProgram(this.vs, this.fs);
|
|
2167
|
+
const i = e.createBuffer();
|
|
2168
|
+
e.bindBuffer(e.ARRAY_BUFFER, i), e.bufferData(e.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1]), e.STATIC_DRAW);
|
|
2169
|
+
const n = e.getAttribLocation(this.program, "position");
|
|
2170
|
+
e.enableVertexAttribArray(n), e.vertexAttribPointer(n, 2, e.FLOAT, !1, 0, 0), this.texture = e.createTexture(), e.bindTexture(e.TEXTURE_2D, this.texture), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE);
|
|
2171
|
+
}
|
|
2172
|
+
/**
|
|
2173
|
+
* Internal WebGL rendering pass.
|
|
2174
|
+
*/
|
|
2175
|
+
render(t, e, i, n) {
|
|
2176
|
+
const { pixelSize: s = 0.85, radius: o = 0.5, darkThreshold: h = 0.04 } = n, c = this.gl;
|
|
2177
|
+
c.viewport(0, 0, c.canvas.width, c.canvas.height), c.useProgram(this.program), c.bindTexture(c.TEXTURE_2D, this.texture), c.texImage2D(c.TEXTURE_2D, 0, c.RGBA8, e, i, 0, c.RGBA, c.UNSIGNED_BYTE, t), c.uniform2f(c.getUniformLocation(this.program, "u_dataRes"), e, i), c.uniform2f(c.getUniformLocation(this.program, "u_canvasRes"), c.canvas.width, c.canvas.height), c.uniform1f(c.getUniformLocation(this.program, "u_pixelSize"), s), c.uniform1f(c.getUniformLocation(this.program, "u_radius"), o), c.uniform1f(c.getUniformLocation(this.program, "u_darkThreshold"), h), c.clearColor(0, 0, 0, 0), c.clear(c.COLOR_BUFFER_BIT), c.enable(c.BLEND), c.blendFunc(c.SRC_ALPHA, c.ONE_MINUS_SRC_ALPHA), c.drawArrays(c.TRIANGLES, 0, 6);
|
|
2178
|
+
}
|
|
2179
|
+
/**
|
|
2180
|
+
* Public API: Renders the LED frame to a target 2D canvas.
|
|
2181
|
+
*/
|
|
2182
|
+
renderFrame(t, e, i, n, s = {}) {
|
|
2183
|
+
if (this.init(), typeof window > "u" || !this.gl)
|
|
2184
|
+
return;
|
|
2185
|
+
(this.gl.canvas.width !== t.width || this.gl.canvas.height !== t.height) && (this.gl.canvas.width = t.width, this.gl.canvas.height = t.height), this.render(e, i, n, s);
|
|
2186
|
+
const o = t.getContext("2d");
|
|
2187
|
+
o && (o.clearRect(0, 0, t.width, t.height), o.drawImage(this.gl.canvas, 0, 0));
|
|
2188
|
+
}
|
|
2189
|
+
createProgram(t, e) {
|
|
2190
|
+
const i = this.gl, n = (o, h) => {
|
|
2191
|
+
const c = i.createShader(o);
|
|
2192
|
+
if (i.shaderSource(c, h), i.compileShader(c), !i.getShaderParameter(c, i.COMPILE_STATUS)) throw new Error(i.getShaderInfoLog(c) || "Shader Error");
|
|
2193
|
+
return c;
|
|
2194
|
+
}, s = i.createProgram();
|
|
2195
|
+
return i.attachShader(s, n(i.VERTEX_SHADER, t)), i.attachShader(s, n(i.FRAGMENT_SHADER, e)), i.linkProgram(s), s;
|
|
2196
|
+
}
|
|
2197
|
+
};
|
|
2198
|
+
u(T, "instance", null);
|
|
2199
|
+
let R = T;
|
|
2200
|
+
const Ce = new R();
|
|
1782
2201
|
export {
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
2202
|
+
k as AuthStatus,
|
|
2203
|
+
he as BusyBar,
|
|
2204
|
+
E as ConnectionStatus,
|
|
2205
|
+
C as DataStatus,
|
|
2206
|
+
_ as DeviceScreen,
|
|
2207
|
+
Te as Input,
|
|
2208
|
+
Ce as LEDRenderer,
|
|
2209
|
+
Ee as LocalStateStream,
|
|
2210
|
+
Se as RemoteStateStream,
|
|
2211
|
+
me as ScreenStream,
|
|
2212
|
+
y as StateStreamError,
|
|
2213
|
+
d as StateStreamErrorCode,
|
|
2214
|
+
f as StreamLifecycle,
|
|
2215
|
+
S as WorkerStatus
|
|
1787
2216
|
};
|