@openfin/core 33.76.36 → 33.77.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 +1 -1
- package/README.md +29 -4
- package/fin.d.ts +2 -2
- package/{src → out}/GlobalOpenFin.d.ts +1 -1
- package/out/mock-alpha.d.ts +16112 -0
- package/out/mock-beta.d.ts +16112 -0
- package/out/mock-public.d.ts +16112 -0
- package/out/mock.d.ts +16797 -0
- package/out/mock.js +17111 -0
- package/package.json +30 -23
- package/LICENSE +0 -13
- package/NOTICE +0 -16
- package/openfin-core-33.76.36.tgz +0 -0
- package/src/OpenFin.d.ts +0 -3091
- package/src/OpenFin.js +0 -2
- package/src/api/api-exposer/api-consumer.d.ts +0 -28
- package/src/api/api-exposer/api-consumer.js +0 -28
- package/src/api/api-exposer/api-exposer.d.ts +0 -35
- package/src/api/api-exposer/api-exposer.js +0 -38
- package/src/api/api-exposer/decorators.d.ts +0 -10
- package/src/api/api-exposer/decorators.js +0 -18
- package/src/api/api-exposer/index.d.ts +0 -4
- package/src/api/api-exposer/index.js +0 -20
- package/src/api/api-exposer/strategies/index.d.ts +0 -1
- package/src/api/api-exposer/strategies/index.js +0 -17
- package/src/api/api-exposer/strategies/openfin-channels/channels-consumer.d.ts +0 -14
- package/src/api/api-exposer/strategies/openfin-channels/channels-consumer.js +0 -20
- package/src/api/api-exposer/strategies/openfin-channels/channels-exposer.d.ts +0 -20
- package/src/api/api-exposer/strategies/openfin-channels/channels-exposer.js +0 -23
- package/src/api/api-exposer/strategies/openfin-channels/index.d.ts +0 -2
- package/src/api/api-exposer/strategies/openfin-channels/index.js +0 -18
- package/src/api/application/Factory.d.ts +0 -196
- package/src/api/application/Factory.js +0 -278
- package/src/api/application/Instance.d.ts +0 -692
- package/src/api/application/Instance.js +0 -821
- package/src/api/application/index.d.ts +0 -12
- package/src/api/application/index.js +0 -28
- package/src/api/base.d.ts +0 -117
- package/src/api/base.js +0 -246
- package/src/api/clipboard/index.d.ts +0 -172
- package/src/api/clipboard/index.js +0 -200
- package/src/api/events/application.d.ts +0 -158
- package/src/api/events/application.js +0 -14
- package/src/api/events/base.d.ts +0 -42
- package/src/api/events/base.js +0 -2
- package/src/api/events/channel.d.ts +0 -35
- package/src/api/events/channel.js +0 -7
- package/src/api/events/emitterMap.d.ts +0 -11
- package/src/api/events/emitterMap.js +0 -35
- package/src/api/events/eventAggregator.d.ts +0 -5
- package/src/api/events/eventAggregator.js +0 -35
- package/src/api/events/externalApplication.d.ts +0 -24
- package/src/api/events/externalApplication.js +0 -7
- package/src/api/events/frame.d.ts +0 -35
- package/src/api/events/frame.js +0 -2
- package/src/api/events/globalHotkey.d.ts +0 -25
- package/src/api/events/globalHotkey.js +0 -2
- package/src/api/events/platform.d.ts +0 -34
- package/src/api/events/platform.js +0 -10
- package/src/api/events/system.d.ts +0 -126
- package/src/api/events/system.js +0 -15
- package/src/api/events/typedEventEmitter.d.ts +0 -20
- package/src/api/events/typedEventEmitter.js +0 -2
- package/src/api/events/view.d.ts +0 -92
- package/src/api/events/view.js +0 -12
- package/src/api/events/webcontents.d.ts +0 -277
- package/src/api/events/webcontents.js +0 -13
- package/src/api/events/window.d.ts +0 -421
- package/src/api/events/window.js +0 -12
- package/src/api/external-application/Factory.d.ts +0 -34
- package/src/api/external-application/Factory.js +0 -47
- package/src/api/external-application/Instance.d.ts +0 -110
- package/src/api/external-application/Instance.js +0 -117
- package/src/api/external-application/index.d.ts +0 -12
- package/src/api/external-application/index.js +0 -28
- package/src/api/fin.d.ts +0 -54
- package/src/api/fin.js +0 -45
- package/src/api/frame/Factory.d.ts +0 -54
- package/src/api/frame/Factory.js +0 -86
- package/src/api/frame/Instance.d.ts +0 -136
- package/src/api/frame/Instance.js +0 -143
- package/src/api/frame/index.d.ts +0 -14
- package/src/api/frame/index.js +0 -30
- package/src/api/global-hotkey/index.d.ts +0 -106
- package/src/api/global-hotkey/index.js +0 -132
- package/src/api/interappbus/channel/channel.d.ts +0 -285
- package/src/api/interappbus/channel/channel.js +0 -334
- package/src/api/interappbus/channel/channels-docs.d.ts +0 -342
- package/src/api/interappbus/channel/channels-docs.js +0 -401
- package/src/api/interappbus/channel/client.d.ts +0 -117
- package/src/api/interappbus/channel/client.js +0 -181
- package/src/api/interappbus/channel/connection-manager.d.ts +0 -29
- package/src/api/interappbus/channel/connection-manager.js +0 -246
- package/src/api/interappbus/channel/index.d.ts +0 -189
- package/src/api/interappbus/channel/index.js +0 -333
- package/src/api/interappbus/channel/protocols/classic/message-receiver.d.ts +0 -13
- package/src/api/interappbus/channel/protocols/classic/message-receiver.js +0 -73
- package/src/api/interappbus/channel/protocols/classic/strategy.d.ts +0 -24
- package/src/api/interappbus/channel/protocols/classic/strategy.js +0 -101
- package/src/api/interappbus/channel/protocols/combined/strategy.d.ts +0 -20
- package/src/api/interappbus/channel/protocols/combined/strategy.js +0 -58
- package/src/api/interappbus/channel/protocols/index.d.ts +0 -47
- package/src/api/interappbus/channel/protocols/index.js +0 -2
- package/src/api/interappbus/channel/protocols/protocol-manager.d.ts +0 -10
- package/src/api/interappbus/channel/protocols/protocol-manager.js +0 -43
- package/src/api/interappbus/channel/protocols/rtc/endpoint.d.ts +0 -25
- package/src/api/interappbus/channel/protocols/rtc/endpoint.js +0 -141
- package/src/api/interappbus/channel/protocols/rtc/ice-manager.d.ts +0 -30
- package/src/api/interappbus/channel/protocols/rtc/ice-manager.js +0 -130
- package/src/api/interappbus/channel/protocols/rtc/strategy.d.ts +0 -24
- package/src/api/interappbus/channel/protocols/rtc/strategy.js +0 -85
- package/src/api/interappbus/channel/protocols/strategy-types.d.ts +0 -13
- package/src/api/interappbus/channel/protocols/strategy-types.js +0 -2
- package/src/api/interappbus/channel/protocols/strategy.d.ts +0 -17
- package/src/api/interappbus/channel/protocols/strategy.js +0 -2
- package/src/api/interappbus/channel/provider.d.ts +0 -206
- package/src/api/interappbus/channel/provider.js +0 -338
- package/src/api/interappbus/index.d.ts +0 -120
- package/src/api/interappbus/index.js +0 -210
- package/src/api/interop/Factory.d.ts +0 -57
- package/src/api/interop/Factory.js +0 -96
- package/src/api/interop/InteropBroker.d.ts +0 -665
- package/src/api/interop/InteropBroker.js +0 -1313
- package/src/api/interop/InteropClient.d.ts +0 -502
- package/src/api/interop/InteropClient.js +0 -683
- package/src/api/interop/SessionContextGroupBroker.d.ts +0 -27
- package/src/api/interop/SessionContextGroupBroker.js +0 -108
- package/src/api/interop/SessionContextGroupClient.d.ts +0 -21
- package/src/api/interop/SessionContextGroupClient.js +0 -86
- package/src/api/interop/fdc3/PrivateChannelClient.d.ts +0 -20
- package/src/api/interop/fdc3/PrivateChannelClient.js +0 -90
- package/src/api/interop/fdc3/PrivateChannelProvider.d.ts +0 -55
- package/src/api/interop/fdc3/PrivateChannelProvider.js +0 -276
- package/src/api/interop/fdc3/documentationStub.d.ts +0 -14
- package/src/api/interop/fdc3/documentationStub.js +0 -17
- package/src/api/interop/fdc3/fdc3-1.2.d.ts +0 -205
- package/src/api/interop/fdc3/fdc3-1.2.js +0 -435
- package/src/api/interop/fdc3/fdc3-2.0.d.ts +0 -298
- package/src/api/interop/fdc3/fdc3-2.0.js +0 -479
- package/src/api/interop/fdc3/fdc3.d.ts +0 -12
- package/src/api/interop/fdc3/fdc3.js +0 -35
- package/src/api/interop/fdc3/overrideCheck.d.ts +0 -4
- package/src/api/interop/fdc3/overrideCheck.js +0 -32
- package/src/api/interop/fdc3/shapes/fdc3v1.d.ts +0 -53
- package/src/api/interop/fdc3/shapes/fdc3v1.js +0 -4
- package/src/api/interop/fdc3/shapes/fdc3v2.d.ts +0 -75
- package/src/api/interop/fdc3/shapes/fdc3v2.js +0 -2
- package/src/api/interop/fdc3/utils.d.ts +0 -45
- package/src/api/interop/fdc3/utils.js +0 -239
- package/src/api/interop/fdc3/versions.d.ts +0 -1
- package/src/api/interop/fdc3/versions.js +0 -2
- package/src/api/interop/index.d.ts +0 -12
- package/src/api/interop/index.js +0 -28
- package/src/api/interop/utils.d.ts +0 -18
- package/src/api/interop/utils.js +0 -61
- package/src/api/me.d.ts +0 -40
- package/src/api/me.js +0 -134
- package/src/api/platform/Factory.d.ts +0 -171
- package/src/api/platform/Factory.js +0 -240
- package/src/api/platform/Instance.d.ts +0 -653
- package/src/api/platform/Instance.js +0 -834
- package/src/api/platform/common-utils.d.ts +0 -7
- package/src/api/platform/common-utils.js +0 -16
- package/src/api/platform/index.d.ts +0 -12
- package/src/api/platform/index.js +0 -28
- package/src/api/platform/layout/Factory.d.ts +0 -91
- package/src/api/platform/layout/Factory.js +0 -151
- package/src/api/platform/layout/Instance.d.ts +0 -192
- package/src/api/platform/layout/Instance.js +0 -224
- package/src/api/platform/layout/controllers/layout-content-cache.d.ts +0 -9
- package/src/api/platform/layout/controllers/layout-content-cache.js +0 -54
- package/src/api/platform/layout/controllers/layout-entities-controller.d.ts +0 -119
- package/src/api/platform/layout/controllers/layout-entities-controller.js +0 -287
- package/src/api/platform/layout/entities/layout-entities.d.ts +0 -427
- package/src/api/platform/layout/entities/layout-entities.js +0 -504
- package/src/api/platform/layout/entities/shapes.d.ts +0 -6
- package/src/api/platform/layout/entities/shapes.js +0 -2
- package/src/api/platform/layout/index.d.ts +0 -11
- package/src/api/platform/layout/index.js +0 -27
- package/src/api/platform/layout/layout.constants.d.ts +0 -1
- package/src/api/platform/layout/layout.constants.js +0 -4
- package/src/api/platform/layout/shapes.d.ts +0 -16
- package/src/api/platform/layout/shapes.js +0 -2
- package/src/api/platform/layout/utils/layout-traversal.d.ts +0 -4
- package/src/api/platform/layout/utils/layout-traversal.js +0 -65
- package/src/api/platform/provider.d.ts +0 -510
- package/src/api/platform/provider.js +0 -2
- package/src/api/snapshot-source/Factory.d.ts +0 -53
- package/src/api/snapshot-source/Factory.js +0 -81
- package/src/api/snapshot-source/Instance.d.ts +0 -53
- package/src/api/snapshot-source/Instance.js +0 -154
- package/src/api/snapshot-source/index.d.ts +0 -12
- package/src/api/snapshot-source/index.js +0 -28
- package/src/api/snapshot-source/utils.d.ts +0 -2
- package/src/api/snapshot-source/utils.js +0 -6
- package/src/api/system/index.d.ts +0 -1468
- package/src/api/system/index.js +0 -1851
- package/src/api/view/Factory.d.ts +0 -88
- package/src/api/view/Factory.js +0 -141
- package/src/api/view/Instance.d.ts +0 -601
- package/src/api/view/Instance.js +0 -671
- package/src/api/view/index.d.ts +0 -12
- package/src/api/view/index.js +0 -28
- package/src/api/webcontents/main.d.ts +0 -922
- package/src/api/webcontents/main.js +0 -1046
- package/src/api/window/Factory.d.ts +0 -96
- package/src/api/window/Factory.js +0 -142
- package/src/api/window/Instance.d.ts +0 -1598
- package/src/api/window/Instance.js +0 -1851
- package/src/api/window/index.d.ts +0 -14
- package/src/api/window/index.js +0 -30
- package/src/browser.d.ts +0 -10
- package/src/browser.js +0 -36
- package/src/environment/browser.d.ts +0 -29
- package/src/environment/browser.js +0 -60
- package/src/environment/environment.d.ts +0 -33
- package/src/environment/environment.js +0 -4
- package/src/environment/mockEnvironment.d.ts +0 -27
- package/src/environment/mockEnvironment.js +0 -61
- package/src/environment/node-env.d.ts +0 -29
- package/src/environment/node-env.js +0 -72
- package/src/fdc3.d.ts +0 -3
- package/src/fdc3.js +0 -9
- package/src/mock.d.ts +0 -3
- package/src/mock.js +0 -18
- package/src/namespaces.d.ts +0 -22
- package/src/namespaces.js +0 -26
- package/src/shapes/ERROR_BOX_TYPES.d.ts +0 -1
- package/src/shapes/ERROR_BOX_TYPES.js +0 -2
- package/src/shapes/WebOptions.d.ts +0 -13
- package/src/shapes/WebOptions.js +0 -2
- package/src/shapes/WindowOptions.d.ts +0 -43
- package/src/shapes/WindowOptions.js +0 -2
- package/src/shapes/protocol.d.ts +0 -204
- package/src/shapes/protocol.js +0 -2
- package/src/transport/mockWire.d.ts +0 -11
- package/src/transport/mockWire.js +0 -26
- package/src/transport/transport-errors.d.ts +0 -31
- package/src/transport/transport-errors.js +0 -79
- package/src/transport/transport.d.ts +0 -73
- package/src/transport/transport.js +0 -219
- package/src/transport/wire.d.ts +0 -77
- package/src/transport/wire.js +0 -36
- package/src/util/asyncFilter.d.ts +0 -1
- package/src/util/asyncFilter.js +0 -7
- package/src/util/channel-api-relay.d.ts +0 -13
- package/src/util/channel-api-relay.js +0 -47
- package/src/util/errors.d.ts +0 -10
- package/src/util/errors.js +0 -12
- package/src/util/exhaustive.d.ts +0 -1
- package/src/util/exhaustive.js +0 -7
- package/src/util/http.d.ts +0 -11
- package/src/util/http.js +0 -90
- package/src/util/inaccessibleObject.d.ts +0 -2
- package/src/util/inaccessibleObject.js +0 -49
- package/src/util/lazy.d.ts +0 -34
- package/src/util/lazy.js +0 -54
- package/src/util/normalize-config.d.ts +0 -3
- package/src/util/normalize-config.js +0 -52
- package/src/util/promises.d.ts +0 -5
- package/src/util/promises.js +0 -27
- package/src/util/ref-counter.d.ts +0 -7
- package/src/util/ref-counter.js +0 -52
- package/src/util/reversible-map.d.ts +0 -11
- package/src/util/reversible-map.js +0 -49
- package/src/util/runtimeVersioning.d.ts +0 -3
- package/src/util/runtimeVersioning.js +0 -25
- package/src/util/utilTypes.d.ts +0 -8
- package/src/util/utilTypes.js +0 -2
- package/src/util/validate.d.ts +0 -3
- package/src/util/validate.js +0 -11
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export interface ProtocolPacketBase {
|
|
2
|
-
version: number;
|
|
3
|
-
minimumVersion?: number;
|
|
4
|
-
type: string;
|
|
5
|
-
payload?: any;
|
|
6
|
-
}
|
|
7
|
-
export interface ClassicProtocolOffer extends ProtocolPacketBase {
|
|
8
|
-
type: 'classic';
|
|
9
|
-
}
|
|
10
|
-
export interface RTCProtocolOffer extends ProtocolPacketBase {
|
|
11
|
-
type: 'rtc';
|
|
12
|
-
payload: {
|
|
13
|
-
offer: RTCSessionDescriptionInit;
|
|
14
|
-
rtcConnectionId: string;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
export type ProtocolOffer = ClassicProtocolOffer | RTCProtocolOffer;
|
|
18
|
-
/**
|
|
19
|
-
* Protocol values for determining channel messaging strategy.
|
|
20
|
-
*/
|
|
21
|
-
export type MessagingProtocols = ProtocolOffer['type'];
|
|
22
|
-
export type LocalSupportedProtocol = {
|
|
23
|
-
type: MessagingProtocols;
|
|
24
|
-
minimumVersion: number;
|
|
25
|
-
version: number;
|
|
26
|
-
};
|
|
27
|
-
export interface ExternalClientOffer {
|
|
28
|
-
maxProtocols: number;
|
|
29
|
-
supportedProtocols: ProtocolPacketBase[];
|
|
30
|
-
}
|
|
31
|
-
export interface ClientOffer {
|
|
32
|
-
supportedProtocols: ProtocolOffer[];
|
|
33
|
-
maxProtocols: number;
|
|
34
|
-
}
|
|
35
|
-
export interface ClassicProtocolAnswer extends ProtocolPacketBase {
|
|
36
|
-
type: 'classic';
|
|
37
|
-
}
|
|
38
|
-
export interface RTCProtocolAnswer extends ProtocolPacketBase {
|
|
39
|
-
type: 'rtc';
|
|
40
|
-
payload: {
|
|
41
|
-
answer: RTCSessionDescriptionInit;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
export type ProtocolAnswer = ClassicProtocolAnswer | RTCProtocolAnswer;
|
|
45
|
-
export interface ClientAnswer {
|
|
46
|
-
supportedProtocols: ProtocolAnswer[];
|
|
47
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ExternalClientOffer, LocalSupportedProtocol, MessagingProtocols, ProtocolOffer } from '.';
|
|
2
|
-
export declare class ProtocolManager {
|
|
3
|
-
private ProtocolsInPreferenceOrder;
|
|
4
|
-
DefaultClientProtocols: ['classic'];
|
|
5
|
-
DefaultProviderProtocols: ['classic'];
|
|
6
|
-
constructor(ProtocolsInPreferenceOrder: MessagingProtocols[]);
|
|
7
|
-
getClientProtocols: (protocols?: string[]) => MessagingProtocols[];
|
|
8
|
-
getProviderProtocols: (protocols?: string[]) => ['rtc'] | ['rtc', 'classic'] | ['classic'];
|
|
9
|
-
getCompatibleProtocols: (providerProtocols: LocalSupportedProtocol[], clientOffer: ExternalClientOffer) => ProtocolOffer[];
|
|
10
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProtocolManager = void 0;
|
|
4
|
-
/*
|
|
5
|
-
This should be agnostic of any actual openfin code to be unit testable.
|
|
6
|
-
Dependencies on the actual srategies should be handled in ConnectionManager
|
|
7
|
-
*/
|
|
8
|
-
class ProtocolManager {
|
|
9
|
-
// eslint-disable-next-line no-useless-constructor
|
|
10
|
-
constructor(ProtocolsInPreferenceOrder) {
|
|
11
|
-
this.ProtocolsInPreferenceOrder = ProtocolsInPreferenceOrder;
|
|
12
|
-
this.DefaultClientProtocols = ['classic'];
|
|
13
|
-
this.DefaultProviderProtocols = ['classic'];
|
|
14
|
-
this.getClientProtocols = (protocols) => {
|
|
15
|
-
const supported = protocols
|
|
16
|
-
? this.ProtocolsInPreferenceOrder.filter((x) => protocols.includes(x))
|
|
17
|
-
: this.DefaultClientProtocols;
|
|
18
|
-
if (!supported.length) {
|
|
19
|
-
throw new Error(`No valid protocols were passed in. Accepted values are: ${this.ProtocolsInPreferenceOrder.join(', ')}.`);
|
|
20
|
-
}
|
|
21
|
-
return supported;
|
|
22
|
-
};
|
|
23
|
-
this.getProviderProtocols = (protocols) => {
|
|
24
|
-
const supported = protocols
|
|
25
|
-
? this.ProtocolsInPreferenceOrder.filter((x) => protocols.includes(x))
|
|
26
|
-
: this.DefaultProviderProtocols;
|
|
27
|
-
if (!supported.length) {
|
|
28
|
-
throw new Error(`No valid protocols were passed in. Accepted values are: ${this.ProtocolsInPreferenceOrder.join(', ')}.`);
|
|
29
|
-
}
|
|
30
|
-
return supported;
|
|
31
|
-
};
|
|
32
|
-
this.getCompatibleProtocols = (providerProtocols, clientOffer) => {
|
|
33
|
-
const supported = clientOffer.supportedProtocols.filter((clientProtocol) => providerProtocols.some((providerProtocol) => {
|
|
34
|
-
var _a;
|
|
35
|
-
return providerProtocol.type === clientProtocol.type &&
|
|
36
|
-
clientProtocol.version >= providerProtocol.minimumVersion &&
|
|
37
|
-
providerProtocol.version >= ((_a = clientProtocol.minimumVersion) !== null && _a !== void 0 ? _a : 0);
|
|
38
|
-
}));
|
|
39
|
-
return supported.slice(0, clientOffer.maxProtocols);
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.ProtocolManager = ProtocolManager;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type * as OpenFin from '../../../../../OpenFin';
|
|
2
|
-
type ProviderIdentity = OpenFin.ProviderIdentity;
|
|
3
|
-
export interface RTCEndpointChannels {
|
|
4
|
-
request: RTCDataChannel;
|
|
5
|
-
response: RTCDataChannel;
|
|
6
|
-
}
|
|
7
|
-
export interface RTCPacket {
|
|
8
|
-
rtcClient: RTCPeerConnection;
|
|
9
|
-
channels: RTCEndpointChannels;
|
|
10
|
-
channelsOpened: Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
export declare class RTCEndpoint {
|
|
13
|
-
#private;
|
|
14
|
-
private rtc;
|
|
15
|
-
private endpointIdentity;
|
|
16
|
-
private responseMap;
|
|
17
|
-
constructor(rtc: RTCPacket, endpointIdentity: OpenFin.ClientIdentity | ProviderIdentity);
|
|
18
|
-
private connectionStateChangeHandler;
|
|
19
|
-
onDisconnect(listener: () => void): void;
|
|
20
|
-
receive(listener: (action: string, payload: any, identity: OpenFin.ClientIdentity | ProviderIdentity) => Promise<any>): void;
|
|
21
|
-
send: (action: string, payload: any) => Promise<any>;
|
|
22
|
-
close: () => void;
|
|
23
|
-
get connected(): boolean;
|
|
24
|
-
}
|
|
25
|
-
export {};
|
|
@@ -1,141 +0,0 @@
|
|
|
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
|
-
};
|
|
7
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
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");
|
|
11
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
|
-
};
|
|
13
|
-
var _RTCEndpoint_processAction, _RTCEndpoint_disconnectListener;
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.RTCEndpoint = void 0;
|
|
16
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
17
|
-
const errors_1 = require("../../../../../util/errors");
|
|
18
|
-
/*
|
|
19
|
-
This handles sending RTC messages between RTC connections over the request and response data channels.
|
|
20
|
-
*/
|
|
21
|
-
class RTCEndpoint {
|
|
22
|
-
constructor(rtc, endpointIdentity) {
|
|
23
|
-
this.rtc = rtc;
|
|
24
|
-
this.endpointIdentity = endpointIdentity;
|
|
25
|
-
this.responseMap = new Map();
|
|
26
|
-
_RTCEndpoint_processAction.set(this, null);
|
|
27
|
-
_RTCEndpoint_disconnectListener.set(this, void 0);
|
|
28
|
-
this.connectionStateChangeHandler = (event) => {
|
|
29
|
-
if (this.rtc.rtcClient.connectionState !== 'connected') {
|
|
30
|
-
this.rtc.rtcClient.removeEventListener('connectionstatechange', this.connectionStateChangeHandler);
|
|
31
|
-
this.close();
|
|
32
|
-
if (__classPrivateFieldGet(this, _RTCEndpoint_disconnectListener, "f")) {
|
|
33
|
-
__classPrivateFieldGet(this, _RTCEndpoint_disconnectListener, "f").call(this);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
this.send = async (action, payload) => {
|
|
38
|
-
const messageId = `message-${Math.random()}`;
|
|
39
|
-
const promise = new Promise((resolve, reject) => {
|
|
40
|
-
this.responseMap.set(messageId, { resolve, reject });
|
|
41
|
-
});
|
|
42
|
-
this.rtc.channels.request.send(JSON.stringify({ action, payload, messageId }));
|
|
43
|
-
return promise;
|
|
44
|
-
};
|
|
45
|
-
this.close = () => {
|
|
46
|
-
this.responseMap.forEach((response) => response.reject('Connection has closed.'));
|
|
47
|
-
this.responseMap = new Map();
|
|
48
|
-
this.rtc.channels.request.close();
|
|
49
|
-
this.rtc.channels.response.close();
|
|
50
|
-
this.rtc.rtcClient.close();
|
|
51
|
-
};
|
|
52
|
-
this.rtc.channels.response.addEventListener('message', (e) => {
|
|
53
|
-
var _a;
|
|
54
|
-
let { data } = e;
|
|
55
|
-
if (e.data instanceof ArrayBuffer) {
|
|
56
|
-
data = new TextDecoder().decode(e.data);
|
|
57
|
-
}
|
|
58
|
-
const { messageId, payload, success, error } = JSON.parse(data);
|
|
59
|
-
const { resolve, reject } = (_a = this.responseMap.get(messageId)) !== null && _a !== void 0 ? _a : {};
|
|
60
|
-
if (resolve && reject) {
|
|
61
|
-
this.responseMap.delete(messageId);
|
|
62
|
-
if (success) {
|
|
63
|
-
resolve(payload);
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
reject(error);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
console.log('Could not find id in responseMap.');
|
|
71
|
-
console.log(e);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
this.rtc.channels.request.addEventListener('message', async (e) => {
|
|
75
|
-
let { data } = e;
|
|
76
|
-
if (e.data instanceof ArrayBuffer) {
|
|
77
|
-
data = new TextDecoder().decode(e.data);
|
|
78
|
-
}
|
|
79
|
-
const { messageId, action, payload } = JSON.parse(data);
|
|
80
|
-
if (__classPrivateFieldGet(this, _RTCEndpoint_processAction, "f")) {
|
|
81
|
-
try {
|
|
82
|
-
const res = await __classPrivateFieldGet(this, _RTCEndpoint_processAction, "f").call(this, action, payload, endpointIdentity);
|
|
83
|
-
this.rtc.channels.response.send(JSON.stringify({
|
|
84
|
-
messageId,
|
|
85
|
-
payload: res,
|
|
86
|
-
success: true
|
|
87
|
-
}));
|
|
88
|
-
}
|
|
89
|
-
catch (error) {
|
|
90
|
-
// Check if RTCDataChannel is open before sending, error gets swallowed here in the case where
|
|
91
|
-
// client dispatched then closed or disconnected before the dispatch resolves.
|
|
92
|
-
if (this.rtc.channels.response.readyState === 'open') {
|
|
93
|
-
this.rtc.channels.response.send(JSON.stringify({
|
|
94
|
-
messageId,
|
|
95
|
-
error: (0, errors_1.errorToPOJO)(error),
|
|
96
|
-
success: false
|
|
97
|
-
}));
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
// Check if RTCDataChannel is open for same reason as catch block above.
|
|
101
|
-
}
|
|
102
|
-
else if (this.rtc.channels.response.readyState === 'open') {
|
|
103
|
-
this.rtc.channels.response.send(JSON.stringify({
|
|
104
|
-
messageId,
|
|
105
|
-
success: false,
|
|
106
|
-
error: 'Connection not ready.'
|
|
107
|
-
}));
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
this.rtc.rtcClient.addEventListener('connectionstatechange', this.connectionStateChangeHandler);
|
|
111
|
-
// Disconnect if data channels close unexpectedly, e.g. can happen due to message size > ~255kB (RTCPeerConnection.sctp.maxMessageSizeLimit: 262144)
|
|
112
|
-
Object.values(this.rtc.channels).forEach((datachannel) => {
|
|
113
|
-
datachannel.onclose = (e) => {
|
|
114
|
-
[...this.responseMap.values()].forEach((promise) => promise.reject(new Error('RTCDataChannel closed unexpectedly, this is most commonly caused by message size. Note: RTC Channels have a message size limit of ~255kB.')));
|
|
115
|
-
this.close();
|
|
116
|
-
if (__classPrivateFieldGet(this, _RTCEndpoint_disconnectListener, "f")) {
|
|
117
|
-
__classPrivateFieldGet(this, _RTCEndpoint_disconnectListener, "f").call(this);
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
onDisconnect(listener) {
|
|
123
|
-
if (!__classPrivateFieldGet(this, _RTCEndpoint_disconnectListener, "f")) {
|
|
124
|
-
__classPrivateFieldSet(this, _RTCEndpoint_disconnectListener, listener, "f");
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
throw new Error('RTCEndpoint disconnectListener cannot be set twice.');
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
receive(listener) {
|
|
131
|
-
if (__classPrivateFieldGet(this, _RTCEndpoint_processAction, "f")) {
|
|
132
|
-
throw new Error('You have already set a listener for this RTC Endpoint.');
|
|
133
|
-
}
|
|
134
|
-
__classPrivateFieldSet(this, _RTCEndpoint_processAction, listener, "f");
|
|
135
|
-
}
|
|
136
|
-
get connected() {
|
|
137
|
-
return this.rtc.rtcClient.connectionState === 'connected';
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
exports.RTCEndpoint = RTCEndpoint;
|
|
141
|
-
_RTCEndpoint_processAction = new WeakMap(), _RTCEndpoint_disconnectListener = new WeakMap();
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Transport } from '../../../../../transport/transport';
|
|
2
|
-
import { EmitterBase } from '../../../../base';
|
|
3
|
-
import { RTCEndpointChannels } from './endpoint';
|
|
4
|
-
export declare class RTCICEManager extends EmitterBase<any> {
|
|
5
|
-
constructor(wire: Transport);
|
|
6
|
-
static createDataChannelPromise(label: string, rtcClient: RTCPeerConnection): Promise<RTCDataChannel>;
|
|
7
|
-
ensureChannelOpened: (channel: RTCDataChannel) => Promise<void>;
|
|
8
|
-
listenForProviderIce(rtcConnectionId: string, listener: any): Promise<void>;
|
|
9
|
-
raiseProviderIce(rtcConnectionId: string, payload: any): Promise<void>;
|
|
10
|
-
listenForClientIce(rtcConnectionId: string, listener: any): Promise<void>;
|
|
11
|
-
raiseClientIce(rtcConnectionId: string, payload: any): Promise<void>;
|
|
12
|
-
private cleanupIceListeners;
|
|
13
|
-
private createClientEventName;
|
|
14
|
-
private createProviderEventName;
|
|
15
|
-
private createRouteString;
|
|
16
|
-
private createRtcPeer;
|
|
17
|
-
startClientOffer(): Promise<{
|
|
18
|
-
rtcClient: RTCPeerConnection;
|
|
19
|
-
offer: RTCSessionDescriptionInit;
|
|
20
|
-
channels: RTCEndpointChannels;
|
|
21
|
-
rtcConnectionId: string;
|
|
22
|
-
channelsOpened: Promise<void>;
|
|
23
|
-
}>;
|
|
24
|
-
finishClientOffer(rtcClient: RTCPeerConnection, answer: RTCSessionDescriptionInit, providerReady: Promise<void>): Promise<boolean>;
|
|
25
|
-
createProviderAnswer(rtcConnectionId: string, offer: RTCSessionDescriptionInit): Promise<{
|
|
26
|
-
rtcClient: RTCPeerConnection;
|
|
27
|
-
answer: RTCSessionDescriptionInit;
|
|
28
|
-
channels: Promise<RTCEndpointChannels>;
|
|
29
|
-
}>;
|
|
30
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RTCICEManager = void 0;
|
|
4
|
-
const base_1 = require("../../../../base");
|
|
5
|
-
/*
|
|
6
|
-
Singleton that facilitates Offer and Answer exchange required for establishing RTC connections.
|
|
7
|
-
*/
|
|
8
|
-
class RTCICEManager extends base_1.EmitterBase {
|
|
9
|
-
constructor(wire) {
|
|
10
|
-
super(wire, 'channel');
|
|
11
|
-
this.ensureChannelOpened = (channel) => {
|
|
12
|
-
return new Promise((resolve, reject) => {
|
|
13
|
-
if (channel.readyState === 'open') {
|
|
14
|
-
resolve();
|
|
15
|
-
}
|
|
16
|
-
else if (channel.readyState === 'connecting') {
|
|
17
|
-
const listener = () => {
|
|
18
|
-
channel.removeEventListener('open', listener);
|
|
19
|
-
resolve();
|
|
20
|
-
};
|
|
21
|
-
channel.addEventListener('open', listener);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
reject(new Error('This Channel has already closed'));
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
static createDataChannelPromise(label, rtcClient) {
|
|
30
|
-
let resolver;
|
|
31
|
-
const promise = new Promise((resolve) => {
|
|
32
|
-
resolver = resolve;
|
|
33
|
-
});
|
|
34
|
-
const listener = (e) => {
|
|
35
|
-
const openListener = () => {
|
|
36
|
-
e.channel.removeEventListener('open', openListener);
|
|
37
|
-
resolver(e.channel);
|
|
38
|
-
};
|
|
39
|
-
if (e.channel.label === label) {
|
|
40
|
-
e.channel.addEventListener('open', openListener);
|
|
41
|
-
rtcClient.removeEventListener('datachannel', listener);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
rtcClient.addEventListener('datachannel', listener);
|
|
45
|
-
return promise;
|
|
46
|
-
}
|
|
47
|
-
async listenForProviderIce(rtcConnectionId, listener) {
|
|
48
|
-
await this.on(this.createProviderEventName(rtcConnectionId), listener, { timestamp: Date.now() });
|
|
49
|
-
}
|
|
50
|
-
async raiseProviderIce(rtcConnectionId, payload) {
|
|
51
|
-
await this.wire.environment.raiseEvent(this.createRouteString(this.createProviderEventName(rtcConnectionId)), payload);
|
|
52
|
-
}
|
|
53
|
-
async listenForClientIce(rtcConnectionId, listener) {
|
|
54
|
-
await this.on(this.createClientEventName(rtcConnectionId), listener, { timestamp: Date.now() });
|
|
55
|
-
}
|
|
56
|
-
async raiseClientIce(rtcConnectionId, payload) {
|
|
57
|
-
await this.wire.environment.raiseEvent(this.createRouteString(this.createClientEventName(rtcConnectionId)), payload);
|
|
58
|
-
}
|
|
59
|
-
cleanupIceListeners(rtcConnectionId) {
|
|
60
|
-
this.removeAllListeners(this.createClientEventName(rtcConnectionId));
|
|
61
|
-
this.removeAllListeners(this.createProviderEventName(rtcConnectionId));
|
|
62
|
-
}
|
|
63
|
-
createClientEventName(rtcConnectionId) {
|
|
64
|
-
return `ice-client-${rtcConnectionId}`;
|
|
65
|
-
}
|
|
66
|
-
createProviderEventName(rtcConnectionId) {
|
|
67
|
-
return `ice-provider-${rtcConnectionId}`;
|
|
68
|
-
}
|
|
69
|
-
createRouteString(name) {
|
|
70
|
-
return `channel/${name}`;
|
|
71
|
-
}
|
|
72
|
-
createRtcPeer() {
|
|
73
|
-
return this.wire.environment.getRtcPeer();
|
|
74
|
-
}
|
|
75
|
-
async startClientOffer() {
|
|
76
|
-
// TODO replace with real guid.
|
|
77
|
-
const rtcConnectionId = Math.random().toString();
|
|
78
|
-
const rtcClient = this.createRtcPeer();
|
|
79
|
-
rtcClient.addEventListener('icecandidate', async (e) => {
|
|
80
|
-
var _a;
|
|
81
|
-
if (e.candidate) {
|
|
82
|
-
await this.raiseClientIce(rtcConnectionId, { candidate: (_a = e.candidate) === null || _a === void 0 ? void 0 : _a.toJSON() });
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
await this.listenForProviderIce(rtcConnectionId, async (payload) => {
|
|
86
|
-
await rtcClient.addIceCandidate(payload.candidate);
|
|
87
|
-
});
|
|
88
|
-
const channels = {
|
|
89
|
-
request: rtcClient.createDataChannel('request'),
|
|
90
|
-
response: rtcClient.createDataChannel('response')
|
|
91
|
-
};
|
|
92
|
-
const offer = await rtcClient.createOffer();
|
|
93
|
-
await rtcClient.setLocalDescription(offer);
|
|
94
|
-
const channelsOpened = Promise.all([channels.request, channels.response].map(this.ensureChannelOpened)).then(() => undefined);
|
|
95
|
-
return { rtcClient, channels, offer, rtcConnectionId, channelsOpened };
|
|
96
|
-
}
|
|
97
|
-
async finishClientOffer(rtcClient, answer, providerReady) {
|
|
98
|
-
await rtcClient.setRemoteDescription(answer);
|
|
99
|
-
await providerReady;
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
async createProviderAnswer(rtcConnectionId, offer) {
|
|
103
|
-
const rtcClient = this.createRtcPeer();
|
|
104
|
-
const requestChannelPromise = RTCICEManager.createDataChannelPromise('request', rtcClient);
|
|
105
|
-
const responseChannelPromise = RTCICEManager.createDataChannelPromise('response', rtcClient);
|
|
106
|
-
rtcClient.addEventListener('icecandidate', async (e) => {
|
|
107
|
-
var _a;
|
|
108
|
-
if (e.candidate) {
|
|
109
|
-
await this.raiseProviderIce(rtcConnectionId, { candidate: (_a = e.candidate) === null || _a === void 0 ? void 0 : _a.toJSON() });
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
await this.listenForClientIce(rtcConnectionId, async (payload) => {
|
|
113
|
-
await rtcClient.addIceCandidate(payload.candidate);
|
|
114
|
-
});
|
|
115
|
-
await rtcClient.setRemoteDescription(offer);
|
|
116
|
-
const answer = await rtcClient.createAnswer();
|
|
117
|
-
await rtcClient.setLocalDescription(answer);
|
|
118
|
-
const channels = Promise.all([requestChannelPromise, responseChannelPromise]).then(([request, response]) => {
|
|
119
|
-
// Clean up ice events.
|
|
120
|
-
this.cleanupIceListeners(rtcConnectionId);
|
|
121
|
-
return { request, response };
|
|
122
|
-
});
|
|
123
|
-
return {
|
|
124
|
-
rtcClient,
|
|
125
|
-
answer,
|
|
126
|
-
channels
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
exports.RTCICEManager = RTCICEManager;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type * as OpenFin from '../../../../../OpenFin';
|
|
2
|
-
import { ChannelStrategy } from '../strategy';
|
|
3
|
-
import { RTCPacket } from './endpoint';
|
|
4
|
-
import { LocalSupportedProtocol } from '..';
|
|
5
|
-
type ProviderIdentity = OpenFin.ProviderIdentity;
|
|
6
|
-
export interface RTCStrategyEndpointPayload {
|
|
7
|
-
endpointIdentity: OpenFin.ClientIdentity | ProviderIdentity;
|
|
8
|
-
rtc: RTCPacket;
|
|
9
|
-
}
|
|
10
|
-
export declare class RTCStrategy implements ChannelStrategy<RTCStrategyEndpointPayload> {
|
|
11
|
-
#private;
|
|
12
|
-
onEndpointDisconnect(endpointId: string, listener: () => void): void;
|
|
13
|
-
receive(listener: (action: string, payload: any, identity: OpenFin.ClientIdentity | OpenFin.ClientIdentityMultiRuntime | ProviderIdentity) => Promise<any>): void;
|
|
14
|
-
send: (endpointId: string, action: string, payload: any) => Promise<any>;
|
|
15
|
-
close: () => Promise<void>;
|
|
16
|
-
private getEndpointById;
|
|
17
|
-
get connected(): boolean;
|
|
18
|
-
isEndpointConnected(endpointId: string): boolean;
|
|
19
|
-
addEndpoint(endpointId: string, payload: RTCStrategyEndpointPayload): void;
|
|
20
|
-
closeEndpoint(endpointId: string): Promise<void>;
|
|
21
|
-
isValidEndpointPayload(payload: any): payload is RTCStrategyEndpointPayload;
|
|
22
|
-
}
|
|
23
|
-
export declare const RTCInfo: LocalSupportedProtocol;
|
|
24
|
-
export {};
|
|
@@ -1,85 +0,0 @@
|
|
|
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
|
-
};
|
|
7
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
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");
|
|
11
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
|
-
};
|
|
13
|
-
var _RTCStrategy_processAction, _RTCStrategy_rtcEndpointMap, _RTCStrategy_connected;
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.RTCInfo = exports.RTCStrategy = void 0;
|
|
16
|
-
const endpoint_1 = require("./endpoint");
|
|
17
|
-
/*
|
|
18
|
-
This is used to abstract out rtc messaging from the channels implementation using RTCEndpoints.
|
|
19
|
-
*/
|
|
20
|
-
class RTCStrategy {
|
|
21
|
-
constructor() {
|
|
22
|
-
_RTCStrategy_processAction.set(this, null);
|
|
23
|
-
_RTCStrategy_rtcEndpointMap.set(this, new Map());
|
|
24
|
-
_RTCStrategy_connected.set(this, true);
|
|
25
|
-
this.send = async (endpointId, action, payload) => {
|
|
26
|
-
return this.getEndpointById(endpointId).send(action, payload);
|
|
27
|
-
};
|
|
28
|
-
this.close = async () => {
|
|
29
|
-
if (__classPrivateFieldGet(this, _RTCStrategy_connected, "f")) {
|
|
30
|
-
__classPrivateFieldGet(this, _RTCStrategy_rtcEndpointMap, "f").forEach((rtcEndpoint) => rtcEndpoint.close());
|
|
31
|
-
__classPrivateFieldSet(this, _RTCStrategy_rtcEndpointMap, new Map(), "f");
|
|
32
|
-
}
|
|
33
|
-
__classPrivateFieldSet(this, _RTCStrategy_connected, false, "f");
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
onEndpointDisconnect(endpointId, listener) {
|
|
37
|
-
this.getEndpointById(endpointId).onDisconnect(listener);
|
|
38
|
-
}
|
|
39
|
-
receive(listener) {
|
|
40
|
-
if (__classPrivateFieldGet(this, _RTCStrategy_processAction, "f")) {
|
|
41
|
-
throw new Error('You have already set a listener for this RTC Strategy');
|
|
42
|
-
}
|
|
43
|
-
__classPrivateFieldSet(this, _RTCStrategy_processAction, listener, "f");
|
|
44
|
-
__classPrivateFieldGet(this, _RTCStrategy_rtcEndpointMap, "f").forEach((rtcEndpoint) => rtcEndpoint.receive(__classPrivateFieldGet(this, _RTCStrategy_processAction, "f")));
|
|
45
|
-
}
|
|
46
|
-
getEndpointById(endpointId) {
|
|
47
|
-
const endpoint = __classPrivateFieldGet(this, _RTCStrategy_rtcEndpointMap, "f").get(endpointId);
|
|
48
|
-
if (!endpoint) {
|
|
49
|
-
throw new Error(`Client with endpoint id ${endpointId} is not connected`);
|
|
50
|
-
}
|
|
51
|
-
return endpoint;
|
|
52
|
-
}
|
|
53
|
-
get connected() {
|
|
54
|
-
return __classPrivateFieldGet(this, _RTCStrategy_connected, "f");
|
|
55
|
-
}
|
|
56
|
-
isEndpointConnected(endpointId) {
|
|
57
|
-
return __classPrivateFieldGet(this, _RTCStrategy_rtcEndpointMap, "f").has(endpointId);
|
|
58
|
-
}
|
|
59
|
-
addEndpoint(endpointId, payload) {
|
|
60
|
-
if (!__classPrivateFieldGet(this, _RTCStrategy_connected, "f")) {
|
|
61
|
-
console.warn('Adding endpoint to disconnected RTC Strategy');
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
const clientStrat = new endpoint_1.RTCEndpoint(payload.rtc, payload.endpointIdentity);
|
|
65
|
-
if (__classPrivateFieldGet(this, _RTCStrategy_processAction, "f")) {
|
|
66
|
-
clientStrat.receive(__classPrivateFieldGet(this, _RTCStrategy_processAction, "f"));
|
|
67
|
-
}
|
|
68
|
-
__classPrivateFieldGet(this, _RTCStrategy_rtcEndpointMap, "f").set(endpointId, clientStrat);
|
|
69
|
-
}
|
|
70
|
-
async closeEndpoint(endpointId) {
|
|
71
|
-
__classPrivateFieldGet(this, _RTCStrategy_rtcEndpointMap, "f").delete(endpointId);
|
|
72
|
-
}
|
|
73
|
-
isValidEndpointPayload(payload) {
|
|
74
|
-
const isObject = (x) => {
|
|
75
|
-
return typeof x === 'object' && x !== null;
|
|
76
|
-
};
|
|
77
|
-
return (isObject(payload) &&
|
|
78
|
-
isObject(payload.endpointIdentity) &&
|
|
79
|
-
isObject(payload.rtc) &&
|
|
80
|
-
typeof payload.endpointIdentity.endpointId === 'string');
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.RTCStrategy = RTCStrategy;
|
|
84
|
-
_RTCStrategy_processAction = new WeakMap(), _RTCStrategy_rtcEndpointMap = new WeakMap(), _RTCStrategy_connected = new WeakMap();
|
|
85
|
-
exports.RTCInfo = { version: 2, minimumVersion: 0, type: 'rtc' };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { MessagingProtocols } from '.';
|
|
2
|
-
import { ClassicStrategy } from './classic/strategy';
|
|
3
|
-
import CombinedStrategy from './combined/strategy';
|
|
4
|
-
import { RTCStrategy } from './rtc/strategy';
|
|
5
|
-
import { ChannelStrategy } from './strategy';
|
|
6
|
-
type StrategyMap = {
|
|
7
|
-
rtc: RTCStrategy;
|
|
8
|
-
classic: ClassicStrategy;
|
|
9
|
-
};
|
|
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
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type * as OpenFin from '../../../../OpenFin';
|
|
2
|
-
type ProviderIdentity = OpenFin.ProviderIdentity;
|
|
3
|
-
export interface ChannelStrategy<T extends unknown> {
|
|
4
|
-
onEndpointDisconnect(endpointId: string, listener: () => void): void;
|
|
5
|
-
receive(listener: (action: string, payload: any, identity: any) => Promise<any>): void;
|
|
6
|
-
send(endpointId: string, action: string, payload: any): Promise<any>;
|
|
7
|
-
closeEndpoint(endpointId: string): Promise<void>;
|
|
8
|
-
close(): Promise<void>;
|
|
9
|
-
isEndpointConnected(endpointId: string): boolean;
|
|
10
|
-
addEndpoint(endpointId: string, payload: T): void;
|
|
11
|
-
isValidEndpointPayload(payload: unknown): payload is T;
|
|
12
|
-
}
|
|
13
|
-
export type EndpointIdentity = OpenFin.ClientIdentity | ProviderIdentity;
|
|
14
|
-
export type EndpointPayload = {
|
|
15
|
-
endpointIdentity: EndpointIdentity;
|
|
16
|
-
};
|
|
17
|
-
export {};
|