@openfin/core 28.71.17 → 28.71.20
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 +1 -1
- package/src/api/interop/InteropBroker.d.ts +10 -0
- package/src/api/interop/InteropBroker.js +21 -4
- package/src/api/interop/InteropClient.d.ts +1 -0
- package/src/api/interop/InteropClient.js +5 -0
- package/src/api/interop/fdc3/fdc3-1.2.d.ts +22 -1
- package/src/api/interop/fdc3/fdc3-1.2.js +44 -4
- package/src/api/interop/fdc3/fdc3.js +1 -0
- package/src/api/interop/fdc3/utils.d.ts +0 -3
- package/src/api/interop/fdc3/utils.js +1 -8
- package/src/api/interop/utils.d.ts +3 -1
- package/src/api/interop/utils.js +8 -3
package/package.json
CHANGED
|
@@ -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;
|
|
@@ -315,6 +315,9 @@ class InteropBroker extends base_1.Base {
|
|
|
315
315
|
this.wire.sendAction('interop-broker-join-context-group').catch((e) => {
|
|
316
316
|
// don't expose, analytics-only call
|
|
317
317
|
});
|
|
318
|
+
if (this.sessionContextGroupMap.has(contextGroupId)) {
|
|
319
|
+
throw new Error(utils_1.BROKER_ERRORS.joinSessionContextGroupWithJoinContextGroup);
|
|
320
|
+
}
|
|
318
321
|
if (target) {
|
|
319
322
|
// If an endpointId is provided, use that. This will likely be used by external adapters.
|
|
320
323
|
if (InteropBroker.hasEndpointId(target)) {
|
|
@@ -510,7 +513,7 @@ class InteropBroker extends base_1.Base {
|
|
|
510
513
|
*/
|
|
511
514
|
// eslint-disable-next-line class-methods-use-this
|
|
512
515
|
async handleFiredIntent(intent, clientIdentity) {
|
|
513
|
-
const warning = utils_1.generateOverrideWarning('
|
|
516
|
+
const warning = utils_1.generateOverrideWarning('fdc3.raiseIntent', 'InteropBroker.handleFiredIntent', clientIdentity, 'interopClient.fireIntent');
|
|
514
517
|
console.warn(warning);
|
|
515
518
|
throw new Error(utils_1.BROKER_ERRORS.fireIntent);
|
|
516
519
|
}
|
|
@@ -568,7 +571,7 @@ class InteropBroker extends base_1.Base {
|
|
|
568
571
|
*/
|
|
569
572
|
// eslint-disable-next-line class-methods-use-this
|
|
570
573
|
async handleInfoForIntent(options, clientIdentity) {
|
|
571
|
-
const warning = utils_1.generateOverrideWarning('
|
|
574
|
+
const warning = utils_1.generateOverrideWarning('fdc3.findIntent', 'InteropBroker.handleInfoForIntent', clientIdentity, 'interopClient.getInfoForIntent');
|
|
572
575
|
console.warn(warning);
|
|
573
576
|
throw new Error(utils_1.BROKER_ERRORS.getInfoForIntent);
|
|
574
577
|
}
|
|
@@ -583,7 +586,7 @@ class InteropBroker extends base_1.Base {
|
|
|
583
586
|
*/
|
|
584
587
|
// eslint-disable-next-line class-methods-use-this
|
|
585
588
|
async handleInfoForIntentsByContext(context, clientIdentity) {
|
|
586
|
-
const warning = utils_1.generateOverrideWarning('
|
|
589
|
+
const warning = utils_1.generateOverrideWarning('fdc3.findIntentsByContext', 'InteropBroker.handleInfoForIntentsByContext', clientIdentity, 'interopClient.getInfoForIntentsByContext');
|
|
587
590
|
console.warn(warning);
|
|
588
591
|
throw new Error(utils_1.BROKER_ERRORS.getInfoForIntentsByContext);
|
|
589
592
|
}
|
|
@@ -598,7 +601,7 @@ class InteropBroker extends base_1.Base {
|
|
|
598
601
|
*/
|
|
599
602
|
// eslint-disable-next-line class-methods-use-this
|
|
600
603
|
async handleFiredIntentForContext(contextForIntent, clientIdentity) {
|
|
601
|
-
const warning = utils_1.generateOverrideWarning('
|
|
604
|
+
const warning = utils_1.generateOverrideWarning('fdc3.raiseIntentForContext', 'InteropBroker.handleFiredIntentForContext', clientIdentity, 'interopClient.fireIntentForContext');
|
|
602
605
|
console.warn(warning);
|
|
603
606
|
throw new Error(utils_1.BROKER_ERRORS.fireIntentForContext);
|
|
604
607
|
}
|
|
@@ -613,6 +616,18 @@ class InteropBroker extends base_1.Base {
|
|
|
613
616
|
// This function is called in channel.onDisconnection.
|
|
614
617
|
// It is meant to be overridden to inform when an Interop Client has been disconnected.
|
|
615
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
|
+
}
|
|
616
631
|
/*
|
|
617
632
|
Snapshot APIs
|
|
618
633
|
*/
|
|
@@ -919,6 +934,8 @@ class InteropBroker extends base_1.Base {
|
|
|
919
934
|
channel.register('intentHandlerRegistered', this.intentHandlerRegistered.bind(this));
|
|
920
935
|
channel.register('removeContextHandler', this.removeContextHandler.bind(this));
|
|
921
936
|
channel.register('sessionContextGroup:createIfNeeded', this.handleJoinSessionContextGroup.bind(this));
|
|
937
|
+
// fdc3 only methods
|
|
938
|
+
channel.register('fdc3Open', this.fdc3HandleOpen.bind(this));
|
|
922
939
|
}
|
|
923
940
|
/**
|
|
924
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
|
-
|
|
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
|
|
@@ -160,7 +175,17 @@ class Fdc3Module extends base_1.Base {
|
|
|
160
175
|
this.wire.sendAction('fdc3-join-channel').catch((e) => {
|
|
161
176
|
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
162
177
|
});
|
|
163
|
-
|
|
178
|
+
try {
|
|
179
|
+
await this.fin.me.interop.joinContextGroup(channelId);
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
if (error.message === utils_2.BROKER_ERRORS.joinSessionContextGroupWithJoinContextGroup) {
|
|
183
|
+
throw new Error('The Channel you have tried to join is an App Channel. Custom Channels can only be defined by the Interop Broker through code or manifest configuration. Please use getOrCreateChannel.');
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
throw new Error(error.message);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
164
189
|
}
|
|
165
190
|
/**
|
|
166
191
|
* Removes the specified target from a context group.
|
|
@@ -323,9 +348,24 @@ class Fdc3Module extends base_1.Base {
|
|
|
323
348
|
providerVersion: runtimeVersion
|
|
324
349
|
};
|
|
325
350
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
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
|
+
}
|
|
329
369
|
}
|
|
330
370
|
// utils
|
|
331
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,13 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnsupportedChannelApiError =
|
|
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,11 +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: (
|
|
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
|
+
joinSessionContextGroupWithJoinContextGroup: string;
|
|
12
|
+
fdc3Open: string;
|
|
11
13
|
};
|
|
12
14
|
export declare const wrapIntentHandler: (handler: OpenFin.IntentHandler, handlerId: string) => (intent: OpenFin.Intent) => Promise<void>;
|
package/src/api/interop/utils.js
CHANGED
|
@@ -24,15 +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 = (
|
|
27
|
+
exports.generateOverrideWarning = (fdc3ClientApi, brokerApi, identity, interopClientApi) => {
|
|
28
28
|
const { uuid, name } = identity;
|
|
29
|
-
|
|
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
|
-
getInfoForIntentsByContext: exports.generateOverrideError('getInfoForIntentsByContext', 'handleInfoForIntentsByContext')
|
|
38
|
+
getInfoForIntentsByContext: exports.generateOverrideError('getInfoForIntentsByContext', 'handleInfoForIntentsByContext'),
|
|
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')
|
|
36
41
|
};
|
|
37
42
|
exports.wrapIntentHandler = (handler, handlerId) => {
|
|
38
43
|
return async (intent) => {
|