@openfin/core 39.83.3 → 39.83.4

Sign up to get free protection for your applications and to get access to all the features.
package/out/mock.js CHANGED
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var require$$0 = require('events');
6
- var require$$3 = require('lodash');
6
+ var require$$0$1 = require('lodash/cloneDeep');
7
+ var require$$3 = require('lodash/isEqual');
7
8
 
8
9
  function _mergeNamespaces(n, m) {
9
10
  m.forEach(function (e) {
@@ -241,27 +242,50 @@ Object.defineProperty(window$2, "__esModule", { value: true });
241
242
  *
242
243
  * @packageDocumentation
243
244
  */
245
+ var __createBinding$1 = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
246
+ if (k2 === undefined) k2 = k;
247
+ var desc = Object.getOwnPropertyDescriptor(m, k);
248
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
249
+ desc = { enumerable: true, get: function() { return m[k]; } };
250
+ }
251
+ Object.defineProperty(o, k2, desc);
252
+ }) : (function(o, m, k, k2) {
253
+ if (k2 === undefined) k2 = k;
254
+ o[k2] = m[k];
255
+ }));
256
+ var __setModuleDefault$1 = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) {
257
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
258
+ }) : function(o, v) {
259
+ o["default"] = v;
260
+ });
261
+ var __importStar$1 = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
262
+ if (mod && mod.__esModule) return mod;
263
+ var result = {};
264
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding$1(result, mod, k);
265
+ __setModuleDefault$1(result, mod);
266
+ return result;
267
+ };
244
268
  Object.defineProperty(events, "__esModule", { value: true });
245
269
  events.WindowEvents = events.WebContentsEvents = events.ViewEvents = events.SystemEvents = events.PlatformEvents = events.GlobalHotkeyEvents = events.FrameEvents = events.ExternalApplicationEvents = events.BaseEvents = events.ApplicationEvents = void 0;
246
- const ApplicationEvents = application$1;
270
+ const ApplicationEvents = __importStar$1(application$1);
247
271
  events.ApplicationEvents = ApplicationEvents;
248
- const BaseEvents = base$1;
272
+ const BaseEvents = __importStar$1(base$1);
249
273
  events.BaseEvents = BaseEvents;
250
- const ExternalApplicationEvents = externalApplication$1;
274
+ const ExternalApplicationEvents = __importStar$1(externalApplication$1);
251
275
  events.ExternalApplicationEvents = ExternalApplicationEvents;
252
- const FrameEvents = frame$1;
276
+ const FrameEvents = __importStar$1(frame$1);
253
277
  events.FrameEvents = FrameEvents;
254
- const GlobalHotkeyEvents = globalHotkey$1;
278
+ const GlobalHotkeyEvents = __importStar$1(globalHotkey$1);
255
279
  events.GlobalHotkeyEvents = GlobalHotkeyEvents;
256
- const PlatformEvents = platform$1;
280
+ const PlatformEvents = __importStar$1(platform$1);
257
281
  events.PlatformEvents = PlatformEvents;
258
- const SystemEvents = system$1;
282
+ const SystemEvents = __importStar$1(system$1);
259
283
  events.SystemEvents = SystemEvents;
260
- const ViewEvents = view$1;
284
+ const ViewEvents = __importStar$1(view$1);
261
285
  events.ViewEvents = ViewEvents;
262
- const WebContentsEvents = webcontents;
286
+ const WebContentsEvents = __importStar$1(webcontents);
263
287
  events.WebContentsEvents = WebContentsEvents;
264
- const WindowEvents = window$2;
288
+ const WindowEvents = __importStar$1(window$2);
265
289
  events.WindowEvents = WindowEvents;
266
290
 
