@viamrobotics/sdk 0.2.4-rc.0 → 0.2.5-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.es.js CHANGED
@@ -9955,10 +9955,11 @@ var timestamp_pb = {};
9955
9955
  }, e.Message.GENERATE_TO_OBJECT && (proto.viam.common.v1.GetKinematicsRequest.prototype.toObject = function(o) {
9956
9956
  return proto.viam.common.v1.GetKinematicsRequest.toObject(o, this);
9957
9957
  }, proto.viam.common.v1.GetKinematicsRequest.toObject = function(o, r) {
9958
- var n = {
9959
- name: e.Message.getFieldWithDefault(r, 1, "")
9958
+ var n, l = {
9959
+ name: e.Message.getFieldWithDefault(r, 1, ""),
9960
+ extra: (n = r.getExtra()) && g.Struct.toObject(o, n)
9960
9961
  };
9961
- return o && (n.$jspbMessageInstance = r), n;
9962
+ return o && (l.$jspbMessageInstance = r), l;
9962
9963
  }), proto.viam.common.v1.GetKinematicsRequest.deserializeBinary = function(o) {
9963
9964
  var r = new e.BinaryReader(o), n = new proto.viam.common.v1.GetKinematicsRequest();
9964
9965
  return proto.viam.common.v1.GetKinematicsRequest.deserializeBinaryFromReader(n, r);
@@ -9973,6 +9974,10 @@ var timestamp_pb = {};
9973
9974
  );
9974
9975
  o.setName(l);
9975
9976
  break;
9977
+ case 99:
9978
+ var l = new g.Struct();
9979
+ r.readMessage(l, g.Struct.deserializeBinaryFromReader), o.setExtra(l);
9980
+ break;
9976
9981
  default:
9977
9982
  r.skipField();
9978
9983
  break;
@@ -9987,6 +9992,10 @@ var timestamp_pb = {};
9987
9992
  n = o.getName(), n.length > 0 && r.writeString(
9988
9993
  1,
9989
9994
  n
9995
+ ), n = o.getExtra(), n != null && r.writeMessage(
9996
+ 99,
9997
+ n,
9998
+ g.Struct.serializeBinaryToWriter
9990
9999
  );
9991
10000
  }, proto.viam.common.v1.GetKinematicsRequest.prototype.getName = function() {
9992
10001
  return (
@@ -9995,6 +10004,17 @@ var timestamp_pb = {};
9995
10004
  );
9996
10005
  }, proto.viam.common.v1.GetKinematicsRequest.prototype.setName = function(o) {
9997
10006
  return e.Message.setProto3StringField(this, 1, o);
10007
+ }, proto.viam.common.v1.GetKinematicsRequest.prototype.getExtra = function() {
10008
+ return (
10009
+ /** @type{?proto.google.protobuf.Struct} */
10010
+ e.Message.getWrapperField(this, g.Struct, 99)
10011
+ );
10012
+ }, proto.viam.common.v1.GetKinematicsRequest.prototype.setExtra = function(o) {
10013
+ return e.Message.setWrapperField(this, 99, o);
10014
+ }, proto.viam.common.v1.GetKinematicsRequest.prototype.clearExtra = function() {
10015
+ return this.setExtra(void 0);
10016
+ }, proto.viam.common.v1.GetKinematicsRequest.prototype.hasExtra = function() {
10017
+ return e.Message.getField(this, 99) != null;
9998
10018
  }, e.Message.GENERATE_TO_OBJECT && (proto.viam.common.v1.GetKinematicsResponse.prototype.toObject = function(o) {
9999
10019
  return proto.viam.common.v1.GetKinematicsResponse.toObject(o, this);
10000
10020
  }, proto.viam.common.v1.GetKinematicsResponse.toObject = function(o, r) {
@@ -10073,10 +10093,11 @@ var timestamp_pb = {};
10073
10093
  }, e.Message.GENERATE_TO_OBJECT && (proto.viam.common.v1.GetGeometriesRequest.prototype.toObject = function(o) {
10074
10094
  return proto.viam.common.v1.GetGeometriesRequest.toObject(o, this);
10075
10095
  }, proto.viam.common.v1.GetGeometriesRequest.toObject = function(o, r) {
10076
- var n = {
10077
- name: e.Message.getFieldWithDefault(r, 1, "")
10096
+ var n, l = {
10097
+ name: e.Message.getFieldWithDefault(r, 1, ""),
10098
+ extra: (n = r.getExtra()) && g.Struct.toObject(o, n)
10078
10099
  };
10079
- return o && (n.$jspbMessageInstance = r), n;
10100
+ return o && (l.$jspbMessageInstance = r), l;
10080
10101
  }), proto.viam.common.v1.GetGeometriesRequest.deserializeBinary = function(o) {
10081
10102
  var r = new e.BinaryReader(o), n = new proto.viam.common.v1.GetGeometriesRequest();
10082
10103
  return proto.viam.common.v1.GetGeometriesRequest.deserializeBinaryFromReader(n, r);
@@ -10091,6 +10112,10 @@ var timestamp_pb = {};
10091
10112
  );
10092
10113
  o.setName(l);
10093
10114
  break;
10115
+ case 99:
10116
+ var l = new g.Struct();
10117
+ r.readMessage(l, g.Struct.deserializeBinaryFromReader), o.setExtra(l);
10118
+ break;
10094
10119
  default:
10095
10120
  r.skipField();
10096
10121
  break;
@@ -10105,6 +10130,10 @@ var timestamp_pb = {};
10105
10130
  n = o.getName(), n.length > 0 && r.writeString(
10106
10131
  1,
10107
10132
  n
10133
+ ), n = o.getExtra(), n != null && r.writeMessage(
10134
+ 99,
10135
+ n,
10136
+ g.Struct.serializeBinaryToWriter
10108
10137
  );
10109
10138
  }, proto.viam.common.v1.GetGeometriesRequest.prototype.getName = function() {
10110
10139
  return (
@@ -10113,6 +10142,17 @@ var timestamp_pb = {};
10113
10142
  );
10114
10143
  }, proto.viam.common.v1.GetGeometriesRequest.prototype.setName = function(o) {
10115
10144
  return e.Message.setProto3StringField(this, 1, o);
10145
+ }, proto.viam.common.v1.GetGeometriesRequest.prototype.getExtra = function() {
10146
+ return (
10147
+ /** @type{?proto.google.protobuf.Struct} */
10148
+ e.Message.getWrapperField(this, g.Struct, 99)
10149
+ );
10150
+ }, proto.viam.common.v1.GetGeometriesRequest.prototype.setExtra = function(o) {
10151
+ return e.Message.setWrapperField(this, 99, o);
10152
+ }, proto.viam.common.v1.GetGeometriesRequest.prototype.clearExtra = function() {
10153
+ return this.setExtra(void 0);
10154
+ }, proto.viam.common.v1.GetGeometriesRequest.prototype.hasExtra = function() {
10155
+ return e.Message.getField(this, 99) != null;
10116
10156
  }, proto.viam.common.v1.GetGeometriesResponse.repeatedFields_ = [1], e.Message.GENERATE_TO_OBJECT && (proto.viam.common.v1.GetGeometriesResponse.prototype.toObject = function(o) {
10117
10157
  return proto.viam.common.v1.GetGeometriesResponse.toObject(o, this);
10118
10158
  }, proto.viam.common.v1.GetGeometriesResponse.toObject = function(o, r) {
@@ -13798,10 +13838,10 @@ var backOff_1 = backoff.backOff = backOff, BackOff = (
13798
13838
  var C = c(this.buffer, this.position, this.position + 5), q = new DataView(C.buffer, C.byteOffset, C.byteLength), W = n(q);
13799
13839
  if (!l(this.buffer, this.position, 5 + W))
13800
13840
  return b;
13801
- var z = c(this.buffer, this.position + 5, this.position + 5 + W);
13841
+ var x = c(this.buffer, this.position + 5, this.position + 5 + W);
13802
13842
  if (this.position += 5 + W, r(q))
13803
- return b.push({ chunkType: u.TRAILERS, trailers: (f = z, new g.Metadata(o(f))) }), b;
13804
- b.push({ chunkType: u.MESSAGE, data: z });
13843
+ return b.push({ chunkType: u.TRAILERS, trailers: (f = x, new g.Metadata(o(f))) }), b;
13844
+ b.push({ chunkType: u.MESSAGE, data: x });
13805
13845
  }
13806
13846
  }, d;
13807
13847
  }();
@@ -20378,22 +20418,22 @@ var backOff_1 = backoff.backOff = backOff, BackOff = (
20378
20418
  }
20379
20419
  function y(h, O, w) {
20380
20420
  return i.__awaiter(this, void 0, void 0, function() {
20381
- var C, q, W, z = this;
20421
+ var C, q, W, x = this;
20382
20422
  return i.__generator(this, function(U) {
20383
20423
  switch (U.label) {
20384
20424
  case 0:
20385
20425
  return C = "", q = function() {
20386
- return i.__awaiter(z, void 0, void 0, function() {
20387
- var I, x, k, S, R, _, E, F, P, T;
20426
+ return i.__awaiter(x, void 0, void 0, function() {
20427
+ var I, z, k, S, R, _, E, F, P, T;
20388
20428
  return i.__generator(this, function(j) {
20389
20429
  switch (j.label) {
20390
20430
  case 0:
20391
20431
  return C != "" ? [3, 5] : (I = "", w.accessToken && w.accessToken !== "" ? [3, 2] : ((E = new n.AuthenticateRequest()).setEntity(w.authEntity ? w.authEntity : h.replace(/^(.*:\/\/)/, "")), (S = new n.Credentials()).setType((P = w.credentials) === null || P === void 0 ? void 0 : P.type), S.setPayload((T = w.credentials) === null || T === void 0 ? void 0 : T.payload), E.setCredentials(S), _ = new Promise(function(A, D) {
20392
- x = A, k = D;
20432
+ z = A, k = D;
20393
20433
  }), u.grpc.invoke(l.AuthService.Authenticate, { request: E, host: w.externalAuthAddress ? w.externalAuthAddress : h, transport: O, onMessage: function(A) {
20394
20434
  I = A.getAccessToken();
20395
20435
  }, onEnd: function(A, D, B) {
20396
- A == u.grpc.Code.OK ? x(F) : k(D);
20436
+ A == u.grpc.Code.OK ? z(F) : k(D);
20397
20437
  } }), [4, _]));
20398
20438
  case 1:
20399
20439
  return j.sent(), [3, 3];
@@ -20401,11 +20441,11 @@ var backOff_1 = backoff.backOff = backOff, BackOff = (
20401
20441
  I = w.accessToken, j.label = 3;
20402
20442
  case 3:
20403
20443
  return C = I, w.externalAuthAddress && w.externalAuthToEntity ? ((R = new u.grpc.Metadata()).set("authorization", "Bearer ".concat(C)), _ = new Promise(function(A, D) {
20404
- x = A, k = D;
20444
+ z = A, k = D;
20405
20445
  }), I = "", (E = new n.AuthenticateToRequest()).setEntity(w.externalAuthToEntity), u.grpc.invoke(l.ExternalAuthService.AuthenticateTo, { request: E, host: w.externalAuthAddress, transport: O, metadata: R, onMessage: function(A) {
20406
20446
  I = A.getAccessToken();
20407
20447
  }, onEnd: function(A, D, B) {
20408
- A == u.grpc.Code.OK ? x(R) : k(D);
20448
+ A == u.grpc.Code.OK ? z(R) : k(D);
20409
20449
  } }), [4, _]) : [3, 5];
20410
20450
  case 4:
20411
20451
  j.sent(), C = I, j.label = 5;
@@ -20442,14 +20482,14 @@ var backOff_1 = backoff.backOff = backOff, BackOff = (
20442
20482
  }();
20443
20483
  function b(h, O, w) {
20444
20484
  return i.__awaiter(this, void 0, void 0, function() {
20445
- var C, q, W, z, U, I;
20446
- return i.__generator(this, function(x) {
20447
- switch (x.label) {
20485
+ var C, q, W, x, U, I;
20486
+ return i.__generator(this, function(z) {
20487
+ switch (z.label) {
20448
20488
  case 0:
20449
20489
  return C = i.__assign({}, w), [4, v(h, C)];
20450
20490
  case 1:
20451
- return q = x.sent(), I = new Promise(function(k, S) {
20452
- W = k, z = S;
20491
+ return q = z.sent(), I = new Promise(function(k, S) {
20492
+ W = k, x = S;
20453
20493
  }), u.grpc.unary(m.SignalingService.OptionalWebRTCConfig, { request: new c.OptionalWebRTCConfigRequest(), metadata: { "rpc-host": O }, host: h, transport: q, onEnd: function(k) {
20454
20494
  var S = k.status, R = k.statusMessage, _ = k.message;
20455
20495
  if (S === u.grpc.Code.OK && _) {
@@ -20457,10 +20497,10 @@ var backOff_1 = backoff.backOff = backOff, BackOff = (
20457
20497
  return void W(new c.WebRTCConfig());
20458
20498
  W(U);
20459
20499
  } else
20460
- z(R);
20500
+ x(R);
20461
20501
  } }), [4, I];
20462
20502
  case 2:
20463
- if (x.sent(), !U)
20503
+ if (z.sent(), !U)
20464
20504
  throw new Error("no config");
20465
20505
  return [2, U];
20466
20506
  }
@@ -20493,7 +20533,7 @@ var backOff_1 = backoff.backOff = backOff, BackOff = (
20493
20533
  }
20494
20534
  }
20495
20535
  e.dialWebRTC = function(h, O, w) {
20496
- var C, q, W, z, U, I, x;
20536
+ var C, q, W, x, U, I, z;
20497
20537
  return i.__awaiter(this, void 0, void 0, function() {
20498
20538
  var k, S, R, _, E, F, P, T, j, A, D, B, G, V, Z, oe, re, ge, ae, ne, pe, ie, le, se, ce, ue, me = this;
20499
20539
  return i.__generator(this, function(J) {
@@ -20507,7 +20547,7 @@ var backOff_1 = backoff.backOff = backOff, BackOff = (
20507
20547
  case 2:
20508
20548
  _ = J.sent(), E = _.pc, F = _.dc, P = !1, J.label = 3;
20509
20549
  case 3:
20510
- return J.trys.push([3, , 10, 11]), T = w, w && (T = i.__assign({}, w), w.accessToken || (T.authEntity = (C = w?.webrtcOptions) === null || C === void 0 ? void 0 : C.signalingAuthEntity, T.authEntity || (T.externalAuthAddress ? T.authEntity = (q = w.externalAuthAddress) === null || q === void 0 ? void 0 : q.replace(/^(.*:\/\/)/, "") : T.authEntity = h.replace(/^(.*:\/\/)/, "")), T.credentials = (W = w?.webrtcOptions) === null || W === void 0 ? void 0 : W.signalingCredentials, T.accessToken = (z = w?.webrtcOptions) === null || z === void 0 ? void 0 : z.signalingAccessToken), T.externalAuthAddress = (U = w?.webrtcOptions) === null || U === void 0 ? void 0 : U.signalingExternalAuthAddress, T.externalAuthToEntity = (I = w?.webrtcOptions) === null || I === void 0 ? void 0 : I.signalingExternalAuthToEntity), [4, v(h, T)];
20550
+ return J.trys.push([3, , 10, 11]), T = w, w && (T = i.__assign({}, w), w.accessToken || (T.authEntity = (C = w?.webrtcOptions) === null || C === void 0 ? void 0 : C.signalingAuthEntity, T.authEntity || (T.externalAuthAddress ? T.authEntity = (q = w.externalAuthAddress) === null || q === void 0 ? void 0 : q.replace(/^(.*:\/\/)/, "") : T.authEntity = h.replace(/^(.*:\/\/)/, "")), T.credentials = (W = w?.webrtcOptions) === null || W === void 0 ? void 0 : W.signalingCredentials, T.accessToken = (x = w?.webrtcOptions) === null || x === void 0 ? void 0 : x.signalingAccessToken), T.externalAuthAddress = (U = w?.webrtcOptions) === null || U === void 0 ? void 0 : U.signalingExternalAuthAddress, T.externalAuthToEntity = (I = w?.webrtcOptions) === null || I === void 0 ? void 0 : I.signalingExternalAuthToEntity), [4, v(h, T)];
20511
20551
  case 4:
20512
20552
  return j = J.sent(), A = u.grpc.client(m.SignalingService.Call, { host: h, transport: j }), D = "", B = !1, G = function(L) {
20513
20553
  if (!B) {
@@ -20598,7 +20638,7 @@ var backOff_1 = backoff.backOff = backOff, BackOff = (
20598
20638
  case 8:
20599
20639
  return J.sent(), [4, ue.ready];
20600
20640
  case 9:
20601
- return J.sent(), re = !0, V(), w?.externalAuthAddress || (x = w?.credentials) === null || x === void 0 || x.type, P = !0, [2, { transportFactory: ue.transportFactory(), peerConnection: E }];
20641
+ return J.sent(), re = !0, V(), w?.externalAuthAddress || (z = w?.credentials) === null || z === void 0 || z.type, P = !0, [2, { transportFactory: ue.transportFactory(), peerConnection: E }];
20602
20642
  case 10:
20603
20643
  return P || E.close(), [7];
20604
20644
  case 11:
@@ -20702,7 +20742,7 @@ var backOff_1 = backoff.backOff = backOff, BackOff = (
20702
20742
  });
20703
20743
  };
20704
20744
  }, 655: (t, e, s) => {
20705
- s.r(e), s.d(e, { __assign: () => g, __asyncDelegator: () => w, __asyncGenerator: () => O, __asyncValues: () => C, __await: () => h, __awaiter: () => l, __classPrivateFieldGet: () => I, __classPrivateFieldIn: () => k, __classPrivateFieldSet: () => x, __createBinding: () => m, __decorate: () => o, __exportStar: () => d, __extends: () => u, __generator: () => c, __importDefault: () => U, __importStar: () => z, __makeTemplateObject: () => q, __metadata: () => n, __param: () => r, __read: () => y, __rest: () => p, __spread: () => f, __spreadArray: () => M, __spreadArrays: () => b, __values: () => v });
20745
+ s.r(e), s.d(e, { __assign: () => g, __asyncDelegator: () => w, __asyncGenerator: () => O, __asyncValues: () => C, __await: () => h, __awaiter: () => l, __classPrivateFieldGet: () => I, __classPrivateFieldIn: () => k, __classPrivateFieldSet: () => z, __createBinding: () => m, __decorate: () => o, __exportStar: () => d, __extends: () => u, __generator: () => c, __importDefault: () => U, __importStar: () => x, __makeTemplateObject: () => q, __metadata: () => n, __param: () => r, __read: () => y, __rest: () => p, __spread: () => f, __spreadArray: () => M, __spreadArrays: () => b, __values: () => v });
20706
20746
  var i = function(S, R) {
20707
20747
  return i = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(_, E) {
20708
20748
  _.__proto__ = E;
@@ -20983,7 +21023,7 @@ var backOff_1 = backoff.backOff = backOff, BackOff = (
20983
21023
  } : function(S, R) {
20984
21024
  S.default = R;
20985
21025
  };
20986
- function z(S) {
21026
+ function x(S) {
20987
21027
  if (S && S.__esModule)
20988
21028
  return S;
20989
21029
  var R = {};
@@ -21002,7 +21042,7 @@ var backOff_1 = backoff.backOff = backOff, BackOff = (
21002
21042
  throw new TypeError("Cannot read private member from an object whose class did not declare it");
21003
21043
  return _ === "m" ? E : _ === "a" ? E.call(S) : E ? E.value : R.get(S);
21004
21044
  }
21005
- function x(S, R, _, E, F) {
21045
+ function z(S, R, _, E, F) {
21006
21046
  if (E === "m")
21007
21047
  throw new TypeError("Private method is not writable");
21008
21048
  if (E === "a" && !F)
@@ -23220,13 +23260,13 @@ var grpcWebClient_umdExports = {}, grpcWebClient_umd = {
23220
23260
  for (; ; ) {
23221
23261
  if (!d(this.buffer, this.position, 5))
23222
23262
  return O;
23223
- var z = v(this.buffer, this.position, this.position + 5), U = new DataView(z.buffer, z.byteOffset, z.byteLength), I = m(U);
23263
+ var x = v(this.buffer, this.position, this.position + 5), U = new DataView(x.buffer, x.byteOffset, x.byteLength), I = m(U);
23224
23264
  if (!d(this.buffer, this.position, 5 + I))
23225
23265
  return O;
23226
- var x = v(this.buffer, this.position + 5, this.position + 5 + I);
23266
+ var z = v(this.buffer, this.position + 5, this.position + 5 + I);
23227
23267
  if (this.position += 5 + I, c(U))
23228
- return O.push({ chunkType: o.TRAILERS, trailers: (h = x, new r.Metadata(l(h))) }), O;
23229
- O.push({ chunkType: o.MESSAGE, data: x });
23268
+ return O.push({ chunkType: o.TRAILERS, trailers: (h = z, new r.Metadata(l(h))) }), O;
23269
+ O.push({ chunkType: o.MESSAGE, data: z });
23230
23270
  }
23231
23271
  }, f;
23232
23272
  }();
@@ -23794,6 +23834,12 @@ const promisify = (t, e) => new Promise((s, i) => {
23794
23834
  return e.setObstaclesList(
23795
23835
  t.obstaclesList.map((s) => encodeGeometriesInFrame(s))
23796
23836
  ), e.setTransformsList(t.transformsList.map((s) => encodeTransform(s))), e;
23837
+ }, encodeGeoPoint = (t) => {
23838
+ const e = new common_pb.GeoPoint();
23839
+ return e.setLatitude(t.latitude), e.setLongitude(t.longitude), e;
23840
+ }, encodeGeoObstacle = (t) => {
23841
+ const e = new common_pb.GeoObstacle();
23842
+ return t.location && e.setLocation(encodeGeoPoint(t.location)), e.setGeometriesList(t.geometriesList.map((s) => encodeGeometry(s))), e;
23797
23843
  };
23798
23844
  var arm_pb = {};
23799
23845
  (function(t) {
@@ -39720,7 +39766,7 @@ class SessionTransport {
39720
39766
  this.transport.cancel();
39721
39767
  }
39722
39768
  }
39723
- const timeoutBlob = new Blob(
39769
+ const timeoutBlob$1 = new Blob(
39724
39770
  [
39725
39771
  `self.onmessage = function(e) {
39726
39772
  setTimeout(() => self.postMessage(""), e.data);
@@ -39778,7 +39824,7 @@ class SessionManager {
39778
39824
  );
39779
39825
  };
39780
39826
  if (this.backgroundHeartbeat && window.Worker) {
39781
- const i = window.URL.createObjectURL(timeoutBlob);
39827
+ const i = window.URL.createObjectURL(timeoutBlob$1);
39782
39828
  e = new Worker(i), URL.revokeObjectURL(i), e.onmessage = () => {
39783
39829
  s();
39784
39830
  };
@@ -39832,10 +39878,80 @@ class SessionManager {
39832
39878
  }
39833
39879
  }
39834
39880
  }
39881
+ const timeoutBlob = new Blob(
39882
+ [
39883
+ `self.onmessage = function(e) {
39884
+ setTimeout(() => self.postMessage(""), e.data);
39885
+ };`
39886
+ ],
39887
+ { type: "text/javascript" }
39888
+ );
39889
+ class GRPCConnectionManager {
39890
+ innerTransportFactory;
39891
+ client;
39892
+ heartbeatIntervalMs;
39893
+ connecting;
39894
+ connectResolve;
39895
+ connectReject;
39896
+ constructor(e, s) {
39897
+ this.innerTransportFactory = s, this.client = new RobotServiceClient_1(e, {
39898
+ transport: this.innerTransportFactory
39899
+ });
39900
+ }
39901
+ heartbeat() {
39902
+ let e;
39903
+ const s = () => {
39904
+ const i = new robot_pb.GetOperationsRequest();
39905
+ this.client.getOperations(
39906
+ i,
39907
+ new grpcWebClient_umdExports.grpc.Metadata(),
39908
+ (u, g) => {
39909
+ if (u) {
39910
+ console.debug(u, g), events.emit(DISCONNECTED, {});
39911
+ return;
39912
+ }
39913
+ e ? e.postMessage(this.heartbeatIntervalMs) : setTimeout(() => s(), this.heartbeatIntervalMs);
39914
+ }
39915
+ );
39916
+ };
39917
+ if (window.Worker) {
39918
+ const i = window.URL.createObjectURL(timeoutBlob);
39919
+ e = new Worker(i), URL.revokeObjectURL(i), e.onmessage = () => {
39920
+ s();
39921
+ };
39922
+ }
39923
+ s();
39924
+ }
39925
+ async start() {
39926
+ this.connecting && await this.connecting, this.connecting = new Promise((s, i) => {
39927
+ this.connectResolve = s, this.connectReject = i;
39928
+ });
39929
+ const e = new robot_pb.GetOperationsRequest();
39930
+ this.client.getOperations(
39931
+ e,
39932
+ new grpcWebClient_umdExports.grpc.Metadata(),
39933
+ (s, i) => {
39934
+ if (s) {
39935
+ this.connectReject?.(s), console.debug("failed to connect");
39936
+ return;
39937
+ }
39938
+ this.connectResolve?.();
39939
+ }
39940
+ );
39941
+ try {
39942
+ await this.connecting;
39943
+ } finally {
39944
+ this.connecting = void 0;
39945
+ }
39946
+ this.heartbeat();
39947
+ }
39948
+ }
39835
39949
  class RobotClient extends EventDispatcher {
39836
39950
  serviceHost;
39837
39951
  webrtcOptions;
39952
+ directOptions;
39838
39953
  sessionOptions;
39954
+ gRPCConnectionManager;
39839
39955
  sessionManager;
39840
39956
  peerConn;
39841
39957
  transportFactory;
@@ -39860,39 +39976,55 @@ class RobotClient extends EventDispatcher {
39860
39976
  sensorsServiceClient;
39861
39977
  servoServiceClient;
39862
39978
  slamServiceClient;
39863
- constructor(e, s, i) {
39864
- super(), this.serviceHost = e, this.webrtcOptions = s, this.sessionOptions = i, this.sessionManager = new SessionManager(
39979
+ constructor(e, s, i, u) {
39980
+ super(), this.serviceHost = e, this.webrtcOptions = s, this.directOptions = u, this.sessionOptions = i, this.gRPCConnectionManager = new GRPCConnectionManager(
39981
+ e,
39982
+ (g) => {
39983
+ if (!this.transportFactory)
39984
+ throw new Error(RobotClient.notConnectedYetStr);
39985
+ return this.transportFactory(g);
39986
+ }
39987
+ ), this.sessionManager = new SessionManager(
39865
39988
  e,
39866
- (u) => {
39989
+ (g) => {
39867
39990
  if (!this.transportFactory)
39868
39991
  throw new Error(RobotClient.notConnectedYetStr);
39869
- return this.transportFactory(u);
39992
+ return this.transportFactory(g);
39870
39993
  }
39871
39994
  ), events.on(RECONNECTED, () => {
39872
39995
  this.emit(RECONNECTED, {});
39873
39996
  }), events.on(DISCONNECTED, () => {
39874
- if (this.emit(DISCONNECTED, {}), this.webrtcOptions?.noReconnect)
39997
+ if (this.emit(DISCONNECTED, {}), this.noReconnect)
39875
39998
  return;
39876
- let u = 0;
39999
+ let g = 0;
39877
40000
  console.debug("connection closed, will try to reconnect"), backOff_1(
39878
40001
  () => this.connect().then(
39879
40002
  () => {
39880
40003
  console.debug("reconnected successfully!"), events.emit(RECONNECTED, {});
39881
40004
  },
39882
- (g) => {
39883
- throw console.debug(`failed to reconnect - retries count: ${u}`), u += 1, u === this.webrtcOptions?.reconnectMaxAttempts && console.log(
39884
- `reached max attempts: ${this.webrtcOptions.reconnectMaxAttempts}`
39885
- ), g;
40005
+ (p) => {
40006
+ throw console.debug(`failed to reconnect - retries count: ${g}`), g += 1, g === this.reconnectMaxAttempts && console.debug(
40007
+ `reached max attempts: ${this.reconnectMaxAttempts}`
40008
+ ), p;
39886
40009
  }
39887
40010
  ),
39888
40011
  {
39889
40012
  // default values taken from `exponential-backoff` library
39890
- maxDelay: this.webrtcOptions?.reconnectMaxWait || Number.POSITIVE_INFINITY,
39891
- numOfAttempts: this.webrtcOptions?.reconnectMaxAttempts || 10
40013
+ maxDelay: this.reconnectMaxWait || Number.POSITIVE_INFINITY,
40014
+ numOfAttempts: this.reconnectMaxAttempts || 10
39892
40015
  }
39893
40016
  );
39894
40017
  });
39895
40018
  }
40019
+ get noReconnect() {
40020
+ return this.webrtcOptions?.noReconnect || this.directOptions?.noReconnect;
40021
+ }
40022
+ get reconnectMaxAttempts() {
40023
+ return this.webrtcOptions?.reconnectMaxAttempts || this.directOptions?.reconnectMaxAttempts;
40024
+ }
40025
+ get reconnectMaxWait() {
40026
+ return this.webrtcOptions?.reconnectMaxWait || this.directOptions?.reconnectMaxWait;
40027
+ }
39896
40028
  get sessionId() {
39897
40029
  return this.sessionManager.sessionID;
39898
40030
  }
@@ -40037,7 +40169,7 @@ class RobotClient extends EventDispatcher {
40037
40169
  }), events.emit("track", o);
40038
40170
  };
40039
40171
  } else
40040
- this.transportFactory = await __webpack_exports__dialDirect(this.serviceHost, i);
40172
+ this.transportFactory = await __webpack_exports__dialDirect(this.serviceHost, i), await this.gRPCConnectionManager.start();
40041
40173
  const g = { transport: this.sessionOptions?.disabled ? this.transportFactory : this.sessionManager.transportFactory };
40042
40174
  this.robotServiceClient = new RobotServiceClient_1(
40043
40175
  this.serviceHost,
@@ -40176,11 +40308,16 @@ const isPosInt = (t) => !!(t > 0 && Number.isInteger(t)), isLocalConnection = (t
40176
40308
  throw new Error(
40177
40309
  `cannot dial "${t.host}" directly, please use a local url instead.`
40178
40310
  );
40179
- let e;
40180
- t.disableSessions && (e = { disabled: !0 });
40181
- const s = new RobotClient(t.host, void 0, e);
40182
- let i;
40183
- return t.credential && (i = t.credential), await s.connect(t.authEntity, i), console.debug("connected via gRPC"), s;
40311
+ const e = {
40312
+ noReconnect: t.noReconnect,
40313
+ reconnectMaxWait: t.reconnectMaxWait,
40314
+ reconnectMaxAttempts: t.reconnectMaxAttempts
40315
+ };
40316
+ let s;
40317
+ t.disableSessions && (s = { disabled: !0 });
40318
+ const i = new RobotClient(t.host, void 0, s, e);
40319
+ let u;
40320
+ return t.credential && (u = t.credential), await i.connect(t.authEntity, u), console.debug("connected via gRPC"), i;
40184
40321
  }, dialWebRTC = async (t) => {
40185
40322
  console.debug("dialing via WebRTC...");
40186
40323
  const e = t.host, { signalingAddress: s } = t, u = { iceServers: t.iceServers ?? [] }, g = {
@@ -40202,21 +40339,20 @@ const isPosInt = (t) => !!(t > 0 && Number.isInteger(t)), isLocalConnection = (t
40202
40339
  return typeof e.signalingAddress != "string" ? !1 : !e.iceServers || Array.isArray(e.iceServers);
40203
40340
  }, createRobotClient = async (t) => {
40204
40341
  let e;
40205
- if (isDialWebRTCConf(t)) {
40206
- if (t.reconnectMaxAttempts && !isPosInt(t.reconnectMaxAttempts))
40207
- throw new Error(
40208
- `Value of max reconnect attempts (${t.reconnectMaxAttempts}) should be a positive integer`
40209
- );
40210
- if (t.reconnectMaxWait && !isPosInt(t.reconnectMaxWait))
40211
- throw new Error(
40212
- `Value of max reconnect wait (${t.reconnectMaxWait}) should be a positive integer`
40213
- );
40342
+ if (t.reconnectMaxAttempts && !isPosInt(t.reconnectMaxAttempts))
40343
+ throw new Error(
40344
+ `Value of max reconnect attempts (${t.reconnectMaxAttempts}) should be a positive integer`
40345
+ );
40346
+ if (t.reconnectMaxWait && !isPosInt(t.reconnectMaxWait))
40347
+ throw new Error(
40348
+ `Value of max reconnect wait (${t.reconnectMaxWait}) should be a positive integer`
40349
+ );
40350
+ if (isDialWebRTCConf(t))
40214
40351
  try {
40215
40352
  e = await dialWebRTC(t);
40216
40353
  } catch {
40217
40354
  console.debug("failed to connect via WebRTC...");
40218
40355
  }
40219
- }
40220
40356
  if (!e)
40221
40357
  try {
40222
40358
  e = await dialDirect(t);
@@ -43033,6 +43169,10 @@ class MotionClient {
43033
43169
  p
43034
43170
  )).getSuccess();
43035
43171
  }
43172
+ async moveOnGlobe(e, s, i, u, g, p, o, r = {}) {
43173
+ const { service: n } = this, l = new motion_pb.MoveOnGlobeRequest();
43174
+ return l.setDestination(encodeGeoPoint(e)), l.setComponentName(encodeResourceName(s)), l.setMovementSensorName(encodeResourceName(i)), u && l.setHeading(u), g && l.setObstaclesList(g.map((m) => encodeGeoObstacle(m))), p && l.setLinearMetersPerSec(p), o && l.setAngularDegPerSec(o), l.setExtra(struct_pb.Struct.fromJavaScript(r)), this.options.requestLogger?.(l), (await promisify(n.moveOnGlobe.bind(n), l)).getSuccess();
43175
+ }
43036
43176
  async moveSingleComponent(e, s, i, u = {}) {
43037
43177
  const { service: g } = this, p = new motion_pb.MoveSingleComponentRequest();
43038
43178
  return p.setName(this.name), p.setDestination(encodePoseInFrame(e)), p.setComponentName(encodeResourceName(s)), i !== void 0 && p.setWorldState(encodeWorldState(i)), p.setExtra(struct_pb.Struct.fromJavaScript(u)), this.options.requestLogger?.(p), (await promisify(g.moveSingleComponent.bind(g), p)).getSuccess();
@@ -43253,6 +43393,65 @@ class DataManagerClient {
43253
43393
  );
43254
43394
  }
43255
43395
  }
43396
+ class NavigationClient {
43397
+ client;
43398
+ name;
43399
+ options;
43400
+ constructor(e, s, i = {}) {
43401
+ this.client = e.createServiceClient(NavigationServiceClient_1), this.name = s, this.options = i;
43402
+ }
43403
+ get service() {
43404
+ return this.client;
43405
+ }
43406
+ async getMode(e = {}) {
43407
+ const { service: s } = this, i = new navigation_pb.GetModeRequest();
43408
+ return i.setName(this.name), i.setExtra(struct_pb.Struct.fromJavaScript(e)), this.options.requestLogger?.(i), (await promisify(
43409
+ s.getMode.bind(s),
43410
+ i
43411
+ )).getMode();
43412
+ }
43413
+ async setMode(e, s = {}) {
43414
+ const { service: i } = this, u = new navigation_pb.SetModeRequest();
43415
+ u.setName(this.name), u.setMode(e), u.setExtra(struct_pb.Struct.fromJavaScript(s)), this.options.requestLogger?.(u), await promisify(
43416
+ i.setMode.bind(i),
43417
+ u
43418
+ );
43419
+ }
43420
+ async getLocation(e = {}) {
43421
+ const { service: s } = this, i = new navigation_pb.GetLocationRequest();
43422
+ i.setName(this.name), i.setExtra(struct_pb.Struct.fromJavaScript(e)), this.options.requestLogger?.(i);
43423
+ const g = (await promisify(s.getLocation.bind(s), i)).getLocation();
43424
+ if (!g)
43425
+ throw new Error("no location");
43426
+ return g.toObject();
43427
+ }
43428
+ async getWayPoints(e = {}) {
43429
+ const { service: s } = this, i = new navigation_pb.GetWaypointsRequest();
43430
+ return i.setName(this.name), i.setExtra(struct_pb.Struct.fromJavaScript(e)), this.options.requestLogger?.(i), (await promisify(s.getWaypoints.bind(s), i)).getWaypointsList().map((g) => g.toObject());
43431
+ }
43432
+ async addWayPoint(e, s = {}) {
43433
+ const { service: i } = this, u = new navigation_pb.AddWaypointRequest();
43434
+ u.setName(this.name), u.setLocation(encodeGeoPoint(e)), u.setExtra(struct_pb.Struct.fromJavaScript(s)), this.options.requestLogger?.(u), await promisify(
43435
+ i.addWaypoint.bind(i),
43436
+ u
43437
+ );
43438
+ }
43439
+ async removeWayPoint(e, s = {}) {
43440
+ const { service: i } = this, u = new navigation_pb.RemoveWaypointRequest();
43441
+ u.setName(this.name), u.setId(e), u.setExtra(struct_pb.Struct.fromJavaScript(s)), this.options.requestLogger?.(u), await promisify(
43442
+ i.removeWaypoint.bind(i),
43443
+ u
43444
+ );
43445
+ }
43446
+ async getObstacles(e = {}) {
43447
+ const { service: s } = this, i = new navigation_pb.GetObstaclesRequest();
43448
+ return i.setName(this.name), i.setExtra(struct_pb.Struct.fromJavaScript(e)), this.options.requestLogger?.(i), (await promisify(s.getObstacles.bind(s), i)).getObstaclesList().map((g) => g.toObject());
43449
+ }
43450
+ async doCommand(e) {
43451
+ const { service: s } = this;
43452
+ return doCommandFromClient(s, this.name, e, this.options);
43453
+ }
43454
+ }
43256
43455
  class ServoClient {
43257
43456
  client;
43258
43457
  name;
@@ -43293,7 +43492,7 @@ class ServoClient {
43293
43492
  return doCommandFromClient(s, this.name, e, this.options);
43294
43493
  }
43295
43494
  }
43296
- const version = "0.2.4-rc.0";
43495
+ const version = "0.2.5-next.0";
43297
43496
  export {
43298
43497
  ArmClient,
43299
43498
  BaseClient,
@@ -43308,6 +43507,7 @@ export {
43308
43507
  MotionClient,
43309
43508
  MotorClient,
43310
43509
  MovementSensorClient,
43510
+ NavigationClient,
43311
43511
  RobotClient,
43312
43512
  SensorClient,
43313
43513
  ServoClient,