@formant/data-sdk 1.11.0 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-sdk.cjs.js +2 -2
- package/dist/data-sdk.cjs.js.map +1 -1
- package/dist/data-sdk.es.js +321 -281
- package/dist/data-sdk.es.js.map +1 -1
- package/dist/data-sdk.es6.js +41 -1
- package/dist/data-sdk.umd.js +1 -1
- package/dist/types/data-sdk/src/EventTriggerGroup.d.ts +0 -0
- package/dist/types/data-sdk/src/Fleet.d.ts +6 -0
- package/dist/types/data-sdk/src/api/getAllEventTriggerGroup.d.ts +2 -0
- package/dist/types/data-sdk/src/api/getEventTriggerGroup.d.ts +2 -0
- package/dist/types/data-sdk/src/api/patchEventTriggerGroup.d.ts +2 -0
- package/dist/types/data-sdk/src/model/IEventTriggerGroup.d.ts +13 -0
- package/package.json +1 -1
package/dist/data-sdk.es.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var re = Object.defineProperty;
|
|
2
2
|
var se = (a, e, t) => e in a ? re(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
|
|
3
|
-
var
|
|
3
|
+
var r = (a, e, t) => (se(a, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
4
|
import { decode as J } from "base-64";
|
|
5
|
-
import * as
|
|
6
|
-
import { startOfMinute as ce, addMinutes as de, roundToNearestMinutes as he, addSeconds as
|
|
7
|
-
import { RtcClient as
|
|
8
|
-
import { EventEmitter as
|
|
5
|
+
import * as l from "date-fns";
|
|
6
|
+
import { startOfMinute as ce, addMinutes as de, roundToNearestMinutes as he, addSeconds as ue } from "date-fns";
|
|
7
|
+
import { RtcClient as j, SignalingPromiseClient as N } from "@formant/realtime-sdk";
|
|
8
|
+
import { EventEmitter as le } from "eventemitter3";
|
|
9
9
|
import { deflate as me } from "pako";
|
|
10
10
|
import { fromByteArray as fe } from "base64-js";
|
|
11
11
|
const we = "https://api.formant.io";
|
|
@@ -44,17 +44,17 @@ class ye {
|
|
|
44
44
|
refreshAuthToken: t,
|
|
45
45
|
addAccessTokenRefreshListener: n
|
|
46
46
|
}) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
47
|
+
r(this, "_refreshToken");
|
|
48
|
+
r(this, "_isShareToken", !1);
|
|
49
|
+
r(this, "_currentOrganization");
|
|
50
|
+
r(this, "_currentUser");
|
|
51
|
+
r(this, "_defaultDeviceId");
|
|
52
|
+
r(this, "_token");
|
|
53
|
+
r(this, "_waitingForAuth", /* @__PURE__ */ new Set());
|
|
54
|
+
r(this, "_refreshTimer");
|
|
55
|
+
r(this, "_apiUrl");
|
|
56
|
+
r(this, "_refreshAuthToken");
|
|
57
|
+
r(this, "_addAccessTokenRefreshListener");
|
|
58
58
|
this._apiUrl = e, this._refreshAuthToken = t, this._addAccessTokenRefreshListener = n;
|
|
59
59
|
}
|
|
60
60
|
get token() {
|
|
@@ -104,9 +104,9 @@ class ye {
|
|
|
104
104
|
var i;
|
|
105
105
|
const n = JSON.parse(J(e.split(".")[1]));
|
|
106
106
|
try {
|
|
107
|
-
let
|
|
108
|
-
if (this._isShareToken = n["formant:claims"] && n["formant:claims"].type == "share", n["formant:claims"] && (this._currentOrganization = n["formant:claims"].organizationId), n["custom:organization_id"] && (this._currentOrganization = n["custom:organization_id"]), this._isShareToken || (
|
|
109
|
-
const c = await fetch(`${this._apiUrl}/v1/admin/users/${
|
|
107
|
+
let s;
|
|
108
|
+
if (this._isShareToken = n["formant:claims"] && n["formant:claims"].type == "share", n["formant:claims"] && (this._currentOrganization = n["formant:claims"].organizationId), n["custom:organization_id"] && (this._currentOrganization = n["custom:organization_id"]), this._isShareToken || (s = n.sub), n["formant:claims"] && n["formant:claims"].userId && (s = n["formant:claims"].userId), s && ((i = this._currentUser) == null ? void 0 : i.id) !== s) {
|
|
109
|
+
const c = await fetch(`${this._apiUrl}/v1/admin/users/${s}`, {
|
|
110
110
|
method: "GET",
|
|
111
111
|
headers: {
|
|
112
112
|
"Content-Type": "application/json",
|
|
@@ -118,8 +118,8 @@ class ye {
|
|
|
118
118
|
this._currentUser = d;
|
|
119
119
|
}
|
|
120
120
|
this._token = e, this._waitingForAuth.forEach((c) => c(!0));
|
|
121
|
-
} catch (
|
|
122
|
-
console.error("loginWithToken() failed", { err:
|
|
121
|
+
} catch (s) {
|
|
122
|
+
console.error("loginWithToken() failed", { err: s }), this._waitingForAuth.forEach((c) => c(!1));
|
|
123
123
|
} finally {
|
|
124
124
|
this._waitingForAuth.clear();
|
|
125
125
|
}
|
|
@@ -241,7 +241,7 @@ function V() {
|
|
|
241
241
|
module: a
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
|
-
function
|
|
244
|
+
function G(a) {
|
|
245
245
|
function e(t) {
|
|
246
246
|
const n = t.data;
|
|
247
247
|
n.type === "auth_token" && a(n.token);
|
|
@@ -253,7 +253,7 @@ function F(a) {
|
|
|
253
253
|
const o = new ye({
|
|
254
254
|
apiUrl: h,
|
|
255
255
|
refreshAuthToken: V,
|
|
256
|
-
addAccessTokenRefreshListener:
|
|
256
|
+
addAccessTokenRefreshListener: G
|
|
257
257
|
});
|
|
258
258
|
async function ge(a) {
|
|
259
259
|
return (await (await fetch(
|
|
@@ -344,14 +344,14 @@ function Ae(a) {
|
|
|
344
344
|
};
|
|
345
345
|
return window.addEventListener("message", e), () => window.removeEventListener("message", e);
|
|
346
346
|
}
|
|
347
|
-
function
|
|
347
|
+
function je(a) {
|
|
348
348
|
const e = (t) => {
|
|
349
349
|
const n = t.data;
|
|
350
350
|
n.type === "module_configuration" && a(n);
|
|
351
351
|
};
|
|
352
352
|
return window.addEventListener("message", e), () => window.removeEventListener("message", e);
|
|
353
353
|
}
|
|
354
|
-
function
|
|
354
|
+
function Ne(a) {
|
|
355
355
|
const e = k();
|
|
356
356
|
e && T({ type: "request_module_data", module: e });
|
|
357
357
|
const t = (n) => {
|
|
@@ -364,7 +364,7 @@ function Pe(a) {
|
|
|
364
364
|
};
|
|
365
365
|
return window.addEventListener("message", t), () => window.removeEventListener("message", t);
|
|
366
366
|
}
|
|
367
|
-
function
|
|
367
|
+
function De(a) {
|
|
368
368
|
T({ type: "request_devices" });
|
|
369
369
|
const e = (t) => {
|
|
370
370
|
const n = t.data;
|
|
@@ -372,10 +372,10 @@ function je(a) {
|
|
|
372
372
|
};
|
|
373
373
|
return window.addEventListener("message", e), () => window.removeEventListener("message", e);
|
|
374
374
|
}
|
|
375
|
-
const
|
|
376
|
-
millisecond:
|
|
377
|
-
second:
|
|
378
|
-
minute:
|
|
375
|
+
const Pe = 1, F = 1e3, W = 60 * F, H = 60 * W, I = 24 * H, Ie = 7 * I, Le = 30 * I, _e = 365 * I, L = {
|
|
376
|
+
millisecond: Pe,
|
|
377
|
+
second: F,
|
|
378
|
+
minute: W,
|
|
379
379
|
hour: H,
|
|
380
380
|
day: I,
|
|
381
381
|
week: Ie,
|
|
@@ -387,27 +387,27 @@ function $e(a, e) {
|
|
|
387
387
|
}
|
|
388
388
|
function ze(a, e, t) {
|
|
389
389
|
const n = e.getTime(), i = t.getTime();
|
|
390
|
-
return a.map((
|
|
391
|
-
...
|
|
392
|
-
points:
|
|
390
|
+
return a.map((s) => ({
|
|
391
|
+
...s,
|
|
392
|
+
points: s.points.filter(
|
|
393
393
|
([c]) => c >= n && c < i
|
|
394
394
|
)
|
|
395
|
-
})).filter(({ points:
|
|
395
|
+
})).filter(({ points: s }) => s.length > 0);
|
|
396
396
|
}
|
|
397
397
|
class x {
|
|
398
398
|
constructor({
|
|
399
399
|
capacity: e,
|
|
400
400
|
timeout: t
|
|
401
401
|
} = {}) {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
402
|
+
r(this, "entries", /* @__PURE__ */ new Map());
|
|
403
|
+
r(this, "metadata", /* @__PURE__ */ new Map());
|
|
404
|
+
r(this, "capacity");
|
|
405
|
+
r(this, "timeout");
|
|
406
406
|
this.capacity = e || 1e4, this.timeout = t || L.minute;
|
|
407
407
|
}
|
|
408
408
|
get(e, t) {
|
|
409
|
-
const n = this.keyToCacheKey(e), i = this.entries.get(n),
|
|
410
|
-
return (i === void 0 ||
|
|
409
|
+
const n = this.keyToCacheKey(e), i = this.entries.get(n), s = this.metadata.get(n);
|
|
410
|
+
return (i === void 0 || s && (s == null ? void 0 : s.expiration.getTime()) < Date.now()) && !(s != null && s.generating) && t && this.generate(e, t()), i === void 0 && s && s.lastValue !== void 0 ? s.lastValue : i;
|
|
411
411
|
}
|
|
412
412
|
set(e, t) {
|
|
413
413
|
const n = this.keyToCacheKey(e);
|
|
@@ -430,7 +430,7 @@ class x {
|
|
|
430
430
|
if (this.metadata.size < 1)
|
|
431
431
|
return;
|
|
432
432
|
const [e] = [...this.metadata.entries()].reduce(
|
|
433
|
-
([t, n], [i,
|
|
433
|
+
([t, n], [i, s]) => s.expiration.getTime() < n.expiration.getTime() ? [i, s] : [t, n]
|
|
434
434
|
);
|
|
435
435
|
this.clearKey(e);
|
|
436
436
|
}
|
|
@@ -441,9 +441,9 @@ class x {
|
|
|
441
441
|
generating: !0,
|
|
442
442
|
expiration: new Date(Date.now() + this.timeout)
|
|
443
443
|
}), setTimeout(() => {
|
|
444
|
-
t.then((
|
|
444
|
+
t.then((s) => {
|
|
445
445
|
const c = this.metadata.get(n);
|
|
446
|
-
!(c != null && c.generating) || this.set(e,
|
|
446
|
+
!(c != null && c.generating) || this.set(e, s);
|
|
447
447
|
});
|
|
448
448
|
}, 0);
|
|
449
449
|
}
|
|
@@ -462,32 +462,32 @@ async function _(a) {
|
|
|
462
462
|
}
|
|
463
463
|
class Be {
|
|
464
464
|
constructor() {
|
|
465
|
-
|
|
465
|
+
r(this, "queryStoreCache", new x({
|
|
466
466
|
capacity: 1e4,
|
|
467
467
|
timeout: 20 * L.second
|
|
468
468
|
}));
|
|
469
|
-
|
|
469
|
+
r(this, "liveQueryStoreCache", new x({
|
|
470
470
|
capacity: 1e4,
|
|
471
471
|
timeout: 200 * L.millisecond
|
|
472
472
|
}));
|
|
473
473
|
}
|
|
474
|
-
moduleQuery(e, t, n, i,
|
|
474
|
+
moduleQuery(e, t, n, i, s, c = !1) {
|
|
475
475
|
const d = {
|
|
476
476
|
...e,
|
|
477
477
|
names: [...t],
|
|
478
478
|
types: [...n]
|
|
479
|
-
}, p = this.query(d, i,
|
|
479
|
+
}, p = this.query(d, i, s, c);
|
|
480
480
|
return p === void 0 || p === "too much data" ? p : $e(p, n);
|
|
481
481
|
}
|
|
482
482
|
query(e, t, n, i = !1) {
|
|
483
|
-
const
|
|
483
|
+
const s = {
|
|
484
484
|
...e,
|
|
485
485
|
start: ce(t).toISOString(),
|
|
486
486
|
end: i ? n.toISOString() : de(he(n), 1).toISOString(),
|
|
487
487
|
latestOnly: i
|
|
488
|
-
}, c = n >
|
|
488
|
+
}, c = n > ue(/* @__PURE__ */ new Date(), -20);
|
|
489
489
|
let d;
|
|
490
|
-
return c ? d = this.liveQueryCache(
|
|
490
|
+
return c ? d = this.liveQueryCache(s) : d = this.queryCache(s), !d || d === "too much data" || i ? d : ze(d, t, n);
|
|
491
491
|
}
|
|
492
492
|
queryCache(e) {
|
|
493
493
|
return this.queryStoreCache.get(e, async () => {
|
|
@@ -511,9 +511,9 @@ class Be {
|
|
|
511
511
|
const Me = new Be();
|
|
512
512
|
function qe(a, e, t) {
|
|
513
513
|
const n = (i) => {
|
|
514
|
-
const
|
|
515
|
-
if (
|
|
516
|
-
const { start: c, end: d } =
|
|
514
|
+
const s = i.data;
|
|
515
|
+
if (s.type === "module_data") {
|
|
516
|
+
const { start: c, end: d } = s.queryRange;
|
|
517
517
|
t(
|
|
518
518
|
Me.moduleQuery(
|
|
519
519
|
{},
|
|
@@ -536,8 +536,8 @@ async function xe(a, e, t) {
|
|
|
536
536
|
maxTime: t,
|
|
537
537
|
time: a
|
|
538
538
|
});
|
|
539
|
-
const i = (
|
|
540
|
-
const c =
|
|
539
|
+
const i = (s) => {
|
|
540
|
+
const c = s.data;
|
|
541
541
|
c.type === "date_response" && (window.removeEventListener("message", i), n(c.data));
|
|
542
542
|
};
|
|
543
543
|
window.addEventListener("message", i);
|
|
@@ -553,8 +553,8 @@ async function Ue(a, e) {
|
|
|
553
553
|
okText: e == null ? void 0 : e.okText,
|
|
554
554
|
cancelText: e == null ? void 0 : e.cancelText
|
|
555
555
|
});
|
|
556
|
-
const i = (
|
|
557
|
-
const c =
|
|
556
|
+
const i = (s) => {
|
|
557
|
+
const c = s.data;
|
|
558
558
|
c.type === "prompt_response" && c.promptId === n && t(c.data), window.removeEventListener("message", i);
|
|
559
559
|
};
|
|
560
560
|
window.addEventListener("message", i);
|
|
@@ -586,12 +586,12 @@ const q = class {
|
|
|
586
586
|
const i = setTimeout(
|
|
587
587
|
() => n(new Error("deadline expired: took too long")),
|
|
588
588
|
e
|
|
589
|
-
),
|
|
590
|
-
window.removeEventListener("message",
|
|
589
|
+
), s = (c) => {
|
|
590
|
+
window.removeEventListener("message", s), clearTimeout(i);
|
|
591
591
|
const { data: d } = c;
|
|
592
592
|
d.type === "formant_online" && (this._isOnline = d.online, t(d.online));
|
|
593
593
|
};
|
|
594
|
-
window.addEventListener("message",
|
|
594
|
+
window.addEventListener("message", s), T({ type: "formant_online" });
|
|
595
595
|
});
|
|
596
596
|
}
|
|
597
597
|
static waitForConnection(e = 5e3) {
|
|
@@ -600,18 +600,18 @@ const q = class {
|
|
|
600
600
|
setTimeout(() => {
|
|
601
601
|
t = !0, d(new Error("deadline expired: took too long"));
|
|
602
602
|
}, e);
|
|
603
|
-
}), i = (c) => new Promise((d) => setTimeout(d, c)),
|
|
603
|
+
}), i = (c) => new Promise((d) => setTimeout(d, c)), s = async () => {
|
|
604
604
|
for (await i(50); !t && !(this.isOnline || await this.checkConnection); )
|
|
605
605
|
await i(500);
|
|
606
606
|
};
|
|
607
|
-
return Promise.race([n,
|
|
607
|
+
return Promise.race([n, s()]);
|
|
608
608
|
}
|
|
609
609
|
};
|
|
610
610
|
let y = q;
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
611
|
+
r(y, "getCurrentModuleContext", k), // senders
|
|
612
|
+
r(y, "disableAnalyticsBottomBar", ve), r(y, "goToDevice", Te), r(y, "goToTime", Ce), r(y, "refreshAuthToken", V), r(y, "requestModuleData", Se), r(y, "sendChannelData", Ee), r(y, "setModuleDateTimeRange", ke), r(y, "setupModuleMenus", Oe), r(y, "showMessage", Re), // listeners
|
|
613
|
+
r(y, "addAccessTokenRefreshListener", G), r(y, "addChannelDataListener", be), r(y, "addMenuListener", Ae), r(y, "addModuleConfigurationListener", je), r(y, "addModuleDataListener", Ne), r(y, "addOverviewDeviceListener", De), r(y, "addStreamListener", qe), // bidirectional
|
|
614
|
+
r(y, "getDate", xe), r(y, "prompt", Ue), r(y, "_isOnline", null);
|
|
615
615
|
function f(a, e) {
|
|
616
616
|
if (a !== void 0)
|
|
617
617
|
return a;
|
|
@@ -622,7 +622,7 @@ const g = {
|
|
|
622
622
|
TELEOP: 1,
|
|
623
623
|
PORT_FORWARD: 2,
|
|
624
624
|
OBSERVE: 3
|
|
625
|
-
},
|
|
625
|
+
}, Xt = {
|
|
626
626
|
...g,
|
|
627
627
|
Unknown: g.UNKNOWN,
|
|
628
628
|
Teleop: g.TELEOP,
|
|
@@ -633,26 +633,26 @@ const g = {
|
|
|
633
633
|
portForward: g.PORT_FORWARD,
|
|
634
634
|
observe: g.OBSERVE
|
|
635
635
|
}, O = Symbol("RtcClientPool.instance");
|
|
636
|
-
var
|
|
637
|
-
class
|
|
636
|
+
var Jt;
|
|
637
|
+
class D {
|
|
638
638
|
constructor(e) {
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
639
|
+
r(this, Jt, null);
|
|
640
|
+
r(this, "createClient");
|
|
641
|
+
r(this, "ttlMs");
|
|
642
|
+
r(this, "proxyHandler");
|
|
643
|
+
r(this, "proxyReceivers", /* @__PURE__ */ new Map());
|
|
644
|
+
r(this, "teardownTimeout", null);
|
|
645
|
+
r(this, "dispatch", (e, t) => {
|
|
646
646
|
this.proxyReceivers.forEach((n) => n == null ? void 0 : n(e, t));
|
|
647
647
|
});
|
|
648
648
|
const { createClient: t, ttlMs: n = 0 } = e;
|
|
649
649
|
this.createClient = t, this.ttlMs = Math.max(n, 0), this.proxyHandler = {
|
|
650
|
-
get: (i,
|
|
651
|
-
switch (
|
|
650
|
+
get: (i, s, c) => {
|
|
651
|
+
switch (s) {
|
|
652
652
|
case "shutdown":
|
|
653
653
|
return () => this.releaseInstance(c);
|
|
654
654
|
default:
|
|
655
|
-
return Reflect.get(i,
|
|
655
|
+
return Reflect.get(i, s, c);
|
|
656
656
|
}
|
|
657
657
|
}
|
|
658
658
|
};
|
|
@@ -691,40 +691,40 @@ class j {
|
|
|
691
691
|
}, this.ttlMs)), !0) : (console.warn("this instance has already been released!"), !1);
|
|
692
692
|
}
|
|
693
693
|
}
|
|
694
|
-
|
|
695
|
-
const
|
|
696
|
-
[g.UNKNOWN]: new
|
|
694
|
+
Jt = O;
|
|
695
|
+
const P = async () => f(o.token, "Realtime when user isn't authorized"), R = {
|
|
696
|
+
[g.UNKNOWN]: new D({
|
|
697
697
|
ttlMs: 2500,
|
|
698
|
-
createClient: (a) => new
|
|
699
|
-
signalingClient: new
|
|
700
|
-
getToken:
|
|
698
|
+
createClient: (a) => new j({
|
|
699
|
+
signalingClient: new N(h),
|
|
700
|
+
getToken: P,
|
|
701
701
|
sessionType: g.UNKNOWN,
|
|
702
702
|
receive: a
|
|
703
703
|
})
|
|
704
704
|
}),
|
|
705
|
-
[g.TELEOP]: new
|
|
705
|
+
[g.TELEOP]: new D({
|
|
706
706
|
ttlMs: 2500,
|
|
707
|
-
createClient: (a) => new
|
|
708
|
-
signalingClient: new
|
|
709
|
-
getToken:
|
|
707
|
+
createClient: (a) => new j({
|
|
708
|
+
signalingClient: new N(h),
|
|
709
|
+
getToken: P,
|
|
710
710
|
sessionType: g.TELEOP,
|
|
711
711
|
receive: a
|
|
712
712
|
})
|
|
713
713
|
}),
|
|
714
|
-
[g.PORT_FORWARD]: new
|
|
714
|
+
[g.PORT_FORWARD]: new D({
|
|
715
715
|
ttlMs: 2500,
|
|
716
|
-
createClient: (a) => new
|
|
717
|
-
signalingClient: new
|
|
718
|
-
getToken:
|
|
716
|
+
createClient: (a) => new j({
|
|
717
|
+
signalingClient: new N(h),
|
|
718
|
+
getToken: P,
|
|
719
719
|
sessionType: g.PORT_FORWARD,
|
|
720
720
|
receive: a
|
|
721
721
|
})
|
|
722
722
|
}),
|
|
723
|
-
[g.OBSERVE]: new
|
|
723
|
+
[g.OBSERVE]: new D({
|
|
724
724
|
ttlMs: 2500,
|
|
725
|
-
createClient: (a) => new
|
|
726
|
-
signalingClient: new
|
|
727
|
-
getToken:
|
|
725
|
+
createClient: (a) => new j({
|
|
726
|
+
signalingClient: new N(h),
|
|
727
|
+
getToken: P,
|
|
728
728
|
sessionType: g.OBSERVE,
|
|
729
729
|
receive: a
|
|
730
730
|
})
|
|
@@ -739,9 +739,9 @@ const N = async () => f(o.token, "Realtime when user isn't authorized"), R = {
|
|
|
739
739
|
const { sessionType: e } = a;
|
|
740
740
|
return e ? Je[e] : $;
|
|
741
741
|
};
|
|
742
|
-
class
|
|
742
|
+
class Ge {
|
|
743
743
|
constructor(e) {
|
|
744
|
-
|
|
744
|
+
r(this, "token");
|
|
745
745
|
this.captureSession = e;
|
|
746
746
|
}
|
|
747
747
|
async ingestJSON(e) {
|
|
@@ -772,17 +772,17 @@ class Fe {
|
|
|
772
772
|
function b(a) {
|
|
773
773
|
return new Promise((e) => setTimeout(e, a));
|
|
774
774
|
}
|
|
775
|
-
const
|
|
776
|
-
class
|
|
775
|
+
const Fe = (a) => a !== void 0 && a.capabilities !== void 0 && a.capabilitySet !== void 0;
|
|
776
|
+
class We {
|
|
777
777
|
constructor(e) {
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
778
|
+
r(this, "ready", !1);
|
|
779
|
+
r(this, "listeners", []);
|
|
780
|
+
r(this, "openListeners", []);
|
|
781
|
+
r(this, "closeListeners", []);
|
|
782
|
+
r(this, "errorListeners", []);
|
|
783
|
+
r(this, "binaryListeners", []);
|
|
784
|
+
r(this, "error");
|
|
785
|
+
r(this, "decoder", new TextDecoder());
|
|
786
786
|
this.dataChannel = e, this.dataChannel.binaryType = "arraybuffer", this.dataChannel.onopen = () => {
|
|
787
787
|
this.setReady();
|
|
788
788
|
}, this.dataChannel.onclose = () => {
|
|
@@ -791,8 +791,8 @@ class Ge {
|
|
|
791
791
|
console.error(t), this.error = "An error occurred in DataChannel", this.errorListeners.forEach((n) => n(t));
|
|
792
792
|
}, this.dataChannel.onmessage = (t) => {
|
|
793
793
|
this.listeners.forEach((n) => {
|
|
794
|
-
const i = new Uint8Array(t.data),
|
|
795
|
-
n(
|
|
794
|
+
const i = new Uint8Array(t.data), s = this.decoder.decode(i);
|
|
795
|
+
n(s);
|
|
796
796
|
}), this.binaryListeners.forEach((n) => {
|
|
797
797
|
n(new Uint8Array(t.data));
|
|
798
798
|
});
|
|
@@ -861,8 +861,8 @@ class Ge {
|
|
|
861
861
|
}
|
|
862
862
|
class He {
|
|
863
863
|
constructor(e, t) {
|
|
864
|
-
|
|
865
|
-
|
|
864
|
+
r(this, "currentListeners", []);
|
|
865
|
+
r(this, "onRealtimeMessage", (e, t) => {
|
|
866
866
|
t.payload.jointState && this.currentListeners.forEach((n) => {
|
|
867
867
|
t.payload.jointState && n(t.payload.jointState);
|
|
868
868
|
});
|
|
@@ -885,8 +885,8 @@ class He {
|
|
|
885
885
|
}
|
|
886
886
|
class K {
|
|
887
887
|
constructor(e, t, n) {
|
|
888
|
-
|
|
889
|
-
|
|
888
|
+
r(this, "channel");
|
|
889
|
+
r(this, "requestIdToResponseMap", /* @__PURE__ */ new Map());
|
|
890
890
|
this.device = e, this.channel_name = t, this.timeout = n;
|
|
891
891
|
}
|
|
892
892
|
addOpenListener(e) {
|
|
@@ -917,8 +917,8 @@ class K {
|
|
|
917
917
|
class Ke extends K {
|
|
918
918
|
constructor() {
|
|
919
919
|
super(...arguments);
|
|
920
|
-
|
|
921
|
-
|
|
920
|
+
r(this, "RESPONSE_SUCCESS_BYTE", 0);
|
|
921
|
+
r(this, "decoder", new TextDecoder());
|
|
922
922
|
}
|
|
923
923
|
/*
|
|
924
924
|
Request binary payload layout:
|
|
@@ -940,21 +940,21 @@ class Ke extends K {
|
|
|
940
940
|
const i = t.slice(0, 16).toString();
|
|
941
941
|
if (i.length === 0)
|
|
942
942
|
throw new Error("Invalid response");
|
|
943
|
-
const
|
|
944
|
-
if (
|
|
943
|
+
const s = t.slice(16);
|
|
944
|
+
if (s.length === 0)
|
|
945
945
|
throw new Error("Invalid response");
|
|
946
|
-
this.requestIdToResponseMap.has(i) && this.requestIdToResponseMap.set(i,
|
|
946
|
+
this.requestIdToResponseMap.has(i) && this.requestIdToResponseMap.set(i, s);
|
|
947
947
|
});
|
|
948
948
|
}
|
|
949
949
|
async request(t) {
|
|
950
950
|
if (this.channel || await this.initialize(), !this.channel)
|
|
951
951
|
throw new Error("Failed to create channel");
|
|
952
|
-
const { channel: n, requestIdToResponseMap: i, timeout:
|
|
952
|
+
const { channel: n, requestIdToResponseMap: i, timeout: s } = this;
|
|
953
953
|
await n.waitTilReady();
|
|
954
954
|
const c = this.generateBinaryId(), d = c.toString();
|
|
955
955
|
i.set(d, !0), n.sendBinary(new Uint8Array([...c, ...t]));
|
|
956
956
|
const p = (/* @__PURE__ */ new Date()).getTime();
|
|
957
|
-
for (; (/* @__PURE__ */ new Date()).getTime() < p +
|
|
957
|
+
for (; (/* @__PURE__ */ new Date()).getTime() < p + s; )
|
|
958
958
|
if (await b(50), i.has(d)) {
|
|
959
959
|
const m = i.get(d);
|
|
960
960
|
if (m !== !0) {
|
|
@@ -970,7 +970,7 @@ class Ke extends K {
|
|
|
970
970
|
}
|
|
971
971
|
throw i.delete(d), console.error({
|
|
972
972
|
name: "TimeoutError",
|
|
973
|
-
message: `Request timed out after ${
|
|
973
|
+
message: `Request timed out after ${s / 1e3} seconds`
|
|
974
974
|
}), new Error("Binary request data channel request timed out");
|
|
975
975
|
}
|
|
976
976
|
}
|
|
@@ -980,10 +980,10 @@ class Qe extends K {
|
|
|
980
980
|
}
|
|
981
981
|
async initialize() {
|
|
982
982
|
this.channel = await this.device.createCustomDataChannel(this.channel_name), this.channel.addListener((e) => {
|
|
983
|
-
const t = JSON.parse(e), { id: n, data: i, error:
|
|
983
|
+
const t = JSON.parse(e), { id: n, data: i, error: s } = t;
|
|
984
984
|
if (!n)
|
|
985
985
|
throw new Error("Invalid response");
|
|
986
|
-
if (!i && !
|
|
986
|
+
if (!i && !s)
|
|
987
987
|
throw new Error("Invalid response");
|
|
988
988
|
this.requestIdToResponseMap.has(n) && this.requestIdToResponseMap.set(n, t);
|
|
989
989
|
});
|
|
@@ -993,19 +993,19 @@ class Qe extends K {
|
|
|
993
993
|
throw new Error("Failed to create channel");
|
|
994
994
|
const { channel: t, requestIdToResponseMap: n, timeout: i } = this;
|
|
995
995
|
await t.waitTilReady();
|
|
996
|
-
const
|
|
997
|
-
n.set(
|
|
996
|
+
const s = this.generateTextId();
|
|
997
|
+
n.set(s, !0), t.send(
|
|
998
998
|
JSON.stringify({
|
|
999
|
-
id:
|
|
999
|
+
id: s,
|
|
1000
1000
|
data: e
|
|
1001
1001
|
})
|
|
1002
1002
|
);
|
|
1003
1003
|
const c = (/* @__PURE__ */ new Date()).getTime();
|
|
1004
1004
|
for (; (/* @__PURE__ */ new Date()).getTime() < c + i; )
|
|
1005
|
-
if (await b(50), n.has(
|
|
1006
|
-
const d = n.get(
|
|
1005
|
+
if (await b(50), n.has(s)) {
|
|
1006
|
+
const d = n.get(s);
|
|
1007
1007
|
if (d !== !0) {
|
|
1008
|
-
n.delete(
|
|
1008
|
+
n.delete(s);
|
|
1009
1009
|
const { data: p, error: m } = d;
|
|
1010
1010
|
if (p)
|
|
1011
1011
|
return p;
|
|
@@ -1016,20 +1016,20 @@ class Qe extends K {
|
|
|
1016
1016
|
}), new Error("Text request datachannel adapter error");
|
|
1017
1017
|
}
|
|
1018
1018
|
}
|
|
1019
|
-
throw n.delete(
|
|
1019
|
+
throw n.delete(s), console.error({
|
|
1020
1020
|
name: "TimeoutError",
|
|
1021
1021
|
message: `Request timed out after ${i / 1e3} seconds`
|
|
1022
1022
|
}), new Error("Text request datachannel request timed out");
|
|
1023
1023
|
}
|
|
1024
1024
|
}
|
|
1025
|
-
class Q extends
|
|
1025
|
+
class Q extends le {
|
|
1026
1026
|
constructor() {
|
|
1027
1027
|
super(...arguments);
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1028
|
+
r(this, "rtcClient");
|
|
1029
|
+
r(this, "remoteDevicePeerId", null);
|
|
1030
|
+
r(this, "realtimeListeners", []);
|
|
1031
|
+
r(this, "connectionMonitorInterval");
|
|
1032
|
+
r(this, "handleMessage", (t, n) => {
|
|
1033
1033
|
this.realtimeListeners.forEach((i) => i(t, n));
|
|
1034
1034
|
});
|
|
1035
1035
|
}
|
|
@@ -1076,13 +1076,13 @@ class Q extends ue {
|
|
|
1076
1076
|
return n;
|
|
1077
1077
|
}
|
|
1078
1078
|
async getRealtimeVideoStreams() {
|
|
1079
|
-
var i,
|
|
1079
|
+
var i, s, c;
|
|
1080
1080
|
const t = await this.getConfiguration(), n = [];
|
|
1081
1081
|
for (const d of ((i = t.teleop) == null ? void 0 : i.hardwareStreams) ?? [])
|
|
1082
1082
|
d.rtcStreamType === "h264-video-frame" && n.push({
|
|
1083
1083
|
name: d.name
|
|
1084
1084
|
});
|
|
1085
|
-
for (const d of ((
|
|
1085
|
+
for (const d of ((s = t.teleop) == null ? void 0 : s.rosStreams) ?? [])
|
|
1086
1086
|
d.topicType == "formant/H264VideoFrame" && n.push({
|
|
1087
1087
|
name: d.topicName
|
|
1088
1088
|
}), (d.topicType === "sensor_msgs/Image" || d.topicType === "sensor_msgs/CompressedImage") && d.encodeVideo && n.push({
|
|
@@ -1170,8 +1170,8 @@ class Q extends ue {
|
|
|
1170
1170
|
const i = f(
|
|
1171
1171
|
this.rtcClient,
|
|
1172
1172
|
"Realtime connection has not been started"
|
|
1173
|
-
),
|
|
1174
|
-
i.controlRemoteStream(f(
|
|
1173
|
+
), s = await this.getRemotePeer();
|
|
1174
|
+
i.controlRemoteStream(f(s).id, {
|
|
1175
1175
|
streamName: t,
|
|
1176
1176
|
setAudioFormat: n
|
|
1177
1177
|
});
|
|
@@ -1180,9 +1180,9 @@ class Q extends ue {
|
|
|
1180
1180
|
const i = f(
|
|
1181
1181
|
this.rtcClient,
|
|
1182
1182
|
"Realtime connection has not been started"
|
|
1183
|
-
),
|
|
1183
|
+
), s = await this.getRemotePeer(), c = await new Promise((d) => {
|
|
1184
1184
|
i.createCustomDataChannel(
|
|
1185
|
-
f(
|
|
1185
|
+
f(s).id,
|
|
1186
1186
|
t,
|
|
1187
1187
|
{
|
|
1188
1188
|
ordered: !0,
|
|
@@ -1190,7 +1190,7 @@ class Q extends ue {
|
|
|
1190
1190
|
},
|
|
1191
1191
|
!1,
|
|
1192
1192
|
(p, m) => {
|
|
1193
|
-
const w = new
|
|
1193
|
+
const w = new We(m);
|
|
1194
1194
|
d(w);
|
|
1195
1195
|
}
|
|
1196
1196
|
);
|
|
@@ -1203,17 +1203,17 @@ class Q extends ue {
|
|
|
1203
1203
|
const i = f(
|
|
1204
1204
|
this.rtcClient,
|
|
1205
1205
|
"Realtime connection has not been started"
|
|
1206
|
-
),
|
|
1207
|
-
i.send(f(
|
|
1206
|
+
), s = await this.getRemotePeer();
|
|
1207
|
+
i.send(f(s).id, t, n);
|
|
1208
1208
|
}
|
|
1209
1209
|
async getRealtimeAudioStreams() {
|
|
1210
|
-
var i,
|
|
1210
|
+
var i, s, c;
|
|
1211
1211
|
const t = await this.getConfiguration(), n = [];
|
|
1212
1212
|
for (const d of ((i = t.teleop) == null ? void 0 : i.hardwareStreams) ?? [])
|
|
1213
1213
|
d.rtcStreamType === "audio-chunk" && n.push({
|
|
1214
1214
|
name: d.name
|
|
1215
1215
|
});
|
|
1216
|
-
for (const d of ((
|
|
1216
|
+
for (const d of ((s = t.teleop) == null ? void 0 : s.rosStreams) ?? [])
|
|
1217
1217
|
d.topicType == "audio_common_msgs/AudioData" && n.push({
|
|
1218
1218
|
name: d.topicName
|
|
1219
1219
|
});
|
|
@@ -1254,12 +1254,12 @@ async function Y(a, e) {
|
|
|
1254
1254
|
"Content-Type": "application/json",
|
|
1255
1255
|
Authorization: "Bearer " + o.token
|
|
1256
1256
|
}
|
|
1257
|
-
}),
|
|
1258
|
-
return `${
|
|
1257
|
+
}), s = h.replace("api", "app"), { code: c } = await i.json();
|
|
1258
|
+
return `${s}/shares/${c}#${Ye({
|
|
1259
1259
|
viewId: n[0].id
|
|
1260
1260
|
})}`;
|
|
1261
1261
|
}
|
|
1262
|
-
const
|
|
1262
|
+
const Yt = [
|
|
1263
1263
|
"day",
|
|
1264
1264
|
"week",
|
|
1265
1265
|
"month",
|
|
@@ -1267,7 +1267,7 @@ const Kt = [
|
|
|
1267
1267
|
"hour",
|
|
1268
1268
|
"minute",
|
|
1269
1269
|
"quarter"
|
|
1270
|
-
],
|
|
1270
|
+
], Zt = [
|
|
1271
1271
|
"interval",
|
|
1272
1272
|
"start",
|
|
1273
1273
|
"end",
|
|
@@ -1295,7 +1295,7 @@ function it(a) {
|
|
|
1295
1295
|
function ot(a) {
|
|
1296
1296
|
return a.count;
|
|
1297
1297
|
}
|
|
1298
|
-
const
|
|
1298
|
+
const en = {
|
|
1299
1299
|
min: nt,
|
|
1300
1300
|
max: tt,
|
|
1301
1301
|
"standard deviation": et,
|
|
@@ -1304,53 +1304,53 @@ const Xt = {
|
|
|
1304
1304
|
count: ot
|
|
1305
1305
|
}, Z = {
|
|
1306
1306
|
day: {
|
|
1307
|
-
interval:
|
|
1308
|
-
start:
|
|
1309
|
-
end:
|
|
1310
|
-
sub:
|
|
1311
|
-
get:
|
|
1307
|
+
interval: l.eachDayOfInterval,
|
|
1308
|
+
start: l.startOfDay,
|
|
1309
|
+
end: l.endOfDay,
|
|
1310
|
+
sub: l.subDays,
|
|
1311
|
+
get: l.getDay
|
|
1312
1312
|
},
|
|
1313
1313
|
week: {
|
|
1314
|
-
interval:
|
|
1315
|
-
start:
|
|
1316
|
-
end:
|
|
1317
|
-
sub:
|
|
1318
|
-
get:
|
|
1314
|
+
interval: l.eachWeekOfInterval,
|
|
1315
|
+
start: l.startOfWeek,
|
|
1316
|
+
end: l.endOfWeek,
|
|
1317
|
+
sub: l.subWeeks,
|
|
1318
|
+
get: l.getWeek
|
|
1319
1319
|
},
|
|
1320
1320
|
month: {
|
|
1321
|
-
interval:
|
|
1322
|
-
start:
|
|
1323
|
-
end:
|
|
1324
|
-
sub:
|
|
1325
|
-
get:
|
|
1321
|
+
interval: l.eachMonthOfInterval,
|
|
1322
|
+
start: l.startOfMonth,
|
|
1323
|
+
end: l.endOfMonth,
|
|
1324
|
+
sub: l.subMonths,
|
|
1325
|
+
get: l.getMonth
|
|
1326
1326
|
},
|
|
1327
1327
|
year: {
|
|
1328
|
-
interval:
|
|
1329
|
-
start:
|
|
1330
|
-
end:
|
|
1331
|
-
sub:
|
|
1332
|
-
get:
|
|
1328
|
+
interval: l.eachYearOfInterval,
|
|
1329
|
+
start: l.startOfYear,
|
|
1330
|
+
end: l.endOfYear,
|
|
1331
|
+
sub: l.subYears,
|
|
1332
|
+
get: l.getYear
|
|
1333
1333
|
},
|
|
1334
1334
|
hour: {
|
|
1335
|
-
interval:
|
|
1336
|
-
start:
|
|
1337
|
-
end:
|
|
1338
|
-
sub:
|
|
1339
|
-
get:
|
|
1335
|
+
interval: l.eachHourOfInterval,
|
|
1336
|
+
start: l.startOfHour,
|
|
1337
|
+
end: l.endOfHour,
|
|
1338
|
+
sub: l.subHours,
|
|
1339
|
+
get: l.getHours
|
|
1340
1340
|
},
|
|
1341
1341
|
minute: {
|
|
1342
|
-
interval:
|
|
1343
|
-
start:
|
|
1344
|
-
end:
|
|
1345
|
-
sub:
|
|
1346
|
-
get:
|
|
1342
|
+
interval: l.eachMinuteOfInterval,
|
|
1343
|
+
start: l.startOfMinute,
|
|
1344
|
+
end: l.endOfMinute,
|
|
1345
|
+
sub: l.subMinutes,
|
|
1346
|
+
get: l.getMinutes
|
|
1347
1347
|
},
|
|
1348
1348
|
quarter: {
|
|
1349
|
-
interval:
|
|
1350
|
-
start:
|
|
1351
|
-
end:
|
|
1352
|
-
sub:
|
|
1353
|
-
get:
|
|
1349
|
+
interval: l.eachQuarterOfInterval,
|
|
1350
|
+
start: l.startOfQuarter,
|
|
1351
|
+
end: l.endOfQuarter,
|
|
1352
|
+
sub: l.subQuarters,
|
|
1353
|
+
get: l.getQuarter
|
|
1354
1354
|
}
|
|
1355
1355
|
}, rt = (a, e) => (
|
|
1356
1356
|
// FIXME this doesn't work for *a lot* locales, other than en-US
|
|
@@ -1372,14 +1372,14 @@ async function z(a) {
|
|
|
1372
1372
|
})).json()).items;
|
|
1373
1373
|
}
|
|
1374
1374
|
async function ee(a, e, t, n, i) {
|
|
1375
|
-
const
|
|
1375
|
+
const s = Z[e];
|
|
1376
1376
|
return await Promise.all(
|
|
1377
1377
|
Array(t).fill(0).map(async (c, d) => {
|
|
1378
|
-
const p = new Date(n), m =
|
|
1379
|
-
|
|
1378
|
+
const p = new Date(n), m = s.sub(
|
|
1379
|
+
s.start(p),
|
|
1380
1380
|
t - d - 1
|
|
1381
|
-
), w =
|
|
1382
|
-
|
|
1381
|
+
), w = s.sub(
|
|
1382
|
+
s.end(p),
|
|
1383
1383
|
t - d - 1
|
|
1384
1384
|
), v = rt(
|
|
1385
1385
|
m.toLocaleDateString(),
|
|
@@ -1399,10 +1399,10 @@ async function B(a, e) {
|
|
|
1399
1399
|
...a,
|
|
1400
1400
|
eventTypes: ["annotation"]
|
|
1401
1401
|
})).filter(
|
|
1402
|
-
(
|
|
1403
|
-
).reduce((
|
|
1402
|
+
(s) => !!s.tags && Object.keys(s.tags).includes(e)
|
|
1403
|
+
).reduce((s, c) => {
|
|
1404
1404
|
const d = c.tags[e];
|
|
1405
|
-
return d in
|
|
1405
|
+
return d in s ? (s[d] += 1, s) : (s[d] = 1, s);
|
|
1406
1406
|
}, {});
|
|
1407
1407
|
}
|
|
1408
1408
|
async function te(a, e, t) {
|
|
@@ -1426,13 +1426,13 @@ async function te(a, e, t) {
|
|
|
1426
1426
|
}));
|
|
1427
1427
|
}
|
|
1428
1428
|
async function ne(a, e, t, n, i) {
|
|
1429
|
-
let
|
|
1430
|
-
Array.isArray(a) || (
|
|
1429
|
+
let s = a;
|
|
1430
|
+
Array.isArray(a) || (s = [a]);
|
|
1431
1431
|
let c = e;
|
|
1432
1432
|
return Array.isArray(e) || (c = [e]), (await (await fetch(`${h}/v1/queries/queries`, {
|
|
1433
1433
|
method: "POST",
|
|
1434
1434
|
body: JSON.stringify({
|
|
1435
|
-
deviceIds:
|
|
1435
|
+
deviceIds: s,
|
|
1436
1436
|
end: n.toISOString(),
|
|
1437
1437
|
names: c,
|
|
1438
1438
|
start: t.toISOString(),
|
|
@@ -1512,7 +1512,7 @@ async function ht(a) {
|
|
|
1512
1512
|
}
|
|
1513
1513
|
})).json()).items;
|
|
1514
1514
|
}
|
|
1515
|
-
async function
|
|
1515
|
+
async function ut(a) {
|
|
1516
1516
|
if (!o.token)
|
|
1517
1517
|
throw new Error("Not authenticated");
|
|
1518
1518
|
return await (await fetch(
|
|
@@ -1645,7 +1645,7 @@ class S extends Q {
|
|
|
1645
1645
|
}
|
|
1646
1646
|
async getRemoteDevicePeerId(e) {
|
|
1647
1647
|
const n = (await e.getPeers()).find((i) => i.deviceId === this.id);
|
|
1648
|
-
if (!
|
|
1648
|
+
if (!Fe(n))
|
|
1649
1649
|
throw new Error("Cannot find peer, is the robot offline?");
|
|
1650
1650
|
return n.id;
|
|
1651
1651
|
}
|
|
@@ -1767,7 +1767,7 @@ class S extends Q {
|
|
|
1767
1767
|
Authorization: "Bearer " + o.token
|
|
1768
1768
|
}
|
|
1769
1769
|
})).json();
|
|
1770
|
-
return new
|
|
1770
|
+
return new Ge(n);
|
|
1771
1771
|
}
|
|
1772
1772
|
async getTelemetry(e, t, n, i) {
|
|
1773
1773
|
return await ne(
|
|
@@ -1844,9 +1844,9 @@ class S extends Q {
|
|
|
1844
1844
|
n
|
|
1845
1845
|
);
|
|
1846
1846
|
}
|
|
1847
|
-
async eventsCounter(e, t, n, i,
|
|
1847
|
+
async eventsCounter(e, t, n, i, s) {
|
|
1848
1848
|
return await ee(e, t, n, i, {
|
|
1849
|
-
...
|
|
1849
|
+
...s,
|
|
1850
1850
|
deviceIds: [this.id]
|
|
1851
1851
|
});
|
|
1852
1852
|
}
|
|
@@ -1854,24 +1854,24 @@ class S extends Q {
|
|
|
1854
1854
|
return e.scope.deviceIds = [this.id], await Y(e, t);
|
|
1855
1855
|
}
|
|
1856
1856
|
}
|
|
1857
|
-
|
|
1858
|
-
class
|
|
1857
|
+
r(S, "createDevice", st), r(S, "patchDevice", ct), r(S, "getDevicesData", dt), r(S, "queryDevicesData", ht), r(S, "disableDevice", ut);
|
|
1858
|
+
class lt extends Q {
|
|
1859
1859
|
constructor(t) {
|
|
1860
1860
|
super();
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1861
|
+
r(this, "id");
|
|
1862
|
+
r(this, "telemetryStreamActive", !1);
|
|
1863
|
+
r(this, "streamTelemetry", {});
|
|
1864
1864
|
this.peerUrl = t;
|
|
1865
1865
|
}
|
|
1866
1866
|
async getLatestTelemetry() {
|
|
1867
1867
|
this.telemetryStreamActive || this.subscribeToTelemetry();
|
|
1868
1868
|
const t = this.streamTelemetry;
|
|
1869
|
-
return Object.entries(t).map(([i,
|
|
1869
|
+
return Object.entries(t).map(([i, s]) => ({
|
|
1870
1870
|
deviceId: this.id,
|
|
1871
1871
|
streamName: i,
|
|
1872
1872
|
streamType: "json",
|
|
1873
|
-
currentValue:
|
|
1874
|
-
currentValueTime:
|
|
1873
|
+
currentValue: s,
|
|
1874
|
+
currentValueTime: s.timestamp,
|
|
1875
1875
|
tags: {}
|
|
1876
1876
|
}));
|
|
1877
1877
|
}
|
|
@@ -1888,8 +1888,8 @@ class ut extends Q {
|
|
|
1888
1888
|
}), n.addEventListener("readystatechange", (i) => {
|
|
1889
1889
|
n.readyState === XMLHttpRequest.DONE && this.handleXHRError("closed");
|
|
1890
1890
|
}), n.addEventListener("progress", (i) => {
|
|
1891
|
-
const
|
|
1892
|
-
t =
|
|
1891
|
+
const s = i.loaded, c = s - t;
|
|
1892
|
+
t = s, n.responseText.substr(-c).split(`
|
|
1893
1893
|
`).forEach((m) => {
|
|
1894
1894
|
var w;
|
|
1895
1895
|
if (m.length > 0) {
|
|
@@ -1919,7 +1919,7 @@ class ut extends Q {
|
|
|
1919
1919
|
this.rtcClient && console.warn(
|
|
1920
1920
|
"overwriting existing rtcClient due to missing connectionMonitorInterval"
|
|
1921
1921
|
);
|
|
1922
|
-
const n = new
|
|
1922
|
+
const n = new j({
|
|
1923
1923
|
lanOnlyMode: !0,
|
|
1924
1924
|
receive: this.handleMessage,
|
|
1925
1925
|
sessionType: t
|
|
@@ -1958,11 +1958,11 @@ class ut extends Q {
|
|
|
1958
1958
|
if (t)
|
|
1959
1959
|
throw new Error(`Realtime connection hasn't been started for ${this.id}`);
|
|
1960
1960
|
}
|
|
1961
|
-
async sendCommand(t, n, i,
|
|
1961
|
+
async sendCommand(t, n, i, s) {
|
|
1962
1962
|
const c = {
|
|
1963
1963
|
value: n,
|
|
1964
1964
|
scrubberTime: (i || /* @__PURE__ */ new Date()).toISOString(),
|
|
1965
|
-
meta:
|
|
1965
|
+
meta: s
|
|
1966
1966
|
};
|
|
1967
1967
|
return await fetch(`${this.peerUrl}/v1/enqueue-command`, {
|
|
1968
1968
|
method: "POST",
|
|
@@ -2227,7 +2227,7 @@ async function At() {
|
|
|
2227
2227
|
);
|
|
2228
2228
|
return (await M()).filter((i) => t.includes(i.id));
|
|
2229
2229
|
}
|
|
2230
|
-
async function
|
|
2230
|
+
async function jt() {
|
|
2231
2231
|
if (!o.token)
|
|
2232
2232
|
throw new Error("Not authenticated");
|
|
2233
2233
|
return (await (await fetch(`${h}/v1/admin/streams`, {
|
|
@@ -2240,7 +2240,7 @@ async function Dt() {
|
|
|
2240
2240
|
(t) => t.enabled
|
|
2241
2241
|
);
|
|
2242
2242
|
}
|
|
2243
|
-
async function
|
|
2243
|
+
async function Nt(a) {
|
|
2244
2244
|
if (!o.token)
|
|
2245
2245
|
throw new Error("Not authenticated");
|
|
2246
2246
|
return await (await fetch(
|
|
@@ -2255,7 +2255,7 @@ async function Pt(a) {
|
|
|
2255
2255
|
}
|
|
2256
2256
|
)).json();
|
|
2257
2257
|
}
|
|
2258
|
-
async function
|
|
2258
|
+
async function Dt() {
|
|
2259
2259
|
if (!o.token)
|
|
2260
2260
|
throw new Error("Not authenticated");
|
|
2261
2261
|
return (await (await fetch(
|
|
@@ -2269,7 +2269,7 @@ async function jt() {
|
|
|
2269
2269
|
}
|
|
2270
2270
|
)).json()).items;
|
|
2271
2271
|
}
|
|
2272
|
-
async function
|
|
2272
|
+
async function Pt() {
|
|
2273
2273
|
if (!o.token)
|
|
2274
2274
|
throw new Error("Not authenticated");
|
|
2275
2275
|
return (await (await fetch(`${h}/v1/admin/fleets`, {
|
|
@@ -2343,6 +2343,46 @@ async function zt(a) {
|
|
|
2343
2343
|
}
|
|
2344
2344
|
})).json();
|
|
2345
2345
|
}
|
|
2346
|
+
async function Bt() {
|
|
2347
|
+
if (!o.token)
|
|
2348
|
+
throw new Error("Not authenticated");
|
|
2349
|
+
return (await (await fetch(`${h}/v1/admin/event-trigger-groups`, {
|
|
2350
|
+
method: "GET",
|
|
2351
|
+
headers: {
|
|
2352
|
+
"Content-Type": "application/json",
|
|
2353
|
+
Authorization: "Bearer " + o.token
|
|
2354
|
+
}
|
|
2355
|
+
})).json()).items;
|
|
2356
|
+
}
|
|
2357
|
+
async function Mt(a) {
|
|
2358
|
+
if (!o.token)
|
|
2359
|
+
throw new Error("Not authenticated");
|
|
2360
|
+
return await (await fetch(
|
|
2361
|
+
`${h}/v1/admin/event-trigger-groups/${a}`,
|
|
2362
|
+
{
|
|
2363
|
+
method: "GET",
|
|
2364
|
+
headers: {
|
|
2365
|
+
"Content-Type": "application/json",
|
|
2366
|
+
Authorization: "Bearer " + o.token
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
)).json();
|
|
2370
|
+
}
|
|
2371
|
+
async function qt(a, e) {
|
|
2372
|
+
if (!o.token)
|
|
2373
|
+
throw new Error("Not authenticated");
|
|
2374
|
+
return await (await fetch(
|
|
2375
|
+
`${h}/v1/admin/event-trigger-groups/${a}`,
|
|
2376
|
+
{
|
|
2377
|
+
method: "PATCH",
|
|
2378
|
+
body: JSON.stringify(e),
|
|
2379
|
+
headers: {
|
|
2380
|
+
"Content-Type": "application/json",
|
|
2381
|
+
Authorization: "Bearer " + o.token
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
)).json();
|
|
2385
|
+
}
|
|
2346
2386
|
const E = class {
|
|
2347
2387
|
static async setDefaultDevice(e) {
|
|
2348
2388
|
E.defaultDeviceId = e;
|
|
@@ -2363,16 +2403,16 @@ const E = class {
|
|
|
2363
2403
|
}
|
|
2364
2404
|
)).json()).items.find(
|
|
2365
2405
|
(c) => c.id === E.defaultDeviceId
|
|
2366
|
-
), i = n.name,
|
|
2406
|
+
), i = n.name, s = new S(
|
|
2367
2407
|
E.defaultDeviceId,
|
|
2368
2408
|
i,
|
|
2369
2409
|
f(o.currentOrganization),
|
|
2370
2410
|
n.tags
|
|
2371
2411
|
);
|
|
2372
|
-
return E.knownContext.push(new WeakRef(
|
|
2412
|
+
return E.knownContext.push(new WeakRef(s)), s;
|
|
2373
2413
|
}
|
|
2374
2414
|
static async getPeerDevice(e) {
|
|
2375
|
-
const t = new
|
|
2415
|
+
const t = new lt(e);
|
|
2376
2416
|
return t.id = await t.getDeviceId(), t;
|
|
2377
2417
|
}
|
|
2378
2418
|
static async getDevice(e) {
|
|
@@ -2380,9 +2420,9 @@ const E = class {
|
|
|
2380
2420
|
return E.knownContext.push(new WeakRef(t)), t;
|
|
2381
2421
|
}
|
|
2382
2422
|
};
|
|
2383
|
-
let
|
|
2384
|
-
|
|
2385
|
-
class
|
|
2423
|
+
let u = E;
|
|
2424
|
+
r(u, "defaultDeviceId"), r(u, "knownContext", []), r(u, "createFleet", zt), r(u, "listFleets", Pt), r(u, "getFleet", Et), r(u, "patchFleet", It), r(u, "deleteFleet", wt), r(u, "addDeviceToFleet", mt), r(u, "getFleetDevices", kt), r(u, "aggregateTelemetry", ft), r(u, "createShareLink", Y), r(u, "eventsCounter", ee), r(u, "getAnalyticStreams", pt), r(u, "getAnalyticsModules", yt), r(u, "getAnalyticsRows", gt), r(u, "getAnnotationCount", B), r(u, "getAnnotationCountByIntervals", te), r(u, "getCurrentGroup", vt), r(u, "getDevices", M), r(u, "getEvent", Ct), r(u, "getFileUrl", St), r(u, "getInterventions", Ot), r(u, "getLatestTelemetry", Rt), r(u, "getOnlineDevices", bt), r(u, "getPeers", ie), r(u, "getRealtimeDevices", At), r(u, "getRealtimeSessions", ae), r(u, "getStreams", jt), r(u, "getTaskReportRows", Nt), r(u, "getTaskReportTables", Dt), r(u, "getTelemetry", ne), r(u, "getViews", X), r(u, "patchStream", Lt), r(u, "patchView", _t), r(u, "queryAnalytics", $t), r(u, "queryDevices", oe), r(u, "queryEvents", z), r(u, "queryTelemetry", _), r(u, "getAllEventTriggerGroup", Bt), r(u, "getEventTriggerGroup", Mt), r(u, "patchEventTriggergroup", qt);
|
|
2425
|
+
class tn {
|
|
2386
2426
|
static async set(e, t, n) {
|
|
2387
2427
|
try {
|
|
2388
2428
|
const i = await fetch(h + "/v1/admin/key-value", {
|
|
@@ -2397,9 +2437,9 @@ class Yt {
|
|
|
2397
2437
|
"Content-Type": "application/json",
|
|
2398
2438
|
Authorization: "Bearer " + o.token
|
|
2399
2439
|
}
|
|
2400
|
-
}),
|
|
2440
|
+
}), s = await i.json();
|
|
2401
2441
|
if (i.status !== 200)
|
|
2402
|
-
throw new Error(
|
|
2442
|
+
throw new Error(s.message);
|
|
2403
2443
|
} catch (i) {
|
|
2404
2444
|
throw i;
|
|
2405
2445
|
}
|
|
@@ -2478,37 +2518,37 @@ class Yt {
|
|
|
2478
2518
|
}
|
|
2479
2519
|
}
|
|
2480
2520
|
}
|
|
2481
|
-
function
|
|
2521
|
+
function xt(a) {
|
|
2482
2522
|
return Uint8Array.from(J(a), (e) => e.charCodeAt(0));
|
|
2483
2523
|
}
|
|
2484
2524
|
function U() {
|
|
2485
2525
|
const { userAgent: a } = navigator;
|
|
2486
2526
|
return a ? a.includes("Firefox/") ? "Firefox" : a.includes("Edg/") ? "Edge" : a.includes("Chrome/") ? "Chrome" : a.includes("Safari/") ? "Safari" : a.includes("MSIE/") || a.includes("Trident/") ? "IE" : "Other" : "Other";
|
|
2487
2527
|
}
|
|
2488
|
-
const
|
|
2489
|
-
class
|
|
2528
|
+
const Ut = "audio-chunk";
|
|
2529
|
+
class nn {
|
|
2490
2530
|
constructor(e, t) {
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2531
|
+
r(this, "muted", !1);
|
|
2532
|
+
r(this, "hasReceivedData", !1);
|
|
2533
|
+
r(this, "audioContext");
|
|
2534
|
+
r(this, "chunks", []);
|
|
2535
|
+
r(this, "isPlaying", !1);
|
|
2536
|
+
r(this, "startTime", 0);
|
|
2537
|
+
r(this, "lastChunkOffset", 0);
|
|
2538
|
+
r(this, "bufferSize", 3);
|
|
2539
|
+
r(this, "receive", async (e) => {
|
|
2500
2540
|
var c;
|
|
2501
2541
|
const t = (c = e.payload.audioChunk) == null ? void 0 : c.chunk_data;
|
|
2502
2542
|
if (!t)
|
|
2503
2543
|
return;
|
|
2504
2544
|
this.hasReceivedData || (this.hasReceivedData = !0);
|
|
2505
2545
|
const { audioContext: n, muted: i } = this;
|
|
2506
|
-
if (!n || e.header.stream.streamType !==
|
|
2546
|
+
if (!n || e.header.stream.streamType !== Ut || i !== !1)
|
|
2507
2547
|
return;
|
|
2508
|
-
const
|
|
2548
|
+
const s = xt(t);
|
|
2509
2549
|
try {
|
|
2510
2550
|
await n.decodeAudioData(
|
|
2511
|
-
|
|
2551
|
+
s.buffer,
|
|
2512
2552
|
this.scheduleChunk
|
|
2513
2553
|
);
|
|
2514
2554
|
} catch (d) {
|
|
@@ -2518,7 +2558,7 @@ class Zt {
|
|
|
2518
2558
|
), this.changeAudioWireFormat("wav");
|
|
2519
2559
|
}
|
|
2520
2560
|
});
|
|
2521
|
-
|
|
2561
|
+
r(this, "scheduleChunk", (e) => {
|
|
2522
2562
|
const { audioContext: t } = this;
|
|
2523
2563
|
if (!t)
|
|
2524
2564
|
return;
|
|
@@ -2528,8 +2568,8 @@ class Zt {
|
|
|
2528
2568
|
const n = this.createChunk(e);
|
|
2529
2569
|
n && n.buffer && (this.isPlaying === !1 && (this.startTime = t.currentTime, this.lastChunkOffset = 0, this.isPlaying = !0), n.start(this.startTime + this.lastChunkOffset, 0, e.duration), this.lastChunkOffset += n.buffer.duration, this.chunks.push(n));
|
|
2530
2570
|
});
|
|
2531
|
-
this.device = e, this.stream = t, this.device.startListeningToRealtimeDataStream(t), this.device.addRealtimeListener((i,
|
|
2532
|
-
this.receive(
|
|
2571
|
+
this.device = e, this.stream = t, this.device.startListeningToRealtimeDataStream(t), this.device.addRealtimeListener((i, s) => {
|
|
2572
|
+
this.receive(s);
|
|
2533
2573
|
}), U() === "Safari" || U() === "IE" ? this.changeAudioWireFormat("wav") : this.changeAudioWireFormat("opus");
|
|
2534
2574
|
const n = window.AudioContext || window.webkitAudioContext;
|
|
2535
2575
|
this.audioContext = new n();
|
|
@@ -2558,7 +2598,7 @@ class Zt {
|
|
|
2558
2598
|
(async () => await this.device.changeStreamAudioType(t.name, e))();
|
|
2559
2599
|
}
|
|
2560
2600
|
}
|
|
2561
|
-
class
|
|
2601
|
+
class an {
|
|
2562
2602
|
static async listAccounts() {
|
|
2563
2603
|
if (!o.token)
|
|
2564
2604
|
throw new Error("Not authenticated");
|
|
@@ -2631,7 +2671,7 @@ class en {
|
|
|
2631
2671
|
)).json();
|
|
2632
2672
|
}
|
|
2633
2673
|
}
|
|
2634
|
-
class
|
|
2674
|
+
class on {
|
|
2635
2675
|
static async listRoles() {
|
|
2636
2676
|
if (!o.token)
|
|
2637
2677
|
throw new Error("Not authenticated");
|
|
@@ -2690,7 +2730,7 @@ class tn {
|
|
|
2690
2730
|
});
|
|
2691
2731
|
}
|
|
2692
2732
|
}
|
|
2693
|
-
class
|
|
2733
|
+
class rn {
|
|
2694
2734
|
static async listUsers() {
|
|
2695
2735
|
if (!o.token)
|
|
2696
2736
|
throw new Error("Not authenticated");
|
|
@@ -2750,14 +2790,14 @@ class nn {
|
|
|
2750
2790
|
});
|
|
2751
2791
|
}
|
|
2752
2792
|
}
|
|
2753
|
-
const
|
|
2793
|
+
const sn = ["viewer", "operator", "administrator"], cn = "viewer", dn = "operator", hn = "administrator", un = [
|
|
2754
2794
|
"year",
|
|
2755
2795
|
"month",
|
|
2756
2796
|
"week",
|
|
2757
2797
|
"day",
|
|
2758
2798
|
"hour",
|
|
2759
2799
|
"minute"
|
|
2760
|
-
],
|
|
2800
|
+
], ln = ["tag", "sheet", "user"], mn = [
|
|
2761
2801
|
"triggered-event",
|
|
2762
2802
|
"intervention-request",
|
|
2763
2803
|
"teleop-session-record",
|
|
@@ -2769,44 +2809,44 @@ const an = ["viewer", "operator", "administrator"], on = "viewer", rn = "operato
|
|
|
2769
2809
|
"comment",
|
|
2770
2810
|
"system",
|
|
2771
2811
|
"annotation"
|
|
2772
|
-
],
|
|
2812
|
+
], fn = [
|
|
2773
2813
|
"unknown",
|
|
2774
2814
|
"operational",
|
|
2775
2815
|
"offline",
|
|
2776
2816
|
"error"
|
|
2777
|
-
],
|
|
2817
|
+
], wn = ["selection", "labeling", "teleop"], pn = ["info", "warning", "error", "critical"], yn = ["video/mp4"], gn = (a) => new Promise((e) => setTimeout(e, a * 1e3));
|
|
2778
2818
|
try {
|
|
2779
2819
|
const a = typeof window < "u" && window.location ? new URLSearchParams(window.location.search) : new URLSearchParams(""), e = a.get("device");
|
|
2780
|
-
e &&
|
|
2820
|
+
e && u.setDefaultDevice(e);
|
|
2781
2821
|
const t = a.get("auth");
|
|
2782
2822
|
t && o.loginWithToken(t), a.get("module") && o.listenForRefresh(), typeof window < "u" && y.listenForConnectionEvents();
|
|
2783
2823
|
} catch {
|
|
2784
2824
|
}
|
|
2785
2825
|
export {
|
|
2786
|
-
|
|
2826
|
+
an as Account,
|
|
2787
2827
|
y as App,
|
|
2788
|
-
|
|
2828
|
+
nn as AudioPlayer,
|
|
2789
2829
|
o as Authentication,
|
|
2790
2830
|
Ke as BinaryRequestDataChannel,
|
|
2791
|
-
|
|
2792
|
-
|
|
2831
|
+
Ge as CaptureStream,
|
|
2832
|
+
We as DataChannel,
|
|
2793
2833
|
S as Device,
|
|
2794
|
-
|
|
2795
|
-
|
|
2834
|
+
u as Fleet,
|
|
2835
|
+
tn as KeyValue,
|
|
2796
2836
|
He as Manipulator,
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2837
|
+
lt as PeerDevice,
|
|
2838
|
+
on as Role,
|
|
2839
|
+
Xt as SessionType,
|
|
2800
2840
|
Qe as TextRequestDataChannel,
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2841
|
+
rn as User,
|
|
2842
|
+
sn as accessLevels,
|
|
2843
|
+
hn as administrator,
|
|
2804
2844
|
Z as aggregateByDateFunctions,
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2845
|
+
en as aggregateFunctionMap,
|
|
2846
|
+
Zt as aggregateFunctions,
|
|
2847
|
+
un as aggregateLevels,
|
|
2848
|
+
ln as annotationTypes,
|
|
2849
|
+
mn as eventTypes,
|
|
2810
2850
|
rt as formatTimeFrameText,
|
|
2811
2851
|
at as getAverage,
|
|
2812
2852
|
ot as getCount,
|
|
@@ -2815,13 +2855,13 @@ export {
|
|
|
2815
2855
|
et as getStandardDeviation,
|
|
2816
2856
|
it as getSum,
|
|
2817
2857
|
Ze as getVariance,
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2858
|
+
fn as healthStatuses,
|
|
2859
|
+
wn as interventionTypes,
|
|
2860
|
+
dn as operator,
|
|
2861
|
+
pn as severities,
|
|
2862
|
+
gn as timeout,
|
|
2863
|
+
Yt as vailableAggregationIntervals,
|
|
2864
|
+
yn as videoMimeTypes,
|
|
2865
|
+
cn as viewer
|
|
2826
2866
|
};
|
|
2827
2867
|
//# sourceMappingURL=data-sdk.es.js.map
|