@openfin/fdc3-api 41.103.2 → 42.100.1

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
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var require$$0 = require('lodash/isEqual');
3
+ var require$$2 = require('lodash/isEqual');
4
4
 
5
5
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
6
6
 
@@ -203,86 +203,15 @@ class PrivateChannelClient {
203
203
  }
204
204
  PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
205
205
 
206
- var fdc3Channels2_0 = {};
207
-
208
- var fdc3Channels1_2 = {};
209
-
210
- var __importDefault$2 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
211
- return (mod && mod.__esModule) ? mod : { "default": mod };
212
- };
213
- Object.defineProperty(fdc3Channels1_2, "__esModule", { value: true });
214
- fdc3Channels1_2.createV1Channel = void 0;
215
- const isEqual_1$1 = __importDefault$2(require$$0);
216
- const createV1Channel = (sessionContextGroup) => {
217
- return {
218
- id: sessionContextGroup.id,
219
- type: 'app',
220
- broadcast: sessionContextGroup.setContext,
221
- getCurrentContext: async (contextType) => {
222
- const context = await sessionContextGroup.getCurrentContext(contextType);
223
- return context === undefined ? null : context;
224
- },
225
- // @ts-expect-error TODO [CORE-1524]
226
- addContextListener: (contextType, handler) => {
227
- let realHandler;
228
- let realType;
229
- if (typeof contextType === 'function') {
230
- console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
231
- realHandler = contextType;
232
- }
233
- else {
234
- realHandler = handler;
235
- if (typeof contextType === 'string') {
236
- realType = contextType;
237
- }
238
- }
239
- const listener = (async () => {
240
- let first = true;
241
- const currentContext = await sessionContextGroup.getCurrentContext(realType);
242
- const wrappedHandler = (context, contextMetadata) => {
243
- if (first) {
244
- first = false;
245
- if ((0, isEqual_1$1.default)(currentContext, context)) {
246
- return;
247
- }
248
- }
249
- // eslint-disable-next-line consistent-return
250
- return realHandler(context, contextMetadata);
251
- };
252
- return sessionContextGroup.addContextHandler(wrappedHandler, realType);
253
- })();
254
- return {
255
- ...listener,
256
- unsubscribe: () => listener.then((l) => l.unsubscribe())
257
- };
258
- }
259
- };
260
- };
261
- fdc3Channels1_2.createV1Channel = createV1Channel;
262
-
263
- Object.defineProperty(fdc3Channels2_0, "__esModule", { value: true });
264
- fdc3Channels2_0.createV2Channel = void 0;
265
- const fdc3_channels_1_2_1$1 = fdc3Channels1_2;
266
- const createV2Channel = (sessionContextGroup) => {
267
- const channel = (0, fdc3_channels_1_2_1$1.createV1Channel)(sessionContextGroup);
268
- return {
269
- ...channel,
270
- // @ts-expect-error Type incompatibility on signature.
271
- addContextListener: async (...args) => channel.addContextListener(...args)
272
- };
273
- };
274
- fdc3Channels2_0.createV2Channel = createV2Channel;
275
-
276
206
  (function (exports) {
277
207
  var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
278
208
  return (mod && mod.__esModule) ? mod : { "default": mod };
279
209
  };
280
210
  Object.defineProperty(exports, "__esModule", { value: true });
281
- exports.getIntentResolution = exports.isChannel = exports.isContext = exports.connectPrivateChannel = exports.buildPrivateChannelObject = exports.ChannelError = exports.ResultError = exports.UnsupportedChannelApiError = exports.getUnsupportedChannelApis = void 0;
211
+ exports.getIntentResolution = exports.isChannel = exports.isContext = exports.connectPrivateChannel = exports.buildAppChannelObject = exports.buildPrivateChannelObject = exports.ChannelError = exports.ResultError = exports.UnsupportedChannelApiError = exports.getUnsupportedChannelApis = void 0;
282
212
  const utils_1 = utils$2;
283
213
  const PrivateChannelClient_1 = PrivateChannelClient$1;
284
- __importDefault(require$$0);
285
- const fdc3_channels_2_0_1 = fdc3Channels2_0;
214
+ const isEqual_1 = __importDefault(require$$2);
286
215
  const getUnsupportedChannelApis = (channelType) => {
287
216
  return {
288
217
  addContextListener: () => {
@@ -381,6 +310,52 @@ fdc3Channels2_0.createV2Channel = createV2Channel;
381
310
  };
382
311
  };
383
312
  exports.buildPrivateChannelObject = buildPrivateChannelObject;
313
+ const buildAppChannelObject = (sessionContextGroup) => {
314
+ return {
315
+ id: sessionContextGroup.id,
316
+ type: 'app',
317
+ broadcast: sessionContextGroup.setContext,
318
+ getCurrentContext: async (contextType) => {
319
+ const context = await sessionContextGroup.getCurrentContext(contextType);
320
+ return context === undefined ? null : context;
321
+ },
322
+ // @ts-expect-error TODO [CORE-1524]
323
+ addContextListener: (contextType, handler) => {
324
+ let realHandler;
325
+ let realType;
326
+ if (typeof contextType === 'function') {
327
+ console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
328
+ realHandler = contextType;
329
+ }
330
+ else {
331
+ realHandler = handler;
332
+ if (typeof contextType === 'string') {
333
+ realType = contextType;
334
+ }
335
+ }
336
+ const listener = (async () => {
337
+ let first = true;
338
+ const currentContext = await sessionContextGroup.getCurrentContext(realType);
339
+ const wrappedHandler = (context, contextMetadata) => {
340
+ if (first) {
341
+ first = false;
342
+ if ((0, isEqual_1.default)(currentContext, context)) {
343
+ return;
344
+ }
345
+ }
346
+ // eslint-disable-next-line consistent-return
347
+ return realHandler(context, contextMetadata);
348
+ };
349
+ return sessionContextGroup.addContextHandler(wrappedHandler, realType);
350
+ })();
351
+ return {
352
+ ...listener,
353
+ unsubscribe: () => listener.then((l) => l.unsubscribe())
354
+ };
355
+ }
356
+ };
357
+ };
358
+ exports.buildAppChannelObject = buildAppChannelObject;
384
359
  const connectPrivateChannel = async (channelId) => {
385
360
  try {
386
361
  const channelClient = await fin.InterApplicationBus.Channel.connect(channelId);
@@ -412,10 +387,6 @@ fdc3Channels2_0.createV2Channel = createV2Channel;
412
387
  // Generate an ID to make a session context group with. We will pass that ID to the Broker.
413
388
  // The broker will then setContext on that session context group later with our Intent Result,
414
389
  const guid = (0, utils_1.generateId)(); // TODO make this undefined in web
415
- let isPromiseSettled = false;
416
- // Adding the intentResolutionResultId to the intentObj. Because fireIntent only accepts a single arg, we have to slap it in here.
417
- const metadata = app ? { target: app, intentResolutionResultId: guid } : { intentResolutionResultId: guid };
418
- const intentObj = intent ? { name: intent, context, metadata } : { ...context, metadata };
419
390
  // Promise we'll use in getResult
420
391
  const getResultPromise = new Promise((resolve, reject) => {
421
392
  fin.InterApplicationBus.subscribe({ uuid: '*' }, guid, (intentResult) => {
@@ -423,29 +394,18 @@ fdc3Channels2_0.createV2Channel = createV2Channel;
423
394
  }).catch(() => {
424
395
  // not supported in web, suppress the error
425
396
  if (interopModule.wire.environment.type === 'other') {
426
- resolve(undefined);
397
+ return;
427
398
  }
428
399
  reject(new Error('getResult is not supported in this environment'));
429
400
  });
430
401
  });
431
- getResultPromise
432
- .then(() => {
433
- isPromiseSettled = true;
434
- })
435
- .catch(() => {
436
- isPromiseSettled = true;
437
- });
402
+ // Adding the intentResolutionResultId to the intentObj. Because fireIntent only accepts a single arg, we have to slap it in here.
403
+ const metadata = app ? { target: app, intentResolutionResultId: guid } : { intentResolutionResultId: guid };
404
+ const intentObj = intent ? { name: intent, context, metadata } : { ...context, metadata };
438
405
  // Set up the getResult call.
439
406
  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
407
  let intentResult = await getResultPromise;
445
- if (isPromiseSettled && !intentResult) {
446
- return undefined;
447
- }
448
- if (typeof intentResult !== 'object') {
408
+ if (!intentResult || typeof intentResult !== 'object') {
449
409
  throw new Error(ResultError.NoResultReturned);
450
410
  }
451
411
  const { error } = intentResult;
@@ -461,7 +421,7 @@ fdc3Channels2_0.createV2Channel = createV2Channel;
461
421
  }
462
422
  case 'app': {
463
423
  const sessionContextGroup = await interopModule.joinSessionContextGroup(id);
464
- intentResult = (0, fdc3_channels_2_0_1.createV2Channel)(sessionContextGroup);
424
+ intentResult = (0, exports.buildAppChannelObject)(sessionContextGroup);
465
425
  break;
466
426
  }
467
427
  }
@@ -1513,7 +1473,7 @@ fdc3Common.FDC3ModuleBase = void 0;
1513
1473
  const utils_1$2 = utils$1;
1514
1474
  const utils_2$1 = utils$2;
1515
1475
  const InteropClient_1$1 = InteropClient$1;
1516
- const isEqual_1 = __importDefault(require$$0);
1476
+ const isEqual_1 = __importDefault(require$$2);
1517
1477
  class FDC3ModuleBase {
1518
1478
  get client() {
1519
1479
  return __classPrivateFieldGet(this, _FDC3ModuleBase_producer, "f").call(this);
@@ -1573,16 +1533,10 @@ class FDC3ModuleBase {
1573
1533
  *
1574
1534
  * @tutorial fdc3.getOrCreateChannel
1575
1535
  */
1576
- async getOrCreateChannel(channelId, fdc3Factory) {
1536
+ async getOrCreateChannel(channelId) {
1577
1537
  this.wire.sendAction('fdc3-get-or-create-channel').catch((e) => {
1578
1538
  // we do not want to expose this error, just continue if this analytics-only call fails
1579
1539
  });
1580
- const hasChannelIdBeenUsed = await InteropClient_1$1.InteropClient.ferryFdc3Call(this.client, 'isIdUsedByPrivateChannel', {
1581
- channelId
1582
- });
1583
- if (hasChannelIdBeenUsed) {
1584
- throw new Error(utils_1$2.ChannelError.AccessDenied);
1585
- }
1586
1540
  const systemChannels = await this._getChannels();
1587
1541
  const userChannel = systemChannels.find((channel) => channel.id === channelId);
1588
1542
  if (userChannel) {
@@ -1590,7 +1544,7 @@ class FDC3ModuleBase {
1590
1544
  }
1591
1545
  try {
1592
1546
  const sessionContextGroup = await this.client.joinSessionContextGroup(channelId);
1593
- return fdc3Factory(sessionContextGroup);
1547
+ return (0, utils_1$2.buildAppChannelObject)(sessionContextGroup);
1594
1548
  }
1595
1549
  catch (error) {
1596
1550
  console.error(error.message);
@@ -1740,7 +1694,6 @@ Object.defineProperty(fdc31_2, "__esModule", { value: true });
1740
1694
  exports.Fdc3Module = fdc31_2.Fdc3Module = void 0;
1741
1695
  const utils_1$1 = utils$2;
1742
1696
  const fdc3_common_1$1 = fdc3Common;
1743
- const fdc3_channels_1_2_1 = fdc3Channels1_2;
1744
1697
  /**
1745
1698
  * @version 1.2
1746
1699
  * The FDC3 Client Library provides a set APIs to be used for FDC3 compliance,
@@ -1923,7 +1876,7 @@ class Fdc3Module extends fdc3_common_1$1.FDC3ModuleBase {
1923
1876
  * @tutorial fdc3.getOrCreateChannel
1924
1877
  */
1925
1878
  async getOrCreateChannel(channelId) {
1926
- return super.getOrCreateChannel(channelId, fdc3_channels_1_2_1.createV1Channel);
1879
+ return super.getOrCreateChannel(channelId);
1927
1880
  }
1928
1881
  /**
1929
1882
  * Returns metadata relating to the FDC3 object and its provider, including the supported version of the FDC3 specification and the name of the provider of the implementation.
@@ -1955,7 +1908,6 @@ const utils_1 = utils$2;
1955
1908
  const InteropClient_1 = InteropClient$1;
1956
1909
  const utils_2 = utils$1;
1957
1910
  const PrivateChannelClient_1 = PrivateChannelClient$1;
1958
- const fdc3_channels_2_0_1 = fdc3Channels2_0;
1959
1911
  /**
1960
1912
  * @version 2.0
1961
1913
  * The FDC3 Client Library provides a set APIs to be used for FDC3 compliance,
@@ -2207,7 +2159,7 @@ class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
2207
2159
  * @tutorial fdc3.getOrCreateChannel
2208
2160
  */
2209
2161
  async getOrCreateChannel(channelId) {
2210
- return super.getOrCreateChannel(channelId, fdc3_channels_2_0_1.createV2Channel);
2162
+ return super.getOrCreateChannel(channelId);
2211
2163
  }
2212
2164
  /**
2213
2165
  * Returns a Channel with an auto-generated identity that is intended for private communication between applications. Primarily used to create channels that will be returned to other applications via an IntentResolution for a raised intent.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/fdc3-api",
3
- "version": "41.103.2",
3
+ "version": "42.100.1",
4
4
  "description": "OpenFin fdc3 module utilities and types.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "private": false,