@busy-app/busy-lib 0.13.1 → 0.14.2
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 +22 -8
- package/dist/index.d.ts +327 -514
- package/dist/index.js +919 -1054
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,112 +1,117 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var l = (
|
|
4
|
-
import
|
|
5
|
-
const
|
|
6
|
-
if (typeof FormData < "u" &&
|
|
7
|
-
return
|
|
8
|
-
let
|
|
9
|
-
return
|
|
1
|
+
var x = Object.defineProperty;
|
|
2
|
+
var U = (e, n, t) => n in e ? x(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
|
|
3
|
+
var l = (e, n, t) => U(e, typeof n != "symbol" ? n + "" : n, t);
|
|
4
|
+
import D from "openapi-fetch";
|
|
5
|
+
const B = (e, n) => {
|
|
6
|
+
if (typeof FormData < "u" && e instanceof FormData || typeof Buffer < "u" && typeof Buffer.isBuffer == "function" && Buffer.isBuffer(e) || typeof File < "u" && e instanceof File || typeof Blob < "u" && e instanceof Blob || typeof ArrayBuffer < "u" && e instanceof ArrayBuffer || typeof ArrayBuffer < "u" && ArrayBuffer.isView && ArrayBuffer.isView(e))
|
|
7
|
+
return e;
|
|
8
|
+
let t;
|
|
9
|
+
return n && (n instanceof Headers ? t = n.get("Content-Type") ?? n.get("content-type") ?? void 0 : typeof n == "object" && (t = n["Content-Type"] ?? n["content-type"]), t === "application/x-www-form-urlencoded") ? e && typeof e == "object" && !(e instanceof URLSearchParams) ? new URLSearchParams(e).toString() : String(e) : JSON.stringify(e);
|
|
10
10
|
};
|
|
11
|
-
async function
|
|
12
|
-
const
|
|
13
|
-
return Object.assign(new Error(i || `HTTP ${
|
|
14
|
-
status:
|
|
15
|
-
statusText:
|
|
16
|
-
body:
|
|
11
|
+
async function w(e) {
|
|
12
|
+
const r = (e.headers.get("content-type") || "").includes("application/json") ? await e.clone().json() : await e.clone().text(), i = typeof r == "object" && r !== null ? r.error || r.message : typeof r == "string" ? r : void 0;
|
|
13
|
+
return Object.assign(new Error(i || `HTTP ${e.status} ${e.statusText}`), {
|
|
14
|
+
status: e.status,
|
|
15
|
+
statusText: e.statusText,
|
|
16
|
+
body: r
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return await r(n.signal);
|
|
25
|
-
} catch (i) {
|
|
26
|
-
throw i instanceof DOMException && i.name === "AbortError" ? new Error(`Request timed out after ${e}ms`) : i;
|
|
27
|
-
} finally {
|
|
28
|
-
clearTimeout(t);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function W(r, e, n) {
|
|
32
|
-
let t, i = n ?? void 0, o, a = null;
|
|
33
|
-
const c = async () => {
|
|
34
|
-
t || (a || (a = (async () => {
|
|
35
|
-
const f = await e();
|
|
19
|
+
function M(e, n, t, r = 3e3) {
|
|
20
|
+
let i, o = t ?? void 0, s, u = null;
|
|
21
|
+
const a = async () => {
|
|
22
|
+
i || (u || (u = (async () => {
|
|
23
|
+
const f = await n();
|
|
36
24
|
if (!f.api_semver)
|
|
37
25
|
throw new Error("Empty API version");
|
|
38
|
-
|
|
26
|
+
i = f.api_semver;
|
|
39
27
|
})().finally(() => {
|
|
40
|
-
|
|
41
|
-
})), await
|
|
42
|
-
},
|
|
43
|
-
async onRequest({ request: f, schemaPath:
|
|
44
|
-
return
|
|
28
|
+
u = null;
|
|
29
|
+
})), await u);
|
|
30
|
+
}, F = {
|
|
31
|
+
async onRequest({ request: f, schemaPath: p }) {
|
|
32
|
+
return o && f.headers.set("Authorization", `Bearer ${o}`), p !== "/version" && (await a(), i && f.headers.set("X-API-Sem-Ver", i), s && f.headers.set("X-API-Token", s)), f;
|
|
45
33
|
},
|
|
46
|
-
async onResponse({ request: f, response:
|
|
34
|
+
async onResponse({ request: f, response: p, options: T, schemaPath: A }) {
|
|
35
|
+
if (p.ok)
|
|
36
|
+
return p;
|
|
37
|
+
if (A === "/version")
|
|
38
|
+
throw await w(p);
|
|
39
|
+
if (p.status !== 405)
|
|
40
|
+
throw await w(p);
|
|
41
|
+
i = void 0, await a(), i && f.headers.set("X-API-Sem-Ver", i), o && f.headers.set("Authorization", `Bearer ${o}`);
|
|
42
|
+
const h = await (T.fetch ?? fetch)(f);
|
|
47
43
|
if (h.ok)
|
|
48
44
|
return h;
|
|
49
|
-
|
|
50
|
-
throw await T(h);
|
|
51
|
-
if (h.status !== 405)
|
|
52
|
-
throw await T(h);
|
|
53
|
-
t = void 0, await c(), t && f.headers.set("X-API-Sem-Ver", t), i && f.headers.set("Authorization", `Bearer ${i}`);
|
|
54
|
-
const R = await (U.fetch ?? fetch)(f);
|
|
55
|
-
if (R.ok)
|
|
56
|
-
return R;
|
|
57
|
-
throw await T(R);
|
|
45
|
+
throw await w(h);
|
|
58
46
|
}
|
|
59
|
-
},
|
|
60
|
-
baseUrl:
|
|
61
|
-
bodySerializer:
|
|
47
|
+
}, R = D({
|
|
48
|
+
baseUrl: e,
|
|
49
|
+
bodySerializer: B
|
|
62
50
|
});
|
|
63
|
-
return
|
|
64
|
-
|
|
51
|
+
return R.withTimeout = async (f, p = r) => {
|
|
52
|
+
if (p <= 0)
|
|
53
|
+
return await f();
|
|
54
|
+
const T = new AbortController(), A = setTimeout(() => T.abort(), p);
|
|
55
|
+
try {
|
|
56
|
+
return await f(T.signal);
|
|
57
|
+
} catch (h) {
|
|
58
|
+
throw h instanceof DOMException && h.name === "AbortError" ? new Error(`Request timed out after ${p}ms`) : h;
|
|
59
|
+
} finally {
|
|
60
|
+
clearTimeout(A);
|
|
61
|
+
}
|
|
62
|
+
}, R.use(F), {
|
|
63
|
+
client: R,
|
|
65
64
|
setApiKey: (f) => {
|
|
66
|
-
|
|
65
|
+
s = f;
|
|
67
66
|
},
|
|
68
67
|
setToken: (f) => {
|
|
69
|
-
|
|
68
|
+
o = f;
|
|
70
69
|
}
|
|
71
70
|
};
|
|
72
71
|
}
|
|
73
|
-
async function G(
|
|
74
|
-
const { data:
|
|
75
|
-
if (
|
|
76
|
-
throw
|
|
77
|
-
return
|
|
78
|
-
}
|
|
79
|
-
async function
|
|
80
|
-
const { data:
|
|
81
|
-
if (
|
|
82
|
-
throw
|
|
83
|
-
return
|
|
84
|
-
}
|
|
85
|
-
async function
|
|
86
|
-
const { data:
|
|
87
|
-
if (
|
|
88
|
-
throw
|
|
89
|
-
return
|
|
90
|
-
}
|
|
91
|
-
async function
|
|
92
|
-
const { data:
|
|
93
|
-
if (
|
|
94
|
-
throw
|
|
95
|
-
return
|
|
96
|
-
}
|
|
97
|
-
async function
|
|
98
|
-
const { data:
|
|
99
|
-
if (
|
|
100
|
-
throw
|
|
101
|
-
return
|
|
102
|
-
}
|
|
103
|
-
async function
|
|
104
|
-
const { data:
|
|
105
|
-
if (
|
|
106
|
-
throw
|
|
107
|
-
return
|
|
108
|
-
}
|
|
109
|
-
|
|
72
|
+
async function G(e, n) {
|
|
73
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/version", { signal: i }), n == null ? void 0 : n.timeout);
|
|
74
|
+
if (r)
|
|
75
|
+
throw r;
|
|
76
|
+
return t;
|
|
77
|
+
}
|
|
78
|
+
async function V(e, n) {
|
|
79
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/status", { signal: i }), n == null ? void 0 : n.timeout);
|
|
80
|
+
if (r)
|
|
81
|
+
throw r;
|
|
82
|
+
return t;
|
|
83
|
+
}
|
|
84
|
+
async function W(e, n) {
|
|
85
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/status/system", { signal: i }), n == null ? void 0 : n.timeout);
|
|
86
|
+
if (r)
|
|
87
|
+
throw r;
|
|
88
|
+
return t;
|
|
89
|
+
}
|
|
90
|
+
async function $(e, n) {
|
|
91
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/status/power", { signal: i }), n == null ? void 0 : n.timeout);
|
|
92
|
+
if (r)
|
|
93
|
+
throw r;
|
|
94
|
+
return t;
|
|
95
|
+
}
|
|
96
|
+
async function z(e, n) {
|
|
97
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/status/device", { signal: i }), n == null ? void 0 : n.timeout);
|
|
98
|
+
if (r)
|
|
99
|
+
throw r;
|
|
100
|
+
return t;
|
|
101
|
+
}
|
|
102
|
+
async function H(e, n) {
|
|
103
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/status/firmware", { signal: i }), n == null ? void 0 : n.timeout);
|
|
104
|
+
if (r)
|
|
105
|
+
throw r;
|
|
106
|
+
return t;
|
|
107
|
+
}
|
|
108
|
+
async function J(e, n) {
|
|
109
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/transport", { signal: i }), n == null ? void 0 : n.timeout);
|
|
110
|
+
if (r)
|
|
111
|
+
throw r;
|
|
112
|
+
return t;
|
|
113
|
+
}
|
|
114
|
+
class K {
|
|
110
115
|
/**
|
|
111
116
|
* Get API version information.
|
|
112
117
|
*
|
|
@@ -114,9 +119,9 @@ class X {
|
|
|
114
119
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
115
120
|
* @returns {Promise<VersionInfo>} A promise that resolves to an object containing the `api_semver` string.
|
|
116
121
|
*/
|
|
117
|
-
async SystemVersionGet(
|
|
118
|
-
const
|
|
119
|
-
return this.apiSemver =
|
|
122
|
+
async SystemVersionGet(n) {
|
|
123
|
+
const t = await G(this.apiClient, n);
|
|
124
|
+
return this.apiSemver = t.api_semver, t;
|
|
120
125
|
}
|
|
121
126
|
/**
|
|
122
127
|
* Get full status.
|
|
@@ -125,8 +130,8 @@ class X {
|
|
|
125
130
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
126
131
|
* @returns {Promise<Status>} Current status of the device.
|
|
127
132
|
*/
|
|
128
|
-
async SystemStatusGet(
|
|
129
|
-
return await
|
|
133
|
+
async SystemStatusGet(n) {
|
|
134
|
+
return await V(this.apiClient, n);
|
|
130
135
|
}
|
|
131
136
|
/**
|
|
132
137
|
* Get system status.
|
|
@@ -135,8 +140,8 @@ class X {
|
|
|
135
140
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
136
141
|
* @returns {Promise<StatusSystem>} Current system status.
|
|
137
142
|
*/
|
|
138
|
-
async SystemInfoGet(
|
|
139
|
-
return await
|
|
143
|
+
async SystemInfoGet(n) {
|
|
144
|
+
return await W(this.apiClient, n);
|
|
140
145
|
}
|
|
141
146
|
/**
|
|
142
147
|
* Get power status.
|
|
@@ -145,8 +150,8 @@ class X {
|
|
|
145
150
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
146
151
|
* @returns {Promise<StatusPower>} Current power status.
|
|
147
152
|
*/
|
|
148
|
-
async SystemStatusPowerGet(
|
|
149
|
-
return await
|
|
153
|
+
async SystemStatusPowerGet(n) {
|
|
154
|
+
return await $(this.apiClient, n);
|
|
150
155
|
}
|
|
151
156
|
/**
|
|
152
157
|
* Get device status.
|
|
@@ -155,8 +160,8 @@ class X {
|
|
|
155
160
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
156
161
|
* @returns {Promise<StatusDevice>} Current device status.
|
|
157
162
|
*/
|
|
158
|
-
async SystemStatusDeviceGet(
|
|
159
|
-
return await
|
|
163
|
+
async SystemStatusDeviceGet(n) {
|
|
164
|
+
return await z(this.apiClient, n);
|
|
160
165
|
}
|
|
161
166
|
/**
|
|
162
167
|
* Get firmware status.
|
|
@@ -165,94 +170,104 @@ class X {
|
|
|
165
170
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
166
171
|
* @returns {Promise<StatusFirmware>} Current firmware status.
|
|
167
172
|
*/
|
|
168
|
-
async SystemStatusFirmwareGet(
|
|
169
|
-
return await
|
|
173
|
+
async SystemStatusFirmwareGet(n) {
|
|
174
|
+
return await H(this.apiClient, n);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Get device transport information.
|
|
178
|
+
*
|
|
179
|
+
* @param {TimeoutOptions} [params] - Optional parameters.
|
|
180
|
+
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
181
|
+
* @returns {Promise<NetworkInterfaceInfo>} Current transport info (usb/wifi).
|
|
182
|
+
*/
|
|
183
|
+
async SystemTransportGet(n) {
|
|
184
|
+
return await J(this.apiClient, n);
|
|
170
185
|
}
|
|
171
186
|
}
|
|
172
|
-
async function Y(
|
|
173
|
-
const { file:
|
|
174
|
-
(o) =>
|
|
187
|
+
async function Y(e, n) {
|
|
188
|
+
const { file: t } = n, { data: r, error: i } = await e.withTimeout(
|
|
189
|
+
(o) => e.POST("/update", {
|
|
175
190
|
headers: {
|
|
176
191
|
"Content-Type": "application/octet-stream"
|
|
177
192
|
},
|
|
178
|
-
body:
|
|
193
|
+
body: t,
|
|
179
194
|
signal: o
|
|
180
195
|
}),
|
|
181
|
-
|
|
196
|
+
n.timeout
|
|
182
197
|
);
|
|
183
198
|
if (i)
|
|
184
199
|
throw i;
|
|
200
|
+
return r;
|
|
201
|
+
}
|
|
202
|
+
async function X(e, n) {
|
|
203
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.POST("/update/check", { signal: i }), n == null ? void 0 : n.timeout);
|
|
204
|
+
if (r)
|
|
205
|
+
throw r;
|
|
206
|
+
return t;
|
|
207
|
+
}
|
|
208
|
+
async function Z(e, n) {
|
|
209
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/update/status", { signal: i }), n == null ? void 0 : n.timeout);
|
|
210
|
+
if (r)
|
|
211
|
+
throw r;
|
|
185
212
|
return t;
|
|
186
213
|
}
|
|
187
|
-
async function
|
|
188
|
-
const {
|
|
189
|
-
|
|
190
|
-
throw t;
|
|
191
|
-
return n;
|
|
192
|
-
}
|
|
193
|
-
async function Q(r, e) {
|
|
194
|
-
const { data: n, error: t } = await s((i) => r.GET("/update/status", { signal: i }), e == null ? void 0 : e.timeout);
|
|
195
|
-
if (t)
|
|
196
|
-
throw t;
|
|
197
|
-
return n;
|
|
198
|
-
}
|
|
199
|
-
async function ee(r, e) {
|
|
200
|
-
const { version: n } = e, { data: t, error: i } = await s(
|
|
201
|
-
(o) => r.GET("/update/changelog", {
|
|
214
|
+
async function Q(e, n) {
|
|
215
|
+
const { version: t } = n, { data: r, error: i } = await e.withTimeout(
|
|
216
|
+
(o) => e.GET("/update/changelog", {
|
|
202
217
|
params: {
|
|
203
218
|
query: {
|
|
204
|
-
version:
|
|
219
|
+
version: t
|
|
205
220
|
}
|
|
206
221
|
},
|
|
207
222
|
signal: o
|
|
208
223
|
}),
|
|
209
|
-
|
|
224
|
+
n.timeout
|
|
210
225
|
);
|
|
211
226
|
if (i)
|
|
212
227
|
throw i;
|
|
213
|
-
return
|
|
228
|
+
return r;
|
|
214
229
|
}
|
|
215
|
-
async function
|
|
216
|
-
const { version:
|
|
217
|
-
(o) =>
|
|
230
|
+
async function nn(e, n) {
|
|
231
|
+
const { version: t } = n, { data: r, error: i } = await e.withTimeout(
|
|
232
|
+
(o) => e.POST("/update/install", {
|
|
218
233
|
params: {
|
|
219
234
|
query: {
|
|
220
|
-
version:
|
|
235
|
+
version: t
|
|
221
236
|
}
|
|
222
237
|
},
|
|
223
238
|
signal: o
|
|
224
239
|
}),
|
|
225
|
-
|
|
240
|
+
n.timeout
|
|
226
241
|
);
|
|
227
242
|
if (i)
|
|
228
243
|
throw i;
|
|
244
|
+
return r;
|
|
245
|
+
}
|
|
246
|
+
async function en(e, n) {
|
|
247
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.POST("/update/abort_download", { signal: i }), n == null ? void 0 : n.timeout);
|
|
248
|
+
if (r)
|
|
249
|
+
throw r;
|
|
229
250
|
return t;
|
|
230
251
|
}
|
|
231
|
-
async function
|
|
232
|
-
const { data:
|
|
233
|
-
if (
|
|
234
|
-
throw
|
|
235
|
-
return
|
|
236
|
-
}
|
|
237
|
-
async function
|
|
238
|
-
const {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
async function ie(r, e) {
|
|
244
|
-
const { is_enabled: n, interval_start: t, interval_end: i } = e, { data: o, error: a } = await s(
|
|
245
|
-
(c) => r.POST("/update/autoupdate", {
|
|
246
|
-
body: { is_enabled: n, interval_start: t, interval_end: i },
|
|
247
|
-
signal: c
|
|
252
|
+
async function tn(e, n) {
|
|
253
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/update/autoupdate", { signal: i }), n == null ? void 0 : n.timeout);
|
|
254
|
+
if (r)
|
|
255
|
+
throw r;
|
|
256
|
+
return t;
|
|
257
|
+
}
|
|
258
|
+
async function rn(e, n) {
|
|
259
|
+
const { is_enabled: t, interval_start: r, interval_end: i } = n, { data: o, error: s } = await e.withTimeout(
|
|
260
|
+
(u) => e.POST("/update/autoupdate", {
|
|
261
|
+
body: { is_enabled: t, interval_start: r, interval_end: i },
|
|
262
|
+
signal: u
|
|
248
263
|
}),
|
|
249
|
-
|
|
264
|
+
n.timeout
|
|
250
265
|
);
|
|
251
|
-
if (
|
|
252
|
-
throw
|
|
266
|
+
if (s)
|
|
267
|
+
throw s;
|
|
253
268
|
return o;
|
|
254
269
|
}
|
|
255
|
-
class
|
|
270
|
+
class on {
|
|
256
271
|
/**
|
|
257
272
|
* Upload firmware update package.
|
|
258
273
|
*
|
|
@@ -261,8 +276,8 @@ class oe {
|
|
|
261
276
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
262
277
|
* @returns {Promise<SuccessResponse>} A promise that resolves when upload is complete.
|
|
263
278
|
*/
|
|
264
|
-
async UpdateFromFile(
|
|
265
|
-
return await Y(this.apiClient,
|
|
279
|
+
async UpdateFromFile(n) {
|
|
280
|
+
return await Y(this.apiClient, n);
|
|
266
281
|
}
|
|
267
282
|
/**
|
|
268
283
|
* Start firmware update check.
|
|
@@ -271,8 +286,8 @@ class oe {
|
|
|
271
286
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
272
287
|
* @returns {Promise<SuccessResponse>} A promise that resolves to the update check result.
|
|
273
288
|
*/
|
|
274
|
-
async UpdateCheck(
|
|
275
|
-
return await
|
|
289
|
+
async UpdateCheck(n) {
|
|
290
|
+
return await X(this.apiClient, n);
|
|
276
291
|
}
|
|
277
292
|
/**
|
|
278
293
|
* Get firmware update status.
|
|
@@ -281,8 +296,8 @@ class oe {
|
|
|
281
296
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
282
297
|
* @returns {Promise<UpdateStatus>} A promise that resolves to the update status.
|
|
283
298
|
*/
|
|
284
|
-
async UpdateStatusGet(
|
|
285
|
-
return await
|
|
299
|
+
async UpdateStatusGet(n) {
|
|
300
|
+
return await Z(this.apiClient, n);
|
|
286
301
|
}
|
|
287
302
|
/**
|
|
288
303
|
* Get firmware update changelog.
|
|
@@ -292,8 +307,8 @@ class oe {
|
|
|
292
307
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
293
308
|
* @returns {Promise<UpdateChangelog>} A promise that resolves to the changelog content.
|
|
294
309
|
*/
|
|
295
|
-
async UpdateChangelogGet(
|
|
296
|
-
return await
|
|
310
|
+
async UpdateChangelogGet(n) {
|
|
311
|
+
return await Q(this.apiClient, n);
|
|
297
312
|
}
|
|
298
313
|
/**
|
|
299
314
|
* Start firmware update installation.
|
|
@@ -303,8 +318,8 @@ class oe {
|
|
|
303
318
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
304
319
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful initiation.
|
|
305
320
|
*/
|
|
306
|
-
async UpdateInstall(
|
|
307
|
-
return await
|
|
321
|
+
async UpdateInstall(n) {
|
|
322
|
+
return await nn(this.apiClient, n);
|
|
308
323
|
}
|
|
309
324
|
/**
|
|
310
325
|
* Abort firmware update download.
|
|
@@ -313,8 +328,8 @@ class oe {
|
|
|
313
328
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
314
329
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful abort.
|
|
315
330
|
*/
|
|
316
|
-
async UpdateAbort(
|
|
317
|
-
return await
|
|
331
|
+
async UpdateAbort(n) {
|
|
332
|
+
return await en(this.apiClient, n);
|
|
318
333
|
}
|
|
319
334
|
/**
|
|
320
335
|
* Get current auto-update settings.
|
|
@@ -323,8 +338,8 @@ class oe {
|
|
|
323
338
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
324
339
|
* @returns {Promise<AutoUpdateSettings>} A promise that resolves to the current auto-update settings.
|
|
325
340
|
*/
|
|
326
|
-
async UpdateAutoUpdateGet(
|
|
327
|
-
return await
|
|
341
|
+
async UpdateAutoUpdateGet(n) {
|
|
342
|
+
return await tn(this.apiClient, n);
|
|
328
343
|
}
|
|
329
344
|
/**
|
|
330
345
|
* Set auto-update settings.
|
|
@@ -336,57 +351,57 @@ class oe {
|
|
|
336
351
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
337
352
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful update of settings.
|
|
338
353
|
*/
|
|
339
|
-
async UpdateAutoUpdateSet(
|
|
340
|
-
return await
|
|
354
|
+
async UpdateAutoUpdateSet(n) {
|
|
355
|
+
return await rn(this.apiClient, n);
|
|
341
356
|
}
|
|
342
357
|
}
|
|
343
|
-
async function
|
|
344
|
-
const { data:
|
|
345
|
-
if (
|
|
346
|
-
throw
|
|
347
|
-
return
|
|
358
|
+
async function sn(e, n) {
|
|
359
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/time", { signal: i }), n == null ? void 0 : n.timeout);
|
|
360
|
+
if (r)
|
|
361
|
+
throw r;
|
|
362
|
+
return t;
|
|
348
363
|
}
|
|
349
|
-
async function
|
|
350
|
-
const { timestamp:
|
|
351
|
-
(o) =>
|
|
364
|
+
async function an(e, n) {
|
|
365
|
+
const { timestamp: t } = n, { data: r, error: i } = await e.withTimeout(
|
|
366
|
+
(o) => e.POST("/time/timestamp", {
|
|
352
367
|
params: {
|
|
353
|
-
query: { timestamp:
|
|
368
|
+
query: { timestamp: t }
|
|
354
369
|
},
|
|
355
370
|
signal: o
|
|
356
371
|
}),
|
|
357
|
-
|
|
372
|
+
n.timeout
|
|
358
373
|
);
|
|
359
374
|
if (i)
|
|
360
375
|
throw i;
|
|
361
|
-
return
|
|
376
|
+
return r;
|
|
362
377
|
}
|
|
363
|
-
async function
|
|
364
|
-
const { data:
|
|
365
|
-
if (
|
|
366
|
-
throw
|
|
367
|
-
return
|
|
378
|
+
async function un(e, n) {
|
|
379
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/time/timezone", { signal: i }), n == null ? void 0 : n.timeout);
|
|
380
|
+
if (r)
|
|
381
|
+
throw r;
|
|
382
|
+
return t;
|
|
368
383
|
}
|
|
369
|
-
async function
|
|
370
|
-
const { timezone:
|
|
371
|
-
(o) =>
|
|
384
|
+
async function ln(e, n) {
|
|
385
|
+
const { timezone: t } = n, { data: r, error: i } = await e.withTimeout(
|
|
386
|
+
(o) => e.POST("/time/timezone", {
|
|
372
387
|
params: {
|
|
373
|
-
query: { timezone:
|
|
388
|
+
query: { timezone: t }
|
|
374
389
|
},
|
|
375
390
|
signal: o
|
|
376
391
|
}),
|
|
377
|
-
|
|
392
|
+
n.timeout
|
|
378
393
|
);
|
|
379
394
|
if (i)
|
|
380
395
|
throw i;
|
|
381
|
-
return
|
|
396
|
+
return r;
|
|
382
397
|
}
|
|
383
|
-
async function
|
|
384
|
-
const { data:
|
|
385
|
-
if (
|
|
386
|
-
throw
|
|
387
|
-
return
|
|
398
|
+
async function fn(e, n) {
|
|
399
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/time/tzlist", { signal: i }), n == null ? void 0 : n.timeout);
|
|
400
|
+
if (r)
|
|
401
|
+
throw r;
|
|
402
|
+
return t;
|
|
388
403
|
}
|
|
389
|
-
class
|
|
404
|
+
class cn {
|
|
390
405
|
/**
|
|
391
406
|
* Get current timestamp info.
|
|
392
407
|
*
|
|
@@ -394,8 +409,8 @@ class fe {
|
|
|
394
409
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
395
410
|
* @returns {Promise<TimestampInfo>} A promise that resolves to the timestamp information.
|
|
396
411
|
*/
|
|
397
|
-
async TimeGet(
|
|
398
|
-
return await
|
|
412
|
+
async TimeGet(n) {
|
|
413
|
+
return await sn(this.apiClient, n);
|
|
399
414
|
}
|
|
400
415
|
/**
|
|
401
416
|
* Set system timestamp.
|
|
@@ -405,8 +420,8 @@ class fe {
|
|
|
405
420
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
406
421
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
407
422
|
*/
|
|
408
|
-
async TimeTimestampSet(
|
|
409
|
-
return await
|
|
423
|
+
async TimeTimestampSet(n) {
|
|
424
|
+
return await an(this.apiClient, n);
|
|
410
425
|
}
|
|
411
426
|
/**
|
|
412
427
|
* Get current timezone.
|
|
@@ -415,8 +430,8 @@ class fe {
|
|
|
415
430
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
416
431
|
* @returns {Promise<TimezoneInfo>} A promise that resolves to the timezone information.
|
|
417
432
|
*/
|
|
418
|
-
async TimeTimezoneGet(
|
|
419
|
-
return await
|
|
433
|
+
async TimeTimezoneGet(n) {
|
|
434
|
+
return await un(this.apiClient, n);
|
|
420
435
|
}
|
|
421
436
|
/**
|
|
422
437
|
* Set system timezone.
|
|
@@ -426,8 +441,8 @@ class fe {
|
|
|
426
441
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
427
442
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
428
443
|
*/
|
|
429
|
-
async TimeTimezoneSet(
|
|
430
|
-
return await
|
|
444
|
+
async TimeTimezoneSet(n) {
|
|
445
|
+
return await ln(this.apiClient, n);
|
|
431
446
|
}
|
|
432
447
|
/**
|
|
433
448
|
* Get list of supported timezones.
|
|
@@ -436,58 +451,58 @@ class fe {
|
|
|
436
451
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
437
452
|
* @returns {Promise<TimezoneList>} A promise that resolves to a list of timezone items.
|
|
438
453
|
*/
|
|
439
|
-
async TimeTzListGet(
|
|
440
|
-
return await
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
async function
|
|
444
|
-
const { data:
|
|
445
|
-
if (
|
|
446
|
-
throw
|
|
447
|
-
return
|
|
448
|
-
}
|
|
449
|
-
async function
|
|
450
|
-
const { data:
|
|
451
|
-
if (
|
|
452
|
-
throw
|
|
453
|
-
return
|
|
454
|
-
}
|
|
455
|
-
async function
|
|
456
|
-
const { data:
|
|
457
|
-
if (
|
|
458
|
-
throw
|
|
459
|
-
return
|
|
460
|
-
}
|
|
461
|
-
async function
|
|
462
|
-
const { profile:
|
|
463
|
-
(
|
|
454
|
+
async TimeTzListGet(n) {
|
|
455
|
+
return await fn(this.apiClient, n);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
async function dn(e, n) {
|
|
459
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/account/status", { signal: i }), n == null ? void 0 : n.timeout);
|
|
460
|
+
if (r)
|
|
461
|
+
throw r;
|
|
462
|
+
return t;
|
|
463
|
+
}
|
|
464
|
+
async function pn(e, n) {
|
|
465
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/account/info", { signal: i }), n == null ? void 0 : n.timeout);
|
|
466
|
+
if (r)
|
|
467
|
+
throw r;
|
|
468
|
+
return t;
|
|
469
|
+
}
|
|
470
|
+
async function hn(e, n) {
|
|
471
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/account/profile", { signal: i }), n == null ? void 0 : n.timeout);
|
|
472
|
+
if (r)
|
|
473
|
+
throw r;
|
|
474
|
+
return t;
|
|
475
|
+
}
|
|
476
|
+
async function yn(e, n) {
|
|
477
|
+
const { profile: t, custom_url: r } = n, { data: i, error: o } = await e.withTimeout(
|
|
478
|
+
(s) => e.POST("/account/profile", {
|
|
464
479
|
params: {
|
|
465
480
|
query: {
|
|
466
|
-
profile:
|
|
467
|
-
custom_url:
|
|
481
|
+
profile: t,
|
|
482
|
+
custom_url: r
|
|
468
483
|
}
|
|
469
484
|
},
|
|
470
|
-
signal:
|
|
485
|
+
signal: s
|
|
471
486
|
}),
|
|
472
|
-
|
|
487
|
+
n.timeout
|
|
473
488
|
);
|
|
474
489
|
if (o)
|
|
475
490
|
throw o;
|
|
476
491
|
return i;
|
|
477
492
|
}
|
|
478
|
-
async function
|
|
479
|
-
const { data:
|
|
480
|
-
if (
|
|
481
|
-
throw
|
|
482
|
-
return
|
|
493
|
+
async function mn(e, n) {
|
|
494
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.DELETE("/account", { signal: i }), n == null ? void 0 : n.timeout);
|
|
495
|
+
if (r)
|
|
496
|
+
throw r;
|
|
497
|
+
return t;
|
|
483
498
|
}
|
|
484
|
-
async function
|
|
485
|
-
const { data:
|
|
486
|
-
if (
|
|
487
|
-
throw
|
|
488
|
-
return
|
|
499
|
+
async function vn(e, n) {
|
|
500
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.POST("/account/link", { signal: i }), n == null ? void 0 : n.timeout);
|
|
501
|
+
if (r)
|
|
502
|
+
throw r;
|
|
503
|
+
return t;
|
|
489
504
|
}
|
|
490
|
-
class
|
|
505
|
+
class gn {
|
|
491
506
|
/**
|
|
492
507
|
* Get account info.
|
|
493
508
|
*
|
|
@@ -495,8 +510,8 @@ class ge {
|
|
|
495
510
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
496
511
|
* @returns {Promise<AccountInfo>} A promise that resolves to the account information.
|
|
497
512
|
*/
|
|
498
|
-
async AccountInfoGet(
|
|
499
|
-
return await
|
|
513
|
+
async AccountInfoGet(n) {
|
|
514
|
+
return await pn(this.apiClient, n);
|
|
500
515
|
}
|
|
501
516
|
/**
|
|
502
517
|
* Get account state.
|
|
@@ -505,8 +520,8 @@ class ge {
|
|
|
505
520
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
506
521
|
* @returns {Promise<AccountStatus>} A promise that resolves to the account state.
|
|
507
522
|
*/
|
|
508
|
-
async AccountStateGet(
|
|
509
|
-
return await
|
|
523
|
+
async AccountStateGet(n) {
|
|
524
|
+
return await dn(this.apiClient, n);
|
|
510
525
|
}
|
|
511
526
|
/**
|
|
512
527
|
* Get account profile.
|
|
@@ -515,8 +530,8 @@ class ge {
|
|
|
515
530
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
516
531
|
* @returns {Promise<AccountProfile>} A promise that resolves to the account profile.
|
|
517
532
|
*/
|
|
518
|
-
async AccountProfileGet(
|
|
519
|
-
return await
|
|
533
|
+
async AccountProfileGet(n) {
|
|
534
|
+
return await hn(this.apiClient, n);
|
|
520
535
|
}
|
|
521
536
|
/**
|
|
522
537
|
* Set account profile.
|
|
@@ -527,8 +542,8 @@ class ge {
|
|
|
527
542
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
528
543
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
529
544
|
*/
|
|
530
|
-
async AccountProfileSet(
|
|
531
|
-
return await
|
|
545
|
+
async AccountProfileSet(n) {
|
|
546
|
+
return await yn(this.apiClient, n);
|
|
532
547
|
}
|
|
533
548
|
/**
|
|
534
549
|
* Unlink device from account. Removes association with the current account.
|
|
@@ -537,8 +552,8 @@ class ge {
|
|
|
537
552
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
538
553
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful unlinking.
|
|
539
554
|
*/
|
|
540
|
-
async AccountUnlink(
|
|
541
|
-
return await
|
|
555
|
+
async AccountUnlink(n) {
|
|
556
|
+
return await mn(this.apiClient, n);
|
|
542
557
|
}
|
|
543
558
|
/**
|
|
544
559
|
* Link device to account. Requests account link PIN. Works only if device is connected to MQTT and is not linked to account.
|
|
@@ -547,89 +562,89 @@ class ge {
|
|
|
547
562
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
548
563
|
* @returns {Promise<AccountLink>} A promise that resolves to the link information (e.g., PIN).
|
|
549
564
|
*/
|
|
550
|
-
async AccountLink(
|
|
551
|
-
return await
|
|
565
|
+
async AccountLink(n) {
|
|
566
|
+
return await vn(this.apiClient, n);
|
|
552
567
|
}
|
|
553
568
|
}
|
|
554
|
-
async function
|
|
555
|
-
const { application_name:
|
|
556
|
-
(
|
|
569
|
+
async function bn(e, n) {
|
|
570
|
+
const { application_name: t, elements: r, priority: i = 50, timeout: o } = n, { data: s, error: u } = await e.withTimeout(
|
|
571
|
+
(a) => e.POST("/display/draw", {
|
|
557
572
|
body: {
|
|
558
|
-
application_name:
|
|
573
|
+
application_name: t,
|
|
559
574
|
priority: i,
|
|
560
|
-
elements:
|
|
575
|
+
elements: r
|
|
561
576
|
},
|
|
562
|
-
signal:
|
|
577
|
+
signal: a
|
|
563
578
|
}),
|
|
564
579
|
o
|
|
565
580
|
);
|
|
566
|
-
if (
|
|
567
|
-
throw
|
|
568
|
-
return
|
|
581
|
+
if (u)
|
|
582
|
+
throw u;
|
|
583
|
+
return s;
|
|
569
584
|
}
|
|
570
|
-
async function
|
|
571
|
-
const { data:
|
|
572
|
-
(i) =>
|
|
585
|
+
async function En(e, n) {
|
|
586
|
+
const { data: t, error: r } = await e.withTimeout(
|
|
587
|
+
(i) => e.DELETE("/display/draw", {
|
|
573
588
|
params: {
|
|
574
589
|
query: {
|
|
575
|
-
application_name:
|
|
590
|
+
application_name: n == null ? void 0 : n.application_name
|
|
576
591
|
}
|
|
577
592
|
},
|
|
578
593
|
signal: i
|
|
579
594
|
}),
|
|
580
|
-
|
|
595
|
+
n == null ? void 0 : n.timeout
|
|
581
596
|
);
|
|
582
|
-
if (
|
|
583
|
-
throw
|
|
584
|
-
return
|
|
597
|
+
if (r)
|
|
598
|
+
throw r;
|
|
599
|
+
return t;
|
|
585
600
|
}
|
|
586
|
-
async function
|
|
587
|
-
const { display:
|
|
588
|
-
(
|
|
601
|
+
async function _n(e, n) {
|
|
602
|
+
const { display: t, timeout: r } = n, { data: i, error: o } = await e.withTimeout(
|
|
603
|
+
(s) => e.GET("/screen", {
|
|
589
604
|
params: {
|
|
590
605
|
query: {
|
|
591
|
-
display:
|
|
606
|
+
display: t
|
|
592
607
|
}
|
|
593
608
|
},
|
|
594
609
|
parseAs: "blob",
|
|
595
|
-
signal:
|
|
610
|
+
signal: s
|
|
596
611
|
}),
|
|
597
|
-
|
|
612
|
+
r
|
|
598
613
|
);
|
|
599
614
|
if (o)
|
|
600
615
|
throw o;
|
|
601
616
|
return i;
|
|
602
617
|
}
|
|
603
|
-
async function
|
|
604
|
-
const { data:
|
|
605
|
-
if (
|
|
606
|
-
throw
|
|
607
|
-
return
|
|
618
|
+
async function Tn(e, n) {
|
|
619
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/display/brightness", { signal: i }), n == null ? void 0 : n.timeout);
|
|
620
|
+
if (r)
|
|
621
|
+
throw r;
|
|
622
|
+
return t;
|
|
608
623
|
}
|
|
609
|
-
async function
|
|
610
|
-
const { value:
|
|
611
|
-
if (typeof
|
|
612
|
-
if (
|
|
624
|
+
async function On(e, n) {
|
|
625
|
+
const { value: t } = n, i = ((u) => {
|
|
626
|
+
if (typeof u == "number") {
|
|
627
|
+
if (u < 0 || u > 100)
|
|
613
628
|
throw new Error("Brightness value must be between 0 and 100 or 'auto'");
|
|
614
|
-
return String(
|
|
629
|
+
return String(u);
|
|
615
630
|
}
|
|
616
631
|
return "auto";
|
|
617
|
-
})(
|
|
618
|
-
(
|
|
632
|
+
})(t), { data: o, error: s } = await e.withTimeout(
|
|
633
|
+
(u) => e.POST("/display/brightness", {
|
|
619
634
|
params: {
|
|
620
635
|
query: {
|
|
621
636
|
value: i
|
|
622
637
|
}
|
|
623
638
|
},
|
|
624
|
-
signal:
|
|
639
|
+
signal: u
|
|
625
640
|
}),
|
|
626
|
-
|
|
641
|
+
n.timeout
|
|
627
642
|
);
|
|
628
|
-
if (
|
|
629
|
-
throw
|
|
643
|
+
if (s)
|
|
644
|
+
throw s;
|
|
630
645
|
return o;
|
|
631
646
|
}
|
|
632
|
-
class
|
|
647
|
+
class Rn {
|
|
633
648
|
/**
|
|
634
649
|
* Draw on display. Sends drawing data to the display. Supports JSON-defined display elements.
|
|
635
650
|
*
|
|
@@ -640,8 +655,8 @@ class Re {
|
|
|
640
655
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
641
656
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful draw command.
|
|
642
657
|
*/
|
|
643
|
-
async DisplayDraw(
|
|
644
|
-
return await
|
|
658
|
+
async DisplayDraw(n) {
|
|
659
|
+
return await bn(this.apiClient, n);
|
|
645
660
|
}
|
|
646
661
|
/**
|
|
647
662
|
* Clear display. Deletes display elements drawn by the Canvas application.
|
|
@@ -652,8 +667,8 @@ class Re {
|
|
|
652
667
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
653
668
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful clear command.
|
|
654
669
|
*/
|
|
655
|
-
async DisplayClear(
|
|
656
|
-
return await
|
|
670
|
+
async DisplayClear(n) {
|
|
671
|
+
return await En(this.apiClient, n);
|
|
657
672
|
}
|
|
658
673
|
/**
|
|
659
674
|
* Get single frame for requested screen.
|
|
@@ -663,8 +678,8 @@ class Re {
|
|
|
663
678
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
664
679
|
* @returns {Promise<Blob>} A promise that resolves to the screen frame as a Blob.
|
|
665
680
|
*/
|
|
666
|
-
async DisplayScreenFrameGet(
|
|
667
|
-
return await
|
|
681
|
+
async DisplayScreenFrameGet(n) {
|
|
682
|
+
return await _n(this.apiClient, n);
|
|
668
683
|
}
|
|
669
684
|
/**
|
|
670
685
|
* Get display brightness.
|
|
@@ -673,8 +688,8 @@ class Re {
|
|
|
673
688
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
674
689
|
* @returns {Promise<DisplayBrightnessInfo>} A promise that resolves to the brightness information.
|
|
675
690
|
*/
|
|
676
|
-
async DisplayBrightnessGet(
|
|
677
|
-
return await
|
|
691
|
+
async DisplayBrightnessGet(n) {
|
|
692
|
+
return await Tn(this.apiClient, n);
|
|
678
693
|
}
|
|
679
694
|
/**
|
|
680
695
|
* Set display brightness.
|
|
@@ -684,59 +699,60 @@ class Re {
|
|
|
684
699
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
685
700
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
686
701
|
*/
|
|
687
|
-
async DisplayBrightnessSet(
|
|
688
|
-
return await
|
|
702
|
+
async DisplayBrightnessSet(n) {
|
|
703
|
+
return await On(this.apiClient, n);
|
|
689
704
|
}
|
|
690
705
|
}
|
|
691
|
-
async function
|
|
692
|
-
const { application_name:
|
|
693
|
-
(
|
|
706
|
+
async function An(e, n) {
|
|
707
|
+
const { application_name: t, path: r } = n, { data: i, error: o } = await e.withTimeout(
|
|
708
|
+
(s) => e.POST("/audio/play", {
|
|
694
709
|
params: {
|
|
695
710
|
query: {
|
|
696
|
-
application_name:
|
|
697
|
-
path:
|
|
711
|
+
application_name: t,
|
|
712
|
+
path: r
|
|
698
713
|
}
|
|
699
714
|
},
|
|
700
|
-
signal:
|
|
715
|
+
signal: s
|
|
701
716
|
}),
|
|
702
|
-
|
|
717
|
+
n.timeout
|
|
703
718
|
);
|
|
704
719
|
if (o)
|
|
705
720
|
throw o;
|
|
706
721
|
return i;
|
|
707
722
|
}
|
|
708
|
-
async function
|
|
709
|
-
const { data:
|
|
710
|
-
if (
|
|
711
|
-
throw
|
|
712
|
-
return
|
|
713
|
-
}
|
|
714
|
-
async function
|
|
715
|
-
const { data:
|
|
716
|
-
if (
|
|
717
|
-
throw
|
|
718
|
-
return
|
|
719
|
-
}
|
|
720
|
-
async function
|
|
721
|
-
const { volume:
|
|
722
|
-
if (typeof
|
|
723
|
+
async function wn(e, n) {
|
|
724
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.DELETE("/audio/play", { signal: i }), n == null ? void 0 : n.timeout);
|
|
725
|
+
if (r)
|
|
726
|
+
throw r;
|
|
727
|
+
return t;
|
|
728
|
+
}
|
|
729
|
+
async function Sn(e, n) {
|
|
730
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/audio/volume", { signal: i }), n == null ? void 0 : n.timeout);
|
|
731
|
+
if (r)
|
|
732
|
+
throw r;
|
|
733
|
+
return t;
|
|
734
|
+
}
|
|
735
|
+
async function Nn(e, n) {
|
|
736
|
+
const { volume: t, silent: r } = n;
|
|
737
|
+
if (typeof t != "number" || t < 0 || t > 100)
|
|
723
738
|
throw new Error("Volume must be a number between 0 and 100");
|
|
724
|
-
const { data:
|
|
725
|
-
(
|
|
739
|
+
const { data: i, error: o } = await e.withTimeout(
|
|
740
|
+
(s) => e.POST("/audio/volume", {
|
|
726
741
|
params: {
|
|
727
742
|
query: {
|
|
728
|
-
volume:
|
|
743
|
+
volume: t,
|
|
744
|
+
silent: r
|
|
729
745
|
}
|
|
730
746
|
},
|
|
731
|
-
signal:
|
|
747
|
+
signal: s
|
|
732
748
|
}),
|
|
733
|
-
|
|
749
|
+
n.timeout
|
|
734
750
|
);
|
|
735
|
-
if (
|
|
736
|
-
throw
|
|
737
|
-
return
|
|
751
|
+
if (o)
|
|
752
|
+
throw o;
|
|
753
|
+
return i;
|
|
738
754
|
}
|
|
739
|
-
class
|
|
755
|
+
class In {
|
|
740
756
|
/**
|
|
741
757
|
* Play audio file. Plays a file from internal storage.
|
|
742
758
|
*
|
|
@@ -746,8 +762,8 @@ class ke {
|
|
|
746
762
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
747
763
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful play command.
|
|
748
764
|
*/
|
|
749
|
-
async AudioPlay(
|
|
750
|
-
return await
|
|
765
|
+
async AudioPlay(n) {
|
|
766
|
+
return await An(this.apiClient, n);
|
|
751
767
|
}
|
|
752
768
|
/**
|
|
753
769
|
* Stop audio playback. Stops any currently playing audio.
|
|
@@ -756,8 +772,8 @@ class ke {
|
|
|
756
772
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
757
773
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful stop command.
|
|
758
774
|
*/
|
|
759
|
-
async AudioStop(
|
|
760
|
-
return await
|
|
775
|
+
async AudioStop(n) {
|
|
776
|
+
return await wn(this.apiClient, n);
|
|
761
777
|
}
|
|
762
778
|
/**
|
|
763
779
|
* Get audio volume.
|
|
@@ -766,8 +782,8 @@ class ke {
|
|
|
766
782
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
767
783
|
* @returns {Promise<AudioVolumeInfo>} A promise that resolves to the audio volume information.
|
|
768
784
|
*/
|
|
769
|
-
async AudioVolumeGet(
|
|
770
|
-
return await
|
|
785
|
+
async AudioVolumeGet(n) {
|
|
786
|
+
return await Sn(this.apiClient, n);
|
|
771
787
|
}
|
|
772
788
|
/**
|
|
773
789
|
* Set audio volume.
|
|
@@ -777,46 +793,46 @@ class ke {
|
|
|
777
793
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
778
794
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
779
795
|
*/
|
|
780
|
-
async AudioVolumeSet(
|
|
781
|
-
return await
|
|
796
|
+
async AudioVolumeSet(n) {
|
|
797
|
+
return await Nn(this.apiClient, n);
|
|
782
798
|
}
|
|
783
799
|
}
|
|
784
|
-
async function
|
|
785
|
-
const { data:
|
|
786
|
-
if (
|
|
787
|
-
throw
|
|
788
|
-
return
|
|
800
|
+
async function Cn(e, n) {
|
|
801
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/wifi/status", { signal: i }), n == null ? void 0 : n.timeout);
|
|
802
|
+
if (r)
|
|
803
|
+
throw r;
|
|
804
|
+
return t;
|
|
789
805
|
}
|
|
790
|
-
async function
|
|
791
|
-
const { ssid:
|
|
792
|
-
(
|
|
806
|
+
async function kn(e, n) {
|
|
807
|
+
const { ssid: t, password: r, security: i, ip_config: o } = n, { data: s, error: u } = await e.withTimeout(
|
|
808
|
+
(a) => e.POST("/wifi/connect", {
|
|
793
809
|
body: {
|
|
794
|
-
ssid:
|
|
795
|
-
password:
|
|
810
|
+
ssid: t,
|
|
811
|
+
password: r,
|
|
796
812
|
security: i,
|
|
797
813
|
ip_config: o
|
|
798
814
|
},
|
|
799
|
-
signal:
|
|
815
|
+
signal: a
|
|
800
816
|
}),
|
|
801
|
-
|
|
817
|
+
n.timeout
|
|
802
818
|
);
|
|
803
|
-
if (
|
|
804
|
-
throw
|
|
805
|
-
return
|
|
806
|
-
}
|
|
807
|
-
async function
|
|
808
|
-
const { data:
|
|
809
|
-
if (
|
|
810
|
-
throw
|
|
811
|
-
return
|
|
812
|
-
}
|
|
813
|
-
async function
|
|
814
|
-
const { data:
|
|
815
|
-
if (
|
|
816
|
-
throw
|
|
817
|
-
return
|
|
818
|
-
}
|
|
819
|
-
class
|
|
819
|
+
if (u)
|
|
820
|
+
throw u;
|
|
821
|
+
return s;
|
|
822
|
+
}
|
|
823
|
+
async function qn(e, n) {
|
|
824
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.POST("/wifi/disconnect", { signal: i }), n == null ? void 0 : n.timeout);
|
|
825
|
+
if (r)
|
|
826
|
+
throw r;
|
|
827
|
+
return t;
|
|
828
|
+
}
|
|
829
|
+
async function Pn(e, n) {
|
|
830
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/wifi/networks", { signal: i }), n == null ? void 0 : n.timeout);
|
|
831
|
+
if (r)
|
|
832
|
+
throw r;
|
|
833
|
+
return t;
|
|
834
|
+
}
|
|
835
|
+
class jn {
|
|
820
836
|
/**
|
|
821
837
|
* Returns current Wi-Fi status.
|
|
822
838
|
*
|
|
@@ -824,8 +840,8 @@ class Pe {
|
|
|
824
840
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
825
841
|
* @returns {Promise<WifiStatusResponse>} A promise that resolves to the Wi-Fi status.
|
|
826
842
|
*/
|
|
827
|
-
async WifiStatusGet(
|
|
828
|
-
return await
|
|
843
|
+
async WifiStatusGet(n) {
|
|
844
|
+
return await Cn(this.apiClient, n);
|
|
829
845
|
}
|
|
830
846
|
/**
|
|
831
847
|
* Connects to Wi-Fi network.
|
|
@@ -838,8 +854,8 @@ class Pe {
|
|
|
838
854
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
839
855
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful connection initiation.
|
|
840
856
|
*/
|
|
841
|
-
async WifiConnect(
|
|
842
|
-
return await
|
|
857
|
+
async WifiConnect(n) {
|
|
858
|
+
return await kn(this.apiClient, n);
|
|
843
859
|
}
|
|
844
860
|
/**
|
|
845
861
|
* Disconnects from Wi-Fi.
|
|
@@ -848,8 +864,8 @@ class Pe {
|
|
|
848
864
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
849
865
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful disconnection.
|
|
850
866
|
*/
|
|
851
|
-
async WifiDisconnect(
|
|
852
|
-
return await
|
|
867
|
+
async WifiDisconnect(n) {
|
|
868
|
+
return await qn(this.apiClient, n);
|
|
853
869
|
}
|
|
854
870
|
/**
|
|
855
871
|
* Scans environment for available Wi-Fi networks.
|
|
@@ -858,119 +874,119 @@ class Pe {
|
|
|
858
874
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
859
875
|
* @returns {Promise<WifiNetworkResponse>} A promise that resolves to a list of available networks.
|
|
860
876
|
*/
|
|
861
|
-
async WifiNetworksGet(
|
|
862
|
-
return await
|
|
877
|
+
async WifiNetworksGet(n) {
|
|
878
|
+
return await Pn(this.apiClient, n);
|
|
863
879
|
}
|
|
864
880
|
}
|
|
865
|
-
async function
|
|
866
|
-
const { path:
|
|
867
|
-
(
|
|
881
|
+
async function Dn(e, n) {
|
|
882
|
+
const { path: t, file: r } = n, { data: i, error: o } = await e.withTimeout(
|
|
883
|
+
(s) => e.POST("/storage/write", {
|
|
868
884
|
params: {
|
|
869
885
|
query: {
|
|
870
|
-
path:
|
|
886
|
+
path: t
|
|
871
887
|
}
|
|
872
888
|
},
|
|
873
889
|
headers: {
|
|
874
890
|
"Content-Type": "application/octet-stream"
|
|
875
891
|
},
|
|
876
|
-
body:
|
|
877
|
-
signal:
|
|
892
|
+
body: r,
|
|
893
|
+
signal: s
|
|
878
894
|
}),
|
|
879
|
-
|
|
895
|
+
n.timeout
|
|
880
896
|
);
|
|
881
897
|
if (o)
|
|
882
898
|
throw o;
|
|
883
899
|
return i;
|
|
884
900
|
}
|
|
885
|
-
async function
|
|
886
|
-
const { path:
|
|
887
|
-
(
|
|
901
|
+
async function Ln(e, n) {
|
|
902
|
+
const { path: t, as_array_buffer: r } = n, { data: i, error: o } = await e.withTimeout(
|
|
903
|
+
(s) => e.GET("/storage/read", {
|
|
888
904
|
params: {
|
|
889
905
|
query: {
|
|
890
|
-
path:
|
|
906
|
+
path: t
|
|
891
907
|
}
|
|
892
908
|
},
|
|
893
|
-
parseAs:
|
|
894
|
-
signal:
|
|
909
|
+
parseAs: r ? "arrayBuffer" : "blob",
|
|
910
|
+
signal: s
|
|
895
911
|
}),
|
|
896
|
-
|
|
912
|
+
n.timeout
|
|
897
913
|
);
|
|
898
914
|
if (o)
|
|
899
915
|
throw o;
|
|
900
916
|
return i;
|
|
901
917
|
}
|
|
902
|
-
async function
|
|
903
|
-
const { path:
|
|
904
|
-
(o) =>
|
|
918
|
+
async function Fn(e, n) {
|
|
919
|
+
const { path: t } = n, { data: r, error: i } = await e.withTimeout(
|
|
920
|
+
(o) => e.GET("/storage/list", {
|
|
905
921
|
params: {
|
|
906
922
|
query: {
|
|
907
|
-
path:
|
|
923
|
+
path: t
|
|
908
924
|
}
|
|
909
925
|
},
|
|
910
926
|
signal: o
|
|
911
927
|
}),
|
|
912
|
-
|
|
928
|
+
n.timeout
|
|
913
929
|
);
|
|
914
930
|
if (i)
|
|
915
931
|
throw i;
|
|
916
|
-
return
|
|
932
|
+
return r;
|
|
917
933
|
}
|
|
918
|
-
async function
|
|
919
|
-
const { path:
|
|
920
|
-
(o) =>
|
|
934
|
+
async function xn(e, n) {
|
|
935
|
+
const { path: t } = n, { data: r, error: i } = await e.withTimeout(
|
|
936
|
+
(o) => e.DELETE("/storage/remove", {
|
|
921
937
|
params: {
|
|
922
938
|
query: {
|
|
923
|
-
path:
|
|
939
|
+
path: t
|
|
924
940
|
}
|
|
925
941
|
},
|
|
926
942
|
signal: o
|
|
927
943
|
}),
|
|
928
|
-
|
|
944
|
+
n.timeout
|
|
929
945
|
);
|
|
930
946
|
if (i)
|
|
931
947
|
throw i;
|
|
932
|
-
return
|
|
948
|
+
return r;
|
|
933
949
|
}
|
|
934
|
-
async function
|
|
935
|
-
const { path:
|
|
936
|
-
(o) =>
|
|
950
|
+
async function Un(e, n) {
|
|
951
|
+
const { path: t } = n, { data: r, error: i } = await e.withTimeout(
|
|
952
|
+
(o) => e.POST("/storage/mkdir", {
|
|
937
953
|
params: {
|
|
938
954
|
query: {
|
|
939
|
-
path:
|
|
955
|
+
path: t
|
|
940
956
|
}
|
|
941
957
|
},
|
|
942
958
|
signal: o
|
|
943
959
|
}),
|
|
944
|
-
|
|
960
|
+
n.timeout
|
|
945
961
|
);
|
|
946
962
|
if (i)
|
|
947
963
|
throw i;
|
|
948
|
-
return
|
|
964
|
+
return r;
|
|
949
965
|
}
|
|
950
|
-
async function
|
|
951
|
-
const { data:
|
|
952
|
-
if (
|
|
953
|
-
throw
|
|
954
|
-
return
|
|
966
|
+
async function Bn(e, n) {
|
|
967
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/storage/status", { signal: i }), n == null ? void 0 : n.timeout);
|
|
968
|
+
if (r)
|
|
969
|
+
throw r;
|
|
970
|
+
return t;
|
|
955
971
|
}
|
|
956
|
-
async function
|
|
957
|
-
const { path:
|
|
958
|
-
(
|
|
972
|
+
async function Mn(e, n) {
|
|
973
|
+
const { path: t, new_path: r } = n, { data: i, error: o } = await e.withTimeout(
|
|
974
|
+
(s) => e.POST("/storage/rename", {
|
|
959
975
|
params: {
|
|
960
976
|
query: {
|
|
961
|
-
path:
|
|
962
|
-
new_path:
|
|
977
|
+
path: t,
|
|
978
|
+
new_path: r
|
|
963
979
|
}
|
|
964
980
|
},
|
|
965
|
-
signal:
|
|
981
|
+
signal: s
|
|
966
982
|
}),
|
|
967
|
-
|
|
983
|
+
n.timeout
|
|
968
984
|
);
|
|
969
985
|
if (o)
|
|
970
986
|
throw o;
|
|
971
987
|
return i;
|
|
972
988
|
}
|
|
973
|
-
class
|
|
989
|
+
class Gn {
|
|
974
990
|
/**
|
|
975
991
|
* Upload file to internal storage. Uploads a file to a specified path.
|
|
976
992
|
*
|
|
@@ -980,8 +996,8 @@ class Ve {
|
|
|
980
996
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
981
997
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful upload.
|
|
982
998
|
*/
|
|
983
|
-
async StorageWrite(
|
|
984
|
-
return await
|
|
999
|
+
async StorageWrite(n) {
|
|
1000
|
+
return await Dn(this.apiClient, n);
|
|
985
1001
|
}
|
|
986
1002
|
/**
|
|
987
1003
|
* Download file from internal storage. Downloads a file from a specified path.
|
|
@@ -992,8 +1008,8 @@ class Ve {
|
|
|
992
1008
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
993
1009
|
* @returns {Promise<StorageReadResponse>} A promise that resolves to the file content (Blob or ArrayBuffer).
|
|
994
1010
|
*/
|
|
995
|
-
async StorageRead(
|
|
996
|
-
return await
|
|
1011
|
+
async StorageRead(n) {
|
|
1012
|
+
return await Ln(this.apiClient, n);
|
|
997
1013
|
}
|
|
998
1014
|
/**
|
|
999
1015
|
* List files on internal storage.
|
|
@@ -1003,8 +1019,8 @@ class Ve {
|
|
|
1003
1019
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1004
1020
|
* @returns {Promise<StorageList>} A promise that resolves to a list of files and directories.
|
|
1005
1021
|
*/
|
|
1006
|
-
async StorageListGet(
|
|
1007
|
-
return await
|
|
1022
|
+
async StorageListGet(n) {
|
|
1023
|
+
return await Fn(this.apiClient, n);
|
|
1008
1024
|
}
|
|
1009
1025
|
/**
|
|
1010
1026
|
* Remove a file on internal storage. Removes a file with a specified path.
|
|
@@ -1014,8 +1030,8 @@ class Ve {
|
|
|
1014
1030
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1015
1031
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful removal.
|
|
1016
1032
|
*/
|
|
1017
|
-
async StorageRemove(
|
|
1018
|
-
return await
|
|
1033
|
+
async StorageRemove(n) {
|
|
1034
|
+
return await xn(this.apiClient, n);
|
|
1019
1035
|
}
|
|
1020
1036
|
/**
|
|
1021
1037
|
* Create a directory on internal storage. Creates a new directory with a specified path.
|
|
@@ -1025,8 +1041,8 @@ class Ve {
|
|
|
1025
1041
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1026
1042
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful creation.
|
|
1027
1043
|
*/
|
|
1028
|
-
async StorageMkdir(
|
|
1029
|
-
return await
|
|
1044
|
+
async StorageMkdir(n) {
|
|
1045
|
+
return await Un(this.apiClient, n);
|
|
1030
1046
|
}
|
|
1031
1047
|
/**
|
|
1032
1048
|
* Show storage usage.
|
|
@@ -1035,8 +1051,8 @@ class Ve {
|
|
|
1035
1051
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1036
1052
|
* @returns {Promise<StorageStatus>} A promise that resolves to the storage status.
|
|
1037
1053
|
*/
|
|
1038
|
-
async StorageStatusGet(
|
|
1039
|
-
return await
|
|
1054
|
+
async StorageStatusGet(n) {
|
|
1055
|
+
return await Bn(this.apiClient, n);
|
|
1040
1056
|
}
|
|
1041
1057
|
/**
|
|
1042
1058
|
* Rename/move a file. Moves a file to a new location.
|
|
@@ -1047,55 +1063,55 @@ class Ve {
|
|
|
1047
1063
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1048
1064
|
* @returns {Promise<SuccessResponse>} A promise that resolves on successful rename.
|
|
1049
1065
|
*/
|
|
1050
|
-
async StorageRename(
|
|
1051
|
-
return await
|
|
1066
|
+
async StorageRename(n) {
|
|
1067
|
+
return await Mn(this.apiClient, n);
|
|
1052
1068
|
}
|
|
1053
1069
|
}
|
|
1054
|
-
async function
|
|
1055
|
-
const { data:
|
|
1056
|
-
if (
|
|
1057
|
-
throw
|
|
1058
|
-
return
|
|
1070
|
+
async function Vn(e, n) {
|
|
1071
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/access", { signal: i }), n == null ? void 0 : n.timeout);
|
|
1072
|
+
if (r)
|
|
1073
|
+
throw r;
|
|
1074
|
+
return t;
|
|
1059
1075
|
}
|
|
1060
|
-
async function
|
|
1061
|
-
const { mode:
|
|
1076
|
+
async function Wn(e, n) {
|
|
1077
|
+
const { mode: t, key: r } = n, i = r ?? "";
|
|
1062
1078
|
if (String(i).trim() && !/^\d{4,10}$/.test(String(i)))
|
|
1063
1079
|
throw new Error("Key must be a string of 4 to 10 digits");
|
|
1064
|
-
const { data: o, error:
|
|
1065
|
-
(
|
|
1080
|
+
const { data: o, error: s } = await e.withTimeout(
|
|
1081
|
+
(u) => e.POST("/access", {
|
|
1066
1082
|
params: {
|
|
1067
1083
|
query: {
|
|
1068
|
-
mode:
|
|
1084
|
+
mode: t,
|
|
1069
1085
|
key: i
|
|
1070
1086
|
}
|
|
1071
1087
|
},
|
|
1072
|
-
signal:
|
|
1088
|
+
signal: u
|
|
1073
1089
|
}),
|
|
1074
|
-
|
|
1090
|
+
n.timeout
|
|
1075
1091
|
);
|
|
1076
|
-
if (
|
|
1077
|
-
throw
|
|
1092
|
+
if (s)
|
|
1093
|
+
throw s;
|
|
1078
1094
|
return o;
|
|
1079
1095
|
}
|
|
1080
|
-
async function $e
|
|
1081
|
-
const { data:
|
|
1082
|
-
if (
|
|
1083
|
-
throw
|
|
1084
|
-
return
|
|
1096
|
+
async function $n(e, n) {
|
|
1097
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/name", { signal: i }), n == null ? void 0 : n.timeout);
|
|
1098
|
+
if (r)
|
|
1099
|
+
throw r;
|
|
1100
|
+
return t;
|
|
1085
1101
|
}
|
|
1086
|
-
async function
|
|
1087
|
-
const { name:
|
|
1088
|
-
(o) =>
|
|
1089
|
-
body: { name:
|
|
1102
|
+
async function zn(e, n) {
|
|
1103
|
+
const { name: t } = n, { data: r, error: i } = await e.withTimeout(
|
|
1104
|
+
(o) => e.POST("/name", {
|
|
1105
|
+
body: { name: t },
|
|
1090
1106
|
signal: o
|
|
1091
1107
|
}),
|
|
1092
|
-
|
|
1108
|
+
n.timeout
|
|
1093
1109
|
);
|
|
1094
1110
|
if (i)
|
|
1095
1111
|
throw i;
|
|
1096
|
-
return
|
|
1112
|
+
return r;
|
|
1097
1113
|
}
|
|
1098
|
-
class
|
|
1114
|
+
class Hn {
|
|
1099
1115
|
/**
|
|
1100
1116
|
* Get HTTP API access over Wi-Fi configuration.
|
|
1101
1117
|
*
|
|
@@ -1103,8 +1119,8 @@ class Je {
|
|
|
1103
1119
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1104
1120
|
* @returns {Promise<HttpAccessInfo>} A promise that resolves to the access configuration.
|
|
1105
1121
|
*/
|
|
1106
|
-
async SettingsAccessGet(
|
|
1107
|
-
return await
|
|
1122
|
+
async SettingsAccessGet(n) {
|
|
1123
|
+
return await Vn(this.apiClient, n);
|
|
1108
1124
|
}
|
|
1109
1125
|
/**
|
|
1110
1126
|
* Set HTTP API access over Wi-Fi configuration.
|
|
@@ -1115,9 +1131,9 @@ class Je {
|
|
|
1115
1131
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1116
1132
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1117
1133
|
*/
|
|
1118
|
-
async SettingsAccessSet(
|
|
1119
|
-
const
|
|
1120
|
-
return
|
|
1134
|
+
async SettingsAccessSet(n) {
|
|
1135
|
+
const t = await Wn(this.apiClient, n);
|
|
1136
|
+
return n.mode === "key" && n.key && this.setApiKey(n.key), t;
|
|
1121
1137
|
}
|
|
1122
1138
|
/**
|
|
1123
1139
|
* Get current device name.
|
|
@@ -1126,8 +1142,8 @@ class Je {
|
|
|
1126
1142
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1127
1143
|
* @returns {Promise<NameInfo>} A promise that resolves to the device name.
|
|
1128
1144
|
*/
|
|
1129
|
-
async SettingsNameGet(
|
|
1130
|
-
return await $
|
|
1145
|
+
async SettingsNameGet(n) {
|
|
1146
|
+
return await $n(this.apiClient, n);
|
|
1131
1147
|
}
|
|
1132
1148
|
/**
|
|
1133
1149
|
* Set device name.
|
|
@@ -1137,35 +1153,35 @@ class Je {
|
|
|
1137
1153
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1138
1154
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1139
1155
|
*/
|
|
1140
|
-
async SettingsNameSet(
|
|
1141
|
-
return await
|
|
1142
|
-
}
|
|
1143
|
-
}
|
|
1144
|
-
async function
|
|
1145
|
-
const { data:
|
|
1146
|
-
if (
|
|
1147
|
-
throw
|
|
1148
|
-
return
|
|
1149
|
-
}
|
|
1150
|
-
async function
|
|
1151
|
-
const { data:
|
|
1152
|
-
if (
|
|
1153
|
-
throw
|
|
1154
|
-
return
|
|
1155
|
-
}
|
|
1156
|
-
async function
|
|
1157
|
-
const { data:
|
|
1158
|
-
if (
|
|
1159
|
-
throw
|
|
1160
|
-
return
|
|
1161
|
-
}
|
|
1162
|
-
async function
|
|
1163
|
-
const { data:
|
|
1164
|
-
if (
|
|
1165
|
-
throw
|
|
1166
|
-
return
|
|
1167
|
-
}
|
|
1168
|
-
class
|
|
1156
|
+
async SettingsNameSet(n) {
|
|
1157
|
+
return await zn(this.apiClient, n);
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
async function Jn(e, n) {
|
|
1161
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.POST("/ble/enable", { signal: i }), n == null ? void 0 : n.timeout);
|
|
1162
|
+
if (r)
|
|
1163
|
+
throw r;
|
|
1164
|
+
return t;
|
|
1165
|
+
}
|
|
1166
|
+
async function Kn(e, n) {
|
|
1167
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.POST("/ble/disable", { signal: i }), n == null ? void 0 : n.timeout);
|
|
1168
|
+
if (r)
|
|
1169
|
+
throw r;
|
|
1170
|
+
return t;
|
|
1171
|
+
}
|
|
1172
|
+
async function Yn(e, n) {
|
|
1173
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.DELETE("/ble/pairing", { signal: i }), n == null ? void 0 : n.timeout);
|
|
1174
|
+
if (r)
|
|
1175
|
+
throw r;
|
|
1176
|
+
return t;
|
|
1177
|
+
}
|
|
1178
|
+
async function Xn(e, n) {
|
|
1179
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/ble/status", { signal: i }), n == null ? void 0 : n.timeout);
|
|
1180
|
+
if (r)
|
|
1181
|
+
throw r;
|
|
1182
|
+
return t;
|
|
1183
|
+
}
|
|
1184
|
+
class Zn {
|
|
1169
1185
|
/**
|
|
1170
1186
|
* Enable BLE. Starts advertising.
|
|
1171
1187
|
*
|
|
@@ -1173,8 +1189,8 @@ class Ze {
|
|
|
1173
1189
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1174
1190
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1175
1191
|
*/
|
|
1176
|
-
async BleEnable(
|
|
1177
|
-
return await
|
|
1192
|
+
async BleEnable(n) {
|
|
1193
|
+
return await Jn(this.apiClient, n);
|
|
1178
1194
|
}
|
|
1179
1195
|
/**
|
|
1180
1196
|
* Disable BLE. Stops advertising.
|
|
@@ -1183,8 +1199,8 @@ class Ze {
|
|
|
1183
1199
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1184
1200
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1185
1201
|
*/
|
|
1186
|
-
async BleDisable(
|
|
1187
|
-
return await
|
|
1202
|
+
async BleDisable(n) {
|
|
1203
|
+
return await Kn(this.apiClient, n);
|
|
1188
1204
|
}
|
|
1189
1205
|
/**
|
|
1190
1206
|
* Remove pairing. Remove pairing with previous device.
|
|
@@ -1193,8 +1209,8 @@ class Ze {
|
|
|
1193
1209
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1194
1210
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1195
1211
|
*/
|
|
1196
|
-
async BleUnpair(
|
|
1197
|
-
return await
|
|
1212
|
+
async BleUnpair(n) {
|
|
1213
|
+
return await Yn(this.apiClient, n);
|
|
1198
1214
|
}
|
|
1199
1215
|
/**
|
|
1200
1216
|
* Returns current BLE status.
|
|
@@ -1203,70 +1219,70 @@ class Ze {
|
|
|
1203
1219
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1204
1220
|
* @returns {Promise<BleStatusResponse>} A promise that resolves to the BLE status.
|
|
1205
1221
|
*/
|
|
1206
|
-
async BleStatusGet(
|
|
1207
|
-
return await
|
|
1222
|
+
async BleStatusGet(n) {
|
|
1223
|
+
return await Xn(this.apiClient, n);
|
|
1208
1224
|
}
|
|
1209
1225
|
}
|
|
1210
|
-
async function
|
|
1211
|
-
const { key:
|
|
1212
|
-
(o) =>
|
|
1226
|
+
async function Qn(e, n) {
|
|
1227
|
+
const { key: t } = n, { data: r, error: i } = await e.withTimeout(
|
|
1228
|
+
(o) => e.POST("/input", {
|
|
1213
1229
|
params: {
|
|
1214
1230
|
query: {
|
|
1215
|
-
key:
|
|
1231
|
+
key: t
|
|
1216
1232
|
}
|
|
1217
1233
|
},
|
|
1218
1234
|
signal: o
|
|
1219
1235
|
}),
|
|
1220
|
-
|
|
1236
|
+
n.timeout
|
|
1221
1237
|
);
|
|
1222
1238
|
if (i)
|
|
1223
1239
|
throw i;
|
|
1224
|
-
return
|
|
1240
|
+
return r;
|
|
1225
1241
|
}
|
|
1226
|
-
class
|
|
1242
|
+
class ne {
|
|
1227
1243
|
/**
|
|
1228
1244
|
* Send input event. Send single key press event.
|
|
1229
1245
|
*
|
|
1230
1246
|
* @param {InputKeyParams} params - Button press parameters:
|
|
1231
|
-
* @param {
|
|
1247
|
+
* @param {InputKeyParams['key']} params.key - Key name.
|
|
1232
1248
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1233
1249
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1234
1250
|
*/
|
|
1235
|
-
async InputSend(
|
|
1236
|
-
return await
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
async function
|
|
1240
|
-
const { data:
|
|
1241
|
-
if (
|
|
1242
|
-
throw
|
|
1243
|
-
return
|
|
1244
|
-
}
|
|
1245
|
-
async function
|
|
1246
|
-
const { data:
|
|
1247
|
-
if (
|
|
1248
|
-
throw
|
|
1249
|
-
return
|
|
1250
|
-
}
|
|
1251
|
-
async function
|
|
1252
|
-
const { data:
|
|
1253
|
-
if (
|
|
1254
|
-
throw
|
|
1255
|
-
return
|
|
1256
|
-
}
|
|
1257
|
-
async function
|
|
1258
|
-
const { data:
|
|
1259
|
-
if (
|
|
1260
|
-
throw
|
|
1261
|
-
return
|
|
1262
|
-
}
|
|
1263
|
-
async function
|
|
1264
|
-
const { timeout:
|
|
1251
|
+
async InputSend(n) {
|
|
1252
|
+
return await Qn(this.apiClient, n);
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
async function ee(e, n) {
|
|
1256
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/smart_home/pairing", { signal: i }), n == null ? void 0 : n.timeout);
|
|
1257
|
+
if (r)
|
|
1258
|
+
throw r;
|
|
1259
|
+
return t;
|
|
1260
|
+
}
|
|
1261
|
+
async function te(e, n) {
|
|
1262
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.POST("/smart_home/pairing", { signal: i }), n == null ? void 0 : n.timeout);
|
|
1263
|
+
if (r)
|
|
1264
|
+
throw r;
|
|
1265
|
+
return t;
|
|
1266
|
+
}
|
|
1267
|
+
async function re(e, n) {
|
|
1268
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.DELETE("/smart_home/pairing", { signal: i }), n == null ? void 0 : n.timeout);
|
|
1269
|
+
if (r)
|
|
1270
|
+
throw r;
|
|
1271
|
+
return t;
|
|
1272
|
+
}
|
|
1273
|
+
async function ie(e, n) {
|
|
1274
|
+
const { data: t, error: r } = await e.withTimeout((i) => e.GET("/smart_home/switch", { signal: i }), n == null ? void 0 : n.timeout);
|
|
1275
|
+
if (r)
|
|
1276
|
+
throw r;
|
|
1277
|
+
return t;
|
|
1278
|
+
}
|
|
1279
|
+
async function oe(e, n) {
|
|
1280
|
+
const { timeout: t, ...r } = n, { data: i, error: o } = await e.withTimeout((s) => e.POST("/smart_home/switch", { body: r, signal: s }), t);
|
|
1265
1281
|
if (o)
|
|
1266
1282
|
throw o;
|
|
1267
1283
|
return i;
|
|
1268
1284
|
}
|
|
1269
|
-
class
|
|
1285
|
+
class se {
|
|
1270
1286
|
/**
|
|
1271
1287
|
* Smart home commissioning status.
|
|
1272
1288
|
*
|
|
@@ -1274,8 +1290,8 @@ class an {
|
|
|
1274
1290
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1275
1291
|
* @returns {Promise<SmartHomePairingInfo>} A promise that resolves to the pairing info.
|
|
1276
1292
|
*/
|
|
1277
|
-
async SmartHomePairingGet(
|
|
1278
|
-
return await
|
|
1293
|
+
async SmartHomePairingGet(n) {
|
|
1294
|
+
return await ee(this.apiClient, n);
|
|
1279
1295
|
}
|
|
1280
1296
|
/**
|
|
1281
1297
|
* Link device to a smart home.
|
|
@@ -1283,8 +1299,8 @@ class an {
|
|
|
1283
1299
|
* @param {TimeoutOptions} [params] - Optional timeout.
|
|
1284
1300
|
* @returns {Promise<SmartHomePairingPayload>} A promise that resolves to the pairing payload.
|
|
1285
1301
|
*/
|
|
1286
|
-
async SmartHomePair(
|
|
1287
|
-
return await
|
|
1302
|
+
async SmartHomePair(n) {
|
|
1303
|
+
return await te(this.apiClient, n);
|
|
1288
1304
|
}
|
|
1289
1305
|
/**
|
|
1290
1306
|
* Erase all smart home links.
|
|
@@ -1293,8 +1309,8 @@ class an {
|
|
|
1293
1309
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1294
1310
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1295
1311
|
*/
|
|
1296
|
-
async SmartHomeErase(
|
|
1297
|
-
return await
|
|
1312
|
+
async SmartHomeErase(n) {
|
|
1313
|
+
return await re(this.apiClient, n);
|
|
1298
1314
|
}
|
|
1299
1315
|
/**
|
|
1300
1316
|
* Get state of emulated smart home switch.
|
|
@@ -1303,8 +1319,8 @@ class an {
|
|
|
1303
1319
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1304
1320
|
* @returns {Promise<SmartHomeSwitchState>} A promise that resolves to the switch state.
|
|
1305
1321
|
*/
|
|
1306
|
-
async SmartHomeSwitchStateGet(
|
|
1307
|
-
return await
|
|
1322
|
+
async SmartHomeSwitchStateGet(n) {
|
|
1323
|
+
return await ie(this.apiClient, n);
|
|
1308
1324
|
}
|
|
1309
1325
|
/**
|
|
1310
1326
|
* Set state of emulated smart home switch.
|
|
@@ -1312,67 +1328,67 @@ class an {
|
|
|
1312
1328
|
* @param {SmartHomeSwitchState & TimeoutOptions} params - Switch state and optional timeout.
|
|
1313
1329
|
* @returns {Promise<SuccessResponse>} A promise that resolves on success.
|
|
1314
1330
|
*/
|
|
1315
|
-
async SmartHomeSwitchStateSet(
|
|
1316
|
-
return await
|
|
1331
|
+
async SmartHomeSwitchStateSet(n) {
|
|
1332
|
+
return await oe(this.apiClient, n);
|
|
1317
1333
|
}
|
|
1318
1334
|
// ALIASES for backward compatibility (Matter -> SmartHome)
|
|
1319
1335
|
/**
|
|
1320
1336
|
* @deprecated Use SmartHomePairingGet instead.
|
|
1321
1337
|
*/
|
|
1322
|
-
async MatterStatusGet(
|
|
1323
|
-
return await this.SmartHomePairingGet(
|
|
1338
|
+
async MatterStatusGet(n) {
|
|
1339
|
+
return await this.SmartHomePairingGet(n);
|
|
1324
1340
|
}
|
|
1325
1341
|
/**
|
|
1326
1342
|
* @deprecated Use SmartHomePair instead.
|
|
1327
1343
|
*/
|
|
1328
|
-
async MatterPair(
|
|
1329
|
-
return await this.SmartHomePair(
|
|
1344
|
+
async MatterPair(n) {
|
|
1345
|
+
return await this.SmartHomePair(n);
|
|
1330
1346
|
}
|
|
1331
1347
|
/**
|
|
1332
1348
|
* @deprecated Use SmartHomeErase instead.
|
|
1333
1349
|
*/
|
|
1334
|
-
async MatterErase(
|
|
1335
|
-
return await this.SmartHomeErase(
|
|
1350
|
+
async MatterErase(n) {
|
|
1351
|
+
return await this.SmartHomeErase(n);
|
|
1336
1352
|
}
|
|
1337
1353
|
}
|
|
1338
|
-
async function
|
|
1339
|
-
const { application_name:
|
|
1340
|
-
(
|
|
1354
|
+
async function ae(e, n) {
|
|
1355
|
+
const { application_name: t, file: r, data: i } = n, { data: o, error: s } = await e.withTimeout(
|
|
1356
|
+
(u) => e.POST("/assets/upload", {
|
|
1341
1357
|
params: {
|
|
1342
1358
|
query: {
|
|
1343
|
-
application_name:
|
|
1344
|
-
file:
|
|
1359
|
+
application_name: t,
|
|
1360
|
+
file: r
|
|
1345
1361
|
}
|
|
1346
1362
|
},
|
|
1347
1363
|
headers: {
|
|
1348
1364
|
"Content-Type": "application/octet-stream"
|
|
1349
1365
|
},
|
|
1350
1366
|
body: i,
|
|
1351
|
-
signal:
|
|
1367
|
+
signal: u
|
|
1352
1368
|
}),
|
|
1353
|
-
|
|
1369
|
+
n.timeout
|
|
1354
1370
|
);
|
|
1355
|
-
if (
|
|
1356
|
-
throw
|
|
1371
|
+
if (s)
|
|
1372
|
+
throw s;
|
|
1357
1373
|
return o;
|
|
1358
1374
|
}
|
|
1359
|
-
async function
|
|
1360
|
-
const { application_name:
|
|
1361
|
-
(o) =>
|
|
1375
|
+
async function ue(e, n) {
|
|
1376
|
+
const { application_name: t } = n, { data: r, error: i } = await e.withTimeout(
|
|
1377
|
+
(o) => e.DELETE("/assets/upload", {
|
|
1362
1378
|
params: {
|
|
1363
1379
|
query: {
|
|
1364
|
-
application_name:
|
|
1380
|
+
application_name: t
|
|
1365
1381
|
}
|
|
1366
1382
|
},
|
|
1367
1383
|
signal: o
|
|
1368
1384
|
}),
|
|
1369
|
-
|
|
1385
|
+
n.timeout
|
|
1370
1386
|
);
|
|
1371
1387
|
if (i)
|
|
1372
1388
|
throw i;
|
|
1373
|
-
return
|
|
1389
|
+
return r;
|
|
1374
1390
|
}
|
|
1375
|
-
class
|
|
1391
|
+
class le {
|
|
1376
1392
|
/**
|
|
1377
1393
|
* Upload asset file with app ID. Uploads a file to a specific app's assets directory.
|
|
1378
1394
|
*
|
|
@@ -1383,8 +1399,8 @@ class cn {
|
|
|
1383
1399
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1384
1400
|
* @returns {Promise<SuccessResponse>} Result of the upload operation.
|
|
1385
1401
|
*/
|
|
1386
|
-
async AssetsUpload(
|
|
1387
|
-
return await
|
|
1402
|
+
async AssetsUpload(n) {
|
|
1403
|
+
return await ae(this.apiClient, n);
|
|
1388
1404
|
}
|
|
1389
1405
|
/**
|
|
1390
1406
|
* Delete app assets. Deletes all assets for a specific app ID.
|
|
@@ -1394,28 +1410,28 @@ class cn {
|
|
|
1394
1410
|
* @param {TimeoutOptions['timeout']} [params.timeout] - Request timeout in milliseconds.
|
|
1395
1411
|
* @returns {Promise<SuccessResponse>} Result of the delete operation.
|
|
1396
1412
|
*/
|
|
1397
|
-
async AssetsDelete(
|
|
1398
|
-
return await
|
|
1413
|
+
async AssetsDelete(n) {
|
|
1414
|
+
return await ue(this.apiClient, n);
|
|
1399
1415
|
}
|
|
1400
1416
|
}
|
|
1401
|
-
const
|
|
1402
|
-
function
|
|
1403
|
-
const
|
|
1404
|
-
if (
|
|
1417
|
+
const fe = "http://10.0.4.20", ce = "https://proxy.busy.app", de = /^https?:\/\/proxy(?:\.(?:dev|test|stage))?\.busy\.app$/i;
|
|
1418
|
+
function pe(e) {
|
|
1419
|
+
const n = e.split(".");
|
|
1420
|
+
if (n.length !== 4)
|
|
1405
1421
|
return !1;
|
|
1406
|
-
for (const
|
|
1407
|
-
if (
|
|
1422
|
+
for (const t of n) {
|
|
1423
|
+
if (t.length === 0 || t.length > 1 && t[0] === "0" || !/^\d+$/.test(t))
|
|
1408
1424
|
return !1;
|
|
1409
|
-
const
|
|
1410
|
-
if (
|
|
1425
|
+
const r = Number(t);
|
|
1426
|
+
if (r < 0 || r > 255)
|
|
1411
1427
|
return !1;
|
|
1412
1428
|
}
|
|
1413
1429
|
return !0;
|
|
1414
1430
|
}
|
|
1415
|
-
function
|
|
1416
|
-
return /\.local$/i.test(
|
|
1431
|
+
function he(e) {
|
|
1432
|
+
return /\.local$/i.test(e);
|
|
1417
1433
|
}
|
|
1418
|
-
class
|
|
1434
|
+
class ye {
|
|
1419
1435
|
/**
|
|
1420
1436
|
* Creates an instance of BUSY Bar.
|
|
1421
1437
|
* Initializes the API client with the provided host address.
|
|
@@ -1437,8 +1453,13 @@ class pn {
|
|
|
1437
1453
|
*
|
|
1438
1454
|
* Must be provided when `addr` points to a secured proxy endpoint
|
|
1439
1455
|
* such as `https://proxy.busy.app`.
|
|
1456
|
+
*
|
|
1457
|
+
* @param {BusyBarConfig['timeout']} config.timeout -
|
|
1458
|
+
* Optional default timeout for all requests in milliseconds.
|
|
1459
|
+
*
|
|
1460
|
+
* Defaults to `3000` if not provided. This value can be overridden in individual method calls.
|
|
1440
1461
|
*/
|
|
1441
|
-
constructor(
|
|
1462
|
+
constructor(n) {
|
|
1442
1463
|
/**
|
|
1443
1464
|
* Device host address (IP or mDNS).
|
|
1444
1465
|
* @type {BusyBarConfig['host']}
|
|
@@ -1463,330 +1484,90 @@ class pn {
|
|
|
1463
1484
|
* - "unknown": Detection failed or not yet completed.
|
|
1464
1485
|
*/
|
|
1465
1486
|
l(this, "connectionType", "unknown");
|
|
1466
|
-
if (!
|
|
1467
|
-
this.addr =
|
|
1468
|
-
else if (!
|
|
1469
|
-
this.addr =
|
|
1487
|
+
if (!n || !n.addr && !n.token)
|
|
1488
|
+
this.addr = fe;
|
|
1489
|
+
else if (!n.addr)
|
|
1490
|
+
this.addr = ce;
|
|
1470
1491
|
else {
|
|
1471
|
-
let o =
|
|
1472
|
-
if (/^https?:\/\//i.test(o) || (o = `http://${o}`),
|
|
1492
|
+
let o = n.addr.trim();
|
|
1493
|
+
if (/^https?:\/\//i.test(o) || (o = `http://${o}`), de.test(o) && !n.token)
|
|
1473
1494
|
throw new Error("Token is required. Please provide it.");
|
|
1474
1495
|
this.addr = o;
|
|
1475
1496
|
}
|
|
1476
1497
|
this.apiSemver = "";
|
|
1477
|
-
const { client:
|
|
1478
|
-
this.apiClient =
|
|
1498
|
+
const { client: t, setApiKey: r, setToken: i } = M(`${this.addr}/api/`, this.SystemVersionGet.bind(this), n == null ? void 0 : n.token, n == null ? void 0 : n.timeout);
|
|
1499
|
+
this.apiClient = t, this.setApiKeyFn = r, this.setTokenFn = i, this.detectConnectionType();
|
|
1479
1500
|
}
|
|
1480
1501
|
/**
|
|
1481
1502
|
* Probes the device to determine connection type.
|
|
1482
1503
|
* Sends a request without authentication credentials.
|
|
1483
1504
|
*/
|
|
1484
1505
|
async detectConnectionType() {
|
|
1485
|
-
const
|
|
1486
|
-
if (!
|
|
1506
|
+
const n = new URL(this.addr).hostname;
|
|
1507
|
+
if (!pe(n) && !he(n)) {
|
|
1487
1508
|
this.connectionType = "wifi";
|
|
1488
1509
|
return;
|
|
1489
1510
|
}
|
|
1490
|
-
const
|
|
1511
|
+
const t = D({
|
|
1491
1512
|
baseUrl: `${this.addr}/api/`
|
|
1492
1513
|
});
|
|
1493
1514
|
try {
|
|
1494
|
-
const { response:
|
|
1495
|
-
if (
|
|
1515
|
+
const { response: r } = await t.GET("/name");
|
|
1516
|
+
if (r.status === 401 || r.status === 403)
|
|
1496
1517
|
this.connectionType = "wifi";
|
|
1497
|
-
else if (
|
|
1518
|
+
else if (r.ok)
|
|
1498
1519
|
this.connectionType = "usb";
|
|
1499
1520
|
else
|
|
1500
|
-
throw new Error(`Failed to detect connection type. Status: ${
|
|
1501
|
-
} catch (
|
|
1502
|
-
throw
|
|
1521
|
+
throw new Error(`Failed to detect connection type. Status: ${r.status}`);
|
|
1522
|
+
} catch (r) {
|
|
1523
|
+
throw r;
|
|
1503
1524
|
}
|
|
1504
1525
|
}
|
|
1505
1526
|
/**
|
|
1506
1527
|
* Sets API key for all subsequent requests.
|
|
1507
1528
|
* @param {string} key - API key to use in "X-API-Token" header.
|
|
1508
1529
|
*/
|
|
1509
|
-
setApiKey(
|
|
1510
|
-
this.setApiKeyFn(
|
|
1530
|
+
setApiKey(n) {
|
|
1531
|
+
this.setApiKeyFn(n);
|
|
1511
1532
|
}
|
|
1512
1533
|
/**
|
|
1513
1534
|
* Sets Bearer token for all subsequent requests.
|
|
1514
1535
|
* @param {string} token - Bearer token to use in "Authorization" header.
|
|
1515
1536
|
*/
|
|
1516
|
-
setToken(
|
|
1517
|
-
this.setTokenFn(
|
|
1537
|
+
setToken(n) {
|
|
1538
|
+
this.setTokenFn(n);
|
|
1518
1539
|
}
|
|
1519
1540
|
}
|
|
1520
|
-
function
|
|
1521
|
-
|
|
1522
|
-
Object.getOwnPropertyNames(
|
|
1523
|
-
Object.defineProperty(
|
|
1541
|
+
function me(e, n) {
|
|
1542
|
+
n.forEach((t) => {
|
|
1543
|
+
Object.getOwnPropertyNames(t.prototype).forEach((r) => {
|
|
1544
|
+
Object.defineProperty(e.prototype, r, Object.getOwnPropertyDescriptor(t.prototype, r) || /* @__PURE__ */ Object.create(null));
|
|
1524
1545
|
});
|
|
1525
1546
|
});
|
|
1526
1547
|
}
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1548
|
+
me(ye, [
|
|
1549
|
+
K,
|
|
1550
|
+
on,
|
|
1551
|
+
cn,
|
|
1552
|
+
gn,
|
|
1553
|
+
Rn,
|
|
1554
|
+
In,
|
|
1555
|
+
jn,
|
|
1556
|
+
Gn,
|
|
1557
|
+
Hn,
|
|
1558
|
+
Zn,
|
|
1559
|
+
ne,
|
|
1560
|
+
se,
|
|
1561
|
+
le
|
|
1541
1562
|
]);
|
|
1542
|
-
var
|
|
1543
|
-
const j = 3e3, P = /* @__PURE__ */ new Set([1001, 1006, 1012, 1013, 1014, 3008]);
|
|
1544
|
-
function D(r, e) {
|
|
1545
|
-
if (e < 0 || e >= r.length)
|
|
1546
|
-
throw new Error(`Index ${e} is out of bounds (0…${r.length - 1})`);
|
|
1547
|
-
const n = r[e];
|
|
1548
|
-
if (n === void 0)
|
|
1549
|
-
throw new Error(`Unexpected undefined at index ${e}`);
|
|
1550
|
-
return n;
|
|
1551
|
-
}
|
|
1552
|
-
function yn(r, e) {
|
|
1553
|
-
let n = 0;
|
|
1554
|
-
const t = r.length, i = [];
|
|
1555
|
-
for (; n < t; ) {
|
|
1556
|
-
const o = D(r, n);
|
|
1557
|
-
if (n += 1, (o & 128) !== 0) {
|
|
1558
|
-
const a = o & 127;
|
|
1559
|
-
for (let c = 0; c < a * e; c++)
|
|
1560
|
-
i.push(r[n + c]);
|
|
1561
|
-
n += a * e;
|
|
1562
|
-
} else {
|
|
1563
|
-
const a = o, c = r.slice(n, n + e);
|
|
1564
|
-
for (let u = 0; u < a; u++)
|
|
1565
|
-
for (let m = 0; m < e; m++)
|
|
1566
|
-
i.push(c[m]);
|
|
1567
|
-
n += e;
|
|
1568
|
-
}
|
|
1569
|
-
}
|
|
1570
|
-
return new Uint8Array(i);
|
|
1571
|
-
}
|
|
1572
|
-
function mn(r) {
|
|
1573
|
-
const e = new Uint8Array(r.length * 2);
|
|
1574
|
-
let n = 0, t = 0;
|
|
1575
|
-
for (; n < r.length; ) {
|
|
1576
|
-
const i = D(r, n), o = i & 15, a = i >> 4 & 15;
|
|
1577
|
-
e[t] = o, e[t + 1] = a, n += 1, t += 2;
|
|
1578
|
-
}
|
|
1579
|
-
return e;
|
|
1580
|
-
}
|
|
1581
|
-
const L = () => typeof window < "u" && typeof window.document < "u";
|
|
1582
|
-
class On {
|
|
1583
|
-
constructor(e) {
|
|
1584
|
-
l(this, "addr");
|
|
1585
|
-
l(this, "connected", !1);
|
|
1586
|
-
// @ts-ignore
|
|
1587
|
-
l(this, "apiKey");
|
|
1588
|
-
// @ts-ignore
|
|
1589
|
-
l(this, "apiSemver");
|
|
1590
|
-
l(this, "dataListeners", []);
|
|
1591
|
-
l(this, "stopListeners", []);
|
|
1592
|
-
l(this, "errorListeners", []);
|
|
1593
|
-
l(this, "socket", null);
|
|
1594
|
-
if (this.config = e, !L())
|
|
1595
|
-
throw new Error("not browser");
|
|
1596
|
-
if (e.apiKey && (this.apiKey = e.apiKey), e.apiSemver && (this.apiSemver = e.apiSemver), !e || !e.addr)
|
|
1597
|
-
this.addr = N;
|
|
1598
|
-
else {
|
|
1599
|
-
let n = e.addr.trim();
|
|
1600
|
-
/^https?:\/\//i.test(n) || (n = `http://${n}`);
|
|
1601
|
-
try {
|
|
1602
|
-
const i = new URL(n).hostname;
|
|
1603
|
-
if (!k(i) && !C(i))
|
|
1604
|
-
throw new Error(`Invalid address: "${e.addr}". Only IP addresses and mDNS names (ending in .local) are supported.`);
|
|
1605
|
-
} catch (t) {
|
|
1606
|
-
throw t instanceof Error && t.message.startsWith("Invalid address") ? t : new Error(`Invalid URL format: "${e.addr}"`);
|
|
1607
|
-
}
|
|
1608
|
-
this.addr = n;
|
|
1609
|
-
}
|
|
1610
|
-
}
|
|
1611
|
-
onData(e) {
|
|
1612
|
-
this.dataListeners.push(e);
|
|
1613
|
-
}
|
|
1614
|
-
onStop(e) {
|
|
1615
|
-
this.stopListeners.push(e);
|
|
1616
|
-
}
|
|
1617
|
-
onError(e) {
|
|
1618
|
-
this.errorListeners.push(e);
|
|
1619
|
-
}
|
|
1620
|
-
emitData(e) {
|
|
1621
|
-
for (const n of this.dataListeners)
|
|
1622
|
-
n(e);
|
|
1623
|
-
}
|
|
1624
|
-
emitStop() {
|
|
1625
|
-
for (const e of this.stopListeners)
|
|
1626
|
-
e();
|
|
1627
|
-
}
|
|
1628
|
-
emitError(e) {
|
|
1629
|
-
for (const n of this.errorListeners)
|
|
1630
|
-
n(e);
|
|
1631
|
-
}
|
|
1632
|
-
async openWebsocket() {
|
|
1633
|
-
this.socket && await this.closeWebsocket();
|
|
1634
|
-
const e = new URL(`${this.addr}/api/screen/ws`);
|
|
1635
|
-
if (this.apiKey && e.searchParams.append("x-api-token", this.apiKey), this.apiSemver && e.searchParams.append("x-api-sem-ver", this.apiSemver), !e)
|
|
1636
|
-
throw new Error("The WebSocket URL is not specified");
|
|
1637
|
-
this.socket = new WebSocket(e), this.socket.onopen = () => {
|
|
1638
|
-
this.socket && (this.socket.send(JSON.stringify({ display: this.config.deviceScreen })), this.connected = !0);
|
|
1639
|
-
}, this.socket.binaryType = "arraybuffer", this.socket.onmessage = (n) => {
|
|
1640
|
-
try {
|
|
1641
|
-
if (typeof n.data == "string")
|
|
1642
|
-
return;
|
|
1643
|
-
const t = new Uint8Array(n.data);
|
|
1644
|
-
let i;
|
|
1645
|
-
const o = this.config.deviceScreen === A.FRONT ? 3 : 2;
|
|
1646
|
-
try {
|
|
1647
|
-
const a = yn(t, o);
|
|
1648
|
-
this.config.deviceScreen === A.BACK ? i = mn(a) : i = a, this.emitData(i);
|
|
1649
|
-
} catch {
|
|
1650
|
-
this.emitData(t);
|
|
1651
|
-
}
|
|
1652
|
-
} catch {
|
|
1653
|
-
this.connected = !1, this.emitStop();
|
|
1654
|
-
}
|
|
1655
|
-
}, this.socket.onerror = (n) => {
|
|
1656
|
-
this.connected = !1, this.emitError({
|
|
1657
|
-
code: 1006,
|
|
1658
|
-
// Standard «abnormal closure» code per RFC-6455
|
|
1659
|
-
message: "WebSocket error occurred",
|
|
1660
|
-
raw: n
|
|
1661
|
-
}), this.emitStop();
|
|
1662
|
-
}, this.socket.onclose = async (n) => {
|
|
1663
|
-
if (this.socket = null, this.connected = !1, n.code === j || P.has(n.code)) {
|
|
1664
|
-
this.emitError({
|
|
1665
|
-
code: n.code,
|
|
1666
|
-
message: n.reason,
|
|
1667
|
-
raw: n
|
|
1668
|
-
});
|
|
1669
|
-
return;
|
|
1670
|
-
}
|
|
1671
|
-
this.emitStop();
|
|
1672
|
-
};
|
|
1673
|
-
}
|
|
1674
|
-
closeWebsocket() {
|
|
1675
|
-
return this.connected = !1, new Promise((e) => {
|
|
1676
|
-
this.socket ? (this.socket.onclose = () => {
|
|
1677
|
-
e();
|
|
1678
|
-
}, this.socket.close(), this.socket = null) : e(), this.emitStop();
|
|
1679
|
-
});
|
|
1680
|
-
}
|
|
1681
|
-
}
|
|
1682
|
-
class wn {
|
|
1683
|
-
constructor(e) {
|
|
1684
|
-
l(this, "addr");
|
|
1685
|
-
l(this, "connected", !1);
|
|
1686
|
-
// @ts-ignore
|
|
1687
|
-
l(this, "apiKey");
|
|
1688
|
-
// @ts-ignore
|
|
1689
|
-
l(this, "apiSemver");
|
|
1690
|
-
l(this, "inputEvent");
|
|
1691
|
-
l(this, "dataListeners", []);
|
|
1692
|
-
l(this, "stopListeners", []);
|
|
1693
|
-
l(this, "errorListeners", []);
|
|
1694
|
-
l(this, "socket", null);
|
|
1695
|
-
if (!L())
|
|
1696
|
-
throw new Error("not browser");
|
|
1697
|
-
if (e != null && e.apiKey && (this.apiKey = e.apiKey), e != null && e.apiSemver && (this.apiSemver = e.apiSemver), !e || !e.addr)
|
|
1698
|
-
this.addr = N;
|
|
1699
|
-
else {
|
|
1700
|
-
let n = e.addr.trim();
|
|
1701
|
-
/^https?:\/\//i.test(n) || (n = `http://${n}`);
|
|
1702
|
-
try {
|
|
1703
|
-
const i = new URL(n).hostname;
|
|
1704
|
-
if (!k(i) && !C(i))
|
|
1705
|
-
throw new Error(`Invalid address: "${e.addr}". Only IP addresses and mDNS names (ending in .local) are supported.`);
|
|
1706
|
-
} catch (t) {
|
|
1707
|
-
throw t instanceof Error && t.message.startsWith("Invalid address") ? t : new Error(`Invalid URL format: "${e.addr}"`);
|
|
1708
|
-
}
|
|
1709
|
-
this.addr = n;
|
|
1710
|
-
}
|
|
1711
|
-
this.inputEvent = {};
|
|
1712
|
-
}
|
|
1713
|
-
onData(e) {
|
|
1714
|
-
this.dataListeners.push(e);
|
|
1715
|
-
}
|
|
1716
|
-
onStop(e) {
|
|
1717
|
-
this.stopListeners.push(e);
|
|
1718
|
-
}
|
|
1719
|
-
onError(e) {
|
|
1720
|
-
this.errorListeners.push(e);
|
|
1721
|
-
}
|
|
1722
|
-
emitData(e) {
|
|
1723
|
-
for (const n of this.dataListeners)
|
|
1724
|
-
n(e);
|
|
1725
|
-
}
|
|
1726
|
-
emitStop() {
|
|
1727
|
-
for (const e of this.stopListeners)
|
|
1728
|
-
e();
|
|
1729
|
-
}
|
|
1730
|
-
emitError(e) {
|
|
1731
|
-
for (const n of this.errorListeners)
|
|
1732
|
-
n(e);
|
|
1733
|
-
}
|
|
1734
|
-
async openWebsocket() {
|
|
1735
|
-
this.socket && await this.closeWebsocket();
|
|
1736
|
-
const e = new URL(`${this.addr}/api/input`);
|
|
1737
|
-
if (this.apiKey && e.searchParams.append("x-api-token", this.apiKey), this.apiSemver && e.searchParams.append("x-api-sem-ver", this.apiSemver), !e)
|
|
1738
|
-
throw new Error("The WebSocket URL is not specified");
|
|
1739
|
-
this.socket = new WebSocket(e), this.socket.onopen = () => {
|
|
1740
|
-
this.socket && (this.connected = !0);
|
|
1741
|
-
}, this.socket.binaryType = "arraybuffer", this.socket.onmessage = (n) => {
|
|
1742
|
-
try {
|
|
1743
|
-
if (typeof n.data == "string")
|
|
1744
|
-
return;
|
|
1745
|
-
const t = new Uint8Array(n.data);
|
|
1746
|
-
this.emitData(t);
|
|
1747
|
-
} catch {
|
|
1748
|
-
this.connected = !1, this.emitStop();
|
|
1749
|
-
}
|
|
1750
|
-
}, this.socket.onerror = (n) => {
|
|
1751
|
-
this.connected = !1, this.emitError({
|
|
1752
|
-
code: 1006,
|
|
1753
|
-
// Standard «abnormal closure» code per RFC-6455
|
|
1754
|
-
message: "WebSocket error occurred",
|
|
1755
|
-
raw: n
|
|
1756
|
-
}), this.emitStop();
|
|
1757
|
-
}, this.socket.onclose = async (n) => {
|
|
1758
|
-
if (this.socket = null, this.connected = !1, n.code === j || P.has(n.code)) {
|
|
1759
|
-
this.emitError({
|
|
1760
|
-
code: n.code,
|
|
1761
|
-
message: n.reason,
|
|
1762
|
-
raw: n
|
|
1763
|
-
});
|
|
1764
|
-
return;
|
|
1765
|
-
}
|
|
1766
|
-
this.emitStop();
|
|
1767
|
-
};
|
|
1768
|
-
}
|
|
1769
|
-
sendInput({ keyName: e, value: n }) {
|
|
1770
|
-
if (!this.socket || !this.connected)
|
|
1771
|
-
throw new Error("WebSocket: Not connected");
|
|
1772
|
-
this.inputEvent[e] = n, this.socket.send(JSON.stringify(this.inputEvent)), n === 0 && delete this.inputEvent[e];
|
|
1773
|
-
}
|
|
1774
|
-
closeWebsocket() {
|
|
1775
|
-
return this.connected = !1, new Promise((e) => {
|
|
1776
|
-
this.socket ? (this.socket.onclose = () => {
|
|
1777
|
-
e();
|
|
1778
|
-
}, this.socket.close(), this.socket = null) : e(), this.emitStop();
|
|
1779
|
-
});
|
|
1780
|
-
}
|
|
1781
|
-
}
|
|
1782
|
-
var d = /* @__PURE__ */ ((r) => (r.CONNECTION_FAILED = "CONNECTION_FAILED", r.RECONNECT_FAILED = "RECONNECT_FAILED", r.CONNECTION_LOST = "CONNECTION_LOST", r.CONNECTION_TIMEOUT = "CONNECTION_TIMEOUT", r.AUTH_FAILED = "AUTH_FAILED", r.AUTH_REFRESH_FAILED = "AUTH_REFRESH_FAILED", r.DEVICE_ERROR = "DEVICE_ERROR", r.DECODE_ERROR = "DECODE_ERROR", r.FRAME_PROCESS_ERROR = "FRAME_PROCESS_ERROR", r.STREAM_ALREADY_STARTED = "STREAM_ALREADY_STARTED", r.WORKER_INIT_FAILED = "WORKER_INIT_FAILED", r.UNKNOWN_ERROR = "UNKNOWN_ERROR", r))(d || {});
|
|
1563
|
+
var c = /* @__PURE__ */ ((e) => (e.CONNECTION_FAILED = "CONNECTION_FAILED", e.RECONNECT_FAILED = "RECONNECT_FAILED", e.CONNECTION_LOST = "CONNECTION_LOST", e.CONNECTION_TIMEOUT = "CONNECTION_TIMEOUT", e.AUTH_FAILED = "AUTH_FAILED", e.AUTH_REFRESH_FAILED = "AUTH_REFRESH_FAILED", e.DEVICE_ERROR = "DEVICE_ERROR", e.DECODE_ERROR = "DECODE_ERROR", e.FRAME_PROCESS_ERROR = "FRAME_PROCESS_ERROR", e.STREAM_ALREADY_STARTED = "STREAM_ALREADY_STARTED", e.WORKER_INIT_FAILED = "WORKER_INIT_FAILED", e.UNKNOWN_ERROR = "UNKNOWN_ERROR", e))(c || {});
|
|
1783
1564
|
class y extends Error {
|
|
1784
|
-
constructor(
|
|
1785
|
-
super(
|
|
1565
|
+
constructor(n, t, r) {
|
|
1566
|
+
super(t), this.code = n, this.data = r, this.name = "StateStreamError";
|
|
1786
1567
|
}
|
|
1787
1568
|
}
|
|
1788
|
-
var
|
|
1789
|
-
const
|
|
1569
|
+
var d = /* @__PURE__ */ ((e) => (e.IDLE = "IDLE", e.STARTING = "STARTING", e.RUNNING = "RUNNING", e.STOPPED = "STOPPED", e.FAILED = "FAILED", e))(d || {}), m = /* @__PURE__ */ ((e) => (e.DISCONNECTED = "DISCONNECTED", e.CONNECTING = "CONNECTING", e.CONNECTED = "CONNECTED", e.RECONNECTING = "RECONNECTING", e))(m || {}), b = /* @__PURE__ */ ((e) => (e.UNAUTHENTICATED = "UNAUTHENTICATED", e.AUTHENTICATING = "AUTHENTICATING", e.AUTHENTICATED = "AUTHENTICATED", e.FAILED = "FAILED", e))(b || {}), E = /* @__PURE__ */ ((e) => (e.NONE = "NONE", e.ACTIVE = "ACTIVE", e.STALE = "STALE", e))(E || {}), _ = /* @__PURE__ */ ((e) => (e.OFF = "OFF", e.INITIALIZING = "INITIALIZING", e.READY = "READY", e.ERROR = "ERROR", e))(_ || {});
|
|
1570
|
+
const L = `var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, src = { exports: {} }, indexLight = { exports: {} }, indexMinimal = {}, minimal = {}, aspromise, hasRequiredAspromise;
|
|
1790
1571
|
function requireAspromise() {
|
|
1791
1572
|
if (hasRequiredAspromise) return aspromise;
|
|
1792
1573
|
hasRequiredAspromise = 1, aspromise = u;
|
|
@@ -5693,10 +5474,12 @@ function connect(u, f, h = !0, c = "local") {
|
|
|
5693
5474
|
code: StateStreamErrorCode.DEVICE_ERROR,
|
|
5694
5475
|
message: \`Server reported \${E}: \${y}\`,
|
|
5695
5476
|
data: l.error
|
|
5696
|
-
}), a === p.values.FATAL
|
|
5477
|
+
}), a === p.values.FATAL) {
|
|
5697
5478
|
stopAndCleanup();
|
|
5698
5479
|
return;
|
|
5699
5480
|
}
|
|
5481
|
+
if (a === p.values.ERROR)
|
|
5482
|
+
return;
|
|
5700
5483
|
} else
|
|
5701
5484
|
broadcast({
|
|
5702
5485
|
type: "ERROR",
|
|
@@ -5727,7 +5510,12 @@ function connect(u, f, h = !0, c = "local") {
|
|
|
5727
5510
|
} : { type: "DATA", data: l });
|
|
5728
5511
|
}
|
|
5729
5512
|
} catch (e) {
|
|
5730
|
-
broadcast({
|
|
5513
|
+
broadcast({
|
|
5514
|
+
type: "ERROR",
|
|
5515
|
+
code: StateStreamErrorCode.DECODE_ERROR,
|
|
5516
|
+
message: \`Decode error: \${String(e)}\`,
|
|
5517
|
+
data: n.data
|
|
5518
|
+
});
|
|
5731
5519
|
}
|
|
5732
5520
|
}).catch(console.error);
|
|
5733
5521
|
}, socket.onerror = () => {
|
|
@@ -5811,29 +5599,29 @@ if ("SharedWorkerGlobalScope" in self) {
|
|
|
5811
5599
|
handleCommand(f.data, u);
|
|
5812
5600
|
};
|
|
5813
5601
|
}
|
|
5814
|
-
`,
|
|
5815
|
-
function
|
|
5816
|
-
let
|
|
5602
|
+
`, N = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", L], { type: "text/javascript;charset=utf-8" });
|
|
5603
|
+
function ve(e) {
|
|
5604
|
+
let n;
|
|
5817
5605
|
try {
|
|
5818
|
-
if (
|
|
5819
|
-
const
|
|
5606
|
+
if (n = N && (self.URL || self.webkitURL).createObjectURL(N), !n) throw "";
|
|
5607
|
+
const t = new Worker(n, {
|
|
5820
5608
|
type: "module",
|
|
5821
|
-
name:
|
|
5609
|
+
name: e == null ? void 0 : e.name
|
|
5822
5610
|
});
|
|
5823
|
-
return
|
|
5824
|
-
(self.URL || self.webkitURL).revokeObjectURL(
|
|
5825
|
-
}),
|
|
5611
|
+
return t.addEventListener("error", () => {
|
|
5612
|
+
(self.URL || self.webkitURL).revokeObjectURL(n);
|
|
5613
|
+
}), t;
|
|
5826
5614
|
} catch {
|
|
5827
5615
|
return new Worker(
|
|
5828
|
-
"data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
5616
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(L),
|
|
5829
5617
|
{
|
|
5830
5618
|
type: "module",
|
|
5831
|
-
name:
|
|
5619
|
+
name: e == null ? void 0 : e.name
|
|
5832
5620
|
}
|
|
5833
5621
|
);
|
|
5834
5622
|
}
|
|
5835
5623
|
}
|
|
5836
|
-
const
|
|
5624
|
+
const ge = `var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, src = { exports: {} }, indexLight = { exports: {} }, indexMinimal = {}, minimal = {}, aspromise, hasRequiredAspromise;
|
|
5837
5625
|
function requireAspromise() {
|
|
5838
5626
|
if (hasRequiredAspromise) return aspromise;
|
|
5839
5627
|
hasRequiredAspromise = 1, aspromise = u;
|
|
@@ -9740,10 +9528,12 @@ function connect(u, f, h = !0, c = "local") {
|
|
|
9740
9528
|
code: StateStreamErrorCode.DEVICE_ERROR,
|
|
9741
9529
|
message: \`Server reported \${E}: \${y}\`,
|
|
9742
9530
|
data: l.error
|
|
9743
|
-
}), a === p.values.FATAL
|
|
9531
|
+
}), a === p.values.FATAL) {
|
|
9744
9532
|
stopAndCleanup();
|
|
9745
9533
|
return;
|
|
9746
9534
|
}
|
|
9535
|
+
if (a === p.values.ERROR)
|
|
9536
|
+
return;
|
|
9747
9537
|
} else
|
|
9748
9538
|
broadcast({
|
|
9749
9539
|
type: "ERROR",
|
|
@@ -9774,7 +9564,12 @@ function connect(u, f, h = !0, c = "local") {
|
|
|
9774
9564
|
} : { type: "DATA", data: l });
|
|
9775
9565
|
}
|
|
9776
9566
|
} catch (e) {
|
|
9777
|
-
broadcast({
|
|
9567
|
+
broadcast({
|
|
9568
|
+
type: "ERROR",
|
|
9569
|
+
code: StateStreamErrorCode.DECODE_ERROR,
|
|
9570
|
+
message: \`Decode error: \${String(e)}\`,
|
|
9571
|
+
data: n.data
|
|
9572
|
+
});
|
|
9778
9573
|
}
|
|
9779
9574
|
}).catch(console.error);
|
|
9780
9575
|
}, socket.onerror = () => {
|
|
@@ -9859,17 +9654,17 @@ if ("SharedWorkerGlobalScope" in self) {
|
|
|
9859
9654
|
};
|
|
9860
9655
|
}
|
|
9861
9656
|
`;
|
|
9862
|
-
function
|
|
9657
|
+
function be(e) {
|
|
9863
9658
|
return new SharedWorker(
|
|
9864
|
-
"data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
9659
|
+
"data:text/javascript;charset=utf-8," + encodeURIComponent(ge),
|
|
9865
9660
|
{
|
|
9866
9661
|
type: "module",
|
|
9867
|
-
name:
|
|
9662
|
+
name: e == null ? void 0 : e.name
|
|
9868
9663
|
}
|
|
9869
9664
|
);
|
|
9870
9665
|
}
|
|
9871
|
-
const
|
|
9872
|
-
constructor(
|
|
9666
|
+
const v = class v {
|
|
9667
|
+
constructor(n, t) {
|
|
9873
9668
|
l(this, "addr");
|
|
9874
9669
|
l(this, "token");
|
|
9875
9670
|
l(this, "isBinary");
|
|
@@ -9884,12 +9679,12 @@ const g = class g {
|
|
|
9884
9679
|
l(this, "rawDataCallback");
|
|
9885
9680
|
l(this, "errorCallback");
|
|
9886
9681
|
l(this, "statusCallback");
|
|
9887
|
-
this.addr =
|
|
9888
|
-
main: { status:
|
|
9889
|
-
connection: { status:
|
|
9890
|
-
auth: { status:
|
|
9891
|
-
data: { status:
|
|
9892
|
-
worker: { status:
|
|
9682
|
+
this.addr = n.addr || "", this.token = n.token, this.isBinary = n.isBinary ?? !0, this.connectTimeout = (t == null ? void 0 : t.timeout) ?? 5e3, this.dataTimeout = (t == null ? void 0 : t.dataTimeout) ?? 15e3, this._status = {
|
|
9683
|
+
main: { status: d.IDLE },
|
|
9684
|
+
connection: { status: m.DISCONNECTED },
|
|
9685
|
+
auth: { status: b.UNAUTHENTICATED },
|
|
9686
|
+
data: { status: E.NONE },
|
|
9687
|
+
worker: { status: _.OFF }
|
|
9893
9688
|
};
|
|
9894
9689
|
}
|
|
9895
9690
|
get status() {
|
|
@@ -9898,39 +9693,39 @@ const g = class g {
|
|
|
9898
9693
|
/**
|
|
9899
9694
|
* Transforms http/https to ws/wss and prefixes with auto-inferred protocol if no protocol present.
|
|
9900
9695
|
*/
|
|
9901
|
-
resolveProtocol(
|
|
9902
|
-
let
|
|
9903
|
-
if (
|
|
9904
|
-
return
|
|
9905
|
-
if (
|
|
9906
|
-
return
|
|
9907
|
-
if (
|
|
9908
|
-
return
|
|
9909
|
-
let
|
|
9910
|
-
return typeof window < "u" && window.location.protocol === "https:" && (
|
|
9696
|
+
resolveProtocol(n) {
|
|
9697
|
+
let t = n.trim();
|
|
9698
|
+
if (t.startsWith("https://"))
|
|
9699
|
+
return t.replace("https://", "wss://");
|
|
9700
|
+
if (t.startsWith("http://"))
|
|
9701
|
+
return t.replace("http://", "ws://");
|
|
9702
|
+
if (t.startsWith("wss://") || t.startsWith("ws://"))
|
|
9703
|
+
return t;
|
|
9704
|
+
let r = "ws:";
|
|
9705
|
+
return typeof window < "u" && window.location.protocol === "https:" && (r = "wss:"), `${r}//${t}`;
|
|
9911
9706
|
}
|
|
9912
9707
|
/**
|
|
9913
9708
|
* Starts the stream connection.
|
|
9914
9709
|
* Throws an error if already running.
|
|
9915
9710
|
*/
|
|
9916
9711
|
start({
|
|
9917
|
-
dataCallback:
|
|
9918
|
-
rawDataCallback:
|
|
9919
|
-
errorCallback:
|
|
9712
|
+
dataCallback: n,
|
|
9713
|
+
rawDataCallback: t,
|
|
9714
|
+
errorCallback: r,
|
|
9920
9715
|
statusCallback: i
|
|
9921
9716
|
}) {
|
|
9922
|
-
if (this._status.main.status ===
|
|
9923
|
-
const o = new y(
|
|
9717
|
+
if (this._status.main.status === d.STARTING || this._status.main.status === d.RUNNING) {
|
|
9718
|
+
const o = new y(c.STREAM_ALREADY_STARTED, "StateStream is already running. Call stop() before starting again.");
|
|
9924
9719
|
if (i && i({
|
|
9925
9720
|
...this._status,
|
|
9926
9721
|
main: { ...this._status.main, lastError: o }
|
|
9927
|
-
}),
|
|
9928
|
-
|
|
9722
|
+
}), r)
|
|
9723
|
+
r(o);
|
|
9929
9724
|
else
|
|
9930
9725
|
throw o;
|
|
9931
9726
|
return;
|
|
9932
9727
|
}
|
|
9933
|
-
this.dataCallback =
|
|
9728
|
+
this.dataCallback = n, this.rawDataCallback = t, this.errorCallback = r, this.statusCallback = i, this.updateStatusComponent("main", { status: d.STARTING, lastError: void 0 });
|
|
9934
9729
|
try {
|
|
9935
9730
|
this.ensureWorker(), this.sendCommand({
|
|
9936
9731
|
type: "START",
|
|
@@ -9939,19 +9734,19 @@ const g = class g {
|
|
|
9939
9734
|
isBinary: this.isBinary,
|
|
9940
9735
|
mode: this.streamMode
|
|
9941
9736
|
}), this.clearConnectionTimer(), this.connectionTimer = setTimeout(() => {
|
|
9942
|
-
const o = new y(
|
|
9737
|
+
const o = new y(c.CONNECTION_TIMEOUT, `Connection timed out after ${this.connectTimeout}ms`);
|
|
9943
9738
|
this.mapErrorToStatus(o), this.errorCallback && this.errorCallback(o), this.stop();
|
|
9944
9739
|
}, this.connectTimeout);
|
|
9945
9740
|
} catch (o) {
|
|
9946
|
-
const
|
|
9947
|
-
this.errorCallback && this.errorCallback(
|
|
9741
|
+
const s = o instanceof y ? o : new y(c.UNKNOWN_ERROR, String(o));
|
|
9742
|
+
this.errorCallback && this.errorCallback(s);
|
|
9948
9743
|
}
|
|
9949
9744
|
}
|
|
9950
9745
|
/**
|
|
9951
9746
|
* Stops the stream connection.
|
|
9952
9747
|
*/
|
|
9953
9748
|
stop() {
|
|
9954
|
-
this.clearConnectionTimer(), this.clearDataTimer(), !(this._status.main.status ===
|
|
9749
|
+
this.clearConnectionTimer(), this.clearDataTimer(), !(this._status.main.status === d.IDLE || this._status.main.status === d.STOPPED) && (this.updateStatusComponent("main", { status: d.STOPPED }), this.updateStatusComponent("connection", { status: m.DISCONNECTED }), this.sendCommand({ type: "STOP" }), this.clearCallbacks());
|
|
9955
9750
|
}
|
|
9956
9751
|
/**
|
|
9957
9752
|
* Cleans up all resources.
|
|
@@ -9968,87 +9763,87 @@ const g = class g {
|
|
|
9968
9763
|
/**
|
|
9969
9764
|
* Sends a new token to the worker (for auth or token refresh).
|
|
9970
9765
|
*/
|
|
9971
|
-
sendToken(
|
|
9972
|
-
this.token =
|
|
9766
|
+
sendToken(n) {
|
|
9767
|
+
this.token = n, this.sendCommand({ type: "UPDATE_TOKEN", token: n });
|
|
9973
9768
|
}
|
|
9974
9769
|
/**
|
|
9975
9770
|
* Sends a command to the worker port.
|
|
9976
9771
|
*/
|
|
9977
|
-
sendCommand(
|
|
9978
|
-
this.worker && this.worker.port.postMessage(
|
|
9772
|
+
sendCommand(n) {
|
|
9773
|
+
this.worker && this.worker.port.postMessage(n);
|
|
9979
9774
|
}
|
|
9980
9775
|
ensureWorker() {
|
|
9981
9776
|
if (this.worker || typeof window > "u") return;
|
|
9982
|
-
const
|
|
9777
|
+
const n = btoa(this.addr);
|
|
9983
9778
|
try {
|
|
9984
|
-
if (this.updateStatusComponent("worker", { status:
|
|
9985
|
-
const
|
|
9986
|
-
name:
|
|
9779
|
+
if (this.updateStatusComponent("worker", { status: _.INITIALIZING, lastError: void 0 }), window.SharedWorker) {
|
|
9780
|
+
const t = new be({
|
|
9781
|
+
name: n
|
|
9987
9782
|
});
|
|
9988
9783
|
this.worker = {
|
|
9989
|
-
port:
|
|
9990
|
-
},
|
|
9991
|
-
this.handleWorkerMessage(
|
|
9992
|
-
},
|
|
9784
|
+
port: t.port
|
|
9785
|
+
}, t.port.onmessage = (r) => {
|
|
9786
|
+
this.handleWorkerMessage(r.data);
|
|
9787
|
+
}, t.port.start();
|
|
9993
9788
|
} else {
|
|
9994
|
-
const
|
|
9789
|
+
const t = new ve();
|
|
9995
9790
|
this.worker = {
|
|
9996
|
-
port:
|
|
9997
|
-
terminate: () =>
|
|
9998
|
-
},
|
|
9999
|
-
this.handleWorkerMessage(
|
|
9791
|
+
port: t,
|
|
9792
|
+
terminate: () => t.terminate()
|
|
9793
|
+
}, t.onmessage = (r) => {
|
|
9794
|
+
this.handleWorkerMessage(r.data);
|
|
10000
9795
|
};
|
|
10001
9796
|
}
|
|
10002
|
-
this.updateStatusComponent("worker", { status:
|
|
10003
|
-
} catch (
|
|
10004
|
-
const
|
|
10005
|
-
throw this.updateStatusComponent("worker", { status:
|
|
9797
|
+
this.updateStatusComponent("worker", { status: _.READY });
|
|
9798
|
+
} catch (t) {
|
|
9799
|
+
const r = new y(c.WORKER_INIT_FAILED, `Failed to initialize worker: ${String(t)}`);
|
|
9800
|
+
throw this.updateStatusComponent("worker", { status: _.ERROR, lastError: r }), this.updateStatusComponent("main", { status: d.FAILED, lastError: r }), r;
|
|
10006
9801
|
}
|
|
10007
9802
|
}
|
|
10008
9803
|
/**
|
|
10009
9804
|
* Processes messages from the worker.
|
|
10010
9805
|
*/
|
|
10011
|
-
handleWorkerMessage(
|
|
10012
|
-
switch (
|
|
9806
|
+
handleWorkerMessage(n) {
|
|
9807
|
+
switch (n.type) {
|
|
10013
9808
|
case "DATA":
|
|
10014
|
-
this.resetDataTimer(), this.dataCallback && this.dataCallback(this.normalizeState(
|
|
9809
|
+
this.resetDataTimer(), this.dataCallback && this.dataCallback(this.normalizeState(n.data));
|
|
10015
9810
|
break;
|
|
10016
9811
|
case "RAW_DATA":
|
|
10017
|
-
this.resetDataTimer(), this.rawDataCallback && this.rawDataCallback(
|
|
9812
|
+
this.resetDataTimer(), this.rawDataCallback && this.rawDataCallback(n.data);
|
|
10018
9813
|
break;
|
|
10019
9814
|
case "CONNECTED":
|
|
10020
|
-
this.clearConnectionTimer(), this.updateStatusComponent("connection", { status:
|
|
9815
|
+
this.clearConnectionTimer(), this.updateStatusComponent("connection", { status: m.CONNECTED }), this.streamMode === "local" && this.updateStatusComponent("main", { status: d.RUNNING });
|
|
10021
9816
|
break;
|
|
10022
9817
|
case "STATUS_UPDATE":
|
|
10023
|
-
|
|
9818
|
+
n.connection && this.updateStatusComponent("connection", { status: n.connection }), n.auth && (this.updateStatusComponent("auth", { status: n.auth }), n.auth === b.AUTHENTICATED && this.updateStatusComponent("main", { status: d.RUNNING }));
|
|
10024
9819
|
break;
|
|
10025
9820
|
case "ERROR": {
|
|
10026
9821
|
this.clearConnectionTimer();
|
|
10027
|
-
const
|
|
10028
|
-
this.mapErrorToStatus(
|
|
9822
|
+
const t = new y(n.code, n.message, n.data);
|
|
9823
|
+
this.mapErrorToStatus(t), this.errorCallback && this.errorCallback(t);
|
|
10029
9824
|
break;
|
|
10030
9825
|
}
|
|
10031
9826
|
case "TOKEN_EXPIRED":
|
|
10032
|
-
this.updateStatusComponent("auth", { status:
|
|
9827
|
+
this.updateStatusComponent("auth", { status: b.AUTHENTICATING }), this.handleTokenExpiredInternal();
|
|
10033
9828
|
break;
|
|
10034
9829
|
case "DISCONNECTED":
|
|
10035
|
-
this.updateStatusComponent("connection", { status:
|
|
9830
|
+
this.updateStatusComponent("connection", { status: m.DISCONNECTED });
|
|
10036
9831
|
break;
|
|
10037
9832
|
}
|
|
10038
9833
|
}
|
|
10039
9834
|
/**
|
|
10040
9835
|
* Maps an error code to the corresponding status component
|
|
10041
9836
|
*/
|
|
10042
|
-
mapErrorToStatus(
|
|
10043
|
-
const
|
|
10044
|
-
(
|
|
9837
|
+
mapErrorToStatus(n) {
|
|
9838
|
+
const t = n.code;
|
|
9839
|
+
(t === c.CONNECTION_FAILED || t === c.CONNECTION_LOST || t === c.RECONNECT_FAILED || t === c.CONNECTION_TIMEOUT) && (this.updateStatusComponent("connection", { status: m.DISCONNECTED, lastError: n }), this.updateStatusComponent("main", { status: d.FAILED, lastError: n })), (t === c.AUTH_FAILED || t === c.AUTH_REFRESH_FAILED) && (this.updateStatusComponent("auth", { status: b.FAILED, lastError: n }), this.updateStatusComponent("main", { status: d.FAILED, lastError: n })), (t === c.DEVICE_ERROR || t === c.DECODE_ERROR) && this.updateStatusComponent("main", { lastError: n });
|
|
10045
9840
|
}
|
|
10046
9841
|
/**
|
|
10047
9842
|
* Updates a single component of the status and notifies listeners
|
|
10048
9843
|
*/
|
|
10049
|
-
updateStatusComponent(
|
|
10050
|
-
const
|
|
10051
|
-
this._status[
|
|
9844
|
+
updateStatusComponent(n, t) {
|
|
9845
|
+
const r = this._status[n];
|
|
9846
|
+
this._status[n] = { ...r, ...t }, this.statusCallback && this.statusCallback({ ...this._status });
|
|
10052
9847
|
}
|
|
10053
9848
|
/**
|
|
10054
9849
|
* Safe timer cleanup
|
|
@@ -10060,11 +9855,11 @@ const g = class g {
|
|
|
10060
9855
|
* Reset the data inactivity timer
|
|
10061
9856
|
*/
|
|
10062
9857
|
resetDataTimer() {
|
|
10063
|
-
this.clearDataTimer(), this._status.data.status !==
|
|
10064
|
-
status:
|
|
9858
|
+
this.clearDataTimer(), this._status.data.status !== E.ACTIVE ? this.updateStatusComponent("data", {
|
|
9859
|
+
status: E.ACTIVE,
|
|
10065
9860
|
lastActivity: Date.now()
|
|
10066
9861
|
}) : this._status.data.lastActivity = Date.now(), this.dataTimer = setTimeout(() => {
|
|
10067
|
-
this.updateStatusComponent("data", { status:
|
|
9862
|
+
this.updateStatusComponent("data", { status: E.STALE });
|
|
10068
9863
|
}, this.dataTimeout);
|
|
10069
9864
|
}
|
|
10070
9865
|
clearDataTimer() {
|
|
@@ -10074,98 +9869,99 @@ const g = class g {
|
|
|
10074
9869
|
* Normalizes the raw state from the worker into a ProcessedState for the UI.
|
|
10075
9870
|
* Extracts the 'state' key for each update and merges bar_id for remote mode.
|
|
10076
9871
|
*/
|
|
10077
|
-
normalizeState(
|
|
10078
|
-
let
|
|
10079
|
-
"bar_id" in
|
|
10080
|
-
let i =
|
|
9872
|
+
normalizeState(n) {
|
|
9873
|
+
let t, r;
|
|
9874
|
+
"bar_id" in n && "state" in n ? (t = n.state, r = n.bar_id) : t = n;
|
|
9875
|
+
let i = t.updates;
|
|
10081
9876
|
return i && (i = i.map((o) => {
|
|
10082
|
-
const
|
|
9877
|
+
const s = Object.keys(o).find((u) => o[u] != null);
|
|
10083
9878
|
return {
|
|
10084
9879
|
...o,
|
|
10085
|
-
state:
|
|
9880
|
+
state: s
|
|
10086
9881
|
};
|
|
10087
9882
|
})), {
|
|
10088
|
-
...
|
|
9883
|
+
...t,
|
|
10089
9884
|
updates: i,
|
|
10090
|
-
bar_id:
|
|
9885
|
+
bar_id: r
|
|
10091
9886
|
};
|
|
10092
9887
|
}
|
|
10093
9888
|
/**
|
|
10094
9889
|
* Internally deduplicates token refresh requests for the same address.
|
|
10095
9890
|
*/
|
|
10096
9891
|
async handleTokenExpiredInternal() {
|
|
10097
|
-
const
|
|
10098
|
-
let
|
|
10099
|
-
if (!
|
|
9892
|
+
const n = this.addr;
|
|
9893
|
+
let t = v.tokenRefreshPromises.get(n);
|
|
9894
|
+
if (!t && this.onTokenExpired && (t = (async () => {
|
|
10100
9895
|
try {
|
|
10101
9896
|
const i = this.onTokenExpired();
|
|
10102
9897
|
return i instanceof Promise ? await i : "";
|
|
10103
9898
|
} finally {
|
|
10104
|
-
|
|
9899
|
+
v.tokenRefreshPromises.delete(n);
|
|
10105
9900
|
}
|
|
10106
|
-
})(),
|
|
10107
|
-
const
|
|
10108
|
-
|
|
9901
|
+
})(), v.tokenRefreshPromises.set(n, t)), t) {
|
|
9902
|
+
const r = await t;
|
|
9903
|
+
r && this.sendToken(r);
|
|
10109
9904
|
}
|
|
10110
9905
|
}
|
|
10111
9906
|
};
|
|
10112
9907
|
/** Static map to deduplicate token refresh requests across all instances in this JS context */
|
|
10113
|
-
l(
|
|
10114
|
-
let
|
|
10115
|
-
class
|
|
10116
|
-
constructor(
|
|
10117
|
-
let i =
|
|
9908
|
+
l(v, "tokenRefreshPromises", /* @__PURE__ */ new Map());
|
|
9909
|
+
let O = v;
|
|
9910
|
+
class Te extends O {
|
|
9911
|
+
constructor(t = {}, r) {
|
|
9912
|
+
let i = t.addr;
|
|
10118
9913
|
i || (typeof window < "u" ? i = window.location.origin : i = "10.0.4.20");
|
|
10119
9914
|
super(
|
|
10120
9915
|
{
|
|
10121
9916
|
isBinary: !0,
|
|
10122
9917
|
// Default for local is binary
|
|
10123
|
-
...
|
|
9918
|
+
...t,
|
|
10124
9919
|
addr: i
|
|
10125
9920
|
},
|
|
10126
|
-
|
|
9921
|
+
r
|
|
10127
9922
|
);
|
|
10128
9923
|
l(this, "streamMode", "local");
|
|
10129
9924
|
}
|
|
10130
9925
|
/**
|
|
10131
9926
|
* Normalizes the address to use ws:// protocol and adds default path if missing.
|
|
9927
|
+
* Adds x-api-token query parameter if token is provided.
|
|
10132
9928
|
*/
|
|
10133
|
-
normalizeUrl(
|
|
10134
|
-
const
|
|
10135
|
-
return (i.pathname === "/" || !i.pathname) && (i.pathname = "/api/status/ws"), i.toString();
|
|
9929
|
+
normalizeUrl(t) {
|
|
9930
|
+
const r = this.resolveProtocol(t), i = new URL(r);
|
|
9931
|
+
return (i.pathname === "/" || !i.pathname) && (i.pathname = "/api/status/ws"), this.token && i.searchParams.set("x-api-token", this.token), i.toString();
|
|
10136
9932
|
}
|
|
10137
9933
|
}
|
|
10138
|
-
class
|
|
10139
|
-
constructor(
|
|
9934
|
+
class Oe extends O {
|
|
9935
|
+
constructor(t, r) {
|
|
10140
9936
|
super(
|
|
10141
9937
|
{
|
|
10142
9938
|
isBinary: !1,
|
|
10143
9939
|
// Default for remote is JSON
|
|
10144
|
-
...
|
|
9940
|
+
...t
|
|
10145
9941
|
},
|
|
10146
|
-
|
|
9942
|
+
r
|
|
10147
9943
|
);
|
|
10148
9944
|
l(this, "streamMode", "remote");
|
|
10149
9945
|
l(this, "tokenProvider");
|
|
10150
|
-
this.tokenProvider =
|
|
9946
|
+
this.tokenProvider = t.tokenProvider;
|
|
10151
9947
|
}
|
|
10152
9948
|
/**
|
|
10153
9949
|
* Subscribes to updates for a specific device GUID.
|
|
10154
9950
|
*/
|
|
10155
|
-
subscribe(
|
|
10156
|
-
this.sendCommand({ type: "SUBSCRIBE", guid:
|
|
9951
|
+
subscribe(t) {
|
|
9952
|
+
this.sendCommand({ type: "SUBSCRIBE", guid: t });
|
|
10157
9953
|
}
|
|
10158
9954
|
/**
|
|
10159
9955
|
* Unsubscribes from updates for a specific device GUID.
|
|
10160
9956
|
*/
|
|
10161
|
-
unsubscribe(
|
|
10162
|
-
this.sendCommand({ type: "UNSUBSCRIBE", guid:
|
|
9957
|
+
unsubscribe(t) {
|
|
9958
|
+
this.sendCommand({ type: "UNSUBSCRIBE", guid: t });
|
|
10163
9959
|
}
|
|
10164
9960
|
/**
|
|
10165
9961
|
* Standardizes the address to use wss:// or ws:// protocol.
|
|
10166
9962
|
*/
|
|
10167
|
-
normalizeUrl(
|
|
10168
|
-
return this.resolveProtocol(
|
|
9963
|
+
normalizeUrl(t) {
|
|
9964
|
+
return this.resolveProtocol(t);
|
|
10169
9965
|
}
|
|
10170
9966
|
/**
|
|
10171
9967
|
* Handles token expiration by invoking the tokenProvider.
|
|
@@ -10173,13 +9969,79 @@ class Tn extends w {
|
|
|
10173
9969
|
*/
|
|
10174
9970
|
onTokenExpired() {
|
|
10175
9971
|
if (this.tokenProvider)
|
|
10176
|
-
return this.tokenProvider().then((
|
|
10177
|
-
const
|
|
10178
|
-
throw this.errorCallback && this.errorCallback(new y(
|
|
9972
|
+
return this.tokenProvider().then((t) => (this.sendToken(t), t)).catch((t) => {
|
|
9973
|
+
const r = `Failed to refresh token: ${t.message}`;
|
|
9974
|
+
throw this.errorCallback && this.errorCallback(new y(c.AUTH_REFRESH_FAILED, r)), t;
|
|
10179
9975
|
});
|
|
10180
9976
|
}
|
|
10181
9977
|
}
|
|
10182
|
-
|
|
9978
|
+
var I;
|
|
9979
|
+
((e) => {
|
|
9980
|
+
((n) => {
|
|
9981
|
+
n[n.DISCHARGING = 0] = "DISCHARGING", n[n.CHARGING = 1] = "CHARGING", n[n.CHARGED = 2] = "CHARGED";
|
|
9982
|
+
})(e.BatteryStatus || (e.BatteryStatus = {})), ((n) => {
|
|
9983
|
+
n[n.CONNECTED = 0] = "CONNECTED", n[n.CONNECTING = 1] = "CONNECTING", n[n.DISCONNECTING = 2] = "DISCONNECTING", n[n.RECONNECTING = 3] = "RECONNECTING";
|
|
9984
|
+
})(e.WifiConnectionStatus || (e.WifiConnectionStatus = {})), ((n) => {
|
|
9985
|
+
n[n.UNKNOWN = 0] = "UNKNOWN", n[n.OPEN = 1] = "OPEN", n[n.WPA = 2] = "WPA", n[n.WPA2 = 3] = "WPA2", n[n.WEP = 4] = "WEP", n[n.WPA_WPA2 = 5] = "WPA_WPA2", n[n.WPA3 = 6] = "WPA3", n[n.WPA2_WPA3 = 7] = "WPA2_WPA3";
|
|
9986
|
+
})(e.WifiSecurity || (e.WifiSecurity = {})), ((n) => {
|
|
9987
|
+
n[n.DHCP = 0] = "DHCP", n[n.STATIC = 1] = "STATIC";
|
|
9988
|
+
})(e.IpConfigurationMethod || (e.IpConfigurationMethod = {})), ((n) => {
|
|
9989
|
+
n[n.IPV4 = 0] = "IPV4", n[n.IPV6 = 1] = "IPV6";
|
|
9990
|
+
})(e.IpProtocol || (e.IpProtocol = {})), ((n) => {
|
|
9991
|
+
n[n.NEVER_STARTED = 0] = "NEVER_STARTED", n[n.STARTED = 1] = "STARTED", n[n.COMPLETED_SUCCESSFULLY = 2] = "COMPLETED_SUCCESSFULLY", n[n.FAILED = 3] = "FAILED";
|
|
9992
|
+
})(e.MatterCommissioningStatus || (e.MatterCommissioningStatus = {})), ((n) => {
|
|
9993
|
+
((t) => {
|
|
9994
|
+
t[t.RESET = 0] = "RESET", t[t.INITIALIZATION = 1] = "INITIALIZATION", t[t.READY = 2] = "READY", t[t.ADVERTISING = 3] = "ADVERTISING", t[t.CONNECTABLE = 4] = "CONNECTABLE", t[t.CONNECTED = 5] = "CONNECTED", t[t.ERROR = 6] = "ERROR";
|
|
9995
|
+
})(n.ServiceStatus || (n.ServiceStatus = {}));
|
|
9996
|
+
})(e.Ble || (e.Ble = {}));
|
|
9997
|
+
})(I || (I = {}));
|
|
9998
|
+
var C;
|
|
9999
|
+
((e) => {
|
|
10000
|
+
((n) => {
|
|
10001
|
+
n[n.SESSION_START = 0] = "SESSION_START", n[n.SESSION_STOP = 1] = "SESSION_STOP", n[n.ACTION_BEGIN = 2] = "ACTION_BEGIN", n[n.ACTION_DONE = 3] = "ACTION_DONE", n[n.DETAIL_CHANGE = 4] = "DETAIL_CHANGE", n[n.ACTION_PROGRESS = 5] = "ACTION_PROGRESS", n[n.EVENT_NONE = 6] = "EVENT_NONE";
|
|
10002
|
+
})(e.UpdateEvent || (e.UpdateEvent = {})), ((n) => {
|
|
10003
|
+
n[n.DOWNLOAD = 0] = "DOWNLOAD", n[n.SHA_VERIFICATION = 1] = "SHA_VERIFICATION", n[n.UNPACK = 2] = "UNPACK", n[n.INSTALLATION_PREPARE = 3] = "INSTALLATION_PREPARE", n[n.INSTALLATION_APPLY = 4] = "INSTALLATION_APPLY", n[n.ACTION_NONE = 5] = "ACTION_NONE";
|
|
10004
|
+
})(e.UpdateAction || (e.UpdateAction = {})), ((n) => {
|
|
10005
|
+
n[n.OK = 0] = "OK", n[n.BATTERY_LOW = 1] = "BATTERY_LOW", n[n.BUSY = 2] = "BUSY", n[n.DOWNLOAD_FAILURE = 3] = "DOWNLOAD_FAILURE", n[n.DOWNLOAD_ABORT = 4] = "DOWNLOAD_ABORT", n[n.SHA_MISMATCH = 5] = "SHA_MISMATCH", n[n.UNPACK_CREATE_STAGING_DIRECTORY_FAILURE = 6] = "UNPACK_CREATE_STAGING_DIRECTORY_FAILURE", n[n.UNPACK_ARCHIVE_OPEN_FAILURE = 7] = "UNPACK_ARCHIVE_OPEN_FAILURE", n[n.UNPACK_ARCHIVE_UNPACK_FAILURE = 8] = "UNPACK_ARCHIVE_UNPACK_FAILURE", n[n.INSTALLATION_PREPARE_MANIFEST_NOT_FOUND = 9] = "INSTALLATION_PREPARE_MANIFEST_NOT_FOUND", n[n.INSTALLATION_PREPARE_MANIFEST_INVALID = 10] = "INSTALLATION_PREPARE_MANIFEST_INVALID", n[n.INSTALLATION_PREPARE_SESSION_CONFIG_SETUP_FAILURE = 11] = "INSTALLATION_PREPARE_SESSION_CONFIG_SETUP_FAILURE", n[n.INSTALLATION_PREPARE_POINTER_SETUP_FAILURE = 12] = "INSTALLATION_PREPARE_POINTER_SETUP_FAILURE", n[n.UNKNOWN_FAILURE = 13] = "UNKNOWN_FAILURE";
|
|
10006
|
+
})(e.UpdateStatus || (e.UpdateStatus = {})), ((n) => {
|
|
10007
|
+
n[n.NOT_AVAILABLE = 0] = "NOT_AVAILABLE", n[n.FAILURE = 1] = "FAILURE", n[n.IDLE = 2] = "IDLE";
|
|
10008
|
+
})(e.CheckError || (e.CheckError = {}));
|
|
10009
|
+
})(C || (C = {}));
|
|
10010
|
+
var k;
|
|
10011
|
+
((e) => {
|
|
10012
|
+
((n) => {
|
|
10013
|
+
n[n.PLAIN = 0] = "PLAIN", n[n.RUN_LENGTH = 1] = "RUN_LENGTH", n[n.DEFLATE = 2] = "DEFLATE", n[n.DEFLATE_RUN_LENGTH = 3] = "DEFLATE_RUN_LENGTH";
|
|
10014
|
+
})(e.Encoding || (e.Encoding = {})), ((n) => {
|
|
10015
|
+
n[n.RGB888 = 0] = "RGB888", n[n.L8 = 1] = "L8", n[n.L4 = 2] = "L4";
|
|
10016
|
+
})(e.PixelFormat || (e.PixelFormat = {})), ((n) => {
|
|
10017
|
+
n[n.FRONT = 0] = "FRONT", n[n.BACK = 1] = "BACK";
|
|
10018
|
+
})(e.Screen || (e.Screen = {}));
|
|
10019
|
+
})(k || (k = {}));
|
|
10020
|
+
var q;
|
|
10021
|
+
((e) => {
|
|
10022
|
+
((n) => {
|
|
10023
|
+
n[n.PLAIN = 0] = "PLAIN", n[n.GZIP = 1] = "GZIP";
|
|
10024
|
+
})(e.Compression || (e.Compression = {}));
|
|
10025
|
+
})(q || (q = {}));
|
|
10026
|
+
var P;
|
|
10027
|
+
((e) => {
|
|
10028
|
+
((n) => {
|
|
10029
|
+
n[n.OK = 0] = "OK", n[n.BACK = 1] = "BACK", n[n.START = 2] = "START";
|
|
10030
|
+
})(e.Button || (e.Button = {})), ((n) => {
|
|
10031
|
+
n[n.PRESS = 0] = "PRESS", n[n.RELEASE = 1] = "RELEASE";
|
|
10032
|
+
})(e.ButtonAction || (e.ButtonAction = {})), ((n) => {
|
|
10033
|
+
n[n.BUSY = 0] = "BUSY", n[n.CUSTOM = 1] = "CUSTOM", n[n.OFF = 2] = "OFF", n[n.APPS = 3] = "APPS", n[n.SETTINGS = 4] = "SETTINGS";
|
|
10034
|
+
})(e.SwitchPosition || (e.SwitchPosition = {}));
|
|
10035
|
+
})(P || (P = {}));
|
|
10036
|
+
var j;
|
|
10037
|
+
((e) => {
|
|
10038
|
+
((n) => {
|
|
10039
|
+
n[n.RESOURCE_LIMIT = 0] = "RESOURCE_LIMIT";
|
|
10040
|
+
})(e.Cause || (e.Cause = {})), ((n) => {
|
|
10041
|
+
n[n.FATAL = 0] = "FATAL", n[n.ERROR = 1] = "ERROR", n[n.WARNING = 2] = "WARNING";
|
|
10042
|
+
})(e.Severity || (e.Severity = {}));
|
|
10043
|
+
})(j || (j = {}));
|
|
10044
|
+
const g = class g {
|
|
10183
10045
|
constructor() {
|
|
10184
10046
|
l(this, "gl", null);
|
|
10185
10047
|
l(this, "program", null);
|
|
@@ -10226,9 +10088,9 @@ const b = class b {
|
|
|
10226
10088
|
outColor = vec4(finalColor, color.a * mask);
|
|
10227
10089
|
}
|
|
10228
10090
|
`);
|
|
10229
|
-
if (
|
|
10230
|
-
return
|
|
10231
|
-
|
|
10091
|
+
if (g.instance)
|
|
10092
|
+
return g.instance;
|
|
10093
|
+
g.instance = this;
|
|
10232
10094
|
}
|
|
10233
10095
|
/**
|
|
10234
10096
|
* Lazily initializes the WebGL context and resources.
|
|
@@ -10237,61 +10099,64 @@ const b = class b {
|
|
|
10237
10099
|
init() {
|
|
10238
10100
|
if (this.gl || typeof window > "u")
|
|
10239
10101
|
return;
|
|
10240
|
-
const
|
|
10102
|
+
const t = document.createElement("canvas").getContext("webgl2", {
|
|
10241
10103
|
antialias: !0,
|
|
10242
10104
|
alpha: !0,
|
|
10243
10105
|
preserveDrawingBuffer: !0
|
|
10244
10106
|
});
|
|
10245
|
-
if (!
|
|
10107
|
+
if (!t)
|
|
10246
10108
|
throw new Error("WebGL 2.0 not supported");
|
|
10247
|
-
this.gl =
|
|
10248
|
-
const
|
|
10249
|
-
|
|
10250
|
-
const i =
|
|
10251
|
-
|
|
10109
|
+
this.gl = t, this.program = this.createProgram(this.vs, this.fs);
|
|
10110
|
+
const r = t.createBuffer();
|
|
10111
|
+
t.bindBuffer(t.ARRAY_BUFFER, r), t.bufferData(t.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1]), t.STATIC_DRAW);
|
|
10112
|
+
const i = t.getAttribLocation(this.program, "position");
|
|
10113
|
+
t.enableVertexAttribArray(i), t.vertexAttribPointer(i, 2, t.FLOAT, !1, 0, 0), this.texture = t.createTexture(), t.bindTexture(t.TEXTURE_2D, this.texture), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.NEAREST), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.NEAREST), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE);
|
|
10252
10114
|
}
|
|
10253
10115
|
/**
|
|
10254
10116
|
* Internal WebGL rendering pass.
|
|
10255
10117
|
*/
|
|
10256
|
-
render(
|
|
10257
|
-
const { pixelSize: o = 0.85, radius:
|
|
10258
|
-
|
|
10118
|
+
render(n, t, r, i) {
|
|
10119
|
+
const { pixelSize: o = 0.85, radius: s = 0.5, darkThreshold: u = 0.04 } = i, a = this.gl;
|
|
10120
|
+
a.viewport(0, 0, a.canvas.width, a.canvas.height), a.useProgram(this.program), a.bindTexture(a.TEXTURE_2D, this.texture), a.texImage2D(a.TEXTURE_2D, 0, a.RGBA8, t, r, 0, a.RGBA, a.UNSIGNED_BYTE, n), a.uniform2f(a.getUniformLocation(this.program, "u_dataRes"), t, r), a.uniform2f(a.getUniformLocation(this.program, "u_canvasRes"), a.canvas.width, a.canvas.height), a.uniform1f(a.getUniformLocation(this.program, "u_pixelSize"), o), a.uniform1f(a.getUniformLocation(this.program, "u_radius"), s), a.uniform1f(a.getUniformLocation(this.program, "u_darkThreshold"), u), a.clearColor(0, 0, 0, 0), a.clear(a.COLOR_BUFFER_BIT), a.enable(a.BLEND), a.blendFunc(a.SRC_ALPHA, a.ONE_MINUS_SRC_ALPHA), a.drawArrays(a.TRIANGLES, 0, 6);
|
|
10259
10121
|
}
|
|
10260
10122
|
/**
|
|
10261
10123
|
* Public API: Renders the LED frame to a target 2D canvas.
|
|
10262
10124
|
*/
|
|
10263
|
-
renderFrame(
|
|
10125
|
+
renderFrame(n, t, r, i, o = {}) {
|
|
10264
10126
|
if (this.init(), typeof window > "u" || !this.gl)
|
|
10265
10127
|
return;
|
|
10266
|
-
(this.gl.canvas.width !==
|
|
10267
|
-
const
|
|
10268
|
-
|
|
10269
|
-
}
|
|
10270
|
-
createProgram(
|
|
10271
|
-
const
|
|
10272
|
-
const
|
|
10273
|
-
if (
|
|
10274
|
-
return
|
|
10275
|
-
}, o =
|
|
10276
|
-
return
|
|
10128
|
+
(this.gl.canvas.width !== n.width || this.gl.canvas.height !== n.height) && (this.gl.canvas.width = n.width, this.gl.canvas.height = n.height), this.render(t, r, i, o);
|
|
10129
|
+
const s = n.getContext("2d");
|
|
10130
|
+
s && (s.clearRect(0, 0, n.width, n.height), s.drawImage(this.gl.canvas, 0, 0));
|
|
10131
|
+
}
|
|
10132
|
+
createProgram(n, t) {
|
|
10133
|
+
const r = this.gl, i = (s, u) => {
|
|
10134
|
+
const a = r.createShader(s);
|
|
10135
|
+
if (r.shaderSource(a, u), r.compileShader(a), !r.getShaderParameter(a, r.COMPILE_STATUS)) throw new Error(r.getShaderInfoLog(a) || "Shader Error");
|
|
10136
|
+
return a;
|
|
10137
|
+
}, o = r.createProgram();
|
|
10138
|
+
return r.attachShader(o, i(r.VERTEX_SHADER, n)), r.attachShader(o, i(r.FRAGMENT_SHADER, t)), r.linkProgram(o), o;
|
|
10277
10139
|
}
|
|
10278
10140
|
};
|
|
10279
|
-
l(
|
|
10280
|
-
let S =
|
|
10281
|
-
const
|
|
10141
|
+
l(g, "instance", null);
|
|
10142
|
+
let S = g;
|
|
10143
|
+
const Re = new S();
|
|
10282
10144
|
export {
|
|
10283
|
-
|
|
10284
|
-
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
|
|
10288
|
-
|
|
10289
|
-
|
|
10290
|
-
|
|
10291
|
-
|
|
10292
|
-
|
|
10145
|
+
b as AuthStatus,
|
|
10146
|
+
j as BSB_Error,
|
|
10147
|
+
k as BSB_Frame,
|
|
10148
|
+
P as BSB_Input,
|
|
10149
|
+
I as BSB_State,
|
|
10150
|
+
C as BSB_Update,
|
|
10151
|
+
q as BSB_Util,
|
|
10152
|
+
ye as BusyBar,
|
|
10153
|
+
m as ConnectionStatus,
|
|
10154
|
+
E as DataStatus,
|
|
10155
|
+
Re as LEDRenderer,
|
|
10156
|
+
Te as LocalStateStream,
|
|
10157
|
+
Oe as RemoteStateStream,
|
|
10293
10158
|
y as StateStreamError,
|
|
10294
|
-
|
|
10295
|
-
|
|
10296
|
-
|
|
10159
|
+
c as StateStreamErrorCode,
|
|
10160
|
+
d as StreamLifecycle,
|
|
10161
|
+
_ as WorkerStatus
|
|
10297
10162
|
};
|