@openfin/fdc3-api 41.103.2 → 41.103.10

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/out/fdc3-api.js CHANGED
@@ -412,7 +412,6 @@ fdc3Channels2_0.createV2Channel = createV2Channel;
412
412
  // Generate an ID to make a session context group with. We will pass that ID to the Broker.
413
413
  // The broker will then setContext on that session context group later with our Intent Result,
414
414
  const guid = (0, utils_1.generateId)(); // TODO make this undefined in web
415
- let isPromiseSettled = false;
416
415
  // Adding the intentResolutionResultId to the intentObj. Because fireIntent only accepts a single arg, we have to slap it in here.
417
416
  const metadata = app ? { target: app, intentResolutionResultId: guid } : { intentResolutionResultId: guid };
418
417
  const intentObj = intent ? { name: intent, context, metadata } : { ...context, metadata };
@@ -428,21 +427,11 @@ fdc3Channels2_0.createV2Channel = createV2Channel;
428
427
  reject(new Error('getResult is not supported in this environment'));
429
428
  });
430
429
  });
431
- getResultPromise
432
- .then(() => {
433
- isPromiseSettled = true;
434
- })
435
- .catch(() => {
436
- isPromiseSettled = true;
437
- });
438
430
  // Set up the getResult call.
439
431
  const getResult = async () => {
440
- // All this mumbo jumbo is needed to make sure that getResult resolves correctly and conforms to the FDC3 spec.
441
- if (!isPromiseSettled) {
442
- return undefined;
443
- }
444
432
  let intentResult = await getResultPromise;
445
- if (isPromiseSettled && !intentResult) {
433
+ // void / no payload, or web path where subscribe resolves undefined (see getResultPromise above)
434
+ if (intentResult == null) {
446
435
  return undefined;
447
436
  }
448
437
  if (typeof intentResult !== 'object') {
@@ -495,35 +484,6 @@ var InteropClient$1 = {};
495
484
 
496
485
  var base = {};
497
486
 
498
- var promises = {};
499
-
500
- Object.defineProperty(promises, "__esModule", { value: true });
501
- promises.promiseMapSerial = promises.serial = promises.promiseMap = promises.promisify = void 0;
502
- function promisify(func) {
503
- return (...args) => new Promise((resolve, reject) => {
504
- func(...args, (err, val) => (err ? reject(err) : resolve(val)));
505
- });
506
- }
507
- promises.promisify = promisify;
508
- async function promiseMap(arr, asyncF) {
509
- return Promise.all(arr.map(asyncF));
510
- }
511
- promises.promiseMap = promiseMap;
512
- async function serial(arr) {
513
- const ret = [];
514
- for (const func of arr) {
515
- // eslint-disable-next-line no-await-in-loop
516
- const next = await func();
517
- ret.push(next);
518
- }
519
- return ret;
520
- }
521
- promises.serial = serial;
522
- async function promiseMapSerial(arr, func) {
523
- return serial(arr.map((value, index, array) => () => func(value, index, array)));
524
- }
525
- promises.promiseMapSerial = promiseMapSerial;
526
-
527
487
  var __classPrivateFieldSet$3 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
528
488
  if (kind === "m") throw new TypeError("Private method is not writable");
529
489
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
@@ -538,7 +498,6 @@ var __classPrivateFieldGet$3 = (commonjsGlobal && commonjsGlobal.__classPrivateF
538
498
  var _EmitterBase_emitterAccessor, _EmitterBase_deregisterOnceListeners;
539
499
  Object.defineProperty(base, "__esModule", { value: true });
540
500
  base.Reply = base.EmitterBase = base.Base = void 0;
541
- const promises_1 = promises;
542
501
  class Base {
543
502
  /**
544
503
  * @internal
@@ -616,27 +575,8 @@ class EmitterBase extends Base {
616
575
  return this.hasEmitter() ? this.getOrCreateEmitter().emit(eventType, payload, ...args) : false;
617
576
  };
618
577
  this.hasEmitter = () => this.wire.eventAggregator.has(__classPrivateFieldGet$3(this, _EmitterBase_emitterAccessor, "f"));
619
- /**
620
- * Cleans up after removal of a listener, e.g. deleting any lingering deregistration handlers for a
621
- * `once` subscription.
622
- *
623
- * @remarks Implementing this as a `removeListener` handler ensures that direct removal of a listener
624
- * on the base emitter will not leak additional core handlers. We could do this in the forwarding method,
625
- * which would involve less "magic," but would be more-vulnerable to accidental re-introduction of a leak.
626
- */
627
- this.cleanUpRemovedListener = (eventType, listener) => {
628
- const deregister = __classPrivateFieldGet$3(this, _EmitterBase_deregisterOnceListeners, "f").get(listener);
629
- if (deregister) {
630
- const emitter = this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$3(this, _EmitterBase_emitterAccessor, "f"));
631
- emitter.removeListener(eventType, deregister);
632
- }
633
- };
634
578
  this.getOrCreateEmitter = () => {
635
- const emitter = this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$3(this, _EmitterBase_emitterAccessor, "f"));
636
- if (!emitter.listeners('removeListener').includes(this.cleanUpRemovedListener)) {
637
- emitter.on('removeListener', this.cleanUpRemovedListener);
638
- }
639
- return emitter;
579
+ return this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$3(this, _EmitterBase_emitterAccessor, "f"));
640
580
  };
641
581
  this.listeners = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(type) : [];
642
582
  this.listenerCount = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listenerCount(type) : 0;
@@ -676,7 +616,6 @@ class EmitterBase extends Base {
676
616
  };
677
617
  __classPrivateFieldSet$3(this, _EmitterBase_emitterAccessor, [topic, ...additionalAccessors], "f");
678
618
  __classPrivateFieldSet$3(this, _EmitterBase_deregisterOnceListeners, new WeakMap(), "f");
679
- this.listeners = (event) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(event) : [];
680
619
  }
681
620
  /**
682
621
  * Adds a listener to the end of the listeners array for the specified event.
@@ -754,6 +693,10 @@ class EmitterBase extends Base {
754
693
  const emitter = await this.deregisterEventListener(eventType, options);
755
694
  if (emitter) {
756
695
  emitter.removeListener(eventType, listener);
696
+ const deregister = __classPrivateFieldGet$3(this, _EmitterBase_deregisterOnceListeners, "f").get(listener);
697
+ if (deregister) {
698
+ emitter.removeListener(eventType, deregister);
699
+ }
757
700
  this.deleteEmitterIfNothingRegistered(emitter);
758
701
  }
759
702
  return this;
@@ -789,12 +732,13 @@ class EmitterBase extends Base {
789
732
  }
790
733
  else if (this.hasEmitter()) {
791
734
  const events = this.getOrCreateEmitter().eventNames();
792
- await (0, promises_1.promiseMap)(events, removeByEvent);
735
+ await Promise.all(events.map(removeByEvent));
793
736
  }
794
737
  return this;
795
738
  }
796
739
  deleteEmitterIfNothingRegistered(emitter) {
797
- if (emitter.eventNames().every((type) => type === 'removeListener')) {
740
+ // TODO: maybe emitterMap should clean up itself..
741
+ if (emitter.eventNames().length === 0) {
798
742
  this.wire.eventAggregator.delete(__classPrivateFieldGet$3(this, _EmitterBase_emitterAccessor, "f"));
799
743
  }
800
744
  }
@@ -1535,9 +1479,7 @@ class FDC3ModuleBase {
1535
1479
  * @static
1536
1480
  */
1537
1481
  async broadcast(context) {
1538
- this.wire.sendAction('fdc3-broadcast').catch((e) => {
1539
- // we do not want to expose this error, just continue if this analytics-only call fails
1540
- });
1482
+ this.wire.recordAnalytic('fdc3-broadcast');
1541
1483
  return this.client.setContext(context);
1542
1484
  }
1543
1485
  /**
@@ -1548,9 +1490,7 @@ class FDC3ModuleBase {
1548
1490
  * @tutorial fdc3.open
1549
1491
  */
1550
1492
  async _open(app, context) {
1551
- this.wire.sendAction('fdc3-open').catch((e) => {
1552
- // we do not want to expose this error, just continue if this analytics-only call fails
1553
- });
1493
+ this.wire.recordAnalytic('fdc3-open');
1554
1494
  try {
1555
1495
  return await InteropClient_1$1.InteropClient.ferryFdc3Call(this.client, 'fdc3Open', { app, context });
1556
1496
  }
@@ -1574,9 +1514,7 @@ class FDC3ModuleBase {
1574
1514
  * @tutorial fdc3.getOrCreateChannel
1575
1515
  */
1576
1516
  async getOrCreateChannel(channelId, fdc3Factory) {
1577
- this.wire.sendAction('fdc3-get-or-create-channel').catch((e) => {
1578
- // we do not want to expose this error, just continue if this analytics-only call fails
1579
- });
1517
+ this.wire.recordAnalytic('fdc3-get-or-create-channel');
1580
1518
  const hasChannelIdBeenUsed = await InteropClient_1$1.InteropClient.ferryFdc3Call(this.client, 'isIdUsedByPrivateChannel', {
1581
1519
  channelId
1582
1520
  });
@@ -1604,9 +1542,7 @@ class FDC3ModuleBase {
1604
1542
  * @static
1605
1543
  */
1606
1544
  async getSystemChannels() {
1607
- this.wire.sendAction('fdc3-get-system-channels').catch((e) => {
1608
- // we do not want to expose this error, just continue if this analytics-only call fails
1609
- });
1545
+ this.wire.recordAnalytic('fdc3-get-system-channels');
1610
1546
  return this._getChannels();
1611
1547
  }
1612
1548
  /**
@@ -1621,9 +1557,7 @@ class FDC3ModuleBase {
1621
1557
  * @static
1622
1558
  */
1623
1559
  async joinChannel(channelId) {
1624
- this.wire.sendAction('fdc3-join-channel').catch((e) => {
1625
- // we do not want to expose this error, just continue if this analytics-only call fails
1626
- });
1560
+ this.wire.recordAnalytic('fdc3-join-channel');
1627
1561
  try {
1628
1562
  return await this.client.joinContextGroup(channelId);
1629
1563
  }
@@ -1646,9 +1580,7 @@ class FDC3ModuleBase {
1646
1580
  * @tutorial fdc3.getCurrentChannel
1647
1581
  */
1648
1582
  async getCurrentChannel() {
1649
- this.wire.sendAction('fdc3-get-current-channel').catch((e) => {
1650
- // we do not want to expose this error, just continue if this analytics-only call fails
1651
- });
1583
+ this.wire.recordAnalytic('fdc3-get-current-channel');
1652
1584
  const currentContextGroupInfo = await this.getCurrentContextGroupInfo();
1653
1585
  if (!currentContextGroupInfo) {
1654
1586
  return null;
@@ -1663,9 +1595,7 @@ class FDC3ModuleBase {
1663
1595
  * @static
1664
1596
  */
1665
1597
  async leaveCurrentChannel() {
1666
- this.wire.sendAction('fdc3-leave-current-channel').catch((e) => {
1667
- // we do not want to expose this error, just continue if this analytics-only call fails
1668
- });
1598
+ this.wire.recordAnalytic('fdc3-leave-current-channel');
1669
1599
  return this.client.removeFromContextGroup();
1670
1600
  }
1671
1601
  // utils
@@ -1791,9 +1721,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
1791
1721
  */
1792
1722
  // @ts-expect-error TODO [CORE-1524]
1793
1723
  addContextListener(contextType, handler) {
1794
- this.wire.sendAction('fdc3-add-context-listener').catch((e) => {
1795
- // we do not want to expose this error, just continue if this analytics-only call fails
1796
- });
1724
+ this.wire.recordAnalytic('fdc3-add-context-listener');
1797
1725
  let listener;
1798
1726
  if (typeof contextType === 'function') {
1799
1727
  console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
@@ -1816,9 +1744,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
1816
1744
  * @static
1817
1745
  */
1818
1746
  addIntentListener(intent, handler) {
1819
- this.wire.sendAction('fdc3-add-intent-listener').catch((e) => {
1820
- // we do not want to expose this error, just continue if this analytics-only call fails
1821
- });
1747
+ this.wire.recordAnalytic('fdc3-add-intent-listener');
1822
1748
  const contextHandler = (raisedIntent) => {
1823
1749
  const { context, metadata: intentMetadata } = raisedIntent;
1824
1750
  const { metadata } = context;
@@ -1846,9 +1772,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
1846
1772
  * @static
1847
1773
  */
1848
1774
  async raiseIntent(intent, context, app) {
1849
- this.wire.sendAction('fdc3-raise-intent').catch((e) => {
1850
- // we do not want to expose this error, just continue if this analytics-only call fails
1851
- });
1775
+ this.wire.recordAnalytic('fdc3-raise-intent');
1852
1776
  const intentObj = app
1853
1777
  ? { name: intent, context, metadata: { target: app } }
1854
1778
  : { name: intent, context };
@@ -1868,9 +1792,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
1868
1792
  * @tutorial fdc3.findIntent
1869
1793
  */
1870
1794
  async findIntent(intent, context) {
1871
- this.wire.sendAction('fdc3-find-intent').catch((e) => {
1872
- // we do not want to expose this error, just continue if this analytics-only call fails
1873
- });
1795
+ this.wire.recordAnalytic('fdc3-find-intent');
1874
1796
  try {
1875
1797
  return await this.client.getInfoForIntent({ name: intent, context });
1876
1798
  }
@@ -1886,9 +1808,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
1886
1808
  * @tutorial fdc3.findIntentsByContext
1887
1809
  */
1888
1810
  async findIntentsByContext(context) {
1889
- this.wire.sendAction('fdc3-find-intents-by-context').catch((e) => {
1890
- // we do not want to expose this error, just continue if this analytics-only call fails
1891
- });
1811
+ this.wire.recordAnalytic('fdc3-find-intents-by-context');
1892
1812
  try {
1893
1813
  return await this.client.getInfoForIntentsByContext(context);
1894
1814
  }
@@ -1905,9 +1825,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
1905
1825
  * @tutorial fdc3.raiseIntentForContext
1906
1826
  */
1907
1827
  async raiseIntentForContext(context, app) {
1908
- this.wire.sendAction('fdc3-raise-intent-for-context').catch((e) => {
1909
- // we do not want to expose this error, just continue if this analytics-only call fails
1910
- });
1828
+ this.wire.recordAnalytic('fdc3-raise-intent-for-context');
1911
1829
  try {
1912
1830
  return await this.client.fireIntentForContext({ ...context, metadata: { target: app } });
1913
1831
  }
@@ -1931,9 +1849,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
1931
1849
  * @tutorial fdc3.getInfo
1932
1850
  */
1933
1851
  getInfo() {
1934
- this.wire.sendAction('fdc3-get-info').catch((e) => {
1935
- // we do not want to expose this error, just continue if this analytics-only call fails
1936
- });
1852
+ this.wire.recordAnalytic('fdc3-get-info');
1937
1853
  const version = this.wire.environment.getAdapterVersionSync();
1938
1854
  return {
1939
1855
  providerVersion: version,
@@ -2013,9 +1929,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
2013
1929
  * @tutorial fdc3v2.findInstances
2014
1930
  */
2015
1931
  async findInstances(app) {
2016
- this.wire.sendAction('fdc3-find-instances').catch((e) => {
2017
- // we do not want to expose this error, just continue if this analytics-only call fails
2018
- });
1932
+ this.wire.recordAnalytic('fdc3-find-instances');
2019
1933
  try {
2020
1934
  return await InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'fdc3FindInstances', app);
2021
1935
  }
@@ -2031,9 +1945,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
2031
1945
  * @tutorial fdc3v2.getAppMetadata
2032
1946
  */
2033
1947
  async getAppMetadata(app) {
2034
- this.wire.sendAction('fdc3-get-app-metadata').catch((e) => {
2035
- // we do not want to expose this error, just continue if this analytics-only call fails
2036
- });
1948
+ this.wire.recordAnalytic('fdc3-get-app-metadata');
2037
1949
  try {
2038
1950
  return await InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'fdc3GetAppMetadata', app);
2039
1951
  }
@@ -2051,9 +1963,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
2051
1963
  */
2052
1964
  // @ts-expect-error TODO [CORE-1524]
2053
1965
  async addContextListener(contextType, handler) {
2054
- this.wire.sendAction('fdc3-add-context-listener').catch((e) => {
2055
- // we do not want to expose this error, just continue if this analytics-only call fails
2056
- });
1966
+ this.wire.recordAnalytic('fdc3-add-context-listener');
2057
1967
  // The FDC3 ContextHandler only expects the context and optional ContextMetadata, so we wrap the handler
2058
1968
  // here so it only gets passed these parameters
2059
1969
  const getWrappedHandler = (handlerToWrap) => {
@@ -2082,9 +1992,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
2082
1992
  * @tutorial fdc3.findIntent
2083
1993
  */
2084
1994
  async findIntent(intent, context, resultType) {
2085
- this.wire.sendAction('fdc3-find-intent').catch((e) => {
2086
- // we do not want to expose this error, just continue if this analytics-only call fails
2087
- });
1995
+ this.wire.recordAnalytic('fdc3-find-intent');
2088
1996
  try {
2089
1997
  return await this.client.getInfoForIntent({ name: intent, context, metadata: { resultType } });
2090
1998
  }
@@ -2101,9 +2009,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
2101
2009
  * @tutorial fdc3v2.findIntentsByContext
2102
2010
  */
2103
2011
  async findIntentsByContext(context, resultType) {
2104
- this.wire.sendAction('fdc3-find-intents-by-context').catch((e) => {
2105
- // we do not want to expose this error, just continue if this analytics-only call fails
2106
- });
2012
+ this.wire.recordAnalytic('fdc3-find-intents-by-context');
2107
2013
  const payload = resultType ? { context, metadata: { resultType } } : context;
2108
2014
  try {
2109
2015
  return await InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'fdc3v2FindIntentsByContext', payload);
@@ -2122,9 +2028,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
2122
2028
  * @tutorial fdc3v2.raiseIntent
2123
2029
  */
2124
2030
  async raiseIntent(intent, context, app) {
2125
- this.wire.sendAction('fdc3-raise-intent').catch((e) => {
2126
- // we do not want to expose this error, just continue if this analytics-only call fails
2127
- });
2031
+ this.wire.recordAnalytic('fdc3-raise-intent');
2128
2032
  try {
2129
2033
  if (typeof app === 'string') {
2130
2034
  console.warn('Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string }).');
@@ -2145,9 +2049,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
2145
2049
  */
2146
2050
  async raiseIntentForContext(context, app) {
2147
2051
  // TODO: We have to do the same thing we do for raiseIntent here as well.
2148
- this.wire.sendAction('fdc3-raise-intent-for-context').catch((e) => {
2149
- // we do not want to expose this error, just continue if this analytics-only call fails
2150
- });
2052
+ this.wire.recordAnalytic('fdc3-raise-intent-for-context');
2151
2053
  try {
2152
2054
  if (typeof app === 'string') {
2153
2055
  console.warn('Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string }).');
@@ -2167,9 +2069,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
2167
2069
  * @tutorial fdc3.addIntentListener
2168
2070
  */
2169
2071
  async addIntentListener(intent, handler) {
2170
- this.wire.sendAction('fdc3-add-intent-listener').catch((e) => {
2171
- // we do not want to expose this error, just continue if this analytics-only call fails
2172
- });
2072
+ this.wire.recordAnalytic('fdc3-add-intent-listener');
2173
2073
  if (typeof intent !== 'string') {
2174
2074
  throw new Error('First argument must be an Intent name');
2175
2075
  }
package/package.json CHANGED
@@ -1,26 +1,31 @@
1
1
  {
2
- "name": "@openfin/fdc3-api",
3
- "version": "41.103.2",
4
- "description": "OpenFin fdc3 module utilities and types.",
5
- "license": "SEE LICENSE IN LICENSE.md",
6
- "private": false,
7
- "main": "./out/fdc3-api.js",
8
- "types": "./out/fdc3-api.d.ts",
9
- "files": [
10
- "out/*"
11
- ],
12
- "scripts": {
13
- "prebuild": "rimraf ./out",
14
- "build": "rollup -c --bundleConfigAsCjs",
15
- "dev": "npm run build -- --environment MODE:development",
16
- "watch": "npm run dev -- --watch",
17
- "ci:prepublish": "of-npm prepublish",
18
- "ci:postpublish": "of-npm postpublish",
19
- "ci:publish": "npm publish",
20
- "version:update": "of-npm version --allow-same-version '$RMAJOR.$RMINOR.$RPATCH'"
21
- },
22
- "author": "OpenFin",
23
- "dependencies": {
24
- "lodash": "^4.17.21"
25
- }
2
+ "name": "@openfin/fdc3-api",
3
+ "version": "41.103.10",
4
+ "description": "OpenFin fdc3 module utilities and types.",
5
+ "license": "SEE LICENSE IN LICENSE.md",
6
+ "private": false,
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "main": "./out/fdc3-api.js",
11
+ "types": "./out/fdc3-api.d.ts",
12
+ "files": [
13
+ "out/*"
14
+ ],
15
+ "author": "OpenFin",
16
+ "dependencies": {
17
+ "lodash": "^4.17.21",
18
+ "tslib": "2.8.1"
19
+ },
20
+ "scripts": {
21
+ "prebuild": "rimraf ./out",
22
+ "build": "rollup -c --bundleConfigAsCjs",
23
+ "dev": "pnpm run build -- --environment MODE:development",
24
+ "watch": "pnpm run dev -- --watch",
25
+ "ci:prepack": "of-npm prepack",
26
+ "ci:pack": "pnpm pack",
27
+ "ci:postpack": "of-npm postpack",
28
+ "version:update": "of-npm version --allow-same-version '$RMAJOR.$RMINOR.$RPATCH'",
29
+ "typecheck": "tsc --noEmit -p tsconfig.json"
30
+ }
26
31
  }