267
291
  (function (exports) {
@@ -793,7 +817,9 @@ function requireFactory$3 () {
793
817
  * @experimental
794
818
  */
795
819
  async wrap(identity) {
796
- this.wire.sendAction('view-wrap');
820
+ this.wire.sendAction('view-wrap').catch((e) => {
821
+ // we do not want to expose this error, just continue if this analytics-only call fails
822
+ });
797
823
  const errorMsg = (0, validate_1.validateIdentity)(identity);
798
824
  if (errorMsg) {
799
825
  throw new Error(errorMsg);
@@ -930,902 +956,238 @@ class AsyncRetryableLazy {
930
956
  }
931
957
  lazy.AsyncRetryableLazy = AsyncRetryableLazy;
932
958
 
933
- var layoutEntities = {};
934
-
935
- var apiExposer$1 = {};
936
-
937
- var apiConsumer = {};
938
-
939
- Object.defineProperty(apiConsumer, "__esModule", { value: true });
940
- apiConsumer.ApiConsumer = void 0;
941
- /**
942
- * Consumer for apis exposed with {@see ApiExposer}.
943
- *
944
- * A strategy that matches the strategy used to expose a target API must be provided.
945
- */
946
- class ApiConsumer {
947
- // eslint-disable-next-line
948
- constructor(strategy) {
949
- this.strategy = strategy;
950
- /**
951
- * Consumes an api exposed using a given transport strategy, and generates a client
952
- * for easy, type safe consumption of that client.
953
- * @param options Strategy specific consumption options.
954
- * @returns An api client matching the given type.
955
- */
956
- this.consume = async (options) => {
957
- const exposedProperties = await this.strategy.getExposedFunctions(options);
958
- return exposedProperties.reduce((client, prop) => ({
959
- ...client,
960
- [prop.key]: this.strategy.createFunction(prop, options)
961
- }), {});
962
- };
963
- }
964
- }
965
- apiConsumer.ApiConsumer = ApiConsumer;
966
-
967
- var apiExposer = {};
968
-
969
- var decorators = {};
970
-
971
- Object.defineProperty(decorators, "__esModule", { value: true });
972
- decorators.expose = decorators.getExposedProperties = void 0;
973
- const exposedProperties = Symbol('exposedProperties');
974
- const getExposedProperties = (target) => {
975
- return target[exposedProperties] || target.prototype[exposedProperties] || [];
976
- };
977
- decorators.getExposedProperties = getExposedProperties;
978
- /**
979
- * Indicates that a class member function can be exposed using {@link ApiExposer}.
980
- * @param options Options specific to the strategy used in {@link ApiExposer}
981
- */
982
- // Returns any as decorator typing is weird.
983
- const expose = (options) => (target, key, descriptor) => {
984
- target[exposedProperties] = target[exposedProperties] || [];
985
- target[exposedProperties].push({ key, descriptor, options });
986
- };
987
- decorators.expose = expose;
959
+ var main = {};
988
960
 
989
- Object.defineProperty(apiExposer, "__esModule", { value: true });
990
- apiExposer.ApiExposer = void 0;
991
- const decorators_1 = decorators;
992
- /**
993
- * Exposes api services on the transport of choice.
994
- */
995
- class ApiExposer {
961
+ Object.defineProperty(main, "__esModule", { value: true });
962
+ main.WebContents = void 0;
963
+ const base_1$j = base;
964
+ class WebContents extends base_1$j.EmitterBase {
996
965
  /**
997
- * @param strategy The expose strategy to use to expose instances.
966
+ * @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
967
+ * @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
998
968
  */
999
- // eslint-disable-next-line
1000
- constructor(strategy) {
1001
- this.strategy = strategy;
1002
- /**
1003
- * Exposes an instance of a given api on
1004
- * @param instance Instance of a class which has been decorated to indicate which functions can be exposed.
1005
- * @param instanceOptions Transport strategy specific options to use when exposing.
1006
- */
1007
- this.exposeInstance = async (instance, instanceOptions) => {
1008
- const exposableProps = (0, decorators_1.getExposedProperties)(instance);
1009
- const exposedProps = await Promise.all(exposableProps.map(async ({ key, options }) => {
1010
- const customConsumptionOptions = await this.strategy.exposeFunction(instance[key].bind(instance), {
1011
- key,
1012
- options,
1013
- meta: instanceOptions
1014
- });
1015
- return {
1016
- key,
1017
- options: customConsumptionOptions
1018
- };
1019
- }));
1020
- await this.strategy.exposeMeta(instanceOptions, exposedProps);
1021
- };
969
+ constructor(wire, identity, entityType) {
970
+ super(wire, entityType, identity.uuid, identity.name);
971
+ this.identity = identity;
972
+ this.entityType = entityType;
1022
973
  }
1023
- ;
1024
- }
1025
- apiExposer.ApiExposer = ApiExposer;
1026
-
1027
- var strategies = {};
1028
-
1029
- var openfinChannels = {};
1030
-
1031
- var channelsConsumer = {};
1032
-
1033
- Object.defineProperty(channelsConsumer, "__esModule", { value: true });
1034
- channelsConsumer.ChannelsConsumer = void 0;
1035
- class ChannelsConsumer {
1036
- // eslint-disable-next-line
1037
- constructor(channel) {
1038
- this.channel = channel;
1039
- this.getExposedFunctions = async (options) => {
1040
- const { id } = options;
1041
- const { props } = await this.channel.dispatch(`api-meta:${id}`);
1042
- return props;
1043
- };
1044
- this.createFunction = (prop) => (...args) => {
1045
- const { action } = prop.options;
1046
- return this.channel.dispatch(action, { args });
1047
- };
974
+ /**
975
+ * Gets a base64 encoded image of all or part of the WebContents.
976
+ * @param options Options for the capturePage call.
977
+ *
978
+ * @example
979
+ *
980
+ * View:
981
+ * ```js
982
+ * const view = fin.View.getCurrentSync();
983
+ *
984
+ * // PNG image of a full visible View
985
+ * console.log(await view.capturePage());
986
+ *
987
+ * // Low-quality JPEG image of a defined visible area of the view
988
+ * const options = {
989
+ * area: {
990
+ * height: 100,
991
+ * width: 100,
992
+ * x: 10,
993
+ * y: 10,
994
+ * },
995
+ * format: 'jpg',
996
+ * quality: 20
997
+ * }
998
+ * console.log(await view.capturePage(options));
999
+ * ```
1000
+ *
1001
+ * Window:
1002
+ * ```js
1003
+ * const wnd = await fin.Window.getCurrent();
1004
+ *
1005
+ * // PNG image of a full visible window
1006
+ * console.log(await wnd.capturePage());
1007
+ *
1008
+ * // Low-quality JPEG image of a defined visible area of the window
1009
+ * const options = {
1010
+ * area: {
1011
+ * height: 100,
1012
+ * width: 100,
1013
+ * x: 10,
1014
+ * y: 10,
1015
+ * },
1016
+ * format: 'jpg',
1017
+ * quality: 20
1018
+ * }
1019
+ * console.log(await wnd.capturePage(options));
1020
+ * ```
1021
+ *
1022
+ * @remarks
1023
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1024
+ * We do not expose an explicit superclass for this functionality, but it does have its own
1025
+ * {@link OpenFin.WebContentsEvents event namespace}.
1026
+ */
1027
+ capturePage(options) {
1028
+ return this.wire.sendAction('capture-page', { options, ...this.identity }).then(({ payload }) => payload.data);
1048
1029
  }
1049
- ;
1050
- }
1051
- channelsConsumer.ChannelsConsumer = ChannelsConsumer;
1052
-
1053
- var channelsExposer = {};
1054
-
1055
- Object.defineProperty(channelsExposer, "__esModule", { value: true });
1056
- channelsExposer.ChannelsExposer = void 0;
1057
- class ChannelsExposer {
1058
- // eslint-disable-next-line
1059
- constructor(channelProviderOrClient) {
1060
- this.channelProviderOrClient = channelProviderOrClient;
1061
- this.exposeFunction = async (target, config) => {
1062
- const { key, options, meta } = config;
1063
- const { id } = meta;
1064
- const action = `${id}.${options?.action || key}`;
1065
- await this.channelProviderOrClient.register(action, async ({ args }) => {
1066
- return target(...args);
1067
- });
1068
- return { action };
1069
- };
1070
- this.exposeMeta = async ({ id }, props) => {
1071
- const action = `api-meta:${id}`;
1072
- await this.channelProviderOrClient.register(action, () => ({ props }));
1073
- };
1030
+ /**
1031
+ * Executes Javascript on the WebContents, restricted to contents you own or contents owned by
1032
+ * applications you have created.
1033
+ * @param code JavaScript code to be executed on the view.
1034
+ *
1035
+ * @example
1036
+ * View:
1037
+ * ```js
1038
+ * async function executeJavaScript(code) {
1039
+ * const view = await fin.View.wrap({uuid: 'uuid', name: 'view name'});
1040
+ * return await view.executeJavaScript(code);
1041
+ * }
1042
+ *
1043
+ * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
1044
+ * ```
1045
+ *
1046
+ * Window:
1047
+ * ```js
1048
+ * async function executeJavaScript(code) {
1049
+ * const app = await fin.Application.start({
1050
+ * name: 'myApp',
1051
+ * uuid: 'app-1',
1052
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.executeJavaScript.html',
1053
+ * autoShow: true
1054
+ * });
1055
+ * const win = await app.getWindow();
1056
+ * return await win.executeJavaScript(code);
1057
+ * }
1058
+ *
1059
+ * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
1060
+ * ```
1061
+ * @remarks
1062
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1063
+ * We do not expose an explicit superclass for this functionality, but it does have its own
1064
+ * {@link OpenFin.WebContentsEvents event namespace}.
1065
+ */
1066
+ executeJavaScript(code) {
1067
+ return this.wire
1068
+ .sendAction('execute-javascript-in-window', { ...this.identity, code })
1069
+ .then(({ payload }) => payload.data);
1074
1070
  }
1075
- }
1076
- channelsExposer.ChannelsExposer = ChannelsExposer;
1077
-
1078
- (function (exports) {
1079
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1080
- if (k2 === undefined) k2 = k;
1081
- var desc = Object.getOwnPropertyDescriptor(m, k);
1082
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1083
- desc = { enumerable: true, get: function() { return m[k]; } };
1084
- }
1085
- Object.defineProperty(o, k2, desc);
1086
- }) : (function(o, m, k, k2) {
1087
- if (k2 === undefined) k2 = k;
1088
- o[k2] = m[k];
1089
- }));
1090
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
1091
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1092
- };
1093
- Object.defineProperty(exports, "__esModule", { value: true });
1094
- __exportStar(channelsConsumer, exports);
1095
- __exportStar(channelsExposer, exports);
1096
- } (openfinChannels));
1097
-
1098
- (function (exports) {
1099
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1100
- if (k2 === undefined) k2 = k;
1101
- var desc = Object.getOwnPropertyDescriptor(m, k);
1102
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1103
- desc = { enumerable: true, get: function() { return m[k]; } };
1104
- }
1105
- Object.defineProperty(o, k2, desc);
1106
- }) : (function(o, m, k, k2) {
1107
- if (k2 === undefined) k2 = k;
1108
- o[k2] = m[k];
1109
- }));
1110
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
1111
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1112
- };
1113
- Object.defineProperty(exports, "__esModule", { value: true });
1114
- __exportStar(openfinChannels, exports);
1115
- } (strategies));
1116
-
1117
- (function (exports) {
1118
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1119
- if (k2 === undefined) k2 = k;
1120
- var desc = Object.getOwnPropertyDescriptor(m, k);
1121
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1122
- desc = { enumerable: true, get: function() { return m[k]; } };
1123
- }
1124
- Object.defineProperty(o, k2, desc);
1125
- }) : (function(o, m, k, k2) {
1126
- if (k2 === undefined) k2 = k;
1127
- o[k2] = m[k];
1128
- }));
1129
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
1130
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1131
- };
1132
- Object.defineProperty(exports, "__esModule", { value: true });
1133
- __exportStar(apiConsumer, exports);
1134
- __exportStar(apiExposer, exports);
1135
- __exportStar(strategies, exports);
1136
- __exportStar(decorators, exports);
1137
- } (apiExposer$1));
1138
-
1139
- var channelApiRelay = {};
1140
-
1141
- Object.defineProperty(channelApiRelay, "__esModule", { value: true });
1142
- channelApiRelay.createRelayedDispatch = channelApiRelay.relayChannelClientApi = void 0;
1143
- const EXPECTED_ERRORS = [
1144
- 'no longer connected',
1145
- 'RTCDataChannel closed unexpectedly',
1146
- 'The client you are trying to dispatch from is disconnected from the target provider',
1147
- ];
1148
- // Checks possible error messages that we want to trap, client error message can originate
1149
- // from ChannelProvider::dispatch OR ClassicStrategy::closeEndpoint OR RTCEndPoint::dataChannel::onclose
1150
- const isDisconnectedError = (errorMsg) => {
1151
- return EXPECTED_ERRORS.some(e => errorMsg.includes(e));
1152
- };
1153
- /**
1154
- * @internal
1155
- * Create a channel relay for a given channel exposition, allowing a single provider to route
1156
- * actions to the designated clients.
1157
- *
1158
- * Designed to be used in conjunction with @expose
1159
- *
1160
- * @param channelProvider The channel provider to relay the actions on.
1161
- * @param config Determines which actions to relay. Please ensure action prefix matches the exposed api.
1162
- */
1163
- const relayChannelClientApi = async (channelProvider, relayId) => {
1164
- channelProvider.register(`relay:${relayId}`, ({ action, target, payload }) => {
1165
- return channelProvider.dispatch(target, action, payload);
1166
- });
1167
- await Promise.resolve();
1168
- };
1169
- channelApiRelay.relayChannelClientApi = relayChannelClientApi;
1170
- const createRelayedDispatch = (client, target, relayId, relayErrorMsg) => async (action, payload) => {
1171
- try {
1172
- return await client.dispatch(`relay:${relayId}`, {
1173
- action,
1174
- payload,
1175
- target
1176
- });
1071
+ /**
1072
+ * Returns the zoom level of the WebContents.
1073
+ *
1074
+ * @example
1075
+ * View:
1076
+ * ```js
1077
+ * async function getZoomLevel() {
1078
+ * const view = await fin.View.getCurrent();
1079
+ * return await view.getZoomLevel();
1080
+ * }
1081
+ *
1082
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
1083
+ * ```
1084
+ *
1085
+ * Window:
1086
+ * ```js
1087
+ * async function createWin() {
1088
+ * const app = await fin.Application.start({
1089
+ * name: 'myApp',
1090
+ * uuid: 'app-1',
1091
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getZoomLevel.html',
1092
+ * autoShow: true
1093
+ * });
1094
+ * return await app.getWindow();
1095
+ * }
1096
+ *
1097
+ * async function getZoomLevel() {
1098
+ * const win = await createWin();
1099
+ * return await win.getZoomLevel();
1100
+ * }
1101
+ *
1102
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
1103
+ * ```
1104
+ * @remarks
1105
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1106
+ * We do not expose an explicit superclass for this functionality, but it does have its own
1107
+ * {@link OpenFin.WebContentsEvents event namespace}.
1108
+ */
1109
+ getZoomLevel() {
1110
+ return this.wire.sendAction('get-zoom-level', this.identity).then(({ payload }) => payload.data);
1177
1111
  }
1178
- catch (e) {
1179
- if (isDisconnectedError(e.message) && relayErrorMsg) {
1180
- throw new Error(relayErrorMsg);
1181
- }
1182
- throw e;
1112
+ /**
1113
+ * Sets the zoom level of the WebContents.
1114
+ * @param level The zoom level
1115
+ *
1116
+ * @example
1117
+ * View:
1118
+ * ```js
1119
+ * async function setZoomLevel(number) {
1120
+ * const view = await fin.View.getCurrent();
1121
+ * return await view.setZoomLevel(number);
1122
+ * }
1123
+ *
1124
+ * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
1125
+ * ```
1126
+ *
1127
+ * Window:
1128
+ * ```js
1129
+ * async function createWin() {
1130
+ * const app = await fin.Application.start({
1131
+ * name: 'myApp',
1132
+ * uuid: 'app-1',
1133
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.setZoomLevel.html',
1134
+ * autoShow: true
1135
+ * });
1136
+ * return await app.getWindow();
1137
+ * }
1138
+ *
1139
+ * async function setZoomLevel(number) {
1140
+ * const win = await createWin();
1141
+ * return await win.setZoomLevel(number);
1142
+ * }
1143
+ *
1144
+ * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
1145
+ * ```
1146
+ * @remarks
1147
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1148
+ * We do not expose an explicit superclass for this functionality, but it does have its own
1149
+ * {@link OpenFin.WebContentsEvents event namespace}.
1150
+ */
1151
+ setZoomLevel(level) {
1152
+ return this.wire.sendAction('set-zoom-level', { ...this.identity, level }).then(() => undefined);
1183
1153
  }
1184
- };
1185
- channelApiRelay.createRelayedDispatch = createRelayedDispatch;
1186
-
1187
- var __classPrivateFieldSet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
1188
- if (kind === "m") throw new TypeError("Private method is not writable");
1189
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
1190
- 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");
1191
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1192
- };
1193
- var __classPrivateFieldGet$d = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
1194
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1195
- 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");
1196
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1197
- };
1198
- var _LayoutNode_client, _TabStack_client, _ColumnOrRow_client;
1199
- Object.defineProperty(layoutEntities, "__esModule", { value: true });
1200
- layoutEntities.ColumnOrRow = layoutEntities.TabStack = layoutEntities.LayoutNode = void 0;
1201
- const api_exposer_1 = apiExposer$1;
1202
- const channel_api_relay_1 = channelApiRelay;
1203
- /*
1204
- This file includes LayoutNode, ColumnOrRow and TabStack classes, which are all closely
1205
- intertwined, and share members via parent abstract class LayoutNode. To prevent circular
1206
- refs, we define and export all the classes here.
1207
- */
1208
- /**
1209
- * @ignore
1210
- * @internal
1211
- * Supplies an ApiClient for {@link LayoutEntitiesController} and helper methods
1212
- * for the entities {@link TabStack} AND {@link ColumnOrRow} to use.
1213
- */
1214
- class LayoutNode {
1215
1154
  /**
1216
- * @internal
1217
- * @ignore
1218
- */
1219
- constructor(client, entityId) {
1220
- /**
1221
- * @ignore
1222
- * @internal
1223
- * ApiClient for {@link LayoutEntitiesController}
1224
- */
1225
- _LayoutNode_client.set(this, void 0);
1226
- /**
1227
- * Checks if the TabStack or ColumnOrRow is the root content item
1228
- *
1229
- * @example
1230
- * ```js
1231
- * if (!fin.me.isView) {
1232
- * throw new Error('Not running in a platform View.');
1233
- * }
1234
- *
1235
- * const stack = await fin.me.getCurrentStack();
1236
- * const isRoot = await stack.isRoot();
1237
- * // The TabStack is root: false
1238
- * console.log(`The TabStack is root: ${isRoot}`);
1239
- *
1240
- * // Retrieves the parent ColumnOrRow
1241
- * const parent = await stack.getParent();
1242
- * const parentIsRoot = await parent.isRoot();
1243
- * // The parent ColumnOrRow is root: true
1244
- * console.log(`The parent ColumnOrRow is root: ${parentIsRoot}`);
1245
- * ```
1246
- */
1247
- this.isRoot = () => __classPrivateFieldGet$d(this, _LayoutNode_client, "f").isRoot(this.entityId);
1248
- /**
1249
- * Checks if the TabStack or ColumnOrRow exists
1250
- *
1251
- * @example
1252
- * ```js
1253
- * if (!fin.me.isView) {
1254
- * throw new Error('Not running in a platform View.');
1255
- * }
1256
- *
1257
- * const stack = await fin.me.getCurrentStack();
1258
- * // Retrieves the parent ColumnOrRow
1259
- * const columnOrRow = await stack.getParent();
1260
- * let exists = await stack.exists();
1261
- * // or
1262
- * let exists = await columnOrRow.exists();
1263
- * // The entity exists: true
1264
- * console.log(`The entity exists: ${exists}`);
1265
- * ```
1266
- */
1267
- this.exists = () => __classPrivateFieldGet$d(this, _LayoutNode_client, "f").exists(this.entityId);
1268
- /**
1269
- * Retrieves the parent of the TabStack or ColumnOrRow
1270
- *
1271
- * @example
1272
- * ```js
1273
- * if (!fin.me.isView) {
1274
- * throw new Error('Not running in a platform View.');
1275
- * }
1276
- *
1277
- * const stack = await fin.me.getCurrentStack();
1278
- * // Retrieves the parent ColumnOrRow
1279
- * const columnOrRow = await stack.getParent();
1280
- *
1281
- * // undefined if entity is the root item
1282
- * let parent = await columnOrRow.getParent();
1283
- * // or
1284
- * let parent = await stack.getParent();
1285
- * ```
1286
- */
1287
- this.getParent = async () => {
1288
- const parent = await __classPrivateFieldGet$d(this, _LayoutNode_client, "f").getParent(this.entityId);
1289
- if (!parent) {
1290
- return undefined;
1291
- }
1292
- return LayoutNode.getEntity(parent, __classPrivateFieldGet$d(this, _LayoutNode_client, "f"));
1293
- };
1294
- /**
1295
- * Creates a new TabStack adjacent to the given TabStack or ColumnOrRow. Inputs can be new views to create, or existing views.
1296
- *
1297
- * Known Issue: If the number of views to add overflows the tab-container, the added views will be set as active
1298
- * during each render, and then placed at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
1299
- * This means the views you pass to createAdjacentStack() may not render in the order given by the array.
1300
- * Until fixed, this problem can be avoided only if your window is wide enough to fit creating all the views in the tabstack.
1301
- *
1302
- * @param views The views that will populate the new TabStack.
1303
- * @param options Additional options that control new TabStack creation.
1304
- * @returns The newly-created TabStack.
1305
- *
1306
- * @example
1307
- * ```js
1308
- * if (!fin.me.isView) {
1309
- * throw new Error('Not running in a platform View.');
1310
- * }
1311
- *
1312
- * const stack = await fin.me.getCurrentStack();
1313
- * const columnOrRow = await stack.getParent();
1314
- *
1315
- * // Create view references by supplying a 'name' and 'url'
1316
- * const views = [
1317
- * // if 'name' is undefined, one will be generated
1318
- * // if 'url' is undefined, it will default the view URL to 'about:blank'
1319
- * { name: 'google-view', url: 'http://google.com/'},
1320
- * { name: 'of-developers-view', url: 'http://developers.openfin.co/'},
1321
- * ];
1322
- *
1323
- * // Create a view beforehand to be included in the new tab stack
1324
- * const outsideView = await fin.View.create({
1325
- * name: 'outside-bloomberg-view',
1326
- * url: 'https://bloomberg.com/',
1327
- * target: fin.me.identity,
1328
- * });
1329
- *
1330
- * // Views to add can be identities, or the reference views mentioned above
1331
- * const viewsToAdd = [outsideView.identity, ...views];
1332
- *
1333
- * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
1334
- * let stackFrom = await columnOrRow.createAdjacentStack(viewsToAdd, { position: 'right' });
1335
- * // Or
1336
- * let newStack = await stack.createAdjacentStack(viewsToAdd, { position: 'right' });
1337
- * console.log(`A new TabStack created to the right has ${newStack.length} views in it`);
1338
- *
1339
- * ```
1340
- * @experimental
1341
- */
1342
- this.createAdjacentStack = async (views, options) => {
1343
- const entityId = await __classPrivateFieldGet$d(this, _LayoutNode_client, "f").createAdjacentStack(this.entityId, views, options);
1344
- return LayoutNode.getEntity({ entityId, type: 'stack' }, __classPrivateFieldGet$d(this, _LayoutNode_client, "f"));
1345
- };
1346
- /**
1347
- * Retrieves the adjacent TabStacks of the given TabStack or ColumnOrRow.
1348
- *
1349
- * @param edge Edge whose adjacent TabStacks will be returned.
1350
- *
1351
- * @example
1352
- * ```js
1353
- * if (!fin.me.isView) {
1354
- * throw new Error('Not running in a platform View.');
1355
- * }
1356
- *
1357
- * const stack = await fin.me.getCurrentStack();
1358
- * const columnOrRow = await stack.getParent();
1359
- * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
1360
- * let rightStacks = await columnOrRow.getAdjacentStacks('right');
1361
- * let leftStacks = await columnOrRow.getAdjacentStacks('left');
1362
- * // or
1363
- * let rightStacks = await stack.getAdjacentStacks('right');
1364
- * let leftStacks = await stack.getAdjacentStacks('left');
1365
- *
1366
- * console.log(`The entity has ${rightStacks.length} stacks to the right, and ${leftStacks.length} stacks to the left`);
1367
- *
1368
- * ```
1369
- * @experimental
1370
- */
1371
- this.getAdjacentStacks = async (edge) => {
1372
- const adjacentStacks = await __classPrivateFieldGet$d(this, _LayoutNode_client, "f").getAdjacentStacks({
1373
- targetId: this.entityId,
1374
- edge
1375
- });
1376
- return adjacentStacks.map((stack) => LayoutNode.getEntity({
1377
- type: 'stack',
1378
- entityId: stack.entityId
1379
- }, __classPrivateFieldGet$d(this, _LayoutNode_client, "f")));
1380
- };
1381
- __classPrivateFieldSet$b(this, _LayoutNode_client, client, "f");
1382
- this.entityId = entityId;
1383
- }
1384
- }
1385
- layoutEntities.LayoutNode = LayoutNode;
1386
- _LayoutNode_client = new WeakMap();
1387
- /**
1388
- * @ignore
1389
- * @internal
1390
- * Encapsulates Api consumption of {@link LayoutEntitiesClient} with a relayed dispatch
1391
- * @param client
1392
- * @param controllerId
1393
- * @param identity
1394
- * @returns a new instance of {@link LayoutEntitiesClient} with bound to the controllerId
1395
- */
1396
- LayoutNode.newLayoutEntitiesClient = async (client, controllerId, identity) => {
1397
- 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.');
1398
- const consumer = new api_exposer_1.ApiConsumer(new api_exposer_1.ChannelsConsumer({ dispatch }));
1399
- return consumer.consume({ id: controllerId });
1400
- };
1401
- LayoutNode.getEntity = (definition, client) => {
1402
- const { entityId, type } = definition;
1403
- switch (type) {
1404
- case 'column':
1405
- case 'row':
1406
- return new ColumnOrRow(client, entityId, type);
1407
- case 'stack':
1408
- return new TabStack(client, entityId);
1409
- default:
1410
- throw new Error(`Unrecognised Layout Entity encountered ('${JSON.stringify(definition)})`);
1411
- }
1412
- };
1413
- /**
1414
- * A TabStack is used to manage the state of a stack of tabs within an OpenFin Layout.
1415
- */
1416
- class TabStack extends LayoutNode {
1417
- /** @internal */
1418
- constructor(client, entityId) {
1419
- super(client, entityId);
1420
- /**
1421
- * @internal
1422
- * ApiClient for {@link LayoutEntitiesController}
1423
- */
1424
- _TabStack_client.set(this, void 0);
1425
- /**
1426
- * Type of the content item. Always stack, but useful for distinguishing between a {@link TabStack} and {@link ColumnOrRow}.
1427
- */
1428
- this.type = 'stack';
1429
- /**
1430
- * Retrieves a list of all views belonging to this {@link TabStack}.
1431
- *
1432
- * Known Issue: If adding a view overflows the tab-container width, the added view will be set as active
1433
- * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
1434
- * If that happens and then getViews() is called, it will return the identities in a different order than
1435
- * than the currently rendered tab order.
1436
- *
1437
- *
1438
- * @throws If the {@link TabStack} has been destroyed.
1439
- * @example
1440
- * ```js
1441
- * if (!fin.me.isView) {
1442
- * throw new Error('Not running in a platform View.');
1443
- * }
1444
- *
1445
- * const stack = await fin.me.getCurrentStack();
1446
- * // Alternatively, you can wrap any view and get the stack from there
1447
- * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
1448
- * // const stack = await viewFromSomewhere.getCurrentStack();
1449
- * const views = await stack.getViews();
1450
- * console.log(`Stack contains ${views.length} view(s)`);
1451
- * ```
1452
- * @experimental
1453
- */
1454
- this.getViews = () => __classPrivateFieldGet$d(this, _TabStack_client, "f").getStackViews(this.entityId);
1455
- /**
1456
- * Adds or creates a view in this {@link TabStack}.
1457
- *
1458
- * @remarks Known Issue: If adding a view overflows the tab-container, the added view will be set as active
1459
- * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
1460
- *
1461
- * @param view The identity of an existing view to add, or options to create a view.
1462
- * @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)
1463
- * @returns Resolves with the {@link OpenFin.Identity identity} of the added view.
1464
- * @throws If the view does not exist or fails to create.
1465
- * @throws If the {@link TabStack} has been destroyed.
1466
- * @example
1467
- * ```js
1468
- * if (!fin.me.isView) {
1469
- * throw new Error('Not running in a platform View.');
1470
- * }
1471
- *
1472
- * const stack = await fin.me.getCurrentStack();
1473
- * // Alternatively, you can wrap any view and get the stack from there
1474
- * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
1475
- * // const stack = await viewFromSomewhere.getCurrentStack();
1476
- * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
1477
- * console.log('Identity of the google view just added', { googleViewIdentity });
1478
- * // pass in { index: number } to set the index in the stack. Here 1 means, end of the stack (defaults to 0)
1479
- * const appleViewIdentity = await stack.addView({ name: 'apple-view', url: 'http://apple.com/' }, { index: 1 });
1480
- * console.log('Identity of the apple view just added', { appleViewIdentity });
1481
- * ```
1482
- * @experimental
1483
- */
1484
- this.addView = async (view, options = { index: 0 }) => __classPrivateFieldGet$d(this, _TabStack_client, "f").addViewToStack(this.entityId, view, options);
1485
- /**
1486
- * Removes a view from this {@link TabStack}.
1487
- *
1488
- * @remarks Throws an exception if the view identity does not exist or was already destroyed.
1489
- *
1490
- * @param view - Identity of the view to remove.
1491
- * @throws If the view does not exist or does not belong to the stack.
1492
- * @throws If the {@link TabStack} has been destroyed.
1493
- *
1494
- * @example
1495
- * ```js
1496
- * if (!fin.me.isView) {
1497
- * throw new Error('Not running in a platform View.');
1498
- * }
1499
- *
1500
- * const stack = await fin.me.getCurrentStack();
1501
- * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
1502
- *
1503
- * await stack.removeView(googleViewIdentity);
1504
- *
1505
- * try {
1506
- * await stack.removeView(googleViewIdentity);
1507
- * } catch (error) {
1508
- * // Tried to remove a view ('google-view') which does not belong to the stack.
1509
- * console.log(error);
1510
- * }
1511
- * ```
1512
- */
1513
- this.removeView = async (view) => {
1514
- await __classPrivateFieldGet$d(this, _TabStack_client, "f").removeViewFromStack(this.entityId, view);
1515
- };
1516
- /**
1517
- * Sets the active view of the {@link TabStack} without focusing it.
1518
- * @param view - Identity of the view to activate.
1519
- * @returns Promise which resolves with void once the view has been activated.
1520
- * @throws If the {@link TabStack} has been destroyed.
1521
- * @throws If the view does not exist.
1522
- * @example
1523
- * Change the active tab of a known View's TabStack:
1524
- * ```js
1525
- * const targetView = fin.View.wrapSync({ uuid: 'uuid', name: 'view-name' });
1526
- * const stack = await targetView.getCurrentStack();
1527
- * await stack.setActiveView(targetView.identity);
1528
- * ```
1529
- *
1530
- * Set the current View as active within its TabStack:
1531
- * ```js
1532
- * const stack = await fin.me.getCurrentStack();
1533
- * await stack.setActiveView(fin.me.identity);
1534
- * ```
1535
- * @experimental
1536
- */
1537
- this.setActiveView = async (view) => {
1538
- await __classPrivateFieldGet$d(this, _TabStack_client, "f").setStackActiveView(this.entityId, view);
1539
- };
1540
- __classPrivateFieldSet$b(this, _TabStack_client, client, "f");
1541
- }
1542
- }
1543
- layoutEntities.TabStack = TabStack;
1544
- _TabStack_client = new WeakMap();
1545
- /**
1546
- * A ColumnOrRow is used to manage the state of Column and Rows within an OpenFin Layout.
1547
- */
1548
- class ColumnOrRow extends LayoutNode {
1549
- /**
1550
- * @internal
1551
- */
1552
- constructor(client, entityId, type) {
1553
- super(client, entityId);
1554
- /**
1555
- * @ignore
1556
- * @internal
1557
- * ApiClient for {@link LayoutEntitiesController}
1558
- */
1559
- _ColumnOrRow_client.set(this, void 0);
1560
- /**
1561
- * Retrieves the content array of the ColumnOrRow
1562
- *
1563
- * @example
1564
- * ```js
1565
- * if (!fin.me.isView) {
1566
- * throw new Error('Not running in a platform View.');
1567
- * }
1568
- *
1569
- * const stack = await fin.me.getCurrentStack();
1570
- * // Retrieves the parent ColumnOrRow
1571
- * const columnOrRow = await stack.getParent();
1572
- *
1573
- * // returns [TabStack]
1574
- * const contentArray = await columnOrRow.getContent();
1575
- * console.log(`The ColumnOrRow has ${contentArray.length} item(s)`);
1576
- * ```
1577
- */
1578
- this.getContent = async () => {
1579
- const contentItemEntities = await __classPrivateFieldGet$d(this, _ColumnOrRow_client, "f").getContent(this.entityId);
1580
- return contentItemEntities.map((entity) => LayoutNode.getEntity(entity, __classPrivateFieldGet$d(this, _ColumnOrRow_client, "f")));
1581
- };
1582
- __classPrivateFieldSet$b(this, _ColumnOrRow_client, client, "f");
1583
- this.type = type;
1584
- }
1585
- }
1586
- layoutEntities.ColumnOrRow = ColumnOrRow;
1587
- _ColumnOrRow_client = new WeakMap();
1588
-
1589
- var layout_constants = {};
1590
-
1591
- Object.defineProperty(layout_constants, "__esModule", { value: true });
1592
- layout_constants.DEFAULT_LAYOUT_KEY = layout_constants.LAYOUT_CONTROLLER_ID = void 0;
1593
- layout_constants.LAYOUT_CONTROLLER_ID = 'layout-entities';
1594
- // TODO: eventually export this somehow
1595
- layout_constants.DEFAULT_LAYOUT_KEY = '__default__';
1596
-
1597
- var main = {};
1598
-
1599
- Object.defineProperty(main, "__esModule", { value: true });
1600
- main.WebContents = void 0;
1601
- const base_1$j = base;
1602
- class WebContents extends base_1$j.EmitterBase {
1603
- /**
1604
- * @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
1605
- * @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
1606
- */
1607
- constructor(wire, identity, entityType) {
1608
- super(wire, entityType, identity.uuid, identity.name);
1609
- this.identity = identity;
1610
- this.entityType = entityType;
1611
- }
1612
- /**
1613
- * Gets a base64 encoded image of all or part of the WebContents.
1614
- * @param options Options for the capturePage call.
1615
- *
1616
- * @example
1617
- *
1618
- * View:
1619
- * ```js
1620
- * const view = fin.View.getCurrentSync();
1621
- *
1622
- * // PNG image of a full visible View
1623
- * console.log(await view.capturePage());
1624
- *
1625
- * // Low-quality JPEG image of a defined visible area of the view
1626
- * const options = {
1627
- * area: {
1628
- * height: 100,
1629
- * width: 100,
1630
- * x: 10,
1631
- * y: 10,
1632
- * },
1633
- * format: 'jpg',
1634
- * quality: 20
1635
- * }
1636
- * console.log(await view.capturePage(options));
1637
- * ```
1638
- *
1639
- * Window:
1640
- * ```js
1641
- * const wnd = await fin.Window.getCurrent();
1642
- *
1643
- * // PNG image of a full visible window
1644
- * console.log(await wnd.capturePage());
1645
- *
1646
- * // Low-quality JPEG image of a defined visible area of the window
1647
- * const options = {
1648
- * area: {
1649
- * height: 100,
1650
- * width: 100,
1651
- * x: 10,
1652
- * y: 10,
1653
- * },
1654
- * format: 'jpg',
1655
- * quality: 20
1656
- * }
1657
- * console.log(await wnd.capturePage(options));
1658
- * ```
1659
- *
1660
- * @remarks
1661
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1662
- * We do not expose an explicit superclass for this functionality, but it does have its own
1663
- * {@link OpenFin.WebContentsEvents event namespace}.
1664
- */
1665
- capturePage(options) {
1666
- return this.wire.sendAction('capture-page', { options, ...this.identity }).then(({ payload }) => payload.data);
1667
- }
1668
- /**
1669
- * Executes Javascript on the WebContents, restricted to contents you own or contents owned by
1670
- * applications you have created.
1671
- * @param code JavaScript code to be executed on the view.
1672
- *
1673
- * @example
1674
- * View:
1675
- * ```js
1676
- * async function executeJavaScript(code) {
1677
- * const view = await fin.View.wrap({uuid: 'uuid', name: 'view name'});
1678
- * return await view.executeJavaScript(code);
1679
- * }
1680
- *
1681
- * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
1682
- * ```
1683
- *
1684
- * Window:
1685
- * ```js
1686
- * async function executeJavaScript(code) {
1687
- * const app = await fin.Application.start({
1688
- * name: 'myApp',
1689
- * uuid: 'app-1',
1690
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.executeJavaScript.html',
1691
- * autoShow: true
1692
- * });
1693
- * const win = await app.getWindow();
1694
- * return await win.executeJavaScript(code);
1695
- * }
1696
- *
1697
- * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
1698
- * ```
1699
- * @remarks
1700
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1701
- * We do not expose an explicit superclass for this functionality, but it does have its own
1702
- * {@link OpenFin.WebContentsEvents event namespace}.
1703
- */
1704
- executeJavaScript(code) {
1705
- return this.wire
1706
- .sendAction('execute-javascript-in-window', { ...this.identity, code })
1707
- .then(({ payload }) => payload.data);
1708
- }
1709
- /**
1710
- * Returns the zoom level of the WebContents.
1711
- *
1712
- * @example
1713
- * View:
1714
- * ```js
1715
- * async function getZoomLevel() {
1716
- * const view = await fin.View.getCurrent();
1717
- * return await view.getZoomLevel();
1718
- * }
1719
- *
1720
- * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
1721
- * ```
1722
- *
1723
- * Window:
1724
- * ```js
1725
- * async function createWin() {
1726
- * const app = await fin.Application.start({
1727
- * name: 'myApp',
1728
- * uuid: 'app-1',
1729
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getZoomLevel.html',
1730
- * autoShow: true
1731
- * });
1732
- * return await app.getWindow();
1733
- * }
1734
- *
1735
- * async function getZoomLevel() {
1736
- * const win = await createWin();
1737
- * return await win.getZoomLevel();
1738
- * }
1739
- *
1740
- * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
1741
- * ```
1742
- * @remarks
1743
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1744
- * We do not expose an explicit superclass for this functionality, but it does have its own
1745
- * {@link OpenFin.WebContentsEvents event namespace}.
1746
- */
1747
- getZoomLevel() {
1748
- return this.wire.sendAction('get-zoom-level', this.identity).then(({ payload }) => payload.data);
1749
- }
1750
- /**
1751
- * Sets the zoom level of the WebContents.
1752
- * @param level The zoom level
1753
- *
1754
- * @example
1755
- * View:
1756
- * ```js
1757
- * async function setZoomLevel(number) {
1758
- * const view = await fin.View.getCurrent();
1759
- * return await view.setZoomLevel(number);
1760
- * }
1761
- *
1762
- * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
1763
- * ```
1764
- *
1765
- * Window:
1766
- * ```js
1767
- * async function createWin() {
1768
- * const app = await fin.Application.start({
1769
- * name: 'myApp',
1770
- * uuid: 'app-1',
1771
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.setZoomLevel.html',
1772
- * autoShow: true
1773
- * });
1774
- * return await app.getWindow();
1775
- * }
1776
- *
1777
- * async function setZoomLevel(number) {
1778
- * const win = await createWin();
1779
- * return await win.setZoomLevel(number);
1780
- * }
1781
- *
1782
- * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
1783
- * ```
1784
- * @remarks
1785
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1786
- * We do not expose an explicit superclass for this functionality, but it does have its own
1787
- * {@link OpenFin.WebContentsEvents event namespace}.
1788
- */
1789
- setZoomLevel(level) {
1790
- return this.wire.sendAction('set-zoom-level', { ...this.identity, level }).then(() => undefined);
1791
- }
1792
- /**
1793
- * Navigates the WebContents to a specified URL.
1794
- *
1795
- * Note: The url must contain the protocol prefix such as http:// or https://.
1796
- * @param url - The URL to navigate the WebContents to.
1797
- *
1798
- * @example
1799
- * View:
1800
- * ```js
1801
- * async function createView() {
1802
- * const me = await fin.Window.getCurrent();
1803
- * return fin.View.create({
1804
- * name: 'viewName',
1805
- * target: me.identity,
1806
- * bounds: {top: 10, left: 10, width: 200, height: 200}
1807
- * });
1808
- * }
1809
- *
1810
- * createView()
1811
- * .then(view => view.navigate('https://example.com'))
1812
- * .then(() => console.log('navigation complete'))
1813
- * .catch(err => console.log(err));
1814
- * ```
1815
- *
1816
- * Window:
1817
- * ```js
1818
- * async function navigate() {
1819
- * const win = await fin.Window.getCurrent();
1820
- * return await win.navigate('https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.navigate.html');
1821
- * }
1822
- * navigate().then(() => console.log('Navigate to tutorial')).catch(err => console.log(err));
1823
- * ```
1824
- * @experimental
1825
- * @remarks
1826
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1827
- * We do not expose an explicit superclass for this functionality, but it does have its own
1828
- * {@link OpenFin.WebContentsEvents event namespace}.
1155
+ * Navigates the WebContents to a specified URL.
1156
+ *
1157
+ * Note: The url must contain the protocol prefix such as http:// or https://.
1158
+ * @param url - The URL to navigate the WebContents to.
1159
+ *
1160
+ * @example
1161
+ * View:
1162
+ * ```js
1163
+ * async function createView() {
1164
+ * const me = await fin.Window.getCurrent();
1165
+ * return fin.View.create({
1166
+ * name: 'viewName',
1167
+ * target: me.identity,
1168
+ * bounds: {top: 10, left: 10, width: 200, height: 200}
1169
+ * });
1170
+ * }
1171
+ *
1172
+ * createView()
1173
+ * .then(view => view.navigate('https://example.com'))
1174
+ * .then(() => console.log('navigation complete'))
1175
+ * .catch(err => console.log(err));
1176
+ * ```
1177
+ *
1178
+ * Window:
1179
+ * ```js
1180
+ * async function navigate() {
1181
+ * const win = await fin.Window.getCurrent();
1182
+ * return await win.navigate('https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.navigate.html');
1183
+ * }
1184
+ * navigate().then(() => console.log('Navigate to tutorial')).catch(err => console.log(err));
1185
+ * ```
1186
+ * @experimental
1187
+ * @remarks
1188
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1189
+ * We do not expose an explicit superclass for this functionality, but it does have its own
1190
+ * {@link OpenFin.WebContentsEvents event namespace}.
1829
1191
  */
1830
1192
  navigate(url) {
1831
1193
  return this.wire.sendAction('navigate-window', { ...this.identity, url }).then(() => undefined);
@@ -2670,18 +2032,11 @@ var hasRequiredInstance$2;
2670
2032
  function requireInstance$2 () {
2671
2033
  if (hasRequiredInstance$2) return Instance$5;
2672
2034
  hasRequiredInstance$2 = 1;
2673
- var __classPrivateFieldGet = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2674
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2675
- 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");
2676
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2677
- };
2678
2035
  var _View_providerChannelClient;
2679
2036
  Object.defineProperty(Instance$5, "__esModule", { value: true });
2680
2037
  Instance$5.View = void 0;
2681
2038
  const transport_errors_1 = transportErrors;
2682
2039
  const lazy_1 = lazy;
2683
- const layout_entities_1 = layoutEntities;
2684
- const layout_constants_1 = layout_constants;
2685
2040
  const main_1 = main;
2686
2041
  const window_1 = requireWindow();
2687
2042
  /**
@@ -2999,7 +2354,7 @@ function requireInstance$2 () {
2999
2354
  return ack.payload.data;
3000
2355
  };
3001
2356
  /**
3002
- * Retrieves the layout for the window the view is attached to.
2357
+ * Retrieves the OpenFin.Layout instance for the Window the View is attached to.
3003
2358
  *
3004
2359
  * @example
3005
2360
  * ```js
@@ -3015,29 +2370,7 @@ function requireInstance$2 () {
3015
2370
  this.wire.sendAction('view-get-parent-layout', { ...this.identity }).catch(() => {
3016
2371
  // don't expose
3017
2372
  });
3018
- const layoutWindow = await this.getCurrentWindow();
3019
- let layoutWindowIdentity = layoutWindow.identity;
3020
- // TODO: CORE-1857 - when we tearout active layout or drag a view out of a window, the above identity includes the whole window info.
3021
- if (layoutWindowIdentity.identity) {
3022
- layoutWindowIdentity = layoutWindowIdentity.identity;
3023
- }
3024
- try {
3025
- const providerChannelClient = await __classPrivateFieldGet(this, _View_providerChannelClient, "f").getValue();
3026
- const client = await layout_entities_1.LayoutNode.newLayoutEntitiesClient(providerChannelClient, layout_constants_1.LAYOUT_CONTROLLER_ID, layoutWindowIdentity);
3027
- const layoutIdentity = await client.getLayoutIdentityForViewOrThrow(this.identity);
3028
- return this.fin.Platform.Layout.wrap(layoutIdentity);
3029
- }
3030
- catch (e) {
3031
- const allowedErrors = [
3032
- 'No action registered at target for',
3033
- 'getLayoutIdentityForViewOrThrow is not a function'
3034
- ];
3035
- if (!allowedErrors.some((m) => e.message.includes(m))) {
3036
- throw e;
3037
- }
3038
- // fallback logic for missing endpoint
3039
- return this.fin.Platform.Layout.wrap(layoutWindowIdentity);
3040
- }
2373
+ return this.fin.Platform.Layout.getLayoutByViewIdentity(this.identity);
3041
2374
  };
3042
2375
  /**
3043
2376
  * Gets the View's options.
@@ -3153,11 +2486,8 @@ function requireInstance$2 () {
3153
2486
  // don't expose
3154
2487
  });
3155
2488
  try {
3156
- const layoutWindow = await this.getCurrentWindow();
3157
- const providerChannelClient = await __classPrivateFieldGet(this, _View_providerChannelClient, "f").getValue();
3158
- const client = await layout_entities_1.LayoutNode.newLayoutEntitiesClient(providerChannelClient, layout_constants_1.LAYOUT_CONTROLLER_ID, layoutWindow.identity);
3159
- const stackDefinition = (await client.getStackByView(this.identity));
3160
- return layout_entities_1.LayoutNode.getEntity(stackDefinition, client);
2489
+ const layout = await this.getParentLayout();
2490
+ return layout.getStackByViewIdentity(this.identity);
3161
2491
  }
3162
2492
  catch (error) {
3163
2493
  throw new transport_errors_1.RuntimeError({ reason: 'This view does not belong to a stack.', error });
@@ -8169,12 +7499,12 @@ class ChannelBase {
8169
7499
  }
8170
7500
  channel.ChannelBase = ChannelBase;
8171
7501
 
8172
- var __classPrivateFieldGet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
7502
+ var __classPrivateFieldGet$d = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8173
7503
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
8174
7504
  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");
8175
7505
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
8176
7506
  };
8177
- var __classPrivateFieldSet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7507
+ var __classPrivateFieldSet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8178
7508
  if (kind === "m") throw new TypeError("Private method is not writable");
8179
7509
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8180
7510
  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");
@@ -8216,7 +7546,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
8216
7546
  static closeChannelByEndpointId(id) {
8217
7547
  const channel = channelClientsByEndpointId.get(id);
8218
7548
  if (channel) {
8219
- __classPrivateFieldGet$c(channel, _ChannelClient_close, "f").call(channel);
7549
+ __classPrivateFieldGet$d(channel, _ChannelClient_close, "f").call(channel);
8220
7550
  }
8221
7551
  }
8222
7552
  /**
@@ -8227,7 +7557,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
8227
7557
  for (const channelClient of channelClientsByEndpointId.values()) {
8228
7558
  if (channelClient.providerIdentity.channelId === eventPayload.channelId) {
8229
7559
  channelClient.disconnectListener(eventPayload);
8230
- __classPrivateFieldGet$c(channelClient, _ChannelClient_close, "f").call(channelClient);
7560
+ __classPrivateFieldGet$d(channelClient, _ChannelClient_close, "f").call(channelClient);
8231
7561
  }
8232
7562
  }
8233
7563
  }
@@ -8242,12 +7572,12 @@ class ChannelClient extends channel_1$1.ChannelBase {
8242
7572
  this.processAction = (action, payload, senderIdentity) => super.processAction(action, payload, senderIdentity);
8243
7573
  _ChannelClient_close.set(this, () => {
8244
7574
  channelClientsByEndpointId.delete(this.endpointId);
8245
- __classPrivateFieldGet$c(this, _ChannelClient_strategy, "f").close();
7575
+ __classPrivateFieldGet$d(this, _ChannelClient_strategy, "f").close();
8246
7576
  });
8247
- __classPrivateFieldSet$a(this, _ChannelClient_protectedObj, new channel_1$1.ProtectedItems(routingInfo, close), "f");
7577
+ __classPrivateFieldSet$b(this, _ChannelClient_protectedObj, new channel_1$1.ProtectedItems(routingInfo, close), "f");
8248
7578
  this.disconnectListener = () => undefined;
8249
7579
  this.endpointId = routingInfo.endpointId;
8250
- __classPrivateFieldSet$a(this, _ChannelClient_strategy, strategy, "f");
7580
+ __classPrivateFieldSet$b(this, _ChannelClient_strategy, strategy, "f");
8251
7581
  channelClientsByEndpointId.set(this.endpointId, this);
8252
7582
  strategy.receive(this.processAction);
8253
7583
  }
@@ -8255,7 +7585,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
8255
7585
  * a read-only provider identity
8256
7586
  */
8257
7587
  get providerIdentity() {
8258
- const protectedObj = __classPrivateFieldGet$c(this, _ChannelClient_protectedObj, "f");
7588
+ const protectedObj = __classPrivateFieldGet$d(this, _ChannelClient_protectedObj, "f");
8259
7589
  return protectedObj.providerIdentity;
8260
7590
  }
8261
7591
  /**
@@ -8284,8 +7614,8 @@ class ChannelClient extends channel_1$1.ChannelBase {
8284
7614
  * ```
8285
7615
  */
8286
7616
  async dispatch(action, payload) {
8287
- if (__classPrivateFieldGet$c(this, _ChannelClient_strategy, "f").isEndpointConnected(this.providerIdentity.channelId)) {
8288
- return __classPrivateFieldGet$c(this, _ChannelClient_strategy, "f").send(this.providerIdentity.channelId, action, payload);
7617
+ if (__classPrivateFieldGet$d(this, _ChannelClient_strategy, "f").isEndpointConnected(this.providerIdentity.channelId)) {
7618
+ return __classPrivateFieldGet$d(this, _ChannelClient_strategy, "f").send(this.providerIdentity.channelId, action, payload);
8289
7619
  }
8290
7620
  throw new Error('The client you are trying to dispatch from is disconnected from the target provider.');
8291
7621
  }
@@ -8335,10 +7665,10 @@ class ChannelClient extends channel_1$1.ChannelBase {
8335
7665
  */
8336
7666
  async disconnect() {
8337
7667
  await this.sendDisconnectAction();
8338
- __classPrivateFieldGet$c(this, _ChannelClient_close, "f").call(this);
7668
+ __classPrivateFieldGet$d(this, _ChannelClient_close, "f").call(this);
8339
7669
  }
8340
7670
  async sendDisconnectAction() {
8341
- const protectedObj = __classPrivateFieldGet$c(this, _ChannelClient_protectedObj, "f");
7671
+ const protectedObj = __classPrivateFieldGet$d(this, _ChannelClient_protectedObj, "f");
8342
7672
  await protectedObj.close();
8343
7673
  }
8344
7674
  /**
@@ -8371,13 +7701,13 @@ exhaustive.exhaustiveCheck = exhaustiveCheck;
8371
7701
 
8372
7702
  var strategy$3 = {};
8373
7703
 
8374
- var __classPrivateFieldSet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7704
+ var __classPrivateFieldSet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8375
7705
  if (kind === "m") throw new TypeError("Private method is not writable");
8376
7706
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8377
7707
  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");
8378
7708
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
8379
7709
  };
8380
- var __classPrivateFieldGet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
7710
+ var __classPrivateFieldGet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8381
7711
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
8382
7712
  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");
8383
7713
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -8402,7 +7732,7 @@ class ClassicStrategy {
8402
7732
  // connection problems occur
8403
7733
  _ClassicStrategy_pendingMessagesByEndpointId.set(this, new Map);
8404
7734
  this.send = async (endpointId, action, payload) => {
8405
- const to = __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
7735
+ const to = __classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
8406
7736
  if (!to) {
8407
7737
  throw new Error(`Could not locate routing info for endpoint ${endpointId}`);
8408
7738
  }
@@ -8414,28 +7744,28 @@ class ClassicStrategy {
8414
7744
  }
8415
7745
  delete cleanId.isLocalEndpointId;
8416
7746
  // grab the promise before awaiting it to save in our pending messages map
8417
- const p = __classPrivateFieldGet$b(this, _ClassicStrategy_wire, "f")
7747
+ const p = __classPrivateFieldGet$c(this, _ClassicStrategy_wire, "f")
8418
7748
  .sendAction('send-channel-message', {
8419
7749
  ...cleanId,
8420
7750
  providerIdentity: this.providerIdentity,
8421
7751
  action,
8422
7752
  payload
8423
7753
  });
8424
- __classPrivateFieldGet$b(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.add(p);
7754
+ __classPrivateFieldGet$c(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.add(p);
8425
7755
  const raw = await p.catch((error) => {
8426
7756
  throw new Error(error.message);
8427
7757
  }).finally(() => {
8428
7758
  // clean up the pending promise
8429
- __classPrivateFieldGet$b(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.delete(p);
7759
+ __classPrivateFieldGet$c(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.delete(p);
8430
7760
  });
8431
7761
  return raw.payload.data.result;
8432
7762
  };
8433
7763
  this.close = async () => {
8434
7764
  this.messageReceiver.removeEndpoint(this.providerIdentity.channelId, this.endpointId);
8435
- [...__classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").keys()].forEach((id) => this.closeEndpoint(id));
8436
- __classPrivateFieldSet$9(this, _ClassicStrategy_endpointIdentityMap, new Map(), "f");
7765
+ [...__classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").keys()].forEach((id) => this.closeEndpoint(id));
7766
+ __classPrivateFieldSet$a(this, _ClassicStrategy_endpointIdentityMap, new Map(), "f");
8437
7767
  };
8438
- __classPrivateFieldSet$9(this, _ClassicStrategy_wire, wire, "f");
7768
+ __classPrivateFieldSet$a(this, _ClassicStrategy_wire, wire, "f");
8439
7769
  }
8440
7770
  onEndpointDisconnect(endpointId, listener) {
8441
7771
  // Never fires for 'classic'.
@@ -8444,20 +7774,20 @@ class ClassicStrategy {
8444
7774
  this.messageReceiver.addEndpoint(listener, this.providerIdentity.channelId, this.endpointId);
8445
7775
  }
8446
7776
  async closeEndpoint(endpointId) {
8447
- const id = __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
8448
- __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").delete(endpointId);
8449
- const pendingSet = __classPrivateFieldGet$b(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId);
7777
+ const id = __classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
7778
+ __classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").delete(endpointId);
7779
+ const pendingSet = __classPrivateFieldGet$c(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId);
8450
7780
  pendingSet?.forEach((p) => {
8451
7781
  const errorMsg = `Channel connection with identity uuid: ${id?.uuid} / name: ${id?.name} / endpointId: ${endpointId} no longer connected.`;
8452
7782
  p.cancel(new Error(errorMsg));
8453
7783
  });
8454
7784
  }
8455
7785
  isEndpointConnected(endpointId) {
8456
- return __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").has(endpointId);
7786
+ return __classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").has(endpointId);
8457
7787
  }
8458
7788
  addEndpoint(endpointId, payload) {
8459
- __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").set(endpointId, payload.endpointIdentity);
8460
- __classPrivateFieldGet$b(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").set(endpointId, new Set());
7789
+ __classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").set(endpointId, payload.endpointIdentity);
7790
+ __classPrivateFieldGet$c(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").set(endpointId, new Set());
8461
7791
  }
8462
7792
  isValidEndpointPayload(payload) {
8463
7793
  return (typeof payload?.endpointIdentity?.endpointId === 'string' ||
@@ -8488,12 +7818,12 @@ function errorToPOJO(error) {
8488
7818
  }
8489
7819
  errors.errorToPOJO = errorToPOJO;
8490
7820
 
8491
- var __classPrivateFieldGet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
7821
+ var __classPrivateFieldGet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8492
7822
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
8493
7823
  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");
8494
7824
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
8495
7825
  };
8496
- var __classPrivateFieldSet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7826
+ var __classPrivateFieldSet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8497
7827
  if (kind === "m") throw new TypeError("Private method is not writable");
8498
7828
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8499
7829
  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");
@@ -8528,8 +7858,8 @@ class RTCEndpoint {
8528
7858
  if (this.rtc.rtcClient.connectionState !== 'connected') {
8529
7859
  this.rtc.rtcClient.removeEventListener('connectionstatechange', this.connectionStateChangeHandler);
8530
7860
  this.close();
8531
- if (__classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f")) {
8532
- __classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f").call(this);
7861
+ if (__classPrivateFieldGet$b(this, _RTCEndpoint_disconnectListener, "f")) {
7862
+ __classPrivateFieldGet$b(this, _RTCEndpoint_disconnectListener, "f").call(this);
8533
7863
  }
8534
7864
  }
8535
7865
  };
@@ -8577,9 +7907,9 @@ class RTCEndpoint {
8577
7907
  data = new TextDecoder().decode(e.data);
8578
7908
  }
8579
7909
  const { messageId, action, payload } = JSON.parse(data);
8580
- if (__classPrivateFieldGet$a(this, _RTCEndpoint_processAction, "f")) {
7910
+ if (__classPrivateFieldGet$b(this, _RTCEndpoint_processAction, "f")) {
8581
7911
  try {
8582
- const res = await __classPrivateFieldGet$a(this, _RTCEndpoint_processAction, "f").call(this, action, payload, endpointIdentity);
7912
+ const res = await __classPrivateFieldGet$b(this, _RTCEndpoint_processAction, "f").call(this, action, payload, endpointIdentity);
8583
7913
  this.rtc.channels.response.send(JSON.stringify({
8584
7914
  messageId,
8585
7915
  payload: res,
@@ -8613,25 +7943,25 @@ class RTCEndpoint {
8613
7943
  datachannel.onclose = (e) => {
8614
7944
  [...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.')));
8615
7945
  this.close();
8616
- if (__classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f")) {
8617
- __classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f").call(this);
7946
+ if (__classPrivateFieldGet$b(this, _RTCEndpoint_disconnectListener, "f")) {
7947
+ __classPrivateFieldGet$b(this, _RTCEndpoint_disconnectListener, "f").call(this);
8618
7948
  }
8619
7949
  };
8620
7950
  });
8621
7951
  }
8622
7952
  onDisconnect(listener) {
8623
- if (!__classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f")) {
8624
- __classPrivateFieldSet$8(this, _RTCEndpoint_disconnectListener, listener, "f");
7953
+ if (!__classPrivateFieldGet$b(this, _RTCEndpoint_disconnectListener, "f")) {
7954
+ __classPrivateFieldSet$9(this, _RTCEndpoint_disconnectListener, listener, "f");
8625
7955
  }
8626
7956
  else {
8627
7957
  throw new Error('RTCEndpoint disconnectListener cannot be set twice.');
8628
7958
  }
8629
7959
  }
8630
7960
  receive(listener) {
8631
- if (__classPrivateFieldGet$a(this, _RTCEndpoint_processAction, "f")) {
7961
+ if (__classPrivateFieldGet$b(this, _RTCEndpoint_processAction, "f")) {
8632
7962
  throw new Error('You have already set a listener for this RTC Endpoint.');
8633
7963
  }
8634
- __classPrivateFieldSet$8(this, _RTCEndpoint_processAction, listener, "f");
7964
+ __classPrivateFieldSet$9(this, _RTCEndpoint_processAction, listener, "f");
8635
7965
  }
8636
7966
  get connected() {
8637
7967
  return this.rtc.rtcClient.connectionState === 'connected';
@@ -8642,12 +7972,12 @@ _RTCEndpoint_processAction = new WeakMap(), _RTCEndpoint_disconnectListener = ne
8642
7972
 
8643
7973
  var strategy$1 = {};
8644
7974
 
8645
- var __classPrivateFieldGet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
7975
+ var __classPrivateFieldGet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8646
7976
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
8647
7977
  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");
8648
7978
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
8649
7979
  };
8650
- var __classPrivateFieldSet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7980
+ var __classPrivateFieldSet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8651
7981
  if (kind === "m") throw new TypeError("Private method is not writable");
8652
7982
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8653
7983
  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");
@@ -8668,11 +7998,11 @@ class EndpointStrategy {
8668
7998
  return this.getEndpointById(endpointId).send(action, payload);
8669
7999
  };
8670
8000
  this.close = async () => {
8671
- if (__classPrivateFieldGet$9(this, _EndpointStrategy_connected, "f")) {
8672
- __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.close());
8673
- __classPrivateFieldSet$7(this, _EndpointStrategy_endpointMap, new Map(), "f");
8001
+ if (__classPrivateFieldGet$a(this, _EndpointStrategy_connected, "f")) {
8002
+ __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.close());
8003
+ __classPrivateFieldSet$8(this, _EndpointStrategy_endpointMap, new Map(), "f");
8674
8004
  }
8675
- __classPrivateFieldSet$7(this, _EndpointStrategy_connected, false, "f");
8005
+ __classPrivateFieldSet$8(this, _EndpointStrategy_connected, false, "f");
8676
8006
  };
8677
8007
  this.isValidEndpointPayload = validateEndpoint;
8678
8008
  }
@@ -8680,39 +8010,39 @@ class EndpointStrategy {
8680
8010
  this.getEndpointById(endpointId).onDisconnect(listener);
8681
8011
  }
8682
8012
  receive(listener) {
8683
- if (__classPrivateFieldGet$9(this, _EndpointStrategy_processAction, "f")) {
8013
+ if (__classPrivateFieldGet$a(this, _EndpointStrategy_processAction, "f")) {
8684
8014
  throw new Error(`You have already set a listener for this ${this.StrategyName} Strategy`);
8685
8015
  }
8686
- __classPrivateFieldSet$7(this, _EndpointStrategy_processAction, listener, "f");
8016
+ __classPrivateFieldSet$8(this, _EndpointStrategy_processAction, listener, "f");
8687
8017
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
8688
- __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.receive(__classPrivateFieldGet$9(this, _EndpointStrategy_processAction, "f")));
8018
+ __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.receive(__classPrivateFieldGet$a(this, _EndpointStrategy_processAction, "f")));
8689
8019
  }
8690
8020
  getEndpointById(endpointId) {
8691
- const endpoint = __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").get(endpointId);
8021
+ const endpoint = __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").get(endpointId);
8692
8022
  if (!endpoint) {
8693
8023
  throw new Error(`Client with endpoint id ${endpointId} is not connected`);
8694
8024
  }
8695
8025
  return endpoint;
8696
8026
  }
8697
8027
  get connected() {
8698
- return __classPrivateFieldGet$9(this, _EndpointStrategy_connected, "f");
8028
+ return __classPrivateFieldGet$a(this, _EndpointStrategy_connected, "f");
8699
8029
  }
8700
8030
  isEndpointConnected(endpointId) {
8701
- return __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").has(endpointId);
8031
+ return __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").has(endpointId);
8702
8032
  }
8703
8033
  addEndpoint(endpointId, payload) {
8704
- if (!__classPrivateFieldGet$9(this, _EndpointStrategy_connected, "f")) {
8034
+ if (!__classPrivateFieldGet$a(this, _EndpointStrategy_connected, "f")) {
8705
8035
  console.warn(`Adding endpoint to disconnected ${this.StrategyName} Strategy`);
8706
8036
  return;
8707
8037
  }
8708
8038
  const clientStrat = new this.EndpointType(payload);
8709
- if (__classPrivateFieldGet$9(this, _EndpointStrategy_processAction, "f")) {
8710
- clientStrat.receive(__classPrivateFieldGet$9(this, _EndpointStrategy_processAction, "f"));
8039
+ if (__classPrivateFieldGet$a(this, _EndpointStrategy_processAction, "f")) {
8040
+ clientStrat.receive(__classPrivateFieldGet$a(this, _EndpointStrategy_processAction, "f"));
8711
8041
  }
8712
- __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").set(endpointId, clientStrat);
8042
+ __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").set(endpointId, clientStrat);
8713
8043
  }
8714
8044
  async closeEndpoint(endpointId) {
8715
- __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").delete(endpointId);
8045
+ __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").delete(endpointId);
8716
8046
  }
8717
8047
  }
8718
8048
  strategy$1.EndpointStrategy = EndpointStrategy;
@@ -8894,12 +8224,12 @@ function runtimeUuidMeetsMinimumRuntimeVersion(runtimeUuid, minVersion) {
8894
8224
  }
8895
8225
  runtimeVersioning.runtimeUuidMeetsMinimumRuntimeVersion = runtimeUuidMeetsMinimumRuntimeVersion;
8896
8226
 
8897
- var __classPrivateFieldGet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8227
+ var __classPrivateFieldGet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8898
8228
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
8899
8229
  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");
8900
8230
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
8901
8231
  };
8902
- var __classPrivateFieldSet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8232
+ var __classPrivateFieldSet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8903
8233
  if (kind === "m") throw new TypeError("Private method is not writable");
8904
8234
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8905
8235
  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");
@@ -8941,18 +8271,18 @@ class ChannelProvider extends channel_1.ChannelBase {
8941
8271
  * a read-only array containing all the identities of connecting clients.
8942
8272
  */
8943
8273
  get connections() {
8944
- return [...__classPrivateFieldGet$8(this, _ChannelProvider_connections, "f")];
8274
+ return [...__classPrivateFieldGet$9(this, _ChannelProvider_connections, "f")];
8945
8275
  }
8946
8276
  static handleClientDisconnection(channel, payload) {
8947
8277
  const removeById = channel.connections.find((identity) => identity.endpointId === payload.endpointId);
8948
8278
  if (removeById) {
8949
- __classPrivateFieldGet$8(channel, _ChannelProvider_removeEndpoint, "f").call(channel, removeById);
8279
+ __classPrivateFieldGet$9(channel, _ChannelProvider_removeEndpoint, "f").call(channel, removeById);
8950
8280
  }
8951
8281
  else {
8952
8282
  const multipleRemoves = channel.connections.filter((identity) => {
8953
8283
  return identity.uuid === payload.uuid && identity.name === payload.name;
8954
8284
  });
8955
- multipleRemoves.forEach(__classPrivateFieldGet$8(channel, _ChannelProvider_removeEndpoint, "f"));
8285
+ multipleRemoves.forEach(__classPrivateFieldGet$9(channel, _ChannelProvider_removeEndpoint, "f"));
8956
8286
  }
8957
8287
  channel.disconnectListener(payload);
8958
8288
  }
@@ -8969,8 +8299,8 @@ class ChannelProvider extends channel_1.ChannelBase {
8969
8299
  _ChannelProvider_strategy.set(this, void 0);
8970
8300
  _ChannelProvider_removeEndpoint.set(this, (identity) => {
8971
8301
  const remainingConnections = this.connections.filter((clientIdentity) => clientIdentity.endpointId !== identity.endpointId);
8972
- __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").closeEndpoint(identity.endpointId);
8973
- __classPrivateFieldSet$6(this, _ChannelProvider_connections, remainingConnections, "f");
8302
+ __classPrivateFieldGet$9(this, _ChannelProvider_strategy, "f").closeEndpoint(identity.endpointId);
8303
+ __classPrivateFieldSet$7(this, _ChannelProvider_connections, remainingConnections, "f");
8974
8304
  });
8975
8305
  // Must be bound.
8976
8306
  this.processAction = async (action, payload, senderIdentity) => {
@@ -8984,17 +8314,17 @@ class ChannelProvider extends channel_1.ChannelBase {
8984
8314
  return super.processAction(action, payload, senderIdentity);
8985
8315
  };
8986
8316
  _ChannelProvider_close.set(this, () => {
8987
- __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").close();
8317
+ __classPrivateFieldGet$9(this, _ChannelProvider_strategy, "f").close();
8988
8318
  const remove = ChannelProvider.removalMap.get(this);
8989
8319
  if (remove) {
8990
8320
  remove();
8991
8321
  }
8992
8322
  });
8993
- __classPrivateFieldSet$6(this, _ChannelProvider_protectedObj, new channel_1.ProtectedItems(providerIdentity, close), "f");
8323
+ __classPrivateFieldSet$7(this, _ChannelProvider_protectedObj, new channel_1.ProtectedItems(providerIdentity, close), "f");
8994
8324
  this.connectListener = () => undefined;
8995
8325
  this.disconnectListener = () => undefined;
8996
- __classPrivateFieldSet$6(this, _ChannelProvider_connections, [], "f");
8997
- __classPrivateFieldSet$6(this, _ChannelProvider_strategy, strategy, "f");
8326
+ __classPrivateFieldSet$7(this, _ChannelProvider_connections, [], "f");
8327
+ __classPrivateFieldSet$7(this, _ChannelProvider_strategy, strategy, "f");
8998
8328
  strategy.receive(this.processAction);
8999
8329
  }
9000
8330
  /**
@@ -9025,13 +8355,13 @@ class ChannelProvider extends channel_1.ChannelBase {
9025
8355
  */
9026
8356
  dispatch(to, action, payload) {
9027
8357
  const endpointId = to.endpointId ?? this.getEndpointIdForOpenFinId(to, action);
9028
- if (endpointId && __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").isEndpointConnected(endpointId)) {
9029
- return __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").send(endpointId, action, payload);
8358
+ if (endpointId && __classPrivateFieldGet$9(this, _ChannelProvider_strategy, "f").isEndpointConnected(endpointId)) {
8359
+ return __classPrivateFieldGet$9(this, _ChannelProvider_strategy, "f").send(endpointId, action, payload);
9030
8360
  }
9031
8361
  return Promise.reject(new Error(`Client connection with identity uuid: ${to.uuid} / name: ${to.name} / endpointId: ${endpointId} no longer connected.`));
9032
8362
  }
9033
8363
  async processConnection(senderId, payload) {
9034
- __classPrivateFieldGet$8(this, _ChannelProvider_connections, "f").push(senderId);
8364
+ __classPrivateFieldGet$9(this, _ChannelProvider_connections, "f").push(senderId);
9035
8365
  return this.connectListener(senderId, payload);
9036
8366
  }
9037
8367
  /**
@@ -9054,7 +8384,7 @@ class ChannelProvider extends channel_1.ChannelBase {
9054
8384
  * ```
9055
8385
  */
9056
8386
  publish(action, payload) {
9057
- return this.connections.map((to) => __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").send(to.endpointId, action, payload));
8387
+ return this.connections.map((to) => __classPrivateFieldGet$9(this, _ChannelProvider_strategy, "f").send(to.endpointId, action, payload));
9058
8388
  }
9059
8389
  /**
9060
8390
  * Register a listener that is called on every new client connection.
@@ -9128,11 +8458,11 @@ class ChannelProvider extends channel_1.ChannelBase {
9128
8458
  * ```
9129
8459
  */
9130
8460
  async destroy() {
9131
- const protectedObj = __classPrivateFieldGet$8(this, _ChannelProvider_protectedObj, "f");
8461
+ const protectedObj = __classPrivateFieldGet$9(this, _ChannelProvider_protectedObj, "f");
9132
8462
  protectedObj.providerIdentity;
9133
- __classPrivateFieldSet$6(this, _ChannelProvider_connections, [], "f");
8463
+ __classPrivateFieldSet$7(this, _ChannelProvider_connections, [], "f");
9134
8464
  await protectedObj.close();
9135
- __classPrivateFieldGet$8(this, _ChannelProvider_close, "f").call(this);
8465
+ __classPrivateFieldGet$9(this, _ChannelProvider_close, "f").call(this);
9136
8466
  }
9137
8467
  /**
9138
8468
  * Returns an array with info on every Client connected to the Provider
@@ -9202,7 +8532,7 @@ class ChannelProvider extends channel_1.ChannelBase {
9202
8532
  getEndpointIdForOpenFinId(clientIdentity, action) {
9203
8533
  const matchingConnections = this.connections.filter((c) => c.name === clientIdentity.name && c.uuid === clientIdentity.uuid);
9204
8534
  if (matchingConnections.length >= 2) {
9205
- const protectedObj = __classPrivateFieldGet$8(this, _ChannelProvider_protectedObj, "f");
8535
+ const protectedObj = __classPrivateFieldGet$9(this, _ChannelProvider_protectedObj, "f");
9206
8536
  const { uuid, name } = clientIdentity;
9207
8537
  const providerUuid = protectedObj?.providerIdentity.uuid;
9208
8538
  const providerName = protectedObj?.providerIdentity.name;
@@ -9411,17 +8741,20 @@ class CombinedStrategy {
9411
8741
  }
9412
8742
  strategy.default = CombinedStrategy;
9413
8743
 
9414
- var __classPrivateFieldSet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8744
+ var __classPrivateFieldSet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
9415
8745
  if (kind === "m") throw new TypeError("Private method is not writable");
9416
8746
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9417
8747
  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");
9418
8748
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
9419
8749
  };
9420
- var __classPrivateFieldGet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8750
+ var __classPrivateFieldGet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9421
8751
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9422
8752
  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");
9423
8753
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
9424
8754
  };
8755
+ var __importDefault$1 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
8756
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8757
+ };
9425
8758
  var _ConnectionManager_messageReceiver, _ConnectionManager_rtcConnectionManager;
9426
8759
  Object.defineProperty(connectionManager, "__esModule", { value: true });
9427
8760
  connectionManager.ConnectionManager = void 0;
@@ -9433,7 +8766,7 @@ const ice_manager_1 = iceManager;
9433
8766
  const provider_1$1 = provider;
9434
8767
  const message_receiver_1 = messageReceiver;
9435
8768
  const protocol_manager_1 = protocolManager;
9436
- const strategy_3 = strategy;
8769
+ const strategy_3 = __importDefault$1(strategy);
9437
8770
  class ConnectionManager extends base_1$f.Base {
9438
8771
  static getProtocolOptionsFromStrings(protocols) {
9439
8772
  return protocols.map((protocol) => {
@@ -9463,8 +8796,8 @@ class ConnectionManager extends base_1$f.Base {
9463
8796
  };
9464
8797
  this.providerMap = new Map();
9465
8798
  this.protocolManager = new protocol_manager_1.ProtocolManager(this.wire.environment.type === 'node' ? ['classic'] : ['rtc', 'classic']);
9466
- __classPrivateFieldSet$5(this, _ConnectionManager_messageReceiver, new message_receiver_1.MessageReceiver(wire), "f");
9467
- __classPrivateFieldSet$5(this, _ConnectionManager_rtcConnectionManager, new ice_manager_1.RTCICEManager(wire), "f");
8799
+ __classPrivateFieldSet$6(this, _ConnectionManager_messageReceiver, new message_receiver_1.MessageReceiver(wire), "f");
8800
+ __classPrivateFieldSet$6(this, _ConnectionManager_rtcConnectionManager, new ice_manager_1.RTCICEManager(wire), "f");
9468
8801
  wire.registerMessageHandler(this.onmessage.bind(this));
9469
8802
  }
9470
8803
  createProvider(options, providerIdentity) {
@@ -9475,7 +8808,7 @@ class ConnectionManager extends base_1$f.Base {
9475
8808
  case 'rtc':
9476
8809
  return new strategy_2.RTCStrategy();
9477
8810
  case 'classic':
9478
- return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$7(this, _ConnectionManager_messageReceiver, "f"),
8811
+ return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$8(this, _ConnectionManager_messageReceiver, "f"),
9479
8812
  // Providers do not have an endpointId, use channelId as endpointId in the strategy.
9480
8813
  providerIdentity.channelId, providerIdentity);
9481
8814
  default:
@@ -9511,7 +8844,7 @@ class ConnectionManager extends base_1$f.Base {
9511
8844
  const supportedProtocols = await Promise.all(protocols.map(async (type) => {
9512
8845
  switch (type) {
9513
8846
  case 'rtc': {
9514
- const { rtcClient, channels, offer, rtcConnectionId, channelsOpened } = await __classPrivateFieldGet$7(this, _ConnectionManager_rtcConnectionManager, "f").startClientOffer();
8847
+ const { rtcClient, channels, offer, rtcConnectionId, channelsOpened } = await __classPrivateFieldGet$8(this, _ConnectionManager_rtcConnectionManager, "f").startClientOffer();
9515
8848
  rtcPacket = { rtcClient, channels, channelsOpened };
9516
8849
  return {
9517
8850
  type: 'rtc',
@@ -9538,18 +8871,18 @@ class ConnectionManager extends base_1$f.Base {
9538
8871
  routingInfo.endpointId = this.wire.environment.getNextMessageId();
9539
8872
  // For New Clients connecting to Old Providers. To prevent multi-dispatching and publishing, we delete previously-connected
9540
8873
  // clients that are in the same context as the newly-connected client.
9541
- __classPrivateFieldGet$7(this, _ConnectionManager_messageReceiver, "f").checkForPreviousClientConnection(routingInfo.channelId);
8874
+ __classPrivateFieldGet$8(this, _ConnectionManager_messageReceiver, "f").checkForPreviousClientConnection(routingInfo.channelId);
9542
8875
  }
9543
8876
  const answer = routingInfo.answer ?? {
9544
8877
  supportedProtocols: [{ type: 'classic', version: 1 }]
9545
8878
  };
9546
8879
  const createStrategyFromAnswer = async (protocol) => {
9547
8880
  if (protocol.type === 'rtc' && rtcPacket) {
9548
- await __classPrivateFieldGet$7(this, _ConnectionManager_rtcConnectionManager, "f").finishClientOffer(rtcPacket.rtcClient, protocol.payload.answer, rtcPacket.channelsOpened);
8881
+ await __classPrivateFieldGet$8(this, _ConnectionManager_rtcConnectionManager, "f").finishClientOffer(rtcPacket.rtcClient, protocol.payload.answer, rtcPacket.channelsOpened);
9549
8882
  return new strategy_2.RTCStrategy();
9550
8883
  }
9551
8884
  if (protocol.type === 'classic') {
9552
- return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$7(this, _ConnectionManager_messageReceiver, "f"), routingInfo.endpointId, routingInfo);
8885
+ return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$8(this, _ConnectionManager_messageReceiver, "f"), routingInfo.endpointId, routingInfo);
9553
8886
  }
9554
8887
  return null;
9555
8888
  };
@@ -9617,7 +8950,7 @@ class ConnectionManager extends base_1$f.Base {
9617
8950
  clientAnswer = await overlappingProtocols.reduce(async (accumP, protocolToUse) => {
9618
8951
  const answer = await accumP;
9619
8952
  if (protocolToUse.type === 'rtc') {
9620
- const { answer: rtcAnswer, rtcClient, channels } = await __classPrivateFieldGet$7(this, _ConnectionManager_rtcConnectionManager, "f").createProviderAnswer(protocolToUse.payload.rtcConnectionId, protocolToUse.payload.offer);
8953
+ const { answer: rtcAnswer, rtcClient, channels } = await __classPrivateFieldGet$8(this, _ConnectionManager_rtcConnectionManager, "f").createProviderAnswer(protocolToUse.payload.rtcConnectionId, protocolToUse.payload.offer);
9621
8954
  answer.supportedProtocols.push({
9622
8955
  type: 'rtc',
9623
8956
  version: strategy_2.RTCInfo.version,
@@ -9665,13 +8998,13 @@ _ConnectionManager_messageReceiver = new WeakMap(), _ConnectionManager_rtcConnec
9665
8998
  *
9666
8999
  * @packageDocumentation
9667
9000
  */
9668
- var __classPrivateFieldSet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
9001
+ var __classPrivateFieldSet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
9669
9002
  if (kind === "m") throw new TypeError("Private method is not writable");
9670
9003
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9671
9004
  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");
9672
9005
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
9673
9006
  };
9674
- var __classPrivateFieldGet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9007
+ var __classPrivateFieldGet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9675
9008
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9676
9009
  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");
9677
9010
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -9728,11 +9061,11 @@ class Channel extends base_1$e.EmitterBase {
9728
9061
  client_1.ChannelClient.handleProviderDisconnect(eventPayload);
9729
9062
  }),
9730
9063
  this.on('connected', (...args) => {
9731
- __classPrivateFieldGet$6(this, _Channel_internalEmitter, "f").emit('connected', ...args);
9064
+ __classPrivateFieldGet$7(this, _Channel_internalEmitter, "f").emit('connected', ...args);
9732
9065
  })
9733
9066
  ]).catch(() => new Error('error setting up channel connection listeners'));
9734
9067
  }));
