@openfin/core 31.74.1 → 31.74.3
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/OpenFin.d.ts +284 -253
- package/src/OpenFin.js +0 -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.js +1 -2
- package/src/api/application/Instance.js +23 -5
- package/src/api/base.d.ts +5 -2
- package/src/api/base.js +7 -0
- package/src/api/events/application.d.ts +22 -22
- package/src/api/events/base.d.ts +6 -9
- package/src/api/events/channel.d.ts +5 -5
- package/src/api/events/emitterMap.d.ts +1 -1
- package/src/api/events/externalApplication.d.ts +3 -3
- package/src/api/events/frame.d.ts +5 -5
- package/src/api/events/globalHotkey.d.ts +3 -3
- package/src/api/events/platform.d.ts +3 -3
- package/src/api/events/system.d.ts +18 -18
- package/src/api/events/typedEventEmitter.d.ts +1 -1
- package/src/api/events/view.d.ts +17 -14
- package/src/api/events/webcontents.d.ts +24 -22
- package/src/api/events/window.d.ts +65 -57
- package/src/api/fin.d.ts +1 -1
- package/src/api/frame/Instance.d.ts +1 -1
- package/src/api/interappbus/channel/channel.d.ts +4 -4
- package/src/api/interappbus/channel/channel.js +3 -3
- package/src/api/interappbus/channel/client.d.ts +2 -2
- package/src/api/interappbus/channel/client.js +20 -20
- package/src/api/interappbus/channel/connection-manager.d.ts +1 -1
- package/src/api/interappbus/channel/connection-manager.js +12 -12
- package/src/api/interappbus/channel/index.d.ts +2 -2
- package/src/api/interappbus/channel/index.js +1 -1
- package/src/api/interappbus/channel/protocols/classic/strategy.d.ts +1 -1
- package/src/api/interappbus/channel/protocols/combined/strategy.d.ts +2 -2
- package/src/api/interappbus/channel/protocols/combined/strategy.js +5 -5
- package/src/api/interappbus/channel/protocols/index.d.ts +4 -4
- package/src/api/interappbus/channel/protocols/rtc/endpoint.d.ts +1 -1
- package/src/api/interappbus/channel/protocols/rtc/strategy.d.ts +1 -1
- package/src/api/interappbus/channel/protocols/strategy-types.d.ts +4 -4
- package/src/api/interappbus/channel/protocols/strategy.d.ts +3 -3
- package/src/api/interappbus/channel/provider.d.ts +5 -5
- package/src/api/interappbus/channel/provider.js +24 -24
- package/src/api/interop/InteropBroker.d.ts +1 -1
- package/src/api/interop/InteropBroker.js +6 -2
- package/src/api/interop/fdc3/PrivateChannelClient.d.ts +2 -1
- package/src/api/interop/fdc3/PrivateChannelClient.js +15 -7
- package/src/api/interop/fdc3/PrivateChannelProvider.d.ts +16 -2
- package/src/api/interop/fdc3/PrivateChannelProvider.js +80 -28
- package/src/api/interop/fdc3/fdc3-1.2.js +53 -5
- package/src/api/interop/fdc3/fdc3-2.0.d.ts +11 -10
- package/src/api/interop/fdc3/fdc3-2.0.js +18 -19
- package/src/api/interop/fdc3/shapes/fdc3v1.d.ts +3 -3
- package/src/api/interop/fdc3/shapes/fdc3v2.d.ts +5 -5
- package/src/api/interop/fdc3/utils.d.ts +17 -0
- package/src/api/interop/fdc3/utils.js +75 -21
- package/src/api/interop/fdc3/versions.d.ts +1 -1
- package/src/api/interop/utils.d.ts +0 -1
- package/src/api/interop/utils.js +1 -9
- package/src/api/me.d.ts +3 -3
- package/src/api/platform/Factory.js +5 -9
- package/src/api/platform/Instance.d.ts +1 -1
- package/src/api/platform/Instance.js +1 -1
- package/src/api/platform/common-utils.d.ts +1 -1
- package/src/api/platform/layout/Factory.d.ts +1 -1
- package/src/api/platform/layout/Factory.js +11 -3
- package/src/api/platform/layout/Instance.d.ts +9 -3
- 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/controllers/splitter-controller.d.ts +1 -1
- 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 +4 -1
- 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/system/index.d.ts +13 -13
- package/src/api/view/Instance.d.ts +13 -3
- package/src/api/view/Instance.js +41 -4
- package/src/environment/browser.d.ts +1 -1
- package/src/environment/environment.d.ts +1 -1
- package/src/environment/node-env.d.ts +1 -1
- package/src/environment/openfin-env.d.ts +1 -1
- package/src/mock.d.ts +1 -1
- package/src/mock.js +5 -2
- package/src/shapes/ERROR_BOX_TYPES.d.ts +1 -1
- package/src/shapes/protocol.d.ts +3 -3
- package/src/transport/transport-errors.d.ts +2 -2
- package/src/transport/transport.d.ts +3 -3
- package/src/transport/transport.js +1 -4
- package/src/transport/wire.d.ts +14 -13
- package/src/util/channel-api-relay.d.ts +13 -0
- package/src/util/channel-api-relay.js +37 -0
- package/src/util/errors.d.ts +2 -2
- package/src/util/http.js +4 -2
- package/src/util/lazy.d.ts +16 -0
- package/src/util/lazy.js +26 -0
- package/src/util/promises.d.ts +1 -1
- package/src/util/reversible-map.d.ts +11 -0
- package/src/util/reversible-map.js +49 -0
- package/src/util/utilTypes.d.ts +1 -1
|
@@ -6,7 +6,7 @@ import { ClientOffer, LocalSupportedProtocol } from './protocols/index';
|
|
|
6
6
|
import { RTCPacket } from './protocols/rtc/endpoint';
|
|
7
7
|
import { ChannelProvider } from './provider';
|
|
8
8
|
import { AnyStrategy } from './protocols/strategy-types';
|
|
9
|
-
export
|
|
9
|
+
export type ProviderEntry = {
|
|
10
10
|
provider: ChannelProvider;
|
|
11
11
|
strategy: AnyStrategy;
|
|
12
12
|
supportedProtocols: LocalSupportedProtocol[];
|
|
@@ -23,6 +23,18 @@ const message_receiver_1 = require("./protocols/classic/message-receiver");
|
|
|
23
23
|
const protocol_manager_1 = require("./protocols/protocol-manager");
|
|
24
24
|
const strategy_3 = require("./protocols/combined/strategy");
|
|
25
25
|
class ConnectionManager extends base_1.Base {
|
|
26
|
+
static getProtocolOptionsFromStrings(protocols) {
|
|
27
|
+
return protocols.map((protocol) => {
|
|
28
|
+
switch (protocol) {
|
|
29
|
+
case 'rtc':
|
|
30
|
+
return strategy_2.RTCInfo;
|
|
31
|
+
case 'classic':
|
|
32
|
+
return strategy_1.ClassicInfo;
|
|
33
|
+
default:
|
|
34
|
+
return (0, exhaustive_1.exhaustiveCheck)(protocol, ['rtc', 'classic']);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
26
38
|
constructor(wire) {
|
|
27
39
|
super(wire);
|
|
28
40
|
_ConnectionManager_messageReceiver.set(this, void 0);
|
|
@@ -43,18 +55,6 @@ class ConnectionManager extends base_1.Base {
|
|
|
43
55
|
__classPrivateFieldSet(this, _ConnectionManager_rtcConnectionManager, new ice_manager_1.RTCICEManager(wire), "f");
|
|
44
56
|
wire.registerMessageHandler(this.onmessage.bind(this));
|
|
45
57
|
}
|
|
46
|
-
static getProtocolOptionsFromStrings(protocols) {
|
|
47
|
-
return protocols.map((protocol) => {
|
|
48
|
-
switch (protocol) {
|
|
49
|
-
case 'rtc':
|
|
50
|
-
return strategy_2.RTCInfo;
|
|
51
|
-
case 'classic':
|
|
52
|
-
return strategy_1.ClassicInfo;
|
|
53
|
-
default:
|
|
54
|
-
return (0, exhaustive_1.exhaustiveCheck)(protocol, ['rtc', 'classic']);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
58
|
createProvider(options, providerIdentity) {
|
|
59
59
|
const opts = Object.assign(this.wire.environment.getDefaultChannelOptions().create, options || {});
|
|
60
60
|
const protocols = this.protocolManager.getProviderProtocols(opts === null || opts === void 0 ? void 0 : opts.protocols);
|
|
@@ -4,8 +4,8 @@ import { ChannelProvider } from './provider';
|
|
|
4
4
|
import { EmitterBase } from '../../base';
|
|
5
5
|
import { Transport, Message } from '../../../transport/transport';
|
|
6
6
|
import { ChannelEvent } from '../../events/channel';
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
type ProviderIdentity = OpenFin.ProviderIdentity;
|
|
8
|
+
type Identity = OpenFin.Identity;
|
|
9
9
|
export interface ChannelMessage extends Message<any> {
|
|
10
10
|
senderIdentity: Identity;
|
|
11
11
|
ackToSender: any;
|
|
@@ -62,7 +62,7 @@ class Channel extends base_1.EmitterBase {
|
|
|
62
62
|
if (entityType === 'iframe') {
|
|
63
63
|
// @ts-expect-error
|
|
64
64
|
// TODO: type this correctly (frame types are broken)
|
|
65
|
-
|
|
65
|
+
connectionUrl = (await this.fin.me.getInfo()).url;
|
|
66
66
|
}
|
|
67
67
|
else if (entityType === 'window' || entityType === 'view') {
|
|
68
68
|
connectionUrl = (await this.fin.me.getInfo()).url;
|
|
@@ -3,7 +3,7 @@ import { Transport } from '../../../../../transport/transport';
|
|
|
3
3
|
import { MessageReceiver } from './message-receiver';
|
|
4
4
|
import { ChannelStrategy, EndpointPayload } from '../strategy';
|
|
5
5
|
import { LocalSupportedProtocol } from '..';
|
|
6
|
-
|
|
6
|
+
type ProviderIdentity = OpenFin.ProviderIdentity;
|
|
7
7
|
export declare class ClassicStrategy implements ChannelStrategy<EndpointPayload> {
|
|
8
8
|
#private;
|
|
9
9
|
private messageReceiver;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ChannelStrategy } from '../strategy';
|
|
2
|
-
|
|
2
|
+
type OverlapsOnlyIfMatching<T, U> = {
|
|
3
3
|
[K in Extract<keyof T, keyof U>]: U[K] extends T[K] ? U[K] : T[K] extends U[K] ? T[K] : never;
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
type OnlyIfCompatible<A, B, D = OverlapsOnlyIfMatching<A, B>> = D extends Record<any, never> ? keyof D extends never ? A | B : never : A | B;
|
|
6
6
|
export default class CombinedStrategy<A, B> implements ChannelStrategy<OnlyIfCompatible<A, B>> {
|
|
7
7
|
private primary;
|
|
8
8
|
private secondary;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
class CombinedStrategy {
|
|
4
|
-
// eslint-disable-next-line no-useless-constructor
|
|
5
|
-
constructor(primary, secondary) {
|
|
6
|
-
this.primary = primary;
|
|
7
|
-
this.secondary = secondary;
|
|
8
|
-
}
|
|
9
4
|
// Making this a static method because the constructor can't be typed.
|
|
10
5
|
// Otherwise it will error when calling addEndpoint but I'd rather the whole instance be typed as never.
|
|
11
6
|
static combine(a, b) {
|
|
12
7
|
return new CombinedStrategy(a, b);
|
|
13
8
|
}
|
|
9
|
+
// eslint-disable-next-line no-useless-constructor
|
|
10
|
+
constructor(primary, secondary) {
|
|
11
|
+
this.primary = primary;
|
|
12
|
+
this.secondary = secondary;
|
|
13
|
+
}
|
|
14
14
|
onEndpointDisconnect(endpointId, listener) {
|
|
15
15
|
this.primary.onEndpointDisconnect(endpointId, () => {
|
|
16
16
|
if (!this.secondary.isEndpointConnected(endpointId)) {
|
|
@@ -14,12 +14,12 @@ export interface RTCProtocolOffer extends ProtocolPacketBase {
|
|
|
14
14
|
rtcConnectionId: string;
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
export
|
|
17
|
+
export type ProtocolOffer = ClassicProtocolOffer | RTCProtocolOffer;
|
|
18
18
|
/**
|
|
19
19
|
* Protocol values for determining channel messaging strategy.
|
|
20
20
|
*/
|
|
21
|
-
export
|
|
22
|
-
export
|
|
21
|
+
export type MessagingProtocols = ProtocolOffer['type'];
|
|
22
|
+
export type LocalSupportedProtocol = {
|
|
23
23
|
type: MessagingProtocols;
|
|
24
24
|
minimumVersion: number;
|
|
25
25
|
version: number;
|
|
@@ -41,7 +41,7 @@ export interface RTCProtocolAnswer extends ProtocolPacketBase {
|
|
|
41
41
|
answer: RTCSessionDescriptionInit;
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
export
|
|
44
|
+
export type ProtocolAnswer = ClassicProtocolAnswer | RTCProtocolAnswer;
|
|
45
45
|
export interface ClientAnswer {
|
|
46
46
|
supportedProtocols: ProtocolAnswer[];
|
|
47
47
|
}
|
|
@@ -2,7 +2,7 @@ import type * as OpenFin from '../../../../../OpenFin';
|
|
|
2
2
|
import { ChannelStrategy } from '../strategy';
|
|
3
3
|
import { RTCPacket } from './endpoint';
|
|
4
4
|
import { LocalSupportedProtocol } from '..';
|
|
5
|
-
|
|
5
|
+
type ProviderIdentity = OpenFin.ProviderIdentity;
|
|
6
6
|
export interface RTCStrategyEndpointPayload {
|
|
7
7
|
endpointIdentity: OpenFin.ClientIdentity | ProviderIdentity;
|
|
8
8
|
rtc: RTCPacket;
|
|
@@ -3,11 +3,11 @@ import { ClassicStrategy } from './classic/strategy';
|
|
|
3
3
|
import CombinedStrategy from './combined/strategy';
|
|
4
4
|
import { RTCStrategy } from './rtc/strategy';
|
|
5
5
|
import { ChannelStrategy } from './strategy';
|
|
6
|
-
|
|
6
|
+
type StrategyMap = {
|
|
7
7
|
rtc: RTCStrategy;
|
|
8
8
|
classic: ClassicStrategy;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
10
|
+
export type StrategyByProtocol<T extends MessagingProtocols> = StrategyMap[T];
|
|
11
|
+
export type PayloadTypeByStrategy<T extends ChannelStrategy<unknown>> = T extends ChannelStrategy<infer U> ? U : never;
|
|
12
|
+
export type AnyStrategy = ClassicStrategy | RTCStrategy | CombinedStrategy<PayloadTypeByStrategy<RTCStrategy>, PayloadTypeByStrategy<ClassicStrategy>>;
|
|
13
13
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as OpenFin from '../../../../OpenFin';
|
|
2
|
-
|
|
2
|
+
type ProviderIdentity = OpenFin.ProviderIdentity;
|
|
3
3
|
export interface ChannelStrategy<T extends unknown> {
|
|
4
4
|
onEndpointDisconnect(endpointId: string, listener: () => void): void;
|
|
5
5
|
receive(listener: (action: string, payload: any, identity: any) => Promise<any>): void;
|
|
@@ -10,8 +10,8 @@ export interface ChannelStrategy<T extends unknown> {
|
|
|
10
10
|
addEndpoint(endpointId: string, payload: T): void;
|
|
11
11
|
isValidEndpointPayload(payload: unknown): payload is T;
|
|
12
12
|
}
|
|
13
|
-
export
|
|
14
|
-
export
|
|
13
|
+
export type EndpointIdentity = OpenFin.ClientIdentity | ProviderIdentity;
|
|
14
|
+
export type EndpointPayload = {
|
|
15
15
|
endpointIdentity: EndpointIdentity;
|
|
16
16
|
};
|
|
17
17
|
export {};
|
|
@@ -2,11 +2,11 @@ import type * as OpenFin from '../../../OpenFin';
|
|
|
2
2
|
import { ChannelBase } from './channel';
|
|
3
3
|
import { Transport } from '../../../transport/transport';
|
|
4
4
|
import { AnyStrategy } from './protocols/strategy-types';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
|
|
5
|
+
type ProviderIdentity = OpenFin.ProviderIdentity;
|
|
6
|
+
type ClientIdentity = OpenFin.ClientIdentity;
|
|
7
|
+
export type ConnectionListener = (identity: ClientIdentity, connectionMessage?: any) => Promise<any> | any;
|
|
8
|
+
export type DisconnectionListener = (identity: ClientIdentity) => any;
|
|
9
|
+
type ClientConnectionPayload = OpenFin.ClientIdentity & OpenFin.ClientInfo;
|
|
10
10
|
export declare class ChannelProvider extends ChannelBase {
|
|
11
11
|
#private;
|
|
12
12
|
private static removalMap;
|
|
@@ -1,21 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
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");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
2
7
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
8
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
9
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
10
|
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
11
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
12
|
};
|
|
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);
|
|
12
|
-
};
|
|
13
13
|
var _ChannelProvider_connections, _ChannelProvider_protectedObj, _ChannelProvider_strategy, _ChannelProvider_removeEndpoint, _ChannelProvider_close;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ChannelProvider = void 0;
|
|
16
16
|
const channel_1 = require("./channel");
|
|
17
17
|
const runtimeVersioning_1 = require("../../../util/runtimeVersioning");
|
|
18
18
|
class ChannelProvider extends channel_1.ChannelBase {
|
|
19
|
+
get connections() {
|
|
20
|
+
return [...__classPrivateFieldGet(this, _ChannelProvider_connections, "f")];
|
|
21
|
+
}
|
|
22
|
+
static handleClientDisconnection(channel, payload) {
|
|
23
|
+
const removeById = channel.connections.find((identity) => identity.endpointId === payload.endpointId);
|
|
24
|
+
if (removeById) {
|
|
25
|
+
__classPrivateFieldGet(channel, _ChannelProvider_removeEndpoint, "f").call(channel, removeById);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
const multipleRemoves = channel.connections.filter((identity) => {
|
|
29
|
+
return identity.uuid === payload.uuid && identity.name === payload.name;
|
|
30
|
+
});
|
|
31
|
+
multipleRemoves.forEach(__classPrivateFieldGet(channel, _ChannelProvider_removeEndpoint, "f"));
|
|
32
|
+
}
|
|
33
|
+
channel.disconnectListener(payload);
|
|
34
|
+
}
|
|
35
|
+
static setProviderRemoval(provider, remove) {
|
|
36
|
+
ChannelProvider.removalMap.set(provider, remove);
|
|
37
|
+
}
|
|
19
38
|
constructor(providerIdentity, wire, strategy) {
|
|
20
39
|
super();
|
|
21
40
|
_ChannelProvider_connections.set(this, void 0);
|
|
@@ -51,25 +70,6 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
51
70
|
__classPrivateFieldSet(this, _ChannelProvider_strategy, strategy, "f");
|
|
52
71
|
strategy.receive(this.processAction);
|
|
53
72
|
}
|
|
54
|
-
get connections() {
|
|
55
|
-
return [...__classPrivateFieldGet(this, _ChannelProvider_connections, "f")];
|
|
56
|
-
}
|
|
57
|
-
static handleClientDisconnection(channel, payload) {
|
|
58
|
-
const removeById = channel.connections.find((identity) => identity.endpointId === payload.endpointId);
|
|
59
|
-
if (removeById) {
|
|
60
|
-
__classPrivateFieldGet(channel, _ChannelProvider_removeEndpoint, "f").call(channel, removeById);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
const multipleRemoves = channel.connections.filter((identity) => {
|
|
64
|
-
return identity.uuid === payload.uuid && identity.name === payload.name;
|
|
65
|
-
});
|
|
66
|
-
multipleRemoves.forEach(__classPrivateFieldGet(channel, _ChannelProvider_removeEndpoint, "f"));
|
|
67
|
-
}
|
|
68
|
-
channel.disconnectListener(payload);
|
|
69
|
-
}
|
|
70
|
-
static setProviderRemoval(provider, remove) {
|
|
71
|
-
ChannelProvider.removalMap.set(provider, remove);
|
|
72
|
-
}
|
|
73
73
|
dispatch(to, action, payload) {
|
|
74
74
|
var _a;
|
|
75
75
|
const endpointId = (_a = to.endpointId) !== null && _a !== void 0 ? _a : this.getEndpointIdForOpenFinId(to, action);
|
|
@@ -3,7 +3,7 @@ import { AppIdentifier } from './fdc3/shapes/fdc3v2';
|
|
|
3
3
|
import type * as OpenFin from '../../OpenFin';
|
|
4
4
|
import { Base } from '../base';
|
|
5
5
|
import type { Transport } from '../../transport/transport';
|
|
6
|
-
|
|
6
|
+
type Identity = OpenFin.Identity;
|
|
7
7
|
/**
|
|
8
8
|
* {@link https://developers.openfin.co/of-docs/docs/enable-color-linking}
|
|
9
9
|
*
|
|
@@ -5,6 +5,7 @@ const base_1 = require("../base");
|
|
|
5
5
|
const SessionContextGroupBroker_1 = require("./SessionContextGroupBroker");
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
7
|
const lodash_1 = require("lodash");
|
|
8
|
+
const PrivateChannelProvider_1 = require("./fdc3/PrivateChannelProvider");
|
|
8
9
|
let contextGroups = [
|
|
9
10
|
{
|
|
10
11
|
id: 'green',
|
|
@@ -1009,8 +1010,6 @@ class InteropBroker extends base_1.Base {
|
|
|
1009
1010
|
});
|
|
1010
1011
|
this.clientDisconnected(clientIdentity);
|
|
1011
1012
|
});
|
|
1012
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1013
|
-
// @ts-ignore
|
|
1014
1013
|
channel.beforeAction(async (action, payload, clientIdentity) => {
|
|
1015
1014
|
var _a, _b;
|
|
1016
1015
|
if (!(await this.isActionAuthorized(action, payload, clientIdentity))) {
|
|
@@ -1052,6 +1051,11 @@ class InteropBroker extends base_1.Base {
|
|
|
1052
1051
|
channel.register('fdc3v2GetInfo', async (payload, clientIdentity) => {
|
|
1053
1052
|
return this.fdc3HandleGetInfo.bind(this)(payload, clientIdentity);
|
|
1054
1053
|
});
|
|
1054
|
+
channel.register('createPrivateChannelProvider', async (payload) => {
|
|
1055
|
+
const { channelId } = payload;
|
|
1056
|
+
const channelProvider = await this.fin.InterApplicationBus.Channel.create(channelId);
|
|
1057
|
+
PrivateChannelProvider_1.PrivateChannelProvider.init(channelProvider, channelId);
|
|
1058
|
+
});
|
|
1055
1059
|
}
|
|
1056
1060
|
/**
|
|
1057
1061
|
* Can be used to completely prevent a connection. Return false to prevent connections. Allows all connections by default.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as OpenFin from '../../../OpenFin';
|
|
2
2
|
import type { Listener, Context, ContextHandler } from './shapes/fdc3v2';
|
|
3
|
-
|
|
3
|
+
type HandlerId = string;
|
|
4
4
|
export declare class PrivateChannelClient {
|
|
5
5
|
id: string;
|
|
6
6
|
client: OpenFin.ChannelClient;
|
|
@@ -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
|
+
type HandlerId = string;
|
|
4
|
+
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;
|
|
@@ -74,16 +84,9 @@ class PrivateChannelProvider {
|
|
|
74
84
|
if (contextType) {
|
|
75
85
|
const currentHandlersList = senderClientState.handlerIdsByContextTypes.get(contextType) || [];
|
|
76
86
|
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
87
|
}
|
|
82
88
|
else {
|
|
83
89
|
senderClientState.globalHandler = handlerId;
|
|
84
|
-
if (this.lastContext) {
|
|
85
|
-
this.provider.dispatch(senderClientIdentity, handlerId, this.lastContext);
|
|
86
|
-
}
|
|
87
90
|
}
|
|
88
91
|
Array.from(this.clients.values()).forEach((currClientState) => {
|
|
89
92
|
if (currClientState.clientIdentity.endpointId !== senderClientIdentity.endpointId &&
|
|
@@ -110,17 +113,18 @@ class PrivateChannelProvider {
|
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
115
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
// getting only valid client connections here, it is possible we haven't removed a disconnected client from the map yet
|
|
117
|
+
// so we need to ensure we don't dispatch to any disconnected client
|
|
118
|
+
// TODO: Take a look at our client disconnection logic and see if we can handle client disconnection cleanly
|
|
119
|
+
const clientsToDispatchTo = await this.getConnectedClients();
|
|
120
|
+
const dispatchPromises = clientsToDispatchTo.map(async (otherClientState) => {
|
|
121
|
+
const { clientIdentity, clientIdentity: { endpointId }, onUnsubscribeHandlerId } = otherClientState;
|
|
122
|
+
if (endpointId !== removingClientIdentity.endpointId && onUnsubscribeHandlerId) {
|
|
123
|
+
await this.provider.dispatch(clientIdentity, onUnsubscribeHandlerId, contextType);
|
|
120
124
|
}
|
|
121
|
-
}
|
|
125
|
+
});
|
|
122
126
|
try {
|
|
123
|
-
await Promise.all(
|
|
127
|
+
await Promise.all(dispatchPromises);
|
|
124
128
|
}
|
|
125
129
|
catch (error) {
|
|
126
130
|
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 +185,68 @@ class PrivateChannelProvider {
|
|
|
181
185
|
}
|
|
182
186
|
clientState.onUnsubscribeHandlerId = handlerId;
|
|
183
187
|
}
|
|
184
|
-
|
|
188
|
+
removeClient(disconnectingClientIdentity) {
|
|
185
189
|
const disconnectingClientState = this.getClientState(disconnectingClientIdentity);
|
|
186
190
|
if (!disconnectingClientState) {
|
|
187
191
|
throw new Error(`Client with Identity: ${disconnectingClientIdentity.uuid} ${disconnectingClientIdentity.name}, tried to call disconnect, is not connected to this Private Channel`);
|
|
188
192
|
}
|
|
189
193
|
disconnectingClientState.handlerIdsByContextTypes.clear();
|
|
190
194
|
this.clients.delete(disconnectingClientIdentity.endpointId);
|
|
191
|
-
|
|
195
|
+
}
|
|
196
|
+
async fireOnDisconnectForOtherClients(disconnectingClientIdentity) {
|
|
192
197
|
// TODO: call onDisconnect Handler of the other client only.
|
|
193
198
|
// 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
|
-
|
|
199
|
+
const { endpointId } = disconnectingClientIdentity;
|
|
200
|
+
// getting only valid client connections here, it is possible we haven't removed a disconnected client from the map yet
|
|
201
|
+
// so we need to ensure we don't dispatch to any disconnected client
|
|
202
|
+
// TODO: Take a look at our client disconnection logic and see if we can handle client disconnection cleanly
|
|
203
|
+
const clientsToDispatchTo = await this.getConnectedClients();
|
|
204
|
+
const dispatchPromises = clientsToDispatchTo.map(async (otherClientState) => {
|
|
205
|
+
const { clientIdentity: { endpointId: otherClientEndpointId }, onDisconnectHandlerId } = otherClientState;
|
|
206
|
+
if (otherClientEndpointId !== endpointId && onDisconnectHandlerId) {
|
|
207
|
+
await this.provider.dispatch(otherClientState.clientIdentity, onDisconnectHandlerId);
|
|
200
208
|
}
|
|
201
|
-
}
|
|
209
|
+
});
|
|
202
210
|
try {
|
|
203
|
-
await Promise.all(
|
|
211
|
+
await Promise.all(dispatchPromises);
|
|
204
212
|
}
|
|
205
213
|
catch (error) {
|
|
206
214
|
console.error(`Problem when attempting to dispatch to onDisconnectHandlers. Error: ${error} Disconnecting Client: uuid: ${disconnectingClientIdentity.uuid}. name: ${disconnectingClientIdentity.name}. endpointId: ${disconnectingClientIdentity.endpointId}`);
|
|
207
215
|
throw new Error(error);
|
|
208
216
|
}
|
|
209
217
|
}
|
|
218
|
+
async unsubscribeAll(clientIdentity) {
|
|
219
|
+
const { endpointId } = clientIdentity;
|
|
220
|
+
const state = this.clients.get(endpointId);
|
|
221
|
+
if (state) {
|
|
222
|
+
const contextTypeHandlerIds = Array.from(state.handlerIdsByContextTypes.values()).flat();
|
|
223
|
+
const globalHandlerId = state.globalHandler;
|
|
224
|
+
if (contextTypeHandlerIds.length > 0) {
|
|
225
|
+
const unsubPromises = contextTypeHandlerIds.map(async (handlerId) => {
|
|
226
|
+
return this.contextHandlerRemoved({ handlerId }, clientIdentity);
|
|
227
|
+
});
|
|
228
|
+
try {
|
|
229
|
+
await Promise.all(unsubPromises);
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
console.error(error.message);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (globalHandlerId) {
|
|
236
|
+
try {
|
|
237
|
+
await this.contextHandlerRemoved({ handlerId: globalHandlerId }, clientIdentity);
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
console.error(error.message);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
async handleClientDisconnecting(disconnectingClientIdentity) {
|
|
246
|
+
await this.unsubscribeAll(disconnectingClientIdentity);
|
|
247
|
+
this.removeClient(disconnectingClientIdentity);
|
|
248
|
+
await this.fireOnDisconnectForOtherClients(disconnectingClientIdentity);
|
|
249
|
+
}
|
|
210
250
|
registerNewClient(clientIdentity) {
|
|
211
251
|
if (!this.clients.has(clientIdentity.endpointId)) {
|
|
212
252
|
const clientSubscriptionState = {
|
|
@@ -220,5 +260,17 @@ class PrivateChannelProvider {
|
|
|
220
260
|
this.clients.set(clientIdentity.endpointId, clientSubscriptionState);
|
|
221
261
|
}
|
|
222
262
|
}
|
|
263
|
+
async getConnectedClients() {
|
|
264
|
+
const allClientInfo = await this.provider.getAllClientInfo();
|
|
265
|
+
return Array.from(this.clients.values()).filter((clientState) => {
|
|
266
|
+
const { uuid, name } = clientState.clientIdentity;
|
|
267
|
+
return allClientInfo.some((clientInfo) => {
|
|
268
|
+
return name === clientInfo.name && uuid === clientInfo.uuid;
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
static init(channelProvider, id) {
|
|
273
|
+
return new PrivateChannelProvider(channelProvider, id);
|
|
274
|
+
}
|
|
223
275
|
}
|
|
224
276
|
exports.PrivateChannelProvider = PrivateChannelProvider;
|