@openfin/core 25.68.30 → 25.70.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/OpenFin.d.ts +30 -826
- package/README.md +12 -2
- package/package.json +1 -1
- package/src/api/application/Factory.d.ts +145 -145
- package/src/api/application/Factory.js +229 -229
- package/src/api/application/Instance.d.ts +301 -302
- package/src/api/application/Instance.js +412 -412
- package/src/api/application/index.d.ts +3 -3
- package/src/api/application/index.js +15 -15
- package/src/api/base.d.ts +43 -43
- package/src/api/base.js +177 -177
- package/src/api/clipboard/index.d.ts +69 -69
- package/src/api/clipboard/index.js +88 -88
- package/src/api/events/application.d.ts +69 -0
- package/src/api/events/application.js +2 -0
- package/src/api/events/base.d.ts +17 -0
- package/src/api/events/base.js +2 -0
- package/src/api/events/channel.d.ts +10 -11
- package/src/api/events/channel.js +2 -2
- package/src/api/events/emitterMap.d.ts +11 -11
- package/src/api/events/emitterMap.js +35 -35
- package/src/api/events/eventAggregator.d.ts +5 -5
- package/src/api/events/eventAggregator.js +43 -43
- package/src/api/events/externalApplication.d.ts +5 -0
- package/src/api/events/externalApplication.js +2 -0
- package/src/api/events/frame.d.ts +9 -0
- package/src/api/events/frame.js +2 -0
- package/src/api/events/globalHotkey.d.ts +10 -0
- package/src/api/events/globalHotkey.js +2 -0
- package/src/api/events/platform.d.ts +18 -0
- package/src/api/events/platform.js +2 -0
- package/src/api/events/system.d.ts +22 -0
- package/src/api/events/system.js +2 -0
- package/src/api/events/view.d.ts +56 -0
- package/src/api/events/view.js +2 -0
- package/src/api/events/webcontents.d.ts +48 -0
- package/src/api/events/webcontents.js +2 -0
- package/src/api/events/window.d.ts +176 -0
- package/src/api/events/window.js +2 -0
- package/src/api/external-application/Factory.d.ts +26 -26
- package/src/api/external-application/Factory.js +40 -40
- package/src/api/external-application/Instance.d.ts +101 -102
- package/src/api/external-application/Instance.js +109 -109
- package/src/api/external-application/index.d.ts +3 -3
- package/src/api/external-application/index.js +15 -15
- package/src/api/fin.d.ts +49 -49
- package/src/api/fin.js +43 -43
- package/src/api/frame/Factory.d.ts +36 -36
- package/src/api/frame/Factory.js +69 -69
- package/src/api/frame/Instance.d.ts +121 -121
- package/src/api/frame/Instance.js +130 -130
- package/src/api/frame/index.d.ts +3 -3
- package/src/api/frame/index.js +15 -15
- package/src/api/global-hotkey/index.d.ts +38 -38
- package/src/api/global-hotkey/index.js +58 -58
- package/src/api/interappbus/channel/channel.d.ts +26 -26
- package/src/api/interappbus/channel/channel.js +77 -77
- package/src/api/interappbus/channel/channels-docs.d.ts +318 -318
- package/src/api/interappbus/channel/channels-docs.js +376 -376
- package/src/api/interappbus/channel/client.d.ts +22 -22
- package/src/api/interappbus/channel/client.js +84 -84
- package/src/api/interappbus/channel/connection-manager.d.ts +28 -28
- package/src/api/interappbus/channel/connection-manager.js +244 -244
- package/src/api/interappbus/channel/index.d.ts +22 -23
- package/src/api/interappbus/channel/index.js +121 -121
- package/src/api/interappbus/channel/protocols/classic/message-receiver.d.ts +13 -13
- package/src/api/interappbus/channel/protocols/classic/message-receiver.js +73 -73
- package/src/api/interappbus/channel/protocols/classic/strategy.d.ts +22 -22
- package/src/api/interappbus/channel/protocols/classic/strategy.js +84 -84
- package/src/api/interappbus/channel/protocols/combined/strategy.d.ts +20 -20
- package/src/api/interappbus/channel/protocols/combined/strategy.js +58 -58
- package/src/api/interappbus/channel/protocols/index.d.ts +44 -44
- package/src/api/interappbus/channel/protocols/index.js +2 -2
- package/src/api/interappbus/channel/protocols/protocol-manager.d.ts +10 -10
- package/src/api/interappbus/channel/protocols/protocol-manager.js +43 -43
- package/src/api/interappbus/channel/protocols/rtc/endpoint.d.ts +23 -23
- package/src/api/interappbus/channel/protocols/rtc/endpoint.js +135 -135
- package/src/api/interappbus/channel/protocols/rtc/ice-manager.d.ts +30 -30
- package/src/api/interappbus/channel/protocols/rtc/ice-manager.js +131 -131
- package/src/api/interappbus/channel/protocols/rtc/strategy.d.ts +22 -22
- package/src/api/interappbus/channel/protocols/rtc/strategy.js +87 -87
- package/src/api/interappbus/channel/protocols/strategy-types.d.ts +13 -13
- package/src/api/interappbus/channel/protocols/strategy-types.js +2 -2
- package/src/api/interappbus/channel/protocols/strategy.d.ts +15 -15
- package/src/api/interappbus/channel/protocols/strategy.js +2 -2
- package/src/api/interappbus/channel/provider.d.ts +31 -31
- package/src/api/interappbus/channel/provider.js +160 -160
- package/src/api/interappbus/index.d.ts +85 -86
- package/src/api/interappbus/index.js +175 -175
- package/src/api/interop/Factory.d.ts +37 -37
- package/src/api/interop/Factory.js +54 -54
- package/src/api/interop/InteropBroker.d.ts +363 -363
- package/src/api/interop/InteropBroker.js +914 -914
- package/src/api/interop/InteropClient.d.ts +268 -268
- package/src/api/interop/InteropClient.js +450 -450
- package/src/api/interop/SessionContextGroupBroker.d.ts +26 -26
- package/src/api/interop/SessionContextGroupBroker.js +107 -107
- package/src/api/interop/SessionContextGroupClient.d.ts +20 -20
- package/src/api/interop/SessionContextGroupClient.js +85 -85
- package/src/api/interop/fdc3/fdc3-1.2.d.ts +187 -187
- package/src/api/interop/fdc3/fdc3-1.2.js +385 -385
- package/src/api/interop/fdc3/fdc3.js +17 -17
- package/src/api/interop/fdc3/utils.d.ts +6 -6
- package/src/api/interop/fdc3/utils.js +17 -17
- package/src/api/interop/index.d.ts +4 -4
- package/src/api/interop/index.js +16 -16
- package/src/api/interop/utils.d.ts +11 -11
- package/src/api/interop/utils.js +36 -36
- package/src/api/me.d.ts +38 -35
- package/src/api/me.js +128 -60
- package/src/api/platform/Factory.d.ts +109 -109
- package/src/api/platform/Factory.js +188 -188
- package/src/api/platform/Instance.d.ts +122 -122
- package/src/api/platform/Instance.js +298 -298
- package/src/api/platform/common-utils.d.ts +6 -6
- package/src/api/platform/common-utils.js +16 -16
- package/src/api/platform/index.d.ts +3 -3
- package/src/api/platform/index.js +15 -15
- package/src/api/platform/layout/Factory.d.ts +108 -108
- package/src/api/platform/layout/Factory.js +189 -189
- package/src/api/platform/layout/Instance.d.ts +49 -49
- package/src/api/platform/layout/Instance.js +99 -99
- package/src/api/platform/layout/index.d.ts +2 -2
- package/src/api/platform/layout/index.js +14 -14
- package/src/api/platform/layout/shapes.d.ts +11 -0
- package/src/api/{window → platform/layout}/shapes.js +2 -2
- package/src/api/snapshot-source/Factory.d.ts +36 -36
- package/src/api/snapshot-source/Factory.js +65 -65
- package/src/api/snapshot-source/Instance.d.ts +30 -30
- package/src/api/snapshot-source/Instance.js +134 -134
- package/src/api/snapshot-source/index.d.ts +3 -3
- package/src/api/snapshot-source/index.js +15 -15
- package/src/api/snapshot-source/utils.d.ts +1 -1
- package/src/api/snapshot-source/utils.js +5 -5
- package/src/api/system/index.d.ts +960 -961
- package/src/api/system/index.js +1241 -1241
- package/src/api/view/Factory.d.ts +49 -49
- package/src/api/view/Factory.js +103 -103
- package/src/api/view/Instance.d.ts +387 -380
- package/src/api/view/Instance.js +422 -415
- package/src/api/view/index.d.ts +3 -3
- package/src/api/view/index.js +15 -15
- package/src/api/webcontents/main.d.ts +36 -36
- package/src/api/webcontents/main.js +82 -82
- package/src/api/window/Factory.d.ts +44 -44
- package/src/api/window/Factory.js +91 -91
- package/src/api/window/Instance.d.ts +972 -966
- package/src/api/window/Instance.js +1209 -1202
- package/src/api/window/index.d.ts +3 -5
- package/src/api/window/index.js +15 -17
- package/src/environment/environment.d.ts +28 -25
- package/src/environment/environment.js +4 -4
- package/src/environment/node-env.d.ts +25 -26
- package/src/environment/node-env.js +64 -64
- package/src/environment/openfin-env.d.ts +29 -30
- package/src/environment/openfin-env.js +107 -107
- package/src/mock.d.ts +3 -3
- package/src/mock.js +91 -90
- package/src/shapes/ERROR_BOX_TYPES.d.ts +1 -0
- package/src/shapes/ERROR_BOX_TYPES.js +2 -0
- package/src/shapes/WebOptions.d.ts +12 -0
- package/src/shapes/WebOptions.js +2 -0
- package/src/shapes/WindowOptions.d.ts +42 -0
- package/src/shapes/WindowOptions.js +2 -0
- package/src/shapes/protocol.d.ts +178 -0
- package/src/shapes/protocol.js +2 -0
- package/src/transport/fin_store.d.ts +4 -4
- package/src/transport/fin_store.js +16 -16
- package/src/transport/transport-errors.d.ts +18 -18
- package/src/transport/transport-errors.js +37 -37
- package/src/transport/transport.d.ts +56 -43
- package/src/transport/transport.js +181 -181
- package/src/transport/wire.d.ts +71 -11
- package/src/transport/wire.js +32 -32
- package/src/util/asyncFilter.d.ts +1 -1
- package/src/util/asyncFilter.js +7 -7
- package/src/util/errors.d.ts +9 -5
- package/src/util/errors.js +11 -11
- package/src/util/exhaustive.d.ts +1 -1
- package/src/util/exhaustive.js +7 -7
- package/src/util/http.d.ts +11 -11
- package/src/util/http.js +83 -83
- package/src/util/normalize-config.d.ts +3 -5
- package/src/util/normalize-config.js +47 -47
- package/src/util/promises.d.ts +5 -5
- package/src/util/promises.js +27 -27
- package/src/util/ref-counter.d.ts +7 -7
- package/src/util/ref-counter.js +51 -51
- package/src/util/runtimeVersioning.d.ts +3 -3
- package/src/util/runtimeVersioning.js +25 -25
- package/src/util/utilTypes.d.ts +8 -8
- package/src/util/utilTypes.js +2 -2
- package/src/util/validate.d.ts +3 -3
- package/src/util/validate.js +11 -11
- package/docs.README(OLD).md +0 -82
- package/resources/win/OpenFinRVM.exe +0 -0
- package/src/api/window/bounds-changed.d.ts +0 -10
- package/src/api/window/bounds-changed.js +0 -6
- package/src/api/window/shapes.d.ts +0 -13
|
@@ -1,121 +1,121 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {
|
|
3
|
-
if (!privateMap.has(receiver)) {
|
|
4
|
-
throw new TypeError("attempted to set private field on non-instance");
|
|
5
|
-
}
|
|
6
|
-
privateMap.set(receiver, value);
|
|
7
|
-
return value;
|
|
8
|
-
};
|
|
9
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {
|
|
10
|
-
if (!privateMap.has(receiver)) {
|
|
11
|
-
throw new TypeError("attempted to get private field on non-instance");
|
|
12
|
-
}
|
|
13
|
-
return privateMap.get(receiver);
|
|
14
|
-
};
|
|
15
|
-
var _connectionManager;
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Channel = void 0;
|
|
18
|
-
/* eslint-disable no-console */
|
|
19
|
-
const client_1 = require("./client");
|
|
20
|
-
const provider_1 = require("./provider");
|
|
21
|
-
const base_1 = require("../../base");
|
|
22
|
-
const connection_manager_1 = require("./connection-manager");
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
24
|
-
const noop = () => { };
|
|
25
|
-
class Channel extends base_1.EmitterBase {
|
|
26
|
-
constructor(wire) {
|
|
27
|
-
super(wire, 'channel');
|
|
28
|
-
_connectionManager.set(this, void 0);
|
|
29
|
-
__classPrivateFieldSet(this, _connectionManager, new connection_manager_1.ConnectionManager(wire));
|
|
30
|
-
}
|
|
31
|
-
async getAllChannels() {
|
|
32
|
-
return this.wire.sendAction('get-all-channels').then(({ payload }) => payload.data);
|
|
33
|
-
}
|
|
34
|
-
async onChannelConnect(listener) {
|
|
35
|
-
await this.on('connected', listener);
|
|
36
|
-
}
|
|
37
|
-
async onChannelDisconnect(listener) {
|
|
38
|
-
await this.on('disconnected', listener);
|
|
39
|
-
}
|
|
40
|
-
async connect(channelName, options) {
|
|
41
|
-
if (!channelName || typeof channelName !== 'string') {
|
|
42
|
-
throw new Error('Please provide a channelName string to connect to a channel.');
|
|
43
|
-
}
|
|
44
|
-
const opts = Object.assign(this.wire.environment.getDefaultChannelOptions().connect, options || {});
|
|
45
|
-
let resolver = noop;
|
|
46
|
-
let listener = noop;
|
|
47
|
-
const waitResponse = new Promise((resolve) => {
|
|
48
|
-
resolver = resolve;
|
|
49
|
-
listener = (payload) => {
|
|
50
|
-
if (channelName === payload.channelName) {
|
|
51
|
-
this.removeListener('connected', listener);
|
|
52
|
-
this.connect(channelName, opts).then((response) => {
|
|
53
|
-
resolve(response);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
this.on('connected', listener);
|
|
58
|
-
});
|
|
59
|
-
try {
|
|
60
|
-
const { offer, rtc: rtcPacket } = await __classPrivateFieldGet(this, _connectionManager).createClientOffer(opts);
|
|
61
|
-
const res = await this.wire.sendAction('connect-to-channel', { channelName, ...opts, offer });
|
|
62
|
-
const { payload: { data: routingInfo } } = res;
|
|
63
|
-
// If there isn't a matching channel, the above sendAction call will error out and go to catch, skipping the logic below.
|
|
64
|
-
if (resolver) {
|
|
65
|
-
resolver();
|
|
66
|
-
}
|
|
67
|
-
this.removeListener('connected', listener);
|
|
68
|
-
const strategy = await __classPrivateFieldGet(this, _connectionManager).createClientStrategy(rtcPacket, routingInfo);
|
|
69
|
-
const channel = new client_1.default(routingInfo, this.wire, strategy);
|
|
70
|
-
// It is the client's responsibility to handle endpoint disconnection to the provider.
|
|
71
|
-
// If the endpoint dies, the client will force a disconnection through the core.
|
|
72
|
-
// The provider does not care about endpoint disconnection.
|
|
73
|
-
strategy.onEndpointDisconnect(routingInfo.channelId, async () => {
|
|
74
|
-
try {
|
|
75
|
-
await channel.disconnect();
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
console.warn(`Something went wrong during disconnect for client with uuid: ${routingInfo.uuid} / name: ${routingInfo.name} / endpointId: ${routingInfo.endpointId}.`);
|
|
79
|
-
}
|
|
80
|
-
finally {
|
|
81
|
-
client_1.default.handleProviderDisconnect(channel, routingInfo);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
this.on('disconnected', (eventPayload) => {
|
|
85
|
-
if (eventPayload.channelName === channelName) {
|
|
86
|
-
client_1.default.handleProviderDisconnect(channel, eventPayload);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
return channel;
|
|
90
|
-
}
|
|
91
|
-
catch (e) {
|
|
92
|
-
const shouldWait = { wait: true, ...opts }.wait;
|
|
93
|
-
const internalNackMessage = 'internal-nack';
|
|
94
|
-
if (shouldWait && e.message && e.message.includes(internalNackMessage)) {
|
|
95
|
-
console.warn(`Channel not found for channelName: ${channelName}, waiting for channel connection.`);
|
|
96
|
-
return waitResponse;
|
|
97
|
-
}
|
|
98
|
-
if (e.message === internalNackMessage) {
|
|
99
|
-
throw new Error(`No channel found for channelName: ${channelName}`);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
throw new Error(e);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
async create(channelName, options) {
|
|
107
|
-
if (!channelName) {
|
|
108
|
-
throw new Error('Please provide a channelName to create a channel');
|
|
109
|
-
}
|
|
110
|
-
const { payload: { data: providerIdentity } } = await this.wire.sendAction('create-channel', { channelName });
|
|
111
|
-
const channel = __classPrivateFieldGet(this, _connectionManager).createProvider(options, providerIdentity);
|
|
112
|
-
this.on('client-disconnected', (eventPayload) => {
|
|
113
|
-
if (eventPayload.channelName === channelName) {
|
|
114
|
-
provider_1.ChannelProvider.handleClientDisconnection(channel, eventPayload);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
return channel;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
exports.Channel = Channel;
|
|
121
|
-
_connectionManager = new WeakMap();
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {
|
|
3
|
+
if (!privateMap.has(receiver)) {
|
|
4
|
+
throw new TypeError("attempted to set private field on non-instance");
|
|
5
|
+
}
|
|
6
|
+
privateMap.set(receiver, value);
|
|
7
|
+
return value;
|
|
8
|
+
};
|
|
9
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {
|
|
10
|
+
if (!privateMap.has(receiver)) {
|
|
11
|
+
throw new TypeError("attempted to get private field on non-instance");
|
|
12
|
+
}
|
|
13
|
+
return privateMap.get(receiver);
|
|
14
|
+
};
|
|
15
|
+
var _connectionManager;
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Channel = void 0;
|
|
18
|
+
/* eslint-disable no-console */
|
|
19
|
+
const client_1 = require("./client");
|
|
20
|
+
const provider_1 = require("./provider");
|
|
21
|
+
const base_1 = require("../../base");
|
|
22
|
+
const connection_manager_1 = require("./connection-manager");
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
24
|
+
const noop = () => { };
|
|
25
|
+
class Channel extends base_1.EmitterBase {
|
|
26
|
+
constructor(wire) {
|
|
27
|
+
super(wire, 'channel');
|
|
28
|
+
_connectionManager.set(this, void 0);
|
|
29
|
+
__classPrivateFieldSet(this, _connectionManager, new connection_manager_1.ConnectionManager(wire));
|
|
30
|
+
}
|
|
31
|
+
async getAllChannels() {
|
|
32
|
+
return this.wire.sendAction('get-all-channels').then(({ payload }) => payload.data);
|
|
33
|
+
}
|
|
34
|
+
async onChannelConnect(listener) {
|
|
35
|
+
await this.on('connected', listener);
|
|
36
|
+
}
|
|
37
|
+
async onChannelDisconnect(listener) {
|
|
38
|
+
await this.on('disconnected', listener);
|
|
39
|
+
}
|
|
40
|
+
async connect(channelName, options) {
|
|
41
|
+
if (!channelName || typeof channelName !== 'string') {
|
|
42
|
+
throw new Error('Please provide a channelName string to connect to a channel.');
|
|
43
|
+
}
|
|
44
|
+
const opts = Object.assign(this.wire.environment.getDefaultChannelOptions().connect, options || {});
|
|
45
|
+
let resolver = noop;
|
|
46
|
+
let listener = noop;
|
|
47
|
+
const waitResponse = new Promise((resolve) => {
|
|
48
|
+
resolver = resolve;
|
|
49
|
+
listener = (payload) => {
|
|
50
|
+
if (channelName === payload.channelName) {
|
|
51
|
+
this.removeListener('connected', listener);
|
|
52
|
+
this.connect(channelName, opts).then((response) => {
|
|
53
|
+
resolve(response);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
this.on('connected', listener);
|
|
58
|
+
});
|
|
59
|
+
try {
|
|
60
|
+
const { offer, rtc: rtcPacket } = await __classPrivateFieldGet(this, _connectionManager).createClientOffer(opts);
|
|
61
|
+
const res = await this.wire.sendAction('connect-to-channel', { channelName, ...opts, offer });
|
|
62
|
+
const { payload: { data: routingInfo } } = res;
|
|
63
|
+
// If there isn't a matching channel, the above sendAction call will error out and go to catch, skipping the logic below.
|
|
64
|
+
if (resolver) {
|
|
65
|
+
resolver();
|
|
66
|
+
}
|
|
67
|
+
this.removeListener('connected', listener);
|
|
68
|
+
const strategy = await __classPrivateFieldGet(this, _connectionManager).createClientStrategy(rtcPacket, routingInfo);
|
|
69
|
+
const channel = new client_1.default(routingInfo, this.wire, strategy);
|
|
70
|
+
// It is the client's responsibility to handle endpoint disconnection to the provider.
|
|
71
|
+
// If the endpoint dies, the client will force a disconnection through the core.
|
|
72
|
+
// The provider does not care about endpoint disconnection.
|
|
73
|
+
strategy.onEndpointDisconnect(routingInfo.channelId, async () => {
|
|
74
|
+
try {
|
|
75
|
+
await channel.disconnect();
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
console.warn(`Something went wrong during disconnect for client with uuid: ${routingInfo.uuid} / name: ${routingInfo.name} / endpointId: ${routingInfo.endpointId}.`);
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
client_1.default.handleProviderDisconnect(channel, routingInfo);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
this.on('disconnected', (eventPayload) => {
|
|
85
|
+
if (eventPayload.channelName === channelName) {
|
|
86
|
+
client_1.default.handleProviderDisconnect(channel, eventPayload);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return channel;
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
const shouldWait = { wait: true, ...opts }.wait;
|
|
93
|
+
const internalNackMessage = 'internal-nack';
|
|
94
|
+
if (shouldWait && e.message && e.message.includes(internalNackMessage)) {
|
|
95
|
+
console.warn(`Channel not found for channelName: ${channelName}, waiting for channel connection.`);
|
|
96
|
+
return waitResponse;
|
|
97
|
+
}
|
|
98
|
+
if (e.message === internalNackMessage) {
|
|
99
|
+
throw new Error(`No channel found for channelName: ${channelName}`);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
throw new Error(e);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async create(channelName, options) {
|
|
107
|
+
if (!channelName) {
|
|
108
|
+
throw new Error('Please provide a channelName to create a channel');
|
|
109
|
+
}
|
|
110
|
+
const { payload: { data: providerIdentity } } = await this.wire.sendAction('create-channel', { channelName });
|
|
111
|
+
const channel = __classPrivateFieldGet(this, _connectionManager).createProvider(options, providerIdentity);
|
|
112
|
+
this.on('client-disconnected', (eventPayload) => {
|
|
113
|
+
if (eventPayload.channelName === channelName) {
|
|
114
|
+
provider_1.ChannelProvider.handleClientDisconnection(channel, eventPayload);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
return channel;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.Channel = Channel;
|
|
121
|
+
_connectionManager = new WeakMap();
|
|
@@ -1,13 +1,13 @@
|
|
|
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
|
+
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 +1,73 @@
|
|
|
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
|
+
"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,22 +1,22 @@
|
|
|
1
|
-
import Transport from '../../../../../transport/transport';
|
|
2
|
-
import { MessageReceiver } from './message-receiver';
|
|
3
|
-
import { ChannelStrategy, EndpointPayload } from '../strategy';
|
|
4
|
-
import { LocalSupportedProtocol } from '..';
|
|
5
|
-
import ProviderIdentity = OpenFin.ProviderIdentity;
|
|
6
|
-
export declare class ClassicStrategy implements ChannelStrategy<EndpointPayload> {
|
|
7
|
-
#private;
|
|
8
|
-
private messageReceiver;
|
|
9
|
-
private endpointId;
|
|
10
|
-
private providerIdentity;
|
|
11
|
-
constructor(wire: Transport, messageReceiver: MessageReceiver, endpointId: string, // Provider endpointId is channelId
|
|
12
|
-
providerIdentity: ProviderIdentity);
|
|
13
|
-
onEndpointDisconnect(endpointId: string, listener: () => void): void;
|
|
14
|
-
receive(listener: (action: string, payload: any, identity: OpenFin.ClientIdentity | OpenFin.ClientIdentityMultiRuntime | ProviderIdentity) => Promise<any>): void;
|
|
15
|
-
send: (endpointId: string, action: string, payload: any) => Promise<any>;
|
|
16
|
-
close: () => Promise<void>;
|
|
17
|
-
closeEndpoint(endpointId: string): Promise<void>;
|
|
18
|
-
isEndpointConnected(endpointId: string): boolean;
|
|
19
|
-
addEndpoint(endpointId: string, payload: EndpointPayload): void;
|
|
20
|
-
isValidEndpointPayload(payload: any): payload is EndpointPayload;
|
|
21
|
-
}
|
|
22
|
-
export declare const ClassicInfo: LocalSupportedProtocol;
|
|
1
|
+
import Transport from '../../../../../transport/transport';
|
|
2
|
+
import { MessageReceiver } from './message-receiver';
|
|
3
|
+
import { ChannelStrategy, EndpointPayload } from '../strategy';
|
|
4
|
+
import { LocalSupportedProtocol } from '..';
|
|
5
|
+
import ProviderIdentity = OpenFin.ProviderIdentity;
|
|
6
|
+
export declare class ClassicStrategy implements ChannelStrategy<EndpointPayload> {
|
|
7
|
+
#private;
|
|
8
|
+
private messageReceiver;
|
|
9
|
+
private endpointId;
|
|
10
|
+
private providerIdentity;
|
|
11
|
+
constructor(wire: Transport, messageReceiver: MessageReceiver, endpointId: string, // Provider endpointId is channelId
|
|
12
|
+
providerIdentity: ProviderIdentity);
|
|
13
|
+
onEndpointDisconnect(endpointId: string, listener: () => void): void;
|
|
14
|
+
receive(listener: (action: string, payload: any, identity: OpenFin.ClientIdentity | OpenFin.ClientIdentityMultiRuntime | ProviderIdentity) => Promise<any>): void;
|
|
15
|
+
send: (endpointId: string, action: string, payload: any) => Promise<any>;
|
|
16
|
+
close: () => Promise<void>;
|
|
17
|
+
closeEndpoint(endpointId: string): Promise<void>;
|
|
18
|
+
isEndpointConnected(endpointId: string): boolean;
|
|
19
|
+
addEndpoint(endpointId: string, payload: EndpointPayload): void;
|
|
20
|
+
isValidEndpointPayload(payload: any): payload is EndpointPayload;
|
|
21
|
+
}
|
|
22
|
+
export declare const ClassicInfo: LocalSupportedProtocol;
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {
|
|
3
|
-
if (!privateMap.has(receiver)) {
|
|
4
|
-
throw new TypeError("attempted to set private field on non-instance");
|
|
5
|
-
}
|
|
6
|
-
privateMap.set(receiver, value);
|
|
7
|
-
return value;
|
|
8
|
-
};
|
|
9
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {
|
|
10
|
-
if (!privateMap.has(receiver)) {
|
|
11
|
-
throw new TypeError("attempted to get private field on non-instance");
|
|
12
|
-
}
|
|
13
|
-
return privateMap.get(receiver);
|
|
14
|
-
};
|
|
15
|
-
var _wire, _endpointIdentityMap;
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.ClassicInfo = exports.ClassicStrategy = void 0;
|
|
18
|
-
/*
|
|
19
|
-
This is used to abstract out ipc messaging from the channels implementation. It is only concerned with sending messages and registration with the MessageReceiver
|
|
20
|
-
*/
|
|
21
|
-
class ClassicStrategy {
|
|
22
|
-
constructor(wire, messageReceiver, endpointId, // Provider endpointId is channelId
|
|
23
|
-
providerIdentity) {
|
|
24
|
-
this.messageReceiver = messageReceiver;
|
|
25
|
-
this.endpointId = endpointId;
|
|
26
|
-
this.providerIdentity = providerIdentity;
|
|
27
|
-
_wire.set(this, void 0);
|
|
28
|
-
// Store full endpointIdentity by endpointId of all known endpoints for this strategy instance.
|
|
29
|
-
// (clients will only have 1: the provider, the provider will have all clients)
|
|
30
|
-
_endpointIdentityMap.set(this, new Map());
|
|
31
|
-
this.send = async (endpointId, action, payload) => {
|
|
32
|
-
const to = __classPrivateFieldGet(this, _endpointIdentityMap).get(endpointId);
|
|
33
|
-
if (!to) {
|
|
34
|
-
throw new Error(`Could not locate routing info for endpoint ${endpointId}`);
|
|
35
|
-
}
|
|
36
|
-
// as casting to any because typescript complains. The following is only relevant if this is a locally set endpointId on a ClientIdentity.
|
|
37
|
-
// We delete these properties to not change backwards compatibility.
|
|
38
|
-
const cleanId = { ...to };
|
|
39
|
-
if (cleanId.isLocalEndpointId) {
|
|
40
|
-
delete cleanId.endpointId;
|
|
41
|
-
}
|
|
42
|
-
delete cleanId.isLocalEndpointId;
|
|
43
|
-
const raw = await __classPrivateFieldGet(this, _wire).sendAction('send-channel-message', {
|
|
44
|
-
...cleanId,
|
|
45
|
-
providerIdentity: this.providerIdentity,
|
|
46
|
-
action,
|
|
47
|
-
payload
|
|
48
|
-
})
|
|
49
|
-
.catch((reason) => {
|
|
50
|
-
throw new Error(reason.message);
|
|
51
|
-
});
|
|
52
|
-
return raw.payload.data.result;
|
|
53
|
-
};
|
|
54
|
-
this.close = async () => {
|
|
55
|
-
this.messageReceiver.removeEndpoint(this.providerIdentity.channelId, this.endpointId);
|
|
56
|
-
__classPrivateFieldSet(this, _endpointIdentityMap, new Map());
|
|
57
|
-
};
|
|
58
|
-
__classPrivateFieldSet(this, _wire, wire);
|
|
59
|
-
}
|
|
60
|
-
onEndpointDisconnect(endpointId, listener) {
|
|
61
|
-
// Never fires for 'classic'.
|
|
62
|
-
}
|
|
63
|
-
receive(listener) {
|
|
64
|
-
this.messageReceiver.addEndpoint(listener, this.providerIdentity.channelId, this.endpointId);
|
|
65
|
-
}
|
|
66
|
-
async closeEndpoint(endpointId) {
|
|
67
|
-
__classPrivateFieldGet(this, _endpointIdentityMap).delete(endpointId);
|
|
68
|
-
}
|
|
69
|
-
isEndpointConnected(endpointId) {
|
|
70
|
-
return __classPrivateFieldGet(this, _endpointIdentityMap).has(endpointId);
|
|
71
|
-
}
|
|
72
|
-
addEndpoint(endpointId, payload) {
|
|
73
|
-
__classPrivateFieldGet(this, _endpointIdentityMap).set(endpointId, payload.endpointIdentity);
|
|
74
|
-
}
|
|
75
|
-
isValidEndpointPayload(payload) {
|
|
76
|
-
var _a, _b;
|
|
77
|
-
return (typeof ((_a = payload === null || payload === void 0 ? void 0 : payload.endpointIdentity) === null || _a === void 0 ? void 0 : _a.endpointId) === 'string' ||
|
|
78
|
-
typeof ((_b = payload === null || payload === void 0 ? void 0 : payload.endpointIdentity) === null || _b === void 0 ? void 0 : _b.channelId) === 'string');
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
exports.ClassicStrategy = ClassicStrategy;
|
|
82
|
-
_wire = new WeakMap(), _endpointIdentityMap = new WeakMap();
|
|
83
|
-
// Arbitrarily starting at 5 to leave the door open to backfilling pre endpointId etc.
|
|
84
|
-
exports.ClassicInfo = { version: 5, minimumVersion: 0, type: 'classic' };
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {
|
|
3
|
+
if (!privateMap.has(receiver)) {
|
|
4
|
+
throw new TypeError("attempted to set private field on non-instance");
|
|
5
|
+
}
|
|
6
|
+
privateMap.set(receiver, value);
|
|
7
|
+
return value;
|
|
8
|
+
};
|
|
9
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {
|
|
10
|
+
if (!privateMap.has(receiver)) {
|
|
11
|
+
throw new TypeError("attempted to get private field on non-instance");
|
|
12
|
+
}
|
|
13
|
+
return privateMap.get(receiver);
|
|
14
|
+
};
|
|
15
|
+
var _wire, _endpointIdentityMap;
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.ClassicInfo = exports.ClassicStrategy = void 0;
|
|
18
|
+
/*
|
|
19
|
+
This is used to abstract out ipc messaging from the channels implementation. It is only concerned with sending messages and registration with the MessageReceiver
|
|
20
|
+
*/
|
|
21
|
+
class ClassicStrategy {
|
|
22
|
+
constructor(wire, messageReceiver, endpointId, // Provider endpointId is channelId
|
|
23
|
+
providerIdentity) {
|
|
24
|
+
this.messageReceiver = messageReceiver;
|
|
25
|
+
this.endpointId = endpointId;
|
|
26
|
+
this.providerIdentity = providerIdentity;
|
|
27
|
+
_wire.set(this, void 0);
|
|
28
|
+
// Store full endpointIdentity by endpointId of all known endpoints for this strategy instance.
|
|
29
|
+
// (clients will only have 1: the provider, the provider will have all clients)
|
|
30
|
+
_endpointIdentityMap.set(this, new Map());
|
|
31
|
+
this.send = async (endpointId, action, payload) => {
|
|
32
|
+
const to = __classPrivateFieldGet(this, _endpointIdentityMap).get(endpointId);
|
|
33
|
+
if (!to) {
|
|
34
|
+
throw new Error(`Could not locate routing info for endpoint ${endpointId}`);
|
|
35
|
+
}
|
|
36
|
+
// as casting to any because typescript complains. The following is only relevant if this is a locally set endpointId on a ClientIdentity.
|
|
37
|
+
// We delete these properties to not change backwards compatibility.
|
|
38
|
+
const cleanId = { ...to };
|
|
39
|
+
if (cleanId.isLocalEndpointId) {
|
|
40
|
+
delete cleanId.endpointId;
|
|
41
|
+
}
|
|
42
|
+
delete cleanId.isLocalEndpointId;
|
|
43
|
+
const raw = await __classPrivateFieldGet(this, _wire).sendAction('send-channel-message', {
|
|
44
|
+
...cleanId,
|
|
45
|
+
providerIdentity: this.providerIdentity,
|
|
46
|
+
action,
|
|
47
|
+
payload
|
|
48
|
+
})
|
|
49
|
+
.catch((reason) => {
|
|
50
|
+
throw new Error(reason.message);
|
|
51
|
+
});
|
|
52
|
+
return raw.payload.data.result;
|
|
53
|
+
};
|
|
54
|
+
this.close = async () => {
|
|
55
|
+
this.messageReceiver.removeEndpoint(this.providerIdentity.channelId, this.endpointId);
|
|
56
|
+
__classPrivateFieldSet(this, _endpointIdentityMap, new Map());
|
|
57
|
+
};
|
|
58
|
+
__classPrivateFieldSet(this, _wire, wire);
|
|
59
|
+
}
|
|
60
|
+
onEndpointDisconnect(endpointId, listener) {
|
|
61
|
+
// Never fires for 'classic'.
|
|
62
|
+
}
|
|
63
|
+
receive(listener) {
|
|
64
|
+
this.messageReceiver.addEndpoint(listener, this.providerIdentity.channelId, this.endpointId);
|
|
65
|
+
}
|
|
66
|
+
async closeEndpoint(endpointId) {
|
|
67
|
+
__classPrivateFieldGet(this, _endpointIdentityMap).delete(endpointId);
|
|
68
|
+
}
|
|
69
|
+
isEndpointConnected(endpointId) {
|
|
70
|
+
return __classPrivateFieldGet(this, _endpointIdentityMap).has(endpointId);
|
|
71
|
+
}
|
|
72
|
+
addEndpoint(endpointId, payload) {
|
|
73
|
+
__classPrivateFieldGet(this, _endpointIdentityMap).set(endpointId, payload.endpointIdentity);
|
|
74
|
+
}
|
|
75
|
+
isValidEndpointPayload(payload) {
|
|
76
|
+
var _a, _b;
|
|
77
|
+
return (typeof ((_a = payload === null || payload === void 0 ? void 0 : payload.endpointIdentity) === null || _a === void 0 ? void 0 : _a.endpointId) === 'string' ||
|
|
78
|
+
typeof ((_b = payload === null || payload === void 0 ? void 0 : payload.endpointIdentity) === null || _b === void 0 ? void 0 : _b.channelId) === 'string');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.ClassicStrategy = ClassicStrategy;
|
|
82
|
+
_wire = new WeakMap(), _endpointIdentityMap = new WeakMap();
|
|
83
|
+
// Arbitrarily starting at 5 to leave the door open to backfilling pre endpointId etc.
|
|
84
|
+
exports.ClassicInfo = { version: 5, minimumVersion: 0, type: 'classic' };
|