9735
- __classPrivateFieldSet$4(this, _Channel_connectionManager, new connection_manager_1.ConnectionManager(wire), "f");
9068
+ __classPrivateFieldSet$5(this, _Channel_connectionManager, new connection_manager_1.ConnectionManager(wire), "f");
9736
9069
  }
9737
9070
  /**
9738
9071
  *
@@ -9807,7 +9140,7 @@ class Channel extends base_1$e.EmitterBase {
9807
9140
  resolve(true);
9808
9141
  }
9809
9142
  };
9810
- __classPrivateFieldGet$6(this, _Channel_internalEmitter, "f").on('connected', connectedListener);
9143
+ __classPrivateFieldGet$7(this, _Channel_internalEmitter, "f").on('connected', connectedListener);
9811
9144
  });
9812
9145
  try {
9813
9146
  if (retryInfo.count > 0) {
@@ -9839,7 +9172,7 @@ class Channel extends base_1$e.EmitterBase {
9839
9172
  finally {
9840
9173
  retryInfo.count += 1;
9841
9174
  // in case of other errors, remove our listener
9842
- __classPrivateFieldGet$6(this, _Channel_internalEmitter, "f").removeListener('connected', connectedListener);
9175
+ __classPrivateFieldGet$7(this, _Channel_internalEmitter, "f").removeListener('connected', connectedListener);
9843
9176
  }
9844
9177
  } while (shouldWait); // If we're waiting we retry the above loop
9845
9178
  // Should wait was false, no channel was found.
@@ -9898,12 +9231,12 @@ class Channel extends base_1$e.EmitterBase {
9898
9231
  async connect(channelName, options = {}) {
9899
9232
  // Make sure we don't connect before listeners are set up
9900
9233
  // This also errors if we're not in OpenFin, ensuring we don't run unnecessary code
9901
- await __classPrivateFieldGet$6(this, _Channel_readyToConnect, "f").getValue();
9234
+ await __classPrivateFieldGet$7(this, _Channel_readyToConnect, "f").getValue();
9902
9235
  if (!channelName || typeof channelName !== 'string') {
9903
9236
  throw new Error('Please provide a channelName string to connect to a channel.');
9904
9237
  }
9905
9238
  const opts = { wait: true, ...this.wire.environment.getDefaultChannelOptions().connect, ...options };
9906
- const { offer, rtc: rtcPacket } = await __classPrivateFieldGet$6(this, _Channel_connectionManager, "f").createClientOffer(opts);
9239
+ const { offer, rtc: rtcPacket } = await __classPrivateFieldGet$7(this, _Channel_connectionManager, "f").createClientOffer(opts);
9907
9240
  let connectionUrl;
9908
9241
  if (this.fin.me.isFrame || this.fin.me.isView || this.fin.me.isWindow) {
9909
9242
  connectionUrl = (await this.fin.me.getInfo()).url;
@@ -9915,7 +9248,7 @@ class Channel extends base_1$e.EmitterBase {
9915
9248
  connectionUrl
9916
9249
  };
9917
9250
  const routingInfo = await this.safeConnect(channelName, opts.wait, connectPayload);
9918
- const strategy = await __classPrivateFieldGet$6(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
9251
+ const strategy = await __classPrivateFieldGet$7(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
9919
9252
  const channel = new client_1.ChannelClient(routingInfo, () => client_1.ChannelClient.wireClose(this.wire, routingInfo, routingInfo.endpointId), strategy);
9920
9253
  // It is the client's responsibility to handle endpoint disconnection to the provider.
9921
9254
  // If the endpoint dies, the client will force a disconnection through the core.
@@ -9984,7 +9317,7 @@ class Channel extends base_1$e.EmitterBase {
9984
9317
  throw new Error('Please provide a channelName to create a channel');
9985
9318
  }
9986
9319
  const { payload: { data: providerIdentity } } = await this.wire.sendAction('create-channel', { channelName });
9987
- const channel = __classPrivateFieldGet$6(this, _Channel_connectionManager, "f").createProvider(options, providerIdentity);
9320
+ const channel = __classPrivateFieldGet$7(this, _Channel_connectionManager, "f").createProvider(options, providerIdentity);
9988
9321
  // TODO: fix typing (internal)
9989
9322
  // @ts-expect-error
9990
9323
  this.on('client-disconnected', (eventPayload) => {
@@ -10875,7 +10208,7 @@ var Factory$3 = {};
10875
10208
 
10876
10209
  var Instance$2 = {};
10877
10210
 
10878
- var __classPrivateFieldGet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
10211
+ var __classPrivateFieldGet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
10879
10212
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10880
10213
  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");
10881
10214
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -10908,7 +10241,7 @@ class Platform extends base_1$6.EmitterBase {
10908
10241
  const target = identity || this.identity;
10909
10242
  const { uuid } = target;
10910
10243
  if (!clientMap.has(uuid)) {
10911
- const clientPromise = __classPrivateFieldGet$5(this, _Platform_connectToProvider, "f").call(this, uuid);
10244
+ const clientPromise = __classPrivateFieldGet$6(this, _Platform_connectToProvider, "f").call(this, uuid);
10912
10245
  clientMap.set(uuid, clientPromise);
10913
10246
  }
10914
10247
  // we set it above
@@ -11429,309 +10762,973 @@ class Platform extends base_1$6.EmitterBase {
11429
10762
  * });
11430
10763
  * }
11431
10764
  *
11432
- * const win = await createWindowWithTwoViews();
11433
- * // ... you will now see a new window with two views in it
10765
+ * const win = await createWindowWithTwoViews();
10766
+ * // ... you will now see a new window with two views in it
10767
+ *
10768
+ * // we take a snapshot of the current state of the app, before changing it
10769
+ * const snapshotOfInitialAppState = await platform.getSnapshot();
10770
+ *
10771
+ * // now let's change the state of the app:
10772
+ * await addViewToWindow(win.identity);
10773
+ * // ... the window now has three views in it
10774
+ *
10775
+ * await platform.applySnapshot(snapshotOfInitialAppState, { closeExistingWindows: true });
10776
+ * // ... the window will revert to previous state, with just two views
10777
+ *
10778
+ * ```
10779
+ */
10780
+ async applySnapshot(requestedSnapshot, options) {
10781
+ this.wire.sendAction('platform-apply-snapshot', this.identity).catch((e) => {
10782
+ // don't expose
10783
+ });
10784
+ const errMsg = 'Requested snapshot must be a valid Snapshot object, or a url or filepath to such an object.';
10785
+ let snapshot;
10786
+ if (typeof requestedSnapshot === 'string') {
10787
+ // Fetch and parse snapshot
10788
+ try {
10789
+ const response = await this._channel.wire.sendAction('get-application-manifest', {
10790
+ manifestUrl: requestedSnapshot
10791
+ });
10792
+ snapshot = response.payload.data;
10793
+ }
10794
+ catch (err) {
10795
+ throw new Error(`${errMsg}: ${err}`);
10796
+ }
10797
+ }
10798
+ else {
10799
+ snapshot = requestedSnapshot;
10800
+ }
10801
+ if (!snapshot.windows) {
10802
+ throw new Error(errMsg);
10803
+ }
10804
+ const client = await this.getClient();
10805
+ await client.dispatch('apply-snapshot', {
10806
+ snapshot,
10807
+ options
10808
+ });
10809
+ return this;
10810
+ }
10811
+ /**
10812
+ * Fetches a JSON manifest using the browser process and returns a Javascript object.
10813
+ * Can be overwritten using {@link Platform.PlatformModule.init Platform.init}.
10814
+ * @param manifestUrl The URL of the manifest to fetch.
10815
+ *
10816
+ * @remarks Can be overwritten using {@link Platform#init Platform.init}.
10817
+ *
10818
+ * @example
10819
+ *
10820
+ * ```js
10821
+ * const platform = fin.Platform.getCurrentSync();
10822
+ * const manifest = await platform.fetchManifest('https://www.path-to-manifest.com/app.json');
10823
+ * console.log(manifest);
10824
+ * ```
10825
+ */
10826
+ async fetchManifest(manifestUrl) {
10827
+ const client = await this.getClient();
10828
+ return client.dispatch('platform-fetch-manifest', { manifestUrl });
10829
+ }
10830
+ /**
10831
+ * Retrieves a manifest by url and launches a legacy application manifest or snapshot into the platform. Returns a promise that
10832
+ * resolves to the wrapped Platform.
10833
+ * @param manifestUrl - The URL of the manifest that will be launched into the platform. If this app manifest
10834
+ * contains a snapshot, that will be launched into the platform. If not, the application described in startup_app options
10835
+ * will be launched into the platform. The applicable startup_app options will become {@link OpenFin.ViewCreationOptions View Options}.
10836
+ *
10837
+ * @remarks If the app manifest contains a snapshot, that will be launched into the platform. If not, the
10838
+ * application described in startup_app options will be launched into the platform as a window with a single view.
10839
+ * The applicable startup_app options will become View Options.
10840
+ *
10841
+ * @example
10842
+ * ```js
10843
+ * try {
10844
+ * const platform = fin.Platform.getCurrentSync();
10845
+ * await platform.launchContentManifest('http://localhost:5555/app.json');
10846
+ * console.log(`content launched successfully into platform`);
10847
+ * } catch(e) {
10848
+ * console.error(e);
10849
+ * }
10850
+ * // For a local manifest file:
10851
+ * try {
10852
+ * const platform = fin.Platform.getCurrentSync();
10853
+ * platform.launchContentManifest('file:///C:/somefolder/app.json');
10854
+ * console.log(`content launched successfully into platform`);
10855
+ * } catch(e) {
10856
+ * console.error(e);
10857
+ * }
10858
+ * ```
10859
+ * @experimental
10860
+ */
10861
+ async launchContentManifest(manifestUrl) {
10862
+ this.wire.sendAction('platform-launch-content-manifest', this.identity).catch(() => {
10863
+ // don't expose
10864
+ });
10865
+ const client = await this.getClient();
10866
+ const manifest = await this.fetchManifest(manifestUrl);
10867
+ client.dispatch('launch-into-platform', { manifest, manifestUrl });
10868
+ return this;
10869
+ }
10870
+ /**
10871
+ * Set the context of a host window. The context will be available to the window itself, and to its child Views. It will be saved in any platform snapshots.
10872
+ * It can be retrieved using {@link Platform#getWindowContext getWindowContext}.
10873
+ * @param context - A field where serializable context data can be stored to be saved in platform snapshots.
10874
+ * @param target - A target window or view may optionally be provided. If no target is provided, the update will be applied
10875
+ * to the current window (if called from a Window) or the current host window (if called from a View).
10876
+ *
10877
+ * @remarks The context data must be serializable. This can only be called from a window or view that has been launched into a
10878
+ * platform.
10879
+ * This method can be called from the window itself, or from any child view. Context data is shared by all
10880
+ * entities within a window.
10881
+ *
10882
+ * @example
10883
+ * Setting own context:
10884
+ * ```js
10885
+ * const platform = fin.Platform.getCurrentSync();
10886
+ * const contextData = {
10887
+ * security: 'STOCK',
10888
+ * currentView: 'detailed'
10889
+ * }
10890
+ *
10891
+ * await platform.setWindowContext(contextData);
10892
+ * // Context of current window is now set to `contextData`
10893
+ * ```
10894
+ *
10895
+ * Setting the context of another window or view:
10896
+ * ```js
10897
+ * const platform = fin.Platform.getCurrentSync();
10898
+ * const contextData = {
10899
+ * security: 'STOCK',
10900
+ * currentView: 'detailed'
10901
+ * }
10902
+ *
10903
+ * const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
10904
+ * await platform.setWindowContext(contextData, windowOrViewIdentity);
10905
+ * // Context of the target window or view is now set to `contextData`
10906
+ * ```
10907
+ *
10908
+ * A view can listen to changes to its host window's context by listening to the `host-context-changed` event.
10909
+ * This event will fire when a host window's context is updated or when the view is reparented to a new window:
10910
+ *
10911
+ * ```js
10912
+ * // From a view
10913
+ * const contextChangeHandler = ({ context }) => {
10914
+ * console.log('Host window\'s context has changed. New context data:', context);
10915
+ * // react to new context data here
10916
+ * }
10917
+ * await fin.me.on('host-context-changed', contextChangeHandler);
10918
+ *
10919
+ * const platform = await fin.Platform.getCurrentSync();
10920
+ * const contextData = {
10921
+ * security: 'STOCK',
10922
+ * currentView: 'detailed'
10923
+ * }
10924
+ * platform.setWindowContext(contextData) // contextChangeHandler will log the new context
10925
+ * ```
10926
+ *
10927
+ * To listen to a window's context updates, use the `context-changed` event:
10928
+ * ```js
10929
+ * // From a window
10930
+ * const contextChangeHandler = ({ context }) => {
10931
+ * console.log('This window\'s context has changed. New context data:', context);
10932
+ * // react to new context data here
10933
+ * }
10934
+ * await fin.me.on('context-changed', contextChangeHandler);
10935
+ *
10936
+ * const platform = await fin.Platform.getCurrentSync();
10937
+ * const contextData = {
10938
+ * security: 'STOCK',
10939
+ * currentView: 'detailed'
10940
+ * }
10941
+ * platform.setWindowContext(contextData) // contextChangeHandler will log the new context
10942
+ * ```
10943
+ * @experimental
10944
+ */
10945
+ async setWindowContext(context = {}, target) {
10946
+ this.wire.sendAction('platform-set-window-context', this.identity).catch((e) => {
10947
+ // don't expose
10948
+ });
10949
+ if (!context) {
10950
+ throw new Error('Please provide a serializable object or string to set the context.');
10951
+ }
10952
+ const client = await this.getClient();
10953
+ const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
10954
+ await client.dispatch('set-window-context', {
10955
+ context,
10956
+ entityType,
10957
+ target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name }
10958
+ });
10959
+ }
10960
+ /**
10961
+ * Get the context context of a host window that was previously set using {@link Platform#setWindowContext setWindowContext}.
10962
+ * The context will be saved in any platform snapshots. Returns a promise that resolves to the context.
10963
+ * @param target - A target window or view may optionally be provided. If no target is provided, target will be
10964
+ * the current window (if called from a Window) or the current host window (if called from a View).
10965
+ *
10966
+ * @remarks This method can be called from the window itself, or from any child view. Context data is shared
10967
+ * by all entities within a window.
10968
+ *
10969
+ * @example
11434
10970
  *
11435
- * // we take a snapshot of the current state of the app, before changing it
11436
- * const snapshotOfInitialAppState = await platform.getSnapshot();
10971
+ * Retrieving context from current window:
10972
+ * ```js
10973
+ * const platform = fin.Platform.getCurrentSync();
10974
+ * const customContext = { answer: 42 };
10975
+ * await platform.setWindowContext(customContext);
11437
10976
  *
11438
- * // now let's change the state of the app:
11439
- * await addViewToWindow(win.identity);
11440
- * // ... the window now has three views in it
10977
+ * const myContext = await platform.getWindowContext();
10978
+ * console.log(myContext); // { answer: 42 }
10979
+ * ```
11441
10980
  *
11442
- * await platform.applySnapshot(snapshotOfInitialAppState, { closeExistingWindows: true });
11443
- * // ... the window will revert to previous state, with just two views
10981
+ * Retrieving the context of another window or view:
10982
+ * ```js
10983
+ * const platform = fin.Platform.getCurrentSync();
10984
+ *
10985
+ * const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
11444
10986
  *
10987
+ * const targetWindowContext = await platform.getWindowContext(windowOrViewIdentity);
10988
+ * console.log(targetWindowContext); // context of target window
11445
10989
  * ```
10990
+ * @experimental
11446
10991
  */
