@iotopen/react-lynx 1.0.2-rc.0 → 1.0.2-rc.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/Contexts/LynxClientProvider.d.ts +1 -1
- package/dist/Contexts/UserProvider.d.ts +1 -1
- package/dist/Hooks/useDevices.d.ts +3 -4
- package/dist/Hooks/useFunctions.d.ts +3 -4
- package/dist/Hooks/useMeta.d.ts +1 -1
- package/dist/Hooks/usePahoMQTTClient.d.ts +3 -3
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +277 -273
- package/dist/esm/index.js.map +1 -1
- package/package.json +11 -7
package/dist/esm/index.js
CHANGED
|
@@ -1,41 +1,43 @@
|
|
|
1
1
|
import { jsx as S } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { LynxClient as R, zero as
|
|
4
|
-
import
|
|
5
|
-
const
|
|
2
|
+
import { createContext as Q, useContext as j, useState as f, useCallback as p, useMemo as G, useLayoutEffect as O, useEffect as M, useRef as I } from "react";
|
|
3
|
+
import { LynxClient as R, zero as H } from "@iotopen/node-lynx";
|
|
4
|
+
import te from "paho-mqtt";
|
|
5
|
+
const ne = {
|
|
6
6
|
lynxClient: new R(""),
|
|
7
7
|
newLynxClient: (t, r, e) => {
|
|
8
8
|
}
|
|
9
|
-
},
|
|
9
|
+
}, J = Q(ne), oe = ({ children: t, url: r, apiKey: e, bearer: n }) => {
|
|
10
10
|
const [o, a] = f(new R(r, e, n)), u = p((i, l, d) => {
|
|
11
11
|
a(new R(i, l, d));
|
|
12
|
-
}, [a]), s =
|
|
13
|
-
return /* @__PURE__ */ S(
|
|
14
|
-
}, E = () =>
|
|
12
|
+
}, [a]), s = G(() => ({ lynxClient: o, newLynxClient: u }), [o, u]);
|
|
13
|
+
return /* @__PURE__ */ S(J.Provider, { value: s, children: t });
|
|
14
|
+
}, E = () => j(J), re = {
|
|
15
15
|
user: null,
|
|
16
16
|
permissions: null
|
|
17
|
-
},
|
|
17
|
+
}, W = Q(re), se = ({ children: t }) => {
|
|
18
18
|
const [r, e] = f(null), [n, o] = f(null), [a, u] = f(!0), [s, i] = f(), { lynxClient: l } = E();
|
|
19
19
|
O(() => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
Promise.resolve().then(() => {
|
|
21
|
+
const c = l.getMe(), h = l.getPermissions();
|
|
22
|
+
u(!0), Promise.all([c, h]).then(([g, y]) => {
|
|
23
|
+
i((v) => v !== void 0 ? void 0 : v), e(g), o(y);
|
|
24
|
+
}).catch((g) => {
|
|
25
|
+
i(g), e(null), o(null);
|
|
26
|
+
}).finally(() => {
|
|
27
|
+
u(!1);
|
|
28
|
+
});
|
|
27
29
|
});
|
|
28
30
|
}, [l]);
|
|
29
|
-
const d =
|
|
30
|
-
return /* @__PURE__ */ S(
|
|
31
|
-
},
|
|
32
|
-
const { permissions: t } =
|
|
31
|
+
const d = G(() => ({ user: r, permissions: n, loading: a, error: s }), [r, n, a, s]);
|
|
32
|
+
return /* @__PURE__ */ S(W.Provider, { value: d, children: t });
|
|
33
|
+
}, X = () => j(W), Y = () => {
|
|
34
|
+
const { permissions: t } = X();
|
|
33
35
|
return t;
|
|
34
|
-
},
|
|
35
|
-
const r =
|
|
36
|
+
}, Pe = ({ children: t, apiURL: r, apiKey: e, bearer: n }) => /* @__PURE__ */ S(oe, { url: r, apiKey: e, bearer: n, children: /* @__PURE__ */ S(se, { children: t }) }), Le = (...t) => {
|
|
37
|
+
const r = Y();
|
|
36
38
|
return r == null ? !1 : t.every((e) => r[e] !== void 0 && r[e]);
|
|
37
39
|
}, Ae = (...t) => {
|
|
38
|
-
const r =
|
|
40
|
+
const r = Y();
|
|
39
41
|
return r == null ? !1 : t.some((e) => r[e] !== void 0 && r[e]);
|
|
40
42
|
}, De = (t) => {
|
|
41
43
|
const r = typeof t == "string" ? Number.parseInt(t) : t;
|
|
@@ -51,14 +53,14 @@ const te = {
|
|
|
51
53
|
});
|
|
52
54
|
}, [r, e]);
|
|
53
55
|
return O(() => {
|
|
54
|
-
|
|
56
|
+
Promise.resolve().then(l);
|
|
55
57
|
}, [l]), {
|
|
56
58
|
refresh: l,
|
|
57
59
|
loading: n,
|
|
58
60
|
error: a,
|
|
59
61
|
apps: s
|
|
60
62
|
};
|
|
61
|
-
},
|
|
63
|
+
}, ie = {
|
|
62
64
|
updated: 0,
|
|
63
65
|
created: 0,
|
|
64
66
|
id: 0,
|
|
@@ -66,16 +68,16 @@ const te = {
|
|
|
66
68
|
type: "",
|
|
67
69
|
meta: {},
|
|
68
70
|
protected_meta: {}
|
|
69
|
-
},
|
|
71
|
+
}, Fe = (t, r) => {
|
|
70
72
|
const e = typeof t == "string" ? Number.parseInt(t) : t, n = typeof r == "string" ? Number.parseInt(r) : r;
|
|
71
73
|
if (isNaN(e) || isNaN(n))
|
|
72
74
|
throw new Error("invalid installationId or deviceId");
|
|
73
|
-
const { lynxClient: o } = E(), [a, u] = f(!0), [s, i] = f({ ...
|
|
75
|
+
const { lynxClient: o } = E(), [a, u] = f(!0), [s, i] = f({ ...ie }), [l, d] = f();
|
|
74
76
|
O(() => {
|
|
75
|
-
o.getDevice(e, n).then((
|
|
76
|
-
d((v) => v !== void 0 ? void 0 : v), i(
|
|
77
|
-
}).catch((
|
|
78
|
-
d(
|
|
77
|
+
o.getDevice(e, n).then((y) => {
|
|
78
|
+
d((v) => v !== void 0 ? void 0 : v), i(y);
|
|
79
|
+
}).catch((y) => {
|
|
80
|
+
d(y);
|
|
79
81
|
}).finally(() => {
|
|
80
82
|
u(!1);
|
|
81
83
|
});
|
|
@@ -84,8 +86,8 @@ const te = {
|
|
|
84
86
|
if (!s)
|
|
85
87
|
throw new Error("update on undefined function");
|
|
86
88
|
return o.updateDevice(s);
|
|
87
|
-
}), [o, s]), h = p((
|
|
88
|
-
s && i({ ...s, type:
|
|
89
|
+
}), [o, s]), h = p((y) => {
|
|
90
|
+
s && i({ ...s, type: y });
|
|
89
91
|
}, [s, i]), g = p(() => new Promise(() => {
|
|
90
92
|
if (!s)
|
|
91
93
|
throw new Error("delete on undefined function");
|
|
@@ -100,7 +102,7 @@ const te = {
|
|
|
100
102
|
remove: g,
|
|
101
103
|
setType: h
|
|
102
104
|
};
|
|
103
|
-
},
|
|
105
|
+
}, Ie = (t, r) => {
|
|
104
106
|
const e = typeof t == "string" ? Number.parseInt(t) : t, n = typeof r == "string" ? Number.parseInt(r) : r, { lynxClient: o } = E(), a = p((i, l, d, c) => {
|
|
105
107
|
const h = d ?? n ?? 0;
|
|
106
108
|
return o.createDeviceMeta(e, h, i, l, c);
|
|
@@ -116,7 +118,7 @@ const te = {
|
|
|
116
118
|
updateMeta: u,
|
|
117
119
|
removeMeta: s
|
|
118
120
|
};
|
|
119
|
-
},
|
|
121
|
+
}, Z = (t, r) => {
|
|
120
122
|
const e = typeof t == "string" ? Number.parseInt(t) : t;
|
|
121
123
|
if (isNaN(e) && e !== void 0)
|
|
122
124
|
throw new Error("invalid installationId");
|
|
@@ -142,8 +144,8 @@ const te = {
|
|
|
142
144
|
return Promise.allSettled(C).then(async (N) => {
|
|
143
145
|
try {
|
|
144
146
|
N.push({ status: "fulfilled", value: await n.deleteDevice(w) });
|
|
145
|
-
} catch (
|
|
146
|
-
N.push({ status: "rejected", reason:
|
|
147
|
+
} catch (m) {
|
|
148
|
+
N.push({ status: "rejected", reason: m });
|
|
147
149
|
}
|
|
148
150
|
return N;
|
|
149
151
|
});
|
|
@@ -159,26 +161,26 @@ const te = {
|
|
|
159
161
|
return Promise.allSettled(C).then(async (N) => {
|
|
160
162
|
try {
|
|
161
163
|
N.push({ status: "fulfilled", value: await n.createDevice(w) });
|
|
162
|
-
} catch (
|
|
163
|
-
N.push({ status: "rejected", reason:
|
|
164
|
+
} catch (m) {
|
|
165
|
+
N.push({ status: "rejected", reason: m });
|
|
164
166
|
}
|
|
165
167
|
return N;
|
|
166
168
|
});
|
|
167
169
|
}
|
|
168
170
|
return n.createDevice(v);
|
|
169
171
|
}
|
|
170
|
-
const g = p(h, [
|
|
172
|
+
const g = p((...v) => h(...v), [h]), y = p((...v) => c(...v), [c]);
|
|
171
173
|
return O(() => {
|
|
172
|
-
|
|
174
|
+
Promise.resolve().then(d);
|
|
173
175
|
}, [d]), {
|
|
174
176
|
loading: o,
|
|
175
177
|
error: i,
|
|
176
178
|
create: g,
|
|
177
|
-
remove:
|
|
179
|
+
remove: y,
|
|
178
180
|
devices: u,
|
|
179
181
|
refresh: d
|
|
180
182
|
};
|
|
181
|
-
},
|
|
183
|
+
}, ce = {
|
|
182
184
|
id: 0,
|
|
183
185
|
created: 0,
|
|
184
186
|
updated: 0,
|
|
@@ -191,11 +193,11 @@ const te = {
|
|
|
191
193
|
publisher: { id: 0 },
|
|
192
194
|
public: !1,
|
|
193
195
|
official: !1
|
|
194
|
-
},
|
|
196
|
+
}, ze = (t) => {
|
|
195
197
|
const r = typeof t == "string" ? Number.parseInt(t) : t;
|
|
196
198
|
if (isNaN(r))
|
|
197
199
|
throw new Error("invalid appId");
|
|
198
|
-
const { lynxClient: e } = E(), [n, o] = f(!1), [a, u] = f(), [s, i] = f({ ...
|
|
200
|
+
const { lynxClient: e } = E(), [n, o] = f(!1), [a, u] = f(), [s, i] = f({ ...ce }), l = p(() => {
|
|
199
201
|
o(!0), e.getEdgeApp(r).then((d) => {
|
|
200
202
|
u((c) => c !== void 0 ? void 0 : c), i(d);
|
|
201
203
|
}).catch((d) => {
|
|
@@ -205,7 +207,7 @@ const te = {
|
|
|
205
207
|
});
|
|
206
208
|
}, [r, e]);
|
|
207
209
|
return O(() => {
|
|
208
|
-
|
|
210
|
+
Promise.resolve().then(l);
|
|
209
211
|
}, [l]), {
|
|
210
212
|
loading: n,
|
|
211
213
|
error: a,
|
|
@@ -213,7 +215,7 @@ const te = {
|
|
|
213
215
|
setApp: i,
|
|
214
216
|
refresh: l
|
|
215
217
|
};
|
|
216
|
-
},
|
|
218
|
+
}, Ue = () => {
|
|
217
219
|
const { lynxClient: t } = E(), [r, e] = f(!0), [n, o] = f(), [a, u] = f([]), s = p(() => {
|
|
218
220
|
e(!0), t.getEdgeApps().then((i) => {
|
|
219
221
|
o((l) => l !== void 0 ? void 0 : l), u(i);
|
|
@@ -224,14 +226,14 @@ const te = {
|
|
|
224
226
|
});
|
|
225
227
|
}, [t]);
|
|
226
228
|
return O(() => {
|
|
227
|
-
|
|
229
|
+
Promise.resolve().then(s);
|
|
228
230
|
}, [s]), {
|
|
229
231
|
apps: a,
|
|
230
232
|
error: n,
|
|
231
233
|
loading: r,
|
|
232
234
|
refresh: s
|
|
233
235
|
};
|
|
234
|
-
},
|
|
236
|
+
}, Se = (t, r) => {
|
|
235
237
|
const e = typeof t == "string" ? Number.parseInt(t) : t;
|
|
236
238
|
if (isNaN(e))
|
|
237
239
|
throw new Error("invalid appId");
|
|
@@ -245,7 +247,7 @@ const te = {
|
|
|
245
247
|
});
|
|
246
248
|
}, [n, e, r]), c = p((h, g) => n.nameEdgeAppVersion(e, h, g), [n, e]);
|
|
247
249
|
return O(() => {
|
|
248
|
-
|
|
250
|
+
Promise.resolve().then(d);
|
|
249
251
|
}, [d]), {
|
|
250
252
|
loading: o,
|
|
251
253
|
error: u,
|
|
@@ -253,7 +255,7 @@ const te = {
|
|
|
253
255
|
nameVersion: c,
|
|
254
256
|
refresh: d
|
|
255
257
|
};
|
|
256
|
-
},
|
|
258
|
+
}, ae = {
|
|
257
259
|
id: 0,
|
|
258
260
|
installation_id: 0,
|
|
259
261
|
type: "",
|
|
@@ -261,16 +263,16 @@ const te = {
|
|
|
261
263
|
created: 0,
|
|
262
264
|
meta: {},
|
|
263
265
|
protected_meta: {}
|
|
264
|
-
},
|
|
266
|
+
}, ke = (t, r) => {
|
|
265
267
|
const e = typeof t == "string" ? Number.parseInt(t) : t, n = typeof r == "string" ? Number.parseInt(r) : r;
|
|
266
268
|
if (isNaN(e) || isNaN(n))
|
|
267
269
|
throw new Error("invalid installationId or functionId");
|
|
268
|
-
const { lynxClient: o } = E(), [a, u] = f(!0), [s, i] = f({ ...
|
|
270
|
+
const { lynxClient: o } = E(), [a, u] = f(!0), [s, i] = f({ ...ae }), [l, d] = f();
|
|
269
271
|
O(() => {
|
|
270
|
-
o.getFunction(e, n).then((
|
|
271
|
-
d((v) => v !== void 0 ? void 0 : v), i(
|
|
272
|
-
}).catch((
|
|
273
|
-
d(
|
|
272
|
+
o.getFunction(e, n).then((y) => {
|
|
273
|
+
d((v) => v !== void 0 ? void 0 : v), i(y);
|
|
274
|
+
}).catch((y) => {
|
|
275
|
+
d(y);
|
|
274
276
|
}).finally(() => {
|
|
275
277
|
u(!1);
|
|
276
278
|
});
|
|
@@ -279,8 +281,8 @@ const te = {
|
|
|
279
281
|
if (!s)
|
|
280
282
|
throw new Error("update on undefined function");
|
|
281
283
|
return o.updateFunction(s);
|
|
282
|
-
}), [o, s]), h = p((
|
|
283
|
-
s && i({ ...s, type:
|
|
284
|
+
}), [o, s]), h = p((y) => {
|
|
285
|
+
s && i({ ...s, type: y });
|
|
284
286
|
}, [s, i]), g = p(() => new Promise(() => {
|
|
285
287
|
if (!s)
|
|
286
288
|
throw new Error("delete on undefined function");
|
|
@@ -295,7 +297,7 @@ const te = {
|
|
|
295
297
|
remove: g,
|
|
296
298
|
setType: h
|
|
297
299
|
};
|
|
298
|
-
},
|
|
300
|
+
}, Re = (t, r) => {
|
|
299
301
|
const e = typeof t == "string" ? Number.parseInt(t) : t, n = typeof r == "string" ? Number.parseInt(r) : r, { lynxClient: o } = E(), a = p((i, l, d, c) => {
|
|
300
302
|
const h = d ?? n ?? 0;
|
|
301
303
|
return o.createFunctionMeta(e, h, i, l, c);
|
|
@@ -311,7 +313,7 @@ const te = {
|
|
|
311
313
|
updateMeta: u,
|
|
312
314
|
removeMeta: s
|
|
313
315
|
};
|
|
314
|
-
},
|
|
316
|
+
}, ee = (t, r) => {
|
|
315
317
|
const e = typeof t == "string" ? Number.parseInt(t) : t;
|
|
316
318
|
if (isNaN(e) && e !== void 0)
|
|
317
319
|
throw new Error("invalid installationId");
|
|
@@ -335,8 +337,8 @@ const te = {
|
|
|
335
337
|
return Promise.allSettled(C).then(async (N) => {
|
|
336
338
|
try {
|
|
337
339
|
N.push({ status: "fulfilled", value: await n.deleteFunction(w) });
|
|
338
|
-
} catch (
|
|
339
|
-
N.push({ status: "rejected", reason:
|
|
340
|
+
} catch (m) {
|
|
341
|
+
N.push({ status: "rejected", reason: m });
|
|
340
342
|
}
|
|
341
343
|
return N;
|
|
342
344
|
});
|
|
@@ -352,26 +354,26 @@ const te = {
|
|
|
352
354
|
return Promise.allSettled(C).then(async (N) => {
|
|
353
355
|
try {
|
|
354
356
|
N.push({ status: "fulfilled", value: await n.createFunction(w) });
|
|
355
|
-
} catch (
|
|
356
|
-
N.push({ status: "rejected", reason:
|
|
357
|
+
} catch (m) {
|
|
358
|
+
N.push({ status: "rejected", reason: m });
|
|
357
359
|
}
|
|
358
360
|
return N;
|
|
359
361
|
});
|
|
360
362
|
}
|
|
361
363
|
return n.createFunction(v);
|
|
362
364
|
}
|
|
363
|
-
const g = p(h, [
|
|
365
|
+
const g = p((...v) => h(...v), [h]), y = p((...v) => c(...v), [c]);
|
|
364
366
|
return O(() => {
|
|
365
|
-
|
|
367
|
+
Promise.resolve().then(d);
|
|
366
368
|
}, [d]), {
|
|
367
369
|
loading: o,
|
|
368
370
|
error: i,
|
|
369
371
|
create: g,
|
|
370
|
-
remove:
|
|
372
|
+
remove: y,
|
|
371
373
|
functions: u,
|
|
372
374
|
refresh: d
|
|
373
375
|
};
|
|
374
|
-
},
|
|
376
|
+
}, Te = () => {
|
|
375
377
|
const { lynxClient: t } = E(), [r, e] = f(!0), [n, o] = f(), [a, u] = f([]), s = p(() => {
|
|
376
378
|
e(!0), t.getIDTokenAlgorithms().then((i) => {
|
|
377
379
|
o((l) => l !== void 0 ? void 0 : l), u(i);
|
|
@@ -389,7 +391,7 @@ const te = {
|
|
|
389
391
|
algs: a,
|
|
390
392
|
error: n
|
|
391
393
|
};
|
|
392
|
-
},
|
|
394
|
+
}, ue = {
|
|
393
395
|
client_id: 0,
|
|
394
396
|
notes: "",
|
|
395
397
|
organization_id: 0,
|
|
@@ -399,11 +401,11 @@ const te = {
|
|
|
399
401
|
meta: {},
|
|
400
402
|
users: [],
|
|
401
403
|
protected_meta: {}
|
|
402
|
-
},
|
|
404
|
+
}, le = (t) => {
|
|
403
405
|
const r = typeof t == "string" ? Number.parseInt(t) : t;
|
|
404
406
|
if (isNaN(r))
|
|
405
407
|
throw new Error("invalid installationId");
|
|
406
|
-
const { lynxClient: e } = E(), [n, o] = f(!0), [a, u] = f(void 0), [s, i] = f({ ...
|
|
408
|
+
const { lynxClient: e } = E(), [n, o] = f(!0), [a, u] = f(void 0), [s, i] = f({ ...ue });
|
|
407
409
|
O(() => {
|
|
408
410
|
e.getInstallationRow(r).then((c) => {
|
|
409
411
|
u((h) => h !== void 0 ? void 0 : h), i(c);
|
|
@@ -430,7 +432,7 @@ const te = {
|
|
|
430
432
|
error: a,
|
|
431
433
|
loading: n
|
|
432
434
|
};
|
|
433
|
-
},
|
|
435
|
+
}, qe = (t) => {
|
|
434
436
|
const { lynxClient: r } = E(), [e, n] = f([]), [o, a] = f(!0), [u, s] = f(void 0), i = p(() => {
|
|
435
437
|
a(!0), r.getInstallations(t).then((l) => {
|
|
436
438
|
s((d) => d !== void 0 ? void 0 : d), n(l);
|
|
@@ -448,36 +450,40 @@ const te = {
|
|
|
448
450
|
loading: o,
|
|
449
451
|
error: u
|
|
450
452
|
};
|
|
451
|
-
},
|
|
453
|
+
}, $e = (t) => {
|
|
452
454
|
const { lynxClient: r } = E(), [e, n] = f(!0), [o, a] = f([]), [u, s] = f(), i = p(() => {
|
|
453
455
|
n(!0), r.listInstallations(t).then((l) => {
|
|
454
456
|
s((d) => d !== void 0 ? void 0 : d), a(l);
|
|
455
457
|
}).catch((l) => {
|
|
456
|
-
s(
|
|
458
|
+
s(l);
|
|
457
459
|
}).finally(() => {
|
|
458
460
|
n(!1);
|
|
459
461
|
});
|
|
460
462
|
}, [r, t]);
|
|
461
463
|
return O(() => {
|
|
462
|
-
|
|
464
|
+
Promise.resolve().then(i);
|
|
463
465
|
}, [i]), {
|
|
464
466
|
loading: e,
|
|
465
467
|
error: u,
|
|
466
468
|
installations: o,
|
|
467
469
|
refresh: i
|
|
468
470
|
};
|
|
469
|
-
}
|
|
471
|
+
};
|
|
472
|
+
function B(t) {
|
|
473
|
+
return t instanceof Error ? t : new Error(String(t));
|
|
474
|
+
}
|
|
475
|
+
const de = (t, r, e, n) => {
|
|
470
476
|
if (n === void 0) {
|
|
471
477
|
let v;
|
|
472
478
|
window?.crypto?.randomUUID ? v = window.crypto.randomUUID() : typeof crypto < "u" && crypto?.randomUUID ? v = crypto.randomUUID() : v = Math.random().toString(36).substring(2, 15), n = `paho-ws-mqtt-${v}`;
|
|
473
479
|
}
|
|
474
|
-
const o = I(new
|
|
480
|
+
const o = I(new te.Client(t, n)), a = I(e), u = I(r), s = I(void 0), [i, l] = f(!1), [d, c] = f(void 0);
|
|
475
481
|
O(() => {
|
|
476
482
|
const v = o, w = s, C = {
|
|
477
483
|
timeout: 5,
|
|
478
484
|
...a.current,
|
|
479
|
-
onFailure: (
|
|
480
|
-
c(
|
|
485
|
+
onFailure: (m) => {
|
|
486
|
+
c(m), l(o.current.isConnected()), w.current ??= window.setInterval(() => {
|
|
481
487
|
v.current.isConnected() ? clearInterval(w.current) : v.current.connect(C);
|
|
482
488
|
}, 5e3);
|
|
483
489
|
},
|
|
@@ -485,10 +491,10 @@ const te = {
|
|
|
485
491
|
c(void 0), l(o.current.isConnected()), w.current !== void 0 && (window.clearInterval(w.current), w.current = void 0);
|
|
486
492
|
}
|
|
487
493
|
}, N = u.current;
|
|
488
|
-
v.current.onConnectionLost = (
|
|
489
|
-
c(
|
|
490
|
-
}, v.current.onConnected = (
|
|
491
|
-
l(o.current.isConnected()), c(void 0), N?.onConnected?.(
|
|
494
|
+
v.current.onConnectionLost = (m) => {
|
|
495
|
+
c(m), l(o.current.isConnected()), N?.onDisconnect?.(m);
|
|
496
|
+
}, v.current.onConnected = (m, b) => {
|
|
497
|
+
l(o.current.isConnected()), c(void 0), N?.onConnected?.(m, b);
|
|
492
498
|
}, N && (N.onMessage && (v.current.onMessageArrived = N.onMessage), N.onDelivery && (v.current.onMessageDelivered = N.onDelivery));
|
|
493
499
|
try {
|
|
494
500
|
v.current.connect(C);
|
|
@@ -500,8 +506,8 @@ const te = {
|
|
|
500
506
|
return () => {
|
|
501
507
|
try {
|
|
502
508
|
v.current.disconnect(), w.current !== void 0 && window.clearInterval(w.current);
|
|
503
|
-
} catch (
|
|
504
|
-
console.log(
|
|
509
|
+
} catch (m) {
|
|
510
|
+
console.log(m);
|
|
505
511
|
}
|
|
506
512
|
};
|
|
507
513
|
}, []);
|
|
@@ -510,29 +516,29 @@ const te = {
|
|
|
510
516
|
qos: w ?? 0,
|
|
511
517
|
timeout: 1,
|
|
512
518
|
onFailure: (N) => {
|
|
513
|
-
throw N;
|
|
519
|
+
throw B(N);
|
|
514
520
|
},
|
|
515
521
|
onSuccess: (N) => {
|
|
516
522
|
C(N.grantedQos);
|
|
517
523
|
}
|
|
518
524
|
});
|
|
519
525
|
}), [o]), g = p((v, w, C, N) => {
|
|
520
|
-
let
|
|
526
|
+
let m;
|
|
521
527
|
if (typeof w == "string")
|
|
522
|
-
|
|
528
|
+
m = w;
|
|
523
529
|
else if (ArrayBuffer.isView(w))
|
|
524
|
-
|
|
530
|
+
m = new Uint8Array(w.buffer, w.byteOffset, w.byteLength).slice().buffer;
|
|
525
531
|
else
|
|
526
532
|
throw new Error("Payload must be a string or TypedArray");
|
|
527
|
-
o.current.send(v,
|
|
528
|
-
}, [o]),
|
|
533
|
+
o.current.send(v, m, C, N);
|
|
534
|
+
}, [o]), y = p((v) => new Promise((w) => {
|
|
529
535
|
o.current.unsubscribe(v, {
|
|
530
536
|
timeout: 1,
|
|
531
537
|
onSuccess: () => {
|
|
532
538
|
w();
|
|
533
539
|
},
|
|
534
540
|
onFailure: (C) => {
|
|
535
|
-
throw C;
|
|
541
|
+
throw B(C);
|
|
536
542
|
}
|
|
537
543
|
});
|
|
538
544
|
}), [o]);
|
|
@@ -542,10 +548,10 @@ const te = {
|
|
|
542
548
|
error: d,
|
|
543
549
|
sub: h,
|
|
544
550
|
pub: g,
|
|
545
|
-
unsub:
|
|
551
|
+
unsub: y
|
|
546
552
|
};
|
|
547
553
|
};
|
|
548
|
-
function
|
|
554
|
+
function fe(t, r) {
|
|
549
555
|
if (t.length === r.length) {
|
|
550
556
|
for (let e = 0; e < t.length; e++)
|
|
551
557
|
if (t[e] !== r[e])
|
|
@@ -554,7 +560,7 @@ function de(t, r) {
|
|
|
554
560
|
}
|
|
555
561
|
return !1;
|
|
556
562
|
}
|
|
557
|
-
function
|
|
563
|
+
function pe(t, r) {
|
|
558
564
|
return new Promise((e) => {
|
|
559
565
|
r.forEach(async (n) => {
|
|
560
566
|
try {
|
|
@@ -565,7 +571,7 @@ function fe(t, r) {
|
|
|
565
571
|
}), e();
|
|
566
572
|
});
|
|
567
573
|
}
|
|
568
|
-
function
|
|
574
|
+
function he(t, r) {
|
|
569
575
|
return new Promise((e) => {
|
|
570
576
|
r.forEach(async (n) => {
|
|
571
577
|
try {
|
|
@@ -576,15 +582,15 @@ function pe(t, r) {
|
|
|
576
582
|
}), e();
|
|
577
583
|
});
|
|
578
584
|
}
|
|
579
|
-
const
|
|
585
|
+
const ve = (t, r, e) => {
|
|
580
586
|
t === void 0 && (window !== void 0 ? t = window.location.protocol === "http:" ? `ws://${window.location.host}/mqtt` : `wss://${window.location.host}/mqtt` : t = location.protocol === "http:" ? `ws://${location.host}/mqtt` : `wss://${location.host}/mqtt`);
|
|
581
|
-
const n = I([]), o = I(/* @__PURE__ */ new Map([])), a = I(/* @__PURE__ */ new Map([])), u = p((
|
|
582
|
-
const b = a.current.get(
|
|
587
|
+
const n = I([]), o = I(/* @__PURE__ */ new Map([])), a = I(/* @__PURE__ */ new Map([])), u = p((m) => {
|
|
588
|
+
const b = a.current.get(m.destinationName);
|
|
583
589
|
b && b.forEach((x) => {
|
|
584
|
-
x(
|
|
585
|
-
}), o.current.forEach((x,
|
|
586
|
-
new RegExp(
|
|
587
|
-
q(
|
|
590
|
+
x(m.destinationName, new TextDecoder().decode(m.payloadBytes), m.qos, m.retained);
|
|
591
|
+
}), o.current.forEach((x, L) => {
|
|
592
|
+
new RegExp(L).test(m.destinationName) && x.forEach((q) => {
|
|
593
|
+
q(m.destinationName, new TextDecoder().decode(m.payloadBytes), m.qos, m.retained);
|
|
588
594
|
});
|
|
589
595
|
});
|
|
590
596
|
}, []), s = I(!1), i = {
|
|
@@ -599,12 +605,12 @@ const he = (t, r, e) => {
|
|
|
599
605
|
sub: c,
|
|
600
606
|
unsub: h,
|
|
601
607
|
pub: g
|
|
602
|
-
} =
|
|
608
|
+
} = de(t, {
|
|
603
609
|
onMessage: u,
|
|
604
610
|
onConnected: () => {
|
|
605
|
-
n.current.forEach((
|
|
606
|
-
c(
|
|
607
|
-
console.warn("Failed to subscribe to",
|
|
611
|
+
n.current.forEach((m) => {
|
|
612
|
+
c(m).catch((b) => {
|
|
613
|
+
console.warn("Failed to subscribe to", m, b);
|
|
608
614
|
});
|
|
609
615
|
});
|
|
610
616
|
}
|
|
@@ -612,52 +618,52 @@ const he = (t, r, e) => {
|
|
|
612
618
|
M(() => {
|
|
613
619
|
s.current = d;
|
|
614
620
|
}, [d]);
|
|
615
|
-
const
|
|
621
|
+
const y = p((m, b) => {
|
|
616
622
|
let x;
|
|
617
|
-
typeof
|
|
618
|
-
const
|
|
619
|
-
let
|
|
620
|
-
if (
|
|
621
|
-
|
|
623
|
+
typeof m == "string" ? x = new RegExp(`^${m}$`) : x = m;
|
|
624
|
+
const L = x.toString().slice(1, -1);
|
|
625
|
+
let A = o.current.get(L);
|
|
626
|
+
if (A === void 0) {
|
|
627
|
+
A = [b], o.current.set(L, A);
|
|
622
628
|
return;
|
|
623
629
|
}
|
|
624
|
-
|
|
625
|
-
}, []), v = p((
|
|
630
|
+
A.includes(b) || A.push(b);
|
|
631
|
+
}, []), v = p((m) => {
|
|
626
632
|
o.current.forEach((b, x) => {
|
|
627
|
-
const
|
|
628
|
-
o.current.set(x,
|
|
633
|
+
const L = b.filter((A) => A !== m);
|
|
634
|
+
o.current.set(x, L);
|
|
629
635
|
});
|
|
630
|
-
}, []), w = p((
|
|
631
|
-
let x = a.current.get(
|
|
636
|
+
}, []), w = p((m, b) => {
|
|
637
|
+
let x = a.current.get(m);
|
|
632
638
|
if (x === void 0) {
|
|
633
|
-
x = [b], a.current.set(
|
|
639
|
+
x = [b], a.current.set(m, x);
|
|
634
640
|
return;
|
|
635
641
|
}
|
|
636
642
|
x.includes(b) || x.push(b);
|
|
637
|
-
}, []), C = p((
|
|
638
|
-
const x = a.current.get(
|
|
639
|
-
x !== void 0 && a.current.set(
|
|
643
|
+
}, []), C = p((m, b) => {
|
|
644
|
+
const x = a.current.get(m);
|
|
645
|
+
x !== void 0 && a.current.set(m, x.filter((L) => L !== b));
|
|
640
646
|
}, []);
|
|
641
647
|
return {
|
|
642
|
-
setSubs: p((
|
|
643
|
-
|
|
648
|
+
setSubs: p((m) => {
|
|
649
|
+
fe(n.current, m) || (s.current && pe(h, n.current).then(() => he(c, m)).catch((b) => {
|
|
644
650
|
console.warn("Failed to update subscriptions", b);
|
|
645
|
-
}), n.current =
|
|
651
|
+
}), n.current = m);
|
|
646
652
|
}, [c, h]),
|
|
647
653
|
error: l,
|
|
648
654
|
connected: d,
|
|
649
|
-
bind:
|
|
655
|
+
bind: y,
|
|
650
656
|
unbind: v,
|
|
651
657
|
bindExact: w,
|
|
652
658
|
unbindExact: C,
|
|
653
659
|
pub: g
|
|
654
660
|
};
|
|
655
661
|
}, T = () => {
|
|
656
|
-
const t = E(), { user: r } =
|
|
662
|
+
const t = E(), { user: r } = X(), e = new URL(t.lynxClient.baseURL), n = e.protocol === "http:" ? "ws:" : "wss:", o = e.hostname, a = e.port ? `:${e.port}` : "", u = `${n}//${o}${a}/mqtt`;
|
|
657
663
|
let s = r?.email ?? "api-key";
|
|
658
|
-
return t.lynxClient.bearer && (s = "bearer"),
|
|
659
|
-
},
|
|
660
|
-
const r = T(), { functions: e, refresh: n } =
|
|
664
|
+
return t.lynxClient.bearer && (s = "bearer"), ve(u, s, t.lynxClient.apiKey);
|
|
665
|
+
}, Ve = (t) => {
|
|
666
|
+
const r = T(), { functions: e, refresh: n } = ee(t.id), { devices: o, refresh: a } = Z(t.id), { unbind: u, bind: s, setSubs: i } = r;
|
|
661
667
|
return M(() => (i([`${t.client_id}/#`]), s(/[0-9]+\/evt\/functionx\/updated/, n), s(/[0-9]+\/evt\/devicex\/updated/, a), () => {
|
|
662
668
|
u(n), u(a);
|
|
663
669
|
}), [s, a, n, t, i, u]), {
|
|
@@ -666,8 +672,8 @@ const he = (t, r, e) => {
|
|
|
666
672
|
devices: o,
|
|
667
673
|
mqtt: r
|
|
668
674
|
};
|
|
669
|
-
},
|
|
670
|
-
const r = T(), { installation: e } =
|
|
675
|
+
}, Be = (t) => {
|
|
676
|
+
const r = T(), { installation: e } = le(t), { functions: n, refresh: o } = ee(t), { devices: a, refresh: u } = Z(t), { unbind: s, bind: i, setSubs: l } = r;
|
|
671
677
|
return M(() => (l([`${e.client_id}/#`]), i(/[0-9]+\/evt\/functionx\/updated/, o), i(/[0-9]+\/evt\/devicex\/updated/, u), () => {
|
|
672
678
|
s(o), s(u);
|
|
673
679
|
}), [i, u, o, e, l, s]), {
|
|
@@ -676,7 +682,7 @@ const he = (t, r, e) => {
|
|
|
676
682
|
devices: a,
|
|
677
683
|
mqtt: r
|
|
678
684
|
};
|
|
679
|
-
},
|
|
685
|
+
}, Ke = (t, r = []) => {
|
|
680
686
|
const [e, n] = f([]);
|
|
681
687
|
O(() => {
|
|
682
688
|
if (t) {
|
|
@@ -702,13 +708,13 @@ const he = (t, r, e) => {
|
|
|
702
708
|
}, [e, n]), u = p((c) => {
|
|
703
709
|
n(e.filter((h, g) => g !== c));
|
|
704
710
|
}, [e, n]), s = p((c, h) => {
|
|
705
|
-
n(e.map((g,
|
|
711
|
+
n(e.map((g, y) => y === c ? h : g));
|
|
706
712
|
}, [e, n]), i = p((c, h) => {
|
|
707
|
-
n(e.map((g,
|
|
713
|
+
n(e.map((g, y) => y === c ? { ...g, key: h } : g));
|
|
708
714
|
}, [e, n]), l = p((c, h) => {
|
|
709
|
-
n(e.map((g,
|
|
715
|
+
n(e.map((g, y) => y === c ? { ...g, value: h } : g));
|
|
710
716
|
}, [e, n]), d = p((c, h) => {
|
|
711
|
-
n(e.map((g,
|
|
717
|
+
n(e.map((g, y) => y === c ? { ...g, protected: h } : g));
|
|
712
718
|
}, [e, n]);
|
|
713
719
|
return {
|
|
714
720
|
metaList: e,
|
|
@@ -720,8 +726,8 @@ const he = (t, r, e) => {
|
|
|
720
726
|
setMetaValue: l,
|
|
721
727
|
setMetaProtected: d
|
|
722
728
|
};
|
|
723
|
-
},
|
|
724
|
-
const { lynxClient: r } = E(), e = T(), { bind: n, unbind: o, setSubs: a } = e, [u, s] = f(/* @__PURE__ */ new Map()), [i, l] = f(/* @__PURE__ */ new Map()), [d, c] = f(/* @__PURE__ */ new Map()), [h, g] = f(/* @__PURE__ */ new Map()),
|
|
729
|
+
}, Qe = (t) => {
|
|
730
|
+
const { lynxClient: r } = E(), e = T(), { bind: n, unbind: o, setSubs: a } = e, [u, s] = f(/* @__PURE__ */ new Map()), [i, l] = f(/* @__PURE__ */ new Map()), [d, c] = f(/* @__PURE__ */ new Map()), [h, g] = f(/* @__PURE__ */ new Map()), y = p((w) => {
|
|
725
731
|
const C = i.get(w);
|
|
726
732
|
return C !== void 0 ? C.client_id : 0;
|
|
727
733
|
}, [i]), v = p((w) => {
|
|
@@ -735,41 +741,41 @@ const he = (t, r, e) => {
|
|
|
735
741
|
t.forEach((_) => {
|
|
736
742
|
w.set(_.id, _), C.set(_.client_id, _), N.push(`${_.client_id}/#`);
|
|
737
743
|
});
|
|
738
|
-
let
|
|
739
|
-
const b = t.map(async (_) => ({ functions: await r.getFunctions(_.id), installationId: _.id })), x = t.map(async (_) => ({ devices: await r.getDevices(_.id), installationId: _.id })),
|
|
744
|
+
let m = !1;
|
|
745
|
+
const b = t.map(async (_) => ({ functions: await r.getFunctions(_.id), installationId: _.id })), x = t.map(async (_) => ({ devices: await r.getDevices(_.id), installationId: _.id })), L = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map();
|
|
740
746
|
new Promise((_, F) => {
|
|
741
|
-
let
|
|
747
|
+
let P = !1, D = !1;
|
|
742
748
|
Promise.allSettled(b).then((z) => {
|
|
743
749
|
z.forEach((U) => {
|
|
744
|
-
U.status === "fulfilled" &&
|
|
745
|
-
}),
|
|
750
|
+
U.status === "fulfilled" && A.set(U.value.installationId, U.value.functions);
|
|
751
|
+
}), P = !0, P && D && _();
|
|
746
752
|
}).catch(F), Promise.allSettled(x).then((z) => {
|
|
747
753
|
z.forEach((U) => {
|
|
748
|
-
U.status === "fulfilled" &&
|
|
749
|
-
}),
|
|
754
|
+
U.status === "fulfilled" && L.set(U.value.installationId, U.value.devices);
|
|
755
|
+
}), D = !0, P && D && _();
|
|
750
756
|
}).catch(F);
|
|
751
757
|
}).finally(() => {
|
|
752
|
-
s(() => C), l(() => w), c(() =>
|
|
758
|
+
s(() => C), l(() => w), c(() => A), g(() => L), m = !0;
|
|
753
759
|
}).catch((_) => {
|
|
754
760
|
console.warn("Error in work.finally:", _);
|
|
755
761
|
});
|
|
756
762
|
const $ = (_) => {
|
|
757
|
-
if (!
|
|
763
|
+
if (!m)
|
|
758
764
|
return;
|
|
759
|
-
const F = Number(_.split("/")[0]),
|
|
760
|
-
|
|
761
|
-
c((z) => new Map([...z, [
|
|
762
|
-
}).catch((
|
|
763
|
-
console.warn("Failed to update function map for",
|
|
765
|
+
const F = Number(_.split("/")[0]), P = C.get(F);
|
|
766
|
+
P !== void 0 && r.getFunctions(P.id).then((D) => {
|
|
767
|
+
c((z) => new Map([...z, [P.id, D]]));
|
|
768
|
+
}).catch((D) => {
|
|
769
|
+
console.warn("Failed to update function map for", P.id, D);
|
|
764
770
|
});
|
|
765
771
|
}, V = (_) => {
|
|
766
|
-
if (!
|
|
772
|
+
if (!m)
|
|
767
773
|
return;
|
|
768
|
-
const F = Number(_.split("/")[0]),
|
|
769
|
-
|
|
770
|
-
g((z) => new Map([...z, [
|
|
771
|
-
}).catch((
|
|
772
|
-
console.warn("Failed to update device map for",
|
|
774
|
+
const F = Number(_.split("/")[0]), P = C.get(F);
|
|
775
|
+
P !== void 0 && r.getDevices(P.id).then((D) => {
|
|
776
|
+
g((z) => new Map([...z, [P.id, D]]));
|
|
777
|
+
}).catch((D) => {
|
|
778
|
+
console.warn("Failed to update device map for", P.id, D);
|
|
773
779
|
});
|
|
774
780
|
};
|
|
775
781
|
return a(N), n(/[0-9]+\/evt\/functionx\/updated/, $), n(/[0-9]+\/evt\/devicex\/updated/, V), () => {
|
|
@@ -780,10 +786,10 @@ const he = (t, r, e) => {
|
|
|
780
786
|
functionMap: d,
|
|
781
787
|
deviceMap: h,
|
|
782
788
|
mqtt: e,
|
|
783
|
-
toClientId:
|
|
789
|
+
toClientId: y,
|
|
784
790
|
toInstallationId: v
|
|
785
791
|
};
|
|
786
|
-
},
|
|
792
|
+
}, je = (t, r) => {
|
|
787
793
|
const e = typeof t == "string" ? Number.parseInt(t) : t;
|
|
788
794
|
if (isNaN(e))
|
|
789
795
|
throw new Error("invalid installationId");
|
|
@@ -802,7 +808,7 @@ const he = (t, r, e) => {
|
|
|
802
808
|
create: s,
|
|
803
809
|
setType: u
|
|
804
810
|
};
|
|
805
|
-
},
|
|
811
|
+
}, Ge = (t, r) => {
|
|
806
812
|
const e = typeof t == "string" ? Number.parseInt(t) : t;
|
|
807
813
|
if (isNaN(e))
|
|
808
814
|
throw new Error("invalid installationId");
|
|
@@ -821,7 +827,7 @@ const he = (t, r, e) => {
|
|
|
821
827
|
create: s,
|
|
822
828
|
setType: u
|
|
823
829
|
};
|
|
824
|
-
},
|
|
830
|
+
}, He = (t, r) => {
|
|
825
831
|
const e = typeof t == "string" ? Number.parseInt(t) : t;
|
|
826
832
|
if (isNaN(e))
|
|
827
833
|
throw new Error("invalid organizationId");
|
|
@@ -839,13 +845,13 @@ const he = (t, r, e) => {
|
|
|
839
845
|
setNewInstallation: o,
|
|
840
846
|
create: u
|
|
841
847
|
};
|
|
842
|
-
},
|
|
848
|
+
}, ge = {
|
|
843
849
|
installation_id: 0,
|
|
844
850
|
name: "",
|
|
845
851
|
text: ""
|
|
846
|
-
},
|
|
852
|
+
}, Je = (t, r) => {
|
|
847
853
|
const e = typeof t == "string" ? Number.parseInt(t) : t, { lynxClient: n } = E(), [o, a] = f({
|
|
848
|
-
...
|
|
854
|
+
...ge,
|
|
849
855
|
...r,
|
|
850
856
|
installation_id: e
|
|
851
857
|
}), u = p(() => n.createNotificationMessage(o), [n, o]);
|
|
@@ -854,15 +860,15 @@ const he = (t, r, e) => {
|
|
|
854
860
|
setNewNotificationMessage: a,
|
|
855
861
|
create: u
|
|
856
862
|
};
|
|
857
|
-
},
|
|
863
|
+
}, me = {
|
|
858
864
|
installation_id: 0,
|
|
859
865
|
name: "",
|
|
860
866
|
notification_message_id: 0,
|
|
861
867
|
notification_output_executor_id: 0,
|
|
862
868
|
config: {}
|
|
863
|
-
},
|
|
869
|
+
}, We = (t, r) => {
|
|
864
870
|
const e = typeof t == "string" ? Number.parseInt(t) : t, { lynxClient: n } = E(), [o, a] = f({
|
|
865
|
-
...
|
|
871
|
+
...me,
|
|
866
872
|
...r,
|
|
867
873
|
installation_id: e
|
|
868
874
|
}), u = p(() => n.createNotificationOutput(o), [n, o]);
|
|
@@ -871,9 +877,9 @@ const he = (t, r, e) => {
|
|
|
871
877
|
setNewNotificationOutput: a,
|
|
872
878
|
create: u
|
|
873
879
|
};
|
|
874
|
-
},
|
|
880
|
+
}, Xe = (t) => {
|
|
875
881
|
const { lynxClient: r } = E(), [e, n] = f({
|
|
876
|
-
...
|
|
882
|
+
...H.getEmptyOAuth2Client(),
|
|
877
883
|
...t
|
|
878
884
|
}), o = p((c) => {
|
|
879
885
|
n({ ...e, name: c });
|
|
@@ -916,7 +922,7 @@ const he = (t, r, e) => {
|
|
|
916
922
|
password_valid_days: 0,
|
|
917
923
|
phone: "",
|
|
918
924
|
protected_meta: {}
|
|
919
|
-
},
|
|
925
|
+
}, Ye = (t, r) => {
|
|
920
926
|
const e = typeof t == "string" ? Number.parseInt(t) : t;
|
|
921
927
|
if (isNaN(e))
|
|
922
928
|
throw new Error("invalid parentId");
|
|
@@ -930,7 +936,7 @@ const he = (t, r, e) => {
|
|
|
930
936
|
setNewOrganization: a,
|
|
931
937
|
create: u
|
|
932
938
|
};
|
|
933
|
-
},
|
|
939
|
+
}, we = {
|
|
934
940
|
address: {
|
|
935
941
|
address: "",
|
|
936
942
|
zip: "",
|
|
@@ -950,9 +956,9 @@ const he = (t, r, e) => {
|
|
|
950
956
|
sms_login: !1,
|
|
951
957
|
protected_meta: {},
|
|
952
958
|
meta: {}
|
|
953
|
-
},
|
|
959
|
+
}, Ze = (t) => {
|
|
954
960
|
const [r, e] = f({
|
|
955
|
-
...
|
|
961
|
+
...we,
|
|
956
962
|
...t
|
|
957
963
|
}), { lynxClient: n } = E(), o = p(() => n.createUser(r), [n, r]);
|
|
958
964
|
return {
|
|
@@ -960,38 +966,38 @@ const he = (t, r, e) => {
|
|
|
960
966
|
setNewUser: e,
|
|
961
967
|
create: o
|
|
962
968
|
};
|
|
963
|
-
},
|
|
969
|
+
}, K = {
|
|
964
970
|
id: 0,
|
|
965
971
|
installation_id: 0,
|
|
966
972
|
name: "",
|
|
967
973
|
text: ""
|
|
968
|
-
},
|
|
974
|
+
}, et = (t, r) => {
|
|
969
975
|
const e = typeof t == "string" ? Number.parseInt(t) : t, n = typeof r == "string" ? Number.parseInt(r) : r;
|
|
970
976
|
if (isNaN(e))
|
|
971
977
|
throw new Error("invalid installationId");
|
|
972
978
|
if (isNaN(n))
|
|
973
979
|
throw new Error("invalid messageId");
|
|
974
980
|
const { lynxClient: o } = E(), [a, u] = f(!0), [s, i] = f({
|
|
975
|
-
...
|
|
981
|
+
...K
|
|
976
982
|
}), [l, d] = f(), c = p(() => {
|
|
977
|
-
e === 0 || n === 0 || (u(!0), o.getNotificationMessage(e, n).then((
|
|
978
|
-
d((v) => v !== void 0 ? void 0 : v), i(
|
|
979
|
-
}).catch((
|
|
980
|
-
d(
|
|
983
|
+
e === 0 || n === 0 || (u(!0), o.getNotificationMessage(e, n).then((y) => {
|
|
984
|
+
d((v) => v !== void 0 ? void 0 : v), i(y);
|
|
985
|
+
}).catch((y) => {
|
|
986
|
+
d(y);
|
|
981
987
|
}).finally(() => {
|
|
982
988
|
u(!1);
|
|
983
989
|
}));
|
|
984
990
|
}, [n, e, o]), h = p(() => {
|
|
985
|
-
l !== void 0 && d(void 0), o.updateNotificationMessage(s).then((
|
|
986
|
-
i(
|
|
987
|
-
}).catch((
|
|
988
|
-
d(
|
|
991
|
+
l !== void 0 && d(void 0), o.updateNotificationMessage(s).then((y) => {
|
|
992
|
+
i(y);
|
|
993
|
+
}).catch((y) => {
|
|
994
|
+
d(y);
|
|
989
995
|
});
|
|
990
996
|
}, [l, o, s]), g = p(() => {
|
|
991
997
|
o.deleteNotificationMessage(s).then(() => {
|
|
992
|
-
i({ ...
|
|
993
|
-
}).catch((
|
|
994
|
-
d(
|
|
998
|
+
i({ ...K });
|
|
999
|
+
}).catch((y) => {
|
|
1000
|
+
d(y);
|
|
995
1001
|
});
|
|
996
1002
|
}, [o, s]);
|
|
997
1003
|
return M(() => {
|
|
@@ -1005,7 +1011,7 @@ const he = (t, r, e) => {
|
|
|
1005
1011
|
remove: g,
|
|
1006
1012
|
update: h
|
|
1007
1013
|
};
|
|
1008
|
-
},
|
|
1014
|
+
}, tt = (t) => {
|
|
1009
1015
|
const r = typeof t == "string" ? Number.parseInt(t) : t;
|
|
1010
1016
|
if (isNaN(r))
|
|
1011
1017
|
throw new Error("invalid installationId");
|
|
@@ -1033,7 +1039,7 @@ const he = (t, r, e) => {
|
|
|
1033
1039
|
notification_message_id: 0,
|
|
1034
1040
|
notification_output_executor_id: 0,
|
|
1035
1041
|
config: {}
|
|
1036
|
-
},
|
|
1042
|
+
}, nt = (t, r) => {
|
|
1037
1043
|
const e = typeof t == "string" ? Number.parseInt(t) : t, n = typeof r == "string" ? Number.parseInt(r) : r;
|
|
1038
1044
|
if (isNaN(e))
|
|
1039
1045
|
throw new Error("invalid installationId");
|
|
@@ -1043,24 +1049,24 @@ const he = (t, r, e) => {
|
|
|
1043
1049
|
...k,
|
|
1044
1050
|
config: { ...k.config }
|
|
1045
1051
|
}), [l, d] = f(), c = p(() => {
|
|
1046
|
-
e === 0 || n === 0 || (u(!0), o.getNotificationOutput(e, n).then((
|
|
1047
|
-
d((v) => v !== void 0 ? void 0 : v), i(
|
|
1048
|
-
}).catch((
|
|
1049
|
-
d(
|
|
1052
|
+
e === 0 || n === 0 || (u(!0), o.getNotificationOutput(e, n).then((y) => {
|
|
1053
|
+
d((v) => v !== void 0 ? void 0 : v), i(y);
|
|
1054
|
+
}).catch((y) => {
|
|
1055
|
+
d(y);
|
|
1050
1056
|
}).finally(() => {
|
|
1051
1057
|
u(!1);
|
|
1052
1058
|
}));
|
|
1053
1059
|
}, [n, e, o]), h = p(() => {
|
|
1054
|
-
l !== void 0 && d(void 0), o.updateNotificationOutput(s).then((
|
|
1055
|
-
i(
|
|
1056
|
-
}).catch((
|
|
1057
|
-
d(
|
|
1060
|
+
l !== void 0 && d(void 0), o.updateNotificationOutput(s).then((y) => {
|
|
1061
|
+
i(y);
|
|
1062
|
+
}).catch((y) => {
|
|
1063
|
+
d(y);
|
|
1058
1064
|
});
|
|
1059
1065
|
}, [l, o, s]), g = p(() => {
|
|
1060
1066
|
o.deleteNotificationOutput(s).then(() => {
|
|
1061
1067
|
i({ ...k });
|
|
1062
|
-
}).catch((
|
|
1063
|
-
d(
|
|
1068
|
+
}).catch((y) => {
|
|
1069
|
+
d(y);
|
|
1064
1070
|
});
|
|
1065
1071
|
}, [o, s]);
|
|
1066
1072
|
return M(() => {
|
|
@@ -1074,21 +1080,21 @@ const he = (t, r, e) => {
|
|
|
1074
1080
|
remove: g,
|
|
1075
1081
|
update: h
|
|
1076
1082
|
};
|
|
1077
|
-
},
|
|
1083
|
+
}, Ne = {
|
|
1078
1084
|
id: 0,
|
|
1079
1085
|
type: "",
|
|
1080
1086
|
name: "",
|
|
1081
1087
|
organization_id: 0,
|
|
1082
1088
|
config: {},
|
|
1083
1089
|
secret: ""
|
|
1084
|
-
},
|
|
1090
|
+
}, ot = (t, r) => {
|
|
1085
1091
|
const e = typeof t == "string" ? Number.parseInt(t) : t, n = typeof r == "string" ? Number.parseInt(r) : r;
|
|
1086
1092
|
if (isNaN(e))
|
|
1087
1093
|
throw new Error("invalid installationId");
|
|
1088
1094
|
if (isNaN(n))
|
|
1089
1095
|
throw new Error("invalid messageId");
|
|
1090
1096
|
const { lynxClient: o } = E(), [a, u] = f(!0), [s, i] = f({
|
|
1091
|
-
...
|
|
1097
|
+
...Ne
|
|
1092
1098
|
}), [l, d] = f(), c = p(() => {
|
|
1093
1099
|
e === 0 || n === 0 || (u(!0), o.getNotificationOutputExecutor(e, n).then((h) => {
|
|
1094
1100
|
d((g) => g !== void 0 ? void 0 : g), i(h);
|
|
@@ -1107,7 +1113,7 @@ const he = (t, r, e) => {
|
|
|
1107
1113
|
error: l,
|
|
1108
1114
|
loading: a
|
|
1109
1115
|
};
|
|
1110
|
-
},
|
|
1116
|
+
}, rt = (t) => {
|
|
1111
1117
|
const r = typeof t == "string" ? Number.parseInt(t) : t;
|
|
1112
1118
|
if (isNaN(r))
|
|
1113
1119
|
throw new Error("invalid installationId");
|
|
@@ -1128,7 +1134,7 @@ const he = (t, r, e) => {
|
|
|
1128
1134
|
error: s,
|
|
1129
1135
|
loading: a
|
|
1130
1136
|
};
|
|
1131
|
-
},
|
|
1137
|
+
}, st = (t) => {
|
|
1132
1138
|
const r = typeof t == "string" ? Number.parseInt(t) : t;
|
|
1133
1139
|
if (isNaN(r))
|
|
1134
1140
|
throw new Error("invalid installationId");
|
|
@@ -1149,8 +1155,8 @@ const he = (t, r, e) => {
|
|
|
1149
1155
|
error: s,
|
|
1150
1156
|
loading: a
|
|
1151
1157
|
};
|
|
1152
|
-
},
|
|
1153
|
-
const { lynxClient: r } = E(), [e, n] = f(!0), [o, a] = f(), [u, s] = f({ ...
|
|
1158
|
+
}, Ee = (t) => {
|
|
1159
|
+
const { lynxClient: r } = E(), [e, n] = f(!0), [o, a] = f(), [u, s] = f({ ...H.getOAuth2Client() }), i = p(() => {
|
|
1154
1160
|
e || n(!0), r.getOAuth2Client(t).then((c) => {
|
|
1155
1161
|
a((h) => h !== void 0 ? void 0 : h), s(c);
|
|
1156
1162
|
}).catch((c) => {
|
|
@@ -1172,7 +1178,7 @@ const he = (t, r, e) => {
|
|
|
1172
1178
|
remove: l,
|
|
1173
1179
|
update: d
|
|
1174
1180
|
};
|
|
1175
|
-
},
|
|
1181
|
+
}, it = () => {
|
|
1176
1182
|
const { lynxClient: t } = E(), [r, e] = f(!0), [n, o] = f(), [a, u] = f([]), s = p(() => {
|
|
1177
1183
|
t.getOAuth2Clients().then((i) => {
|
|
1178
1184
|
o((l) => l !== void 0 ? void 0 : l), u(i);
|
|
@@ -1190,19 +1196,19 @@ const he = (t, r, e) => {
|
|
|
1190
1196
|
error: n,
|
|
1191
1197
|
loading: r
|
|
1192
1198
|
};
|
|
1193
|
-
},
|
|
1194
|
-
const { lynxClient: t } = E(), [r, e] = f([]), [n] = f(new URLSearchParams(window.location.search)), o = n.get("client_id") ?? "", { client: a } =
|
|
1199
|
+
}, ct = () => {
|
|
1200
|
+
const { lynxClient: t } = E(), [r, e] = f([]), [n] = f(new URLSearchParams(window.location.search)), o = n.get("client_id") ?? "", { client: a } = Ee(o), u = p((s) => {
|
|
1195
1201
|
const i = Object.fromEntries(n);
|
|
1196
1202
|
return i.scope = s.join(" "), t.consentOAuth2Authorization(i);
|
|
1197
1203
|
}, [t, n]);
|
|
1198
1204
|
return M(() => {
|
|
1199
|
-
e(n.get("scope")?.split(" ") ?? []);
|
|
1205
|
+
Promise.resolve().then(() => e(n.get("scope")?.split(" ") ?? []));
|
|
1200
1206
|
}, [n]), {
|
|
1201
1207
|
consent: u,
|
|
1202
1208
|
client: a,
|
|
1203
1209
|
requestedScopes: r
|
|
1204
1210
|
};
|
|
1205
|
-
},
|
|
1211
|
+
}, Ce = {
|
|
1206
1212
|
address: {
|
|
1207
1213
|
address: "",
|
|
1208
1214
|
city: "",
|
|
@@ -1220,11 +1226,11 @@ const he = (t, r, e) => {
|
|
|
1220
1226
|
phone: "",
|
|
1221
1227
|
protected_meta: {},
|
|
1222
1228
|
id: 0
|
|
1223
|
-
},
|
|
1229
|
+
}, at = (t) => {
|
|
1224
1230
|
const r = typeof t == "string" ? Number.parseInt(t) : t;
|
|
1225
1231
|
if (isNaN(r))
|
|
1226
1232
|
throw new Error("invalid organizationId");
|
|
1227
|
-
const [e, n] = f({ ...
|
|
1233
|
+
const [e, n] = f({ ...Ce }), [o, a] = f(!0), [u, s] = f(), { lynxClient: i } = E(), l = p(() => {
|
|
1228
1234
|
a(!0), i.getOrganization(r).then((h) => {
|
|
1229
1235
|
s((g) => g !== void 0 ? void 0 : g), n(h);
|
|
1230
1236
|
}).catch((h) => {
|
|
@@ -1246,7 +1252,7 @@ const he = (t, r, e) => {
|
|
|
1246
1252
|
remove: c,
|
|
1247
1253
|
refresh: l
|
|
1248
1254
|
};
|
|
1249
|
-
},
|
|
1255
|
+
}, ut = (t) => {
|
|
1250
1256
|
const { lynxClient: r } = E(), [e, n] = f(!0), [o, a] = f(), [u, s] = f([]), i = p(() => {
|
|
1251
1257
|
n(!0), r.getOrganizations(t === !0).then((c) => {
|
|
1252
1258
|
a((h) => h !== void 0 ? void 0 : h), s(c);
|
|
@@ -1268,7 +1274,7 @@ const he = (t, r, e) => {
|
|
|
1268
1274
|
create: l,
|
|
1269
1275
|
remove: d
|
|
1270
1276
|
};
|
|
1271
|
-
},
|
|
1277
|
+
}, lt = () => {
|
|
1272
1278
|
const { lynxClient: t } = E(), [r, e] = f([]), [n, o] = f(), [a, u] = f(!0), s = p(() => {
|
|
1273
1279
|
u(!0), t.getRoles().then((i) => {
|
|
1274
1280
|
o((l) => l !== void 0 ? void 0 : l), e(i);
|
|
@@ -1286,7 +1292,7 @@ const he = (t, r, e) => {
|
|
|
1286
1292
|
roles: r,
|
|
1287
1293
|
refresh: s
|
|
1288
1294
|
};
|
|
1289
|
-
},
|
|
1295
|
+
}, dt = () => {
|
|
1290
1296
|
const { lynxClient: t } = E(), [r, e] = f(!0), [n, o] = f(), [a, u] = f([]), s = p(() => {
|
|
1291
1297
|
e(!0), t.getTokens().then((d) => {
|
|
1292
1298
|
o((c) => c !== void 0 ? void 0 : c), u(d);
|
|
@@ -1297,7 +1303,7 @@ const he = (t, r, e) => {
|
|
|
1297
1303
|
});
|
|
1298
1304
|
}, [t]), i = p((d) => t.deleteToken(d), [t]), l = p((d) => t.createToken(d), [t]);
|
|
1299
1305
|
return O(() => {
|
|
1300
|
-
|
|
1306
|
+
Promise.resolve().then(s);
|
|
1301
1307
|
}, [s]), {
|
|
1302
1308
|
tokens: a,
|
|
1303
1309
|
remove: i,
|
|
@@ -1306,7 +1312,7 @@ const he = (t, r, e) => {
|
|
|
1306
1312
|
loading: r,
|
|
1307
1313
|
error: n
|
|
1308
1314
|
};
|
|
1309
|
-
},
|
|
1315
|
+
}, be = {
|
|
1310
1316
|
id: 0,
|
|
1311
1317
|
address: {
|
|
1312
1318
|
address: "",
|
|
@@ -1327,11 +1333,11 @@ const he = (t, r, e) => {
|
|
|
1327
1333
|
sms_login: !1,
|
|
1328
1334
|
protected_meta: {},
|
|
1329
1335
|
meta: {}
|
|
1330
|
-
},
|
|
1336
|
+
}, ft = (t) => {
|
|
1331
1337
|
const r = typeof t == "string" ? Number.parseInt(t) : t;
|
|
1332
1338
|
if (isNaN(r))
|
|
1333
1339
|
throw new Error("invalid userId");
|
|
1334
|
-
const [e, n] = f({ ...
|
|
1340
|
+
const [e, n] = f({ ...be }), [o, a] = f(!0), { lynxClient: u } = E(), [s, i] = f(), l = p(() => {
|
|
1335
1341
|
a(!0), u.getUser(r).then((h) => {
|
|
1336
1342
|
i((g) => g !== void 0 ? void 0 : g), n(h);
|
|
1337
1343
|
}).catch((h) => {
|
|
@@ -1349,10 +1355,8 @@ const he = (t, r, e) => {
|
|
|
1349
1355
|
refresh: l,
|
|
1350
1356
|
remove: c
|
|
1351
1357
|
};
|
|
1352
|
-
},
|
|
1353
|
-
const [r, e] = f([]), [n, o] = f(!0), [a, u] = f(), { lynxClient: s } = E()
|
|
1354
|
-
new URLSearchParams();
|
|
1355
|
-
const i = p(() => {
|
|
1358
|
+
}, pt = (t) => {
|
|
1359
|
+
const [r, e] = f([]), [n, o] = f(!0), [a, u] = f(), { lynxClient: s } = E(), i = p(() => {
|
|
1356
1360
|
o(!0), s.getUsers(t).then((l) => {
|
|
1357
1361
|
u((d) => d !== void 0 ? void 0 : d), e(l);
|
|
1358
1362
|
}).catch((l) => {
|
|
@@ -1370,55 +1374,55 @@ const he = (t, r, e) => {
|
|
|
1370
1374
|
};
|
|
1371
1375
|
};
|
|
1372
1376
|
export {
|
|
1373
|
-
|
|
1377
|
+
Pe as LynxProvider,
|
|
1374
1378
|
De as useConfiguredEdgeApps,
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1379
|
+
Fe as useDevice,
|
|
1380
|
+
Ie as useDeviceMeta,
|
|
1381
|
+
Z as useDevices,
|
|
1382
|
+
ze as useEdgeApp,
|
|
1383
|
+
Se as useEdgeAppVersions,
|
|
1384
|
+
Ue as useEdgeApps,
|
|
1385
|
+
ke as useFunction,
|
|
1386
|
+
Re as useFunctionMeta,
|
|
1387
|
+
ee as useFunctions,
|
|
1384
1388
|
E as useGlobalLynxClient,
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1389
|
+
Y as useGlobalPermissions,
|
|
1390
|
+
X as useGlobalUser,
|
|
1391
|
+
Te as useIDTokenAlgorithms,
|
|
1392
|
+
le as useInstallation,
|
|
1393
|
+
qe as useInstallationInfo,
|
|
1394
|
+
$e as useInstallations,
|
|
1395
|
+
Ve as useLiveInstallation,
|
|
1396
|
+
Be as useLiveInstallationId,
|
|
1393
1397
|
T as useMQTT,
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1398
|
+
Ke as useMeta,
|
|
1399
|
+
Qe as useMultiLiveInstallation,
|
|
1400
|
+
je as useNewDevice,
|
|
1401
|
+
Ge as useNewFunction,
|
|
1402
|
+
He as useNewInstallation,
|
|
1403
|
+
Je as useNewNotificationMessage,
|
|
1404
|
+
We as useNewNotificationOutput,
|
|
1405
|
+
Xe as useNewOAuth2Client,
|
|
1406
|
+
Ye as useNewOrganization,
|
|
1407
|
+
Ze as useNewUser,
|
|
1408
|
+
et as useNotificationMessage,
|
|
1409
|
+
tt as useNotificationMessages,
|
|
1410
|
+
nt as useNotificationOutput,
|
|
1411
|
+
ot as useNotificationOutputExecutor,
|
|
1412
|
+
rt as useNotificationOutputExecutors,
|
|
1413
|
+
st as useNotificationOutputs,
|
|
1414
|
+
Ee as useOAuth2Client,
|
|
1415
|
+
it as useOAuth2Clients,
|
|
1416
|
+
ct as useOAuth2Consent,
|
|
1417
|
+
at as useOrganization,
|
|
1418
|
+
ut as useOrganizations,
|
|
1419
|
+
de as usePahoMQTTClient,
|
|
1416
1420
|
Le as usePermissionsCheckAll,
|
|
1417
1421
|
Ae as usePermissionsCheckAny,
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1422
|
+
lt as useRoles,
|
|
1423
|
+
ve as useSimpleMQTT,
|
|
1424
|
+
dt as useTokens,
|
|
1425
|
+
ft as useUser,
|
|
1426
|
+
pt as useUsers
|
|
1423
1427
|
};
|
|
1424
1428
|
//# sourceMappingURL=index.js.map
|