@acrobits/ipc-sdk 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/ipc-sdk.js CHANGED
@@ -1,7 +1,7 @@
1
- var Re = Object.defineProperty;
2
- var Ae = (n, t, e) => t in n ? Re(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var M = (n, t, e) => (Ae(n, typeof t != "symbol" ? t + "" : t, e), e);
4
- var y = /* @__PURE__ */ ((n) => (n.BadgeQuery = "BADGE QUERY", n.Lifecycle = "LIFECYCLE", n.PushToken = "PUSH TOKEN", n))(y || {}), z = function(n, t) {
1
+ var Ie = Object.defineProperty;
2
+ var Ae = (n, t, e) => t in n ? Ie(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var x = (n, t, e) => (Ae(n, typeof t != "symbol" ? t + "" : t, e), e);
4
+ var b = /* @__PURE__ */ ((n) => (n.BadgeQuery = "BADGE QUERY", n.Lifecycle = "LIFECYCLE", n.PushToken = "PUSH TOKEN", n))(b || {}), z = function(n, t) {
5
5
  return z = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
6
6
  e.__proto__ = r;
7
7
  } || function(e, r) {
@@ -9,7 +9,7 @@ var y = /* @__PURE__ */ ((n) => (n.BadgeQuery = "BADGE QUERY", n.Lifecycle = "LI
9
9
  Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]);
10
10
  }, z(n, t);
11
11
  };
12
- function x(n, t) {
12
+ function M(n, t) {
13
13
  if (typeof t != "function" && t !== null)
14
14
  throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
15
15
  z(n, t);
@@ -80,7 +80,7 @@ function U(n, t) {
80
80
  0 <= e && n.splice(e, 1);
81
81
  }
82
82
  }
83
- var I = function() {
83
+ var R = function() {
84
84
  function n(t) {
85
85
  this.initialTeardown = t, this.closed = !1, this._parentage = null, this._finalizers = null;
86
86
  }
@@ -96,8 +96,8 @@ var I = function() {
96
96
  var a = c.value;
97
97
  a.remove(this);
98
98
  }
99
- } catch (d) {
100
- t = { error: d };
99
+ } catch (p) {
100
+ t = { error: p };
101
101
  } finally {
102
102
  try {
103
103
  c && !c.done && (e = u.return) && e.call(u);
@@ -112,23 +112,23 @@ var I = function() {
112
112
  if (m(g))
113
113
  try {
114
114
  g();
115
- } catch (d) {
116
- s = d instanceof D ? d.errors : [d];
115
+ } catch (p) {
116
+ s = p instanceof D ? p.errors : [p];
117
117
  }
118
118
  var v = this._finalizers;
119
119
  if (v) {
120
120
  this._finalizers = null;
121
121
  try {
122
122
  for (var E = Q(v), w = E.next(); !w.done; w = E.next()) {
123
- var N = w.value;
123
+ var j = w.value;
124
124
  try {
125
- se(N);
126
- } catch (d) {
127
- s = s ?? [], d instanceof D ? s = T(T([], _(s)), _(d.errors)) : s.push(d);
125
+ se(j);
126
+ } catch (p) {
127
+ s = s ?? [], p instanceof D ? s = T(T([], _(s)), _(p.errors)) : s.push(p);
128
128
  }
129
129
  }
130
- } catch (d) {
131
- r = { error: d };
130
+ } catch (p) {
131
+ r = { error: p };
132
132
  } finally {
133
133
  try {
134
134
  w && !w.done && (i = E.return) && i.call(E);
@@ -170,9 +170,9 @@ var I = function() {
170
170
  var t = new n();
171
171
  return t.closed = !0, t;
172
172
  }(), n;
173
- }(), me = I.EMPTY;
173
+ }(), me = R.EMPTY;
174
174
  function we(n) {
175
- return n instanceof I || n && "closed" in n && m(n.remove) && m(n.add) && m(n.unsubscribe);
175
+ return n instanceof R || n && "closed" in n && m(n.remove) && m(n.add) && m(n.unsubscribe);
176
176
  }
177
177
  function se(n) {
178
178
  m(n) ? n() : n.unsubscribe();
@@ -207,7 +207,7 @@ function L(n) {
207
207
  n();
208
208
  }
209
209
  var ee = function(n) {
210
- x(t, n);
210
+ M(t, n);
211
211
  function t(e) {
212
212
  var r = n.call(this) || this;
213
213
  return r.isStopped = !1, e ? (r.destination = e, we(e) && e.add(r)) : r.destination = ke, r;
@@ -237,7 +237,7 @@ var ee = function(n) {
237
237
  this.unsubscribe();
238
238
  }
239
239
  }, t;
240
- }(I), Le = Function.prototype.bind;
240
+ }(R), Le = Function.prototype.bind;
241
241
  function B(n, t) {
242
242
  return Le.call(n, t);
243
243
  }
@@ -251,7 +251,7 @@ var $e = function() {
251
251
  try {
252
252
  e.next(t);
253
253
  } catch (r) {
254
- R(r);
254
+ I(r);
255
255
  }
256
256
  }, n.prototype.error = function(t) {
257
257
  var e = this.partialObserver;
@@ -259,21 +259,21 @@ var $e = function() {
259
259
  try {
260
260
  e.error(t);
261
261
  } catch (r) {
262
- R(r);
262
+ I(r);
263
263
  }
264
264
  else
265
- R(t);
265
+ I(t);
266
266
  }, n.prototype.complete = function() {
267
267
  var t = this.partialObserver;
268
268
  if (t.complete)
269
269
  try {
270
270
  t.complete();
271
271
  } catch (e) {
272
- R(e);
272
+ I(e);
273
273
  }
274
274
  }, n;
275
275
  }(), k = function(n) {
276
- x(t, n);
276
+ M(t, n);
277
277
  function t(e, r, i) {
278
278
  var s = n.call(this) || this, o;
279
279
  if (m(e) || !e)
@@ -296,7 +296,7 @@ var $e = function() {
296
296
  }
297
297
  return t;
298
298
  }(ee);
299
- function R(n) {
299
+ function I(n) {
300
300
  Oe(n);
301
301
  }
302
302
  function Ue(n) {
@@ -307,13 +307,13 @@ var ke = {
307
307
  next: oe,
308
308
  error: Ue,
309
309
  complete: oe
310
- }, Ve = function() {
310
+ }, Fe = function() {
311
311
  return typeof Symbol == "function" && Symbol.observable || "@@observable";
312
312
  }();
313
313
  function Ee(n) {
314
314
  return n;
315
315
  }
316
- function je(n) {
316
+ function Ne(n) {
317
317
  return n.length === 0 ? Ee : n.length === 1 ? n[0] : function(e) {
318
318
  return n.reduce(function(r, i) {
319
319
  return i(r);
@@ -328,7 +328,7 @@ var G = function() {
328
328
  var e = new n();
329
329
  return e.source = this, e.operator = t, e;
330
330
  }, n.prototype.subscribe = function(t, e, r) {
331
- var i = this, s = Ne(t) ? t : new k(t, e, r);
331
+ var i = this, s = je(t) ? t : new k(t, e, r);
332
332
  return L(function() {
333
333
  var o = i, u = o.operator, c = o.source;
334
334
  s.add(u ? u.call(s, c) : c ? i._subscribe(s) : i._trySubscribe(s));
@@ -358,12 +358,12 @@ var G = function() {
358
358
  }, n.prototype._subscribe = function(t) {
359
359
  var e;
360
360
  return (e = this.source) === null || e === void 0 ? void 0 : e.subscribe(t);
361
- }, n.prototype[Ve] = function() {
361
+ }, n.prototype[Fe] = function() {
362
362
  return this;
363
363
  }, n.prototype.pipe = function() {
364
364
  for (var t = [], e = 0; e < arguments.length; e++)
365
365
  t[e] = arguments[e];
366
- return je(t)(this);
366
+ return Ne(t)(this);
367
367
  }, n.prototype.toPromise = function(t) {
368
368
  var e = this;
369
369
  return t = ce(t), new t(function(r, i) {
@@ -384,11 +384,11 @@ function ce(n) {
384
384
  var t;
385
385
  return (t = n ?? Se.Promise) !== null && t !== void 0 ? t : Promise;
386
386
  }
387
- function Fe(n) {
387
+ function Ve(n) {
388
388
  return n && m(n.next) && m(n.error) && m(n.complete);
389
389
  }
390
- function Ne(n) {
391
- return n && n instanceof ee || Fe(n) && we(n);
390
+ function je(n) {
391
+ return n && n instanceof ee || Ve(n) && we(n);
392
392
  }
393
393
  function De(n) {
394
394
  return m(n == null ? void 0 : n.lift);
@@ -406,11 +406,11 @@ function Ce(n) {
406
406
  throw new TypeError("Unable to lift unknown Observable type");
407
407
  };
408
408
  }
409
- function xe(n, t, e, r, i) {
409
+ function Me(n, t, e, r, i) {
410
410
  return new Be(n, t, e, r, i);
411
411
  }
412
412
  var Be = function(n) {
413
- x(t, n);
413
+ M(t, n);
414
414
  function t(e, r, i, s, o, u) {
415
415
  var c = n.call(this, e) || this;
416
416
  return c.onFinalize = o, c.shouldUnsubscribe = u, c._next = r ? function(a) {
@@ -448,8 +448,8 @@ var Be = function(n) {
448
448
  return function() {
449
449
  n(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
450
450
  };
451
- }), Me = function(n) {
452
- x(t, n);
451
+ }), xe = function(n) {
452
+ M(t, n);
453
453
  function t() {
454
454
  var e = n.call(this) || this;
455
455
  return e.closed = !1, e.currentObservers = null, e.observers = [], e.isStopped = !1, e.hasError = !1, e.thrownError = null, e;
@@ -516,7 +516,7 @@ var Be = function(n) {
516
516
  return this._throwIfClosed(), this._checkFinalizedStatuses(e), this._innerSubscribe(e);
517
517
  }, t.prototype._innerSubscribe = function(e) {
518
518
  var r = this, i = this, s = i.hasError, o = i.isStopped, u = i.observers;
519
- return s || o ? me : (this.currentObservers = null, u.push(e), new I(function() {
519
+ return s || o ? me : (this.currentObservers = null, u.push(e), new R(function() {
520
520
  r.currentObservers = null, U(u, e);
521
521
  }));
522
522
  }, t.prototype._checkFinalizedStatuses = function(e) {
@@ -529,7 +529,7 @@ var Be = function(n) {
529
529
  return new ue(e, r);
530
530
  }, t;
531
531
  }(G), ue = function(n) {
532
- x(t, n);
532
+ M(t, n);
533
533
  function t(e, r) {
534
534
  var i = n.call(this) || this;
535
535
  return i.destination = e, i.source = r, i;
@@ -547,33 +547,33 @@ var Be = function(n) {
547
547
  var r, i;
548
548
  return (i = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(e)) !== null && i !== void 0 ? i : me;
549
549
  }, t;
550
- }(Me), _e = {
550
+ }(xe), _e = {
551
551
  now: function() {
552
552
  return (_e.delegate || Date).now();
553
553
  },
554
554
  delegate: void 0
555
555
  }, He = function(n) {
556
- x(t, n);
556
+ M(t, n);
557
557
  function t(e, r) {
558
558
  return n.call(this) || this;
559
559
  }
560
560
  return t.prototype.schedule = function(e, r) {
561
561
  return this;
562
562
  }, t;
563
- }(I), V = {
563
+ }(R), F = {
564
564
  setInterval: function(n, t) {
565
565
  for (var e = [], r = 2; r < arguments.length; r++)
566
566
  e[r - 2] = arguments[r];
567
- var i = V.delegate;
567
+ var i = F.delegate;
568
568
  return i != null && i.setInterval ? i.setInterval.apply(i, T([n, t], _(e))) : setInterval.apply(void 0, T([n, t], _(e)));
569
569
  },
570
570
  clearInterval: function(n) {
571
- var t = V.delegate;
571
+ var t = F.delegate;
572
572
  return ((t == null ? void 0 : t.clearInterval) || clearInterval)(n);
573
573
  },
574
574
  delegate: void 0
575
575
  }, ze = function(n) {
576
- x(t, n);
576
+ M(t, n);
577
577
  function t(e, r) {
578
578
  var i = n.call(this, e, r) || this;
579
579
  return i.scheduler = e, i.work = r, i.pending = !1, i;
@@ -586,11 +586,11 @@ var Be = function(n) {
586
586
  var s = this.id, o = this.scheduler;
587
587
  return s != null && (this.id = this.recycleAsyncId(o, s, r)), this.pending = !0, this.delay = r, this.id = (i = this.id) !== null && i !== void 0 ? i : this.requestAsyncId(o, this.id, r), this;
588
588
  }, t.prototype.requestAsyncId = function(e, r, i) {
589
- return i === void 0 && (i = 0), V.setInterval(e.flush.bind(e, this), i);
589
+ return i === void 0 && (i = 0), F.setInterval(e.flush.bind(e, this), i);
590
590
  }, t.prototype.recycleAsyncId = function(e, r, i) {
591
591
  if (i === void 0 && (i = 0), i != null && this.delay === i && this.pending === !1)
592
592
  return r;
593
- r != null && V.clearInterval(r);
593
+ r != null && F.clearInterval(r);
594
594
  }, t.prototype.execute = function(e, r) {
595
595
  if (this.closed)
596
596
  return new Error("executing a cancelled action");
@@ -622,7 +622,7 @@ var Be = function(n) {
622
622
  return e === void 0 && (e = 0), new this.schedulerActionCtor(this, t).schedule(r, e);
623
623
  }, n.now = _e.now, n;
624
624
  }(), Qe = function(n) {
625
- x(t, n);
625
+ M(t, n);
626
626
  function t(e, r) {
627
627
  r === void 0 && (r = ae.now);
628
628
  var i = n.call(this, e, r) || this;
@@ -676,7 +676,7 @@ function We(n) {
676
676
  function A(n, t) {
677
677
  return Ce(function(e, r) {
678
678
  var i = 0;
679
- e.subscribe(xe(r, function(s) {
679
+ e.subscribe(Me(r, function(s) {
680
680
  r.next(n.call(t, s, i++));
681
681
  }));
682
682
  });
@@ -699,7 +699,7 @@ function Ze(n, t, e) {
699
699
  var o;
700
700
  (o = r.subscribe) === null || o === void 0 || o.call(r);
701
701
  var u = !0;
702
- i.subscribe(xe(s, function(c) {
702
+ i.subscribe(Me(s, function(c) {
703
703
  var a;
704
704
  (a = r.next) === null || a === void 0 || a.call(r, c), s.next(c);
705
705
  }, function() {
@@ -754,7 +754,7 @@ function S(n) {
754
754
  function it(n) {
755
755
  return S(n == null ? void 0 : n.lift);
756
756
  }
757
- function j(n) {
757
+ function N(n) {
758
758
  return function(t) {
759
759
  if (it(t))
760
760
  return t.lift(function(e) {
@@ -859,8 +859,8 @@ var re = function() {
859
859
  var a = c.value;
860
860
  a.remove(this);
861
861
  }
862
- } catch (d) {
863
- t = { error: d };
862
+ } catch (p) {
863
+ t = { error: p };
864
864
  } finally {
865
865
  try {
866
866
  c && !c.done && (e = u.return) && e.call(u);
@@ -875,23 +875,23 @@ var re = function() {
875
875
  if (S(g))
876
876
  try {
877
877
  g();
878
- } catch (d) {
879
- s = d instanceof q ? d.errors : [d];
878
+ } catch (p) {
879
+ s = p instanceof q ? p.errors : [p];
880
880
  }
881
881
  var v = this._finalizers;
882
882
  if (v) {
883
883
  this._finalizers = null;
884
884
  try {
885
885
  for (var E = de(v), w = E.next(); !w.done; w = E.next()) {
886
- var N = w.value;
886
+ var j = w.value;
887
887
  try {
888
- fe(N);
889
- } catch (d) {
890
- s = s ?? [], d instanceof q ? s = W(W([], K(s)), K(d.errors)) : s.push(d);
888
+ fe(j);
889
+ } catch (p) {
890
+ s = s ?? [], p instanceof q ? s = W(W([], K(s)), K(p.errors)) : s.push(p);
891
891
  }
892
892
  }
893
- } catch (d) {
894
- r = { error: d };
893
+ } catch (p) {
894
+ r = { error: p };
895
895
  } finally {
896
896
  try {
897
897
  w && !w.done && (i = E.return) && i.call(E);
@@ -1072,11 +1072,11 @@ var dt = {
1072
1072
  }, pt = function() {
1073
1073
  return typeof Symbol == "function" && Symbol.observable || "@@observable";
1074
1074
  }();
1075
- function Ie(n) {
1075
+ function Re(n) {
1076
1076
  return n;
1077
1077
  }
1078
1078
  function ft(n) {
1079
- return n.length === 0 ? Ie : n.length === 1 ? n[0] : function(t) {
1079
+ return n.length === 0 ? Re : n.length === 1 ? n[0] : function(t) {
1080
1080
  return n.reduce(function(e, r) {
1081
1081
  return r(e);
1082
1082
  }, t);
@@ -1152,7 +1152,7 @@ function vt(n) {
1152
1152
  function yt(n) {
1153
1153
  return n && n instanceof ne || vt(n) && Te(n);
1154
1154
  }
1155
- function F(n, t, e, r, i) {
1155
+ function V(n, t, e, r, i) {
1156
1156
  return new bt(n, t, e, r, i);
1157
1157
  }
1158
1158
  var bt = function(n) {
@@ -1192,9 +1192,9 @@ var bt = function(n) {
1192
1192
  }, t;
1193
1193
  }(ne);
1194
1194
  function h(n, t) {
1195
- return j(function(e, r) {
1195
+ return N(function(e, r) {
1196
1196
  var i = 0;
1197
- e.subscribe(F(r, function(s) {
1197
+ e.subscribe(V(r, function(s) {
1198
1198
  r.next(n.call(t, s, i++));
1199
1199
  }));
1200
1200
  });
@@ -1202,31 +1202,31 @@ function h(n, t) {
1202
1202
  var mt = new gt(function(n) {
1203
1203
  return n.complete();
1204
1204
  });
1205
- function b(n) {
1205
+ function y(n) {
1206
1206
  return n <= 0 ? function() {
1207
1207
  return mt;
1208
- } : j(function(t, e) {
1208
+ } : N(function(t, e) {
1209
1209
  var r = 0;
1210
- t.subscribe(F(e, function(i) {
1210
+ t.subscribe(V(e, function(i) {
1211
1211
  ++r <= n && (e.next(i), n <= r && e.complete());
1212
1212
  }));
1213
1213
  });
1214
1214
  }
1215
1215
  function f(n, t) {
1216
- return j(function(e, r) {
1216
+ return N(function(e, r) {
1217
1217
  var i = 0;
1218
- e.subscribe(F(r, function(s) {
1218
+ e.subscribe(V(r, function(s) {
1219
1219
  return n.call(t, s, i++) && r.next(s);
1220
1220
  }));
1221
1221
  });
1222
1222
  }
1223
- function p(n, t, e) {
1223
+ function d(n, t, e) {
1224
1224
  var r = S(n) || t || e ? { next: n, error: t, complete: e } : n;
1225
- return r ? j(function(i, s) {
1225
+ return r ? N(function(i, s) {
1226
1226
  var o;
1227
1227
  (o = r.subscribe) === null || o === void 0 || o.call(r);
1228
1228
  var u = !0;
1229
- i.subscribe(F(s, function(c) {
1229
+ i.subscribe(V(s, function(c) {
1230
1230
  var a;
1231
1231
  (a = r.next) === null || a === void 0 || a.call(r, c), s.next(c);
1232
1232
  }, function() {
@@ -1239,7 +1239,7 @@ function p(n, t, e) {
1239
1239
  var c, a;
1240
1240
  u && ((c = r.unsubscribe) === null || c === void 0 || c.call(r)), (a = r.finalize) === null || a === void 0 || a.call(r);
1241
1241
  }));
1242
- }) : Ie;
1242
+ }) : Re;
1243
1243
  }
1244
1244
  const wt = /^(\d+)\.(\d+)$/;
1245
1245
  function St(n) {
@@ -1265,7 +1265,7 @@ function Ct(n, t) {
1265
1265
  return ie(n, t) >= 0;
1266
1266
  }
1267
1267
  const be = "2.0";
1268
- class xt {
1268
+ class Mt {
1269
1269
  /**
1270
1270
  * Create a new instance of the {@link IpcHelper | IPC Protocol Helper}.
1271
1271
  *
@@ -1276,7 +1276,7 @@ class xt {
1276
1276
  * @param logService - An instance of a logging service or utility
1277
1277
  */
1278
1278
  constructor(t, e) {
1279
- if (C(this, "negotiatedProtocolVersion"), C(this, "currentContext"), C(this, "incomingMessages$"), C(this, "inIframe", !1), C(this, "embeddedResult"), C(this, "iframePort1"), C(this, "iframePort2"), this.supportedVersions = t, this.logService = e, this.incomingMessages$ = new Me(), this.supportedVersions = t.filter((r) => Ct(r, be)), !this.supportedVersions.length)
1279
+ if (C(this, "negotiatedProtocolVersion"), C(this, "currentContext"), C(this, "incomingMessages$"), C(this, "inIframe", !1), C(this, "embeddedResult"), C(this, "iframePort1"), C(this, "iframePort2"), this.supportedVersions = t, this.logService = e, this.incomingMessages$ = new xe(), this.supportedVersions = t.filter((r) => Ct(r, be)), !this.supportedVersions.length)
1280
1280
  throw new he(t, be);
1281
1281
  this.negotiatedProtocolVersion = this.supportedVersions[0], this.embeddedResult = null, this.iframePort2 = null;
1282
1282
  }
@@ -1315,7 +1315,7 @@ class xt {
1315
1315
  determineContext() {
1316
1316
  return Xe(1e3).pipe(
1317
1317
  h(() => (this.isEmbedded() ? this.currentContext = "user" : this.currentContext = "guest", this.currentContext)),
1318
- b(1)
1318
+ y(1)
1319
1319
  );
1320
1320
  }
1321
1321
  /**
@@ -1332,18 +1332,18 @@ class xt {
1332
1332
  const r = this.incomingMessages$.pipe(
1333
1333
  f((i) => i.type === t && i.replyTo === e.id),
1334
1334
  h((i) => i),
1335
- p(this.logReceived(t)),
1335
+ d(this.logReceived(t)),
1336
1336
  h((i) => {
1337
1337
  if (this.supportedVersions.some((s) => Et(s, i.protocolVersion)))
1338
1338
  throw new he(i.protocolVersion, this.supportedVersions[0]);
1339
1339
  return i;
1340
1340
  }),
1341
- p((i) => {
1341
+ d((i) => {
1342
1342
  this.negotiatedProtocolVersion = i.protocolVersion, this.logService.info(
1343
1343
  `[IPC] Negotiated IPC Protocol Version: ${this.negotiatedProtocolVersion}`
1344
1344
  );
1345
1345
  }),
1346
- b(1)
1346
+ y(1)
1347
1347
  );
1348
1348
  return this.logService.debug(`Created ${t} Reply handler`), this.inIframe ? this.createIframeChannel().then(() => this.finishIpcSetup(e)) : this.finishIpcSetup(e), r;
1349
1349
  }
@@ -1362,8 +1362,8 @@ class xt {
1362
1362
  const r = this.incomingMessages$.pipe(
1363
1363
  f((i) => i.type === t && i.replyTo === e.id),
1364
1364
  h((i) => i),
1365
- p(this.logReceived(t)),
1366
- b(1)
1365
+ d(this.logReceived(t)),
1366
+ y(1)
1367
1367
  );
1368
1368
  return this.logService.debug(`Created ${t} Reply handler`), this.port2.postMessage(e), this.logSent(t, e), r;
1369
1369
  }
@@ -1445,7 +1445,7 @@ class xt {
1445
1445
  return this.incomingMessages$.pipe(
1446
1446
  f((e) => e.type === t && e.target === "client"),
1447
1447
  h((e) => e),
1448
- p(this.logReceived(t)),
1448
+ d(this.logReceived(t)),
1449
1449
  h((e) => e)
1450
1450
  );
1451
1451
  }
@@ -1481,7 +1481,7 @@ class xt {
1481
1481
  return this.incomingMessages$.pipe(
1482
1482
  f((e) => e.type === t && e.target === "client"),
1483
1483
  h((e) => e),
1484
- p(this.logReceived(t)),
1484
+ d(this.logReceived(t)),
1485
1485
  h((e) => e)
1486
1486
  );
1487
1487
  }
@@ -1518,7 +1518,7 @@ class xt {
1518
1518
  return this.incomingMessages$.pipe(
1519
1519
  f((e) => e.type === t && e.target === "client"),
1520
1520
  h((e) => e),
1521
- p(this.logReceived(t)),
1521
+ d(this.logReceived(t)),
1522
1522
  h((e) => ({
1523
1523
  preferredCameraType: e.preferredCameraType,
1524
1524
  preferredMicType: e.preferredMicType,
@@ -1541,9 +1541,9 @@ class xt {
1541
1541
  const i = this.incomingMessages$.pipe(
1542
1542
  f((s) => s.type === e && s.replyTo === r.id),
1543
1543
  h((s) => s),
1544
- p(this.logReceived(e)),
1544
+ d(this.logReceived(e)),
1545
1545
  h((s) => s),
1546
- b(1)
1546
+ y(1)
1547
1547
  );
1548
1548
  return this.logService.debug(`Created ${e} Reply handler`), this.port2.postMessage(r), this.logSent(e, r), i;
1549
1549
  }
@@ -1555,9 +1555,9 @@ class xt {
1555
1555
  if (e && r ? (s = this.createMessage(i, !1, r), s.result = e) : (s = this.createMessage(i), o = this.incomingMessages$.pipe(
1556
1556
  f((u) => u.type === i && u.replyTo === s.id),
1557
1557
  h((u) => u),
1558
- p(this.logReceived(i)),
1558
+ d(this.logReceived(i)),
1559
1559
  h((u) => u),
1560
- b(1)
1560
+ y(1)
1561
1561
  ), this.logService.debug(`Created ${i} Reply handler`)), s.layout = t, this.logCreated(i, s), this.port2.postMessage(s), this.logSent(i, s), o)
1562
1562
  return o;
1563
1563
  }
@@ -1599,7 +1599,7 @@ class xt {
1599
1599
  return this.incomingMessages$.pipe(
1600
1600
  f((e) => e.type === t && e.target === "client" && e.replyTo === null),
1601
1601
  h((e) => e),
1602
- p(this.logReceived(t)),
1602
+ d(this.logReceived(t)),
1603
1603
  h((e) => e)
1604
1604
  );
1605
1605
  }
@@ -1612,8 +1612,8 @@ class xt {
1612
1612
  const i = this.incomingMessages$.pipe(
1613
1613
  f((s) => s.type === e && s.replyTo === r.id),
1614
1614
  h((s) => s),
1615
- p(this.logReceived(e)),
1616
- b(1)
1615
+ d(this.logReceived(e)),
1616
+ y(1)
1617
1617
  );
1618
1618
  return this.logService.debug(`Created ${e} Reply handler`), this.port2.postMessage(r), this.logSent(e, r), i;
1619
1619
  }
@@ -1642,7 +1642,7 @@ class xt {
1642
1642
  o.streamType = e, o.streamId = t, o.contactType = r, o.currentContacts = i, this.logCreated(s, o);
1643
1643
  const u = this.incomingMessages$.pipe(
1644
1644
  f((c) => c.type === s && c.replyTo === o.id),
1645
- p(this.logReceived(s)),
1645
+ d(this.logReceived(s)),
1646
1646
  // validate if `streamId` is the same as we sent
1647
1647
  h((c) => {
1648
1648
  const a = c;
@@ -1650,7 +1650,7 @@ class xt {
1650
1650
  throw new rt(a.streamId, t);
1651
1651
  return e === "direct" && a.contacts.length > 1 && (a.contacts = [a.contacts[0]]), a;
1652
1652
  }),
1653
- b(1)
1653
+ y(1)
1654
1654
  );
1655
1655
  return this.logService.debug(`Created ${s} Reply handler`), this.port2.postMessage(o), this.logSent(s, o), u;
1656
1656
  }
@@ -1671,9 +1671,9 @@ class xt {
1671
1671
  r.contacts = [...t], this.logCreated(e, r);
1672
1672
  const i = this.incomingMessages$.pipe(
1673
1673
  f((s) => s.type === e && s.replyTo === r.id),
1674
- p(this.logReceived(e)),
1674
+ d(this.logReceived(e)),
1675
1675
  h((s) => s),
1676
- b(1)
1676
+ y(1)
1677
1677
  );
1678
1678
  return this.logService.debug(`Created ${e} Reply handler`), this.port2.postMessage(r), this.logSent(e, r), i;
1679
1679
  }
@@ -1710,7 +1710,7 @@ class xt {
1710
1710
  return this.incomingMessages$.pipe(
1711
1711
  f((e) => e.type === t && e.target === "client"),
1712
1712
  h((e) => e),
1713
- p(this.logReceived(t))
1713
+ d(this.logReceived(t))
1714
1714
  );
1715
1715
  }
1716
1716
  /**
@@ -1729,9 +1729,9 @@ class xt {
1729
1729
  this.logCreated(t, e);
1730
1730
  const r = this.incomingMessages$.pipe(
1731
1731
  f((i) => i.type === t && i.replyTo === e.id),
1732
- p(this.logReceived(t)),
1732
+ d(this.logReceived(t)),
1733
1733
  h((i) => i),
1734
- b(1)
1734
+ y(1)
1735
1735
  );
1736
1736
  return this.logService.debug(`Created ${t} Reply handler`), this.port2.postMessage(e), this.logSent(t, e), r;
1737
1737
  }
@@ -1775,8 +1775,8 @@ class xt {
1775
1775
  return e;
1776
1776
  throw new Error("PushTokenMessage is missing required PushTokenPayload fields");
1777
1777
  }),
1778
- p((e) => e.pushToken),
1779
- p(this.logReceived(t))
1778
+ d((e) => e.pushToken),
1779
+ d(this.logReceived(t))
1780
1780
  );
1781
1781
  }
1782
1782
  /**
@@ -1793,7 +1793,7 @@ class xt {
1793
1793
  return this.incomingMessages$.pipe(
1794
1794
  f((e) => e.type === t && e.target === "client"),
1795
1795
  h((e) => e),
1796
- p(this.logReceived(t))
1796
+ d(this.logReceived(t))
1797
1797
  );
1798
1798
  }
1799
1799
  /**
@@ -1851,7 +1851,7 @@ class xt {
1851
1851
  return this.incomingMessages$.pipe(
1852
1852
  f((e) => e.type === t && e.target === "client"),
1853
1853
  h((e) => e),
1854
- p(this.logReceived(t))
1854
+ d(this.logReceived(t))
1855
1855
  );
1856
1856
  }
1857
1857
  /**
@@ -1891,7 +1891,7 @@ class xt {
1891
1891
  return this.incomingMessages$.pipe(
1892
1892
  f((e) => e.type === t && e.target === "client"),
1893
1893
  h((e) => e),
1894
- p(this.logReceived(t))
1894
+ d(this.logReceived(t))
1895
1895
  );
1896
1896
  }
1897
1897
  /**
@@ -1922,14 +1922,38 @@ class xt {
1922
1922
  * integrity.
1923
1923
  *
1924
1924
  * @param payload - The {@link FileTransferPayload} to send to the host app.
1925
+ * @param shouldOpen - _Optional_. Whether the file should be opened after it's transferred.
1926
+ *
1927
+ * @returns This method returns void.
1928
+ */
1929
+ sendFileTransferMessage(t, e) {
1930
+ if (!this.isEmbedded())
1931
+ throw new l(this.currentContext);
1932
+ const r = "FILE TRANSFER", i = this.createMessage(r, !1);
1933
+ i.mimeType = t.mimeType, i.fileName = t.fileName, i.fileSize = t.fileSize, i.fileHash = t.fileHash, i.dataType = t.dataType, i.data = t.data, e && (i.shouldOpen = e), this.logCreated(r, i);
1934
+ const s = this.incomingMessages$.pipe(
1935
+ f((o) => o.type === r && o.replyTo === i.id),
1936
+ d(this.logReceived(r)),
1937
+ h((o) => o),
1938
+ y(1)
1939
+ );
1940
+ return this.port2.postMessage(i), this.logSent(r, i), s;
1941
+ }
1942
+ /**
1943
+ * Send a {@link FileTransferMessageReply} to the `Host` app, to reply to a
1944
+ * {@link FileTransferMessage} sent by the `Host` app.
1945
+ *
1946
+ * @param replyTo - ID of the {@link FileTransferMessage} being replied to
1947
+ * @param result - The result of the file transfer. Should be of {@link FileTransferMessageResult}
1948
+ * @param errorMessage - _Optional_. The error message to send if the result is `error`.
1925
1949
  *
1926
1950
  * @returns This method returns void.
1927
1951
  */
1928
- fileTransfer(t) {
1952
+ sendFileTransferMessageReply(t, e, r) {
1929
1953
  if (!this.isEmbedded())
1930
1954
  throw new l(this.currentContext);
1931
- const e = "FILE TRANSFER", r = this.createMessage(e, !1);
1932
- r.mimeType = t.mimeType, r.fileName = t.fileName, r.fileSize = t.fileSize, r.fileHash = t.fileHash, r.dataType = t.dataType, r.fileId = t.fileId, r.data = t.data, this.logCreated(e, r), this.port2.postMessage(r), this.logSent(e, r);
1955
+ const i = "FILE TRANSFER", s = this.createMessage(i, !1, t);
1956
+ s.result = e, r && e === "error" && (s.errorMessage = r), this.logCreated(i, s), this.port2.postMessage(s), this.logSent(i, s);
1933
1957
  }
1934
1958
  /**
1935
1959
  * Setup listener for {@link FileTransferMessage}, which can be sent by a `Host` app to transfer
@@ -1948,9 +1972,9 @@ class xt {
1948
1972
  throw new l(this.currentContext);
1949
1973
  const t = "FILE TRANSFER";
1950
1974
  return this.incomingMessages$.pipe(
1951
- f((e) => e.type === t && e.target === "client"),
1975
+ f((e) => e.type === t && e.target === "client" && e.replyTo === null),
1952
1976
  h((e) => e),
1953
- p(this.logReceived(t))
1977
+ d(this.logReceived(t))
1954
1978
  );
1955
1979
  }
1956
1980
  /**
@@ -1977,9 +2001,9 @@ class xt {
1977
2001
  i.maxCount = t, i.mimeTypes = e, this.logCreated(r, i);
1978
2002
  const s = this.incomingMessages$.pipe(
1979
2003
  f((o) => o.type === r && o.replyTo === i.id),
1980
- p(this.logReceived(r)),
2004
+ d(this.logReceived(r)),
1981
2005
  h((o) => o),
1982
- b(1)
2006
+ y(1)
1983
2007
  );
1984
2008
  return this.port2.postMessage(i), this.logSent(r, i), s;
1985
2009
  }
@@ -2007,9 +2031,9 @@ class xt {
2007
2031
  o.url = t, o.key = e, o.fileName = r, o.mimeType = i, this.logCreated(s, o);
2008
2032
  const u = this.incomingMessages$.pipe(
2009
2033
  f((c) => c.type === s && c.replyTo === o.id),
2010
- p(this.logReceived(s)),
2034
+ d(this.logReceived(s)),
2011
2035
  h((c) => c),
2012
- b(1)
2036
+ y(1)
2013
2037
  );
2014
2038
  return this.port2.postMessage(o), this.logSent(s, o), u;
2015
2039
  }
@@ -2017,32 +2041,27 @@ class xt {
2017
2041
  throw new Error("Not implemented");
2018
2042
  }
2019
2043
  /**
2020
- * Sends a {@link FileOpenMessage} to the Host app, to either open a file from the device's
2021
- * storage or download the specified encrypted file from the given URL and open it.
2044
+ * Sends a {@link FileOpenMessage} to the Host app, to try and open a file the device may already
2045
+ * have in it's storage.
2022
2046
  *
2023
2047
  * @remarks
2024
- * If the Client has previously resolved the `fileId` of the file, the `fileId` parameter can be
2025
- * used to open the file from the device's storage. Otherwise, the parameter is omitted and the
2026
- * file is downloaded from the specified `url`.
2048
+ * The `hash` parameter is the SHA256 hash of the decrypted file, which is used as an identifier
2049
+ * for the target file in the `Host` app as well as to verify the integrity of the file.
2027
2050
  *
2028
- * The file at the specified `url` is encrypted using the provided `key` and the Host app needs
2029
- * to decrypt it. The `mimeType` and `name` parameters are used to display the file in the Host
2030
- * app.
2031
- *
2032
- * The `hash` parameter is used to verify the integrity of the file.
2033
- *
2034
- * @param url - The URL of the encrypted file to download from.
2035
- * @param key - The decryption key for the encrypted file.
2036
- * @param mimeType - The MIME type of the file to open.
2037
- * @param name - The name of the file to open.
2038
2051
  * @param hash - The SHA256 hash of the file to open.
2039
- * @param fileId - _Optional_. The ID of the file to open.
2040
2052
  */
2041
- sendFileOpenMessage(t, e, r, i, s, o) {
2053
+ sendFileOpenMessage(t) {
2042
2054
  if (!this.isEmbedded())
2043
2055
  throw new l(this.currentContext);
2044
- const u = "FILE OPEN", c = this.createMessage(u, !1);
2045
- c.hash = s, c.url = t, c.key = e, c.mimeType = r, c.name = i, c.fileId = o, this.logCreated(u, c), this.port2.postMessage(c), this.logSent(u, c);
2056
+ const e = "FILE OPEN", r = this.createMessage(e, !0);
2057
+ r.hash = t, this.logCreated(e, r);
2058
+ const i = this.incomingMessages$.pipe(
2059
+ f((s) => s.type === e && s.replyTo === r.id),
2060
+ d(this.logReceived(e)),
2061
+ h((s) => s),
2062
+ y(1)
2063
+ );
2064
+ return this.port2.postMessage(r), this.logSent(e, r), i;
2046
2065
  }
2047
2066
  /**
2048
2067
  * Sends a {@link FileReferenceMessage} to the Host app, to request a reference to a file from
@@ -2066,9 +2085,9 @@ class xt {
2066
2085
  s.hash = t, s.mimeType = e, s.name = r, this.logCreated(i, s);
2067
2086
  const o = this.incomingMessages$.pipe(
2068
2087
  f((u) => u.type === i && u.replyTo === s.id),
2069
- p(this.logReceived(i)),
2088
+ d(this.logReceived(i)),
2070
2089
  h((u) => u),
2071
- b(1)
2090
+ y(1)
2072
2091
  );
2073
2092
  return this.port2.postMessage(s), this.logSent(i, s), o;
2074
2093
  }
@@ -2173,7 +2192,7 @@ class xt {
2173
2192
  return i.join("");
2174
2193
  }
2175
2194
  }
2176
- const Mt = ["2.0"];
2195
+ const xt = ["2.0"];
2177
2196
  class Tt {
2178
2197
  /**
2179
2198
  * A class that manages the IPC communication between the `Client` and the `Host`.
@@ -2189,15 +2208,15 @@ class Tt {
2189
2208
  /**
2190
2209
  * The type of the `Host` app the `Client` is embedded in.
2191
2210
  */
2192
- M(this, "host");
2211
+ x(this, "host");
2193
2212
  /**
2194
2213
  * The cloud ID of the `Host` app the `Client` is embedded in.
2195
2214
  */
2196
- M(this, "cloudId");
2197
- M(this, "logger");
2198
- M(this, "helper");
2199
- M(this, "listeners");
2200
- this.logger = t ?? console, this.helper = new xt(Mt, this.logger), this.listeners = /* @__PURE__ */ new Map(), this.listeners.set(y.BadgeQuery, /* @__PURE__ */ new Set()), this.listeners.set(y.Lifecycle, /* @__PURE__ */ new Set()), this.listeners.set(y.PushToken, /* @__PURE__ */ new Set());
2215
+ x(this, "cloudId");
2216
+ x(this, "logger");
2217
+ x(this, "helper");
2218
+ x(this, "listeners");
2219
+ this.logger = t ?? console, this.helper = new Mt(xt, this.logger), this.listeners = /* @__PURE__ */ new Map(), this.listeners.set(b.BadgeQuery, /* @__PURE__ */ new Set()), this.listeners.set(b.Lifecycle, /* @__PURE__ */ new Set()), this.listeners.set(b.PushToken, /* @__PURE__ */ new Set());
2201
2220
  }
2202
2221
  /**
2203
2222
  * Returns whether the app is running inside a native WebView (`host` context) or as a
@@ -2239,17 +2258,17 @@ class Tt {
2239
2258
  this.helper.onBadgeQueryMessage().subscribe((e) => {
2240
2259
  var r;
2241
2260
  this.logger.debug("Received Badge Query: ", e);
2242
- for (const i of ((r = this.listeners.get(y.BadgeQuery)) == null ? void 0 : r.values()) ?? [])
2261
+ for (const i of ((r = this.listeners.get(b.BadgeQuery)) == null ? void 0 : r.values()) ?? [])
2243
2262
  i();
2244
2263
  }), this.helper.onLifecycleMessage().subscribe((e) => {
2245
2264
  var r;
2246
2265
  this.logger.debug("Received Lifecycle Event: ", e);
2247
- for (const i of ((r = this.listeners.get(y.Lifecycle)) == null ? void 0 : r.values()) ?? [])
2266
+ for (const i of ((r = this.listeners.get(b.Lifecycle)) == null ? void 0 : r.values()) ?? [])
2248
2267
  i(e.eventName, e.payload);
2249
2268
  }), this.helper.onPushTokenMessage().subscribe((e) => {
2250
2269
  var r;
2251
2270
  this.logger.debug("Received Push Token: ", e);
2252
- for (const i of ((r = this.listeners.get(y.PushToken)) == null ? void 0 : r.values()) ?? [])
2271
+ for (const i of ((r = this.listeners.get(b.PushToken)) == null ? void 0 : r.values()) ?? [])
2253
2272
  i(e.pushToken, e.appId, e.selector, e.expiry);
2254
2273
  }), this.cloudId = t.cloudId, this.host = t.host;
2255
2274
  }),
@@ -2326,9 +2345,9 @@ class Tt {
2326
2345
  */
2327
2346
  onBadgeQueryRequest(t) {
2328
2347
  var e;
2329
- return this.logger.debug("Registering for Badge Query"), (e = this.listeners.get(y.BadgeQuery)) == null || e.add(t), () => {
2348
+ return this.logger.debug("Registering for Badge Query"), (e = this.listeners.get(b.BadgeQuery)) == null || e.add(t), () => {
2330
2349
  var r;
2331
- return (r = this.listeners.get(y.BadgeQuery)) == null ? void 0 : r.delete(t);
2350
+ return (r = this.listeners.get(b.BadgeQuery)) == null ? void 0 : r.delete(t);
2332
2351
  };
2333
2352
  }
2334
2353
  /**
@@ -2345,9 +2364,9 @@ class Tt {
2345
2364
  */
2346
2365
  onLifecycleEvent(t) {
2347
2366
  var e;
2348
- return this.logger.debug("Registering for Lifecycle Event"), (e = this.listeners.get(y.Lifecycle)) == null || e.add(t), () => {
2367
+ return this.logger.debug("Registering for Lifecycle Event"), (e = this.listeners.get(b.Lifecycle)) == null || e.add(t), () => {
2349
2368
  var r;
2350
- return (r = this.listeners.get(y.Lifecycle)) == null ? void 0 : r.delete(t);
2369
+ return (r = this.listeners.get(b.Lifecycle)) == null ? void 0 : r.delete(t);
2351
2370
  };
2352
2371
  }
2353
2372
  /**
@@ -2363,9 +2382,9 @@ class Tt {
2363
2382
  */
2364
2383
  onPushToken(t) {
2365
2384
  var e;
2366
- return this.logger.debug("Registering for Push Token"), (e = this.listeners.get(y.PushToken)) == null || e.add(t), () => {
2385
+ return this.logger.debug("Registering for Push Token"), (e = this.listeners.get(b.PushToken)) == null || e.add(t), () => {
2367
2386
  var r;
2368
- return (r = this.listeners.get(y.PushToken)) == null ? void 0 : r.delete(t);
2387
+ return (r = this.listeners.get(b.PushToken)) == null ? void 0 : r.delete(t);
2369
2388
  };
2370
2389
  }
2371
2390
  evaluateContext(t) {
@@ -2376,6 +2395,6 @@ class Tt {
2376
2395
  }
2377
2396
  }
2378
2397
  export {
2379
- y as IPCEvents,
2398
+ b as IPCEvents,
2380
2399
  Tt as IPCManager
2381
2400
  };