@openfin/node-adapter 40.82.19 → 40.82.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/out/node-adapter.js +1001 -972
  2. package/package.json +2 -2
@@ -767,781 +767,117 @@ class AsyncRetryableLazy {
767
767
  }
768
768
  lazy.AsyncRetryableLazy = AsyncRetryableLazy;
769
769
 
770
- var layoutEntities = {};
771
-
772
- var apiExposer$1 = {};
773
-
774
- var apiConsumer = {};
775
-
776
- Object.defineProperty(apiConsumer, "__esModule", { value: true });
777
- apiConsumer.ApiConsumer = void 0;
778
- /**
779
- * Consumer for apis exposed with {@see ApiExposer}.
780
- *
781
- * A strategy that matches the strategy used to expose a target API must be provided.
782
- */
783
- class ApiConsumer {
784
- // eslint-disable-next-line
785
- constructor(strategy) {
786
- this.strategy = strategy;
787
- /**
788
- * Consumes an api exposed using a given transport strategy, and generates a client
789
- * for easy, type safe consumption of that client.
790
- * @param options Strategy specific consumption options.
791
- * @returns An api client matching the given type.
792
- */
793
- this.consume = async (options) => {
794
- const exposedProperties = await this.strategy.getExposedFunctions(options);
795
- return exposedProperties.reduce((client, prop) => ({
796
- ...client,
797
- [prop.key]: this.strategy.createFunction(prop, options)
798
- }), {});
799
- };
800
- }
801
- }
802
- apiConsumer.ApiConsumer = ApiConsumer;
803
-
804
- var apiExposer = {};
805
-
806
- var decorators = {};
807
-
808
- Object.defineProperty(decorators, "__esModule", { value: true });
809
- decorators.expose = decorators.getExposedProperties = void 0;
810
- const exposedProperties = Symbol('exposedProperties');
811
- const getExposedProperties = (target) => {
812
- return target[exposedProperties] || target.prototype[exposedProperties] || [];
813
- };
814
- decorators.getExposedProperties = getExposedProperties;
815
- /**
816
- * Indicates that a class member function can be exposed using {@link ApiExposer}.
817
- * @param options Options specific to the strategy used in {@link ApiExposer}
818
- */
819
- // Returns any as decorator typing is weird.
820
- const expose = (options) => (target, key, descriptor) => {
821
- target[exposedProperties] = target[exposedProperties] || [];
822
- target[exposedProperties].push({ key, descriptor, options });
823
- };
824
- decorators.expose = expose;
770
+ var main = {};
825
771
 
