@openfin/core 31.74.1 → 31.74.2
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/base.d.ts +2 -2
- 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 +17 -17
- 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 -21
- package/src/api/interop/fdc3/fdc3-1.2.js +19 -4
- 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 +52 -18
- 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
|
@@ -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;
|
|
@@ -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;
|
|
@@ -169,11 +169,15 @@ class Fdc3Module extends base_1.Base {
|
|
|
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
|
/**
|
|
@@ -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.
|