@openfin/core 28.71.19 → 29.71.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfin/core",
3
- "version": "28.71.19",
3
+ "version": "29.71.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./src/mock.js",
6
6
  "types": "./src/mock.d.ts",
@@ -322,6 +322,16 @@ export declare class InteropBroker extends Base {
322
322
  * @tutorial interop.clientDisconnected
323
323
  */
324
324
  clientDisconnected(clientIdentity: OpenFin.ClientIdentity): Promise<void>;
325
+ /**
326
+ * Responsible for resolving an fdc3.open call.
327
+ * Must be overridden.
328
+ * @param { Fdc3OpenOptions } fdc3OpenOptions fdc3.open options
329
+ * @param { clientIdentity } clientIdentity Identity of the Client making the request.
330
+ */
331
+ fdc3HandleOpen({ app, context }: {
332
+ app: FDC3.TargetApp;
333
+ context: OpenFin.Context;
334
+ }, clientIdentity: OpenFin.ClientIdentity): Promise<void>;
325
335
  decorateSnapshot(snapshot: OpenFin.Snapshot): OpenFin.Snapshot;
326
336
  applySnapshot(snapshot: OpenFin.Snapshot, options: OpenFin.ApplySnapshotOptions): void;
327
337
  updateExistingClients(contextGroupStates: OpenFin.ContextGroupStates): void;
@@ -513,7 +513,7 @@ class InteropBroker extends base_1.Base {
513
513
  */
514
514
  // eslint-disable-next-line class-methods-use-this
515
515
  async handleFiredIntent(intent, clientIdentity) {
516
- const warning = utils_1.generateOverrideWarning('interopClient.fireIntent', 'fdc3.raiseIntent', 'InteropBroker.handleFiredIntent', clientIdentity);
516
+ const warning = utils_1.generateOverrideWarning('fdc3.raiseIntent', 'InteropBroker.handleFiredIntent', clientIdentity, 'interopClient.fireIntent');
517
517
  console.warn(warning);
518
518
  throw new Error(utils_1.BROKER_ERRORS.fireIntent);
519
519
  }
@@ -571,7 +571,7 @@ class InteropBroker extends base_1.Base {
571
571
  */
572
572
  // eslint-disable-next-line class-methods-use-this
573
573
  async handleInfoForIntent(options, clientIdentity) {
574
- const warning = utils_1.generateOverrideWarning('interopClient.getInfoForIntent', 'fdc3.findIntent', 'InteropBroker.handleInfoForIntent', clientIdentity);
574
+ const warning = utils_1.generateOverrideWarning('fdc3.findIntent', 'InteropBroker.handleInfoForIntent', clientIdentity, 'interopClient.getInfoForIntent');
575
575
  console.warn(warning);
576
576
  throw new Error(utils_1.BROKER_ERRORS.getInfoForIntent);
577
577
  }
@@ -586,7 +586,7 @@ class InteropBroker extends base_1.Base {
586
586
  */
587
587
  // eslint-disable-next-line class-methods-use-this
588
588
  async handleInfoForIntentsByContext(context, clientIdentity) {
589
- const warning = utils_1.generateOverrideWarning('interopClient.getInfoForIntentsByContext', 'fdc3.findIntentsByContext', 'InteropBroker.handleInfoForIntentsByContext', clientIdentity);
589
+ const warning = utils_1.generateOverrideWarning('fdc3.findIntentsByContext', 'InteropBroker.handleInfoForIntentsByContext', clientIdentity, 'interopClient.getInfoForIntentsByContext');
590
590
  console.warn(warning);
591
591
  throw new Error(utils_1.BROKER_ERRORS.getInfoForIntentsByContext);
592
592
  }
@@ -601,7 +601,7 @@ class InteropBroker extends base_1.Base {
601
601
  */
602
602
  // eslint-disable-next-line class-methods-use-this
603
603
  async handleFiredIntentForContext(contextForIntent, clientIdentity) {
604
- const warning = utils_1.generateOverrideWarning('interopClient.fireIntentForContext', 'fdc3.raiseIntentForContext', 'InteropBroker.handleFiredIntentForContext', clientIdentity);
604
+ const warning = utils_1.generateOverrideWarning('fdc3.raiseIntentForContext', 'InteropBroker.handleFiredIntentForContext', clientIdentity, 'interopClient.fireIntentForContext');
605
605
  console.warn(warning);
606
606
  throw new Error(utils_1.BROKER_ERRORS.fireIntentForContext);
607
607
  }
@@ -616,6 +616,18 @@ class InteropBroker extends base_1.Base {
616
616
  // This function is called in channel.onDisconnection.
617
617
  // It is meant to be overridden to inform when an Interop Client has been disconnected.
618
618
  }
619
+ /**
620
+ * Responsible for resolving an fdc3.open call.
621
+ * Must be overridden.
622
+ * @param { Fdc3OpenOptions } fdc3OpenOptions fdc3.open options
623
+ * @param { clientIdentity } clientIdentity Identity of the Client making the request.
624
+ */
625
+ // eslint-disable-next-line class-methods-use-this
626
+ async fdc3HandleOpen({ app, context }, clientIdentity) {
627
+ const warning = utils_1.generateOverrideWarning('fdc3.open', 'InteropBroker.fdc3HandleOpen', clientIdentity);
628
+ console.warn(warning);
629
+ throw new Error(utils_1.BROKER_ERRORS.fdc3Open);
630
+ }
619
631
  /*
620
632
  Snapshot APIs
621
633
  */
@@ -922,6 +934,8 @@ class InteropBroker extends base_1.Base {
922
934
  channel.register('intentHandlerRegistered', this.intentHandlerRegistered.bind(this));
923
935
  channel.register('removeContextHandler', this.removeContextHandler.bind(this));
924
936
  channel.register('sessionContextGroup:createIfNeeded', this.handleJoinSessionContextGroup.bind(this));
937
+ // fdc3 only methods
938
+ channel.register('fdc3Open', this.fdc3HandleOpen.bind(this));
925
939
  }
926
940
  /**
927
941
  * Can be used to completely prevent a connection. Return false to prevent connections. Allows all connections by default.
@@ -272,4 +272,5 @@ export declare class InteropClient extends Base {
272
272
  * @tutorial interop.onDisconnection
273
273
  */
274
274
  onDisconnection(listener: OpenFin.InteropClientOnDisconnectionListener): Promise<void>;
275
+ static ferryFdc3Call(interopClient: OpenFin.InteropClient, action: string, payload: any): Promise<any>;
275
276
  }
@@ -450,6 +450,11 @@ class InteropClient extends base_1.Base {
450
450
  listener({ type: 'interop-broker', topic: 'disconnected', brokerName: uuid });
451
451
  });
452
452
  }
453
+ // used to ferry fdc3-only calls from the fdc3 shim to the Interop Broker
454
+ static async ferryFdc3Call(interopClient, action, payload) {
455
+ const client = await __classPrivateFieldGet(interopClient, _clientPromise);
456
+ return client.dispatch(action, payload);
457
+ }
453
458
  }
454
459
  exports.InteropClient = InteropClient;
455
460
  _clientPromise = new WeakMap(), _sessionContextGroups = new WeakMap();
@@ -70,6 +70,20 @@ import { Base } from '../../base';
70
70
  *
71
71
  * If using a {@link Platform Platform } application, you can set this property in defaultWindowOptions and defaultViewOptions.
72
72
  *
73
+ * In order to ensure that the FDC3 Api is ready before use, you can use the 'fdc3Ready' event fired on the DOM Window object:
74
+ *
75
+ * ```js
76
+ * function fdc3Action() {
77
+ * // Make some fdc3 API calls here
78
+ * }
79
+ *
80
+ * if (window.fdc3) {
81
+ * fdc3Action();
82
+ * } else {
83
+ * window.addEventListener('fdc3Ready', fdc3Action);
84
+ * }
85
+ * ```
86
+ *
73
87
  * @class
74
88
  * @alias Fdc3
75
89
  * @hideconstructor
@@ -180,7 +194,14 @@ export default class Fdc3Module extends Base implements FDC3.DesktopAgent {
180
194
  * @tutorial fdc3.getInfo
181
195
  */
182
196
  getInfo(): FDC3.ImplementationMetadata;
183
- open(): void;
197
+ /**
198
+ * Launches an app with target information, which can either be a string or an AppMetadata object.
199
+ * @param { TargetApp } app
200
+ * @param { Context } [context]
201
+ * @return { Promise<void> }
202
+ * @tutorial fdc3.open
203
+ */
204
+ open(app: FDC3.TargetApp, context?: OpenFin.Context): Promise<void>;
184
205
  private getCurrentContextGroupInfo;
185
206
  private buildChannelObject;
186
207
  private buildAppChannelObject;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const base_1 = require("../../base");
4
4
  const utils_1 = require("./utils");
5
5
  const utils_2 = require("../utils");
6
+ const InteropClient_1 = require("../InteropClient");
6
7
  /**
7
8
  * @typedef { object } Listener
8
9
  * @summary Listener object returned by addContextListener and addIntentListener
@@ -74,6 +75,20 @@ const utils_2 = require("../utils");
74
75
  *
75
76
  * If using a {@link Platform Platform } application, you can set this property in defaultWindowOptions and defaultViewOptions.
76
77
  *
78
+ * In order to ensure that the FDC3 Api is ready before use, you can use the 'fdc3Ready' event fired on the DOM Window object:
79
+ *
80
+ * ```js
81
+ * function fdc3Action() {
82
+ * // Make some fdc3 API calls here
83
+ * }
84
+ *
85
+ * if (window.fdc3) {
86
+ * fdc3Action();
87
+ * } else {
88
+ * window.addEventListener('fdc3Ready', fdc3Action);
89
+ * }
90
+ * ```
91
+ *
77
92
  * @class
78
93
  * @alias Fdc3
79
94
  * @hideconstructor
@@ -333,9 +348,24 @@ class Fdc3Module extends base_1.Base {
333
348
  providerVersion: runtimeVersion
334
349
  };
335
350
  }
336
- // eslint-disable-next-line class-methods-use-this
337
- open() {
338
- throw new utils_1.UnsupportedError('open');
351
+ /**
352
+ * Launches an app with target information, which can either be a string or an AppMetadata object.
353
+ * @param { TargetApp } app
354
+ * @param { Context } [context]
355
+ * @return { Promise<void> }
356
+ * @tutorial fdc3.open
357
+ */
358
+ async open(app, context) {
359
+ this.wire.sendAction('fdc3-open').catch((e) => {
360
+ // we do not want to expose this error, just continue if this analytics-only call fails
361
+ });
362
+ try {
363
+ return await InteropClient_1.InteropClient.ferryFdc3Call(fin.me.interop, 'fdc3Open', { app, context });
364
+ }
365
+ catch (error) {
366
+ const errorToThrow = error.message === utils_2.BROKER_ERRORS.fdc3Open ? 'ResolverUnavailable' : error;
367
+ throw new Error(errorToThrow);
368
+ }
339
369
  }
340
370
  // utils
341
371
  // eslint-disable-next-line class-methods-use-this
@@ -9,6 +9,7 @@ function registerFdc3Shim(version, transport) {
9
9
  if (Object.keys(exports.versionMap).includes(version)) {
10
10
  const Api = exports.versionMap[version];
11
11
  window.fdc3 = new Api(transport);
12
+ window.dispatchEvent(new CustomEvent('fdc3Ready'));
12
13
  }
13
14
  else {
14
15
  console.error(`FDC3 API version ${version} is not supported`);
@@ -1,6 +1,3 @@
1
- export declare class UnsupportedError extends Error {
2
- constructor(apiName: string);
3
- }
4
1
  export declare class UnsupportedChannelApiError extends Error {
5
2
  constructor(apiName: string);
6
3
  }
@@ -1,13 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UnsupportedChannelApiError = exports.UnsupportedError = void 0;
4
- class UnsupportedError extends Error {
5
- constructor(apiName) {
6
- super(apiName);
7
- this.message = `${apiName} is not a supported API`;
8
- }
9
- }
10
- exports.UnsupportedError = UnsupportedError;
3
+ exports.UnsupportedChannelApiError = void 0;
11
4
  class UnsupportedChannelApiError extends Error {
12
5
  constructor(apiName) {
13
6
  super(apiName);
@@ -2,12 +2,13 @@ export declare const generateId: () => string;
2
2
  export declare const wrapInTryCatch: <T>(f: (...args: any[]) => T, prefix?: string) => (...args: any[]) => T;
3
3
  export declare const wrapContextHandler: (handler: OpenFin.ContextHandler, handlerId: string) => (context: OpenFin.Context) => Promise<void>;
4
4
  export declare const generateOverrideError: (clientApi: string, brokerApi: string) => string;
5
- export declare const generateOverrideWarning: (interopClientApi: string, fdc3ClientApi: string, brokerApi: string, identity: OpenFin.ClientIdentity) => string;
5
+ export declare const generateOverrideWarning: (fdc3ClientApi: string, brokerApi: string, identity: OpenFin.ClientIdentity, interopClientApi?: string) => string;
6
6
  export declare const BROKER_ERRORS: {
7
7
  fireIntent: string;
8
8
  fireIntentForContext: string;
9
9
  getInfoForIntent: string;
10
10
  getInfoForIntentsByContext: string;
11
11
  joinSessionContextGroupWithJoinContextGroup: string;
12
+ fdc3Open: string;
12
13
  };
13
14
  export declare const wrapIntentHandler: (handler: OpenFin.IntentHandler, handlerId: string) => (intent: OpenFin.Intent) => Promise<void>;
@@ -24,16 +24,20 @@ exports.wrapContextHandler = (handler, handlerId) => {
24
24
  exports.generateOverrideError = (clientApi, brokerApi) => {
25
25
  return `You have tried to to use ${clientApi} but ${brokerApi} has not been overridden in the Interop Broker. Please override this function. Refer to our documentation for more info.`;
26
26
  };
27
- exports.generateOverrideWarning = (interopClientApi, fdc3ClientApi, brokerApi, identity) => {
27
+ exports.generateOverrideWarning = (fdc3ClientApi, brokerApi, identity, interopClientApi) => {
28
28
  const { uuid, name } = identity;
29
- return `Entity with identity: ${uuid}/${name} has called ${interopClientApi} or ${fdc3ClientApi} but ${brokerApi} has not been overridden.`;
29
+ const message = interopClientApi
30
+ ? `Entity with identity: ${uuid}/${name} has called ${interopClientApi} or ${fdc3ClientApi} but ${brokerApi} has not been overridden.`
31
+ : `Entity with identity: ${uuid}/${name} has called ${fdc3ClientApi} but ${brokerApi} has not been overridden.`;
32
+ return message;
30
33
  };
31
34
  exports.BROKER_ERRORS = {
32
35
  fireIntent: exports.generateOverrideError('fireIntent', 'handleFiredIntent'),
33
36
  fireIntentForContext: exports.generateOverrideError('fireIntentForContext', 'handleFiredIntentForContext'),
34
37
  getInfoForIntent: exports.generateOverrideError('getInfoForIntent', 'handleInfoForIntent'),
35
38
  getInfoForIntentsByContext: exports.generateOverrideError('getInfoForIntentsByContext', 'handleInfoForIntentsByContext'),
36
- joinSessionContextGroupWithJoinContextGroup: 'The Context Group you have tried to join is a Session Context Group. Custom Context Groups can only be defined by the Interop Broker through code or manifest configuration. Please use joinSessionContextGroup.'
39
+ joinSessionContextGroupWithJoinContextGroup: 'The Context Group you have tried to join is a Session Context Group. Custom Context Groups can only be defined by the Interop Broker through code or manifest configuration. Please use joinSessionContextGroup.',
40
+ fdc3Open: exports.generateOverrideError('fdc3.open', 'fdc3HandleOpen')
37
41
  };
38
42
  exports.wrapIntentHandler = (handler, handlerId) => {
39
43
  return async (intent) => {