@openfin/core 40.200.2 → 41.83.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/out/mock.js CHANGED
@@ -361,7 +361,7 @@ async function promiseMapSerial(arr, func) {
361
361
  }
362
362
  promises.promiseMapSerial = promiseMapSerial;
363
363
 
364
- var __classPrivateFieldSet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
364
+ var __classPrivateFieldSet$d = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
365
365
  if (kind === "m") throw new TypeError("Private method is not writable");
366
366
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
367
367
  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");
@@ -490,7 +490,7 @@ class EmitterBase extends Base {
490
490
  // This will only be reached if unsubscribe from event that does not exist but do not want to error here
491
491
  return Promise.resolve();
492
492
  };
493
- __classPrivateFieldSet$c(this, _EmitterBase_emitterAccessor, [topic, ...additionalAccessors], "f");
493
+ __classPrivateFieldSet$d(this, _EmitterBase_emitterAccessor, [topic, ...additionalAccessors], "f");
494
494
  this.listeners = (event) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(event) : [];
495
495
  }
496
496
  /**
@@ -1055,902 +1055,238 @@ class AsyncRetryableLazy {
1055
1055
  }
1056
1056
  lazy.AsyncRetryableLazy = AsyncRetryableLazy;
1057
1057
 
1058
- var layoutEntities = {};
1059
-
1060
- var apiExposer$1 = {};
1061
-
1062
- var apiConsumer = {};
1063
-
1064
- Object.defineProperty(apiConsumer, "__esModule", { value: true });
1065
- apiConsumer.ApiConsumer = void 0;
1066
- /**
1067
- * Consumer for apis exposed with {@see ApiExposer}.
1068
- *
1069
- * A strategy that matches the strategy used to expose a target API must be provided.
1070
- */
1071
- class ApiConsumer {
1072
- // eslint-disable-next-line
1073
- constructor(strategy) {
1074
- this.strategy = strategy;
1075
- /**
1076
- * Consumes an api exposed using a given transport strategy, and generates a client
1077
- * for easy, type safe consumption of that client.
1078
- * @param options Strategy specific consumption options.
1079
- * @returns An api client matching the given type.
1080
- */
1081
- this.consume = async (options) => {
1082
- const exposedProperties = await this.strategy.getExposedFunctions(options);
1083
- return exposedProperties.reduce((client, prop) => ({
1084
- ...client,
1085
- [prop.key]: this.strategy.createFunction(prop, options)
1086
- }), {});
1087
- };
1088
- }
1089
- }
1090
- apiConsumer.ApiConsumer = ApiConsumer;
1091
-
1092
- var apiExposer = {};
1093
-
1094
- var decorators = {};
1095
-
1096
- Object.defineProperty(decorators, "__esModule", { value: true });
1097
- decorators.expose = decorators.getExposedProperties = void 0;
1098
- const exposedProperties = Symbol('exposedProperties');
1099
- const getExposedProperties = (target) => {
1100
- return target[exposedProperties] || target.prototype[exposedProperties] || [];
1101
- };
1102
- decorators.getExposedProperties = getExposedProperties;
1103
- /**
1104
- * Indicates that a class member function can be exposed using {@link ApiExposer}.
1105
- * @param options Options specific to the strategy used in {@link ApiExposer}
1106
- */
1107
- // Returns any as decorator typing is weird.
1108
- const expose = (options) => (target, key, descriptor) => {
1109
- target[exposedProperties] = target[exposedProperties] || [];
1110
- target[exposedProperties].push({ key, descriptor, options });
1111
- };
1112
- decorators.expose = expose;
1058
+ var main = {};
1113
1059
 
