@openfin/core 30.73.27 → 30.74.6
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/LICENSE.md +4 -0
- package/package.json +2 -2
- package/src/OpenFin.d.ts +1726 -189
- package/src/OpenFin.js +3 -2
- package/src/api/api-exposer/api-consumer.d.ts +28 -0
- package/src/api/api-exposer/api-consumer.js +28 -0
- package/src/api/api-exposer/api-exposer.d.ts +35 -0
- package/src/api/api-exposer/api-exposer.js +38 -0
- package/src/api/api-exposer/decorators.d.ts +10 -0
- package/src/api/api-exposer/decorators.js +18 -0
- package/src/api/api-exposer/index.d.ts +4 -0
- package/src/api/api-exposer/index.js +20 -0
- package/src/api/api-exposer/strategies/index.d.ts +1 -0
- package/src/api/api-exposer/strategies/index.js +17 -0
- package/src/api/api-exposer/strategies/openfin-channels/channels-consumer.d.ts +14 -0
- package/src/api/api-exposer/strategies/openfin-channels/channels-consumer.js +20 -0
- package/src/api/api-exposer/strategies/openfin-channels/channels-exposer.d.ts +20 -0
- package/src/api/api-exposer/strategies/openfin-channels/channels-exposer.js +23 -0
- package/src/api/api-exposer/strategies/openfin-channels/index.d.ts +2 -0
- package/src/api/api-exposer/strategies/openfin-channels/index.js +18 -0
- package/src/api/application/Factory.d.ts +1 -0
- package/src/api/application/Factory.js +1 -0
- package/src/api/application/Instance.d.ts +2 -1
- package/src/api/application/Instance.js +1 -0
- package/src/api/base.d.ts +2 -2
- package/src/api/clipboard/index.d.ts +1 -0
- package/src/api/clipboard/index.js +1 -0
- package/src/api/events/base.d.ts +0 -3
- package/src/api/events/platform.d.ts +4 -5
- package/src/api/events/system.d.ts +5 -6
- package/src/api/events/view.d.ts +6 -3
- package/src/api/events/webcontents.d.ts +25 -3
- package/src/api/events/window.d.ts +21 -13
- package/src/api/external-application/Instance.d.ts +1 -1
- package/src/api/fin.d.ts +1 -1
- package/src/api/frame/Instance.d.ts +1 -1
- package/src/api/global-hotkey/index.d.ts +1 -1
- package/src/api/interappbus/channel/channel.d.ts +1 -1
- package/src/api/interappbus/channel/channels-docs.d.ts +7 -0
- package/src/api/interappbus/channel/channels-docs.js +7 -0
- package/src/api/interappbus/channel/client.d.ts +3 -2
- package/src/api/interappbus/channel/client.js +12 -5
- package/src/api/interappbus/channel/connection-manager.d.ts +1 -1
- package/src/api/interappbus/channel/index.d.ts +1 -1
- package/src/api/interappbus/channel/index.js +6 -8
- package/src/api/interappbus/channel/protocols/classic/message-receiver.d.ts +1 -1
- package/src/api/interappbus/channel/protocols/classic/strategy.d.ts +1 -1
- package/src/api/interappbus/channel/protocols/index.d.ts +3 -0
- package/src/api/interappbus/channel/protocols/rtc/endpoint.js +10 -2
- package/src/api/interappbus/channel/protocols/rtc/ice-manager.d.ts +1 -1
- package/src/api/interappbus/channel/protocols/rtc/strategy.js +1 -1
- package/src/api/interappbus/channel/provider.d.ts +1 -1
- package/src/api/interappbus/index.d.ts +1 -1
- package/src/api/interop/Factory.d.ts +1 -2
- package/src/api/interop/Factory.js +20 -4
- package/src/api/interop/InteropBroker.d.ts +16 -48
- package/src/api/interop/InteropBroker.js +39 -47
- package/src/api/interop/InteropClient.d.ts +10 -9
- package/src/api/interop/InteropClient.js +9 -8
- package/src/api/interop/SessionContextGroupClient.d.ts +1 -1
- package/src/api/interop/fdc3/PrivateChannelClient.d.ts +1 -0
- package/src/api/interop/fdc3/PrivateChannelClient.js +15 -7
- package/src/api/interop/fdc3/PrivateChannelProvider.d.ts +15 -1
- package/src/api/interop/fdc3/PrivateChannelProvider.js +80 -21
- package/src/api/interop/fdc3/fdc3-1.2.js +27 -12
- package/src/api/interop/fdc3/fdc3-2.0.d.ts +13 -12
- package/src/api/interop/fdc3/fdc3-2.0.js +33 -26
- package/src/api/interop/fdc3/fdc3.d.ts +4 -5
- package/src/api/interop/fdc3/overrideCheck.d.ts +4 -0
- package/src/api/interop/fdc3/overrideCheck.js +32 -0
- package/src/api/interop/fdc3/shapes/fdc3v2.d.ts +1 -1
- package/src/api/interop/fdc3/utils.d.ts +17 -0
- package/src/api/interop/fdc3/utils.js +52 -18
- package/src/api/interop/fdc3/versions.d.ts +1 -0
- package/src/api/interop/fdc3/versions.js +2 -0
- package/src/api/me.d.ts +1 -1
- package/src/api/platform/Factory.d.ts +6 -1
- package/src/api/platform/Factory.js +5 -0
- package/src/api/platform/Instance.d.ts +5 -3
- package/src/api/platform/Instance.js +5 -3
- package/src/api/platform/layout/Factory.d.ts +4 -0
- package/src/api/platform/layout/Factory.js +15 -3
- package/src/api/platform/layout/Instance.d.ts +7 -1
- package/src/api/platform/layout/Instance.js +26 -1
- package/src/api/platform/layout/controllers/layout-content-cache.d.ts +9 -0
- package/src/api/platform/layout/controllers/layout-content-cache.js +54 -0
- package/src/api/platform/layout/controllers/layout-entities-controller.d.ts +117 -0
- package/src/api/platform/layout/controllers/layout-entities-controller.js +270 -0
- package/src/api/platform/layout/entities/layout-entities.d.ts +144 -0
- package/src/api/platform/layout/entities/layout-entities.js +216 -0
- package/src/api/platform/layout/entities/shapes.d.ts +6 -0
- package/src/api/platform/layout/entities/shapes.js +2 -0
- package/src/api/platform/layout/layout.constants.d.ts +1 -0
- package/src/api/platform/layout/layout.constants.js +4 -0
- package/src/api/platform/layout/shapes.d.ts +3 -0
- package/src/api/platform/layout/utils/layout-traversal.d.ts +4 -0
- package/src/api/platform/layout/utils/layout-traversal.js +65 -0
- package/src/api/platform/layout/utils/view-overlay.d.ts +1 -1
- package/src/api/platform/provider.d.ts +162 -0
- package/src/api/platform/provider.js +2 -0
- package/src/api/snapshot-source/Factory.d.ts +1 -0
- package/src/api/snapshot-source/Factory.js +1 -0
- package/src/api/snapshot-source/Instance.d.ts +1 -1
- package/src/api/system/index.d.ts +1 -471
- package/src/api/system/index.js +6 -476
- package/src/api/view/Instance.d.ts +24 -5
- package/src/api/view/Instance.js +53 -8
- package/src/api/webcontents/main.d.ts +18 -4
- package/src/api/window/Instance.d.ts +26 -1
- package/src/api/window/Instance.js +25 -0
- package/src/browser.js +1 -1
- package/src/mock.js +1 -1
- package/src/namespaces.d.ts +21 -0
- package/src/namespaces.js +24 -0
- package/src/transport/fin_store.d.ts +1 -1
- package/src/transport/transport-errors.d.ts +6 -1
- package/src/transport/transport-errors.js +1 -2
- package/src/transport/transport.d.ts +9 -6
- package/src/transport/transport.js +11 -2
- package/src/util/channel-api-relay.d.ts +13 -0
- package/src/util/channel-api-relay.js +37 -0
- package/src/util/inaccessibleObject.d.ts +2 -0
- package/src/util/inaccessibleObject.js +49 -0
- package/src/util/lazy.d.ts +16 -0
- package/src/util/lazy.js +26 -0
- package/src/util/reversible-map.d.ts +11 -0
- package/src/util/reversible-map.js +49 -0
|
@@ -17,12 +17,14 @@ const base_1 = require("../base");
|
|
|
17
17
|
const SessionContextGroupClient_1 = require("./SessionContextGroupClient");
|
|
18
18
|
const utils_1 = require("./utils");
|
|
19
19
|
/**
|
|
20
|
+
* @PORTED
|
|
20
21
|
* @typedef { object } Intent
|
|
21
22
|
* @summary The combination of an action and a context that is passed to an application for resolution.
|
|
22
23
|
* @property { string } name Name of the intent.
|
|
23
24
|
* @property { Context } context Data associated with the intent
|
|
24
25
|
*/
|
|
25
26
|
/**
|
|
27
|
+
* @REMOVED
|
|
26
28
|
* @typedef { object } Subscription
|
|
27
29
|
* @summary Object returned when subscribing a handler.
|
|
28
30
|
* @property { function } unsubscribe Function to unsubscribe the handler.
|
|
@@ -36,6 +38,7 @@ const utils_1 = require("./utils");
|
|
|
36
38
|
* @summary Subscription function for registerIntentHandler
|
|
37
39
|
*/
|
|
38
40
|
/**
|
|
41
|
+
* @PORTED
|
|
39
42
|
* @typedef { object } ClientIdentity
|
|
40
43
|
* @summary The Identity for a Channel Client. Includes endpointId to differentiate between different connections for an entity.
|
|
41
44
|
* @property {string} uuid GUID of an application.
|
|
@@ -43,12 +46,14 @@ const utils_1 = require("./utils");
|
|
|
43
46
|
* @property {string} endpointId Unique differentiator for different Channel connections for an entity.
|
|
44
47
|
*/
|
|
45
48
|
/**
|
|
49
|
+
* @PORTED
|
|
46
50
|
* @typedef { object } ContextGroupInfo
|
|
47
51
|
* @summary Information for a Context Group. Contains metadata for displaying the group properly.
|
|
48
52
|
* @property {string} id Name of the context group
|
|
49
53
|
* @property {DisplayMetadata} displayMetadata Metadata for the Context Group. Contains the group's human-readable name, color, and an image, as defined by the Interop Broker.
|
|
50
54
|
*/
|
|
51
55
|
/**
|
|
56
|
+
* @PORTED
|
|
52
57
|
* @typedef { object } DisplayMetadata
|
|
53
58
|
* @summary The display data for a Context Group.
|
|
54
59
|
* @property {string} name A user-readable name for this context group, e.g: `"Red"`
|
|
@@ -56,6 +61,7 @@ const utils_1 = require("./utils");
|
|
|
56
61
|
* @property {string} [glyph] A URL of an image that can be used to display this context group
|
|
57
62
|
*/
|
|
58
63
|
/**
|
|
64
|
+
* @PORTED
|
|
59
65
|
* @typedef { object } Context
|
|
60
66
|
* @summary Data passed between entities and applications.
|
|
61
67
|
* @property {object} [id] An object containing string key-value pairs for the bulk of the data for the context. Differs between context types.
|
|
@@ -63,6 +69,7 @@ const utils_1 = require("./utils");
|
|
|
63
69
|
* @property {string} type Conserved type for the context (e.g. `instrument` or `country`)
|
|
64
70
|
*/
|
|
65
71
|
/**
|
|
72
|
+
* @REMOVED
|
|
66
73
|
* @typedef { object } ContextForIntent
|
|
67
74
|
* @summary Data passed between entities and applications, including an optional metadata.
|
|
68
75
|
* @property {object} [id] An object containing string key-value pairs for the bulk of the data for the context. Differs between context types.
|
|
@@ -71,6 +78,7 @@ const utils_1 = require("./utils");
|
|
|
71
78
|
* @property {any} [metadata]
|
|
72
79
|
*/
|
|
73
80
|
/**
|
|
81
|
+
* @REMOVED
|
|
74
82
|
* @typedef { object } SessionContextGroup
|
|
75
83
|
* @summary An instance of a SessionContextGroup
|
|
76
84
|
* @property {string} id The SessionContextGroup's id.
|
|
@@ -98,7 +106,7 @@ const utils_1 = require("./utils");
|
|
|
98
106
|
* @return {Promise<void>}
|
|
99
107
|
*/
|
|
100
108
|
/**
|
|
101
|
-
* {@link https://developers.openfin.co/of-docs/docs/enable-color-linking
|
|
109
|
+
* {@link https://developers.openfin.co/of-docs/docs/enable-color-linking}
|
|
102
110
|
*
|
|
103
111
|
* The Interop Client API is broken up into two groups:
|
|
104
112
|
*
|
|
@@ -305,7 +313,6 @@ class InteropClient extends base_1.Base {
|
|
|
305
313
|
* @param { Intent } intent - The combination of an action and a context that is passed to an application for resolution.
|
|
306
314
|
* @return { Promise<unknown>}
|
|
307
315
|
* @tutorial interop.fireIntent
|
|
308
|
-
* @experimental
|
|
309
316
|
*/
|
|
310
317
|
async fireIntent(intent) {
|
|
311
318
|
this.wire.sendAction('interop-client-fire-intent').catch((e) => {
|
|
@@ -320,7 +327,6 @@ class InteropClient extends base_1.Base {
|
|
|
320
327
|
* @param { string } intentName - The name of an intent.
|
|
321
328
|
* @return { Promise<Subscription> }
|
|
322
329
|
* @tutorial interop.registerIntentHandler
|
|
323
|
-
* @experimental
|
|
324
330
|
*/
|
|
325
331
|
async registerIntentHandler(handler, intentName, options) {
|
|
326
332
|
this.wire.sendAction('interop-client-register-intent-handler').catch((e) => {
|
|
@@ -348,7 +354,6 @@ class InteropClient extends base_1.Base {
|
|
|
348
354
|
* @param { string } [contextType]
|
|
349
355
|
* @return { Promise<Context> }
|
|
350
356
|
* @tutorial interop.getCurrentContext
|
|
351
|
-
* @experimental
|
|
352
357
|
*/
|
|
353
358
|
async getCurrentContext(contextType) {
|
|
354
359
|
this.wire.sendAction('interop-client-get-current-context').catch((e) => {
|
|
@@ -362,7 +367,6 @@ class InteropClient extends base_1.Base {
|
|
|
362
367
|
* @param { InfoForIntentOptions } options
|
|
363
368
|
* @return { Promise<unknown> }
|
|
364
369
|
* @tutorial interop.getInfoForIntent
|
|
365
|
-
* @experimental
|
|
366
370
|
*/
|
|
367
371
|
async getInfoForIntent(options) {
|
|
368
372
|
this.wire.sendAction('interop-client-get-info-for-intent').catch((e) => {
|
|
@@ -376,7 +380,6 @@ class InteropClient extends base_1.Base {
|
|
|
376
380
|
* @param { Context } context
|
|
377
381
|
* @return { Promise<unknown> }
|
|
378
382
|
* @tutorial interop.getInfoForIntentsByContext
|
|
379
|
-
* @experimental
|
|
380
383
|
*/
|
|
381
384
|
async getInfoForIntentsByContext(context) {
|
|
382
385
|
this.wire.sendAction('interop-client-get-info-for-intents-by-context').catch((e) => {
|
|
@@ -391,7 +394,6 @@ class InteropClient extends base_1.Base {
|
|
|
391
394
|
* @param { ContextForIntent } context
|
|
392
395
|
* @return { Promise<unknown> }
|
|
393
396
|
* @tutorial interop.fireIntentForContext
|
|
394
|
-
* @experimental
|
|
395
397
|
*/
|
|
396
398
|
async fireIntentForContext(context) {
|
|
397
399
|
this.wire.sendAction('interop-client-fire-intent-for-context').catch((e) => {
|
|
@@ -407,7 +409,6 @@ class InteropClient extends base_1.Base {
|
|
|
407
409
|
* @param { string } sessionContextGroupId - Id of the context group.
|
|
408
410
|
* @return { Promise<SessionContextGroup>}
|
|
409
411
|
* @tutorial interop.joinSessionContextGroup
|
|
410
|
-
* @experimental
|
|
411
412
|
*/
|
|
412
413
|
async joinSessionContextGroup(sessionContextGroupId) {
|
|
413
414
|
try {
|
|
@@ -14,6 +14,7 @@ export declare class PrivateChannelClient {
|
|
|
14
14
|
onAddContextListener(handler: (contextType?: string) => void): Listener;
|
|
15
15
|
onDisconnect(handler: () => void): Listener;
|
|
16
16
|
onUnsubscribe(handler: (contextType?: string) => void): Listener;
|
|
17
|
+
cleanUpAllSubs(): Promise<void>;
|
|
17
18
|
disconnect(): Promise<void>;
|
|
18
19
|
}
|
|
19
20
|
export {};
|
|
@@ -69,14 +69,22 @@ class PrivateChannelClient {
|
|
|
69
69
|
this.client.dispatch(`onUnsubscribeHandlerAdded`, { handlerId });
|
|
70
70
|
return listener;
|
|
71
71
|
}
|
|
72
|
-
async
|
|
73
|
-
const listenerUnsubscribers = Array.from(this.listeners.
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
async cleanUpAllSubs() {
|
|
73
|
+
const listenerUnsubscribers = Array.from(this.listeners.keys());
|
|
74
|
+
listenerUnsubscribers.forEach((handlerId) => {
|
|
75
|
+
this.client.remove(handlerId);
|
|
76
|
+
this.listeners.delete(handlerId);
|
|
76
77
|
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
}
|
|
79
|
+
async disconnect() {
|
|
80
|
+
try {
|
|
81
|
+
await this.client.dispatch('clientDisconnecting');
|
|
82
|
+
await this.cleanUpAllSubs();
|
|
83
|
+
await this.client.disconnect();
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
throw new Error(error.message);
|
|
87
|
+
}
|
|
80
88
|
}
|
|
81
89
|
}
|
|
82
90
|
exports.PrivateChannelClient = PrivateChannelClient;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import type * as OpenFin from '../../../OpenFin';
|
|
2
2
|
import { ChannelProvider } from '../../interappbus/channel/provider';
|
|
3
3
|
declare type HandlerId = string;
|
|
4
|
+
declare type ContextType = string;
|
|
5
|
+
interface PrivateChannelClientState {
|
|
6
|
+
clientIdentity: OpenFin.ClientIdentity;
|
|
7
|
+
handlerIdsByContextTypes: Map<ContextType, HandlerId[]>;
|
|
8
|
+
globalHandler: HandlerId | undefined;
|
|
9
|
+
onAddContextListenerHandlerId: HandlerId | undefined;
|
|
10
|
+
onUnsubscribeHandlerId: HandlerId | undefined;
|
|
11
|
+
onDisconnectHandlerId: HandlerId | undefined;
|
|
12
|
+
}
|
|
4
13
|
export declare class PrivateChannelProvider {
|
|
5
14
|
id: string;
|
|
6
15
|
private provider;
|
|
@@ -35,7 +44,12 @@ export declare class PrivateChannelProvider {
|
|
|
35
44
|
onUnsubscribeHandlerAdded(payload: {
|
|
36
45
|
handlerId: HandlerId;
|
|
37
46
|
}, id: OpenFin.ClientIdentity): void;
|
|
38
|
-
|
|
47
|
+
removeClient(disconnectingClientIdentity: OpenFin.ClientIdentity): void;
|
|
48
|
+
fireOnDisconnectForOtherClients(disconnectingClientIdentity: OpenFin.ClientIdentity): Promise<void>;
|
|
49
|
+
unsubscribeAll(clientIdentity: OpenFin.ClientIdentity): Promise<void>;
|
|
50
|
+
handleClientDisconnecting(disconnectingClientIdentity: OpenFin.ClientIdentity): Promise<void>;
|
|
39
51
|
registerNewClient(clientIdentity: OpenFin.ClientIdentity): void;
|
|
52
|
+
getConnectedClients(): Promise<PrivateChannelClientState[]>;
|
|
53
|
+
static init(channelProvider: OpenFin.ChannelProvider, id: string): PrivateChannelProvider;
|
|
40
54
|
}
|
|
41
55
|
export {};
|
|
@@ -11,7 +11,15 @@ class PrivateChannelProvider {
|
|
|
11
11
|
this.contextByContextType = new Map();
|
|
12
12
|
this.lastContext = undefined;
|
|
13
13
|
this.provider.onConnection((clientIdentity) => this.registerNewClient(clientIdentity));
|
|
14
|
-
this.provider.onDisconnection((clientIdentity) =>
|
|
14
|
+
this.provider.onDisconnection(async (clientIdentity) => {
|
|
15
|
+
const { endpointId } = clientIdentity;
|
|
16
|
+
if (this.clients.has(endpointId)) {
|
|
17
|
+
await this.handleClientDisconnecting(clientIdentity);
|
|
18
|
+
}
|
|
19
|
+
if ((await this.provider.getAllClientInfo()).length === 0) {
|
|
20
|
+
this.provider.destroy();
|
|
21
|
+
}
|
|
22
|
+
});
|
|
15
23
|
}
|
|
16
24
|
getClientState(id) {
|
|
17
25
|
return this.clients.get(id.endpointId);
|
|
@@ -25,7 +33,9 @@ class PrivateChannelProvider {
|
|
|
25
33
|
this.provider.register('onAddContextHandlerAdded', this.onAddContextHandlerAdded.bind(this));
|
|
26
34
|
this.provider.register('onDisconnectHandlerAdded', this.onDisconnectHandlerAdded.bind(this));
|
|
27
35
|
this.provider.register('onUnsubscribeHandlerAdded', this.onUnsubscribeHandlerAdded.bind(this));
|
|
28
|
-
this.provider.register('clientDisconnecting',
|
|
36
|
+
this.provider.register('clientDisconnecting', (payload, clientIdentity) => {
|
|
37
|
+
this.handleClientDisconnecting(clientIdentity);
|
|
38
|
+
});
|
|
29
39
|
}
|
|
30
40
|
broadcast(payload, broadcasterClientIdentity) {
|
|
31
41
|
const { context } = payload;
|
|
@@ -110,17 +120,18 @@ class PrivateChannelProvider {
|
|
|
110
120
|
}
|
|
111
121
|
}
|
|
112
122
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
// getting only valid client connections here, it is possible we haven't removed a disconnected client from the map yet
|
|
124
|
+
// so we need to ensure we don't dispatch to any disconnected client
|
|
125
|
+
// TODO: Take a look at our client disconnection logic and see if we can handle client disconnection cleanly
|
|
126
|
+
const clientsToDispatchTo = await this.getConnectedClients();
|
|
127
|
+
const dispatchPromises = clientsToDispatchTo.map(async (otherClientState) => {
|
|
128
|
+
const { clientIdentity, clientIdentity: { endpointId }, onUnsubscribeHandlerId } = otherClientState;
|
|
129
|
+
if (endpointId !== removingClientIdentity.endpointId && onUnsubscribeHandlerId) {
|
|
130
|
+
await this.provider.dispatch(clientIdentity, onUnsubscribeHandlerId, contextType);
|
|
120
131
|
}
|
|
121
|
-
}
|
|
132
|
+
});
|
|
122
133
|
try {
|
|
123
|
-
await Promise.all(
|
|
134
|
+
await Promise.all(dispatchPromises);
|
|
124
135
|
}
|
|
125
136
|
catch (error) {
|
|
126
137
|
console.error(`Problem when attempting to dispatch to onUnsubscribeHandlers. Error: ${error} Removing Client: ${handlerId}. uuid: ${removingClientIdentity.uuid}. name: ${removingClientIdentity.name}. endpointId: ${removingClientIdentity.endpointId}`);
|
|
@@ -181,32 +192,68 @@ class PrivateChannelProvider {
|
|
|
181
192
|
}
|
|
182
193
|
clientState.onUnsubscribeHandlerId = handlerId;
|
|
183
194
|
}
|
|
184
|
-
|
|
195
|
+
removeClient(disconnectingClientIdentity) {
|
|
185
196
|
const disconnectingClientState = this.getClientState(disconnectingClientIdentity);
|
|
186
197
|
if (!disconnectingClientState) {
|
|
187
198
|
throw new Error(`Client with Identity: ${disconnectingClientIdentity.uuid} ${disconnectingClientIdentity.name}, tried to call disconnect, is not connected to this Private Channel`);
|
|
188
199
|
}
|
|
189
200
|
disconnectingClientState.handlerIdsByContextTypes.clear();
|
|
190
201
|
this.clients.delete(disconnectingClientIdentity.endpointId);
|
|
191
|
-
|
|
202
|
+
}
|
|
203
|
+
async fireOnDisconnectForOtherClients(disconnectingClientIdentity) {
|
|
192
204
|
// TODO: call onDisconnect Handler of the other client only.
|
|
193
205
|
// CURRENTLY, just calling the onDisconnect handler for all the other clients. Once we limit it to just one other client, we can eliminate all the iteration code.
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
206
|
+
const { endpointId } = disconnectingClientIdentity;
|
|
207
|
+
// getting only valid client connections here, it is possible we haven't removed a disconnected client from the map yet
|
|
208
|
+
// so we need to ensure we don't dispatch to any disconnected client
|
|
209
|
+
// TODO: Take a look at our client disconnection logic and see if we can handle client disconnection cleanly
|
|
210
|
+
const clientsToDispatchTo = await this.getConnectedClients();
|
|
211
|
+
const dispatchPromises = clientsToDispatchTo.map(async (otherClientState) => {
|
|
212
|
+
const { clientIdentity: { endpointId: otherClientEndpointId }, onDisconnectHandlerId } = otherClientState;
|
|
213
|
+
if (otherClientEndpointId !== endpointId && onDisconnectHandlerId) {
|
|
214
|
+
await this.provider.dispatch(otherClientState.clientIdentity, onDisconnectHandlerId);
|
|
200
215
|
}
|
|
201
|
-
}
|
|
216
|
+
});
|
|
202
217
|
try {
|
|
203
|
-
await Promise.all(
|
|
218
|
+
await Promise.all(dispatchPromises);
|
|
204
219
|
}
|
|
205
220
|
catch (error) {
|
|
206
221
|
console.error(`Problem when attempting to dispatch to onDisconnectHandlers. Error: ${error} Disconnecting Client: uuid: ${disconnectingClientIdentity.uuid}. name: ${disconnectingClientIdentity.name}. endpointId: ${disconnectingClientIdentity.endpointId}`);
|
|
207
222
|
throw new Error(error);
|
|
208
223
|
}
|
|
209
224
|
}
|
|
225
|
+
async unsubscribeAll(clientIdentity) {
|
|
226
|
+
const { endpointId } = clientIdentity;
|
|
227
|
+
const state = this.clients.get(endpointId);
|
|
228
|
+
if (state) {
|
|
229
|
+
const contextTypeHandlerIds = Array.from(state.handlerIdsByContextTypes.values()).flat();
|
|
230
|
+
const globalHandlerId = state.globalHandler;
|
|
231
|
+
if (contextTypeHandlerIds.length > 0) {
|
|
232
|
+
const unsubPromises = contextTypeHandlerIds.map(async (handlerId) => {
|
|
233
|
+
return this.contextHandlerRemoved({ handlerId }, clientIdentity);
|
|
234
|
+
});
|
|
235
|
+
try {
|
|
236
|
+
await Promise.all(unsubPromises);
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
console.error(error.message);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (globalHandlerId) {
|
|
243
|
+
try {
|
|
244
|
+
await this.contextHandlerRemoved({ handlerId: globalHandlerId }, clientIdentity);
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
console.error(error.message);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
async handleClientDisconnecting(disconnectingClientIdentity) {
|
|
253
|
+
await this.unsubscribeAll(disconnectingClientIdentity);
|
|
254
|
+
this.removeClient(disconnectingClientIdentity);
|
|
255
|
+
await this.fireOnDisconnectForOtherClients(disconnectingClientIdentity);
|
|
256
|
+
}
|
|
210
257
|
registerNewClient(clientIdentity) {
|
|
211
258
|
if (!this.clients.has(clientIdentity.endpointId)) {
|
|
212
259
|
const clientSubscriptionState = {
|
|
@@ -220,5 +267,17 @@ class PrivateChannelProvider {
|
|
|
220
267
|
this.clients.set(clientIdentity.endpointId, clientSubscriptionState);
|
|
221
268
|
}
|
|
222
269
|
}
|
|
270
|
+
async getConnectedClients() {
|
|
271
|
+
const allClientInfo = await this.provider.getAllClientInfo();
|
|
272
|
+
return Array.from(this.clients.values()).filter((clientState) => {
|
|
273
|
+
const { uuid, name } = clientState.clientIdentity;
|
|
274
|
+
return allClientInfo.some(clientInfo => {
|
|
275
|
+
return name === clientInfo.name && uuid === clientInfo.uuid;
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
static init(channelProvider, id) {
|
|
280
|
+
return new PrivateChannelProvider(channelProvider, id);
|
|
281
|
+
}
|
|
223
282
|
}
|
|
224
283
|
exports.PrivateChannelProvider = PrivateChannelProvider;
|
|
@@ -130,7 +130,7 @@ class Fdc3Module extends base_1.Base {
|
|
|
130
130
|
this.wire.sendAction('fdc3-broadcast').catch((e) => {
|
|
131
131
|
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
132
132
|
});
|
|
133
|
-
this.fin.me.interop.setContext(context);
|
|
133
|
+
return this.fin.me.interop.setContext(context);
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
136
|
* Returns the Interop-Broker-defined context groups available for an entity to join.
|
|
@@ -165,15 +165,19 @@ class Fdc3Module extends base_1.Base {
|
|
|
165
165
|
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
166
166
|
});
|
|
167
167
|
try {
|
|
168
|
-
await this.fin.me.interop.joinContextGroup(channelId);
|
|
168
|
+
return await this.fin.me.interop.joinContextGroup(channelId);
|
|
169
169
|
}
|
|
170
170
|
catch (error) {
|
|
171
171
|
if (error.message === utils_2.BROKER_ERRORS.joinSessionContextGroupWithJoinContextGroup) {
|
|
172
|
-
|
|
172
|
+
console.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.');
|
|
173
173
|
}
|
|
174
174
|
else {
|
|
175
|
-
|
|
175
|
+
console.error(error.message);
|
|
176
176
|
}
|
|
177
|
+
if (error.message.startsWith('Attempting to join a context group that does not exist')) {
|
|
178
|
+
throw new Error(utils_1.ChannelError.NoChannelFound);
|
|
179
|
+
}
|
|
180
|
+
throw new Error(utils_1.ChannelError.AccessDenied);
|
|
177
181
|
}
|
|
178
182
|
}
|
|
179
183
|
/**
|
|
@@ -187,7 +191,7 @@ class Fdc3Module extends base_1.Base {
|
|
|
187
191
|
this.wire.sendAction('fdc3-leave-current-channel').catch((e) => {
|
|
188
192
|
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
189
193
|
});
|
|
190
|
-
this.fin.me.interop.removeFromContextGroup();
|
|
194
|
+
return this.fin.me.interop.removeFromContextGroup();
|
|
191
195
|
}
|
|
192
196
|
/**
|
|
193
197
|
* Adds a listener for incoming Intents.
|
|
@@ -232,7 +236,7 @@ class Fdc3Module extends base_1.Base {
|
|
|
232
236
|
return await this.fin.me.interop.fireIntent(intentObj);
|
|
233
237
|
}
|
|
234
238
|
catch (error) {
|
|
235
|
-
const errorToThrow = error.message === utils_2.BROKER_ERRORS.fireIntent ? 'ResolverUnavailable' : error;
|
|
239
|
+
const errorToThrow = error.message === utils_2.BROKER_ERRORS.fireIntent ? 'ResolverUnavailable' : error.message;
|
|
236
240
|
throw new Error(errorToThrow);
|
|
237
241
|
}
|
|
238
242
|
}
|
|
@@ -266,7 +270,7 @@ class Fdc3Module extends base_1.Base {
|
|
|
266
270
|
return await this.fin.me.interop.getInfoForIntent({ name: intent, context });
|
|
267
271
|
}
|
|
268
272
|
catch (error) {
|
|
269
|
-
const errorToThrow = error.message === utils_2.BROKER_ERRORS.getInfoForIntent ? 'ResolverUnavailable' : error;
|
|
273
|
+
const errorToThrow = error.message === utils_2.BROKER_ERRORS.getInfoForIntent ? 'ResolverUnavailable' : error.message;
|
|
270
274
|
throw new Error(errorToThrow);
|
|
271
275
|
}
|
|
272
276
|
}
|
|
@@ -284,7 +288,7 @@ class Fdc3Module extends base_1.Base {
|
|
|
284
288
|
return await this.fin.me.interop.getInfoForIntentsByContext(context);
|
|
285
289
|
}
|
|
286
290
|
catch (error) {
|
|
287
|
-
const errorToThrow = error.message === utils_2.BROKER_ERRORS.getInfoForIntentsByContext ? 'ResolverUnavailable' : error;
|
|
291
|
+
const errorToThrow = error.message === utils_2.BROKER_ERRORS.getInfoForIntentsByContext ? 'ResolverUnavailable' : error.message;
|
|
288
292
|
throw new Error(errorToThrow);
|
|
289
293
|
}
|
|
290
294
|
}
|
|
@@ -303,7 +307,7 @@ class Fdc3Module extends base_1.Base {
|
|
|
303
307
|
return await this.fin.me.interop.fireIntentForContext({ ...context, metadata: { target: app } });
|
|
304
308
|
}
|
|
305
309
|
catch (error) {
|
|
306
|
-
const errorToThrow = error.message === utils_2.BROKER_ERRORS.fireIntentForContext ? 'ResolverUnavailable' : error;
|
|
310
|
+
const errorToThrow = error.message === utils_2.BROKER_ERRORS.fireIntentForContext ? 'ResolverUnavailable' : error.message;
|
|
307
311
|
throw new Error(errorToThrow);
|
|
308
312
|
}
|
|
309
313
|
}
|
|
@@ -317,8 +321,19 @@ class Fdc3Module extends base_1.Base {
|
|
|
317
321
|
this.wire.sendAction('fdc3-get-or-create-channel').catch((e) => {
|
|
318
322
|
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
319
323
|
});
|
|
320
|
-
const
|
|
321
|
-
|
|
324
|
+
const systemChannels = await this.getSystemChannels();
|
|
325
|
+
const userChannel = systemChannels.find((channel) => channel.id === channelId);
|
|
326
|
+
if (userChannel) {
|
|
327
|
+
return { ...userChannel, type: 'system', ...(0, utils_1.getUnsupportedChannelApis)() };
|
|
328
|
+
}
|
|
329
|
+
try {
|
|
330
|
+
const sessionContextGroup = await this.fin.me.interop.joinSessionContextGroup(channelId);
|
|
331
|
+
return (0, utils_1.buildAppChannelObject)(sessionContextGroup);
|
|
332
|
+
}
|
|
333
|
+
catch (error) {
|
|
334
|
+
console.error(error.message);
|
|
335
|
+
throw new Error(utils_1.ChannelError.CreationFailed);
|
|
336
|
+
}
|
|
322
337
|
}
|
|
323
338
|
/**
|
|
324
339
|
* 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.
|
|
@@ -354,7 +369,7 @@ class Fdc3Module extends base_1.Base {
|
|
|
354
369
|
return await InteropClient_1.InteropClient.ferryFdc3Call(this.fin.me.interop, 'fdc3Open', { app, context });
|
|
355
370
|
}
|
|
356
371
|
catch (error) {
|
|
357
|
-
const errorToThrow = error.message === utils_2.BROKER_ERRORS.fdc3Open ? 'ResolverUnavailable' : error;
|
|
372
|
+
const errorToThrow = error.message === utils_2.BROKER_ERRORS.fdc3Open ? 'ResolverUnavailable' : error.message;
|
|
358
373
|
throw new Error(errorToThrow);
|
|
359
374
|
}
|
|
360
375
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as FDC3v1 from './shapes/fdc3v1';
|
|
2
2
|
import type * as FDC3v2 from './shapes/fdc3v2';
|
|
3
3
|
import { Base } from '../../base';
|
|
4
|
-
import Transport from '../../../transport/transport';
|
|
4
|
+
import { Transport } from '../../../transport/transport';
|
|
5
5
|
/**
|
|
6
6
|
* @typedef { object } AppIdentifier
|
|
7
7
|
* @summary Identifies an application, or instance of an application, and is used to target FDC3 API calls at specific applications.
|
|
@@ -171,14 +171,14 @@ export default class Fdc3Module2 extends Base implements FDC3v2.DesktopAgent {
|
|
|
171
171
|
* Find all the available instances for a particular application.
|
|
172
172
|
* @param { AppIdentifier } app
|
|
173
173
|
* @returns { Promise<Array<AppIdentifier>> }
|
|
174
|
-
* @tutorial findInstances
|
|
174
|
+
* @tutorial fdc3v2.findInstances
|
|
175
175
|
*/
|
|
176
176
|
findInstances(app: FDC3v2.AppIdentifier): Promise<Array<FDC3v2.AppIdentifier>>;
|
|
177
177
|
/**
|
|
178
178
|
* Retrieves the AppMetadata for an AppIdentifier, which provides additional metadata (such as icons, a title and description) from the App Directory record for the application, that may be used for display purposes.
|
|
179
179
|
* @param { AppIdentifier } app
|
|
180
180
|
* @returns { Promise<AppMetadata(2)> }
|
|
181
|
-
* @tutorial getAppMetadata
|
|
181
|
+
* @tutorial fdc3v2.getAppMetadata
|
|
182
182
|
*/
|
|
183
183
|
getAppMetadata(app: FDC3v2.AppIdentifier): Promise<FDC3v2.AppMetadata>;
|
|
184
184
|
/**
|
|
@@ -210,7 +210,7 @@ export default class Fdc3Module2 extends Base implements FDC3v2.DesktopAgent {
|
|
|
210
210
|
* @param { Context } context
|
|
211
211
|
* @param { string } [resultType] The type of result returned for any intent specified during resolution.
|
|
212
212
|
* @returns { Promise<Array<AppIntent(2)>> }
|
|
213
|
-
* @tutorial findIntentsByContext
|
|
213
|
+
* @tutorial fdc3v2.findIntentsByContext
|
|
214
214
|
*/
|
|
215
215
|
findIntentsByContext(context: FDC3v2.Context, resultType?: string): Promise<Array<FDC3v2.AppIntent>>;
|
|
216
216
|
/**
|
|
@@ -219,7 +219,7 @@ export default class Fdc3Module2 extends Base implements FDC3v2.DesktopAgent {
|
|
|
219
219
|
* @param { Context } context Context associated with the Intent
|
|
220
220
|
* @param { AppIdentifier | TargetApp } [app]
|
|
221
221
|
* @returns { Promise<IntentResolution(2)> }
|
|
222
|
-
* @tutorial raiseIntent
|
|
222
|
+
* @tutorial fdc3v2.raiseIntent
|
|
223
223
|
*/
|
|
224
224
|
raiseIntent(intent: string, context: FDC3v2.Context, app?: FDC3v2.AppIdentifier | FDC3v1.TargetApp): Promise<FDC3v2.IntentResolution>;
|
|
225
225
|
/**
|
|
@@ -227,7 +227,7 @@ export default class Fdc3Module2 extends Base implements FDC3v2.DesktopAgent {
|
|
|
227
227
|
* @param { Context } context Context associated with the Intent
|
|
228
228
|
* @param { AppIdentifier | TargetApp } [app]
|
|
229
229
|
* @returns { Promise<IntentResolution(2)> }
|
|
230
|
-
* @tutorial raiseIntentForContext
|
|
230
|
+
* @tutorial fdc3v2.raiseIntentForContext
|
|
231
231
|
*/
|
|
232
232
|
raiseIntentForContext(context: FDC3v2.Context, app?: FDC3v2.AppIdentifier | FDC3v1.TargetApp): Promise<FDC3v2.IntentResolution>;
|
|
233
233
|
/**
|
|
@@ -244,17 +244,17 @@ export default class Fdc3Module2 extends Base implements FDC3v2.DesktopAgent {
|
|
|
244
244
|
* @returns { Promise<Channel> }
|
|
245
245
|
* @tutorial fdc3.getOrCreateChannel
|
|
246
246
|
*/
|
|
247
|
-
getOrCreateChannel(channelId: string): Promise<
|
|
247
|
+
getOrCreateChannel(channelId: string): Promise<FDC3v2.Channel>;
|
|
248
248
|
/**
|
|
249
249
|
* 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.
|
|
250
250
|
* @returns { Promise<PrivateChannel> }
|
|
251
|
-
* @tutorial createPrivateChannel
|
|
251
|
+
* @tutorial fdc3v2.createPrivateChannel
|
|
252
252
|
*/
|
|
253
253
|
createPrivateChannel(): Promise<FDC3v2.PrivateChannel>;
|
|
254
254
|
/**
|
|
255
255
|
* Retrieves a list of the User Channels available for the app to join.
|
|
256
256
|
* @returns { Promise<Channel[]>}
|
|
257
|
-
* @tutorial getUserChannels
|
|
257
|
+
* @tutorial fdc3v2.getUserChannels
|
|
258
258
|
*/
|
|
259
259
|
getUserChannels(): Promise<Array<FDC3v1.SystemChannel>>;
|
|
260
260
|
/**
|
|
@@ -268,7 +268,7 @@ export default class Fdc3Module2 extends Base implements FDC3v2.DesktopAgent {
|
|
|
268
268
|
* Join an app to a specified User channel.
|
|
269
269
|
* @param { string } channelId Channel name
|
|
270
270
|
* @returns { Promise<void> }
|
|
271
|
-
* @tutorial joinUserChannel
|
|
271
|
+
* @tutorial fdc3v2.joinUserChannel
|
|
272
272
|
*/
|
|
273
273
|
joinUserChannel(channelId: string): Promise<void>;
|
|
274
274
|
/**
|
|
@@ -282,8 +282,9 @@ export default class Fdc3Module2 extends Base implements FDC3v2.DesktopAgent {
|
|
|
282
282
|
/**
|
|
283
283
|
* Returns the Channel object for the current User channel membership
|
|
284
284
|
* @returns { Promise<FDC3.Channel | null> }
|
|
285
|
+
* @tutorial fdc3.getCurrentChannel
|
|
285
286
|
*/
|
|
286
|
-
getCurrentChannel(): Promise<
|
|
287
|
+
getCurrentChannel(): Promise<FDC3v2.Channel | null>;
|
|
287
288
|
/**
|
|
288
289
|
* Removes the app from any User channel membership.
|
|
289
290
|
* @returns { Promise<void> }
|
|
@@ -294,7 +295,7 @@ export default class Fdc3Module2 extends Base implements FDC3v2.DesktopAgent {
|
|
|
294
295
|
* Retrieves information about the FDC3 implementation, including the supported version of the FDC3 specification, the name of the provider of the implementation, its own version number, details of whether optional API features are implemented and the metadata of the calling application according to the desktop agent.
|
|
295
296
|
* fdc3HandleGetInfo must be overridden in the InteropBroker so that the ImplementationMetadata will have the appMetadata info.
|
|
296
297
|
* @returns { Promise<ImplementationMetadata(2)> }
|
|
297
|
-
* @tutorial getInfo
|
|
298
|
+
* @tutorial fdc3v2.getInfo
|
|
298
299
|
*/
|
|
299
300
|
getInfo(): Promise<FDC3v2.ImplementationMetadata>;
|
|
300
301
|
}
|