@openfin/node-adapter 37.80.38 → 37.81.19
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/out/node-adapter-alpha.d.ts +301 -465
- package/out/node-adapter-beta.d.ts +301 -465
- package/out/node-adapter-public.d.ts +301 -465
- package/out/node-adapter.d.ts +309 -473
- package/out/node-adapter.js +2226 -1025
- package/package.json +7 -15
- package/resources/darwin/OpenFinRVM.app/Contents/CodeResources +0 -0
- package/resources/darwin/OpenFinRVM.app/Contents/Helpers/FinLinksHandler.app/Contents/Info.plist +29 -0
- package/resources/darwin/OpenFinRVM.app/Contents/Helpers/FinLinksHandler.app/Contents/MacOS/FinLinksHandler +0 -0
- package/resources/darwin/OpenFinRVM.app/Contents/Helpers/FinLinksHandler.app/Contents/PkgInfo +1 -0
- package/resources/darwin/OpenFinRVM.app/Contents/Helpers/FinLinksHandler.app/Contents/Resources/OpenFinRVM.icns +0 -0
- package/resources/darwin/OpenFinRVM.app/Contents/Helpers/FinLinksHandler.app/Contents/_CodeSignature/CodeResources +128 -0
- package/resources/darwin/OpenFinRVM.app/Contents/Info.plist +29 -0
- package/resources/darwin/OpenFinRVM.app/Contents/MacOS/OpenFinRVM +0 -0
- package/resources/darwin/OpenFinRVM.app/Contents/PkgInfo +1 -0
- package/resources/darwin/OpenFinRVM.app/Contents/Resources/OpenFinRVM.icns +0 -0
- package/resources/darwin/OpenFinRVM.app/Contents/_CodeSignature/CodeResources +137 -0
- package/resources/win/OpenFinRVM.exe +0 -0
package/out/node-adapter.js
CHANGED
@@ -5,11 +5,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
var require$$0 = require('events');
|
6
6
|
var require$$3 = require('lodash');
|
7
7
|
var require$$0$2 = require('fs');
|
8
|
-
var require$$1$
|
8
|
+
var require$$1$3 = require('crypto');
|
9
9
|
var require$$2$1 = require('ws');
|
10
|
-
var require$$1 = require('net');
|
11
|
-
var require$$
|
12
|
-
var require$$
|
10
|
+
var require$$1$2 = require('net');
|
11
|
+
var require$$1$1 = require('os');
|
12
|
+
var require$$1 = require('path');
|
13
13
|
var require$$4 = require('timers');
|
14
14
|
var require$$2 = require('child_process');
|
15
15
|
var require$$0$1 = require('node:url');
|
@@ -72,13 +72,13 @@ async function promiseMapSerial(arr, func) {
|
|
72
72
|
}
|
73
73
|
promises.promiseMapSerial = promiseMapSerial;
|
74
74
|
|
75
|
-
var __classPrivateFieldSet$
|
75
|
+
var __classPrivateFieldSet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
76
76
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
77
77
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
78
78
|
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");
|
79
79
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
80
80
|
};
|
81
|
-
var __classPrivateFieldGet$
|
81
|
+
var __classPrivateFieldGet$e = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
82
82
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
83
83
|
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");
|
84
84
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
@@ -165,8 +165,8 @@ class EmitterBase extends Base {
|
|
165
165
|
this.emit = (eventType, payload, ...args) => {
|
166
166
|
return this.hasEmitter() ? this.getOrCreateEmitter().emit(eventType, payload, ...args) : false;
|
167
167
|
};
|
168
|
-
this.hasEmitter = () => this.wire.eventAggregator.has(__classPrivateFieldGet$
|
169
|
-
this.getOrCreateEmitter = () => this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$
|
168
|
+
this.hasEmitter = () => this.wire.eventAggregator.has(__classPrivateFieldGet$e(this, _EmitterBase_emitterAccessor, "f"));
|
169
|
+
this.getOrCreateEmitter = () => this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet$e(this, _EmitterBase_emitterAccessor, "f"));
|
170
170
|
this.listeners = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(type) : [];
|
171
171
|
this.listenerCount = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listenerCount(type) : 0;
|
172
172
|
this.registerEventListener = async (eventType, options = {}, applySubscription, undoSubscription) => {
|
@@ -204,7 +204,7 @@ class EmitterBase extends Base {
|
|
204
204
|
// This will only be reached if unsubscribe from event that does not exist but do not want to error here
|
205
205
|
return Promise.resolve();
|
206
206
|
};
|
207
|
-
__classPrivateFieldSet$
|
207
|
+
__classPrivateFieldSet$c(this, _EmitterBase_emitterAccessor, [topic, ...additionalAccessors], "f");
|
208
208
|
this.listeners = (event) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(event) : [];
|
209
209
|
}
|
210
210
|
/**
|
@@ -322,7 +322,7 @@ class EmitterBase extends Base {
|
|
322
322
|
}
|
323
323
|
deleteEmitterIfNothingRegistered(emitter) {
|
324
324
|
if (emitter.eventNames().length === 0) {
|
325
|
-
this.wire.eventAggregator.delete(__classPrivateFieldGet$
|
325
|
+
this.wire.eventAggregator.delete(__classPrivateFieldGet$e(this, _EmitterBase_emitterAccessor, "f"));
|
326
326
|
}
|
327
327
|
}
|
328
328
|
}
|
@@ -922,13 +922,13 @@ const createRelayedDispatch = (client, target, relayId, relayErrorMsg) => async
|
|
922
922
|
};
|
923
923
|
channelApiRelay.createRelayedDispatch = createRelayedDispatch;
|
924
924
|
|
925
|
-
var __classPrivateFieldSet$
|
925
|
+
var __classPrivateFieldSet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
926
926
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
927
927
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
928
928
|
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");
|
929
929
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
930
930
|
};
|
931
|
-
var __classPrivateFieldGet$
|
931
|
+
var __classPrivateFieldGet$d = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
932
932
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
933
933
|
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");
|
934
934
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
@@ -982,7 +982,7 @@ class LayoutNode {
|
|
982
982
|
* console.log(`The parent ColumnOrRow is root: ${parentIsRoot}`);
|
983
983
|
* ```
|
984
984
|
*/
|
985
|
-
this.isRoot = () => __classPrivateFieldGet$
|
985
|
+
this.isRoot = () => __classPrivateFieldGet$d(this, _LayoutNode_client, "f").isRoot(this.entityId);
|
986
986
|
/**
|
987
987
|
* Checks if the TabStack or ColumnOrRow exists
|
988
988
|
*
|
@@ -1002,7 +1002,7 @@ class LayoutNode {
|
|
1002
1002
|
* console.log(`The entity exists: ${exists}`);
|
1003
1003
|
* ```
|
1004
1004
|
*/
|
1005
|
-
this.exists = () => __classPrivateFieldGet$
|
1005
|
+
this.exists = () => __classPrivateFieldGet$d(this, _LayoutNode_client, "f").exists(this.entityId);
|
1006
1006
|
/**
|
1007
1007
|
* Retrieves the parent of the TabStack or ColumnOrRow
|
1008
1008
|
*
|
@@ -1023,11 +1023,11 @@ class LayoutNode {
|
|
1023
1023
|
* ```
|
1024
1024
|
*/
|
1025
1025
|
this.getParent = async () => {
|
1026
|
-
const parent = await __classPrivateFieldGet$
|
1026
|
+
const parent = await __classPrivateFieldGet$d(this, _LayoutNode_client, "f").getParent(this.entityId);
|
1027
1027
|
if (!parent) {
|
1028
1028
|
return undefined;
|
1029
1029
|
}
|
1030
|
-
return LayoutNode.getEntity(parent, __classPrivateFieldGet$
|
1030
|
+
return LayoutNode.getEntity(parent, __classPrivateFieldGet$d(this, _LayoutNode_client, "f"));
|
1031
1031
|
};
|
1032
1032
|
/**
|
1033
1033
|
* Creates a new TabStack adjacent to the given TabStack or ColumnOrRow. Inputs can be new views to create, or existing views.
|
@@ -1078,8 +1078,8 @@ class LayoutNode {
|
|
1078
1078
|
* @experimental
|
1079
1079
|
*/
|
1080
1080
|
this.createAdjacentStack = async (views, options) => {
|
1081
|
-
const entityId = await __classPrivateFieldGet$
|
1082
|
-
return LayoutNode.getEntity({ entityId, type: 'stack' }, __classPrivateFieldGet$
|
1081
|
+
const entityId = await __classPrivateFieldGet$d(this, _LayoutNode_client, "f").createAdjacentStack(this.entityId, views, options);
|
1082
|
+
return LayoutNode.getEntity({ entityId, type: 'stack' }, __classPrivateFieldGet$d(this, _LayoutNode_client, "f"));
|
1083
1083
|
};
|
1084
1084
|
/**
|
1085
1085
|
* Retrieves the adjacent TabStacks of the given TabStack or ColumnOrRow.
|
@@ -1107,16 +1107,16 @@ class LayoutNode {
|
|
1107
1107
|
* @experimental
|
1108
1108
|
*/
|
1109
1109
|
this.getAdjacentStacks = async (edge) => {
|
1110
|
-
const adjacentStacks = await __classPrivateFieldGet$
|
1110
|
+
const adjacentStacks = await __classPrivateFieldGet$d(this, _LayoutNode_client, "f").getAdjacentStacks({
|
1111
1111
|
targetId: this.entityId,
|
1112
1112
|
edge
|
1113
1113
|
});
|
1114
1114
|
return adjacentStacks.map((stack) => LayoutNode.getEntity({
|
1115
1115
|
type: 'stack',
|
1116
1116
|
entityId: stack.entityId
|
1117
|
-
}, __classPrivateFieldGet$
|
1117
|
+
}, __classPrivateFieldGet$d(this, _LayoutNode_client, "f")));
|
1118
1118
|
};
|
1119
|
-
__classPrivateFieldSet$
|
1119
|
+
__classPrivateFieldSet$b(this, _LayoutNode_client, client, "f");
|
1120
1120
|
this.entityId = entityId;
|
1121
1121
|
}
|
1122
1122
|
}
|
@@ -1189,7 +1189,7 @@ class TabStack extends LayoutNode {
|
|
1189
1189
|
* ```
|
1190
1190
|
* @experimental
|
1191
1191
|
*/
|
1192
|
-
this.getViews = () => __classPrivateFieldGet$
|
1192
|
+
this.getViews = () => __classPrivateFieldGet$d(this, _TabStack_client, "f").getStackViews(this.entityId);
|
1193
1193
|
/**
|
1194
1194
|
* Adds or creates a view in this {@link TabStack}.
|
1195
1195
|
*
|
@@ -1219,7 +1219,7 @@ class TabStack extends LayoutNode {
|
|
1219
1219
|
* ```
|
1220
1220
|
* @experimental
|
1221
1221
|
*/
|
1222
|
-
this.addView = async (view, options = { index: 0 }) => __classPrivateFieldGet$
|
1222
|
+
this.addView = async (view, options = { index: 0 }) => __classPrivateFieldGet$d(this, _TabStack_client, "f").addViewToStack(this.entityId, view, options);
|
1223
1223
|
/**
|
1224
1224
|
* Removes a view from this {@link TabStack}.
|
1225
1225
|
*
|
@@ -1249,7 +1249,7 @@ class TabStack extends LayoutNode {
|
|
1249
1249
|
* ```
|
1250
1250
|
*/
|
1251
1251
|
this.removeView = async (view) => {
|
1252
|
-
await __classPrivateFieldGet$
|
1252
|
+
await __classPrivateFieldGet$d(this, _TabStack_client, "f").removeViewFromStack(this.entityId, view);
|
1253
1253
|
};
|
1254
1254
|
/**
|
1255
1255
|
* Sets the active view of the {@link TabStack} without focusing it.
|
@@ -1273,9 +1273,9 @@ class TabStack extends LayoutNode {
|
|
1273
1273
|
* @experimental
|
1274
1274
|
*/
|
1275
1275
|
this.setActiveView = async (view) => {
|
1276
|
-
await __classPrivateFieldGet$
|
1276
|
+
await __classPrivateFieldGet$d(this, _TabStack_client, "f").setStackActiveView(this.entityId, view);
|
1277
1277
|
};
|
1278
|
-
__classPrivateFieldSet$
|
1278
|
+
__classPrivateFieldSet$b(this, _TabStack_client, client, "f");
|
1279
1279
|
}
|
1280
1280
|
}
|
1281
1281
|
layoutEntities.TabStack = TabStack;
|
@@ -1314,10 +1314,10 @@ class ColumnOrRow extends LayoutNode {
|
|
1314
1314
|
* ```
|
1315
1315
|
*/
|
1316
1316
|
this.getContent = async () => {
|
1317
|
-
const contentItemEntities = await __classPrivateFieldGet$
|
1318
|
-
return contentItemEntities.map((entity) => LayoutNode.getEntity(entity, __classPrivateFieldGet$
|
1317
|
+
const contentItemEntities = await __classPrivateFieldGet$d(this, _ColumnOrRow_client, "f").getContent(this.entityId);
|
1318
|
+
return contentItemEntities.map((entity) => LayoutNode.getEntity(entity, __classPrivateFieldGet$d(this, _ColumnOrRow_client, "f")));
|
1319
1319
|
};
|
1320
|
-
__classPrivateFieldSet$
|
1320
|
+
__classPrivateFieldSet$b(this, _ColumnOrRow_client, client, "f");
|
1321
1321
|
this.type = type;
|
1322
1322
|
}
|
1323
1323
|
}
|
@@ -1336,8 +1336,8 @@ var main = {};
|
|
1336
1336
|
|
1337
1337
|
Object.defineProperty(main, "__esModule", { value: true });
|
1338
1338
|
main.WebContents = void 0;
|
1339
|
-
const base_1$
|
1340
|
-
class WebContents extends base_1$
|
1339
|
+
const base_1$j = base$1;
|
1340
|
+
class WebContents extends base_1$j.EmitterBase {
|
1341
1341
|
/**
|
1342
1342
|
* @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
|
1343
1343
|
* @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
|
@@ -4138,6 +4138,37 @@ function requireApplication () {
|
|
4138
4138
|
return application$1;
|
4139
4139
|
}
|
4140
4140
|
|
4141
|
+
var promisifySubscription$1 = {};
|
4142
|
+
|
4143
|
+
Object.defineProperty(promisifySubscription$1, "__esModule", { value: true });
|
4144
|
+
promisifySubscription$1.promisifySubscription = void 0;
|
4145
|
+
const promisifySubscription = async (emitter, eventName, predicate = () => true, timeout) => {
|
4146
|
+
let resolve;
|
4147
|
+
let reject;
|
4148
|
+
let timer;
|
4149
|
+
const valuePromise = new Promise((y, n) => {
|
4150
|
+
resolve = y;
|
4151
|
+
reject = n;
|
4152
|
+
});
|
4153
|
+
const listener = (e) => {
|
4154
|
+
if (predicate(e)) {
|
4155
|
+
clearTimeout(timer);
|
4156
|
+
resolve(e);
|
4157
|
+
}
|
4158
|
+
};
|
4159
|
+
await emitter.on(eventName, listener);
|
4160
|
+
if (timeout) {
|
4161
|
+
timer = setTimeout(() => reject(new Error('event timed out')), timeout);
|
4162
|
+
}
|
4163
|
+
valuePromise.finally(() => {
|
4164
|
+
emitter.removeListener(eventName, listener).catch(() => null);
|
4165
|
+
});
|
4166
|
+
return {
|
4167
|
+
getValue: () => valuePromise
|
4168
|
+
};
|
4169
|
+
};
|
4170
|
+
promisifySubscription$1.promisifySubscription = promisifySubscription;
|
4171
|
+
|
4141
4172
|
var hasRequiredInstance;
|
4142
4173
|
|
4143
4174
|
function requireInstance () {
|
@@ -4153,6 +4184,7 @@ function requireInstance () {
|
|
4153
4184
|
const main_1 = main;
|
4154
4185
|
const view_1 = requireView();
|
4155
4186
|
const warnings_1 = warnings;
|
4187
|
+
const promisifySubscription_1 = promisifySubscription$1;
|
4156
4188
|
/**
|
4157
4189
|
* A basic window that wraps a native HTML window. Provides more fine-grained
|
4158
4190
|
* control over the window state such as the ability to minimize, maximize, restore, etc.
|
@@ -4168,79 +4200,60 @@ function requireInstance () {
|
|
4168
4200
|
constructor(wire, identity) {
|
4169
4201
|
super(wire, identity, 'window');
|
4170
4202
|
}
|
4171
|
-
|
4172
|
-
* create a new window
|
4173
|
-
* @internal
|
4174
|
-
*/
|
4175
|
-
createWindow(options) {
|
4203
|
+
async createWindow(options) {
|
4176
4204
|
this.wire.sendAction('window-create-window', this.identity).catch((e) => {
|
4177
4205
|
// we do not want to expose this error, just continue if this analytics-only call fails
|
4178
4206
|
});
|
4179
|
-
|
4180
|
-
|
4181
|
-
|
4182
|
-
|
4183
|
-
|
4184
|
-
|
4185
|
-
|
4186
|
-
|
4187
|
-
|
4188
|
-
|
4189
|
-
|
4190
|
-
|
4191
|
-
|
4192
|
-
|
4193
|
-
|
4194
|
-
|
4195
|
-
|
4196
|
-
|
4197
|
-
|
4198
|
-
|
4199
|
-
|
4200
|
-
|
4201
|
-
|
4202
|
-
|
4203
|
-
|
4204
|
-
|
4205
|
-
|
4206
|
-
|
4207
|
-
|
4208
|
-
|
4209
|
-
|
4210
|
-
|
4211
|
-
|
4212
|
-
|
4213
|
-
|
4214
|
-
|
4215
|
-
|
4216
|
-
|
4217
|
-
|
4218
|
-
|
4219
|
-
|
4220
|
-
|
4221
|
-
|
4222
|
-
|
4223
|
-
|
4224
|
-
|
4225
|
-
|
4226
|
-
|
4227
|
-
|
4228
|
-
|
4229
|
-
try {
|
4230
|
-
// this is to enforce a 5.0 contract that the child's main function
|
4231
|
-
// will not fire before the parent's success callback on creation.
|
4232
|
-
// if the child window is not accessible (CORS) this contract does
|
4233
|
-
// not hold.
|
4234
|
-
const webWindow = this.getWebWindow();
|
4235
|
-
webWindow.fin.__internal_.openerSuccessCBCalled();
|
4236
|
-
}
|
4237
|
-
catch (e) {
|
4238
|
-
// common for main windows, we do not want to expose this error. here just to have a debug target.
|
4239
|
-
// console.error(e);
|
4240
|
-
}
|
4241
|
-
})
|
4242
|
-
.catch(reject);
|
4243
|
-
});
|
4207
|
+
const CONSTRUCTOR_CB_TOPIC = 'fire-constructor-callback';
|
4208
|
+
const responseSubscription = await (0, promisifySubscription_1.promisifySubscription)(this, CONSTRUCTOR_CB_TOPIC);
|
4209
|
+
// set defaults:
|
4210
|
+
if (options.waitForPageLoad === undefined) {
|
4211
|
+
options.waitForPageLoad = false;
|
4212
|
+
}
|
4213
|
+
if (options.autoShow === undefined) {
|
4214
|
+
options.autoShow = true;
|
4215
|
+
}
|
4216
|
+
(0, warnings_1.handleDeprecatedWarnings)(options);
|
4217
|
+
const windowCreation = this.wire.environment.createChildContent({ entityType: 'window', options });
|
4218
|
+
const [response] = await Promise.all([responseSubscription.getValue(), windowCreation]);
|
4219
|
+
let cbPayload;
|
4220
|
+
const { success } = response;
|
4221
|
+
const responseData = response.data;
|
4222
|
+
const { message } = responseData;
|
4223
|
+
if (success) {
|
4224
|
+
cbPayload = {
|
4225
|
+
httpResponseCode: responseData.httpResponseCode,
|
4226
|
+
apiInjected: responseData.apiInjected
|
4227
|
+
};
|
4228
|
+
}
|
4229
|
+
else {
|
4230
|
+
cbPayload = {
|
4231
|
+
message: responseData.message,
|
4232
|
+
networkErrorCode: responseData.networkErrorCode,
|
4233
|
+
stack: responseData.stack
|
4234
|
+
};
|
4235
|
+
}
|
4236
|
+
const pageResolve = {
|
4237
|
+
message,
|
4238
|
+
cbPayload,
|
4239
|
+
success
|
4240
|
+
};
|
4241
|
+
try {
|
4242
|
+
// this is to enforce a 5.0 contract that the child's main function
|
4243
|
+
// will not fire before the parent's success callback on creation.
|
4244
|
+
// if the child window is not accessible (CORS) this contract does
|
4245
|
+
// not hold.
|
4246
|
+
const webWindow = this.getWebWindow();
|
4247
|
+
webWindow.fin.__internal_.openerSuccessCBCalled();
|
4248
|
+
}
|
4249
|
+
catch (e) {
|
4250
|
+
// common for main windows, we do not want to expose this error. here just to have a debug target.
|
4251
|
+
// console.error(e);
|
4252
|
+
}
|
4253
|
+
if (pageResolve.success) {
|
4254
|
+
return this;
|
4255
|
+
}
|
4256
|
+
return Promise.reject(pageResolve);
|
4244
4257
|
}
|
4245
4258
|
/**
|
4246
4259
|
* Retrieves an array of frame info objects representing the main frame and any
|
@@ -5619,7 +5632,7 @@ function requireWindow () {
|
|
5619
5632
|
*/
|
5620
5633
|
Object.defineProperty(system$1, "__esModule", { value: true });
|
5621
5634
|
system$1.System = void 0;
|
5622
|
-
const base_1$
|
5635
|
+
const base_1$i = base$1;
|
5623
5636
|
const transport_errors_1$2 = transportErrors;
|
5624
5637
|
const window_1 = requireWindow();
|
5625
5638
|
const events_1$6 = require$$0;
|
@@ -5629,7 +5642,7 @@ const events_1$6 = require$$0;
|
|
5629
5642
|
* clearing the cache and exiting the runtime as well as listen to {@link OpenFin.SystemEvents system events}.
|
5630
5643
|
*
|
5631
5644
|
*/
|
5632
|
-
class System extends base_1$
|
5645
|
+
class System extends base_1$i.EmitterBase {
|
5633
5646
|
/**
|
5634
5647
|
* @internal
|
5635
5648
|
*/
|
@@ -7535,9 +7548,10 @@ class ProtectedItems {
|
|
7535
7548
|
/**
|
7536
7549
|
* @internal
|
7537
7550
|
*/
|
7538
|
-
|
7551
|
+
// eslint-disable-next-line no-useless-constructor
|
7552
|
+
constructor(providerIdentity, close) {
|
7539
7553
|
this.providerIdentity = providerIdentity;
|
7540
|
-
this.
|
7554
|
+
this.close = close;
|
7541
7555
|
}
|
7542
7556
|
}
|
7543
7557
|
channel.ProtectedItems = ProtectedItems;
|
@@ -7859,12 +7873,12 @@ class ChannelBase {
|
|
7859
7873
|
}
|
7860
7874
|
channel.ChannelBase = ChannelBase;
|
7861
7875
|
|
7862
|
-
var __classPrivateFieldGet$
|
7876
|
+
var __classPrivateFieldGet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
7863
7877
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
7864
7878
|
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");
|
7865
7879
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
7866
7880
|
};
|
7867
|
-
var __classPrivateFieldSet$
|
7881
|
+
var __classPrivateFieldSet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
7868
7882
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
7869
7883
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
7870
7884
|
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");
|
@@ -7906,7 +7920,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
7906
7920
|
static closeChannelByEndpointId(id) {
|
7907
7921
|
const channel = channelClientsByEndpointId.get(id);
|
7908
7922
|
if (channel) {
|
7909
|
-
__classPrivateFieldGet$
|
7923
|
+
__classPrivateFieldGet$c(channel, _ChannelClient_close, "f").call(channel);
|
7910
7924
|
}
|
7911
7925
|
}
|
7912
7926
|
/**
|
@@ -7917,14 +7931,14 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
7917
7931
|
for (const channelClient of channelClientsByEndpointId.values()) {
|
7918
7932
|
if (channelClient.providerIdentity.channelId === eventPayload.channelId) {
|
7919
7933
|
channelClient.disconnectListener(eventPayload);
|
7920
|
-
__classPrivateFieldGet$
|
7934
|
+
__classPrivateFieldGet$c(channelClient, _ChannelClient_close, "f").call(channelClient);
|
7921
7935
|
}
|
7922
7936
|
}
|
7923
7937
|
}
|
7924
7938
|
/**
|
7925
7939
|
* @internal
|
7926
7940
|
*/
|
7927
|
-
constructor(routingInfo,
|
7941
|
+
constructor(routingInfo, close, strategy) {
|
7928
7942
|
super();
|
7929
7943
|
_ChannelClient_protectedObj.set(this, void 0);
|
7930
7944
|
_ChannelClient_strategy.set(this, void 0);
|
@@ -7932,12 +7946,12 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
7932
7946
|
this.processAction = (action, payload, senderIdentity) => super.processAction(action, payload, senderIdentity);
|
7933
7947
|
_ChannelClient_close.set(this, () => {
|
7934
7948
|
channelClientsByEndpointId.delete(this.endpointId);
|
7935
|
-
__classPrivateFieldGet$
|
7949
|
+
__classPrivateFieldGet$c(this, _ChannelClient_strategy, "f").close();
|
7936
7950
|
});
|
7937
|
-
__classPrivateFieldSet$
|
7951
|
+
__classPrivateFieldSet$a(this, _ChannelClient_protectedObj, new channel_1$1.ProtectedItems(routingInfo, close), "f");
|
7938
7952
|
this.disconnectListener = () => undefined;
|
7939
7953
|
this.endpointId = routingInfo.endpointId;
|
7940
|
-
__classPrivateFieldSet$
|
7954
|
+
__classPrivateFieldSet$a(this, _ChannelClient_strategy, strategy, "f");
|
7941
7955
|
channelClientsByEndpointId.set(this.endpointId, this);
|
7942
7956
|
strategy.receive(this.processAction);
|
7943
7957
|
}
|
@@ -7945,7 +7959,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
7945
7959
|
* a read-only provider identity
|
7946
7960
|
*/
|
7947
7961
|
get providerIdentity() {
|
7948
|
-
const protectedObj = __classPrivateFieldGet$
|
7962
|
+
const protectedObj = __classPrivateFieldGet$c(this, _ChannelClient_protectedObj, "f");
|
7949
7963
|
return protectedObj.providerIdentity;
|
7950
7964
|
}
|
7951
7965
|
/**
|
@@ -7974,8 +7988,8 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
7974
7988
|
* ```
|
7975
7989
|
*/
|
7976
7990
|
async dispatch(action, payload) {
|
7977
|
-
if (__classPrivateFieldGet$
|
7978
|
-
return __classPrivateFieldGet$
|
7991
|
+
if (__classPrivateFieldGet$c(this, _ChannelClient_strategy, "f").isEndpointConnected(this.providerIdentity.channelId)) {
|
7992
|
+
return __classPrivateFieldGet$c(this, _ChannelClient_strategy, "f").send(this.providerIdentity.channelId, action, payload);
|
7979
7993
|
}
|
7980
7994
|
throw new Error('The client you are trying to dispatch from is disconnected from the target provider.');
|
7981
7995
|
}
|
@@ -8025,16 +8039,23 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
8025
8039
|
*/
|
8026
8040
|
async disconnect() {
|
8027
8041
|
await this.sendDisconnectAction();
|
8028
|
-
__classPrivateFieldGet$
|
8042
|
+
__classPrivateFieldGet$c(this, _ChannelClient_close, "f").call(this);
|
8029
8043
|
}
|
8030
8044
|
async sendDisconnectAction() {
|
8031
|
-
const protectedObj = __classPrivateFieldGet$
|
8032
|
-
|
8033
|
-
|
8045
|
+
const protectedObj = __classPrivateFieldGet$c(this, _ChannelClient_protectedObj, "f");
|
8046
|
+
await protectedObj.close();
|
8047
|
+
}
|
8048
|
+
/**
|
8049
|
+
* @internal
|
8050
|
+
* Writing this as a static to keep code together, but in environments with a wire, this will be DI'd into the protectedObject class as close.
|
8051
|
+
*/
|
8052
|
+
static async wireClose(wire, providerIdentity, endpointId) {
|
8053
|
+
const { channelName, uuid, name } = providerIdentity;
|
8054
|
+
await wire.sendAction('disconnect-from-channel', {
|
8034
8055
|
channelName,
|
8035
8056
|
uuid,
|
8036
8057
|
name,
|
8037
|
-
endpointId
|
8058
|
+
endpointId
|
8038
8059
|
});
|
8039
8060
|
}
|
8040
8061
|
}
|
@@ -8054,13 +8075,13 @@ exhaustive.exhaustiveCheck = exhaustiveCheck;
|
|
8054
8075
|
|
8055
8076
|
var strategy$3 = {};
|
8056
8077
|
|
8057
|
-
var __classPrivateFieldSet$
|
8078
|
+
var __classPrivateFieldSet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
8058
8079
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
8059
8080
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
8060
8081
|
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");
|
8061
8082
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
8062
8083
|
};
|
8063
|
-
var __classPrivateFieldGet$
|
8084
|
+
var __classPrivateFieldGet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
8064
8085
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
8065
8086
|
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");
|
8066
8087
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
@@ -8085,7 +8106,7 @@ class ClassicStrategy {
|
|
8085
8106
|
// connection problems occur
|
8086
8107
|
_ClassicStrategy_pendingMessagesByEndpointId.set(this, new Map);
|
8087
8108
|
this.send = async (endpointId, action, payload) => {
|
8088
|
-
const to = __classPrivateFieldGet$
|
8109
|
+
const to = __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
|
8089
8110
|
if (!to) {
|
8090
8111
|
throw new Error(`Could not locate routing info for endpoint ${endpointId}`);
|
8091
8112
|
}
|
@@ -8097,28 +8118,28 @@ class ClassicStrategy {
|
|
8097
8118
|
}
|
8098
8119
|
delete cleanId.isLocalEndpointId;
|
8099
8120
|
// grab the promise before awaiting it to save in our pending messages map
|
8100
|
-
const p = __classPrivateFieldGet$
|
8121
|
+
const p = __classPrivateFieldGet$b(this, _ClassicStrategy_wire, "f")
|
8101
8122
|
.sendAction('send-channel-message', {
|
8102
8123
|
...cleanId,
|
8103
8124
|
providerIdentity: this.providerIdentity,
|
8104
8125
|
action,
|
8105
8126
|
payload
|
8106
8127
|
});
|
8107
|
-
__classPrivateFieldGet$
|
8128
|
+
__classPrivateFieldGet$b(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.add(p);
|
8108
8129
|
const raw = await p.catch((error) => {
|
8109
8130
|
throw new Error(error.message);
|
8110
8131
|
}).finally(() => {
|
8111
8132
|
// clean up the pending promise
|
8112
|
-
__classPrivateFieldGet$
|
8133
|
+
__classPrivateFieldGet$b(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.delete(p);
|
8113
8134
|
});
|
8114
8135
|
return raw.payload.data.result;
|
8115
8136
|
};
|
8116
8137
|
this.close = async () => {
|
8117
8138
|
this.messageReceiver.removeEndpoint(this.providerIdentity.channelId, this.endpointId);
|
8118
|
-
[...__classPrivateFieldGet$
|
8119
|
-
__classPrivateFieldSet$
|
8139
|
+
[...__classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").keys()].forEach((id) => this.closeEndpoint(id));
|
8140
|
+
__classPrivateFieldSet$9(this, _ClassicStrategy_endpointIdentityMap, new Map(), "f");
|
8120
8141
|
};
|
8121
|
-
__classPrivateFieldSet$
|
8142
|
+
__classPrivateFieldSet$9(this, _ClassicStrategy_wire, wire, "f");
|
8122
8143
|
}
|
8123
8144
|
onEndpointDisconnect(endpointId, listener) {
|
8124
8145
|
// Never fires for 'classic'.
|
@@ -8127,20 +8148,20 @@ class ClassicStrategy {
|
|
8127
8148
|
this.messageReceiver.addEndpoint(listener, this.providerIdentity.channelId, this.endpointId);
|
8128
8149
|
}
|
8129
8150
|
async closeEndpoint(endpointId) {
|
8130
|
-
const id = __classPrivateFieldGet$
|
8131
|
-
__classPrivateFieldGet$
|
8132
|
-
const pendingSet = __classPrivateFieldGet$
|
8151
|
+
const id = __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
|
8152
|
+
__classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").delete(endpointId);
|
8153
|
+
const pendingSet = __classPrivateFieldGet$b(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId);
|
8133
8154
|
pendingSet?.forEach((p) => {
|
8134
8155
|
const errorMsg = `Channel connection with identity uuid: ${id?.uuid} / name: ${id?.name} / endpointId: ${endpointId} no longer connected.`;
|
8135
8156
|
p.cancel(new Error(errorMsg));
|
8136
8157
|
});
|
8137
8158
|
}
|
8138
8159
|
isEndpointConnected(endpointId) {
|
8139
|
-
return __classPrivateFieldGet$
|
8160
|
+
return __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").has(endpointId);
|
8140
8161
|
}
|
8141
8162
|
addEndpoint(endpointId, payload) {
|
8142
|
-
__classPrivateFieldGet$
|
8143
|
-
__classPrivateFieldGet$
|
8163
|
+
__classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").set(endpointId, payload.endpointIdentity);
|
8164
|
+
__classPrivateFieldGet$b(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").set(endpointId, new Set());
|
8144
8165
|
}
|
8145
8166
|
isValidEndpointPayload(payload) {
|
8146
8167
|
return (typeof payload?.endpointIdentity?.endpointId === 'string' ||
|
@@ -8171,12 +8192,12 @@ function errorToPOJO(error) {
|
|
8171
8192
|
}
|
8172
8193
|
errors.errorToPOJO = errorToPOJO;
|
8173
8194
|
|
8174
|
-
var __classPrivateFieldGet$
|
8195
|
+
var __classPrivateFieldGet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
8175
8196
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
8176
8197
|
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");
|
8177
8198
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
8178
8199
|
};
|
8179
|
-
var __classPrivateFieldSet$
|
8200
|
+
var __classPrivateFieldSet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
8180
8201
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
8181
8202
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
8182
8203
|
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");
|
@@ -8211,8 +8232,8 @@ class RTCEndpoint {
|
|
8211
8232
|
if (this.rtc.rtcClient.connectionState !== 'connected') {
|
8212
8233
|
this.rtc.rtcClient.removeEventListener('connectionstatechange', this.connectionStateChangeHandler);
|
8213
8234
|
this.close();
|
8214
|
-
if (__classPrivateFieldGet$
|
8215
|
-
__classPrivateFieldGet$
|
8235
|
+
if (__classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f")) {
|
8236
|
+
__classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f").call(this);
|
8216
8237
|
}
|
8217
8238
|
}
|
8218
8239
|
};
|
@@ -8260,9 +8281,9 @@ class RTCEndpoint {
|
|
8260
8281
|
data = new TextDecoder().decode(e.data);
|
8261
8282
|
}
|
8262
8283
|
const { messageId, action, payload } = JSON.parse(data);
|
8263
|
-
if (__classPrivateFieldGet$
|
8284
|
+
if (__classPrivateFieldGet$a(this, _RTCEndpoint_processAction, "f")) {
|
8264
8285
|
try {
|
8265
|
-
const res = await __classPrivateFieldGet$
|
8286
|
+
const res = await __classPrivateFieldGet$a(this, _RTCEndpoint_processAction, "f").call(this, action, payload, endpointIdentity);
|
8266
8287
|
this.rtc.channels.response.send(JSON.stringify({
|
8267
8288
|
messageId,
|
8268
8289
|
payload: res,
|
@@ -8296,25 +8317,25 @@ class RTCEndpoint {
|
|
8296
8317
|
datachannel.onclose = (e) => {
|
8297
8318
|
[...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.')));
|
8298
8319
|
this.close();
|
8299
|
-
if (__classPrivateFieldGet$
|
8300
|
-
__classPrivateFieldGet$
|
8320
|
+
if (__classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f")) {
|
8321
|
+
__classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f").call(this);
|
8301
8322
|
}
|
8302
8323
|
};
|
8303
8324
|
});
|
8304
8325
|
}
|
8305
8326
|
onDisconnect(listener) {
|
8306
|
-
if (!__classPrivateFieldGet$
|
8307
|
-
__classPrivateFieldSet$
|
8327
|
+
if (!__classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f")) {
|
8328
|
+
__classPrivateFieldSet$8(this, _RTCEndpoint_disconnectListener, listener, "f");
|
8308
8329
|
}
|
8309
8330
|
else {
|
8310
8331
|
throw new Error('RTCEndpoint disconnectListener cannot be set twice.');
|
8311
8332
|
}
|
8312
8333
|
}
|
8313
8334
|
receive(listener) {
|
8314
|
-
if (__classPrivateFieldGet$
|
8335
|
+
if (__classPrivateFieldGet$a(this, _RTCEndpoint_processAction, "f")) {
|
8315
8336
|
throw new Error('You have already set a listener for this RTC Endpoint.');
|
8316
8337
|
}
|
8317
|
-
__classPrivateFieldSet$
|
8338
|
+
__classPrivateFieldSet$8(this, _RTCEndpoint_processAction, listener, "f");
|
8318
8339
|
}
|
8319
8340
|
get connected() {
|
8320
8341
|
return this.rtc.rtcClient.connectionState === 'connected';
|
@@ -8325,12 +8346,12 @@ _RTCEndpoint_processAction = new WeakMap(), _RTCEndpoint_disconnectListener = ne
|
|
8325
8346
|
|
8326
8347
|
var strategy$1 = {};
|
8327
8348
|
|
8328
|
-
var __classPrivateFieldGet$
|
8349
|
+
var __classPrivateFieldGet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
8329
8350
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
8330
8351
|
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");
|
8331
8352
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
8332
8353
|
};
|
8333
|
-
var __classPrivateFieldSet$
|
8354
|
+
var __classPrivateFieldSet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
8334
8355
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
8335
8356
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
8336
8357
|
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");
|
@@ -8351,11 +8372,11 @@ class EndpointStrategy {
|
|
8351
8372
|
return this.getEndpointById(endpointId).send(action, payload);
|
8352
8373
|
};
|
8353
8374
|
this.close = async () => {
|
8354
|
-
if (__classPrivateFieldGet$
|
8355
|
-
__classPrivateFieldGet$
|
8356
|
-
__classPrivateFieldSet$
|
8375
|
+
if (__classPrivateFieldGet$9(this, _EndpointStrategy_connected, "f")) {
|
8376
|
+
__classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.close());
|
8377
|
+
__classPrivateFieldSet$7(this, _EndpointStrategy_endpointMap, new Map(), "f");
|
8357
8378
|
}
|
8358
|
-
__classPrivateFieldSet$
|
8379
|
+
__classPrivateFieldSet$7(this, _EndpointStrategy_connected, false, "f");
|
8359
8380
|
};
|
8360
8381
|
this.isValidEndpointPayload = validateEndpoint;
|
8361
8382
|
}
|
@@ -8363,39 +8384,39 @@ class EndpointStrategy {
|
|
8363
8384
|
this.getEndpointById(endpointId).onDisconnect(listener);
|
8364
8385
|
}
|
8365
8386
|
receive(listener) {
|
8366
|
-
if (__classPrivateFieldGet$
|
8387
|
+
if (__classPrivateFieldGet$9(this, _EndpointStrategy_processAction, "f")) {
|
8367
8388
|
throw new Error(`You have already set a listener for this ${this.StrategyName} Strategy`);
|
8368
8389
|
}
|
8369
|
-
__classPrivateFieldSet$
|
8390
|
+
__classPrivateFieldSet$7(this, _EndpointStrategy_processAction, listener, "f");
|
8370
8391
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
8371
|
-
__classPrivateFieldGet$
|
8392
|
+
__classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.receive(__classPrivateFieldGet$9(this, _EndpointStrategy_processAction, "f")));
|
8372
8393
|
}
|
8373
8394
|
getEndpointById(endpointId) {
|
8374
|
-
const endpoint = __classPrivateFieldGet$
|
8395
|
+
const endpoint = __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").get(endpointId);
|
8375
8396
|
if (!endpoint) {
|
8376
8397
|
throw new Error(`Client with endpoint id ${endpointId} is not connected`);
|
8377
8398
|
}
|
8378
8399
|
return endpoint;
|
8379
8400
|
}
|
8380
8401
|
get connected() {
|
8381
|
-
return __classPrivateFieldGet$
|
8402
|
+
return __classPrivateFieldGet$9(this, _EndpointStrategy_connected, "f");
|
8382
8403
|
}
|
8383
8404
|
isEndpointConnected(endpointId) {
|
8384
|
-
return __classPrivateFieldGet$
|
8405
|
+
return __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").has(endpointId);
|
8385
8406
|
}
|
8386
8407
|
addEndpoint(endpointId, payload) {
|
8387
|
-
if (!__classPrivateFieldGet$
|
8408
|
+
if (!__classPrivateFieldGet$9(this, _EndpointStrategy_connected, "f")) {
|
8388
8409
|
console.warn(`Adding endpoint to disconnected ${this.StrategyName} Strategy`);
|
8389
8410
|
return;
|
8390
8411
|
}
|
8391
8412
|
const clientStrat = new this.EndpointType(payload);
|
8392
|
-
if (__classPrivateFieldGet$
|
8393
|
-
clientStrat.receive(__classPrivateFieldGet$
|
8413
|
+
if (__classPrivateFieldGet$9(this, _EndpointStrategy_processAction, "f")) {
|
8414
|
+
clientStrat.receive(__classPrivateFieldGet$9(this, _EndpointStrategy_processAction, "f"));
|
8394
8415
|
}
|
8395
|
-
__classPrivateFieldGet$
|
8416
|
+
__classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").set(endpointId, clientStrat);
|
8396
8417
|
}
|
8397
8418
|
async closeEndpoint(endpointId) {
|
8398
|
-
__classPrivateFieldGet$
|
8419
|
+
__classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").delete(endpointId);
|
8399
8420
|
}
|
8400
8421
|
}
|
8401
8422
|
strategy$1.EndpointStrategy = EndpointStrategy;
|
@@ -8422,11 +8443,11 @@ var iceManager = {};
|
|
8422
8443
|
|
8423
8444
|
Object.defineProperty(iceManager, "__esModule", { value: true });
|
8424
8445
|
iceManager.RTCICEManager = void 0;
|
8425
|
-
const base_1$
|
8446
|
+
const base_1$h = base$1;
|
8426
8447
|
/*
|
8427
8448
|
Singleton that facilitates Offer and Answer exchange required for establishing RTC connections.
|
8428
8449
|
*/
|
8429
|
-
class RTCICEManager extends base_1$
|
8450
|
+
class RTCICEManager extends base_1$h.EmitterBase {
|
8430
8451
|
constructor(wire) {
|
8431
8452
|
super(wire, 'channel');
|
8432
8453
|
this.ensureChannelOpened = (channel) => {
|
@@ -8577,12 +8598,12 @@ function runtimeUuidMeetsMinimumRuntimeVersion(runtimeUuid, minVersion) {
|
|
8577
8598
|
}
|
8578
8599
|
runtimeVersioning.runtimeUuidMeetsMinimumRuntimeVersion = runtimeUuidMeetsMinimumRuntimeVersion;
|
8579
8600
|
|
8580
|
-
var __classPrivateFieldGet$
|
8601
|
+
var __classPrivateFieldGet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
8581
8602
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
8582
8603
|
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");
|
8583
8604
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
8584
8605
|
};
|
8585
|
-
var __classPrivateFieldSet$
|
8606
|
+
var __classPrivateFieldSet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
8586
8607
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
8587
8608
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
8588
8609
|
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");
|
@@ -8624,18 +8645,18 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
8624
8645
|
* a read-only array containing all the identities of connecting clients.
|
8625
8646
|
*/
|
8626
8647
|
get connections() {
|
8627
|
-
return [...__classPrivateFieldGet$
|
8648
|
+
return [...__classPrivateFieldGet$8(this, _ChannelProvider_connections, "f")];
|
8628
8649
|
}
|
8629
8650
|
static handleClientDisconnection(channel, payload) {
|
8630
8651
|
const removeById = channel.connections.find((identity) => identity.endpointId === payload.endpointId);
|
8631
8652
|
if (removeById) {
|
8632
|
-
__classPrivateFieldGet$
|
8653
|
+
__classPrivateFieldGet$8(channel, _ChannelProvider_removeEndpoint, "f").call(channel, removeById);
|
8633
8654
|
}
|
8634
8655
|
else {
|
8635
8656
|
const multipleRemoves = channel.connections.filter((identity) => {
|
8636
8657
|
return identity.uuid === payload.uuid && identity.name === payload.name;
|
8637
8658
|
});
|
8638
|
-
multipleRemoves.forEach(__classPrivateFieldGet$
|
8659
|
+
multipleRemoves.forEach(__classPrivateFieldGet$8(channel, _ChannelProvider_removeEndpoint, "f"));
|
8639
8660
|
}
|
8640
8661
|
channel.disconnectListener(payload);
|
8641
8662
|
}
|
@@ -8645,15 +8666,15 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
8645
8666
|
/**
|
8646
8667
|
* @internal
|
8647
8668
|
*/
|
8648
|
-
constructor(providerIdentity,
|
8669
|
+
constructor(providerIdentity, close, strategy) {
|
8649
8670
|
super();
|
8650
8671
|
_ChannelProvider_connections.set(this, void 0);
|
8651
8672
|
_ChannelProvider_protectedObj.set(this, void 0);
|
8652
8673
|
_ChannelProvider_strategy.set(this, void 0);
|
8653
8674
|
_ChannelProvider_removeEndpoint.set(this, (identity) => {
|
8654
8675
|
const remainingConnections = this.connections.filter((clientIdentity) => clientIdentity.endpointId !== identity.endpointId);
|
8655
|
-
__classPrivateFieldGet$
|
8656
|
-
__classPrivateFieldSet$
|
8676
|
+
__classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").closeEndpoint(identity.endpointId);
|
8677
|
+
__classPrivateFieldSet$6(this, _ChannelProvider_connections, remainingConnections, "f");
|
8657
8678
|
});
|
8658
8679
|
// Must be bound.
|
8659
8680
|
this.processAction = async (action, payload, senderIdentity) => {
|
@@ -8667,17 +8688,17 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
8667
8688
|
return super.processAction(action, payload, senderIdentity);
|
8668
8689
|
};
|
8669
8690
|
_ChannelProvider_close.set(this, () => {
|
8670
|
-
__classPrivateFieldGet$
|
8691
|
+
__classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").close();
|
8671
8692
|
const remove = ChannelProvider.removalMap.get(this);
|
8672
8693
|
if (remove) {
|
8673
8694
|
remove();
|
8674
8695
|
}
|
8675
8696
|
});
|
8676
|
-
__classPrivateFieldSet$
|
8697
|
+
__classPrivateFieldSet$6(this, _ChannelProvider_protectedObj, new channel_1.ProtectedItems(providerIdentity, close), "f");
|
8677
8698
|
this.connectListener = () => undefined;
|
8678
8699
|
this.disconnectListener = () => undefined;
|
8679
|
-
__classPrivateFieldSet$
|
8680
|
-
__classPrivateFieldSet$
|
8700
|
+
__classPrivateFieldSet$6(this, _ChannelProvider_connections, [], "f");
|
8701
|
+
__classPrivateFieldSet$6(this, _ChannelProvider_strategy, strategy, "f");
|
8681
8702
|
strategy.receive(this.processAction);
|
8682
8703
|
}
|
8683
8704
|
/**
|
@@ -8708,13 +8729,13 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
8708
8729
|
*/
|
8709
8730
|
dispatch(to, action, payload) {
|
8710
8731
|
const endpointId = to.endpointId ?? this.getEndpointIdForOpenFinId(to, action);
|
8711
|
-
if (endpointId && __classPrivateFieldGet$
|
8712
|
-
return __classPrivateFieldGet$
|
8732
|
+
if (endpointId && __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").isEndpointConnected(endpointId)) {
|
8733
|
+
return __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").send(endpointId, action, payload);
|
8713
8734
|
}
|
8714
8735
|
return Promise.reject(new Error(`Client connection with identity uuid: ${to.uuid} / name: ${to.name} / endpointId: ${endpointId} no longer connected.`));
|
8715
8736
|
}
|
8716
8737
|
async processConnection(senderId, payload) {
|
8717
|
-
__classPrivateFieldGet$
|
8738
|
+
__classPrivateFieldGet$8(this, _ChannelProvider_connections, "f").push(senderId);
|
8718
8739
|
return this.connectListener(senderId, payload);
|
8719
8740
|
}
|
8720
8741
|
/**
|
@@ -8737,7 +8758,7 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
8737
8758
|
* ```
|
8738
8759
|
*/
|
8739
8760
|
publish(action, payload) {
|
8740
|
-
return this.connections.map((to) => __classPrivateFieldGet$
|
8761
|
+
return this.connections.map((to) => __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").send(to.endpointId, action, payload));
|
8741
8762
|
}
|
8742
8763
|
/**
|
8743
8764
|
* Register a listener that is called on every new client connection.
|
@@ -8811,11 +8832,11 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
8811
8832
|
* ```
|
8812
8833
|
*/
|
8813
8834
|
async destroy() {
|
8814
|
-
const protectedObj = __classPrivateFieldGet$
|
8815
|
-
|
8816
|
-
__classPrivateFieldSet$
|
8817
|
-
await protectedObj.
|
8818
|
-
__classPrivateFieldGet$
|
8835
|
+
const protectedObj = __classPrivateFieldGet$8(this, _ChannelProvider_protectedObj, "f");
|
8836
|
+
protectedObj.providerIdentity;
|
8837
|
+
__classPrivateFieldSet$6(this, _ChannelProvider_connections, [], "f");
|
8838
|
+
await protectedObj.close();
|
8839
|
+
__classPrivateFieldGet$8(this, _ChannelProvider_close, "f").call(this);
|
8819
8840
|
}
|
8820
8841
|
/**
|
8821
8842
|
* Returns an array with info on every Client connected to the Provider
|
@@ -8885,7 +8906,7 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
8885
8906
|
getEndpointIdForOpenFinId(clientIdentity, action) {
|
8886
8907
|
const matchingConnections = this.connections.filter((c) => c.name === clientIdentity.name && c.uuid === clientIdentity.uuid);
|
8887
8908
|
if (matchingConnections.length >= 2) {
|
8888
|
-
const protectedObj = __classPrivateFieldGet$
|
8909
|
+
const protectedObj = __classPrivateFieldGet$8(this, _ChannelProvider_protectedObj, "f");
|
8889
8910
|
const { uuid, name } = clientIdentity;
|
8890
8911
|
const providerUuid = protectedObj?.providerIdentity.uuid;
|
8891
8912
|
const providerName = protectedObj?.providerIdentity.name;
|
@@ -8906,6 +8927,9 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
8906
8927
|
static clientIsMultiRuntime(subscriptionIdentity) {
|
8907
8928
|
return subscriptionIdentity.runtimeUuid !== undefined;
|
8908
8929
|
}
|
8930
|
+
static async wireClose(wire, channelName) {
|
8931
|
+
await wire.sendAction('destroy-channel', { channelName });
|
8932
|
+
}
|
8909
8933
|
}
|
8910
8934
|
provider.ChannelProvider = ChannelProvider;
|
8911
8935
|
_ChannelProvider_connections = new WeakMap(), _ChannelProvider_protectedObj = new WeakMap(), _ChannelProvider_strategy = new WeakMap(), _ChannelProvider_removeEndpoint = new WeakMap(), _ChannelProvider_close = new WeakMap();
|
@@ -8918,13 +8942,13 @@ var messageReceiver$1 = {};
|
|
8918
8942
|
Object.defineProperty(messageReceiver$1, "__esModule", { value: true });
|
8919
8943
|
messageReceiver$1.MessageReceiver = void 0;
|
8920
8944
|
const client_1$1 = client;
|
8921
|
-
const base_1$
|
8945
|
+
const base_1$g = base$1;
|
8922
8946
|
/*
|
8923
8947
|
This is a singleton (per fin object) tasked with routing messages coming off the ipc to the correct endpoint.
|
8924
8948
|
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.
|
8925
8949
|
If functionality is not about receiving messages, it does not belong here.
|
8926
8950
|
*/
|
8927
|
-
class MessageReceiver extends base_1$
|
8951
|
+
class MessageReceiver extends base_1$g.Base {
|
8928
8952
|
constructor(wire) {
|
8929
8953
|
super(wire);
|
8930
8954
|
this.onmessage = (msg) => {
|
@@ -9091,13 +9115,13 @@ class CombinedStrategy {
|
|
9091
9115
|
}
|
9092
9116
|
strategy.default = CombinedStrategy;
|
9093
9117
|
|
9094
|
-
var __classPrivateFieldSet$
|
9118
|
+
var __classPrivateFieldSet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
9095
9119
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
9096
9120
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
9097
9121
|
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");
|
9098
9122
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
9099
9123
|
};
|
9100
|
-
var __classPrivateFieldGet$
|
9124
|
+
var __classPrivateFieldGet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
9101
9125
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
9102
9126
|
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");
|
9103
9127
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
@@ -9106,7 +9130,7 @@ var _ConnectionManager_messageReceiver, _ConnectionManager_rtcConnectionManager;
|
|
9106
9130
|
Object.defineProperty(connectionManager, "__esModule", { value: true });
|
9107
9131
|
connectionManager.ConnectionManager = void 0;
|
9108
9132
|
const exhaustive_1 = exhaustive;
|
9109
|
-
const base_1$
|
9133
|
+
const base_1$f = base$1;
|
9110
9134
|
const strategy_1 = strategy$3;
|
9111
9135
|
const strategy_2 = strategy$2;
|
9112
9136
|
const ice_manager_1 = iceManager;
|
@@ -9114,7 +9138,7 @@ const provider_1$1 = provider;
|
|
9114
9138
|
const message_receiver_1 = messageReceiver$1;
|
9115
9139
|
const protocol_manager_1 = protocolManager;
|
9116
9140
|
const strategy_3 = strategy;
|
9117
|
-
class ConnectionManager extends base_1$
|
9141
|
+
class ConnectionManager extends base_1$f.Base {
|
9118
9142
|
static getProtocolOptionsFromStrings(protocols) {
|
9119
9143
|
return protocols.map((protocol) => {
|
9120
9144
|
switch (protocol) {
|
@@ -9143,8 +9167,8 @@ class ConnectionManager extends base_1$g.Base {
|
|
9143
9167
|
};
|
9144
9168
|
this.providerMap = new Map();
|
9145
9169
|
this.protocolManager = new protocol_manager_1.ProtocolManager(this.wire.environment.type === 'node' ? ['classic'] : ['rtc', 'classic']);
|
9146
|
-
__classPrivateFieldSet$
|
9147
|
-
__classPrivateFieldSet$
|
9170
|
+
__classPrivateFieldSet$5(this, _ConnectionManager_messageReceiver, new message_receiver_1.MessageReceiver(wire), "f");
|
9171
|
+
__classPrivateFieldSet$5(this, _ConnectionManager_rtcConnectionManager, new ice_manager_1.RTCICEManager(wire), "f");
|
9148
9172
|
wire.registerMessageHandler(this.onmessage.bind(this));
|
9149
9173
|
}
|
9150
9174
|
createProvider(options, providerIdentity) {
|
@@ -9155,7 +9179,7 @@ class ConnectionManager extends base_1$g.Base {
|
|
9155
9179
|
case 'rtc':
|
9156
9180
|
return new strategy_2.RTCStrategy();
|
9157
9181
|
case 'classic':
|
9158
|
-
return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$
|
9182
|
+
return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$7(this, _ConnectionManager_messageReceiver, "f"),
|
9159
9183
|
// Providers do not have an endpointId, use channelId as endpointId in the strategy.
|
9160
9184
|
providerIdentity.channelId, providerIdentity);
|
9161
9185
|
default:
|
@@ -9175,7 +9199,7 @@ class ConnectionManager extends base_1$g.Base {
|
|
9175
9199
|
// Should be impossible.
|
9176
9200
|
throw new Error('failed to combine strategies');
|
9177
9201
|
}
|
9178
|
-
const channel = new provider_1$1.ChannelProvider(providerIdentity, this.wire, strategy);
|
9202
|
+
const channel = new provider_1$1.ChannelProvider(providerIdentity, () => provider_1$1.ChannelProvider.wireClose(this.wire, providerIdentity.channelName), strategy);
|
9179
9203
|
const key = providerIdentity.channelId;
|
9180
9204
|
this.providerMap.set(key, {
|
9181
9205
|
provider: channel,
|
@@ -9191,7 +9215,7 @@ class ConnectionManager extends base_1$g.Base {
|
|
9191
9215
|
const supportedProtocols = await Promise.all(protocols.map(async (type) => {
|
9192
9216
|
switch (type) {
|
9193
9217
|
case 'rtc': {
|
9194
|
-
const { rtcClient, channels, offer, rtcConnectionId, channelsOpened } = await __classPrivateFieldGet$
|
9218
|
+
const { rtcClient, channels, offer, rtcConnectionId, channelsOpened } = await __classPrivateFieldGet$7(this, _ConnectionManager_rtcConnectionManager, "f").startClientOffer();
|
9195
9219
|
rtcPacket = { rtcClient, channels, channelsOpened };
|
9196
9220
|
return {
|
9197
9221
|
type: 'rtc',
|
@@ -9218,18 +9242,18 @@ class ConnectionManager extends base_1$g.Base {
|
|
9218
9242
|
routingInfo.endpointId = this.wire.environment.getNextMessageId();
|
9219
9243
|
// For New Clients connecting to Old Providers. To prevent multi-dispatching and publishing, we delete previously-connected
|
9220
9244
|
// clients that are in the same context as the newly-connected client.
|
9221
|
-
__classPrivateFieldGet$
|
9245
|
+
__classPrivateFieldGet$7(this, _ConnectionManager_messageReceiver, "f").checkForPreviousClientConnection(routingInfo.channelId);
|
9222
9246
|
}
|
9223
9247
|
const answer = routingInfo.answer ?? {
|
9224
9248
|
supportedProtocols: [{ type: 'classic', version: 1 }]
|
9225
9249
|
};
|
9226
9250
|
const createStrategyFromAnswer = async (protocol) => {
|
9227
9251
|
if (protocol.type === 'rtc' && rtcPacket) {
|
9228
|
-
await __classPrivateFieldGet$
|
9252
|
+
await __classPrivateFieldGet$7(this, _ConnectionManager_rtcConnectionManager, "f").finishClientOffer(rtcPacket.rtcClient, protocol.payload.answer, rtcPacket.channelsOpened);
|
9229
9253
|
return new strategy_2.RTCStrategy();
|
9230
9254
|
}
|
9231
9255
|
if (protocol.type === 'classic') {
|
9232
|
-
return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$
|
9256
|
+
return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$7(this, _ConnectionManager_messageReceiver, "f"), routingInfo.endpointId, routingInfo);
|
9233
9257
|
}
|
9234
9258
|
return null;
|
9235
9259
|
};
|
@@ -9297,7 +9321,7 @@ class ConnectionManager extends base_1$g.Base {
|
|
9297
9321
|
clientAnswer = await overlappingProtocols.reduce(async (accumP, protocolToUse) => {
|
9298
9322
|
const answer = await accumP;
|
9299
9323
|
if (protocolToUse.type === 'rtc') {
|
9300
|
-
const { answer: rtcAnswer, rtcClient, channels } = await __classPrivateFieldGet$
|
9324
|
+
const { answer: rtcAnswer, rtcClient, channels } = await __classPrivateFieldGet$7(this, _ConnectionManager_rtcConnectionManager, "f").createProviderAnswer(protocolToUse.payload.rtcConnectionId, protocolToUse.payload.offer);
|
9301
9325
|
answer.supportedProtocols.push({
|
9302
9326
|
type: 'rtc',
|
9303
9327
|
version: strategy_2.RTCInfo.version,
|
@@ -9345,13 +9369,13 @@ _ConnectionManager_messageReceiver = new WeakMap(), _ConnectionManager_rtcConnec
|
|
9345
9369
|
*
|
9346
9370
|
* @packageDocumentation
|
9347
9371
|
*/
|
9348
|
-
var __classPrivateFieldSet$
|
9372
|
+
var __classPrivateFieldSet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
9349
9373
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
9350
9374
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
9351
9375
|
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");
|
9352
9376
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
9353
9377
|
};
|
9354
|
-
var __classPrivateFieldGet$
|
9378
|
+
var __classPrivateFieldGet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
9355
9379
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
9356
9380
|
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");
|
9357
9381
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
@@ -9362,7 +9386,7 @@ channel$1.Channel = void 0;
|
|
9362
9386
|
/* eslint-disable no-console */
|
9363
9387
|
const events_1$5 = require$$0;
|
9364
9388
|
const lazy_1$1 = lazy;
|
9365
|
-
const base_1$
|
9389
|
+
const base_1$e = base$1;
|
9366
9390
|
const client_1 = client;
|
9367
9391
|
const connection_manager_1 = connectionManager;
|
9368
9392
|
const provider_1 = provider;
|
@@ -9393,7 +9417,7 @@ function retryDelay(count) {
|
|
9393
9417
|
* * {@link Channel.onChannelConnect onChannelConnect(listener)}
|
9394
9418
|
* * {@link Channel.onChannelDisconnect onChannelDisconnect(listener)}
|
9395
9419
|
*/
|
9396
|
-
class Channel extends base_1$
|
9420
|
+
class Channel extends base_1$e.EmitterBase {
|
9397
9421
|
/**
|
9398
9422
|
* @internal
|
9399
9423
|
*/
|
@@ -9408,11 +9432,11 @@ class Channel extends base_1$f.EmitterBase {
|
|
9408
9432
|
client_1.ChannelClient.handleProviderDisconnect(eventPayload);
|
9409
9433
|
}),
|
9410
9434
|
this.on('connected', (...args) => {
|
9411
|
-
__classPrivateFieldGet$
|
9435
|
+
__classPrivateFieldGet$6(this, _Channel_internalEmitter, "f").emit('connected', ...args);
|
9412
9436
|
})
|
9413
9437
|
]).catch(() => new Error('error setting up channel connection listeners'));
|
9414
9438
|
}));
|
9415
|
-
__classPrivateFieldSet$
|
9439
|
+
__classPrivateFieldSet$4(this, _Channel_connectionManager, new connection_manager_1.ConnectionManager(wire), "f");
|
9416
9440
|
}
|
9417
9441
|
/**
|
9418
9442
|
*
|
@@ -9487,7 +9511,7 @@ class Channel extends base_1$f.EmitterBase {
|
|
9487
9511
|
resolve(true);
|
9488
9512
|
}
|
9489
9513
|
};
|
9490
|
-
__classPrivateFieldGet$
|
9514
|
+
__classPrivateFieldGet$6(this, _Channel_internalEmitter, "f").on('connected', connectedListener);
|
9491
9515
|
});
|
9492
9516
|
try {
|
9493
9517
|
if (retryInfo.count > 0) {
|
@@ -9519,7 +9543,7 @@ class Channel extends base_1$f.EmitterBase {
|
|
9519
9543
|
finally {
|
9520
9544
|
retryInfo.count += 1;
|
9521
9545
|
// in case of other errors, remove our listener
|
9522
|
-
__classPrivateFieldGet$
|
9546
|
+
__classPrivateFieldGet$6(this, _Channel_internalEmitter, "f").removeListener('connected', connectedListener);
|
9523
9547
|
}
|
9524
9548
|
} while (shouldWait); // If we're waiting we retry the above loop
|
9525
9549
|
// Should wait was false, no channel was found.
|
@@ -9578,12 +9602,12 @@ class Channel extends base_1$f.EmitterBase {
|
|
9578
9602
|
async connect(channelName, options = {}) {
|
9579
9603
|
// Make sure we don't connect before listeners are set up
|
9580
9604
|
// This also errors if we're not in OpenFin, ensuring we don't run unnecessary code
|
9581
|
-
await __classPrivateFieldGet$
|
9605
|
+
await __classPrivateFieldGet$6(this, _Channel_readyToConnect, "f").getValue();
|
9582
9606
|
if (!channelName || typeof channelName !== 'string') {
|
9583
9607
|
throw new Error('Please provide a channelName string to connect to a channel.');
|
9584
9608
|
}
|
9585
9609
|
const opts = { wait: true, ...this.wire.environment.getDefaultChannelOptions().connect, ...options };
|
9586
|
-
const { offer, rtc: rtcPacket } = await __classPrivateFieldGet$
|
9610
|
+
const { offer, rtc: rtcPacket } = await __classPrivateFieldGet$6(this, _Channel_connectionManager, "f").createClientOffer(opts);
|
9587
9611
|
let connectionUrl;
|
9588
9612
|
if (this.fin.me.isFrame || this.fin.me.isView || this.fin.me.isWindow) {
|
9589
9613
|
connectionUrl = (await this.fin.me.getInfo()).url;
|
@@ -9595,8 +9619,8 @@ class Channel extends base_1$f.EmitterBase {
|
|
9595
9619
|
connectionUrl
|
9596
9620
|
};
|
9597
9621
|
const routingInfo = await this.safeConnect(channelName, opts.wait, connectPayload);
|
9598
|
-
const strategy = await __classPrivateFieldGet$
|
9599
|
-
const channel = new client_1.ChannelClient(routingInfo, this.wire, strategy);
|
9622
|
+
const strategy = await __classPrivateFieldGet$6(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
|
9623
|
+
const channel = new client_1.ChannelClient(routingInfo, () => client_1.ChannelClient.wireClose(this.wire, routingInfo, routingInfo.endpointId), strategy);
|
9600
9624
|
// It is the client's responsibility to handle endpoint disconnection to the provider.
|
9601
9625
|
// If the endpoint dies, the client will force a disconnection through the core.
|
9602
9626
|
// The provider does not care about endpoint disconnection.
|
@@ -9664,7 +9688,7 @@ class Channel extends base_1$f.EmitterBase {
|
|
9664
9688
|
throw new Error('Please provide a channelName to create a channel');
|
9665
9689
|
}
|
9666
9690
|
const { payload: { data: providerIdentity } } = await this.wire.sendAction('create-channel', { channelName });
|
9667
|
-
const channel = __classPrivateFieldGet$
|
9691
|
+
const channel = __classPrivateFieldGet$6(this, _Channel_connectionManager, "f").createProvider(options, providerIdentity);
|
9668
9692
|
// TODO: fix typing (internal)
|
9669
9693
|
// @ts-expect-error
|
9670
9694
|
this.on('client-disconnected', (eventPayload) => {
|
@@ -9688,7 +9712,7 @@ interappbus.InterAppPayload = interappbus.InterApplicationBus = void 0;
|
|
9688
9712
|
* @packageDocumentation
|
9689
9713
|
*/
|
9690
9714
|
const events_1$4 = require$$0;
|
9691
|
-
const base_1$
|
9715
|
+
const base_1$d = base$1;
|
9692
9716
|
const ref_counter_1 = refCounter;
|
9693
9717
|
const index_1$2 = channel$1;
|
9694
9718
|
const validate_1$3 = validate;
|
@@ -9696,7 +9720,7 @@ const validate_1$3 = validate;
|
|
9696
9720
|
* A messaging bus that allows for pub/sub messaging between different applications.
|
9697
9721
|
*
|
9698
9722
|
*/
|
9699
|
-
class InterApplicationBus extends base_1$
|
9723
|
+
class InterApplicationBus extends base_1$d.Base {
|
9700
9724
|
/**
|
9701
9725
|
* @internal
|
9702
9726
|
*/
|
@@ -9902,12 +9926,12 @@ var clipboard = {};
|
|
9902
9926
|
*/
|
9903
9927
|
Object.defineProperty(clipboard, "__esModule", { value: true });
|
9904
9928
|
clipboard.Clipboard = void 0;
|
9905
|
-
const base_1$
|
9929
|
+
const base_1$c = base$1;
|
9906
9930
|
/**
|
9907
9931
|
* The Clipboard API allows reading and writing to the clipboard in multiple formats.
|
9908
9932
|
*
|
9909
9933
|
*/
|
9910
|
-
class Clipboard extends base_1$
|
9934
|
+
class Clipboard extends base_1$c.Base {
|
9911
9935
|
/**
|
9912
9936
|
* Writes data into the clipboard as plain text
|
9913
9937
|
* @param writeObj The object for writing data into the clipboard
|
@@ -10096,7 +10120,7 @@ var Instance$4 = {};
|
|
10096
10120
|
Object.defineProperty(Instance$4, "__esModule", { value: true });
|
10097
10121
|
Instance$4.ExternalApplication = void 0;
|
10098
10122
|
/* eslint-disable import/prefer-default-export */
|
10099
|
-
const base_1$
|
10123
|
+
const base_1$b = base$1;
|
10100
10124
|
/**
|
10101
10125
|
* An ExternalApplication object representing native language adapter connections to the runtime. Allows
|
10102
10126
|
* the developer to listen to {@link OpenFin.ExternalApplicationEvents external application events}.
|
@@ -10107,7 +10131,7 @@ const base_1$c = base$1;
|
|
10107
10131
|
* - Processes started via `System.launchExternalApplication`
|
10108
10132
|
* - Processes monitored via `System.monitorExternalProcess`
|
10109
10133
|
*/
|
10110
|
-
class ExternalApplication extends base_1$
|
10134
|
+
class ExternalApplication extends base_1$b.EmitterBase {
|
10111
10135
|
/**
|
10112
10136
|
* @internal
|
10113
10137
|
*/
|
@@ -10135,12 +10159,12 @@ Instance$4.ExternalApplication = ExternalApplication;
|
|
10135
10159
|
|
10136
10160
|
Object.defineProperty(Factory$5, "__esModule", { value: true });
|
10137
10161
|
Factory$5.ExternalApplicationModule = void 0;
|
10138
|
-
const base_1$
|
10162
|
+
const base_1$a = base$1;
|
10139
10163
|
const Instance_1$4 = Instance$4;
|
10140
10164
|
/**
|
10141
10165
|
* Static namespace for OpenFin API methods that interact with the {@link ExternalApplication} class, available under `fin.ExternalApplication`.
|
10142
10166
|
*/
|
10143
|
-
class ExternalApplicationModule extends base_1$
|
10167
|
+
class ExternalApplicationModule extends base_1$a.Base {
|
10144
10168
|
/**
|
10145
10169
|
* Asynchronously returns an External Application object that represents an external application.
|
10146
10170
|
* <br>It is possible to wrap a process that does not yet exist, (for example, to listen for startup-related events)
|
@@ -10222,7 +10246,7 @@ var Instance$3 = {};
|
|
10222
10246
|
Object.defineProperty(Instance$3, "__esModule", { value: true });
|
10223
10247
|
Instance$3._Frame = void 0;
|
10224
10248
|
/* eslint-disable import/prefer-default-export */
|
10225
|
-
const base_1$
|
10249
|
+
const base_1$9 = base$1;
|
10226
10250
|
/**
|
10227
10251
|
* An iframe represents an embedded HTML page within a parent HTML page. Because this embedded page
|
10228
10252
|
* has its own DOM and global JS context (which may or may not be linked to that of the parent depending
|
@@ -10243,7 +10267,7 @@ const base_1$a = base$1;
|
|
10243
10267
|
* The fin.Frame namespace represents a way to interact with `iframes` and facilitates the discovery of current context
|
10244
10268
|
* (iframe or main window) as well as the ability to listen for {@link OpenFin.FrameEvents frame-specific events}.
|
10245
10269
|
*/
|
10246
|
-
class _Frame extends base_1$
|
10270
|
+
class _Frame extends base_1$9.EmitterBase {
|
10247
10271
|
/**
|
10248
10272
|
* @internal
|
10249
10273
|
*/
|
@@ -10289,13 +10313,13 @@ Instance$3._Frame = _Frame;
|
|
10289
10313
|
|
10290
10314
|
Object.defineProperty(Factory$4, "__esModule", { value: true });
|
10291
10315
|
Factory$4._FrameModule = void 0;
|
10292
|
-
const base_1$
|
10316
|
+
const base_1$8 = base$1;
|
10293
10317
|
const validate_1$2 = validate;
|
10294
10318
|
const Instance_1$3 = Instance$3;
|
10295
10319
|
/**
|
10296
10320
|
* Static namespace for OpenFin API methods that interact with the {@link _Frame} class, available under `fin.Frame`.
|
10297
10321
|
*/
|
10298
|
-
class _FrameModule extends base_1$
|
10322
|
+
class _FrameModule extends base_1$8.Base {
|
10299
10323
|
/**
|
10300
10324
|
* Asynchronously returns an API handle for the given Frame identity.
|
10301
10325
|
*
|
@@ -10416,12 +10440,12 @@ var globalHotkey$1 = {};
|
|
10416
10440
|
|
10417
10441
|
Object.defineProperty(globalHotkey$1, "__esModule", { value: true });
|
10418
10442
|
globalHotkey$1.GlobalHotkey = void 0;
|
10419
|
-
const base_1$
|
10443
|
+
const base_1$7 = base$1;
|
10420
10444
|
/**
|
10421
10445
|
* The GlobalHotkey module can register/unregister a global hotkeys.
|
10422
10446
|
*
|
10423
10447
|
*/
|
10424
|
-
class GlobalHotkey extends base_1$
|
10448
|
+
class GlobalHotkey extends base_1$7.EmitterBase {
|
10425
10449
|
/**
|
10426
10450
|
* @internal
|
10427
10451
|
*/
|
@@ -10555,7 +10579,7 @@ var Factory$3 = {};
|
|
10555
10579
|
|
10556
10580
|
var Instance$2 = {};
|
10557
10581
|
|
10558
|
-
var __classPrivateFieldGet$
|
10582
|
+
var __classPrivateFieldGet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
10559
10583
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
10560
10584
|
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");
|
10561
10585
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
@@ -10564,7 +10588,7 @@ var _Platform_connectToProvider;
|
|
10564
10588
|
Object.defineProperty(Instance$2, "__esModule", { value: true });
|
10565
10589
|
Instance$2.Platform = void 0;
|
10566
10590
|
/* eslint-disable import/prefer-default-export, no-undef */
|
10567
|
-
const base_1$
|
10591
|
+
const base_1$6 = base$1;
|
10568
10592
|
const validate_1$1 = validate;
|
10569
10593
|
// Reuse clients to avoid overwriting already-registered client in provider
|
10570
10594
|
const clientMap = new Map();
|
@@ -10573,7 +10597,7 @@ const clientMap = new Map();
|
|
10573
10597
|
* Enables taking snapshots of itself and applying them to restore a previous configuration
|
10574
10598
|
* as well as listen to {@link OpenFin.PlatformEvents platform events}.
|
10575
10599
|
*/
|
10576
|
-
class Platform extends base_1$
|
10600
|
+
class Platform extends base_1$6.EmitterBase {
|
10577
10601
|
/**
|
10578
10602
|
* @internal
|
10579
10603
|
*/
|
@@ -10588,7 +10612,7 @@ class Platform extends base_1$7.EmitterBase {
|
|
10588
10612
|
const target = identity || this.identity;
|
10589
10613
|
const { uuid } = target;
|
10590
10614
|
if (!clientMap.has(uuid)) {
|
10591
|
-
const clientPromise = __classPrivateFieldGet$
|
10615
|
+
const clientPromise = __classPrivateFieldGet$5(this, _Platform_connectToProvider, "f").call(this, uuid);
|
10592
10616
|
clientMap.set(uuid, clientPromise);
|
10593
10617
|
}
|
10594
10618
|
// we set it above
|
@@ -11413,7 +11437,7 @@ function overrideFromComposables(...overrides) {
|
|
11413
11437
|
commonUtils.overrideFromComposables = overrideFromComposables;
|
11414
11438
|
commonUtils.default = { isValidPresetType };
|
11415
11439
|
|
11416
|
-
var __classPrivateFieldGet$
|
11440
|
+
var __classPrivateFieldGet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
11417
11441
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
11418
11442
|
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");
|
11419
11443
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
@@ -11423,7 +11447,7 @@ Object.defineProperty(Instance$1, "__esModule", { value: true });
|
|
11423
11447
|
Instance$1.Layout = void 0;
|
11424
11448
|
const lazy_1 = lazy;
|
11425
11449
|
const validate_1 = validate;
|
11426
|
-
const base_1$
|
11450
|
+
const base_1$5 = base$1;
|
11427
11451
|
const common_utils_1 = commonUtils;
|
11428
11452
|
const layout_entities_1 = layoutEntities;
|
11429
11453
|
const layout_constants_1$1 = layout_constants;
|
@@ -11559,7 +11583,7 @@ const layout_constants_1$1 = layout_constants;
|
|
11559
11583
|
* }
|
11560
11584
|
* ```
|
11561
11585
|
*/
|
11562
|
-
class Layout extends base_1$
|
11586
|
+
class Layout extends base_1$5.Base {
|
11563
11587
|
/**
|
11564
11588
|
* @internal
|
11565
11589
|
*/
|
@@ -11780,7 +11804,7 @@ class Layout extends base_1$6.Base {
|
|
11780
11804
|
this.wire.sendAction('layout-get-root-item').catch(() => {
|
11781
11805
|
// don't expose
|
11782
11806
|
});
|
11783
|
-
const client = await __classPrivateFieldGet$
|
11807
|
+
const client = await __classPrivateFieldGet$4(this, _Layout_layoutClient, "f").getValue();
|
11784
11808
|
const root = await client.getRoot('layoutName' in this.identity ? this.identity : undefined);
|
11785
11809
|
return layout_entities_1.LayoutNode.getEntity(root, client);
|
11786
11810
|
}
|
@@ -11788,12 +11812,12 @@ class Layout extends base_1$6.Base {
|
|
11788
11812
|
Instance$1.Layout = Layout;
|
11789
11813
|
_Layout_layoutClient = new WeakMap();
|
11790
11814
|
|
11791
|
-
var __classPrivateFieldGet$
|
11815
|
+
var __classPrivateFieldGet$3 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
11792
11816
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
11793
11817
|
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");
|
11794
11818
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
11795
11819
|
};
|
11796
|
-
var __classPrivateFieldSet$
|
11820
|
+
var __classPrivateFieldSet$3 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
11797
11821
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
11798
11822
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
11799
11823
|
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");
|
@@ -11802,13 +11826,13 @@ var __classPrivateFieldSet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateF
|
|
11802
11826
|
var _LayoutModule_instances, _LayoutModule_layoutInitializationAttempted, _LayoutModule_layoutManager, _LayoutModule_getLayoutManagerSpy, _LayoutModule_getSafeLayoutManager;
|
11803
11827
|
Object.defineProperty(Factory$2, "__esModule", { value: true });
|
11804
11828
|
Factory$2.LayoutModule = void 0;
|
11805
|
-
const base_1$
|
11829
|
+
const base_1$4 = base$1;
|
11806
11830
|
const Instance_1$2 = Instance$1;
|
11807
11831
|
const layout_constants_1 = layout_constants;
|
11808
11832
|
/**
|
11809
11833
|
* Static namespace for OpenFin API methods that interact with the {@link Layout} class, available under `fin.Platform.Layout`.
|
11810
11834
|
*/
|
11811
|
-
class LayoutModule extends base_1$
|
11835
|
+
class LayoutModule extends base_1$4.Base {
|
11812
11836
|
constructor() {
|
11813
11837
|
super(...arguments);
|
11814
11838
|
_LayoutModule_instances.add(this);
|
@@ -11859,19 +11883,19 @@ class LayoutModule extends base_1$5.Base {
|
|
11859
11883
|
if (!this.fin.me.isWindow) {
|
11860
11884
|
throw new Error('Layout.init can only be called from a Window context.');
|
11861
11885
|
}
|
11862
|
-
else if (__classPrivateFieldGet$
|
11886
|
+
else if (__classPrivateFieldGet$3(this, _LayoutModule_layoutInitializationAttempted, "f")) {
|
11863
11887
|
throw new Error('Layout.init was already called, please use Layout.create to add additional layouts.');
|
11864
11888
|
}
|
11865
|
-
__classPrivateFieldSet$
|
11889
|
+
__classPrivateFieldSet$3(this, _LayoutModule_layoutInitializationAttempted, true, "f");
|
11866
11890
|
// preload the client
|
11867
11891
|
await this.fin.Platform.getCurrentSync().getClient();
|
11868
|
-
__classPrivateFieldSet$
|
11869
|
-
await this.wire.environment.applyLayoutSnapshot(this.fin, __classPrivateFieldGet$
|
11892
|
+
__classPrivateFieldSet$3(this, _LayoutModule_layoutManager, await this.wire.environment.initLayoutManager(this.fin, this.wire, options), "f");
|
11893
|
+
await this.wire.environment.applyLayoutSnapshot(this.fin, __classPrivateFieldGet$3(this, _LayoutModule_layoutManager, "f"), options);
|
11870
11894
|
if (!options.layoutManagerOverride) {
|
11871
11895
|
// CORE-1081 to be removed when we actually delete the `layoutManager` prop
|
11872
11896
|
// in single-layout case, we return the undocumented layoutManager type
|
11873
11897
|
const layoutIdentity = { layoutName: layout_constants_1.DEFAULT_LAYOUT_KEY, ...this.fin.me.identity };
|
11874
|
-
return __classPrivateFieldGet$
|
11898
|
+
return __classPrivateFieldGet$3(this, _LayoutModule_getLayoutManagerSpy, "f").call(this, layoutIdentity);
|
11875
11899
|
}
|
11876
11900
|
return this.wrapSync(this.fin.me.identity);
|
11877
11901
|
};
|
@@ -11900,13 +11924,13 @@ class LayoutModule extends base_1$5.Base {
|
|
11900
11924
|
* @returns
|
11901
11925
|
*/
|
11902
11926
|
this.getCurrentLayoutManagerSync = () => {
|
11903
|
-
return __classPrivateFieldGet$
|
11927
|
+
return __classPrivateFieldGet$3(this, _LayoutModule_instances, "m", _LayoutModule_getSafeLayoutManager).call(this, `fin.Platform.Layout.getCurrentLayoutManagerSync()`);
|
11904
11928
|
};
|
11905
11929
|
this.create = async (options) => {
|
11906
|
-
return this.wire.environment.createLayout(__classPrivateFieldGet$
|
11930
|
+
return this.wire.environment.createLayout(__classPrivateFieldGet$3(this, _LayoutModule_instances, "m", _LayoutModule_getSafeLayoutManager).call(this, `fin.Platform.Layout.create()`), options);
|
11907
11931
|
};
|
11908
11932
|
this.destroy = async (layoutIdentity) => {
|
11909
|
-
return this.wire.environment.destroyLayout(__classPrivateFieldGet$
|
11933
|
+
return this.wire.environment.destroyLayout(__classPrivateFieldGet$3(this, _LayoutModule_instances, "m", _LayoutModule_getSafeLayoutManager).call(this, `fin.Platform.Layout.destroy()`), layoutIdentity);
|
11910
11934
|
};
|
11911
11935
|
}
|
11912
11936
|
/**
|
@@ -12005,10 +12029,10 @@ class LayoutModule extends base_1$5.Base {
|
|
12005
12029
|
}
|
12006
12030
|
Factory$2.LayoutModule = LayoutModule;
|
12007
12031
|
_LayoutModule_layoutInitializationAttempted = new WeakMap(), _LayoutModule_layoutManager = new WeakMap(), _LayoutModule_getLayoutManagerSpy = new WeakMap(), _LayoutModule_instances = new WeakSet(), _LayoutModule_getSafeLayoutManager = function _LayoutModule_getSafeLayoutManager(method) {
|
12008
|
-
if (!__classPrivateFieldGet$
|
12032
|
+
if (!__classPrivateFieldGet$3(this, _LayoutModule_layoutManager, "f")) {
|
12009
12033
|
throw new Error(`You must call init before using the API ${method}`);
|
12010
12034
|
}
|
12011
|
-
return __classPrivateFieldGet$
|
12035
|
+
return __classPrivateFieldGet$3(this, _LayoutModule_layoutManager, "f");
|
12012
12036
|
};
|
12013
12037
|
|
12014
12038
|
(function (exports) {
|
@@ -12045,13 +12069,13 @@ _LayoutModule_layoutInitializationAttempted = new WeakMap(), _LayoutModule_layou
|
|
12045
12069
|
|
12046
12070
|
Object.defineProperty(Factory$3, "__esModule", { value: true });
|
12047
12071
|
Factory$3.PlatformModule = void 0;
|
12048
|
-
const base_1$
|
12072
|
+
const base_1$3 = base$1;
|
12049
12073
|
const Instance_1$1 = Instance$2;
|
12050
12074
|
const index_1$1 = layout;
|
12051
12075
|
/**
|
12052
12076
|
* Static namespace for OpenFin API methods that interact with the {@link Platform} class, available under `fin.Platform`.
|
12053
12077
|
*/
|
12054
|
-
class PlatformModule extends base_1$
|
12078
|
+
class PlatformModule extends base_1$3.Base {
|
12055
12079
|
/**
|
12056
12080
|
* @internal
|
12057
12081
|
*/
|
@@ -12622,7 +12646,7 @@ function requireSessionContextGroupBroker () {
|
|
12622
12646
|
return SessionContextGroupBroker;
|
12623
12647
|
}
|
12624
12648
|
|
12625
|
-
var utils$
|
12649
|
+
var utils$3 = {};
|
12626
12650
|
|
12627
12651
|
(function (exports) {
|
12628
12652
|
Object.defineProperty(exports, "__esModule", { value: true });
|
@@ -12685,7 +12709,7 @@ var utils$1 = {};
|
|
12685
12709
|
};
|
12686
12710
|
};
|
12687
12711
|
exports.wrapIntentHandler = wrapIntentHandler;
|
12688
|
-
} (utils$
|
12712
|
+
} (utils$3));
|
12689
12713
|
|
12690
12714
|
var PrivateChannelProvider = {};
|
12691
12715
|
|
@@ -12988,14 +13012,15 @@ function requireInteropBroker () {
|
|
12988
13012
|
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");
|
12989
13013
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
12990
13014
|
};
|
12991
|
-
var _InteropBroker_fdc3Info, _InteropBroker_contextGroups;
|
13015
|
+
var _InteropBroker_fdc3Info, _InteropBroker_contextGroups, _InteropBroker_providerPromise;
|
12992
13016
|
Object.defineProperty(InteropBroker, "__esModule", { value: true });
|
12993
13017
|
InteropBroker.InteropBroker = void 0;
|
12994
13018
|
const base_1 = base$1;
|
12995
13019
|
const SessionContextGroupBroker_1 = requireSessionContextGroupBroker();
|
12996
|
-
const utils_1 = utils$
|
13020
|
+
const utils_1 = utils$3;
|
12997
13021
|
const lodash_1 = require$$3;
|
12998
13022
|
const PrivateChannelProvider_1 = requirePrivateChannelProvider();
|
13023
|
+
const lazy_1 = lazy;
|
12999
13024
|
const defaultContextGroups = [
|
13000
13025
|
{
|
13001
13026
|
id: 'green',
|
@@ -13163,12 +13188,15 @@ function requireInteropBroker () {
|
|
13163
13188
|
/**
|
13164
13189
|
* @internal
|
13165
13190
|
*/
|
13166
|
-
constructor(wire,
|
13191
|
+
constructor(wire, createProvider, options) {
|
13167
13192
|
// Tip from Pierre and Michael from the overrideCheck work: Don't use bound methods for overrideable InteropBroker functions.
|
13168
13193
|
super(wire);
|
13169
|
-
this.getProvider = getProvider;
|
13170
13194
|
_InteropBroker_fdc3Info.set(this, void 0);
|
13171
13195
|
_InteropBroker_contextGroups.set(this, void 0);
|
13196
|
+
_InteropBroker_providerPromise.set(this, void 0);
|
13197
|
+
this.getProvider = () => {
|
13198
|
+
return __classPrivateFieldGet(this, _InteropBroker_providerPromise, "f").getValue();
|
13199
|
+
};
|
13172
13200
|
this.interopClients = new Map();
|
13173
13201
|
this.contextGroupsById = new Map();
|
13174
13202
|
__classPrivateFieldSet(this, _InteropBroker_contextGroups, options.contextGroups ?? [...defaultContextGroups], "f");
|
@@ -13179,6 +13207,7 @@ function requireInteropBroker () {
|
|
13179
13207
|
this.intentClientMap = new Map();
|
13180
13208
|
this.lastContextMap = new Map();
|
13181
13209
|
this.sessionContextGroupMap = new Map();
|
13210
|
+
__classPrivateFieldSet(this, _InteropBroker_providerPromise, new lazy_1.Lazy(createProvider), "f");
|
13182
13211
|
this.setContextGroupMap();
|
13183
13212
|
this.setupChannelProvider();
|
13184
13213
|
}
|
@@ -14262,35 +14291,35 @@ function requireInteropBroker () {
|
|
14262
14291
|
}
|
14263
14292
|
};
|
14264
14293
|
InteropBroker.InteropBroker = InteropBroker$1;
|
14265
|
-
_InteropBroker_fdc3Info = new WeakMap(), _InteropBroker_contextGroups = new WeakMap();
|
14294
|
+
_InteropBroker_fdc3Info = new WeakMap(), _InteropBroker_contextGroups = new WeakMap(), _InteropBroker_providerPromise = new WeakMap();
|
14266
14295
|
return InteropBroker;
|
14267
14296
|
}
|
14268
14297
|
|
14269
|
-
var InteropClient
|
14298
|
+
var InteropClient = {};
|
14270
14299
|
|
14271
14300
|
var SessionContextGroupClient$1 = {};
|
14272
14301
|
|
14273
|
-
var __classPrivateFieldSet$
|
14302
|
+
var __classPrivateFieldSet$2 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
14274
14303
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
14275
14304
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
14276
14305
|
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");
|
14277
14306
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
14278
14307
|
};
|
14279
|
-
var __classPrivateFieldGet$
|
14308
|
+
var __classPrivateFieldGet$2 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
14280
14309
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
14281
14310
|
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");
|
14282
14311
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
14283
14312
|
};
|
14284
14313
|
var _SessionContextGroupClient_clientPromise;
|
14285
14314
|
Object.defineProperty(SessionContextGroupClient$1, "__esModule", { value: true });
|
14286
|
-
const base_1$
|
14287
|
-
const utils_1$
|
14288
|
-
class SessionContextGroupClient extends base_1$
|
14315
|
+
const base_1$2 = base$1;
|
14316
|
+
const utils_1$2 = utils$3;
|
14317
|
+
class SessionContextGroupClient extends base_1$2.Base {
|
14289
14318
|
constructor(wire, client, id) {
|
14290
14319
|
super(wire);
|
14291
14320
|
_SessionContextGroupClient_clientPromise.set(this, void 0);
|
14292
14321
|
this.id = id;
|
14293
|
-
__classPrivateFieldSet$
|
14322
|
+
__classPrivateFieldSet$2(this, _SessionContextGroupClient_clientPromise, client, "f");
|
14294
14323
|
}
|
14295
14324
|
/**
|
14296
14325
|
* Sets a context for the session context group.
|
@@ -14302,7 +14331,7 @@ class SessionContextGroupClient extends base_1$3.Base {
|
|
14302
14331
|
this.wire.sendAction('interop-session-context-group-set-context').catch((e) => {
|
14303
14332
|
// don't expose, analytics-only call
|
14304
14333
|
});
|
14305
|
-
const client = await __classPrivateFieldGet$
|
14334
|
+
const client = await __classPrivateFieldGet$2(this, _SessionContextGroupClient_clientPromise, "f");
|
14306
14335
|
return client.dispatch(`sessionContextGroup:setContext-${this.id}`, {
|
14307
14336
|
sessionContextGroupId: this.id,
|
14308
14337
|
context
|
@@ -14312,7 +14341,7 @@ class SessionContextGroupClient extends base_1$3.Base {
|
|
14312
14341
|
this.wire.sendAction('interop-session-context-group-get-context').catch((e) => {
|
14313
14342
|
// don't expose, analytics-only call
|
14314
14343
|
});
|
14315
|
-
const client = await __classPrivateFieldGet$
|
14344
|
+
const client = await __classPrivateFieldGet$2(this, _SessionContextGroupClient_clientPromise, "f");
|
14316
14345
|
return client.dispatch(`sessionContextGroup:getContext-${this.id}`, {
|
14317
14346
|
sessionContextGroupId: this.id,
|
14318
14347
|
type
|
@@ -14325,20 +14354,20 @@ class SessionContextGroupClient extends base_1$3.Base {
|
|
14325
14354
|
if (typeof contextHandler !== 'function') {
|
14326
14355
|
throw new Error("Non-function argument passed to the first parameter 'handler'. Be aware that the argument order does not match the FDC3 standard.");
|
14327
14356
|
}
|
14328
|
-
const client = await __classPrivateFieldGet$
|
14357
|
+
const client = await __classPrivateFieldGet$2(this, _SessionContextGroupClient_clientPromise, "f");
|
14329
14358
|
let handlerId;
|
14330
14359
|
if (contextType) {
|
14331
|
-
handlerId = `sessionContextHandler:invoke-${this.id}-${contextType}-${(0, utils_1$
|
14360
|
+
handlerId = `sessionContextHandler:invoke-${this.id}-${contextType}-${(0, utils_1$2.generateId)()}`;
|
14332
14361
|
}
|
14333
14362
|
else {
|
14334
14363
|
handlerId = `sessionContextHandler:invoke-${this.id}`;
|
14335
14364
|
}
|
14336
|
-
client.register(handlerId, (0, utils_1$
|
14365
|
+
client.register(handlerId, (0, utils_1$2.wrapContextHandler)(contextHandler, handlerId));
|
14337
14366
|
await client.dispatch(`sessionContextGroup:handlerAdded-${this.id}`, { handlerId, contextType });
|
14338
14367
|
return { unsubscribe: await this.createUnsubscribeCb(handlerId) };
|
14339
14368
|
}
|
14340
14369
|
async createUnsubscribeCb(handlerId) {
|
14341
|
-
const client = await __classPrivateFieldGet$
|
14370
|
+
const client = await __classPrivateFieldGet$2(this, _SessionContextGroupClient_clientPromise, "f");
|
14342
14371
|
return async () => {
|
14343
14372
|
client.remove(handlerId);
|
14344
14373
|
await client.dispatch(`sessionContextGroup:handlerRemoved-${this.id}`, { handlerId });
|
@@ -14347,610 +14376,1773 @@ class SessionContextGroupClient extends base_1$3.Base {
|
|
14347
14376
|
getUserInstance() {
|
14348
14377
|
return {
|
14349
14378
|
id: this.id,
|
14350
|
-
setContext: (0, utils_1$
|
14351
|
-
getCurrentContext: (0, utils_1$
|
14352
|
-
addContextHandler: (0, utils_1$
|
14379
|
+
setContext: (0, utils_1$2.wrapInTryCatch)(this.setContext.bind(this), 'Failed to set context: '),
|
14380
|
+
getCurrentContext: (0, utils_1$2.wrapInTryCatch)(this.getCurrentContext.bind(this), 'Failed to get context: '),
|
14381
|
+
addContextHandler: (0, utils_1$2.wrapInTryCatch)(this.addContextHandler.bind(this), 'Failed to add context handler: ')
|
14353
14382
|
};
|
14354
14383
|
}
|
14355
14384
|
}
|
14356
14385
|
SessionContextGroupClient$1.default = SessionContextGroupClient;
|
14357
14386
|
_SessionContextGroupClient_clientPromise = new WeakMap();
|
14358
14387
|
|
14359
|
-
var
|
14360
|
-
|
14361
|
-
|
14362
|
-
|
14363
|
-
|
14364
|
-
|
14365
|
-
var
|
14366
|
-
|
14367
|
-
|
14368
|
-
|
14369
|
-
|
14370
|
-
|
14371
|
-
|
14372
|
-
|
14373
|
-
|
14374
|
-
|
14375
|
-
const utils_1$2 = utils$1;
|
14376
|
-
/**
|
14377
|
-
* The Interop Client API is broken up into two groups:
|
14378
|
-
*
|
14379
|
-
* **Content Facing APIs** - For Application Developers putting Views into a Platform Window, who care about Context. These are APIs that send out and receive the Context data that flows between applications. Think of this as the Water in the Interop Pipes.
|
14380
|
-
*
|
14381
|
-
* **Context Grouping APIs** - For Platform Developers, to add and remove Views to and from Context Groups. These APIs are utilized under-the-hood in Platforms, so they don't need to be used to participate in Interop. These are the APIs that decide which entities the context data flows between. Think of these as the valves or pipes that control the flow of Context Data for Interop.
|
14382
|
-
*
|
14383
|
-
* ---
|
14384
|
-
*
|
14385
|
-
* All APIs are available at the `fin.me.interop` namespace.
|
14386
|
-
*
|
14387
|
-
* ---
|
14388
|
-
*
|
14389
|
-
* **You only need 2 things to participate in Interop Context Grouping:**
|
14390
|
-
* * A Context Handler for incoming context: {@link InteropClient#addContextHandler addContextHandler(handler, contextType?)}
|
14391
|
-
* * Call setContext on your context group when you want to share context with other group members: {@link InteropClient#setContext setContext(context)}
|
14392
|
-
*
|
14393
|
-
* ---
|
14394
|
-
*
|
14395
|
-
* ##### Constructor
|
14396
|
-
* Returned by {@link Interop.connectSync Interop.connectSync}.
|
14397
|
-
*
|
14398
|
-
* ---
|
14399
|
-
*
|
14400
|
-
* ##### Interop methods intended for Views
|
14401
|
-
*
|
14402
|
-
*
|
14403
|
-
* **Context Groups API**
|
14404
|
-
* * {@link InteropClient#addContextHandler addContextHandler(handler, contextType?)}
|
14405
|
-
* * {@link InteropClient#setContext setContext(context)}
|
14406
|
-
* * {@link InteropClient#getCurrentContext getCurrentContext(contextType?)}
|
14407
|
-
* * {@link InteropClient#joinSessionContextGroup joinSessionContextGroup(sessionContextGroupId)}
|
14408
|
-
*
|
14409
|
-
*
|
14410
|
-
* **Intents API**
|
14411
|
-
* * {@link InteropClient#fireIntent fireIntent(intent)}
|
14412
|
-
* * {@link InteropClient#registerIntentHandler registerIntentHandler(intentHandler, intentName)}
|
14413
|
-
* * {@link InteropClient#getInfoForIntent getInfoForIntent(infoForIntentOptions)}
|
14414
|
-
* * {@link InteropClient#getInfoForIntentsByContext getInfoForIntentsByContext(context)}
|
14415
|
-
* * {@link InteropClient#fireIntentForContext fireIntentForContext(contextForIntent)}
|
14416
|
-
*
|
14417
|
-
* ##### Interop methods intended for Windows
|
14418
|
-
* * {@link InteropClient#getContextGroups getContextGroups()}
|
14419
|
-
* * {@link InteropClient#joinContextGroup joinContextGroup(contextGroupId, target?)}
|
14420
|
-
* * {@link InteropClient#removeFromContextGroup removeFromContextGroup(target?)}
|
14421
|
-
* * {@link InteropClient#getInfoForContextGroup getInfoForContextGroup(contextGroupId)}
|
14422
|
-
* * {@link InteropClient#getAllClientsInContextGroup getAllClientsInContextGroup(contextGroupId)}
|
14423
|
-
*
|
14424
|
-
*/
|
14425
|
-
class InteropClient extends base_1$2.Base {
|
14426
|
-
/**
|
14427
|
-
* @internal
|
14428
|
-
*/
|
14429
|
-
constructor(wire, name, interopConfig = {}) {
|
14430
|
-
super(wire);
|
14431
|
-
_InteropClient_clientPromise.set(this, void 0);
|
14432
|
-
_InteropClient_sessionContextGroups.set(this, void 0);
|
14433
|
-
__classPrivateFieldSet$2(this, _InteropClient_sessionContextGroups, new Map(), "f");
|
14434
|
-
__classPrivateFieldSet$2(this, _InteropClient_clientPromise, this.wire.environment.whenReady().then(() => {
|
14435
|
-
return this.fin.InterApplicationBus.Channel.connect(`interop-broker-${name}`, {
|
14436
|
-
payload: interopConfig
|
14437
|
-
});
|
14438
|
-
}), "f");
|
14388
|
+
var fdc31_2 = {};
|
14389
|
+
|
14390
|
+
var fdc3Common = {};
|
14391
|
+
|
14392
|
+
var utils$2 = {};
|
14393
|
+
|
14394
|
+
var PrivateChannelClient$1 = {};
|
14395
|
+
|
14396
|
+
Object.defineProperty(PrivateChannelClient$1, "__esModule", { value: true });
|
14397
|
+
PrivateChannelClient$1.PrivateChannelClient = void 0;
|
14398
|
+
const utils$1 = utils$3;
|
14399
|
+
class PrivateChannelClient {
|
14400
|
+
constructor(client, id) {
|
14401
|
+
this.id = id;
|
14402
|
+
this.client = client;
|
14403
|
+
this.listeners = new Map();
|
14439
14404
|
}
|
14440
|
-
|
14441
|
-
|
14442
|
-
*/
|
14443
|
-
/**
|
14444
|
-
* Sets a context for the context group of the current entity.
|
14445
|
-
*
|
14446
|
-
* @remarks The entity must be part of a context group in order set a context.
|
14447
|
-
*
|
14448
|
-
* @param context - New context to set.
|
14449
|
-
*
|
14450
|
-
* @example
|
14451
|
-
* ```js
|
14452
|
-
* setInstrumentContext = async (ticker) => {
|
14453
|
-
* fin.me.interop.setContext({type: 'instrument', id: {ticker}})
|
14454
|
-
* }
|
14455
|
-
*
|
14456
|
-
* // The user clicks an instrument of interest. We want to set that Instrument context so that the rest of our workflow updates with information for that instrument
|
14457
|
-
* instrumentElement.on('click', (evt) => {
|
14458
|
-
* setInstrumentContext(evt.ticker)
|
14459
|
-
* })
|
14460
|
-
* ```
|
14461
|
-
*/
|
14462
|
-
async setContext(context) {
|
14463
|
-
this.wire.sendAction('interop-client-set-context').catch((e) => {
|
14464
|
-
// don't expose, analytics-only call
|
14465
|
-
});
|
14466
|
-
const client = await __classPrivateFieldGet$2(this, _InteropClient_clientPromise, "f");
|
14467
|
-
return client.dispatch('setContext', { context });
|
14405
|
+
async broadcast(context) {
|
14406
|
+
return this.client.dispatch('broadcast', { context });
|
14468
14407
|
}
|
14469
|
-
|
14470
|
-
|
14471
|
-
|
14472
|
-
|
14473
|
-
* @param handler - Handler for incoming context.
|
14474
|
-
* @param contextType - The type of context you wish to handle.
|
14475
|
-
*
|
14476
|
-
* @example
|
14477
|
-
* ```js
|
14478
|
-
* function handleIncomingContext(contextInfo) {
|
14479
|
-
* const { type, id } = contextInfo;
|
14480
|
-
* switch (type) {
|
14481
|
-
* case 'instrument':
|
14482
|
-
* handleInstrumentContext(contextInfo);
|
14483
|
-
* break;
|
14484
|
-
* case 'country':
|
14485
|
-
* handleCountryContext(contextInfo);
|
14486
|
-
* break;
|
14487
|
-
*
|
14488
|
-
* default:
|
14489
|
-
* break;
|
14490
|
-
* }
|
14491
|
-
* }
|
14492
|
-
*
|
14493
|
-
*
|
14494
|
-
* function handleInstrumentContext(contextInfo) {
|
14495
|
-
* const { type, id } = contextInfo;
|
14496
|
-
* console.log('contextInfo for instrument', contextInfo)
|
14497
|
-
* }
|
14498
|
-
*
|
14499
|
-
* function handleCountryContext(contextInfo) {
|
14500
|
-
* const { type, id } = contextInfo;
|
14501
|
-
* console.log('contextInfo for country', contextInfo)
|
14502
|
-
* }
|
14503
|
-
*
|
14504
|
-
* fin.me.interop.addContextHandler(handleIncomingContext);
|
14505
|
-
* ```
|
14506
|
-
*
|
14507
|
-
*
|
14508
|
-
* We are also testing the ability to add a context handler for specific contexts. If you would like to use
|
14509
|
-
* this, please make sure you add your context handlers at the top level of your application, on a page that
|
14510
|
-
* does not navigate/reload/re-render, to avoid memory leaks. This feature is experimental:
|
14511
|
-
*
|
14512
|
-
* ```js
|
14513
|
-
* function handleInstrumentContext(contextInfo) {
|
14514
|
-
* const { type, id } = contextInfo;
|
14515
|
-
* console.log('contextInfo for instrument', contextInfo)
|
14516
|
-
* }
|
14517
|
-
*
|
14518
|
-
* function handleCountryContext(contextInfo) {
|
14519
|
-
* const { type, id } = contextInfo;
|
14520
|
-
* console.log('contextInfo for country', contextInfo)
|
14521
|
-
* }
|
14522
|
-
*
|
14523
|
-
*
|
14524
|
-
* fin.me.interop.addContextHandler(handleInstrumentContext, 'instrument')
|
14525
|
-
* fin.me.interop.addContextHandler(handleCountryContext, 'country')
|
14526
|
-
* ```
|
14527
|
-
*/
|
14528
|
-
async addContextHandler(handler, contextType) {
|
14529
|
-
this.wire.sendAction('interop-client-add-context-handler').catch((e) => {
|
14530
|
-
// don't expose, analytics-only call
|
14531
|
-
});
|
14408
|
+
async getCurrentContext(contextType) {
|
14409
|
+
return this.client.dispatch('getCurrentContext', { contextType });
|
14410
|
+
}
|
14411
|
+
async addContextListener(contextType, handler) {
|
14532
14412
|
if (typeof handler !== 'function') {
|
14533
|
-
throw new Error("Non-function argument passed to the
|
14413
|
+
throw new Error("Non-function argument passed to the second parameter 'handler'. Be aware that the argument order does not match the FDC3 standard.");
|
14534
14414
|
}
|
14535
|
-
const client = await __classPrivateFieldGet$2(this, _InteropClient_clientPromise, "f");
|
14536
14415
|
let handlerId;
|
14537
14416
|
if (contextType) {
|
14538
|
-
handlerId = `
|
14539
|
-
console.warn(`Warning: By providing a contextType (${contextType}), you are using the experimental addContextHandler. To avoid issues, make sure you are adding your context handlers at the top level in your application.`);
|
14417
|
+
handlerId = `contextHandler:invoke-${this.id}-${contextType}-${utils$1.generateId()}`;
|
14540
14418
|
}
|
14541
14419
|
else {
|
14542
|
-
handlerId =
|
14420
|
+
handlerId = `contextHandler:invoke-${this.id}-${utils$1.generateId()}`;
|
14543
14421
|
}
|
14544
|
-
|
14545
|
-
|
14546
|
-
|
14547
|
-
|
14548
|
-
|
14549
|
-
|
14550
|
-
|
14551
|
-
|
14422
|
+
this.client.register(handlerId, utils$1.wrapContextHandler(handler, handlerId));
|
14423
|
+
const listener = { unsubscribe: await this.createContextUnsubscribeCb(handlerId) };
|
14424
|
+
this.listeners.set(handlerId, listener);
|
14425
|
+
await this.client.dispatch(`contextHandlerAdded`, { handlerId, contextType });
|
14426
|
+
return listener;
|
14427
|
+
}
|
14428
|
+
createNonStandardUnsubscribeCb(handlerId) {
|
14429
|
+
return async () => {
|
14430
|
+
this.client.remove(handlerId);
|
14431
|
+
this.listeners.delete(handlerId);
|
14432
|
+
await this.client.dispatch('nonStandardHandlerRemoved', { handlerId });
|
14552
14433
|
};
|
14553
14434
|
}
|
14554
|
-
|
14555
|
-
|
14556
|
-
|
14557
|
-
|
14558
|
-
|
14559
|
-
|
14560
|
-
*
|
14561
|
-
* @example
|
14562
|
-
* ```js
|
14563
|
-
* fin.me.interop.getContextGroups()
|
14564
|
-
* .then(contextGroups => {
|
14565
|
-
* contextGroups.forEach(contextGroup => {
|
14566
|
-
* console.log(contextGroup.displayMetadata.name)
|
14567
|
-
* console.log(contextGroup.displayMetadata.color)
|
14568
|
-
* })
|
14569
|
-
* })
|
14570
|
-
* ```
|
14571
|
-
*/
|
14572
|
-
async getContextGroups() {
|
14573
|
-
this.wire.sendAction('interop-client-get-context-groups').catch((e) => {
|
14574
|
-
// don't expose, analytics-only call
|
14575
|
-
});
|
14576
|
-
const client = await __classPrivateFieldGet$2(this, _InteropClient_clientPromise, "f");
|
14577
|
-
return client.dispatch('getContextGroups');
|
14435
|
+
createContextUnsubscribeCb(handlerId) {
|
14436
|
+
return async () => {
|
14437
|
+
this.client.remove(handlerId);
|
14438
|
+
this.listeners.delete(handlerId);
|
14439
|
+
await this.client.dispatch('contextHandlerRemoved', { handlerId });
|
14440
|
+
};
|
14578
14441
|
}
|
14579
|
-
|
14580
|
-
|
14581
|
-
|
14582
|
-
|
14583
|
-
|
14584
|
-
|
14585
|
-
|
14586
|
-
|
14587
|
-
|
14588
|
-
|
14589
|
-
|
14590
|
-
|
14591
|
-
|
14592
|
-
|
14593
|
-
|
14594
|
-
|
14595
|
-
|
14596
|
-
|
14597
|
-
|
14598
|
-
|
14599
|
-
|
14600
|
-
|
14601
|
-
|
14602
|
-
|
14603
|
-
async
|
14604
|
-
this.
|
14605
|
-
|
14442
|
+
onAddContextListener(handler) {
|
14443
|
+
const handlerId = `onContextHandlerAdded:invoke-${this.id}-${utils$1.generateId()}`;
|
14444
|
+
this.client.register(handlerId, handler);
|
14445
|
+
const listener = { unsubscribe: this.createNonStandardUnsubscribeCb(handlerId) };
|
14446
|
+
this.listeners.set(handlerId, listener);
|
14447
|
+
this.client.dispatch(`onAddContextHandlerAdded`, { handlerId });
|
14448
|
+
return listener;
|
14449
|
+
}
|
14450
|
+
onDisconnect(handler) {
|
14451
|
+
const handlerId = `onDisconnect:invoke-${this.id}-${utils$1.generateId()}`;
|
14452
|
+
this.client.register(handlerId, handler);
|
14453
|
+
const listener = { unsubscribe: this.createNonStandardUnsubscribeCb(handlerId) };
|
14454
|
+
this.listeners.set(handlerId, listener);
|
14455
|
+
this.client.dispatch(`onDisconnectHandlerAdded`, { handlerId });
|
14456
|
+
return listener;
|
14457
|
+
}
|
14458
|
+
onUnsubscribe(handler) {
|
14459
|
+
const handlerId = `onUnsubscribe:invoke-${this.id}-${utils$1.generateId()}`;
|
14460
|
+
this.client.register(handlerId, handler);
|
14461
|
+
const listener = { unsubscribe: this.createNonStandardUnsubscribeCb(handlerId) };
|
14462
|
+
this.listeners.set(handlerId, listener);
|
14463
|
+
this.client.dispatch(`onUnsubscribeHandlerAdded`, { handlerId });
|
14464
|
+
return listener;
|
14465
|
+
}
|
14466
|
+
async cleanUpAllSubs() {
|
14467
|
+
const listenerUnsubscribers = Array.from(this.listeners.keys());
|
14468
|
+
listenerUnsubscribers.forEach((handlerId) => {
|
14469
|
+
this.client.remove(handlerId);
|
14470
|
+
this.listeners.delete(handlerId);
|
14606
14471
|
});
|
14607
|
-
|
14608
|
-
|
14609
|
-
|
14472
|
+
}
|
14473
|
+
async disconnect() {
|
14474
|
+
try {
|
14475
|
+
await this.client.dispatch('clientDisconnecting');
|
14476
|
+
await this.cleanUpAllSubs();
|
14477
|
+
await this.client.disconnect();
|
14478
|
+
}
|
14479
|
+
catch (error) {
|
14480
|
+
throw new Error(error.message);
|
14610
14481
|
}
|
14611
|
-
return client.dispatch('joinContextGroup', { contextGroupId, target });
|
14612
|
-
}
|
14613
|
-
/**
|
14614
|
-
* Removes the specified target from a context group.
|
14615
|
-
* If no target is specified, it removes the sender from their context group.
|
14616
|
-
* Used by Platform Windows.
|
14617
|
-
*
|
14618
|
-
* @param target - Identity of the entity you wish to join to a context group.
|
14619
|
-
*
|
14620
|
-
* @example
|
14621
|
-
* ```js
|
14622
|
-
* removeViewFromContextGroup = async (view) => {
|
14623
|
-
* await fin.me.interop.removeFromContextGroup(view);
|
14624
|
-
* }
|
14625
|
-
*
|
14626
|
-
* getLastFocusedView()
|
14627
|
-
* .then(lastFocusedViewIdentity => {
|
14628
|
-
* removeViewFromContextGroup(lastFocusedViewIdentity)
|
14629
|
-
* })
|
14630
|
-
* ```
|
14631
|
-
*/
|
14632
|
-
async removeFromContextGroup(target) {
|
14633
|
-
this.wire.sendAction('interop-client-remove-from-context-group').catch((e) => {
|
14634
|
-
// don't expose, analytics-only call
|
14635
|
-
});
|
14636
|
-
const client = await __classPrivateFieldGet$2(this, _InteropClient_clientPromise, "f");
|
14637
|
-
return client.dispatch('removeFromContextGroup', { target });
|
14638
|
-
}
|
14639
|
-
/**
|
14640
|
-
* Gets all clients for a context group.
|
14641
|
-
*
|
14642
|
-
* @remarks **This is primarily used for platform windows. Views within a platform should not have to use this API.**
|
14643
|
-
*
|
14644
|
-
* Returns the Interop-Broker-defined context groups available for an entity to join.
|
14645
|
-
* @param contextGroupId - The id of context group you wish to get clients for.
|
14646
|
-
*
|
14647
|
-
* @example
|
14648
|
-
* ```js
|
14649
|
-
* fin.me.interop.getAllClientsInContextGroup('red')
|
14650
|
-
* .then(clientsInContextGroup => {
|
14651
|
-
* console.log(clientsInContextGroup)
|
14652
|
-
* })
|
14653
|
-
* ```
|
14654
|
-
*/
|
14655
|
-
async getAllClientsInContextGroup(contextGroupId) {
|
14656
|
-
this.wire.sendAction('interop-client-get-all-clients-in-context-group').catch((e) => {
|
14657
|
-
// don't expose, analytics-only call
|
14658
|
-
});
|
14659
|
-
const client = await __classPrivateFieldGet$2(this, _InteropClient_clientPromise, "f");
|
14660
|
-
if (!contextGroupId) {
|
14661
|
-
throw new Error('No contextGroupId specified for getAllClientsInContextGroup.');
|
14662
|
-
}
|
14663
|
-
return client.dispatch('getAllClientsInContextGroup', { contextGroupId });
|
14664
|
-
}
|
14665
|
-
/**
|
14666
|
-
* Gets display info for a context group
|
14667
|
-
*
|
14668
|
-
* @remarks Used by Platform Windows.
|
14669
|
-
* @param contextGroupId - The id of context group you wish to get display info for.
|
14670
|
-
*
|
14671
|
-
* @example
|
14672
|
-
* ```js
|
14673
|
-
* fin.me.interop.getInfoForContextGroup('red')
|
14674
|
-
* .then(contextGroupInfo => {
|
14675
|
-
* console.log(contextGroupInfo.displayMetadata.name)
|
14676
|
-
* console.log(contextGroupInfo.displayMetadata.color)
|
14677
|
-
* })
|
14678
|
-
* ```
|
14679
|
-
*/
|
14680
|
-
async getInfoForContextGroup(contextGroupId) {
|
14681
|
-
this.wire.sendAction('interop-client-get-info-for-context-group').catch((e) => {
|
14682
|
-
// don't expose, analytics-only call
|
14683
|
-
});
|
14684
|
-
const client = await __classPrivateFieldGet$2(this, _InteropClient_clientPromise, "f");
|
14685
|
-
if (!contextGroupId) {
|
14686
|
-
throw new Error('No contextGroupId specified for getInfoForContextGroup.');
|
14687
|
-
}
|
14688
|
-
return client.dispatch('getInfoForContextGroup', { contextGroupId });
|
14689
|
-
}
|
14690
|
-
/**
|
14691
|
-
* Sends an intent to the Interop Broker to resolve.
|
14692
|
-
* @param intent - The combination of an action and a context that is passed to an application for resolution.
|
14693
|
-
*
|
14694
|
-
* @example
|
14695
|
-
* ```js
|
14696
|
-
* // View wants to fire an Intent after a user clicks on a ticker
|
14697
|
-
* tickerElement.on('click', (element) => {
|
14698
|
-
* const ticker = element.innerText;
|
14699
|
-
* const intent = {
|
14700
|
-
* name: 'ViewChart',
|
14701
|
-
* context: {type: 'fdc3.instrument', id: { ticker }}
|
14702
|
-
* }
|
14703
|
-
*
|
14704
|
-
* fin.me.interop.fireIntent(intent);
|
14705
|
-
* })
|
14706
|
-
* ```
|
14707
|
-
*/
|
14708
|
-
async fireIntent(intent) {
|
14709
|
-
this.wire.sendAction('interop-client-fire-intent').catch((e) => {
|
14710
|
-
// don't expose, this is only for api analytics purposes
|
14711
|
-
});
|
14712
|
-
const client = await __classPrivateFieldGet$2(this, _InteropClient_clientPromise, "f");
|
14713
|
-
return client.dispatch('fireIntent', intent);
|
14714
|
-
}
|
14715
|
-
/**
|
14716
|
-
* Adds an intent handler for incoming intents. The last intent sent of the name subscribed to will be received.
|
14717
|
-
* @param handler - Registered function meant to handle a specific intent type.
|
14718
|
-
* @param intentName - The name of an intent.
|
14719
|
-
*
|
14720
|
-
* @example
|
14721
|
-
* ```js
|
14722
|
-
* const intentHandler = (intent) => {
|
14723
|
-
* const { context } = intent;
|
14724
|
-
* myViewChartHandler(context);
|
14725
|
-
* };
|
14726
|
-
*
|
14727
|
-
* const subscription = await fin.me.interop.registerIntentHandler(intentHandler, 'ViewChart');
|
14728
|
-
*
|
14729
|
-
* function myAppCloseSequence() {
|
14730
|
-
* // to unsubscribe the handler, simply call:
|
14731
|
-
* subscription.unsubscribe();
|
14732
|
-
* }
|
14733
|
-
* ```
|
14734
|
-
*/
|
14735
|
-
async registerIntentHandler(handler, intentName, options) {
|
14736
|
-
this.wire.sendAction('interop-client-register-intent-handler').catch((e) => {
|
14737
|
-
// don't expose, this is only for api analytics purposes
|
14738
|
-
});
|
14739
|
-
const client = await __classPrivateFieldGet$2(this, _InteropClient_clientPromise, "f");
|
14740
|
-
const handlerId = `intent-handler-${intentName}`;
|
14741
|
-
const wrappedHandler = (0, utils_1$2.wrapIntentHandler)(handler, handlerId);
|
14742
|
-
try {
|
14743
|
-
await client.register(handlerId, wrappedHandler);
|
14744
|
-
await client.dispatch('intentHandlerRegistered', { handlerId, ...options });
|
14745
|
-
}
|
14746
|
-
catch (error) {
|
14747
|
-
throw new Error('Unable to register intent handler');
|
14748
|
-
}
|
14749
|
-
return {
|
14750
|
-
unsubscribe: async () => {
|
14751
|
-
client.remove(handlerId);
|
14752
|
-
}
|
14753
|
-
};
|
14754
|
-
}
|
14755
|
-
/**
|
14756
|
-
* Gets the last context of the Context Group currently subscribed to. It takes an optional Context Type and returns the
|
14757
|
-
* last context of that type.
|
14758
|
-
* @param contextType
|
14759
|
-
*
|
14760
|
-
* @example
|
14761
|
-
* ```js
|
14762
|
-
* await fin.me.interop.joinContextGroup('yellow');
|
14763
|
-
* await fin.me.interop.setContext({ type: 'instrument', id: { ticker: 'FOO' }});
|
14764
|
-
* const currentContext = await fin.me.interop.getCurrentContext();
|
14765
|
-
*
|
14766
|
-
* // with a specific context
|
14767
|
-
* await fin.me.interop.joinContextGroup('yellow');
|
14768
|
-
* await fin.me.interop.setContext({ type: 'country', id: { ISOALPHA3: 'US' }});
|
14769
|
-
* await fin.me.interop.setContext({ type: 'instrument', id: { ticker: 'FOO' }});
|
14770
|
-
* const currentContext = await fin.me.interop.getCurrentContext('country');
|
14771
|
-
* ```
|
14772
|
-
*/
|
14773
|
-
async getCurrentContext(contextType) {
|
14774
|
-
this.wire.sendAction('interop-client-get-current-context').catch((e) => {
|
14775
|
-
// don't expose, analytics-only call
|
14776
|
-
});
|
14777
|
-
const client = await __classPrivateFieldGet$2(this, _InteropClient_clientPromise, "f");
|
14778
|
-
return client.dispatch('getCurrentContext', { contextType });
|
14779
|
-
}
|
14780
|
-
/**
|
14781
|
-
* Get information for a particular Intent from the Interop Broker.
|
14782
|
-
*
|
14783
|
-
* @remarks To resolve this info, the function handleInfoForIntent is meant to be overridden in the Interop Broker.
|
14784
|
-
* The format for the response will be determined by the App Provider overriding the function.
|
14785
|
-
*
|
14786
|
-
* @param options
|
14787
|
-
*
|
14788
|
-
* @example
|
14789
|
-
* ```js
|
14790
|
-
* const intentInfo = await fin.me.interop.getInfoForIntent('ViewChart');
|
14791
|
-
* ```
|
14792
|
-
*/
|
14793
|
-
async getInfoForIntent(options) {
|
14794
|
-
this.wire.sendAction('interop-client-get-info-for-intent').catch((e) => {
|
14795
|
-
// don't expose, analytics-only call
|
14796
|
-
});
|
14797
|
-
const client = await __classPrivateFieldGet$2(this, _InteropClient_clientPromise, "f");
|
14798
|
-
return client.dispatch('getInfoForIntent', options);
|
14799
|
-
}
|
14800
|
-
/**
|
14801
|
-
* Get information from the Interop Broker on all Intents that are meant to handle a particular context.
|
14802
|
-
*
|
14803
|
-
* @remarks To resolve this info, the function handleInfoForIntentsByContext is meant to be overridden in the Interop Broker.
|
14804
|
-
* The format for the response will be determined by the App Provider overriding the function.
|
14805
|
-
*
|
14806
|
-
* @param context
|
14807
|
-
*
|
14808
|
-
* @example
|
14809
|
-
* ```js
|
14810
|
-
* tickerElement.on('click', (element) => {
|
14811
|
-
* const ticker = element.innerText;
|
14812
|
-
*
|
14813
|
-
* const context = {
|
14814
|
-
* type: 'fdc3.instrument',
|
14815
|
-
* id: {
|
14816
|
-
* ticker
|
14817
|
-
* }
|
14818
|
-
* }
|
14819
|
-
*
|
14820
|
-
* const intentsInfo = await fin.me.interop.getInfoForIntentByContext(context);
|
14821
|
-
* })
|
14822
|
-
* ```
|
14823
|
-
*/
|
14824
|
-
async getInfoForIntentsByContext(context) {
|
14825
|
-
this.wire.sendAction('interop-client-get-info-for-intents-by-context').catch((e) => {
|
14826
|
-
// don't expose, analytics-only call
|
14827
|
-
});
|
14828
|
-
const client = await __classPrivateFieldGet$2(this, _InteropClient_clientPromise, "f");
|
14829
|
-
return client.dispatch('getInfoForIntentsByContext', context);
|
14830
|
-
}
|
14831
|
-
/**
|
14832
|
-
* Sends a Context that will be resolved to an Intent by the Interop Broker.
|
14833
|
-
* This context accepts a metadata property.
|
14834
|
-
*
|
14835
|
-
* @remarks To resolve this info, the function handleFiredIntentByContext is meant to be overridden in the Interop Broker.
|
14836
|
-
* The format for the response will be determined by the App Provider overriding the function.
|
14837
|
-
*
|
14838
|
-
* @param context
|
14839
|
-
*
|
14840
|
-
* @example
|
14841
|
-
* ```js
|
14842
|
-
* tickerElement.on('click', (element) => {
|
14843
|
-
* const ticker = element.innerText;
|
14844
|
-
*
|
14845
|
-
* const context = {
|
14846
|
-
* type: 'fdc3.instrument',
|
14847
|
-
* id: {
|
14848
|
-
* ticker
|
14849
|
-
* }
|
14850
|
-
* }
|
14851
|
-
*
|
14852
|
-
* const intentResolution = await fin.me.interop.fireIntentForContext(context);
|
14853
|
-
* })
|
14854
|
-
* ```
|
14855
|
-
*/
|
14856
|
-
async fireIntentForContext(context) {
|
14857
|
-
this.wire.sendAction('interop-client-fire-intent-for-context').catch((e) => {
|
14858
|
-
// don't expose, analytics-only call
|
14859
|
-
});
|
14860
|
-
const client = await __classPrivateFieldGet$2(this, _InteropClient_clientPromise, "f");
|
14861
|
-
return client.dispatch('fireIntentForContext', context);
|
14862
|
-
}
|
14863
|
-
/**
|
14864
|
-
* Join the current entity to session context group `sessionContextGroupId` and return a sessionContextGroup instance.
|
14865
|
-
* If the sessionContextGroup doesn't exist, one will get created.
|
14866
|
-
*
|
14867
|
-
* @remarks Session Context Groups do not persist between runs and aren't present on snapshots.
|
14868
|
-
* @param sessionContextGroupId - Id of the context group.
|
14869
|
-
*
|
14870
|
-
* @example
|
14871
|
-
* Say we want to have a Session Context Group that holds UI theme information for all apps to consume:
|
14872
|
-
*
|
14873
|
-
* My color-picker View:
|
14874
|
-
* ```js
|
14875
|
-
* const themeSessionContextGroup = await fin.me.interop.joinSessionContextGroup('theme');
|
14876
|
-
*
|
14877
|
-
* const myColorPickerElement = document.getElementById('color-palette-picker');
|
14878
|
-
* myColorPickerElement.addEventListener('change', event => {
|
14879
|
-
* themeSessionContextGroup.setContext({ type: 'color-palette', selection: event.value });
|
14880
|
-
* });
|
14881
|
-
* ```
|
14882
|
-
*
|
14883
|
-
* In other views:
|
14884
|
-
* ```js
|
14885
|
-
* const themeSessionContextGroup = await fin.me.interop.joinSessionContextGroup('theme');
|
14886
|
-
*
|
14887
|
-
* const changeColorPalette = ({ selection }) => {
|
14888
|
-
* // change the color palette to the selection
|
14889
|
-
* };
|
14890
|
-
*
|
14891
|
-
* // If the context is already set by the time the handler was set, the handler will get invoked immediately with the current context.
|
14892
|
-
* themeSessionContextGroup.addContextHandler(changeColorPalette, 'color-palette');
|
14893
|
-
* ```
|
14894
|
-
*/
|
14895
|
-
async joinSessionContextGroup(sessionContextGroupId) {
|
14896
|
-
try {
|
14897
|
-
const currentSessionContextGroup = __classPrivateFieldGet$2(this, _InteropClient_sessionContextGroups, "f").get(sessionContextGroupId);
|
14898
|
-
if (currentSessionContextGroup) {
|
14899
|
-
return currentSessionContextGroup.getUserInstance();
|
14900
|
-
}
|
14901
|
-
const client = await __classPrivateFieldGet$2(this, _InteropClient_clientPromise, "f");
|
14902
|
-
const { hasConflict } = await client.dispatch('sessionContextGroup:createIfNeeded', {
|
14903
|
-
sessionContextGroupId
|
14904
|
-
});
|
14905
|
-
if (hasConflict) {
|
14906
|
-
console.warn(`A (non-session) context group with the name "${sessionContextGroupId}" already exists. If you are trying to join a Context Group, call joinContextGroup instead.`);
|
14907
|
-
}
|
14908
|
-
const newSessionContextGroup = new SessionContextGroupClient_1.default(this.wire, __classPrivateFieldGet$2(this, _InteropClient_clientPromise, "f"), sessionContextGroupId);
|
14909
|
-
__classPrivateFieldGet$2(this, _InteropClient_sessionContextGroups, "f").set(sessionContextGroupId, newSessionContextGroup);
|
14910
|
-
return newSessionContextGroup.getUserInstance();
|
14911
|
-
}
|
14912
|
-
catch (error) {
|
14913
|
-
console.error(`Error thrown trying to create Session Context Group with id "${sessionContextGroupId}": ${error}`);
|
14914
|
-
throw error;
|
14915
|
-
}
|
14916
|
-
}
|
14917
|
-
/**
|
14918
|
-
* Register a listener that is called when the Interop Client has been disconnected from the Interop Broker.
|
14919
|
-
* Only one listener per Interop Client can be set.
|
14920
|
-
* @param listener
|
14921
|
-
*
|
14922
|
-
* @example
|
14923
|
-
* ```js
|
14924
|
-
* const listener = (event) => {
|
14925
|
-
* const { type, topic, brokerName} = event;
|
14926
|
-
* console.log(`Disconnected from Interop Broker ${brokerName} `);
|
14927
|
-
* }
|
14928
|
-
*
|
14929
|
-
* await fin.me.interop.onDisconnection(listener);
|
14930
|
-
* ```
|
14931
|
-
*/
|
14932
|
-
async onDisconnection(listener) {
|
14933
|
-
this.wire.sendAction('interop-client-add-ondisconnection-listener').catch((e) => {
|
14934
|
-
// don't expose, analytics-only call
|
14935
|
-
});
|
14936
|
-
const client = await __classPrivateFieldGet$2(this, _InteropClient_clientPromise, "f");
|
14937
|
-
return client.onDisconnection((event) => {
|
14938
|
-
const { uuid } = event;
|
14939
|
-
listener({ type: 'interop-broker', topic: 'disconnected', brokerName: uuid });
|
14940
|
-
});
|
14941
|
-
}
|
14942
|
-
/**
|
14943
|
-
* @internal
|
14944
|
-
*
|
14945
|
-
* Used to ferry fdc3-only calls from the fdc3 shim to the Interop Broker
|
14946
|
-
*/
|
14947
|
-
static async ferryFdc3Call(interopClient, action, payload) {
|
14948
|
-
const client = await __classPrivateFieldGet$2(interopClient, _InteropClient_clientPromise, "f");
|
14949
|
-
return client.dispatch(action, payload || null);
|
14950
14482
|
}
|
14951
14483
|
}
|
14952
|
-
|
14953
|
-
|
14484
|
+
PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
|
14485
|
+
|
14486
|
+
(function (exports) {
|
14487
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
14488
|
+
exports.getIntentResolution = exports.isChannel = exports.isContext = exports.connectPrivateChannel = exports.buildAppChannelObject = exports.buildPrivateChannelObject = exports.ChannelError = exports.ResultError = exports.UnsupportedChannelApiError = exports.getUnsupportedChannelApis = void 0;
|
14489
|
+
const utils_1 = utils$3;
|
14490
|
+
const PrivateChannelClient_1 = PrivateChannelClient$1;
|
14491
|
+
const lodash_1 = require$$3;
|
14492
|
+
const getUnsupportedChannelApis = (channelType) => {
|
14493
|
+
return {
|
14494
|
+
addContextListener: () => {
|
14495
|
+
throw new UnsupportedChannelApiError('Channel.addContextListener', channelType);
|
14496
|
+
},
|
14497
|
+
broadcast: () => {
|
14498
|
+
throw new UnsupportedChannelApiError('Channel.broadcast', channelType);
|
14499
|
+
},
|
14500
|
+
getCurrentContext: () => {
|
14501
|
+
throw new UnsupportedChannelApiError('Channel.getCurrentContext', channelType);
|
14502
|
+
}
|
14503
|
+
};
|
14504
|
+
};
|
14505
|
+
exports.getUnsupportedChannelApis = getUnsupportedChannelApis;
|
14506
|
+
class UnsupportedChannelApiError extends Error {
|
14507
|
+
constructor(apiName, channelType = 'System') {
|
14508
|
+
super(apiName);
|
14509
|
+
this.message = `Calling ${apiName} on an instance of a ${channelType} Channel returned by fdc3.get${channelType}Channels is not supported. If you would like to use a ${channelType} Channel, please use fdc3.joinChannel, fdc3.addContextListener, and fdc3.broadcast instead.`;
|
14510
|
+
}
|
14511
|
+
}
|
14512
|
+
exports.UnsupportedChannelApiError = UnsupportedChannelApiError;
|
14513
|
+
var ResultError;
|
14514
|
+
(function (ResultError) {
|
14515
|
+
/** Returned if the `IntentHandler` exited without returning a Promise or that
|
14516
|
+
* Promise was not resolved with a Context or Channel object.
|
14517
|
+
*/
|
14518
|
+
ResultError["NoResultReturned"] = "NoResultReturned";
|
14519
|
+
/** Returned if the `IntentHandler` function processing the raised intent
|
14520
|
+
* throws an error or rejects the Promise it returned.
|
14521
|
+
*/
|
14522
|
+
ResultError["IntentHandlerRejected"] = "IntentHandlerRejected";
|
14523
|
+
})(ResultError = exports.ResultError || (exports.ResultError = {}));
|
14524
|
+
(function (ChannelError) {
|
14525
|
+
/** Returned if the specified channel is not found when attempting to join a
|
14526
|
+
* channel via the `joinUserChannel` function of the DesktopAgent (`fdc3`).
|
14527
|
+
*/
|
14528
|
+
ChannelError["NoChannelFound"] = "NoChannelFound";
|
14529
|
+
/** SHOULD be returned when a request to join a user channel or to a retrieve
|
14530
|
+
* a Channel object via the `joinUserChannel` or `getOrCreateChannel` methods
|
14531
|
+
* of the DesktopAgent (`fdc3`) object is denied.
|
14532
|
+
*/
|
14533
|
+
ChannelError["AccessDenied"] = "AccessDenied";
|
14534
|
+
/** SHOULD be returned when a channel cannot be created or retrieved via the
|
14535
|
+
* `getOrCreateChannel` method of the DesktopAgent (`fdc3`).
|
14536
|
+
*/
|
14537
|
+
ChannelError["CreationFailed"] = "CreationFailed";
|
14538
|
+
})(exports.ChannelError || (exports.ChannelError = {}));
|
14539
|
+
const buildPrivateChannelObject = (privateChannelClient) => {
|
14540
|
+
let clientDisconnected = false;
|
14541
|
+
const checkIfClientDisconnected = () => {
|
14542
|
+
if (clientDisconnected) {
|
14543
|
+
throw new Error('Private Channel Client has been disconnected from the Private Channel');
|
14544
|
+
}
|
14545
|
+
};
|
14546
|
+
return {
|
14547
|
+
id: privateChannelClient.id,
|
14548
|
+
type: 'private',
|
14549
|
+
broadcast: async (context) => {
|
14550
|
+
checkIfClientDisconnected();
|
14551
|
+
return privateChannelClient.broadcast(context);
|
14552
|
+
},
|
14553
|
+
getCurrentContext: async (contextType) => {
|
14554
|
+
checkIfClientDisconnected();
|
14555
|
+
return privateChannelClient.getCurrentContext(contextType);
|
14556
|
+
},
|
14557
|
+
// @ts-expect-error TODO [CORE-1524]
|
14558
|
+
addContextListener: async (contextType, handler) => {
|
14559
|
+
checkIfClientDisconnected();
|
14560
|
+
let handlerInUse = handler;
|
14561
|
+
let contextTypeInUse = contextType;
|
14562
|
+
if (typeof contextType === 'function') {
|
14563
|
+
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
14564
|
+
handlerInUse = contextType;
|
14565
|
+
contextTypeInUse = null;
|
14566
|
+
}
|
14567
|
+
const listener = privateChannelClient.addContextListener(contextTypeInUse, handlerInUse);
|
14568
|
+
return listener;
|
14569
|
+
},
|
14570
|
+
onAddContextListener: (handler) => {
|
14571
|
+
checkIfClientDisconnected();
|
14572
|
+
return privateChannelClient.onAddContextListener(handler);
|
14573
|
+
},
|
14574
|
+
disconnect: async () => {
|
14575
|
+
checkIfClientDisconnected();
|
14576
|
+
clientDisconnected = true;
|
14577
|
+
return privateChannelClient.disconnect();
|
14578
|
+
},
|
14579
|
+
onDisconnect: (handler) => {
|
14580
|
+
checkIfClientDisconnected();
|
14581
|
+
return privateChannelClient.onDisconnect(handler);
|
14582
|
+
},
|
14583
|
+
onUnsubscribe: (handler) => {
|
14584
|
+
checkIfClientDisconnected();
|
14585
|
+
return privateChannelClient.onUnsubscribe(handler);
|
14586
|
+
}
|
14587
|
+
};
|
14588
|
+
};
|
14589
|
+
exports.buildPrivateChannelObject = buildPrivateChannelObject;
|
14590
|
+
const buildAppChannelObject = (sessionContextGroup) => {
|
14591
|
+
return {
|
14592
|
+
id: sessionContextGroup.id,
|
14593
|
+
type: 'app',
|
14594
|
+
broadcast: sessionContextGroup.setContext,
|
14595
|
+
getCurrentContext: async (contextType) => {
|
14596
|
+
const context = await sessionContextGroup.getCurrentContext(contextType);
|
14597
|
+
return context === undefined ? null : context;
|
14598
|
+
},
|
14599
|
+
// @ts-expect-error TODO [CORE-1524]
|
14600
|
+
addContextListener: (contextType, handler) => {
|
14601
|
+
let realHandler;
|
14602
|
+
let realType;
|
14603
|
+
if (typeof contextType === 'function') {
|
14604
|
+
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
14605
|
+
realHandler = contextType;
|
14606
|
+
}
|
14607
|
+
else {
|
14608
|
+
realHandler = handler;
|
14609
|
+
if (typeof contextType === 'string') {
|
14610
|
+
realType = contextType;
|
14611
|
+
}
|
14612
|
+
}
|
14613
|
+
const listener = (async () => {
|
14614
|
+
let first = true;
|
14615
|
+
const currentContext = await sessionContextGroup.getCurrentContext(realType);
|
14616
|
+
const wrappedHandler = (context, contextMetadata) => {
|
14617
|
+
if (first) {
|
14618
|
+
first = false;
|
14619
|
+
if ((0, lodash_1.isEqual)(currentContext, context)) {
|
14620
|
+
return;
|
14621
|
+
}
|
14622
|
+
}
|
14623
|
+
// eslint-disable-next-line consistent-return
|
14624
|
+
return realHandler(context, contextMetadata);
|
14625
|
+
};
|
14626
|
+
return sessionContextGroup.addContextHandler(wrappedHandler, realType);
|
14627
|
+
})();
|
14628
|
+
return {
|
14629
|
+
...listener,
|
14630
|
+
unsubscribe: () => listener.then((l) => l.unsubscribe())
|
14631
|
+
};
|
14632
|
+
}
|
14633
|
+
};
|
14634
|
+
};
|
14635
|
+
exports.buildAppChannelObject = buildAppChannelObject;
|
14636
|
+
const connectPrivateChannel = async (channelId) => {
|
14637
|
+
try {
|
14638
|
+
const channelClient = await fin.InterApplicationBus.Channel.connect(channelId);
|
14639
|
+
const privateChannelClient = new PrivateChannelClient_1.PrivateChannelClient(channelClient, channelId);
|
14640
|
+
return (0, exports.buildPrivateChannelObject)(privateChannelClient);
|
14641
|
+
}
|
14642
|
+
catch (error) {
|
14643
|
+
throw new Error(`Private Channel with id: ${channelId} doesn't exist`);
|
14644
|
+
}
|
14645
|
+
};
|
14646
|
+
exports.connectPrivateChannel = connectPrivateChannel;
|
14647
|
+
const isContext = (context) => {
|
14648
|
+
if (context && typeof context === 'object' && 'type' in context) {
|
14649
|
+
const { type } = context;
|
14650
|
+
return typeof type === 'string';
|
14651
|
+
}
|
14652
|
+
return false;
|
14653
|
+
};
|
14654
|
+
exports.isContext = isContext;
|
14655
|
+
const isChannel = (channel) => {
|
14656
|
+
if (channel && typeof channel === 'object' && 'type' in channel && 'id' in channel) {
|
14657
|
+
const { type, id } = channel;
|
14658
|
+
return typeof type === 'string' && typeof id === 'string' && (type === 'app' || type === 'private');
|
14659
|
+
}
|
14660
|
+
return false;
|
14661
|
+
};
|
14662
|
+
exports.isChannel = isChannel;
|
14663
|
+
const getIntentResolution = async (interopModule, context, app, intent) => {
|
14664
|
+
// Generate an ID to make a session context group with. We will pass that ID to the Broker.
|
14665
|
+
// The broker will then setContext on that session context group later with our Intent Result,
|
14666
|
+
const guid = (0, utils_1.generateId)(); // TODO make this undefined in web
|
14667
|
+
// Promise we'll use in getResult
|
14668
|
+
const getResultPromise = new Promise((resolve, reject) => {
|
14669
|
+
fin.InterApplicationBus.subscribe({ uuid: '*' }, guid, (intentResult) => {
|
14670
|
+
resolve(intentResult);
|
14671
|
+
}).catch(() => reject(new Error('getResult is not supported in this environment')));
|
14672
|
+
});
|
14673
|
+
// Adding the intentResolutionResultId to the intentObj. Because fireIntent only accepts a single arg, we have to slap it in here.
|
14674
|
+
const metadata = app ? { target: app, intentResolutionResultId: guid } : { intentResolutionResultId: guid };
|
14675
|
+
const intentObj = intent ? { name: intent, context, metadata } : { ...context, metadata };
|
14676
|
+
// Set up the getResult call.
|
14677
|
+
const getResult = async () => {
|
14678
|
+
let intentResult = await getResultPromise;
|
14679
|
+
if (!intentResult || typeof intentResult !== 'object') {
|
14680
|
+
throw new Error(ResultError.NoResultReturned);
|
14681
|
+
}
|
14682
|
+
const { error } = intentResult;
|
14683
|
+
if (error) {
|
14684
|
+
throw new Error(ResultError.IntentHandlerRejected);
|
14685
|
+
}
|
14686
|
+
if ((0, exports.isChannel)(intentResult)) {
|
14687
|
+
const { id, type } = intentResult;
|
14688
|
+
switch (type) {
|
14689
|
+
case 'private': {
|
14690
|
+
intentResult = await (0, exports.connectPrivateChannel)(id);
|
14691
|
+
break;
|
14692
|
+
}
|
14693
|
+
case 'app': {
|
14694
|
+
const sessionContextGroup = await interopModule.joinSessionContextGroup(id);
|
14695
|
+
intentResult = (0, exports.buildAppChannelObject)(sessionContextGroup);
|
14696
|
+
break;
|
14697
|
+
}
|
14698
|
+
}
|
14699
|
+
}
|
14700
|
+
else if (!(0, exports.isContext)(intentResult)) {
|
14701
|
+
throw new Error(ResultError.NoResultReturned);
|
14702
|
+
}
|
14703
|
+
return intentResult;
|
14704
|
+
};
|
14705
|
+
// Finally fire the intent.
|
14706
|
+
const intentResolutionInfoFromBroker = intent
|
14707
|
+
? await interopModule.fireIntent(intentObj)
|
14708
|
+
: await interopModule.fireIntentForContext(intentObj);
|
14709
|
+
if (typeof intentResolutionInfoFromBroker !== 'object') {
|
14710
|
+
return {
|
14711
|
+
source: {
|
14712
|
+
appId: '',
|
14713
|
+
instanceId: ''
|
14714
|
+
},
|
14715
|
+
intent: '',
|
14716
|
+
version: '2.0',
|
14717
|
+
getResult
|
14718
|
+
};
|
14719
|
+
}
|
14720
|
+
return { ...intentResolutionInfoFromBroker, getResult };
|
14721
|
+
};
|
14722
|
+
exports.getIntentResolution = getIntentResolution;
|
14723
|
+
} (utils$2));
|
14724
|
+
|
14725
|
+
var hasRequiredFdc3Common;
|
14726
|
+
|
14727
|
+
function requireFdc3Common () {
|
14728
|
+
if (hasRequiredFdc3Common) return fdc3Common;
|
14729
|
+
hasRequiredFdc3Common = 1;
|
14730
|
+
var __classPrivateFieldGet = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
14731
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
14732
|
+
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");
|
14733
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
14734
|
+
};
|
14735
|
+
var __classPrivateFieldSet = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
14736
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
14737
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
14738
|
+
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");
|
14739
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
14740
|
+
};
|
14741
|
+
var _FDC3ModuleBase_producer;
|
14742
|
+
Object.defineProperty(fdc3Common, "__esModule", { value: true });
|
14743
|
+
fdc3Common.FDC3ModuleBase = void 0;
|
14744
|
+
const utils_1 = utils$2;
|
14745
|
+
const utils_2 = utils$3;
|
14746
|
+
const InteropClient_1 = requireInteropClient();
|
14747
|
+
const lodash_1 = require$$3;
|
14748
|
+
class FDC3ModuleBase {
|
14749
|
+
get client() {
|
14750
|
+
return __classPrivateFieldGet(this, _FDC3ModuleBase_producer, "f").call(this);
|
14751
|
+
}
|
14752
|
+
get fin() {
|
14753
|
+
return this.wire.getFin();
|
14754
|
+
}
|
14755
|
+
// eslint-disable-next-line no-useless-constructor
|
14756
|
+
constructor(producer, wire) {
|
14757
|
+
this.wire = wire;
|
14758
|
+
_FDC3ModuleBase_producer.set(this, void 0);
|
14759
|
+
__classPrivateFieldSet(this, _FDC3ModuleBase_producer, producer, "f");
|
14760
|
+
}
|
14761
|
+
/**
|
14762
|
+
* Broadcasts a context for the channel of the current entity.
|
14763
|
+
* @param context - New context to set.
|
14764
|
+
*
|
14765
|
+
* @tutorial fdc3.broadcast
|
14766
|
+
* @static
|
14767
|
+
*/
|
14768
|
+
async broadcast(context) {
|
14769
|
+
this.wire.sendAction('fdc3-broadcast').catch((e) => {
|
14770
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
14771
|
+
});
|
14772
|
+
return this.client.setContext(context);
|
14773
|
+
}
|
14774
|
+
/**
|
14775
|
+
* Launches an app with target information, which can either be a string or an AppMetadata object.
|
14776
|
+
* @param app
|
14777
|
+
* @param context
|
14778
|
+
*
|
14779
|
+
* @tutorial fdc3.open
|
14780
|
+
*/
|
14781
|
+
async _open(app, context) {
|
14782
|
+
this.wire.sendAction('fdc3-open').catch((e) => {
|
14783
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
14784
|
+
});
|
14785
|
+
try {
|
14786
|
+
return await InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'fdc3Open', { app, context });
|
14787
|
+
}
|
14788
|
+
catch (error) {
|
14789
|
+
const errorToThrow = error.message === utils_2.BROKER_ERRORS.fdc3Open ? 'ResolverUnavailable' : error.message;
|
14790
|
+
throw new Error(errorToThrow);
|
14791
|
+
}
|
14792
|
+
}
|
14793
|
+
/**
|
14794
|
+
* Returns a Channel object for the specified channel, creating it as an App Channel if it does not exist.
|
14795
|
+
* @param channelId
|
14796
|
+
*
|
14797
|
+
* @tutorial fdc3.getOrCreateChannel
|
14798
|
+
*/
|
14799
|
+
async getOrCreateChannel(channelId) {
|
14800
|
+
this.wire.sendAction('fdc3-get-or-create-channel').catch((e) => {
|
14801
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
14802
|
+
});
|
14803
|
+
const systemChannels = await this.getSystemChannels();
|
14804
|
+
const userChannel = systemChannels.find((channel) => channel.id === channelId);
|
14805
|
+
if (userChannel) {
|
14806
|
+
return { ...userChannel, type: 'system', ...(0, utils_1.getUnsupportedChannelApis)() };
|
14807
|
+
}
|
14808
|
+
try {
|
14809
|
+
const sessionContextGroup = await this.client.joinSessionContextGroup(channelId);
|
14810
|
+
return (0, utils_1.buildAppChannelObject)(sessionContextGroup);
|
14811
|
+
}
|
14812
|
+
catch (error) {
|
14813
|
+
console.error(error.message);
|
14814
|
+
throw new Error(utils_1.ChannelError.CreationFailed);
|
14815
|
+
}
|
14816
|
+
}
|
14817
|
+
/**
|
14818
|
+
* Returns the Interop-Broker-defined context groups available for an entity to join.
|
14819
|
+
*
|
14820
|
+
* @tutorial fdc3.getSystemChannels
|
14821
|
+
* @static
|
14822
|
+
*/
|
14823
|
+
async getSystemChannels() {
|
14824
|
+
this.wire.sendAction('fdc3-get-system-channels').catch((e) => {
|
14825
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
14826
|
+
});
|
14827
|
+
const channels = await this.client.getContextGroups();
|
14828
|
+
// fdc3 implementation of getSystemChannels returns on array of channels, have to decorate over
|
14829
|
+
// this so people know that these APIs are not supported
|
14830
|
+
return channels.map((channel) => {
|
14831
|
+
return { ...channel, type: 'system', ...(0, utils_1.getUnsupportedChannelApis)() };
|
14832
|
+
});
|
14833
|
+
}
|
14834
|
+
/**
|
14835
|
+
* Join all Interop Clients at the given identity to context group `contextGroupId`.
|
14836
|
+
* If no target is specified, it adds the sender to the context group.
|
14837
|
+
* Because multiple Channel connections/Interop Clients can potentially exist at a `uuid`/`name` combo, we currently join all Channel connections/Interop Clients at the given identity to the context group.
|
14838
|
+
* If an `endpointId` is provided (which is unlikely, unless the call is coming from an external adapter), then we only join that single connection to the context group.
|
14839
|
+
* For all intents and purposes, there will only be 1 connection present in Platform and Browser implementations, so this point is more-or-less moot.
|
14840
|
+
* @param channelId - Id of the context group.
|
14841
|
+
*
|
14842
|
+
* @tutorial fdc3.joinChannel
|
14843
|
+
* @static
|
14844
|
+
*/
|
14845
|
+
async joinChannel(channelId) {
|
14846
|
+
this.wire.sendAction('fdc3-join-channel').catch((e) => {
|
14847
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
14848
|
+
});
|
14849
|
+
try {
|
14850
|
+
return await this.client.joinContextGroup(channelId);
|
14851
|
+
}
|
14852
|
+
catch (error) {
|
14853
|
+
if (error.message === utils_2.BROKER_ERRORS.joinSessionContextGroupWithJoinContextGroup) {
|
14854
|
+
console.error('The Channel you have tried to join is an App Channel. Custom Channels can only be defined by the Interop Broker through code or manifest configuration. Please use getOrCreateChannel.');
|
14855
|
+
}
|
14856
|
+
else {
|
14857
|
+
console.error(error.message);
|
14858
|
+
}
|
14859
|
+
if (error.message.startsWith('Attempting to join a context group that does not exist')) {
|
14860
|
+
throw new Error(utils_1.ChannelError.NoChannelFound);
|
14861
|
+
}
|
14862
|
+
throw new Error(utils_1.ChannelError.AccessDenied);
|
14863
|
+
}
|
14864
|
+
}
|
14865
|
+
/**
|
14866
|
+
* Returns the Channel that the entity is subscribed to. Returns null if not joined to a channel.
|
14867
|
+
*
|
14868
|
+
* @tutorial fdc3.getCurrentChannel
|
14869
|
+
*/
|
14870
|
+
async getCurrentChannel() {
|
14871
|
+
this.wire.sendAction('fdc3-get-current-channel').catch((e) => {
|
14872
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
14873
|
+
});
|
14874
|
+
const currentContextGroupInfo = await this.getCurrentContextGroupInfo();
|
14875
|
+
if (!currentContextGroupInfo) {
|
14876
|
+
return null;
|
14877
|
+
}
|
14878
|
+
return this.buildChannelObject(currentContextGroupInfo);
|
14879
|
+
}
|
14880
|
+
/**
|
14881
|
+
* Removes the specified target from a context group.
|
14882
|
+
* If no target is specified, it removes the sender from their context group.
|
14883
|
+
*
|
14884
|
+
* @tutorial fdc3.leaveCurrentChannel
|
14885
|
+
* @static
|
14886
|
+
*/
|
14887
|
+
async leaveCurrentChannel() {
|
14888
|
+
this.wire.sendAction('fdc3-leave-current-channel').catch((e) => {
|
14889
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
14890
|
+
});
|
14891
|
+
return this.client.removeFromContextGroup();
|
14892
|
+
}
|
14893
|
+
// utils
|
14894
|
+
// eslint-disable-next-line class-methods-use-this
|
14895
|
+
async getCurrentContextGroupInfo() {
|
14896
|
+
const contextGroups = await this.client.getContextGroups();
|
14897
|
+
const clientsInCtxGroupsPromise = contextGroups.map(async (ctxGroup) => {
|
14898
|
+
return this.client.getAllClientsInContextGroup(ctxGroup.id);
|
14899
|
+
});
|
14900
|
+
const clientsInCtxGroups = await Promise.all(clientsInCtxGroupsPromise);
|
14901
|
+
const clientIdx = clientsInCtxGroups.findIndex((clientIdentityArr) => {
|
14902
|
+
return clientIdentityArr.some((clientIdentity) => {
|
14903
|
+
const { uuid, name } = clientIdentity;
|
14904
|
+
return this.wire.me.uuid === uuid && this.wire.me.name === name;
|
14905
|
+
});
|
14906
|
+
});
|
14907
|
+
return contextGroups[clientIdx];
|
14908
|
+
}
|
14909
|
+
async buildChannelObject(currentContextGroupInfo) {
|
14910
|
+
// @ts-expect-error
|
14911
|
+
return {
|
14912
|
+
...currentContextGroupInfo,
|
14913
|
+
type: 'system',
|
14914
|
+
addContextListener: (...[contextType, handler]) => {
|
14915
|
+
let realHandler;
|
14916
|
+
let realType;
|
14917
|
+
if (typeof contextType === 'function') {
|
14918
|
+
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
14919
|
+
realHandler = contextType;
|
14920
|
+
}
|
14921
|
+
else {
|
14922
|
+
realHandler = handler;
|
14923
|
+
if (typeof contextType === 'string') {
|
14924
|
+
realType = contextType;
|
14925
|
+
}
|
14926
|
+
}
|
14927
|
+
const listener = (async () => {
|
14928
|
+
let first = true;
|
14929
|
+
const currentContext = await this.client.getCurrentContext(realType);
|
14930
|
+
const wrappedHandler = (context, contextMetadata) => {
|
14931
|
+
if (first) {
|
14932
|
+
first = false;
|
14933
|
+
if ((0, lodash_1.isEqual)(currentContext, context)) {
|
14934
|
+
return;
|
14935
|
+
}
|
14936
|
+
}
|
14937
|
+
// eslint-disable-next-line consistent-return
|
14938
|
+
return realHandler(context, contextMetadata);
|
14939
|
+
};
|
14940
|
+
return this.client.addContextHandler(wrappedHandler, realType);
|
14941
|
+
})();
|
14942
|
+
// @ts-expect-error TODO [CORE-1524]
|
14943
|
+
return {
|
14944
|
+
...listener,
|
14945
|
+
unsubscribe: () => listener.then((l) => l.unsubscribe())
|
14946
|
+
};
|
14947
|
+
},
|
14948
|
+
broadcast: this.broadcast.bind(this),
|
14949
|
+
// @ts-expect-error Typescript fails to infer the returntype is a Promise
|
14950
|
+
getCurrentContext: async (contextType) => {
|
14951
|
+
const context = await this.client.getCurrentContext(contextType);
|
14952
|
+
// @ts-expect-error Typescript fails to infer the returntype is a Promise
|
14953
|
+
return context === undefined ? null : context;
|
14954
|
+
}
|
14955
|
+
};
|
14956
|
+
}
|
14957
|
+
}
|
14958
|
+
fdc3Common.FDC3ModuleBase = FDC3ModuleBase;
|
14959
|
+
_FDC3ModuleBase_producer = new WeakMap();
|
14960
|
+
return fdc3Common;
|
14961
|
+
}
|
14962
|
+
|
14963
|
+
var hasRequiredFdc31_2;
|
14964
|
+
|
14965
|
+
function requireFdc31_2 () {
|
14966
|
+
if (hasRequiredFdc31_2) return fdc31_2;
|
14967
|
+
hasRequiredFdc31_2 = 1;
|
14968
|
+
Object.defineProperty(fdc31_2, "__esModule", { value: true });
|
14969
|
+
fdc31_2.Fdc3Module = void 0;
|
14970
|
+
const utils_1 = utils$3;
|
14971
|
+
const fdc3_common_1 = requireFdc3Common();
|
14972
|
+
/**
|
14973
|
+
* @version 1.2
|
14974
|
+
* The FDC3 Client Library provides a set APIs to be used for FDC3 compliance,
|
14975
|
+
* while using our Interop API under the hood. In order to use this set of APIs
|
14976
|
+
* you will need to set up your own {@link InteropBroker InteropBroker} or use a Platform application, which does the setup for you. Refer to our documentation on
|
14977
|
+
* our {@link https://developers.openfin.co/of-docs/docs/enable-color-linking Interop API}.
|
14978
|
+
*
|
14979
|
+
* To enable the FDC3 APIs in a {@link Window Window} or {@link View View}, add the fdc3InteropApi
|
14980
|
+
* property to its options:
|
14981
|
+
*
|
14982
|
+
* ```js
|
14983
|
+
* {
|
14984
|
+
* autoShow: false,
|
14985
|
+
* saveWindowState: true,
|
14986
|
+
* url: 'https://openfin.co',
|
14987
|
+
* fdc3InteropApi: '1.2'
|
14988
|
+
* }
|
14989
|
+
* ```
|
14990
|
+
*
|
14991
|
+
* If using a {@link Platform Platform } application, you can set this property in defaultWindowOptions and defaultViewOptions.
|
14992
|
+
*
|
14993
|
+
* In order to ensure that the FDC3 Api is ready before use, you can use the 'fdc3Ready' event fired on the DOM Window object:
|
14994
|
+
*
|
14995
|
+
* ```js
|
14996
|
+
* function fdc3Action() {
|
14997
|
+
* // Make some fdc3 API calls here
|
14998
|
+
* }
|
14999
|
+
*
|
15000
|
+
* if (window.fdc3) {
|
15001
|
+
* fdc3Action();
|
15002
|
+
* } else {
|
15003
|
+
* window.addEventListener('fdc3Ready', fdc3Action);
|
15004
|
+
* }
|
15005
|
+
* ```
|
15006
|
+
*/
|
15007
|
+
class Fdc3Module extends fdc3_common_1.FDC3ModuleBase {
|
15008
|
+
async open(app, context) {
|
15009
|
+
// eslint-disable-next-line no-underscore-dangle
|
15010
|
+
await super._open(app, context);
|
15011
|
+
}
|
15012
|
+
/**
|
15013
|
+
* Add a context handler for incoming context. If an entity is part of a context group, and then sets its context handler, it will receive all of its declared contexts. If you wish to listen for all incoming contexts, pass `null` for the contextType argument.
|
15014
|
+
* @param contextType - The type of context you wish to handle.
|
15015
|
+
* @param handler - Handler for incoming context.
|
15016
|
+
*
|
15017
|
+
* @tutorial fdc3.addContextListener
|
15018
|
+
* @static
|
15019
|
+
*/
|
15020
|
+
// @ts-expect-error TODO [CORE-1524]
|
15021
|
+
addContextListener(contextType, handler) {
|
15022
|
+
this.wire.sendAction('fdc3-add-context-listener').catch((e) => {
|
15023
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
15024
|
+
});
|
15025
|
+
let listener;
|
15026
|
+
if (typeof contextType === 'function') {
|
15027
|
+
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
15028
|
+
listener = this.client.addContextHandler(contextType);
|
15029
|
+
}
|
15030
|
+
else {
|
15031
|
+
listener = this.client.addContextHandler(handler, contextType === null ? undefined : contextType);
|
15032
|
+
}
|
15033
|
+
return {
|
15034
|
+
...listener,
|
15035
|
+
unsubscribe: () => listener.then((l) => l.unsubscribe())
|
15036
|
+
};
|
15037
|
+
}
|
15038
|
+
/**
|
15039
|
+
* Adds a listener for incoming Intents.
|
15040
|
+
* @param intent - Name of the Intent
|
15041
|
+
* @param handler - Handler for incoming Intent
|
15042
|
+
*
|
15043
|
+
* @tutorial fdc3.addIntentListener
|
15044
|
+
* @static
|
15045
|
+
*/
|
15046
|
+
addIntentListener(intent, handler) {
|
15047
|
+
this.wire.sendAction('fdc3-add-intent-listener').catch((e) => {
|
15048
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
15049
|
+
});
|
15050
|
+
const contextHandler = (raisedIntent) => {
|
15051
|
+
const { context, metadata: intentMetadata } = raisedIntent;
|
15052
|
+
const { metadata } = context;
|
15053
|
+
const intentResolutionResultId = intentMetadata?.intentResolutionResultId || metadata?.intentResolutionResultId;
|
15054
|
+
if (intentResolutionResultId) {
|
15055
|
+
this.fin.InterApplicationBus.publish(intentResolutionResultId, null).catch(() => null);
|
15056
|
+
}
|
15057
|
+
handler(raisedIntent.context);
|
15058
|
+
};
|
15059
|
+
const listener = this.client.registerIntentHandler(contextHandler, intent, {
|
15060
|
+
fdc3Version: '1.2'
|
15061
|
+
});
|
15062
|
+
return {
|
15063
|
+
...listener,
|
15064
|
+
unsubscribe: () => listener.then((l) => l.unsubscribe())
|
15065
|
+
};
|
15066
|
+
}
|
15067
|
+
/**
|
15068
|
+
* Raises a specific intent.
|
15069
|
+
* @param intent Name of the Intent.
|
15070
|
+
* @param context Context associated with the Intent.
|
15071
|
+
* @param app App that will resolve the Intent. This is added as metadata to the Intent. Can be accessed by the app provider in {@link InteropBroker#handleFiredIntent InteropBroker.handleFiredIntent}.
|
15072
|
+
*
|
15073
|
+
* @tutorial fdc3.raiseIntent
|
15074
|
+
* @static
|
15075
|
+
*/
|
15076
|
+
async raiseIntent(intent, context, app) {
|
15077
|
+
this.wire.sendAction('fdc3-raise-intent').catch((e) => {
|
15078
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
15079
|
+
});
|
15080
|
+
const intentObj = app
|
15081
|
+
? { name: intent, context, metadata: { target: app } }
|
15082
|
+
: { name: intent, context };
|
15083
|
+
try {
|
15084
|
+
return await this.client.fireIntent(intentObj);
|
15085
|
+
}
|
15086
|
+
catch (error) {
|
15087
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.fireIntent ? 'ResolverUnavailable' : error.message;
|
15088
|
+
throw new Error(errorToThrow);
|
15089
|
+
}
|
15090
|
+
}
|
15091
|
+
/**
|
15092
|
+
* Find out more information about a particular intent by passing its name, and optionally its context.
|
15093
|
+
* @param intent Name of the Intent
|
15094
|
+
* @param context
|
15095
|
+
*
|
15096
|
+
* @tutorial fdc3.findIntent
|
15097
|
+
*/
|
15098
|
+
async findIntent(intent, context) {
|
15099
|
+
this.wire.sendAction('fdc3-find-intent').catch((e) => {
|
15100
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
15101
|
+
});
|
15102
|
+
try {
|
15103
|
+
return await this.client.getInfoForIntent({ name: intent, context });
|
15104
|
+
}
|
15105
|
+
catch (error) {
|
15106
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.getInfoForIntent ? 'ResolverUnavailable' : error.message;
|
15107
|
+
throw new Error(errorToThrow);
|
15108
|
+
}
|
15109
|
+
}
|
15110
|
+
/**
|
15111
|
+
* Find all the available intents for a particular context.
|
15112
|
+
* @param context
|
15113
|
+
*
|
15114
|
+
* @tutorial fdc3.findIntentsByContext
|
15115
|
+
*/
|
15116
|
+
async findIntentsByContext(context) {
|
15117
|
+
this.wire.sendAction('fdc3-find-intents-by-context').catch((e) => {
|
15118
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
15119
|
+
});
|
15120
|
+
try {
|
15121
|
+
return await this.client.getInfoForIntentsByContext(context);
|
15122
|
+
}
|
15123
|
+
catch (error) {
|
15124
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.getInfoForIntentsByContext ? 'ResolverUnavailable' : error.message;
|
15125
|
+
throw new Error(errorToThrow);
|
15126
|
+
}
|
15127
|
+
}
|
15128
|
+
/**
|
15129
|
+
* Finds and raises an intent against a target app based purely on context data.
|
15130
|
+
* @param context
|
15131
|
+
* @param app
|
15132
|
+
*
|
15133
|
+
* @tutorial fdc3.raiseIntentForContext
|
15134
|
+
*/
|
15135
|
+
async raiseIntentForContext(context, app) {
|
15136
|
+
this.wire.sendAction('fdc3-raise-intent-for-context').catch((e) => {
|
15137
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
15138
|
+
});
|
15139
|
+
try {
|
15140
|
+
return await this.client.fireIntentForContext({ ...context, metadata: { target: app } });
|
15141
|
+
}
|
15142
|
+
catch (error) {
|
15143
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.fireIntentForContext ? 'ResolverUnavailable' : error.message;
|
15144
|
+
throw new Error(errorToThrow);
|
15145
|
+
}
|
15146
|
+
}
|
15147
|
+
/**
|
15148
|
+
* Returns a Channel object for the specified channel, creating it as an App Channel if it does not exist.
|
15149
|
+
* @param channelId
|
15150
|
+
*
|
15151
|
+
* @tutorial fdc3.getOrCreateChannel
|
15152
|
+
*/
|
15153
|
+
async getOrCreateChannel(channelId) {
|
15154
|
+
return super.getOrCreateChannel(channelId);
|
15155
|
+
}
|
15156
|
+
/**
|
15157
|
+
* Returns metadata relating to the FDC3 object and its provider, including the supported version of the FDC3 specification and the name of the provider of the implementation.
|
15158
|
+
*
|
15159
|
+
* @tutorial fdc3.getInfo
|
15160
|
+
*/
|
15161
|
+
getInfo() {
|
15162
|
+
this.wire.sendAction('fdc3-get-info').catch((e) => {
|
15163
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
15164
|
+
});
|
15165
|
+
// @ts-expect-error
|
15166
|
+
const { uuid, fdc3InteropApi } = fin.__internal_.initialOptions;
|
15167
|
+
// @ts-expect-error
|
15168
|
+
const runtimeVersion = fin.desktop.getVersion();
|
15169
|
+
return {
|
15170
|
+
fdc3Version: fdc3InteropApi,
|
15171
|
+
provider: `openfin-${uuid}`,
|
15172
|
+
providerVersion: runtimeVersion
|
15173
|
+
};
|
15174
|
+
}
|
15175
|
+
}
|
15176
|
+
fdc31_2.Fdc3Module = Fdc3Module;
|
15177
|
+
return fdc31_2;
|
15178
|
+
}
|
15179
|
+
|
15180
|
+
var fdc32_0 = {};
|
15181
|
+
|
15182
|
+
var hasRequiredFdc32_0;
|
15183
|
+
|
15184
|
+
function requireFdc32_0 () {
|
15185
|
+
if (hasRequiredFdc32_0) return fdc32_0;
|
15186
|
+
hasRequiredFdc32_0 = 1;
|
15187
|
+
Object.defineProperty(fdc32_0, "__esModule", { value: true });
|
15188
|
+
fdc32_0.Fdc3Module2 = void 0;
|
15189
|
+
const fdc3_common_1 = requireFdc3Common();
|
15190
|
+
const utils_1 = utils$3;
|
15191
|
+
const InteropClient_1 = requireInteropClient();
|
15192
|
+
const utils_2 = utils$2;
|
15193
|
+
const PrivateChannelClient_1 = PrivateChannelClient$1;
|
15194
|
+
/**
|
15195
|
+
* @version 2.0
|
15196
|
+
* The FDC3 Client Library provides a set APIs to be used for FDC3 compliance,
|
15197
|
+
* while using our Interop API under the hood. In order to use this set of APIs
|
15198
|
+
* you will need to set up your own {@link InteropBroker InteropBroker} or use a Platform application, which does the setup for you. Refer to our documentation on
|
15199
|
+
* our {@link https://developers.openfin.co/of-docs/docs/enable-context-sharing Interop API}.
|
15200
|
+
*
|
15201
|
+
* To enable the FDC3 APIs in a {@link Window Window} or {@link View View}, add the fdc3InteropApi
|
15202
|
+
* property to its options:
|
15203
|
+
*
|
15204
|
+
* ```js
|
15205
|
+
* {
|
15206
|
+
* autoShow: false,
|
15207
|
+
* saveWindowState: true,
|
15208
|
+
* url: 'https://openfin.co',
|
15209
|
+
* fdc3InteropApi: '2.0'
|
15210
|
+
* }
|
15211
|
+
* ```
|
15212
|
+
*
|
15213
|
+
* If using a {@link Platform Platform } application, you can set this property in defaultWindowOptions and defaultViewOptions.
|
15214
|
+
*
|
15215
|
+
* In order to ensure that the FDC3 Api is ready before use, you can use the 'fdc3Ready' event fired on the DOM Window object:
|
15216
|
+
*
|
15217
|
+
* ```js
|
15218
|
+
* function fdc3Action() {
|
15219
|
+
* // Make some fdc3 API calls here
|
15220
|
+
* }
|
15221
|
+
*
|
15222
|
+
* if (window.fdc3) {
|
15223
|
+
* fdc3Action();
|
15224
|
+
* } else {
|
15225
|
+
* window.addEventListener('fdc3Ready', fdc3Action);
|
15226
|
+
* }
|
15227
|
+
* ```
|
15228
|
+
*/
|
15229
|
+
class Fdc3Module2 extends fdc3_common_1.FDC3ModuleBase {
|
15230
|
+
/**
|
15231
|
+
* Launches an app, specified via an AppIdentifier object.
|
15232
|
+
* @param app
|
15233
|
+
* @param context
|
15234
|
+
*
|
15235
|
+
* @tutorial fdc3.open
|
15236
|
+
*/
|
15237
|
+
async open(app, context) {
|
15238
|
+
if (typeof app === 'string') {
|
15239
|
+
console.warn('Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string }).');
|
15240
|
+
}
|
15241
|
+
// eslint-disable-next-line no-underscore-dangle
|
15242
|
+
return super._open(app, context);
|
15243
|
+
}
|
15244
|
+
/**
|
15245
|
+
* Find all the available instances for a particular application.
|
15246
|
+
* @param app
|
15247
|
+
*
|
15248
|
+
* @tutorial fdc3v2.findInstances
|
15249
|
+
*/
|
15250
|
+
async findInstances(app) {
|
15251
|
+
this.wire.sendAction('fdc3-find-instances').catch((e) => {
|
15252
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
15253
|
+
});
|
15254
|
+
try {
|
15255
|
+
return await InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'fdc3FindInstances', app);
|
15256
|
+
}
|
15257
|
+
catch (error) {
|
15258
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.fdc3FindInstances ? 'ResolverUnavailable' : error.message;
|
15259
|
+
throw new Error(errorToThrow);
|
15260
|
+
}
|
15261
|
+
}
|
15262
|
+
/**
|
15263
|
+
* Retrieves the AppMetadata for an AppIdentifier, which provides additional metadata (such as icons, a title and description) from the App Directory record for the application, that may be used for display purposes.
|
15264
|
+
* @param app
|
15265
|
+
*
|
15266
|
+
* @tutorial fdc3v2.getAppMetadata
|
15267
|
+
*/
|
15268
|
+
async getAppMetadata(app) {
|
15269
|
+
this.wire.sendAction('fdc3-get-app-metadata').catch((e) => {
|
15270
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
15271
|
+
});
|
15272
|
+
try {
|
15273
|
+
return await InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'fdc3GetAppMetadata', app);
|
15274
|
+
}
|
15275
|
+
catch (error) {
|
15276
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.fdc3GetAppMetadata ? 'ResolverUnavailable' : error.message;
|
15277
|
+
throw new Error(errorToThrow);
|
15278
|
+
}
|
15279
|
+
}
|
15280
|
+
/**
|
15281
|
+
* Add a context handler for incoming context. If an entity is part of a context group, and then sets its context handler, it will receive all of its declared contexts. If you wish to listen for all incoming contexts, pass `null` for the contextType argument.
|
15282
|
+
* @param contextType
|
15283
|
+
* @param handler
|
15284
|
+
*
|
15285
|
+
* @tutorial fdc3.addContextListener
|
15286
|
+
*/
|
15287
|
+
// @ts-expect-error TODO [CORE-1524]
|
15288
|
+
async addContextListener(contextType, handler) {
|
15289
|
+
this.wire.sendAction('fdc3-add-context-listener').catch((e) => {
|
15290
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
15291
|
+
});
|
15292
|
+
// The FDC3 ContextHandler only expects the context and optional ContextMetadata, so we wrap the handler
|
15293
|
+
// here so it only gets passed these parameters
|
15294
|
+
const getWrappedHandler = (handlerToWrap) => {
|
15295
|
+
return (context) => {
|
15296
|
+
const { contextMetadata, ...rest } = context;
|
15297
|
+
const args = contextMetadata ? [{ ...rest }, contextMetadata] : [context, null];
|
15298
|
+
handlerToWrap(...args);
|
15299
|
+
};
|
15300
|
+
};
|
15301
|
+
let actualHandler = handler;
|
15302
|
+
let wrappedHandler = getWrappedHandler(actualHandler);
|
15303
|
+
if (typeof contextType === 'function') {
|
15304
|
+
console.warn('addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)');
|
15305
|
+
actualHandler = contextType;
|
15306
|
+
wrappedHandler = getWrappedHandler(actualHandler);
|
15307
|
+
return this.client.addContextHandler(wrappedHandler);
|
15308
|
+
}
|
15309
|
+
return this.client.addContextHandler(wrappedHandler, contextType === null ? undefined : contextType);
|
15310
|
+
}
|
15311
|
+
/**
|
15312
|
+
* Find out more information about a particular intent by passing its name, and optionally its context and resultType.
|
15313
|
+
* @param intent Name of the Intent
|
15314
|
+
* @param context Context
|
15315
|
+
* @param resultType The type of result returned for any intent specified during resolution.
|
15316
|
+
*
|
15317
|
+
* @tutorial fdc3.findIntent
|
15318
|
+
*/
|
15319
|
+
async findIntent(intent, context, resultType) {
|
15320
|
+
this.wire.sendAction('fdc3-find-intent').catch((e) => {
|
15321
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
15322
|
+
});
|
15323
|
+
try {
|
15324
|
+
return await this.client.getInfoForIntent({ name: intent, context, metadata: { resultType } });
|
15325
|
+
}
|
15326
|
+
catch (error) {
|
15327
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.getInfoForIntent ? 'ResolverUnavailable' : error.message;
|
15328
|
+
throw new Error(errorToThrow);
|
15329
|
+
}
|
15330
|
+
}
|
15331
|
+
/**
|
15332
|
+
* Find all the available intents for a particular context.
|
15333
|
+
* @param context
|
15334
|
+
* @param resultType The type of result returned for any intent specified during resolution.
|
15335
|
+
*
|
15336
|
+
* @tutorial fdc3v2.findIntentsByContext
|
15337
|
+
*/
|
15338
|
+
async findIntentsByContext(context, resultType) {
|
15339
|
+
this.wire.sendAction('fdc3-find-intents-by-context').catch((e) => {
|
15340
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
15341
|
+
});
|
15342
|
+
const payload = resultType ? { context, metadata: { resultType } } : context;
|
15343
|
+
try {
|
15344
|
+
return await InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'fdc3v2FindIntentsByContext', payload);
|
15345
|
+
}
|
15346
|
+
catch (error) {
|
15347
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.getInfoForIntentsByContext ? 'ResolverUnavailable' : error.message;
|
15348
|
+
throw new Error(errorToThrow);
|
15349
|
+
}
|
15350
|
+
}
|
15351
|
+
/**
|
15352
|
+
* Raises a specific intent for resolution against apps registered with the desktop agent.
|
15353
|
+
* @param intent Name of the Intent
|
15354
|
+
* @param context Context associated with the Intent
|
15355
|
+
* @param app
|
15356
|
+
*
|
15357
|
+
* @tutorial fdc3v2.raiseIntent
|
15358
|
+
*/
|
15359
|
+
async raiseIntent(intent, context, app) {
|
15360
|
+
this.wire.sendAction('fdc3-raise-intent').catch((e) => {
|
15361
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
15362
|
+
});
|
15363
|
+
try {
|
15364
|
+
if (typeof app === 'string') {
|
15365
|
+
console.warn('Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string }).');
|
15366
|
+
}
|
15367
|
+
return (0, utils_2.getIntentResolution)(this.client, context, app, intent);
|
15368
|
+
}
|
15369
|
+
catch (error) {
|
15370
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.fireIntent ? 'ResolverUnavailable' : error.message;
|
15371
|
+
throw new Error(errorToThrow);
|
15372
|
+
}
|
15373
|
+
}
|
15374
|
+
/**
|
15375
|
+
* Finds and raises an intent against apps registered with the desktop agent based purely on the type of the context data.
|
15376
|
+
* @param context Context associated with the Intent
|
15377
|
+
* @param app
|
15378
|
+
*
|
15379
|
+
* @tutorial fdc3v2.raiseIntentForContext
|
15380
|
+
*/
|
15381
|
+
async raiseIntentForContext(context, app) {
|
15382
|
+
// TODO: We have to do the same thing we do for raiseIntent here as well.
|
15383
|
+
this.wire.sendAction('fdc3-raise-intent-for-context').catch((e) => {
|
15384
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
15385
|
+
});
|
15386
|
+
try {
|
15387
|
+
if (typeof app === 'string') {
|
15388
|
+
console.warn('Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string }).');
|
15389
|
+
}
|
15390
|
+
return (0, utils_2.getIntentResolution)(this.client, context, app);
|
15391
|
+
}
|
15392
|
+
catch (error) {
|
15393
|
+
const errorToThrow = error.message === utils_1.BROKER_ERRORS.fireIntent ? 'ResolverUnavailable' : error.message;
|
15394
|
+
throw new Error(errorToThrow);
|
15395
|
+
}
|
15396
|
+
}
|
15397
|
+
/**
|
15398
|
+
* Adds a listener for incoming intents.
|
15399
|
+
* @param intent Name of the Intent
|
15400
|
+
* @param handler A callback that handles a context event and may return a promise of a Context or Channel object to be returned to the application that raised the intent.
|
15401
|
+
*
|
15402
|
+
* @tutorial fdc3.addIntentListener
|
15403
|
+
*/
|
15404
|
+
async addIntentListener(intent, handler) {
|
15405
|
+
this.wire.sendAction('fdc3-add-intent-listener').catch((e) => {
|
15406
|
+
// we do not want to expose this error, just continue if this analytics-only call fails
|
15407
|
+
});
|
15408
|
+
if (typeof intent !== 'string') {
|
15409
|
+
throw new Error('First argument must be an Intent name');
|
15410
|
+
}
|
15411
|
+
// The FDC3 Intenter handler only expects the context and contextMetadata to be passed to the handler,
|
15412
|
+
// so we wrap it here and only pass those paramaters.
|
15413
|
+
const contextHandler = async (raisedIntent) => {
|
15414
|
+
let intentResult;
|
15415
|
+
let intentResultToSend;
|
15416
|
+
const { context, metadata: intentMetadata } = raisedIntent;
|
15417
|
+
const { contextMetadata, metadata, ...rest } = context;
|
15418
|
+
const intentResolutionResultId = intentMetadata?.intentResolutionResultId || metadata?.intentResolutionResultId;
|
15419
|
+
try {
|
15420
|
+
const newContext = metadata ? { metadata, ...rest } : { ...rest };
|
15421
|
+
intentResult = await handler(newContext, contextMetadata);
|
15422
|
+
intentResultToSend = intentResult;
|
15423
|
+
}
|
15424
|
+
catch (error) {
|
15425
|
+
intentResult = error;
|
15426
|
+
intentResultToSend = { error: true };
|
15427
|
+
}
|
15428
|
+
if (intentResolutionResultId) {
|
15429
|
+
this.fin.InterApplicationBus.publish(intentResolutionResultId, intentResultToSend).catch(() => null);
|
15430
|
+
}
|
15431
|
+
if (intentResult instanceof Error) {
|
15432
|
+
throw new Error(intentResult.message);
|
15433
|
+
}
|
15434
|
+
return intentResult;
|
15435
|
+
};
|
15436
|
+
return this.client.registerIntentHandler(contextHandler, intent, { fdc3Version: '2.0' });
|
15437
|
+
}
|
15438
|
+
/**
|
15439
|
+
* Returns a Channel object for the specified channel, creating it as an App Channel if it does not exist.
|
15440
|
+
* @param channelId
|
15441
|
+
*
|
15442
|
+
* @tutorial fdc3.getOrCreateChannel
|
15443
|
+
*/
|
15444
|
+
async getOrCreateChannel(channelId) {
|
15445
|
+
return super.getOrCreateChannel(channelId);
|
15446
|
+
}
|
15447
|
+
/**
|
15448
|
+
* Returns a Channel with an auto-generated identity that is intended for private communication between applications. Primarily used to create channels that will be returned to other applications via an IntentResolution for a raised intent.
|
15449
|
+
*
|
15450
|
+
* @tutorial fdc3v2.createPrivateChannel
|
15451
|
+
*/
|
15452
|
+
async createPrivateChannel() {
|
15453
|
+
const channelId = (0, utils_1.generateId)();
|
15454
|
+
await InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'createPrivateChannelProvider', { channelId });
|
15455
|
+
const channelClient = await this.fin.InterApplicationBus.Channel.connect(channelId);
|
15456
|
+
const newPrivateChannelClient = new PrivateChannelClient_1.PrivateChannelClient(channelClient, channelId);
|
15457
|
+
return (0, utils_2.buildPrivateChannelObject)(newPrivateChannelClient);
|
15458
|
+
}
|
15459
|
+
/**
|
15460
|
+
* Retrieves a list of the User Channels available for the app to join.
|
15461
|
+
*
|
15462
|
+
* @tutorial fdc3v2.getUserChannels
|
15463
|
+
*/
|
15464
|
+
async getUserChannels() {
|
15465
|
+
const channels = await this.client.getContextGroups();
|
15466
|
+
// fdc3 implementation of getUserChannels returns on array of channels, have to decorate over
|
15467
|
+
// this so people know that these APIs are not supported
|
15468
|
+
return channels.map((channel) => {
|
15469
|
+
// @ts-expect-error TODO [CORE-1524]
|
15470
|
+
return { ...channel, type: 'user', ...(0, utils_2.getUnsupportedChannelApis)('User') };
|
15471
|
+
});
|
15472
|
+
}
|
15473
|
+
/**
|
15474
|
+
* Retrieves a list of the User Channels available for the app to join.
|
15475
|
+
*
|
15476
|
+
* @deprecated Please use {@link fdc3.getUserChannels fdc3.getUserChannels} instead
|
15477
|
+
* @tutorial fdc3.getSystemChannels
|
15478
|
+
*/
|
15479
|
+
async getSystemChannels() {
|
15480
|
+
console.warn('This API has been deprecated. Please use fdc3.getUserChannels instead.');
|
15481
|
+
return super.getSystemChannels();
|
15482
|
+
}
|
15483
|
+
/**
|
15484
|
+
* Join an app to a specified User channel.
|
15485
|
+
* @param channelId Channel name
|
15486
|
+
*
|
15487
|
+
* @tutorial fdc3v2.joinUserChannel
|
15488
|
+
*/
|
15489
|
+
async joinUserChannel(channelId) {
|
15490
|
+
return super.joinChannel(channelId);
|
15491
|
+
}
|
15492
|
+
/**
|
15493
|
+
* Join an app to a specified User channel.
|
15494
|
+
* @param channelId Channel name
|
15495
|
+
* @deprecated Please use {@link fdc3.joinUserChannel fdc3.joinUserChannel} instead
|
15496
|
+
*
|
15497
|
+
* @tutorial fdc3.joinChannel
|
15498
|
+
*/
|
15499
|
+
async joinChannel(channelId) {
|
15500
|
+
console.warn('This API has been deprecated. Please use fdc3.joinUserChannel instead.');
|
15501
|
+
return super.joinChannel(channelId);
|
15502
|
+
}
|
15503
|
+
/**
|
15504
|
+
* Returns the Channel object for the current User channel membership
|
15505
|
+
*
|
15506
|
+
* @tutorial fdc3.getCurrentChannel
|
15507
|
+
*/
|
15508
|
+
async getCurrentChannel() {
|
15509
|
+
const currentChannel = await super.getCurrentChannel();
|
15510
|
+
if (!currentChannel) {
|
15511
|
+
return null;
|
15512
|
+
}
|
15513
|
+
return {
|
15514
|
+
...currentChannel,
|
15515
|
+
type: 'user',
|
15516
|
+
broadcast: this.broadcast.bind(this)
|
15517
|
+
};
|
15518
|
+
}
|
15519
|
+
/**
|
15520
|
+
* Retrieves information about the FDC3 implementation, including the supported version of the FDC3 specification, the name of the provider of the implementation, its own version number, details of whether optional API features are implemented and the metadata of the calling application according to the desktop agent.
|
15521
|
+
* fdc3HandleGetInfo must be overridden in the InteropBroker so that the ImplementationMetadata will have the appMetadata info.
|
15522
|
+
*
|
15523
|
+
* @tutorial fdc3v2.getInfo
|
15524
|
+
*/
|
15525
|
+
async getInfo() {
|
15526
|
+
return InteropClient_1.InteropClient.ferryFdc3Call(this.client, 'fdc3v2GetInfo', { fdc3Version: '2.0' });
|
15527
|
+
}
|
15528
|
+
}
|
15529
|
+
fdc32_0.Fdc3Module2 = Fdc3Module2;
|
15530
|
+
return fdc32_0;
|
15531
|
+
}
|
15532
|
+
|
15533
|
+
var hasRequiredInteropClient;
|
15534
|
+
|
15535
|
+
function requireInteropClient () {
|
15536
|
+
if (hasRequiredInteropClient) return InteropClient;
|
15537
|
+
hasRequiredInteropClient = 1;
|
15538
|
+
var __classPrivateFieldSet = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
15539
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
15540
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
15541
|
+
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");
|
15542
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
15543
|
+
};
|
15544
|
+
var __classPrivateFieldGet = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
15545
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
15546
|
+
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");
|
15547
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
15548
|
+
};
|
15549
|
+
var _InteropClient_clientPromise, _InteropClient_sessionContextGroups;
|
15550
|
+
Object.defineProperty(InteropClient, "__esModule", { value: true });
|
15551
|
+
InteropClient.InteropClient = void 0;
|
15552
|
+
const base_1 = base$1;
|
15553
|
+
const SessionContextGroupClient_1 = SessionContextGroupClient$1;
|
15554
|
+
const fdc3_1_2_1 = requireFdc31_2();
|
15555
|
+
const fdc3_2_0_1 = requireFdc32_0();
|
15556
|
+
const utils_1 = utils$3;
|
15557
|
+
/**
|
15558
|
+
* The Interop Client API is broken up into two groups:
|
15559
|
+
*
|
15560
|
+
* **Content Facing APIs** - For Application Developers putting Views into a Platform Window, who care about Context. These are APIs that send out and receive the Context data that flows between applications. Think of this as the Water in the Interop Pipes.
|
15561
|
+
*
|
15562
|
+
* **Context Grouping APIs** - For Platform Developers, to add and remove Views to and from Context Groups. These APIs are utilized under-the-hood in Platforms, so they don't need to be used to participate in Interop. These are the APIs that decide which entities the context data flows between. Think of these as the valves or pipes that control the flow of Context Data for Interop.
|
15563
|
+
*
|
15564
|
+
* ---
|
15565
|
+
*
|
15566
|
+
* All APIs are available at the `fin.me.interop` namespace.
|
15567
|
+
*
|
15568
|
+
* ---
|
15569
|
+
*
|
15570
|
+
* **You only need 2 things to participate in Interop Context Grouping:**
|
15571
|
+
* * A Context Handler for incoming context: {@link InteropClient#addContextHandler addContextHandler(handler, contextType?)}
|
15572
|
+
* * Call setContext on your context group when you want to share context with other group members: {@link InteropClient#setContext setContext(context)}
|
15573
|
+
*
|
15574
|
+
* ---
|
15575
|
+
*
|
15576
|
+
* ##### Constructor
|
15577
|
+
* Returned by {@link Interop.connectSync Interop.connectSync}.
|
15578
|
+
*
|
15579
|
+
* ---
|
15580
|
+
*
|
15581
|
+
* ##### Interop methods intended for Views
|
15582
|
+
*
|
15583
|
+
*
|
15584
|
+
* **Context Groups API**
|
15585
|
+
* * {@link InteropClient#addContextHandler addContextHandler(handler, contextType?)}
|
15586
|
+
* * {@link InteropClient#setContext setContext(context)}
|
15587
|
+
* * {@link InteropClient#getCurrentContext getCurrentContext(contextType?)}
|
15588
|
+
* * {@link InteropClient#joinSessionContextGroup joinSessionContextGroup(sessionContextGroupId)}
|
15589
|
+
*
|
15590
|
+
*
|
15591
|
+
* **Intents API**
|
15592
|
+
* * {@link InteropClient#fireIntent fireIntent(intent)}
|
15593
|
+
* * {@link InteropClient#registerIntentHandler registerIntentHandler(intentHandler, intentName)}
|
15594
|
+
* * {@link InteropClient#getInfoForIntent getInfoForIntent(infoForIntentOptions)}
|
15595
|
+
* * {@link InteropClient#getInfoForIntentsByContext getInfoForIntentsByContext(context)}
|
15596
|
+
* * {@link InteropClient#fireIntentForContext fireIntentForContext(contextForIntent)}
|
15597
|
+
*
|
15598
|
+
* ##### Interop methods intended for Windows
|
15599
|
+
* * {@link InteropClient#getContextGroups getContextGroups()}
|
15600
|
+
* * {@link InteropClient#joinContextGroup joinContextGroup(contextGroupId, target?)}
|
15601
|
+
* * {@link InteropClient#removeFromContextGroup removeFromContextGroup(target?)}
|
15602
|
+
* * {@link InteropClient#getInfoForContextGroup getInfoForContextGroup(contextGroupId)}
|
15603
|
+
* * {@link InteropClient#getAllClientsInContextGroup getAllClientsInContextGroup(contextGroupId)}
|
15604
|
+
*
|
15605
|
+
*/
|
15606
|
+
let InteropClient$1 = class InteropClient extends base_1.Base {
|
15607
|
+
/**
|
15608
|
+
* @internal
|
15609
|
+
*/
|
15610
|
+
constructor(wire, clientPromise) {
|
15611
|
+
super(wire);
|
15612
|
+
_InteropClient_clientPromise.set(this, void 0);
|
15613
|
+
_InteropClient_sessionContextGroups.set(this, void 0);
|
15614
|
+
__classPrivateFieldSet(this, _InteropClient_sessionContextGroups, new Map(), "f");
|
15615
|
+
__classPrivateFieldSet(this, _InteropClient_clientPromise, clientPromise, "f");
|
15616
|
+
}
|
15617
|
+
/*
|
15618
|
+
Client APIs
|
15619
|
+
*/
|
15620
|
+
/**
|
15621
|
+
* Sets a context for the context group of the current entity.
|
15622
|
+
*
|
15623
|
+
* @remarks The entity must be part of a context group in order set a context.
|
15624
|
+
*
|
15625
|
+
* @param context - New context to set.
|
15626
|
+
*
|
15627
|
+
* @example
|
15628
|
+
* ```js
|
15629
|
+
* setInstrumentContext = async (ticker) => {
|
15630
|
+
* fin.me.interop.setContext({type: 'instrument', id: {ticker}})
|
15631
|
+
* }
|
15632
|
+
*
|
15633
|
+
* // The user clicks an instrument of interest. We want to set that Instrument context so that the rest of our workflow updates with information for that instrument
|
15634
|
+
* instrumentElement.on('click', (evt) => {
|
15635
|
+
* setInstrumentContext(evt.ticker)
|
15636
|
+
* })
|
15637
|
+
* ```
|
15638
|
+
*/
|
15639
|
+
async setContext(context) {
|
15640
|
+
this.wire.sendAction('interop-client-set-context').catch((e) => {
|
15641
|
+
// don't expose, analytics-only call
|
15642
|
+
});
|
15643
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
15644
|
+
return client.dispatch('setContext', { context });
|
15645
|
+
}
|
15646
|
+
/**
|
15647
|
+
* Add a context handler for incoming context. If an entity is part of a context group, and then sets its context handler,
|
15648
|
+
* it will receive all of its declared contexts.
|
15649
|
+
*
|
15650
|
+
* @param handler - Handler for incoming context.
|
15651
|
+
* @param contextType - The type of context you wish to handle.
|
15652
|
+
*
|
15653
|
+
* @example
|
15654
|
+
* ```js
|
15655
|
+
* function handleIncomingContext(contextInfo) {
|
15656
|
+
* const { type, id } = contextInfo;
|
15657
|
+
* switch (type) {
|
15658
|
+
* case 'instrument':
|
15659
|
+
* handleInstrumentContext(contextInfo);
|
15660
|
+
* break;
|
15661
|
+
* case 'country':
|
15662
|
+
* handleCountryContext(contextInfo);
|
15663
|
+
* break;
|
15664
|
+
*
|
15665
|
+
* default:
|
15666
|
+
* break;
|
15667
|
+
* }
|
15668
|
+
* }
|
15669
|
+
*
|
15670
|
+
*
|
15671
|
+
* function handleInstrumentContext(contextInfo) {
|
15672
|
+
* const { type, id } = contextInfo;
|
15673
|
+
* console.log('contextInfo for instrument', contextInfo)
|
15674
|
+
* }
|
15675
|
+
*
|
15676
|
+
* function handleCountryContext(contextInfo) {
|
15677
|
+
* const { type, id } = contextInfo;
|
15678
|
+
* console.log('contextInfo for country', contextInfo)
|
15679
|
+
* }
|
15680
|
+
*
|
15681
|
+
* fin.me.interop.addContextHandler(handleIncomingContext);
|
15682
|
+
* ```
|
15683
|
+
*
|
15684
|
+
*
|
15685
|
+
* We are also testing the ability to add a context handler for specific contexts. If you would like to use
|
15686
|
+
* this, please make sure you add your context handlers at the top level of your application, on a page that
|
15687
|
+
* does not navigate/reload/re-render, to avoid memory leaks. This feature is experimental:
|
15688
|
+
*
|
15689
|
+
* ```js
|
15690
|
+
* function handleInstrumentContext(contextInfo) {
|
15691
|
+
* const { type, id } = contextInfo;
|
15692
|
+
* console.log('contextInfo for instrument', contextInfo)
|
15693
|
+
* }
|
15694
|
+
*
|
15695
|
+
* function handleCountryContext(contextInfo) {
|
15696
|
+
* const { type, id } = contextInfo;
|
15697
|
+
* console.log('contextInfo for country', contextInfo)
|
15698
|
+
* }
|
15699
|
+
*
|
15700
|
+
*
|
15701
|
+
* fin.me.interop.addContextHandler(handleInstrumentContext, 'instrument')
|
15702
|
+
* fin.me.interop.addContextHandler(handleCountryContext, 'country')
|
15703
|
+
* ```
|
15704
|
+
*/
|
15705
|
+
async addContextHandler(handler, contextType) {
|
15706
|
+
this.wire.sendAction('interop-client-add-context-handler').catch((e) => {
|
15707
|
+
// don't expose, analytics-only call
|
15708
|
+
});
|
15709
|
+
if (typeof handler !== 'function') {
|
15710
|
+
throw new Error("Non-function argument passed to the first parameter 'handler'. Be aware that the argument order does not match the FDC3 standard.");
|
15711
|
+
}
|
15712
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
15713
|
+
let handlerId;
|
15714
|
+
if (contextType) {
|
15715
|
+
handlerId = `invokeContextHandler-${contextType}-${(0, utils_1.generateId)()}`;
|
15716
|
+
console.warn(`Warning: By providing a contextType (${contextType}), you are using the experimental addContextHandler. To avoid issues, make sure you are adding your context handlers at the top level in your application.`);
|
15717
|
+
}
|
15718
|
+
else {
|
15719
|
+
handlerId = 'invokeContextHandler';
|
15720
|
+
}
|
15721
|
+
const wrappedHandler = (0, utils_1.wrapContextHandler)(handler, handlerId);
|
15722
|
+
client.register(handlerId, wrappedHandler);
|
15723
|
+
await client.dispatch('contextHandlerRegistered', { handlerId, contextType });
|
15724
|
+
return {
|
15725
|
+
unsubscribe: async () => {
|
15726
|
+
client.remove(handlerId);
|
15727
|
+
await client.dispatch('removeContextHandler', { handlerId });
|
15728
|
+
}
|
15729
|
+
};
|
15730
|
+
}
|
15731
|
+
/*
|
15732
|
+
Platform Window APIs
|
15733
|
+
*/
|
15734
|
+
/**
|
15735
|
+
* Returns the Interop-Broker-defined context groups available for an entity to join.
|
15736
|
+
* Used by Platform Windows.
|
15737
|
+
*
|
15738
|
+
* @example
|
15739
|
+
* ```js
|
15740
|
+
* fin.me.interop.getContextGroups()
|
15741
|
+
* .then(contextGroups => {
|
15742
|
+
* contextGroups.forEach(contextGroup => {
|
15743
|
+
* console.log(contextGroup.displayMetadata.name)
|
15744
|
+
* console.log(contextGroup.displayMetadata.color)
|
15745
|
+
* })
|
15746
|
+
* })
|
15747
|
+
* ```
|
15748
|
+
*/
|
15749
|
+
async getContextGroups() {
|
15750
|
+
this.wire.sendAction('interop-client-get-context-groups').catch((e) => {
|
15751
|
+
// don't expose, analytics-only call
|
15752
|
+
});
|
15753
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
15754
|
+
return client.dispatch('getContextGroups');
|
15755
|
+
}
|
15756
|
+
/**
|
15757
|
+
* Join all Interop Clients at the given identity to context group `contextGroupId`.
|
15758
|
+
* If no target is specified, it adds the sender to the context group.
|
15759
|
+
*
|
15760
|
+
* @remarks Because multiple Channel connections/Interop Clients can potentially exist at a `uuid`/`name` combo, we currently join all Channel connections/Interop Clients at the given identity to the context group.
|
15761
|
+
* If an `endpointId` is provided (which is unlikely, unless the call is coming from an external adapter), then we only join that single connection to the context group.
|
15762
|
+
* For all intents and purposes, there will only be 1 connection present in Platform and Browser implmentations, so this point is more-or-less moot.
|
15763
|
+
* Used by Platform Windows.
|
15764
|
+
*
|
15765
|
+
* @param contextGroupId - Id of the context group.
|
15766
|
+
* @param target - Identity of the entity you wish to join to a context group.
|
15767
|
+
*
|
15768
|
+
* @example
|
15769
|
+
* ```js
|
15770
|
+
* joinViewToContextGroup = async (contextGroupId, view) => {
|
15771
|
+
* await fin.me.interop.joinContextGroup(contextGroupId, view);
|
15772
|
+
* }
|
15773
|
+
*
|
15774
|
+
* getLastFocusedView()
|
15775
|
+
* .then(lastFocusedViewIdentity => {
|
15776
|
+
* joinViewToContextGroup('red', lastFocusedViewIdentity)
|
15777
|
+
* })
|
15778
|
+
* ```
|
15779
|
+
*/
|
15780
|
+
async joinContextGroup(contextGroupId, target) {
|
15781
|
+
this.wire.sendAction('interop-client-join-context-group').catch((e) => {
|
15782
|
+
// don't expose, analytics-only call
|
15783
|
+
});
|
15784
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
15785
|
+
if (!contextGroupId) {
|
15786
|
+
throw new Error('No contextGroupId specified for joinContextGroup.');
|
15787
|
+
}
|
15788
|
+
return client.dispatch('joinContextGroup', { contextGroupId, target });
|
15789
|
+
}
|
15790
|
+
/**
|
15791
|
+
* Removes the specified target from a context group.
|
15792
|
+
* If no target is specified, it removes the sender from their context group.
|
15793
|
+
* Used by Platform Windows.
|
15794
|
+
*
|
15795
|
+
* @param target - Identity of the entity you wish to join to a context group.
|
15796
|
+
*
|
15797
|
+
* @example
|
15798
|
+
* ```js
|
15799
|
+
* removeViewFromContextGroup = async (view) => {
|
15800
|
+
* await fin.me.interop.removeFromContextGroup(view);
|
15801
|
+
* }
|
15802
|
+
*
|
15803
|
+
* getLastFocusedView()
|
15804
|
+
* .then(lastFocusedViewIdentity => {
|
15805
|
+
* removeViewFromContextGroup(lastFocusedViewIdentity)
|
15806
|
+
* })
|
15807
|
+
* ```
|
15808
|
+
*/
|
15809
|
+
async removeFromContextGroup(target) {
|
15810
|
+
this.wire.sendAction('interop-client-remove-from-context-group').catch((e) => {
|
15811
|
+
// don't expose, analytics-only call
|
15812
|
+
});
|
15813
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
15814
|
+
return client.dispatch('removeFromContextGroup', { target });
|
15815
|
+
}
|
15816
|
+
/**
|
15817
|
+
* Gets all clients for a context group.
|
15818
|
+
*
|
15819
|
+
* @remarks **This is primarily used for platform windows. Views within a platform should not have to use this API.**
|
15820
|
+
*
|
15821
|
+
* Returns the Interop-Broker-defined context groups available for an entity to join.
|
15822
|
+
* @param contextGroupId - The id of context group you wish to get clients for.
|
15823
|
+
*
|
15824
|
+
* @example
|
15825
|
+
* ```js
|
15826
|
+
* fin.me.interop.getAllClientsInContextGroup('red')
|
15827
|
+
* .then(clientsInContextGroup => {
|
15828
|
+
* console.log(clientsInContextGroup)
|
15829
|
+
* })
|
15830
|
+
* ```
|
15831
|
+
*/
|
15832
|
+
async getAllClientsInContextGroup(contextGroupId) {
|
15833
|
+
this.wire.sendAction('interop-client-get-all-clients-in-context-group').catch((e) => {
|
15834
|
+
// don't expose, analytics-only call
|
15835
|
+
});
|
15836
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
15837
|
+
if (!contextGroupId) {
|
15838
|
+
throw new Error('No contextGroupId specified for getAllClientsInContextGroup.');
|
15839
|
+
}
|
15840
|
+
return client.dispatch('getAllClientsInContextGroup', { contextGroupId });
|
15841
|
+
}
|
15842
|
+
/**
|
15843
|
+
* Gets display info for a context group
|
15844
|
+
*
|
15845
|
+
* @remarks Used by Platform Windows.
|
15846
|
+
* @param contextGroupId - The id of context group you wish to get display info for.
|
15847
|
+
*
|
15848
|
+
* @example
|
15849
|
+
* ```js
|
15850
|
+
* fin.me.interop.getInfoForContextGroup('red')
|
15851
|
+
* .then(contextGroupInfo => {
|
15852
|
+
* console.log(contextGroupInfo.displayMetadata.name)
|
15853
|
+
* console.log(contextGroupInfo.displayMetadata.color)
|
15854
|
+
* })
|
15855
|
+
* ```
|
15856
|
+
*/
|
15857
|
+
async getInfoForContextGroup(contextGroupId) {
|
15858
|
+
this.wire.sendAction('interop-client-get-info-for-context-group').catch((e) => {
|
15859
|
+
// don't expose, analytics-only call
|
15860
|
+
});
|
15861
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
15862
|
+
if (!contextGroupId) {
|
15863
|
+
throw new Error('No contextGroupId specified for getInfoForContextGroup.');
|
15864
|
+
}
|
15865
|
+
return client.dispatch('getInfoForContextGroup', { contextGroupId });
|
15866
|
+
}
|
15867
|
+
/**
|
15868
|
+
* Sends an intent to the Interop Broker to resolve.
|
15869
|
+
* @param intent - The combination of an action and a context that is passed to an application for resolution.
|
15870
|
+
*
|
15871
|
+
* @example
|
15872
|
+
* ```js
|
15873
|
+
* // View wants to fire an Intent after a user clicks on a ticker
|
15874
|
+
* tickerElement.on('click', (element) => {
|
15875
|
+
* const ticker = element.innerText;
|
15876
|
+
* const intent = {
|
15877
|
+
* name: 'ViewChart',
|
15878
|
+
* context: {type: 'fdc3.instrument', id: { ticker }}
|
15879
|
+
* }
|
15880
|
+
*
|
15881
|
+
* fin.me.interop.fireIntent(intent);
|
15882
|
+
* })
|
15883
|
+
* ```
|
15884
|
+
*/
|
15885
|
+
async fireIntent(intent) {
|
15886
|
+
this.wire.sendAction('interop-client-fire-intent').catch((e) => {
|
15887
|
+
// don't expose, this is only for api analytics purposes
|
15888
|
+
});
|
15889
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
15890
|
+
return client.dispatch('fireIntent', intent);
|
15891
|
+
}
|
15892
|
+
/**
|
15893
|
+
* Adds an intent handler for incoming intents. The last intent sent of the name subscribed to will be received.
|
15894
|
+
* @param handler - Registered function meant to handle a specific intent type.
|
15895
|
+
* @param intentName - The name of an intent.
|
15896
|
+
*
|
15897
|
+
* @example
|
15898
|
+
* ```js
|
15899
|
+
* const intentHandler = (intent) => {
|
15900
|
+
* const { context } = intent;
|
15901
|
+
* myViewChartHandler(context);
|
15902
|
+
* };
|
15903
|
+
*
|
15904
|
+
* const subscription = await fin.me.interop.registerIntentHandler(intentHandler, 'ViewChart');
|
15905
|
+
*
|
15906
|
+
* function myAppCloseSequence() {
|
15907
|
+
* // to unsubscribe the handler, simply call:
|
15908
|
+
* subscription.unsubscribe();
|
15909
|
+
* }
|
15910
|
+
* ```
|
15911
|
+
*/
|
15912
|
+
async registerIntentHandler(handler, intentName, options) {
|
15913
|
+
this.wire.sendAction('interop-client-register-intent-handler').catch((e) => {
|
15914
|
+
// don't expose, this is only for api analytics purposes
|
15915
|
+
});
|
15916
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
15917
|
+
const handlerId = `intent-handler-${intentName}`;
|
15918
|
+
const wrappedHandler = (0, utils_1.wrapIntentHandler)(handler, handlerId);
|
15919
|
+
try {
|
15920
|
+
await client.register(handlerId, wrappedHandler);
|
15921
|
+
await client.dispatch('intentHandlerRegistered', { handlerId, ...options });
|
15922
|
+
}
|
15923
|
+
catch (error) {
|
15924
|
+
throw new Error('Unable to register intent handler');
|
15925
|
+
}
|
15926
|
+
return {
|
15927
|
+
unsubscribe: async () => {
|
15928
|
+
client.remove(handlerId);
|
15929
|
+
}
|
15930
|
+
};
|
15931
|
+
}
|
15932
|
+
/**
|
15933
|
+
* Gets the last context of the Context Group currently subscribed to. It takes an optional Context Type and returns the
|
15934
|
+
* last context of that type.
|
15935
|
+
* @param contextType
|
15936
|
+
*
|
15937
|
+
* @example
|
15938
|
+
* ```js
|
15939
|
+
* await fin.me.interop.joinContextGroup('yellow');
|
15940
|
+
* await fin.me.interop.setContext({ type: 'instrument', id: { ticker: 'FOO' }});
|
15941
|
+
* const currentContext = await fin.me.interop.getCurrentContext();
|
15942
|
+
*
|
15943
|
+
* // with a specific context
|
15944
|
+
* await fin.me.interop.joinContextGroup('yellow');
|
15945
|
+
* await fin.me.interop.setContext({ type: 'country', id: { ISOALPHA3: 'US' }});
|
15946
|
+
* await fin.me.interop.setContext({ type: 'instrument', id: { ticker: 'FOO' }});
|
15947
|
+
* const currentContext = await fin.me.interop.getCurrentContext('country');
|
15948
|
+
* ```
|
15949
|
+
*/
|
15950
|
+
async getCurrentContext(contextType) {
|
15951
|
+
this.wire.sendAction('interop-client-get-current-context').catch((e) => {
|
15952
|
+
// don't expose, analytics-only call
|
15953
|
+
});
|
15954
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
15955
|
+
return client.dispatch('getCurrentContext', { contextType });
|
15956
|
+
}
|
15957
|
+
/**
|
15958
|
+
* Get information for a particular Intent from the Interop Broker.
|
15959
|
+
*
|
15960
|
+
* @remarks To resolve this info, the function handleInfoForIntent is meant to be overridden in the Interop Broker.
|
15961
|
+
* The format for the response will be determined by the App Provider overriding the function.
|
15962
|
+
*
|
15963
|
+
* @param options
|
15964
|
+
*
|
15965
|
+
* @example
|
15966
|
+
* ```js
|
15967
|
+
* const intentInfo = await fin.me.interop.getInfoForIntent('ViewChart');
|
15968
|
+
* ```
|
15969
|
+
*/
|
15970
|
+
async getInfoForIntent(options) {
|
15971
|
+
this.wire.sendAction('interop-client-get-info-for-intent').catch((e) => {
|
15972
|
+
// don't expose, analytics-only call
|
15973
|
+
});
|
15974
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
15975
|
+
return client.dispatch('getInfoForIntent', options);
|
15976
|
+
}
|
15977
|
+
/**
|
15978
|
+
* Get information from the Interop Broker on all Intents that are meant to handle a particular context.
|
15979
|
+
*
|
15980
|
+
* @remarks To resolve this info, the function handleInfoForIntentsByContext is meant to be overridden in the Interop Broker.
|
15981
|
+
* The format for the response will be determined by the App Provider overriding the function.
|
15982
|
+
*
|
15983
|
+
* @param context
|
15984
|
+
*
|
15985
|
+
* @example
|
15986
|
+
* ```js
|
15987
|
+
* tickerElement.on('click', (element) => {
|
15988
|
+
* const ticker = element.innerText;
|
15989
|
+
*
|
15990
|
+
* const context = {
|
15991
|
+
* type: 'fdc3.instrument',
|
15992
|
+
* id: {
|
15993
|
+
* ticker
|
15994
|
+
* }
|
15995
|
+
* }
|
15996
|
+
*
|
15997
|
+
* const intentsInfo = await fin.me.interop.getInfoForIntentByContext(context);
|
15998
|
+
* })
|
15999
|
+
* ```
|
16000
|
+
*/
|
16001
|
+
async getInfoForIntentsByContext(context) {
|
16002
|
+
this.wire.sendAction('interop-client-get-info-for-intents-by-context').catch((e) => {
|
16003
|
+
// don't expose, analytics-only call
|
16004
|
+
});
|
16005
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
16006
|
+
return client.dispatch('getInfoForIntentsByContext', context);
|
16007
|
+
}
|
16008
|
+
/**
|
16009
|
+
* Sends a Context that will be resolved to an Intent by the Interop Broker.
|
16010
|
+
* This context accepts a metadata property.
|
16011
|
+
*
|
16012
|
+
* @remarks To resolve this info, the function handleFiredIntentByContext is meant to be overridden in the Interop Broker.
|
16013
|
+
* The format for the response will be determined by the App Provider overriding the function.
|
16014
|
+
*
|
16015
|
+
* @param context
|
16016
|
+
*
|
16017
|
+
* @example
|
16018
|
+
* ```js
|
16019
|
+
* tickerElement.on('click', (element) => {
|
16020
|
+
* const ticker = element.innerText;
|
16021
|
+
*
|
16022
|
+
* const context = {
|
16023
|
+
* type: 'fdc3.instrument',
|
16024
|
+
* id: {
|
16025
|
+
* ticker
|
16026
|
+
* }
|
16027
|
+
* }
|
16028
|
+
*
|
16029
|
+
* const intentResolution = await fin.me.interop.fireIntentForContext(context);
|
16030
|
+
* })
|
16031
|
+
* ```
|
16032
|
+
*/
|
16033
|
+
async fireIntentForContext(context) {
|
16034
|
+
this.wire.sendAction('interop-client-fire-intent-for-context').catch((e) => {
|
16035
|
+
// don't expose, analytics-only call
|
16036
|
+
});
|
16037
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
16038
|
+
return client.dispatch('fireIntentForContext', context);
|
16039
|
+
}
|
16040
|
+
/**
|
16041
|
+
* Join the current entity to session context group `sessionContextGroupId` and return a sessionContextGroup instance.
|
16042
|
+
* If the sessionContextGroup doesn't exist, one will get created.
|
16043
|
+
*
|
16044
|
+
* @remarks Session Context Groups do not persist between runs and aren't present on snapshots.
|
16045
|
+
* @param sessionContextGroupId - Id of the context group.
|
16046
|
+
*
|
16047
|
+
* @example
|
16048
|
+
* Say we want to have a Session Context Group that holds UI theme information for all apps to consume:
|
16049
|
+
*
|
16050
|
+
* My color-picker View:
|
16051
|
+
* ```js
|
16052
|
+
* const themeSessionContextGroup = await fin.me.interop.joinSessionContextGroup('theme');
|
16053
|
+
*
|
16054
|
+
* const myColorPickerElement = document.getElementById('color-palette-picker');
|
16055
|
+
* myColorPickerElement.addEventListener('change', event => {
|
16056
|
+
* themeSessionContextGroup.setContext({ type: 'color-palette', selection: event.value });
|
16057
|
+
* });
|
16058
|
+
* ```
|
16059
|
+
*
|
16060
|
+
* In other views:
|
16061
|
+
* ```js
|
16062
|
+
* const themeSessionContextGroup = await fin.me.interop.joinSessionContextGroup('theme');
|
16063
|
+
*
|
16064
|
+
* const changeColorPalette = ({ selection }) => {
|
16065
|
+
* // change the color palette to the selection
|
16066
|
+
* };
|
16067
|
+
*
|
16068
|
+
* // If the context is already set by the time the handler was set, the handler will get invoked immediately with the current context.
|
16069
|
+
* themeSessionContextGroup.addContextHandler(changeColorPalette, 'color-palette');
|
16070
|
+
* ```
|
16071
|
+
*/
|
16072
|
+
async joinSessionContextGroup(sessionContextGroupId) {
|
16073
|
+
try {
|
16074
|
+
const currentSessionContextGroup = __classPrivateFieldGet(this, _InteropClient_sessionContextGroups, "f").get(sessionContextGroupId);
|
16075
|
+
if (currentSessionContextGroup) {
|
16076
|
+
return currentSessionContextGroup.getUserInstance();
|
16077
|
+
}
|
16078
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
16079
|
+
const { hasConflict } = await client.dispatch('sessionContextGroup:createIfNeeded', {
|
16080
|
+
sessionContextGroupId
|
16081
|
+
});
|
16082
|
+
if (hasConflict) {
|
16083
|
+
console.warn(`A (non-session) context group with the name "${sessionContextGroupId}" already exists. If you are trying to join a Context Group, call joinContextGroup instead.`);
|
16084
|
+
}
|
16085
|
+
const newSessionContextGroup = new SessionContextGroupClient_1.default(this.wire, __classPrivateFieldGet(this, _InteropClient_clientPromise, "f"), sessionContextGroupId);
|
16086
|
+
__classPrivateFieldGet(this, _InteropClient_sessionContextGroups, "f").set(sessionContextGroupId, newSessionContextGroup);
|
16087
|
+
return newSessionContextGroup.getUserInstance();
|
16088
|
+
}
|
16089
|
+
catch (error) {
|
16090
|
+
console.error(`Error thrown trying to create Session Context Group with id "${sessionContextGroupId}": ${error}`);
|
16091
|
+
throw error;
|
16092
|
+
}
|
16093
|
+
}
|
16094
|
+
/**
|
16095
|
+
* Register a listener that is called when the Interop Client has been disconnected from the Interop Broker.
|
16096
|
+
* Only one listener per Interop Client can be set.
|
16097
|
+
* @param listener
|
16098
|
+
*
|
16099
|
+
* @example
|
16100
|
+
* ```js
|
16101
|
+
* const listener = (event) => {
|
16102
|
+
* const { type, topic, brokerName} = event;
|
16103
|
+
* console.log(`Disconnected from Interop Broker ${brokerName} `);
|
16104
|
+
* }
|
16105
|
+
*
|
16106
|
+
* await fin.me.interop.onDisconnection(listener);
|
16107
|
+
* ```
|
16108
|
+
*/
|
16109
|
+
async onDisconnection(listener) {
|
16110
|
+
this.wire.sendAction('interop-client-add-ondisconnection-listener').catch((e) => {
|
16111
|
+
// don't expose, analytics-only call
|
16112
|
+
});
|
16113
|
+
const client = await __classPrivateFieldGet(this, _InteropClient_clientPromise, "f");
|
16114
|
+
return client.onDisconnection((event) => {
|
16115
|
+
const { uuid } = event;
|
16116
|
+
listener({ type: 'interop-broker', topic: 'disconnected', brokerName: uuid });
|
16117
|
+
});
|
16118
|
+
}
|
16119
|
+
getFDC3Sync(version) {
|
16120
|
+
switch (version) {
|
16121
|
+
case '1.2':
|
16122
|
+
return new fdc3_1_2_1.Fdc3Module(() => this, this.wire);
|
16123
|
+
case '2.0':
|
16124
|
+
return new fdc3_2_0_1.Fdc3Module2(() => this, this.wire);
|
16125
|
+
default:
|
16126
|
+
throw new Error(`Invalid FDC3 version provided: ${version}. Must be '1.2' or '2.0'`);
|
16127
|
+
}
|
16128
|
+
}
|
16129
|
+
async getFDC3(version) {
|
16130
|
+
return this.getFDC3Sync(version);
|
16131
|
+
}
|
16132
|
+
/**
|
16133
|
+
* @internal
|
16134
|
+
*
|
16135
|
+
* Used to ferry fdc3-only calls from the fdc3 shim to the Interop Broker
|
16136
|
+
*/
|
16137
|
+
static async ferryFdc3Call(interopClient, action, payload) {
|
16138
|
+
const client = await __classPrivateFieldGet(interopClient, _InteropClient_clientPromise, "f");
|
16139
|
+
return client.dispatch(action, payload || null);
|
16140
|
+
}
|
16141
|
+
};
|
16142
|
+
InteropClient.InteropClient = InteropClient$1;
|
16143
|
+
_InteropClient_clientPromise = new WeakMap(), _InteropClient_sessionContextGroups = new WeakMap();
|
16144
|
+
return InteropClient;
|
16145
|
+
}
|
14954
16146
|
|
14955
16147
|
var overrideCheck = {};
|
14956
16148
|
|
@@ -15007,7 +16199,7 @@ function requireFactory () {
|
|
15007
16199
|
const inaccessibleObject_1 = inaccessibleObject;
|
15008
16200
|
const base_1 = base$1;
|
15009
16201
|
const InteropBroker_1 = requireInteropBroker();
|
15010
|
-
const InteropClient_1 =
|
16202
|
+
const InteropClient_1 = requireInteropClient();
|
15011
16203
|
const overrideCheck_1 = requireOverrideCheck();
|
15012
16204
|
const common_utils_1 = commonUtils;
|
15013
16205
|
const defaultOverride = (Class) => new Class();
|
@@ -15041,12 +16233,8 @@ function requireFactory () {
|
|
15041
16233
|
const options = await this.wire.environment.getInteropInfo(this.wire.getFin());
|
15042
16234
|
const objectThatThrows = (0, inaccessibleObject_1.createUnusableObject)(BrokerParamAccessError);
|
15043
16235
|
const warningOptsClone = (0, inaccessibleObject_1.createWarningObject)(BrokerParamAccessError, (0, lodash_1.cloneDeep)(options));
|
15044
|
-
let provider;
|
15045
16236
|
const getProvider = () => {
|
15046
|
-
|
15047
|
-
provider = this.fin.InterApplicationBus.Channel.create(`interop-broker-${name}`);
|
15048
|
-
}
|
15049
|
-
return provider;
|
16237
|
+
return this.fin.InterApplicationBus.Channel.create(`interop-broker-${name}`);
|
15050
16238
|
};
|
15051
16239
|
const throwingGetProvider = async () => {
|
15052
16240
|
// eslint-disable-next-line no-console
|
@@ -15092,7 +16280,11 @@ function requireFactory () {
|
|
15092
16280
|
this.wire.sendAction('interop-connect-sync').catch(() => {
|
15093
16281
|
// don't expose, analytics-only call
|
15094
16282
|
});
|
15095
|
-
return new InteropClient_1.InteropClient(this.wire,
|
16283
|
+
return new InteropClient_1.InteropClient(this.wire, this.wire.environment.whenReady().then(() => {
|
16284
|
+
return this.fin.InterApplicationBus.Channel.connect(`interop-broker-${name}`, {
|
16285
|
+
payload: interopConfig
|
16286
|
+
});
|
16287
|
+
}));
|
15096
16288
|
}
|
15097
16289
|
}
|
15098
16290
|
Factory$1.InteropModule = InteropModule;
|
@@ -15129,7 +16321,7 @@ function requireInterop () {
|
|
15129
16321
|
};
|
15130
16322
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15131
16323
|
__exportStar(requireFactory(), exports);
|
15132
|
-
__exportStar(
|
16324
|
+
__exportStar(requireInteropClient(), exports);
|
15133
16325
|
__exportStar(requireInteropBroker(), exports);
|
15134
16326
|
} (interop));
|
15135
16327
|
return interop;
|
@@ -15522,7 +16714,7 @@ var portDiscovery = {};
|
|
15522
16714
|
|
15523
16715
|
var launcher = {};
|
15524
16716
|
|
15525
|
-
var
|
16717
|
+
var nixLaunch = {};
|
15526
16718
|
|
15527
16719
|
var util = {};
|
15528
16720
|
|
@@ -15635,7 +16827,7 @@ var http = {};
|
|
15635
16827
|
|
15636
16828
|
Object.defineProperty(util, "__esModule", { value: true });
|
15637
16829
|
util.resolveDir = util.first = util.resolveRuntimeVersion = util.rmDir = util.unzip = util.exists = void 0;
|
15638
|
-
const path$1 = require$$
|
16830
|
+
const path$1 = require$$1;
|
15639
16831
|
const fs$1 = require$$0$2;
|
15640
16832
|
const child_process_1$1 = require$$2;
|
15641
16833
|
const promises_1$1 = promises;
|
@@ -15737,54 +16929,6 @@ async function resolveDir(base, paths) {
|
|
15737
16929
|
}
|
15738
16930
|
util.resolveDir = resolveDir;
|
15739
16931
|
|
15740
|
-
Object.defineProperty(winLaunch, "__esModule", { value: true });
|
15741
|
-
const path = require$$0$3;
|
15742
|
-
const child_process_1 = require$$2;
|
15743
|
-
const util_1 = util;
|
15744
|
-
function launchRVM(config, manifestLocation, namedPipeName, rvm) {
|
15745
|
-
const runtimeArgs = `--runtime-arguments=--runtime-information-channel-v6=${namedPipeName}`;
|
15746
|
-
const rvmArgs = [];
|
15747
|
-
if (config.installerUI !== true) {
|
15748
|
-
rvmArgs.push('--no-ui');
|
15749
|
-
}
|
15750
|
-
rvmArgs.push(`--config=${manifestLocation}`);
|
15751
|
-
rvmArgs.push(runtimeArgs);
|
15752
|
-
if (config.runtime.rvmDir) {
|
15753
|
-
rvmArgs.push(`--working-dir=${config.runtime.rvmDir}`);
|
15754
|
-
}
|
15755
|
-
if (config.assetsUrl) {
|
15756
|
-
rvmArgs.push(`--assetsUrl=${config.assetsUrl}`);
|
15757
|
-
}
|
15758
|
-
return (0, child_process_1.spawn)(rvm, rvmArgs, { stdio: ['pipe', 'ignore', 'pipe'], detached: true });
|
15759
|
-
}
|
15760
|
-
async function checkRvmPath() {
|
15761
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
15762
|
-
let rvmPath = path.resolve(process.env.LOCALAPPDATA, 'OpenFin', 'OpenFinRVM.exe');
|
15763
|
-
if (!(await (0, util_1.exists)(rvmPath))) {
|
15764
|
-
rvmPath = path.join(__dirname, '..', 'resources', 'win', 'OpenFinRVM.exe');
|
15765
|
-
}
|
15766
|
-
return rvmPath;
|
15767
|
-
}
|
15768
|
-
const checkRVM = makeQueued(checkRvmPath);
|
15769
|
-
async function launch(config, manifestLocation, namedPipeName) {
|
15770
|
-
const rvmPath = await checkRVM();
|
15771
|
-
return launchRVM(config, manifestLocation, namedPipeName, rvmPath);
|
15772
|
-
}
|
15773
|
-
winLaunch.default = launch;
|
15774
|
-
function makeQueued(func) {
|
15775
|
-
let initial;
|
15776
|
-
return async function (...args) {
|
15777
|
-
const x = initial || Promise.resolve();
|
15778
|
-
initial = x
|
15779
|
-
.then(() => new Promise((resolve, reject) => setImmediate(() => resolve())))
|
15780
|
-
.then(() => func(...args))
|
15781
|
-
.catch(() => func(...args));
|
15782
|
-
return initial;
|
15783
|
-
};
|
15784
|
-
}
|
15785
|
-
|
15786
|
-
var nixLaunch = {};
|
15787
|
-
|
15788
16932
|
var services = {};
|
15789
16933
|
|
15790
16934
|
var hasRequiredServices;
|
@@ -15834,9 +16978,9 @@ function requireNixLaunch () {
|
|
15834
16978
|
if (hasRequiredNixLaunch) return nixLaunch;
|
15835
16979
|
hasRequiredNixLaunch = 1;
|
15836
16980
|
Object.defineProperty(nixLaunch, "__esModule", { value: true });
|
15837
|
-
nixLaunch.install = nixLaunch.getRuntimePath = nixLaunch.download = nixLaunch.getUrl = void 0;
|
16981
|
+
nixLaunch.launch = nixLaunch.install = nixLaunch.getRuntimePath = nixLaunch.download = nixLaunch.getUrl = void 0;
|
15838
16982
|
const fs = require$$0$2;
|
15839
|
-
const path = require$$
|
16983
|
+
const path = require$$1;
|
15840
16984
|
const child_process_1 = require$$2;
|
15841
16985
|
const promises_1 = promises;
|
15842
16986
|
const util_1 = util;
|
@@ -15934,85 +17078,161 @@ function requireNixLaunch () {
|
|
15934
17078
|
throw e;
|
15935
17079
|
}
|
15936
17080
|
}
|
15937
|
-
nixLaunch.
|
17081
|
+
nixLaunch.launch = launch;
|
15938
17082
|
return nixLaunch;
|
15939
17083
|
}
|
15940
17084
|
|
17085
|
+
var rvmLaunch = {};
|
17086
|
+
|
17087
|
+
Object.defineProperty(rvmLaunch, "__esModule", { value: true });
|
17088
|
+
rvmLaunch.launch = void 0;
|
17089
|
+
const child_process_1 = require$$2;
|
17090
|
+
const os = require$$1$1;
|
17091
|
+
const path = require$$1;
|
17092
|
+
const util_1 = util;
|
17093
|
+
const getRvmPath = () => {
|
17094
|
+
switch (process.platform) {
|
17095
|
+
case 'darwin':
|
17096
|
+
return path.resolve(os.homedir(), 'Applications', 'OpenFinRVM.app', 'Contents', 'MacOS', 'OpenFinRVM');
|
17097
|
+
case 'win32':
|
17098
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
17099
|
+
return path.resolve(process.env.LOCALAPPDATA, 'OpenFin', 'OpenFinRVM.exe');
|
17100
|
+
default:
|
17101
|
+
throw new Error(`Unsupported platform: ${process.platform}`);
|
17102
|
+
}
|
17103
|
+
};
|
17104
|
+
const getRvmLocalPath = () => {
|
17105
|
+
switch (process.platform) {
|
17106
|
+
case 'darwin':
|
17107
|
+
return path.resolve(__dirname, '..', 'resources', 'darwin', 'OpenFinRVM.app', 'Contents', 'MacOS', 'OpenFinRVM');
|
17108
|
+
case 'win32':
|
17109
|
+
return path.resolve(__dirname, '..', 'resources', 'win', 'OpenFinRVM.exe');
|
17110
|
+
default:
|
17111
|
+
throw new Error(`Unsupported platform: ${process.platform}`);
|
17112
|
+
}
|
17113
|
+
};
|
17114
|
+
function launchRVM(config, manifestLocation, namedPipeName, rvm) {
|
17115
|
+
const runtimeArgs = `--runtime-arguments=--runtime-information-channel-v6=${namedPipeName}`;
|
17116
|
+
const rvmArgs = [];
|
17117
|
+
if (config.installerUI !== true) {
|
17118
|
+
rvmArgs.push('--no-ui');
|
17119
|
+
}
|
17120
|
+
rvmArgs.push(`--config=${manifestLocation}`);
|
17121
|
+
rvmArgs.push(runtimeArgs);
|
17122
|
+
if (config.runtime.rvmDir) {
|
17123
|
+
rvmArgs.push(`--working-dir=${config.runtime.rvmDir}`);
|
17124
|
+
}
|
17125
|
+
if (config.assetsUrl) {
|
17126
|
+
rvmArgs.push(`--assetsUrl=${config.assetsUrl}`);
|
17127
|
+
}
|
17128
|
+
return (0, child_process_1.spawn)(rvm, rvmArgs, { stdio: ['pipe', 'ignore', 'pipe'], detached: true });
|
17129
|
+
}
|
17130
|
+
async function checkRvmPath() {
|
17131
|
+
const rvmPath = getRvmPath();
|
17132
|
+
if (!(await (0, util_1.exists)(rvmPath))) {
|
17133
|
+
// TODO: update win RVM exe to v13
|
17134
|
+
const newRvmPath = getRvmLocalPath();
|
17135
|
+
console.log(`[OpenFin Launcher] RVM not found at ${rvmPath}, spwaning locally pacakged RVM at ${newRvmPath}`);
|
17136
|
+
return newRvmPath;
|
17137
|
+
}
|
17138
|
+
return rvmPath;
|
17139
|
+
}
|
17140
|
+
const checkRVM = makeQueued(checkRvmPath);
|
17141
|
+
async function launch(config, manifestLocation, namedPipeName) {
|
17142
|
+
const rvmPath = await checkRVM();
|
17143
|
+
return launchRVM(config, manifestLocation, namedPipeName, rvmPath);
|
17144
|
+
}
|
17145
|
+
rvmLaunch.launch = launch;
|
17146
|
+
function makeQueued(func) {
|
17147
|
+
let initial;
|
17148
|
+
return async function (...args) {
|
17149
|
+
const x = initial || Promise.resolve();
|
17150
|
+
initial = x
|
17151
|
+
.then(() => new Promise((resolve, reject) => setImmediate(() => resolve())))
|
17152
|
+
.then(() => func(...args))
|
17153
|
+
.catch(() => func(...args));
|
17154
|
+
return initial;
|
17155
|
+
};
|
17156
|
+
}
|
17157
|
+
|
15941
17158
|
var hasRequiredLauncher;
|
15942
17159
|
|
15943
17160
|
function requireLauncher () {
|
15944
17161
|
if (hasRequiredLauncher) return launcher;
|
15945
17162
|
hasRequiredLauncher = 1;
|
15946
17163
|
Object.defineProperty(launcher, "__esModule", { value: true });
|
15947
|
-
const os = require$$
|
15948
|
-
const path = require$$
|
15949
|
-
const win_launch_1 = winLaunch;
|
17164
|
+
const os = require$$1$1;
|
17165
|
+
const path = require$$1;
|
15950
17166
|
const nix_launch_1 = requireNixLaunch();
|
17167
|
+
const rvm_launch_1 = rvmLaunch;
|
15951
17168
|
class Launcher {
|
15952
17169
|
constructor() {
|
15953
|
-
this.OpenFin_Installer = 'OpenFinInstaller.exe';
|
15954
17170
|
this.Installer_Work_Dir = path.join(os.tmpdir(), 'openfinnode');
|
15955
17171
|
this.Security_Realm_Config_Key = '--security-realm=';
|
15956
|
-
|
15957
|
-
|
15958
|
-
if (this.os === 'darwin') {
|
15959
|
-
this.nixConfig = {
|
15960
|
-
urlPath: 'mac/x64',
|
15961
|
-
executablePath: 'OpenFin.app/Contents/MacOS/OpenFin'
|
15962
|
-
};
|
15963
|
-
}
|
15964
|
-
else if (this.os === 'linux') {
|
15965
|
-
this.nixConfig = {
|
15966
|
-
urlPath: `linux/${os.arch()}`,
|
15967
|
-
executablePath: 'openfin'
|
15968
|
-
};
|
15969
|
-
}
|
15970
|
-
else {
|
15971
|
-
throw new Error(`Launching not supported on ${this.os}`);
|
15972
|
-
}
|
17172
|
+
if (!Launcher.IS_SUPPORTED()) {
|
17173
|
+
throw new Error(`Launching not supported on ${os.platform()}`);
|
15973
17174
|
}
|
15974
17175
|
}
|
15975
|
-
launch(config, manifestLocation, namedPipeName) {
|
15976
|
-
if (
|
15977
|
-
return
|
15978
|
-
}
|
15979
|
-
if (this.os === 'darwin') {
|
15980
|
-
const osConf = {
|
15981
|
-
manifestLocation,
|
15982
|
-
namedPipeName,
|
15983
|
-
...this.nixConfig
|
15984
|
-
};
|
15985
|
-
return this.macLaunch(config, osConf);
|
17176
|
+
async launch(config, manifestLocation, namedPipeName) {
|
17177
|
+
if (Launcher.RVM_SUPPORTED()) {
|
17178
|
+
return (0, rvm_launch_1.launch)(config, manifestLocation, namedPipeName);
|
15986
17179
|
}
|
15987
|
-
if (
|
15988
|
-
const
|
17180
|
+
if (os.platform() === 'linux') {
|
17181
|
+
const osConfig = {
|
15989
17182
|
manifestLocation,
|
15990
17183
|
namedPipeName,
|
15991
17184
|
urlPath: `linux/${os.arch()}`,
|
15992
|
-
executablePath: 'openfin'
|
15993
|
-
...this.nixConfig
|
17185
|
+
executablePath: 'openfin'
|
15994
17186
|
};
|
15995
|
-
return
|
17187
|
+
return (0, nix_launch_1.launch)(config, osConfig);
|
15996
17188
|
}
|
15997
|
-
throw new Error(`Launching not supported on ${
|
17189
|
+
throw new Error(`Launching not supported on ${os.platform()}`);
|
15998
17190
|
}
|
15999
17191
|
static IS_SUPPORTED() {
|
16000
17192
|
const platform = os.platform();
|
16001
|
-
return
|
17193
|
+
return ['win32', 'darwin', 'linux'].includes(platform);
|
16002
17194
|
}
|
16003
|
-
|
16004
|
-
|
16005
|
-
return
|
16006
|
-
}
|
16007
|
-
// eslint-disable-next-line class-methods-use-this
|
16008
|
-
winLaunch(config, manifestLocation, namedPipeName) {
|
16009
|
-
return (0, win_launch_1.default)(config, manifestLocation, namedPipeName);
|
17195
|
+
static RVM_SUPPORTED() {
|
17196
|
+
const platform = os.platform();
|
17197
|
+
return ['win32', 'darwin'].includes(platform);
|
16010
17198
|
}
|
16011
17199
|
}
|
16012
17200
|
launcher.default = Launcher;
|
16013
17201
|
return launcher;
|
16014
17202
|
}
|
16015
17203
|
|
17204
|
+
var bufferReader = {};
|
17205
|
+
|
17206
|
+
Object.defineProperty(bufferReader, "__esModule", { value: true });
|
17207
|
+
bufferReader.BufferReader = void 0;
|
17208
|
+
/**
|
17209
|
+
* Really simple buffer reader that reads from a buffer and keeps track of the offset.
|
17210
|
+
* Ripped from runtime test helpers: https://gitlab.com/openfin/runtime/runtime/-/commit/d5f8e356911d70f92d78f4f62874f659f36f3667
|
17211
|
+
*/
|
17212
|
+
class BufferReader {
|
17213
|
+
constructor(buf) {
|
17214
|
+
this.buf = buf;
|
17215
|
+
this.buf = buf;
|
17216
|
+
this.offset = 0;
|
17217
|
+
}
|
17218
|
+
readInt16() {
|
17219
|
+
const result = this.buf.readInt16LE(this.offset);
|
17220
|
+
this.offset += 2;
|
17221
|
+
return result;
|
17222
|
+
}
|
17223
|
+
readInt32() {
|
17224
|
+
const result = this.buf.readInt32LE(this.offset);
|
17225
|
+
this.offset += 4;
|
17226
|
+
return result;
|
17227
|
+
}
|
17228
|
+
readString(stringLength) {
|
17229
|
+
const result = this.buf.subarray(this.offset, this.offset + stringLength).toString();
|
17230
|
+
this.offset += stringLength;
|
17231
|
+
return result;
|
17232
|
+
}
|
17233
|
+
}
|
17234
|
+
bufferReader.BufferReader = BufferReader;
|
17235
|
+
|
16016
17236
|
var hasRequiredPortDiscovery;
|
16017
17237
|
|
16018
17238
|
function requirePortDiscovery () {
|
@@ -16021,14 +17241,14 @@ function requirePortDiscovery () {
|
|
16021
17241
|
Object.defineProperty(portDiscovery, "__esModule", { value: true });
|
16022
17242
|
/* eslint-disable @typescript-eslint/naming-convention */
|
16023
17243
|
const fs = require$$0$2;
|
16024
|
-
const net = require$$1;
|
16025
|
-
const
|
16026
|
-
const
|
17244
|
+
const net = require$$1$2;
|
17245
|
+
const os = require$$1$1;
|
17246
|
+
const path = require$$1;
|
16027
17247
|
const timers_1 = require$$4;
|
16028
|
-
const wire_1 = wire;
|
16029
17248
|
const launcher_1 = requireLauncher();
|
17249
|
+
const buffer_reader_1 = bufferReader;
|
17250
|
+
const wire_1 = wire;
|
16030
17251
|
const launcher = new launcher_1.default();
|
16031
|
-
const MessageHeaderSize = 20; // sizeof(ChromiumMessageHeader)
|
16032
17252
|
// value for message_type
|
16033
17253
|
var ChromiumMessageType;
|
16034
17254
|
(function (ChromiumMessageType) {
|
@@ -16083,78 +17303,59 @@ function requirePortDiscovery () {
|
|
16083
17303
|
return manifest;
|
16084
17304
|
}
|
16085
17305
|
function onRuntimeHello(data, conn) {
|
16086
|
-
const
|
17306
|
+
const reader = new buffer_reader_1.BufferReader(data);
|
17307
|
+
const header = readHeader(reader);
|
16087
17308
|
if (header.message_type === ChromiumMessageType.RUNTIME_HELLO_MESSAGE) {
|
16088
|
-
|
16089
|
-
if (helloPayload === 0) {
|
16090
|
-
// need to read again on unix
|
16091
|
-
header.extraInteger = true;
|
16092
|
-
helloPayload = readUint32(data, MessageHeaderSize + 4);
|
16093
|
-
}
|
16094
|
-
writeHelloMessage(header, conn);
|
17309
|
+
conn.write(data);
|
16095
17310
|
}
|
16096
17311
|
else {
|
16097
|
-
console.error(`Invalid port discovery hello message type ${header.message_type}`);
|
17312
|
+
console.error(`[port-discovery] Invalid port discovery hello message type ${header.message_type}`);
|
16098
17313
|
}
|
16099
17314
|
}
|
16100
17315
|
function onDiscoverMessage(data) {
|
16101
|
-
const
|
17316
|
+
const reader = new buffer_reader_1.BufferReader(data);
|
17317
|
+
const header = readHeader(reader);
|
16102
17318
|
if (header.message_type === ChromiumMessageType.RUNTIME_STRING_MESSAGE) {
|
16103
|
-
const
|
16104
|
-
|
16105
|
-
|
16106
|
-
|
16107
|
-
|
16108
|
-
|
16109
|
-
|
16110
|
-
|
16111
|
-
|
16112
|
-
|
16113
|
-
|
16114
|
-
|
17319
|
+
const messageLength = reader.readInt32();
|
17320
|
+
const msg = reader.readString(messageLength);
|
17321
|
+
try {
|
17322
|
+
const env = JSON.parse(msg);
|
17323
|
+
if (env?.payload) {
|
17324
|
+
return env.payload;
|
17325
|
+
}
|
17326
|
+
console.warn(`[port-discovery] Discovery message did not have payload`, {
|
17327
|
+
header,
|
17328
|
+
msg,
|
17329
|
+
messageLength
|
17330
|
+
});
|
16115
17331
|
}
|
16116
|
-
|
16117
|
-
|
16118
|
-
|
16119
|
-
|
17332
|
+
catch (e) {
|
17333
|
+
console.error(`[port-discovery] Error parsing discovery message: ${e.message}`, {
|
17334
|
+
header,
|
17335
|
+
msg,
|
17336
|
+
messageLength
|
17337
|
+
});
|
16120
17338
|
}
|
16121
|
-
console.warn('discovery message did not have payload');
|
16122
17339
|
}
|
16123
17340
|
else {
|
16124
|
-
console.error(`Invalid port discovery message type ${header.message_type}`);
|
17341
|
+
console.error(`[port-discovery] Invalid port discovery message type ${header.message_type}`);
|
16125
17342
|
}
|
16126
17343
|
return undefined;
|
16127
17344
|
}
|
16128
|
-
function readHeader(
|
17345
|
+
function readHeader(reader) {
|
16129
17346
|
const header = {};
|
16130
|
-
header.payload_size =
|
16131
|
-
header.routing_id =
|
16132
|
-
header.message_type =
|
16133
|
-
header.flags =
|
16134
|
-
header.attachment_count =
|
17347
|
+
header.payload_size = reader.readInt32();
|
17348
|
+
header.routing_id = reader.readInt32();
|
17349
|
+
header.message_type = reader.readInt32();
|
17350
|
+
header.flags = reader.readInt32();
|
17351
|
+
header.attachment_count = reader.readInt32();
|
17352
|
+
header.os = os.platform();
|
17353
|
+
if (header.os !== 'win32') {
|
17354
|
+
header.num_fds = reader.readInt16();
|
17355
|
+
header.pad = reader.readInt16();
|
17356
|
+
}
|
16135
17357
|
return header;
|
16136
17358
|
}
|
16137
|
-
function writeHelloMessage(header, conn) {
|
16138
|
-
const data = Buffer.alloc(MessageHeaderSize + (header.extraInteger ? 28 : 4));
|
16139
|
-
writeUint32(data, header.payload_size, 0);
|
16140
|
-
writeUint32(data, header.routing_id, 4);
|
16141
|
-
writeUint32(data, header.message_type, 8);
|
16142
|
-
writeUint32(data, header.flags, 12);
|
16143
|
-
writeUint32(data, header.attachment_count, 16);
|
16144
|
-
let next = 20;
|
16145
|
-
if (header.extraInteger) {
|
16146
|
-
writeUint32(data, 0, next);
|
16147
|
-
next += 4;
|
16148
|
-
}
|
16149
|
-
writeUint32(data, process.pid, next);
|
16150
|
-
conn.write(data);
|
16151
|
-
}
|
16152
|
-
function readUint32(data, offset) {
|
16153
|
-
return data.readInt32LE(offset);
|
16154
|
-
}
|
16155
|
-
function writeUint32(data, value, offset) {
|
16156
|
-
data.writeInt32LE(value, offset);
|
16157
|
-
}
|
16158
17359
|
class PortDiscovery {
|
16159
17360
|
constructor(config, environment) {
|
16160
17361
|
this.savedConfig = { ...config };
|
@@ -16319,7 +17520,7 @@ function requireNodeEnv () {
|
|
16319
17520
|
Object.defineProperty(nodeEnv, "__esModule", { value: true });
|
16320
17521
|
/* eslint-disable class-methods-use-this */
|
16321
17522
|
const fs_1 = require$$0$2;
|
16322
|
-
const crypto_1 = require$$1$
|
17523
|
+
const crypto_1 = require$$1$3;
|
16323
17524
|
const _WS = require$$2$1;
|
16324
17525
|
const environment_1 = environment;
|
16325
17526
|
const port_discovery_1 = requirePortDiscovery();
|