1114
- Object.defineProperty(apiExposer, "__esModule", { value: true });
1115
- apiExposer.ApiExposer = void 0;
1116
- const decorators_1 = decorators;
1117
- /**
1118
- * Exposes api services on the transport of choice.
1119
- */
1120
- class ApiExposer {
1060
+ Object.defineProperty(main, "__esModule", { value: true });
1061
+ main.WebContents = void 0;
1062
+ const base_1$j = base;
1063
+ class WebContents extends base_1$j.EmitterBase {
1121
1064
  /**
1122
- * @param strategy The expose strategy to use to expose instances.
1065
+ * @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
1066
+ * @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
1123
1067
  */
1124
- // eslint-disable-next-line
1125
- constructor(strategy) {
1126
- this.strategy = strategy;
1127
- /**
1128
- * Exposes an instance of a given api on
1129
- * @param instance Instance of a class which has been decorated to indicate which functions can be exposed.
1130
- * @param instanceOptions Transport strategy specific options to use when exposing.
1131
- */
1132
- this.exposeInstance = async (instance, instanceOptions) => {
1133
- const exposableProps = (0, decorators_1.getExposedProperties)(instance);
1134
- const exposedProps = await Promise.all(exposableProps.map(async ({ key, options }) => {
1135
- const customConsumptionOptions = await this.strategy.exposeFunction(instance[key].bind(instance), {
1136
- key,
1137
- options,
1138
- meta: instanceOptions
1139
- });
1140
- return {
1141
- key,
1142
- options: customConsumptionOptions
1143
- };
1144
- }));
1145
- await this.strategy.exposeMeta(instanceOptions, exposedProps);
1146
- };
1068
+ constructor(wire, identity, entityType) {
1069
+ super(wire, entityType, identity.uuid, identity.name);
1070
+ this.identity = identity;
1071
+ this.entityType = entityType;
1147
1072
  }
1148
- ;
1149
- }
1150
- apiExposer.ApiExposer = ApiExposer;
1151
-
1152
- var strategies = {};
1153
-
1154
- var openfinChannels = {};
1155
-
1156
- var channelsConsumer = {};
1157
-
1158
- Object.defineProperty(channelsConsumer, "__esModule", { value: true });
1159
- channelsConsumer.ChannelsConsumer = void 0;
1160
- class ChannelsConsumer {
1161
- // eslint-disable-next-line
1162
- constructor(channel) {
1163
- this.channel = channel;
1164
- this.getExposedFunctions = async (options) => {
1165
- const { id } = options;
1166
- const { props } = await this.channel.dispatch(`api-meta:${id}`);
1167
- return props;
1168
- };
1169
- this.createFunction = (prop) => (...args) => {
1170
- const { action } = prop.options;
1171
- return this.channel.dispatch(action, { args });
1172
- };
1073
+ /**
1074
+ * Gets a base64 encoded image of all or part of the WebContents.
1075
+ * @param options Options for the capturePage call.
1076
+ *
1077
+ * @example
1078
+ *
1079
+ * View:
1080
+ * ```js
1081
+ * const view = fin.View.getCurrentSync();
1082
+ *
1083
+ * // PNG image of a full visible View
1084
+ * console.log(await view.capturePage());
1085
+ *
1086
+ * // Low-quality JPEG image of a defined visible area of the view
1087
+ * const options = {
1088
+ * area: {
1089
+ * height: 100,
1090
+ * width: 100,
1091
+ * x: 10,
1092
+ * y: 10,
1093
+ * },
1094
+ * format: 'jpg',
1095
+ * quality: 20
1096
+ * }
1097
+ * console.log(await view.capturePage(options));
1098
+ * ```
1099
+ *
1100
+ * Window:
1101
+ * ```js
1102
+ * const wnd = await fin.Window.getCurrent();
1103
+ *
1104
+ * // PNG image of a full visible window
1105
+ * console.log(await wnd.capturePage());
1106
+ *
1107
+ * // Low-quality JPEG image of a defined visible area of the window
1108
+ * const options = {
1109
+ * area: {
1110
+ * height: 100,
1111
+ * width: 100,
1112
+ * x: 10,
1113
+ * y: 10,
1114
+ * },
1115
+ * format: 'jpg',
1116
+ * quality: 20
1117
+ * }
1118
+ * console.log(await wnd.capturePage(options));
1119
+ * ```
1120
+ *
1121
+ * @remarks
1122
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1123
+ * We do not expose an explicit superclass for this functionality, but it does have its own
1124
+ * {@link OpenFin.WebContentsEvents event namespace}.
1125
+ */
1126
+ capturePage(options) {
1127
+ return this.wire.sendAction('capture-page', { options, ...this.identity }).then(({ payload }) => payload.data);
1173
1128
  }
1174
- ;
1175
- }
1176
- channelsConsumer.ChannelsConsumer = ChannelsConsumer;
1177
-
1178
- var channelsExposer = {};
1179
-
1180
- Object.defineProperty(channelsExposer, "__esModule", { value: true });
1181
- channelsExposer.ChannelsExposer = void 0;
1182
- class ChannelsExposer {
1183
- // eslint-disable-next-line
1184
- constructor(channelProviderOrClient) {
1185
- this.channelProviderOrClient = channelProviderOrClient;
1186
- this.exposeFunction = async (target, config) => {
1187
- const { key, options, meta } = config;
1188
- const { id } = meta;
1189
- const action = `${id}.${options?.action || key}`;
1190
- await this.channelProviderOrClient.register(action, async ({ args }) => {
1191
- return target(...args);
1192
- });
1193
- return { action };
1194
- };
1195
- this.exposeMeta = async ({ id }, props) => {
1196
- const action = `api-meta:${id}`;
1197
- await this.channelProviderOrClient.register(action, () => ({ props }));
1198
- };
1129
+ /**
1130
+ * Executes Javascript on the WebContents, restricted to contents you own or contents owned by
1131
+ * applications you have created.
1132
+ * @param code JavaScript code to be executed on the view.
1133
+ *
1134
+ * @example
1135
+ * View:
1136
+ * ```js
1137
+ * async function executeJavaScript(code) {
1138
+ * const view = await fin.View.wrap({uuid: 'uuid', name: 'view name'});
1139
+ * return await view.executeJavaScript(code);
1140
+ * }
1141
+ *
1142
+ * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
1143
+ * ```
1144
+ *
1145
+ * Window:
1146
+ * ```js
1147
+ * async function executeJavaScript(code) {
1148
+ * const app = await fin.Application.start({
1149
+ * name: 'myApp',
1150
+ * uuid: 'app-1',
1151
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.executeJavaScript.html',
1152
+ * autoShow: true
1153
+ * });
1154
+ * const win = await app.getWindow();
1155
+ * return await win.executeJavaScript(code);
1156
+ * }
1157
+ *
1158
+ * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
1159
+ * ```
1160
+ * @remarks
1161
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1162
+ * We do not expose an explicit superclass for this functionality, but it does have its own
1163
+ * {@link OpenFin.WebContentsEvents event namespace}.
1164
+ */
1165
+ executeJavaScript(code) {
1166
+ return this.wire
1167
+ .sendAction('execute-javascript-in-window', { ...this.identity, code })
1168
+ .then(({ payload }) => payload.data);
1199
1169
  }
1200
- }
1201
- channelsExposer.ChannelsExposer = ChannelsExposer;
1202
-
1203
- (function (exports) {
1204
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1205
- if (k2 === undefined) k2 = k;
1206
- var desc = Object.getOwnPropertyDescriptor(m, k);
1207
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1208
- desc = { enumerable: true, get: function() { return m[k]; } };
1209
- }
1210
- Object.defineProperty(o, k2, desc);
1211
- }) : (function(o, m, k, k2) {
1212
- if (k2 === undefined) k2 = k;
1213
- o[k2] = m[k];
1214
- }));
1215
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
1216
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1217
- };
1218
- Object.defineProperty(exports, "__esModule", { value: true });
1219
- __exportStar(channelsConsumer, exports);
1220
- __exportStar(channelsExposer, exports);
1221
- } (openfinChannels));
1222
-
1223
- (function (exports) {
1224
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1225
- if (k2 === undefined) k2 = k;
1226
- var desc = Object.getOwnPropertyDescriptor(m, k);
1227
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1228
- desc = { enumerable: true, get: function() { return m[k]; } };
1229
- }
1230
- Object.defineProperty(o, k2, desc);
1231
- }) : (function(o, m, k, k2) {
1232
- if (k2 === undefined) k2 = k;
1233
- o[k2] = m[k];
1234
- }));
1235
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
1236
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1237
- };
1238
- Object.defineProperty(exports, "__esModule", { value: true });
1239
- __exportStar(openfinChannels, exports);
1240
- } (strategies));
1241
-
1242
- (function (exports) {
1243
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1244
- if (k2 === undefined) k2 = k;
1245
- var desc = Object.getOwnPropertyDescriptor(m, k);
1246
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1247
- desc = { enumerable: true, get: function() { return m[k]; } };
1248
- }
1249
- Object.defineProperty(o, k2, desc);
1250
- }) : (function(o, m, k, k2) {
1251
- if (k2 === undefined) k2 = k;
1252
- o[k2] = m[k];
1253
- }));
1254
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
1255
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1256
- };
1257
- Object.defineProperty(exports, "__esModule", { value: true });
1258
- __exportStar(apiConsumer, exports);
1259
- __exportStar(apiExposer, exports);
1260
- __exportStar(strategies, exports);
1261
- __exportStar(decorators, exports);
1262
- } (apiExposer$1));
1263
-
1264
- var channelApiRelay = {};
1265
-
1266
- Object.defineProperty(channelApiRelay, "__esModule", { value: true });
1267
- channelApiRelay.createRelayedDispatch = channelApiRelay.relayChannelClientApi = void 0;
1268
- const EXPECTED_ERRORS = [
1269
- 'no longer connected',
1270
- 'RTCDataChannel closed unexpectedly',
1271
- 'The client you are trying to dispatch from is disconnected from the target provider',
1272
- ];
1273
- // Checks possible error messages that we want to trap, client error message can originate
1274
- // from ChannelProvider::dispatch OR ClassicStrategy::closeEndpoint OR RTCEndPoint::dataChannel::onclose
1275
- const isDisconnectedError = (errorMsg) => {
1276
- return EXPECTED_ERRORS.some(e => errorMsg.includes(e));
1277
- };
1278
- /**
1279
- * @internal
1280
- * Create a channel relay for a given channel exposition, allowing a single provider to route
1281
- * actions to the designated clients.
1282
- *
1283
- * Designed to be used in conjunction with @expose
1284
- *
1285
- * @param channelProvider The channel provider to relay the actions on.
1286
- * @param config Determines which actions to relay. Please ensure action prefix matches the exposed api.
1287
- */
1288
- const relayChannelClientApi = async (channelProvider, relayId) => {
1289
- channelProvider.register(`relay:${relayId}`, ({ action, target, payload }) => {
1290
- return channelProvider.dispatch(target, action, payload);
1291
- });
1292
- await Promise.resolve();
1293
- };
1294
- channelApiRelay.relayChannelClientApi = relayChannelClientApi;
1295
- const createRelayedDispatch = (client, target, relayId, relayErrorMsg) => async (action, payload) => {
1296
- try {
1297
- return await client.dispatch(`relay:${relayId}`, {
1298
- action,
1299
- payload,
1300
- target
1301
- });
1170
+ /**
1171
+ * Returns the zoom level of the WebContents.
1172
+ *
1173
+ * @example
1174
+ * View:
1175
+ * ```js
1176
+ * async function getZoomLevel() {
1177
+ * const view = await fin.View.getCurrent();
1178
+ * return await view.getZoomLevel();
1179
+ * }
1180
+ *
1181
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
1182
+ * ```
1183
+ *
1184
+ * Window:
1185
+ * ```js
1186
+ * async function createWin() {
1187
+ * const app = await fin.Application.start({
1188
+ * name: 'myApp',
1189
+ * uuid: 'app-1',
1190
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getZoomLevel.html',
1191
+ * autoShow: true
1192
+ * });
1193
+ * return await app.getWindow();
1194
+ * }
1195
+ *
1196
+ * async function getZoomLevel() {
1197
+ * const win = await createWin();
1198
+ * return await win.getZoomLevel();
1199
+ * }
1200
+ *
1201
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
1202
+ * ```
1203
+ * @remarks
1204
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1205
+ * We do not expose an explicit superclass for this functionality, but it does have its own
1206
+ * {@link OpenFin.WebContentsEvents event namespace}.
1207
+ */
1208
+ getZoomLevel() {
1209
+ return this.wire.sendAction('get-zoom-level', this.identity).then(({ payload }) => payload.data);
1302
1210
  }
1303
- catch (e) {
1304
- if (isDisconnectedError(e.message) && relayErrorMsg) {
1305
- throw new Error(relayErrorMsg);
1306
- }
1307
- throw e;
1211
+ /**
1212
+ * Sets the zoom level of the WebContents.
1213
+ * @param level The zoom level
1214
+ *
1215
+ * @example
1216
+ * View:
1217
+ * ```js
1218
+ * async function setZoomLevel(number) {
1219
+ * const view = await fin.View.getCurrent();
1220
+ * return await view.setZoomLevel(number);
1221
+ * }
1222
+ *
1223
+ * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
1224
+ * ```
1225
+ *
1226
+ * Window:
1227
+ * ```js
1228
+ * async function createWin() {
1229
+ * const app = await fin.Application.start({
1230
+ * name: 'myApp',
1231
+ * uuid: 'app-1',
1232
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.setZoomLevel.html',
1233
+ * autoShow: true
1234
+ * });
1235
+ * return await app.getWindow();
1236
+ * }
1237
+ *
1238
+ * async function setZoomLevel(number) {
1239
+ * const win = await createWin();
1240
+ * return await win.setZoomLevel(number);
1241
+ * }
1242
+ *
1243
+ * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
1244
+ * ```
1245
+ * @remarks
1246
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1247
+ * We do not expose an explicit superclass for this functionality, but it does have its own
1248
+ * {@link OpenFin.WebContentsEvents event namespace}.
1249
+ */
1250
+ setZoomLevel(level) {
1251
+ return this.wire.sendAction('set-zoom-level', { ...this.identity, level }).then(() => undefined);
1308
1252
  }
1309
- };
1310
- channelApiRelay.createRelayedDispatch = createRelayedDispatch;
1311
-
1312
- var __classPrivateFieldSet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
1313
- if (kind === "m") throw new TypeError("Private method is not writable");
1314
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
1315
- 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");
1316
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1317
- };
1318
- var __classPrivateFieldGet$d = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
1319
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1320
- 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");
1321
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1322
- };
1323
- var _LayoutNode_client, _TabStack_client, _ColumnOrRow_client;
1324
- Object.defineProperty(layoutEntities, "__esModule", { value: true });
1325
- layoutEntities.ColumnOrRow = layoutEntities.TabStack = layoutEntities.LayoutNode = void 0;
1326
- const api_exposer_1 = apiExposer$1;
1327
- const channel_api_relay_1 = channelApiRelay;
1328
- /*
1329
- This file includes LayoutNode, ColumnOrRow and TabStack classes, which are all closely
1330
- intertwined, and share members via parent abstract class LayoutNode. To prevent circular
1331
- refs, we define and export all the classes here.
1332
- */
1333
- /**
1334
- * @ignore
1335
- * @internal
1336
- * Supplies an ApiClient for {@link LayoutEntitiesController} and helper methods
1337
- * for the entities {@link TabStack} AND {@link ColumnOrRow} to use.
1338
- */
1339
- class LayoutNode {
1340
1253
  /**
1341
- * @internal
1342
- * @ignore
1343
- */
1344
- constructor(client, entityId) {
1345
- /**
1346
- * @ignore
1347
- * @internal
1348
- * ApiClient for {@link LayoutEntitiesController}
1349
- */
1350
- _LayoutNode_client.set(this, void 0);
1351
- /**
1352
- * Checks if the TabStack or ColumnOrRow is the root content item
1353
- *
1354
- * @example
1355
- * ```js
1356
- * if (!fin.me.isView) {
1357
- * throw new Error('Not running in a platform View.');
1358
- * }
1359
- *
1360
- * const stack = await fin.me.getCurrentStack();
1361
- * const isRoot = await stack.isRoot();
1362
- * // The TabStack is root: false
1363
- * console.log(`The TabStack is root: ${isRoot}`);
1364
- *
1365
- * // Retrieves the parent ColumnOrRow
1366
- * const parent = await stack.getParent();
1367
- * const parentIsRoot = await parent.isRoot();
1368
- * // The parent ColumnOrRow is root: true
1369
- * console.log(`The parent ColumnOrRow is root: ${parentIsRoot}`);
1370
- * ```
1371
- */
1372
- this.isRoot = () => __classPrivateFieldGet$d(this, _LayoutNode_client, "f").isRoot(this.entityId);
1373
- /**
1374
- * Checks if the TabStack or ColumnOrRow exists
1375
- *
1376
- * @example
1377
- * ```js
1378
- * if (!fin.me.isView) {
1379
- * throw new Error('Not running in a platform View.');
1380
- * }
1381
- *
1382
- * const stack = await fin.me.getCurrentStack();
1383
- * // Retrieves the parent ColumnOrRow
1384
- * const columnOrRow = await stack.getParent();
1385
- * let exists = await stack.exists();
1386
- * // or
1387
- * let exists = await columnOrRow.exists();
1388
- * // The entity exists: true
1389
- * console.log(`The entity exists: ${exists}`);
1390
- * ```
1391
- */
1392
- this.exists = () => __classPrivateFieldGet$d(this, _LayoutNode_client, "f").exists(this.entityId);
1393
- /**
1394
- * Retrieves the parent of the TabStack or ColumnOrRow
1395
- *
1396
- * @example
1397
- * ```js
1398
- * if (!fin.me.isView) {
1399
- * throw new Error('Not running in a platform View.');
1400
- * }
1401
- *
1402
- * const stack = await fin.me.getCurrentStack();
1403
- * // Retrieves the parent ColumnOrRow
1404
- * const columnOrRow = await stack.getParent();
1405
- *
1406
- * // undefined if entity is the root item
1407
- * let parent = await columnOrRow.getParent();
1408
- * // or
1409
- * let parent = await stack.getParent();
1410
- * ```
1411
- */
1412
- this.getParent = async () => {
1413
- const parent = await __classPrivateFieldGet$d(this, _LayoutNode_client, "f").getParent(this.entityId);
1414
- if (!parent) {
1415
- return undefined;
1416
- }
1417
- return LayoutNode.getEntity(parent, __classPrivateFieldGet$d(this, _LayoutNode_client, "f"));
1418
- };
1419
- /**
1420
- * Creates a new TabStack adjacent to the given TabStack or ColumnOrRow. Inputs can be new views to create, or existing views.
1421
- *
1422
- * Known Issue: If the number of views to add overflows the tab-container, the added views will be set as active
1423
- * during each render, and then placed at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
1424
- * This means the views you pass to createAdjacentStack() may not render in the order given by the array.
1425
- * Until fixed, this problem can be avoided only if your window is wide enough to fit creating all the views in the tabstack.
1426
- *
1427
- * @param views The views that will populate the new TabStack.
1428
- * @param options Additional options that control new TabStack creation.
1429
- * @returns The newly-created TabStack.
1430
- *
1431
- * @example
1432
- * ```js
1433
- * if (!fin.me.isView) {
1434
- * throw new Error('Not running in a platform View.');
1435
- * }
1436
- *
1437
- * const stack = await fin.me.getCurrentStack();
1438
- * const columnOrRow = await stack.getParent();
1439
- *
1440
- * // Create view references by supplying a 'name' and 'url'
1441
- * const views = [
1442
- * // if 'name' is undefined, one will be generated
1443
- * // if 'url' is undefined, it will default the view URL to 'about:blank'
1444
- * { name: 'google-view', url: 'http://google.com/'},
1445
- * { name: 'of-developers-view', url: 'http://developers.openfin.co/'},
1446
- * ];
1447
- *
1448
- * // Create a view beforehand to be included in the new tab stack
1449
- * const outsideView = await fin.View.create({
1450
- * name: 'outside-bloomberg-view',
1451
- * url: 'https://bloomberg.com/',
1452
- * target: fin.me.identity,
1453
- * });
1454
- *
1455
- * // Views to add can be identities, or the reference views mentioned above
1456
- * const viewsToAdd = [outsideView.identity, ...views];
1457
- *
1458
- * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
1459
- * let stackFrom = await columnOrRow.createAdjacentStack(viewsToAdd, { position: 'right' });
1460
- * // Or
1461
- * let newStack = await stack.createAdjacentStack(viewsToAdd, { position: 'right' });
1462
- * console.log(`A new TabStack created to the right has ${newStack.length} views in it`);
1463
- *
1464
- * ```
1465
- * @experimental
1466
- */
1467
- this.createAdjacentStack = async (views, options) => {
1468
- const entityId = await __classPrivateFieldGet$d(this, _LayoutNode_client, "f").createAdjacentStack(this.entityId, views, options);
1469
- return LayoutNode.getEntity({ entityId, type: 'stack' }, __classPrivateFieldGet$d(this, _LayoutNode_client, "f"));
1470
- };
1471
- /**
1472
- * Retrieves the adjacent TabStacks of the given TabStack or ColumnOrRow.
1473
- *
1474
- * @param edge Edge whose adjacent TabStacks will be returned.
1475
- *
1476
- * @example
1477
- * ```js
1478
- * if (!fin.me.isView) {
1479
- * throw new Error('Not running in a platform View.');
1480
- * }
1481
- *
1482
- * const stack = await fin.me.getCurrentStack();
1483
- * const columnOrRow = await stack.getParent();
1484
- * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
1485
- * let rightStacks = await columnOrRow.getAdjacentStacks('right');
1486
- * let leftStacks = await columnOrRow.getAdjacentStacks('left');
1487
- * // or
1488
- * let rightStacks = await stack.getAdjacentStacks('right');
1489
- * let leftStacks = await stack.getAdjacentStacks('left');
1490
- *
1491
- * console.log(`The entity has ${rightStacks.length} stacks to the right, and ${leftStacks.length} stacks to the left`);
1492
- *
1493
- * ```
1494
- * @experimental
1495
- */
1496
- this.getAdjacentStacks = async (edge) => {
1497
- const adjacentStacks = await __classPrivateFieldGet$d(this, _LayoutNode_client, "f").getAdjacentStacks({
1498
- targetId: this.entityId,
1499
- edge
1500
- });
1501
- return adjacentStacks.map((stack) => LayoutNode.getEntity({
1502
- type: 'stack',
1503
- entityId: stack.entityId
1504
- }, __classPrivateFieldGet$d(this, _LayoutNode_client, "f")));
1505
- };
1506
- __classPrivateFieldSet$b(this, _LayoutNode_client, client, "f");
1507
- this.entityId = entityId;
1508
- }
1509
- }
1510
- layoutEntities.LayoutNode = LayoutNode;
1511
- _LayoutNode_client = new WeakMap();
1512
- /**
1513
- * @ignore
1514
- * @internal
1515
- * Encapsulates Api consumption of {@link LayoutEntitiesClient} with a relayed dispatch
1516
- * @param client
1517
- * @param controllerId
1518
- * @param identity
1519
- * @returns a new instance of {@link LayoutEntitiesClient} with bound to the controllerId
1520
- */
1521
- LayoutNode.newLayoutEntitiesClient = async (client, controllerId, identity) => {
1522
- const dispatch = (0, channel_api_relay_1.createRelayedDispatch)(client, identity, 'layout-relay', 'You are trying to interact with a layout component on a window that does not exist or has been destroyed.');
1523
- const consumer = new api_exposer_1.ApiConsumer(new api_exposer_1.ChannelsConsumer({ dispatch }));
1524
- return consumer.consume({ id: controllerId });
1525
- };
1526
- LayoutNode.getEntity = (definition, client) => {
1527
- const { entityId, type } = definition;
1528
- switch (type) {
1529
- case 'column':
1530
- case 'row':
1531
- return new ColumnOrRow(client, entityId, type);
1532
- case 'stack':
1533
- return new TabStack(client, entityId);
1534
- default:
1535
- throw new Error(`Unrecognised Layout Entity encountered ('${JSON.stringify(definition)})`);
1536
- }
1537
- };
1538
- /**
1539
- * A TabStack is used to manage the state of a stack of tabs within an OpenFin Layout.
1540
- */
1541
- class TabStack extends LayoutNode {
1542
- /** @internal */
1543
- constructor(client, entityId) {
1544
- super(client, entityId);
1545
- /**
1546
- * @internal
1547
- * ApiClient for {@link LayoutEntitiesController}
1548
- */
1549
- _TabStack_client.set(this, void 0);
1550
- /**
1551
- * Type of the content item. Always stack, but useful for distinguishing between a {@link TabStack} and {@link ColumnOrRow}.
1552
- */
1553
- this.type = 'stack';
1554
- /**
1555
- * Retrieves a list of all views belonging to this {@link TabStack}.
1556
- *
1557
- * Known Issue: If adding a view overflows the tab-container width, the added view will be set as active
1558
- * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
1559
- * If that happens and then getViews() is called, it will return the identities in a different order than
1560
- * than the currently rendered tab order.
1561
- *
1562
- *
1563
- * @throws If the {@link TabStack} has been destroyed.
1564
- * @example
1565
- * ```js
1566
- * if (!fin.me.isView) {
1567
- * throw new Error('Not running in a platform View.');
1568
- * }
1569
- *
1570
- * const stack = await fin.me.getCurrentStack();
1571
- * // Alternatively, you can wrap any view and get the stack from there
1572
- * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
1573
- * // const stack = await viewFromSomewhere.getCurrentStack();
1574
- * const views = await stack.getViews();
1575
- * console.log(`Stack contains ${views.length} view(s)`);
1576
- * ```
1577
- * @experimental
1578
- */
1579
- this.getViews = () => __classPrivateFieldGet$d(this, _TabStack_client, "f").getStackViews(this.entityId);
1580
- /**
1581
- * Adds or creates a view in this {@link TabStack}.
1582
- *
1583
- * @remarks Known Issue: If adding a view overflows the tab-container, the added view will be set as active
1584
- * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
1585
- *
1586
- * @param view The identity of an existing view to add, or options to create a view.
1587
- * @param options Optional view options: index number used to insert the view into the stack at that index. Defaults to 0 (front of the stack)
1588
- * @returns Resolves with the {@link OpenFin.Identity identity} of the added view.
1589
- * @throws If the view does not exist or fails to create.
1590
- * @throws If the {@link TabStack} has been destroyed.
1591
- * @example
1592
- * ```js
1593
- * if (!fin.me.isView) {
1594
- * throw new Error('Not running in a platform View.');
1595
- * }
1596
- *
1597
- * const stack = await fin.me.getCurrentStack();
1598
- * // Alternatively, you can wrap any view and get the stack from there
1599
- * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
1600
- * // const stack = await viewFromSomewhere.getCurrentStack();
1601
- * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
1602
- * console.log('Identity of the google view just added', { googleViewIdentity });
1603
- * // pass in { index: number } to set the index in the stack. Here 1 means, end of the stack (defaults to 0)
1604
- * const appleViewIdentity = await stack.addView({ name: 'apple-view', url: 'http://apple.com/' }, { index: 1 });
1605
- * console.log('Identity of the apple view just added', { appleViewIdentity });
1606
- * ```
1607
- * @experimental
1608
- */
1609
- this.addView = async (view, options = { index: 0 }) => __classPrivateFieldGet$d(this, _TabStack_client, "f").addViewToStack(this.entityId, view, options);
1610
- /**
1611
- * Removes a view from this {@link TabStack}.
1612
- *
1613
- * @remarks Throws an exception if the view identity does not exist or was already destroyed.
1614
- *
1615
- * @param view - Identity of the view to remove.
1616
- * @throws If the view does not exist or does not belong to the stack.
1617
- * @throws If the {@link TabStack} has been destroyed.
1618
- *
1619
- * @example
1620
- * ```js
1621
- * if (!fin.me.isView) {
1622
- * throw new Error('Not running in a platform View.');
1623
- * }
1624
- *
1625
- * const stack = await fin.me.getCurrentStack();
1626
- * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
1627
- *
1628
- * await stack.removeView(googleViewIdentity);
1629
- *
1630
- * try {
1631
- * await stack.removeView(googleViewIdentity);
1632
- * } catch (error) {
1633
- * // Tried to remove a view ('google-view') which does not belong to the stack.
1634
- * console.log(error);
1635
- * }
1636
- * ```
1637
- */
1638
- this.removeView = async (view) => {
1639
- await __classPrivateFieldGet$d(this, _TabStack_client, "f").removeViewFromStack(this.entityId, view);
1640
- };
1641
- /**
1642
- * Sets the active view of the {@link TabStack} without focusing it.
1643
- * @param view - Identity of the view to activate.
1644
- * @returns Promise which resolves with void once the view has been activated.
1645
- * @throws If the {@link TabStack} has been destroyed.
1646
- * @throws If the view does not exist.
1647
- * @example
1648
- * Change the active tab of a known View's TabStack:
1649
- * ```js
1650
- * const targetView = fin.View.wrapSync({ uuid: 'uuid', name: 'view-name' });
1651
- * const stack = await targetView.getCurrentStack();
1652
- * await stack.setActiveView(targetView.identity);
1653
- * ```
1654
- *
1655
- * Set the current View as active within its TabStack:
1656
- * ```js
1657
- * const stack = await fin.me.getCurrentStack();
1658
- * await stack.setActiveView(fin.me.identity);
1659
- * ```
1660
- * @experimental
1661
- */
1662
- this.setActiveView = async (view) => {
1663
- await __classPrivateFieldGet$d(this, _TabStack_client, "f").setStackActiveView(this.entityId, view);
1664
- };
1665
- __classPrivateFieldSet$b(this, _TabStack_client, client, "f");
1666
- }
1667
- }
1668
- layoutEntities.TabStack = TabStack;
1669
- _TabStack_client = new WeakMap();
1670
- /**
1671
- * A ColumnOrRow is used to manage the state of Column and Rows within an OpenFin Layout.
1672
- */
1673
- class ColumnOrRow extends LayoutNode {
1674
- /**
1675
- * @internal
1676
- */
1677
- constructor(client, entityId, type) {
1678
- super(client, entityId);
1679
- /**
1680
- * @ignore
1681
- * @internal
1682
- * ApiClient for {@link LayoutEntitiesController}
1683
- */
1684
- _ColumnOrRow_client.set(this, void 0);
1685
- /**
1686
- * Retrieves the content array of the ColumnOrRow
1687
- *
1688
- * @example
1689
- * ```js
1690
- * if (!fin.me.isView) {
1691
- * throw new Error('Not running in a platform View.');
1692
- * }
1693
- *
1694
- * const stack = await fin.me.getCurrentStack();
1695
- * // Retrieves the parent ColumnOrRow
1696
- * const columnOrRow = await stack.getParent();
1697
- *
1698
- * // returns [TabStack]
1699
- * const contentArray = await columnOrRow.getContent();
1700
- * console.log(`The ColumnOrRow has ${contentArray.length} item(s)`);
1701
- * ```
1702
- */
1703
- this.getContent = async () => {
1704
- const contentItemEntities = await __classPrivateFieldGet$d(this, _ColumnOrRow_client, "f").getContent(this.entityId);
1705
- return contentItemEntities.map((entity) => LayoutNode.getEntity(entity, __classPrivateFieldGet$d(this, _ColumnOrRow_client, "f")));
1706
- };
1707
- __classPrivateFieldSet$b(this, _ColumnOrRow_client, client, "f");
1708
- this.type = type;
1709
- }
1710
- }
1711
- layoutEntities.ColumnOrRow = ColumnOrRow;
1712
- _ColumnOrRow_client = new WeakMap();
1713
-
1714
- var layout_constants = {};
1715
-
1716
- Object.defineProperty(layout_constants, "__esModule", { value: true });
1717
- layout_constants.DEFAULT_LAYOUT_KEY = layout_constants.LAYOUT_CONTROLLER_ID = void 0;
1718
- layout_constants.LAYOUT_CONTROLLER_ID = 'layout-entities';
1719
- // TODO: eventually export this somehow
1720
- layout_constants.DEFAULT_LAYOUT_KEY = '__default__';
1721
-
1722
- var main = {};
1723
-
1724
- Object.defineProperty(main, "__esModule", { value: true });
1725
- main.WebContents = void 0;
1726
- const base_1$j = base;
1727
- class WebContents extends base_1$j.EmitterBase {
1728
- /**
1729
- * @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
1730
- * @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
1731
- */
1732
- constructor(wire, identity, entityType) {
1733
- super(wire, entityType, identity.uuid, identity.name);
1734
- this.identity = identity;
1735
- this.entityType = entityType;
1736
- }
1737
- /**
1738
- * Gets a base64 encoded image of all or part of the WebContents.
1739
- * @param options Options for the capturePage call.
1740
- *
1741
- * @example
1742
- *
1743
- * View:
1744
- * ```js
1745
- * const view = fin.View.getCurrentSync();
1746
- *
1747
- * // PNG image of a full visible View
1748
- * console.log(await view.capturePage());
1749
- *
1750
- * // Low-quality JPEG image of a defined visible area of the view
1751
- * const options = {
1752
- * area: {
1753
- * height: 100,
1754
- * width: 100,
1755
- * x: 10,
1756
- * y: 10,
1757
- * },
1758
- * format: 'jpg',
1759
- * quality: 20
1760
- * }
1761
- * console.log(await view.capturePage(options));
1762
- * ```
1763
- *
1764
- * Window:
1765
- * ```js
1766
- * const wnd = await fin.Window.getCurrent();
1767
- *
1768
- * // PNG image of a full visible window
1769
- * console.log(await wnd.capturePage());
1770
- *
1771
- * // Low-quality JPEG image of a defined visible area of the window
1772
- * const options = {
1773
- * area: {
1774
- * height: 100,
1775
- * width: 100,
1776
- * x: 10,
1777
- * y: 10,
1778
- * },
1779
- * format: 'jpg',
1780
- * quality: 20
1781
- * }
1782
- * console.log(await wnd.capturePage(options));
1783
- * ```
1784
- *
1785
- * @remarks
1786
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1787
- * We do not expose an explicit superclass for this functionality, but it does have its own
1788
- * {@link OpenFin.WebContentsEvents event namespace}.
1789
- */
1790
- capturePage(options) {
1791
- return this.wire.sendAction('capture-page', { options, ...this.identity }).then(({ payload }) => payload.data);
1792
- }
1793
- /**
1794
- * Executes Javascript on the WebContents, restricted to contents you own or contents owned by
1795
- * applications you have created.
1796
- * @param code JavaScript code to be executed on the view.
1797
- *
1798
- * @example
1799
- * View:
1800
- * ```js
1801
- * async function executeJavaScript(code) {
1802
- * const view = await fin.View.wrap({uuid: 'uuid', name: 'view name'});
1803
- * return await view.executeJavaScript(code);
1804
- * }
1805
- *
1806
- * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
1807
- * ```
1808
- *
1809
- * Window:
1810
- * ```js
1811
- * async function executeJavaScript(code) {
1812
- * const app = await fin.Application.start({
1813
- * name: 'myApp',
1814
- * uuid: 'app-1',
1815
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.executeJavaScript.html',
1816
- * autoShow: true
1817
- * });
1818
- * const win = await app.getWindow();
1819
- * return await win.executeJavaScript(code);
1820
- * }
1821
- *
1822
- * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
1823
- * ```
1824
- * @remarks
1825
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1826
- * We do not expose an explicit superclass for this functionality, but it does have its own
1827
- * {@link OpenFin.WebContentsEvents event namespace}.
1828
- */
1829
- executeJavaScript(code) {
1830
- return this.wire
1831
- .sendAction('execute-javascript-in-window', { ...this.identity, code })
1832
- .then(({ payload }) => payload.data);
1833
- }
1834
- /**
1835
- * Returns the zoom level of the WebContents.
1836
- *
1837
- * @example
1838
- * View:
1839
- * ```js
1840
- * async function getZoomLevel() {
1841
- * const view = await fin.View.getCurrent();
1842
- * return await view.getZoomLevel();
1843
- * }
1844
- *
1845
- * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
1846
- * ```
1847
- *
1848
- * Window:
1849
- * ```js
1850
- * async function createWin() {
1851
- * const app = await fin.Application.start({
1852
- * name: 'myApp',
1853
- * uuid: 'app-1',
1854
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getZoomLevel.html',
1855
- * autoShow: true
1856
- * });
1857
- * return await app.getWindow();
1858
- * }
1859
- *
1860
- * async function getZoomLevel() {
1861
- * const win = await createWin();
1862
- * return await win.getZoomLevel();
1863
- * }
1864
- *
1865
- * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
1866
- * ```
1867
- * @remarks
1868
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1869
- * We do not expose an explicit superclass for this functionality, but it does have its own
1870
- * {@link OpenFin.WebContentsEvents event namespace}.
1871
- */
1872
- getZoomLevel() {
1873
- return this.wire.sendAction('get-zoom-level', this.identity).then(({ payload }) => payload.data);
1874
- }
1875
- /**
1876
- * Sets the zoom level of the WebContents.
1877
- * @param level The zoom level
1878
- *
1879
- * @example
1880
- * View:
1881
- * ```js
1882
- * async function setZoomLevel(number) {
1883
- * const view = await fin.View.getCurrent();
1884
- * return await view.setZoomLevel(number);
1885
- * }
1886
- *
1887
- * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
1888
- * ```
1889
- *
1890
- * Window:
1891
- * ```js
1892
- * async function createWin() {
1893
- * const app = await fin.Application.start({
1894
- * name: 'myApp',
1895
- * uuid: 'app-1',
1896
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.setZoomLevel.html',
1897
- * autoShow: true
1898
- * });
1899
- * return await app.getWindow();
1900
- * }
1901
- *
1902
- * async function setZoomLevel(number) {
1903
- * const win = await createWin();
1904
- * return await win.setZoomLevel(number);
1905
- * }
1906
- *
1907
- * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
1908
- * ```
1909
- * @remarks
1910
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1911
- * We do not expose an explicit superclass for this functionality, but it does have its own
1912
- * {@link OpenFin.WebContentsEvents event namespace}.
1913
- */
1914
- setZoomLevel(level) {
1915
- return this.wire.sendAction('set-zoom-level', { ...this.identity, level }).then(() => undefined);
1916
- }
1917
- /**
1918
- * Navigates the WebContents to a specified URL.
1919
- *
1920
- * Note: The url must contain the protocol prefix such as http:// or https://.
1921
- * @param url - The URL to navigate the WebContents to.
1922
- *
1923
- * @example
1924
- * View:
1925
- * ```js
1926
- * async function createView() {
1927
- * const me = await fin.Window.getCurrent();
1928
- * return fin.View.create({
1929
- * name: 'viewName',
1930
- * target: me.identity,
1931
- * bounds: {top: 10, left: 10, width: 200, height: 200}
1932
- * });
1933
- * }
1934
- *
1935
- * createView()
1936
- * .then(view => view.navigate('https://example.com'))
1937
- * .then(() => console.log('navigation complete'))
1938
- * .catch(err => console.log(err));
1939
- * ```
1940
- *
1941
- * Window:
1942
- * ```js
1943
- * async function navigate() {
1944
- * const win = await fin.Window.getCurrent();
1945
- * return await win.navigate('https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.navigate.html');
1946
- * }
1947
- * navigate().then(() => console.log('Navigate to tutorial')).catch(err => console.log(err));
1948
- * ```
1949
- * @experimental
1950
- * @remarks
1951
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1952
- * We do not expose an explicit superclass for this functionality, but it does have its own
1953
- * {@link OpenFin.WebContentsEvents event namespace}.
1254
+ * Navigates the WebContents to a specified URL.
1255
+ *
1256
+ * Note: The url must contain the protocol prefix such as http:// or https://.
1257
+ * @param url - The URL to navigate the WebContents to.
1258
+ *
1259
+ * @example
1260
+ * View:
1261
+ * ```js
1262
+ * async function createView() {
1263
+ * const me = await fin.Window.getCurrent();
1264
+ * return fin.View.create({
1265
+ * name: 'viewName',
1266
+ * target: me.identity,
1267
+ * bounds: {top: 10, left: 10, width: 200, height: 200}
1268
+ * });
1269
+ * }
1270
+ *
1271
+ * createView()
1272
+ * .then(view => view.navigate('https://example.com'))
1273
+ * .then(() => console.log('navigation complete'))
1274
+ * .catch(err => console.log(err));
1275
+ * ```
1276
+ *
1277
+ * Window:
1278
+ * ```js
1279
+ * async function navigate() {
1280
+ * const win = await fin.Window.getCurrent();
1281
+ * return await win.navigate('https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.navigate.html');
1282
+ * }
1283
+ * navigate().then(() => console.log('Navigate to tutorial')).catch(err => console.log(err));
1284
+ * ```
1285
+ * @experimental
1286
+ * @remarks
1287
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1288
+ * We do not expose an explicit superclass for this functionality, but it does have its own
1289
+ * {@link OpenFin.WebContentsEvents event namespace}.
1954
1290
  */
1955
1291
  navigate(url) {
1956
1292
  return this.wire.sendAction('navigate-window', { ...this.identity, url }).then(() => undefined);
@@ -2795,18 +2131,11 @@ var hasRequiredInstance$2;
2795
2131
  function requireInstance$2 () {
2796
2132
  if (hasRequiredInstance$2) return Instance$5;
2797
2133
  hasRequiredInstance$2 = 1;
2798
- var __classPrivateFieldGet = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2799
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2800
- 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");
2801
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2802
- };
2803
2134
  var _View_providerChannelClient;
2804
2135
  Object.defineProperty(Instance$5, "__esModule", { value: true });
2805
2136
  Instance$5.View = void 0;
2806
2137
  const transport_errors_1 = transportErrors;
2807
2138
  const lazy_1 = lazy;
2808
- const layout_entities_1 = layoutEntities;
2809
- const layout_constants_1 = layout_constants;
2810
2139
  const main_1 = main;
2811
2140
  const window_1 = requireWindow();
2812
2141
  /**
@@ -3124,7 +2453,7 @@ function requireInstance$2 () {
3124
2453
  return ack.payload.data;
3125
2454
  };
3126
2455
  /**
3127
- * Retrieves the layout for the window the view is attached to.
2456
+ * Retrieves the OpenFin.Layout instance for the Window the View is attached to.
3128
2457
  *
3129
2458
  * @example
3130
2459
  * ```js
@@ -3140,29 +2469,7 @@ function requireInstance$2 () {
3140
2469
  this.wire.sendAction('view-get-parent-layout', { ...this.identity }).catch(() => {
3141
2470
  // don't expose
3142
2471
  });
3143
- const layoutWindow = await this.getCurrentWindow();
3144
- let layoutWindowIdentity = layoutWindow.identity;
3145
- // TODO: CORE-1857 - when we tearout active layout or drag a view out of a window, the above identity includes the whole window info.
3146
- if (layoutWindowIdentity.identity) {
3147
- layoutWindowIdentity = layoutWindowIdentity.identity;
3148
- }
3149
- try {
3150
- const providerChannelClient = await __classPrivateFieldGet(this, _View_providerChannelClient, "f").getValue();
3151
- const client = await layout_entities_1.LayoutNode.newLayoutEntitiesClient(providerChannelClient, layout_constants_1.LAYOUT_CONTROLLER_ID, layoutWindowIdentity);
3152
- const layoutIdentity = await client.getLayoutIdentityForViewOrThrow(this.identity);
3153
- return this.fin.Platform.Layout.wrap(layoutIdentity);
3154
- }
3155
- catch (e) {
3156
- const allowedErrors = [
3157
- 'No action registered at target for',
3158
- 'getLayoutIdentityForViewOrThrow is not a function'
3159
- ];
3160
- if (!allowedErrors.some((m) => e.message.includes(m))) {
3161
- throw e;
3162
- }
3163
- // fallback logic for missing endpoint
3164
- return this.fin.Platform.Layout.wrap(layoutWindowIdentity);
3165
- }
2472
+ return this.fin.Platform.Layout.getLayoutByViewIdentity(this.identity);
3166
2473
  };
3167
2474
  /**
3168
2475
  * Gets the View's options.
@@ -3278,11 +2585,8 @@ function requireInstance$2 () {
3278
2585
  // don't expose
3279
2586
  });
3280
2587
  try {
3281
- const layoutWindow = await this.getCurrentWindow();
3282
- const providerChannelClient = await __classPrivateFieldGet(this, _View_providerChannelClient, "f").getValue();
3283
- const client = await layout_entities_1.LayoutNode.newLayoutEntitiesClient(providerChannelClient, layout_constants_1.LAYOUT_CONTROLLER_ID, layoutWindow.identity);
3284
- const stackDefinition = (await client.getStackByView(this.identity));
3285
- return layout_entities_1.LayoutNode.getEntity(stackDefinition, client);
2588
+ const layout = await this.getParentLayout();
2589
+ return layout.getStackByViewIdentity(this.identity);
3286
2590
  }
3287
2591
  catch (error) {
3288
2592
  throw new transport_errors_1.RuntimeError({ reason: 'This view does not belong to a stack.', error });
@@ -6053,13 +5357,6 @@ class System extends base_1$i.EmitterBase {
6053
5357
  constructor(wire) {
6054
5358
  super(wire, 'system');
6055
5359
  }
6056
- /**
6057
- * Dispatch an event to the webcontents that created the notification.
6058
- * Only works for notifications that have been intercepted in the same runtime.
6059
- */
6060
- async dispatchNotificationAction(notificationId, { action }) {
6061
- await this.wire.sendAction('dispatch-notification-action', { notificationId, action });
6062
- }
6063
5360
  sendExternalProcessRequest(action, options) {
6064
5361
  return new Promise((resolve, reject) => {
6065
5362
  const exitEventKey = 'external-process-exited';
@@ -6328,7 +5625,9 @@ class System extends base_1$i.EmitterBase {
6328
5625
  .then(({ payload }) => payload.data);
6329
5626
  }
6330
5627
  /**
6331
- * Get current focused window.
5628
+ * Get currently focused Window.
5629
+ * If a View currently has focus, returns the identity of View's parent Window.
5630
+ * Use {@link Window._Window#getFocusedContent Window.getFocusedContent} to directly access currently focused Window or View.
6332
5631
  *
6333
5632
  * @example
6334
5633
  * ```js
@@ -6338,6 +5637,17 @@ class System extends base_1$i.EmitterBase {
6338
5637
  getFocusedWindow() {
6339
5638
  return this.wire.sendAction('get-focused-window').then(({ payload }) => payload.data);
6340
5639
  }
5640
+ /**
5641
+ * Get currently focused content. Returns identity of entity with `entityType`.
5642
+ *
5643
+ * @example
5644
+ * ```js
5645
+ * fin.System.getFocusedContent().then(contentIdentity => console.log(contentIdentity)).catch(err => console.log(err));
5646
+ * ```
5647
+ */
5648
+ getFocusedContent() {
5649
+ return this.wire.sendAction('get-focused-content').then(({ payload }) => payload.data);
5650
+ }
6341
5651
  /**
6342
5652
  * Returns information about the given app's certification status
6343
5653
  *
@@ -7901,6 +7211,22 @@ class System extends base_1$i.EmitterBase {
7901
7211
  async setDomainSettings(domainSettings) {
7902
7212
  await this.wire.sendAction('set-domain-settings', { domainSettings, ...this.identity });
7903
7213
  }
7214
+ /**
7215
+ * Attempts to install and enable extensions for the security realm. Users may want to call this function in response
7216
+ * to an `extensions-install-failed` event. Only extensions allowed by every application on the current security realm
7217
+ * will be installed/enabled.
7218
+ */
7219
+ async refreshExtensions() {
7220
+ const { payload } = await this.wire.sendAction('refresh-extensions');
7221
+ return payload.data;
7222
+ }
7223
+ /**
7224
+ * Gets the currently-installed
7225
+ */
7226
+ async getInstalledExtensions() {
7227
+ const { payload } = await this.wire.sendAction('get-installed-extensions');
7228
+ return payload.data;
7229
+ }
7904
7230
  }
7905
7231
  system.System = System;
7906
7232
 
@@ -8322,12 +7648,12 @@ class ChannelError extends Error {
8322
7648
  }
8323
7649
  channelError.ChannelError = ChannelError;
8324
7650
 
8325
- var __classPrivateFieldGet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
7651
+ var __classPrivateFieldGet$d = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8326
7652
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
8327
7653
  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");
8328
7654
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
8329
7655
  };
8330
- var __classPrivateFieldSet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7656
+ var __classPrivateFieldSet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8331
7657
  if (kind === "m") throw new TypeError("Private method is not writable");
8332
7658
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8333
7659
  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");
@@ -8371,7 +7697,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
8371
7697
  static closeChannelByEndpointId(id) {
8372
7698
  const channel = channelClientsByEndpointId.get(id);
8373
7699
  if (channel) {
8374
- __classPrivateFieldGet$c(channel, _ChannelClient_close, "f").call(channel);
7700
+ __classPrivateFieldGet$d(channel, _ChannelClient_close, "f").call(channel);
8375
7701
  }
8376
7702
  }
8377
7703
  /**
@@ -8382,7 +7708,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
8382
7708
  for (const channelClient of channelClientsByEndpointId.values()) {
8383
7709
  if (channelClient.providerIdentity.channelId === eventPayload.channelId) {
8384
7710
  channelClient.disconnectListener(eventPayload);
8385
- __classPrivateFieldGet$c(channelClient, _ChannelClient_close, "f").call(channelClient);
7711
+ __classPrivateFieldGet$d(channelClient, _ChannelClient_close, "f").call(channelClient);
8386
7712
  }
8387
7713
  }
8388
7714
  }
@@ -8397,12 +7723,12 @@ class ChannelClient extends channel_1$1.ChannelBase {
8397
7723
  this.processAction = (action, payload, senderIdentity) => super.processAction(action, payload, senderIdentity);
8398
7724
  _ChannelClient_close.set(this, () => {
8399
7725
  channelClientsByEndpointId.delete(this.endpointId);
8400
- __classPrivateFieldGet$c(this, _ChannelClient_strategy, "f").close();
7726
+ __classPrivateFieldGet$d(this, _ChannelClient_strategy, "f").close();
8401
7727
  });
8402
- __classPrivateFieldSet$a(this, _ChannelClient_protectedObj, new channel_1$1.ProtectedItems(routingInfo, close), "f");
7728
+ __classPrivateFieldSet$c(this, _ChannelClient_protectedObj, new channel_1$1.ProtectedItems(routingInfo, close), "f");
8403
7729
  this.disconnectListener = () => undefined;
8404
7730
  this.endpointId = routingInfo.endpointId;
8405
- __classPrivateFieldSet$a(this, _ChannelClient_strategy, strategy, "f");
7731
+ __classPrivateFieldSet$c(this, _ChannelClient_strategy, strategy, "f");
8406
7732
  channelClientsByEndpointId.set(this.endpointId, this);
8407
7733
  strategy.receive(this.processAction);
8408
7734
  }
@@ -8410,7 +7736,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
8410
7736
  * a read-only provider identity
8411
7737
  */
8412
7738
  get providerIdentity() {
8413
- const protectedObj = __classPrivateFieldGet$c(this, _ChannelClient_protectedObj, "f");
7739
+ const protectedObj = __classPrivateFieldGet$d(this, _ChannelClient_protectedObj, "f");
8414
7740
  return protectedObj.providerIdentity;
8415
7741
  }
8416
7742
  /**
@@ -8439,9 +7765,9 @@ class ChannelClient extends channel_1$1.ChannelBase {
8439
7765
  * ```
8440
7766
  */
8441
7767
  async dispatch(action, payload) {
8442
- if (__classPrivateFieldGet$c(this, _ChannelClient_strategy, "f").isEndpointConnected(this.providerIdentity.channelId)) {
7768
+ if (__classPrivateFieldGet$d(this, _ChannelClient_strategy, "f").isEndpointConnected(this.providerIdentity.channelId)) {
8443
7769
  const callSites = transport_errors_1$2.RuntimeError.getCallSite();
8444
- return __classPrivateFieldGet$c(this, _ChannelClient_strategy, "f").send(this.providerIdentity.channelId, action, payload).catch((e) => {
7770
+ return __classPrivateFieldGet$d(this, _ChannelClient_strategy, "f").send(this.providerIdentity.channelId, action, payload).catch((e) => {
8445
7771
  throw new channel_error_1$1.ChannelError(e, action, payload, callSites);
8446
7772
  });
8447
7773
  }
@@ -8493,10 +7819,10 @@ class ChannelClient extends channel_1$1.ChannelBase {
8493
7819
  */
8494
7820
  async disconnect() {
8495
7821
  await this.sendDisconnectAction();
8496
- __classPrivateFieldGet$c(this, _ChannelClient_close, "f").call(this);
7822
+ __classPrivateFieldGet$d(this, _ChannelClient_close, "f").call(this);
8497
7823
  }
8498
7824
  async sendDisconnectAction() {
8499
- const protectedObj = __classPrivateFieldGet$c(this, _ChannelClient_protectedObj, "f");
7825
+ const protectedObj = __classPrivateFieldGet$d(this, _ChannelClient_protectedObj, "f");
8500
7826
  await protectedObj.close();
8501
7827
  }
8502
7828
  /**
@@ -8529,13 +7855,13 @@ exhaustive.exhaustiveCheck = exhaustiveCheck;
8529
7855
 
8530
7856
  var strategy$3 = {};
8531
7857
 
8532
- var __classPrivateFieldSet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7858
+ var __classPrivateFieldSet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8533
7859
  if (kind === "m") throw new TypeError("Private method is not writable");
8534
7860
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8535
7861
  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");
8536
7862
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
8537
7863
  };
8538
- var __classPrivateFieldGet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
7864
+ var __classPrivateFieldGet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8539
7865
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
8540
7866
  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");
8541
7867
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -8560,7 +7886,7 @@ class ClassicStrategy {
8560
7886
  // connection problems occur
8561
7887
  _ClassicStrategy_pendingMessagesByEndpointId.set(this, new Map());
8562
7888
  this.send = async (endpointId, action, payload) => {
8563
- const to = __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
7889
+ const to = __classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
8564
7890
  if (!to) {
8565
7891
  throw new Error(`Could not locate routing info for endpoint ${endpointId}`);
8566
7892
  }
@@ -8572,13 +7898,13 @@ class ClassicStrategy {
8572
7898
  }
8573
7899
  delete cleanId.isLocalEndpointId;
8574
7900
  // grab the promise before awaiting it to save in our pending messages map
8575
- const p = __classPrivateFieldGet$b(this, _ClassicStrategy_wire, "f").sendAction('send-channel-message', {
7901
+ const p = __classPrivateFieldGet$c(this, _ClassicStrategy_wire, "f").sendAction('send-channel-message', {
8576
7902
  ...cleanId,
8577
7903
  providerIdentity: this.providerIdentity,
8578
7904
  action,
8579
7905
  payload
8580
7906
  });
8581
- __classPrivateFieldGet$b(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.add(p);
7907
+ __classPrivateFieldGet$c(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.add(p);
8582
7908
  const raw = await p
8583
7909
  .catch((error) => {
8584
7910
  if ('cause' in error) {
@@ -8588,16 +7914,16 @@ class ClassicStrategy {
8588
7914
  })
8589
7915
  .finally(() => {
8590
7916
  // clean up the pending promise
8591
- __classPrivateFieldGet$b(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.delete(p);
7917
+ __classPrivateFieldGet$c(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.delete(p);
8592
7918
  });
8593
7919
  return raw.payload.data.result;
8594
7920
  };
8595
7921
  this.close = async () => {
8596
7922
  this.messageReceiver.removeEndpoint(this.providerIdentity.channelId, this.endpointId);
8597
- [...__classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").keys()].forEach((id) => this.closeEndpoint(id));
8598
- __classPrivateFieldSet$9(this, _ClassicStrategy_endpointIdentityMap, new Map(), "f");
7923
+ [...__classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").keys()].forEach((id) => this.closeEndpoint(id));
7924
+ __classPrivateFieldSet$b(this, _ClassicStrategy_endpointIdentityMap, new Map(), "f");
8599
7925
  };
8600
- __classPrivateFieldSet$9(this, _ClassicStrategy_wire, wire, "f");
7926
+ __classPrivateFieldSet$b(this, _ClassicStrategy_wire, wire, "f");
8601
7927
  }
8602
7928
  onEndpointDisconnect(endpointId, listener) {
8603
7929
  // Never fires for 'classic'.
@@ -8606,20 +7932,20 @@ class ClassicStrategy {
8606
7932
  this.messageReceiver.addEndpoint(listener, this.providerIdentity.channelId, this.endpointId);
8607
7933
  }
8608
7934
  async closeEndpoint(endpointId) {
8609
- const id = __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
8610
- __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").delete(endpointId);
8611
- const pendingSet = __classPrivateFieldGet$b(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId);
7935
+ const id = __classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
7936
+ __classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").delete(endpointId);
7937
+ const pendingSet = __classPrivateFieldGet$c(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId);
8612
7938
  pendingSet?.forEach((p) => {
8613
7939
  const errorMsg = `Channel connection with identity uuid: ${id?.uuid} / name: ${id?.name} / endpointId: ${endpointId} no longer connected.`;
8614
7940
  p.cancel(new Error(errorMsg));
8615
7941
  });
8616
7942
  }
8617
7943
  isEndpointConnected(endpointId) {
8618
- return __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").has(endpointId);
7944
+ return __classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").has(endpointId);
8619
7945
  }
8620
7946
  addEndpoint(endpointId, payload) {
8621
- __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").set(endpointId, payload.endpointIdentity);
8622
- __classPrivateFieldGet$b(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").set(endpointId, new Set());
7947
+ __classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").set(endpointId, payload.endpointIdentity);
7948
+ __classPrivateFieldGet$c(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").set(endpointId, new Set());
8623
7949
  }
8624
7950
  isValidEndpointPayload(payload) {
8625
7951
  return (typeof payload?.endpointIdentity?.endpointId === 'string' ||
@@ -8654,12 +7980,12 @@ function errorToPOJO(error) {
8654
7980
  }
8655
7981
  errors.errorToPOJO = errorToPOJO;
8656
7982
 
8657
- var __classPrivateFieldGet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
7983
+ var __classPrivateFieldGet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8658
7984
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
8659
7985
  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");
8660
7986
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
8661
7987
  };
8662
- var __classPrivateFieldSet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7988
+ var __classPrivateFieldSet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8663
7989
  if (kind === "m") throw new TypeError("Private method is not writable");
8664
7990
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8665
7991
  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");
@@ -8694,8 +8020,8 @@ class RTCEndpoint {
8694
8020
  if (this.rtc.rtcClient.connectionState !== 'connected') {
8695
8021
  this.rtc.rtcClient.removeEventListener('connectionstatechange', this.connectionStateChangeHandler);
8696
8022
  this.close();
8697
- if (__classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f")) {
8698
- __classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f").call(this);
8023
+ if (__classPrivateFieldGet$b(this, _RTCEndpoint_disconnectListener, "f")) {
8024
+ __classPrivateFieldGet$b(this, _RTCEndpoint_disconnectListener, "f").call(this);
8699
8025
  }
8700
8026
  }
8701
8027
  };
@@ -8743,9 +8069,9 @@ class RTCEndpoint {
8743
8069
  data = new TextDecoder().decode(e.data);
8744
8070
  }
8745
8071
  const { messageId, action, payload } = JSON.parse(data);
8746
- if (__classPrivateFieldGet$a(this, _RTCEndpoint_processAction, "f")) {
8072
+ if (__classPrivateFieldGet$b(this, _RTCEndpoint_processAction, "f")) {
8747
8073
  try {
8748
- const res = await __classPrivateFieldGet$a(this, _RTCEndpoint_processAction, "f").call(this, action, payload, endpointIdentity);
8074
+ const res = await __classPrivateFieldGet$b(this, _RTCEndpoint_processAction, "f").call(this, action, payload, endpointIdentity);
8749
8075
  this.rtc.channels.response.send(JSON.stringify({
8750
8076
  messageId,
8751
8077
  payload: res,
@@ -8779,25 +8105,25 @@ class RTCEndpoint {
8779
8105
  datachannel.onclose = (e) => {
8780
8106
  [...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.')));
8781
8107
  this.close();
8782
- if (__classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f")) {
8783
- __classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f").call(this);
8108
+ if (__classPrivateFieldGet$b(this, _RTCEndpoint_disconnectListener, "f")) {
8109
+ __classPrivateFieldGet$b(this, _RTCEndpoint_disconnectListener, "f").call(this);
8784
8110
  }
8785
8111
  };
8786
8112
  });
8787
8113
  }
8788
8114
  onDisconnect(listener) {
8789
- if (!__classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f")) {
8790
- __classPrivateFieldSet$8(this, _RTCEndpoint_disconnectListener, listener, "f");
8115
+ if (!__classPrivateFieldGet$b(this, _RTCEndpoint_disconnectListener, "f")) {
8116
+ __classPrivateFieldSet$a(this, _RTCEndpoint_disconnectListener, listener, "f");
8791
8117
  }
8792
8118
  else {
8793
8119
  throw new Error('RTCEndpoint disconnectListener cannot be set twice.');
8794
8120
  }
8795
8121
  }
8796
8122
  receive(listener) {
8797
- if (__classPrivateFieldGet$a(this, _RTCEndpoint_processAction, "f")) {
8123
+ if (__classPrivateFieldGet$b(this, _RTCEndpoint_processAction, "f")) {
8798
8124
  throw new Error('You have already set a listener for this RTC Endpoint.');
8799
8125
  }
8800
- __classPrivateFieldSet$8(this, _RTCEndpoint_processAction, listener, "f");
8126
+ __classPrivateFieldSet$a(this, _RTCEndpoint_processAction, listener, "f");
8801
8127
  }
8802
8128
  get connected() {
8803
8129
  return this.rtc.rtcClient.connectionState === 'connected';
@@ -8808,12 +8134,12 @@ _RTCEndpoint_processAction = new WeakMap(), _RTCEndpoint_disconnectListener = ne
8808
8134
 
8809
8135
  var strategy$1 = {};
8810
8136
 
8811
- var __classPrivateFieldGet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8137
+ var __classPrivateFieldGet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8812
8138
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
8813
8139
  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");
8814
8140
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
8815
8141
  };
8816
- var __classPrivateFieldSet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8142
+ var __classPrivateFieldSet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8817
8143
  if (kind === "m") throw new TypeError("Private method is not writable");
8818
8144
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8819
8145
  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");
@@ -8834,11 +8160,11 @@ class EndpointStrategy {
8834
8160
  return this.getEndpointById(endpointId).send(action, payload);
8835
8161
  };
8836
8162
  this.close = async () => {
8837
- if (__classPrivateFieldGet$9(this, _EndpointStrategy_connected, "f")) {
8838
- __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.close());
8839
- __classPrivateFieldSet$7(this, _EndpointStrategy_endpointMap, new Map(), "f");
8163
+ if (__classPrivateFieldGet$a(this, _EndpointStrategy_connected, "f")) {
8164
+ __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.close());
8165
+ __classPrivateFieldSet$9(this, _EndpointStrategy_endpointMap, new Map(), "f");
8840
8166
  }
8841
- __classPrivateFieldSet$7(this, _EndpointStrategy_connected, false, "f");
8167
+ __classPrivateFieldSet$9(this, _EndpointStrategy_connected, false, "f");
8842
8168
  };
8843
8169
  this.isValidEndpointPayload = validateEndpoint;
8844
8170
  }
@@ -8846,39 +8172,39 @@ class EndpointStrategy {
8846
8172
  this.getEndpointById(endpointId).onDisconnect(listener);
8847
8173
  }
8848
8174
  receive(listener) {
8849
- if (__classPrivateFieldGet$9(this, _EndpointStrategy_processAction, "f")) {
8175
+ if (__classPrivateFieldGet$a(this, _EndpointStrategy_processAction, "f")) {
8850
8176
  throw new Error(`You have already set a listener for this ${this.StrategyName} Strategy`);
8851
8177
  }
8852
- __classPrivateFieldSet$7(this, _EndpointStrategy_processAction, listener, "f");
8178
+ __classPrivateFieldSet$9(this, _EndpointStrategy_processAction, listener, "f");
8853
8179
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
8854
- __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.receive(__classPrivateFieldGet$9(this, _EndpointStrategy_processAction, "f")));
8180
+ __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.receive(__classPrivateFieldGet$a(this, _EndpointStrategy_processAction, "f")));
8855
8181
  }
8856
8182
  getEndpointById(endpointId) {
8857
- const endpoint = __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").get(endpointId);
8183
+ const endpoint = __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").get(endpointId);
8858
8184
  if (!endpoint) {
8859
8185
  throw new Error(`Client with endpoint id ${endpointId} is not connected`);
8860
8186
  }
8861
8187
  return endpoint;
8862
8188
  }
8863
8189
  get connected() {
8864
- return __classPrivateFieldGet$9(this, _EndpointStrategy_connected, "f");
8190
+ return __classPrivateFieldGet$a(this, _EndpointStrategy_connected, "f");
8865
8191
  }
8866
8192
  isEndpointConnected(endpointId) {
8867
- return __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").has(endpointId);
8193
+ return __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").has(endpointId);
8868
8194
  }
8869
8195
  addEndpoint(endpointId, payload) {
8870
- if (!__classPrivateFieldGet$9(this, _EndpointStrategy_connected, "f")) {
8196
+ if (!__classPrivateFieldGet$a(this, _EndpointStrategy_connected, "f")) {
8871
8197
  console.warn(`Adding endpoint to disconnected ${this.StrategyName} Strategy`);
8872
8198
  return;
8873
8199
  }
8874
8200
  const clientStrat = new this.EndpointType(payload);
8875
- if (__classPrivateFieldGet$9(this, _EndpointStrategy_processAction, "f")) {
8876
- clientStrat.receive(__classPrivateFieldGet$9(this, _EndpointStrategy_processAction, "f"));
8201
+ if (__classPrivateFieldGet$a(this, _EndpointStrategy_processAction, "f")) {
8202
+ clientStrat.receive(__classPrivateFieldGet$a(this, _EndpointStrategy_processAction, "f"));
8877
8203
  }
8878
- __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").set(endpointId, clientStrat);
8204
+ __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").set(endpointId, clientStrat);
8879
8205
  }
8880
8206
  async closeEndpoint(endpointId) {
8881
- __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").delete(endpointId);
8207
+ __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").delete(endpointId);
8882
8208
  }
8883
8209
  }
8884
8210
  strategy$1.EndpointStrategy = EndpointStrategy;
@@ -9060,12 +8386,12 @@ function runtimeUuidMeetsMinimumRuntimeVersion(runtimeUuid, minVersion) {
9060
8386
  }
9061
8387
  runtimeVersioning.runtimeUuidMeetsMinimumRuntimeVersion = runtimeUuidMeetsMinimumRuntimeVersion;
9062
8388
 
9063
- var __classPrivateFieldGet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8389
+ var __classPrivateFieldGet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9064
8390
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9065
8391
  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");
9066
8392
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
9067
8393
  };
9068
- var __classPrivateFieldSet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8394
+ var __classPrivateFieldSet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
9069
8395
  if (kind === "m") throw new TypeError("Private method is not writable");
9070
8396
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9071
8397
  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");
@@ -9109,18 +8435,18 @@ class ChannelProvider extends channel_1.ChannelBase {
9109
8435
  * a read-only array containing all the identities of connecting clients.
9110
8436
  */
9111
8437
  get connections() {
9112
- return [...__classPrivateFieldGet$8(this, _ChannelProvider_connections, "f")];
8438
+ return [...__classPrivateFieldGet$9(this, _ChannelProvider_connections, "f")];
9113
8439
  }
9114
8440
  static handleClientDisconnection(channel, payload) {
9115
8441
  const removeById = channel.connections.find((identity) => identity.endpointId === payload.endpointId);
9116
8442
  if (removeById) {
9117
- __classPrivateFieldGet$8(channel, _ChannelProvider_removeEndpoint, "f").call(channel, removeById);
8443
+ __classPrivateFieldGet$9(channel, _ChannelProvider_removeEndpoint, "f").call(channel, removeById);
9118
8444
  }
9119
8445
  else {
9120
8446
  const multipleRemoves = channel.connections.filter((identity) => {
9121
8447
  return identity.uuid === payload.uuid && identity.name === payload.name;
9122
8448
  });
9123
- multipleRemoves.forEach(__classPrivateFieldGet$8(channel, _ChannelProvider_removeEndpoint, "f"));
8449
+ multipleRemoves.forEach(__classPrivateFieldGet$9(channel, _ChannelProvider_removeEndpoint, "f"));
9124
8450
  }
9125
8451
  channel.disconnectListener(payload);
9126
8452
  }
@@ -9137,8 +8463,8 @@ class ChannelProvider extends channel_1.ChannelBase {
9137
8463
  _ChannelProvider_strategy.set(this, void 0);
9138
8464
  _ChannelProvider_removeEndpoint.set(this, (identity) => {
9139
8465
  const remainingConnections = this.connections.filter((clientIdentity) => clientIdentity.endpointId !== identity.endpointId);
9140
- __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").closeEndpoint(identity.endpointId);
9141
- __classPrivateFieldSet$6(this, _ChannelProvider_connections, remainingConnections, "f");
8466
+ __classPrivateFieldGet$9(this, _ChannelProvider_strategy, "f").closeEndpoint(identity.endpointId);
8467
+ __classPrivateFieldSet$8(this, _ChannelProvider_connections, remainingConnections, "f");
9142
8468
  });
9143
8469
  // Must be bound.
9144
8470
  this.processAction = async (action, payload, senderIdentity) => {
@@ -9152,17 +8478,17 @@ class ChannelProvider extends channel_1.ChannelBase {
9152
8478
  return super.processAction(action, payload, senderIdentity);
9153
8479
  };
9154
8480
  _ChannelProvider_close.set(this, () => {
9155
- __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").close();
8481
+ __classPrivateFieldGet$9(this, _ChannelProvider_strategy, "f").close();
9156
8482
  const remove = ChannelProvider.removalMap.get(this);
9157
8483
  if (remove) {
9158
8484
  remove();
9159
8485
  }
9160
8486
  });
9161
- __classPrivateFieldSet$6(this, _ChannelProvider_protectedObj, new channel_1.ProtectedItems(providerIdentity, close), "f");
8487
+ __classPrivateFieldSet$8(this, _ChannelProvider_protectedObj, new channel_1.ProtectedItems(providerIdentity, close), "f");
9162
8488
  this.connectListener = () => undefined;
9163
8489
  this.disconnectListener = () => undefined;
9164
- __classPrivateFieldSet$6(this, _ChannelProvider_connections, [], "f");
9165
- __classPrivateFieldSet$6(this, _ChannelProvider_strategy, strategy, "f");
8490
+ __classPrivateFieldSet$8(this, _ChannelProvider_connections, [], "f");
8491
+ __classPrivateFieldSet$8(this, _ChannelProvider_strategy, strategy, "f");
9166
8492
  strategy.receive(this.processAction);
9167
8493
  }
9168
8494
  /**
@@ -9193,16 +8519,16 @@ class ChannelProvider extends channel_1.ChannelBase {
9193
8519
  */
9194
8520
  dispatch(to, action, payload) {
9195
8521
  const endpointId = to.endpointId ?? this.getEndpointIdForOpenFinId(to, action);
9196
- if (endpointId && __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").isEndpointConnected(endpointId)) {
8522
+ if (endpointId && __classPrivateFieldGet$9(this, _ChannelProvider_strategy, "f").isEndpointConnected(endpointId)) {
9197
8523
  const callSites = transport_errors_1$1.RuntimeError.getCallSite();
9198
- return __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").send(endpointId, action, payload).catch((e) => {
8524
+ return __classPrivateFieldGet$9(this, _ChannelProvider_strategy, "f").send(endpointId, action, payload).catch((e) => {
9199
8525
  throw new channel_error_1.ChannelError(e, action, payload, callSites);
9200
8526
  });
9201
8527
  }
9202
8528
  return Promise.reject(new Error(`Client connection with identity uuid: ${to.uuid} / name: ${to.name} / endpointId: ${endpointId} no longer connected.`));
9203
8529
  }
9204
8530
  async processConnection(senderId, payload) {
9205
- __classPrivateFieldGet$8(this, _ChannelProvider_connections, "f").push(senderId);
8531
+ __classPrivateFieldGet$9(this, _ChannelProvider_connections, "f").push(senderId);
9206
8532
  return this.connectListener(senderId, payload);
9207
8533
  }
9208
8534
  /**
@@ -9225,7 +8551,7 @@ class ChannelProvider extends channel_1.ChannelBase {
9225
8551
  * ```
9226
8552
  */
9227
8553
  publish(action, payload) {
9228
- return this.connections.map((to) => __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").send(to.endpointId, action, payload));
8554
+ return this.connections.map((to) => __classPrivateFieldGet$9(this, _ChannelProvider_strategy, "f").send(to.endpointId, action, payload));
9229
8555
  }
9230
8556
  /**
9231
8557
  * Register a listener that is called on every new client connection.
@@ -9299,11 +8625,11 @@ class ChannelProvider extends channel_1.ChannelBase {
9299
8625
  * ```
9300
8626
  */
9301
8627
  async destroy() {
9302
- const protectedObj = __classPrivateFieldGet$8(this, _ChannelProvider_protectedObj, "f");
8628
+ const protectedObj = __classPrivateFieldGet$9(this, _ChannelProvider_protectedObj, "f");
9303
8629
  protectedObj.providerIdentity;
9304
- __classPrivateFieldSet$6(this, _ChannelProvider_connections, [], "f");
8630
+ __classPrivateFieldSet$8(this, _ChannelProvider_connections, [], "f");
9305
8631
  await protectedObj.close();
9306
- __classPrivateFieldGet$8(this, _ChannelProvider_close, "f").call(this);
8632
+ __classPrivateFieldGet$9(this, _ChannelProvider_close, "f").call(this);
9307
8633
  }
9308
8634
  /**
9309
8635
  * Returns an array with info on every Client connected to the Provider
@@ -9373,7 +8699,7 @@ class ChannelProvider extends channel_1.ChannelBase {
9373
8699
  getEndpointIdForOpenFinId(clientIdentity, action) {
9374
8700
  const matchingConnections = this.connections.filter((c) => c.name === clientIdentity.name && c.uuid === clientIdentity.uuid);
9375
8701
  if (matchingConnections.length >= 2) {
9376
- const protectedObj = __classPrivateFieldGet$8(this, _ChannelProvider_protectedObj, "f");
8702
+ const protectedObj = __classPrivateFieldGet$9(this, _ChannelProvider_protectedObj, "f");
9377
8703
  const { uuid, name } = clientIdentity;
9378
8704
  const providerUuid = protectedObj?.providerIdentity.uuid;
9379
8705
  const providerName = protectedObj?.providerIdentity.name;
@@ -9585,13 +8911,13 @@ class CombinedStrategy {
9585
8911
  }
9586
8912
  strategy.default = CombinedStrategy;
9587
8913
 
9588
- var __classPrivateFieldSet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8914
+ var __classPrivateFieldSet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
9589
8915
  if (kind === "m") throw new TypeError("Private method is not writable");
9590
8916
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9591
8917
  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");
9592
8918
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
9593
8919
  };
9594
- var __classPrivateFieldGet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8920
+ var __classPrivateFieldGet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9595
8921
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9596
8922
  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");
9597
8923
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -9640,8 +8966,8 @@ class ConnectionManager extends base_1$f.Base {
9640
8966
  };
9641
8967
  this.providerMap = new Map();
9642
8968
  this.protocolManager = new protocol_manager_1.ProtocolManager(this.wire.environment.type === 'node' ? ['classic'] : ['rtc', 'classic']);
9643
- __classPrivateFieldSet$5(this, _ConnectionManager_messageReceiver, new message_receiver_1.MessageReceiver(wire), "f");
9644
- __classPrivateFieldSet$5(this, _ConnectionManager_rtcConnectionManager, new ice_manager_1.RTCICEManager(wire), "f");
8969
+ __classPrivateFieldSet$7(this, _ConnectionManager_messageReceiver, new message_receiver_1.MessageReceiver(wire), "f");
8970
+ __classPrivateFieldSet$7(this, _ConnectionManager_rtcConnectionManager, new ice_manager_1.RTCICEManager(wire), "f");
9645
8971
  wire.registerMessageHandler(this.onmessage.bind(this));
9646
8972
  }
9647
8973
  createProvider(options, providerIdentity) {
@@ -9652,7 +8978,7 @@ class ConnectionManager extends base_1$f.Base {
9652
8978
  case 'rtc':
9653
8979
  return new strategy_2.RTCStrategy();
9654
8980
  case 'classic':
9655
- return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$7(this, _ConnectionManager_messageReceiver, "f"),
8981
+ return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$8(this, _ConnectionManager_messageReceiver, "f"),
9656
8982
  // Providers do not have an endpointId, use channelId as endpointId in the strategy.
9657
8983
  providerIdentity.channelId, providerIdentity);
9658
8984
  default:
@@ -9688,7 +9014,7 @@ class ConnectionManager extends base_1$f.Base {
9688
9014
  const supportedProtocols = await Promise.all(protocols.map(async (type) => {
9689
9015
  switch (type) {
9690
9016
  case 'rtc': {
9691
- const { rtcClient, channels, offer, rtcConnectionId, channelsOpened } = await __classPrivateFieldGet$7(this, _ConnectionManager_rtcConnectionManager, "f").startClientOffer();
9017
+ const { rtcClient, channels, offer, rtcConnectionId, channelsOpened } = await __classPrivateFieldGet$8(this, _ConnectionManager_rtcConnectionManager, "f").startClientOffer();
9692
9018
  rtcPacket = { rtcClient, channels, channelsOpened };
9693
9019
  return {
9694
9020
  type: 'rtc',
@@ -9715,18 +9041,18 @@ class ConnectionManager extends base_1$f.Base {
9715
9041
  routingInfo.endpointId = this.wire.environment.getNextMessageId();
9716
9042
  // For New Clients connecting to Old Providers. To prevent multi-dispatching and publishing, we delete previously-connected
9717
9043
  // clients that are in the same context as the newly-connected client.
9718
- __classPrivateFieldGet$7(this, _ConnectionManager_messageReceiver, "f").checkForPreviousClientConnection(routingInfo.channelId);
9044
+ __classPrivateFieldGet$8(this, _ConnectionManager_messageReceiver, "f").checkForPreviousClientConnection(routingInfo.channelId);
9719
9045
  }
9720
9046
  const answer = routingInfo.answer ?? {
9721
9047
  supportedProtocols: [{ type: 'classic', version: 1 }]
9722
9048
  };
9723
9049
  const createStrategyFromAnswer = async (protocol) => {
9724
9050
  if (protocol.type === 'rtc' && rtcPacket) {
9725
- await __classPrivateFieldGet$7(this, _ConnectionManager_rtcConnectionManager, "f").finishClientOffer(rtcPacket.rtcClient, protocol.payload.answer, rtcPacket.channelsOpened);
9051
+ await __classPrivateFieldGet$8(this, _ConnectionManager_rtcConnectionManager, "f").finishClientOffer(rtcPacket.rtcClient, protocol.payload.answer, rtcPacket.channelsOpened);
9726
9052
  return new strategy_2.RTCStrategy();
9727
9053
  }
9728
9054
  if (protocol.type === 'classic') {
9729
- return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$7(this, _ConnectionManager_messageReceiver, "f"), routingInfo.endpointId, routingInfo);
9055
+ return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$8(this, _ConnectionManager_messageReceiver, "f"), routingInfo.endpointId, routingInfo);
9730
9056
  }
9731
9057
  return null;
9732
9058
  };
@@ -9794,7 +9120,7 @@ class ConnectionManager extends base_1$f.Base {
9794
9120
  clientAnswer = await overlappingProtocols.reduce(async (accumP, protocolToUse) => {
9795
9121
  const answer = await accumP;
9796
9122
  if (protocolToUse.type === 'rtc') {
9797
- const { answer: rtcAnswer, rtcClient, channels } = await __classPrivateFieldGet$7(this, _ConnectionManager_rtcConnectionManager, "f").createProviderAnswer(protocolToUse.payload.rtcConnectionId, protocolToUse.payload.offer);
9123
+ const { answer: rtcAnswer, rtcClient, channels } = await __classPrivateFieldGet$8(this, _ConnectionManager_rtcConnectionManager, "f").createProviderAnswer(protocolToUse.payload.rtcConnectionId, protocolToUse.payload.offer);
9798
9124
  answer.supportedProtocols.push({
9799
9125
  type: 'rtc',
9800
9126
  version: strategy_2.RTCInfo.version,
@@ -9842,13 +9168,13 @@ _ConnectionManager_messageReceiver = new WeakMap(), _ConnectionManager_rtcConnec
9842
9168
  *
9843
9169
  * @packageDocumentation
9844
9170
  */
9845
- var __classPrivateFieldSet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
9171
+ var __classPrivateFieldSet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
9846
9172
  if (kind === "m") throw new TypeError("Private method is not writable");
9847
9173
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9848
9174
  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");
9849
9175
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
9850
9176
  };
9851
- var __classPrivateFieldGet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9177
+ var __classPrivateFieldGet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9852
9178
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9853
9179
  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");
9854
9180
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -9905,11 +9231,11 @@ class Channel extends base_1$e.EmitterBase {
9905
9231
  client_1.ChannelClient.handleProviderDisconnect(eventPayload);
9906
9232
  }),
9907
9233
  this.on('connected', (...args) => {
9908
- __classPrivateFieldGet$6(this, _Channel_internalEmitter, "f").emit('connected', ...args);
9234
+ __classPrivateFieldGet$7(this, _Channel_internalEmitter, "f").emit('connected', ...args);
9909
9235
  })
9910
9236
  ]).catch(() => new Error('error setting up channel connection listeners'));
9911
9237
  }));
9912
- __classPrivateFieldSet$4(this, _Channel_connectionManager, new connection_manager_1.ConnectionManager(wire), "f");
9238
+ __classPrivateFieldSet$6(this, _Channel_connectionManager, new connection_manager_1.ConnectionManager(wire), "f");
9913
9239
  }
9914
9240
  /**
9915
9241
  *
@@ -9984,7 +9310,7 @@ class Channel extends base_1$e.EmitterBase {
9984
9310
  resolve(true);
9985
9311
  }
9986
9312
  };
9987
- __classPrivateFieldGet$6(this, _Channel_internalEmitter, "f").on('connected', connectedListener);
9313
+ __classPrivateFieldGet$7(this, _Channel_internalEmitter, "f").on('connected', connectedListener);
9988
9314
  });
9989
9315
  try {
9990
9316
  if (retryInfo.count > 0) {
@@ -10016,7 +9342,7 @@ class Channel extends base_1$e.EmitterBase {
10016
9342
  finally {
10017
9343
  retryInfo.count += 1;
10018
9344
  // in case of other errors, remove our listener
10019
- __classPrivateFieldGet$6(this, _Channel_internalEmitter, "f").removeListener('connected', connectedListener);
9345
+ __classPrivateFieldGet$7(this, _Channel_internalEmitter, "f").removeListener('connected', connectedListener);
10020
9346
  }
10021
9347
  } while (shouldWait); // If we're waiting we retry the above loop
10022
9348
  // Should wait was false, no channel was found.
@@ -10075,12 +9401,12 @@ class Channel extends base_1$e.EmitterBase {
10075
9401
  async connect(channelName, options = {}) {
10076
9402
  // Make sure we don't connect before listeners are set up
10077
9403
  // This also errors if we're not in OpenFin, ensuring we don't run unnecessary code
10078
- await __classPrivateFieldGet$6(this, _Channel_readyToConnect, "f").getValue();
9404
+ await __classPrivateFieldGet$7(this, _Channel_readyToConnect, "f").getValue();
10079
9405
  if (!channelName || typeof channelName !== 'string') {
10080
9406
  throw new Error('Please provide a channelName string to connect to a channel.');
10081
9407
  }
10082
9408
  const opts = { wait: true, ...this.wire.environment.getDefaultChannelOptions().connect, ...options };
10083
- const { offer, rtc: rtcPacket } = await __classPrivateFieldGet$6(this, _Channel_connectionManager, "f").createClientOffer(opts);
9409
+ const { offer, rtc: rtcPacket } = await __classPrivateFieldGet$7(this, _Channel_connectionManager, "f").createClientOffer(opts);
10084
9410
  let connectionUrl;
10085
9411
  if (this.fin.me.isFrame || this.fin.me.isView || this.fin.me.isWindow) {
10086
9412
  connectionUrl = (await this.fin.me.getInfo()).url;
@@ -10092,7 +9418,7 @@ class Channel extends base_1$e.EmitterBase {
10092
9418
  connectionUrl
10093
9419
  };
10094
9420
  const routingInfo = await this.safeConnect(channelName, opts.wait, connectPayload);
10095
- const strategy = await __classPrivateFieldGet$6(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
9421
+ const strategy = await __classPrivateFieldGet$7(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
10096
9422
  const channel = new client_1.ChannelClient(routingInfo, () => client_1.ChannelClient.wireClose(this.wire, routingInfo, routingInfo.endpointId), strategy);
10097
9423
  // It is the client's responsibility to handle endpoint disconnection to the provider.
10098
9424
  // If the endpoint dies, the client will force a disconnection through the core.
@@ -10161,7 +9487,7 @@ class Channel extends base_1$e.EmitterBase {
10161
9487
  throw new Error('Please provide a channelName to create a channel');
10162
9488
  }
10163
9489
  const { payload: { data: providerIdentity } } = await this.wire.sendAction('create-channel', { channelName });
10164
- const channel = __classPrivateFieldGet$6(this, _Channel_connectionManager, "f").createProvider(options, providerIdentity);
9490
+ const channel = __classPrivateFieldGet$7(this, _Channel_connectionManager, "f").createProvider(options, providerIdentity);
10165
9491
  // TODO: fix typing (internal)
10166
9492
  // @ts-expect-error
10167
9493
  this.on('client-disconnected', (eventPayload) => {
@@ -11052,19 +10378,23 @@ var Factory$3 = {};
11052
10378
 
11053
10379
  var Instance$2 = {};
11054
10380
 
11055
- var __classPrivateFieldGet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
10381
+ var __classPrivateFieldSet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
10382
+ if (kind === "m") throw new TypeError("Private method is not writable");
10383
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10384
+ 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");
10385
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
10386
+ };
10387
+ var __classPrivateFieldGet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
11056
10388
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
11057
10389
  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");
11058
10390
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11059
10391
  };
11060
- var _Platform_connectToProvider;
10392
+ var _Platform_channelName, _Platform_connectToProvider;
11061
10393
  Object.defineProperty(Instance$2, "__esModule", { value: true });
11062
10394
  Instance$2.Platform = void 0;
11063
10395
  /* eslint-disable import/prefer-default-export, no-undef */
11064
10396
  const base_1$6 = base;
11065
10397
  const validate_1$1 = validate;
11066
- // Reuse clients to avoid overwriting already-registered client in provider
11067
- const clientMap = new Map();
11068
10398
  /** Manages the life cycle of windows and views in the application.
11069
10399
  *
11070
10400
  * Enables taking snapshots of itself and applying them to restore a previous configuration
@@ -11075,34 +10405,40 @@ class Platform extends base_1$6.EmitterBase {
11075
10405
  * @internal
11076
10406
  */
11077
10407
  // eslint-disable-next-line no-shadow
11078
- constructor(identity, channel) {
10408
+ constructor(wire, identity, channelName = `custom-frame-${identity.uuid}`) {
11079
10409
  // we piggyback off of application event emitter because from the core's perspective platform is just an app.
11080
- super(channel.wire, 'application', identity.uuid);
11081
- this.getClient = (identity) => {
10410
+ super(wire, 'application', identity.uuid);
10411
+ /**
10412
+ * @internal
10413
+ */
10414
+ _Platform_channelName.set(this, void 0);
10415
+ this.getClient = (identity = this.identity) => {
10416
+ if (identity.uuid !== this.identity.uuid) {
10417
+ // I have no idea why we allow passing in a different identity, but we do.
10418
+ // Doing this above the analytics call so we only register one call.
10419
+ return new Platform(this.wire, identity).getClient();
10420
+ }
11082
10421
  this.wire.sendAction('platform-get-client', this.identity).catch((e) => {
11083
10422
  // don't expose
11084
10423
  });
11085
- const target = identity || this.identity;
11086
- const { uuid } = target;
11087
- if (!clientMap.has(uuid)) {
11088
- const clientPromise = __classPrivateFieldGet$5(this, _Platform_connectToProvider, "f").call(this, uuid);
11089
- clientMap.set(uuid, clientPromise);
10424
+ if (!Platform.clientMap.has(__classPrivateFieldGet$6(this, _Platform_channelName, "f"))) {
10425
+ const clientPromise = __classPrivateFieldGet$6(this, _Platform_connectToProvider, "f").call(this);
10426
+ Platform.clientMap.set(__classPrivateFieldGet$6(this, _Platform_channelName, "f"), clientPromise);
11090
10427
  }
11091
10428
  // we set it above
11092
10429
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
11093
- return clientMap.get(uuid);
10430
+ return Platform.clientMap.get(__classPrivateFieldGet$6(this, _Platform_channelName, "f"));
11094
10431
  };
11095
- _Platform_connectToProvider.set(this, async (uuid) => {
10432
+ _Platform_connectToProvider.set(this, async () => {
11096
10433
  try {
11097
- const channelName = `custom-frame-${uuid}`;
11098
- const client = await this._channel.connect(channelName, { wait: false });
10434
+ const client = await this._channel.connect(__classPrivateFieldGet$6(this, _Platform_channelName, "f"), { wait: false });
11099
10435
  client.onDisconnection(() => {
11100
- clientMap.delete(uuid);
10436
+ Platform.clientMap.delete(__classPrivateFieldGet$6(this, _Platform_channelName, "f"));
11101
10437
  });
11102
10438
  return client;
11103
10439
  }
11104
10440
  catch (e) {
11105
- clientMap.delete(uuid);
10441
+ Platform.clientMap.delete(__classPrivateFieldGet$6(this, _Platform_channelName, "f"));
11106
10442
  throw new Error('The targeted Platform is not currently running. Listen for application-started event for the given Uuid.');
11107
10443
  }
11108
10444
  });
@@ -11115,7 +10451,8 @@ class Platform extends base_1$6.EmitterBase {
11115
10451
  if (errorMsg) {
11116
10452
  throw new Error(errorMsg);
11117
10453
  }
11118
- this._channel = channel;
10454
+ __classPrivateFieldSet$5(this, _Platform_channelName, channelName, "f");
10455
+ this._channel = this.fin.InterApplicationBus.Channel;
11119
10456
  this.identity = { uuid: identity.uuid };
11120
10457
  this.Layout = this.fin.Platform.Layout;
11121
10458
  this.Application = this.fin.Application.wrapSync(this.identity);
@@ -11786,136 +11123,806 @@ class Platform extends base_1$6.EmitterBase {
11786
11123
  * ```
11787
11124
  * @experimental
11788
11125
  */
11789
- async setWindowContext(context = {}, target) {
11790
- this.wire.sendAction('platform-set-window-context', this.identity).catch((e) => {
11791
- // don't expose
11126
+ async setWindowContext(context = {}, target) {
11127
+ this.wire.sendAction('platform-set-window-context', this.identity).catch((e) => {
11128
+ // don't expose
11129
+ });
11130
+ if (!context) {
11131
+ throw new Error('Please provide a serializable object or string to set the context.');
11132
+ }
11133
+ const client = await this.getClient();
11134
+ const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
11135
+ await client.dispatch('set-window-context', {
11136
+ context,
11137
+ entityType,
11138
+ target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name }
11139
+ });
11140
+ }
11141
+ /**
11142
+ * Get the context context of a host window that was previously set using {@link Platform#setWindowContext setWindowContext}.
11143
+ * The context will be saved in any platform snapshots. Returns a promise that resolves to the context.
11144
+ * @param target - A target window or view may optionally be provided. If no target is provided, target will be
11145
+ * the current window (if called from a Window) or the current host window (if called from a View).
11146
+ *
11147
+ * @remarks This method can be called from the window itself, or from any child view. Context data is shared
11148
+ * by all entities within a window.
11149
+ *
11150
+ * @example
11151
+ *
11152
+ * Retrieving context from current window:
11153
+ * ```js
11154
+ * const platform = fin.Platform.getCurrentSync();
11155
+ * const customContext = { answer: 42 };
11156
+ * await platform.setWindowContext(customContext);
11157
+ *
11158
+ * const myContext = await platform.getWindowContext();
11159
+ * console.log(myContext); // { answer: 42 }
11160
+ * ```
11161
+ *
11162
+ * Retrieving the context of another window or view:
11163
+ * ```js
11164
+ * const platform = fin.Platform.getCurrentSync();
11165
+ *
11166
+ * const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
11167
+ *
11168
+ * const targetWindowContext = await platform.getWindowContext(windowOrViewIdentity);
11169
+ * console.log(targetWindowContext); // context of target window
11170
+ * ```
11171
+ * @experimental
11172
+ */
11173
+ async getWindowContext(target) {
11174
+ this.wire.sendAction('platform-get-window-context', this.identity).catch((e) => {
11175
+ // don't expose
11176
+ });
11177
+ const client = await this.getClient();
11178
+ const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
11179
+ return client.dispatch('get-window-context', {
11180
+ target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name },
11181
+ entityType
11182
+ });
11183
+ }
11184
+ /**
11185
+ * Closes a window. If enableBeforeUnload is enabled in the Platform options, any beforeunload handler set on Views will fire
11186
+ * This behavior can be disabled by setting skipBeforeUnload to false in the options parameter.
11187
+ * @param winId
11188
+ * @param options
11189
+ *
11190
+ * @remarks This method works by setting a `close-requested` handler on the Platform Window. If you have your own `close-requested` handler set on the Platform Window as well,
11191
+ * it is recommended to move that logic over to the [PlatformProvider.closeWindow]{@link PlatformProvider#closeWindow} override to ensure it runs when the Window closes.
11192
+ *
11193
+ * @example
11194
+ *
11195
+ * ```js
11196
+ * // Close the current Window inside a Window context
11197
+ * const platform = await fin.Platform.getCurrent();
11198
+ * platform.closeWindow(fin.me.identity);
11199
+ *
11200
+ * // Close the Window from inside a View context
11201
+ * const platform = await fin.Platform.getCurrent();
11202
+ * const parentWindow = await fin.me.getCurrentWindow();
11203
+ * platform.closeWindow(parentWindow.identity);
11204
+ *
11205
+ * // Close the Window and do not fire the before unload handler on Views
11206
+ * const platform = await fin.Platform.getCurrent();
11207
+ * platform.closeWindow(fin.me.identity, { skipBeforeUnload: true });
11208
+ * ```
11209
+ * @experimental
11210
+ */
11211
+ async closeWindow(windowId, options = { skipBeforeUnload: false }) {
11212
+ this.wire.sendAction('platform-close-window', this.identity).catch((e) => {
11213
+ // don't expose
11214
+ });
11215
+ const client = await this.getClient();
11216
+ return client.dispatch('close-window', { windowId, options });
11217
+ }
11218
+ }
11219
+ Instance$2.Platform = Platform;
11220
+ _Platform_channelName = new WeakMap(), _Platform_connectToProvider = new WeakMap();
11221
+ /**
11222
+ * @internal
11223
+ * Reuse clients to avoid overwriting already-registered client in provider
11224
+ * This ensures that only channel client is created per channel name per `fin` instance
11225
+ */
11226
+ Platform.clientMap = new Map();
11227
+
11228
+ var layout = {};
11229
+
11230
+ var Factory$2 = {};
11231
+
11232
+ var Instance$1 = {};
11233
+
11234
+ var commonUtils = {};
11235
+
11236
+ Object.defineProperty(commonUtils, "__esModule", { value: true });
11237
+ commonUtils.overrideFromComposables = commonUtils.isValidPresetType = void 0;
11238
+ function isValidPresetType(type) {
11239
+ switch (type) {
11240
+ case 'columns':
11241
+ case 'grid':
11242
+ case 'rows':
11243
+ case 'tabs':
11244
+ return true;
11245
+ default:
11246
+ return false;
11247
+ }
11248
+ }
11249
+ commonUtils.isValidPresetType = isValidPresetType;
11250
+ function overrideFromComposables(...overrides) {
11251
+ return (base) => overrides.reduceRight((p, c) => (b) => c(p(b)), (x) => x)(base);
11252
+ }
11253
+ commonUtils.overrideFromComposables = overrideFromComposables;
11254
+ commonUtils.default = { isValidPresetType };
11255
+
11256
+ var layoutEntities = {};
11257
+
11258
+ var apiExposer$1 = {};
11259
+
11260
+ var apiConsumer = {};
11261
+
11262
+ Object.defineProperty(apiConsumer, "__esModule", { value: true });
11263
+ apiConsumer.ApiConsumer = void 0;
11264
+ /**
11265
+ * Consumer for apis exposed with {@see ApiExposer}.
11266
+ *
11267
+ * A strategy that matches the strategy used to expose a target API must be provided.
11268
+ */
11269
+ class ApiConsumer {
11270
+ // eslint-disable-next-line
11271
+ constructor(strategy) {
11272
+ this.strategy = strategy;
11273
+ /**
11274
+ * Consumes an api exposed using a given transport strategy, and generates a client
11275
+ * for easy, type safe consumption of that client.
11276
+ * @param options Strategy specific consumption options.
11277
+ * @returns An api client matching the given type.
11278
+ */
11279
+ this.consume = async (options) => {
11280
+ const exposedProperties = await this.strategy.getExposedFunctions(options);
11281
+ return exposedProperties.reduce((client, prop) => ({
11282
+ ...client,
11283
+ [prop.key]: this.strategy.createFunction(prop, options)
11284
+ }), {});
11285
+ };
11286
+ }
11287
+ }
11288
+ apiConsumer.ApiConsumer = ApiConsumer;
11289
+
11290
+ var apiExposer = {};
11291
+
11292
+ var decorators = {};
11293
+
11294
+ Object.defineProperty(decorators, "__esModule", { value: true });
11295
+ decorators.expose = decorators.getExposedProperties = void 0;
11296
+ const exposedProperties = Symbol('exposedProperties');
11297
+ const getExposedProperties = (target) => {
11298
+ return target[exposedProperties] || target.prototype[exposedProperties] || [];
11299
+ };
11300
+ decorators.getExposedProperties = getExposedProperties;
11301
+ /**
11302
+ * Indicates that a class member function can be exposed using {@link ApiExposer}.
11303
+ * @param options Options specific to the strategy used in {@link ApiExposer}
11304
+ */
11305
+ // Returns any as decorator typing is weird.
11306
+ const expose = (options) => (target, key, descriptor) => {
11307
+ target[exposedProperties] = target[exposedProperties] || [];
11308
+ target[exposedProperties].push({ key, descriptor, options });
11309
+ };
11310
+ decorators.expose = expose;
11311
+
11312
+ Object.defineProperty(apiExposer, "__esModule", { value: true });
11313
+ apiExposer.ApiExposer = void 0;
11314
+ const decorators_1 = decorators;
11315
+ /**
11316
+ * Exposes api services on the transport of choice.
11317
+ */
11318
+ class ApiExposer {
11319
+ /**
11320
+ * @param strategy The expose strategy to use to expose instances.
11321
+ */
11322
+ // eslint-disable-next-line
11323
+ constructor(strategy) {
11324
+ this.strategy = strategy;
11325
+ /**
11326
+ * Exposes an instance of a given api on
11327
+ * @param instance Instance of a class which has been decorated to indicate which functions can be exposed.
11328
+ * @param instanceOptions Transport strategy specific options to use when exposing.
11329
+ */
11330
+ this.exposeInstance = async (instance, instanceOptions) => {
11331
+ const exposableProps = (0, decorators_1.getExposedProperties)(instance);
11332
+ const exposedProps = await Promise.all(exposableProps.map(async ({ key, options }) => {
11333
+ const customConsumptionOptions = await this.strategy.exposeFunction(instance[key].bind(instance), {
11334
+ key,
11335
+ options,
11336
+ meta: instanceOptions
11337
+ });
11338
+ return {
11339
+ key,
11340
+ options: customConsumptionOptions
11341
+ };
11342
+ }));
11343
+ await this.strategy.exposeMeta(instanceOptions, exposedProps);
11344
+ };
11345
+ }
11346
+ ;
11347
+ }
11348
+ apiExposer.ApiExposer = ApiExposer;
11349
+
11350
+ var strategies = {};
11351
+
11352
+ var openfinChannels = {};
11353
+
11354
+ var channelsConsumer = {};
11355
+
11356
+ Object.defineProperty(channelsConsumer, "__esModule", { value: true });
11357
+ channelsConsumer.ChannelsConsumer = void 0;
11358
+ class ChannelsConsumer {
11359
+ // eslint-disable-next-line
11360
+ constructor(channel) {
11361
+ this.channel = channel;
11362
+ this.getExposedFunctions = async (options) => {
11363
+ const { id } = options;
11364
+ const { props } = await this.channel.dispatch(`api-meta:${id}`);
11365
+ return props;
11366
+ };
11367
+ this.createFunction = (prop) => (...args) => {
11368
+ const { action } = prop.options;
11369
+ return this.channel.dispatch(action, { args });
11370
+ };
11371
+ }
11372
+ ;
11373
+ }
11374
+ channelsConsumer.ChannelsConsumer = ChannelsConsumer;
11375
+
11376
+ var channelsExposer = {};
11377
+
11378
+ Object.defineProperty(channelsExposer, "__esModule", { value: true });
11379
+ channelsExposer.ChannelsExposer = void 0;
11380
+ class ChannelsExposer {
11381
+ // eslint-disable-next-line
11382
+ constructor(channelProviderOrClient) {
11383
+ this.channelProviderOrClient = channelProviderOrClient;
11384
+ this.exposeFunction = async (target, config) => {
11385
+ const { key, options, meta } = config;
11386
+ const { id } = meta;
11387
+ const action = `${id}.${options?.action || key}`;
11388
+ await this.channelProviderOrClient.register(action, async ({ args }) => {
11389
+ return target(...args);
11390
+ });
11391
+ return { action };
11392
+ };
11393
+ this.exposeMeta = async ({ id }, props) => {
11394
+ const action = `api-meta:${id}`;
11395
+ await this.channelProviderOrClient.register(action, () => ({ props }));
11396
+ };
11397
+ }
11398
+ }
11399
+ channelsExposer.ChannelsExposer = ChannelsExposer;
11400
+
11401
+ (function (exports) {
11402
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11403
+ if (k2 === undefined) k2 = k;
11404
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11405
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11406
+ desc = { enumerable: true, get: function() { return m[k]; } };
11407
+ }
11408
+ Object.defineProperty(o, k2, desc);
11409
+ }) : (function(o, m, k, k2) {
11410
+ if (k2 === undefined) k2 = k;
11411
+ o[k2] = m[k];
11412
+ }));
11413
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
11414
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11415
+ };
11416
+ Object.defineProperty(exports, "__esModule", { value: true });
11417
+ __exportStar(channelsConsumer, exports);
11418
+ __exportStar(channelsExposer, exports);
11419
+ } (openfinChannels));
11420
+
11421
+ (function (exports) {
11422
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11423
+ if (k2 === undefined) k2 = k;
11424
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11425
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11426
+ desc = { enumerable: true, get: function() { return m[k]; } };
11427
+ }
11428
+ Object.defineProperty(o, k2, desc);
11429
+ }) : (function(o, m, k, k2) {
11430
+ if (k2 === undefined) k2 = k;
11431
+ o[k2] = m[k];
11432
+ }));
11433
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
11434
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11435
+ };
11436
+ Object.defineProperty(exports, "__esModule", { value: true });
11437
+ __exportStar(openfinChannels, exports);
11438
+ } (strategies));
11439
+
11440
+ (function (exports) {
11441
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11442
+ if (k2 === undefined) k2 = k;
11443
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11444
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11445
+ desc = { enumerable: true, get: function() { return m[k]; } };
11446
+ }
11447
+ Object.defineProperty(o, k2, desc);
11448
+ }) : (function(o, m, k, k2) {
11449
+ if (k2 === undefined) k2 = k;
11450
+ o[k2] = m[k];
11451
+ }));
11452
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
11453
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11454
+ };
11455
+ Object.defineProperty(exports, "__esModule", { value: true });
11456
+ __exportStar(apiConsumer, exports);
11457
+ __exportStar(apiExposer, exports);
11458
+ __exportStar(strategies, exports);
11459
+ __exportStar(decorators, exports);
11460
+ } (apiExposer$1));
11461
+
11462
+ var channelApiRelay = {};
11463
+
11464
+ Object.defineProperty(channelApiRelay, "__esModule", { value: true });
11465
+ channelApiRelay.createRelayedDispatch = channelApiRelay.relayChannelClientApi = void 0;
11466
+ const EXPECTED_ERRORS = [
11467
+ 'no longer connected',
11468
+ 'RTCDataChannel closed unexpectedly',
11469
+ 'The client you are trying to dispatch from is disconnected from the target provider',
11470
+ ];
11471
+ // Checks possible error messages that we want to trap, client error message can originate
11472
+ // from ChannelProvider::dispatch OR ClassicStrategy::closeEndpoint OR RTCEndPoint::dataChannel::onclose
11473
+ const isDisconnectedError = (errorMsg) => {
11474
+ return EXPECTED_ERRORS.some(e => errorMsg.includes(e));
11475
+ };
11476
+ /**
11477
+ * @internal
11478
+ * Create a channel relay for a given channel exposition, allowing a single provider to route
11479
+ * actions to the designated clients.
11480
+ *
11481
+ * Designed to be used in conjunction with @expose
11482
+ *
11483
+ * @param channelProvider The channel provider to relay the actions on.
11484
+ * @param config Determines which actions to relay. Please ensure action prefix matches the exposed api.
11485
+ */
11486
+ const relayChannelClientApi = async (channelProvider, relayId) => {
11487
+ channelProvider.register(`relay:${relayId}`, ({ action, target, payload }) => {
11488
+ return channelProvider.dispatch(target, action, payload);
11489
+ });
11490
+ await Promise.resolve();
11491
+ };
11492
+ channelApiRelay.relayChannelClientApi = relayChannelClientApi;
11493
+ const createRelayedDispatch = (client, target, relayId, relayErrorMsg) => async (action, payload) => {
11494
+ try {
11495
+ return await client.dispatch(`relay:${relayId}`, {
11496
+ action,
11497
+ payload,
11498
+ target
11792
11499
  });
11793
- if (!context) {
11794
- throw new Error('Please provide a serializable object or string to set the context.');
11500
+ }
11501
+ catch (e) {
11502
+ if (isDisconnectedError(e.message) && relayErrorMsg) {
11503
+ throw new Error(relayErrorMsg);
11795
11504
  }
11796
- const client = await this.getClient();
11797
- const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
11798
- await client.dispatch('set-window-context', {
11799
- context,
11800
- entityType,
11801
- target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name }
11802
- });
11505
+ throw e;
11803
11506
  }
11507
+ };
11508
+ channelApiRelay.createRelayedDispatch = createRelayedDispatch;
11509
+
11510
+ var __classPrivateFieldSet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
11511
+ if (kind === "m") throw new TypeError("Private method is not writable");
11512
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
11513
+ 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");
11514
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11515
+ };
11516
+ var __classPrivateFieldGet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
11517
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
11518
+ 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");
11519
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11520
+ };
11521
+ var _LayoutNode_client, _TabStack_client, _ColumnOrRow_client;
11522
+ Object.defineProperty(layoutEntities, "__esModule", { value: true });
11523
+ layoutEntities.ColumnOrRow = layoutEntities.TabStack = layoutEntities.LayoutNode = void 0;
11524
+ const api_exposer_1 = apiExposer$1;
11525
+ const channel_api_relay_1 = channelApiRelay;
11526
+ /*
11527
+ This file includes LayoutNode, ColumnOrRow and TabStack classes, which are all closely
11528
+ intertwined, and share members via parent abstract class LayoutNode. To prevent circular
11529
+ refs, we define and export all the classes here.
11530
+ */
11531
+ /**
11532
+ * @ignore
11533
+ * @internal
11534
+ * Supplies an ApiClient for {@link LayoutEntitiesController} and helper methods
11535
+ * for the entities {@link TabStack} AND {@link ColumnOrRow} to use.
11536
+ */
11537
+ class LayoutNode {
11804
11538
  /**
11805
- * Get the context context of a host window that was previously set using {@link Platform#setWindowContext setWindowContext}.
11806
- * The context will be saved in any platform snapshots. Returns a promise that resolves to the context.
11807
- * @param target - A target window or view may optionally be provided. If no target is provided, target will be
11808
- * the current window (if called from a Window) or the current host window (if called from a View).
11809
- *
11810
- * @remarks This method can be called from the window itself, or from any child view. Context data is shared
11811
- * by all entities within a window.
11812
- *
11813
- * @example
11814
- *
11815
- * Retrieving context from current window:
11816
- * ```js
11817
- * const platform = fin.Platform.getCurrentSync();
11818
- * const customContext = { answer: 42 };
11819
- * await platform.setWindowContext(customContext);
11820
- *
11821
- * const myContext = await platform.getWindowContext();
11822
- * console.log(myContext); // { answer: 42 }
11823
- * ```
11824
- *
11825
- * Retrieving the context of another window or view:
11826
- * ```js
11827
- * const platform = fin.Platform.getCurrentSync();
11828
- *
11829
- * const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
11830
- *
11831
- * const targetWindowContext = await platform.getWindowContext(windowOrViewIdentity);
11832
- * console.log(targetWindowContext); // context of target window
11833
- * ```
11834
- * @experimental
11539
+ * @internal
11540
+ * @ignore
11835
11541
  */
11836
- async getWindowContext(target) {
11837
- this.wire.sendAction('platform-get-window-context', this.identity).catch((e) => {
11838
- // don't expose
11839
- });
11840
- const client = await this.getClient();
11841
- const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
11842
- return client.dispatch('get-window-context', {
11843
- target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name },
11844
- entityType
11845
- });
11542
+ constructor(client, entityId) {
11543
+ /**
11544
+ * @ignore
11545
+ * @internal
11546
+ * ApiClient for {@link LayoutEntitiesController}
11547
+ */
11548
+ _LayoutNode_client.set(this, void 0);
11549
+ /**
11550
+ * Checks if the TabStack or ColumnOrRow is the root content item
11551
+ *
11552
+ * @example
11553
+ * ```js
11554
+ * if (!fin.me.isView) {
11555
+ * throw new Error('Not running in a platform View.');
11556
+ * }
11557
+ *
11558
+ * const stack = await fin.me.getCurrentStack();
11559
+ * const isRoot = await stack.isRoot();
11560
+ * // The TabStack is root: false
11561
+ * console.log(`The TabStack is root: ${isRoot}`);
11562
+ *
11563
+ * // Retrieves the parent ColumnOrRow
11564
+ * const parent = await stack.getParent();
11565
+ * const parentIsRoot = await parent.isRoot();
11566
+ * // The parent ColumnOrRow is root: true
11567
+ * console.log(`The parent ColumnOrRow is root: ${parentIsRoot}`);
11568
+ * ```
11569
+ */
11570
+ this.isRoot = () => __classPrivateFieldGet$5(this, _LayoutNode_client, "f").isRoot(this.entityId);
11571
+ /**
11572
+ * Checks if the TabStack or ColumnOrRow exists
11573
+ *
11574
+ * @example
11575
+ * ```js
11576
+ * if (!fin.me.isView) {
11577
+ * throw new Error('Not running in a platform View.');
11578
+ * }
11579
+ *
11580
+ * const stack = await fin.me.getCurrentStack();
11581
+ * // Retrieves the parent ColumnOrRow
11582
+ * const columnOrRow = await stack.getParent();
11583
+ * let exists = await stack.exists();
11584
+ * // or
11585
+ * let exists = await columnOrRow.exists();
11586
+ * // The entity exists: true
11587
+ * console.log(`The entity exists: ${exists}`);
11588
+ * ```
11589
+ */
11590
+ this.exists = () => __classPrivateFieldGet$5(this, _LayoutNode_client, "f").exists(this.entityId);
11591
+ /**
11592
+ * Retrieves the parent of the TabStack or ColumnOrRow
11593
+ *
11594
+ * @example
11595
+ * ```js
11596
+ * if (!fin.me.isView) {
11597
+ * throw new Error('Not running in a platform View.');
11598
+ * }
11599
+ *
11600
+ * const stack = await fin.me.getCurrentStack();
11601
+ * // Retrieves the parent ColumnOrRow
11602
+ * const columnOrRow = await stack.getParent();
11603
+ *
11604
+ * // undefined if entity is the root item
11605
+ * let parent = await columnOrRow.getParent();
11606
+ * // or
11607
+ * let parent = await stack.getParent();
11608
+ * ```
11609
+ */
11610
+ this.getParent = async () => {
11611
+ const parent = await __classPrivateFieldGet$5(this, _LayoutNode_client, "f").getParent(this.entityId);
11612
+ if (!parent) {
11613
+ return undefined;
11614
+ }
11615
+ return LayoutNode.getEntity(parent, __classPrivateFieldGet$5(this, _LayoutNode_client, "f"));
11616
+ };
11617
+ /**
11618
+ * Creates a new TabStack adjacent to the given TabStack or ColumnOrRow. Inputs can be new views to create, or existing views.
11619
+ *
11620
+ * Known Issue: If the number of views to add overflows the tab-container, the added views will be set as active
11621
+ * during each render, and then placed at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
11622
+ * This means the views you pass to createAdjacentStack() may not render in the order given by the array.
11623
+ * Until fixed, this problem can be avoided only if your window is wide enough to fit creating all the views in the tabstack.
11624
+ *
11625
+ * @param views The views that will populate the new TabStack.
11626
+ * @param options Additional options that control new TabStack creation.
11627
+ * @returns The newly-created TabStack.
11628
+ *
11629
+ * @example
11630
+ * ```js
11631
+ * if (!fin.me.isView) {
11632
+ * throw new Error('Not running in a platform View.');
11633
+ * }
11634
+ *
11635
+ * const stack = await fin.me.getCurrentStack();
11636
+ * const columnOrRow = await stack.getParent();
11637
+ *
11638
+ * // Create view references by supplying a 'name' and 'url'
11639
+ * const views = [
11640
+ * // if 'name' is undefined, one will be generated
11641
+ * // if 'url' is undefined, it will default the view URL to 'about:blank'
11642
+ * { name: 'google-view', url: 'http://google.com/'},
11643
+ * { name: 'of-developers-view', url: 'http://developers.openfin.co/'},
11644
+ * ];
11645
+ *
11646
+ * // Create a view beforehand to be included in the new tab stack
11647
+ * const outsideView = await fin.View.create({
11648
+ * name: 'outside-bloomberg-view',
11649
+ * url: 'https://bloomberg.com/',
11650
+ * target: fin.me.identity,
11651
+ * });
11652
+ *
11653
+ * // Views to add can be identities, or the reference views mentioned above
11654
+ * const viewsToAdd = [outsideView.identity, ...views];
11655
+ *
11656
+ * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
11657
+ * let stackFrom = await columnOrRow.createAdjacentStack(viewsToAdd, { position: 'right' });
11658
+ * // Or
11659
+ * let newStack = await stack.createAdjacentStack(viewsToAdd, { position: 'right' });
11660
+ * console.log(`A new TabStack created to the right has ${newStack.length} views in it`);
11661
+ *
11662
+ * ```
11663
+ * @experimental
11664
+ */
11665
+ this.createAdjacentStack = async (views, options) => {
11666
+ const entityId = await __classPrivateFieldGet$5(this, _LayoutNode_client, "f").createAdjacentStack(this.entityId, views, options);
11667
+ return LayoutNode.getEntity({ entityId, type: 'stack' }, __classPrivateFieldGet$5(this, _LayoutNode_client, "f"));
11668
+ };
11669
+ /**
11670
+ * Retrieves the adjacent TabStacks of the given TabStack or ColumnOrRow.
11671
+ *
11672
+ * @param edge Edge whose adjacent TabStacks will be returned.
11673
+ *
11674
+ * @example
11675
+ * ```js
11676
+ * if (!fin.me.isView) {
11677
+ * throw new Error('Not running in a platform View.');
11678
+ * }
11679
+ *
11680
+ * const stack = await fin.me.getCurrentStack();
11681
+ * const columnOrRow = await stack.getParent();
11682
+ * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
11683
+ * let rightStacks = await columnOrRow.getAdjacentStacks('right');
11684
+ * let leftStacks = await columnOrRow.getAdjacentStacks('left');
11685
+ * // or
11686
+ * let rightStacks = await stack.getAdjacentStacks('right');
11687
+ * let leftStacks = await stack.getAdjacentStacks('left');
11688
+ *
11689
+ * console.log(`The entity has ${rightStacks.length} stacks to the right, and ${leftStacks.length} stacks to the left`);
11690
+ *
11691
+ * ```
11692
+ * @experimental
11693
+ */
11694
+ this.getAdjacentStacks = async (edge) => {
11695
+ const adjacentStacks = await __classPrivateFieldGet$5(this, _LayoutNode_client, "f").getAdjacentStacks({
11696
+ targetId: this.entityId,
11697
+ edge
11698
+ });
11699
+ return adjacentStacks.map((stack) => LayoutNode.getEntity({
11700
+ type: 'stack',
11701
+ entityId: stack.entityId
11702
+ }, __classPrivateFieldGet$5(this, _LayoutNode_client, "f")));
11703
+ };
11704
+ __classPrivateFieldSet$4(this, _LayoutNode_client, client, "f");
11705
+ this.entityId = entityId;
11706
+ }
11707
+ }
11708
+ layoutEntities.LayoutNode = LayoutNode;
11709
+ _LayoutNode_client = new WeakMap();
11710
+ /**
11711
+ * @ignore
11712
+ * @internal
11713
+ * Encapsulates Api consumption of {@link LayoutEntitiesClient} with a relayed dispatch
11714
+ * @param client
11715
+ * @param controllerId
11716
+ * @param identity
11717
+ * @returns a new instance of {@link LayoutEntitiesClient} with bound to the controllerId
11718
+ */
11719
+ LayoutNode.newLayoutEntitiesClient = async (client, controllerId, identity) => {
11720
+ const dispatch = (0, channel_api_relay_1.createRelayedDispatch)(client, identity, 'layout-relay', 'You are trying to interact with a layout component on a window that does not exist or has been destroyed.');
11721
+ const consumer = new api_exposer_1.ApiConsumer(new api_exposer_1.ChannelsConsumer({ dispatch }));
11722
+ return consumer.consume({ id: controllerId });
11723
+ };
11724
+ LayoutNode.getEntity = (definition, client) => {
11725
+ const { entityId, type } = definition;
11726
+ switch (type) {
11727
+ case 'column':
11728
+ case 'row':
11729
+ return new ColumnOrRow(client, entityId, type);
11730
+ case 'stack':
11731
+ return new TabStack(client, entityId);
11732
+ default:
11733
+ throw new Error(`Unrecognised Layout Entity encountered ('${JSON.stringify(definition)})`);
11734
+ }
11735
+ };
11736
+ /**
11737
+ * A TabStack is used to manage the state of a stack of tabs within an OpenFin Layout.
11738
+ */
11739
+ class TabStack extends LayoutNode {
11740
+ /** @internal */
11741
+ constructor(client, entityId) {
11742
+ super(client, entityId);
11743
+ /**
11744
+ * @internal
11745
+ * ApiClient for {@link LayoutEntitiesController}
11746
+ */
11747
+ _TabStack_client.set(this, void 0);
11748
+ /**
11749
+ * Type of the content item. Always stack, but useful for distinguishing between a {@link TabStack} and {@link ColumnOrRow}.
11750
+ */
11751
+ this.type = 'stack';
11752
+ /**
11753
+ * Retrieves a list of all views belonging to this {@link TabStack}.
11754
+ *
11755
+ * Known Issue: If adding a view overflows the tab-container width, the added view will be set as active
11756
+ * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
11757
+ * If that happens and then getViews() is called, it will return the identities in a different order than
11758
+ * than the currently rendered tab order.
11759
+ *
11760
+ *
11761
+ * @throws If the {@link TabStack} has been destroyed.
11762
+ * @example
11763
+ * ```js
11764
+ * if (!fin.me.isView) {
11765
+ * throw new Error('Not running in a platform View.');
11766
+ * }
11767
+ *
11768
+ * const stack = await fin.me.getCurrentStack();
11769
+ * // Alternatively, you can wrap any view and get the stack from there
11770
+ * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
11771
+ * // const stack = await viewFromSomewhere.getCurrentStack();
11772
+ * const views = await stack.getViews();
11773
+ * console.log(`Stack contains ${views.length} view(s)`);
11774
+ * ```
11775
+ * @experimental
11776
+ */
11777
+ this.getViews = () => __classPrivateFieldGet$5(this, _TabStack_client, "f").getStackViews(this.entityId);
11778
+ /**
11779
+ * Adds or creates a view in this {@link TabStack}.
11780
+ *
11781
+ * @remarks Known Issue: If adding a view overflows the tab-container, the added view will be set as active
11782
+ * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
11783
+ *
11784
+ * @param view The identity of an existing view to add, or options to create a view.
11785
+ * @param options Optional view options: index number used to insert the view into the stack at that index. Defaults to 0 (front of the stack)
11786
+ * @returns Resolves with the {@link OpenFin.Identity identity} of the added view.
11787
+ * @throws If the view does not exist or fails to create.
11788
+ * @throws If the {@link TabStack} has been destroyed.
11789
+ * @example
11790
+ * ```js
11791
+ * if (!fin.me.isView) {
11792
+ * throw new Error('Not running in a platform View.');
11793
+ * }
11794
+ *
11795
+ * const stack = await fin.me.getCurrentStack();
11796
+ * // Alternatively, you can wrap any view and get the stack from there
11797
+ * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
11798
+ * // const stack = await viewFromSomewhere.getCurrentStack();
11799
+ * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
11800
+ * console.log('Identity of the google view just added', { googleViewIdentity });
11801
+ * // pass in { index: number } to set the index in the stack. Here 1 means, end of the stack (defaults to 0)
11802
+ * const appleViewIdentity = await stack.addView({ name: 'apple-view', url: 'http://apple.com/' }, { index: 1 });
11803
+ * console.log('Identity of the apple view just added', { appleViewIdentity });
11804
+ * ```
11805
+ * @experimental
11806
+ */
11807
+ this.addView = async (view, options = { index: 0 }) => __classPrivateFieldGet$5(this, _TabStack_client, "f").addViewToStack(this.entityId, view, options);
11808
+ /**
11809
+ * Removes a view from this {@link TabStack}.
11810
+ *
11811
+ * @remarks Throws an exception if the view identity does not exist or was already destroyed.
11812
+ *
11813
+ * @param view - Identity of the view to remove.
11814
+ * @throws If the view does not exist or does not belong to the stack.
11815
+ * @throws If the {@link TabStack} has been destroyed.
11816
+ *
11817
+ * @example
11818
+ * ```js
11819
+ * if (!fin.me.isView) {
11820
+ * throw new Error('Not running in a platform View.');
11821
+ * }
11822
+ *
11823
+ * const stack = await fin.me.getCurrentStack();
11824
+ * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
11825
+ *
11826
+ * await stack.removeView(googleViewIdentity);
11827
+ *
11828
+ * try {
11829
+ * await stack.removeView(googleViewIdentity);
11830
+ * } catch (error) {
11831
+ * // Tried to remove a view ('google-view') which does not belong to the stack.
11832
+ * console.log(error);
11833
+ * }
11834
+ * ```
11835
+ */
11836
+ this.removeView = async (view) => {
11837
+ await __classPrivateFieldGet$5(this, _TabStack_client, "f").removeViewFromStack(this.entityId, view);
11838
+ };
11839
+ /**
11840
+ * Sets the active view of the {@link TabStack} without focusing it.
11841
+ * @param view - Identity of the view to activate.
11842
+ * @returns Promise which resolves with void once the view has been activated.
11843
+ * @throws If the {@link TabStack} has been destroyed.
11844
+ * @throws If the view does not exist.
11845
+ * @example
11846
+ * Change the active tab of a known View's TabStack:
11847
+ * ```js
11848
+ * const targetView = fin.View.wrapSync({ uuid: 'uuid', name: 'view-name' });
11849
+ * const stack = await targetView.getCurrentStack();
11850
+ * await stack.setActiveView(targetView.identity);
11851
+ * ```
11852
+ *
11853
+ * Set the current View as active within its TabStack:
11854
+ * ```js
11855
+ * const stack = await fin.me.getCurrentStack();
11856
+ * await stack.setActiveView(fin.me.identity);
11857
+ * ```
11858
+ * @experimental
11859
+ */
11860
+ this.setActiveView = async (view) => {
11861
+ await __classPrivateFieldGet$5(this, _TabStack_client, "f").setStackActiveView(this.entityId, view);
11862
+ };
11863
+ __classPrivateFieldSet$4(this, _TabStack_client, client, "f");
11846
11864
  }
11865
+ }
11866
+ layoutEntities.TabStack = TabStack;
11867
+ _TabStack_client = new WeakMap();
11868
+ /**
11869
+ * A ColumnOrRow is used to manage the state of Column and Rows within an OpenFin Layout.
11870
+ */
11871
+ class ColumnOrRow extends LayoutNode {
11847
11872
  /**
11848
- * Closes a window. If enableBeforeUnload is enabled in the Platform options, any beforeunload handler set on Views will fire
11849
- * This behavior can be disabled by setting skipBeforeUnload to false in the options parameter.
11850
- * @param winId
11851
- * @param options
11852
- *
11853
- * @remarks This method works by setting a `close-requested` handler on the Platform Window. If you have your own `close-requested` handler set on the Platform Window as well,
11854
- * it is recommended to move that logic over to the [PlatformProvider.closeWindow]{@link PlatformProvider#closeWindow} override to ensure it runs when the Window closes.
11855
- *
11856
- * @example
11857
- *
11858
- * ```js
11859
- * // Close the current Window inside a Window context
11860
- * const platform = await fin.Platform.getCurrent();
11861
- * platform.closeWindow(fin.me.identity);
11862
- *
11863
- * // Close the Window from inside a View context
11864
- * const platform = await fin.Platform.getCurrent();
11865
- * const parentWindow = await fin.me.getCurrentWindow();
11866
- * platform.closeWindow(parentWindow.identity);
11867
- *
11868
- * // Close the Window and do not fire the before unload handler on Views
11869
- * const platform = await fin.Platform.getCurrent();
11870
- * platform.closeWindow(fin.me.identity, { skipBeforeUnload: true });
11871
- * ```
11872
- * @experimental
11873
+ * @internal
11873
11874
  */
11874
- async closeWindow(windowId, options = { skipBeforeUnload: false }) {
11875
- this.wire.sendAction('platform-close-window', this.identity).catch((e) => {
11876
- // don't expose
11877
- });
11878
- const client = await this.getClient();
11879
- return client.dispatch('close-window', { windowId, options });
11875
+ constructor(client, entityId, type) {
11876
+ super(client, entityId);
11877
+ /**
11878
+ * @ignore
11879
+ * @internal
11880
+ * ApiClient for {@link LayoutEntitiesController}
11881
+ */
11882
+ _ColumnOrRow_client.set(this, void 0);
11883
+ /**
11884
+ * Retrieves the content array of the ColumnOrRow
11885
+ *
11886
+ * @example
11887
+ * ```js
11888
+ * if (!fin.me.isView) {
11889
+ * throw new Error('Not running in a platform View.');
11890
+ * }
11891
+ *
11892
+ * const stack = await fin.me.getCurrentStack();
11893
+ * // Retrieves the parent ColumnOrRow
11894
+ * const columnOrRow = await stack.getParent();
11895
+ *
11896
+ * // returns [TabStack]
11897
+ * const contentArray = await columnOrRow.getContent();
11898
+ * console.log(`The ColumnOrRow has ${contentArray.length} item(s)`);
11899
+ * ```
11900
+ */
11901
+ this.getContent = async () => {
11902
+ const contentItemEntities = await __classPrivateFieldGet$5(this, _ColumnOrRow_client, "f").getContent(this.entityId);
11903
+ return contentItemEntities.map((entity) => LayoutNode.getEntity(entity, __classPrivateFieldGet$5(this, _ColumnOrRow_client, "f")));
11904
+ };
11905
+ __classPrivateFieldSet$4(this, _ColumnOrRow_client, client, "f");
11906
+ this.type = type;
11880
11907
  }
11881
11908
  }
11882
- Instance$2.Platform = Platform;
11883
- _Platform_connectToProvider = new WeakMap();
11884
-
11885
- var layout = {};
11886
-
11887
- var Factory$2 = {};
11888
-
11889
- var Instance$1 = {};
11909
+ layoutEntities.ColumnOrRow = ColumnOrRow;
11910
+ _ColumnOrRow_client = new WeakMap();
11890
11911
 
11891
- var commonUtils = {};
11912
+ var layout_constants = {};
11892
11913
 
11893
- Object.defineProperty(commonUtils, "__esModule", { value: true });
11894
- commonUtils.overrideFromComposables = commonUtils.isValidPresetType = void 0;
11895
- function isValidPresetType(type) {
11896
- switch (type) {
11897
- case 'columns':
11898
- case 'grid':
11899
- case 'rows':
11900
- case 'tabs':
11901
- return true;
11902
- default:
11903
- return false;
11904
- }
11905
- }
11906
- commonUtils.isValidPresetType = isValidPresetType;
11907
- function overrideFromComposables(...overrides) {
11908
- return (base) => overrides.reduceRight((p, c) => (b) => c(p(b)), (x) => x)(base);
11909
- }
11910
- commonUtils.overrideFromComposables = overrideFromComposables;
11911
- commonUtils.default = { isValidPresetType };
11914
+ Object.defineProperty(layout_constants, "__esModule", { value: true });
11915
+ layout_constants.DEFAULT_LAYOUT_KEY = layout_constants.LAYOUT_CONTROLLER_ID = void 0;
11916
+ layout_constants.LAYOUT_CONTROLLER_ID = 'layout-entities';
11917
+ // TODO: eventually export this somehow
11918
+ layout_constants.DEFAULT_LAYOUT_KEY = '__default__';
11912
11919
 
11913
11920
  var __classPrivateFieldGet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
11914
11921
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
11915
11922
  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");
11916
11923
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11917
11924
  };
11918
- var _Layout_layoutClient;
11925
+ var _Layout_instances, _Layout_layoutClient, _Layout_forwardLayoutAction;
11919
11926
  Object.defineProperty(Instance$1, "__esModule", { value: true });
11920
11927
  Instance$1.Layout = void 0;
11921
11928
  const lazy_1 = lazy;
@@ -12057,12 +12064,19 @@ const layout_constants_1$1 = layout_constants;
12057
12064
  * ```
12058
12065
  */
12059
12066
  class Layout extends base_1$5.Base {
12067
+ /**
12068
+ * @internal
12069
+ */
12070
+ static getClient(layout) {
12071
+ return __classPrivateFieldGet$4(layout, _Layout_layoutClient, "f").getValue();
12072
+ }
12060
12073
  /**
12061
12074
  * @internal
12062
12075
  */
12063
12076
  // eslint-disable-next-line no-shadow
12064
12077
  constructor(identity, wire) {
12065
12078
  super(wire);
12079
+ _Layout_instances.add(this);
12066
12080
  /**
12067
12081
  * @internal
12068
12082
  * Lazily constructed {@link LayoutEntitiesClient} bound to this platform's client and identity
@@ -12281,9 +12295,71 @@ class Layout extends base_1$5.Base {
12281
12295
  const root = await client.getRoot('layoutName' in this.identity ? this.identity : undefined);
12282
12296
  return layout_entities_1.LayoutNode.getEntity(root, client);
12283
12297
  }
12298
+ /**
12299
+ * Retrieves the OpenFin.TabStack instance which the View belongs to.
12300
+ *
12301
+ * @example
12302
+ * ```js
12303
+ * const viewIdentity = { uuid: 'uuid', name: 'view-name' };
12304
+ * const stack = await fin.View.wrapSync(viewIdentity).getStackByViewIdentity(viewIdentity);
12305
+ * console.log(await stack.getViews());
12306
+ * ```
12307
+ */
12308
+ async getStackByViewIdentity(identity) {
12309
+ this.wire.sendAction('layout-get-stack-by-view').catch(() => {
12310
+ // don't expose
12311
+ });
12312
+ const client = await __classPrivateFieldGet$4(this, _Layout_layoutClient, "f").getValue();
12313
+ const stack = await client.getStackByView(identity);
12314
+ if (!stack) {
12315
+ throw new Error(`No stack found for view: ${identity.uuid}/${identity.name}`);
12316
+ }
12317
+ return layout_entities_1.LayoutNode.getEntity(stack, client);
12318
+ }
12319
+ /**
12320
+ * Adds a view to the platform layout. Behaves like @link{Platform#createView} with the current layout as the target.
12321
+ *
12322
+ * @param viewOptions - The options for creating the view.
12323
+ * @param options - Optional parameters for adding the view.
12324
+ * @param options.location - The location where the view should be added.
12325
+ * @param options.targetView - The target view to which the new view should be added.
12326
+ * @returns A promise that resolves to an object containing the identity of the added view.
12327
+ */
12328
+ async addView(viewOptions, { location, targetView } = {}) {
12329
+ this.wire.sendAction('layout-add-view').catch((e) => {
12330
+ // don't expose
12331
+ });
12332
+ const { identity } = await __classPrivateFieldGet$4(this, _Layout_instances, "m", _Layout_forwardLayoutAction).call(this, 'layout-add-view', {
12333
+ viewOptions,
12334
+ location,
12335
+ targetView
12336
+ });
12337
+ return { identity };
12338
+ }
12339
+ /**
12340
+ * Closes a view by its identity. Throws an error if the view does not belong to the current layout.
12341
+ * Behaves like @link{Platform#closeView} but only closes the view if it belongs the current layout.
12342
+ *
12343
+ * @param viewIdentity - The identity of the view to close.
12344
+ * @returns A promise that resolves when the view is closed.
12345
+ */
12346
+ async closeView(viewIdentity) {
12347
+ this.wire.sendAction('layout-close-view').catch((e) => {
12348
+ // don't expose
12349
+ });
12350
+ await __classPrivateFieldGet$4(this, _Layout_instances, "m", _Layout_forwardLayoutAction).call(this, 'layout-close-view', { viewIdentity });
12351
+ }
12284
12352
  }
12285
12353
  Instance$1.Layout = Layout;
12286
- _Layout_layoutClient = new WeakMap();
12354
+ _Layout_layoutClient = new WeakMap(), _Layout_instances = new WeakSet(), _Layout_forwardLayoutAction =
12355
+ /**
12356
+ * @internal
12357
+ * Use to type-guard actions sent to the layout via the provider.
12358
+ */
12359
+ async function _Layout_forwardLayoutAction(action, payload) {
12360
+ const client = await this.platform.getClient();
12361
+ return client.dispatch(action, { target: this.identity, opts: payload });
12362
+ };
12287
12363
 
12288
12364
  var __classPrivateFieldGet$3 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12289
12365
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
@@ -12474,7 +12550,7 @@ class LayoutModule extends base_1$4.Base {
12474
12550
  this.wire.sendAction('layout-get-current').catch((e) => {
12475
12551
  // don't expose
12476
12552
  });
12477
- if (!this.fin.me.isWindow) {
12553
+ if (this.wire.environment.type === 'openfin' && !this.fin.me.isWindow) {
12478
12554
  throw new Error('You are not in a Window context. Only Windows can have a Layout.');
12479
12555
  }
12480
12556
  const { uuid, name } = this.fin.me;
@@ -12497,12 +12573,54 @@ class LayoutModule extends base_1$4.Base {
12497
12573
  this.wire.sendAction('layout-get-current-sync').catch((e) => {
12498
12574
  // don't expose
12499
12575
  });
12500
- if (!this.fin.me.isWindow) {
12576
+ if (this.wire.environment.type === 'openfin' && !this.fin.me.isWindow) {
12501
12577
  throw new Error('You are not in a Window context. Only Windows can have a Layout.');
12502
12578
  }
12503
12579
  const { uuid, name } = this.fin.me;
12504
12580
  return this.wrapSync({ uuid, name });
12505
12581
  }
12582
+ /**
12583
+ * Retrieves the OpenFin.Layout instance for the Window the View is attached to.
12584
+ *
12585
+ * @example
12586
+ * ```js
12587
+ * const viewIdentity = { uuid: 'uuid', name: 'view-name' };
12588
+ * const layout = await fin.Platform.Layout.getLayoutByViewIdentity(viewIdentity);
12589
+ * console.log(await layout.getCurrentViews());
12590
+ * ```
12591
+ */
12592
+ async getLayoutByViewIdentity(viewIdentity) {
12593
+ this.wire.sendAction('layout-get-by-view-identity').catch(() => {
12594
+ // don't expose
12595
+ });
12596
+ const winIdentity = await this.wire.environment.getViewWindowIdentity(this.fin, viewIdentity);
12597
+ let layoutWindowIdentity = winIdentity;
12598
+ // TODO: CORE-1857 - when we tearout active layout or drag a view out of a window, the above identity includes the whole window info.
12599
+ if (layoutWindowIdentity.identity) {
12600
+ layoutWindowIdentity = layoutWindowIdentity.identity;
12601
+ }
12602
+ try {
12603
+ const layoutWindow = this.wrapSync(layoutWindowIdentity);
12604
+ const client = await Instance_1$2.Layout.getClient(layoutWindow);
12605
+ const layoutIdentity = await client.getLayoutIdentityForViewOrThrow(viewIdentity);
12606
+ return this.wrapSync(layoutIdentity);
12607
+ }
12608
+ catch (e) {
12609
+ const allowedErrors = [
12610
+ 'No action registered at target for',
12611
+ 'getLayoutIdentityForViewOrThrow is not a function'
12612
+ ];
12613
+ if (!allowedErrors.some((m) => e.message.includes(m))) {
12614
+ throw e;
12615
+ }
12616
+ // If a view is attached to provider window, return null
12617
+ if (layoutWindowIdentity.uuid === layoutWindowIdentity.name) {
12618
+ throw new Error(`View identity ${JSON.stringify(viewIdentity)} is not attached to any layout in provider window ${JSON.stringify(layoutWindowIdentity)}.`);
12619
+ }
12620
+ // fallback logic for missing endpoint in older runtimes
12621
+ return this.wrapSync(layoutWindowIdentity);
12622
+ }
12623
+ }
12506
12624
  }
12507
12625
  Factory$2.LayoutModule = LayoutModule;
12508
12626
  _LayoutModule_layoutInitializationAttempted = new WeakMap(), _LayoutModule_layoutManager = new WeakMap(), _LayoutModule_getLayoutManagerSpy = new WeakMap(), _LayoutModule_instances = new WeakSet(), _LayoutModule_getSafeLayoutManager = function _LayoutModule_getSafeLayoutManager(method) {
@@ -12639,7 +12757,7 @@ class PlatformModule extends base_1$3.Base {
12639
12757
  this.wire.sendAction('platform-wrap').catch((e) => {
12640
12758
  // don't expose
12641
12759
  });
12642
- return new Instance_1$1.Platform({ uuid: identity.uuid }, this._channel);
12760
+ return new Instance_1$1.Platform(this.wire, { uuid: identity.uuid });
12643
12761
  }
12644
12762
  /**
12645
12763
  * Synchronously returns a Platform object that represents an existing platform.
@@ -12656,7 +12774,7 @@ class PlatformModule extends base_1$3.Base {
12656
12774
  this.wire.sendAction('platform-wrap-sync').catch((e) => {
12657
12775
  // don't expose
12658
12776
  });
12659
- return new Instance_1$1.Platform({ uuid: identity.uuid }, this._channel);
12777
+ return new Instance_1$1.Platform(this.wire, { uuid: identity.uuid });
12660
12778
  }
12661
12779
  /**
12662
12780
  * Asynchronously returns a Platform object that represents the current platform.
@@ -17540,6 +17658,9 @@ class MockEnvironment {
17540
17658
  async getInteropInfo() {
17541
17659
  throw new Error(me_1.environmentUnsupportedMessage);
17542
17660
  }
17661
+ async getViewWindowIdentity() {
17662
+ throw new Error(me_1.environmentUnsupportedMessage);
17663
+ }
17543
17664
  getDefaultChannelOptions() {
17544
17665
  throw new Error(me_1.environmentUnsupportedMessage);
17545
17666
  }