@openfin/node-adapter 40.200.2 → 41.83.1

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 +1442 -1320
  2. package/package.json +2 -2
@@ -73,7 +73,7 @@ async function promiseMapSerial(arr, func) {
73
73
  }
74
74
  promises.promiseMapSerial = promiseMapSerial;
75
75
 
76
- var __classPrivateFieldSet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
76
+ var __classPrivateFieldSet$d = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
77
77
  if (kind === "m") throw new TypeError("Private method is not writable");
78
78
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
79
79
  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");
@@ -202,7 +202,7 @@ class EmitterBase extends Base {
202
202
  // This will only be reached if unsubscribe from event that does not exist but do not want to error here
203
203
  return Promise.resolve();
204
204
  };
205
- __classPrivateFieldSet$c(this, _EmitterBase_emitterAccessor, [topic, ...additionalAccessors], "f");
205
+ __classPrivateFieldSet$d(this, _EmitterBase_emitterAccessor, [topic, ...additionalAccessors], "f");
206
206
  this.listeners = (event) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(event) : [];
207
207
  }
208
208
  /**
@@ -767,902 +767,238 @@ 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
- };
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);
911
881
  }
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
- });
882
+ /**
883
+ * Returns the zoom level of the WebContents.
884
+ *
885
+ * @example
886
+ * View:
887
+ * ```js
888
+ * async function getZoomLevel() {
889
+ * const view = await fin.View.getCurrent();
890
+ * return await view.getZoomLevel();
891
+ * }
892
+ *
893
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
894
+ * ```
895
+ *
896
+ * Window:
897
+ * ```js
898
+ * async function createWin() {
899
+ * const app = await fin.Application.start({
900
+ * name: 'myApp',
901
+ * uuid: 'app-1',
902
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getZoomLevel.html',
903
+ * autoShow: true
904
+ * });
905
+ * return await app.getWindow();
906
+ * }
907
+ *
908
+ * async function getZoomLevel() {
909
+ * const win = await createWin();
910
+ * return await win.getZoomLevel();
911
+ * }
912
+ *
913
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
914
+ * ```
915
+ * @remarks
916
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
917
+ * We do not expose an explicit superclass for this functionality, but it does have its own
918
+ * {@link OpenFin.WebContentsEvents event namespace}.
919
+ */
920
+ getZoomLevel() {
921
+ return this.wire.sendAction('get-zoom-level', this.identity).then(({ payload }) => payload.data);
1014
922
  }
