@acrobits/ipc-sdk 0.1.8 → 0.2.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/lib/index.d.ts CHANGED
@@ -12,6 +12,10 @@ export declare interface BaseContactItem {
12
12
  * Cloud ID associated with the contact.
13
13
  */
14
14
  cloudId: string;
15
+ /**
16
+ * Network ID for the contact.
17
+ */
18
+ networkId: string;
15
19
  }
16
20
 
17
21
  /**
@@ -84,6 +88,10 @@ export declare interface DetailedContactItem {
84
88
  * Cloud username associated with the contact.
85
89
  */
86
90
  cloudUsername: string;
91
+ /**
92
+ * Network ID for the contact.
93
+ */
94
+ networkId: string;
87
95
  /**
88
96
  * URI or number associated with the contact with prefix (e.g. sip: or tel:)
89
97
  */
@@ -212,11 +220,13 @@ export declare class IPCManager {
212
220
  *
213
221
  * @param corelationId - An identifier for the message stream
214
222
  * @param mode - _Optional_. Whether to allow `single` or `multi` contact selection.
223
+ * @param contactType - _Optional_. The type of contacts to be selected. This can be either
224
+ * `cloudUsername` or `uri`. Defaults to `cloudUsername`.
215
225
  *
216
226
  * @returns A collection of {@link ContactItem} objects which the user selected along with the
217
227
  * `corelationId`.
218
228
  */
219
- selectContacts(corelationId: number, mode?: 'single'): Promise<ContactItem[]>;
229
+ selectContacts(corelationId: number, mode?: 'single', contactType?: ContactType): Promise<ContactItem[]>;
220
230
  /**
221
231
  * Requests the `Host` app to open the contact selection UI.
222
232
  *
@@ -231,11 +241,13 @@ export declare class IPCManager {
231
241
  * @param mode - Whether to allow `single` or `multi` contact selection.
232
242
  * @param currentContacts - A list of {@link ContactItem} objects that are currently selected.
233
243
  * This is used to highlight the current contacts from the selection UI.
244
+ * @param contactType - _Optional_. The type of contacts to be selected. This can be either
245
+ * `cloudUsername` or `uri`. Defaults to `cloudUsername`.
234
246
  *
235
247
  * @returns A collection of {@link ContactItem} objects which the user selected along with the
236
248
  * `corelationId`.
237
249
  */
238
- selectContacts(streamId: number, mode: 'multi', currentContacts: ContactItem[]): Promise<ContactItem[]>;
250
+ selectContacts(corelationId: number, mode: 'multi', currentContacts: ContactItem[], contactType?: ContactType): Promise<ContactItem[]>;
239
251
  /**
240
252
  * Matches batch of {@link ContactItem} objects against the Host's contact list to fetch detailed
241
253
  * contact information.
package/lib/ipc-sdk.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var Pe = Object.defineProperty;
2
- var Ae = (n, t, e) => t in n ? Pe(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var _ = (n, t, e) => (Ae(n, typeof t != "symbol" ? t + "" : t, e), e);
4
- var C = /* @__PURE__ */ ((n) => (n.BadgeQuery = "BADGE QUERY", n.HostInForeground = "HOST IN FOREGROUND", n))(C || {}), Q = function(n, t) {
2
+ var Re = (n, t, e) => t in n ? Pe(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var _ = (n, t, e) => (Re(n, typeof t != "symbol" ? t + "" : t, e), e);
4
+ var E = /* @__PURE__ */ ((n) => (n.BadgeQuery = "BADGE QUERY", n.HostInForeground = "HOST IN FOREGROUND", n))(E || {}), Q = function(n, t) {
5
5
  return Q = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
6
6
  e.__proto__ = r;
7
7
  } || function(e, r) {
@@ -80,7 +80,7 @@ function L(n, t) {
80
80
  0 <= e && n.splice(e, 1);
81
81
  }
82
82
  }
83
- var T = function() {
83
+ var A = function() {
84
84
  function n(t) {
85
85
  this.initialTeardown = t, this.closed = !1, this._parentage = null, this._finalizers = null;
86
86
  }
@@ -170,9 +170,9 @@ var T = function() {
170
170
  var t = new n();
171
171
  return t.closed = !0, t;
172
172
  }(), n;
173
- }(), me = T.EMPTY;
173
+ }(), me = A.EMPTY;
174
174
  function we(n) {
175
- return n instanceof T || n && "closed" in n && b(n.remove) && b(n.add) && b(n.unsubscribe);
175
+ return n instanceof A || n && "closed" in n && b(n.remove) && b(n.add) && b(n.unsubscribe);
176
176
  }
177
177
  function oe(n) {
178
178
  b(n) ? n() : n.unsubscribe();
@@ -196,7 +196,7 @@ var Se = {
196
196
  },
197
197
  delegate: void 0
198
198
  };
199
- function Re(n) {
199
+ function Te(n) {
200
200
  z.setTimeout(function() {
201
201
  throw n;
202
202
  });
@@ -237,7 +237,7 @@ var ee = function(n) {
237
237
  this.unsubscribe();
238
238
  }
239
239
  }, t;
240
- }(T), Ue = Function.prototype.bind;
240
+ }(A), Ue = Function.prototype.bind;
241
241
  function k(n, t) {
242
242
  return Ue.call(n, t);
243
243
  }
@@ -297,7 +297,7 @@ var $e = function() {
297
297
  return t;
298
298
  }(ee);
299
299
  function P(n) {
300
- Re(n);
300
+ Te(n);
301
301
  }
302
302
  function Le(n) {
303
303
  throw n;
@@ -310,11 +310,11 @@ var Ve = {
310
310
  }, je = function() {
311
311
  return typeof Symbol == "function" && Symbol.observable || "@@observable";
312
312
  }();
313
- function Ce(n) {
313
+ function Ee(n) {
314
314
  return n;
315
315
  }
316
316
  function Fe(n) {
317
- return n.length === 0 ? Ce : n.length === 1 ? n[0] : function(e) {
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);
320
320
  }, e);
@@ -393,7 +393,7 @@ function De(n) {
393
393
  function Ne(n) {
394
394
  return b(n == null ? void 0 : n.lift);
395
395
  }
396
- function Ee(n) {
396
+ function Ce(n) {
397
397
  return function(t) {
398
398
  if (Ne(t))
399
399
  return t.lift(function(e) {
@@ -516,7 +516,7 @@ var ke = 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, o = i.hasError, s = i.isStopped, c = i.observers;
519
- return o || s ? me : (this.currentObservers = null, c.push(e), new T(function() {
519
+ return o || s ? me : (this.currentObservers = null, c.push(e), new A(function() {
520
520
  r.currentObservers = null, L(c, e);
521
521
  }));
522
522
  }, t.prototype._checkFinalizedStatuses = function(e) {
@@ -560,7 +560,7 @@ var ke = function(n) {
560
560
  return t.prototype.schedule = function(e, r) {
561
561
  return this;
562
562
  }, t;
563
- }(T), j = {
563
+ }(A), j = {
564
564
  setInterval: function(n, t) {
565
565
  for (var e = [], r = 2; r < arguments.length; r++)
566
566
  e[r - 2] = arguments[r];
@@ -673,8 +673,8 @@ function O(n, t) {
673
673
  function Ke(n) {
674
674
  return n instanceof Date && !isNaN(n);
675
675
  }
676
- function A(n, t) {
677
- return Ee(function(e, r) {
676
+ function R(n, t) {
677
+ return Ce(function(e, r) {
678
678
  var i = 0;
679
679
  e.subscribe(xe(r, function(o) {
680
680
  r.next(n.call(t, o, i++));
@@ -695,7 +695,7 @@ function Xe(n, t, e) {
695
695
  }
696
696
  function Ze(n, t, e) {
697
697
  var r = b(n) || t || e ? { next: n, error: t, complete: e } : n;
698
- return r ? Ee(function(i, o) {
698
+ return r ? Ce(function(i, o) {
699
699
  var s;
700
700
  (s = r.subscribe) === null || s === void 0 || s.call(r);
701
701
  var c = !0;
@@ -712,12 +712,12 @@ function Ze(n, t, e) {
712
712
  var u, a;
713
713
  c && ((u = r.unsubscribe) === null || u === void 0 || u.call(r)), (a = r.finalize) === null || a === void 0 || a.call(r);
714
714
  }));
715
- }) : Ce;
715
+ }) : Ee;
716
716
  }
717
- var et = Object.defineProperty, tt = (n, t, e) => t in n ? et(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, E = (n, t, e) => (tt(n, typeof t != "symbol" ? t + "" : t, e), e);
717
+ var et = Object.defineProperty, tt = (n, t, e) => t in n ? et(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, C = (n, t, e) => (tt(n, typeof t != "symbol" ? t + "" : t, e), e);
718
718
  class h extends Error {
719
719
  constructor(t) {
720
- super(`Incorrect context (${t}). Cannot perform the requested operation.`), E(this, "context"), this.context = t;
720
+ super(`Incorrect context (${t}). Cannot perform the requested operation.`), C(this, "context"), this.context = t;
721
721
  }
722
722
  }
723
723
  class $ extends Error {
@@ -1013,7 +1013,7 @@ var lt = function() {
1013
1013
  try {
1014
1014
  e.next(t);
1015
1015
  } catch (r) {
1016
- R(r);
1016
+ T(r);
1017
1017
  }
1018
1018
  }, n.prototype.error = function(t) {
1019
1019
  var e = this.partialObserver;
@@ -1021,17 +1021,17 @@ var lt = function() {
1021
1021
  try {
1022
1022
  e.error(t);
1023
1023
  } catch (r) {
1024
- R(r);
1024
+ T(r);
1025
1025
  }
1026
1026
  else
1027
- R(t);
1027
+ T(t);
1028
1028
  }, n.prototype.complete = function() {
1029
1029
  var t = this.partialObserver;
1030
1030
  if (t.complete)
1031
1031
  try {
1032
1032
  t.complete();
1033
1033
  } catch (e) {
1034
- R(e);
1034
+ T(e);
1035
1035
  }
1036
1036
  }, n;
1037
1037
  }(), X = function(n) {
@@ -1058,7 +1058,7 @@ var lt = function() {
1058
1058
  }
1059
1059
  return t;
1060
1060
  }(ne);
1061
- function R(n) {
1061
+ function T(n) {
1062
1062
  ut(n);
1063
1063
  }
1064
1064
  function ht(n) {
@@ -1072,11 +1072,11 @@ var dt = {
1072
1072
  }, pt = function() {
1073
1073
  return typeof Symbol == "function" && Symbol.observable || "@@observable";
1074
1074
  }();
1075
- function Te(n) {
1075
+ function Ae(n) {
1076
1076
  return n;
1077
1077
  }
1078
1078
  function ft(n) {
1079
- return n.length === 0 ? Te : n.length === 1 ? n[0] : function(t) {
1079
+ return n.length === 0 ? Ae : n.length === 1 ? n[0] : function(t) {
1080
1080
  return n.reduce(function(e, r) {
1081
1081
  return r(e);
1082
1082
  }, t);
@@ -1239,7 +1239,7 @@ function p(n, t, e) {
1239
1239
  var u, a;
1240
1240
  c && ((u = r.unsubscribe) === null || u === void 0 || u.call(r)), (a = r.finalize) === null || a === void 0 || a.call(r);
1241
1241
  }));
1242
- }) : Te;
1242
+ }) : Ae;
1243
1243
  }
1244
1244
  const wt = /^(\d+)\.(\d+)$/;
1245
1245
  function St(n) {
@@ -1258,10 +1258,10 @@ function ie(n, t) {
1258
1258
  const [e, r] = be(n), [i, o] = be(t);
1259
1259
  return e < i ? -1 : e > i ? 1 : r < o ? -1 : r > o ? 1 : 0;
1260
1260
  }
1261
- function Ct(n, t) {
1261
+ function Et(n, t) {
1262
1262
  return ie(n, t) === 1;
1263
1263
  }
1264
- function Et(n, t) {
1264
+ function Ct(n, t) {
1265
1265
  return ie(n, t) >= 0;
1266
1266
  }
1267
1267
  const ye = "2.0";
@@ -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 (E(this, "negotiatedProtocolVersion"), E(this, "currentContext"), E(this, "incomingMessages$"), E(this, "inIframe", !1), E(this, "embeddedResult"), E(this, "iframePort1"), E(this, "iframePort2"), this.supportedVersions = t, this.logService = e, this.incomingMessages$ = new _e(), this.supportedVersions = t.filter((r) => Et(r, ye)), !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 _e(), this.supportedVersions = t.filter((r) => Ct(r, ye)), !this.supportedVersions.length)
1280
1280
  throw new he(t, ye);
1281
1281
  this.negotiatedProtocolVersion = this.supportedVersions[0], this.embeddedResult = null, this.iframePort2 = null;
1282
1282
  }
@@ -1334,7 +1334,7 @@ class xt {
1334
1334
  l((i) => i),
1335
1335
  p(this.logReceived(t)),
1336
1336
  l((i) => {
1337
- if (this.supportedVersions.some((o) => Ct(o, i.protocolVersion)))
1337
+ if (this.supportedVersions.some((o) => Et(o, i.protocolVersion)))
1338
1338
  throw new he(i.protocolVersion, this.supportedVersions[0]);
1339
1339
  return i;
1340
1340
  }),
@@ -1623,36 +1623,36 @@ class xt {
1623
1623
  const r = "OPEN URL", i = this.createMessage(r, !1);
1624
1624
  i.url = t, i.data = e, this.logCreated(r, i), this.port2.postMessage(i), this.logSent(r, i);
1625
1625
  }
1626
- selectContacts(t, e, r) {
1626
+ selectContacts(t, e, r, i) {
1627
1627
  if (!this.isEmbedded())
1628
1628
  throw new h(this.currentContext);
1629
- if (e === "group" && r === void 0)
1629
+ if (e === "group" && i === void 0)
1630
1630
  throw new $(
1631
1631
  "currentContacts",
1632
- r,
1632
+ i,
1633
1633
  "currentContacts is required for group streams"
1634
1634
  );
1635
- if (e === "direct" && r !== void 0)
1635
+ if (e === "direct" && i !== void 0)
1636
1636
  throw new $(
1637
1637
  "currentContacts",
1638
- r,
1638
+ i,
1639
1639
  "currentContacts should not be passed for direct streams"
1640
1640
  );
1641
- const i = "SELECT CONTACTS", o = this.createMessage(i, !0);
1642
- o.streamType = e, o.streamId = t, o.currentContacts = r, this.logCreated(i, o);
1643
- const s = this.incomingMessages$.pipe(
1644
- v((c) => c.type === i && c.replyTo === o.id),
1645
- p(this.logReceived(i)),
1641
+ const o = "SELECT CONTACTS", s = this.createMessage(o, !0);
1642
+ s.streamType = e, s.streamId = t, s.contactType = r, s.currentContacts = i, this.logCreated(o, s);
1643
+ const c = this.incomingMessages$.pipe(
1644
+ v((u) => u.type === o && u.replyTo === s.id),
1645
+ p(this.logReceived(o)),
1646
1646
  // validate if `streamId` is the same as we sent
1647
- l((c) => {
1648
- const u = c;
1649
- if (u.streamId !== t)
1650
- throw new rt(u.streamId, t);
1651
- return e === "direct" && u.contacts.length > 1 && (u.contacts = [u.contacts[0]]), u;
1647
+ l((u) => {
1648
+ const a = u;
1649
+ if (a.streamId !== t)
1650
+ throw new rt(a.streamId, t);
1651
+ return e === "direct" && a.contacts.length > 1 && (a.contacts = [a.contacts[0]]), a;
1652
1652
  }),
1653
1653
  S(1)
1654
1654
  );
1655
- return this.logService.debug(`Created ${i} Reply handler`), this.port2.postMessage(o), this.logSent(i, o), s;
1655
+ return this.logService.debug(`Created ${o} Reply handler`), this.port2.postMessage(s), this.logSent(o, s), c;
1656
1656
  }
1657
1657
  /**
1658
1658
  * Request detailed contact information for the given Cloud usernames.
@@ -1995,7 +1995,7 @@ class It {
1995
1995
  _(this, "logger");
1996
1996
  _(this, "helper");
1997
1997
  _(this, "listeners");
1998
- this.logger = t ?? console, this.helper = new xt(_t, this.logger), this.listeners = /* @__PURE__ */ new Map(), this.listeners.set(C.BadgeQuery, /* @__PURE__ */ new Set()), this.listeners.set(C.HostInForeground, /* @__PURE__ */ new Set());
1998
+ this.logger = t ?? console, this.helper = new xt(_t, this.logger), this.listeners = /* @__PURE__ */ new Map(), this.listeners.set(E.BadgeQuery, /* @__PURE__ */ new Set()), this.listeners.set(E.HostInForeground, /* @__PURE__ */ new Set());
1999
1999
  }
2000
2000
  /**
2001
2001
  * Returns whether the app is running inside a native WebView (`host` context) or as a
@@ -2037,34 +2037,39 @@ class It {
2037
2037
  this.helper.onBadgeQueryMessage().subscribe((e) => {
2038
2038
  var r;
2039
2039
  this.logger.debug("Received Badge Query: ", e);
2040
- for (const i of ((r = this.listeners.get(C.BadgeQuery)) == null ? void 0 : r.values()) ?? [])
2040
+ for (const i of ((r = this.listeners.get(E.BadgeQuery)) == null ? void 0 : r.values()) ?? [])
2041
2041
  i();
2042
2042
  }), this.helper.onHostInForegroundMessage().subscribe((e) => {
2043
2043
  var r;
2044
2044
  this.logger.debug("Received Host In Foreground: ", e);
2045
- for (const i of ((r = this.listeners.get(C.HostInForeground)) == null ? void 0 : r.values()) ?? [])
2045
+ for (const i of ((r = this.listeners.get(E.HostInForeground)) == null ? void 0 : r.values()) ?? [])
2046
2046
  i();
2047
2047
  }), this.cloudId = t.cloudId, this.host = t.host;
2048
2048
  }),
2049
- A(() => {
2049
+ R(() => {
2050
2050
  })
2051
2051
  )
2052
2052
  );
2053
2053
  }
2054
- selectContacts(t, e, r) {
2054
+ selectContacts(t, e, r, i) {
2055
2055
  this.logger.debug("Selecting Contacts: ", ...arguments);
2056
- let i;
2056
+ let o;
2057
2057
  if (e === "multi") {
2058
- if (!r)
2058
+ if (!r || !Array.isArray(r))
2059
2059
  throw new $(
2060
2060
  "currentContacts",
2061
2061
  r,
2062
2062
  "currentContacts is required for group streams"
2063
2063
  );
2064
- i = this.helper.selectContacts(t.toString(), "group", r);
2064
+ i || (i = "cloudUsername"), o = this.helper.selectContacts(
2065
+ t.toString(),
2066
+ "group",
2067
+ i,
2068
+ r
2069
+ );
2065
2070
  } else
2066
- i = this.helper.selectContacts(t.toString(), "direct");
2067
- return O(i.pipe(A((o) => o.contacts)));
2071
+ r ? i = r : i = "cloudUsername", o = this.helper.selectContacts(t.toString(), "direct", i);
2072
+ return O(o.pipe(R((s) => s.contacts)));
2068
2073
  }
2069
2074
  /**
2070
2075
  * Matches batch of {@link ContactItem} objects against the Host's contact list to fetch detailed
@@ -2076,7 +2081,7 @@ class It {
2076
2081
  * Host's contact list.
2077
2082
  */
2078
2083
  matchContacts(t) {
2079
- return this.logger.debug("Match Contacts: ", t), O(this.helper.matchContacts(t).pipe(A((e) => e.contacts)));
2084
+ return this.logger.debug("Match Contacts: ", t), O(this.helper.matchContacts(t).pipe(R((e) => e.contacts)));
2080
2085
  }
2081
2086
  /**
2082
2087
  * Requests the `Host` app to provide the Push Token for the current device.
@@ -2084,7 +2089,7 @@ class It {
2084
2089
  * @returns A promise with the Push Token as `string`.
2085
2090
  */
2086
2091
  requestPushToken() {
2087
- return this.logger.debug("Requesting Push Token"), O(this.helper.requestPushToken().pipe(A((t) => t.pushToken)));
2092
+ return this.logger.debug("Requesting Push Token"), O(this.helper.requestPushToken().pipe(R((t) => t.pushToken)));
2088
2093
  }
2089
2094
  /**
2090
2095
  * Sends the current badge count to the `Host` app.
@@ -2103,9 +2108,9 @@ class It {
2103
2108
  */
2104
2109
  onBadgeQueryRequest(t) {
2105
2110
  var e;
2106
- return this.logger.debug("Registering for Badge Query"), (e = this.listeners.get(C.BadgeQuery)) == null || e.add(t), () => {
2111
+ return this.logger.debug("Registering for Badge Query"), (e = this.listeners.get(E.BadgeQuery)) == null || e.add(t), () => {
2107
2112
  var r;
2108
- return (r = this.listeners.get(C.BadgeQuery)) == null ? void 0 : r.delete(t);
2113
+ return (r = this.listeners.get(E.BadgeQuery)) == null ? void 0 : r.delete(t);
2109
2114
  };
2110
2115
  }
2111
2116
  /**
@@ -2117,9 +2122,9 @@ class It {
2117
2122
  */
2118
2123
  onHostInForeground(t) {
2119
2124
  var e;
2120
- return this.logger.debug("Registering for Host In Foreground"), (e = this.listeners.get(C.HostInForeground)) == null || e.add(t), () => {
2125
+ return this.logger.debug("Registering for Host In Foreground"), (e = this.listeners.get(E.HostInForeground)) == null || e.add(t), () => {
2121
2126
  var r;
2122
- return (r = this.listeners.get(C.HostInForeground)) == null ? void 0 : r.delete(t);
2127
+ return (r = this.listeners.get(E.HostInForeground)) == null ? void 0 : r.delete(t);
2123
2128
  };
2124
2129
  }
2125
2130
  evaluateContext(t) {
@@ -2130,6 +2135,6 @@ class It {
2130
2135
  }
2131
2136
  }
2132
2137
  export {
2133
- C as IPCEvents,
2138
+ E as IPCEvents,
2134
2139
  It as IPCManager
2135
2140
  };