@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,29 +0,0 @@
|
|
|
1
|
-
import type * as OpenFin from '../../../OpenFin';
|
|
2
|
-
import { ChannelMessage } from '.';
|
|
3
|
-
import { Transport } from '../../../transport/transport';
|
|
4
|
-
import { Base } from '../../base';
|
|
5
|
-
import { ClientOffer, LocalSupportedProtocol } from './protocols/index';
|
|
6
|
-
import { RTCPacket } from './protocols/rtc/endpoint';
|
|
7
|
-
import { ChannelProvider } from './provider';
|
|
8
|
-
import { AnyStrategy } from './protocols/strategy-types';
|
|
9
|
-
export type ProviderEntry = {
|
|
10
|
-
provider: ChannelProvider;
|
|
11
|
-
strategy: AnyStrategy;
|
|
12
|
-
supportedProtocols: LocalSupportedProtocol[];
|
|
13
|
-
};
|
|
14
|
-
export declare class ConnectionManager extends Base {
|
|
15
|
-
#private;
|
|
16
|
-
private protocolManager;
|
|
17
|
-
private providerMap;
|
|
18
|
-
private static getProtocolOptionsFromStrings;
|
|
19
|
-
constructor(wire: Transport);
|
|
20
|
-
createProvider(options: OpenFin.ChannelCreateOptions | undefined, providerIdentity: any): ChannelProvider;
|
|
21
|
-
createClientOffer(options?: OpenFin.ChannelConnectOptions): Promise<{
|
|
22
|
-
offer: ClientOffer;
|
|
23
|
-
rtc?: RTCPacket;
|
|
24
|
-
}>;
|
|
25
|
-
createClientStrategy(rtcPacket: RTCPacket | undefined, routingInfo: any): Promise<AnyStrategy>;
|
|
26
|
-
removeChannelFromProviderMap: (channelId: string) => void;
|
|
27
|
-
onmessage: (msg: ChannelMessage) => boolean;
|
|
28
|
-
private processChannelConnection;
|
|
29
|
-
}
|
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
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
|
-
var _ConnectionManager_messageReceiver, _ConnectionManager_rtcConnectionManager;
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.ConnectionManager = void 0;
|
|
16
|
-
const exhaustive_1 = require("../../../util/exhaustive");
|
|
17
|
-
const base_1 = require("../../base");
|
|
18
|
-
const strategy_1 = require("./protocols/classic/strategy");
|
|
19
|
-
const strategy_2 = require("./protocols/rtc/strategy");
|
|
20
|
-
const ice_manager_1 = require("./protocols/rtc/ice-manager");
|
|
21
|
-
const provider_1 = require("./provider");
|
|
22
|
-
const message_receiver_1 = require("./protocols/classic/message-receiver");
|
|
23
|
-
const protocol_manager_1 = require("./protocols/protocol-manager");
|
|
24
|
-
const strategy_3 = require("./protocols/combined/strategy");
|
|
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
|
-
}
|
|
38
|
-
constructor(wire) {
|
|
39
|
-
super(wire);
|
|
40
|
-
_ConnectionManager_messageReceiver.set(this, void 0);
|
|
41
|
-
_ConnectionManager_rtcConnectionManager.set(this, void 0);
|
|
42
|
-
this.removeChannelFromProviderMap = (channelId) => {
|
|
43
|
-
this.providerMap.delete(channelId);
|
|
44
|
-
};
|
|
45
|
-
this.onmessage = (msg) => {
|
|
46
|
-
if (msg.action === 'process-channel-connection') {
|
|
47
|
-
this.processChannelConnection(msg);
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
return false;
|
|
51
|
-
};
|
|
52
|
-
this.providerMap = new Map();
|
|
53
|
-
this.protocolManager = new protocol_manager_1.ProtocolManager(this.isNodeEnvironment() ? ['classic'] : ['rtc', 'classic']);
|
|
54
|
-
__classPrivateFieldSet(this, _ConnectionManager_messageReceiver, new message_receiver_1.MessageReceiver(wire), "f");
|
|
55
|
-
__classPrivateFieldSet(this, _ConnectionManager_rtcConnectionManager, new ice_manager_1.RTCICEManager(wire), "f");
|
|
56
|
-
wire.registerMessageHandler(this.onmessage.bind(this));
|
|
57
|
-
}
|
|
58
|
-
createProvider(options, providerIdentity) {
|
|
59
|
-
const opts = Object.assign(this.wire.environment.getDefaultChannelOptions().create, options || {});
|
|
60
|
-
const protocols = this.protocolManager.getProviderProtocols(opts === null || opts === void 0 ? void 0 : opts.protocols);
|
|
61
|
-
const createSingleStrategy = (stratType) => {
|
|
62
|
-
switch (stratType) {
|
|
63
|
-
case 'rtc':
|
|
64
|
-
return new strategy_2.RTCStrategy();
|
|
65
|
-
case 'classic':
|
|
66
|
-
return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet(this, _ConnectionManager_messageReceiver, "f"),
|
|
67
|
-
// Providers do not have an endpointId, use channelId as endpointId in the strategy.
|
|
68
|
-
providerIdentity.channelId, providerIdentity);
|
|
69
|
-
default:
|
|
70
|
-
return (0, exhaustive_1.exhaustiveCheck)(stratType, ['rtc', 'classic']);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
const strategies = protocols.map(createSingleStrategy);
|
|
74
|
-
let strategy;
|
|
75
|
-
if (strategies.length === 2) {
|
|
76
|
-
const [a, b] = strategies;
|
|
77
|
-
strategy = strategy_3.default.combine(a, b);
|
|
78
|
-
}
|
|
79
|
-
else if (strategies.length === 1) {
|
|
80
|
-
[strategy] = strategies;
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
// Should be impossible.
|
|
84
|
-
throw new Error('failed to combine strategies');
|
|
85
|
-
}
|
|
86
|
-
const channel = new provider_1.ChannelProvider(providerIdentity, this.wire, strategy);
|
|
87
|
-
const key = providerIdentity.channelId;
|
|
88
|
-
this.providerMap.set(key, {
|
|
89
|
-
provider: channel,
|
|
90
|
-
strategy,
|
|
91
|
-
supportedProtocols: ConnectionManager.getProtocolOptionsFromStrings(protocols)
|
|
92
|
-
});
|
|
93
|
-
provider_1.ChannelProvider.setProviderRemoval(channel, this.removeChannelFromProviderMap.bind(this));
|
|
94
|
-
return channel;
|
|
95
|
-
}
|
|
96
|
-
async createClientOffer(options) {
|
|
97
|
-
const protocols = this.protocolManager.getClientProtocols(options === null || options === void 0 ? void 0 : options.protocols);
|
|
98
|
-
let rtcPacket;
|
|
99
|
-
const supportedProtocols = await Promise.all(protocols.map(async (type) => {
|
|
100
|
-
switch (type) {
|
|
101
|
-
case 'rtc': {
|
|
102
|
-
const { rtcClient, channels, offer, rtcConnectionId, channelsOpened } = await __classPrivateFieldGet(this, _ConnectionManager_rtcConnectionManager, "f").startClientOffer();
|
|
103
|
-
rtcPacket = { rtcClient, channels, channelsOpened };
|
|
104
|
-
return {
|
|
105
|
-
type: 'rtc',
|
|
106
|
-
version: strategy_2.RTCInfo.version,
|
|
107
|
-
payload: { offer, rtcConnectionId }
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
case 'classic':
|
|
111
|
-
return { type: 'classic', version: strategy_1.ClassicInfo.version };
|
|
112
|
-
default:
|
|
113
|
-
return (0, exhaustive_1.exhaustiveCheck)(type, ['rtc', 'classic']);
|
|
114
|
-
}
|
|
115
|
-
}));
|
|
116
|
-
return {
|
|
117
|
-
offer: {
|
|
118
|
-
supportedProtocols,
|
|
119
|
-
maxProtocols: 2
|
|
120
|
-
},
|
|
121
|
-
rtc: rtcPacket
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
async createClientStrategy(rtcPacket, routingInfo) {
|
|
125
|
-
var _a;
|
|
126
|
-
if (!routingInfo.endpointId) {
|
|
127
|
-
routingInfo.endpointId = this.wire.environment.getNextMessageId();
|
|
128
|
-
// For New Clients connecting to Old Providers. To prevent multi-dispatching and publishing, we delete previously-connected
|
|
129
|
-
// clients that are in the same context as the newly-connected client.
|
|
130
|
-
__classPrivateFieldGet(this, _ConnectionManager_messageReceiver, "f").checkForPreviousClientConnection(routingInfo.channelId);
|
|
131
|
-
}
|
|
132
|
-
const answer = (_a = routingInfo.answer) !== null && _a !== void 0 ? _a : {
|
|
133
|
-
supportedProtocols: [{ type: 'classic', version: 1 }]
|
|
134
|
-
};
|
|
135
|
-
const createStrategyFromAnswer = async (protocol) => {
|
|
136
|
-
if (protocol.type === 'rtc' && rtcPacket) {
|
|
137
|
-
await __classPrivateFieldGet(this, _ConnectionManager_rtcConnectionManager, "f").finishClientOffer(rtcPacket.rtcClient, protocol.payload.answer, rtcPacket.channelsOpened);
|
|
138
|
-
return new strategy_2.RTCStrategy();
|
|
139
|
-
}
|
|
140
|
-
if (protocol.type === 'classic') {
|
|
141
|
-
return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet(this, _ConnectionManager_messageReceiver, "f"), routingInfo.endpointId, routingInfo);
|
|
142
|
-
}
|
|
143
|
-
return null;
|
|
144
|
-
};
|
|
145
|
-
const allProtocols = (await Promise.all(answer.supportedProtocols.map(createStrategyFromAnswer))).filter((x) => x !== null);
|
|
146
|
-
// Clean up logic if provider didn't support rtc.
|
|
147
|
-
if (rtcPacket && !allProtocols.some((x) => x instanceof strategy_2.RTCStrategy)) {
|
|
148
|
-
if (rtcPacket) {
|
|
149
|
-
rtcPacket.rtcClient.close();
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
let strategy;
|
|
153
|
-
if (allProtocols.length >= 2) {
|
|
154
|
-
strategy = strategy_3.default.combine(allProtocols[0], allProtocols[1]);
|
|
155
|
-
}
|
|
156
|
-
else if (allProtocols.length) {
|
|
157
|
-
[strategy] = allProtocols;
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
// Should be impossible.
|
|
161
|
-
throw new Error('No compatible protocols');
|
|
162
|
-
}
|
|
163
|
-
// as casting rtcPacket because we won't have an rtcStrategy if rtcPacket is undefined;
|
|
164
|
-
const endpointPayload = { endpointIdentity: routingInfo, rtc: rtcPacket };
|
|
165
|
-
strategy.addEndpoint(routingInfo.channelId, endpointPayload);
|
|
166
|
-
return strategy;
|
|
167
|
-
}
|
|
168
|
-
async processChannelConnection(msg) {
|
|
169
|
-
const { clientIdentity, providerIdentity, ackToSender, payload, offer: clientOffer } = msg.payload;
|
|
170
|
-
if (!clientIdentity.endpointId) {
|
|
171
|
-
// Should be polyfilled by core but not in cases of node connecting to an old runtime.
|
|
172
|
-
clientIdentity.endpointId = this.wire.environment.getNextMessageId();
|
|
173
|
-
clientIdentity.isLocalEndpointId = true;
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
clientIdentity.isLocalEndpointId = false;
|
|
177
|
-
}
|
|
178
|
-
const key = providerIdentity.channelId;
|
|
179
|
-
const bus = this.providerMap.get(key);
|
|
180
|
-
if (!bus) {
|
|
181
|
-
ackToSender.payload.success = false;
|
|
182
|
-
ackToSender.payload.reason = `Channel "${providerIdentity.channelName}" has been destroyed.`;
|
|
183
|
-
return this.wire.sendRaw(ackToSender);
|
|
184
|
-
}
|
|
185
|
-
const { provider, strategy, supportedProtocols } = bus;
|
|
186
|
-
try {
|
|
187
|
-
if (!(provider instanceof provider_1.ChannelProvider)) {
|
|
188
|
-
throw Error('Cannot connect to a channel client');
|
|
189
|
-
}
|
|
190
|
-
const offer = clientOffer !== null && clientOffer !== void 0 ? clientOffer : {
|
|
191
|
-
supportedProtocols: [{ type: 'classic', version: 1 }],
|
|
192
|
-
maxProtocols: 1
|
|
193
|
-
};
|
|
194
|
-
const overlappingProtocols = this.protocolManager.getCompatibleProtocols(supportedProtocols, offer);
|
|
195
|
-
if (!overlappingProtocols.length) {
|
|
196
|
-
throw new Error('This provider does not support any of the offered protocols.');
|
|
197
|
-
}
|
|
198
|
-
const res = await provider.processConnection(clientIdentity, payload);
|
|
199
|
-
ackToSender.payload.payload = ackToSender.payload.payload || {};
|
|
200
|
-
// Loop through all supported protocols and accumulate them into the answer
|
|
201
|
-
// addEndpoint is tricky but we need to wait for channel resolution before adding the endpoint.
|
|
202
|
-
let clientAnswer = {
|
|
203
|
-
supportedProtocols: [],
|
|
204
|
-
endpointPayloadPromise: Promise.resolve({ endpointIdentity: clientIdentity })
|
|
205
|
-
};
|
|
206
|
-
clientAnswer = await overlappingProtocols.reduce(async (accumP, protocolToUse) => {
|
|
207
|
-
const answer = await accumP;
|
|
208
|
-
if (protocolToUse.type === 'rtc') {
|
|
209
|
-
const { answer: rtcAnswer, rtcClient, channels } = await __classPrivateFieldGet(this, _ConnectionManager_rtcConnectionManager, "f").createProviderAnswer(protocolToUse.payload.rtcConnectionId, protocolToUse.payload.offer);
|
|
210
|
-
answer.supportedProtocols.push({
|
|
211
|
-
type: 'rtc',
|
|
212
|
-
version: strategy_2.RTCInfo.version,
|
|
213
|
-
payload: {
|
|
214
|
-
answer: rtcAnswer
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
answer.endpointPayloadPromise = answer.endpointPayloadPromise.then((endpointPayload) => channels.then((resolvedChannels) => {
|
|
218
|
-
return {
|
|
219
|
-
...endpointPayload,
|
|
220
|
-
rtc: {
|
|
221
|
-
rtcClient,
|
|
222
|
-
channels: resolvedChannels
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
}));
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
answer.supportedProtocols.push({ type: 'classic', version: strategy_1.ClassicInfo.version });
|
|
229
|
-
}
|
|
230
|
-
return answer;
|
|
231
|
-
}, Promise.resolve(clientAnswer));
|
|
232
|
-
// Need to as cast here.
|
|
233
|
-
clientAnswer.endpointPayloadPromise.then((endpointPayload) => strategy.addEndpoint(clientIdentity.endpointId, endpointPayload));
|
|
234
|
-
ackToSender.payload.payload.result = res;
|
|
235
|
-
ackToSender.payload.payload.answer = clientAnswer;
|
|
236
|
-
return this.wire.sendRaw(ackToSender);
|
|
237
|
-
}
|
|
238
|
-
catch (e) {
|
|
239
|
-
ackToSender.payload.success = false;
|
|
240
|
-
ackToSender.payload.reason = e.message;
|
|
241
|
-
return this.wire.sendRaw(ackToSender);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
exports.ConnectionManager = ConnectionManager;
|
|
246
|
-
_ConnectionManager_messageReceiver = new WeakMap(), _ConnectionManager_rtcConnectionManager = new WeakMap();
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import type * as OpenFin from '../../../OpenFin';
|
|
2
|
-
import { Message, Transport } from '../../../transport/transport';
|
|
3
|
-
import { EmitterBase } from '../../base';
|
|
4
|
-
import { ChannelEvent } from '../../events/channel';
|
|
5
|
-
import ChannelClient from './client';
|
|
6
|
-
import { ChannelProvider } from './provider';
|
|
7
|
-
type ProviderIdentity = OpenFin.ProviderIdentity;
|
|
8
|
-
type Identity = OpenFin.Identity;
|
|
9
|
-
export interface ChannelMessage extends Message<any> {
|
|
10
|
-
senderIdentity: Identity;
|
|
11
|
-
ackToSender: any;
|
|
12
|
-
providerIdentity: ProviderIdentity;
|
|
13
|
-
connectAction: boolean;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* The Channel API allows an OpenFin application to create a channel as a {@link ChannelProvider ChannelProvider},
|
|
17
|
-
* or connect to a channel as a {@link ChannelClient ChannelClient}.
|
|
18
|
-
* @remarks The "handshake" between the communication partners is
|
|
19
|
-
* simplified when using a channel. A request to connect to a channel as a client will return a promise that resolves if/when the channel has been created. Both the
|
|
20
|
-
* provider and client can dispatch actions that have been registered on their opposites, and dispatch returns a promise that resolves with a payload from the other
|
|
21
|
-
* communication participant. There can be only one provider per channel, but many clients. Version `9.61.35.*` or later is required for both communication partners.
|
|
22
|
-
*
|
|
23
|
-
* Asynchronous Methods:
|
|
24
|
-
* * {@link Channel.create create(channelName, options)}
|
|
25
|
-
* * {@link Channel.connect connect(channelName, options)}
|
|
26
|
-
* * {@link Channel.onChannelConnect onChannelConnect(listener)}
|
|
27
|
-
* * {@link Channel.onChannelDisconnect onChannelDisconnect(listener)}
|
|
28
|
-
*/
|
|
29
|
-
export declare class Channel extends EmitterBase<ChannelEvent> {
|
|
30
|
-
#private;
|
|
31
|
-
/**
|
|
32
|
-
* @internal
|
|
33
|
-
*/
|
|
34
|
-
constructor(wire: Transport);
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
* @internal
|
|
38
|
-
*/
|
|
39
|
-
getAllChannels(): Promise<ProviderIdentity[]>;
|
|
40
|
-
/**
|
|
41
|
-
* Listens for channel connections.
|
|
42
|
-
*
|
|
43
|
-
* @param listener - callback to execute.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
*
|
|
47
|
-
* ```js
|
|
48
|
-
* const listener = (channelPayload) => console.log(channelPayload); // see return value below
|
|
49
|
-
*
|
|
50
|
-
* fin.InterApplicationBus.Channel.onChannelConnect(listener);
|
|
51
|
-
*
|
|
52
|
-
* // example shape
|
|
53
|
-
* {
|
|
54
|
-
* "topic": "channel",
|
|
55
|
-
* "type": "connected",
|
|
56
|
-
* "uuid": "OpenfinPOC",
|
|
57
|
-
* "name": "OpenfinPOC",
|
|
58
|
-
* "channelName": "counter",
|
|
59
|
-
* "channelId": "OpenfinPOC/OpenfinPOC/counter"
|
|
60
|
-
* }
|
|
61
|
-
*
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
onChannelConnect(listener: (...args: any[]) => void): Promise<void>;
|
|
65
|
-
/**
|
|
66
|
-
* Listen for channel disconnections.
|
|
67
|
-
*
|
|
68
|
-
* @param listener - callback to execute.
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
*
|
|
72
|
-
* ```js
|
|
73
|
-
* const listener = (channelPayload) => console.log(channelPayload); // see return value below
|
|
74
|
-
*
|
|
75
|
-
* fin.InterApplicationBus.Channel.onChannelDisconnect(listener);
|
|
76
|
-
*
|
|
77
|
-
* // example shape
|
|
78
|
-
* {
|
|
79
|
-
* "topic": "channel",
|
|
80
|
-
* "type": "disconnected",
|
|
81
|
-
* "uuid": "OpenfinPOC",
|
|
82
|
-
* "name": "OpenfinPOC",
|
|
83
|
-
* "channelName": "counter",
|
|
84
|
-
* "channelId": "OpenfinPOC/OpenfinPOC/counter"
|
|
85
|
-
* }
|
|
86
|
-
*
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
onChannelDisconnect(listener: (...args: any[]) => void): Promise<void>;
|
|
90
|
-
private safeConnect;
|
|
91
|
-
/**
|
|
92
|
-
* Connect to a channel. If you wish to send a payload to the provider, add a payload property to the options argument.
|
|
93
|
-
* EXPERIMENTAL: pass { protocols: ['rtc'] } as options to opt-in to High Throughput Channels.
|
|
94
|
-
*
|
|
95
|
-
* @param channelName - Name of the target channel.
|
|
96
|
-
* @param options - Connection options.
|
|
97
|
-
* @returns Returns a promise that resolves with an instance of {@link ChannelClient ChannelClient}.
|
|
98
|
-
*
|
|
99
|
-
* @remarks The connection request will be routed to the channelProvider if/when the channel is created. If the connect
|
|
100
|
-
* request is sent prior to creation, the promise will not resolve or reject until the channel is created by a channelProvider
|
|
101
|
-
* (whether or not to wait for creation is configurable in the connectOptions).
|
|
102
|
-
*
|
|
103
|
-
* The connect call returns a promise that will resolve with a channelClient bus if accepted by the channelProvider, or reject if
|
|
104
|
-
* the channelProvider throws an error to reject the connection. This bus can communicate with the Provider, but not to other
|
|
105
|
-
* clients on the channel. Using the bus, the channelClient can register actions and middleware. Channel lifecycle can also be
|
|
106
|
-
* handled with an onDisconnection listener.
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
*
|
|
110
|
-
* ```js
|
|
111
|
-
* async function makeClient(channelName) {
|
|
112
|
-
* // A payload can be sent along with channel connection requests to help with authentication
|
|
113
|
-
* const connectPayload = { payload: 'token' };
|
|
114
|
-
*
|
|
115
|
-
* // If the channel has been created this request will be sent to the provider. If not, the
|
|
116
|
-
* // promise will not be resolved or rejected until the channel has been created.
|
|
117
|
-
* const clientBus = await fin.InterApplicationBus.Channel.connect(channelName, connectPayload);
|
|
118
|
-
*
|
|
119
|
-
* clientBus.onDisconnection(channelInfo => {
|
|
120
|
-
* // handle the channel lifecycle here - we can connect again which will return a promise
|
|
121
|
-
* // that will resolve if/when the channel is re-created.
|
|
122
|
-
* makeClient(channelInfo.channelName);
|
|
123
|
-
* })
|
|
124
|
-
*
|
|
125
|
-
* clientBus.register('topic', (payload, identity) => {
|
|
126
|
-
* // register a callback for a topic to which the channel provider can dispatch an action
|
|
127
|
-
* console.log('Action dispatched by provider: ', JSON.stringify(identity));
|
|
128
|
-
* console.log('Payload sent in dispatch: ', JSON.stringify(payload));
|
|
129
|
-
* return {
|
|
130
|
-
* echo: payload
|
|
131
|
-
* };
|
|
132
|
-
* });
|
|
133
|
-
* }
|
|
134
|
-
*
|
|
135
|
-
* makeClient('channelName')
|
|
136
|
-
* .then(() => console.log('Connected'))
|
|
137
|
-
* .catch(console.error);
|
|
138
|
-
* ```
|
|
139
|
-
*/
|
|
140
|
-
connect(channelName: string, options?: OpenFin.ChannelConnectOptions): Promise<ChannelClient>;
|
|
141
|
-
/**
|
|
142
|
-
* Create a new channel.
|
|
143
|
-
* You must provide a unique channelName. If a channelName is not provided, or it is not unique, the creation will fail.
|
|
144
|
-
* EXPERIMENTAL: pass { protocols: ['rtc'] } as options to opt-in to High Throughput Channels.
|
|
145
|
-
*
|
|
146
|
-
* @param channelName - Name of the channel to be created.
|
|
147
|
-
* @param options - Creation options.
|
|
148
|
-
* @returns Returns a promise that resolves with an instance of {@link ChannelProvider ChannelProvider}.
|
|
149
|
-
*
|
|
150
|
-
* @remarks If successful, the create method returns a promise that resolves to an instance of the channelProvider bus. The caller
|
|
151
|
-
* then becomes the “channel provider” and can use the channelProvider bus to register actions and middleware.
|
|
152
|
-
*
|
|
153
|
-
* The caller can also set an onConnection and/or onDisconnection listener that will execute on any new channel
|
|
154
|
-
* connection/disconnection attempt from a channel client. To reject a connection, simply throw an error in the
|
|
155
|
-
* onConnection listener. The default behavior is to accept all new connections.
|
|
156
|
-
*
|
|
157
|
-
* A map of client connections is updated automatically on client connection and disconnection and saved in the
|
|
158
|
-
* [read-only] `connections` property on the channelProvider bus. The channel will exist until the provider
|
|
159
|
-
* destroys it or disconnects by closing or destroying the context (navigating or reloading). To setup a channel
|
|
160
|
-
* as a channelProvider, call `Channel.create` with a unique channel name. A map of client connections is updated
|
|
161
|
-
* automatically on client connection and disconnection.
|
|
162
|
-
*
|
|
163
|
-
* @example
|
|
164
|
-
*
|
|
165
|
-
* ```js
|
|
166
|
-
* (async ()=> {
|
|
167
|
-
* // entity creates a channel and becomes the channelProvider
|
|
168
|
-
* const providerBus = await fin.InterApplicationBus.Channel.create('channelName');
|
|
169
|
-
*
|
|
170
|
-
* providerBus.onConnection((identity, payload) => {
|
|
171
|
-
* // can reject a connection here by throwing an error
|
|
172
|
-
* console.log('Client connection request identity: ', JSON.stringify(identity));
|
|
173
|
-
* console.log('Client connection request payload: ', JSON.stringify(payload));
|
|
174
|
-
* });
|
|
175
|
-
*
|
|
176
|
-
* providerBus.register('topic', (payload, identity) => {
|
|
177
|
-
* // register a callback for a 'topic' to which clients can dispatch an action
|
|
178
|
-
* console.log('Action dispatched by client: ', JSON.stringify(identity));
|
|
179
|
-
* console.log('Payload sent in dispatch: ', JSON.stringify(payload));
|
|
180
|
-
* return {
|
|
181
|
-
* echo: payload
|
|
182
|
-
* };
|
|
183
|
-
* });
|
|
184
|
-
* })();
|
|
185
|
-
* ```
|
|
186
|
-
*/
|
|
187
|
-
create(channelName: string, options?: OpenFin.ChannelCreateOptions): Promise<ChannelProvider>;
|
|
188
|
-
}
|
|
189
|
-
export {};
|