826
- Object.defineProperty(apiExposer, "__esModule", { value: true });
827
- apiExposer.ApiExposer = void 0;
828
- const decorators_1 = decorators;
829
- /**
830
- * Exposes api services on the transport of choice.
831
- */
832
- class ApiExposer {
772
+ Object.defineProperty(main, "__esModule", { value: true });
773
+ main.WebContents = void 0;
774
+ const base_1$j = base;
775
+ class WebContents extends base_1$j.EmitterBase {
833
776
  /**
834
- * @param strategy The expose strategy to use to expose instances.
777
+ * @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
778
+ * @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
835
779
  */
836
- // eslint-disable-next-line
837
- constructor(strategy) {
838
- this.strategy = strategy;
839
- /**
840
- * Exposes an instance of a given api on
841
- * @param instance Instance of a class which has been decorated to indicate which functions can be exposed.
842
- * @param instanceOptions Transport strategy specific options to use when exposing.
843
- */
844
- this.exposeInstance = async (instance, instanceOptions) => {
845
- const exposableProps = (0, decorators_1.getExposedProperties)(instance);
846
- const exposedProps = await Promise.all(exposableProps.map(async ({ key, options }) => {
847
- const customConsumptionOptions = await this.strategy.exposeFunction(instance[key].bind(instance), {
848
- key,
849
- options,
850
- meta: instanceOptions
851
- });
852
- return {
853
- key,
854
- options: customConsumptionOptions
855
- };
856
- }));
857
- await this.strategy.exposeMeta(instanceOptions, exposedProps);
858
- };
780
+ constructor(wire, identity, entityType) {
781
+ super(wire, entityType, identity.uuid, identity.name);
782
+ this.identity = identity;
783
+ this.entityType = entityType;
859
784
  }
860
- ;
861
- }
862
- apiExposer.ApiExposer = ApiExposer;
863
-
864
- var strategies = {};
865
-
866
- var openfinChannels = {};
867
-
868
- var channelsConsumer = {};
869
-
870
- Object.defineProperty(channelsConsumer, "__esModule", { value: true });
871
- channelsConsumer.ChannelsConsumer = void 0;
872
- class ChannelsConsumer {
873
- // eslint-disable-next-line
874
- constructor(channel) {
875
- this.channel = channel;
876
- this.getExposedFunctions = async (options) => {
877
- const { id } = options;
878
- const { props } = await this.channel.dispatch(`api-meta:${id}`);
879
- return props;
880
- };
881
- this.createFunction = (prop) => (...args) => {
882
- const { action } = prop.options;
883
- return this.channel.dispatch(action, { args });
884
- };
785
+ /**
786
+ * Gets a base64 encoded image of all or part of the WebContents.
787
+ * @param options Options for the capturePage call.
788
+ *
789
+ * @example
790
+ *
791
+ * View:
792
+ * ```js
793
+ * const view = fin.View.getCurrentSync();
794
+ *
795
+ * // PNG image of a full visible View
796
+ * console.log(await view.capturePage());
797
+ *
798
+ * // Low-quality JPEG image of a defined visible area of the view
799
+ * const options = {
800
+ * area: {
801
+ * height: 100,
802
+ * width: 100,
803
+ * x: 10,
804
+ * y: 10,
805
+ * },
806
+ * format: 'jpg',
807
+ * quality: 20
808
+ * }
809
+ * console.log(await view.capturePage(options));
810
+ * ```
811
+ *
812
+ * Window:
813
+ * ```js
814
+ * const wnd = await fin.Window.getCurrent();
815
+ *
816
+ * // PNG image of a full visible window
817
+ * console.log(await wnd.capturePage());
818
+ *
819
+ * // Low-quality JPEG image of a defined visible area of the window
820
+ * const options = {
821
+ * area: {
822
+ * height: 100,
823
+ * width: 100,
824
+ * x: 10,
825
+ * y: 10,
826
+ * },
827
+ * format: 'jpg',
828
+ * quality: 20
829
+ * }
830
+ * console.log(await wnd.capturePage(options));
831
+ * ```
832
+ *
833
+ * @remarks
834
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
835
+ * We do not expose an explicit superclass for this functionality, but it does have its own
836
+ * {@link OpenFin.WebContentsEvents event namespace}.
837
+ */
838
+ capturePage(options) {
839
+ return this.wire.sendAction('capture-page', { options, ...this.identity }).then(({ payload }) => payload.data);
885
840
  }
886
- ;
887
- }
888
- channelsConsumer.ChannelsConsumer = ChannelsConsumer;
889
-
890
- var channelsExposer = {};
891
-
892
- Object.defineProperty(channelsExposer, "__esModule", { value: true });
893
- channelsExposer.ChannelsExposer = void 0;
894
- class ChannelsExposer {
895
- // eslint-disable-next-line
896
- constructor(channelProviderOrClient) {
897
- this.channelProviderOrClient = channelProviderOrClient;
898
- this.exposeFunction = async (target, config) => {
899
- const { key, options, meta } = config;
900
- const { id } = meta;
901
- const action = `${id}.${options?.action || key}`;
902
- await this.channelProviderOrClient.register(action, async ({ args }) => {
903
- return target(...args);
904
- });
905
- return { action };
906
- };
907
- this.exposeMeta = async ({ id }, props) => {
908
- const action = `api-meta:${id}`;
909
- await this.channelProviderOrClient.register(action, () => ({ props }));
910
- };
911
- }
912
- }
913
- channelsExposer.ChannelsExposer = ChannelsExposer;
914
-
915
- (function (exports) {
916
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
917
- if (k2 === undefined) k2 = k;
918
- var desc = Object.getOwnPropertyDescriptor(m, k);
919
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
920
- desc = { enumerable: true, get: function() { return m[k]; } };
921
- }
922
- Object.defineProperty(o, k2, desc);
923
- }) : (function(o, m, k, k2) {
924
- if (k2 === undefined) k2 = k;
925
- o[k2] = m[k];
926
- }));
927
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
928
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
929
- };
930
- Object.defineProperty(exports, "__esModule", { value: true });
931
- __exportStar(channelsConsumer, exports);
932
- __exportStar(channelsExposer, exports);
933
- } (openfinChannels));
934
-
935
- (function (exports) {
936
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
937
- if (k2 === undefined) k2 = k;
938
- var desc = Object.getOwnPropertyDescriptor(m, k);
939
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
940
- desc = { enumerable: true, get: function() { return m[k]; } };
941
- }
942
- Object.defineProperty(o, k2, desc);
943
- }) : (function(o, m, k, k2) {
944
- if (k2 === undefined) k2 = k;
945
- o[k2] = m[k];
946
- }));
947
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
948
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
949
- };
950
- Object.defineProperty(exports, "__esModule", { value: true });
951
- __exportStar(openfinChannels, exports);
952
- } (strategies));
953
-
954
- (function (exports) {
955
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
956
- if (k2 === undefined) k2 = k;
957
- var desc = Object.getOwnPropertyDescriptor(m, k);
958
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
959
- desc = { enumerable: true, get: function() { return m[k]; } };
960
- }
961
- Object.defineProperty(o, k2, desc);
962
- }) : (function(o, m, k, k2) {
963
- if (k2 === undefined) k2 = k;
964
- o[k2] = m[k];
965
- }));
966
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
967
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
968
- };
969
- Object.defineProperty(exports, "__esModule", { value: true });
970
- __exportStar(apiConsumer, exports);
971
- __exportStar(apiExposer, exports);
972
- __exportStar(strategies, exports);
973
- __exportStar(decorators, exports);
974
- } (apiExposer$1));
975
-
976
- var channelApiRelay = {};
977
-
978
- Object.defineProperty(channelApiRelay, "__esModule", { value: true });
979
- channelApiRelay.createRelayedDispatch = channelApiRelay.relayChannelClientApi = void 0;
980
- const EXPECTED_ERRORS = [
981
- 'no longer connected',
982
- 'RTCDataChannel closed unexpectedly',
983
- 'The client you are trying to dispatch from is disconnected from the target provider',
984
- ];
985
- // Checks possible error messages that we want to trap, client error message can originate
986
- // from ChannelProvider::dispatch OR ClassicStrategy::closeEndpoint OR RTCEndPoint::dataChannel::onclose
987
- const isDisconnectedError = (errorMsg) => {
988
- return EXPECTED_ERRORS.some(e => errorMsg.includes(e));
989
- };
990
- /**
991
- * @internal
992
- * Create a channel relay for a given channel exposition, allowing a single provider to route
993
- * actions to the designated clients.
994
- *
995
- * Designed to be used in conjunction with @expose
996
- *
997
- * @param channelProvider The channel provider to relay the actions on.
998
- * @param config Determines which actions to relay. Please ensure action prefix matches the exposed api.
999
- */
1000
- const relayChannelClientApi = async (channelProvider, relayId) => {
1001
- channelProvider.register(`relay:${relayId}`, ({ action, target, payload }) => {
1002
- return channelProvider.dispatch(target, action, payload);
1003
- });
1004
- await Promise.resolve();
1005
- };
1006
- channelApiRelay.relayChannelClientApi = relayChannelClientApi;
1007
- const createRelayedDispatch = (client, target, relayId, relayErrorMsg) => async (action, payload) => {
1008
- try {
1009
- return await client.dispatch(`relay:${relayId}`, {
1010
- action,
1011
- payload,
1012
- target
1013
- });
1014
- }
1015
- catch (e) {
1016
- if (isDisconnectedError(e.message) && relayErrorMsg) {
1017
- throw new Error(relayErrorMsg);
1018
- }
1019
- throw e;
1020
- }
1021
- };
1022
- channelApiRelay.createRelayedDispatch = createRelayedDispatch;
1023
-
1024
- var __classPrivateFieldSet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
1025
- if (kind === "m") throw new TypeError("Private method is not writable");
1026
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
1027
- 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");
1028
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1029
- };
1030
- var __classPrivateFieldGet$d = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
1031
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1032
- 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");
1033
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1034
- };
1035
- var _LayoutNode_client, _TabStack_client, _ColumnOrRow_client;
1036
- Object.defineProperty(layoutEntities, "__esModule", { value: true });
1037
- layoutEntities.ColumnOrRow = layoutEntities.TabStack = layoutEntities.LayoutNode = void 0;
1038
- const api_exposer_1 = apiExposer$1;
1039
- const channel_api_relay_1 = channelApiRelay;
1040
- /*
1041
- This file includes LayoutNode, ColumnOrRow and TabStack classes, which are all closely
1042
- intertwined, and share members via parent abstract class LayoutNode. To prevent circular
1043
- refs, we define and export all the classes here.
1044
- */
1045
- /**
1046
- * @ignore
1047
- * @internal
1048
- * Supplies an ApiClient for {@link LayoutEntitiesController} and helper methods
1049
- * for the entities {@link TabStack} AND {@link ColumnOrRow} to use.
1050
- */
1051
- class LayoutNode {
1052
- /**
1053
- * @internal
1054
- * @ignore
1055
- */
1056
- constructor(client, entityId) {
1057
- /**
1058
- * @ignore
1059
- * @internal
1060
- * ApiClient for {@link LayoutEntitiesController}
1061
- */
1062
- _LayoutNode_client.set(this, void 0);
1063
- /**
1064
- * Checks if the TabStack or ColumnOrRow is the root content item
1065
- *
1066
- * @example
1067
- * ```js
1068
- * if (!fin.me.isView) {
1069
- * throw new Error('Not running in a platform View.');
1070
- * }
1071
- *
1072
- * const stack = await fin.me.getCurrentStack();
1073
- * const isRoot = await stack.isRoot();
1074
- * // The TabStack is root: false
1075
- * console.log(`The TabStack is root: ${isRoot}`);
1076
- *
1077
- * // Retrieves the parent ColumnOrRow
1078
- * const parent = await stack.getParent();
1079
- * const parentIsRoot = await parent.isRoot();
1080
- * // The parent ColumnOrRow is root: true
1081
- * console.log(`The parent ColumnOrRow is root: ${parentIsRoot}`);
1082
- * ```
1083
- */
1084
- this.isRoot = () => __classPrivateFieldGet$d(this, _LayoutNode_client, "f").isRoot(this.entityId);
1085
- /**
1086
- * Checks if the TabStack or ColumnOrRow exists
1087
- *
1088
- * @example
1089
- * ```js
1090
- * if (!fin.me.isView) {
1091
- * throw new Error('Not running in a platform View.');
1092
- * }
1093
- *
1094
- * const stack = await fin.me.getCurrentStack();
1095
- * // Retrieves the parent ColumnOrRow
1096
- * const columnOrRow = await stack.getParent();
1097
- * let exists = await stack.exists();
1098
- * // or
1099
- * let exists = await columnOrRow.exists();
1100
- * // The entity exists: true
1101
- * console.log(`The entity exists: ${exists}`);
1102
- * ```
1103
- */
1104
- this.exists = () => __classPrivateFieldGet$d(this, _LayoutNode_client, "f").exists(this.entityId);
1105
- /**
1106
- * Retrieves the parent of the TabStack or ColumnOrRow
1107
- *
1108
- * @example
1109
- * ```js
1110
- * if (!fin.me.isView) {
1111
- * throw new Error('Not running in a platform View.');
1112
- * }
1113
- *
1114
- * const stack = await fin.me.getCurrentStack();
1115
- * // Retrieves the parent ColumnOrRow
1116
- * const columnOrRow = await stack.getParent();
1117
- *
1118
- * // undefined if entity is the root item
1119
- * let parent = await columnOrRow.getParent();
1120
- * // or
1121
- * let parent = await stack.getParent();
1122
- * ```
1123
- */
1124
- this.getParent = async () => {
1125
- const parent = await __classPrivateFieldGet$d(this, _LayoutNode_client, "f").getParent(this.entityId);
1126
- if (!parent) {
1127
- return undefined;
1128
- }
1129
- return LayoutNode.getEntity(parent, __classPrivateFieldGet$d(this, _LayoutNode_client, "f"));
1130
- };
1131
- /**
1132
- * Creates a new TabStack adjacent to the given TabStack or ColumnOrRow. Inputs can be new views to create, or existing views.
1133
- *
1134
- * Known Issue: If the number of views to add overflows the tab-container, the added views will be set as active
1135
- * during each render, and then placed at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
1136
- * This means the views you pass to createAdjacentStack() may not render in the order given by the array.
1137
- * Until fixed, this problem can be avoided only if your window is wide enough to fit creating all the views in the tabstack.
1138
- *
1139
- * @param views The views that will populate the new TabStack.
1140
- * @param options Additional options that control new TabStack creation.
1141
- * @returns The newly-created TabStack.
1142
- *
1143
- * @example
1144
- * ```js
1145
- * if (!fin.me.isView) {
1146
- * throw new Error('Not running in a platform View.');
1147
- * }
1148
- *
1149
- * const stack = await fin.me.getCurrentStack();
1150
- * const columnOrRow = await stack.getParent();
1151
- *
1152
- * // Create view references by supplying a 'name' and 'url'
1153
- * const views = [
1154
- * // if 'name' is undefined, one will be generated
1155
- * // if 'url' is undefined, it will default the view URL to 'about:blank'
1156
- * { name: 'google-view', url: 'http://google.com/'},
1157
- * { name: 'of-developers-view', url: 'http://developers.openfin.co/'},
1158
- * ];
1159
- *
1160
- * // Create a view beforehand to be included in the new tab stack
1161
- * const outsideView = await fin.View.create({
1162
- * name: 'outside-bloomberg-view',
1163
- * url: 'https://bloomberg.com/',
1164
- * target: fin.me.identity,
1165
- * });
1166
- *
1167
- * // Views to add can be identities, or the reference views mentioned above
1168
- * const viewsToAdd = [outsideView.identity, ...views];
1169
- *
1170
- * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
1171
- * let stackFrom = await columnOrRow.createAdjacentStack(viewsToAdd, { position: 'right' });
1172
- * // Or
1173
- * let newStack = await stack.createAdjacentStack(viewsToAdd, { position: 'right' });
1174
- * console.log(`A new TabStack created to the right has ${newStack.length} views in it`);
1175
- *
1176
- * ```
1177
- * @experimental
1178
- */
1179
- this.createAdjacentStack = async (views, options) => {
1180
- const entityId = await __classPrivateFieldGet$d(this, _LayoutNode_client, "f").createAdjacentStack(this.entityId, views, options);
1181
- return LayoutNode.getEntity({ entityId, type: 'stack' }, __classPrivateFieldGet$d(this, _LayoutNode_client, "f"));
1182
- };
1183
- /**
1184
- * Retrieves the adjacent TabStacks of the given TabStack or ColumnOrRow.
1185
- *
1186
- * @param edge Edge whose adjacent TabStacks will be returned.
1187
- *
1188
- * @example
1189
- * ```js
1190
- * if (!fin.me.isView) {
1191
- * throw new Error('Not running in a platform View.');
1192
- * }
1193
- *
1194
- * const stack = await fin.me.getCurrentStack();
1195
- * const columnOrRow = await stack.getParent();
1196
- * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
1197
- * let rightStacks = await columnOrRow.getAdjacentStacks('right');
1198
- * let leftStacks = await columnOrRow.getAdjacentStacks('left');
1199
- * // or
1200
- * let rightStacks = await stack.getAdjacentStacks('right');
1201
- * let leftStacks = await stack.getAdjacentStacks('left');
1202
- *
1203
- * console.log(`The entity has ${rightStacks.length} stacks to the right, and ${leftStacks.length} stacks to the left`);
1204
- *
1205
- * ```
1206
- * @experimental
1207
- */
1208
- this.getAdjacentStacks = async (edge) => {
1209
- const adjacentStacks = await __classPrivateFieldGet$d(this, _LayoutNode_client, "f").getAdjacentStacks({
1210
- targetId: this.entityId,
1211
- edge
1212
- });
1213
- return adjacentStacks.map((stack) => LayoutNode.getEntity({
1214
- type: 'stack',
1215
- entityId: stack.entityId
1216
- }, __classPrivateFieldGet$d(this, _LayoutNode_client, "f")));
1217
- };
1218
- __classPrivateFieldSet$c(this, _LayoutNode_client, client, "f");
1219
- this.entityId = entityId;
1220
- }
1221
- }
1222
- layoutEntities.LayoutNode = LayoutNode;
1223
- _LayoutNode_client = new WeakMap();
1224
- /**
1225
- * @ignore
1226
- * @internal
1227
- * Encapsulates Api consumption of {@link LayoutEntitiesClient} with a relayed dispatch
1228
- * @param client
1229
- * @param controllerId
1230
- * @param identity
1231
- * @returns a new instance of {@link LayoutEntitiesClient} with bound to the controllerId
1232
- */
1233
- LayoutNode.newLayoutEntitiesClient = async (client, controllerId, identity) => {
1234
- 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.');
1235
- const consumer = new api_exposer_1.ApiConsumer(new api_exposer_1.ChannelsConsumer({ dispatch }));
1236
- return consumer.consume({ id: controllerId });
1237
- };
1238
- LayoutNode.getEntity = (definition, client) => {
1239
- const { entityId, type } = definition;
1240
- switch (type) {
1241
- case 'column':
1242
- case 'row':
1243
- return new ColumnOrRow(client, entityId, type);
1244
- case 'stack':
1245
- return new TabStack(client, entityId);
1246
- default:
1247
- throw new Error(`Unrecognised Layout Entity encountered ('${JSON.stringify(definition)})`);
1248
- }
1249
- };
1250
- /**
1251
- * A TabStack is used to manage the state of a stack of tabs within an OpenFin Layout.
1252
- */
1253
- class TabStack extends LayoutNode {
1254
- /** @internal */
1255
- constructor(client, entityId) {
1256
- super(client, entityId);
1257
- /**
1258
- * @internal
1259
- * ApiClient for {@link LayoutEntitiesController}
1260
- */
1261
- _TabStack_client.set(this, void 0);
1262
- /**
1263
- * Type of the content item. Always stack, but useful for distinguishing between a {@link TabStack} and {@link ColumnOrRow}.
1264
- */
1265
- this.type = 'stack';
1266
- /**
1267
- * Retrieves a list of all views belonging to this {@link TabStack}.
1268
- *
1269
- * Known Issue: If adding a view overflows the tab-container width, the added view will be set as active
1270
- * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
1271
- * If that happens and then getViews() is called, it will return the identities in a different order than
1272
- * than the currently rendered tab order.
1273
- *
1274
- *
1275
- * @throws If the {@link TabStack} has been destroyed.
1276
- * @example
1277
- * ```js
1278
- * if (!fin.me.isView) {
1279
- * throw new Error('Not running in a platform View.');
1280
- * }
1281
- *
1282
- * const stack = await fin.me.getCurrentStack();
1283
- * // Alternatively, you can wrap any view and get the stack from there
1284
- * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
1285
- * // const stack = await viewFromSomewhere.getCurrentStack();
1286
- * const views = await stack.getViews();
1287
- * console.log(`Stack contains ${views.length} view(s)`);
1288
- * ```
1289
- * @experimental
1290
- */
1291
- this.getViews = () => __classPrivateFieldGet$d(this, _TabStack_client, "f").getStackViews(this.entityId);
1292
- /**
1293
- * Adds or creates a view in this {@link TabStack}.
1294
- *
1295
- * @remarks Known Issue: If adding a view overflows the tab-container, the added view will be set as active
1296
- * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
1297
- *
1298
- * @param view The identity of an existing view to add, or options to create a view.
1299
- * @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)
1300
- * @returns Resolves with the {@link OpenFin.Identity identity} of the added view.
1301
- * @throws If the view does not exist or fails to create.
1302
- * @throws If the {@link TabStack} has been destroyed.
1303
- * @example
1304
- * ```js
1305
- * if (!fin.me.isView) {
1306
- * throw new Error('Not running in a platform View.');
1307
- * }
1308
- *
1309
- * const stack = await fin.me.getCurrentStack();
1310
- * // Alternatively, you can wrap any view and get the stack from there
1311
- * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
1312
- * // const stack = await viewFromSomewhere.getCurrentStack();
1313
- * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
1314
- * console.log('Identity of the google view just added', { googleViewIdentity });
1315
- * // pass in { index: number } to set the index in the stack. Here 1 means, end of the stack (defaults to 0)
1316
- * const appleViewIdentity = await stack.addView({ name: 'apple-view', url: 'http://apple.com/' }, { index: 1 });
1317
- * console.log('Identity of the apple view just added', { appleViewIdentity });
1318
- * ```
1319
- * @experimental
1320
- */
1321
- this.addView = async (view, options = { index: 0 }) => __classPrivateFieldGet$d(this, _TabStack_client, "f").addViewToStack(this.entityId, view, options);
1322
- /**
1323
- * Removes a view from this {@link TabStack}.
1324
- *
1325
- * @remarks Throws an exception if the view identity does not exist or was already destroyed.
1326
- *
1327
- * @param view - Identity of the view to remove.
1328
- * @throws If the view does not exist or does not belong to the stack.
1329
- * @throws If the {@link TabStack} has been destroyed.
1330
- *
1331
- * @example
1332
- * ```js
1333
- * if (!fin.me.isView) {
1334
- * throw new Error('Not running in a platform View.');
1335
- * }
1336
- *
1337
- * const stack = await fin.me.getCurrentStack();
1338
- * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
1339
- *
1340
- * await stack.removeView(googleViewIdentity);
1341
- *
1342
- * try {
1343
- * await stack.removeView(googleViewIdentity);
1344
- * } catch (error) {
1345
- * // Tried to remove a view ('google-view') which does not belong to the stack.
1346
- * console.log(error);
1347
- * }
1348
- * ```
1349
- */
1350
- this.removeView = async (view) => {
1351
- await __classPrivateFieldGet$d(this, _TabStack_client, "f").removeViewFromStack(this.entityId, view);
1352
- };
1353
- /**
1354
- * Sets the active view of the {@link TabStack} without focusing it.
1355
- * @param view - Identity of the view to activate.
1356
- * @returns Promise which resolves with void once the view has been activated.
1357
- * @throws If the {@link TabStack} has been destroyed.
1358
- * @throws If the view does not exist.
1359
- * @example
1360
- * Change the active tab of a known View's TabStack:
1361
- * ```js
1362
- * const targetView = fin.View.wrapSync({ uuid: 'uuid', name: 'view-name' });
1363
- * const stack = await targetView.getCurrentStack();
1364
- * await stack.setActiveView(targetView.identity);
1365
- * ```
1366
- *
1367
- * Set the current View as active within its TabStack:
1368
- * ```js
1369
- * const stack = await fin.me.getCurrentStack();
1370
- * await stack.setActiveView(fin.me.identity);
1371
- * ```
1372
- * @experimental
1373
- */
1374
- this.setActiveView = async (view) => {
1375
- await __classPrivateFieldGet$d(this, _TabStack_client, "f").setStackActiveView(this.entityId, view);
1376
- };
1377
- __classPrivateFieldSet$c(this, _TabStack_client, client, "f");
1378
- }
1379
- }
1380
- layoutEntities.TabStack = TabStack;
1381
- _TabStack_client = new WeakMap();
1382
- /**
1383
- * A ColumnOrRow is used to manage the state of Column and Rows within an OpenFin Layout.
1384
- */
1385
- class ColumnOrRow extends LayoutNode {
1386
- /**
1387
- * @internal
1388
- */
1389
- constructor(client, entityId, type) {
1390
- super(client, entityId);
1391
- /**
1392
- * @ignore
1393
- * @internal
1394
- * ApiClient for {@link LayoutEntitiesController}
1395
- */
1396
- _ColumnOrRow_client.set(this, void 0);
1397
- /**
1398
- * Retrieves the content array of the ColumnOrRow
1399
- *
1400
- * @example
1401
- * ```js
1402
- * if (!fin.me.isView) {
1403
- * throw new Error('Not running in a platform View.');
1404
- * }
1405
- *
1406
- * const stack = await fin.me.getCurrentStack();
1407
- * // Retrieves the parent ColumnOrRow
1408
- * const columnOrRow = await stack.getParent();
1409
- *
1410
- * // returns [TabStack]
1411
- * const contentArray = await columnOrRow.getContent();
1412
- * console.log(`The ColumnOrRow has ${contentArray.length} item(s)`);
1413
- * ```
1414
- */
1415
- this.getContent = async () => {
1416
- const contentItemEntities = await __classPrivateFieldGet$d(this, _ColumnOrRow_client, "f").getContent(this.entityId);
1417
- return contentItemEntities.map((entity) => LayoutNode.getEntity(entity, __classPrivateFieldGet$d(this, _ColumnOrRow_client, "f")));
1418
- };
1419
- __classPrivateFieldSet$c(this, _ColumnOrRow_client, client, "f");
1420
- this.type = type;
1421
- }
1422
- }
1423
- layoutEntities.ColumnOrRow = ColumnOrRow;
1424
- _ColumnOrRow_client = new WeakMap();
1425
-
1426
- var layout_constants = {};
1427
-
1428
- Object.defineProperty(layout_constants, "__esModule", { value: true });
1429
- layout_constants.DEFAULT_LAYOUT_KEY = layout_constants.LAYOUT_CONTROLLER_ID = void 0;
1430
- layout_constants.LAYOUT_CONTROLLER_ID = 'layout-entities';
1431
- // TODO: eventually export this somehow
1432
- layout_constants.DEFAULT_LAYOUT_KEY = '__default__';
1433
-
1434
- var main = {};
1435
-
1436
- Object.defineProperty(main, "__esModule", { value: true });
1437
- main.WebContents = void 0;
1438
- const base_1$j = base;
1439
- class WebContents extends base_1$j.EmitterBase {
1440
- /**
1441
- * @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
1442
- * @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
1443
- */
1444
- constructor(wire, identity, entityType) {
1445
- super(wire, entityType, identity.uuid, identity.name);
1446
- this.identity = identity;
1447
- this.entityType = entityType;
1448
- }
1449
- /**
1450
- * Gets a base64 encoded image of all or part of the WebContents.
1451
- * @param options Options for the capturePage call.
1452
- *
1453
- * @example
1454
- *
1455
- * View:
1456
- * ```js
1457
- * const view = fin.View.getCurrentSync();
1458
- *
1459
- * // PNG image of a full visible View
1460
- * console.log(await view.capturePage());
1461
- *
1462
- * // Low-quality JPEG image of a defined visible area of the view
1463
- * const options = {
1464
- * area: {
1465
- * height: 100,
1466
- * width: 100,
1467
- * x: 10,
1468
- * y: 10,
1469
- * },
1470
- * format: 'jpg',
1471
- * quality: 20
1472
- * }
1473
- * console.log(await view.capturePage(options));
1474
- * ```
1475
- *
1476
- * Window:
1477
- * ```js
1478
- * const wnd = await fin.Window.getCurrent();
1479
- *
1480
- * // PNG image of a full visible window
1481
- * console.log(await wnd.capturePage());
1482
- *
1483
- * // Low-quality JPEG image of a defined visible area of the window
1484
- * const options = {
1485
- * area: {
1486
- * height: 100,
1487
- * width: 100,
1488
- * x: 10,
1489
- * y: 10,
1490
- * },
1491
- * format: 'jpg',
1492
- * quality: 20
1493
- * }
1494
- * console.log(await wnd.capturePage(options));
1495
- * ```
1496
- *
1497
- * @remarks
1498
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1499
- * We do not expose an explicit superclass for this functionality, but it does have its own
1500
- * {@link OpenFin.WebContentsEvents event namespace}.
1501
- */
1502
- capturePage(options) {
1503
- return this.wire.sendAction('capture-page', { options, ...this.identity }).then(({ payload }) => payload.data);
1504
- }
1505
- /**
1506
- * Executes Javascript on the WebContents, restricted to contents you own or contents owned by
1507
- * applications you have created.
1508
- * @param code JavaScript code to be executed on the view.
1509
- *
1510
- * @example
1511
- * View:
1512
- * ```js
1513
- * async function executeJavaScript(code) {
1514
- * const view = await fin.View.wrap({uuid: 'uuid', name: 'view name'});
1515
- * return await view.executeJavaScript(code);
1516
- * }
1517
- *
1518
- * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
1519
- * ```
1520
- *
1521
- * Window:
1522
- * ```js
1523
- * async function executeJavaScript(code) {
1524
- * const app = await fin.Application.start({
1525
- * name: 'myApp',
1526
- * uuid: 'app-1',
1527
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.executeJavaScript.html',
1528
- * autoShow: true
1529
- * });
1530
- * const win = await app.getWindow();
1531
- * return await win.executeJavaScript(code);
1532
- * }
1533
- *
1534
- * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
1535
- * ```
1536
- * @remarks
1537
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1538
- * We do not expose an explicit superclass for this functionality, but it does have its own
1539
- * {@link OpenFin.WebContentsEvents event namespace}.
1540
- */
1541
- executeJavaScript(code) {
1542
- return this.wire
1543
- .sendAction('execute-javascript-in-window', { ...this.identity, code })
1544
- .then(({ payload }) => payload.data);
841
+ /**
842
+ * Executes Javascript on the WebContents, restricted to contents you own or contents owned by
843
+ * applications you have created.
844
+ * @param code JavaScript code to be executed on the view.
845
+ *
846
+ * @example
847
+ * View:
848
+ * ```js
849
+ * async function executeJavaScript(code) {
850
+ * const view = await fin.View.wrap({uuid: 'uuid', name: 'view name'});
851
+ * return await view.executeJavaScript(code);
852
+ * }
853
+ *
854
+ * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
855
+ * ```
856
+ *
857
+ * Window:
858
+ * ```js
859
+ * async function executeJavaScript(code) {
860
+ * const app = await fin.Application.start({
861
+ * name: 'myApp',
862
+ * uuid: 'app-1',
863
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.executeJavaScript.html',
864
+ * autoShow: true
865
+ * });
866
+ * const win = await app.getWindow();
867
+ * return await win.executeJavaScript(code);
868
+ * }
869
+ *
870
+ * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
871
+ * ```
872
+ * @remarks
873
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
874
+ * We do not expose an explicit superclass for this functionality, but it does have its own
875
+ * {@link OpenFin.WebContentsEvents event namespace}.
876
+ */
877
+ executeJavaScript(code) {
878
+ return this.wire
879
+ .sendAction('execute-javascript-in-window', { ...this.identity, code })
880
+ .then(({ payload }) => payload.data);
1545
881
  }
1546
882
  /**
1547
883
  * Returns the zoom level of the WebContents.
@@ -2507,18 +1843,11 @@ var hasRequiredInstance$2;
2507
1843
  function requireInstance$2 () {
2508
1844
  if (hasRequiredInstance$2) return Instance$5;
2509
1845
  hasRequiredInstance$2 = 1;
2510
- var __classPrivateFieldGet = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2511
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
2512
- 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");
2513
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2514
- };
2515
1846
  var _View_providerChannelClient;
2516
1847
  Object.defineProperty(Instance$5, "__esModule", { value: true });
2517
1848
  Instance$5.View = void 0;
2518
1849
  const transport_errors_1 = transportErrors;
2519
1850
  const lazy_1 = lazy;
2520
- const layout_entities_1 = layoutEntities;
2521
- const layout_constants_1 = layout_constants;
2522
1851
  const main_1 = main;
2523
1852
  const window_1 = requireWindow();
2524
1853
  /**
@@ -2836,7 +2165,7 @@ function requireInstance$2 () {
2836
2165
  return ack.payload.data;
2837
2166
  };
2838
2167
  /**
2839
- * Retrieves the layout for the window the view is attached to.
2168
+ * Retrieves the OpenFin.Layout instance for the Window the View is attached to.
2840
2169
  *
2841
2170
  * @example
2842
2171
  * ```js
@@ -2852,29 +2181,7 @@ function requireInstance$2 () {
2852
2181
  this.wire.sendAction('view-get-parent-layout', { ...this.identity }).catch(() => {
2853
2182
  // don't expose
2854
2183
  });
2855
- const layoutWindow = await this.getCurrentWindow();
2856
- let layoutWindowIdentity = layoutWindow.identity;
2857
- // TODO: CORE-1857 - when we tearout active layout or drag a view out of a window, the above identity includes the whole window info.
2858
- if (layoutWindowIdentity.identity) {
2859
- layoutWindowIdentity = layoutWindowIdentity.identity;
2860
- }
2861
- try {
2862
- const providerChannelClient = await __classPrivateFieldGet(this, _View_providerChannelClient, "f").getValue();
2863
- const client = await layout_entities_1.LayoutNode.newLayoutEntitiesClient(providerChannelClient, layout_constants_1.LAYOUT_CONTROLLER_ID, layoutWindowIdentity);
2864
- const layoutIdentity = await client.getLayoutIdentityForViewOrThrow(this.identity);
2865
- return this.fin.Platform.Layout.wrap(layoutIdentity);
2866
- }
2867
- catch (e) {
2868
- const allowedErrors = [
2869
- 'No action registered at target for',
2870
- 'getLayoutIdentityForViewOrThrow is not a function'
2871
- ];
2872
- if (!allowedErrors.some((m) => e.message.includes(m))) {
2873
- throw e;
2874
- }
2875
- // fallback logic for missing endpoint
2876
- return this.fin.Platform.Layout.wrap(layoutWindowIdentity);
2877
- }
2184
+ return this.fin.Platform.Layout.getLayoutByViewIdentity(this.identity);
2878
2185
  };
2879
2186
  /**
2880
2187
  * Gets the View's options.
@@ -8024,12 +7331,12 @@ class ChannelError extends Error {
8024
7331
  }
8025
7332
  channelError.ChannelError = ChannelError;
8026
7333
 
8027
- var __classPrivateFieldGet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
7334
+ var __classPrivateFieldGet$d = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8028
7335
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
8029
7336
  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");
8030
7337
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
8031
7338
  };
8032
- var __classPrivateFieldSet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7339
+ var __classPrivateFieldSet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8033
7340
  if (kind === "m") throw new TypeError("Private method is not writable");
8034
7341
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8035
7342
  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");
@@ -8073,7 +7380,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
8073
7380
  static closeChannelByEndpointId(id) {
8074
7381
  const channel = channelClientsByEndpointId.get(id);
8075
7382
  if (channel) {
8076
- __classPrivateFieldGet$c(channel, _ChannelClient_close, "f").call(channel);
7383
+ __classPrivateFieldGet$d(channel, _ChannelClient_close, "f").call(channel);
8077
7384
  }
8078
7385
  }
8079
7386
  /**
@@ -8084,7 +7391,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
8084
7391
  for (const channelClient of channelClientsByEndpointId.values()) {
8085
7392
  if (channelClient.providerIdentity.channelId === eventPayload.channelId) {
8086
7393
  channelClient.disconnectListener(eventPayload);
8087
- __classPrivateFieldGet$c(channelClient, _ChannelClient_close, "f").call(channelClient);
7394
+ __classPrivateFieldGet$d(channelClient, _ChannelClient_close, "f").call(channelClient);
8088
7395
  }
8089
7396
  }
8090
7397
  }
@@ -8099,12 +7406,12 @@ class ChannelClient extends channel_1$1.ChannelBase {
8099
7406
  this.processAction = (action, payload, senderIdentity) => super.processAction(action, payload, senderIdentity);
8100
7407
  _ChannelClient_close.set(this, () => {
8101
7408
  channelClientsByEndpointId.delete(this.endpointId);
8102
- __classPrivateFieldGet$c(this, _ChannelClient_strategy, "f").close();
7409
+ __classPrivateFieldGet$d(this, _ChannelClient_strategy, "f").close();
8103
7410
  });
8104
- __classPrivateFieldSet$b(this, _ChannelClient_protectedObj, new channel_1$1.ProtectedItems(routingInfo, close), "f");
7411
+ __classPrivateFieldSet$c(this, _ChannelClient_protectedObj, new channel_1$1.ProtectedItems(routingInfo, close), "f");
8105
7412
  this.disconnectListener = () => undefined;
8106
7413
  this.endpointId = routingInfo.endpointId;
8107
- __classPrivateFieldSet$b(this, _ChannelClient_strategy, strategy, "f");
7414
+ __classPrivateFieldSet$c(this, _ChannelClient_strategy, strategy, "f");
8108
7415
  channelClientsByEndpointId.set(this.endpointId, this);
8109
7416
  strategy.receive(this.processAction);
8110
7417
  }
@@ -8112,7 +7419,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
8112
7419
  * a read-only provider identity
8113
7420
  */
8114
7421
  get providerIdentity() {
8115
- const protectedObj = __classPrivateFieldGet$c(this, _ChannelClient_protectedObj, "f");
7422
+ const protectedObj = __classPrivateFieldGet$d(this, _ChannelClient_protectedObj, "f");
8116
7423
  return protectedObj.providerIdentity;
8117
7424
  }
8118
7425
  /**
@@ -8141,9 +7448,9 @@ class ChannelClient extends channel_1$1.ChannelBase {
8141
7448
  * ```
8142
7449
  */
8143
7450
  async dispatch(action, payload) {
8144
- if (__classPrivateFieldGet$c(this, _ChannelClient_strategy, "f").isEndpointConnected(this.providerIdentity.channelId)) {
7451
+ if (__classPrivateFieldGet$d(this, _ChannelClient_strategy, "f").isEndpointConnected(this.providerIdentity.channelId)) {
8145
7452
  const callSites = transport_errors_1$3.RuntimeError.getCallSite();
8146
- return __classPrivateFieldGet$c(this, _ChannelClient_strategy, "f").send(this.providerIdentity.channelId, action, payload).catch((e) => {
7453
+ return __classPrivateFieldGet$d(this, _ChannelClient_strategy, "f").send(this.providerIdentity.channelId, action, payload).catch((e) => {
8147
7454
  throw new channel_error_1$1.ChannelError(e, action, payload, callSites);
8148
7455
  });
8149
7456
  }
@@ -8195,10 +7502,10 @@ class ChannelClient extends channel_1$1.ChannelBase {
8195
7502
  */
8196
7503
  async disconnect() {
8197
7504
  await this.sendDisconnectAction();
8198
- __classPrivateFieldGet$c(this, _ChannelClient_close, "f").call(this);
7505
+ __classPrivateFieldGet$d(this, _ChannelClient_close, "f").call(this);
8199
7506
  }
8200
7507
  async sendDisconnectAction() {
8201
- const protectedObj = __classPrivateFieldGet$c(this, _ChannelClient_protectedObj, "f");
7508
+ const protectedObj = __classPrivateFieldGet$d(this, _ChannelClient_protectedObj, "f");
8202
7509
  await protectedObj.close();
8203
7510
  }
8204
7511
  /**
@@ -8231,13 +7538,13 @@ exhaustive.exhaustiveCheck = exhaustiveCheck;
8231
7538
 
8232
7539
  var strategy$3 = {};
8233
7540
 
8234
- var __classPrivateFieldSet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7541
+ var __classPrivateFieldSet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8235
7542
  if (kind === "m") throw new TypeError("Private method is not writable");
8236
7543
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8237
7544
  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");
8238
7545
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
8239
7546
  };
8240
- var __classPrivateFieldGet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
7547
+ var __classPrivateFieldGet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8241
7548
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
8242
7549
  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");
8243
7550
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -8262,7 +7569,7 @@ class ClassicStrategy {
8262
7569
  // connection problems occur
8263
7570
  _ClassicStrategy_pendingMessagesByEndpointId.set(this, new Map());
8264
7571
  this.send = async (endpointId, action, payload) => {
8265
- const to = __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
7572
+ const to = __classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
8266
7573
  if (!to) {
8267
7574
  throw new Error(`Could not locate routing info for endpoint ${endpointId}`);
8268
7575
  }
@@ -8274,13 +7581,13 @@ class ClassicStrategy {
8274
7581
  }
8275
7582
  delete cleanId.isLocalEndpointId;
8276
7583
  // grab the promise before awaiting it to save in our pending messages map
8277
- const p = __classPrivateFieldGet$b(this, _ClassicStrategy_wire, "f").sendAction('send-channel-message', {
7584
+ const p = __classPrivateFieldGet$c(this, _ClassicStrategy_wire, "f").sendAction('send-channel-message', {
8278
7585
  ...cleanId,
8279
7586
  providerIdentity: this.providerIdentity,
8280
7587
  action,
8281
7588
  payload
8282
7589
  });
8283
- __classPrivateFieldGet$b(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.add(p);
7590
+ __classPrivateFieldGet$c(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.add(p);
8284
7591
  const raw = await p
8285
7592
  .catch((error) => {
8286
7593
  if ('cause' in error) {
@@ -8290,16 +7597,16 @@ class ClassicStrategy {
8290
7597
  })
8291
7598
  .finally(() => {
8292
7599
  // clean up the pending promise
8293
- __classPrivateFieldGet$b(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.delete(p);
7600
+ __classPrivateFieldGet$c(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.delete(p);
8294
7601
  });
8295
7602
  return raw.payload.data.result;
8296
7603
  };
8297
7604
  this.close = async () => {
8298
7605
  this.messageReceiver.removeEndpoint(this.providerIdentity.channelId, this.endpointId);
8299
- [...__classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").keys()].forEach((id) => this.closeEndpoint(id));
8300
- __classPrivateFieldSet$a(this, _ClassicStrategy_endpointIdentityMap, new Map(), "f");
7606
+ [...__classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").keys()].forEach((id) => this.closeEndpoint(id));
7607
+ __classPrivateFieldSet$b(this, _ClassicStrategy_endpointIdentityMap, new Map(), "f");
8301
7608
  };
8302
- __classPrivateFieldSet$a(this, _ClassicStrategy_wire, wire, "f");
7609
+ __classPrivateFieldSet$b(this, _ClassicStrategy_wire, wire, "f");
8303
7610
  }
8304
7611
  onEndpointDisconnect(endpointId, listener) {
8305
7612
  // Never fires for 'classic'.
@@ -8308,20 +7615,20 @@ class ClassicStrategy {
8308
7615
  this.messageReceiver.addEndpoint(listener, this.providerIdentity.channelId, this.endpointId);
8309
7616
  }
8310
7617
  async closeEndpoint(endpointId) {
8311
- const id = __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
8312
- __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").delete(endpointId);
8313
- const pendingSet = __classPrivateFieldGet$b(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId);
7618
+ const id = __classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
7619
+ __classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").delete(endpointId);
7620
+ const pendingSet = __classPrivateFieldGet$c(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId);
8314
7621
  pendingSet?.forEach((p) => {
8315
7622
  const errorMsg = `Channel connection with identity uuid: ${id?.uuid} / name: ${id?.name} / endpointId: ${endpointId} no longer connected.`;
8316
7623
  p.cancel(new Error(errorMsg));
8317
7624
  });
8318
7625
  }
8319
7626
  isEndpointConnected(endpointId) {
8320
- return __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").has(endpointId);
7627
+ return __classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").has(endpointId);
8321
7628
  }
8322
7629
  addEndpoint(endpointId, payload) {
8323
- __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").set(endpointId, payload.endpointIdentity);
8324
- __classPrivateFieldGet$b(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").set(endpointId, new Set());
7630
+ __classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").set(endpointId, payload.endpointIdentity);
7631
+ __classPrivateFieldGet$c(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").set(endpointId, new Set());
8325
7632
  }
8326
7633
  isValidEndpointPayload(payload) {
8327
7634
  return (typeof payload?.endpointIdentity?.endpointId === 'string' ||
@@ -8356,12 +7663,12 @@ function errorToPOJO(error) {
8356
7663
  }
8357
7664
  errors.errorToPOJO = errorToPOJO;
8358
7665
 
8359
- var __classPrivateFieldGet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
7666
+ var __classPrivateFieldGet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8360
7667
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
8361
7668
  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");
8362
7669
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
8363
7670
  };
8364
- var __classPrivateFieldSet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7671
+ var __classPrivateFieldSet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8365
7672
  if (kind === "m") throw new TypeError("Private method is not writable");
8366
7673
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8367
7674
  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");
@@ -8396,8 +7703,8 @@ class RTCEndpoint {
8396
7703
  if (this.rtc.rtcClient.connectionState !== 'connected') {
8397
7704
  this.rtc.rtcClient.removeEventListener('connectionstatechange', this.connectionStateChangeHandler);
8398
7705
  this.close();
8399
- if (__classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f")) {
8400
- __classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f").call(this);
7706
+ if (__classPrivateFieldGet$b(this, _RTCEndpoint_disconnectListener, "f")) {
7707
+ __classPrivateFieldGet$b(this, _RTCEndpoint_disconnectListener, "f").call(this);
8401
7708
  }
8402
7709
  }
8403
7710
  };
@@ -8445,9 +7752,9 @@ class RTCEndpoint {
8445
7752
  data = new TextDecoder().decode(e.data);
8446
7753
  }
8447
7754
  const { messageId, action, payload } = JSON.parse(data);
8448
- if (__classPrivateFieldGet$a(this, _RTCEndpoint_processAction, "f")) {
7755
+ if (__classPrivateFieldGet$b(this, _RTCEndpoint_processAction, "f")) {
8449
7756
  try {
8450
- const res = await __classPrivateFieldGet$a(this, _RTCEndpoint_processAction, "f").call(this, action, payload, endpointIdentity);
7757
+ const res = await __classPrivateFieldGet$b(this, _RTCEndpoint_processAction, "f").call(this, action, payload, endpointIdentity);
8451
7758
  this.rtc.channels.response.send(JSON.stringify({
8452
7759
  messageId,
8453
7760
  payload: res,
@@ -8481,25 +7788,25 @@ class RTCEndpoint {
8481
7788
  datachannel.onclose = (e) => {
8482
7789
  [...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.')));
8483
7790
  this.close();
8484
- if (__classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f")) {
8485
- __classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f").call(this);
7791
+ if (__classPrivateFieldGet$b(this, _RTCEndpoint_disconnectListener, "f")) {
7792
+ __classPrivateFieldGet$b(this, _RTCEndpoint_disconnectListener, "f").call(this);
8486
7793
  }
8487
7794
  };
8488
7795
  });
8489
7796
  }
8490
7797
  onDisconnect(listener) {
8491
- if (!__classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f")) {
8492
- __classPrivateFieldSet$9(this, _RTCEndpoint_disconnectListener, listener, "f");
7798
+ if (!__classPrivateFieldGet$b(this, _RTCEndpoint_disconnectListener, "f")) {
7799
+ __classPrivateFieldSet$a(this, _RTCEndpoint_disconnectListener, listener, "f");
8493
7800
  }
8494
7801
  else {
8495
7802
  throw new Error('RTCEndpoint disconnectListener cannot be set twice.');
8496
7803
  }
8497
7804
  }
8498
7805
  receive(listener) {
8499
- if (__classPrivateFieldGet$a(this, _RTCEndpoint_processAction, "f")) {
7806
+ if (__classPrivateFieldGet$b(this, _RTCEndpoint_processAction, "f")) {
8500
7807
  throw new Error('You have already set a listener for this RTC Endpoint.');
8501
7808
  }
8502
- __classPrivateFieldSet$9(this, _RTCEndpoint_processAction, listener, "f");
7809
+ __classPrivateFieldSet$a(this, _RTCEndpoint_processAction, listener, "f");
8503
7810
  }
8504
7811
  get connected() {
8505
7812
  return this.rtc.rtcClient.connectionState === 'connected';
@@ -8510,12 +7817,12 @@ _RTCEndpoint_processAction = new WeakMap(), _RTCEndpoint_disconnectListener = ne
8510
7817
 
8511
7818
  var strategy$1 = {};
8512
7819
 
8513
- var __classPrivateFieldGet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
7820
+ var __classPrivateFieldGet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8514
7821
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
8515
7822
  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");
8516
7823
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
8517
7824
  };
8518
- var __classPrivateFieldSet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7825
+ var __classPrivateFieldSet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8519
7826
  if (kind === "m") throw new TypeError("Private method is not writable");
8520
7827
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8521
7828
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
@@ -8536,11 +7843,11 @@ class EndpointStrategy {
8536
7843
  return this.getEndpointById(endpointId).send(action, payload);
8537
7844
  };
8538
7845
  this.close = async () => {
8539
- if (__classPrivateFieldGet$9(this, _EndpointStrategy_connected, "f")) {
8540
- __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.close());
8541
- __classPrivateFieldSet$8(this, _EndpointStrategy_endpointMap, new Map(), "f");
7846
+ if (__classPrivateFieldGet$a(this, _EndpointStrategy_connected, "f")) {
7847
+ __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.close());
7848
+ __classPrivateFieldSet$9(this, _EndpointStrategy_endpointMap, new Map(), "f");
8542
7849
  }
8543
- __classPrivateFieldSet$8(this, _EndpointStrategy_connected, false, "f");
7850
+ __classPrivateFieldSet$9(this, _EndpointStrategy_connected, false, "f");
8544
7851
  };
8545
7852
  this.isValidEndpointPayload = validateEndpoint;
8546
7853
  }
@@ -8548,39 +7855,39 @@ class EndpointStrategy {
8548
7855
  this.getEndpointById(endpointId).onDisconnect(listener);
8549
7856
  }
8550
7857
  receive(listener) {
8551
- if (__classPrivateFieldGet$9(this, _EndpointStrategy_processAction, "f")) {
7858
+ if (__classPrivateFieldGet$a(this, _EndpointStrategy_processAction, "f")) {
8552
7859
  throw new Error(`You have already set a listener for this ${this.StrategyName} Strategy`);
8553
7860
  }
8554
- __classPrivateFieldSet$8(this, _EndpointStrategy_processAction, listener, "f");
7861
+ __classPrivateFieldSet$9(this, _EndpointStrategy_processAction, listener, "f");
8555
7862
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
8556
- __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.receive(__classPrivateFieldGet$9(this, _EndpointStrategy_processAction, "f")));
7863
+ __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.receive(__classPrivateFieldGet$a(this, _EndpointStrategy_processAction, "f")));
8557
7864
  }
8558
7865
  getEndpointById(endpointId) {
8559
- const endpoint = __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").get(endpointId);
7866
+ const endpoint = __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").get(endpointId);
8560
7867
  if (!endpoint) {
8561
7868
  throw new Error(`Client with endpoint id ${endpointId} is not connected`);
8562
7869
  }
8563
7870
  return endpoint;
8564
7871
  }
8565
7872
  get connected() {
8566
- return __classPrivateFieldGet$9(this, _EndpointStrategy_connected, "f");
7873
+ return __classPrivateFieldGet$a(this, _EndpointStrategy_connected, "f");
8567
7874
  }
8568
7875
  isEndpointConnected(endpointId) {
8569
- return __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").has(endpointId);
7876
+ return __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").has(endpointId);
8570
7877
  }
8571
7878
  addEndpoint(endpointId, payload) {
8572
- if (!__classPrivateFieldGet$9(this, _EndpointStrategy_connected, "f")) {
7879
+ if (!__classPrivateFieldGet$a(this, _EndpointStrategy_connected, "f")) {
8573
7880
  console.warn(`Adding endpoint to disconnected ${this.StrategyName} Strategy`);
8574
7881
  return;
8575
7882
  }
8576
7883
  const clientStrat = new this.EndpointType(payload);
8577
- if (__classPrivateFieldGet$9(this, _EndpointStrategy_processAction, "f")) {
8578
- clientStrat.receive(__classPrivateFieldGet$9(this, _EndpointStrategy_processAction, "f"));
7884
+ if (__classPrivateFieldGet$a(this, _EndpointStrategy_processAction, "f")) {
7885
+ clientStrat.receive(__classPrivateFieldGet$a(this, _EndpointStrategy_processAction, "f"));
8579
7886
  }
8580
- __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").set(endpointId, clientStrat);
7887
+ __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").set(endpointId, clientStrat);
8581
7888
  }
8582
7889
  async closeEndpoint(endpointId) {
8583
- __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").delete(endpointId);
7890
+ __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").delete(endpointId);
8584
7891
  }
8585
7892
  }
8586
7893
  strategy$1.EndpointStrategy = EndpointStrategy;
@@ -8762,12 +8069,12 @@ function runtimeUuidMeetsMinimumRuntimeVersion(runtimeUuid, minVersion) {
8762
8069
  }
8763
8070
  runtimeVersioning.runtimeUuidMeetsMinimumRuntimeVersion = runtimeUuidMeetsMinimumRuntimeVersion;
8764
8071
 
8765
- var __classPrivateFieldGet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8072
+ var __classPrivateFieldGet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8766
8073
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
8767
8074
  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");
8768
8075
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
8769
8076
  };
8770
- var __classPrivateFieldSet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8077
+ var __classPrivateFieldSet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8771
8078
  if (kind === "m") throw new TypeError("Private method is not writable");
8772
8079
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8773
8080
  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");
@@ -8811,18 +8118,18 @@ class ChannelProvider extends channel_1.ChannelBase {
8811
8118
  * a read-only array containing all the identities of connecting clients.
8812
8119
  */
8813
8120
  get connections() {
8814
- return [...__classPrivateFieldGet$8(this, _ChannelProvider_connections, "f")];
8121
+ return [...__classPrivateFieldGet$9(this, _ChannelProvider_connections, "f")];
8815
8122
  }
8816
8123
  static handleClientDisconnection(channel, payload) {
8817
8124
  const removeById = channel.connections.find((identity) => identity.endpointId === payload.endpointId);
8818
8125
  if (removeById) {
8819
- __classPrivateFieldGet$8(channel, _ChannelProvider_removeEndpoint, "f").call(channel, removeById);
8126
+ __classPrivateFieldGet$9(channel, _ChannelProvider_removeEndpoint, "f").call(channel, removeById);
8820
8127
  }
8821
8128
  else {
8822
8129
  const multipleRemoves = channel.connections.filter((identity) => {
8823
8130
  return identity.uuid === payload.uuid && identity.name === payload.name;
8824
8131
  });
8825
- multipleRemoves.forEach(__classPrivateFieldGet$8(channel, _ChannelProvider_removeEndpoint, "f"));
8132
+ multipleRemoves.forEach(__classPrivateFieldGet$9(channel, _ChannelProvider_removeEndpoint, "f"));
8826
8133
  }
8827
8134
  channel.disconnectListener(payload);
8828
8135
  }
@@ -8839,8 +8146,8 @@ class ChannelProvider extends channel_1.ChannelBase {
8839
8146
  _ChannelProvider_strategy.set(this, void 0);
8840
8147
  _ChannelProvider_removeEndpoint.set(this, (identity) => {
8841
8148
  const remainingConnections = this.connections.filter((clientIdentity) => clientIdentity.endpointId !== identity.endpointId);
8842
- __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").closeEndpoint(identity.endpointId);
8843
- __classPrivateFieldSet$7(this, _ChannelProvider_connections, remainingConnections, "f");
8149
+ __classPrivateFieldGet$9(this, _ChannelProvider_strategy, "f").closeEndpoint(identity.endpointId);
8150
+ __classPrivateFieldSet$8(this, _ChannelProvider_connections, remainingConnections, "f");
8844
8151
  });
8845
8152
  // Must be bound.
8846
8153
  this.processAction = async (action, payload, senderIdentity) => {
@@ -8854,17 +8161,17 @@ class ChannelProvider extends channel_1.ChannelBase {
8854
8161
  return super.processAction(action, payload, senderIdentity);
8855
8162
  };
8856
8163
  _ChannelProvider_close.set(this, () => {
8857
- __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").close();
8164
+ __classPrivateFieldGet$9(this, _ChannelProvider_strategy, "f").close();
8858
8165
  const remove = ChannelProvider.removalMap.get(this);
8859
8166
  if (remove) {
8860
8167
  remove();
8861
8168
  }
8862
8169
  });
8863
- __classPrivateFieldSet$7(this, _ChannelProvider_protectedObj, new channel_1.ProtectedItems(providerIdentity, close), "f");
8170
+ __classPrivateFieldSet$8(this, _ChannelProvider_protectedObj, new channel_1.ProtectedItems(providerIdentity, close), "f");
8864
8171
  this.connectListener = () => undefined;
8865
8172
  this.disconnectListener = () => undefined;
8866
- __classPrivateFieldSet$7(this, _ChannelProvider_connections, [], "f");
8867
- __classPrivateFieldSet$7(this, _ChannelProvider_strategy, strategy, "f");
8173
+ __classPrivateFieldSet$8(this, _ChannelProvider_connections, [], "f");
8174
+ __classPrivateFieldSet$8(this, _ChannelProvider_strategy, strategy, "f");
8868
8175
  strategy.receive(this.processAction);
8869
8176
  }
8870
8177
  /**
@@ -8895,16 +8202,16 @@ class ChannelProvider extends channel_1.ChannelBase {
8895
8202
  */
8896
8203
  dispatch(to, action, payload) {
8897
8204
  const endpointId = to.endpointId ?? this.getEndpointIdForOpenFinId(to, action);
8898
- if (endpointId && __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").isEndpointConnected(endpointId)) {
8205
+ if (endpointId && __classPrivateFieldGet$9(this, _ChannelProvider_strategy, "f").isEndpointConnected(endpointId)) {
8899
8206
  const callSites = transport_errors_1$2.RuntimeError.getCallSite();
8900
- return __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").send(endpointId, action, payload).catch((e) => {
8207
+ return __classPrivateFieldGet$9(this, _ChannelProvider_strategy, "f").send(endpointId, action, payload).catch((e) => {
8901
8208
  throw new channel_error_1.ChannelError(e, action, payload, callSites);
8902
8209
  });
8903
8210
  }
8904
8211
  return Promise.reject(new Error(`Client connection with identity uuid: ${to.uuid} / name: ${to.name} / endpointId: ${endpointId} no longer connected.`));
8905
8212
  }
8906
8213
  async processConnection(senderId, payload) {
8907
- __classPrivateFieldGet$8(this, _ChannelProvider_connections, "f").push(senderId);
8214
+ __classPrivateFieldGet$9(this, _ChannelProvider_connections, "f").push(senderId);
8908
8215
  return this.connectListener(senderId, payload);
8909
8216
  }
8910
8217
  /**
@@ -8927,7 +8234,7 @@ class ChannelProvider extends channel_1.ChannelBase {
8927
8234
  * ```
8928
8235
  */
8929
8236
  publish(action, payload) {
8930
- return this.connections.map((to) => __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").send(to.endpointId, action, payload));
8237
+ return this.connections.map((to) => __classPrivateFieldGet$9(this, _ChannelProvider_strategy, "f").send(to.endpointId, action, payload));
8931
8238
  }
8932
8239
  /**
8933
8240
  * Register a listener that is called on every new client connection.
@@ -9001,11 +8308,11 @@ class ChannelProvider extends channel_1.ChannelBase {
9001
8308
  * ```
9002
8309
  */
9003
8310
  async destroy() {
9004
- const protectedObj = __classPrivateFieldGet$8(this, _ChannelProvider_protectedObj, "f");
8311
+ const protectedObj = __classPrivateFieldGet$9(this, _ChannelProvider_protectedObj, "f");
9005
8312
  protectedObj.providerIdentity;
9006
- __classPrivateFieldSet$7(this, _ChannelProvider_connections, [], "f");
8313
+ __classPrivateFieldSet$8(this, _ChannelProvider_connections, [], "f");
9007
8314
  await protectedObj.close();
9008
- __classPrivateFieldGet$8(this, _ChannelProvider_close, "f").call(this);
8315
+ __classPrivateFieldGet$9(this, _ChannelProvider_close, "f").call(this);
9009
8316
  }
9010
8317
  /**
9011
8318
  * Returns an array with info on every Client connected to the Provider
@@ -9075,7 +8382,7 @@ class ChannelProvider extends channel_1.ChannelBase {
9075
8382
  getEndpointIdForOpenFinId(clientIdentity, action) {
9076
8383
  const matchingConnections = this.connections.filter((c) => c.name === clientIdentity.name && c.uuid === clientIdentity.uuid);
9077
8384
  if (matchingConnections.length >= 2) {
9078
- const protectedObj = __classPrivateFieldGet$8(this, _ChannelProvider_protectedObj, "f");
8385
+ const protectedObj = __classPrivateFieldGet$9(this, _ChannelProvider_protectedObj, "f");
9079
8386
  const { uuid, name } = clientIdentity;
9080
8387
  const providerUuid = protectedObj?.providerIdentity.uuid;
9081
8388
  const providerName = protectedObj?.providerIdentity.name;
@@ -9287,13 +8594,13 @@ class CombinedStrategy {
9287
8594
  }
9288
8595
  strategy.default = CombinedStrategy;
9289
8596
 
9290
- var __classPrivateFieldSet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8597
+ var __classPrivateFieldSet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
9291
8598
  if (kind === "m") throw new TypeError("Private method is not writable");
9292
8599
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9293
8600
  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");
9294
8601
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
9295
8602
  };
9296
- var __classPrivateFieldGet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8603
+ var __classPrivateFieldGet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9297
8604
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9298
8605
  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");
9299
8606
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -9342,8 +8649,8 @@ class ConnectionManager extends base_1$f.Base {
9342
8649
  };
9343
8650
  this.providerMap = new Map();
9344
8651
  this.protocolManager = new protocol_manager_1.ProtocolManager(this.wire.environment.type === 'node' ? ['classic'] : ['rtc', 'classic']);
9345
- __classPrivateFieldSet$6(this, _ConnectionManager_messageReceiver, new message_receiver_1.MessageReceiver(wire), "f");
9346
- __classPrivateFieldSet$6(this, _ConnectionManager_rtcConnectionManager, new ice_manager_1.RTCICEManager(wire), "f");
8652
+ __classPrivateFieldSet$7(this, _ConnectionManager_messageReceiver, new message_receiver_1.MessageReceiver(wire), "f");
8653
+ __classPrivateFieldSet$7(this, _ConnectionManager_rtcConnectionManager, new ice_manager_1.RTCICEManager(wire), "f");
9347
8654
  wire.registerMessageHandler(this.onmessage.bind(this));
9348
8655
  }
9349
8656
  createProvider(options, providerIdentity) {
@@ -9354,7 +8661,7 @@ class ConnectionManager extends base_1$f.Base {
9354
8661
  case 'rtc':
9355
8662
  return new strategy_2.RTCStrategy();
9356
8663
  case 'classic':
9357
- return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$7(this, _ConnectionManager_messageReceiver, "f"),
8664
+ return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$8(this, _ConnectionManager_messageReceiver, "f"),
9358
8665
  // Providers do not have an endpointId, use channelId as endpointId in the strategy.
9359
8666
  providerIdentity.channelId, providerIdentity);
9360
8667
  default:
@@ -9390,7 +8697,7 @@ class ConnectionManager extends base_1$f.Base {
9390
8697
  const supportedProtocols = await Promise.all(protocols.map(async (type) => {
9391
8698
  switch (type) {
9392
8699
  case 'rtc': {
9393
- const { rtcClient, channels, offer, rtcConnectionId, channelsOpened } = await __classPrivateFieldGet$7(this, _ConnectionManager_rtcConnectionManager, "f").startClientOffer();
8700
+ const { rtcClient, channels, offer, rtcConnectionId, channelsOpened } = await __classPrivateFieldGet$8(this, _ConnectionManager_rtcConnectionManager, "f").startClientOffer();
9394
8701
  rtcPacket = { rtcClient, channels, channelsOpened };
9395
8702
  return {
9396
8703
  type: 'rtc',
@@ -9417,18 +8724,18 @@ class ConnectionManager extends base_1$f.Base {
9417
8724
  routingInfo.endpointId = this.wire.environment.getNextMessageId();
9418
8725
  // For New Clients connecting to Old Providers. To prevent multi-dispatching and publishing, we delete previously-connected
9419
8726
  // clients that are in the same context as the newly-connected client.
9420
- __classPrivateFieldGet$7(this, _ConnectionManager_messageReceiver, "f").checkForPreviousClientConnection(routingInfo.channelId);
8727
+ __classPrivateFieldGet$8(this, _ConnectionManager_messageReceiver, "f").checkForPreviousClientConnection(routingInfo.channelId);
9421
8728
  }
9422
8729
  const answer = routingInfo.answer ?? {
9423
8730
  supportedProtocols: [{ type: 'classic', version: 1 }]
9424
8731
  };
9425
8732
  const createStrategyFromAnswer = async (protocol) => {
9426
8733
  if (protocol.type === 'rtc' && rtcPacket) {
9427
- await __classPrivateFieldGet$7(this, _ConnectionManager_rtcConnectionManager, "f").finishClientOffer(rtcPacket.rtcClient, protocol.payload.answer, rtcPacket.channelsOpened);
8734
+ await __classPrivateFieldGet$8(this, _ConnectionManager_rtcConnectionManager, "f").finishClientOffer(rtcPacket.rtcClient, protocol.payload.answer, rtcPacket.channelsOpened);
9428
8735
  return new strategy_2.RTCStrategy();
9429
8736
  }
9430
8737
  if (protocol.type === 'classic') {
9431
- return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$7(this, _ConnectionManager_messageReceiver, "f"), routingInfo.endpointId, routingInfo);
8738
+ return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$8(this, _ConnectionManager_messageReceiver, "f"), routingInfo.endpointId, routingInfo);
9432
8739
  }
9433
8740
  return null;
9434
8741
  };
@@ -9496,7 +8803,7 @@ class ConnectionManager extends base_1$f.Base {
9496
8803
  clientAnswer = await overlappingProtocols.reduce(async (accumP, protocolToUse) => {
9497
8804
  const answer = await accumP;
9498
8805
  if (protocolToUse.type === 'rtc') {
9499
- const { answer: rtcAnswer, rtcClient, channels } = await __classPrivateFieldGet$7(this, _ConnectionManager_rtcConnectionManager, "f").createProviderAnswer(protocolToUse.payload.rtcConnectionId, protocolToUse.payload.offer);
8806
+ const { answer: rtcAnswer, rtcClient, channels } = await __classPrivateFieldGet$8(this, _ConnectionManager_rtcConnectionManager, "f").createProviderAnswer(protocolToUse.payload.rtcConnectionId, protocolToUse.payload.offer);
9500
8807
  answer.supportedProtocols.push({
9501
8808
  type: 'rtc',
9502
8809
  version: strategy_2.RTCInfo.version,
@@ -9544,13 +8851,13 @@ _ConnectionManager_messageReceiver = new WeakMap(), _ConnectionManager_rtcConnec
9544
8851
  *
9545
8852
  * @packageDocumentation
9546
8853
  */
9547
- var __classPrivateFieldSet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8854
+ var __classPrivateFieldSet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
9548
8855
  if (kind === "m") throw new TypeError("Private method is not writable");
9549
8856
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9550
8857
  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");
9551
8858
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
9552
8859
  };
9553
- var __classPrivateFieldGet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8860
+ var __classPrivateFieldGet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9554
8861
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9555
8862
  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");
9556
8863
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -9607,11 +8914,11 @@ class Channel extends base_1$e.EmitterBase {
9607
8914
  client_1.ChannelClient.handleProviderDisconnect(eventPayload);
9608
8915
  }),
9609
8916
  this.on('connected', (...args) => {
9610
- __classPrivateFieldGet$6(this, _Channel_internalEmitter, "f").emit('connected', ...args);
8917
+ __classPrivateFieldGet$7(this, _Channel_internalEmitter, "f").emit('connected', ...args);
9611
8918
  })
9612
8919
  ]).catch(() => new Error('error setting up channel connection listeners'));
9613
8920
  }));
9614
- __classPrivateFieldSet$5(this, _Channel_connectionManager, new connection_manager_1.ConnectionManager(wire), "f");
8921
+ __classPrivateFieldSet$6(this, _Channel_connectionManager, new connection_manager_1.ConnectionManager(wire), "f");
9615
8922
  }
9616
8923
  /**
9617
8924
  *
@@ -9686,7 +8993,7 @@ class Channel extends base_1$e.EmitterBase {
9686
8993
  resolve(true);
9687
8994
  }
9688
8995
  };
9689
- __classPrivateFieldGet$6(this, _Channel_internalEmitter, "f").on('connected', connectedListener);
8996
+ __classPrivateFieldGet$7(this, _Channel_internalEmitter, "f").on('connected', connectedListener);
9690
8997
  });
9691
8998
  try {
9692
8999
  if (retryInfo.count > 0) {
@@ -9718,7 +9025,7 @@ class Channel extends base_1$e.EmitterBase {
9718
9025
  finally {
9719
9026
  retryInfo.count += 1;
9720
9027
  // in case of other errors, remove our listener
9721
- __classPrivateFieldGet$6(this, _Channel_internalEmitter, "f").removeListener('connected', connectedListener);
9028
+ __classPrivateFieldGet$7(this, _Channel_internalEmitter, "f").removeListener('connected', connectedListener);
9722
9029
  }
9723
9030
  } while (shouldWait); // If we're waiting we retry the above loop
9724
9031
  // Should wait was false, no channel was found.
@@ -9777,12 +9084,12 @@ class Channel extends base_1$e.EmitterBase {
9777
9084
  async connect(channelName, options = {}) {
9778
9085
  // Make sure we don't connect before listeners are set up
9779
9086
  // This also errors if we're not in OpenFin, ensuring we don't run unnecessary code
9780
- await __classPrivateFieldGet$6(this, _Channel_readyToConnect, "f").getValue();
9087
+ await __classPrivateFieldGet$7(this, _Channel_readyToConnect, "f").getValue();
9781
9088
  if (!channelName || typeof channelName !== 'string') {
9782
9089
  throw new Error('Please provide a channelName string to connect to a channel.');
9783
9090
  }
9784
9091
  const opts = { wait: true, ...this.wire.environment.getDefaultChannelOptions().connect, ...options };
9785
- const { offer, rtc: rtcPacket } = await __classPrivateFieldGet$6(this, _Channel_connectionManager, "f").createClientOffer(opts);
9092
+ const { offer, rtc: rtcPacket } = await __classPrivateFieldGet$7(this, _Channel_connectionManager, "f").createClientOffer(opts);
9786
9093
  let connectionUrl;
9787
9094
  if (this.fin.me.isFrame || this.fin.me.isView || this.fin.me.isWindow) {
9788
9095
  connectionUrl = (await this.fin.me.getInfo()).url;
@@ -9794,7 +9101,7 @@ class Channel extends base_1$e.EmitterBase {
9794
9101
  connectionUrl
9795
9102
  };
9796
9103
  const routingInfo = await this.safeConnect(channelName, opts.wait, connectPayload);
9797
- const strategy = await __classPrivateFieldGet$6(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
9104
+ const strategy = await __classPrivateFieldGet$7(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
9798
9105
  const channel = new client_1.ChannelClient(routingInfo, () => client_1.ChannelClient.wireClose(this.wire, routingInfo, routingInfo.endpointId), strategy);
9799
9106
  // It is the client's responsibility to handle endpoint disconnection to the provider.
9800
9107
  // If the endpoint dies, the client will force a disconnection through the core.
@@ -9863,7 +9170,7 @@ class Channel extends base_1$e.EmitterBase {
9863
9170
  throw new Error('Please provide a channelName to create a channel');
9864
9171
  }
9865
9172
  const { payload: { data: providerIdentity } } = await this.wire.sendAction('create-channel', { channelName });
9866
- const channel = __classPrivateFieldGet$6(this, _Channel_connectionManager, "f").createProvider(options, providerIdentity);
9173
+ const channel = __classPrivateFieldGet$7(this, _Channel_connectionManager, "f").createProvider(options, providerIdentity);
9867
9174
  // TODO: fix typing (internal)
9868
9175
  // @ts-expect-error
9869
9176
  this.on('client-disconnected', (eventPayload) => {
@@ -10754,13 +10061,13 @@ var Factory$3 = {};
10754
10061
 
10755
10062
  var Instance$2 = {};
10756
10063
 
10757
- var __classPrivateFieldSet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
10064
+ var __classPrivateFieldSet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
10758
10065
  if (kind === "m") throw new TypeError("Private method is not writable");
10759
10066
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10760
10067
  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");
10761
10068
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
10762
10069
  };
10763
- var __classPrivateFieldGet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
10070
+ var __classPrivateFieldGet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
10764
10071
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10765
10072
  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");
10766
10073
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -10797,24 +10104,24 @@ class Platform extends base_1$6.EmitterBase {
10797
10104
  this.wire.sendAction('platform-get-client', this.identity).catch((e) => {
10798
10105
  // don't expose
10799
10106
  });
10800
- if (!Platform.clientMap.has(__classPrivateFieldGet$5(this, _Platform_channelName, "f"))) {
10801
- const clientPromise = __classPrivateFieldGet$5(this, _Platform_connectToProvider, "f").call(this);
10802
- Platform.clientMap.set(__classPrivateFieldGet$5(this, _Platform_channelName, "f"), clientPromise);
10107
+ if (!Platform.clientMap.has(__classPrivateFieldGet$6(this, _Platform_channelName, "f"))) {
10108
+ const clientPromise = __classPrivateFieldGet$6(this, _Platform_connectToProvider, "f").call(this);
10109
+ Platform.clientMap.set(__classPrivateFieldGet$6(this, _Platform_channelName, "f"), clientPromise);
10803
10110
  }
10804
10111
  // we set it above
10805
10112
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
10806
- return Platform.clientMap.get(__classPrivateFieldGet$5(this, _Platform_channelName, "f"));
10113
+ return Platform.clientMap.get(__classPrivateFieldGet$6(this, _Platform_channelName, "f"));
10807
10114
  };
10808
10115
  _Platform_connectToProvider.set(this, async () => {
10809
10116
  try {
10810
- const client = await this._channel.connect(__classPrivateFieldGet$5(this, _Platform_channelName, "f"), { wait: false });
10117
+ const client = await this._channel.connect(__classPrivateFieldGet$6(this, _Platform_channelName, "f"), { wait: false });
10811
10118
  client.onDisconnection(() => {
10812
- Platform.clientMap.delete(__classPrivateFieldGet$5(this, _Platform_channelName, "f"));
10119
+ Platform.clientMap.delete(__classPrivateFieldGet$6(this, _Platform_channelName, "f"));
10813
10120
  });
10814
10121
  return client;
10815
10122
  }
10816
10123
  catch (e) {
10817
- Platform.clientMap.delete(__classPrivateFieldGet$5(this, _Platform_channelName, "f"));
10124
+ Platform.clientMap.delete(__classPrivateFieldGet$6(this, _Platform_channelName, "f"));
10818
10125
  throw new Error('The targeted Platform is not currently running. Listen for application-started event for the given Uuid.');
10819
10126
  }
10820
10127
  });
@@ -10827,7 +10134,7 @@ class Platform extends base_1$6.EmitterBase {
10827
10134
  if (errorMsg) {
10828
10135
  throw new Error(errorMsg);
10829
10136
  }
10830
- __classPrivateFieldSet$4(this, _Platform_channelName, channelName, "f");
10137
+ __classPrivateFieldSet$5(this, _Platform_channelName, channelName, "f");
10831
10138
  this._channel = this.fin.InterApplicationBus.Channel;
10832
10139
  this.identity = { uuid: identity.uuid };
10833
10140
  this.Layout = this.fin.Platform.Layout;
@@ -11546,88 +10853,752 @@ class Platform extends base_1$6.EmitterBase {
11546
10853
  * ```
11547
10854
  * @experimental
11548
10855
  */
11549
- async getWindowContext(target) {
11550
- this.wire.sendAction('platform-get-window-context', this.identity).catch((e) => {
10856
+ async getWindowContext(target) {
10857
+ this.wire.sendAction('platform-get-window-context', this.identity).catch((e) => {
10858
+ // don't expose
10859
+ });
10860
+ const client = await this.getClient();
10861
+ const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
10862
+ return client.dispatch('get-window-context', {
10863
+ target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name },
10864
+ entityType
10865
+ });
10866
+ }
10867
+ /**
10868
+ * Closes a window. If enableBeforeUnload is enabled in the Platform options, any beforeunload handler set on Views will fire
10869
+ * This behavior can be disabled by setting skipBeforeUnload to false in the options parameter.
10870
+ * @param winId
10871
+ * @param options
10872
+ *
10873
+ * @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,
10874
+ * it is recommended to move that logic over to the [PlatformProvider.closeWindow]{@link PlatformProvider#closeWindow} override to ensure it runs when the Window closes.
10875
+ *
10876
+ * @example
10877
+ *
10878
+ * ```js
10879
+ * // Close the current Window inside a Window context
10880
+ * const platform = await fin.Platform.getCurrent();
10881
+ * platform.closeWindow(fin.me.identity);
10882
+ *
10883
+ * // Close the Window from inside a View context
10884
+ * const platform = await fin.Platform.getCurrent();
10885
+ * const parentWindow = await fin.me.getCurrentWindow();
10886
+ * platform.closeWindow(parentWindow.identity);
10887
+ *
10888
+ * // Close the Window and do not fire the before unload handler on Views
10889
+ * const platform = await fin.Platform.getCurrent();
10890
+ * platform.closeWindow(fin.me.identity, { skipBeforeUnload: true });
10891
+ * ```
10892
+ * @experimental
10893
+ */
10894
+ async closeWindow(windowId, options = { skipBeforeUnload: false }) {
10895
+ this.wire.sendAction('platform-close-window', this.identity).catch((e) => {
11551
10896
  // don't expose
11552
10897
  });
11553
10898
  const client = await this.getClient();
11554
- const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
11555
- return client.dispatch('get-window-context', {
11556
- target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name },
11557
- entityType
10899
+ return client.dispatch('close-window', { windowId, options });
10900
+ }
10901
+ }
10902
+ Instance$2.Platform = Platform;
10903
+ _Platform_channelName = new WeakMap(), _Platform_connectToProvider = new WeakMap();
10904
+ /**
10905
+ * @internal
10906
+ * Reuse clients to avoid overwriting already-registered client in provider
10907
+ * This ensures that only channel client is created per channel name per `fin` instance
10908
+ */
10909
+ Platform.clientMap = new Map();
10910
+
10911
+ var layout = {};
10912
+
10913
+ var Factory$2 = {};
10914
+
10915
+ var Instance$1 = {};
10916
+
10917
+ var commonUtils = {};
10918
+
10919
+ Object.defineProperty(commonUtils, "__esModule", { value: true });
10920
+ commonUtils.overrideFromComposables = commonUtils.isValidPresetType = void 0;
10921
+ function isValidPresetType(type) {
10922
+ switch (type) {
10923
+ case 'columns':
10924
+ case 'grid':
10925
+ case 'rows':
10926
+ case 'tabs':
10927
+ return true;
10928
+ default:
10929
+ return false;
10930
+ }
10931
+ }
10932
+ commonUtils.isValidPresetType = isValidPresetType;
10933
+ function overrideFromComposables(...overrides) {
10934
+ return (base) => overrides.reduceRight((p, c) => (b) => c(p(b)), (x) => x)(base);
10935
+ }
10936
+ commonUtils.overrideFromComposables = overrideFromComposables;
10937
+ commonUtils.default = { isValidPresetType };
10938
+
10939
+ var layoutEntities = {};
10940
+
10941
+ var apiExposer$1 = {};
10942
+
10943
+ var apiConsumer = {};
10944
+
10945
+ Object.defineProperty(apiConsumer, "__esModule", { value: true });
10946
+ apiConsumer.ApiConsumer = void 0;
10947
+ /**
10948
+ * Consumer for apis exposed with {@see ApiExposer}.
10949
+ *
10950
+ * A strategy that matches the strategy used to expose a target API must be provided.
10951
+ */
10952
+ class ApiConsumer {
10953
+ // eslint-disable-next-line
10954
+ constructor(strategy) {
10955
+ this.strategy = strategy;
10956
+ /**
10957
+ * Consumes an api exposed using a given transport strategy, and generates a client
10958
+ * for easy, type safe consumption of that client.
10959
+ * @param options Strategy specific consumption options.
10960
+ * @returns An api client matching the given type.
10961
+ */
10962
+ this.consume = async (options) => {
10963
+ const exposedProperties = await this.strategy.getExposedFunctions(options);
10964
+ return exposedProperties.reduce((client, prop) => ({
10965
+ ...client,
10966
+ [prop.key]: this.strategy.createFunction(prop, options)
10967
+ }), {});
10968
+ };
10969
+ }
10970
+ }
10971
+ apiConsumer.ApiConsumer = ApiConsumer;
10972
+
10973
+ var apiExposer = {};
10974
+
10975
+ var decorators = {};
10976
+
10977
+ Object.defineProperty(decorators, "__esModule", { value: true });
10978
+ decorators.expose = decorators.getExposedProperties = void 0;
10979
+ const exposedProperties = Symbol('exposedProperties');
10980
+ const getExposedProperties = (target) => {
10981
+ return target[exposedProperties] || target.prototype[exposedProperties] || [];
10982
+ };
10983
+ decorators.getExposedProperties = getExposedProperties;
10984
+ /**
10985
+ * Indicates that a class member function can be exposed using {@link ApiExposer}.
10986
+ * @param options Options specific to the strategy used in {@link ApiExposer}
10987
+ */
10988
+ // Returns any as decorator typing is weird.
10989
+ const expose = (options) => (target, key, descriptor) => {
10990
+ target[exposedProperties] = target[exposedProperties] || [];
10991
+ target[exposedProperties].push({ key, descriptor, options });
10992
+ };
10993
+ decorators.expose = expose;
10994
+
10995
+ Object.defineProperty(apiExposer, "__esModule", { value: true });
10996
+ apiExposer.ApiExposer = void 0;
10997
+ const decorators_1 = decorators;
10998
+ /**
10999
+ * Exposes api services on the transport of choice.
11000
+ */
11001
+ class ApiExposer {
11002
+ /**
11003
+ * @param strategy The expose strategy to use to expose instances.
11004
+ */
11005
+ // eslint-disable-next-line
11006
+ constructor(strategy) {
11007
+ this.strategy = strategy;
11008
+ /**
11009
+ * Exposes an instance of a given api on
11010
+ * @param instance Instance of a class which has been decorated to indicate which functions can be exposed.
11011
+ * @param instanceOptions Transport strategy specific options to use when exposing.
11012
+ */
11013
+ this.exposeInstance = async (instance, instanceOptions) => {
11014
+ const exposableProps = (0, decorators_1.getExposedProperties)(instance);
11015
+ const exposedProps = await Promise.all(exposableProps.map(async ({ key, options }) => {
11016
+ const customConsumptionOptions = await this.strategy.exposeFunction(instance[key].bind(instance), {
11017
+ key,
11018
+ options,
11019
+ meta: instanceOptions
11020
+ });
11021
+ return {
11022
+ key,
11023
+ options: customConsumptionOptions
11024
+ };
11025
+ }));
11026
+ await this.strategy.exposeMeta(instanceOptions, exposedProps);
11027
+ };
11028
+ }
11029
+ ;
11030
+ }
11031
+ apiExposer.ApiExposer = ApiExposer;
11032
+
11033
+ var strategies = {};
11034
+
11035
+ var openfinChannels = {};
11036
+
11037
+ var channelsConsumer = {};
11038
+
11039
+ Object.defineProperty(channelsConsumer, "__esModule", { value: true });
11040
+ channelsConsumer.ChannelsConsumer = void 0;
11041
+ class ChannelsConsumer {
11042
+ // eslint-disable-next-line
11043
+ constructor(channel) {
11044
+ this.channel = channel;
11045
+ this.getExposedFunctions = async (options) => {
11046
+ const { id } = options;
11047
+ const { props } = await this.channel.dispatch(`api-meta:${id}`);
11048
+ return props;
11049
+ };
11050
+ this.createFunction = (prop) => (...args) => {
11051
+ const { action } = prop.options;
11052
+ return this.channel.dispatch(action, { args });
11053
+ };
11054
+ }
11055
+ ;
11056
+ }
11057
+ channelsConsumer.ChannelsConsumer = ChannelsConsumer;
11058
+
11059
+ var channelsExposer = {};
11060
+
11061
+ Object.defineProperty(channelsExposer, "__esModule", { value: true });
11062
+ channelsExposer.ChannelsExposer = void 0;
11063
+ class ChannelsExposer {
11064
+ // eslint-disable-next-line
11065
+ constructor(channelProviderOrClient) {
11066
+ this.channelProviderOrClient = channelProviderOrClient;
11067
+ this.exposeFunction = async (target, config) => {
11068
+ const { key, options, meta } = config;
11069
+ const { id } = meta;
11070
+ const action = `${id}.${options?.action || key}`;
11071
+ await this.channelProviderOrClient.register(action, async ({ args }) => {
11072
+ return target(...args);
11073
+ });
11074
+ return { action };
11075
+ };
11076
+ this.exposeMeta = async ({ id }, props) => {
11077
+ const action = `api-meta:${id}`;
11078
+ await this.channelProviderOrClient.register(action, () => ({ props }));
11079
+ };
11080
+ }
11081
+ }
11082
+ channelsExposer.ChannelsExposer = ChannelsExposer;
11083
+
11084
+ (function (exports) {
11085
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11086
+ if (k2 === undefined) k2 = k;
11087
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11088
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11089
+ desc = { enumerable: true, get: function() { return m[k]; } };
11090
+ }
11091
+ Object.defineProperty(o, k2, desc);
11092
+ }) : (function(o, m, k, k2) {
11093
+ if (k2 === undefined) k2 = k;
11094
+ o[k2] = m[k];
11095
+ }));
11096
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
11097
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11098
+ };
11099
+ Object.defineProperty(exports, "__esModule", { value: true });
11100
+ __exportStar(channelsConsumer, exports);
11101
+ __exportStar(channelsExposer, exports);
11102
+ } (openfinChannels));
11103
+
11104
+ (function (exports) {
11105
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11106
+ if (k2 === undefined) k2 = k;
11107
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11108
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11109
+ desc = { enumerable: true, get: function() { return m[k]; } };
11110
+ }
11111
+ Object.defineProperty(o, k2, desc);
11112
+ }) : (function(o, m, k, k2) {
11113
+ if (k2 === undefined) k2 = k;
11114
+ o[k2] = m[k];
11115
+ }));
11116
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
11117
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11118
+ };
11119
+ Object.defineProperty(exports, "__esModule", { value: true });
11120
+ __exportStar(openfinChannels, exports);
11121
+ } (strategies));
11122
+
11123
+ (function (exports) {
11124
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11125
+ if (k2 === undefined) k2 = k;
11126
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11127
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11128
+ desc = { enumerable: true, get: function() { return m[k]; } };
11129
+ }
11130
+ Object.defineProperty(o, k2, desc);
11131
+ }) : (function(o, m, k, k2) {
11132
+ if (k2 === undefined) k2 = k;
11133
+ o[k2] = m[k];
11134
+ }));
11135
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
11136
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11137
+ };
11138
+ Object.defineProperty(exports, "__esModule", { value: true });
11139
+ __exportStar(apiConsumer, exports);
11140
+ __exportStar(apiExposer, exports);
11141
+ __exportStar(strategies, exports);
11142
+ __exportStar(decorators, exports);
11143
+ } (apiExposer$1));
11144
+
11145
+ var channelApiRelay = {};
11146
+
11147
+ Object.defineProperty(channelApiRelay, "__esModule", { value: true });
11148
+ channelApiRelay.createRelayedDispatch = channelApiRelay.relayChannelClientApi = void 0;
11149
+ const EXPECTED_ERRORS = [
11150
+ 'no longer connected',
11151
+ 'RTCDataChannel closed unexpectedly',
11152
+ 'The client you are trying to dispatch from is disconnected from the target provider',
11153
+ ];
11154
+ // Checks possible error messages that we want to trap, client error message can originate
11155
+ // from ChannelProvider::dispatch OR ClassicStrategy::closeEndpoint OR RTCEndPoint::dataChannel::onclose
11156
+ const isDisconnectedError = (errorMsg) => {
11157
+ return EXPECTED_ERRORS.some(e => errorMsg.includes(e));
11158
+ };
11159
+ /**
11160
+ * @internal
11161
+ * Create a channel relay for a given channel exposition, allowing a single provider to route
11162
+ * actions to the designated clients.
11163
+ *
11164
+ * Designed to be used in conjunction with @expose
11165
+ *
11166
+ * @param channelProvider The channel provider to relay the actions on.
11167
+ * @param config Determines which actions to relay. Please ensure action prefix matches the exposed api.
11168
+ */
11169
+ const relayChannelClientApi = async (channelProvider, relayId) => {
11170
+ channelProvider.register(`relay:${relayId}`, ({ action, target, payload }) => {
11171
+ return channelProvider.dispatch(target, action, payload);
11172
+ });
11173
+ await Promise.resolve();
11174
+ };
11175
+ channelApiRelay.relayChannelClientApi = relayChannelClientApi;
11176
+ const createRelayedDispatch = (client, target, relayId, relayErrorMsg) => async (action, payload) => {
11177
+ try {
11178
+ return await client.dispatch(`relay:${relayId}`, {
11179
+ action,
11180
+ payload,
11181
+ target
11558
11182
  });
11559
11183
  }
11184
+ catch (e) {
11185
+ if (isDisconnectedError(e.message) && relayErrorMsg) {
11186
+ throw new Error(relayErrorMsg);
11187
+ }
11188
+ throw e;
11189
+ }
11190
+ };
11191
+ channelApiRelay.createRelayedDispatch = createRelayedDispatch;
11192
+
11193
+ var __classPrivateFieldSet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
11194
+ if (kind === "m") throw new TypeError("Private method is not writable");
11195
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
11196
+ 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");
11197
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11198
+ };
11199
+ var __classPrivateFieldGet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
11200
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
11201
+ 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");
11202
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11203
+ };
11204
+ var _LayoutNode_client, _TabStack_client, _ColumnOrRow_client;
11205
+ Object.defineProperty(layoutEntities, "__esModule", { value: true });
11206
+ layoutEntities.ColumnOrRow = layoutEntities.TabStack = layoutEntities.LayoutNode = void 0;
11207
+ const api_exposer_1 = apiExposer$1;
11208
+ const channel_api_relay_1 = channelApiRelay;
11209
+ /*
11210
+ This file includes LayoutNode, ColumnOrRow and TabStack classes, which are all closely
11211
+ intertwined, and share members via parent abstract class LayoutNode. To prevent circular
11212
+ refs, we define and export all the classes here.
11213
+ */
11214
+ /**
11215
+ * @ignore
11216
+ * @internal
11217
+ * Supplies an ApiClient for {@link LayoutEntitiesController} and helper methods
11218
+ * for the entities {@link TabStack} AND {@link ColumnOrRow} to use.
11219
+ */
11220
+ class LayoutNode {
11560
11221
  /**
11561
- * Closes a window. If enableBeforeUnload is enabled in the Platform options, any beforeunload handler set on Views will fire
11562
- * This behavior can be disabled by setting skipBeforeUnload to false in the options parameter.
11563
- * @param winId
11564
- * @param options
11565
- *
11566
- * @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,
11567
- * it is recommended to move that logic over to the [PlatformProvider.closeWindow]{@link PlatformProvider#closeWindow} override to ensure it runs when the Window closes.
11568
- *
11569
- * @example
11570
- *
11571
- * ```js
11572
- * // Close the current Window inside a Window context
11573
- * const platform = await fin.Platform.getCurrent();
11574
- * platform.closeWindow(fin.me.identity);
11575
- *
11576
- * // Close the Window from inside a View context
11577
- * const platform = await fin.Platform.getCurrent();
11578
- * const parentWindow = await fin.me.getCurrentWindow();
11579
- * platform.closeWindow(parentWindow.identity);
11580
- *
11581
- * // Close the Window and do not fire the before unload handler on Views
11582
- * const platform = await fin.Platform.getCurrent();
11583
- * platform.closeWindow(fin.me.identity, { skipBeforeUnload: true });
11584
- * ```
11585
- * @experimental
11222
+ * @internal
11223
+ * @ignore
11586
11224
  */
11587
- async closeWindow(windowId, options = { skipBeforeUnload: false }) {
11588
- this.wire.sendAction('platform-close-window', this.identity).catch((e) => {
11589
- // don't expose
11590
- });
11591
- const client = await this.getClient();
11592
- return client.dispatch('close-window', { windowId, options });
11225
+ constructor(client, entityId) {
11226
+ /**
11227
+ * @ignore
11228
+ * @internal
11229
+ * ApiClient for {@link LayoutEntitiesController}
11230
+ */
11231
+ _LayoutNode_client.set(this, void 0);
11232
+ /**
11233
+ * Checks if the TabStack or ColumnOrRow is the root content item
11234
+ *
11235
+ * @example
11236
+ * ```js
11237
+ * if (!fin.me.isView) {
11238
+ * throw new Error('Not running in a platform View.');
11239
+ * }
11240
+ *
11241
+ * const stack = await fin.me.getCurrentStack();
11242
+ * const isRoot = await stack.isRoot();
11243
+ * // The TabStack is root: false
11244
+ * console.log(`The TabStack is root: ${isRoot}`);
11245
+ *
11246
+ * // Retrieves the parent ColumnOrRow
11247
+ * const parent = await stack.getParent();
11248
+ * const parentIsRoot = await parent.isRoot();
11249
+ * // The parent ColumnOrRow is root: true
11250
+ * console.log(`The parent ColumnOrRow is root: ${parentIsRoot}`);
11251
+ * ```
11252
+ */
11253
+ this.isRoot = () => __classPrivateFieldGet$5(this, _LayoutNode_client, "f").isRoot(this.entityId);
11254
+ /**
11255
+ * Checks if the TabStack or ColumnOrRow exists
11256
+ *
11257
+ * @example
11258
+ * ```js
11259
+ * if (!fin.me.isView) {
11260
+ * throw new Error('Not running in a platform View.');
11261
+ * }
11262
+ *
11263
+ * const stack = await fin.me.getCurrentStack();
11264
+ * // Retrieves the parent ColumnOrRow
11265
+ * const columnOrRow = await stack.getParent();
11266
+ * let exists = await stack.exists();
11267
+ * // or
11268
+ * let exists = await columnOrRow.exists();
11269
+ * // The entity exists: true
11270
+ * console.log(`The entity exists: ${exists}`);
11271
+ * ```
11272
+ */
11273
+ this.exists = () => __classPrivateFieldGet$5(this, _LayoutNode_client, "f").exists(this.entityId);
11274
+ /**
11275
+ * Retrieves the parent of the TabStack or ColumnOrRow
11276
+ *
11277
+ * @example
11278
+ * ```js
11279
+ * if (!fin.me.isView) {
11280
+ * throw new Error('Not running in a platform View.');
11281
+ * }
11282
+ *
11283
+ * const stack = await fin.me.getCurrentStack();
11284
+ * // Retrieves the parent ColumnOrRow
11285
+ * const columnOrRow = await stack.getParent();
11286
+ *
11287
+ * // undefined if entity is the root item
11288
+ * let parent = await columnOrRow.getParent();
11289
+ * // or
11290
+ * let parent = await stack.getParent();
11291
+ * ```
11292
+ */
11293
+ this.getParent = async () => {
11294
+ const parent = await __classPrivateFieldGet$5(this, _LayoutNode_client, "f").getParent(this.entityId);
11295
+ if (!parent) {
11296
+ return undefined;
11297
+ }
11298
+ return LayoutNode.getEntity(parent, __classPrivateFieldGet$5(this, _LayoutNode_client, "f"));
11299
+ };
11300
+ /**
11301
+ * Creates a new TabStack adjacent to the given TabStack or ColumnOrRow. Inputs can be new views to create, or existing views.
11302
+ *
11303
+ * Known Issue: If the number of views to add overflows the tab-container, the added views will be set as active
11304
+ * during each render, and then placed at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
11305
+ * This means the views you pass to createAdjacentStack() may not render in the order given by the array.
11306
+ * Until fixed, this problem can be avoided only if your window is wide enough to fit creating all the views in the tabstack.
11307
+ *
11308
+ * @param views The views that will populate the new TabStack.
11309
+ * @param options Additional options that control new TabStack creation.
11310
+ * @returns The newly-created TabStack.
11311
+ *
11312
+ * @example
11313
+ * ```js
11314
+ * if (!fin.me.isView) {
11315
+ * throw new Error('Not running in a platform View.');
11316
+ * }
11317
+ *
11318
+ * const stack = await fin.me.getCurrentStack();
11319
+ * const columnOrRow = await stack.getParent();
11320
+ *
11321
+ * // Create view references by supplying a 'name' and 'url'
11322
+ * const views = [
11323
+ * // if 'name' is undefined, one will be generated
11324
+ * // if 'url' is undefined, it will default the view URL to 'about:blank'
11325
+ * { name: 'google-view', url: 'http://google.com/'},
11326
+ * { name: 'of-developers-view', url: 'http://developers.openfin.co/'},
11327
+ * ];
11328
+ *
11329
+ * // Create a view beforehand to be included in the new tab stack
11330
+ * const outsideView = await fin.View.create({
11331
+ * name: 'outside-bloomberg-view',
11332
+ * url: 'https://bloomberg.com/',
11333
+ * target: fin.me.identity,
11334
+ * });
11335
+ *
11336
+ * // Views to add can be identities, or the reference views mentioned above
11337
+ * const viewsToAdd = [outsideView.identity, ...views];
11338
+ *
11339
+ * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
11340
+ * let stackFrom = await columnOrRow.createAdjacentStack(viewsToAdd, { position: 'right' });
11341
+ * // Or
11342
+ * let newStack = await stack.createAdjacentStack(viewsToAdd, { position: 'right' });
11343
+ * console.log(`A new TabStack created to the right has ${newStack.length} views in it`);
11344
+ *
11345
+ * ```
11346
+ * @experimental
11347
+ */
11348
+ this.createAdjacentStack = async (views, options) => {
11349
+ const entityId = await __classPrivateFieldGet$5(this, _LayoutNode_client, "f").createAdjacentStack(this.entityId, views, options);
11350
+ return LayoutNode.getEntity({ entityId, type: 'stack' }, __classPrivateFieldGet$5(this, _LayoutNode_client, "f"));
11351
+ };
11352
+ /**
11353
+ * Retrieves the adjacent TabStacks of the given TabStack or ColumnOrRow.
11354
+ *
11355
+ * @param edge Edge whose adjacent TabStacks will be returned.
11356
+ *
11357
+ * @example
11358
+ * ```js
11359
+ * if (!fin.me.isView) {
11360
+ * throw new Error('Not running in a platform View.');
11361
+ * }
11362
+ *
11363
+ * const stack = await fin.me.getCurrentStack();
11364
+ * const columnOrRow = await stack.getParent();
11365
+ * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
11366
+ * let rightStacks = await columnOrRow.getAdjacentStacks('right');
11367
+ * let leftStacks = await columnOrRow.getAdjacentStacks('left');
11368
+ * // or
11369
+ * let rightStacks = await stack.getAdjacentStacks('right');
11370
+ * let leftStacks = await stack.getAdjacentStacks('left');
11371
+ *
11372
+ * console.log(`The entity has ${rightStacks.length} stacks to the right, and ${leftStacks.length} stacks to the left`);
11373
+ *
11374
+ * ```
11375
+ * @experimental
11376
+ */
11377
+ this.getAdjacentStacks = async (edge) => {
11378
+ const adjacentStacks = await __classPrivateFieldGet$5(this, _LayoutNode_client, "f").getAdjacentStacks({
11379
+ targetId: this.entityId,
11380
+ edge
11381
+ });
11382
+ return adjacentStacks.map((stack) => LayoutNode.getEntity({
11383
+ type: 'stack',
11384
+ entityId: stack.entityId
11385
+ }, __classPrivateFieldGet$5(this, _LayoutNode_client, "f")));
11386
+ };
11387
+ __classPrivateFieldSet$4(this, _LayoutNode_client, client, "f");
11388
+ this.entityId = entityId;
11593
11389
  }
11594
11390
  }
11595
- Instance$2.Platform = Platform;
11596
- _Platform_channelName = new WeakMap(), _Platform_connectToProvider = new WeakMap();
11391
+ layoutEntities.LayoutNode = LayoutNode;
11392
+ _LayoutNode_client = new WeakMap();
11597
11393
  /**
11394
+ * @ignore
11598
11395
  * @internal
11599
- * Reuse clients to avoid overwriting already-registered client in provider
11600
- * This ensures that only channel client is created per channel name per `fin` instance
11396
+ * Encapsulates Api consumption of {@link LayoutEntitiesClient} with a relayed dispatch
11397
+ * @param client
11398
+ * @param controllerId
11399
+ * @param identity
11400
+ * @returns a new instance of {@link LayoutEntitiesClient} with bound to the controllerId
11601
11401
  */
11602
- Platform.clientMap = new Map();
11603
-
11604
- var layout = {};
11605
-
11606
- var Factory$2 = {};
11607
-
11608
- var Instance$1 = {};
11609
-
11610
- var commonUtils = {};
11611
-
11612
- Object.defineProperty(commonUtils, "__esModule", { value: true });
11613
- commonUtils.overrideFromComposables = commonUtils.isValidPresetType = void 0;
11614
- function isValidPresetType(type) {
11402
+ LayoutNode.newLayoutEntitiesClient = async (client, controllerId, identity) => {
11403
+ 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.');
11404
+ const consumer = new api_exposer_1.ApiConsumer(new api_exposer_1.ChannelsConsumer({ dispatch }));
11405
+ return consumer.consume({ id: controllerId });
11406
+ };
11407
+ LayoutNode.getEntity = (definition, client) => {
11408
+ const { entityId, type } = definition;
11615
11409
  switch (type) {
11616
- case 'columns':
11617
- case 'grid':
11618
- case 'rows':
11619
- case 'tabs':
11620
- return true;
11410
+ case 'column':
11411
+ case 'row':
11412
+ return new ColumnOrRow(client, entityId, type);
11413
+ case 'stack':
11414
+ return new TabStack(client, entityId);
11621
11415
  default:
11622
- return false;
11416
+ throw new Error(`Unrecognised Layout Entity encountered ('${JSON.stringify(definition)})`);
11417
+ }
11418
+ };
11419
+ /**
11420
+ * A TabStack is used to manage the state of a stack of tabs within an OpenFin Layout.
11421
+ */
11422
+ class TabStack extends LayoutNode {
11423
+ /** @internal */
11424
+ constructor(client, entityId) {
11425
+ super(client, entityId);
11426
+ /**
11427
+ * @internal
11428
+ * ApiClient for {@link LayoutEntitiesController}
11429
+ */
11430
+ _TabStack_client.set(this, void 0);
11431
+ /**
11432
+ * Type of the content item. Always stack, but useful for distinguishing between a {@link TabStack} and {@link ColumnOrRow}.
11433
+ */
11434
+ this.type = 'stack';
11435
+ /**
11436
+ * Retrieves a list of all views belonging to this {@link TabStack}.
11437
+ *
11438
+ * Known Issue: If adding a view overflows the tab-container width, the added view will be set as active
11439
+ * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
11440
+ * If that happens and then getViews() is called, it will return the identities in a different order than
11441
+ * than the currently rendered tab order.
11442
+ *
11443
+ *
11444
+ * @throws If the {@link TabStack} has been destroyed.
11445
+ * @example
11446
+ * ```js
11447
+ * if (!fin.me.isView) {
11448
+ * throw new Error('Not running in a platform View.');
11449
+ * }
11450
+ *
11451
+ * const stack = await fin.me.getCurrentStack();
11452
+ * // Alternatively, you can wrap any view and get the stack from there
11453
+ * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
11454
+ * // const stack = await viewFromSomewhere.getCurrentStack();
11455
+ * const views = await stack.getViews();
11456
+ * console.log(`Stack contains ${views.length} view(s)`);
11457
+ * ```
11458
+ * @experimental
11459
+ */
11460
+ this.getViews = () => __classPrivateFieldGet$5(this, _TabStack_client, "f").getStackViews(this.entityId);
11461
+ /**
11462
+ * Adds or creates a view in this {@link TabStack}.
11463
+ *
11464
+ * @remarks Known Issue: If adding a view overflows the tab-container, the added view will be set as active
11465
+ * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
11466
+ *
11467
+ * @param view The identity of an existing view to add, or options to create a view.
11468
+ * @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)
11469
+ * @returns Resolves with the {@link OpenFin.Identity identity} of the added view.
11470
+ * @throws If the view does not exist or fails to create.
11471
+ * @throws If the {@link TabStack} has been destroyed.
11472
+ * @example
11473
+ * ```js
11474
+ * if (!fin.me.isView) {
11475
+ * throw new Error('Not running in a platform View.');
11476
+ * }
11477
+ *
11478
+ * const stack = await fin.me.getCurrentStack();
11479
+ * // Alternatively, you can wrap any view and get the stack from there
11480
+ * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
11481
+ * // const stack = await viewFromSomewhere.getCurrentStack();
11482
+ * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
11483
+ * console.log('Identity of the google view just added', { googleViewIdentity });
11484
+ * // pass in { index: number } to set the index in the stack. Here 1 means, end of the stack (defaults to 0)
11485
+ * const appleViewIdentity = await stack.addView({ name: 'apple-view', url: 'http://apple.com/' }, { index: 1 });
11486
+ * console.log('Identity of the apple view just added', { appleViewIdentity });
11487
+ * ```
11488
+ * @experimental
11489
+ */
11490
+ this.addView = async (view, options = { index: 0 }) => __classPrivateFieldGet$5(this, _TabStack_client, "f").addViewToStack(this.entityId, view, options);
11491
+ /**
11492
+ * Removes a view from this {@link TabStack}.
11493
+ *
11494
+ * @remarks Throws an exception if the view identity does not exist or was already destroyed.
11495
+ *
11496
+ * @param view - Identity of the view to remove.
11497
+ * @throws If the view does not exist or does not belong to the stack.
11498
+ * @throws If the {@link TabStack} has been destroyed.
11499
+ *
11500
+ * @example
11501
+ * ```js
11502
+ * if (!fin.me.isView) {
11503
+ * throw new Error('Not running in a platform View.');
11504
+ * }
11505
+ *
11506
+ * const stack = await fin.me.getCurrentStack();
11507
+ * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
11508
+ *
11509
+ * await stack.removeView(googleViewIdentity);
11510
+ *
11511
+ * try {
11512
+ * await stack.removeView(googleViewIdentity);
11513
+ * } catch (error) {
11514
+ * // Tried to remove a view ('google-view') which does not belong to the stack.
11515
+ * console.log(error);
11516
+ * }
11517
+ * ```
11518
+ */
11519
+ this.removeView = async (view) => {
11520
+ await __classPrivateFieldGet$5(this, _TabStack_client, "f").removeViewFromStack(this.entityId, view);
11521
+ };
11522
+ /**
11523
+ * Sets the active view of the {@link TabStack} without focusing it.
11524
+ * @param view - Identity of the view to activate.
11525
+ * @returns Promise which resolves with void once the view has been activated.
11526
+ * @throws If the {@link TabStack} has been destroyed.
11527
+ * @throws If the view does not exist.
11528
+ * @example
11529
+ * Change the active tab of a known View's TabStack:
11530
+ * ```js
11531
+ * const targetView = fin.View.wrapSync({ uuid: 'uuid', name: 'view-name' });
11532
+ * const stack = await targetView.getCurrentStack();
11533
+ * await stack.setActiveView(targetView.identity);
11534
+ * ```
11535
+ *
11536
+ * Set the current View as active within its TabStack:
11537
+ * ```js
11538
+ * const stack = await fin.me.getCurrentStack();
11539
+ * await stack.setActiveView(fin.me.identity);
11540
+ * ```
11541
+ * @experimental
11542
+ */
11543
+ this.setActiveView = async (view) => {
11544
+ await __classPrivateFieldGet$5(this, _TabStack_client, "f").setStackActiveView(this.entityId, view);
11545
+ };
11546
+ __classPrivateFieldSet$4(this, _TabStack_client, client, "f");
11623
11547
  }
11624
11548
  }
11625
- commonUtils.isValidPresetType = isValidPresetType;
11626
- function overrideFromComposables(...overrides) {
11627
- return (base) => overrides.reduceRight((p, c) => (b) => c(p(b)), (x) => x)(base);
11549
+ layoutEntities.TabStack = TabStack;
11550
+ _TabStack_client = new WeakMap();
11551
+ /**
11552
+ * A ColumnOrRow is used to manage the state of Column and Rows within an OpenFin Layout.
11553
+ */
11554
+ class ColumnOrRow extends LayoutNode {
11555
+ /**
11556
+ * @internal
11557
+ */
11558
+ constructor(client, entityId, type) {
11559
+ super(client, entityId);
11560
+ /**
11561
+ * @ignore
11562
+ * @internal
11563
+ * ApiClient for {@link LayoutEntitiesController}
11564
+ */
11565
+ _ColumnOrRow_client.set(this, void 0);
11566
+ /**
11567
+ * Retrieves the content array of the ColumnOrRow
11568
+ *
11569
+ * @example
11570
+ * ```js
11571
+ * if (!fin.me.isView) {
11572
+ * throw new Error('Not running in a platform View.');
11573
+ * }
11574
+ *
11575
+ * const stack = await fin.me.getCurrentStack();
11576
+ * // Retrieves the parent ColumnOrRow
11577
+ * const columnOrRow = await stack.getParent();
11578
+ *
11579
+ * // returns [TabStack]
11580
+ * const contentArray = await columnOrRow.getContent();
11581
+ * console.log(`The ColumnOrRow has ${contentArray.length} item(s)`);
11582
+ * ```
11583
+ */
11584
+ this.getContent = async () => {
11585
+ const contentItemEntities = await __classPrivateFieldGet$5(this, _ColumnOrRow_client, "f").getContent(this.entityId);
11586
+ return contentItemEntities.map((entity) => LayoutNode.getEntity(entity, __classPrivateFieldGet$5(this, _ColumnOrRow_client, "f")));
11587
+ };
11588
+ __classPrivateFieldSet$4(this, _ColumnOrRow_client, client, "f");
11589
+ this.type = type;
11590
+ }
11628
11591
  }
11629
- commonUtils.overrideFromComposables = overrideFromComposables;
11630
- commonUtils.default = { isValidPresetType };
11592
+ layoutEntities.ColumnOrRow = ColumnOrRow;
11593
+ _ColumnOrRow_client = new WeakMap();
11594
+
11595
+ var layout_constants = {};
11596
+
11597
+ Object.defineProperty(layout_constants, "__esModule", { value: true });
11598
+ layout_constants.DEFAULT_LAYOUT_KEY = layout_constants.LAYOUT_CONTROLLER_ID = void 0;
11599
+ layout_constants.LAYOUT_CONTROLLER_ID = 'layout-entities';
11600
+ // TODO: eventually export this somehow
11601
+ layout_constants.DEFAULT_LAYOUT_KEY = '__default__';
11631
11602
 
11632
11603
  var __classPrivateFieldGet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
11633
11604
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
@@ -11776,6 +11747,12 @@ const layout_constants_1$1 = layout_constants;
11776
11747
  * ```
11777
11748
  */
11778
11749
  class Layout extends base_1$5.Base {
11750
+ /**
11751
+ * @internal
11752
+ */
11753
+ static getClient(layout) {
11754
+ return __classPrivateFieldGet$4(layout, _Layout_layoutClient, "f").getValue();
11755
+ }
11779
11756
  /**
11780
11757
  * @internal
11781
11758
  */
@@ -12000,6 +11977,16 @@ class Layout extends base_1$5.Base {
12000
11977
  const root = await client.getRoot('layoutName' in this.identity ? this.identity : undefined);
12001
11978
  return layout_entities_1.LayoutNode.getEntity(root, client);
12002
11979
  }
11980
+ /**
11981
+ * Retrieves the OpenFin.TabStack instance which the View belongs to.
11982
+ *
11983
+ * @example
11984
+ * ```js
11985
+ * const viewIdentity = { uuid: 'uuid', name: 'view-name' };
11986
+ * const stack = await fin.View.wrapSync(viewIdentity).getStackByViewIdentity(viewIdentity);
11987
+ * console.log(await stack.getViews());
11988
+ * ```
11989
+ */
12003
11990
  async getStackByViewIdentity(identity) {
12004
11991
  this.wire.sendAction('layout-get-stack-by-view').catch(() => {
12005
11992
  // don't expose
@@ -12233,6 +12220,44 @@ class LayoutModule extends base_1$4.Base {
12233
12220
  const { uuid, name } = this.fin.me;
12234
12221
  return this.wrapSync({ uuid, name });
12235
12222
  }
12223
+ /**
12224
+ * Retrieves the OpenFin.Layout instance for the Window the View is attached to.
12225
+ *
12226
+ * @example
12227
+ * ```js
12228
+ * const viewIdentity = { uuid: 'uuid', name: 'view-name' };
12229
+ * const layout = await fin.Platform.Layout.getLayoutByViewIdentity(viewIdentity);
12230
+ * console.log(await layout.getCurrentViews());
12231
+ * ```
12232
+ */
12233
+ async getLayoutByViewIdentity(viewIdentity) {
12234
+ this.wire.sendAction('layout-get-by-view-identity').catch(() => {
12235
+ // don't expose
12236
+ });
12237
+ const winIdentity = await this.wire.environment.getViewWindowIdentity(this.fin, viewIdentity);
12238
+ let layoutWindowIdentity = winIdentity;
12239
+ // TODO: CORE-1857 - when we tearout active layout or drag a view out of a window, the above identity includes the whole window info.
12240
+ if (layoutWindowIdentity.identity) {
12241
+ layoutWindowIdentity = layoutWindowIdentity.identity;
12242
+ }
12243
+ try {
12244
+ const layoutWindow = this.wrapSync(layoutWindowIdentity);
12245
+ const client = await Instance_1$2.Layout.getClient(layoutWindow);
12246
+ const layoutIdentity = await client.getLayoutIdentityForViewOrThrow(viewIdentity);
12247
+ return this.wrapSync(layoutIdentity);
12248
+ }
12249
+ catch (e) {
12250
+ const allowedErrors = [
12251
+ 'No action registered at target for',
12252
+ 'getLayoutIdentityForViewOrThrow is not a function'
12253
+ ];
12254
+ if (!allowedErrors.some((m) => e.message.includes(m))) {
12255
+ throw e;
12256
+ }
12257
+ // fallback logic for missing endpoint in older runtimes
12258
+ return this.wrapSync(layoutWindowIdentity);
12259
+ }
12260
+ }
12236
12261
  }
12237
12262
  Factory$2.LayoutModule = LayoutModule;
12238
12263
  _LayoutModule_layoutInitializationAttempted = new WeakMap(), _LayoutModule_layoutManager = new WeakMap(), _LayoutModule_getLayoutManagerSpy = new WeakMap(), _LayoutModule_instances = new WeakSet(), _LayoutModule_getSafeLayoutManager = function _LayoutModule_getSafeLayoutManager(method) {
@@ -17593,6 +17618,10 @@ Object.defineProperty(baseEnv, "__esModule", { value: true });
17593
17618
  var BaseEnvironment_1 = baseEnv.BaseEnvironment = void 0;
17594
17619
  const overrideCheck_1 = requireOverrideCheck();
17595
17620
  class BaseEnvironment {
17621
+ async getViewWindowIdentity(fin, viewIdentity) {
17622
+ const { identity } = await fin.View.wrapSync(viewIdentity).getCurrentWindow();
17623
+ return identity;
17624
+ }
17596
17625
  async getInteropInfo(fin) {
17597
17626
  const appInfo = await fin.Application.getCurrentSync()
17598
17627
  .getInfo()
@@ -17656,7 +17685,7 @@ class NodeEnvironment extends BaseEnvironment_1 {
17656
17685
  };
17657
17686
  }
17658
17687
  getAdapterVersionSync() {
17659
- return "40.82.19";
17688
+ return "40.82.21";
17660
17689
  }
17661
17690
  observeBounds(element, onChange) {
17662
17691
  throw new Error('Method not implemented.');