@openfin/core 29.72.17 → 29.73.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/OpenFin.d.ts +45 -27
- package/package.json +1 -1
- package/src/api/application/Factory.js +3 -3
- package/src/api/application/index.js +7 -3
- package/src/api/base.js +18 -20
- package/src/api/external-application/index.js +7 -3
- package/src/api/fin.js +2 -2
- package/src/api/frame/Factory.js +2 -2
- package/src/api/frame/index.js +7 -3
- package/src/api/interappbus/channel/client.js +24 -26
- package/src/api/interappbus/channel/connection-manager.js +24 -26
- package/src/api/interappbus/channel/index.js +16 -18
- package/src/api/interappbus/channel/protocols/classic/strategy.js +21 -22
- package/src/api/interappbus/channel/protocols/rtc/endpoint.js +24 -26
- package/src/api/interappbus/channel/protocols/rtc/strategy.js +29 -31
- package/src/api/interappbus/channel/provider.js +134 -139
- package/src/api/interappbus/index.js +1 -1
- package/src/api/interop/InteropBroker.js +9 -9
- package/src/api/interop/InteropClient.js +38 -40
- package/src/api/interop/SessionContextGroupClient.js +22 -24
- package/src/api/interop/fdc3/PrivateChannelClient.d.ts +17 -0
- package/src/api/interop/fdc3/PrivateChannelClient.js +82 -0
- package/src/api/interop/fdc3/PrivateChannelProvider.d.ts +40 -0
- package/src/api/interop/fdc3/PrivateChannelProvider.js +224 -0
- package/src/api/interop/fdc3/fdc3-1.2.d.ts +0 -1
- package/src/api/interop/fdc3/fdc3-1.2.js +1 -27
- package/src/api/interop/fdc3/fdc3-2.0.d.ts +22 -3
- package/src/api/interop/fdc3/fdc3-2.0.js +76 -11
- package/src/api/interop/fdc3/utils.d.ts +15 -0
- package/src/api/interop/fdc3/utils.js +162 -1
- package/src/api/interop/index.js +7 -3
- package/src/api/interop/utils.js +21 -15
- package/src/api/platform/Factory.js +5 -5
- package/src/api/platform/Instance.js +11 -12
- package/src/api/platform/index.js +7 -3
- package/src/api/platform/layout/Factory.js +18 -20
- package/src/api/platform/layout/Instance.d.ts +1 -1
- package/src/api/platform/layout/Instance.js +2 -2
- package/src/api/platform/layout/controllers/splitter-controller.js +1 -1
- package/src/api/platform/layout/controllers/tab-drag-controller.d.ts +17 -8
- package/src/api/platform/layout/controllers/tab-drag-controller.js +44 -22
- package/src/api/platform/layout/index.js +7 -3
- package/src/api/platform/layout/utils/bounds-observer.js +5 -3
- package/src/api/snapshot-source/Factory.js +1 -1
- package/src/api/snapshot-source/Instance.js +33 -35
- package/src/api/snapshot-source/index.js +7 -3
- package/src/api/snapshot-source/utils.js +2 -1
- package/src/api/view/Factory.js +2 -2
- package/src/api/view/Instance.d.ts +31 -1
- package/src/api/view/Instance.js +31 -1
- package/src/api/view/index.js +7 -3
- package/src/api/window/Factory.js +2 -2
- package/src/api/window/Instance.d.ts +3 -0
- package/src/api/window/Instance.js +3 -0
- package/src/api/window/index.js +7 -3
- package/src/environment/node-env.js +2 -2
- package/src/environment/openfin-env.js +15 -17
- package/src/fdc3.js +1 -1
- package/src/mock.js +1 -2
- package/src/transport/transport.js +26 -28
- package/src/transport/wire.d.ts +9 -7
- package/src/util/http.d.ts +1 -1
- package/src/util/http.js +16 -11
- package/src/util/normalize-config.js +5 -5
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver,
|
|
3
|
-
if (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return value;
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
8
7
|
};
|
|
9
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver,
|
|
10
|
-
if (!
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return privateMap.get(receiver);
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
14
12
|
};
|
|
15
|
-
var
|
|
13
|
+
var _SessionContextGroupClient_clientPromise;
|
|
16
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
15
|
const base_1 = require("../base");
|
|
18
16
|
const utils_1 = require("./utils");
|
|
19
17
|
class SessionContextGroupClient extends base_1.Base {
|
|
20
18
|
constructor(wire, client, id) {
|
|
21
19
|
super(wire);
|
|
22
|
-
|
|
20
|
+
_SessionContextGroupClient_clientPromise.set(this, void 0);
|
|
23
21
|
this.id = id;
|
|
24
|
-
__classPrivateFieldSet(this,
|
|
22
|
+
__classPrivateFieldSet(this, _SessionContextGroupClient_clientPromise, client, "f");
|
|
25
23
|
}
|
|
26
24
|
/**
|
|
27
25
|
* Sets a context for the session context group.
|
|
@@ -33,7 +31,7 @@ class SessionContextGroupClient extends base_1.Base {
|
|
|
33
31
|
this.wire.sendAction('interop-session-context-group-set-context').catch((e) => {
|
|
34
32
|
// don't expose, analytics-only call
|
|
35
33
|
});
|
|
36
|
-
const client = await __classPrivateFieldGet(this,
|
|
34
|
+
const client = await __classPrivateFieldGet(this, _SessionContextGroupClient_clientPromise, "f");
|
|
37
35
|
return client.dispatch(`sessionContextGroup:setContext-${this.id}`, {
|
|
38
36
|
sessionContextGroupId: this.id,
|
|
39
37
|
context
|
|
@@ -43,7 +41,7 @@ class SessionContextGroupClient extends base_1.Base {
|
|
|
43
41
|
this.wire.sendAction('interop-session-context-group-get-context').catch((e) => {
|
|
44
42
|
// don't expose, analytics-only call
|
|
45
43
|
});
|
|
46
|
-
const client = await __classPrivateFieldGet(this,
|
|
44
|
+
const client = await __classPrivateFieldGet(this, _SessionContextGroupClient_clientPromise, "f");
|
|
47
45
|
return client.dispatch(`sessionContextGroup:getContext-${this.id}`, {
|
|
48
46
|
sessionContextGroupId: this.id,
|
|
49
47
|
type
|
|
@@ -56,20 +54,20 @@ class SessionContextGroupClient extends base_1.Base {
|
|
|
56
54
|
if (typeof contextHandler !== 'function') {
|
|
57
55
|
throw new Error("Non-function argument passed to the first parameter 'handler'. Be aware that the argument order does not match the FDC3 standard.");
|
|
58
56
|
}
|
|
59
|
-
const client = await __classPrivateFieldGet(this,
|
|
57
|
+
const client = await __classPrivateFieldGet(this, _SessionContextGroupClient_clientPromise, "f");
|
|
60
58
|
let handlerId;
|
|
61
59
|
if (contextType) {
|
|
62
|
-
handlerId = `sessionContextHandler:invoke-${this.id}-${contextType}-${utils_1.generateId()}`;
|
|
60
|
+
handlerId = `sessionContextHandler:invoke-${this.id}-${contextType}-${(0, utils_1.generateId)()}`;
|
|
63
61
|
}
|
|
64
62
|
else {
|
|
65
63
|
handlerId = `sessionContextHandler:invoke-${this.id}`;
|
|
66
64
|
}
|
|
67
|
-
client.register(handlerId, utils_1.wrapContextHandler(contextHandler, handlerId));
|
|
65
|
+
client.register(handlerId, (0, utils_1.wrapContextHandler)(contextHandler, handlerId));
|
|
68
66
|
client.dispatch(`sessionContextGroup:handlerAdded-${this.id}`, { handlerId, contextType });
|
|
69
67
|
return { unsubscribe: await this.createUnsubscribeCb(handlerId) };
|
|
70
68
|
}
|
|
71
69
|
async createUnsubscribeCb(handlerId) {
|
|
72
|
-
const client = await __classPrivateFieldGet(this,
|
|
70
|
+
const client = await __classPrivateFieldGet(this, _SessionContextGroupClient_clientPromise, "f");
|
|
73
71
|
return async () => {
|
|
74
72
|
client.remove(handlerId);
|
|
75
73
|
await client.dispatch(`sessionContextGroup:handlerRemoved-${this.id}`, { handlerId });
|
|
@@ -78,11 +76,11 @@ class SessionContextGroupClient extends base_1.Base {
|
|
|
78
76
|
getUserInstance() {
|
|
79
77
|
return {
|
|
80
78
|
id: this.id,
|
|
81
|
-
setContext: utils_1.wrapInTryCatch(this.setContext.bind(this), 'Failed to set context: '),
|
|
82
|
-
getCurrentContext: utils_1.wrapInTryCatch(this.getCurrentContext.bind(this), 'Failed to get context: '),
|
|
83
|
-
addContextHandler: utils_1.wrapInTryCatch(this.addContextHandler.bind(this), 'Failed to add context handler: ')
|
|
79
|
+
setContext: (0, utils_1.wrapInTryCatch)(this.setContext.bind(this), 'Failed to set context: '),
|
|
80
|
+
getCurrentContext: (0, utils_1.wrapInTryCatch)(this.getCurrentContext.bind(this), 'Failed to get context: '),
|
|
81
|
+
addContextHandler: (0, utils_1.wrapInTryCatch)(this.addContextHandler.bind(this), 'Failed to add context handler: ')
|
|
84
82
|
};
|
|
85
83
|
}
|
|
86
84
|
}
|
|
87
85
|
exports.default = SessionContextGroupClient;
|
|
88
|
-
|
|
86
|
+
_SessionContextGroupClient_clientPromise = new WeakMap();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare type HandlerId = string;
|
|
2
|
+
export declare class PrivateChannelClient {
|
|
3
|
+
id: string;
|
|
4
|
+
client: OpenFin.ChannelClient;
|
|
5
|
+
listeners: Map<HandlerId, FDC3v2.Listener>;
|
|
6
|
+
constructor(client: OpenFin.ChannelClient, id: string);
|
|
7
|
+
broadcast(context: OpenFin.Context): Promise<void>;
|
|
8
|
+
getCurrentContext(contextType?: string): Promise<OpenFin.Context | null>;
|
|
9
|
+
addContextListener(contextType: string | null, handler: OpenFin.ContextHandler): Promise<FDC3v2.Listener>;
|
|
10
|
+
private createNonStandardUnsubscribeCb;
|
|
11
|
+
private createContextUnsubscribeCb;
|
|
12
|
+
onAddContextListener(handler: (contextType?: string) => void): FDC3v2.Listener;
|
|
13
|
+
onDisconnect(handler: () => void): FDC3v2.Listener;
|
|
14
|
+
onUnsubscribe(handler: (contextType?: string) => void): FDC3v2.Listener;
|
|
15
|
+
disconnect(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PrivateChannelClient = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
class PrivateChannelClient {
|
|
6
|
+
constructor(client, id) {
|
|
7
|
+
this.id = id;
|
|
8
|
+
this.client = client;
|
|
9
|
+
this.listeners = new Map();
|
|
10
|
+
}
|
|
11
|
+
async broadcast(context) {
|
|
12
|
+
return this.client.dispatch('broadcast', { context });
|
|
13
|
+
}
|
|
14
|
+
async getCurrentContext(contextType) {
|
|
15
|
+
return this.client.dispatch('getCurrentContext', { contextType });
|
|
16
|
+
}
|
|
17
|
+
async addContextListener(contextType, handler) {
|
|
18
|
+
if (typeof handler !== 'function') {
|
|
19
|
+
throw new Error("Non-function argument passed to the second parameter 'handler'. Be aware that the argument order does not match the FDC3 standard.");
|
|
20
|
+
}
|
|
21
|
+
let handlerId;
|
|
22
|
+
if (contextType) {
|
|
23
|
+
handlerId = `contextHandler:invoke-${this.id}-${contextType}-${(0, utils_1.generateId)()}`;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
handlerId = `contextHandler:invoke-${this.id}-${(0, utils_1.generateId)()}`;
|
|
27
|
+
}
|
|
28
|
+
this.client.register(handlerId, (0, utils_1.wrapContextHandler)(handler, handlerId));
|
|
29
|
+
const listener = { unsubscribe: await this.createContextUnsubscribeCb(handlerId) };
|
|
30
|
+
this.listeners.set(handlerId, listener);
|
|
31
|
+
await this.client.dispatch(`contextHandlerAdded`, { handlerId, contextType });
|
|
32
|
+
return listener;
|
|
33
|
+
}
|
|
34
|
+
createNonStandardUnsubscribeCb(handlerId) {
|
|
35
|
+
return async () => {
|
|
36
|
+
this.client.remove(handlerId);
|
|
37
|
+
this.listeners.delete(handlerId);
|
|
38
|
+
await this.client.dispatch('nonStandardHandlerRemoved', { handlerId });
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
createContextUnsubscribeCb(handlerId) {
|
|
42
|
+
return async () => {
|
|
43
|
+
this.client.remove(handlerId);
|
|
44
|
+
this.listeners.delete(handlerId);
|
|
45
|
+
await this.client.dispatch('contextHandlerRemoved', { handlerId });
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
onAddContextListener(handler) {
|
|
49
|
+
const handlerId = `onContextHandlerAdded:invoke-${this.id}-${(0, utils_1.generateId)()}`;
|
|
50
|
+
this.client.register(handlerId, handler);
|
|
51
|
+
const listener = { unsubscribe: this.createNonStandardUnsubscribeCb(handlerId) };
|
|
52
|
+
this.listeners.set(handlerId, listener);
|
|
53
|
+
this.client.dispatch(`onAddContextHandlerAdded`, { handlerId });
|
|
54
|
+
return listener;
|
|
55
|
+
}
|
|
56
|
+
onDisconnect(handler) {
|
|
57
|
+
const handlerId = `onDisconnect:invoke-${this.id}-${(0, utils_1.generateId)()}`;
|
|
58
|
+
this.client.register(handlerId, handler);
|
|
59
|
+
const listener = { unsubscribe: this.createNonStandardUnsubscribeCb(handlerId) };
|
|
60
|
+
this.listeners.set(handlerId, listener);
|
|
61
|
+
this.client.dispatch(`onDisconnectHandlerAdded`, { handlerId });
|
|
62
|
+
return listener;
|
|
63
|
+
}
|
|
64
|
+
onUnsubscribe(handler) {
|
|
65
|
+
const handlerId = `onUnsubscribe:invoke-${this.id}-${(0, utils_1.generateId)()}`;
|
|
66
|
+
this.client.register(handlerId, handler);
|
|
67
|
+
const listener = { unsubscribe: this.createNonStandardUnsubscribeCb(handlerId) };
|
|
68
|
+
this.listeners.set(handlerId, listener);
|
|
69
|
+
this.client.dispatch(`onUnsubscribeHandlerAdded`, { handlerId });
|
|
70
|
+
return listener;
|
|
71
|
+
}
|
|
72
|
+
async disconnect() {
|
|
73
|
+
const listenerUnsubscribers = Array.from(this.listeners.values());
|
|
74
|
+
const promises = listenerUnsubscribers.map(async (listenerUnsubscriber) => {
|
|
75
|
+
await listenerUnsubscriber.unsubscribe();
|
|
76
|
+
});
|
|
77
|
+
await Promise.all(promises);
|
|
78
|
+
await this.client.dispatch('clientDisconnecting');
|
|
79
|
+
await this.client.disconnect();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.PrivateChannelClient = PrivateChannelClient;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ChannelProvider } from '../../interappbus/channel/provider';
|
|
2
|
+
declare type HandlerId = string;
|
|
3
|
+
export declare class PrivateChannelProvider {
|
|
4
|
+
id: string;
|
|
5
|
+
private provider;
|
|
6
|
+
private clients;
|
|
7
|
+
private contextByContextType;
|
|
8
|
+
private lastContext;
|
|
9
|
+
constructor(provider: ChannelProvider, id: string);
|
|
10
|
+
private getClientState;
|
|
11
|
+
registerListeners(): void;
|
|
12
|
+
broadcast(payload: {
|
|
13
|
+
context: OpenFin.Context;
|
|
14
|
+
}, broadcasterClientIdentity: OpenFin.ClientIdentity): void;
|
|
15
|
+
getCurrentContext(payload: {
|
|
16
|
+
contextType?: string;
|
|
17
|
+
}, senderClientIdentity: OpenFin.ClientIdentity): OpenFin.Context | null;
|
|
18
|
+
contextHandlerAdded(payload: {
|
|
19
|
+
handlerId: HandlerId;
|
|
20
|
+
contextType?: string;
|
|
21
|
+
}, senderClientIdentity: OpenFin.ClientIdentity): void;
|
|
22
|
+
contextHandlerRemoved(payload: {
|
|
23
|
+
handlerId: HandlerId;
|
|
24
|
+
}, removingClientIdentity: OpenFin.ClientIdentity): Promise<void>;
|
|
25
|
+
nonStandardHandlerRemoved(payload: {
|
|
26
|
+
handlerId: HandlerId;
|
|
27
|
+
}, id: OpenFin.ClientIdentity): void;
|
|
28
|
+
onAddContextHandlerAdded(payload: {
|
|
29
|
+
handlerId: HandlerId;
|
|
30
|
+
}, senderClientIdentity: OpenFin.ClientIdentity): void;
|
|
31
|
+
onDisconnectHandlerAdded(payload: {
|
|
32
|
+
handlerId: HandlerId;
|
|
33
|
+
}, id: OpenFin.ClientIdentity): void;
|
|
34
|
+
onUnsubscribeHandlerAdded(payload: {
|
|
35
|
+
handlerId: HandlerId;
|
|
36
|
+
}, id: OpenFin.ClientIdentity): void;
|
|
37
|
+
clientDisconnecting(payload: {}, disconnectingClientIdentity: OpenFin.ClientIdentity): Promise<void>;
|
|
38
|
+
registerNewClient(clientIdentity: OpenFin.ClientIdentity): void;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PrivateChannelProvider = void 0;
|
|
4
|
+
const InteropBroker_1 = require("../InteropBroker");
|
|
5
|
+
class PrivateChannelProvider {
|
|
6
|
+
constructor(provider, id) {
|
|
7
|
+
this.provider = provider;
|
|
8
|
+
this.id = id;
|
|
9
|
+
this.clients = new Map();
|
|
10
|
+
this.registerListeners();
|
|
11
|
+
this.contextByContextType = new Map();
|
|
12
|
+
this.lastContext = undefined;
|
|
13
|
+
this.provider.onConnection((clientIdentity) => this.registerNewClient(clientIdentity));
|
|
14
|
+
this.provider.onDisconnection((clientIdentity) => this.clients.delete(clientIdentity.endpointId));
|
|
15
|
+
}
|
|
16
|
+
getClientState(id) {
|
|
17
|
+
return this.clients.get(id.endpointId);
|
|
18
|
+
}
|
|
19
|
+
registerListeners() {
|
|
20
|
+
this.provider.register('broadcast', this.broadcast.bind(this));
|
|
21
|
+
this.provider.register('getCurrentContext', this.getCurrentContext.bind(this));
|
|
22
|
+
this.provider.register('contextHandlerAdded', this.contextHandlerAdded.bind(this));
|
|
23
|
+
this.provider.register('contextHandlerRemoved', this.contextHandlerRemoved.bind(this));
|
|
24
|
+
this.provider.register('nonStandardHandlerRemoved', this.nonStandardHandlerRemoved.bind(this));
|
|
25
|
+
this.provider.register('onAddContextHandlerAdded', this.onAddContextHandlerAdded.bind(this));
|
|
26
|
+
this.provider.register('onDisconnectHandlerAdded', this.onDisconnectHandlerAdded.bind(this));
|
|
27
|
+
this.provider.register('onUnsubscribeHandlerAdded', this.onUnsubscribeHandlerAdded.bind(this));
|
|
28
|
+
this.provider.register('clientDisconnecting', this.clientDisconnecting.bind(this));
|
|
29
|
+
}
|
|
30
|
+
broadcast(payload, broadcasterClientIdentity) {
|
|
31
|
+
const { context } = payload;
|
|
32
|
+
const broadcasterClientState = this.getClientState(broadcasterClientIdentity);
|
|
33
|
+
if (!broadcasterClientState) {
|
|
34
|
+
throw new Error(`Client with Identity: ${broadcasterClientIdentity.uuid} ${broadcasterClientIdentity.name}, tried to call broadcast, is not connected to this Private Channel`);
|
|
35
|
+
}
|
|
36
|
+
const contextIntegrityCheckResult = InteropBroker_1.InteropBroker.checkContextIntegrity(context);
|
|
37
|
+
if (contextIntegrityCheckResult.isValid === false) {
|
|
38
|
+
throw new Error(`Failed to broadcast - bad Context. Reason: ${contextIntegrityCheckResult.reason}. Context: ${JSON.stringify(context)}`);
|
|
39
|
+
}
|
|
40
|
+
this.contextByContextType.set(context.type, context);
|
|
41
|
+
this.lastContext = context;
|
|
42
|
+
Array.from(this.clients.values()).forEach((currClientState) => {
|
|
43
|
+
const handlerIdsForContextType = currClientState.handlerIdsByContextTypes.get(context.type);
|
|
44
|
+
if (handlerIdsForContextType) {
|
|
45
|
+
handlerIdsForContextType.forEach((handlerId) => {
|
|
46
|
+
this.provider.dispatch(currClientState.clientIdentity, handlerId, context);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (currClientState.globalHandler) {
|
|
50
|
+
this.provider.dispatch(currClientState.clientIdentity, currClientState.globalHandler, context);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
getCurrentContext(payload, senderClientIdentity) {
|
|
55
|
+
const { contextType } = payload;
|
|
56
|
+
const clientState = this.getClientState(senderClientIdentity);
|
|
57
|
+
if (!clientState) {
|
|
58
|
+
throw new Error(`Client with Identity: ${senderClientIdentity.uuid} ${senderClientIdentity.name}, tried to call getCurrentContext, is not connected to this Private Channel`);
|
|
59
|
+
}
|
|
60
|
+
if (contextType !== undefined) {
|
|
61
|
+
const currentContext = this.contextByContextType.get(contextType);
|
|
62
|
+
if (currentContext)
|
|
63
|
+
return currentContext;
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return this.lastContext ? this.lastContext : null;
|
|
67
|
+
}
|
|
68
|
+
contextHandlerAdded(payload, senderClientIdentity) {
|
|
69
|
+
const { handlerId, contextType } = payload;
|
|
70
|
+
const senderClientState = this.getClientState(senderClientIdentity);
|
|
71
|
+
if (!senderClientState) {
|
|
72
|
+
throw new Error(`Client with Identity: ${senderClientIdentity.uuid} ${senderClientIdentity.name}, tried to call addContextListener, is not connected to this Private Channel`);
|
|
73
|
+
}
|
|
74
|
+
if (contextType) {
|
|
75
|
+
const currentHandlersList = senderClientState.handlerIdsByContextTypes.get(contextType) || [];
|
|
76
|
+
senderClientState.handlerIdsByContextTypes.set(contextType, [...currentHandlersList, handlerId]);
|
|
77
|
+
const currContext = this.contextByContextType.get(contextType);
|
|
78
|
+
if (currContext) {
|
|
79
|
+
this.provider.dispatch(senderClientIdentity, handlerId, currContext);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
senderClientState.globalHandler = handlerId;
|
|
84
|
+
if (this.lastContext) {
|
|
85
|
+
this.provider.dispatch(senderClientIdentity, handlerId, this.lastContext);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
Array.from(this.clients.values()).forEach((currClientState) => {
|
|
89
|
+
if (currClientState.clientIdentity.endpointId !== senderClientIdentity.endpointId &&
|
|
90
|
+
currClientState.onAddContextListenerHandlerId) {
|
|
91
|
+
this.provider.dispatch(currClientState.clientIdentity, currClientState.onAddContextListenerHandlerId, contextType);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
async contextHandlerRemoved(payload, removingClientIdentity) {
|
|
96
|
+
// MC: Made this removal async to ensure that onUnsubscribe handlers are hit before anything else happens.
|
|
97
|
+
const { handlerId } = payload;
|
|
98
|
+
const removingClientState = this.getClientState(removingClientIdentity);
|
|
99
|
+
if (removingClientState) {
|
|
100
|
+
let contextType;
|
|
101
|
+
if (removingClientState.globalHandler === handlerId) {
|
|
102
|
+
removingClientState.globalHandler = undefined;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
for (const [currContextType, handlersIds] of removingClientState.handlerIdsByContextTypes) {
|
|
106
|
+
const index = handlersIds.indexOf(handlerId);
|
|
107
|
+
if (index > -1) {
|
|
108
|
+
handlersIds.splice(index, 1);
|
|
109
|
+
contextType = currContextType;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const dispatchesToSend = [];
|
|
114
|
+
const otherClientStates = Array.from(this.clients.values());
|
|
115
|
+
for (let i = 0; i < otherClientStates.length; i++) {
|
|
116
|
+
const otherClientState = otherClientStates[i];
|
|
117
|
+
if (otherClientState.clientIdentity.endpointId !== removingClientIdentity.endpointId &&
|
|
118
|
+
otherClientState.onUnsubscribeHandlerId) {
|
|
119
|
+
dispatchesToSend.push(this.provider.dispatch(otherClientState.clientIdentity, otherClientState.onUnsubscribeHandlerId, contextType));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
await Promise.all(dispatchesToSend);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
console.error(`Problem when attempting to dispatch to onUnsubscribeHandlers. Error: ${error} Removing Client: ${handlerId}. uuid: ${removingClientIdentity.uuid}. name: ${removingClientIdentity.name}. endpointId: ${removingClientIdentity.endpointId}`);
|
|
127
|
+
throw new Error(error);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
console.warn(`Trying to remove a handler from a client that isn't mapped. handlerId: ${handlerId}. uuid: ${removingClientIdentity.uuid}. name: ${removingClientIdentity.name}. endpointId: ${removingClientIdentity.endpointId}.`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
nonStandardHandlerRemoved(payload, id) {
|
|
135
|
+
const { handlerId } = payload;
|
|
136
|
+
const clientState = this.getClientState(id);
|
|
137
|
+
if (clientState) {
|
|
138
|
+
if (clientState.onDisconnectHandlerId === handlerId) {
|
|
139
|
+
clientState.onDisconnectHandlerId = undefined;
|
|
140
|
+
}
|
|
141
|
+
else if (clientState.onAddContextListenerHandlerId === handlerId) {
|
|
142
|
+
clientState.onAddContextListenerHandlerId = undefined;
|
|
143
|
+
}
|
|
144
|
+
else if (clientState.onUnsubscribeHandlerId === handlerId) {
|
|
145
|
+
clientState.onUnsubscribeHandlerId = undefined;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
console.warn(`Trying to remove a handler from a client that isn't mapped. handlerId: ${handlerId}. clientIdentity: ${id}`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
onAddContextHandlerAdded(payload, senderClientIdentity) {
|
|
153
|
+
const clientState = this.getClientState(senderClientIdentity);
|
|
154
|
+
const { handlerId } = payload;
|
|
155
|
+
if (!clientState) {
|
|
156
|
+
throw new Error(`Client with Identity: ${senderClientIdentity.uuid} ${senderClientIdentity.name}, tried to call onAddContextListener, is not connected to this Private Channel`);
|
|
157
|
+
}
|
|
158
|
+
clientState.onAddContextListenerHandlerId = handlerId;
|
|
159
|
+
// FDC3 Spec says that the added listener should fire for all previously-registered addContextListeners from the other client
|
|
160
|
+
Array.from(this.clients.values()).forEach((otherClientState) => {
|
|
161
|
+
if (otherClientState.clientIdentity.endpointId !== senderClientIdentity.endpointId) {
|
|
162
|
+
Array.from(otherClientState.handlerIdsByContextTypes.keys()).forEach((subscribedContextType) => {
|
|
163
|
+
this.provider.dispatch(senderClientIdentity, handlerId, subscribedContextType);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
onDisconnectHandlerAdded(payload, id) {
|
|
169
|
+
const clientState = this.getClientState(id);
|
|
170
|
+
const { handlerId } = payload;
|
|
171
|
+
if (!clientState) {
|
|
172
|
+
throw new Error(`Client with Identity: ${id.uuid} ${id.name}, tried to call onDisconnect, is not connected to this Private Channel`);
|
|
173
|
+
}
|
|
174
|
+
clientState.onDisconnectHandlerId = handlerId;
|
|
175
|
+
}
|
|
176
|
+
onUnsubscribeHandlerAdded(payload, id) {
|
|
177
|
+
const clientState = this.getClientState(id);
|
|
178
|
+
const { handlerId } = payload;
|
|
179
|
+
if (!clientState) {
|
|
180
|
+
throw new Error(`Client with Identity: ${id.uuid} ${id.name}, tried to call onUnsubscribe, is not connected to this Private Channel`);
|
|
181
|
+
}
|
|
182
|
+
clientState.onUnsubscribeHandlerId = handlerId;
|
|
183
|
+
}
|
|
184
|
+
async clientDisconnecting(payload, disconnectingClientIdentity) {
|
|
185
|
+
const disconnectingClientState = this.getClientState(disconnectingClientIdentity);
|
|
186
|
+
if (!disconnectingClientState) {
|
|
187
|
+
throw new Error(`Client with Identity: ${disconnectingClientIdentity.uuid} ${disconnectingClientIdentity.name}, tried to call disconnect, is not connected to this Private Channel`);
|
|
188
|
+
}
|
|
189
|
+
disconnectingClientState.handlerIdsByContextTypes.clear();
|
|
190
|
+
this.clients.delete(disconnectingClientIdentity.endpointId);
|
|
191
|
+
const dispatchesToSend = [];
|
|
192
|
+
// TODO: call onDisconnect Handler of the other client only.
|
|
193
|
+
// 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 otherClientStates = Array.from(this.clients.values());
|
|
195
|
+
for (let i = 0; i < otherClientStates.length; i++) {
|
|
196
|
+
const otherClientState = otherClientStates[i];
|
|
197
|
+
if (otherClientState.clientIdentity.endpointId !== disconnectingClientIdentity.endpointId &&
|
|
198
|
+
otherClientState.onDisconnectHandlerId) {
|
|
199
|
+
dispatchesToSend.push(this.provider.dispatch(otherClientState.clientIdentity, otherClientState.onDisconnectHandlerId));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
try {
|
|
203
|
+
await Promise.all(dispatchesToSend);
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
console.error(`Problem when attempting to dispatch to onDisconnectHandlers. Error: ${error} Disconnecting Client: uuid: ${disconnectingClientIdentity.uuid}. name: ${disconnectingClientIdentity.name}. endpointId: ${disconnectingClientIdentity.endpointId}`);
|
|
207
|
+
throw new Error(error);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
registerNewClient(clientIdentity) {
|
|
211
|
+
if (!this.clients.has(clientIdentity.endpointId)) {
|
|
212
|
+
const clientSubscriptionState = {
|
|
213
|
+
clientIdentity,
|
|
214
|
+
handlerIdsByContextTypes: new Map(),
|
|
215
|
+
globalHandler: undefined,
|
|
216
|
+
onAddContextListenerHandlerId: undefined,
|
|
217
|
+
onUnsubscribeHandlerId: undefined,
|
|
218
|
+
onDisconnectHandlerId: undefined
|
|
219
|
+
};
|
|
220
|
+
this.clients.set(clientIdentity.endpointId, clientSubscriptionState);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
exports.PrivateChannelProvider = PrivateChannelProvider;
|
|
@@ -329,7 +329,7 @@ class Fdc3Module extends base_1.Base {
|
|
|
329
329
|
// we do not want to expose this error, just continue if this analytics-only call fails
|
|
330
330
|
});
|
|
331
331
|
const sessionContextGroup = await this.fin.me.interop.joinSessionContextGroup(channelId);
|
|
332
|
-
return
|
|
332
|
+
return (0, utils_1.buildAppChannelObject)(sessionContextGroup);
|
|
333
333
|
}
|
|
334
334
|
/**
|
|
335
335
|
* 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.
|
|
@@ -397,31 +397,5 @@ class Fdc3Module extends base_1.Base {
|
|
|
397
397
|
}
|
|
398
398
|
};
|
|
399
399
|
}
|
|
400
|
-
// eslint-disable-next-line class-methods-use-this
|
|
401
|
-
buildAppChannelObject(sessionContextGroup) {
|
|
402
|
-
return {
|
|
403
|
-
id: sessionContextGroup.id,
|
|
404
|
-
type: 'app',
|
|
405
|
-
broadcast: sessionContextGroup.setContext,
|
|
406
|
-
getCurrentContext: async (contextType) => {
|
|
407
|
-
const context = await sessionContextGroup.getCurrentContext(contextType);
|
|
408
|
-
return context === undefined ? null : context;
|
|
409
|
-
},
|
|
410
|
-
addContextListener: (contextType, handler) => {
|
|
411
|
-
let listener;
|
|
412
|
-
if (typeof contextType === 'function') {
|
|
413
|
-
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
|
414
|
-
listener = sessionContextGroup.addContextHandler(contextType);
|
|
415
|
-
}
|
|
416
|
-
else {
|
|
417
|
-
listener = sessionContextGroup.addContextHandler(handler, contextType === null ? undefined : contextType);
|
|
418
|
-
}
|
|
419
|
-
return {
|
|
420
|
-
...listener,
|
|
421
|
-
unsubscribe: () => listener.then((l) => l.unsubscribe())
|
|
422
|
-
};
|
|
423
|
-
}
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
400
|
}
|
|
427
401
|
exports.default = Fdc3Module;
|
|
@@ -102,6 +102,20 @@ import Transport from '../../../transport/transport';
|
|
|
102
102
|
* @property { string } [version] The version number of the Intents schema being used.
|
|
103
103
|
* @property { Function } getResult {@link getResult Function} that returns a promise that will resolve to either `Context` data returned by the application that resolves the raised intent or a `Channel` established and returned by the app resolving the intent.
|
|
104
104
|
*/
|
|
105
|
+
/**
|
|
106
|
+
* @typedef { object } PrivateChannel
|
|
107
|
+
* @summary Object representing a private context channel, which is intended to support secure communication between applications, and extends the Channel interface with event handlers which provide information on the connection state of both parties, ensuring that desktop agents do not need to queue or retain messages that are broadcast before a context listener is added and that applications are able to stop broadcasting messages when the other party has disconnected.
|
|
108
|
+
* @property { string } id Private Channel Id
|
|
109
|
+
* @property { string } type Channel Type
|
|
110
|
+
* @property { DisplayMetadata } [displayMetadata]
|
|
111
|
+
* @property { function } broadcast
|
|
112
|
+
* @property { function } getCurrentContext
|
|
113
|
+
* @property { function } addContextListener
|
|
114
|
+
* @property { function } onAddContextListener
|
|
115
|
+
* @property { function } onUnsubscribe
|
|
116
|
+
* @property { function } onDisconnect
|
|
117
|
+
* @property { function } disconnect
|
|
118
|
+
*/
|
|
105
119
|
/**
|
|
106
120
|
* @class
|
|
107
121
|
* @alias fdc3v2
|
|
@@ -203,7 +217,7 @@ export default class Fdc3Module2 extends Base implements FDC3v2.DesktopAgent {
|
|
|
203
217
|
* @param { Context } context Context associated with the Intent
|
|
204
218
|
* @param { AppIdentifier | TargetApp } [app]
|
|
205
219
|
* @returns { Promise<IntentResolution(2)> }
|
|
206
|
-
* @tutorial
|
|
220
|
+
* @tutorial fdc3v2.raiseIntent
|
|
207
221
|
*/
|
|
208
222
|
raiseIntent(intent: string, context: OpenFin.Context, app?: FDC3v2.AppIdentifier | FDC3.TargetApp): Promise<FDC3v2.IntentResolution>;
|
|
209
223
|
/**
|
|
@@ -211,7 +225,7 @@ export default class Fdc3Module2 extends Base implements FDC3v2.DesktopAgent {
|
|
|
211
225
|
* @param { Context } context Context associated with the Intent
|
|
212
226
|
* @param { AppIdentifier | TargetApp } [app]
|
|
213
227
|
* @returns { Promise<IntentResolution(2)> }
|
|
214
|
-
* @tutorial
|
|
228
|
+
* @tutorial fdc3v2.raiseIntentForContext
|
|
215
229
|
*/
|
|
216
230
|
raiseIntentForContext(context: OpenFin.Context, app?: FDC3v2.AppIdentifier | FDC3.TargetApp): Promise<FDC3v2.IntentResolution>;
|
|
217
231
|
/**
|
|
@@ -229,7 +243,12 @@ export default class Fdc3Module2 extends Base implements FDC3v2.DesktopAgent {
|
|
|
229
243
|
* @tutorial fdc3.getOrCreateChannel
|
|
230
244
|
*/
|
|
231
245
|
getOrCreateChannel(channelId: string): Promise<FDC3.Channel>;
|
|
232
|
-
|
|
246
|
+
/**
|
|
247
|
+
* 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.
|
|
248
|
+
* @returns { Promise<PrivateChannel> }
|
|
249
|
+
* @tutorial fdc3v2.createPrivateChannel
|
|
250
|
+
*/
|
|
251
|
+
createPrivateChannel(): Promise<FDC3v2.PrivateChannel>;
|
|
233
252
|
/**
|
|
234
253
|
* Retrieves a list of the User Channels available for the app to join.
|
|
235
254
|
* @returns { Promise<Channel[]>}
|