@openfin/core 33.76.31 → 33.76.38
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 +17104 -0
- package/package.json +30 -23
- package/LICENSE +0 -13
- package/NOTICE +0 -16
- package/openfin-core-33.76.31.tgz +0 -0
- package/src/OpenFin.d.ts +0 -3080
- 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 -148
- package/src/api/application/Factory.js +0 -230
- package/src/api/application/Instance.d.ts +0 -321
- package/src/api/application/Instance.js +0 -453
- package/src/api/application/index.d.ts +0 -3
- package/src/api/application/index.js +0 -19
- package/src/api/base.d.ts +0 -48
- package/src/api/base.js +0 -177
- package/src/api/clipboard/index.d.ts +0 -92
- package/src/api/clipboard/index.js +0 -120
- package/src/api/events/application.d.ts +0 -146
- package/src/api/events/application.js +0 -2
- 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 -30
- package/src/api/events/channel.js +0 -2
- 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 -19
- package/src/api/events/externalApplication.js +0 -2
- package/src/api/events/frame.d.ts +0 -30
- package/src/api/events/frame.js +0 -2
- package/src/api/events/globalHotkey.d.ts +0 -20
- package/src/api/events/globalHotkey.js +0 -2
- package/src/api/events/platform.d.ts +0 -26
- package/src/api/events/platform.js +0 -2
- package/src/api/events/system.d.ts +0 -113
- package/src/api/events/system.js +0 -2
- 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 -82
- package/src/api/events/view.js +0 -2
- package/src/api/events/webcontents.d.ts +0 -266
- package/src/api/events/webcontents.js +0 -2
- package/src/api/events/window.d.ts +0 -352
- package/src/api/events/window.js +0 -2
- package/src/api/external-application/Factory.d.ts +0 -27
- package/src/api/external-application/Factory.js +0 -40
- package/src/api/external-application/Instance.d.ts +0 -102
- package/src/api/external-application/Instance.js +0 -109
- package/src/api/external-application/index.d.ts +0 -3
- package/src/api/external-application/index.js +0 -19
- package/src/api/fin.d.ts +0 -51
- package/src/api/fin.js +0 -42
- package/src/api/frame/Factory.d.ts +0 -37
- package/src/api/frame/Factory.js +0 -69
- package/src/api/frame/Instance.d.ts +0 -123
- package/src/api/frame/Instance.js +0 -130
- package/src/api/frame/index.d.ts +0 -3
- package/src/api/frame/index.js +0 -19
- package/src/api/global-hotkey/index.d.ts +0 -38
- package/src/api/global-hotkey/index.js +0 -64
- package/src/api/interappbus/channel/channel.d.ts +0 -28
- package/src/api/interappbus/channel/channel.js +0 -77
- package/src/api/interappbus/channel/channels-docs.d.ts +0 -340
- package/src/api/interappbus/channel/channels-docs.js +0 -398
- package/src/api/interappbus/channel/client.d.ts +0 -24
- package/src/api/interappbus/channel/client.js +0 -89
- 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 -25
- package/src/api/interappbus/channel/index.js +0 -169
- 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 -34
- package/src/api/interappbus/channel/provider.js +0 -166
- package/src/api/interappbus/index.d.ts +0 -85
- package/src/api/interappbus/index.js +0 -175
- package/src/api/interop/Factory.d.ts +0 -37
- package/src/api/interop/Factory.js +0 -76
- package/src/api/interop/InteropBroker.d.ts +0 -437
- package/src/api/interop/InteropBroker.js +0 -1085
- package/src/api/interop/InteropClient.d.ts +0 -278
- package/src/api/interop/InteropClient.js +0 -459
- 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/fdc3-1.2.d.ts +0 -208
- package/src/api/interop/fdc3/fdc3-1.2.js +0 -438
- package/src/api/interop/fdc3/fdc3-2.0.d.ts +0 -301
- package/src/api/interop/fdc3/fdc3-2.0.js +0 -482
- 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 -4
- package/src/api/interop/index.js +0 -20
- 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 -115
- package/src/api/platform/Factory.js +0 -184
- package/src/api/platform/Instance.d.ts +0 -150
- package/src/api/platform/Instance.js +0 -332
- 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 -3
- package/src/api/platform/index.js +0 -19
- package/src/api/platform/layout/Factory.d.ts +0 -114
- package/src/api/platform/layout/Factory.js +0 -174
- package/src/api/platform/layout/Instance.d.ts +0 -57
- package/src/api/platform/layout/Instance.js +0 -126
- 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 -235
- package/src/api/platform/layout/entities/layout-entities.js +0 -312
- 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 -2
- package/src/api/platform/layout/index.js +0 -18
- 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 -163
- package/src/api/platform/provider.js +0 -2
- package/src/api/snapshot-source/Factory.d.ts +0 -38
- package/src/api/snapshot-source/Factory.js +0 -66
- package/src/api/snapshot-source/Instance.d.ts +0 -31
- package/src/api/snapshot-source/Instance.js +0 -132
- package/src/api/snapshot-source/index.d.ts +0 -3
- package/src/api/snapshot-source/index.js +0 -19
- 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 -517
- package/src/api/system/index.js +0 -895
- package/src/api/view/Factory.d.ts +0 -50
- package/src/api/view/Factory.js +0 -103
- package/src/api/view/Instance.d.ts +0 -487
- package/src/api/view/Instance.js +0 -557
- package/src/api/view/index.d.ts +0 -3
- package/src/api/view/index.js +0 -19
- package/src/api/webcontents/main.d.ts +0 -32
- package/src/api/webcontents/main.js +0 -156
- package/src/api/window/Factory.d.ts +0 -45
- package/src/api/window/Factory.js +0 -91
- package/src/api/window/Instance.d.ts +0 -1090
- package/src/api/window/Instance.js +0 -1349
- package/src/api/window/index.d.ts +0 -3
- package/src/api/window/index.js +0 -19
- 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 -21
- package/src/namespaces.js +0 -24
- 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 -200
- 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,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,25 +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
|
-
export declare class Channel extends EmitterBase<ChannelEvent> {
|
|
16
|
-
#private;
|
|
17
|
-
constructor(wire: Transport);
|
|
18
|
-
getAllChannels(): Promise<ProviderIdentity[]>;
|
|
19
|
-
onChannelConnect(listener: (...args: any[]) => void): Promise<void>;
|
|
20
|
-
onChannelDisconnect(listener: (...args: any[]) => void): Promise<void>;
|
|
21
|
-
private safeConnect;
|
|
22
|
-
connect(channelName: string, options?: OpenFin.ChannelConnectOptions): Promise<ChannelClient>;
|
|
23
|
-
create(channelName: string, options?: OpenFin.ChannelCreateOptions): Promise<ChannelProvider>;
|
|
24
|
-
}
|
|
25
|
-
export {};
|
|
@@ -1,169 +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 _Channel_connectionManager, _Channel_internalEmitter, _Channel_readyToConnect;
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.Channel = void 0;
|
|
16
|
-
/* eslint-disable no-console */
|
|
17
|
-
const events_1 = require("events");
|
|
18
|
-
const lazy_1 = require("../../../util/lazy");
|
|
19
|
-
const base_1 = require("../../base");
|
|
20
|
-
const client_1 = require("./client");
|
|
21
|
-
const connection_manager_1 = require("./connection-manager");
|
|
22
|
-
const provider_1 = require("./provider");
|
|
23
|
-
function retryDelay(count) {
|
|
24
|
-
const interval = 500; // base delay
|
|
25
|
-
const steps = 10; // How many retries to do before incrementing the delay
|
|
26
|
-
const base = 2; // How much to multiply the previous delay by
|
|
27
|
-
const max = 30000; // max delay
|
|
28
|
-
const step = Math.floor(count / steps);
|
|
29
|
-
const delay = Math.min(max, interval * base ** step);
|
|
30
|
-
return new Promise(resolve => {
|
|
31
|
-
setTimeout(() => {
|
|
32
|
-
resolve(false);
|
|
33
|
-
}, delay);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
class Channel extends base_1.EmitterBase {
|
|
37
|
-
constructor(wire) {
|
|
38
|
-
super(wire, 'channel');
|
|
39
|
-
_Channel_connectionManager.set(this, void 0);
|
|
40
|
-
_Channel_internalEmitter.set(this, new events_1.EventEmitter());
|
|
41
|
-
// OpenFin API has not been injected at construction time, *must* wait for API to be ready.
|
|
42
|
-
_Channel_readyToConnect.set(this, new lazy_1.AsyncRetryableLazy(async () => {
|
|
43
|
-
await Promise.all([
|
|
44
|
-
this.on('disconnected', (eventPayload) => {
|
|
45
|
-
client_1.default.handleProviderDisconnect(eventPayload);
|
|
46
|
-
}),
|
|
47
|
-
this.on('connected', (...args) => {
|
|
48
|
-
__classPrivateFieldGet(this, _Channel_internalEmitter, "f").emit('connected', ...args);
|
|
49
|
-
})
|
|
50
|
-
]).catch(() => new Error('error setting up channel connection listeners'));
|
|
51
|
-
}));
|
|
52
|
-
__classPrivateFieldSet(this, _Channel_connectionManager, new connection_manager_1.ConnectionManager(wire), "f");
|
|
53
|
-
}
|
|
54
|
-
async getAllChannels() {
|
|
55
|
-
return this.wire.sendAction('get-all-channels').then(({ payload }) => payload.data);
|
|
56
|
-
}
|
|
57
|
-
async onChannelConnect(listener) {
|
|
58
|
-
await this.on('connected', listener);
|
|
59
|
-
}
|
|
60
|
-
async onChannelDisconnect(listener) {
|
|
61
|
-
await this.on('disconnected', listener);
|
|
62
|
-
}
|
|
63
|
-
async safeConnect(channelName, shouldWait, connectPayload) {
|
|
64
|
-
const retryInfo = { count: 0 };
|
|
65
|
-
/* eslint-disable no-await-in-loop, no-constant-condition */
|
|
66
|
-
do {
|
|
67
|
-
// setup a listener and a connected promise to await in case we connect before the channel is ready
|
|
68
|
-
let connectedListener = () => undefined;
|
|
69
|
-
const connectedPromise = new Promise((resolve) => {
|
|
70
|
-
connectedListener = (payload) => {
|
|
71
|
-
if (channelName === payload.channelName) {
|
|
72
|
-
resolve(true);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
__classPrivateFieldGet(this, _Channel_internalEmitter, "f").on('connected', connectedListener);
|
|
76
|
-
});
|
|
77
|
-
try {
|
|
78
|
-
if (retryInfo.count > 0) {
|
|
79
|
-
// Wait before retrying
|
|
80
|
-
// Delay returns false connectedPromise returns true so we can know if a retry is due to connected event
|
|
81
|
-
retryInfo.gotConnectedEvent = await Promise.race([retryDelay(retryInfo.count), connectedPromise]);
|
|
82
|
-
const result = await this.wire.sendAction('connect-to-channel', { ...connectPayload, retryInfo });
|
|
83
|
-
// log only if there was a retry
|
|
84
|
-
console.log(`Successfully connected to channelName: ${channelName}`);
|
|
85
|
-
return result.payload.data;
|
|
86
|
-
}
|
|
87
|
-
// Send retryInfo to the core for debug log inclusion
|
|
88
|
-
const sentMessagePromise = this.wire.sendAction('connect-to-channel', connectPayload);
|
|
89
|
-
// Save messageId from the first connection attempt
|
|
90
|
-
retryInfo.originalMessageId = sentMessagePromise.messageId;
|
|
91
|
-
const result = await sentMessagePromise;
|
|
92
|
-
return result.payload.data;
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
if (!error.message.includes('internal-nack')) {
|
|
96
|
-
// Not an internal nack, break the loop
|
|
97
|
-
throw error;
|
|
98
|
-
}
|
|
99
|
-
if (shouldWait && retryInfo.count === 0) {
|
|
100
|
-
// start waiting on the next iteration, warn the user
|
|
101
|
-
console.warn(`No channel found for channelName: ${channelName}. Waiting for connection...`);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
finally {
|
|
105
|
-
retryInfo.count += 1;
|
|
106
|
-
// in case of other errors, remove our listener
|
|
107
|
-
__classPrivateFieldGet(this, _Channel_internalEmitter, "f").removeListener('connected', connectedListener);
|
|
108
|
-
}
|
|
109
|
-
} while (shouldWait); // If we're waiting we retry the above loop
|
|
110
|
-
// Should wait was false, no channel was found.
|
|
111
|
-
throw new Error(`No channel found for channelName: ${channelName}.`);
|
|
112
|
-
/* eslint-enable no-await-in-loop, no-constant-condition */
|
|
113
|
-
}
|
|
114
|
-
async connect(channelName, options = {}) {
|
|
115
|
-
// Make sure we don't connect before listeners are set up
|
|
116
|
-
// This also errors if we're not in OpenFin, ensuring we don't run unnecessary code
|
|
117
|
-
await __classPrivateFieldGet(this, _Channel_readyToConnect, "f").getValue();
|
|
118
|
-
if (!channelName || typeof channelName !== 'string') {
|
|
119
|
-
throw new Error('Please provide a channelName string to connect to a channel.');
|
|
120
|
-
}
|
|
121
|
-
const opts = { wait: true, ...this.wire.environment.getDefaultChannelOptions().connect, ...options };
|
|
122
|
-
const { offer, rtc: rtcPacket } = await __classPrivateFieldGet(this, _Channel_connectionManager, "f").createClientOffer(opts);
|
|
123
|
-
let connectionUrl;
|
|
124
|
-
if (this.fin.me.isFrame || this.fin.me.isView || this.fin.me.isWindow) {
|
|
125
|
-
connectionUrl = (await this.fin.me.getInfo()).url;
|
|
126
|
-
}
|
|
127
|
-
const connectPayload = {
|
|
128
|
-
channelName,
|
|
129
|
-
...opts,
|
|
130
|
-
offer,
|
|
131
|
-
connectionUrl
|
|
132
|
-
};
|
|
133
|
-
const routingInfo = await this.safeConnect(channelName, opts.wait, connectPayload);
|
|
134
|
-
const strategy = await __classPrivateFieldGet(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
|
|
135
|
-
const channel = new client_1.default(routingInfo, this.wire, strategy);
|
|
136
|
-
// It is the client's responsibility to handle endpoint disconnection to the provider.
|
|
137
|
-
// If the endpoint dies, the client will force a disconnection through the core.
|
|
138
|
-
// The provider does not care about endpoint disconnection.
|
|
139
|
-
strategy.onEndpointDisconnect(routingInfo.channelId, async () => {
|
|
140
|
-
try {
|
|
141
|
-
await channel.sendDisconnectAction();
|
|
142
|
-
}
|
|
143
|
-
catch (error) {
|
|
144
|
-
console.warn(`Something went wrong during disconnect for client with uuid: ${routingInfo.uuid} / name: ${routingInfo.name} / endpointId: ${routingInfo.endpointId}.`);
|
|
145
|
-
}
|
|
146
|
-
finally {
|
|
147
|
-
client_1.default.handleProviderDisconnect(routingInfo);
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
return channel;
|
|
151
|
-
}
|
|
152
|
-
async create(channelName, options) {
|
|
153
|
-
if (!channelName) {
|
|
154
|
-
throw new Error('Please provide a channelName to create a channel');
|
|
155
|
-
}
|
|
156
|
-
const { payload: { data: providerIdentity } } = await this.wire.sendAction('create-channel', { channelName });
|
|
157
|
-
const channel = __classPrivateFieldGet(this, _Channel_connectionManager, "f").createProvider(options, providerIdentity);
|
|
158
|
-
// TODO: fix typing (internal)
|
|
159
|
-
// @ts-expect-error
|
|
160
|
-
this.on('client-disconnected', (eventPayload) => {
|
|
161
|
-
if (eventPayload.channelName === channelName) {
|
|
162
|
-
provider_1.ChannelProvider.handleClientDisconnection(channel, eventPayload);
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
return channel;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
exports.Channel = Channel;
|
|
169
|
-
_Channel_connectionManager = new WeakMap(), _Channel_internalEmitter = new WeakMap(), _Channel_readyToConnect = new WeakMap();
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Transport } from '../../../../../transport/transport';
|
|
2
|
-
import { Base } from '../../../../base';
|
|
3
|
-
import { ChannelBase } from '../../channel';
|
|
4
|
-
export declare class MessageReceiver extends Base {
|
|
5
|
-
private endpointMap;
|
|
6
|
-
private latestEndpointIdByChannelId;
|
|
7
|
-
constructor(wire: Transport);
|
|
8
|
-
private processChannelMessage;
|
|
9
|
-
private onmessage;
|
|
10
|
-
addEndpoint(handler: ChannelBase['processAction'], channelId: string, endpointId: string): void;
|
|
11
|
-
removeEndpoint(channelId: string, endpointId: string): void;
|
|
12
|
-
checkForPreviousClientConnection(channelId: string): void;
|
|
13
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MessageReceiver = void 0;
|
|
4
|
-
const client_1 = require("../../client");
|
|
5
|
-
const base_1 = require("../../../../base");
|
|
6
|
-
/*
|
|
7
|
-
This is a singleton (per fin object) tasked with routing messages coming off the ipc to the correct endpoint.
|
|
8
|
-
It needs to be a singleton because there can only be one per wire. It tracks both clients and providers' processAction passed in via the strategy.
|
|
9
|
-
If functionality is not about receiving messages, it does not belong here.
|
|
10
|
-
*/
|
|
11
|
-
class MessageReceiver extends base_1.Base {
|
|
12
|
-
constructor(wire) {
|
|
13
|
-
super(wire);
|
|
14
|
-
this.onmessage = (msg) => {
|
|
15
|
-
if (msg.action === 'process-channel-message') {
|
|
16
|
-
this.processChannelMessage(msg);
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
return false;
|
|
20
|
-
};
|
|
21
|
-
this.endpointMap = new Map();
|
|
22
|
-
this.latestEndpointIdByChannelId = new Map();
|
|
23
|
-
wire.registerMessageHandler(this.onmessage.bind(this));
|
|
24
|
-
}
|
|
25
|
-
async processChannelMessage(msg) {
|
|
26
|
-
var _a, _b;
|
|
27
|
-
const { senderIdentity, providerIdentity, action, ackToSender, payload, intendedTargetIdentity } = msg.payload;
|
|
28
|
-
const key = (_b = (_a = intendedTargetIdentity.channelId) !== null && _a !== void 0 ? _a : intendedTargetIdentity.endpointId) !== null && _b !== void 0 ? _b : this.latestEndpointIdByChannelId.get(providerIdentity.channelId); // No endpointId was passed, make best attempt
|
|
29
|
-
const handler = this.endpointMap.get(key);
|
|
30
|
-
if (!handler) {
|
|
31
|
-
ackToSender.payload.success = false;
|
|
32
|
-
ackToSender.payload.reason = `Client connection with identity uuid: ${this.wire.me.uuid} / name: ${this.wire.me.name} / endpointId: ${key} no longer connected.`;
|
|
33
|
-
return this.wire.sendRaw(ackToSender);
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
const res = await handler(action, payload, senderIdentity);
|
|
37
|
-
ackToSender.payload.payload = ackToSender.payload.payload || {};
|
|
38
|
-
ackToSender.payload.payload.result = res;
|
|
39
|
-
return this.wire.sendRaw(ackToSender);
|
|
40
|
-
}
|
|
41
|
-
catch (e) {
|
|
42
|
-
ackToSender.payload.success = false;
|
|
43
|
-
ackToSender.payload.reason = e.message;
|
|
44
|
-
return this.wire.sendRaw(ackToSender);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
addEndpoint(handler, channelId, endpointId) {
|
|
48
|
-
this.endpointMap.set(endpointId, handler);
|
|
49
|
-
// Providers have the same endpointId and channelId.
|
|
50
|
-
// This is only used when clients are receiving messages from providers, so we shouldn't save provider endpointId here.
|
|
51
|
-
if (channelId !== endpointId) {
|
|
52
|
-
this.latestEndpointIdByChannelId.set(channelId, endpointId);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
removeEndpoint(channelId, endpointId) {
|
|
56
|
-
this.endpointMap.delete(endpointId);
|
|
57
|
-
if (this.latestEndpointIdByChannelId.get(channelId) === endpointId) {
|
|
58
|
-
this.latestEndpointIdByChannelId.delete(channelId);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
checkForPreviousClientConnection(channelId) {
|
|
62
|
-
const endpointIdFromPreviousConnection = this.latestEndpointIdByChannelId.get(channelId);
|
|
63
|
-
if (endpointIdFromPreviousConnection) {
|
|
64
|
-
// Not convinced by this way of doing things, but pushing up for now.
|
|
65
|
-
client_1.default.closeChannelByEndpointId(endpointIdFromPreviousConnection);
|
|
66
|
-
// eslint-disable-next-line no-console
|
|
67
|
-
console.warn('You have created a second connection to an older provider. First connection has been removed from the clientMap');
|
|
68
|
-
// eslint-disable-next-line no-console
|
|
69
|
-
console.warn('If the provider calls publish(), you may receive multiple messages.');
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
exports.MessageReceiver = MessageReceiver;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type * as OpenFin from '../../../../../OpenFin';
|
|
2
|
-
import { Transport } from '../../../../../transport/transport';
|
|
3
|
-
import { MessageReceiver } from './message-receiver';
|
|
4
|
-
import { ChannelStrategy, EndpointPayload } from '../strategy';
|
|
5
|
-
import { LocalSupportedProtocol } from '..';
|
|
6
|
-
type ProviderIdentity = OpenFin.ProviderIdentity;
|
|
7
|
-
export declare class ClassicStrategy implements ChannelStrategy<EndpointPayload> {
|
|
8
|
-
#private;
|
|
9
|
-
private messageReceiver;
|
|
10
|
-
private endpointId;
|
|
11
|
-
private providerIdentity;
|
|
12
|
-
constructor(wire: Transport, messageReceiver: MessageReceiver, endpointId: string, // Provider endpointId is channelId
|
|
13
|
-
providerIdentity: ProviderIdentity);
|
|
14
|
-
onEndpointDisconnect(endpointId: string, listener: () => void): void;
|
|
15
|
-
receive(listener: (action: string, payload: any, identity: OpenFin.ClientIdentity | OpenFin.ClientIdentityMultiRuntime | ProviderIdentity) => Promise<any>): void;
|
|
16
|
-
send: (endpointId: string, action: string, payload: any) => Promise<any>;
|
|
17
|
-
close: () => Promise<void>;
|
|
18
|
-
closeEndpoint(endpointId: string): Promise<void>;
|
|
19
|
-
isEndpointConnected(endpointId: string): boolean;
|
|
20
|
-
addEndpoint(endpointId: string, payload: EndpointPayload): void;
|
|
21
|
-
isValidEndpointPayload(payload: any): payload is EndpointPayload;
|
|
22
|
-
}
|
|
23
|
-
export declare const ClassicInfo: LocalSupportedProtocol;
|
|
24
|
-
export {};
|
|
@@ -1,101 +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 _ClassicStrategy_wire, _ClassicStrategy_endpointIdentityMap, _ClassicStrategy_pendingMessagesByEndpointId;
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.ClassicInfo = exports.ClassicStrategy = void 0;
|
|
16
|
-
/*
|
|
17
|
-
This is used to abstract out ipc messaging from the channels implementation. It is only concerned with sending messages and registration with the MessageReceiver
|
|
18
|
-
*/
|
|
19
|
-
class ClassicStrategy {
|
|
20
|
-
constructor(wire, messageReceiver, endpointId, // Provider endpointId is channelId
|
|
21
|
-
providerIdentity) {
|
|
22
|
-
this.messageReceiver = messageReceiver;
|
|
23
|
-
this.endpointId = endpointId;
|
|
24
|
-
this.providerIdentity = providerIdentity;
|
|
25
|
-
_ClassicStrategy_wire.set(this, void 0);
|
|
26
|
-
// Store full endpointIdentity by endpointId of all known endpoints for this strategy instance.
|
|
27
|
-
// (clients will only have 1: the provider, the provider will have all clients)
|
|
28
|
-
_ClassicStrategy_endpointIdentityMap.set(this, new Map());
|
|
29
|
-
// Store a set of cancellable promises to be able to reject them when client
|
|
30
|
-
// connection problems occur
|
|
31
|
-
_ClassicStrategy_pendingMessagesByEndpointId.set(this, new Map);
|
|
32
|
-
this.send = async (endpointId, action, payload) => {
|
|
33
|
-
var _a;
|
|
34
|
-
const to = __classPrivateFieldGet(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
|
|
35
|
-
if (!to) {
|
|
36
|
-
throw new Error(`Could not locate routing info for endpoint ${endpointId}`);
|
|
37
|
-
}
|
|
38
|
-
// as casting to any because typescript complains. The following is only relevant if this is a locally set endpointId on a ClientIdentity.
|
|
39
|
-
// We delete these properties to not change backwards compatibility.
|
|
40
|
-
const cleanId = { ...to };
|
|
41
|
-
if (cleanId.isLocalEndpointId) {
|
|
42
|
-
delete cleanId.endpointId;
|
|
43
|
-
}
|
|
44
|
-
delete cleanId.isLocalEndpointId;
|
|
45
|
-
// grab the promise before awaiting it to save in our pending messages map
|
|
46
|
-
const p = __classPrivateFieldGet(this, _ClassicStrategy_wire, "f")
|
|
47
|
-
.sendAction('send-channel-message', {
|
|
48
|
-
...cleanId,
|
|
49
|
-
providerIdentity: this.providerIdentity,
|
|
50
|
-
action,
|
|
51
|
-
payload
|
|
52
|
-
});
|
|
53
|
-
(_a = __classPrivateFieldGet(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)) === null || _a === void 0 ? void 0 : _a.add(p);
|
|
54
|
-
const raw = await p.catch((error) => {
|
|
55
|
-
throw new Error(error.message);
|
|
56
|
-
}).finally(() => {
|
|
57
|
-
var _a;
|
|
58
|
-
// clean up the pending promise
|
|
59
|
-
(_a = __classPrivateFieldGet(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)) === null || _a === void 0 ? void 0 : _a.delete(p);
|
|
60
|
-
});
|
|
61
|
-
return raw.payload.data.result;
|
|
62
|
-
};
|
|
63
|
-
this.close = async () => {
|
|
64
|
-
this.messageReceiver.removeEndpoint(this.providerIdentity.channelId, this.endpointId);
|
|
65
|
-
[...__classPrivateFieldGet(this, _ClassicStrategy_endpointIdentityMap, "f").keys()].forEach((id) => this.closeEndpoint(id));
|
|
66
|
-
__classPrivateFieldSet(this, _ClassicStrategy_endpointIdentityMap, new Map(), "f");
|
|
67
|
-
};
|
|
68
|
-
__classPrivateFieldSet(this, _ClassicStrategy_wire, wire, "f");
|
|
69
|
-
}
|
|
70
|
-
onEndpointDisconnect(endpointId, listener) {
|
|
71
|
-
// Never fires for 'classic'.
|
|
72
|
-
}
|
|
73
|
-
receive(listener) {
|
|
74
|
-
this.messageReceiver.addEndpoint(listener, this.providerIdentity.channelId, this.endpointId);
|
|
75
|
-
}
|
|
76
|
-
async closeEndpoint(endpointId) {
|
|
77
|
-
const id = __classPrivateFieldGet(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
|
|
78
|
-
__classPrivateFieldGet(this, _ClassicStrategy_endpointIdentityMap, "f").delete(endpointId);
|
|
79
|
-
const pendingSet = __classPrivateFieldGet(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId);
|
|
80
|
-
pendingSet === null || pendingSet === void 0 ? void 0 : pendingSet.forEach((p) => {
|
|
81
|
-
const errorMsg = `Channel connection with identity uuid: ${id === null || id === void 0 ? void 0 : id.uuid} / name: ${id === null || id === void 0 ? void 0 : id.name} / endpointId: ${endpointId} no longer connected.`;
|
|
82
|
-
p.cancel(new Error(errorMsg));
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
isEndpointConnected(endpointId) {
|
|
86
|
-
return __classPrivateFieldGet(this, _ClassicStrategy_endpointIdentityMap, "f").has(endpointId);
|
|
87
|
-
}
|
|
88
|
-
addEndpoint(endpointId, payload) {
|
|
89
|
-
__classPrivateFieldGet(this, _ClassicStrategy_endpointIdentityMap, "f").set(endpointId, payload.endpointIdentity);
|
|
90
|
-
__classPrivateFieldGet(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").set(endpointId, new Set());
|
|
91
|
-
}
|
|
92
|
-
isValidEndpointPayload(payload) {
|
|
93
|
-
var _a, _b;
|
|
94
|
-
return (typeof ((_a = payload === null || payload === void 0 ? void 0 : payload.endpointIdentity) === null || _a === void 0 ? void 0 : _a.endpointId) === 'string' ||
|
|
95
|
-
typeof ((_b = payload === null || payload === void 0 ? void 0 : payload.endpointIdentity) === null || _b === void 0 ? void 0 : _b.channelId) === 'string');
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
exports.ClassicStrategy = ClassicStrategy;
|
|
99
|
-
_ClassicStrategy_wire = new WeakMap(), _ClassicStrategy_endpointIdentityMap = new WeakMap(), _ClassicStrategy_pendingMessagesByEndpointId = new WeakMap();
|
|
100
|
-
// Arbitrarily starting at 5 to leave the door open to backfilling pre endpointId etc.
|
|
101
|
-
exports.ClassicInfo = { version: 5, minimumVersion: 0, type: 'classic' };
|