1015
- catch (e) {
1016
- if (isDisconnectedError(e.message) && relayErrorMsg) {
1017
- throw new Error(relayErrorMsg);
1018
- }
1019
- throw e;
923
+ /**
924
+ * Sets the zoom level of the WebContents.
925
+ * @param level The zoom level
926
+ *
927
+ * @example
928
+ * View:
929
+ * ```js
930
+ * async function setZoomLevel(number) {
931
+ * const view = await fin.View.getCurrent();
932
+ * return await view.setZoomLevel(number);
933
+ * }
934
+ *
935
+ * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
936
+ * ```
937
+ *
938
+ * Window:
939
+ * ```js
940
+ * async function createWin() {
941
+ * const app = await fin.Application.start({
942
+ * name: 'myApp',
943
+ * uuid: 'app-1',
944
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.setZoomLevel.html',
945
+ * autoShow: true
946
+ * });
947
+ * return await app.getWindow();
948
+ * }
949
+ *
950
+ * async function setZoomLevel(number) {
951
+ * const win = await createWin();
952
+ * return await win.setZoomLevel(number);
953
+ * }
954
+ *
955
+ * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
956
+ * ```
957
+ * @remarks
958
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
959
+ * We do not expose an explicit superclass for this functionality, but it does have its own
960
+ * {@link OpenFin.WebContentsEvents event namespace}.
961
+ */
962
+ setZoomLevel(level) {
963
+ return this.wire.sendAction('set-zoom-level', { ...this.identity, level }).then(() => undefined);
1020
964
  }
1021
- };
1022
- channelApiRelay.createRelayedDispatch = createRelayedDispatch;
1023
-
1024
- var __classPrivateFieldSet$b = (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
965
  /**
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$b(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$b(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$b(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);
1545
- }
1546
- /**
1547
- * Returns the zoom level of the WebContents.
1548
- *
1549
- * @example
1550
- * View:
1551
- * ```js
1552
- * async function getZoomLevel() {
1553
- * const view = await fin.View.getCurrent();
1554
- * return await view.getZoomLevel();
1555
- * }
1556
- *
1557
- * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
1558
- * ```
1559
- *
1560
- * Window:
1561
- * ```js
1562
- * async function createWin() {
1563
- * const app = await fin.Application.start({
1564
- * name: 'myApp',
1565
- * uuid: 'app-1',
1566
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getZoomLevel.html',
1567
- * autoShow: true
1568
- * });
1569
- * return await app.getWindow();
1570
- * }
1571
- *
1572
- * async function getZoomLevel() {
1573
- * const win = await createWin();
1574
- * return await win.getZoomLevel();
1575
- * }
1576
- *
1577
- * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
1578
- * ```
1579
- * @remarks
1580
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1581
- * We do not expose an explicit superclass for this functionality, but it does have its own
1582
- * {@link OpenFin.WebContentsEvents event namespace}.
1583
- */
1584
- getZoomLevel() {
1585
- return this.wire.sendAction('get-zoom-level', this.identity).then(({ payload }) => payload.data);
1586
- }
1587
- /**
1588
- * Sets the zoom level of the WebContents.
1589
- * @param level The zoom level
1590
- *
1591
- * @example
1592
- * View:
1593
- * ```js
1594
- * async function setZoomLevel(number) {
1595
- * const view = await fin.View.getCurrent();
1596
- * return await view.setZoomLevel(number);
1597
- * }
1598
- *
1599
- * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
1600
- * ```
1601
- *
1602
- * Window:
1603
- * ```js
1604
- * async function createWin() {
1605
- * const app = await fin.Application.start({
1606
- * name: 'myApp',
1607
- * uuid: 'app-1',
1608
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.setZoomLevel.html',
1609
- * autoShow: true
1610
- * });
1611
- * return await app.getWindow();
1612
- * }
1613
- *
1614
- * async function setZoomLevel(number) {
1615
- * const win = await createWin();
1616
- * return await win.setZoomLevel(number);
1617
- * }
1618
- *
1619
- * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
1620
- * ```
1621
- * @remarks
1622
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1623
- * We do not expose an explicit superclass for this functionality, but it does have its own
1624
- * {@link OpenFin.WebContentsEvents event namespace}.
1625
- */
1626
- setZoomLevel(level) {
1627
- return this.wire.sendAction('set-zoom-level', { ...this.identity, level }).then(() => undefined);
1628
- }
1629
- /**
1630
- * Navigates the WebContents to a specified URL.
1631
- *
1632
- * Note: The url must contain the protocol prefix such as http:// or https://.
1633
- * @param url - The URL to navigate the WebContents to.
1634
- *
1635
- * @example
1636
- * View:
1637
- * ```js
1638
- * async function createView() {
1639
- * const me = await fin.Window.getCurrent();
1640
- * return fin.View.create({
1641
- * name: 'viewName',
1642
- * target: me.identity,
1643
- * bounds: {top: 10, left: 10, width: 200, height: 200}
1644
- * });
1645
- * }
1646
- *
1647
- * createView()
1648
- * .then(view => view.navigate('https://example.com'))
1649
- * .then(() => console.log('navigation complete'))
1650
- * .catch(err => console.log(err));
1651
- * ```
1652
- *
1653
- * Window:
1654
- * ```js
1655
- * async function navigate() {
1656
- * const win = await fin.Window.getCurrent();
1657
- * return await win.navigate('https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.navigate.html');
1658
- * }
1659
- * navigate().then(() => console.log('Navigate to tutorial')).catch(err => console.log(err));
1660
- * ```
1661
- * @experimental
1662
- * @remarks
1663
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1664
- * We do not expose an explicit superclass for this functionality, but it does have its own
1665
- * {@link OpenFin.WebContentsEvents event namespace}.
966
+ * Navigates the WebContents to a specified URL.
967
+ *
968
+ * Note: The url must contain the protocol prefix such as http:// or https://.
969
+ * @param url - The URL to navigate the WebContents to.
970
+ *
971
+ * @example
972
+ * View:
973
+ * ```js
974
+ * async function createView() {
975
+ * const me = await fin.Window.getCurrent();
976
+ * return fin.View.create({
977
+ * name: 'viewName',
978
+ * target: me.identity,
979
+ * bounds: {top: 10, left: 10, width: 200, height: 200}
980
+ * });
981
+ * }
982
+ *
983
+ * createView()
984
+ * .then(view => view.navigate('https://example.com'))
985
+ * .then(() => console.log('navigation complete'))
986
+ * .catch(err => console.log(err));
987
+ * ```
988
+ *
989
+ * Window:
990
+ * ```js
991
+ * async function navigate() {
992
+ * const win = await fin.Window.getCurrent();
993
+ * return await win.navigate('https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.navigate.html');
994
+ * }
995
+ * navigate().then(() => console.log('Navigate to tutorial')).catch(err => console.log(err));
996
+ * ```
997
+ * @experimental
998
+ * @remarks
999
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
1000
+ * We do not expose an explicit superclass for this functionality, but it does have its own
1001
+ * {@link OpenFin.WebContentsEvents event namespace}.
1666
1002
  */
1667
1003
  navigate(url) {
1668
1004
  return this.wire.sendAction('navigate-window', { ...this.identity, url }).then(() => undefined);
@@ -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.
@@ -2990,11 +2297,8 @@ function requireInstance$2 () {
2990
2297
  // don't expose
2991
2298
  });
2992
2299
  try {
2993
- const layoutWindow = await this.getCurrentWindow();
2994
- const providerChannelClient = await __classPrivateFieldGet(this, _View_providerChannelClient, "f").getValue();
2995
- const client = await layout_entities_1.LayoutNode.newLayoutEntitiesClient(providerChannelClient, layout_constants_1.LAYOUT_CONTROLLER_ID, layoutWindow.identity);
2996
- const stackDefinition = (await client.getStackByView(this.identity));
2997
- return layout_entities_1.LayoutNode.getEntity(stackDefinition, client);
2300
+ const layout = await this.getParentLayout();
2301
+ return layout.getStackByViewIdentity(this.identity);
2998
2302
  }
2999
2303
  catch (error) {
3000
2304
  throw new transport_errors_1.RuntimeError({ reason: 'This view does not belong to a stack.', error });
@@ -5765,13 +5069,6 @@ class System extends base_1$i.EmitterBase {
5765
5069
  constructor(wire) {
5766
5070
  super(wire, 'system');
5767
5071
  }
5768
- /**
5769
- * Dispatch an event to the webcontents that created the notification.
5770
- * Only works for notifications that have been intercepted in the same runtime.
5771
- */
5772
- async dispatchNotificationAction(notificationId, { action }) {
5773
- await this.wire.sendAction('dispatch-notification-action', { notificationId, action });
5774
- }
5775
5072
  sendExternalProcessRequest(action, options) {
5776
5073
  return new Promise((resolve, reject) => {
5777
5074
  const exitEventKey = 'external-process-exited';
@@ -6040,7 +5337,9 @@ class System extends base_1$i.EmitterBase {
6040
5337
  .then(({ payload }) => payload.data);
6041
5338
  }
6042
5339
  /**
6043
- * Get current focused window.
5340
+ * Get currently focused Window.
5341
+ * If a View currently has focus, returns the identity of View's parent Window.
5342
+ * Use {@link Window._Window#getFocusedContent Window.getFocusedContent} to directly access currently focused Window or View.
6044
5343
  *
6045
5344
  * @example
6046
5345
  * ```js
@@ -6050,6 +5349,17 @@ class System extends base_1$i.EmitterBase {
6050
5349
  getFocusedWindow() {
6051
5350
  return this.wire.sendAction('get-focused-window').then(({ payload }) => payload.data);
6052
5351
  }
5352
+ /**
5353
+ * Get currently focused content. Returns identity of entity with `entityType`.
5354
+ *
5355
+ * @example
5356
+ * ```js
5357
+ * fin.System.getFocusedContent().then(contentIdentity => console.log(contentIdentity)).catch(err => console.log(err));
5358
+ * ```
5359
+ */
5360
+ getFocusedContent() {
5361
+ return this.wire.sendAction('get-focused-content').then(({ payload }) => payload.data);
5362
+ }
6053
5363
  /**
6054
5364
  * Returns information about the given app's certification status
6055
5365
  *
@@ -7613,6 +6923,22 @@ class System extends base_1$i.EmitterBase {
7613
6923
  async setDomainSettings(domainSettings) {
7614
6924
  await this.wire.sendAction('set-domain-settings', { domainSettings, ...this.identity });
7615
6925
  }
6926
+ /**
6927
+ * Attempts to install and enable extensions for the security realm. Users may want to call this function in response
6928
+ * to an `extensions-install-failed` event. Only extensions allowed by every application on the current security realm
6929
+ * will be installed/enabled.
6930
+ */
6931
+ async refreshExtensions() {
6932
+ const { payload } = await this.wire.sendAction('refresh-extensions');
6933
+ return payload.data;
6934
+ }
6935
+ /**
6936
+ * Gets the currently-installed
6937
+ */
6938
+ async getInstalledExtensions() {
6939
+ const { payload } = await this.wire.sendAction('get-installed-extensions');
6940
+ return payload.data;
6941
+ }
7616
6942
  }
7617
6943
  system.System = System;
7618
6944
 
@@ -8034,12 +7360,12 @@ class ChannelError extends Error {
8034
7360
  }
8035
7361
  channelError.ChannelError = ChannelError;
8036
7362
 
8037
- var __classPrivateFieldGet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
7363
+ var __classPrivateFieldGet$d = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8038
7364
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
8039
7365
  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");
8040
7366
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
8041
7367
  };
8042
- var __classPrivateFieldSet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7368
+ var __classPrivateFieldSet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8043
7369
  if (kind === "m") throw new TypeError("Private method is not writable");
8044
7370
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8045
7371
  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");
@@ -8083,7 +7409,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
8083
7409
  static closeChannelByEndpointId(id) {
8084
7410
  const channel = channelClientsByEndpointId.get(id);
8085
7411
  if (channel) {
8086
- __classPrivateFieldGet$c(channel, _ChannelClient_close, "f").call(channel);
7412
+ __classPrivateFieldGet$d(channel, _ChannelClient_close, "f").call(channel);
8087
7413
  }
8088
7414
  }
8089
7415
  /**
@@ -8094,7 +7420,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
8094
7420
  for (const channelClient of channelClientsByEndpointId.values()) {
8095
7421
  if (channelClient.providerIdentity.channelId === eventPayload.channelId) {
8096
7422
  channelClient.disconnectListener(eventPayload);
8097
- __classPrivateFieldGet$c(channelClient, _ChannelClient_close, "f").call(channelClient);
7423
+ __classPrivateFieldGet$d(channelClient, _ChannelClient_close, "f").call(channelClient);
8098
7424
  }
8099
7425
  }
8100
7426
  }
@@ -8109,12 +7435,12 @@ class ChannelClient extends channel_1$1.ChannelBase {
8109
7435
  this.processAction = (action, payload, senderIdentity) => super.processAction(action, payload, senderIdentity);
8110
7436
  _ChannelClient_close.set(this, () => {
8111
7437
  channelClientsByEndpointId.delete(this.endpointId);
8112
- __classPrivateFieldGet$c(this, _ChannelClient_strategy, "f").close();
7438
+ __classPrivateFieldGet$d(this, _ChannelClient_strategy, "f").close();
8113
7439
  });
8114
- __classPrivateFieldSet$a(this, _ChannelClient_protectedObj, new channel_1$1.ProtectedItems(routingInfo, close), "f");
7440
+ __classPrivateFieldSet$c(this, _ChannelClient_protectedObj, new channel_1$1.ProtectedItems(routingInfo, close), "f");
8115
7441
  this.disconnectListener = () => undefined;
8116
7442
  this.endpointId = routingInfo.endpointId;
8117
- __classPrivateFieldSet$a(this, _ChannelClient_strategy, strategy, "f");
7443
+ __classPrivateFieldSet$c(this, _ChannelClient_strategy, strategy, "f");
8118
7444
  channelClientsByEndpointId.set(this.endpointId, this);
8119
7445
  strategy.receive(this.processAction);
8120
7446
  }
@@ -8122,7 +7448,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
8122
7448
  * a read-only provider identity
8123
7449
  */
8124
7450
  get providerIdentity() {
8125
- const protectedObj = __classPrivateFieldGet$c(this, _ChannelClient_protectedObj, "f");
7451
+ const protectedObj = __classPrivateFieldGet$d(this, _ChannelClient_protectedObj, "f");
8126
7452
  return protectedObj.providerIdentity;
8127
7453
  }
8128
7454
  /**
@@ -8151,9 +7477,9 @@ class ChannelClient extends channel_1$1.ChannelBase {
8151
7477
  * ```
8152
7478
  */
8153
7479
  async dispatch(action, payload) {
8154
- if (__classPrivateFieldGet$c(this, _ChannelClient_strategy, "f").isEndpointConnected(this.providerIdentity.channelId)) {
7480
+ if (__classPrivateFieldGet$d(this, _ChannelClient_strategy, "f").isEndpointConnected(this.providerIdentity.channelId)) {
8155
7481
  const callSites = transport_errors_1$3.RuntimeError.getCallSite();
8156
- return __classPrivateFieldGet$c(this, _ChannelClient_strategy, "f").send(this.providerIdentity.channelId, action, payload).catch((e) => {
7482
+ return __classPrivateFieldGet$d(this, _ChannelClient_strategy, "f").send(this.providerIdentity.channelId, action, payload).catch((e) => {
8157
7483
  throw new channel_error_1$1.ChannelError(e, action, payload, callSites);
8158
7484
  });
8159
7485
  }
@@ -8205,10 +7531,10 @@ class ChannelClient extends channel_1$1.ChannelBase {
8205
7531
  */
8206
7532
  async disconnect() {
8207
7533
  await this.sendDisconnectAction();
8208
- __classPrivateFieldGet$c(this, _ChannelClient_close, "f").call(this);
7534
+ __classPrivateFieldGet$d(this, _ChannelClient_close, "f").call(this);
8209
7535
  }
8210
7536
  async sendDisconnectAction() {
8211
- const protectedObj = __classPrivateFieldGet$c(this, _ChannelClient_protectedObj, "f");
7537
+ const protectedObj = __classPrivateFieldGet$d(this, _ChannelClient_protectedObj, "f");
8212
7538
  await protectedObj.close();
8213
7539
  }
8214
7540
  /**
@@ -8241,13 +7567,13 @@ exhaustive.exhaustiveCheck = exhaustiveCheck;
8241
7567
 
8242
7568
  var strategy$3 = {};
8243
7569
 
8244
- var __classPrivateFieldSet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7570
+ var __classPrivateFieldSet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8245
7571
  if (kind === "m") throw new TypeError("Private method is not writable");
8246
7572
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8247
7573
  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");
8248
7574
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
8249
7575
  };
8250
- var __classPrivateFieldGet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
7576
+ var __classPrivateFieldGet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8251
7577
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
8252
7578
  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");
8253
7579
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -8272,7 +7598,7 @@ class ClassicStrategy {
8272
7598
  // connection problems occur
8273
7599
  _ClassicStrategy_pendingMessagesByEndpointId.set(this, new Map());
8274
7600
  this.send = async (endpointId, action, payload) => {
8275
- const to = __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
7601
+ const to = __classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
8276
7602
  if (!to) {
8277
7603
  throw new Error(`Could not locate routing info for endpoint ${endpointId}`);
8278
7604
  }
@@ -8284,13 +7610,13 @@ class ClassicStrategy {
8284
7610
  }
8285
7611
  delete cleanId.isLocalEndpointId;
8286
7612
  // grab the promise before awaiting it to save in our pending messages map
8287
- const p = __classPrivateFieldGet$b(this, _ClassicStrategy_wire, "f").sendAction('send-channel-message', {
7613
+ const p = __classPrivateFieldGet$c(this, _ClassicStrategy_wire, "f").sendAction('send-channel-message', {
8288
7614
  ...cleanId,
8289
7615
  providerIdentity: this.providerIdentity,
8290
7616
  action,
8291
7617
  payload
8292
7618
  });
8293
- __classPrivateFieldGet$b(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.add(p);
7619
+ __classPrivateFieldGet$c(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.add(p);
8294
7620
  const raw = await p
8295
7621
  .catch((error) => {
8296
7622
  if ('cause' in error) {
@@ -8300,16 +7626,16 @@ class ClassicStrategy {
8300
7626
  })
8301
7627
  .finally(() => {
8302
7628
  // clean up the pending promise
8303
- __classPrivateFieldGet$b(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.delete(p);
7629
+ __classPrivateFieldGet$c(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.delete(p);
8304
7630
  });
8305
7631
  return raw.payload.data.result;
8306
7632
  };
8307
7633
  this.close = async () => {
8308
7634
  this.messageReceiver.removeEndpoint(this.providerIdentity.channelId, this.endpointId);
8309
- [...__classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").keys()].forEach((id) => this.closeEndpoint(id));
8310
- __classPrivateFieldSet$9(this, _ClassicStrategy_endpointIdentityMap, new Map(), "f");
7635
+ [...__classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").keys()].forEach((id) => this.closeEndpoint(id));
7636
+ __classPrivateFieldSet$b(this, _ClassicStrategy_endpointIdentityMap, new Map(), "f");
8311
7637
  };
8312
- __classPrivateFieldSet$9(this, _ClassicStrategy_wire, wire, "f");
7638
+ __classPrivateFieldSet$b(this, _ClassicStrategy_wire, wire, "f");
8313
7639
  }
8314
7640
  onEndpointDisconnect(endpointId, listener) {
8315
7641
  // Never fires for 'classic'.
@@ -8318,20 +7644,20 @@ class ClassicStrategy {
8318
7644
  this.messageReceiver.addEndpoint(listener, this.providerIdentity.channelId, this.endpointId);
8319
7645
  }
8320
7646
  async closeEndpoint(endpointId) {
8321
- const id = __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
8322
- __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").delete(endpointId);
8323
- const pendingSet = __classPrivateFieldGet$b(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId);
7647
+ const id = __classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
7648
+ __classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").delete(endpointId);
7649
+ const pendingSet = __classPrivateFieldGet$c(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId);
8324
7650
  pendingSet?.forEach((p) => {
8325
7651
  const errorMsg = `Channel connection with identity uuid: ${id?.uuid} / name: ${id?.name} / endpointId: ${endpointId} no longer connected.`;
8326
7652
  p.cancel(new Error(errorMsg));
8327
7653
  });
8328
7654
  }
8329
7655
  isEndpointConnected(endpointId) {
8330
- return __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").has(endpointId);
7656
+ return __classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").has(endpointId);
8331
7657
  }
8332
7658
  addEndpoint(endpointId, payload) {
8333
- __classPrivateFieldGet$b(this, _ClassicStrategy_endpointIdentityMap, "f").set(endpointId, payload.endpointIdentity);
8334
- __classPrivateFieldGet$b(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").set(endpointId, new Set());
7659
+ __classPrivateFieldGet$c(this, _ClassicStrategy_endpointIdentityMap, "f").set(endpointId, payload.endpointIdentity);
7660
+ __classPrivateFieldGet$c(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").set(endpointId, new Set());
8335
7661
  }
8336
7662
  isValidEndpointPayload(payload) {
8337
7663
  return (typeof payload?.endpointIdentity?.endpointId === 'string' ||
@@ -8366,12 +7692,12 @@ function errorToPOJO(error) {
8366
7692
  }
8367
7693
  errors.errorToPOJO = errorToPOJO;
8368
7694
 
8369
- var __classPrivateFieldGet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
7695
+ var __classPrivateFieldGet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8370
7696
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
8371
7697
  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");
8372
7698
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
8373
7699
  };
8374
- var __classPrivateFieldSet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7700
+ var __classPrivateFieldSet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8375
7701
  if (kind === "m") throw new TypeError("Private method is not writable");
8376
7702
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8377
7703
  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");
@@ -8406,8 +7732,8 @@ class RTCEndpoint {
8406
7732
  if (this.rtc.rtcClient.connectionState !== 'connected') {
8407
7733
  this.rtc.rtcClient.removeEventListener('connectionstatechange', this.connectionStateChangeHandler);
8408
7734
  this.close();
8409
- if (__classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f")) {
8410
- __classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f").call(this);
7735
+ if (__classPrivateFieldGet$b(this, _RTCEndpoint_disconnectListener, "f")) {
7736
+ __classPrivateFieldGet$b(this, _RTCEndpoint_disconnectListener, "f").call(this);
8411
7737
  }
8412
7738
  }
8413
7739
  };
@@ -8455,9 +7781,9 @@ class RTCEndpoint {
8455
7781
  data = new TextDecoder().decode(e.data);
8456
7782
  }
8457
7783
  const { messageId, action, payload } = JSON.parse(data);
8458
- if (__classPrivateFieldGet$a(this, _RTCEndpoint_processAction, "f")) {
7784
+ if (__classPrivateFieldGet$b(this, _RTCEndpoint_processAction, "f")) {
8459
7785
  try {
8460
- const res = await __classPrivateFieldGet$a(this, _RTCEndpoint_processAction, "f").call(this, action, payload, endpointIdentity);
7786
+ const res = await __classPrivateFieldGet$b(this, _RTCEndpoint_processAction, "f").call(this, action, payload, endpointIdentity);
8461
7787
  this.rtc.channels.response.send(JSON.stringify({
8462
7788
  messageId,
8463
7789
  payload: res,
@@ -8491,25 +7817,25 @@ class RTCEndpoint {
8491
7817
  datachannel.onclose = (e) => {
8492
7818
  [...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.')));
8493
7819
  this.close();
8494
- if (__classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f")) {
8495
- __classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f").call(this);
7820
+ if (__classPrivateFieldGet$b(this, _RTCEndpoint_disconnectListener, "f")) {
7821
+ __classPrivateFieldGet$b(this, _RTCEndpoint_disconnectListener, "f").call(this);
8496
7822
  }
8497
7823
  };
8498
7824
  });
8499
7825
  }
8500
7826
  onDisconnect(listener) {
8501
- if (!__classPrivateFieldGet$a(this, _RTCEndpoint_disconnectListener, "f")) {
8502
- __classPrivateFieldSet$8(this, _RTCEndpoint_disconnectListener, listener, "f");
7827
+ if (!__classPrivateFieldGet$b(this, _RTCEndpoint_disconnectListener, "f")) {
7828
+ __classPrivateFieldSet$a(this, _RTCEndpoint_disconnectListener, listener, "f");
8503
7829
  }
8504
7830
  else {
8505
7831
  throw new Error('RTCEndpoint disconnectListener cannot be set twice.');
8506
7832
  }
8507
7833
  }
8508
7834
  receive(listener) {
8509
- if (__classPrivateFieldGet$a(this, _RTCEndpoint_processAction, "f")) {
7835
+ if (__classPrivateFieldGet$b(this, _RTCEndpoint_processAction, "f")) {
8510
7836
  throw new Error('You have already set a listener for this RTC Endpoint.');
8511
7837
  }
8512
- __classPrivateFieldSet$8(this, _RTCEndpoint_processAction, listener, "f");
7838
+ __classPrivateFieldSet$a(this, _RTCEndpoint_processAction, listener, "f");
8513
7839
  }
8514
7840
  get connected() {
8515
7841
  return this.rtc.rtcClient.connectionState === 'connected';
@@ -8520,12 +7846,12 @@ _RTCEndpoint_processAction = new WeakMap(), _RTCEndpoint_disconnectListener = ne
8520
7846
 
8521
7847
  var strategy$1 = {};
8522
7848
 
8523
- var __classPrivateFieldGet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
7849
+ var __classPrivateFieldGet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8524
7850
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
8525
7851
  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");
8526
7852
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
8527
7853
  };
8528
- var __classPrivateFieldSet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7854
+ var __classPrivateFieldSet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8529
7855
  if (kind === "m") throw new TypeError("Private method is not writable");
8530
7856
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8531
7857
  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");
@@ -8546,11 +7872,11 @@ class EndpointStrategy {
8546
7872
  return this.getEndpointById(endpointId).send(action, payload);
8547
7873
  };
8548
7874
  this.close = async () => {
8549
- if (__classPrivateFieldGet$9(this, _EndpointStrategy_connected, "f")) {
8550
- __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.close());
8551
- __classPrivateFieldSet$7(this, _EndpointStrategy_endpointMap, new Map(), "f");
7875
+ if (__classPrivateFieldGet$a(this, _EndpointStrategy_connected, "f")) {
7876
+ __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.close());
7877
+ __classPrivateFieldSet$9(this, _EndpointStrategy_endpointMap, new Map(), "f");
8552
7878
  }
8553
- __classPrivateFieldSet$7(this, _EndpointStrategy_connected, false, "f");
7879
+ __classPrivateFieldSet$9(this, _EndpointStrategy_connected, false, "f");
8554
7880
  };
8555
7881
  this.isValidEndpointPayload = validateEndpoint;
8556
7882
  }
@@ -8558,39 +7884,39 @@ class EndpointStrategy {
8558
7884
  this.getEndpointById(endpointId).onDisconnect(listener);
8559
7885
  }
8560
7886
  receive(listener) {
8561
- if (__classPrivateFieldGet$9(this, _EndpointStrategy_processAction, "f")) {
7887
+ if (__classPrivateFieldGet$a(this, _EndpointStrategy_processAction, "f")) {
8562
7888
  throw new Error(`You have already set a listener for this ${this.StrategyName} Strategy`);
8563
7889
  }
8564
- __classPrivateFieldSet$7(this, _EndpointStrategy_processAction, listener, "f");
7890
+ __classPrivateFieldSet$9(this, _EndpointStrategy_processAction, listener, "f");
8565
7891
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
8566
- __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.receive(__classPrivateFieldGet$9(this, _EndpointStrategy_processAction, "f")));
7892
+ __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.receive(__classPrivateFieldGet$a(this, _EndpointStrategy_processAction, "f")));
8567
7893
  }
8568
7894
  getEndpointById(endpointId) {
8569
- const endpoint = __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").get(endpointId);
7895
+ const endpoint = __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").get(endpointId);
8570
7896
  if (!endpoint) {
8571
7897
  throw new Error(`Client with endpoint id ${endpointId} is not connected`);
8572
7898
  }
8573
7899
  return endpoint;
8574
7900
  }
8575
7901
  get connected() {
8576
- return __classPrivateFieldGet$9(this, _EndpointStrategy_connected, "f");
7902
+ return __classPrivateFieldGet$a(this, _EndpointStrategy_connected, "f");
8577
7903
  }
8578
7904
  isEndpointConnected(endpointId) {
8579
- return __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").has(endpointId);
7905
+ return __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").has(endpointId);
8580
7906
  }
8581
7907
  addEndpoint(endpointId, payload) {
8582
- if (!__classPrivateFieldGet$9(this, _EndpointStrategy_connected, "f")) {
7908
+ if (!__classPrivateFieldGet$a(this, _EndpointStrategy_connected, "f")) {
8583
7909
  console.warn(`Adding endpoint to disconnected ${this.StrategyName} Strategy`);
8584
7910
  return;
8585
7911
  }
8586
7912
  const clientStrat = new this.EndpointType(payload);
8587
- if (__classPrivateFieldGet$9(this, _EndpointStrategy_processAction, "f")) {
8588
- clientStrat.receive(__classPrivateFieldGet$9(this, _EndpointStrategy_processAction, "f"));
7913
+ if (__classPrivateFieldGet$a(this, _EndpointStrategy_processAction, "f")) {
7914
+ clientStrat.receive(__classPrivateFieldGet$a(this, _EndpointStrategy_processAction, "f"));
8589
7915
  }
8590
- __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").set(endpointId, clientStrat);
7916
+ __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").set(endpointId, clientStrat);
8591
7917
  }
8592
7918
  async closeEndpoint(endpointId) {
8593
- __classPrivateFieldGet$9(this, _EndpointStrategy_endpointMap, "f").delete(endpointId);
7919
+ __classPrivateFieldGet$a(this, _EndpointStrategy_endpointMap, "f").delete(endpointId);
8594
7920
  }
8595
7921
  }
8596
7922
  strategy$1.EndpointStrategy = EndpointStrategy;
@@ -8772,12 +8098,12 @@ function runtimeUuidMeetsMinimumRuntimeVersion(runtimeUuid, minVersion) {
8772
8098
  }
8773
8099
  runtimeVersioning.runtimeUuidMeetsMinimumRuntimeVersion = runtimeUuidMeetsMinimumRuntimeVersion;
8774
8100
 
8775
- var __classPrivateFieldGet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8101
+ var __classPrivateFieldGet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8776
8102
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
8777
8103
  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");
8778
8104
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
8779
8105
  };
8780
- var __classPrivateFieldSet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8106
+ var __classPrivateFieldSet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8781
8107
  if (kind === "m") throw new TypeError("Private method is not writable");
8782
8108
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
8783
8109
  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");
@@ -8821,18 +8147,18 @@ class ChannelProvider extends channel_1.ChannelBase {
8821
8147
  * a read-only array containing all the identities of connecting clients.
8822
8148
  */
8823
8149
  get connections() {
8824
- return [...__classPrivateFieldGet$8(this, _ChannelProvider_connections, "f")];
8150
+ return [...__classPrivateFieldGet$9(this, _ChannelProvider_connections, "f")];
8825
8151
  }
8826
8152
  static handleClientDisconnection(channel, payload) {
8827
8153
  const removeById = channel.connections.find((identity) => identity.endpointId === payload.endpointId);
8828
8154
  if (removeById) {
8829
- __classPrivateFieldGet$8(channel, _ChannelProvider_removeEndpoint, "f").call(channel, removeById);
8155
+ __classPrivateFieldGet$9(channel, _ChannelProvider_removeEndpoint, "f").call(channel, removeById);
8830
8156
  }
8831
8157
  else {
8832
8158
  const multipleRemoves = channel.connections.filter((identity) => {
8833
8159
  return identity.uuid === payload.uuid && identity.name === payload.name;
8834
8160
  });
8835
- multipleRemoves.forEach(__classPrivateFieldGet$8(channel, _ChannelProvider_removeEndpoint, "f"));
8161
+ multipleRemoves.forEach(__classPrivateFieldGet$9(channel, _ChannelProvider_removeEndpoint, "f"));
8836
8162
  }
8837
8163
  channel.disconnectListener(payload);
8838
8164
  }
@@ -8849,8 +8175,8 @@ class ChannelProvider extends channel_1.ChannelBase {
8849
8175
  _ChannelProvider_strategy.set(this, void 0);
8850
8176
  _ChannelProvider_removeEndpoint.set(this, (identity) => {
8851
8177
  const remainingConnections = this.connections.filter((clientIdentity) => clientIdentity.endpointId !== identity.endpointId);
8852
- __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").closeEndpoint(identity.endpointId);
8853
- __classPrivateFieldSet$6(this, _ChannelProvider_connections, remainingConnections, "f");
8178
+ __classPrivateFieldGet$9(this, _ChannelProvider_strategy, "f").closeEndpoint(identity.endpointId);
8179
+ __classPrivateFieldSet$8(this, _ChannelProvider_connections, remainingConnections, "f");
8854
8180
  });
8855
8181
  // Must be bound.
8856
8182
  this.processAction = async (action, payload, senderIdentity) => {
@@ -8864,17 +8190,17 @@ class ChannelProvider extends channel_1.ChannelBase {
8864
8190
  return super.processAction(action, payload, senderIdentity);
8865
8191
  };
8866
8192
  _ChannelProvider_close.set(this, () => {
8867
- __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").close();
8193
+ __classPrivateFieldGet$9(this, _ChannelProvider_strategy, "f").close();
8868
8194
  const remove = ChannelProvider.removalMap.get(this);
8869
8195
  if (remove) {
8870
8196
  remove();
8871
8197
  }
8872
8198
  });
8873
- __classPrivateFieldSet$6(this, _ChannelProvider_protectedObj, new channel_1.ProtectedItems(providerIdentity, close), "f");
8199
+ __classPrivateFieldSet$8(this, _ChannelProvider_protectedObj, new channel_1.ProtectedItems(providerIdentity, close), "f");
8874
8200
  this.connectListener = () => undefined;
8875
8201
  this.disconnectListener = () => undefined;
8876
- __classPrivateFieldSet$6(this, _ChannelProvider_connections, [], "f");
8877
- __classPrivateFieldSet$6(this, _ChannelProvider_strategy, strategy, "f");
8202
+ __classPrivateFieldSet$8(this, _ChannelProvider_connections, [], "f");
8203
+ __classPrivateFieldSet$8(this, _ChannelProvider_strategy, strategy, "f");
8878
8204
  strategy.receive(this.processAction);
8879
8205
  }
8880
8206
  /**
@@ -8905,16 +8231,16 @@ class ChannelProvider extends channel_1.ChannelBase {
8905
8231
  */
8906
8232
  dispatch(to, action, payload) {
8907
8233
  const endpointId = to.endpointId ?? this.getEndpointIdForOpenFinId(to, action);
8908
- if (endpointId && __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").isEndpointConnected(endpointId)) {
8234
+ if (endpointId && __classPrivateFieldGet$9(this, _ChannelProvider_strategy, "f").isEndpointConnected(endpointId)) {
8909
8235
  const callSites = transport_errors_1$2.RuntimeError.getCallSite();
8910
- return __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").send(endpointId, action, payload).catch((e) => {
8236
+ return __classPrivateFieldGet$9(this, _ChannelProvider_strategy, "f").send(endpointId, action, payload).catch((e) => {
8911
8237
  throw new channel_error_1.ChannelError(e, action, payload, callSites);
8912
8238
  });
8913
8239
  }
8914
8240
  return Promise.reject(new Error(`Client connection with identity uuid: ${to.uuid} / name: ${to.name} / endpointId: ${endpointId} no longer connected.`));
8915
8241
  }
8916
8242
  async processConnection(senderId, payload) {
8917
- __classPrivateFieldGet$8(this, _ChannelProvider_connections, "f").push(senderId);
8243
+ __classPrivateFieldGet$9(this, _ChannelProvider_connections, "f").push(senderId);
8918
8244
  return this.connectListener(senderId, payload);
8919
8245
  }
8920
8246
  /**
@@ -8937,7 +8263,7 @@ class ChannelProvider extends channel_1.ChannelBase {
8937
8263
  * ```
8938
8264
  */
8939
8265
  publish(action, payload) {
8940
- return this.connections.map((to) => __classPrivateFieldGet$8(this, _ChannelProvider_strategy, "f").send(to.endpointId, action, payload));
8266
+ return this.connections.map((to) => __classPrivateFieldGet$9(this, _ChannelProvider_strategy, "f").send(to.endpointId, action, payload));
8941
8267
  }
8942
8268
  /**
8943
8269
  * Register a listener that is called on every new client connection.
@@ -9011,11 +8337,11 @@ class ChannelProvider extends channel_1.ChannelBase {
9011
8337
  * ```
9012
8338
  */
9013
8339
  async destroy() {
9014
- const protectedObj = __classPrivateFieldGet$8(this, _ChannelProvider_protectedObj, "f");
8340
+ const protectedObj = __classPrivateFieldGet$9(this, _ChannelProvider_protectedObj, "f");
9015
8341
  protectedObj.providerIdentity;
9016
- __classPrivateFieldSet$6(this, _ChannelProvider_connections, [], "f");
8342
+ __classPrivateFieldSet$8(this, _ChannelProvider_connections, [], "f");
9017
8343
  await protectedObj.close();
9018
- __classPrivateFieldGet$8(this, _ChannelProvider_close, "f").call(this);
8344
+ __classPrivateFieldGet$9(this, _ChannelProvider_close, "f").call(this);
9019
8345
  }
9020
8346
  /**
9021
8347
  * Returns an array with info on every Client connected to the Provider
@@ -9085,7 +8411,7 @@ class ChannelProvider extends channel_1.ChannelBase {
9085
8411
  getEndpointIdForOpenFinId(clientIdentity, action) {
9086
8412
  const matchingConnections = this.connections.filter((c) => c.name === clientIdentity.name && c.uuid === clientIdentity.uuid);
9087
8413
  if (matchingConnections.length >= 2) {
9088
- const protectedObj = __classPrivateFieldGet$8(this, _ChannelProvider_protectedObj, "f");
8414
+ const protectedObj = __classPrivateFieldGet$9(this, _ChannelProvider_protectedObj, "f");
9089
8415
  const { uuid, name } = clientIdentity;
9090
8416
  const providerUuid = protectedObj?.providerIdentity.uuid;
9091
8417
  const providerName = protectedObj?.providerIdentity.name;
@@ -9297,13 +8623,13 @@ class CombinedStrategy {
9297
8623
  }
9298
8624
  strategy.default = CombinedStrategy;
9299
8625
 
9300
- var __classPrivateFieldSet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8626
+ var __classPrivateFieldSet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
9301
8627
  if (kind === "m") throw new TypeError("Private method is not writable");
9302
8628
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9303
8629
  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");
9304
8630
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
9305
8631
  };
9306
- var __classPrivateFieldGet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8632
+ var __classPrivateFieldGet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9307
8633
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9308
8634
  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");
9309
8635
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -9352,8 +8678,8 @@ class ConnectionManager extends base_1$f.Base {
9352
8678
  };
9353
8679
  this.providerMap = new Map();
9354
8680
  this.protocolManager = new protocol_manager_1.ProtocolManager(this.wire.environment.type === 'node' ? ['classic'] : ['rtc', 'classic']);
9355
- __classPrivateFieldSet$5(this, _ConnectionManager_messageReceiver, new message_receiver_1.MessageReceiver(wire), "f");
9356
- __classPrivateFieldSet$5(this, _ConnectionManager_rtcConnectionManager, new ice_manager_1.RTCICEManager(wire), "f");
8681
+ __classPrivateFieldSet$7(this, _ConnectionManager_messageReceiver, new message_receiver_1.MessageReceiver(wire), "f");
8682
+ __classPrivateFieldSet$7(this, _ConnectionManager_rtcConnectionManager, new ice_manager_1.RTCICEManager(wire), "f");
9357
8683
  wire.registerMessageHandler(this.onmessage.bind(this));
9358
8684
  }
9359
8685
  createProvider(options, providerIdentity) {
@@ -9364,7 +8690,7 @@ class ConnectionManager extends base_1$f.Base {
9364
8690
  case 'rtc':
9365
8691
  return new strategy_2.RTCStrategy();
9366
8692
  case 'classic':
9367
- return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$7(this, _ConnectionManager_messageReceiver, "f"),
8693
+ return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$8(this, _ConnectionManager_messageReceiver, "f"),
9368
8694
  // Providers do not have an endpointId, use channelId as endpointId in the strategy.
9369
8695
  providerIdentity.channelId, providerIdentity);
9370
8696
  default:
@@ -9400,7 +8726,7 @@ class ConnectionManager extends base_1$f.Base {
9400
8726
  const supportedProtocols = await Promise.all(protocols.map(async (type) => {
9401
8727
  switch (type) {
9402
8728
  case 'rtc': {
9403
- const { rtcClient, channels, offer, rtcConnectionId, channelsOpened } = await __classPrivateFieldGet$7(this, _ConnectionManager_rtcConnectionManager, "f").startClientOffer();
8729
+ const { rtcClient, channels, offer, rtcConnectionId, channelsOpened } = await __classPrivateFieldGet$8(this, _ConnectionManager_rtcConnectionManager, "f").startClientOffer();
9404
8730
  rtcPacket = { rtcClient, channels, channelsOpened };
9405
8731
  return {
9406
8732
  type: 'rtc',
@@ -9427,18 +8753,18 @@ class ConnectionManager extends base_1$f.Base {
9427
8753
  routingInfo.endpointId = this.wire.environment.getNextMessageId();
9428
8754
  // For New Clients connecting to Old Providers. To prevent multi-dispatching and publishing, we delete previously-connected
9429
8755
  // clients that are in the same context as the newly-connected client.
9430
- __classPrivateFieldGet$7(this, _ConnectionManager_messageReceiver, "f").checkForPreviousClientConnection(routingInfo.channelId);
8756
+ __classPrivateFieldGet$8(this, _ConnectionManager_messageReceiver, "f").checkForPreviousClientConnection(routingInfo.channelId);
9431
8757
  }
9432
8758
  const answer = routingInfo.answer ?? {
9433
8759
  supportedProtocols: [{ type: 'classic', version: 1 }]
9434
8760
  };
9435
8761
  const createStrategyFromAnswer = async (protocol) => {
9436
8762
  if (protocol.type === 'rtc' && rtcPacket) {
9437
- await __classPrivateFieldGet$7(this, _ConnectionManager_rtcConnectionManager, "f").finishClientOffer(rtcPacket.rtcClient, protocol.payload.answer, rtcPacket.channelsOpened);
8763
+ await __classPrivateFieldGet$8(this, _ConnectionManager_rtcConnectionManager, "f").finishClientOffer(rtcPacket.rtcClient, protocol.payload.answer, rtcPacket.channelsOpened);
9438
8764
  return new strategy_2.RTCStrategy();
9439
8765
  }
9440
8766
  if (protocol.type === 'classic') {
9441
- return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$7(this, _ConnectionManager_messageReceiver, "f"), routingInfo.endpointId, routingInfo);
8767
+ return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$8(this, _ConnectionManager_messageReceiver, "f"), routingInfo.endpointId, routingInfo);
9442
8768
  }
9443
8769
  return null;
9444
8770
  };
@@ -9506,7 +8832,7 @@ class ConnectionManager extends base_1$f.Base {
9506
8832
  clientAnswer = await overlappingProtocols.reduce(async (accumP, protocolToUse) => {
9507
8833
  const answer = await accumP;
9508
8834
  if (protocolToUse.type === 'rtc') {
9509
- const { answer: rtcAnswer, rtcClient, channels } = await __classPrivateFieldGet$7(this, _ConnectionManager_rtcConnectionManager, "f").createProviderAnswer(protocolToUse.payload.rtcConnectionId, protocolToUse.payload.offer);
8835
+ const { answer: rtcAnswer, rtcClient, channels } = await __classPrivateFieldGet$8(this, _ConnectionManager_rtcConnectionManager, "f").createProviderAnswer(protocolToUse.payload.rtcConnectionId, protocolToUse.payload.offer);
9510
8836
  answer.supportedProtocols.push({
9511
8837
  type: 'rtc',
9512
8838
  version: strategy_2.RTCInfo.version,
@@ -9554,13 +8880,13 @@ _ConnectionManager_messageReceiver = new WeakMap(), _ConnectionManager_rtcConnec
9554
8880
  *
9555
8881
  * @packageDocumentation
9556
8882
  */
9557
- var __classPrivateFieldSet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8883
+ var __classPrivateFieldSet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
9558
8884
  if (kind === "m") throw new TypeError("Private method is not writable");
9559
8885
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9560
8886
  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");
9561
8887
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
9562
8888
  };
9563
- var __classPrivateFieldGet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8889
+ var __classPrivateFieldGet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9564
8890
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9565
8891
  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");
9566
8892
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -9617,11 +8943,11 @@ class Channel extends base_1$e.EmitterBase {
9617
8943
  client_1.ChannelClient.handleProviderDisconnect(eventPayload);
9618
8944
  }),
9619
8945
  this.on('connected', (...args) => {
9620
- __classPrivateFieldGet$6(this, _Channel_internalEmitter, "f").emit('connected', ...args);
8946
+ __classPrivateFieldGet$7(this, _Channel_internalEmitter, "f").emit('connected', ...args);
9621
8947
  })
9622
8948
  ]).catch(() => new Error('error setting up channel connection listeners'));
9623
8949
  }));
9624
- __classPrivateFieldSet$4(this, _Channel_connectionManager, new connection_manager_1.ConnectionManager(wire), "f");
8950
+ __classPrivateFieldSet$6(this, _Channel_connectionManager, new connection_manager_1.ConnectionManager(wire), "f");
9625
8951
  }
9626
8952
  /**
9627
8953
  *
@@ -9696,7 +9022,7 @@ class Channel extends base_1$e.EmitterBase {
9696
9022
  resolve(true);
9697
9023
  }
9698
9024
  };
9699
- __classPrivateFieldGet$6(this, _Channel_internalEmitter, "f").on('connected', connectedListener);
9025
+ __classPrivateFieldGet$7(this, _Channel_internalEmitter, "f").on('connected', connectedListener);
9700
9026
  });
9701
9027
  try {
9702
9028
  if (retryInfo.count > 0) {
@@ -9728,7 +9054,7 @@ class Channel extends base_1$e.EmitterBase {
9728
9054
  finally {
9729
9055
  retryInfo.count += 1;
9730
9056
  // in case of other errors, remove our listener
9731
- __classPrivateFieldGet$6(this, _Channel_internalEmitter, "f").removeListener('connected', connectedListener);
9057
+ __classPrivateFieldGet$7(this, _Channel_internalEmitter, "f").removeListener('connected', connectedListener);
9732
9058
  }
9733
9059
  } while (shouldWait); // If we're waiting we retry the above loop
9734
9060
  // Should wait was false, no channel was found.
@@ -9787,12 +9113,12 @@ class Channel extends base_1$e.EmitterBase {
9787
9113
  async connect(channelName, options = {}) {
9788
9114
  // Make sure we don't connect before listeners are set up
9789
9115
  // This also errors if we're not in OpenFin, ensuring we don't run unnecessary code
9790
- await __classPrivateFieldGet$6(this, _Channel_readyToConnect, "f").getValue();
9116
+ await __classPrivateFieldGet$7(this, _Channel_readyToConnect, "f").getValue();
9791
9117
  if (!channelName || typeof channelName !== 'string') {
9792
9118
  throw new Error('Please provide a channelName string to connect to a channel.');
9793
9119
  }
9794
9120
  const opts = { wait: true, ...this.wire.environment.getDefaultChannelOptions().connect, ...options };
9795
- const { offer, rtc: rtcPacket } = await __classPrivateFieldGet$6(this, _Channel_connectionManager, "f").createClientOffer(opts);
9121
+ const { offer, rtc: rtcPacket } = await __classPrivateFieldGet$7(this, _Channel_connectionManager, "f").createClientOffer(opts);
9796
9122
  let connectionUrl;
9797
9123
  if (this.fin.me.isFrame || this.fin.me.isView || this.fin.me.isWindow) {
9798
9124
  connectionUrl = (await this.fin.me.getInfo()).url;
@@ -9804,7 +9130,7 @@ class Channel extends base_1$e.EmitterBase {
9804
9130
  connectionUrl
9805
9131
  };
9806
9132
  const routingInfo = await this.safeConnect(channelName, opts.wait, connectPayload);
9807
- const strategy = await __classPrivateFieldGet$6(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
9133
+ const strategy = await __classPrivateFieldGet$7(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
9808
9134
  const channel = new client_1.ChannelClient(routingInfo, () => client_1.ChannelClient.wireClose(this.wire, routingInfo, routingInfo.endpointId), strategy);
9809
9135
  // It is the client's responsibility to handle endpoint disconnection to the provider.
9810
9136
  // If the endpoint dies, the client will force a disconnection through the core.
@@ -9873,7 +9199,7 @@ class Channel extends base_1$e.EmitterBase {
9873
9199
  throw new Error('Please provide a channelName to create a channel');
9874
9200
  }
9875
9201
  const { payload: { data: providerIdentity } } = await this.wire.sendAction('create-channel', { channelName });
9876
- const channel = __classPrivateFieldGet$6(this, _Channel_connectionManager, "f").createProvider(options, providerIdentity);
9202
+ const channel = __classPrivateFieldGet$7(this, _Channel_connectionManager, "f").createProvider(options, providerIdentity);
9877
9203
  // TODO: fix typing (internal)
9878
9204
  // @ts-expect-error
9879
9205
  this.on('client-disconnected', (eventPayload) => {
@@ -10764,19 +10090,23 @@ var Factory$3 = {};
10764
10090
 
10765
10091
  var Instance$2 = {};
10766
10092
 
10767
- var __classPrivateFieldGet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
10093
+ var __classPrivateFieldSet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
10094
+ if (kind === "m") throw new TypeError("Private method is not writable");
10095
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10096
+ 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");
10097
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
10098
+ };
10099
+ var __classPrivateFieldGet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
10768
10100
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10769
10101
  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");
10770
10102
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
10771
10103
  };
10772
- var _Platform_connectToProvider;
10104
+ var _Platform_channelName, _Platform_connectToProvider;
10773
10105
  Object.defineProperty(Instance$2, "__esModule", { value: true });
10774
10106
  Instance$2.Platform = void 0;
10775
10107
  /* eslint-disable import/prefer-default-export, no-undef */
10776
10108
  const base_1$6 = base;
10777
10109
  const validate_1$1 = validate;
10778
- // Reuse clients to avoid overwriting already-registered client in provider
10779
- const clientMap = new Map();
10780
10110
  /** Manages the life cycle of windows and views in the application.
10781
10111
  *
10782
10112
  * Enables taking snapshots of itself and applying them to restore a previous configuration
@@ -10787,34 +10117,40 @@ class Platform extends base_1$6.EmitterBase {
10787
10117
  * @internal
10788
10118
  */
10789
10119
  // eslint-disable-next-line no-shadow
10790
- constructor(identity, channel) {
10120
+ constructor(wire, identity, channelName = `custom-frame-${identity.uuid}`) {
10791
10121
  // we piggyback off of application event emitter because from the core's perspective platform is just an app.
10792
- super(channel.wire, 'application', identity.uuid);
10793
- this.getClient = (identity) => {
10122
+ super(wire, 'application', identity.uuid);
10123
+ /**
10124
+ * @internal
10125
+ */
10126
+ _Platform_channelName.set(this, void 0);
10127
+ this.getClient = (identity = this.identity) => {
10128
+ if (identity.uuid !== this.identity.uuid) {
10129
+ // I have no idea why we allow passing in a different identity, but we do.
10130
+ // Doing this above the analytics call so we only register one call.
10131
+ return new Platform(this.wire, identity).getClient();
10132
+ }
10794
10133
  this.wire.sendAction('platform-get-client', this.identity).catch((e) => {
10795
10134
  // don't expose
10796
10135
  });
10797
- const target = identity || this.identity;
10798
- const { uuid } = target;
10799
- if (!clientMap.has(uuid)) {
10800
- const clientPromise = __classPrivateFieldGet$5(this, _Platform_connectToProvider, "f").call(this, uuid);
10801
- clientMap.set(uuid, clientPromise);
10136
+ if (!Platform.clientMap.has(__classPrivateFieldGet$6(this, _Platform_channelName, "f"))) {
10137
+ const clientPromise = __classPrivateFieldGet$6(this, _Platform_connectToProvider, "f").call(this);
10138
+ Platform.clientMap.set(__classPrivateFieldGet$6(this, _Platform_channelName, "f"), clientPromise);
10802
10139
  }
10803
10140
  // we set it above
10804
10141
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
10805
- return clientMap.get(uuid);
10142
+ return Platform.clientMap.get(__classPrivateFieldGet$6(this, _Platform_channelName, "f"));
10806
10143
  };
10807
- _Platform_connectToProvider.set(this, async (uuid) => {
10144
+ _Platform_connectToProvider.set(this, async () => {
10808
10145
  try {
10809
- const channelName = `custom-frame-${uuid}`;
10810
- const client = await this._channel.connect(channelName, { wait: false });
10146
+ const client = await this._channel.connect(__classPrivateFieldGet$6(this, _Platform_channelName, "f"), { wait: false });
10811
10147
  client.onDisconnection(() => {
10812
- clientMap.delete(uuid);
10148
+ Platform.clientMap.delete(__classPrivateFieldGet$6(this, _Platform_channelName, "f"));
10813
10149
  });
10814
10150
  return client;
10815
10151
  }
10816
10152
  catch (e) {
10817
- clientMap.delete(uuid);
10153
+ Platform.clientMap.delete(__classPrivateFieldGet$6(this, _Platform_channelName, "f"));
10818
10154
  throw new Error('The targeted Platform is not currently running. Listen for application-started event for the given Uuid.');
10819
10155
  }
10820
10156
  });
@@ -10827,7 +10163,8 @@ class Platform extends base_1$6.EmitterBase {
10827
10163
  if (errorMsg) {
10828
10164
  throw new Error(errorMsg);
10829
10165
  }
10830
- this._channel = channel;
10166
+ __classPrivateFieldSet$5(this, _Platform_channelName, channelName, "f");
10167
+ this._channel = this.fin.InterApplicationBus.Channel;
10831
10168
  this.identity = { uuid: identity.uuid };
10832
10169
  this.Layout = this.fin.Platform.Layout;
10833
10170
  this.Application = this.fin.Application.wrapSync(this.identity);
@@ -11324,310 +10661,980 @@ class Platform extends base_1$6.EmitterBase {
11324
10661
  * // we take a snapshot of the current state of the app, before changing it
11325
10662
  * const snapshotOfInitialAppState = await platform.getSnapshot();
11326
10663
  *
11327
- * // now let's change the state of the app:
11328
- * await addViewToWindow(win.identity);
11329
- * // ... the window now has three views in it
10664
+ * // now let's change the state of the app:
10665
+ * await addViewToWindow(win.identity);
10666
+ * // ... the window now has three views in it
10667
+ *
10668
+ * await platform.applySnapshot(snapshotOfInitialAppState, { closeExistingWindows: true });
10669
+ * // ... the window will revert to previous state, with just two views
10670
+ *
10671
+ * ```
10672
+ */
10673
+ async applySnapshot(requestedSnapshot, options) {
10674
+ this.wire.sendAction('platform-apply-snapshot', this.identity).catch((e) => {
10675
+ // don't expose
10676
+ });
10677
+ const errMsg = 'Requested snapshot must be a valid Snapshot object, or a url or filepath to such an object.';
10678
+ let snapshot;
10679
+ if (typeof requestedSnapshot === 'string') {
10680
+ // Fetch and parse snapshot
10681
+ try {
10682
+ const response = await this._channel.wire.sendAction('get-application-manifest', {
10683
+ manifestUrl: requestedSnapshot
10684
+ });
10685
+ snapshot = response.payload.data;
10686
+ }
10687
+ catch (err) {
10688
+ throw new Error(`${errMsg}: ${err}`);
10689
+ }
10690
+ }
10691
+ else {
10692
+ snapshot = requestedSnapshot;
10693
+ }
10694
+ if (!snapshot.windows) {
10695
+ throw new Error(errMsg);
10696
+ }
10697
+ const client = await this.getClient();
10698
+ await client.dispatch('apply-snapshot', {
10699
+ snapshot,
10700
+ options
10701
+ });
10702
+ return this;
10703
+ }
10704
+ /**
10705
+ * Fetches a JSON manifest using the browser process and returns a Javascript object.
10706
+ * Can be overwritten using {@link Platform.PlatformModule.init Platform.init}.
10707
+ * @param manifestUrl The URL of the manifest to fetch.
10708
+ *
10709
+ * @remarks Can be overwritten using {@link Platform#init Platform.init}.
10710
+ *
10711
+ * @example
10712
+ *
10713
+ * ```js
10714
+ * const platform = fin.Platform.getCurrentSync();
10715
+ * const manifest = await platform.fetchManifest('https://www.path-to-manifest.com/app.json');
10716
+ * console.log(manifest);
10717
+ * ```
10718
+ */
10719
+ async fetchManifest(manifestUrl) {
10720
+ const client = await this.getClient();
10721
+ return client.dispatch('platform-fetch-manifest', { manifestUrl });
10722
+ }
10723
+ /**
10724
+ * Retrieves a manifest by url and launches a legacy application manifest or snapshot into the platform. Returns a promise that
10725
+ * resolves to the wrapped Platform.
10726
+ * @param manifestUrl - The URL of the manifest that will be launched into the platform. If this app manifest
10727
+ * contains a snapshot, that will be launched into the platform. If not, the application described in startup_app options
10728
+ * will be launched into the platform. The applicable startup_app options will become {@link OpenFin.ViewCreationOptions View Options}.
10729
+ *
10730
+ * @remarks If the app manifest contains a snapshot, that will be launched into the platform. If not, the
10731
+ * application described in startup_app options will be launched into the platform as a window with a single view.
10732
+ * The applicable startup_app options will become View Options.
10733
+ *
10734
+ * @example
10735
+ * ```js
10736
+ * try {
10737
+ * const platform = fin.Platform.getCurrentSync();
10738
+ * await platform.launchContentManifest('http://localhost:5555/app.json');
10739
+ * console.log(`content launched successfully into platform`);
10740
+ * } catch(e) {
10741
+ * console.error(e);
10742
+ * }
10743
+ * // For a local manifest file:
10744
+ * try {
10745
+ * const platform = fin.Platform.getCurrentSync();
10746
+ * platform.launchContentManifest('file:///C:/somefolder/app.json');
10747
+ * console.log(`content launched successfully into platform`);
10748
+ * } catch(e) {
10749
+ * console.error(e);
10750
+ * }
10751
+ * ```
10752
+ * @experimental
10753
+ */
10754
+ async launchContentManifest(manifestUrl) {
10755
+ this.wire.sendAction('platform-launch-content-manifest', this.identity).catch(() => {
10756
+ // don't expose
10757
+ });
10758
+ const client = await this.getClient();
10759
+ const manifest = await this.fetchManifest(manifestUrl);
10760
+ client.dispatch('launch-into-platform', { manifest, manifestUrl });
10761
+ return this;
10762
+ }
10763
+ /**
10764
+ * Set the context of a host window. The context will be available to the window itself, and to its child Views. It will be saved in any platform snapshots.
10765
+ * It can be retrieved using {@link Platform#getWindowContext getWindowContext}.
10766
+ * @param context - A field where serializable context data can be stored to be saved in platform snapshots.
10767
+ * @param target - A target window or view may optionally be provided. If no target is provided, the update will be applied
10768
+ * to the current window (if called from a Window) or the current host window (if called from a View).
10769
+ *
10770
+ * @remarks The context data must be serializable. This can only be called from a window or view that has been launched into a
10771
+ * platform.
10772
+ * This method can be called from the window itself, or from any child view. Context data is shared by all
10773
+ * entities within a window.
10774
+ *
10775
+ * @example
10776
+ * Setting own context:
10777
+ * ```js
10778
+ * const platform = fin.Platform.getCurrentSync();
10779
+ * const contextData = {
10780
+ * security: 'STOCK',
10781
+ * currentView: 'detailed'
10782
+ * }
10783
+ *
10784
+ * await platform.setWindowContext(contextData);
10785
+ * // Context of current window is now set to `contextData`
10786
+ * ```
10787
+ *
10788
+ * Setting the context of another window or view:
10789
+ * ```js
10790
+ * const platform = fin.Platform.getCurrentSync();
10791
+ * const contextData = {
10792
+ * security: 'STOCK',
10793
+ * currentView: 'detailed'
10794
+ * }
10795
+ *
10796
+ * const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
10797
+ * await platform.setWindowContext(contextData, windowOrViewIdentity);
10798
+ * // Context of the target window or view is now set to `contextData`
10799
+ * ```
10800
+ *
10801
+ * A view can listen to changes to its host window's context by listening to the `host-context-changed` event.
10802
+ * This event will fire when a host window's context is updated or when the view is reparented to a new window:
10803
+ *
10804
+ * ```js
10805
+ * // From a view
10806
+ * const contextChangeHandler = ({ context }) => {
10807
+ * console.log('Host window\'s context has changed. New context data:', context);
10808
+ * // react to new context data here
10809
+ * }
10810
+ * await fin.me.on('host-context-changed', contextChangeHandler);
10811
+ *
10812
+ * const platform = await fin.Platform.getCurrentSync();
10813
+ * const contextData = {
10814
+ * security: 'STOCK',
10815
+ * currentView: 'detailed'
10816
+ * }
10817
+ * platform.setWindowContext(contextData) // contextChangeHandler will log the new context
10818
+ * ```
10819
+ *
10820
+ * To listen to a window's context updates, use the `context-changed` event:
10821
+ * ```js
10822
+ * // From a window
10823
+ * const contextChangeHandler = ({ context }) => {
10824
+ * console.log('This window\'s context has changed. New context data:', context);
10825
+ * // react to new context data here
10826
+ * }
10827
+ * await fin.me.on('context-changed', contextChangeHandler);
10828
+ *
10829
+ * const platform = await fin.Platform.getCurrentSync();
10830
+ * const contextData = {
10831
+ * security: 'STOCK',
10832
+ * currentView: 'detailed'
10833
+ * }
10834
+ * platform.setWindowContext(contextData) // contextChangeHandler will log the new context
10835
+ * ```
10836
+ * @experimental
10837
+ */
10838
+ async setWindowContext(context = {}, target) {
10839
+ this.wire.sendAction('platform-set-window-context', this.identity).catch((e) => {
10840
+ // don't expose
10841
+ });
10842
+ if (!context) {
10843
+ throw new Error('Please provide a serializable object or string to set the context.');
10844
+ }
10845
+ const client = await this.getClient();
10846
+ const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
10847
+ await client.dispatch('set-window-context', {
10848
+ context,
10849
+ entityType,
10850
+ target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name }
10851
+ });
10852
+ }
10853
+ /**
10854
+ * Get the context context of a host window that was previously set using {@link Platform#setWindowContext setWindowContext}.
10855
+ * The context will be saved in any platform snapshots. Returns a promise that resolves to the context.
10856
+ * @param target - A target window or view may optionally be provided. If no target is provided, target will be
10857
+ * the current window (if called from a Window) or the current host window (if called from a View).
10858
+ *
10859
+ * @remarks This method can be called from the window itself, or from any child view. Context data is shared
10860
+ * by all entities within a window.
10861
+ *
10862
+ * @example
10863
+ *
10864
+ * Retrieving context from current window:
10865
+ * ```js
10866
+ * const platform = fin.Platform.getCurrentSync();
10867
+ * const customContext = { answer: 42 };
10868
+ * await platform.setWindowContext(customContext);
10869
+ *
10870
+ * const myContext = await platform.getWindowContext();
10871
+ * console.log(myContext); // { answer: 42 }
10872
+ * ```
10873
+ *
10874
+ * Retrieving the context of another window or view:
10875
+ * ```js
10876
+ * const platform = fin.Platform.getCurrentSync();
11330
10877
  *
11331
- * await platform.applySnapshot(snapshotOfInitialAppState, { closeExistingWindows: true });
11332
- * // ... the window will revert to previous state, with just two views
10878
+ * const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
11333
10879
  *
10880
+ * const targetWindowContext = await platform.getWindowContext(windowOrViewIdentity);
10881
+ * console.log(targetWindowContext); // context of target window
11334
10882
  * ```
10883
+ * @experimental
11335
10884
  */
11336
- async applySnapshot(requestedSnapshot, options) {
11337
- this.wire.sendAction('platform-apply-snapshot', this.identity).catch((e) => {
10885
+ async getWindowContext(target) {
10886
+ this.wire.sendAction('platform-get-window-context', this.identity).catch((e) => {
11338
10887
  // don't expose
11339
10888
  });
11340
- const errMsg = 'Requested snapshot must be a valid Snapshot object, or a url or filepath to such an object.';
11341
- let snapshot;
11342
- if (typeof requestedSnapshot === 'string') {
11343
- // Fetch and parse snapshot
11344
- try {
11345
- const response = await this._channel.wire.sendAction('get-application-manifest', {
11346
- manifestUrl: requestedSnapshot
11347
- });
11348
- snapshot = response.payload.data;
11349
- }
11350
- catch (err) {
11351
- throw new Error(`${errMsg}: ${err}`);
11352
- }
11353
- }
11354
- else {
11355
- snapshot = requestedSnapshot;
11356
- }
11357
- if (!snapshot.windows) {
11358
- throw new Error(errMsg);
11359
- }
11360
10889
  const client = await this.getClient();
11361
- await client.dispatch('apply-snapshot', {
11362
- snapshot,
11363
- options
10890
+ const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
10891
+ return client.dispatch('get-window-context', {
10892
+ target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name },
10893
+ entityType
11364
10894
  });
11365
- return this;
11366
10895
  }
11367
10896
  /**
11368
- * Fetches a JSON manifest using the browser process and returns a Javascript object.
11369
- * Can be overwritten using {@link Platform.PlatformModule.init Platform.init}.
11370
- * @param manifestUrl The URL of the manifest to fetch.
10897
+ * Closes a window. If enableBeforeUnload is enabled in the Platform options, any beforeunload handler set on Views will fire
10898
+ * This behavior can be disabled by setting skipBeforeUnload to false in the options parameter.
10899
+ * @param winId
10900
+ * @param options
11371
10901
  *
11372
- * @remarks Can be overwritten using {@link Platform#init Platform.init}.
10902
+ * @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,
10903
+ * it is recommended to move that logic over to the [PlatformProvider.closeWindow]{@link PlatformProvider#closeWindow} override to ensure it runs when the Window closes.
11373
10904
  *
11374
10905
  * @example
11375
10906
  *
11376
10907
  * ```js
11377
- * const platform = fin.Platform.getCurrentSync();
11378
- * const manifest = await platform.fetchManifest('https://www.path-to-manifest.com/app.json');
11379
- * console.log(manifest);
10908
+ * // Close the current Window inside a Window context
10909
+ * const platform = await fin.Platform.getCurrent();
10910
+ * platform.closeWindow(fin.me.identity);
10911
+ *
10912
+ * // Close the Window from inside a View context
10913
+ * const platform = await fin.Platform.getCurrent();
10914
+ * const parentWindow = await fin.me.getCurrentWindow();
10915
+ * platform.closeWindow(parentWindow.identity);
10916
+ *
10917
+ * // Close the Window and do not fire the before unload handler on Views
10918
+ * const platform = await fin.Platform.getCurrent();
10919
+ * platform.closeWindow(fin.me.identity, { skipBeforeUnload: true });
11380
10920
  * ```
10921
+ * @experimental
11381
10922
  */
11382
- async fetchManifest(manifestUrl) {
10923
+ async closeWindow(windowId, options = { skipBeforeUnload: false }) {
10924
+ this.wire.sendAction('platform-close-window', this.identity).catch((e) => {
10925
+ // don't expose
10926
+ });
11383
10927
  const client = await this.getClient();
11384
- return client.dispatch('platform-fetch-manifest', { manifestUrl });
10928
+ return client.dispatch('close-window', { windowId, options });
10929
+ }
10930
+ }
10931
+ Instance$2.Platform = Platform;
10932
+ _Platform_channelName = new WeakMap(), _Platform_connectToProvider = new WeakMap();
10933
+ /**
10934
+ * @internal
10935
+ * Reuse clients to avoid overwriting already-registered client in provider
10936
+ * This ensures that only channel client is created per channel name per `fin` instance
10937
+ */
10938
+ Platform.clientMap = new Map();
10939
+
10940
+ var layout = {};
10941
+
10942
+ var Factory$2 = {};
10943
+
10944
+ var Instance$1 = {};
10945
+
10946
+ var commonUtils = {};
10947
+
10948
+ Object.defineProperty(commonUtils, "__esModule", { value: true });
10949
+ commonUtils.overrideFromComposables = commonUtils.isValidPresetType = void 0;
10950
+ function isValidPresetType(type) {
10951
+ switch (type) {
10952
+ case 'columns':
10953
+ case 'grid':
10954
+ case 'rows':
10955
+ case 'tabs':
10956
+ return true;
10957
+ default:
10958
+ return false;
10959
+ }
10960
+ }
10961
+ commonUtils.isValidPresetType = isValidPresetType;
10962
+ function overrideFromComposables(...overrides) {
10963
+ return (base) => overrides.reduceRight((p, c) => (b) => c(p(b)), (x) => x)(base);
10964
+ }
10965
+ commonUtils.overrideFromComposables = overrideFromComposables;
10966
+ commonUtils.default = { isValidPresetType };
10967
+
10968
+ var layoutEntities = {};
10969
+
10970
+ var apiExposer$1 = {};
10971
+
10972
+ var apiConsumer = {};
10973
+
10974
+ Object.defineProperty(apiConsumer, "__esModule", { value: true });
10975
+ apiConsumer.ApiConsumer = void 0;
10976
+ /**
10977
+ * Consumer for apis exposed with {@see ApiExposer}.
10978
+ *
10979
+ * A strategy that matches the strategy used to expose a target API must be provided.
10980
+ */
10981
+ class ApiConsumer {
10982
+ // eslint-disable-next-line
10983
+ constructor(strategy) {
10984
+ this.strategy = strategy;
10985
+ /**
10986
+ * Consumes an api exposed using a given transport strategy, and generates a client
10987
+ * for easy, type safe consumption of that client.
10988
+ * @param options Strategy specific consumption options.
10989
+ * @returns An api client matching the given type.
10990
+ */
10991
+ this.consume = async (options) => {
10992
+ const exposedProperties = await this.strategy.getExposedFunctions(options);
10993
+ return exposedProperties.reduce((client, prop) => ({
10994
+ ...client,
10995
+ [prop.key]: this.strategy.createFunction(prop, options)
10996
+ }), {});
10997
+ };
10998
+ }
10999
+ }
11000
+ apiConsumer.ApiConsumer = ApiConsumer;
11001
+
11002
+ var apiExposer = {};
11003
+
11004
+ var decorators = {};
11005
+
11006
+ Object.defineProperty(decorators, "__esModule", { value: true });
11007
+ decorators.expose = decorators.getExposedProperties = void 0;
11008
+ const exposedProperties = Symbol('exposedProperties');
11009
+ const getExposedProperties = (target) => {
11010
+ return target[exposedProperties] || target.prototype[exposedProperties] || [];
11011
+ };
11012
+ decorators.getExposedProperties = getExposedProperties;
11013
+ /**
11014
+ * Indicates that a class member function can be exposed using {@link ApiExposer}.
11015
+ * @param options Options specific to the strategy used in {@link ApiExposer}
11016
+ */
11017
+ // Returns any as decorator typing is weird.
11018
+ const expose = (options) => (target, key, descriptor) => {
11019
+ target[exposedProperties] = target[exposedProperties] || [];
11020
+ target[exposedProperties].push({ key, descriptor, options });
11021
+ };
11022
+ decorators.expose = expose;
11023
+
11024
+ Object.defineProperty(apiExposer, "__esModule", { value: true });
11025
+ apiExposer.ApiExposer = void 0;
11026
+ const decorators_1 = decorators;
11027
+ /**
11028
+ * Exposes api services on the transport of choice.
11029
+ */
11030
+ class ApiExposer {
11031
+ /**
11032
+ * @param strategy The expose strategy to use to expose instances.
11033
+ */
11034
+ // eslint-disable-next-line
11035
+ constructor(strategy) {
11036
+ this.strategy = strategy;
11037
+ /**
11038
+ * Exposes an instance of a given api on
11039
+ * @param instance Instance of a class which has been decorated to indicate which functions can be exposed.
11040
+ * @param instanceOptions Transport strategy specific options to use when exposing.
11041
+ */
11042
+ this.exposeInstance = async (instance, instanceOptions) => {
11043
+ const exposableProps = (0, decorators_1.getExposedProperties)(instance);
11044
+ const exposedProps = await Promise.all(exposableProps.map(async ({ key, options }) => {
11045
+ const customConsumptionOptions = await this.strategy.exposeFunction(instance[key].bind(instance), {
11046
+ key,
11047
+ options,
11048
+ meta: instanceOptions
11049
+ });
11050
+ return {
11051
+ key,
11052
+ options: customConsumptionOptions
11053
+ };
11054
+ }));
11055
+ await this.strategy.exposeMeta(instanceOptions, exposedProps);
11056
+ };
11057
+ }
11058
+ ;
11059
+ }
11060
+ apiExposer.ApiExposer = ApiExposer;
11061
+
11062
+ var strategies = {};
11063
+
11064
+ var openfinChannels = {};
11065
+
11066
+ var channelsConsumer = {};
11067
+
11068
+ Object.defineProperty(channelsConsumer, "__esModule", { value: true });
11069
+ channelsConsumer.ChannelsConsumer = void 0;
11070
+ class ChannelsConsumer {
11071
+ // eslint-disable-next-line
11072
+ constructor(channel) {
11073
+ this.channel = channel;
11074
+ this.getExposedFunctions = async (options) => {
11075
+ const { id } = options;
11076
+ const { props } = await this.channel.dispatch(`api-meta:${id}`);
11077
+ return props;
11078
+ };
11079
+ this.createFunction = (prop) => (...args) => {
11080
+ const { action } = prop.options;
11081
+ return this.channel.dispatch(action, { args });
11082
+ };
11083
+ }
11084
+ ;
11085
+ }
11086
+ channelsConsumer.ChannelsConsumer = ChannelsConsumer;
11087
+
11088
+ var channelsExposer = {};
11089
+
11090
+ Object.defineProperty(channelsExposer, "__esModule", { value: true });
11091
+ channelsExposer.ChannelsExposer = void 0;
11092
+ class ChannelsExposer {
11093
+ // eslint-disable-next-line
11094
+ constructor(channelProviderOrClient) {
11095
+ this.channelProviderOrClient = channelProviderOrClient;
11096
+ this.exposeFunction = async (target, config) => {
11097
+ const { key, options, meta } = config;
11098
+ const { id } = meta;
11099
+ const action = `${id}.${options?.action || key}`;
11100
+ await this.channelProviderOrClient.register(action, async ({ args }) => {
11101
+ return target(...args);
11102
+ });
11103
+ return { action };
11104
+ };
11105
+ this.exposeMeta = async ({ id }, props) => {
11106
+ const action = `api-meta:${id}`;
11107
+ await this.channelProviderOrClient.register(action, () => ({ props }));
11108
+ };
11385
11109
  }
11386
- /**
11387
- * Retrieves a manifest by url and launches a legacy application manifest or snapshot into the platform. Returns a promise that
11388
- * resolves to the wrapped Platform.
11389
- * @param manifestUrl - The URL of the manifest that will be launched into the platform. If this app manifest
11390
- * contains a snapshot, that will be launched into the platform. If not, the application described in startup_app options
11391
- * will be launched into the platform. The applicable startup_app options will become {@link OpenFin.ViewCreationOptions View Options}.
11392
- *
11393
- * @remarks If the app manifest contains a snapshot, that will be launched into the platform. If not, the
11394
- * application described in startup_app options will be launched into the platform as a window with a single view.
11395
- * The applicable startup_app options will become View Options.
11396
- *
11397
- * @example
11398
- * ```js
11399
- * try {
11400
- * const platform = fin.Platform.getCurrentSync();
11401
- * await platform.launchContentManifest('http://localhost:5555/app.json');
11402
- * console.log(`content launched successfully into platform`);
11403
- * } catch(e) {
11404
- * console.error(e);
11405
- * }
11406
- * // For a local manifest file:
11407
- * try {
11408
- * const platform = fin.Platform.getCurrentSync();
11409
- * platform.launchContentManifest('file:///C:/somefolder/app.json');
11410
- * console.log(`content launched successfully into platform`);
11411
- * } catch(e) {
11412
- * console.error(e);
11413
- * }
11414
- * ```
11415
- * @experimental
11416
- */
11417
- async launchContentManifest(manifestUrl) {
11418
- this.wire.sendAction('platform-launch-content-manifest', this.identity).catch(() => {
11419
- // don't expose
11110
+ }
11111
+ channelsExposer.ChannelsExposer = ChannelsExposer;
11112
+
11113
+ (function (exports) {
11114
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11115
+ if (k2 === undefined) k2 = k;
11116
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11117
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11118
+ desc = { enumerable: true, get: function() { return m[k]; } };
11119
+ }
11120
+ Object.defineProperty(o, k2, desc);
11121
+ }) : (function(o, m, k, k2) {
11122
+ if (k2 === undefined) k2 = k;
11123
+ o[k2] = m[k];
11124
+ }));
11125
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
11126
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11127
+ };
11128
+ Object.defineProperty(exports, "__esModule", { value: true });
11129
+ __exportStar(channelsConsumer, exports);
11130
+ __exportStar(channelsExposer, exports);
11131
+ } (openfinChannels));
11132
+
11133
+ (function (exports) {
11134
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11135
+ if (k2 === undefined) k2 = k;
11136
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11137
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11138
+ desc = { enumerable: true, get: function() { return m[k]; } };
11139
+ }
11140
+ Object.defineProperty(o, k2, desc);
11141
+ }) : (function(o, m, k, k2) {
11142
+ if (k2 === undefined) k2 = k;
11143
+ o[k2] = m[k];
11144
+ }));
11145
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
11146
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11147
+ };
11148
+ Object.defineProperty(exports, "__esModule", { value: true });
11149
+ __exportStar(openfinChannels, exports);
11150
+ } (strategies));
11151
+
11152
+ (function (exports) {
11153
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11154
+ if (k2 === undefined) k2 = k;
11155
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11156
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11157
+ desc = { enumerable: true, get: function() { return m[k]; } };
11158
+ }
11159
+ Object.defineProperty(o, k2, desc);
11160
+ }) : (function(o, m, k, k2) {
11161
+ if (k2 === undefined) k2 = k;
11162
+ o[k2] = m[k];
11163
+ }));
11164
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
11165
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11166
+ };
11167
+ Object.defineProperty(exports, "__esModule", { value: true });
11168
+ __exportStar(apiConsumer, exports);
11169
+ __exportStar(apiExposer, exports);
11170
+ __exportStar(strategies, exports);
11171
+ __exportStar(decorators, exports);
11172
+ } (apiExposer$1));
11173
+
11174
+ var channelApiRelay = {};
11175
+
11176
+ Object.defineProperty(channelApiRelay, "__esModule", { value: true });
11177
+ channelApiRelay.createRelayedDispatch = channelApiRelay.relayChannelClientApi = void 0;
11178
+ const EXPECTED_ERRORS = [
11179
+ 'no longer connected',
11180
+ 'RTCDataChannel closed unexpectedly',
11181
+ 'The client you are trying to dispatch from is disconnected from the target provider',
11182
+ ];
11183
+ // Checks possible error messages that we want to trap, client error message can originate
11184
+ // from ChannelProvider::dispatch OR ClassicStrategy::closeEndpoint OR RTCEndPoint::dataChannel::onclose
11185
+ const isDisconnectedError = (errorMsg) => {
11186
+ return EXPECTED_ERRORS.some(e => errorMsg.includes(e));
11187
+ };
11188
+ /**
11189
+ * @internal
11190
+ * Create a channel relay for a given channel exposition, allowing a single provider to route
11191
+ * actions to the designated clients.
11192
+ *
11193
+ * Designed to be used in conjunction with @expose
11194
+ *
11195
+ * @param channelProvider The channel provider to relay the actions on.
11196
+ * @param config Determines which actions to relay. Please ensure action prefix matches the exposed api.
11197
+ */
11198
+ const relayChannelClientApi = async (channelProvider, relayId) => {
11199
+ channelProvider.register(`relay:${relayId}`, ({ action, target, payload }) => {
11200
+ return channelProvider.dispatch(target, action, payload);
11201
+ });
11202
+ await Promise.resolve();
11203
+ };
11204
+ channelApiRelay.relayChannelClientApi = relayChannelClientApi;
11205
+ const createRelayedDispatch = (client, target, relayId, relayErrorMsg) => async (action, payload) => {
11206
+ try {
11207
+ return await client.dispatch(`relay:${relayId}`, {
11208
+ action,
11209
+ payload,
11210
+ target
11420
11211
  });
11421
- const client = await this.getClient();
11422
- const manifest = await this.fetchManifest(manifestUrl);
11423
- client.dispatch('launch-into-platform', { manifest, manifestUrl });
11424
- return this;
11425
11212
  }
11426
- /**
11427
- * Set the context of a host window. The context will be available to the window itself, and to its child Views. It will be saved in any platform snapshots.
11428
- * It can be retrieved using {@link Platform#getWindowContext getWindowContext}.
11429
- * @param context - A field where serializable context data can be stored to be saved in platform snapshots.
11430
- * @param target - A target window or view may optionally be provided. If no target is provided, the update will be applied
11431
- * to the current window (if called from a Window) or the current host window (if called from a View).
11432
- *
11433
- * @remarks The context data must be serializable. This can only be called from a window or view that has been launched into a
11434
- * platform.
11435
- * This method can be called from the window itself, or from any child view. Context data is shared by all
11436
- * entities within a window.
11437
- *
11438
- * @example
11439
- * Setting own context:
11440
- * ```js
11441
- * const platform = fin.Platform.getCurrentSync();
11442
- * const contextData = {
11443
- * security: 'STOCK',
11444
- * currentView: 'detailed'
11445
- * }
11446
- *
11447
- * await platform.setWindowContext(contextData);
11448
- * // Context of current window is now set to `contextData`
11449
- * ```
11450
- *
11451
- * Setting the context of another window or view:
11452
- * ```js
11453
- * const platform = fin.Platform.getCurrentSync();
11454
- * const contextData = {
11455
- * security: 'STOCK',
11456
- * currentView: 'detailed'
11457
- * }
11458
- *
11459
- * const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
11460
- * await platform.setWindowContext(contextData, windowOrViewIdentity);
11461
- * // Context of the target window or view is now set to `contextData`
11462
- * ```
11463
- *
11464
- * A view can listen to changes to its host window's context by listening to the `host-context-changed` event.
11465
- * This event will fire when a host window's context is updated or when the view is reparented to a new window:
11466
- *
11467
- * ```js
11468
- * // From a view
11469
- * const contextChangeHandler = ({ context }) => {
11470
- * console.log('Host window\'s context has changed. New context data:', context);
11471
- * // react to new context data here
11472
- * }
11473
- * await fin.me.on('host-context-changed', contextChangeHandler);
11474
- *
11475
- * const platform = await fin.Platform.getCurrentSync();
11476
- * const contextData = {
11477
- * security: 'STOCK',
11478
- * currentView: 'detailed'
11479
- * }
11480
- * platform.setWindowContext(contextData) // contextChangeHandler will log the new context
11481
- * ```
11482
- *
11483
- * To listen to a window's context updates, use the `context-changed` event:
11484
- * ```js
11485
- * // From a window
11486
- * const contextChangeHandler = ({ context }) => {
11487
- * console.log('This window\'s context has changed. New context data:', context);
11488
- * // react to new context data here
11489
- * }
11490
- * await fin.me.on('context-changed', contextChangeHandler);
11491
- *
11492
- * const platform = await fin.Platform.getCurrentSync();
11493
- * const contextData = {
11494
- * security: 'STOCK',
11495
- * currentView: 'detailed'
11496
- * }
11497
- * platform.setWindowContext(contextData) // contextChangeHandler will log the new context
11498
- * ```
11499
- * @experimental
11500
- */
11501
- async setWindowContext(context = {}, target) {
11502
- this.wire.sendAction('platform-set-window-context', this.identity).catch((e) => {
11503
- // don't expose
11504
- });
11505
- if (!context) {
11506
- throw new Error('Please provide a serializable object or string to set the context.');
11213
+ catch (e) {
11214
+ if (isDisconnectedError(e.message) && relayErrorMsg) {
11215
+ throw new Error(relayErrorMsg);
11507
11216
  }
11508
- const client = await this.getClient();
11509
- const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
11510
- await client.dispatch('set-window-context', {
11511
- context,
11512
- entityType,
11513
- target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name }
11514
- });
11217
+ throw e;
11515
11218
  }
11219
+ };
11220
+ channelApiRelay.createRelayedDispatch = createRelayedDispatch;
11221
+
11222
+ var __classPrivateFieldSet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
11223
+ if (kind === "m") throw new TypeError("Private method is not writable");
11224
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
11225
+ 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");
11226
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11227
+ };
11228
+ var __classPrivateFieldGet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
11229
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
11230
+ 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");
11231
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11232
+ };
11233
+ var _LayoutNode_client, _TabStack_client, _ColumnOrRow_client;
11234
+ Object.defineProperty(layoutEntities, "__esModule", { value: true });
11235
+ layoutEntities.ColumnOrRow = layoutEntities.TabStack = layoutEntities.LayoutNode = void 0;
11236
+ const api_exposer_1 = apiExposer$1;
11237
+ const channel_api_relay_1 = channelApiRelay;
11238
+ /*
11239
+ This file includes LayoutNode, ColumnOrRow and TabStack classes, which are all closely
11240
+ intertwined, and share members via parent abstract class LayoutNode. To prevent circular
11241
+ refs, we define and export all the classes here.
11242
+ */
11243
+ /**
11244
+ * @ignore
11245
+ * @internal
11246
+ * Supplies an ApiClient for {@link LayoutEntitiesController} and helper methods
11247
+ * for the entities {@link TabStack} AND {@link ColumnOrRow} to use.
11248
+ */
11249
+ class LayoutNode {
11516
11250
  /**
11517
- * Get the context context of a host window that was previously set using {@link Platform#setWindowContext setWindowContext}.
11518
- * The context will be saved in any platform snapshots. Returns a promise that resolves to the context.
11519
- * @param target - A target window or view may optionally be provided. If no target is provided, target will be
11520
- * the current window (if called from a Window) or the current host window (if called from a View).
11521
- *
11522
- * @remarks This method can be called from the window itself, or from any child view. Context data is shared
11523
- * by all entities within a window.
11524
- *
11525
- * @example
11526
- *
11527
- * Retrieving context from current window:
11528
- * ```js
11529
- * const platform = fin.Platform.getCurrentSync();
11530
- * const customContext = { answer: 42 };
11531
- * await platform.setWindowContext(customContext);
11532
- *
11533
- * const myContext = await platform.getWindowContext();
11534
- * console.log(myContext); // { answer: 42 }
11535
- * ```
11536
- *
11537
- * Retrieving the context of another window or view:
11538
- * ```js
11539
- * const platform = fin.Platform.getCurrentSync();
11540
- *
11541
- * const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
11542
- *
11543
- * const targetWindowContext = await platform.getWindowContext(windowOrViewIdentity);
11544
- * console.log(targetWindowContext); // context of target window
11545
- * ```
11546
- * @experimental
11251
+ * @internal
11252
+ * @ignore
11547
11253
  */
11548
- async getWindowContext(target) {
11549
- this.wire.sendAction('platform-get-window-context', this.identity).catch((e) => {
11550
- // don't expose
11551
- });
11552
- const client = await this.getClient();
11553
- const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
11554
- return client.dispatch('get-window-context', {
11555
- target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name },
11556
- entityType
11557
- });
11254
+ constructor(client, entityId) {
11255
+ /**
11256
+ * @ignore
11257
+ * @internal
11258
+ * ApiClient for {@link LayoutEntitiesController}
11259
+ */
11260
+ _LayoutNode_client.set(this, void 0);
11261
+ /**
11262
+ * Checks if the TabStack or ColumnOrRow is the root content item
11263
+ *
11264
+ * @example
11265
+ * ```js
11266
+ * if (!fin.me.isView) {
11267
+ * throw new Error('Not running in a platform View.');
11268
+ * }
11269
+ *
11270
+ * const stack = await fin.me.getCurrentStack();
11271
+ * const isRoot = await stack.isRoot();
11272
+ * // The TabStack is root: false
11273
+ * console.log(`The TabStack is root: ${isRoot}`);
11274
+ *
11275
+ * // Retrieves the parent ColumnOrRow
11276
+ * const parent = await stack.getParent();
11277
+ * const parentIsRoot = await parent.isRoot();
11278
+ * // The parent ColumnOrRow is root: true
11279
+ * console.log(`The parent ColumnOrRow is root: ${parentIsRoot}`);
11280
+ * ```
11281
+ */
11282
+ this.isRoot = () => __classPrivateFieldGet$5(this, _LayoutNode_client, "f").isRoot(this.entityId);
11283
+ /**
11284
+ * Checks if the TabStack or ColumnOrRow exists
11285
+ *
11286
+ * @example
11287
+ * ```js
11288
+ * if (!fin.me.isView) {
11289
+ * throw new Error('Not running in a platform View.');
11290
+ * }
11291
+ *
11292
+ * const stack = await fin.me.getCurrentStack();
11293
+ * // Retrieves the parent ColumnOrRow
11294
+ * const columnOrRow = await stack.getParent();
11295
+ * let exists = await stack.exists();
11296
+ * // or
11297
+ * let exists = await columnOrRow.exists();
11298
+ * // The entity exists: true
11299
+ * console.log(`The entity exists: ${exists}`);
11300
+ * ```
11301
+ */
11302
+ this.exists = () => __classPrivateFieldGet$5(this, _LayoutNode_client, "f").exists(this.entityId);
11303
+ /**
11304
+ * Retrieves the parent of the TabStack or ColumnOrRow
11305
+ *
11306
+ * @example
11307
+ * ```js
11308
+ * if (!fin.me.isView) {
11309
+ * throw new Error('Not running in a platform View.');
11310
+ * }
11311
+ *
11312
+ * const stack = await fin.me.getCurrentStack();
11313
+ * // Retrieves the parent ColumnOrRow
11314
+ * const columnOrRow = await stack.getParent();
11315
+ *
11316
+ * // undefined if entity is the root item
11317
+ * let parent = await columnOrRow.getParent();
11318
+ * // or
11319
+ * let parent = await stack.getParent();
11320
+ * ```
11321
+ */
11322
+ this.getParent = async () => {
11323
+ const parent = await __classPrivateFieldGet$5(this, _LayoutNode_client, "f").getParent(this.entityId);
11324
+ if (!parent) {
11325
+ return undefined;
11326
+ }
11327
+ return LayoutNode.getEntity(parent, __classPrivateFieldGet$5(this, _LayoutNode_client, "f"));
11328
+ };
11329
+ /**
11330
+ * Creates a new TabStack adjacent to the given TabStack or ColumnOrRow. Inputs can be new views to create, or existing views.
11331
+ *
11332
+ * Known Issue: If the number of views to add overflows the tab-container, the added views will be set as active
11333
+ * during each render, and then placed at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
11334
+ * This means the views you pass to createAdjacentStack() may not render in the order given by the array.
11335
+ * Until fixed, this problem can be avoided only if your window is wide enough to fit creating all the views in the tabstack.
11336
+ *
11337
+ * @param views The views that will populate the new TabStack.
11338
+ * @param options Additional options that control new TabStack creation.
11339
+ * @returns The newly-created TabStack.
11340
+ *
11341
+ * @example
11342
+ * ```js
11343
+ * if (!fin.me.isView) {
11344
+ * throw new Error('Not running in a platform View.');
11345
+ * }
11346
+ *
11347
+ * const stack = await fin.me.getCurrentStack();
11348
+ * const columnOrRow = await stack.getParent();
11349
+ *
11350
+ * // Create view references by supplying a 'name' and 'url'
11351
+ * const views = [
11352
+ * // if 'name' is undefined, one will be generated
11353
+ * // if 'url' is undefined, it will default the view URL to 'about:blank'
11354
+ * { name: 'google-view', url: 'http://google.com/'},
11355
+ * { name: 'of-developers-view', url: 'http://developers.openfin.co/'},
11356
+ * ];
11357
+ *
11358
+ * // Create a view beforehand to be included in the new tab stack
11359
+ * const outsideView = await fin.View.create({
11360
+ * name: 'outside-bloomberg-view',
11361
+ * url: 'https://bloomberg.com/',
11362
+ * target: fin.me.identity,
11363
+ * });
11364
+ *
11365
+ * // Views to add can be identities, or the reference views mentioned above
11366
+ * const viewsToAdd = [outsideView.identity, ...views];
11367
+ *
11368
+ * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
11369
+ * let stackFrom = await columnOrRow.createAdjacentStack(viewsToAdd, { position: 'right' });
11370
+ * // Or
11371
+ * let newStack = await stack.createAdjacentStack(viewsToAdd, { position: 'right' });
11372
+ * console.log(`A new TabStack created to the right has ${newStack.length} views in it`);
11373
+ *
11374
+ * ```
11375
+ * @experimental
11376
+ */
11377
+ this.createAdjacentStack = async (views, options) => {
11378
+ const entityId = await __classPrivateFieldGet$5(this, _LayoutNode_client, "f").createAdjacentStack(this.entityId, views, options);
11379
+ return LayoutNode.getEntity({ entityId, type: 'stack' }, __classPrivateFieldGet$5(this, _LayoutNode_client, "f"));
11380
+ };
11381
+ /**
11382
+ * Retrieves the adjacent TabStacks of the given TabStack or ColumnOrRow.
11383
+ *
11384
+ * @param edge Edge whose adjacent TabStacks will be returned.
11385
+ *
11386
+ * @example
11387
+ * ```js
11388
+ * if (!fin.me.isView) {
11389
+ * throw new Error('Not running in a platform View.');
11390
+ * }
11391
+ *
11392
+ * const stack = await fin.me.getCurrentStack();
11393
+ * const columnOrRow = await stack.getParent();
11394
+ * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
11395
+ * let rightStacks = await columnOrRow.getAdjacentStacks('right');
11396
+ * let leftStacks = await columnOrRow.getAdjacentStacks('left');
11397
+ * // or
11398
+ * let rightStacks = await stack.getAdjacentStacks('right');
11399
+ * let leftStacks = await stack.getAdjacentStacks('left');
11400
+ *
11401
+ * console.log(`The entity has ${rightStacks.length} stacks to the right, and ${leftStacks.length} stacks to the left`);
11402
+ *
11403
+ * ```
11404
+ * @experimental
11405
+ */
11406
+ this.getAdjacentStacks = async (edge) => {
11407
+ const adjacentStacks = await __classPrivateFieldGet$5(this, _LayoutNode_client, "f").getAdjacentStacks({
11408
+ targetId: this.entityId,
11409
+ edge
11410
+ });
11411
+ return adjacentStacks.map((stack) => LayoutNode.getEntity({
11412
+ type: 'stack',
11413
+ entityId: stack.entityId
11414
+ }, __classPrivateFieldGet$5(this, _LayoutNode_client, "f")));
11415
+ };
11416
+ __classPrivateFieldSet$4(this, _LayoutNode_client, client, "f");
11417
+ this.entityId = entityId;
11418
+ }
11419
+ }
11420
+ layoutEntities.LayoutNode = LayoutNode;
11421
+ _LayoutNode_client = new WeakMap();
11422
+ /**
11423
+ * @ignore
11424
+ * @internal
11425
+ * Encapsulates Api consumption of {@link LayoutEntitiesClient} with a relayed dispatch
11426
+ * @param client
11427
+ * @param controllerId
11428
+ * @param identity
11429
+ * @returns a new instance of {@link LayoutEntitiesClient} with bound to the controllerId
11430
+ */
11431
+ LayoutNode.newLayoutEntitiesClient = async (client, controllerId, identity) => {
11432
+ 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.');
11433
+ const consumer = new api_exposer_1.ApiConsumer(new api_exposer_1.ChannelsConsumer({ dispatch }));
11434
+ return consumer.consume({ id: controllerId });
11435
+ };
11436
+ LayoutNode.getEntity = (definition, client) => {
11437
+ const { entityId, type } = definition;
11438
+ switch (type) {
11439
+ case 'column':
11440
+ case 'row':
11441
+ return new ColumnOrRow(client, entityId, type);
11442
+ case 'stack':
11443
+ return new TabStack(client, entityId);
11444
+ default:
11445
+ throw new Error(`Unrecognised Layout Entity encountered ('${JSON.stringify(definition)})`);
11446
+ }
11447
+ };
11448
+ /**
11449
+ * A TabStack is used to manage the state of a stack of tabs within an OpenFin Layout.
11450
+ */
11451
+ class TabStack extends LayoutNode {
11452
+ /** @internal */
11453
+ constructor(client, entityId) {
11454
+ super(client, entityId);
11455
+ /**
11456
+ * @internal
11457
+ * ApiClient for {@link LayoutEntitiesController}
11458
+ */
11459
+ _TabStack_client.set(this, void 0);
11460
+ /**
11461
+ * Type of the content item. Always stack, but useful for distinguishing between a {@link TabStack} and {@link ColumnOrRow}.
11462
+ */
11463
+ this.type = 'stack';
11464
+ /**
11465
+ * Retrieves a list of all views belonging to this {@link TabStack}.
11466
+ *
11467
+ * Known Issue: If adding a view overflows the tab-container width, the added view will be set as active
11468
+ * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
11469
+ * If that happens and then getViews() is called, it will return the identities in a different order than
11470
+ * than the currently rendered tab order.
11471
+ *
11472
+ *
11473
+ * @throws If the {@link TabStack} has been destroyed.
11474
+ * @example
11475
+ * ```js
11476
+ * if (!fin.me.isView) {
11477
+ * throw new Error('Not running in a platform View.');
11478
+ * }
11479
+ *
11480
+ * const stack = await fin.me.getCurrentStack();
11481
+ * // Alternatively, you can wrap any view and get the stack from there
11482
+ * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
11483
+ * // const stack = await viewFromSomewhere.getCurrentStack();
11484
+ * const views = await stack.getViews();
11485
+ * console.log(`Stack contains ${views.length} view(s)`);
11486
+ * ```
11487
+ * @experimental
11488
+ */
11489
+ this.getViews = () => __classPrivateFieldGet$5(this, _TabStack_client, "f").getStackViews(this.entityId);
11490
+ /**
11491
+ * Adds or creates a view in this {@link TabStack}.
11492
+ *
11493
+ * @remarks Known Issue: If adding a view overflows the tab-container, the added view will be set as active
11494
+ * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
11495
+ *
11496
+ * @param view The identity of an existing view to add, or options to create a view.
11497
+ * @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)
11498
+ * @returns Resolves with the {@link OpenFin.Identity identity} of the added view.
11499
+ * @throws If the view does not exist or fails to create.
11500
+ * @throws If the {@link TabStack} has been destroyed.
11501
+ * @example
11502
+ * ```js
11503
+ * if (!fin.me.isView) {
11504
+ * throw new Error('Not running in a platform View.');
11505
+ * }
11506
+ *
11507
+ * const stack = await fin.me.getCurrentStack();
11508
+ * // Alternatively, you can wrap any view and get the stack from there
11509
+ * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
11510
+ * // const stack = await viewFromSomewhere.getCurrentStack();
11511
+ * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
11512
+ * console.log('Identity of the google view just added', { googleViewIdentity });
11513
+ * // pass in { index: number } to set the index in the stack. Here 1 means, end of the stack (defaults to 0)
11514
+ * const appleViewIdentity = await stack.addView({ name: 'apple-view', url: 'http://apple.com/' }, { index: 1 });
11515
+ * console.log('Identity of the apple view just added', { appleViewIdentity });
11516
+ * ```
11517
+ * @experimental
11518
+ */
11519
+ this.addView = async (view, options = { index: 0 }) => __classPrivateFieldGet$5(this, _TabStack_client, "f").addViewToStack(this.entityId, view, options);
11520
+ /**
11521
+ * Removes a view from this {@link TabStack}.
11522
+ *
11523
+ * @remarks Throws an exception if the view identity does not exist or was already destroyed.
11524
+ *
11525
+ * @param view - Identity of the view to remove.
11526
+ * @throws If the view does not exist or does not belong to the stack.
11527
+ * @throws If the {@link TabStack} has been destroyed.
11528
+ *
11529
+ * @example
11530
+ * ```js
11531
+ * if (!fin.me.isView) {
11532
+ * throw new Error('Not running in a platform View.');
11533
+ * }
11534
+ *
11535
+ * const stack = await fin.me.getCurrentStack();
11536
+ * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
11537
+ *
11538
+ * await stack.removeView(googleViewIdentity);
11539
+ *
11540
+ * try {
11541
+ * await stack.removeView(googleViewIdentity);
11542
+ * } catch (error) {
11543
+ * // Tried to remove a view ('google-view') which does not belong to the stack.
11544
+ * console.log(error);
11545
+ * }
11546
+ * ```
11547
+ */
11548
+ this.removeView = async (view) => {
11549
+ await __classPrivateFieldGet$5(this, _TabStack_client, "f").removeViewFromStack(this.entityId, view);
11550
+ };
11551
+ /**
11552
+ * Sets the active view of the {@link TabStack} without focusing it.
11553
+ * @param view - Identity of the view to activate.
11554
+ * @returns Promise which resolves with void once the view has been activated.
11555
+ * @throws If the {@link TabStack} has been destroyed.
11556
+ * @throws If the view does not exist.
11557
+ * @example
11558
+ * Change the active tab of a known View's TabStack:
11559
+ * ```js
11560
+ * const targetView = fin.View.wrapSync({ uuid: 'uuid', name: 'view-name' });
11561
+ * const stack = await targetView.getCurrentStack();
11562
+ * await stack.setActiveView(targetView.identity);
11563
+ * ```
11564
+ *
11565
+ * Set the current View as active within its TabStack:
11566
+ * ```js
11567
+ * const stack = await fin.me.getCurrentStack();
11568
+ * await stack.setActiveView(fin.me.identity);
11569
+ * ```
11570
+ * @experimental
11571
+ */
11572
+ this.setActiveView = async (view) => {
11573
+ await __classPrivateFieldGet$5(this, _TabStack_client, "f").setStackActiveView(this.entityId, view);
11574
+ };
11575
+ __classPrivateFieldSet$4(this, _TabStack_client, client, "f");
11558
11576
  }
11577
+ }
11578
+ layoutEntities.TabStack = TabStack;
11579
+ _TabStack_client = new WeakMap();
11580
+ /**
11581
+ * A ColumnOrRow is used to manage the state of Column and Rows within an OpenFin Layout.
11582
+ */
11583
+ class ColumnOrRow extends LayoutNode {
11559
11584
  /**
11560
- * Closes a window. If enableBeforeUnload is enabled in the Platform options, any beforeunload handler set on Views will fire
11561
- * This behavior can be disabled by setting skipBeforeUnload to false in the options parameter.
11562
- * @param winId
11563
- * @param options
11564
- *
11565
- * @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,
11566
- * it is recommended to move that logic over to the [PlatformProvider.closeWindow]{@link PlatformProvider#closeWindow} override to ensure it runs when the Window closes.
11567
- *
11568
- * @example
11569
- *
11570
- * ```js
11571
- * // Close the current Window inside a Window context
11572
- * const platform = await fin.Platform.getCurrent();
11573
- * platform.closeWindow(fin.me.identity);
11574
- *
11575
- * // Close the Window from inside a View context
11576
- * const platform = await fin.Platform.getCurrent();
11577
- * const parentWindow = await fin.me.getCurrentWindow();
11578
- * platform.closeWindow(parentWindow.identity);
11579
- *
11580
- * // Close the Window and do not fire the before unload handler on Views
11581
- * const platform = await fin.Platform.getCurrent();
11582
- * platform.closeWindow(fin.me.identity, { skipBeforeUnload: true });
11583
- * ```
11584
- * @experimental
11585
+ * @internal
11585
11586
  */
11586
- async closeWindow(windowId, options = { skipBeforeUnload: false }) {
11587
- this.wire.sendAction('platform-close-window', this.identity).catch((e) => {
11588
- // don't expose
11589
- });
11590
- const client = await this.getClient();
11591
- return client.dispatch('close-window', { windowId, options });
11587
+ constructor(client, entityId, type) {
11588
+ super(client, entityId);
11589
+ /**
11590
+ * @ignore
11591
+ * @internal
11592
+ * ApiClient for {@link LayoutEntitiesController}
11593
+ */
11594
+ _ColumnOrRow_client.set(this, void 0);
11595
+ /**
11596
+ * Retrieves the content array of the ColumnOrRow
11597
+ *
11598
+ * @example
11599
+ * ```js
11600
+ * if (!fin.me.isView) {
11601
+ * throw new Error('Not running in a platform View.');
11602
+ * }
11603
+ *
11604
+ * const stack = await fin.me.getCurrentStack();
11605
+ * // Retrieves the parent ColumnOrRow
11606
+ * const columnOrRow = await stack.getParent();
11607
+ *
11608
+ * // returns [TabStack]
11609
+ * const contentArray = await columnOrRow.getContent();
11610
+ * console.log(`The ColumnOrRow has ${contentArray.length} item(s)`);
11611
+ * ```
11612
+ */
11613
+ this.getContent = async () => {
11614
+ const contentItemEntities = await __classPrivateFieldGet$5(this, _ColumnOrRow_client, "f").getContent(this.entityId);
11615
+ return contentItemEntities.map((entity) => LayoutNode.getEntity(entity, __classPrivateFieldGet$5(this, _ColumnOrRow_client, "f")));
11616
+ };
11617
+ __classPrivateFieldSet$4(this, _ColumnOrRow_client, client, "f");
11618
+ this.type = type;
11592
11619
  }
11593
11620
  }
11594
- Instance$2.Platform = Platform;
11595
- _Platform_connectToProvider = new WeakMap();
11596
-
11597
- var layout = {};
11598
-
11599
- var Factory$2 = {};
11600
-
11601
- var Instance$1 = {};
11621
+ layoutEntities.ColumnOrRow = ColumnOrRow;
11622
+ _ColumnOrRow_client = new WeakMap();
11602
11623
 
11603
- var commonUtils = {};
11624
+ var layout_constants = {};
11604
11625
 
11605
- Object.defineProperty(commonUtils, "__esModule", { value: true });
11606
- commonUtils.overrideFromComposables = commonUtils.isValidPresetType = void 0;
11607
- function isValidPresetType(type) {
11608
- switch (type) {
11609
- case 'columns':
11610
- case 'grid':
11611
- case 'rows':
11612
- case 'tabs':
11613
- return true;
11614
- default:
11615
- return false;
11616
- }
11617
- }
11618
- commonUtils.isValidPresetType = isValidPresetType;
11619
- function overrideFromComposables(...overrides) {
11620
- return (base) => overrides.reduceRight((p, c) => (b) => c(p(b)), (x) => x)(base);
11621
- }
11622
- commonUtils.overrideFromComposables = overrideFromComposables;
11623
- commonUtils.default = { isValidPresetType };
11626
+ Object.defineProperty(layout_constants, "__esModule", { value: true });
11627
+ layout_constants.DEFAULT_LAYOUT_KEY = layout_constants.LAYOUT_CONTROLLER_ID = void 0;
11628
+ layout_constants.LAYOUT_CONTROLLER_ID = 'layout-entities';
11629
+ // TODO: eventually export this somehow
11630
+ layout_constants.DEFAULT_LAYOUT_KEY = '__default__';
11624
11631
 
11625
11632
  var __classPrivateFieldGet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
11626
11633
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
11627
11634
  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");
11628
11635
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11629
11636
  };
11630
- var _Layout_layoutClient;
11637
+ var _Layout_instances, _Layout_layoutClient, _Layout_forwardLayoutAction;
11631
11638
  Object.defineProperty(Instance$1, "__esModule", { value: true });
11632
11639
  Instance$1.Layout = void 0;
11633
11640
  const lazy_1 = lazy;
@@ -11769,12 +11776,19 @@ const layout_constants_1$1 = layout_constants;
11769
11776
  * ```
11770
11777
  */
11771
11778
  class Layout extends base_1$5.Base {
11779
+ /**
11780
+ * @internal
11781
+ */
11782
+ static getClient(layout) {
11783
+ return __classPrivateFieldGet$4(layout, _Layout_layoutClient, "f").getValue();
11784
+ }
11772
11785
  /**
11773
11786
  * @internal
11774
11787
  */
11775
11788
  // eslint-disable-next-line no-shadow
11776
11789
  constructor(identity, wire) {
11777
11790
  super(wire);
11791
+ _Layout_instances.add(this);
11778
11792
  /**
11779
11793
  * @internal
11780
11794
  * Lazily constructed {@link LayoutEntitiesClient} bound to this platform's client and identity
@@ -11993,9 +12007,71 @@ class Layout extends base_1$5.Base {
11993
12007
  const root = await client.getRoot('layoutName' in this.identity ? this.identity : undefined);
11994
12008
  return layout_entities_1.LayoutNode.getEntity(root, client);
11995
12009
  }
12010
+ /**
12011
+ * Retrieves the OpenFin.TabStack instance which the View belongs to.
12012
+ *
12013
+ * @example
12014
+ * ```js
12015
+ * const viewIdentity = { uuid: 'uuid', name: 'view-name' };
12016
+ * const stack = await fin.View.wrapSync(viewIdentity).getStackByViewIdentity(viewIdentity);
12017
+ * console.log(await stack.getViews());
12018
+ * ```
12019
+ */
12020
+ async getStackByViewIdentity(identity) {
12021
+ this.wire.sendAction('layout-get-stack-by-view').catch(() => {
12022
+ // don't expose
12023
+ });
12024
+ const client = await __classPrivateFieldGet$4(this, _Layout_layoutClient, "f").getValue();
12025
+ const stack = await client.getStackByView(identity);
12026
+ if (!stack) {
12027
+ throw new Error(`No stack found for view: ${identity.uuid}/${identity.name}`);
12028
+ }
12029
+ return layout_entities_1.LayoutNode.getEntity(stack, client);
12030
+ }
12031
+ /**
12032
+ * Adds a view to the platform layout. Behaves like @link{Platform#createView} with the current layout as the target.
12033
+ *
12034
+ * @param viewOptions - The options for creating the view.
12035
+ * @param options - Optional parameters for adding the view.
12036
+ * @param options.location - The location where the view should be added.
12037
+ * @param options.targetView - The target view to which the new view should be added.
12038
+ * @returns A promise that resolves to an object containing the identity of the added view.
12039
+ */
12040
+ async addView(viewOptions, { location, targetView } = {}) {
12041
+ this.wire.sendAction('layout-add-view').catch((e) => {
12042
+ // don't expose
12043
+ });
12044
+ const { identity } = await __classPrivateFieldGet$4(this, _Layout_instances, "m", _Layout_forwardLayoutAction).call(this, 'layout-add-view', {
12045
+ viewOptions,
12046
+ location,
12047
+ targetView
12048
+ });
12049
+ return { identity };
12050
+ }
12051
+ /**
12052
+ * Closes a view by its identity. Throws an error if the view does not belong to the current layout.
12053
+ * Behaves like @link{Platform#closeView} but only closes the view if it belongs the current layout.
12054
+ *
12055
+ * @param viewIdentity - The identity of the view to close.
12056
+ * @returns A promise that resolves when the view is closed.
12057
+ */
12058
+ async closeView(viewIdentity) {
12059
+ this.wire.sendAction('layout-close-view').catch((e) => {
12060
+ // don't expose
12061
+ });
12062
+ await __classPrivateFieldGet$4(this, _Layout_instances, "m", _Layout_forwardLayoutAction).call(this, 'layout-close-view', { viewIdentity });
12063
+ }
11996
12064
  }
11997
12065
  Instance$1.Layout = Layout;
11998
- _Layout_layoutClient = new WeakMap();
12066
+ _Layout_layoutClient = new WeakMap(), _Layout_instances = new WeakSet(), _Layout_forwardLayoutAction =
12067
+ /**
12068
+ * @internal
12069
+ * Use to type-guard actions sent to the layout via the provider.
12070
+ */
12071
+ async function _Layout_forwardLayoutAction(action, payload) {
12072
+ const client = await this.platform.getClient();
12073
+ return client.dispatch(action, { target: this.identity, opts: payload });
12074
+ };
11999
12075
 
12000
12076
  var __classPrivateFieldGet$3 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12001
12077
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
@@ -12186,7 +12262,7 @@ class LayoutModule extends base_1$4.Base {
12186
12262
  this.wire.sendAction('layout-get-current').catch((e) => {
12187
12263
  // don't expose
12188
12264
  });
12189
- if (!this.fin.me.isWindow) {
12265
+ if (this.wire.environment.type === 'openfin' && !this.fin.me.isWindow) {
12190
12266
  throw new Error('You are not in a Window context. Only Windows can have a Layout.');
12191
12267
  }
12192
12268
  const { uuid, name } = this.fin.me;
@@ -12209,12 +12285,54 @@ class LayoutModule extends base_1$4.Base {
12209
12285
  this.wire.sendAction('layout-get-current-sync').catch((e) => {
12210
12286
  // don't expose
12211
12287
  });
12212
- if (!this.fin.me.isWindow) {
12288
+ if (this.wire.environment.type === 'openfin' && !this.fin.me.isWindow) {
12213
12289
  throw new Error('You are not in a Window context. Only Windows can have a Layout.');
12214
12290
  }
12215
12291
  const { uuid, name } = this.fin.me;
12216
12292
  return this.wrapSync({ uuid, name });
12217
12293
  }
12294
+ /**
12295
+ * Retrieves the OpenFin.Layout instance for the Window the View is attached to.
12296
+ *
12297
+ * @example
12298
+ * ```js
12299
+ * const viewIdentity = { uuid: 'uuid', name: 'view-name' };
12300
+ * const layout = await fin.Platform.Layout.getLayoutByViewIdentity(viewIdentity);
12301
+ * console.log(await layout.getCurrentViews());
12302
+ * ```
12303
+ */
12304
+ async getLayoutByViewIdentity(viewIdentity) {
12305
+ this.wire.sendAction('layout-get-by-view-identity').catch(() => {
12306
+ // don't expose
12307
+ });
12308
+ const winIdentity = await this.wire.environment.getViewWindowIdentity(this.fin, viewIdentity);
12309
+ let layoutWindowIdentity = winIdentity;
12310
+ // TODO: CORE-1857 - when we tearout active layout or drag a view out of a window, the above identity includes the whole window info.
12311
+ if (layoutWindowIdentity.identity) {
12312
+ layoutWindowIdentity = layoutWindowIdentity.identity;
12313
+ }
12314
+ try {
12315
+ const layoutWindow = this.wrapSync(layoutWindowIdentity);
12316
+ const client = await Instance_1$2.Layout.getClient(layoutWindow);
12317
+ const layoutIdentity = await client.getLayoutIdentityForViewOrThrow(viewIdentity);
12318
+ return this.wrapSync(layoutIdentity);
12319
+ }
12320
+ catch (e) {
12321
+ const allowedErrors = [
12322
+ 'No action registered at target for',
12323
+ 'getLayoutIdentityForViewOrThrow is not a function'
12324
+ ];
12325
+ if (!allowedErrors.some((m) => e.message.includes(m))) {
12326
+ throw e;
12327
+ }
12328
+ // If a view is attached to provider window, return null
12329
+ if (layoutWindowIdentity.uuid === layoutWindowIdentity.name) {
12330
+ throw new Error(`View identity ${JSON.stringify(viewIdentity)} is not attached to any layout in provider window ${JSON.stringify(layoutWindowIdentity)}.`);
12331
+ }
12332
+ // fallback logic for missing endpoint in older runtimes
12333
+ return this.wrapSync(layoutWindowIdentity);
12334
+ }
12335
+ }
12218
12336
  }
12219
12337
  Factory$2.LayoutModule = LayoutModule;
12220
12338
  _LayoutModule_layoutInitializationAttempted = new WeakMap(), _LayoutModule_layoutManager = new WeakMap(), _LayoutModule_getLayoutManagerSpy = new WeakMap(), _LayoutModule_instances = new WeakSet(), _LayoutModule_getSafeLayoutManager = function _LayoutModule_getSafeLayoutManager(method) {
@@ -12351,7 +12469,7 @@ class PlatformModule extends base_1$3.Base {
12351
12469
  this.wire.sendAction('platform-wrap').catch((e) => {
12352
12470
  // don't expose
12353
12471
  });
12354
- return new Instance_1$1.Platform({ uuid: identity.uuid }, this._channel);
12472
+ return new Instance_1$1.Platform(this.wire, { uuid: identity.uuid });
12355
12473
  }
12356
12474
  /**
12357
12475
  * Synchronously returns a Platform object that represents an existing platform.
@@ -12368,7 +12486,7 @@ class PlatformModule extends base_1$3.Base {
12368
12486
  this.wire.sendAction('platform-wrap-sync').catch((e) => {
12369
12487
  // don't expose
12370
12488
  });
12371
- return new Instance_1$1.Platform({ uuid: identity.uuid }, this._channel);
12489
+ return new Instance_1$1.Platform(this.wire, { uuid: identity.uuid });
12372
12490
  }
12373
12491
  /**
12374
12492
  * Asynchronously returns a Platform object that represents the current platform.
@@ -17575,6 +17693,10 @@ Object.defineProperty(baseEnv, "__esModule", { value: true });
17575
17693
  var BaseEnvironment_1 = baseEnv.BaseEnvironment = void 0;
17576
17694
  const overrideCheck_1 = requireOverrideCheck();
17577
17695
  class BaseEnvironment {
17696
+ async getViewWindowIdentity(fin, viewIdentity) {
17697
+ const { identity } = await fin.View.wrapSync(viewIdentity).getCurrentWindow();
17698
+ return identity;
17699
+ }
17578
17700
  async getInteropInfo(fin) {
17579
17701
  const appInfo = await fin.Application.getCurrentSync()
17580
17702
  .getInfo()
@@ -17638,7 +17760,7 @@ class NodeEnvironment extends BaseEnvironment_1 {
17638
17760
  };
17639
17761
  }
17640
17762
  getAdapterVersionSync() {
17641
- return "40.200.2";
17763
+ return "41.83.1";
17642
17764
  }
17643
17765
  observeBounds(element, onChange) {
17644
17766
  throw new Error('Method not implemented.');
@@ -18082,7 +18204,7 @@ async function loadConfig(config) {
18082
18204
  return await readLocalConfig(config.manifestUrl);
18083
18205
  }
18084
18206
  catch (error) {
18085
- throw new Error(`Could not locate JSON at supplied manifestUrl: ${config.manifestUrl}`);
18207
+ throw new Error(`Could not fetch and read local JSON at supplied manifestUrl: ${config.manifestUrl} Error caught: ${error.stack}`);
18086
18208
  }
18087
18209
  }
18088
18210
  }