@openfin/core 29.72.17 → 29.73.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/OpenFin.d.ts +45 -27
- package/package.json +1 -1
- package/src/api/application/Factory.js +3 -3
- package/src/api/application/index.js +7 -3
- package/src/api/base.js +18 -20
- package/src/api/external-application/index.js +7 -3
- package/src/api/fin.js +2 -2
- package/src/api/frame/Factory.js +2 -2
- package/src/api/frame/index.js +7 -3
- package/src/api/interappbus/channel/client.js +24 -26
- package/src/api/interappbus/channel/connection-manager.js +24 -26
- package/src/api/interappbus/channel/index.js +16 -18
- package/src/api/interappbus/channel/protocols/classic/strategy.js +21 -22
- package/src/api/interappbus/channel/protocols/rtc/endpoint.js +24 -26
- package/src/api/interappbus/channel/protocols/rtc/strategy.js +29 -31
- package/src/api/interappbus/channel/provider.js +134 -139
- package/src/api/interappbus/index.js +1 -1
- package/src/api/interop/InteropBroker.js +9 -9
- package/src/api/interop/InteropClient.js +38 -40
- package/src/api/interop/SessionContextGroupClient.js +22 -24
- package/src/api/interop/fdc3/PrivateChannelClient.d.ts +17 -0
- package/src/api/interop/fdc3/PrivateChannelClient.js +82 -0
- package/src/api/interop/fdc3/PrivateChannelProvider.d.ts +40 -0
- package/src/api/interop/fdc3/PrivateChannelProvider.js +224 -0
- package/src/api/interop/fdc3/fdc3-1.2.d.ts +0 -1
- package/src/api/interop/fdc3/fdc3-1.2.js +1 -27
- package/src/api/interop/fdc3/fdc3-2.0.d.ts +22 -3
- package/src/api/interop/fdc3/fdc3-2.0.js +76 -11
- package/src/api/interop/fdc3/utils.d.ts +15 -0
- package/src/api/interop/fdc3/utils.js +162 -1
- package/src/api/interop/index.js +7 -3
- package/src/api/interop/utils.js +21 -15
- package/src/api/platform/Factory.js +5 -5
- package/src/api/platform/Instance.js +11 -12
- package/src/api/platform/index.js +7 -3
- package/src/api/platform/layout/Factory.js +18 -20
- package/src/api/platform/layout/Instance.d.ts +1 -1
- package/src/api/platform/layout/Instance.js +2 -2
- package/src/api/platform/layout/controllers/splitter-controller.js +1 -1
- package/src/api/platform/layout/controllers/tab-drag-controller.d.ts +17 -8
- package/src/api/platform/layout/controllers/tab-drag-controller.js +44 -22
- package/src/api/platform/layout/index.js +7 -3
- package/src/api/platform/layout/utils/bounds-observer.js +5 -3
- package/src/api/snapshot-source/Factory.js +1 -1
- package/src/api/snapshot-source/Instance.js +33 -35
- package/src/api/snapshot-source/index.js +7 -3
- package/src/api/snapshot-source/utils.js +2 -1
- package/src/api/view/Factory.js +2 -2
- package/src/api/view/Instance.d.ts +31 -1
- package/src/api/view/Instance.js +31 -1
- package/src/api/view/index.js +7 -3
- package/src/api/window/Factory.js +2 -2
- package/src/api/window/Instance.d.ts +3 -0
- package/src/api/window/Instance.js +3 -0
- package/src/api/window/index.js +7 -3
- package/src/environment/node-env.js +2 -2
- package/src/environment/openfin-env.js +15 -17
- package/src/fdc3.js +1 -1
- package/src/mock.js +1 -2
- package/src/transport/transport.js +26 -28
- package/src/transport/wire.d.ts +9 -7
- package/src/util/http.d.ts +1 -1
- package/src/util/http.js +16 -11
- package/src/util/normalize-config.js +5 -5
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver,
|
|
3
|
-
if (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return value;
|
|
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;
|
|
8
7
|
};
|
|
9
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver,
|
|
10
|
-
if (!
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return privateMap.get(receiver);
|
|
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);
|
|
14
12
|
};
|
|
15
|
-
var
|
|
13
|
+
var _Channel_connectionManager;
|
|
16
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
15
|
exports.Channel = void 0;
|
|
18
16
|
/* eslint-disable no-console */
|
|
@@ -25,8 +23,8 @@ const noop = () => { };
|
|
|
25
23
|
class Channel extends base_1.EmitterBase {
|
|
26
24
|
constructor(wire) {
|
|
27
25
|
super(wire, 'channel');
|
|
28
|
-
|
|
29
|
-
__classPrivateFieldSet(this,
|
|
26
|
+
_Channel_connectionManager.set(this, void 0);
|
|
27
|
+
__classPrivateFieldSet(this, _Channel_connectionManager, new connection_manager_1.ConnectionManager(wire), "f");
|
|
30
28
|
}
|
|
31
29
|
async getAllChannels() {
|
|
32
30
|
return this.wire.sendAction('get-all-channels').then(({ payload }) => payload.data);
|
|
@@ -55,7 +53,7 @@ class Channel extends base_1.EmitterBase {
|
|
|
55
53
|
this.on('connected', listener);
|
|
56
54
|
});
|
|
57
55
|
try {
|
|
58
|
-
const { offer, rtc: rtcPacket } = await __classPrivateFieldGet(this,
|
|
56
|
+
const { offer, rtc: rtcPacket } = await __classPrivateFieldGet(this, _Channel_connectionManager, "f").createClientOffer(opts);
|
|
59
57
|
const res = await this.wire.sendAction('connect-to-channel', { channelName, ...opts, offer });
|
|
60
58
|
const { payload: { data: routingInfo } } = res;
|
|
61
59
|
// If there isn't a matching channel, the above sendAction call will error out and go to catch, skipping the logic below.
|
|
@@ -63,7 +61,7 @@ class Channel extends base_1.EmitterBase {
|
|
|
63
61
|
resolver();
|
|
64
62
|
}
|
|
65
63
|
this.removeListener('connected', listener);
|
|
66
|
-
const strategy = await __classPrivateFieldGet(this,
|
|
64
|
+
const strategy = await __classPrivateFieldGet(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
|
|
67
65
|
const channel = new client_1.default(routingInfo, this.wire, strategy);
|
|
68
66
|
// It is the client's responsibility to handle endpoint disconnection to the provider.
|
|
69
67
|
// If the endpoint dies, the client will force a disconnection through the core.
|
|
@@ -106,7 +104,7 @@ class Channel extends base_1.EmitterBase {
|
|
|
106
104
|
throw new Error('Please provide a channelName to create a channel');
|
|
107
105
|
}
|
|
108
106
|
const { payload: { data: providerIdentity } } = await this.wire.sendAction('create-channel', { channelName });
|
|
109
|
-
const channel = __classPrivateFieldGet(this,
|
|
107
|
+
const channel = __classPrivateFieldGet(this, _Channel_connectionManager, "f").createProvider(options, providerIdentity);
|
|
110
108
|
this.on('client-disconnected', (eventPayload) => {
|
|
111
109
|
if (eventPayload.channelName === channelName) {
|
|
112
110
|
provider_1.ChannelProvider.handleClientDisconnection(channel, eventPayload);
|
|
@@ -116,4 +114,4 @@ class Channel extends base_1.EmitterBase {
|
|
|
116
114
|
}
|
|
117
115
|
}
|
|
118
116
|
exports.Channel = Channel;
|
|
119
|
-
|
|
117
|
+
_Channel_connectionManager = new WeakMap();
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver,
|
|
3
|
-
if (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return value;
|
|
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;
|
|
8
7
|
};
|
|
9
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver,
|
|
10
|
-
if (!
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return privateMap.get(receiver);
|
|
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);
|
|
14
12
|
};
|
|
15
|
-
var
|
|
13
|
+
var _ClassicStrategy_wire, _ClassicStrategy_endpointIdentityMap;
|
|
16
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
15
|
exports.ClassicInfo = exports.ClassicStrategy = void 0;
|
|
18
16
|
/*
|
|
@@ -24,12 +22,12 @@ class ClassicStrategy {
|
|
|
24
22
|
this.messageReceiver = messageReceiver;
|
|
25
23
|
this.endpointId = endpointId;
|
|
26
24
|
this.providerIdentity = providerIdentity;
|
|
27
|
-
|
|
25
|
+
_ClassicStrategy_wire.set(this, void 0);
|
|
28
26
|
// Store full endpointIdentity by endpointId of all known endpoints for this strategy instance.
|
|
29
27
|
// (clients will only have 1: the provider, the provider will have all clients)
|
|
30
|
-
|
|
28
|
+
_ClassicStrategy_endpointIdentityMap.set(this, new Map());
|
|
31
29
|
this.send = async (endpointId, action, payload) => {
|
|
32
|
-
const to = __classPrivateFieldGet(this,
|
|
30
|
+
const to = __classPrivateFieldGet(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
|
|
33
31
|
if (!to) {
|
|
34
32
|
throw new Error(`Could not locate routing info for endpoint ${endpointId}`);
|
|
35
33
|
}
|
|
@@ -40,7 +38,8 @@ class ClassicStrategy {
|
|
|
40
38
|
delete cleanId.endpointId;
|
|
41
39
|
}
|
|
42
40
|
delete cleanId.isLocalEndpointId;
|
|
43
|
-
const raw = await __classPrivateFieldGet(this,
|
|
41
|
+
const raw = await __classPrivateFieldGet(this, _ClassicStrategy_wire, "f")
|
|
42
|
+
.sendAction('send-channel-message', {
|
|
44
43
|
...cleanId,
|
|
45
44
|
providerIdentity: this.providerIdentity,
|
|
46
45
|
action,
|
|
@@ -53,9 +52,9 @@ class ClassicStrategy {
|
|
|
53
52
|
};
|
|
54
53
|
this.close = async () => {
|
|
55
54
|
this.messageReceiver.removeEndpoint(this.providerIdentity.channelId, this.endpointId);
|
|
56
|
-
__classPrivateFieldSet(this,
|
|
55
|
+
__classPrivateFieldSet(this, _ClassicStrategy_endpointIdentityMap, new Map(), "f");
|
|
57
56
|
};
|
|
58
|
-
__classPrivateFieldSet(this,
|
|
57
|
+
__classPrivateFieldSet(this, _ClassicStrategy_wire, wire, "f");
|
|
59
58
|
}
|
|
60
59
|
onEndpointDisconnect(endpointId, listener) {
|
|
61
60
|
// Never fires for 'classic'.
|
|
@@ -64,13 +63,13 @@ class ClassicStrategy {
|
|
|
64
63
|
this.messageReceiver.addEndpoint(listener, this.providerIdentity.channelId, this.endpointId);
|
|
65
64
|
}
|
|
66
65
|
async closeEndpoint(endpointId) {
|
|
67
|
-
__classPrivateFieldGet(this,
|
|
66
|
+
__classPrivateFieldGet(this, _ClassicStrategy_endpointIdentityMap, "f").delete(endpointId);
|
|
68
67
|
}
|
|
69
68
|
isEndpointConnected(endpointId) {
|
|
70
|
-
return __classPrivateFieldGet(this,
|
|
69
|
+
return __classPrivateFieldGet(this, _ClassicStrategy_endpointIdentityMap, "f").has(endpointId);
|
|
71
70
|
}
|
|
72
71
|
addEndpoint(endpointId, payload) {
|
|
73
|
-
__classPrivateFieldGet(this,
|
|
72
|
+
__classPrivateFieldGet(this, _ClassicStrategy_endpointIdentityMap, "f").set(endpointId, payload.endpointIdentity);
|
|
74
73
|
}
|
|
75
74
|
isValidEndpointPayload(payload) {
|
|
76
75
|
var _a, _b;
|
|
@@ -79,6 +78,6 @@ class ClassicStrategy {
|
|
|
79
78
|
}
|
|
80
79
|
}
|
|
81
80
|
exports.ClassicStrategy = ClassicStrategy;
|
|
82
|
-
|
|
81
|
+
_ClassicStrategy_wire = new WeakMap(), _ClassicStrategy_endpointIdentityMap = new WeakMap();
|
|
83
82
|
// Arbitrarily starting at 5 to leave the door open to backfilling pre endpointId etc.
|
|
84
83
|
exports.ClassicInfo = { version: 5, minimumVersion: 0, type: 'classic' };
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver,
|
|
4
|
-
if (!
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return privateMap.get(receiver);
|
|
3
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
5
|
+
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");
|
|
6
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
8
7
|
};
|
|
9
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver,
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return value;
|
|
8
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
9
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
10
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
11
|
+
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");
|
|
12
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
15
13
|
};
|
|
16
|
-
var
|
|
14
|
+
var _RTCEndpoint_processAction, _RTCEndpoint_disconnectListener;
|
|
17
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
16
|
exports.RTCEndpoint = void 0;
|
|
19
17
|
const errors_1 = require("../../../../../util/errors");
|
|
@@ -25,14 +23,14 @@ class RTCEndpoint {
|
|
|
25
23
|
this.rtc = rtc;
|
|
26
24
|
this.endpointIdentity = endpointIdentity;
|
|
27
25
|
this.responseMap = new Map();
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
_RTCEndpoint_processAction.set(this, null);
|
|
27
|
+
_RTCEndpoint_disconnectListener.set(this, void 0);
|
|
30
28
|
this.connectionStateChangeHandler = (event) => {
|
|
31
29
|
if (this.rtc.rtcClient.connectionState !== 'connected') {
|
|
32
30
|
this.rtc.rtcClient.removeEventListener('connectionstatechange', this.connectionStateChangeHandler);
|
|
33
31
|
this.close();
|
|
34
|
-
if (__classPrivateFieldGet(this,
|
|
35
|
-
__classPrivateFieldGet(this,
|
|
32
|
+
if (__classPrivateFieldGet(this, _RTCEndpoint_disconnectListener, "f")) {
|
|
33
|
+
__classPrivateFieldGet(this, _RTCEndpoint_disconnectListener, "f").call(this);
|
|
36
34
|
}
|
|
37
35
|
}
|
|
38
36
|
};
|
|
@@ -71,9 +69,9 @@ class RTCEndpoint {
|
|
|
71
69
|
});
|
|
72
70
|
this.rtc.channels.request.addEventListener('message', async (e) => {
|
|
73
71
|
const { messageId, action, payload } = JSON.parse(e.data);
|
|
74
|
-
if (__classPrivateFieldGet(this,
|
|
72
|
+
if (__classPrivateFieldGet(this, _RTCEndpoint_processAction, "f")) {
|
|
75
73
|
try {
|
|
76
|
-
const res = await __classPrivateFieldGet(this,
|
|
74
|
+
const res = await __classPrivateFieldGet(this, _RTCEndpoint_processAction, "f").call(this, action, payload, endpointIdentity);
|
|
77
75
|
this.rtc.channels.response.send(JSON.stringify({
|
|
78
76
|
messageId,
|
|
79
77
|
payload: res,
|
|
@@ -86,7 +84,7 @@ class RTCEndpoint {
|
|
|
86
84
|
if (this.rtc.channels.response.readyState === 'open') {
|
|
87
85
|
this.rtc.channels.response.send(JSON.stringify({
|
|
88
86
|
messageId,
|
|
89
|
-
error: errors_1.errorToPOJO(error),
|
|
87
|
+
error: (0, errors_1.errorToPOJO)(error),
|
|
90
88
|
success: false
|
|
91
89
|
}));
|
|
92
90
|
}
|
|
@@ -107,29 +105,29 @@ class RTCEndpoint {
|
|
|
107
105
|
datachannel.onclose = (e) => {
|
|
108
106
|
[...this.responseMap.values()].forEach((promise) => promise.reject(new Error('RTCDataChannel closed unexpectedly, this is most commonly caused by message size. Note: RTC Channels have a message size limit of ~255kB.')));
|
|
109
107
|
this.close();
|
|
110
|
-
if (__classPrivateFieldGet(this,
|
|
111
|
-
__classPrivateFieldGet(this,
|
|
108
|
+
if (__classPrivateFieldGet(this, _RTCEndpoint_disconnectListener, "f")) {
|
|
109
|
+
__classPrivateFieldGet(this, _RTCEndpoint_disconnectListener, "f").call(this);
|
|
112
110
|
}
|
|
113
111
|
};
|
|
114
112
|
});
|
|
115
113
|
}
|
|
116
114
|
onDisconnect(listener) {
|
|
117
|
-
if (!__classPrivateFieldGet(this,
|
|
118
|
-
__classPrivateFieldSet(this,
|
|
115
|
+
if (!__classPrivateFieldGet(this, _RTCEndpoint_disconnectListener, "f")) {
|
|
116
|
+
__classPrivateFieldSet(this, _RTCEndpoint_disconnectListener, listener, "f");
|
|
119
117
|
}
|
|
120
118
|
else {
|
|
121
119
|
throw new Error('RTCEndpoint disconnectListener cannot be set twice.');
|
|
122
120
|
}
|
|
123
121
|
}
|
|
124
122
|
receive(listener) {
|
|
125
|
-
if (__classPrivateFieldGet(this,
|
|
123
|
+
if (__classPrivateFieldGet(this, _RTCEndpoint_processAction, "f")) {
|
|
126
124
|
throw new Error('You have already set a listener for this RTC Endpoint.');
|
|
127
125
|
}
|
|
128
|
-
__classPrivateFieldSet(this,
|
|
126
|
+
__classPrivateFieldSet(this, _RTCEndpoint_processAction, listener, "f");
|
|
129
127
|
}
|
|
130
128
|
get connected() {
|
|
131
129
|
return this.rtc.rtcClient.connectionState === 'connected';
|
|
132
130
|
}
|
|
133
131
|
}
|
|
134
132
|
exports.RTCEndpoint = RTCEndpoint;
|
|
135
|
-
|
|
133
|
+
_RTCEndpoint_processAction = new WeakMap(), _RTCEndpoint_disconnectListener = new WeakMap();
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver,
|
|
3
|
-
if (!
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return privateMap.get(receiver);
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
7
6
|
};
|
|
8
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver,
|
|
9
|
-
if (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return value;
|
|
7
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
11
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
14
12
|
};
|
|
15
|
-
var
|
|
13
|
+
var _RTCStrategy_processAction, _RTCStrategy_rtcEndpointMap, _RTCStrategy_connected;
|
|
16
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
15
|
exports.RTCInfo = exports.RTCStrategy = void 0;
|
|
18
16
|
const endpoint_1 = require("./endpoint");
|
|
@@ -21,56 +19,56 @@ This is used to abstract out rtc messaging from the channels implementation usin
|
|
|
21
19
|
*/
|
|
22
20
|
class RTCStrategy {
|
|
23
21
|
constructor() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
_RTCStrategy_processAction.set(this, null);
|
|
23
|
+
_RTCStrategy_rtcEndpointMap.set(this, new Map());
|
|
24
|
+
_RTCStrategy_connected.set(this, true);
|
|
27
25
|
this.send = async (endpointId, action, payload) => {
|
|
28
26
|
return this.getEndpointById(endpointId).send(action, payload);
|
|
29
27
|
};
|
|
30
28
|
this.close = async () => {
|
|
31
|
-
if (__classPrivateFieldGet(this,
|
|
32
|
-
__classPrivateFieldGet(this,
|
|
33
|
-
__classPrivateFieldSet(this,
|
|
29
|
+
if (__classPrivateFieldGet(this, _RTCStrategy_connected, "f")) {
|
|
30
|
+
__classPrivateFieldGet(this, _RTCStrategy_rtcEndpointMap, "f").forEach((rtcEndpoint) => rtcEndpoint.close());
|
|
31
|
+
__classPrivateFieldSet(this, _RTCStrategy_rtcEndpointMap, new Map(), "f");
|
|
34
32
|
}
|
|
35
|
-
__classPrivateFieldSet(this,
|
|
33
|
+
__classPrivateFieldSet(this, _RTCStrategy_connected, false, "f");
|
|
36
34
|
};
|
|
37
35
|
}
|
|
38
36
|
onEndpointDisconnect(endpointId, listener) {
|
|
39
37
|
this.getEndpointById(endpointId).onDisconnect(listener);
|
|
40
38
|
}
|
|
41
39
|
receive(listener) {
|
|
42
|
-
if (__classPrivateFieldGet(this,
|
|
40
|
+
if (__classPrivateFieldGet(this, _RTCStrategy_processAction, "f")) {
|
|
43
41
|
throw new Error('You have already set a listener for this RTC Strategy');
|
|
44
42
|
}
|
|
45
|
-
__classPrivateFieldSet(this,
|
|
46
|
-
__classPrivateFieldGet(this,
|
|
43
|
+
__classPrivateFieldSet(this, _RTCStrategy_processAction, listener, "f");
|
|
44
|
+
__classPrivateFieldGet(this, _RTCStrategy_rtcEndpointMap, "f").forEach((rtcEndpoint) => rtcEndpoint.receive(__classPrivateFieldGet(this, _RTCStrategy_processAction, "f")));
|
|
47
45
|
}
|
|
48
46
|
getEndpointById(endpointId) {
|
|
49
|
-
const endpoint = __classPrivateFieldGet(this,
|
|
47
|
+
const endpoint = __classPrivateFieldGet(this, _RTCStrategy_rtcEndpointMap, "f").get(endpointId);
|
|
50
48
|
if (!endpoint) {
|
|
51
49
|
throw new Error(`Client with endpoint id ${endpointId} is not connected`);
|
|
52
50
|
}
|
|
53
51
|
return endpoint;
|
|
54
52
|
}
|
|
55
53
|
get connected() {
|
|
56
|
-
return __classPrivateFieldGet(this,
|
|
54
|
+
return __classPrivateFieldGet(this, _RTCStrategy_connected, "f");
|
|
57
55
|
}
|
|
58
56
|
isEndpointConnected(endpointId) {
|
|
59
|
-
return __classPrivateFieldGet(this,
|
|
57
|
+
return __classPrivateFieldGet(this, _RTCStrategy_rtcEndpointMap, "f").has(endpointId);
|
|
60
58
|
}
|
|
61
59
|
addEndpoint(endpointId, payload) {
|
|
62
|
-
if (!__classPrivateFieldGet(this,
|
|
60
|
+
if (!__classPrivateFieldGet(this, _RTCStrategy_connected, "f")) {
|
|
63
61
|
console.warn('Adding endpoint to disconnected RTC Strategy');
|
|
64
62
|
return;
|
|
65
63
|
}
|
|
66
64
|
const clientStrat = new endpoint_1.RTCEndpoint(payload.rtc, payload.endpointIdentity);
|
|
67
|
-
if (__classPrivateFieldGet(this,
|
|
68
|
-
clientStrat.receive(__classPrivateFieldGet(this,
|
|
65
|
+
if (__classPrivateFieldGet(this, _RTCStrategy_processAction, "f")) {
|
|
66
|
+
clientStrat.receive(__classPrivateFieldGet(this, _RTCStrategy_processAction, "f"));
|
|
69
67
|
}
|
|
70
|
-
__classPrivateFieldGet(this,
|
|
68
|
+
__classPrivateFieldGet(this, _RTCStrategy_rtcEndpointMap, "f").set(endpointId, clientStrat);
|
|
71
69
|
}
|
|
72
70
|
async closeEndpoint(endpointId) {
|
|
73
|
-
__classPrivateFieldGet(this,
|
|
71
|
+
__classPrivateFieldGet(this, _RTCStrategy_rtcEndpointMap, "f").delete(endpointId);
|
|
74
72
|
}
|
|
75
73
|
isValidEndpointPayload(payload) {
|
|
76
74
|
const isObject = (x) => {
|
|
@@ -83,5 +81,5 @@ class RTCStrategy {
|
|
|
83
81
|
}
|
|
84
82
|
}
|
|
85
83
|
exports.RTCStrategy = RTCStrategy;
|
|
86
|
-
|
|
84
|
+
_RTCStrategy_processAction = new WeakMap(), _RTCStrategy_rtcEndpointMap = new WeakMap(), _RTCStrategy_connected = new WeakMap();
|
|
87
85
|
exports.RTCInfo = { version: 1, minimumVersion: 0, type: 'rtc' };
|