11447
- async applySnapshot(requestedSnapshot, options) {
11448
- this.wire.sendAction('platform-apply-snapshot', this.identity).catch((e) => {
10992
+ async getWindowContext(target) {
10993
+ this.wire.sendAction('platform-get-window-context', this.identity).catch((e) => {
11449
10994
  // don't expose
11450
10995
  });
11451
- const errMsg = 'Requested snapshot must be a valid Snapshot object, or a url or filepath to such an object.';
11452
- let snapshot;
11453
- if (typeof requestedSnapshot === 'string') {
11454
- // Fetch and parse snapshot
11455
- try {
11456
- const response = await this._channel.wire.sendAction('get-application-manifest', {
11457
- manifestUrl: requestedSnapshot
11458
- });
11459
- snapshot = response.payload.data;
11460
- }
11461
- catch (err) {
11462
- throw new Error(`${errMsg}: ${err}`);
11463
- }
11464
- }
11465
- else {
11466
- snapshot = requestedSnapshot;
11467
- }
11468
- if (!snapshot.windows) {
11469
- throw new Error(errMsg);
11470
- }
11471
10996
  const client = await this.getClient();
11472
- await client.dispatch('apply-snapshot', {
11473
- snapshot,
11474
- options
10997
+ const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
10998
+ return client.dispatch('get-window-context', {
10999
+ target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name },
11000
+ entityType
11475
11001
  });
11476
- return this;
11477
11002
  }
11478
11003
  /**
11479
- * Fetches a JSON manifest using the browser process and returns a Javascript object.
11480
- * Can be overwritten using {@link Platform.PlatformModule.init Platform.init}.
11481
- * @param manifestUrl The URL of the manifest to fetch.
11004
+ * Closes a window. If enableBeforeUnload is enabled in the Platform options, any beforeunload handler set on Views will fire
11005
+ * This behavior can be disabled by setting skipBeforeUnload to false in the options parameter.
11006
+ * @param winId
11007
+ * @param options
11482
11008
  *
11483
- * @remarks Can be overwritten using {@link Platform#init Platform.init}.
11009
+ * @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,
11010
+ * it is recommended to move that logic over to the [PlatformProvider.closeWindow]{@link PlatformProvider#closeWindow} override to ensure it runs when the Window closes.
11484
11011
  *
11485
11012
  * @example
11486
11013
  *
11487
11014
  * ```js
11488
- * const platform = fin.Platform.getCurrentSync();
11489
- * const manifest = await platform.fetchManifest('https://www.path-to-manifest.com/app.json');
11490
- * console.log(manifest);
11015
+ * // Close the current Window inside a Window context
11016
+ * const platform = await fin.Platform.getCurrent();
11017
+ * platform.closeWindow(fin.me.identity);
11018
+ *
11019
+ * // Close the Window from inside a View context
11020
+ * const platform = await fin.Platform.getCurrent();
11021
+ * const parentWindow = await fin.me.getCurrentWindow();
11022
+ * platform.closeWindow(parentWindow.identity);
11023
+ *
11024
+ * // Close the Window and do not fire the before unload handler on Views
11025
+ * const platform = await fin.Platform.getCurrent();
11026
+ * platform.closeWindow(fin.me.identity, { skipBeforeUnload: true });
11491
11027
  * ```
11028
+ * @experimental
11492
11029
  */
11493
- async fetchManifest(manifestUrl) {
11030
+ async closeWindow(windowId, options = { skipBeforeUnload: false }) {
11031
+ this.wire.sendAction('platform-close-window', this.identity).catch((e) => {
11032
+ // don't expose
11033
+ });
11494
11034
  const client = await this.getClient();
11495
- return client.dispatch('platform-fetch-manifest', { manifestUrl });
11035
+ return client.dispatch('close-window', { windowId, options });
11036
+ }
11037
+ }
11038
+ Instance$2.Platform = Platform;
11039
+ _Platform_connectToProvider = new WeakMap();
11040
+
11041
+ var layout = {};
11042
+
11043
+ var Factory$2 = {};
11044
+
11045
+ var Instance$1 = {};
11046
+
11047
+ var commonUtils = {};
11048
+
11049
+ Object.defineProperty(commonUtils, "__esModule", { value: true });
11050
+ commonUtils.overrideFromComposables = commonUtils.isValidPresetType = void 0;
11051
+ function isValidPresetType(type) {
11052
+ switch (type) {
11053
+ case 'columns':
11054
+ case 'grid':
11055
+ case 'rows':
11056
+ case 'tabs':
11057
+ return true;
11058
+ default:
11059
+ return false;
11060
+ }
11061
+ }
11062
+ commonUtils.isValidPresetType = isValidPresetType;
11063
+ function overrideFromComposables(...overrides) {
11064
+ return (base) => overrides.reduceRight((p, c) => (b) => c(p(b)), (x) => x)(base);
11065
+ }
11066
+ commonUtils.overrideFromComposables = overrideFromComposables;
11067
+ commonUtils.default = { isValidPresetType };
11068
+
11069
+ var layoutEntities = {};
11070
+
11071
+ var apiExposer$1 = {};
11072
+
11073
+ var apiConsumer = {};
11074
+
11075
+ Object.defineProperty(apiConsumer, "__esModule", { value: true });
11076
+ apiConsumer.ApiConsumer = void 0;
11077
+ /**
11078
+ * Consumer for apis exposed with {@see ApiExposer}.
11079
+ *
11080
+ * A strategy that matches the strategy used to expose a target API must be provided.
11081
+ */
11082
+ class ApiConsumer {
11083
+ // eslint-disable-next-line
11084
+ constructor(strategy) {
11085
+ this.strategy = strategy;
11086
+ /**
11087
+ * Consumes an api exposed using a given transport strategy, and generates a client
11088
+ * for easy, type safe consumption of that client.
11089
+ * @param options Strategy specific consumption options.
11090
+ * @returns An api client matching the given type.
11091
+ */
11092
+ this.consume = async (options) => {
11093
+ const exposedProperties = await this.strategy.getExposedFunctions(options);
11094
+ return exposedProperties.reduce((client, prop) => ({
11095
+ ...client,
11096
+ [prop.key]: this.strategy.createFunction(prop, options)
11097
+ }), {});
11098
+ };
11099
+ }
11100
+ }
11101
+ apiConsumer.ApiConsumer = ApiConsumer;
11102
+
11103
+ var apiExposer = {};
11104
+
11105
+ var decorators = {};
11106
+
11107
+ Object.defineProperty(decorators, "__esModule", { value: true });
11108
+ decorators.expose = decorators.getExposedProperties = void 0;
11109
+ const exposedProperties = Symbol('exposedProperties');
11110
+ const getExposedProperties = (target) => {
11111
+ return target[exposedProperties] || target.prototype[exposedProperties] || [];
11112
+ };
11113
+ decorators.getExposedProperties = getExposedProperties;
11114
+ /**
11115
+ * Indicates that a class member function can be exposed using {@link ApiExposer}.
11116
+ * @param options Options specific to the strategy used in {@link ApiExposer}
11117
+ */
11118
+ // Returns any as decorator typing is weird.
11119
+ const expose = (options) => (target, key, descriptor) => {
11120
+ target[exposedProperties] = target[exposedProperties] || [];
11121
+ target[exposedProperties].push({ key, descriptor, options });
11122
+ };
11123
+ decorators.expose = expose;
11124
+
11125
+ Object.defineProperty(apiExposer, "__esModule", { value: true });
11126
+ apiExposer.ApiExposer = void 0;
11127
+ const decorators_1 = decorators;
11128
+ /**
11129
+ * Exposes api services on the transport of choice.
11130
+ */
11131
+ class ApiExposer {
11132
+ /**
11133
+ * @param strategy The expose strategy to use to expose instances.
11134
+ */
11135
+ // eslint-disable-next-line
11136
+ constructor(strategy) {
11137
+ this.strategy = strategy;
11138
+ /**
11139
+ * Exposes an instance of a given api on
11140
+ * @param instance Instance of a class which has been decorated to indicate which functions can be exposed.
11141
+ * @param instanceOptions Transport strategy specific options to use when exposing.
11142
+ */
11143
+ this.exposeInstance = async (instance, instanceOptions) => {
11144
+ const exposableProps = (0, decorators_1.getExposedProperties)(instance);
11145
+ const exposedProps = await Promise.all(exposableProps.map(async ({ key, options }) => {
11146
+ const customConsumptionOptions = await this.strategy.exposeFunction(instance[key].bind(instance), {
11147
+ key,
11148
+ options,
11149
+ meta: instanceOptions
11150
+ });
11151
+ return {
11152
+ key,
11153
+ options: customConsumptionOptions
11154
+ };
11155
+ }));
11156
+ await this.strategy.exposeMeta(instanceOptions, exposedProps);
11157
+ };
11158
+ }
11159
+ ;
11160
+ }
11161
+ apiExposer.ApiExposer = ApiExposer;
11162
+
11163
+ var strategies = {};
11164
+
11165
+ var openfinChannels = {};
11166
+
11167
+ var channelsConsumer = {};
11168
+
11169
+ Object.defineProperty(channelsConsumer, "__esModule", { value: true });
11170
+ channelsConsumer.ChannelsConsumer = void 0;
11171
+ class ChannelsConsumer {
11172
+ // eslint-disable-next-line
11173
+ constructor(channel) {
11174
+ this.channel = channel;
11175
+ this.getExposedFunctions = async (options) => {
11176
+ const { id } = options;
11177
+ const { props } = await this.channel.dispatch(`api-meta:${id}`);
11178
+ return props;
11179
+ };
11180
+ this.createFunction = (prop) => (...args) => {
11181
+ const { action } = prop.options;
11182
+ return this.channel.dispatch(action, { args });
11183
+ };
11184
+ }
11185
+ ;
11186
+ }
11187
+ channelsConsumer.ChannelsConsumer = ChannelsConsumer;
11188
+
11189
+ var channelsExposer = {};
11190
+
11191
+ Object.defineProperty(channelsExposer, "__esModule", { value: true });
11192
+ channelsExposer.ChannelsExposer = void 0;
11193
+ class ChannelsExposer {
11194
+ // eslint-disable-next-line
11195
+ constructor(channelProviderOrClient) {
11196
+ this.channelProviderOrClient = channelProviderOrClient;
11197
+ this.exposeFunction = async (target, config) => {
11198
+ const { key, options, meta } = config;
11199
+ const { id } = meta;
11200
+ const action = `${id}.${options?.action || key}`;
11201
+ await this.channelProviderOrClient.register(action, async ({ args }) => {
11202
+ return target(...args);
11203
+ });
11204
+ return { action };
11205
+ };
11206
+ this.exposeMeta = async ({ id }, props) => {
11207
+ const action = `api-meta:${id}`;
11208
+ await this.channelProviderOrClient.register(action, () => ({ props }));
11209
+ };
11496
11210
  }
11497
- /**
11498
- * Retrieves a manifest by url and launches a legacy application manifest or snapshot into the platform. Returns a promise that
11499
- * resolves to the wrapped Platform.
11500
- * @param manifestUrl - The URL of the manifest that will be launched into the platform. If this app manifest
11501
- * contains a snapshot, that will be launched into the platform. If not, the application described in startup_app options
11502
- * will be launched into the platform. The applicable startup_app options will become {@link OpenFin.ViewCreationOptions View Options}.
11503
- *
11504
- * @remarks If the app manifest contains a snapshot, that will be launched into the platform. If not, the
11505
- * application described in startup_app options will be launched into the platform as a window with a single view.
11506
- * The applicable startup_app options will become View Options.
11507
- *
11508
- * @example
11509
- * ```js
11510
- * try {
11511
- * const platform = fin.Platform.getCurrentSync();
11512
- * await platform.launchContentManifest('http://localhost:5555/app.json');
11513
- * console.log(`content launched successfully into platform`);
11514
- * } catch(e) {
11515
- * console.error(e);
11516
- * }
11517
- * // For a local manifest file:
11518
- * try {
11519
- * const platform = fin.Platform.getCurrentSync();
11520
- * platform.launchContentManifest('file:///C:/somefolder/app.json');
11521
- * console.log(`content launched successfully into platform`);
11522
- * } catch(e) {
11523
- * console.error(e);
11524
- * }
11525
- * ```
11526
- * @experimental
11527
- */
11528
- async launchContentManifest(manifestUrl) {
11529
- this.wire.sendAction('platform-launch-content-manifest', this.identity).catch(() => {
11530
- // don't expose
11211
+ }
11212
+ channelsExposer.ChannelsExposer = ChannelsExposer;
11213
+
11214
+ (function (exports) {
11215
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11216
+ if (k2 === undefined) k2 = k;
11217
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11218
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11219
+ desc = { enumerable: true, get: function() { return m[k]; } };
11220
+ }
11221
+ Object.defineProperty(o, k2, desc);
11222
+ }) : (function(o, m, k, k2) {
11223
+ if (k2 === undefined) k2 = k;
11224
+ o[k2] = m[k];
11225
+ }));
11226
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
11227
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11228
+ };
11229
+ Object.defineProperty(exports, "__esModule", { value: true });
11230
+ __exportStar(channelsConsumer, exports);
11231
+ __exportStar(channelsExposer, exports);
11232
+ } (openfinChannels));
11233
+
11234
+ (function (exports) {
11235
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11236
+ if (k2 === undefined) k2 = k;
11237
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11238
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11239
+ desc = { enumerable: true, get: function() { return m[k]; } };
11240
+ }
11241
+ Object.defineProperty(o, k2, desc);
11242
+ }) : (function(o, m, k, k2) {
11243
+ if (k2 === undefined) k2 = k;
11244
+ o[k2] = m[k];
11245
+ }));
11246
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
11247
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11248
+ };
11249
+ Object.defineProperty(exports, "__esModule", { value: true });
11250
+ __exportStar(openfinChannels, exports);
11251
+ } (strategies));
11252
+
11253
+ (function (exports) {
11254
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11255
+ if (k2 === undefined) k2 = k;
11256
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11257
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11258
+ desc = { enumerable: true, get: function() { return m[k]; } };
11259
+ }
11260
+ Object.defineProperty(o, k2, desc);
11261
+ }) : (function(o, m, k, k2) {
11262
+ if (k2 === undefined) k2 = k;
11263
+ o[k2] = m[k];
11264
+ }));
11265
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
11266
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11267
+ };
11268
+ Object.defineProperty(exports, "__esModule", { value: true });
11269
+ __exportStar(apiConsumer, exports);
11270
+ __exportStar(apiExposer, exports);
11271
+ __exportStar(strategies, exports);
11272
+ __exportStar(decorators, exports);
11273
+ } (apiExposer$1));
11274
+
11275
+ var channelApiRelay = {};
11276
+
11277
+ Object.defineProperty(channelApiRelay, "__esModule", { value: true });
11278
+ channelApiRelay.createRelayedDispatch = channelApiRelay.relayChannelClientApi = void 0;
11279
+ const EXPECTED_ERRORS = [
11280
+ 'no longer connected',
11281
+ 'RTCDataChannel closed unexpectedly',
11282
+ 'The client you are trying to dispatch from is disconnected from the target provider',
11283
+ ];
11284
+ // Checks possible error messages that we want to trap, client error message can originate
11285
+ // from ChannelProvider::dispatch OR ClassicStrategy::closeEndpoint OR RTCEndPoint::dataChannel::onclose
11286
+ const isDisconnectedError = (errorMsg) => {
11287
+ return EXPECTED_ERRORS.some(e => errorMsg.includes(e));
11288
+ };
11289
+ /**
11290
+ * @internal
11291
+ * Create a channel relay for a given channel exposition, allowing a single provider to route
11292
+ * actions to the designated clients.
11293
+ *
11294
+ * Designed to be used in conjunction with @expose
11295
+ *
11296
+ * @param channelProvider The channel provider to relay the actions on.
11297
+ * @param config Determines which actions to relay. Please ensure action prefix matches the exposed api.
11298
+ */
11299
+ const relayChannelClientApi = async (channelProvider, relayId) => {
11300
+ channelProvider.register(`relay:${relayId}`, ({ action, target, payload }) => {
11301
+ return channelProvider.dispatch(target, action, payload);
11302
+ });
11303
+ await Promise.resolve();
11304
+ };
11305
+ channelApiRelay.relayChannelClientApi = relayChannelClientApi;
11306
+ const createRelayedDispatch = (client, target, relayId, relayErrorMsg) => async (action, payload) => {
11307
+ try {
11308
+ return await client.dispatch(`relay:${relayId}`, {
11309
+ action,
11310
+ payload,
11311
+ target
11531
11312
  });
11532
- const client = await this.getClient();
11533
- const manifest = await this.fetchManifest(manifestUrl);
11534
- client.dispatch('launch-into-platform', { manifest, manifestUrl });
11535
- return this;
11536
11313
  }
11537
- /**
11538
- * Set the context of a host window. The context will be available to the window itself, and to its child Views. It will be saved in any platform snapshots.
11539
- * It can be retrieved using {@link Platform#getWindowContext getWindowContext}.
11540
- * @param context - A field where serializable context data can be stored to be saved in platform snapshots.
11541
- * @param target - A target window or view may optionally be provided. If no target is provided, the update will be applied
11542
- * to the current window (if called from a Window) or the current host window (if called from a View).
11543
- *
11544
- * @remarks The context data must be serializable. This can only be called from a window or view that has been launched into a
11545
- * platform.
11546
- * This method can be called from the window itself, or from any child view. Context data is shared by all
11547
- * entities within a window.
11548
- *
11549
- * @example
11550
- * Setting own context:
11551
- * ```js
11552
- * const platform = fin.Platform.getCurrentSync();
11553
- * const contextData = {
11554
- * security: 'STOCK',
11555
- * currentView: 'detailed'
11556
- * }
11557
- *
11558
- * await platform.setWindowContext(contextData);
11559
- * // Context of current window is now set to `contextData`
11560
- * ```
11561
- *
11562
- * Setting the context of another window or view:
11563
- * ```js
11564
- * const platform = fin.Platform.getCurrentSync();
11565
- * const contextData = {
11566
- * security: 'STOCK',
11567
- * currentView: 'detailed'
11568
- * }
11569
- *
11570
- * const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
11571
- * await platform.setWindowContext(contextData, windowOrViewIdentity);
11572
- * // Context of the target window or view is now set to `contextData`
11573
- * ```
11574
- *
11575
- * A view can listen to changes to its host window's context by listening to the `host-context-changed` event.
11576
- * This event will fire when a host window's context is updated or when the view is reparented to a new window:
11577
- *
11578
- * ```js
11579
- * // From a view
11580
- * const contextChangeHandler = ({ context }) => {
11581
- * console.log('Host window\'s context has changed. New context data:', context);
11582
- * // react to new context data here
11583
- * }
11584
- * await fin.me.on('host-context-changed', contextChangeHandler);
11585
- *
11586
- * const platform = await fin.Platform.getCurrentSync();
11587
- * const contextData = {
11588
- * security: 'STOCK',
11589
- * currentView: 'detailed'
11590
- * }
11591
- * platform.setWindowContext(contextData) // contextChangeHandler will log the new context
11592
- * ```
11593
- *
11594
- * To listen to a window's context updates, use the `context-changed` event:
11595
- * ```js
11596
- * // From a window
11597
- * const contextChangeHandler = ({ context }) => {
11598
- * console.log('This window\'s context has changed. New context data:', context);
11599
- * // react to new context data here
11600
- * }
11601
- * await fin.me.on('context-changed', contextChangeHandler);
11602
- *
11603
- * const platform = await fin.Platform.getCurrentSync();
11604
- * const contextData = {
11605
- * security: 'STOCK',
11606
- * currentView: 'detailed'
11607
- * }
11608
- * platform.setWindowContext(contextData) // contextChangeHandler will log the new context
11609
- * ```
11610
- * @experimental
11611
- */
11612
- async setWindowContext(context = {}, target) {
11613
- this.wire.sendAction('platform-set-window-context', this.identity).catch((e) => {
11614
- // don't expose
11615
- });
11616
- if (!context) {
11617
- throw new Error('Please provide a serializable object or string to set the context.');
11314
+ catch (e) {
11315
+ if (isDisconnectedError(e.message) && relayErrorMsg) {
11316
+ throw new Error(relayErrorMsg);
11618
11317
  }
11619
- const client = await this.getClient();
11620
- const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
11621
- await client.dispatch('set-window-context', {
11622
- context,
11623
- entityType,
11624
- target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name }
11625
- });
11318
+ throw e;
11626
11319
  }
11320
+ };
11321
+ channelApiRelay.createRelayedDispatch = createRelayedDispatch;
11322
+
11323
+ var __classPrivateFieldSet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
11324
+ if (kind === "m") throw new TypeError("Private method is not writable");
11325
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
11326
+ 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");
11327
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11328
+ };
11329
+ var __classPrivateFieldGet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
11330
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
11331
+ 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");
11332
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11333
+ };
11334
+ var _LayoutNode_client, _TabStack_client, _ColumnOrRow_client;
11335
+ Object.defineProperty(layoutEntities, "__esModule", { value: true });
11336
+ layoutEntities.ColumnOrRow = layoutEntities.TabStack = layoutEntities.LayoutNode = void 0;
11337
+ const api_exposer_1 = apiExposer$1;
11338
+ const channel_api_relay_1 = channelApiRelay;
11339
+ /*
11340
+ This file includes LayoutNode, ColumnOrRow and TabStack classes, which are all closely
11341
+ intertwined, and share members via parent abstract class LayoutNode. To prevent circular
11342
+ refs, we define and export all the classes here.
11343
+ */
11344
+ /**
11345
+ * @ignore
11346
+ * @internal
11347
+ * Supplies an ApiClient for {@link LayoutEntitiesController} and helper methods
11348
+ * for the entities {@link TabStack} AND {@link ColumnOrRow} to use.
11349
+ */
11350
+ class LayoutNode {
11627
11351
  /**
11628
- * Get the context context of a host window that was previously set using {@link Platform#setWindowContext setWindowContext}.
11629
- * The context will be saved in any platform snapshots. Returns a promise that resolves to the context.
11630
- * @param target - A target window or view may optionally be provided. If no target is provided, target will be
11631
- * the current window (if called from a Window) or the current host window (if called from a View).
11632
- *
11633
- * @remarks This method can be called from the window itself, or from any child view. Context data is shared
11634
- * by all entities within a window.
11635
- *
11636
- * @example
11637
- *
11638
- * Retrieving context from current window:
11639
- * ```js
11640
- * const platform = fin.Platform.getCurrentSync();
11641
- * const customContext = { answer: 42 };
11642
- * await platform.setWindowContext(customContext);
11643
- *
11644
- * const myContext = await platform.getWindowContext();
11645
- * console.log(myContext); // { answer: 42 }
11646
- * ```
11647
- *
11648
- * Retrieving the context of another window or view:
11649
- * ```js
11650
- * const platform = fin.Platform.getCurrentSync();
11651
- *
11652
- * const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
11653
- *
11654
- * const targetWindowContext = await platform.getWindowContext(windowOrViewIdentity);
11655
- * console.log(targetWindowContext); // context of target window
11656
- * ```
11657
- * @experimental
11352
+ * @internal
11353
+ * @ignore
11658
11354
  */
11659
- async getWindowContext(target) {
11660
- this.wire.sendAction('platform-get-window-context', this.identity).catch((e) => {
11661
- // don't expose
11662
- });
11663
- const client = await this.getClient();
11664
- const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
11665
- return client.dispatch('get-window-context', {
11666
- target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name },
11667
- entityType
11668
- });
11355
+ constructor(client, entityId) {
11356
+ /**
11357
+ * @ignore
11358
+ * @internal
11359
+ * ApiClient for {@link LayoutEntitiesController}
11360
+ */
11361
+ _LayoutNode_client.set(this, void 0);
11362
+ /**
11363
+ * Checks if the TabStack or ColumnOrRow is the root content item
11364
+ *
11365
+ * @example
11366
+ * ```js
11367
+ * if (!fin.me.isView) {
11368
+ * throw new Error('Not running in a platform View.');
11369
+ * }
11370
+ *
11371
+ * const stack = await fin.me.getCurrentStack();
11372
+ * const isRoot = await stack.isRoot();
11373
+ * // The TabStack is root: false
11374
+ * console.log(`The TabStack is root: ${isRoot}`);
11375
+ *
11376
+ * // Retrieves the parent ColumnOrRow
11377
+ * const parent = await stack.getParent();
11378
+ * const parentIsRoot = await parent.isRoot();
11379
+ * // The parent ColumnOrRow is root: true
11380
+ * console.log(`The parent ColumnOrRow is root: ${parentIsRoot}`);
11381
+ * ```
11382
+ */
11383
+ this.isRoot = () => __classPrivateFieldGet$5(this, _LayoutNode_client, "f").isRoot(this.entityId);
11384
+ /**
11385
+ * Checks if the TabStack or ColumnOrRow exists
11386
+ *
11387
+ * @example
11388
+ * ```js
11389
+ * if (!fin.me.isView) {
11390
+ * throw new Error('Not running in a platform View.');
11391
+ * }
11392
+ *
11393
+ * const stack = await fin.me.getCurrentStack();
11394
+ * // Retrieves the parent ColumnOrRow
11395
+ * const columnOrRow = await stack.getParent();
11396
+ * let exists = await stack.exists();
11397
+ * // or
11398
+ * let exists = await columnOrRow.exists();
11399
+ * // The entity exists: true
11400
+ * console.log(`The entity exists: ${exists}`);
11401
+ * ```
11402
+ */
11403
+ this.exists = () => __classPrivateFieldGet$5(this, _LayoutNode_client, "f").exists(this.entityId);
11404
+ /**
11405
+ * Retrieves the parent of the TabStack or ColumnOrRow
11406
+ *
11407
+ * @example
11408
+ * ```js
11409
+ * if (!fin.me.isView) {
11410
+ * throw new Error('Not running in a platform View.');
11411
+ * }
11412
+ *
11413
+ * const stack = await fin.me.getCurrentStack();
11414
+ * // Retrieves the parent ColumnOrRow
11415
+ * const columnOrRow = await stack.getParent();
11416
+ *
11417
+ * // undefined if entity is the root item
11418
+ * let parent = await columnOrRow.getParent();
11419
+ * // or
11420
+ * let parent = await stack.getParent();
11421
+ * ```
11422
+ */
11423
+ this.getParent = async () => {
11424
+ const parent = await __classPrivateFieldGet$5(this, _LayoutNode_client, "f").getParent(this.entityId);
11425
+ if (!parent) {
11426
+ return undefined;
11427
+ }
11428
+ return LayoutNode.getEntity(parent, __classPrivateFieldGet$5(this, _LayoutNode_client, "f"));
11429
+ };
11430
+ /**
11431
+ * Creates a new TabStack adjacent to the given TabStack or ColumnOrRow. Inputs can be new views to create, or existing views.
11432
+ *
11433
+ * Known Issue: If the number of views to add overflows the tab-container, the added views will be set as active
11434
+ * during each render, and then placed at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
11435
+ * This means the views you pass to createAdjacentStack() may not render in the order given by the array.
11436
+ * Until fixed, this problem can be avoided only if your window is wide enough to fit creating all the views in the tabstack.
11437
+ *
11438
+ * @param views The views that will populate the new TabStack.
11439
+ * @param options Additional options that control new TabStack creation.
11440
+ * @returns The newly-created TabStack.
11441
+ *
11442
+ * @example
11443
+ * ```js
11444
+ * if (!fin.me.isView) {
11445
+ * throw new Error('Not running in a platform View.');
11446
+ * }
11447
+ *
11448
+ * const stack = await fin.me.getCurrentStack();
11449
+ * const columnOrRow = await stack.getParent();
11450
+ *
11451
+ * // Create view references by supplying a 'name' and 'url'
11452
+ * const views = [
11453
+ * // if 'name' is undefined, one will be generated
11454
+ * // if 'url' is undefined, it will default the view URL to 'about:blank'
11455
+ * { name: 'google-view', url: 'http://google.com/'},
11456
+ * { name: 'of-developers-view', url: 'http://developers.openfin.co/'},
11457
+ * ];
11458
+ *
11459
+ * // Create a view beforehand to be included in the new tab stack
11460
+ * const outsideView = await fin.View.create({
11461
+ * name: 'outside-bloomberg-view',
11462
+ * url: 'https://bloomberg.com/',
11463
+ * target: fin.me.identity,
11464
+ * });
11465
+ *
11466
+ * // Views to add can be identities, or the reference views mentioned above
11467
+ * const viewsToAdd = [outsideView.identity, ...views];
11468
+ *
11469
+ * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
11470
+ * let stackFrom = await columnOrRow.createAdjacentStack(viewsToAdd, { position: 'right' });
11471
+ * // Or
11472
+ * let newStack = await stack.createAdjacentStack(viewsToAdd, { position: 'right' });
11473
+ * console.log(`A new TabStack created to the right has ${newStack.length} views in it`);
11474
+ *
11475
+ * ```
11476
+ * @experimental
11477
+ */
11478
+ this.createAdjacentStack = async (views, options) => {
11479
+ const entityId = await __classPrivateFieldGet$5(this, _LayoutNode_client, "f").createAdjacentStack(this.entityId, views, options);
11480
+ return LayoutNode.getEntity({ entityId, type: 'stack' }, __classPrivateFieldGet$5(this, _LayoutNode_client, "f"));
11481
+ };
11482
+ /**
11483
+ * Retrieves the adjacent TabStacks of the given TabStack or ColumnOrRow.
11484
+ *
11485
+ * @param edge Edge whose adjacent TabStacks will be returned.
11486
+ *
11487
+ * @example
11488
+ * ```js
11489
+ * if (!fin.me.isView) {
11490
+ * throw new Error('Not running in a platform View.');
11491
+ * }
11492
+ *
11493
+ * const stack = await fin.me.getCurrentStack();
11494
+ * const columnOrRow = await stack.getParent();
11495
+ * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
11496
+ * let rightStacks = await columnOrRow.getAdjacentStacks('right');
11497
+ * let leftStacks = await columnOrRow.getAdjacentStacks('left');
11498
+ * // or
11499
+ * let rightStacks = await stack.getAdjacentStacks('right');
11500
+ * let leftStacks = await stack.getAdjacentStacks('left');
11501
+ *
11502
+ * console.log(`The entity has ${rightStacks.length} stacks to the right, and ${leftStacks.length} stacks to the left`);
11503
+ *
11504
+ * ```
11505
+ * @experimental
11506
+ */
11507
+ this.getAdjacentStacks = async (edge) => {
11508
+ const adjacentStacks = await __classPrivateFieldGet$5(this, _LayoutNode_client, "f").getAdjacentStacks({
11509
+ targetId: this.entityId,
11510
+ edge
11511
+ });
11512
+ return adjacentStacks.map((stack) => LayoutNode.getEntity({
11513
+ type: 'stack',
11514
+ entityId: stack.entityId
11515
+ }, __classPrivateFieldGet$5(this, _LayoutNode_client, "f")));
11516
+ };
11517
+ __classPrivateFieldSet$4(this, _LayoutNode_client, client, "f");
11518
+ this.entityId = entityId;
11519
+ }
11520
+ }
11521
+ layoutEntities.LayoutNode = LayoutNode;
11522
+ _LayoutNode_client = new WeakMap();
11523
+ /**
11524
+ * @ignore
11525
+ * @internal
11526
+ * Encapsulates Api consumption of {@link LayoutEntitiesClient} with a relayed dispatch
11527
+ * @param client
11528
+ * @param controllerId
11529
+ * @param identity
11530
+ * @returns a new instance of {@link LayoutEntitiesClient} with bound to the controllerId
11531
+ */
11532
+ LayoutNode.newLayoutEntitiesClient = async (client, controllerId, identity) => {
11533
+ 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.');
11534
+ const consumer = new api_exposer_1.ApiConsumer(new api_exposer_1.ChannelsConsumer({ dispatch }));
11535
+ return consumer.consume({ id: controllerId });
11536
+ };
11537
+ LayoutNode.getEntity = (definition, client) => {
11538
+ const { entityId, type } = definition;
11539
+ switch (type) {
11540
+ case 'column':
11541
+ case 'row':
11542
+ return new ColumnOrRow(client, entityId, type);
11543
+ case 'stack':
11544
+ return new TabStack(client, entityId);
11545
+ default:
11546
+ throw new Error(`Unrecognised Layout Entity encountered ('${JSON.stringify(definition)})`);
11547
+ }
11548
+ };
11549
+ /**
11550
+ * A TabStack is used to manage the state of a stack of tabs within an OpenFin Layout.
11551
+ */
11552
+ class TabStack extends LayoutNode {
11553
+ /** @internal */
11554
+ constructor(client, entityId) {
11555
+ super(client, entityId);
11556
+ /**
11557
+ * @internal
11558
+ * ApiClient for {@link LayoutEntitiesController}
11559
+ */
11560
+ _TabStack_client.set(this, void 0);
11561
+ /**
11562
+ * Type of the content item. Always stack, but useful for distinguishing between a {@link TabStack} and {@link ColumnOrRow}.
11563
+ */
11564
+ this.type = 'stack';
11565
+ /**
11566
+ * Retrieves a list of all views belonging to this {@link TabStack}.
11567
+ *
11568
+ * Known Issue: If adding a view overflows the tab-container width, the added view will be set as active
11569
+ * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
11570
+ * If that happens and then getViews() is called, it will return the identities in a different order than
11571
+ * than the currently rendered tab order.
11572
+ *
11573
+ *
11574
+ * @throws If the {@link TabStack} has been destroyed.
11575
+ * @example
11576
+ * ```js
11577
+ * if (!fin.me.isView) {
11578
+ * throw new Error('Not running in a platform View.');
11579
+ * }
11580
+ *
11581
+ * const stack = await fin.me.getCurrentStack();
11582
+ * // Alternatively, you can wrap any view and get the stack from there
11583
+ * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
11584
+ * // const stack = await viewFromSomewhere.getCurrentStack();
11585
+ * const views = await stack.getViews();
11586
+ * console.log(`Stack contains ${views.length} view(s)`);
11587
+ * ```
11588
+ * @experimental
11589
+ */
11590
+ this.getViews = () => __classPrivateFieldGet$5(this, _TabStack_client, "f").getStackViews(this.entityId);
11591
+ /**
11592
+ * Adds or creates a view in this {@link TabStack}.
11593
+ *
11594
+ * @remarks Known Issue: If adding a view overflows the tab-container, the added view will be set as active
11595
+ * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
11596
+ *
11597
+ * @param view The identity of an existing view to add, or options to create a view.
11598
+ * @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)
11599
+ * @returns Resolves with the {@link OpenFin.Identity identity} of the added view.
11600
+ * @throws If the view does not exist or fails to create.
11601
+ * @throws If the {@link TabStack} has been destroyed.
11602
+ * @example
11603
+ * ```js
11604
+ * if (!fin.me.isView) {
11605
+ * throw new Error('Not running in a platform View.');
11606
+ * }
11607
+ *
11608
+ * const stack = await fin.me.getCurrentStack();
11609
+ * // Alternatively, you can wrap any view and get the stack from there
11610
+ * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
11611
+ * // const stack = await viewFromSomewhere.getCurrentStack();
11612
+ * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
11613
+ * console.log('Identity of the google view just added', { googleViewIdentity });
11614
+ * // pass in { index: number } to set the index in the stack. Here 1 means, end of the stack (defaults to 0)
11615
+ * const appleViewIdentity = await stack.addView({ name: 'apple-view', url: 'http://apple.com/' }, { index: 1 });
11616
+ * console.log('Identity of the apple view just added', { appleViewIdentity });
11617
+ * ```
11618
+ * @experimental
11619
+ */
11620
+ this.addView = async (view, options = { index: 0 }) => __classPrivateFieldGet$5(this, _TabStack_client, "f").addViewToStack(this.entityId, view, options);
11621
+ /**
11622
+ * Removes a view from this {@link TabStack}.
11623
+ *
11624
+ * @remarks Throws an exception if the view identity does not exist or was already destroyed.
11625
+ *
11626
+ * @param view - Identity of the view to remove.
11627
+ * @throws If the view does not exist or does not belong to the stack.
11628
+ * @throws If the {@link TabStack} has been destroyed.
11629
+ *
11630
+ * @example
11631
+ * ```js
11632
+ * if (!fin.me.isView) {
11633
+ * throw new Error('Not running in a platform View.');
11634
+ * }
11635
+ *
11636
+ * const stack = await fin.me.getCurrentStack();
11637
+ * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
11638
+ *
11639
+ * await stack.removeView(googleViewIdentity);
11640
+ *
11641
+ * try {
11642
+ * await stack.removeView(googleViewIdentity);
11643
+ * } catch (error) {
11644
+ * // Tried to remove a view ('google-view') which does not belong to the stack.
11645
+ * console.log(error);
11646
+ * }
11647
+ * ```
11648
+ */
11649
+ this.removeView = async (view) => {
11650
+ await __classPrivateFieldGet$5(this, _TabStack_client, "f").removeViewFromStack(this.entityId, view);
11651
+ };
11652
+ /**
11653
+ * Sets the active view of the {@link TabStack} without focusing it.
11654
+ * @param view - Identity of the view to activate.
11655
+ * @returns Promise which resolves with void once the view has been activated.
11656
+ * @throws If the {@link TabStack} has been destroyed.
11657
+ * @throws If the view does not exist.
11658
+ * @example
11659
+ * Change the active tab of a known View's TabStack:
11660
+ * ```js
11661
+ * const targetView = fin.View.wrapSync({ uuid: 'uuid', name: 'view-name' });
11662
+ * const stack = await targetView.getCurrentStack();
11663
+ * await stack.setActiveView(targetView.identity);
11664
+ * ```
11665
+ *
11666
+ * Set the current View as active within its TabStack:
11667
+ * ```js
11668
+ * const stack = await fin.me.getCurrentStack();
11669
+ * await stack.setActiveView(fin.me.identity);
11670
+ * ```
11671
+ * @experimental
11672
+ */
11673
+ this.setActiveView = async (view) => {
11674
+ await __classPrivateFieldGet$5(this, _TabStack_client, "f").setStackActiveView(this.entityId, view);
11675
+ };
11676
+ __classPrivateFieldSet$4(this, _TabStack_client, client, "f");
11669
11677
  }
11678
+ }
11679
+ layoutEntities.TabStack = TabStack;
11680
+ _TabStack_client = new WeakMap();
11681
+ /**
11682
+ * A ColumnOrRow is used to manage the state of Column and Rows within an OpenFin Layout.
11683
+ */
11684
+ class ColumnOrRow extends LayoutNode {
11670
11685
  /**
11671
- * Closes a window. If enableBeforeUnload is enabled in the Platform options, any beforeunload handler set on Views will fire
11672
- * This behavior can be disabled by setting skipBeforeUnload to false in the options parameter.
11673
- * @param winId
11674
- * @param options
11675
- *
11676
- * @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,
11677
- * it is recommended to move that logic over to the [PlatformProvider.closeWindow]{@link PlatformProvider#closeWindow} override to ensure it runs when the Window closes.
11678
- *
11679
- * @example
11680
- *
11681
- * ```js
11682
- * // Close the current Window inside a Window context
11683
- * const platform = await fin.Platform.getCurrent();
11684
- * platform.closeWindow(fin.me.identity);
11685
- *
11686
- * // Close the Window from inside a View context
11687
- * const platform = await fin.Platform.getCurrent();
11688
- * const parentWindow = await fin.me.getCurrentWindow();
11689
- * platform.closeWindow(parentWindow.identity);
11690
- *
11691
- * // Close the Window and do not fire the before unload handler on Views
11692
- * const platform = await fin.Platform.getCurrent();
11693
- * platform.closeWindow(fin.me.identity, { skipBeforeUnload: true });
11694
- * ```
11695
- * @experimental
11686
+ * @internal
11696
11687
  */
11697
- async closeWindow(windowId, options = { skipBeforeUnload: false }) {
11698
- this.wire.sendAction('platform-close-window', this.identity).catch((e) => {
11699
- // don't expose
11700
- });
11701
- const client = await this.getClient();
11702
- return client.dispatch('close-window', { windowId, options });
11688
+ constructor(client, entityId, type) {
11689
+ super(client, entityId);
11690
+ /**
11691
+ * @ignore
11692
+ * @internal
11693
+ * ApiClient for {@link LayoutEntitiesController}
11694
+ */
11695
+ _ColumnOrRow_client.set(this, void 0);
11696
+ /**
11697
+ * Retrieves the content array of the ColumnOrRow
11698
+ *
11699
+ * @example
11700
+ * ```js
11701
+ * if (!fin.me.isView) {
11702
+ * throw new Error('Not running in a platform View.');
11703
+ * }
11704
+ *
11705
+ * const stack = await fin.me.getCurrentStack();
11706
+ * // Retrieves the parent ColumnOrRow
11707
+ * const columnOrRow = await stack.getParent();
11708
+ *
11709
+ * // returns [TabStack]
11710
+ * const contentArray = await columnOrRow.getContent();
11711
+ * console.log(`The ColumnOrRow has ${contentArray.length} item(s)`);
11712
+ * ```
11713
+ */
11714
+ this.getContent = async () => {
11715
+ const contentItemEntities = await __classPrivateFieldGet$5(this, _ColumnOrRow_client, "f").getContent(this.entityId);
11716
+ return contentItemEntities.map((entity) => LayoutNode.getEntity(entity, __classPrivateFieldGet$5(this, _ColumnOrRow_client, "f")));
11717
+ };
11718
+ __classPrivateFieldSet$4(this, _ColumnOrRow_client, client, "f");
11719
+ this.type = type;
11703
11720
  }
11704
11721
  }
11705
- Instance$2.Platform = Platform;
11706
- _Platform_connectToProvider = new WeakMap();
11707
-
11708
- var layout = {};
11709
-
11710
- var Factory$2 = {};
11711
-
11712
- var Instance$1 = {};
11722
+ layoutEntities.ColumnOrRow = ColumnOrRow;
11723
+ _ColumnOrRow_client = new WeakMap();
11713
11724
 
11714
- var commonUtils = {};
11725
+ var layout_constants = {};
11715
11726
 
11716
- Object.defineProperty(commonUtils, "__esModule", { value: true });
11717
- commonUtils.overrideFromComposables = commonUtils.isValidPresetType = void 0;
11718
- function isValidPresetType(type) {
11719
- switch (type) {
11720
- case 'columns':
11721
- case 'grid':
11722
- case 'rows':
11723
- case 'tabs':
11724
- return true;
11725
- default:
11726
- return false;
11727
- }
11728
- }
11729
- commonUtils.isValidPresetType = isValidPresetType;
11730
- function overrideFromComposables(...overrides) {
11731
- return (base) => overrides.reduceRight((p, c) => (b) => c(p(b)), (x) => x)(base);
11732
- }
11733
- commonUtils.overrideFromComposables = overrideFromComposables;
11734
- commonUtils.default = { isValidPresetType };
11727
+ Object.defineProperty(layout_constants, "__esModule", { value: true });
11728
+ layout_constants.DEFAULT_LAYOUT_KEY = layout_constants.LAYOUT_CONTROLLER_ID = void 0;
11729
+ layout_constants.LAYOUT_CONTROLLER_ID = 'layout-entities';
11730
+ // TODO: eventually export this somehow
11731
+ layout_constants.DEFAULT_LAYOUT_KEY = '__default__';
11735
11732
 
11736
11733
  var __classPrivateFieldGet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
11737
11734
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
@@ -11880,6 +11877,12 @@ const layout_constants_1$1 = layout_constants;
11880
11877
  * ```
11881
11878
  */
11882
11879
  class Layout extends base_1$5.Base {
11880
+ /**
11881
+ * @internal
11882
+ */
11883
+ static getClient(layout) {
11884
+ return __classPrivateFieldGet$4(layout, _Layout_layoutClient, "f").getValue();
11885
+ }
11883
11886
  /**
11884
11887
  * @internal
11885
11888
  */
@@ -12104,6 +12107,27 @@ class Layout extends base_1$5.Base {
12104
12107
  const root = await client.getRoot('layoutName' in this.identity ? this.identity : undefined);
12105
12108
  return layout_entities_1.LayoutNode.getEntity(root, client);
12106
12109
  }
12110
+ /**
12111
+ * Retrieves the OpenFin.TabStack instance which the View belongs to.
12112
+ *
12113
+ * @example
12114
+ * ```js
12115
+ * const viewIdentity = { uuid: 'uuid', name: 'view-name' };
12116
+ * const stack = await fin.View.wrapSync(viewIdentity).getStackByViewIdentity(viewIdentity);
12117
+ * console.log(await stack.getViews());
12118
+ * ```
12119
+ */
12120
+ async getStackByViewIdentity(identity) {
12121
+ this.wire.sendAction('layout-get-stack-by-view').catch(() => {
12122
+ // don't expose
12123
+ });
12124
+ const client = await __classPrivateFieldGet$4(this, _Layout_layoutClient, "f").getValue();
12125
+ const stack = await client.getStackByView(identity);
12126
+ if (!stack) {
12127
+ throw new Error(`No stack found for view: ${identity.uuid}/${identity.name}`);
12128
+ }
12129
+ return layout_entities_1.LayoutNode.getEntity(stack, client);
12130
+ }
12107
12131
  }
12108
12132
  Instance$1.Layout = Layout;
12109
12133
  _Layout_layoutClient = new WeakMap();
@@ -12297,7 +12321,7 @@ class LayoutModule extends base_1$4.Base {
12297
12321
  this.wire.sendAction('layout-get-current').catch((e) => {
12298
12322
  // don't expose
12299
12323
  });
12300
- if (!this.fin.me.isWindow) {
12324
+ if (this.wire.environment.type === 'openfin' && !this.fin.me.isWindow) {
12301
12325
  throw new Error('You are not in a Window context. Only Windows can have a Layout.');
12302
12326
  }
12303
12327
  const { uuid, name } = this.fin.me;
@@ -12320,12 +12344,50 @@ class LayoutModule extends base_1$4.Base {
12320
12344
  this.wire.sendAction('layout-get-current-sync').catch((e) => {
12321
12345
  // don't expose
12322
12346
  });
12323
- if (!this.fin.me.isWindow) {
12347
+ if (this.wire.environment.type === 'openfin' && !this.fin.me.isWindow) {
12324
12348
  throw new Error('You are not in a Window context. Only Windows can have a Layout.');
12325
12349
  }
12326
12350
  const { uuid, name } = this.fin.me;
12327
12351
  return this.wrapSync({ uuid, name });
12328
12352
  }
12353
+ /**
12354
+ * Retrieves the OpenFin.Layout instance for the Window the View is attached to.
12355
+ *
12356
+ * @example
12357
+ * ```js
12358
+ * const viewIdentity = { uuid: 'uuid', name: 'view-name' };
12359
+ * const layout = await fin.Platform.Layout.getLayoutByViewIdentity(viewIdentity);
12360
+ * console.log(await layout.getCurrentViews());
12361
+ * ```
12362
+ */
12363
+ async getLayoutByViewIdentity(viewIdentity) {
12364
+ this.wire.sendAction('layout-get-by-view-identity').catch(() => {
12365
+ // don't expose
12366
+ });
12367
+ const winIdentity = await this.wire.environment.getViewWindowIdentity(this.fin, viewIdentity);
12368
+ let layoutWindowIdentity = winIdentity;
12369
+ // TODO: CORE-1857 - when we tearout active layout or drag a view out of a window, the above identity includes the whole window info.
12370
+ if (layoutWindowIdentity.identity) {
12371
+ layoutWindowIdentity = layoutWindowIdentity.identity;
12372
+ }
12373
+ try {
12374
+ const layoutWindow = this.wrapSync(layoutWindowIdentity);
12375
+ const client = await Instance_1$2.Layout.getClient(layoutWindow);
12376
+ const layoutIdentity = await client.getLayoutIdentityForViewOrThrow(viewIdentity);
12377
+ return this.wrapSync(layoutIdentity);
12378
+ }
12379
+ catch (e) {
12380
+ const allowedErrors = [
12381
+ 'No action registered at target for',
12382
+ 'getLayoutIdentityForViewOrThrow is not a function'
12383
+ ];
12384
+ if (!allowedErrors.some((m) => e.message.includes(m))) {
12385
+ throw e;
12386
+ }
12387
+ // fallback logic for missing endpoint in older runtimes
12388
+ return this.wrapSync(layoutWindowIdentity);
12389
+ }
12390
+ }
12329
12391
  }
12330
12392
  Factory$2.LayoutModule = LayoutModule;
12331
12393
  _LayoutModule_layoutInitializationAttempted = new WeakMap(), _LayoutModule_layoutManager = new WeakMap(), _LayoutModule_getLayoutManagerSpy = new WeakMap(), _LayoutModule_instances = new WeakSet(), _LayoutModule_getSafeLayoutManager = function _LayoutModule_getSafeLayoutManager(method) {
@@ -13312,13 +13374,16 @@ function requireInteropBroker () {
13312
13374
  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");
13313
13375
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
13314
13376
  };
13377
+ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
13378
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13379
+ };
13315
13380
  var _InteropBroker_fdc3Info, _InteropBroker_contextGroups, _InteropBroker_providerPromise;
13316
13381
  Object.defineProperty(InteropBroker, "__esModule", { value: true });
13317
13382
  InteropBroker.InteropBroker = void 0;
13318
13383
  const base_1 = base;
13319
- const SessionContextGroupBroker_1 = requireSessionContextGroupBroker();
13384
+ const SessionContextGroupBroker_1 = __importDefault(requireSessionContextGroupBroker());
13320
13385
  const utils_1 = utils$3;
13321
- const lodash_1 = require$$3;
13386
+ const isEqual_1 = __importDefault(require$$3);
13322
13387
  const PrivateChannelProvider_1 = requirePrivateChannelProvider();
13323
13388
  const lazy_1 = lazy;
13324
13389
  const defaultContextGroups = [
@@ -13516,7 +13581,7 @@ function requireInteropBroker () {
13516
13581
  constructor(...unused) {
13517
13582
  if (unused.length) {
13518
13583
  const [_ignore1, ignore2, opts] = unused;
13519
- if (opts && typeof opts === 'object' && !(0, lodash_1.isEqual)(opts, args[2])) {
13584
+ if (opts && typeof opts === 'object' && !(0, isEqual_1.default)(opts, args[2])) {
13520
13585
  // eslint-disable-next-line no-console
13521
13586
  console.warn('You have modified the parameters of the InteropOverride constructor. This behavior is deprecated and will be removed in a future version. You can modify these options in your manifest. Please consult our Interop docs for guidance on migrating to the new override scheme.');
13522
13587
  super(args[0], args[1], opts);
@@ -14693,9 +14758,32 @@ var utils$2 = {};
14693
14758
 
14694
14759
  var PrivateChannelClient$1 = {};
14695
14760
 
14761
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14762
+ if (k2 === undefined) k2 = k;
14763
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14764
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
14765
+ desc = { enumerable: true, get: function() { return m[k]; } };
14766
+ }
14767
+ Object.defineProperty(o, k2, desc);
14768
+ }) : (function(o, m, k, k2) {
14769
+ if (k2 === undefined) k2 = k;
14770
+ o[k2] = m[k];
14771
+ }));
14772
+ var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) {
14773
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14774
+ }) : function(o, v) {
14775
+ o["default"] = v;
14776
+ });
14777
+ var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
14778
+ if (mod && mod.__esModule) return mod;
14779
+ var result = {};
14780
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
14781
+ __setModuleDefault(result, mod);
14782
+ return result;
14783
+ };
14696
14784
  Object.defineProperty(PrivateChannelClient$1, "__esModule", { value: true });
14697
14785
  PrivateChannelClient$1.PrivateChannelClient = void 0;
14698
- const utils$1 = utils$3;
14786
+ const utils$1 = __importStar(utils$3);
14699
14787
  class PrivateChannelClient {
14700
14788
  constructor(client, id) {
14701
14789
  this.id = id;
@@ -14784,11 +14872,14 @@ class PrivateChannelClient {
14784
14872
  PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
14785
14873
 
14786
14874
  (function (exports) {
14875
+ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
14876
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14877
+ };
14787
14878
  Object.defineProperty(exports, "__esModule", { value: true });
14788
14879
  exports.getIntentResolution = exports.isChannel = exports.isContext = exports.connectPrivateChannel = exports.buildAppChannelObject = exports.buildPrivateChannelObject = exports.ChannelError = exports.ResultError = exports.UnsupportedChannelApiError = exports.getUnsupportedChannelApis = void 0;
14789
14880
  const utils_1 = utils$3;
14790
14881
  const PrivateChannelClient_1 = PrivateChannelClient$1;
14791
- const lodash_1 = require$$3;
14882
+ const isEqual_1 = __importDefault(require$$3);
14792
14883
  const getUnsupportedChannelApis = (channelType) => {
14793
14884
  return {
14794
14885
  addContextListener: () => {
@@ -14916,7 +15007,7 @@ PrivateChannelClient$1.PrivateChannelClient = PrivateChannelClient;
14916
15007
  const wrappedHandler = (context, contextMetadata) => {
14917
15008
  if (first) {
14918
15009
  first = false;
14919
- if ((0, lodash_1.isEqual)(currentContext, context)) {
15010
+ if ((0, isEqual_1.default)(currentContext, context)) {
14920
15011
  return;
14921
15012
  }
14922
15013
  }
@@ -15038,13 +15129,16 @@ function requireFdc3Common () {
15038
15129
  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");
15039
15130
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
15040
15131
  };
15132
+ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
15133
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15134
+ };
15041
15135
  var _FDC3ModuleBase_producer;
15042
15136
  Object.defineProperty(fdc3Common, "__esModule", { value: true });
15043
15137
  fdc3Common.FDC3ModuleBase = void 0;
15044
15138
  const utils_1 = utils$2;
15045
15139
  const utils_2 = utils$3;
15046
15140
  const InteropClient_1 = requireInteropClient();
15047
- const lodash_1 = require$$3;
15141
+ const isEqual_1 = __importDefault(require$$3);
15048
15142
  class FDC3ModuleBase {
15049
15143
  get client() {
15050
15144
  return __classPrivateFieldGet(this, _FDC3ModuleBase_producer, "f").call(this);
@@ -15233,7 +15327,7 @@ function requireFdc3Common () {
15233
15327
  const wrappedHandler = (context, contextMetadata) => {
15234
15328
  if (first) {
15235
15329
  first = false;
15236
- if ((0, lodash_1.isEqual)(currentContext, context)) {
15330
+ if ((0, isEqual_1.default)(currentContext, context)) {
15237
15331
  return;
15238
15332
  }
15239
15333
  }
@@ -15846,11 +15940,14 @@ function requireInteropClient () {
15846
15940
  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");
15847
15941
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15848
15942
  };
15943
+ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
15944
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15945
+ };
15849
15946
  var _InteropClient_clientPromise, _InteropClient_sessionContextGroups;
15850
15947
  Object.defineProperty(InteropClient, "__esModule", { value: true });
15851
15948
  InteropClient.InteropClient = void 0;
15852
15949
  const base_1 = base;
15853
- const SessionContextGroupClient_1 = SessionContextGroupClient$1;
15950
+ const SessionContextGroupClient_1 = __importDefault(SessionContextGroupClient$1);
15854
15951
  const fdc3_1_2_1 = requireFdc31_2();
15855
15952
  const fdc3_2_0_1 = requireFdc32_0();
15856
15953
  const utils_1 = utils$3;
@@ -16490,9 +16587,12 @@ var hasRequiredFactory;
16490
16587
  function requireFactory () {
16491
16588
  if (hasRequiredFactory) return Factory$1;
16492
16589
  hasRequiredFactory = 1;
16590
+ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
16591
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16592
+ };
16493
16593
  Object.defineProperty(Factory$1, "__esModule", { value: true });
16494
16594
  Factory$1.InteropModule = void 0;
16495
- const lodash_1 = require$$3;
16595
+ const cloneDeep_1 = __importDefault(require$$0$1);
16496
16596
  const inaccessibleObject_1 = inaccessibleObject;
16497
16597
  const base_1 = base;
16498
16598
  const InteropBroker_1 = requireInteropBroker();
@@ -16529,7 +16629,7 @@ function requireFactory () {
16529
16629
  // Allows for manifest-level configuration, without having to override. (e.g. specifying custom context groups)
16530
16630
  const options = await this.wire.environment.getInteropInfo(this.wire.getFin());
16531
16631
  const objectThatThrows = (0, inaccessibleObject_1.createUnusableObject)(BrokerParamAccessError);
16532
- const warningOptsClone = (0, inaccessibleObject_1.createWarningObject)(BrokerParamAccessError, (0, lodash_1.cloneDeep)(options));
16632
+ const warningOptsClone = (0, inaccessibleObject_1.createWarningObject)(BrokerParamAccessError, (0, cloneDeep_1.default)(options));
16533
16633
  const getProvider = () => {
16534
16634
  return this.fin.InterApplicationBus.Channel.create(`interop-broker-${name}`);
16535
16635
  };
@@ -17086,13 +17186,16 @@ var __classPrivateFieldGet = (commonjsGlobal && commonjsGlobal.__classPrivateFie
17086
17186
  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");
17087
17187
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
17088
17188
  };
17189
+ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
17190
+ return (mod && mod.__esModule) ? mod : { "default": mod };
17191
+ };
17089
17192
  var _Transport_wire, _Transport_fin;
17090
17193
  Object.defineProperty(transport, "__esModule", { value: true });
17091
17194
  var Transport_1 = transport.Transport = void 0;
17092
17195
  const events_1$1 = require$$0;
17093
17196
  const wire_1 = wire;
17094
17197
  const transport_errors_1 = transportErrors;
17095
- const eventAggregator_1 = eventAggregator;
17198
+ const eventAggregator_1 = __importDefault(eventAggregator);
17096
17199
  const me_1$1 = me;
17097
17200
  const errors_1 = errors;
17098
17201
  class Transport extends events_1$1.EventEmitter {
@@ -17319,6 +17422,9 @@ class MockEnvironment {
17319
17422
  async getInteropInfo() {
17320
17423
  throw new Error(me_1.environmentUnsupportedMessage);
17321
17424
  }
17425
+ async getViewWindowIdentity() {
17426
+ throw new Error(me_1.environmentUnsupportedMessage);
17427
+ }
17322
17428
  getDefaultChannelOptions() {
17323
17429
  throw new Error(me_1.environmentUnsupportedMessage);
17324
17430
  }