@formant/data-sdk 0.0.89 → 0.0.92
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.es.js
CHANGED
|
@@ -1106,9 +1106,7 @@ ${T(o2)}`), a3;
|
|
|
1106
1106
|
}
|
|
1107
1107
|
};
|
|
1108
1108
|
}, function(e, t, r) {
|
|
1109
|
-
var n = r(95), o = n, i =
|
|
1110
|
-
return this || window || i || self || Function("return this")();
|
|
1111
|
-
}.call(null), s = r(94);
|
|
1109
|
+
var n = r(95), o = n, i = Function("return this")(), s = r(94);
|
|
1112
1110
|
o.object.extend(proto, s), o.exportSymbol("proto.v1.signaling.api.CreatePeerRequest", null, i), o.exportSymbol("proto.v1.signaling.api.CreatePeerResponse", null, i), o.exportSymbol("proto.v1.signaling.api.DeletePeerRequest", null, i), o.exportSymbol("proto.v1.signaling.api.DeletePeerResponse", null, i), o.exportSymbol("proto.v1.signaling.api.GetIceServersRequest", null, i), o.exportSymbol("proto.v1.signaling.api.GetIceServersResponse", null, i), o.exportSymbol("proto.v1.signaling.api.GetPeersRequest", null, i), o.exportSymbol("proto.v1.signaling.api.GetPeersResponse", null, i), o.exportSymbol("proto.v1.signaling.api.Peer", null, i), o.exportSymbol("proto.v1.signaling.api.ReceiveSignalStreamRequest", null, i), o.exportSymbol("proto.v1.signaling.api.ReceiveSignalStreamResponse", null, i), o.exportSymbol("proto.v1.signaling.api.RefreshPeerRequest", null, i), o.exportSymbol("proto.v1.signaling.api.RefreshPeerResponse", null, i), o.exportSymbol("proto.v1.signaling.api.SendSignalRequest", null, i), o.exportSymbol("proto.v1.signaling.api.SendSignalResponse", null, i), o.exportSymbol("proto.v1.signaling.api.SessionType", null, i), o.exportSymbol("proto.v1.signaling.api.Signal", null, i), proto.v1.signaling.api.Peer = function(e2) {
|
|
1113
1111
|
n.Message.initialize(this, e2, 0, -1, proto.v1.signaling.api.Peer.repeatedFields_, null);
|
|
1114
1112
|
}, o.inherits(proto.v1.signaling.api.Peer, n.Message), o.DEBUG && !COMPILED && (proto.v1.signaling.api.Peer.displayName = "proto.v1.signaling.api.Peer"), proto.v1.signaling.api.Signal = function(e2) {
|
|
@@ -16886,7 +16884,11 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
16886
16884
|
}), r.d(t, "IRtcStreamMessage", function() {
|
|
16887
16885
|
}), r.d(t, "IStreamControl", function() {
|
|
16888
16886
|
}), r.d(t, "RtcClient", function() {
|
|
16889
|
-
return
|
|
16887
|
+
return ee;
|
|
16888
|
+
}), r.d(t, "createRtcStreamMessage", function() {
|
|
16889
|
+
return Z;
|
|
16890
|
+
}), r.d(t, "IRtcStream", function() {
|
|
16891
|
+
}), r.d(t, "IRtcStreamPayload", function() {
|
|
16890
16892
|
});
|
|
16891
16893
|
var n = r(25), o = function(e2, t2, r2, n2) {
|
|
16892
16894
|
return new (r2 || (r2 = Promise))(function(o2, i2) {
|
|
@@ -17471,10 +17473,13 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17471
17473
|
});
|
|
17472
17474
|
}
|
|
17473
17475
|
}
|
|
17474
|
-
function Z(e2) {
|
|
17476
|
+
function Z(e2, t2) {
|
|
17477
|
+
return { header: { stream: e2, created: Date.now(), frameId: "" }, payload: t2 };
|
|
17478
|
+
}
|
|
17479
|
+
function $(e2) {
|
|
17475
17480
|
return (/* @__PURE__ */ new Set(["disconnected", "failed", "closed"])).has(e2.iceConnectionState);
|
|
17476
17481
|
}
|
|
17477
|
-
var
|
|
17482
|
+
var K = function(e2, t2, r2, n2) {
|
|
17478
17483
|
return new (r2 || (r2 = Promise))(function(o2, i2) {
|
|
17479
17484
|
function s2(e3) {
|
|
17480
17485
|
try {
|
|
@@ -17499,7 +17504,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17499
17504
|
l2((n2 = n2.apply(e2, t2 || [])).next());
|
|
17500
17505
|
});
|
|
17501
17506
|
};
|
|
17502
|
-
class
|
|
17507
|
+
class X {
|
|
17503
17508
|
constructor(e2, t2, r2) {
|
|
17504
17509
|
this.peerConnection = e2, this.config = t2, this.dataChannelNotifier = r2, this.connectTimeoutMs = 20 * l.a.second, this.iceGatheringTimeoutMs = 15 * l.a.second, this.pingUpdateTimeoutMs = 1 * l.a.second, this.streamsInfoUpdateTimeoutMs = 2 * l.a.second, this.reassemblyTimeoutMs = 500 * l.a.millisecond, this.reassemblyTableCleanupMs = 1 * l.a.second, this.heartbeatTimeoutMs = 20 * l.a.millisecond, this.streamLatestTimestamp = /* @__PURE__ */ new Map(), this.reassemblyTable = /* @__PURE__ */ new Map(), this.reassemblyTableLastTimestamp = /* @__PURE__ */ new Map(), this.closeCalled = false, this.gotOffer = false, this.hasIceCandidate = false;
|
|
17505
17510
|
const { isOffer: n2 } = t2.baseConfig;
|
|
@@ -17540,7 +17545,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17540
17545
|
}, this.heartbeatTimeoutMs);
|
|
17541
17546
|
}
|
|
17542
17547
|
handleSignal(e2) {
|
|
17543
|
-
return
|
|
17548
|
+
return K(this, void 0, void 0, function* () {
|
|
17544
17549
|
const { peerConnection: t2 } = this, { track: r2 } = this.config.baseConfig, n2 = (() => {
|
|
17545
17550
|
try {
|
|
17546
17551
|
return JSON.parse(e2.getPayload());
|
|
@@ -17593,7 +17598,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17593
17598
|
return (e2 == null ? void 0 : e2.readyState) === "open" && (t2 == null ? void 0 : t2.readyState) === "open" && (r2 == null ? void 0 : r2.readyState) === "open" && (n2 == null ? void 0 : n2.readyState) === "open";
|
|
17594
17599
|
}
|
|
17595
17600
|
close() {
|
|
17596
|
-
return
|
|
17601
|
+
return K(this, void 0, void 0, function* () {
|
|
17597
17602
|
if (this.closeCalled)
|
|
17598
17603
|
return;
|
|
17599
17604
|
this.closeCalled = true, this.sessionMetrics && (yield this.sessionMetrics.uploadMetrics()), this.pingUpdateTimeout && clearInterval(this.pingUpdateTimeout), this.reassemblyTableCleanupTimeout && clearInterval(this.reassemblyTableCleanupTimeout), this.streamsInfoUpdateTimeout && clearInterval(this.streamsInfoUpdateTimeout), this.heartbeatTimeout && clearInterval(this.heartbeatTimeout);
|
|
@@ -17636,7 +17641,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17636
17641
|
return (e2 = this.sessionMetrics) === null || e2 === void 0 ? void 0 : e2.counts;
|
|
17637
17642
|
}
|
|
17638
17643
|
getConnectionStatsInfo() {
|
|
17639
|
-
return
|
|
17644
|
+
return K(this, void 0, void 0, function* () {
|
|
17640
17645
|
const { peerConnection: e2 } = this;
|
|
17641
17646
|
if (!e2)
|
|
17642
17647
|
return;
|
|
@@ -17659,19 +17664,19 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17659
17664
|
}
|
|
17660
17665
|
getOffer() {
|
|
17661
17666
|
var e2, t2, r2;
|
|
17662
|
-
return
|
|
17667
|
+
return K(this, void 0, void 0, function* () {
|
|
17663
17668
|
const { gotOffer: n2 } = this, { peerConnection: o2, config: i2 } = this;
|
|
17664
17669
|
if (this.config.baseConfig.isLan)
|
|
17665
17670
|
throw new Error('"getOffer" method can only be called with internet connections. LAN connections should call the "getLanOffer" method.');
|
|
17666
17671
|
const s2 = (e2 = this.config.remoteConfig) === null || e2 === void 0 ? void 0 : e2.sessionId;
|
|
17667
17672
|
if (n2)
|
|
17668
17673
|
return void w.a.debug("Failed to generate offer because gotOffer was already called.");
|
|
17669
|
-
if (this.gotOffer = true,
|
|
17674
|
+
if (this.gotOffer = true, $(this.peerConnection))
|
|
17670
17675
|
return void w.a.debug("Failed to generate offer because the peer connection was inactive.");
|
|
17671
17676
|
const a3 = i2.baseConfig.track;
|
|
17672
17677
|
o2.onicecandidate = () => {
|
|
17673
17678
|
this.hasIceCandidate = true;
|
|
17674
|
-
}, o2.oniceconnectionstatechange = () =>
|
|
17679
|
+
}, o2.oniceconnectionstatechange = () => K(this, void 0, void 0, function* () {
|
|
17675
17680
|
const e3 = o2.iceConnectionState;
|
|
17676
17681
|
if (e3 === "connected" || e3 === "completed") {
|
|
17677
17682
|
const t3 = yield this.getConnectionStatsInfo(), r3 = t3 ? function(e4) {
|
|
@@ -17704,13 +17709,13 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17704
17709
|
});
|
|
17705
17710
|
}
|
|
17706
17711
|
getLanOffer() {
|
|
17707
|
-
return
|
|
17712
|
+
return K(this, void 0, void 0, function* () {
|
|
17708
17713
|
const { peerConnection: e2, gotOffer: t2 } = this;
|
|
17709
17714
|
if (!this.config.baseConfig.isLan)
|
|
17710
17715
|
throw new Error('"getLanOffer" method can only be used with LAN connections. Internet connections should call the "getOffer" method.');
|
|
17711
17716
|
if (t2)
|
|
17712
17717
|
return void w.a.debug("Failed to generate offer because gotOffer was already called.");
|
|
17713
|
-
if (this.gotOffer = true,
|
|
17718
|
+
if (this.gotOffer = true, $(this.peerConnection))
|
|
17714
17719
|
return void w.a.debug("Failed to generate offer because the peer connection was inactive.");
|
|
17715
17720
|
yield e2.setLocalDescription(yield e2.createOffer());
|
|
17716
17721
|
const r2 = new Date().getTime();
|
|
@@ -17728,7 +17733,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17728
17733
|
});
|
|
17729
17734
|
}
|
|
17730
17735
|
handleLanAnswer(e2) {
|
|
17731
|
-
return
|
|
17736
|
+
return K(this, void 0, void 0, function* () {
|
|
17732
17737
|
const { peerConnection: t2 } = this;
|
|
17733
17738
|
if (!this.config.baseConfig.isLan)
|
|
17734
17739
|
throw new Error('"handleLanAnswer" method can only be used with LAN connections. Internet connections should call the "handleSignal" method.');
|
|
@@ -17876,20 +17881,18 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17876
17881
|
case "streams-info":
|
|
17877
17882
|
s2 = { streamsInfo: (r2 = this.sessionMetrics) === null || r2 === void 0 ? void 0 : r2.getLocalStreamsInfo(new Date().getTime()) };
|
|
17878
17883
|
}
|
|
17879
|
-
this.sendOnChannel(e2,
|
|
17880
|
-
return { header: { stream: e3, created: Date.now(), frameId: "" }, payload: t3 };
|
|
17881
|
-
}(i2, s2));
|
|
17884
|
+
this.sendOnChannel(e2, Z(i2, s2));
|
|
17882
17885
|
}
|
|
17883
17886
|
isLatestMessage(e2) {
|
|
17884
17887
|
const t2 = G(e2.header.stream), r2 = (this.streamLatestTimestamp.get(t2) || 0) <= e2.header.created;
|
|
17885
17888
|
return r2 && this.streamLatestTimestamp.set(t2, e2.header.created), r2;
|
|
17886
17889
|
}
|
|
17887
17890
|
}
|
|
17888
|
-
function
|
|
17891
|
+
function J(e2) {
|
|
17889
17892
|
var t2, r2;
|
|
17890
17893
|
return { userId: (t2 = e2.getUserId()) === null || t2 === void 0 ? void 0 : t2.getValue(), deviceId: (r2 = e2.getDeviceId()) === null || r2 === void 0 ? void 0 : r2.getValue(), organizationId: e2.getOrganizationId(), id: e2.getPeerId(), capabilities: [], capabilitySet: {} };
|
|
17891
17894
|
}
|
|
17892
|
-
var
|
|
17895
|
+
var Q = function(e2, t2, r2, n2) {
|
|
17893
17896
|
return new (r2 || (r2 = Promise))(function(o2, i2) {
|
|
17894
17897
|
function s2(e3) {
|
|
17895
17898
|
try {
|
|
@@ -17914,11 +17917,11 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17914
17917
|
l2((n2 = n2.apply(e2, t2 || [])).next());
|
|
17915
17918
|
});
|
|
17916
17919
|
};
|
|
17917
|
-
class
|
|
17920
|
+
class ee {
|
|
17918
17921
|
constructor(e2) {
|
|
17919
17922
|
this.config = e2, this.grpcCallDeadline = 5 * l.a.second, this.refreshIntervalDelayMs = 2 * l.a.second, this.iceServersTtl = 30 * l.a.minute, this.connections = [], this.localConnections = [], this.isConnectionInitiator = /* @__PURE__ */ new Map(), this.isOutgoingConnection = /* @__PURE__ */ new Map(), this.peerDataChannelListeners = [];
|
|
17920
17923
|
const { refreshIntervalDelayMs: t2 } = this;
|
|
17921
|
-
this.refreshInterval = T({ func: () =>
|
|
17924
|
+
this.refreshInterval = T({ func: () => Q(this, void 0, void 0, function* () {
|
|
17922
17925
|
try {
|
|
17923
17926
|
yield this.update();
|
|
17924
17927
|
} catch (e3) {
|
|
@@ -17935,15 +17938,15 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17935
17938
|
r2 ? r2.isReady() ? r2.controlRemoteStream(t2) : w.a.warn("controlRemoteStream called with unready connection.") : w.a.warn("controlRemoteStream called with no connection.");
|
|
17936
17939
|
}
|
|
17937
17940
|
getLocalPeer() {
|
|
17938
|
-
return
|
|
17941
|
+
return Q(this, void 0, void 0, function* () {
|
|
17939
17942
|
for (; !this.localPeer; )
|
|
17940
17943
|
yield Object(u.a)(0.1 * l.a.second);
|
|
17941
|
-
return
|
|
17944
|
+
return J(this.localPeer);
|
|
17942
17945
|
});
|
|
17943
17946
|
}
|
|
17944
17947
|
connect(e2, t2) {
|
|
17945
17948
|
var r2, n2, o2;
|
|
17946
|
-
return
|
|
17949
|
+
return Q(this, void 0, void 0, function* () {
|
|
17947
17950
|
if (this.config.lanOnlyMode === true)
|
|
17948
17951
|
throw new Error("connect method called in local only mode.");
|
|
17949
17952
|
const { track: i2, signalingClient: s2 } = this.config, { localPeer: a3, receiveSignalStream: l2, iceServers: u2 } = this;
|
|
@@ -17954,7 +17957,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17954
17957
|
if (this.isOutgoingConnection.get(e2))
|
|
17955
17958
|
return void w.a.warn("Connect called for peer with an existing outgoing connection offer.");
|
|
17956
17959
|
this.isOutgoingConnection.set(e2, true);
|
|
17957
|
-
const g2 = new
|
|
17960
|
+
const g2 = new X(yield this.createRTCPeerConnection(u2, t2), { baseConfig: { isOffer: true, isLan: false, receive: (e3, t3) => this.config.receive(e3, t3), onStreamsInfoUpdate: this.config.onStreamsInfoUpdate ? (e3, t3) => {
|
|
17958
17961
|
var r3, n3;
|
|
17959
17962
|
return (n3 = (r3 = this.config).onStreamsInfoUpdate) === null || n3 === void 0 ? void 0 : n3.call(r3, e3, t3);
|
|
17960
17963
|
} : void 0, track: this.config.lanOnlyMode ? void 0 : this.config.track, localUserId: (r2 = a3.getUserId()) === null || r2 === void 0 ? void 0 : r2.getValue(), localPeerId: a3.getPeerId(), remotePeerId: e2, sessionType: t2 == null ? void 0 : t2.sessionType }, remoteConfig: {} }, (t3) => this.onCustomDataChannel(e2, t3)), c2 = yield g2.getOffer();
|
|
@@ -17963,7 +17966,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17963
17966
|
w.a.debug("Sending offer."), i2 == null || i2("Sending offer", c2);
|
|
17964
17967
|
const f2 = new N.SendSignalRequest();
|
|
17965
17968
|
f2.setSignal(c2);
|
|
17966
|
-
const p2 = yield (() =>
|
|
17969
|
+
const p2 = yield (() => Q(this, void 0, void 0, function* () {
|
|
17967
17970
|
try {
|
|
17968
17971
|
return yield s2.sendSignal(f2, yield this.getMetadata({}));
|
|
17969
17972
|
} catch (e3) {
|
|
@@ -17979,8 +17982,8 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17979
17982
|
}
|
|
17980
17983
|
connectLan(e2) {
|
|
17981
17984
|
var t2, r2;
|
|
17982
|
-
return
|
|
17983
|
-
const n2 = new B(e2), o2 = new
|
|
17985
|
+
return Q(this, void 0, void 0, function* () {
|
|
17986
|
+
const n2 = new B(e2), o2 = new X(yield this.createRTCPeerConnection([]), { baseConfig: { isOffer: true, isLan: true, receive: (e3, t3) => this.config.receive(e3, t3), onStreamsInfoUpdate: this.config.onStreamsInfoUpdate ? (e3, t3) => {
|
|
17984
17987
|
var r3, n3;
|
|
17985
17988
|
return (n3 = (r3 = this.config).onStreamsInfoUpdate) === null || n3 === void 0 ? void 0 : n3.call(r3, e3, t3);
|
|
17986
17989
|
} : void 0, track: this.config.lanOnlyMode ? void 0 : this.config.track, localUserId: (r2 = (t2 = this.localPeer) === null || t2 === void 0 ? void 0 : t2.getUserId()) === null || r2 === void 0 ? void 0 : r2.getValue(), localPeerId: "lan_client", remotePeerId: e2 } }, (t3) => this.onCustomDataChannel(e2, t3)), i2 = yield o2.getLanOffer();
|
|
@@ -18017,23 +18020,23 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18017
18020
|
return t2 ? t2.isReady() ? "connected" : "connecting" : "disconnected";
|
|
18018
18021
|
}
|
|
18019
18022
|
getConnectionStatsInfo(e2) {
|
|
18020
|
-
return
|
|
18023
|
+
return Q(this, void 0, void 0, function* () {
|
|
18021
18024
|
const t2 = this.getActiveConnection(e2);
|
|
18022
18025
|
if (t2)
|
|
18023
18026
|
return yield t2.getConnectionStatsInfo();
|
|
18024
18027
|
});
|
|
18025
18028
|
}
|
|
18026
18029
|
disconnect(e2) {
|
|
18027
|
-
return
|
|
18030
|
+
return Q(this, void 0, void 0, function* () {
|
|
18028
18031
|
const t2 = this.getActiveConnection(e2);
|
|
18029
18032
|
t2 && (yield t2.close());
|
|
18030
18033
|
});
|
|
18031
18034
|
}
|
|
18032
18035
|
getPeers() {
|
|
18033
|
-
return
|
|
18036
|
+
return Q(this, void 0, void 0, function* () {
|
|
18034
18037
|
if (this.config.lanOnlyMode)
|
|
18035
18038
|
throw new Error("getPeers method cannot be used in local-only mode.");
|
|
18036
|
-
const { signalingClient: e2 } = this.config, t2 = yield (() =>
|
|
18039
|
+
const { signalingClient: e2 } = this.config, t2 = yield (() => Q(this, void 0, void 0, function* () {
|
|
18037
18040
|
try {
|
|
18038
18041
|
return yield e2.getPeers(new N.GetPeersRequest(), yield this.getMetadata({}));
|
|
18039
18042
|
} catch (e3) {
|
|
@@ -18049,14 +18052,14 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18049
18052
|
var t3, r3;
|
|
18050
18053
|
return (r3 = (t3 = e3.getPeerCreatedTimestamp()) === null || t3 === void 0 ? void 0 : t3.getValue()) !== null && r3 !== void 0 ? r3 : 0;
|
|
18051
18054
|
};
|
|
18052
|
-
return r2.sort((e3, t3) => n2(t3) - n2(e3)).map((e3) =>
|
|
18055
|
+
return r2.sort((e3, t3) => n2(t3) - n2(e3)).map((e3) => J(e3));
|
|
18053
18056
|
});
|
|
18054
18057
|
}
|
|
18055
18058
|
getSessions() {
|
|
18056
|
-
return
|
|
18059
|
+
return Q(this, void 0, void 0, function* () {
|
|
18057
18060
|
if (this.config.lanOnlyMode)
|
|
18058
18061
|
throw new Error("getPeers method cannot be used in local-only mode.");
|
|
18059
|
-
const { signalingClient: e2 } = this.config, t2 = yield (() =>
|
|
18062
|
+
const { signalingClient: e2 } = this.config, t2 = yield (() => Q(this, void 0, void 0, function* () {
|
|
18060
18063
|
try {
|
|
18061
18064
|
return yield e2.getPeers(new N.GetPeersRequest(), yield this.getMetadata({}));
|
|
18062
18065
|
} catch (e3) {
|
|
@@ -18096,7 +18099,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18096
18099
|
return !!(e2 && t2 && r2);
|
|
18097
18100
|
}
|
|
18098
18101
|
shutdown() {
|
|
18099
|
-
return
|
|
18102
|
+
return Q(this, void 0, void 0, function* () {
|
|
18100
18103
|
w.a.info("Shutdown called on RTC client"), yield this.refreshInterval.stop(), this.receiveSignalStream && this.receiveSignalStream.cancel();
|
|
18101
18104
|
const e2 = this.connections;
|
|
18102
18105
|
this.connections = [], yield this.closeConnections(e2);
|
|
@@ -18106,7 +18109,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18106
18109
|
if (this.config.lanOnlyMode)
|
|
18107
18110
|
return;
|
|
18108
18111
|
const { signalingClient: r2 } = this.config;
|
|
18109
|
-
yield (() =>
|
|
18112
|
+
yield (() => Q(this, void 0, void 0, function* () {
|
|
18110
18113
|
try {
|
|
18111
18114
|
const e3 = new N.DeletePeerRequest();
|
|
18112
18115
|
e3.setPeerId(t2.getPeerId()), yield r2.deletePeer(e3, yield this.getMetadata({}));
|
|
@@ -18117,10 +18120,10 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18117
18120
|
});
|
|
18118
18121
|
}
|
|
18119
18122
|
createPeer() {
|
|
18120
|
-
return
|
|
18123
|
+
return Q(this, void 0, void 0, function* () {
|
|
18121
18124
|
if (this.config.lanOnlyMode)
|
|
18122
18125
|
throw new Error("createPeer method cannot be used in local-only mode.");
|
|
18123
|
-
const { signalingClient: e2 } = this.config, t2 = yield (() =>
|
|
18126
|
+
const { signalingClient: e2 } = this.config, t2 = yield (() => Q(this, void 0, void 0, function* () {
|
|
18124
18127
|
try {
|
|
18125
18128
|
return yield e2.createPeer(new N.CreatePeerRequest(), yield this.getMetadata({}));
|
|
18126
18129
|
} catch (e3) {
|
|
@@ -18133,7 +18136,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18133
18136
|
});
|
|
18134
18137
|
}
|
|
18135
18138
|
createReceiveSignalStream() {
|
|
18136
|
-
return
|
|
18139
|
+
return Q(this, void 0, void 0, function* () {
|
|
18137
18140
|
if (this.config.lanOnlyMode)
|
|
18138
18141
|
throw new Error("createReceiveSignalStream method cannot be used in local-only mode.");
|
|
18139
18142
|
const { signalingClient: e2 } = this.config, { localPeer: t2, iceServers: r2 } = this;
|
|
@@ -18143,7 +18146,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18143
18146
|
n2 && n2.cancel();
|
|
18144
18147
|
const o2 = new N.ReceiveSignalStreamRequest();
|
|
18145
18148
|
o2.setPeerId(t2.getPeerId());
|
|
18146
|
-
const i2 = yield (() =>
|
|
18149
|
+
const i2 = yield (() => Q(this, void 0, void 0, function* () {
|
|
18147
18150
|
try {
|
|
18148
18151
|
return e2.receiveSignalStream(o2, yield this.getMetadata({ hasDeadline: false }));
|
|
18149
18152
|
} catch (e3) {
|
|
@@ -18152,7 +18155,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18152
18155
|
}))();
|
|
18153
18156
|
if (!i2)
|
|
18154
18157
|
throw new Error("Response did not provide stream.");
|
|
18155
|
-
return i2.on("data", (e3) =>
|
|
18158
|
+
return i2.on("data", (e3) => Q(this, void 0, void 0, function* () {
|
|
18156
18159
|
var n3, o3, i3, s2;
|
|
18157
18160
|
const a3 = e3.getSignal(), l2 = (n3 = a3 == null ? void 0 : a3.getSessionId()) === null || n3 === void 0 ? void 0 : n3.getValue(), u2 = a3 == null ? void 0 : a3.getSenderId(), g2 = a3 == null ? void 0 : a3.getReceiverId(), c2 = (o3 = a3 == null ? void 0 : a3.getSessionCreatedTimestamp()) === null || o3 === void 0 ? void 0 : o3.getValue();
|
|
18158
18161
|
if (!(a3 && l2 && u2 && g2 && c2))
|
|
@@ -18162,7 +18165,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18162
18165
|
if (f2.getSessionId() !== l2) {
|
|
18163
18166
|
if (w.a.debug("Received signal: different session for a peer we're already connected to."), (f2.getSessionCreatedTimestamp() || 0) > c2)
|
|
18164
18167
|
return;
|
|
18165
|
-
const e4 = new
|
|
18168
|
+
const e4 = new X(yield this.createRTCPeerConnection(r2), { baseConfig: { isOffer: false, isLan: false, receive: (e5, t3) => this.config.receive(e5, t3), onStreamsInfoUpdate: this.config.onStreamsInfoUpdate ? (e5, t3) => {
|
|
18166
18169
|
var r3, n4;
|
|
18167
18170
|
return (n4 = (r3 = this.config).onStreamsInfoUpdate) === null || n4 === void 0 ? void 0 : n4.call(r3, e5, t3);
|
|
18168
18171
|
} : void 0, track: this.config.lanOnlyMode ? void 0 : this.config.track, localPeerId: t2.getPeerId(), localUserId: (s2 = t2.getUserId()) === null || s2 === void 0 ? void 0 : s2.getValue(), remotePeerId: u2 }, remoteConfig: { sessionId: l2, sessionCreatedTimestamp: c2 } }, (e5) => this.onCustomDataChannel(u2, e5));
|
|
@@ -18171,7 +18174,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18171
18174
|
w.a.debug("Received signal: for an existing connection."), yield f2.handleSignal(a3);
|
|
18172
18175
|
else {
|
|
18173
18176
|
w.a.debug("Received signal: new connection.");
|
|
18174
|
-
const e4 = new
|
|
18177
|
+
const e4 = new X(yield this.createRTCPeerConnection(r2), { baseConfig: { isOffer: false, isLan: false, receive: (e5, t3) => this.config.receive(e5, t3), onStreamsInfoUpdate: this.config.onStreamsInfoUpdate ? (e5, t3) => {
|
|
18175
18178
|
var r3, n4;
|
|
18176
18179
|
return (n4 = (r3 = this.config).onStreamsInfoUpdate) === null || n4 === void 0 ? void 0 : n4.call(r3, e5, t3);
|
|
18177
18180
|
} : void 0, track: this.config.lanOnlyMode ? void 0 : this.config.track, localPeerId: t2.getPeerId(), localUserId: (i3 = t2.getUserId()) === null || i3 === void 0 ? void 0 : i3.getValue(), remotePeerId: u2 }, remoteConfig: { sessionId: l2, sessionCreatedTimestamp: c2 } }, (e5) => this.onCustomDataChannel(u2, e5));
|
|
@@ -18198,7 +18201,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18198
18201
|
}
|
|
18199
18202
|
createRTCPeerConnection(e2, t2) {
|
|
18200
18203
|
var r2;
|
|
18201
|
-
return
|
|
18204
|
+
return Q(this, void 0, void 0, function* () {
|
|
18202
18205
|
const n2 = t2 == null ? void 0 : t2.rtcIceTransportPolicies, o2 = (t2 == null ? void 0 : t2.rtcIceServerProtocol) ? [t2 == null ? void 0 : t2.rtcIceServerProtocol] : void 0, i2 = e2.map((e3) => Object.assign(Object.assign({}, e3), { urls: typeof e3.urls == "string" ? [e3.urls] : e3.urls })).map((e3) => Object.assign(Object.assign({}, e3), { urls: e3.urls.filter((e4) => {
|
|
18203
18206
|
const t3 = (n2 === void 0 || n2.some((t4) => ((e5, t5) => {
|
|
18204
18207
|
switch (t5) {
|
|
@@ -18216,8 +18219,8 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18216
18219
|
});
|
|
18217
18220
|
}
|
|
18218
18221
|
closeConnections(e2) {
|
|
18219
|
-
return
|
|
18220
|
-
const t2 = yield v(e2.map((e3) =>
|
|
18222
|
+
return Q(this, void 0, void 0, function* () {
|
|
18223
|
+
const t2 = yield v(e2.map((e3) => Q(this, void 0, void 0, function* () {
|
|
18221
18224
|
yield e3.close();
|
|
18222
18225
|
})));
|
|
18223
18226
|
for (const e3 of t2)
|
|
@@ -18229,7 +18232,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18229
18232
|
}
|
|
18230
18233
|
update() {
|
|
18231
18234
|
var e2;
|
|
18232
|
-
return
|
|
18235
|
+
return Q(this, void 0, void 0, function* () {
|
|
18233
18236
|
if (this.localConnections = this.localConnections.filter((e3) => e3.isActive()), this.config.lanOnlyMode)
|
|
18234
18237
|
return;
|
|
18235
18238
|
const { signalingClient: t2 } = this.config;
|
|
@@ -18251,12 +18254,12 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18251
18254
|
});
|
|
18252
18255
|
}
|
|
18253
18256
|
reset() {
|
|
18254
|
-
return
|
|
18257
|
+
return Q(this, void 0, void 0, function* () {
|
|
18255
18258
|
yield this.closeConnections(this.connections), this.connections = [], this.isOutgoingConnection = /* @__PURE__ */ new Map(), yield this.createPeer(), yield this.createReceiveSignalStream();
|
|
18256
18259
|
});
|
|
18257
18260
|
}
|
|
18258
18261
|
updateIceServers() {
|
|
18259
|
-
return
|
|
18262
|
+
return Q(this, void 0, void 0, function* () {
|
|
18260
18263
|
if (this.config.lanOnlyMode)
|
|
18261
18264
|
return;
|
|
18262
18265
|
const { iceServersLastUpdate: e2, iceServersTtl: t2 } = this, r2 = new Date().getTime();
|
|
@@ -18271,7 +18274,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18271
18274
|
}
|
|
18272
18275
|
setupHandlers(e2) {
|
|
18273
18276
|
const { peerConnection: t2 } = e2, r2 = e2.getSessionCreatedTimestamp();
|
|
18274
|
-
t2.onconnectionstatechange = () =>
|
|
18277
|
+
t2.onconnectionstatechange = () => Q(this, void 0, void 0, function* () {
|
|
18275
18278
|
const e3 = t2.connectionState;
|
|
18276
18279
|
if (r2)
|
|
18277
18280
|
switch (e3) {
|
|
@@ -18284,7 +18287,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18284
18287
|
});
|
|
18285
18288
|
}
|
|
18286
18289
|
getMetadata(e2) {
|
|
18287
|
-
return
|
|
18290
|
+
return Q(this, void 0, void 0, function* () {
|
|
18288
18291
|
if (this.config.lanOnlyMode)
|
|
18289
18292
|
throw new Error("getMetadata method cannot be called in local-only mode");
|
|
18290
18293
|
const { getToken: t2 } = this.config, { grpcCallDeadline: r2 } = this, { hasDeadline: n2 } = e2, o2 = n2 === false ? void 0 : new Date().getTime() + r2;
|
|
@@ -18954,7 +18957,7 @@ class Device {
|
|
|
18954
18957
|
throw new Error(`Realtime connection hasn't been started for ${this.id}`);
|
|
18955
18958
|
}
|
|
18956
18959
|
}
|
|
18957
|
-
async startRealtimeConnection(
|
|
18960
|
+
async startRealtimeConnection(config) {
|
|
18958
18961
|
if (!this.rtcClient) {
|
|
18959
18962
|
const rtcClient = new dist.exports.RtcClient({
|
|
18960
18963
|
signalingClient: new dist.exports.SignalingPromiseClient(FORMANT_API_URL, null, null),
|
|
@@ -18972,8 +18975,8 @@ class Device {
|
|
|
18972
18975
|
throw new Error("Cannot find peer, is the robot offline?");
|
|
18973
18976
|
}
|
|
18974
18977
|
this.remoteDevicePeerId = devicePeer.id;
|
|
18975
|
-
await rtcClient.connect(this.remoteDevicePeerId, {
|
|
18976
|
-
sessionType:
|
|
18978
|
+
await rtcClient.connect(this.remoteDevicePeerId, config || {
|
|
18979
|
+
sessionType: 1
|
|
18977
18980
|
});
|
|
18978
18981
|
while (rtcClient.getConnectionStatus(this.remoteDevicePeerId) !== "connected") {
|
|
18979
18982
|
await delay(100);
|
|
@@ -19130,7 +19133,8 @@ class Device {
|
|
|
19130
19133
|
description: i.description,
|
|
19131
19134
|
parameterEnabled: i.parameterEnabled,
|
|
19132
19135
|
parameterValue: i.parameterValue,
|
|
19133
|
-
parameterMeta: i.parameterMeta
|
|
19136
|
+
parameterMeta: i.parameterMeta,
|
|
19137
|
+
enabled: i.enabled
|
|
19134
19138
|
}));
|
|
19135
19139
|
}
|
|
19136
19140
|
async sendCommand(name, data, time, metadata) {
|
|
@@ -19327,7 +19331,7 @@ class PeerDevice {
|
|
|
19327
19331
|
throw new Error(`Realtime connection hasn't been started`);
|
|
19328
19332
|
}
|
|
19329
19333
|
}
|
|
19330
|
-
async startRealtimeConnection(
|
|
19334
|
+
async startRealtimeConnection(_config) {
|
|
19331
19335
|
if (!this.rtcClient) {
|
|
19332
19336
|
const rtcClient = new dist.exports.RtcClient({
|
|
19333
19337
|
lanOnlyMode: true,
|
|
@@ -19701,6 +19705,19 @@ const _Fleet = class {
|
|
|
19701
19705
|
});
|
|
19702
19706
|
return (await data.json()).items;
|
|
19703
19707
|
}
|
|
19708
|
+
static async getEvent(uuid) {
|
|
19709
|
+
if (!Authentication.token) {
|
|
19710
|
+
throw new Error("Not authenticated");
|
|
19711
|
+
}
|
|
19712
|
+
const data = await fetch(`${FORMANT_API_URL}/v1/admin/events/query/id=${uuid}`, {
|
|
19713
|
+
method: "GET",
|
|
19714
|
+
headers: {
|
|
19715
|
+
"Content-Type": "application/json",
|
|
19716
|
+
Authorization: "Bearer " + Authentication.token
|
|
19717
|
+
}
|
|
19718
|
+
});
|
|
19719
|
+
return (await data.json()).items;
|
|
19720
|
+
}
|
|
19704
19721
|
static async getInterventions() {
|
|
19705
19722
|
if (!Authentication.token) {
|
|
19706
19723
|
throw new Error("Not authenticated");
|