@acrobits/ipc-sdk 0.11.2-alpha.6 → 0.11.2-alpha.8

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/lib/ipc-sdk.js CHANGED
@@ -38,8 +38,8 @@ function $(s, t) {
38
38
  try {
39
39
  for (; (t === void 0 || t-- > 0) && !(n = r.next()).done; )
40
40
  i.push(n.value);
41
- } catch (c) {
42
- o = { error: c };
41
+ } catch (a) {
42
+ o = { error: a };
43
43
  } finally {
44
44
  try {
45
45
  n && !n.done && (e = r.return) && e.call(r);
@@ -92,15 +92,15 @@ var x = function() {
92
92
  if (o)
93
93
  if (this._parentage = null, Array.isArray(o))
94
94
  try {
95
- for (var c = Q(o), a = c.next(); !a.done; a = c.next()) {
96
- var u = a.value;
97
- u.remove(this);
95
+ for (var a = Q(o), c = a.next(); !c.done; c = a.next()) {
96
+ var l = c.value;
97
+ l.remove(this);
98
98
  }
99
99
  } catch (v) {
100
100
  t = { error: v };
101
101
  } finally {
102
102
  try {
103
- a && !a.done && (e = c.return) && e.call(c);
103
+ c && !c.done && (e = a.return) && e.call(a);
104
104
  } finally {
105
105
  if (t)
106
106
  throw t.error;
@@ -115,11 +115,11 @@ var x = function() {
115
115
  } catch (v) {
116
116
  i = v instanceof V ? v.errors : [v];
117
117
  }
118
- var l = this._finalizers;
119
- if (l) {
118
+ var u = this._finalizers;
119
+ if (u) {
120
120
  this._finalizers = null;
121
121
  try {
122
- for (var b = Q(l), p = b.next(); !p.done; p = b.next()) {
122
+ for (var b = Q(u), p = b.next(); !p.done; p = b.next()) {
123
123
  var F = p.value;
124
124
  try {
125
125
  se(F);
@@ -282,13 +282,13 @@ var Oe = function() {
282
282
  complete: n ?? void 0
283
283
  };
284
284
  else {
285
- var c;
286
- i && we.useDeprecatedNextContext ? (c = Object.create(e), c.unsubscribe = function() {
285
+ var a;
286
+ i && we.useDeprecatedNextContext ? (a = Object.create(e), a.unsubscribe = function() {
287
287
  return i.unsubscribe();
288
288
  }, o = {
289
- next: e.next && H(e.next, c),
290
- error: e.error && H(e.error, c),
291
- complete: e.complete && H(e.complete, c)
289
+ next: e.next && H(e.next, a),
290
+ error: e.error && H(e.error, a),
291
+ complete: e.complete && H(e.complete, a)
292
292
  }) : o = e;
293
293
  }
294
294
  return i.destination = new Oe(o), i;
@@ -329,8 +329,8 @@ var G = function() {
329
329
  }, s.prototype.subscribe = function(t, e, r) {
330
330
  var n = this, i = Ve(t) ? t : new N(t, e, r);
331
331
  return O(function() {
332
- var o = n, c = o.operator, a = o.source;
333
- i.add(c ? c.call(i, a) : a ? n._subscribe(i) : n._trySubscribe(i));
332
+ var o = n, a = o.operator, c = o.source;
333
+ i.add(a ? a.call(i, c) : c ? n._subscribe(i) : n._trySubscribe(i));
334
334
  }), i;
335
335
  }, s.prototype._trySubscribe = function(t) {
336
336
  try {
@@ -342,11 +342,11 @@ var G = function() {
342
342
  var r = this;
343
343
  return e = ie(e), new e(function(n, i) {
344
344
  var o = new N({
345
- next: function(c) {
345
+ next: function(a) {
346
346
  try {
347
- t(c);
348
- } catch (a) {
349
- i(a), o.unsubscribe();
347
+ t(a);
348
+ } catch (c) {
349
+ i(c), o.unsubscribe();
350
350
  }
351
351
  },
352
352
  error: i,
@@ -410,31 +410,31 @@ function Me(s, t, e, r, n) {
410
410
  }
411
411
  var je = function(s) {
412
412
  U(t, s);
413
- function t(e, r, n, i, o, c) {
414
- var a = s.call(this, e) || this;
415
- return a.onFinalize = o, a.shouldUnsubscribe = c, a._next = r ? function(u) {
413
+ function t(e, r, n, i, o, a) {
414
+ var c = s.call(this, e) || this;
415
+ return c.onFinalize = o, c.shouldUnsubscribe = a, c._next = r ? function(l) {
416
416
  try {
417
- r(u);
417
+ r(l);
418
418
  } catch (h) {
419
419
  e.error(h);
420
420
  }
421
- } : s.prototype._next, a._error = i ? function(u) {
421
+ } : s.prototype._next, c._error = i ? function(l) {
422
422
  try {
423
- i(u);
423
+ i(l);
424
424
  } catch (h) {
425
425
  e.error(h);
426
426
  } finally {
427
427
  this.unsubscribe();
428
428
  }
429
- } : s.prototype._error, a._complete = n ? function() {
429
+ } : s.prototype._error, c._complete = n ? function() {
430
430
  try {
431
431
  n();
432
- } catch (u) {
433
- e.error(u);
432
+ } catch (l) {
433
+ e.error(l);
434
434
  } finally {
435
435
  this.unsubscribe();
436
436
  }
437
- } : s.prototype._complete, a;
437
+ } : s.prototype._complete, c;
438
438
  }
439
439
  return t.prototype.unsubscribe = function() {
440
440
  var e;
@@ -466,15 +466,15 @@ var je = function(s) {
466
466
  if (r._throwIfClosed(), !r.isStopped) {
467
467
  r.currentObservers || (r.currentObservers = Array.from(r.observers));
468
468
  try {
469
- for (var o = Q(r.currentObservers), c = o.next(); !c.done; c = o.next()) {
470
- var a = c.value;
471
- a.next(e);
469
+ for (var o = Q(r.currentObservers), a = o.next(); !a.done; a = o.next()) {
470
+ var c = a.value;
471
+ c.next(e);
472
472
  }
473
- } catch (u) {
474
- n = { error: u };
473
+ } catch (l) {
474
+ n = { error: l };
475
475
  } finally {
476
476
  try {
477
- c && !c.done && (i = o.return) && i.call(o);
477
+ a && !a.done && (i = o.return) && i.call(o);
478
478
  } finally {
479
479
  if (n)
480
480
  throw n.error;
@@ -514,9 +514,9 @@ var je = function(s) {
514
514
  }, t.prototype._subscribe = function(e) {
515
515
  return this._throwIfClosed(), this._checkFinalizedStatuses(e), this._innerSubscribe(e);
516
516
  }, t.prototype._innerSubscribe = function(e) {
517
- var r = this, n = this, i = n.hasError, o = n.isStopped, c = n.observers;
518
- return i || o ? ve : (this.currentObservers = null, c.push(e), new x(function() {
519
- r.currentObservers = null, D(c, e);
517
+ var r = this, n = this, i = n.hasError, o = n.isStopped, a = n.observers;
518
+ return i || o ? ve : (this.currentObservers = null, a.push(e), new x(function() {
519
+ r.currentObservers = null, D(a, e);
520
520
  }));
521
521
  }, t.prototype._checkFinalizedStatuses = function(e) {
522
522
  var r = this, n = r.hasError, i = r.thrownError, o = r.isStopped;
@@ -696,19 +696,19 @@ function et(s, t, e) {
696
696
  return r ? Ee(function(n, i) {
697
697
  var o;
698
698
  (o = r.subscribe) === null || o === void 0 || o.call(r);
699
- var c = !0;
700
- n.subscribe(Me(i, function(a) {
701
- var u;
702
- (u = r.next) === null || u === void 0 || u.call(r, a), i.next(a);
699
+ var a = !0;
700
+ n.subscribe(Me(i, function(c) {
701
+ var l;
702
+ (l = r.next) === null || l === void 0 || l.call(r, c), i.next(c);
703
703
  }, function() {
704
- var a;
705
- c = !1, (a = r.complete) === null || a === void 0 || a.call(r), i.complete();
706
- }, function(a) {
707
- var u;
708
- c = !1, (u = r.error) === null || u === void 0 || u.call(r, a), i.error(a);
704
+ var c;
705
+ a = !1, (c = r.complete) === null || c === void 0 || c.call(r), i.complete();
706
+ }, function(c) {
707
+ var l;
708
+ a = !1, (l = r.error) === null || l === void 0 || l.call(r, c), i.error(c);
709
709
  }, function() {
710
- var a, u;
711
- c && ((a = r.unsubscribe) === null || a === void 0 || a.call(r)), (u = r.finalize) === null || u === void 0 || u.call(r);
710
+ var c, l;
711
+ a && ((c = r.unsubscribe) === null || c === void 0 || c.call(r)), (l = r.finalize) === null || l === void 0 || l.call(r);
712
712
  }));
713
713
  }) : Ce;
714
714
  }
@@ -718,7 +718,7 @@ class d extends Error {
718
718
  super(`Incorrect context (${t}). Cannot perform the requested operation.`), I(this, "context"), this.context = t;
719
719
  }
720
720
  }
721
- class y extends Error {
721
+ class m extends Error {
722
722
  constructor(t, e, r) {
723
723
  super(`Invalid parameter (${t}). ${r}`), this.param = t, this.value = e, this.reason = r;
724
724
  }
@@ -735,12 +735,12 @@ class st extends Error {
735
735
  super(`Invalid version format: ${t}`);
736
736
  }
737
737
  }
738
- class ue extends Error {
738
+ class le extends Error {
739
739
  constructor(t) {
740
740
  super(`${t} needs to be initialized before it can be used.`);
741
741
  }
742
742
  }
743
- class le extends Error {
743
+ class ue extends Error {
744
744
  constructor(t, e) {
745
745
  let r = `Unsupported Protocol ${Array.isArray(t) ? "versions" : "version"}: (${t}).`;
746
746
  e && (r += ` Minimum version supported is ${e}.`), super(r), this.version = t;
@@ -802,8 +802,8 @@ function J(s, t) {
802
802
  try {
803
803
  for (; (t === void 0 || t-- > 0) && !(n = r.next()).done; )
804
804
  i.push(n.value);
805
- } catch (c) {
806
- o = { error: c };
805
+ } catch (a) {
806
+ o = { error: a };
807
807
  } finally {
808
808
  try {
809
809
  n && !n.done && (e = r.return) && e.call(r);
@@ -853,15 +853,15 @@ var te = function() {
853
853
  if (o)
854
854
  if (this._parentage = null, Array.isArray(o))
855
855
  try {
856
- for (var c = he(o), a = c.next(); !a.done; a = c.next()) {
857
- var u = a.value;
858
- u.remove(this);
856
+ for (var a = he(o), c = a.next(); !c.done; c = a.next()) {
857
+ var l = c.value;
858
+ l.remove(this);
859
859
  }
860
860
  } catch (v) {
861
861
  t = { error: v };
862
862
  } finally {
863
863
  try {
864
- a && !a.done && (e = c.return) && e.call(c);
864
+ c && !c.done && (e = a.return) && e.call(a);
865
865
  } finally {
866
866
  if (t)
867
867
  throw t.error;
@@ -876,11 +876,11 @@ var te = function() {
876
876
  } catch (v) {
877
877
  i = v instanceof j ? v.errors : [v];
878
878
  }
879
- var l = this._finalizers;
880
- if (l) {
879
+ var u = this._finalizers;
880
+ if (u) {
881
881
  this._finalizers = null;
882
882
  try {
883
- for (var b = he(l), p = b.next(); !p.done; p = b.next()) {
883
+ for (var b = he(u), p = b.next(); !p.done; p = b.next()) {
884
884
  var F = p.value;
885
885
  try {
886
886
  pe(F);
@@ -997,11 +997,11 @@ var re = function(s) {
997
997
  this.unsubscribe();
998
998
  }
999
999
  }, t;
1000
- }(te), ut = Function.prototype.bind;
1000
+ }(te), lt = Function.prototype.bind;
1001
1001
  function q(s, t) {
1002
- return ut.call(s, t);
1002
+ return lt.call(s, t);
1003
1003
  }
1004
- var lt = function() {
1004
+ var ut = function() {
1005
1005
  function s(t) {
1006
1006
  this.partialObserver = t;
1007
1007
  }
@@ -1043,16 +1043,16 @@ var lt = function() {
1043
1043
  complete: n ?? void 0
1044
1044
  };
1045
1045
  else {
1046
- var c;
1047
- i && Te.useDeprecatedNextContext ? (c = Object.create(e), c.unsubscribe = function() {
1046
+ var a;
1047
+ i && Te.useDeprecatedNextContext ? (a = Object.create(e), a.unsubscribe = function() {
1048
1048
  return i.unsubscribe();
1049
1049
  }, o = {
1050
- next: e.next && q(e.next, c),
1051
- error: e.error && q(e.error, c),
1052
- complete: e.complete && q(e.complete, c)
1050
+ next: e.next && q(e.next, a),
1051
+ error: e.error && q(e.error, a),
1052
+ complete: e.complete && q(e.complete, a)
1053
1053
  }) : o = e;
1054
1054
  }
1055
- return i.destination = new lt(o), i;
1055
+ return i.destination = new ut(o), i;
1056
1056
  }
1057
1057
  return t;
1058
1058
  }(re);
@@ -1088,10 +1088,10 @@ var gt = function() {
1088
1088
  var e = new s();
1089
1089
  return e.source = this, e.operator = t, e;
1090
1090
  }, s.prototype.subscribe = function(t, e, r) {
1091
- var n = this, i = yt(t) ? t : new K(t, e, r);
1091
+ var n = this, i = mt(t) ? t : new K(t, e, r);
1092
1092
  return at(function() {
1093
- var o = n, c = o.operator, a = o.source;
1094
- i.add(c ? c.call(i, a) : a ? n._subscribe(i) : n._trySubscribe(i));
1093
+ var o = n, a = o.operator, c = o.source;
1094
+ i.add(a ? a.call(i, c) : c ? n._subscribe(i) : n._trySubscribe(i));
1095
1095
  }), i;
1096
1096
  }, s.prototype._trySubscribe = function(t) {
1097
1097
  try {
@@ -1103,11 +1103,11 @@ var gt = function() {
1103
1103
  var r = this;
1104
1104
  return e = ge(e), new e(function(n, i) {
1105
1105
  var o = new K({
1106
- next: function(c) {
1106
+ next: function(a) {
1107
1107
  try {
1108
- t(c);
1109
- } catch (a) {
1110
- i(a), o.unsubscribe();
1108
+ t(a);
1109
+ } catch (c) {
1110
+ i(c), o.unsubscribe();
1111
1111
  }
1112
1112
  },
1113
1113
  error: i,
@@ -1144,42 +1144,42 @@ function ge(s) {
1144
1144
  var t;
1145
1145
  return (t = s ?? Te.Promise) !== null && t !== void 0 ? t : Promise;
1146
1146
  }
1147
- function mt(s) {
1147
+ function yt(s) {
1148
1148
  return s && E(s.next) && E(s.error) && E(s.complete);
1149
1149
  }
1150
- function yt(s) {
1151
- return s && s instanceof re || mt(s) && Ue(s);
1150
+ function mt(s) {
1151
+ return s && s instanceof re || yt(s) && Ue(s);
1152
1152
  }
1153
1153
  function P(s, t, e, r, n) {
1154
1154
  return new vt(s, t, e, r, n);
1155
1155
  }
1156
1156
  var vt = function(s) {
1157
1157
  ee(t, s);
1158
- function t(e, r, n, i, o, c) {
1159
- var a = s.call(this, e) || this;
1160
- return a.onFinalize = o, a.shouldUnsubscribe = c, a._next = r ? function(u) {
1158
+ function t(e, r, n, i, o, a) {
1159
+ var c = s.call(this, e) || this;
1160
+ return c.onFinalize = o, c.shouldUnsubscribe = a, c._next = r ? function(l) {
1161
1161
  try {
1162
- r(u);
1162
+ r(l);
1163
1163
  } catch (h) {
1164
1164
  e.error(h);
1165
1165
  }
1166
- } : s.prototype._next, a._error = i ? function(u) {
1166
+ } : s.prototype._next, c._error = i ? function(l) {
1167
1167
  try {
1168
- i(u);
1168
+ i(l);
1169
1169
  } catch (h) {
1170
1170
  e.error(h);
1171
1171
  } finally {
1172
1172
  this.unsubscribe();
1173
1173
  }
1174
- } : s.prototype._error, a._complete = n ? function() {
1174
+ } : s.prototype._error, c._complete = n ? function() {
1175
1175
  try {
1176
1176
  n();
1177
- } catch (u) {
1178
- e.error(u);
1177
+ } catch (l) {
1178
+ e.error(l);
1179
1179
  } finally {
1180
1180
  this.unsubscribe();
1181
1181
  }
1182
- } : s.prototype._complete, a;
1182
+ } : s.prototype._complete, c;
1183
1183
  }
1184
1184
  return t.prototype.unsubscribe = function() {
1185
1185
  var e;
@@ -1210,7 +1210,7 @@ function w(s) {
1210
1210
  }));
1211
1211
  });
1212
1212
  }
1213
- function m(s, t) {
1213
+ function y(s, t) {
1214
1214
  return R(function(e, r) {
1215
1215
  var n = 0;
1216
1216
  e.subscribe(P(r, function(i) {
@@ -1232,19 +1232,19 @@ function g(s, t, e) {
1232
1232
  return r ? R(function(n, i) {
1233
1233
  var o;
1234
1234
  (o = r.subscribe) === null || o === void 0 || o.call(r);
1235
- var c = !0;
1236
- n.subscribe(P(i, function(a) {
1237
- var u;
1238
- (u = r.next) === null || u === void 0 || u.call(r, a), i.next(a);
1235
+ var a = !0;
1236
+ n.subscribe(P(i, function(c) {
1237
+ var l;
1238
+ (l = r.next) === null || l === void 0 || l.call(r, c), i.next(c);
1239
1239
  }, function() {
1240
- var a;
1241
- c = !1, (a = r.complete) === null || a === void 0 || a.call(r), i.complete();
1242
- }, function(a) {
1243
- var u;
1244
- c = !1, (u = r.error) === null || u === void 0 || u.call(r, a), i.error(a);
1240
+ var c;
1241
+ a = !1, (c = r.complete) === null || c === void 0 || c.call(r), i.complete();
1242
+ }, function(c) {
1243
+ var l;
1244
+ a = !1, (l = r.error) === null || l === void 0 || l.call(r, c), i.error(c);
1245
1245
  }, function() {
1246
- var a, u;
1247
- c && ((a = r.unsubscribe) === null || a === void 0 || a.call(r)), (u = r.finalize) === null || u === void 0 || u.call(r);
1246
+ var c, l;
1247
+ a && ((c = r.unsubscribe) === null || c === void 0 || c.call(r)), (l = r.finalize) === null || l === void 0 || l.call(r);
1248
1248
  }));
1249
1249
  }) : xe;
1250
1250
  }
@@ -1257,18 +1257,18 @@ function Ct(s) {
1257
1257
  }
1258
1258
  throw new st(s);
1259
1259
  }
1260
- function me(s) {
1260
+ function ye(s) {
1261
1261
  const t = Ct(s), [e, r] = t.split("."), [n, i] = [parseInt(e), parseInt(r)];
1262
1262
  return [n, i];
1263
1263
  }
1264
1264
  function Re(s, t) {
1265
- const [e, r] = me(s), [n, i] = me(t);
1265
+ const [e, r] = ye(s), [n, i] = ye(t);
1266
1266
  return e < n ? -1 : e > n ? 1 : r < i ? -1 : r > i ? 1 : 0;
1267
1267
  }
1268
1268
  function Et(s, t) {
1269
1269
  return Re(s, t) >= 0;
1270
1270
  }
1271
- const ye = "2.0";
1271
+ const me = "2.0";
1272
1272
  class Mt {
1273
1273
  /**
1274
1274
  * Create a new instance of the {@link IpcHelper | IPC Protocol Helper}.
@@ -1280,8 +1280,8 @@ class Mt {
1280
1280
  * @param logService - An instance of a logging service or utility
1281
1281
  */
1282
1282
  constructor(t, e) {
1283
- if (I(this, "negotiatedProtocolVersion"), I(this, "currentContext"), I(this, "incomingMessages$"), I(this, "inIframe", !1), I(this, "embeddedResult"), I(this, "iframePort1"), I(this, "iframePort2"), this.supportedVersions = t, this.logService = e, this.incomingMessages$ = new Ie(), this.supportedVersions = t.filter((r) => Et(r, ye)), !this.supportedVersions.length)
1284
- throw new le(t, ye);
1283
+ if (I(this, "negotiatedProtocolVersion"), I(this, "currentContext"), I(this, "incomingMessages$"), I(this, "inIframe", !1), I(this, "embeddedResult"), I(this, "iframePort1"), I(this, "iframePort2"), this.supportedVersions = t, this.logService = e, this.incomingMessages$ = new Ie(), this.supportedVersions = t.filter((r) => Et(r, me)), !this.supportedVersions.length)
1284
+ throw new ue(t, me);
1285
1285
  this.negotiatedProtocolVersion = this.supportedVersions[0], this.embeddedResult = null, this.iframePort2 = null;
1286
1286
  }
1287
1287
  get parent() {
@@ -1303,11 +1303,11 @@ class Mt {
1303
1303
  var t, e, r, n;
1304
1304
  if (this.inIframe) {
1305
1305
  if (!this.iframePort2)
1306
- throw new ue("port2");
1306
+ throw new le("port2");
1307
1307
  return this.iframePort2;
1308
1308
  } else {
1309
1309
  if (!((e = (t = window.Acrobits) == null ? void 0 : t.messageChannel) != null && e.port2))
1310
- throw new ue("port2");
1310
+ throw new le("port2");
1311
1311
  return (n = (r = window.Acrobits) == null ? void 0 : r.messageChannel) == null ? void 0 : n.port2;
1312
1312
  }
1313
1313
  }
@@ -1334,12 +1334,12 @@ class Mt {
1334
1334
  const t = "HELLO", e = this.createMessage(t);
1335
1335
  e.protocolVersions = this.supportedVersions, this.logCreated(t, e);
1336
1336
  const r = this.incomingMessages$.pipe(
1337
- m((n) => n.type === t && n.replyTo === e.id),
1337
+ y((n) => n.type === t && n.replyTo === e.id),
1338
1338
  f((n) => n),
1339
1339
  g(this.logReceived()),
1340
1340
  f((n) => {
1341
1341
  if (!this.supportedVersions.includes(n.protocolVersion))
1342
- throw new le(n.protocolVersion, this.supportedVersions[0]);
1342
+ throw new ue(n.protocolVersion, this.supportedVersions[0]);
1343
1343
  return n.displayName || (n.displayName = n.cloudUsername), n;
1344
1344
  }),
1345
1345
  g((n) => {
@@ -1366,7 +1366,7 @@ class Mt {
1366
1366
  const t = "TOKEN", e = this.createMessage(t);
1367
1367
  this.logCreated(t, e);
1368
1368
  const r = this.incomingMessages$.pipe(
1369
- m((n) => n.type === t && n.replyTo === e.id),
1369
+ y((n) => n.type === t && n.replyTo === e.id),
1370
1370
  f((n) => n),
1371
1371
  g(this.logReceived()),
1372
1372
  w(1)
@@ -1395,11 +1395,11 @@ class Mt {
1395
1395
  displayName: n,
1396
1396
  jwtToken: i,
1397
1397
  serverUrl: o,
1398
- region: c,
1399
- joinMicMuted: a,
1400
- joinWithoutCamera: u
1401
- } = t, h = "JOINING ROOM", l = this.createMessage(h, !1);
1402
- l.roomName = e, l.jwtToken = i, l.serverUrl = o, l.region = c, l.roomInvite = r, l.joinMicMuted = a ?? !1, l.joinWithoutCamera = u ?? !1, l.displayName = n, this.logCreated(h, l), this.port2.postMessage(l), this.logSent(h, l);
1398
+ region: a,
1399
+ joinMicMuted: c,
1400
+ joinWithoutCamera: l
1401
+ } = t, h = "JOINING ROOM", u = this.createMessage(h, !1);
1402
+ u.roomName = e, u.jwtToken = i, u.serverUrl = o, u.region = a, u.roomInvite = r, u.joinMicMuted = c ?? !1, u.joinWithoutCamera = l ?? !1, u.displayName = n, this.logCreated(h, u), this.port2.postMessage(u), this.logSent(h, u);
1403
1403
  }
1404
1404
  /**
1405
1405
  * Sends a {@link LeavingRoomMessage} lifecycle message to the Host app.
@@ -1449,7 +1449,7 @@ class Mt {
1449
1449
  throw new d(this.currentContext);
1450
1450
  const t = "JOIN ROOM";
1451
1451
  return this.incomingMessages$.pipe(
1452
- m((e) => e.type === t && e.target === "client"),
1452
+ y((e) => e.type === t && e.target === "client"),
1453
1453
  f((e) => e),
1454
1454
  g(this.logReceived()),
1455
1455
  f((e) => e)
@@ -1485,7 +1485,7 @@ class Mt {
1485
1485
  throw new d(this.currentContext);
1486
1486
  const t = "LEAVE ROOM";
1487
1487
  return this.incomingMessages$.pipe(
1488
- m((e) => e.type === t && e.target === "client"),
1488
+ y((e) => e.type === t && e.target === "client"),
1489
1489
  f((e) => e),
1490
1490
  g(this.logReceived()),
1491
1491
  f((e) => e)
@@ -1522,7 +1522,7 @@ class Mt {
1522
1522
  throw new d(this.currentContext);
1523
1523
  const t = "CONFIG";
1524
1524
  return this.incomingMessages$.pipe(
1525
- m((e) => e.type === t && e.target === "client"),
1525
+ y((e) => e.type === t && e.target === "client"),
1526
1526
  f((e) => e),
1527
1527
  g(this.logReceived()),
1528
1528
  f((e) => ({
@@ -1546,7 +1546,7 @@ class Mt {
1546
1546
  const e = "SCREENSHARE SOURCE", r = this.createMessage(e);
1547
1547
  r.sourceTypes = t, this.logCreated(e, r);
1548
1548
  const n = this.incomingMessages$.pipe(
1549
- m((i) => i.type === e && i.replyTo === r.id),
1549
+ y((i) => i.type === e && i.replyTo === r.id),
1550
1550
  f((i) => i),
1551
1551
  g(this.logReceived()),
1552
1552
  f((i) => i),
@@ -1560,10 +1560,10 @@ class Mt {
1560
1560
  const n = "LAYOUT CHANGE";
1561
1561
  let i, o;
1562
1562
  if (e && r ? (i = this.createMessage(n, !1, r), i.result = e) : (i = this.createMessage(n), o = this.incomingMessages$.pipe(
1563
- m((c) => c.type === n && c.replyTo === i.id),
1564
- f((c) => c),
1563
+ y((a) => a.type === n && a.replyTo === i.id),
1564
+ f((a) => a),
1565
1565
  g(this.logReceived()),
1566
- f((c) => c),
1566
+ f((a) => a),
1567
1567
  w(1)
1568
1568
  ), this.logService.debug(`Created ${n} Reply handler`)), i.layout = t, this.logCreated(n, i), this.port2.postMessage(i), this.logSent(n, i), o)
1569
1569
  return o;
@@ -1604,7 +1604,7 @@ class Mt {
1604
1604
  throw new d(this.currentContext);
1605
1605
  const t = "LAYOUT CHANGE";
1606
1606
  return this.incomingMessages$.pipe(
1607
- m((e) => e.type === t && e.target === "client" && e.replyTo === null),
1607
+ y((e) => e.type === t && e.target === "client" && e.replyTo === null),
1608
1608
  f((e) => e),
1609
1609
  g(this.logReceived()),
1610
1610
  f((e) => e)
@@ -1617,7 +1617,7 @@ class Mt {
1617
1617
  const e = "OAUTH TOKEN", r = this.createMessage(e);
1618
1618
  r.providerTypes = t, this.logCreated(e, r);
1619
1619
  const n = this.incomingMessages$.pipe(
1620
- m((i) => i.type === e && i.replyTo === r.id),
1620
+ y((i) => i.type === e && i.replyTo === r.id),
1621
1621
  f((i) => i),
1622
1622
  g(this.logReceived()),
1623
1623
  w(1)
@@ -1635,13 +1635,13 @@ class Mt {
1635
1635
  throw new d(this.currentContext);
1636
1636
  if (this.negotiatedProtocolVersion === "2.0") {
1637
1637
  if (e === void 0 || typeof e == "object")
1638
- throw new y(
1638
+ throw new m(
1639
1639
  "streamType",
1640
1640
  e,
1641
1641
  "streamType is missing or invalid"
1642
1642
  );
1643
1643
  if (r === void 0 || typeof r == "object" || typeof r == "number")
1644
- throw new y(
1644
+ throw new m(
1645
1645
  "contactType",
1646
1646
  r,
1647
1647
  "contactType is missing or invalid"
@@ -1654,9 +1654,9 @@ class Mt {
1654
1654
  );
1655
1655
  }
1656
1656
  if (typeof e < "u" && typeof e != "object")
1657
- throw new y("options", e, "options is invalid");
1657
+ throw new m("options", e, "options is invalid");
1658
1658
  if (typeof r < "u" && !Array.isArray(r))
1659
- throw new y(
1659
+ throw new m(
1660
1660
  "currentContacts",
1661
1661
  r,
1662
1662
  "currentContacts is invalid"
@@ -1666,119 +1666,148 @@ class Mt {
1666
1666
  selectContactsV2_0(t, e, r, n) {
1667
1667
  if (!this.isEmbedded())
1668
1668
  throw new d(this.currentContext);
1669
- n && n.length > 0 && (n = n.map((a) => a.type === "cloudUsername" && a.contactUser ? {
1670
- ...a,
1671
- cloudId: a.cloudId || a.contactUser.cloudId,
1672
- networkId: a.networkId || a.contactUser.networkId,
1673
- cloudUsername: a.cloudUsername || a.contactUser.cloudUsername
1674
- } : a));
1669
+ n && n.length > 0 && (n = n.map((c) => c.type === "cloudUsername" && c.contactUser ? {
1670
+ ...c,
1671
+ cloudId: c.cloudId || c.contactUser.cloudId,
1672
+ networkId: c.networkId || c.contactUser.networkId,
1673
+ cloudUsername: c.cloudUsername || c.contactUser.cloudUsername
1674
+ } : c));
1675
1675
  const i = "SELECT CONTACTS", o = this.createMessage(i, !0);
1676
1676
  o.streamId = t, o.streamType = e, o.contactType = r, o.resultTypes = [r], o.currentContacts = n, this.logCreated(i, o);
1677
- const c = this.incomingMessages$.pipe(
1678
- m((a) => a.type === i && a.replyTo === o.id),
1677
+ const a = this.incomingMessages$.pipe(
1678
+ y((c) => c.type === i && c.replyTo === o.id),
1679
1679
  g(this.logReceived()),
1680
- f((a) => {
1681
- const u = a;
1682
- if (u.result === "success") {
1683
- if (u.streamId !== t)
1684
- throw new ae(u.streamId, t);
1685
- e === "direct" && u.contacts.length > 1 && (u.contacts = [u.contacts[0]]);
1680
+ f((c) => {
1681
+ const l = c;
1682
+ if (l.result === "success") {
1683
+ if (l.streamId !== t)
1684
+ throw new ae(l.streamId, t);
1685
+ e === "direct" && l.contacts.length > 1 && (l.contacts = [l.contacts[0]]);
1686
1686
  }
1687
- return u;
1687
+ return l;
1688
1688
  }),
1689
1689
  w(1)
1690
1690
  );
1691
- return this.logService.debug(`Created ${i} Reply handler`), this.port2.postMessage(o), this.logSent(i, o), c;
1691
+ return this.logService.debug(`Created ${i} Reply handler`), this.port2.postMessage(o), this.logSent(i, o), a;
1692
1692
  }
1693
1693
  selectContactsV2_1(t, e, r) {
1694
1694
  if (!this.isEmbedded())
1695
1695
  throw new d(this.currentContext);
1696
1696
  const n = {
1697
1697
  allowMultipleSelection: (e == null ? void 0 : e.allowMultipleSelection) ?? !1,
1698
- resultTypes: (e == null ? void 0 : e.resultTypes) ?? ["cloudUsername"]
1698
+ filterToSelectedType: (e == null ? void 0 : e.filterToSelectedType) ?? !1,
1699
+ resultTypes: (e == null ? void 0 : e.resultTypes) ?? ["cloudUsername"],
1700
+ streamName: e == null ? void 0 : e.streamName
1699
1701
  };
1702
+ if (n.filterToSelectedType) {
1703
+ if (!n.allowMultipleSelection)
1704
+ throw new m(
1705
+ "filterToSelectedType",
1706
+ n.filterToSelectedType,
1707
+ "filterToSelectedType can only be set when allowMultipleSelection is true"
1708
+ );
1709
+ if (n.resultTypes.length === 1 && this.logService.warn(
1710
+ "[IPC] [SelectContacts] filterToSelectedType is redundant when resultTypes contains only one type"
1711
+ ), r && r.length > 0) {
1712
+ const c = r[0].type;
1713
+ if (r.some((l) => l.type !== c))
1714
+ throw new m(
1715
+ "currentContacts",
1716
+ r,
1717
+ "When filterToSelectedType is true, all items in currentContacts must be of the same type"
1718
+ );
1719
+ }
1720
+ }
1700
1721
  if (r && r.length > 0)
1701
- for (const a of r) {
1702
- if (a.contactId === void 0)
1703
- throw new y(
1722
+ for (const c of r) {
1723
+ if (c.contactId === void 0)
1724
+ throw new m(
1704
1725
  "currentContacts",
1705
1726
  r,
1706
1727
  "ContactItem contactId is required since v2.1 on all contacts"
1707
1728
  );
1708
- if (a.type === "cloudUsername") {
1709
- if (!a.contactUser)
1710
- throw new y(
1729
+ if (c.type === "cloudUsername") {
1730
+ if (!c.contactUser)
1731
+ throw new m(
1711
1732
  "currentContacts",
1712
- a,
1733
+ c,
1713
1734
  "CloudUsername contact must include contactUser since v2.1"
1714
1735
  );
1715
- if (!a.contactUser.cloudId || !a.contactUser.networkId || !a.contactUser.cloudUsername)
1716
- throw new y(
1736
+ if (!c.contactUser.cloudId || !c.contactUser.networkId || !c.contactUser.cloudUsername)
1737
+ throw new m(
1717
1738
  "currentContacts",
1718
- a,
1739
+ c,
1719
1740
  "CloudContact must define cloudUsername, cloudId, and networkId since v2.1"
1720
1741
  );
1721
1742
  }
1722
1743
  }
1723
1744
  const i = "SELECT CONTACTS", o = this.createMessage(i, !0);
1724
- o.streamId = t, o.resultTypes = n.resultTypes, o.currentContacts = r, o.allowMultipleSelection = n.allowMultipleSelection, this.logCreated(i, o);
1725
- const c = this.incomingMessages$.pipe(
1726
- m((a) => a.type === i && a.replyTo === o.id),
1745
+ o.streamId = t, o.streamName = n.streamName, o.resultTypes = n.resultTypes, o.currentContacts = r, o.allowMultipleSelection = n.allowMultipleSelection, o.filterToSelectedType = n.filterToSelectedType, this.logCreated(i, o);
1746
+ const a = this.incomingMessages$.pipe(
1747
+ y((c) => c.type === i && c.replyTo === o.id),
1727
1748
  g(this.logReceived()),
1728
- f((a) => {
1729
- const u = a;
1730
- if (u.result === "success") {
1731
- if (u.streamId !== t)
1732
- throw new ae(u.streamId, t);
1733
- const h = u.contacts.length;
1734
- u.contacts = u.contacts.filter(
1735
- (l) => n.resultTypes.includes(l.type)
1736
- ), u.contacts.length !== h && this.logService.debug(
1737
- `[IPC] [SelectContactsReply] Filtered ${h - u.contacts.length} contacts from reply`
1738
- ), !n.allowMultipleSelection && u.contacts.length > 1 && (u.contacts = [u.contacts[0]]);
1739
- for (const l of u.contacts) {
1740
- if (l.type === "cloudUsername") {
1741
- if (!l.contactUser)
1749
+ f((c) => {
1750
+ const l = c;
1751
+ if (l.result === "success") {
1752
+ if (l.streamId !== t)
1753
+ throw new ae(l.streamId, t);
1754
+ const h = l.contacts.length;
1755
+ if (l.contacts = l.contacts.filter(
1756
+ (u) => n.resultTypes.includes(u.type)
1757
+ ), l.contacts.length !== h && this.logService.debug(
1758
+ `[IPC] [SelectContactsReply] Filtered ${h - l.contacts.length} contacts from reply`
1759
+ ), !n.allowMultipleSelection && l.contacts.length > 1 && (l.contacts = [l.contacts[0]]), n.filterToSelectedType && l.contacts.length > 1) {
1760
+ const u = l.contacts[0].type;
1761
+ if (l.contacts.some(
1762
+ (b) => b.type !== u
1763
+ ))
1764
+ throw new Error(
1765
+ `When filterToSelectedType is true, all contacts in the reply must be of the same type. Expected all contacts to be of type '${u}', but received mixed types.`
1766
+ );
1767
+ }
1768
+ for (const u of l.contacts) {
1769
+ if (u.type === "cloudUsername") {
1770
+ if (!u.contactUser)
1742
1771
  throw new Error(
1743
1772
  `CloudUsername contact must include contactUser since v2.1. ContactItem: ${JSON.stringify(
1744
- l
1773
+ u
1745
1774
  )}`
1746
1775
  );
1747
- if (!l.contactUser.cloudId || !l.contactUser.networkId || !l.contactUser.cloudUsername)
1776
+ if (!u.contactUser.cloudId || !u.contactUser.networkId || !u.contactUser.cloudUsername)
1748
1777
  throw new Error(
1749
1778
  `CloudContact must define cloudUsername, cloudId, and networkId since v2.1. ContactItem: ${JSON.stringify(
1750
- l
1779
+ u
1751
1780
  )}`
1752
1781
  );
1753
1782
  }
1754
- this.negotiatedProtocolVersion === "2.2" && (l.type === "number" && l.numbers.length > 1 ? l.numbers = [l.numbers[0]] : l.type === "email" && l.emails.length > 1 && (l.emails = [l.emails[0]]));
1783
+ this.negotiatedProtocolVersion === "2.2" && (u.type === "number" && u.numbers.length > 1 ? u.numbers = [u.numbers[0]] : u.type === "email" && u.emails.length > 1 && (u.emails = [u.emails[0]]));
1755
1784
  }
1756
1785
  }
1757
- return u;
1786
+ return l;
1758
1787
  }),
1759
1788
  w(1)
1760
1789
  );
1761
- return this.logService.debug(`Created ${i} Reply handler`), this.port2.postMessage(o), this.logSent(i, o), c;
1790
+ return this.logService.debug(`Created ${i} Reply handler`), this.port2.postMessage(o), this.logSent(i, o), a;
1762
1791
  }
1763
1792
  matchContacts(t) {
1764
1793
  if (!this.isEmbedded())
1765
1794
  throw new d(this.currentContext);
1766
1795
  if (!Array.isArray(t))
1767
- throw new y("contacts", t, "contacts is not an array");
1796
+ throw new m("contacts", t, "contacts is not an array");
1768
1797
  if (!t.length)
1769
- throw new y("contacts", t, "At least one contact is required");
1798
+ throw new m("contacts", t, "At least one contact is required");
1770
1799
  const e = this.createMessage("MATCH CONTACTS");
1771
1800
  if (this.compareVersion("2.1") >= 0) {
1772
1801
  for (const n of t)
1773
1802
  if (n.type === "cloudUsername") {
1774
1803
  if (!n.contactUser)
1775
- throw new y(
1804
+ throw new m(
1776
1805
  "contacts",
1777
1806
  n,
1778
1807
  "CloudUsername contact must include contactUser"
1779
1808
  );
1780
1809
  if (!n.contactUser.cloudUsername || !n.contactUser.cloudId || !n.contactUser.networkId)
1781
- throw new y(
1810
+ throw new m(
1782
1811
  "contacts",
1783
1812
  n,
1784
1813
  "CloudContact must define cloudUsername, cloudId, and networkId"
@@ -1792,7 +1821,7 @@ class Mt {
1792
1821
  }
1793
1822
  this.logCreated(e.type, e);
1794
1823
  const r = this.incomingMessages$.pipe(
1795
- m((n) => n.type === e.type && n.replyTo === e.id),
1824
+ y((n) => n.type === e.type && n.replyTo === e.id),
1796
1825
  g(this.logReceived()),
1797
1826
  f((n) => {
1798
1827
  const i = n;
@@ -1801,29 +1830,29 @@ class Mt {
1801
1830
  throw new Error(
1802
1831
  "MatchContactsMessageReply should return a Record<string, DetailedContactItem> of contacts when using IPC Protocol v2.1+"
1803
1832
  );
1804
- for (const [o, c] of Object.entries(i.contacts)) {
1805
- if (c == null) {
1833
+ for (const [o, a] of Object.entries(i.contacts)) {
1834
+ if (a == null) {
1806
1835
  this.logService.debug(
1807
1836
  `[IPC] [MatchContactsReply] Received null or undefined contact for ${o}`
1808
1837
  );
1809
1838
  continue;
1810
1839
  }
1811
- if (c.contactId === void 0)
1840
+ if (a.contactId === void 0)
1812
1841
  throw new Error(
1813
1842
  `ContactItem 'contactId' is required since v2.1. ContactItem: ${JSON.stringify(
1814
- c
1843
+ a
1815
1844
  )}`
1816
1845
  );
1817
- if (!c.contactUser && (!c.uri || c.uri.length === 0) && (!c.numbers || c.numbers.length === 0))
1846
+ if (!a.contactUser && (!a.uri || a.uri.length === 0) && (!a.numbers || a.numbers.length === 0))
1818
1847
  throw new Error(
1819
1848
  `DetailedContactItem must define at least one contact method (contactUser, uri, or numbers). ContactItem: ${JSON.stringify(
1820
- c
1849
+ a
1821
1850
  )}`
1822
1851
  );
1823
- if (c.contactUser && (!c.contactUser.cloudId || !c.contactUser.networkId || !c.contactUser.cloudUsername))
1852
+ if (a.contactUser && (!a.contactUser.cloudId || !a.contactUser.networkId || !a.contactUser.cloudUsername))
1824
1853
  throw new Error(
1825
1854
  `When contactUser is defined, cloudId, networkId, and cloudUsername must also be defined. ContactItem: ${JSON.stringify(
1826
- c
1855
+ a
1827
1856
  )}`
1828
1857
  );
1829
1858
  }
@@ -1837,14 +1866,14 @@ class Mt {
1837
1866
  "The number of contacts in the reply does not match the number of contacts in the request"
1838
1867
  );
1839
1868
  for (const o of i.contacts) {
1840
- const c = o;
1841
- if (c.type === "cloudUsername" && !("cloudUsername" in c))
1869
+ const a = o;
1870
+ if (a.type === "cloudUsername" && !("cloudUsername" in a))
1842
1871
  throw new Error(
1843
1872
  `CloudUsernameDetailedContactItem must define cloudUsername. ContactItem: ${JSON.stringify(
1844
1873
  o
1845
1874
  )}`
1846
1875
  );
1847
- if (c.type === "uri" && (!("uri" in c) || !Array.isArray(c.uri)))
1876
+ if (a.type === "uri" && (!("uri" in a) || !Array.isArray(a.uri)))
1848
1877
  throw new Error(
1849
1878
  `UriDetailedContactItem must define uri as an array. ContactItem: ${JSON.stringify(
1850
1879
  o
@@ -1889,7 +1918,7 @@ class Mt {
1889
1918
  throw new d(this.currentContext);
1890
1919
  const t = "PUSH MESSAGE";
1891
1920
  return this.incomingMessages$.pipe(
1892
- m((e) => e.type === t && e.target === "client"),
1921
+ y((e) => e.type === t && e.target === "client"),
1893
1922
  f((e) => e),
1894
1923
  g(this.logReceived())
1895
1924
  );
@@ -1909,7 +1938,7 @@ class Mt {
1909
1938
  const t = "PUSH TOKEN", e = this.createMessage(t);
1910
1939
  this.logCreated(t, e);
1911
1940
  const r = this.incomingMessages$.pipe(
1912
- m((n) => n.type === t && n.replyTo === e.id),
1941
+ y((n) => n.type === t && n.replyTo === e.id),
1913
1942
  g(this.logReceived()),
1914
1943
  f((n) => n),
1915
1944
  w(1)
@@ -1948,7 +1977,7 @@ class Mt {
1948
1977
  throw new d(this.currentContext);
1949
1978
  const t = "PUSH TOKEN";
1950
1979
  return this.incomingMessages$.pipe(
1951
- m(
1980
+ y(
1952
1981
  (e) => e.type === t && e.target === "client" && e.replyTo === null && e.expectReply === !1
1953
1982
  ),
1954
1983
  f((e) => {
@@ -1972,7 +2001,7 @@ class Mt {
1972
2001
  throw new d(this.currentContext);
1973
2002
  const t = "BADGE QUERY";
1974
2003
  return this.incomingMessages$.pipe(
1975
- m((e) => e.type === t && e.target === "client"),
2004
+ y((e) => e.type === t && e.target === "client"),
1976
2005
  f((e) => e),
1977
2006
  g(this.logReceived())
1978
2007
  );
@@ -2030,7 +2059,7 @@ class Mt {
2030
2059
  throw new d(this.currentContext);
2031
2060
  const t = "LIFECYCLE";
2032
2061
  return this.incomingMessages$.pipe(
2033
- m((e) => e.type === t && e.target === "client"),
2062
+ y((e) => e.type === t && e.target === "client"),
2034
2063
  f((e) => e),
2035
2064
  g(this.logReceived())
2036
2065
  );
@@ -2070,7 +2099,7 @@ class Mt {
2070
2099
  throw new d(this.currentContext);
2071
2100
  const t = "REQUEST LOGS";
2072
2101
  return this.incomingMessages$.pipe(
2073
- m((e) => e.type === t && e.target === "client"),
2102
+ y((e) => e.type === t && e.target === "client"),
2074
2103
  f((e) => e),
2075
2104
  g(this.logReceived())
2076
2105
  );
@@ -2088,8 +2117,8 @@ class Mt {
2088
2117
  sendRequestLogsMessageReply(t, e, r, n, i) {
2089
2118
  if (!this.isEmbedded())
2090
2119
  throw new d(this.currentContext);
2091
- const o = "REQUEST LOGS", c = this.createMessage(o, !1, i);
2092
- c.fileId = t, c.fileHash = e, c.fileSize = r, c.format = n, this.logCreated(o, c), this.port2.postMessage(c), this.logSent(o, c);
2120
+ const o = "REQUEST LOGS", a = this.createMessage(o, !1, i);
2121
+ a.fileId = t, a.fileHash = e, a.fileSize = r, a.format = n, this.logCreated(o, a), this.port2.postMessage(a), this.logSent(o, a);
2093
2122
  }
2094
2123
  /**
2095
2124
  * Send a {@link ViewTransitionMessage} to the `Host` app, notifying it of a view transition
@@ -2154,28 +2183,28 @@ class Mt {
2154
2183
  sendFileRequestMessage(t, e, r, n, i) {
2155
2184
  if (!this.isEmbedded())
2156
2185
  throw new d(this.currentContext);
2157
- const o = "FILE REQUEST", c = this.createMessage(o);
2158
- if (c.fileId = t, c.fileHash = e.toLowerCase(), c.intent = r, c.maxChunkSizeInBytes = i, r === "attachment") {
2186
+ const o = "FILE REQUEST", a = this.createMessage(o);
2187
+ if (a.fileId = t, a.fileHash = e.toLowerCase(), a.intent = r, a.maxChunkSizeInBytes = i, r === "attachment") {
2159
2188
  if (!n)
2160
- throw new y(
2189
+ throw new m(
2161
2190
  "streamId",
2162
2191
  n,
2163
2192
  "streamId is required for attachment intent"
2164
2193
  );
2165
- c.streamId = n;
2194
+ a.streamId = n;
2166
2195
  }
2167
- this.logCreated(o, c);
2168
- let a = 0;
2169
- const u = this.incomingMessages$.pipe(
2170
- m(
2171
- (h) => h.type === o && h.replyTo === c.id
2196
+ this.logCreated(o, a);
2197
+ let c = 0;
2198
+ const l = this.incomingMessages$.pipe(
2199
+ y(
2200
+ (h) => h.type === o && h.replyTo === a.id
2172
2201
  ),
2173
2202
  g(this.logReceived()),
2174
- g(() => a++),
2203
+ g(() => c++),
2175
2204
  f((h) => (h.result === "success" && (h.chunkHash = h.chunkHash.toLowerCase(), h.fileHash = h.fileHash.toLowerCase()), h)),
2176
- wt((h) => h.result === "success" && a < h.totalChunks, !0)
2205
+ wt((h) => h.result === "success" && c < h.totalChunks, !0)
2177
2206
  );
2178
- return this.port2.postMessage(c), this.logSent(o, c), u;
2207
+ return this.port2.postMessage(a), this.logSent(o, a), l;
2179
2208
  }
2180
2209
  /**
2181
2210
  * Sends a {@link FileRequestMessageReply} to the Host app, to reply to a
@@ -2222,7 +2251,7 @@ class Mt {
2222
2251
  throw new d(this.currentContext);
2223
2252
  const t = "FILE REQUEST";
2224
2253
  return this.incomingMessages$.pipe(
2225
- m(
2254
+ y(
2226
2255
  (e) => e.type === t && e.target === "client" && e.replyTo === null
2227
2256
  ),
2228
2257
  f((e) => (e.fileHash = e.fileHash.toLowerCase(), e)),
@@ -2254,35 +2283,35 @@ class Mt {
2254
2283
  sendFileSelectionMessage(t = "attachment", e, r, n, i, o) {
2255
2284
  if (!this.isEmbedded())
2256
2285
  throw new d(this.currentContext);
2257
- const c = "FILE SELECTION", a = this.createMessage(c);
2258
- if (a.intent = t, a.maxCount = n, a.maxFileSizeInBytes = i, a.mimeTypes = o, t === "attachment") {
2286
+ const a = "FILE SELECTION", c = this.createMessage(a);
2287
+ if (c.intent = t, c.maxCount = n, c.maxFileSizeInBytes = i, c.mimeTypes = o, t === "attachment") {
2259
2288
  if (!e)
2260
- throw new y(
2289
+ throw new m(
2261
2290
  "streamId",
2262
2291
  e,
2263
2292
  "streamId is required for attachment intent"
2264
2293
  );
2265
2294
  if (!r)
2266
- throw new y(
2295
+ throw new m(
2267
2296
  "correlationId",
2268
2297
  r,
2269
2298
  "correlationId is required for attachment intent"
2270
2299
  );
2271
- a.streamId = e, a.correlationId = r;
2300
+ c.streamId = e, c.correlationId = r;
2272
2301
  }
2273
- this.logCreated(c, a);
2274
- const u = this.incomingMessages$.pipe(
2275
- m(
2276
- (h) => h.type === c && h.replyTo === a.id
2302
+ this.logCreated(a, c);
2303
+ const l = this.incomingMessages$.pipe(
2304
+ y(
2305
+ (h) => h.type === a && h.replyTo === c.id
2277
2306
  ),
2278
2307
  f((h) => {
2279
- var l;
2280
- return h.result === "success" && (h.files = (l = h.files) == null ? void 0 : l.map((b) => (b.original.fileHash = b.original.fileHash.toLowerCase(), b.preview && (b.preview.fileHash = b.preview.fileHash.toLowerCase()), b))), h;
2308
+ var u;
2309
+ return h.result === "success" && (h.files = (u = h.files) == null ? void 0 : u.map((b) => (b.original.fileHash = b.original.fileHash.toLowerCase(), b.preview && (b.preview.fileHash = b.preview.fileHash.toLowerCase()), b))), h;
2281
2310
  }),
2282
2311
  g(this.logReceived()),
2283
2312
  w(1)
2284
2313
  );
2285
- return this.port2.postMessage(a), this.logSent(c, a), u;
2314
+ return this.port2.postMessage(c), this.logSent(a, c), l;
2286
2315
  }
2287
2316
  /**
2288
2317
  * Sends a {@link FileDownloadProgressQueryMessage} to the Host app, to query the progress of a
@@ -2312,11 +2341,11 @@ class Mt {
2312
2341
  );
2313
2342
  i.fileHash = t.toLowerCase(), i.url = e, i.correlationId = r, this.logCreated(n, i);
2314
2343
  const o = this.incomingMessages$.pipe(
2315
- m(
2316
- (c) => c.type === "FILE DOWNLOAD PROGRESS UPDATE" && c.replyTo === i.id
2344
+ y(
2345
+ (a) => a.type === "FILE DOWNLOAD PROGRESS UPDATE" && a.replyTo === i.id
2317
2346
  ),
2318
- g((c) => this.logReceived(c)),
2319
- f((c) => (c.fileHash && (c.fileHash = c.fileHash.toLowerCase()), c)),
2347
+ g((a) => this.logReceived(a)),
2348
+ f((a) => (a.fileHash && (a.fileHash = a.fileHash.toLowerCase()), a)),
2320
2349
  w(1)
2321
2350
  );
2322
2351
  return this.port2.postMessage(i), this.logSent(n, i), o;
@@ -2333,7 +2362,7 @@ class Mt {
2333
2362
  throw new d(this.currentContext);
2334
2363
  const t = "FILE DOWNLOAD PROGRESS UPDATE";
2335
2364
  return this.incomingMessages$.pipe(
2336
- m(
2365
+ y(
2337
2366
  (e) => e.type === t && e.target === "client" && e.replyTo === null
2338
2367
  ),
2339
2368
  f((e) => (e.fileHash && (e.fileHash = e.fileHash.toLowerCase()), e)),
@@ -2363,11 +2392,11 @@ class Mt {
2363
2392
  );
2364
2393
  i.fileHash = t.toLowerCase(), i.fileId = e, i.correlationId = r, this.logCreated(n, i);
2365
2394
  const o = this.incomingMessages$.pipe(
2366
- m(
2367
- (c) => c.type === "FILE UPLOAD PROGRESS UPDATE" && c.replyTo === i.id
2395
+ y(
2396
+ (a) => a.type === "FILE UPLOAD PROGRESS UPDATE" && a.replyTo === i.id
2368
2397
  ),
2369
2398
  g(this.logReceived()),
2370
- f((c) => (c.fileHash && (c.fileHash = c.fileHash.toLowerCase()), c)),
2399
+ f((a) => (a.fileHash && (a.fileHash = a.fileHash.toLowerCase()), a)),
2371
2400
  w(1)
2372
2401
  );
2373
2402
  return this.port2.postMessage(i), this.logSent(n, i), o;
@@ -2388,7 +2417,7 @@ class Mt {
2388
2417
  throw new d(this.currentContext);
2389
2418
  const t = "FILE UPLOAD PROGRESS UPDATE";
2390
2419
  return this.incomingMessages$.pipe(
2391
- m(
2420
+ y(
2392
2421
  (e) => e.type === t && e.target === "client" && e.replyTo === null
2393
2422
  ),
2394
2423
  f((e) => (e.fileHash && (e.fileHash = e.fileHash.toLowerCase()), e)),
@@ -2420,39 +2449,39 @@ class Mt {
2420
2449
  * @returns An observable which emits a {@link FileDownloadMessageReply} instance containing the
2421
2450
  * result of the request. Emits once.
2422
2451
  */
2423
- sendFileDownloadMessage(t, e, r, n, i, o, c, a, u) {
2452
+ sendFileDownloadMessage(t, e, r, n, i, o, a, c, l) {
2424
2453
  if (!this.isEmbedded())
2425
2454
  throw new d(this.currentContext);
2426
- if (a && this.compareVersion("2.1") < 0)
2427
- a.type === "cloudUsername" && a.contactUser && (a = {
2428
- ...a,
2429
- cloudId: a.cloudId || a.contactUser.cloudId,
2430
- networkId: a.networkId || a.contactUser.networkId,
2431
- cloudUsername: a.cloudUsername || a.contactUser.cloudUsername
2455
+ if (c && this.compareVersion("2.1") < 0)
2456
+ c.type === "cloudUsername" && c.contactUser && (c = {
2457
+ ...c,
2458
+ cloudId: c.cloudId || c.contactUser.cloudId,
2459
+ networkId: c.networkId || c.contactUser.networkId,
2460
+ cloudUsername: c.cloudUsername || c.contactUser.cloudUsername
2432
2461
  });
2433
- else if (a && this.compareVersion("2.1") >= 0 && a.type === "cloudUsername") {
2434
- if (!a.contactUser)
2435
- throw new y(
2462
+ else if (c && this.compareVersion("2.1") >= 0 && c.type === "cloudUsername") {
2463
+ if (!c.contactUser)
2464
+ throw new m(
2436
2465
  "sender",
2437
- a,
2466
+ c,
2438
2467
  "CloudUsername contact must include contactUser since v2.1"
2439
2468
  );
2440
- if (!a.contactUser.cloudId || !a.contactUser.networkId || !a.contactUser.cloudUsername)
2441
- throw new y(
2469
+ if (!c.contactUser.cloudId || !c.contactUser.networkId || !c.contactUser.cloudUsername)
2470
+ throw new m(
2442
2471
  "sender",
2443
- a,
2472
+ c,
2444
2473
  "CloudContact must define cloudUsername, cloudId, and networkId since v2.1"
2445
2474
  );
2446
2475
  }
2447
- const h = "FILE DOWNLOAD", l = this.createMessage(h, !0);
2448
- l.url = t, l.key = e, l.fileHash = r.toLowerCase(), l.mimeType = n, l.fileName = i, l.streamId = o, l.correlationId = c, l.sender = a, l.intent = u ?? "download", this.logCreated(h, l);
2476
+ const h = "FILE DOWNLOAD", u = this.createMessage(h, !0);
2477
+ u.url = t, u.key = e, u.fileHash = r.toLowerCase(), u.mimeType = n, u.fileName = i, u.streamId = o, u.correlationId = a, u.sender = c, u.intent = l ?? "download", this.logCreated(h, u);
2449
2478
  const b = this.incomingMessages$.pipe(
2450
- m((p) => p.type === h && p.replyTo === l.id),
2479
+ y((p) => p.type === h && p.replyTo === u.id),
2451
2480
  g(this.logReceived()),
2452
2481
  f((p) => p),
2453
2482
  w(1)
2454
2483
  );
2455
- return this.port2.postMessage(l), this.logSent(h, l), b;
2484
+ return this.port2.postMessage(u), this.logSent(h, u), b;
2456
2485
  }
2457
2486
  /**
2458
2487
  * Sends a {@link CancelFileDownloadMessage} to the Host app, to cancel downloading of a file
@@ -2489,7 +2518,7 @@ class Mt {
2489
2518
  const r = "FILE REMOVE", n = this.createMessage(r, !0);
2490
2519
  n.hash = t.toLowerCase(), n.streamId = e, this.logCreated(r, n);
2491
2520
  const i = this.incomingMessages$.pipe(
2492
- m((o) => o.type === r && o.replyTo === n.id),
2521
+ y((o) => o.type === r && o.replyTo === n.id),
2493
2522
  g(this.logReceived()),
2494
2523
  f((o) => o),
2495
2524
  w(1)
@@ -2557,13 +2586,13 @@ class Mt {
2557
2586
  * @returns An observable which emits a {@link SendMessageMessageReply} instance containing the
2558
2587
  * result of the request. Emits once.
2559
2588
  */
2560
- sendSendMessageMessage(t, e, r, n = "TEXT", i, o, c, a = !0, u) {
2589
+ sendSendMessageMessage(t, e, r, n = "TEXT", i, o, a, c = !0, l) {
2561
2590
  if (!this.isEmbedded())
2562
2591
  throw new d(this.currentContext);
2563
- const h = "SEND MESSAGE", l = this.createMessage(h, !0);
2564
- if (l.streamId = t, l.correlationId = e, l.body = r, l.messageType = n, i && i.length > 0)
2592
+ const h = "SEND MESSAGE", u = this.createMessage(h, !0);
2593
+ if (u.streamId = t, u.correlationId = e, u.body = r, u.messageType = n, i && i.length > 0)
2565
2594
  if (this.compareVersion("2.1") < 0)
2566
- l.mentions = i.map((p) => p.contactUser ? {
2595
+ u.mentions = i.map((p) => p.contactUser ? {
2567
2596
  ...p,
2568
2597
  cloudId: p.cloudId || p.contactUser.cloudId,
2569
2598
  networkId: p.networkId || p.contactUser.networkId,
@@ -2572,30 +2601,30 @@ class Mt {
2572
2601
  else {
2573
2602
  for (const p of i) {
2574
2603
  if (p.type === "cloudUsername" && !p.contactUser)
2575
- throw new y(
2604
+ throw new m(
2576
2605
  "mentions",
2577
2606
  p,
2578
2607
  "CloudUsername mention must include contactUser"
2579
2608
  );
2580
2609
  if (p.contactUser && (!p.contactUser.cloudId || !p.contactUser.networkId || !p.contactUser.cloudUsername))
2581
- throw new y(
2610
+ throw new m(
2582
2611
  "mentions",
2583
2612
  p,
2584
2613
  "CloudContact must define cloudUsername, cloudId, and networkId"
2585
2614
  );
2586
2615
  }
2587
- l.mentions = i;
2616
+ u.mentions = i;
2588
2617
  }
2589
2618
  else
2590
- l.mentions = [];
2591
- l.attachments = (o == null ? void 0 : o.map((p) => p.toLowerCase())) ?? [], l.relatedMessageId = c, l.setCursors = a, l.threadId = u, this.logCreated(h, l);
2619
+ u.mentions = [];
2620
+ u.attachments = (o == null ? void 0 : o.map((p) => p.toLowerCase())) ?? [], u.relatedMessageId = a, u.setCursors = c, u.threadId = l, this.logCreated(h, u);
2592
2621
  const b = this.incomingMessages$.pipe(
2593
- m((p) => p.type === h && p.replyTo === l.id),
2622
+ y((p) => p.type === h && p.replyTo === u.id),
2594
2623
  g(this.logReceived()),
2595
2624
  f((p) => p),
2596
2625
  w(1)
2597
2626
  );
2598
- return this.port2.postMessage(l), this.logSent(h, l), b;
2627
+ return this.port2.postMessage(u), this.logSent(h, u), b;
2599
2628
  }
2600
2629
  /**
2601
2630
  * Sends a {@link CancelSendMessageMessage} to the Host app, to cancel a message that was being
@@ -2644,7 +2673,7 @@ class Mt {
2644
2673
  const r = "SEND MESSAGE STATUS QUERY", n = this.createMessage(r, !0);
2645
2674
  n.correlationId = t, n.streamId = e, this.logCreated(r, n);
2646
2675
  const i = this.incomingMessages$.pipe(
2647
- m(
2676
+ y(
2648
2677
  (o) => o.type === "SEND MESSAGE STATUS UPDATE" && o.replyTo === n.id
2649
2678
  ),
2650
2679
  g(this.logReceived()),
@@ -2665,7 +2694,7 @@ class Mt {
2665
2694
  throw new d(this.currentContext);
2666
2695
  const t = "SEND MESSAGE STATUS UPDATE";
2667
2696
  return this.incomingMessages$.pipe(
2668
- m((e) => e.type === t && e.target === "client" && e.replyTo === null),
2697
+ y((e) => e.type === t && e.target === "client" && e.replyTo === null),
2669
2698
  f((e) => e),
2670
2699
  g(this.logReceived())
2671
2700
  );
@@ -2690,13 +2719,13 @@ class Mt {
2690
2719
  });
2691
2720
  else if (t.type === "cloudUsername") {
2692
2721
  if (!t.contactUser)
2693
- throw new y(
2722
+ throw new m(
2694
2723
  "contact",
2695
2724
  t,
2696
2725
  "CloudUsername contact must include contactUser since v2.1"
2697
2726
  );
2698
2727
  if (!t.contactUser.cloudId || !t.contactUser.networkId || !t.contactUser.cloudUsername)
2699
- throw new y(
2728
+ throw new m(
2700
2729
  "contact",
2701
2730
  t,
2702
2731
  "CloudContact must define cloudUsername, cloudId, and networkId since v2.1"
@@ -2759,7 +2788,7 @@ class Mt {
2759
2788
  throw new d(this.currentContext);
2760
2789
  const t = "BUTTONS";
2761
2790
  return this.incomingMessages$.pipe(
2762
- m((e) => e.type === t && e.target === "client"),
2791
+ y((e) => e.type === t && e.target === "client"),
2763
2792
  f((e) => e),
2764
2793
  g(this.logReceived())
2765
2794
  );
@@ -2960,9 +2989,9 @@ class xt {
2960
2989
  let i;
2961
2990
  if (this.negotiatedVersion === "2.0") {
2962
2991
  if (typeof e != "string")
2963
- throw new y("mode", e, 'mode must be "single" or "multi"');
2992
+ throw new m("mode", e, 'mode must be "single" or "multi"');
2964
2993
  if (n === "number")
2965
- throw new y(
2994
+ throw new m(
2966
2995
  "contactType",
2967
2996
  n,
2968
2997
  'contactType cannot be "number" for version 2.0 of the IPC protocol'
@@ -2975,7 +3004,7 @@ class xt {
2975
3004
  );
2976
3005
  } else {
2977
3006
  if (typeof e != "object")
2978
- throw new y("options", e, "options must be an object");
3007
+ throw new m("options", e, "options must be an object");
2979
3008
  i = this.selectContacts_V2_1(t, e);
2980
3009
  }
2981
3010
  return T(
@@ -2992,7 +3021,7 @@ class xt {
2992
3021
  selectContacts_V2_0(t, e, r, n) {
2993
3022
  if (this.logger.debug("Selecting Contacts: ", ...arguments), e === "multi") {
2994
3023
  if (!r || !Array.isArray(r))
2995
- throw new y(
3024
+ throw new m(
2996
3025
  "currentContacts",
2997
3026
  r,
2998
3027
  "currentContacts is required for group streams"
@@ -3007,19 +3036,35 @@ class xt {
3007
3036
  return n || (n = "cloudUsername"), this.helper.selectContacts(t.toString(), "direct", n);
3008
3037
  }
3009
3038
  selectContacts_V2_1(t, e) {
3010
- if (this.logger.debug("Selecting Contacts: ", e), e.mode === "multi" && (!e.currentContacts || !Array.isArray(e.currentContacts)))
3011
- throw new y(
3039
+ this.logger.debug("Selecting Contacts: ", e);
3040
+ const r = t.toString(), n = e.resultTypes ?? ["cloudUsername"];
3041
+ if (e.mode === "single")
3042
+ return this.helper.selectContacts(r, {
3043
+ allowMultipleSelection: !1,
3044
+ resultTypes: n
3045
+ });
3046
+ if (!e.currentContacts || !Array.isArray(e.currentContacts))
3047
+ throw new m(
3012
3048
  "currentContacts",
3013
3049
  e.currentContacts,
3014
3050
  "currentContacts is required for group streams"
3015
3051
  );
3016
- return this.helper.selectContacts(
3017
- t.toString(),
3052
+ return e.filterToSelectedType ? this.helper.selectContacts(
3053
+ r,
3054
+ {
3055
+ allowMultipleSelection: !0,
3056
+ filterToSelectedType: !0,
3057
+ resultTypes: n
3058
+ },
3059
+ e.currentContacts
3060
+ ) : this.helper.selectContacts(
3061
+ r,
3018
3062
  {
3019
- allowMultipleSelection: e.mode === "multi",
3020
- resultTypes: e.resultTypes ?? ["cloudUsername"]
3063
+ allowMultipleSelection: !0,
3064
+ filterToSelectedType: !1,
3065
+ resultTypes: n
3021
3066
  },
3022
- e.mode === "multi" ? e.currentContacts : void 0
3067
+ e.currentContacts
3023
3068
  );
3024
3069
  }
3025
3070
  /**