@openfin/remote-adapter 40.200.2 → 41.83.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/out/remote-adapter.js +1471 -1349
  2. package/package.json +2 -2
@@ -49,7 +49,7 @@ async function promiseMapSerial(arr, func) {
49
49
  }
50
50
  promises.promiseMapSerial = promiseMapSerial;
51
51
 
52
- var __classPrivateFieldSet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
52
+ var __classPrivateFieldSet$d = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
53
53
  if (kind === "m") throw new TypeError("Private method is not writable");
54
54
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
55
55
  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");
@@ -178,7 +178,7 @@ class EmitterBase extends Base {
178
178
  // This will only be reached if unsubscribe from event that does not exist but do not want to error here
179
179
  return Promise.resolve();
180
180
  };
181
- __classPrivateFieldSet$c(this, _EmitterBase_emitterAccessor, [topic, ...additionalAccessors], "f");
181
+ __classPrivateFieldSet$d(this, _EmitterBase_emitterAccessor, [topic, ...additionalAccessors], "f");
182
182
  this.listeners = (event) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(event) : [];
183
183
  }
184
184
  /**
@@ -432,7 +432,7 @@ var utils$3 = {};
432
432
  exports.wrapIntentHandler = wrapIntentHandler;
433
433
  } (utils$3));
434
434
 
435
- var __classPrivateFieldSet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
435
+ var __classPrivateFieldSet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
436
436
  if (kind === "m") throw new TypeError("Private method is not writable");
437
437
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
438
438
  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");
@@ -452,7 +452,7 @@ class SessionContextGroupClient extends base_1$j.Base {
452
452
  super(wire);
453
453
  _SessionContextGroupClient_clientPromise.set(this, void 0);
454
454
  this.id = id;
455
- __classPrivateFieldSet$b(this, _SessionContextGroupClient_clientPromise, client, "f");
455
+ __classPrivateFieldSet$c(this, _SessionContextGroupClient_clientPromise, client, "f");
456
456
  }
457
457
  /**
458
458
  * Sets a context for the session context group.
@@ -4273,6 +4273,10 @@ Object.defineProperty(baseEnv, "__esModule", { value: true });
4273
4273
  baseEnv.BaseEnvironment = void 0;
4274
4274
  const overrideCheck_1 = requireOverrideCheck();
4275
4275
  class BaseEnvironment {
4276
+ async getViewWindowIdentity(fin, viewIdentity) {
4277
+ const { identity } = await fin.View.wrapSync(viewIdentity).getCurrentWindow();
4278
+ return identity;
4279
+ }
4276
4280
  async getInteropInfo(fin) {
4277
4281
  const appInfo = await fin.Application.getCurrentSync()
4278
4282
  .getInfo()
@@ -4862,902 +4866,238 @@ function requireFactory$2 () {
4862
4866
 
4863
4867
  var Instance$7 = {};
4864
4868
 
4865
- var layoutEntities = {};
4866
-
4867
- var apiExposer$1 = {};
4868
-
4869
- var apiConsumer = {};
4870
-
4871
- Object.defineProperty(apiConsumer, "__esModule", { value: true });
4872
- apiConsumer.ApiConsumer = void 0;
4873
- /**
4874
- * Consumer for apis exposed with {@see ApiExposer}.
4875
- *
4876
- * A strategy that matches the strategy used to expose a target API must be provided.
4877
- */
4878
- class ApiConsumer {
4879
- // eslint-disable-next-line
4880
- constructor(strategy) {
4881
- this.strategy = strategy;
4882
- /**
4883
- * Consumes an api exposed using a given transport strategy, and generates a client
4884
- * for easy, type safe consumption of that client.
4885
- * @param options Strategy specific consumption options.
4886
- * @returns An api client matching the given type.
4887
- */
4888
- this.consume = async (options) => {
4889
- const exposedProperties = await this.strategy.getExposedFunctions(options);
4890
- return exposedProperties.reduce((client, prop) => ({
4891
- ...client,
4892
- [prop.key]: this.strategy.createFunction(prop, options)
4893
- }), {});
4894
- };
4895
- }
4896
- }
4897
- apiConsumer.ApiConsumer = ApiConsumer;
4898
-
4899
- var apiExposer = {};
4900
-
4901
- var decorators = {};
4902
-
4903
- Object.defineProperty(decorators, "__esModule", { value: true });
4904
- decorators.expose = decorators.getExposedProperties = void 0;
4905
- const exposedProperties = Symbol('exposedProperties');
4906
- const getExposedProperties = (target) => {
4907
- return target[exposedProperties] || target.prototype[exposedProperties] || [];
4908
- };
4909
- decorators.getExposedProperties = getExposedProperties;
4910
- /**
4911
- * Indicates that a class member function can be exposed using {@link ApiExposer}.
4912
- * @param options Options specific to the strategy used in {@link ApiExposer}
4913
- */
4914
- // Returns any as decorator typing is weird.
4915
- const expose = (options) => (target, key, descriptor) => {
4916
- target[exposedProperties] = target[exposedProperties] || [];
4917
- target[exposedProperties].push({ key, descriptor, options });
4918
- };
4919
- decorators.expose = expose;
4869
+ var main = {};
4920
4870
 
4921
- Object.defineProperty(apiExposer, "__esModule", { value: true });
4922
- apiExposer.ApiExposer = void 0;
4923
- const decorators_1 = decorators;
4924
- /**
4925
- * Exposes api services on the transport of choice.
4926
- */
4927
- class ApiExposer {
4871
+ Object.defineProperty(main, "__esModule", { value: true });
4872
+ main.WebContents = void 0;
4873
+ const base_1$i = base;
4874
+ class WebContents extends base_1$i.EmitterBase {
4928
4875
  /**
4929
- * @param strategy The expose strategy to use to expose instances.
4876
+ * @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
4877
+ * @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
4930
4878
  */
4931
- // eslint-disable-next-line
4932
- constructor(strategy) {
4933
- this.strategy = strategy;
4934
- /**
4935
- * Exposes an instance of a given api on
4936
- * @param instance Instance of a class which has been decorated to indicate which functions can be exposed.
4937
- * @param instanceOptions Transport strategy specific options to use when exposing.
4938
- */
4939
- this.exposeInstance = async (instance, instanceOptions) => {
4940
- const exposableProps = (0, decorators_1.getExposedProperties)(instance);
4941
- const exposedProps = await Promise.all(exposableProps.map(async ({ key, options }) => {
4942
- const customConsumptionOptions = await this.strategy.exposeFunction(instance[key].bind(instance), {
4943
- key,
4944
- options,
4945
- meta: instanceOptions
4946
- });
4947
- return {
4948
- key,
4949
- options: customConsumptionOptions
4950
- };
4951
- }));
4952
- await this.strategy.exposeMeta(instanceOptions, exposedProps);
4953
- };
4879
+ constructor(wire, identity, entityType) {
4880
+ super(wire, entityType, identity.uuid, identity.name);
4881
+ this.identity = identity;
4882
+ this.entityType = entityType;
4954
4883
  }
4955
- ;
4956
- }
4957
- apiExposer.ApiExposer = ApiExposer;
4958
-
4959
- var strategies = {};
4960
-
4961
- var openfinChannels = {};
4962
-
4963
- var channelsConsumer = {};
4964
-
4965
- Object.defineProperty(channelsConsumer, "__esModule", { value: true });
4966
- channelsConsumer.ChannelsConsumer = void 0;
4967
- class ChannelsConsumer {
4968
- // eslint-disable-next-line
4969
- constructor(channel) {
4970
- this.channel = channel;
4971
- this.getExposedFunctions = async (options) => {
4972
- const { id } = options;
4973
- const { props } = await this.channel.dispatch(`api-meta:${id}`);
4974
- return props;
4975
- };
4976
- this.createFunction = (prop) => (...args) => {
4977
- const { action } = prop.options;
4978
- return this.channel.dispatch(action, { args });
4979
- };
4884
+ /**
4885
+ * Gets a base64 encoded image of all or part of the WebContents.
4886
+ * @param options Options for the capturePage call.
4887
+ *
4888
+ * @example
4889
+ *
4890
+ * View:
4891
+ * ```js
4892
+ * const view = fin.View.getCurrentSync();
4893
+ *
4894
+ * // PNG image of a full visible View
4895
+ * console.log(await view.capturePage());
4896
+ *
4897
+ * // Low-quality JPEG image of a defined visible area of the view
4898
+ * const options = {
4899
+ * area: {
4900
+ * height: 100,
4901
+ * width: 100,
4902
+ * x: 10,
4903
+ * y: 10,
4904
+ * },
4905
+ * format: 'jpg',
4906
+ * quality: 20
4907
+ * }
4908
+ * console.log(await view.capturePage(options));
4909
+ * ```
4910
+ *
4911
+ * Window:
4912
+ * ```js
4913
+ * const wnd = await fin.Window.getCurrent();
4914
+ *
4915
+ * // PNG image of a full visible window
4916
+ * console.log(await wnd.capturePage());
4917
+ *
4918
+ * // Low-quality JPEG image of a defined visible area of the window
4919
+ * const options = {
4920
+ * area: {
4921
+ * height: 100,
4922
+ * width: 100,
4923
+ * x: 10,
4924
+ * y: 10,
4925
+ * },
4926
+ * format: 'jpg',
4927
+ * quality: 20
4928
+ * }
4929
+ * console.log(await wnd.capturePage(options));
4930
+ * ```
4931
+ *
4932
+ * @remarks
4933
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
4934
+ * We do not expose an explicit superclass for this functionality, but it does have its own
4935
+ * {@link OpenFin.WebContentsEvents event namespace}.
4936
+ */
4937
+ capturePage(options) {
4938
+ return this.wire.sendAction('capture-page', { options, ...this.identity }).then(({ payload }) => payload.data);
4980
4939
  }
4981
- ;
4982
- }
4983
- channelsConsumer.ChannelsConsumer = ChannelsConsumer;
4984
-
4985
- var channelsExposer = {};
4986
-
4987
- Object.defineProperty(channelsExposer, "__esModule", { value: true });
4988
- channelsExposer.ChannelsExposer = void 0;
4989
- class ChannelsExposer {
4990
- // eslint-disable-next-line
4991
- constructor(channelProviderOrClient) {
4992
- this.channelProviderOrClient = channelProviderOrClient;
4993
- this.exposeFunction = async (target, config) => {
4994
- const { key, options, meta } = config;
4995
- const { id } = meta;
4996
- const action = `${id}.${options?.action || key}`;
4997
- await this.channelProviderOrClient.register(action, async ({ args }) => {
4998
- return target(...args);
4999
- });
5000
- return { action };
5001
- };
5002
- this.exposeMeta = async ({ id }, props) => {
5003
- const action = `api-meta:${id}`;
5004
- await this.channelProviderOrClient.register(action, () => ({ props }));
5005
- };
4940
+ /**
4941
+ * Executes Javascript on the WebContents, restricted to contents you own or contents owned by
4942
+ * applications you have created.
4943
+ * @param code JavaScript code to be executed on the view.
4944
+ *
4945
+ * @example
4946
+ * View:
4947
+ * ```js
4948
+ * async function executeJavaScript(code) {
4949
+ * const view = await fin.View.wrap({uuid: 'uuid', name: 'view name'});
4950
+ * return await view.executeJavaScript(code);
4951
+ * }
4952
+ *
4953
+ * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
4954
+ * ```
4955
+ *
4956
+ * Window:
4957
+ * ```js
4958
+ * async function executeJavaScript(code) {
4959
+ * const app = await fin.Application.start({
4960
+ * name: 'myApp',
4961
+ * uuid: 'app-1',
4962
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.executeJavaScript.html',
4963
+ * autoShow: true
4964
+ * });
4965
+ * const win = await app.getWindow();
4966
+ * return await win.executeJavaScript(code);
4967
+ * }
4968
+ *
4969
+ * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
4970
+ * ```
4971
+ * @remarks
4972
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
4973
+ * We do not expose an explicit superclass for this functionality, but it does have its own
4974
+ * {@link OpenFin.WebContentsEvents event namespace}.
4975
+ */
4976
+ executeJavaScript(code) {
4977
+ return this.wire
4978
+ .sendAction('execute-javascript-in-window', { ...this.identity, code })
4979
+ .then(({ payload }) => payload.data);
5006
4980
  }
5007
- }
5008
- channelsExposer.ChannelsExposer = ChannelsExposer;
5009
-
5010
- (function (exports) {
5011
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5012
- if (k2 === undefined) k2 = k;
5013
- var desc = Object.getOwnPropertyDescriptor(m, k);
5014
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5015
- desc = { enumerable: true, get: function() { return m[k]; } };
5016
- }
5017
- Object.defineProperty(o, k2, desc);
5018
- }) : (function(o, m, k, k2) {
5019
- if (k2 === undefined) k2 = k;
5020
- o[k2] = m[k];
5021
- }));
5022
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
5023
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
5024
- };
5025
- Object.defineProperty(exports, "__esModule", { value: true });
5026
- __exportStar(channelsConsumer, exports);
5027
- __exportStar(channelsExposer, exports);
5028
- } (openfinChannels));
5029
-
5030
- (function (exports) {
5031
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5032
- if (k2 === undefined) k2 = k;
5033
- var desc = Object.getOwnPropertyDescriptor(m, k);
5034
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5035
- desc = { enumerable: true, get: function() { return m[k]; } };
5036
- }
5037
- Object.defineProperty(o, k2, desc);
5038
- }) : (function(o, m, k, k2) {
5039
- if (k2 === undefined) k2 = k;
5040
- o[k2] = m[k];
5041
- }));
5042
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
5043
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
5044
- };
5045
- Object.defineProperty(exports, "__esModule", { value: true });
5046
- __exportStar(openfinChannels, exports);
5047
- } (strategies));
5048
-
5049
- (function (exports) {
5050
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5051
- if (k2 === undefined) k2 = k;
5052
- var desc = Object.getOwnPropertyDescriptor(m, k);
5053
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5054
- desc = { enumerable: true, get: function() { return m[k]; } };
5055
- }
5056
- Object.defineProperty(o, k2, desc);
5057
- }) : (function(o, m, k, k2) {
5058
- if (k2 === undefined) k2 = k;
5059
- o[k2] = m[k];
5060
- }));
5061
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
5062
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
5063
- };
5064
- Object.defineProperty(exports, "__esModule", { value: true });
5065
- __exportStar(apiConsumer, exports);
5066
- __exportStar(apiExposer, exports);
5067
- __exportStar(strategies, exports);
5068
- __exportStar(decorators, exports);
5069
- } (apiExposer$1));
5070
-
5071
- var channelApiRelay = {};
5072
-
5073
- Object.defineProperty(channelApiRelay, "__esModule", { value: true });
5074
- channelApiRelay.createRelayedDispatch = channelApiRelay.relayChannelClientApi = void 0;
5075
- const EXPECTED_ERRORS = [
5076
- 'no longer connected',
5077
- 'RTCDataChannel closed unexpectedly',
5078
- 'The client you are trying to dispatch from is disconnected from the target provider',
5079
- ];
5080
- // Checks possible error messages that we want to trap, client error message can originate
5081
- // from ChannelProvider::dispatch OR ClassicStrategy::closeEndpoint OR RTCEndPoint::dataChannel::onclose
5082
- const isDisconnectedError = (errorMsg) => {
5083
- return EXPECTED_ERRORS.some(e => errorMsg.includes(e));
5084
- };
5085
- /**
5086
- * @internal
5087
- * Create a channel relay for a given channel exposition, allowing a single provider to route
5088
- * actions to the designated clients.
5089
- *
5090
- * Designed to be used in conjunction with @expose
5091
- *
5092
- * @param channelProvider The channel provider to relay the actions on.
5093
- * @param config Determines which actions to relay. Please ensure action prefix matches the exposed api.
5094
- */
5095
- const relayChannelClientApi = async (channelProvider, relayId) => {
5096
- channelProvider.register(`relay:${relayId}`, ({ action, target, payload }) => {
5097
- return channelProvider.dispatch(target, action, payload);
5098
- });
5099
- await Promise.resolve();
5100
- };
5101
- channelApiRelay.relayChannelClientApi = relayChannelClientApi;
5102
- const createRelayedDispatch = (client, target, relayId, relayErrorMsg) => async (action, payload) => {
5103
- try {
5104
- return await client.dispatch(`relay:${relayId}`, {
5105
- action,
5106
- payload,
5107
- target
5108
- });
4981
+ /**
4982
+ * Returns the zoom level of the WebContents.
4983
+ *
4984
+ * @example
4985
+ * View:
4986
+ * ```js
4987
+ * async function getZoomLevel() {
4988
+ * const view = await fin.View.getCurrent();
4989
+ * return await view.getZoomLevel();
4990
+ * }
4991
+ *
4992
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
4993
+ * ```
4994
+ *
4995
+ * Window:
4996
+ * ```js
4997
+ * async function createWin() {
4998
+ * const app = await fin.Application.start({
4999
+ * name: 'myApp',
5000
+ * uuid: 'app-1',
5001
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getZoomLevel.html',
5002
+ * autoShow: true
5003
+ * });
5004
+ * return await app.getWindow();
5005
+ * }
5006
+ *
5007
+ * async function getZoomLevel() {
5008
+ * const win = await createWin();
5009
+ * return await win.getZoomLevel();
5010
+ * }
5011
+ *
5012
+ * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
5013
+ * ```
5014
+ * @remarks
5015
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5016
+ * We do not expose an explicit superclass for this functionality, but it does have its own
5017
+ * {@link OpenFin.WebContentsEvents event namespace}.
5018
+ */
5019
+ getZoomLevel() {
5020
+ return this.wire.sendAction('get-zoom-level', this.identity).then(({ payload }) => payload.data);
5109
5021
  }
5110
- catch (e) {
5111
- if (isDisconnectedError(e.message) && relayErrorMsg) {
5112
- throw new Error(relayErrorMsg);
5113
- }
5114
- throw e;
5022
+ /**
5023
+ * Sets the zoom level of the WebContents.
5024
+ * @param level The zoom level
5025
+ *
5026
+ * @example
5027
+ * View:
5028
+ * ```js
5029
+ * async function setZoomLevel(number) {
5030
+ * const view = await fin.View.getCurrent();
5031
+ * return await view.setZoomLevel(number);
5032
+ * }
5033
+ *
5034
+ * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
5035
+ * ```
5036
+ *
5037
+ * Window:
5038
+ * ```js
5039
+ * async function createWin() {
5040
+ * const app = await fin.Application.start({
5041
+ * name: 'myApp',
5042
+ * uuid: 'app-1',
5043
+ * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.setZoomLevel.html',
5044
+ * autoShow: true
5045
+ * });
5046
+ * return await app.getWindow();
5047
+ * }
5048
+ *
5049
+ * async function setZoomLevel(number) {
5050
+ * const win = await createWin();
5051
+ * return await win.setZoomLevel(number);
5052
+ * }
5053
+ *
5054
+ * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
5055
+ * ```
5056
+ * @remarks
5057
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5058
+ * We do not expose an explicit superclass for this functionality, but it does have its own
5059
+ * {@link OpenFin.WebContentsEvents event namespace}.
5060
+ */
5061
+ setZoomLevel(level) {
5062
+ return this.wire.sendAction('set-zoom-level', { ...this.identity, level }).then(() => undefined);
5115
5063
  }
5116
- };
5117
- channelApiRelay.createRelayedDispatch = createRelayedDispatch;
5118
-
5119
- var __classPrivateFieldSet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
5120
- if (kind === "m") throw new TypeError("Private method is not writable");
5121
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5122
- 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");
5123
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
5124
- };
5125
- var __classPrivateFieldGet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
5126
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
5127
- 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");
5128
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5129
- };
5130
- var _LayoutNode_client, _TabStack_client, _ColumnOrRow_client;
5131
- Object.defineProperty(layoutEntities, "__esModule", { value: true });
5132
- layoutEntities.ColumnOrRow = layoutEntities.TabStack = layoutEntities.LayoutNode = void 0;
5133
- const api_exposer_1 = apiExposer$1;
5134
- const channel_api_relay_1 = channelApiRelay;
5135
- /*
5136
- This file includes LayoutNode, ColumnOrRow and TabStack classes, which are all closely
5137
- intertwined, and share members via parent abstract class LayoutNode. To prevent circular
5138
- refs, we define and export all the classes here.
5139
- */
5140
- /**
5141
- * @ignore
5142
- * @internal
5143
- * Supplies an ApiClient for {@link LayoutEntitiesController} and helper methods
5144
- * for the entities {@link TabStack} AND {@link ColumnOrRow} to use.
5145
- */
5146
- class LayoutNode {
5147
5064
  /**
5148
- * @internal
5149
- * @ignore
5150
- */
5151
- constructor(client, entityId) {
5152
- /**
5153
- * @ignore
5154
- * @internal
5155
- * ApiClient for {@link LayoutEntitiesController}
5156
- */
5157
- _LayoutNode_client.set(this, void 0);
5158
- /**
5159
- * Checks if the TabStack or ColumnOrRow is the root content item
5160
- *
5161
- * @example
5162
- * ```js
5163
- * if (!fin.me.isView) {
5164
- * throw new Error('Not running in a platform View.');
5165
- * }
5166
- *
5167
- * const stack = await fin.me.getCurrentStack();
5168
- * const isRoot = await stack.isRoot();
5169
- * // The TabStack is root: false
5170
- * console.log(`The TabStack is root: ${isRoot}`);
5171
- *
5172
- * // Retrieves the parent ColumnOrRow
5173
- * const parent = await stack.getParent();
5174
- * const parentIsRoot = await parent.isRoot();
5175
- * // The parent ColumnOrRow is root: true
5176
- * console.log(`The parent ColumnOrRow is root: ${parentIsRoot}`);
5177
- * ```
5178
- */
5179
- this.isRoot = () => __classPrivateFieldGet$c(this, _LayoutNode_client, "f").isRoot(this.entityId);
5180
- /**
5181
- * Checks if the TabStack or ColumnOrRow exists
5182
- *
5183
- * @example
5184
- * ```js
5185
- * if (!fin.me.isView) {
5186
- * throw new Error('Not running in a platform View.');
5187
- * }
5188
- *
5189
- * const stack = await fin.me.getCurrentStack();
5190
- * // Retrieves the parent ColumnOrRow
5191
- * const columnOrRow = await stack.getParent();
5192
- * let exists = await stack.exists();
5193
- * // or
5194
- * let exists = await columnOrRow.exists();
5195
- * // The entity exists: true
5196
- * console.log(`The entity exists: ${exists}`);
5197
- * ```
5198
- */
5199
- this.exists = () => __classPrivateFieldGet$c(this, _LayoutNode_client, "f").exists(this.entityId);
5200
- /**
5201
- * Retrieves the parent of the TabStack or ColumnOrRow
5202
- *
5203
- * @example
5204
- * ```js
5205
- * if (!fin.me.isView) {
5206
- * throw new Error('Not running in a platform View.');
5207
- * }
5208
- *
5209
- * const stack = await fin.me.getCurrentStack();
5210
- * // Retrieves the parent ColumnOrRow
5211
- * const columnOrRow = await stack.getParent();
5212
- *
5213
- * // undefined if entity is the root item
5214
- * let parent = await columnOrRow.getParent();
5215
- * // or
5216
- * let parent = await stack.getParent();
5217
- * ```
5218
- */
5219
- this.getParent = async () => {
5220
- const parent = await __classPrivateFieldGet$c(this, _LayoutNode_client, "f").getParent(this.entityId);
5221
- if (!parent) {
5222
- return undefined;
5223
- }
5224
- return LayoutNode.getEntity(parent, __classPrivateFieldGet$c(this, _LayoutNode_client, "f"));
5225
- };
5226
- /**
5227
- * Creates a new TabStack adjacent to the given TabStack or ColumnOrRow. Inputs can be new views to create, or existing views.
5228
- *
5229
- * Known Issue: If the number of views to add overflows the tab-container, the added views will be set as active
5230
- * during each render, and then placed at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
5231
- * This means the views you pass to createAdjacentStack() may not render in the order given by the array.
5232
- * Until fixed, this problem can be avoided only if your window is wide enough to fit creating all the views in the tabstack.
5233
- *
5234
- * @param views The views that will populate the new TabStack.
5235
- * @param options Additional options that control new TabStack creation.
5236
- * @returns The newly-created TabStack.
5237
- *
5238
- * @example
5239
- * ```js
5240
- * if (!fin.me.isView) {
5241
- * throw new Error('Not running in a platform View.');
5242
- * }
5243
- *
5244
- * const stack = await fin.me.getCurrentStack();
5245
- * const columnOrRow = await stack.getParent();
5246
- *
5247
- * // Create view references by supplying a 'name' and 'url'
5248
- * const views = [
5249
- * // if 'name' is undefined, one will be generated
5250
- * // if 'url' is undefined, it will default the view URL to 'about:blank'
5251
- * { name: 'google-view', url: 'http://google.com/'},
5252
- * { name: 'of-developers-view', url: 'http://developers.openfin.co/'},
5253
- * ];
5254
- *
5255
- * // Create a view beforehand to be included in the new tab stack
5256
- * const outsideView = await fin.View.create({
5257
- * name: 'outside-bloomberg-view',
5258
- * url: 'https://bloomberg.com/',
5259
- * target: fin.me.identity,
5260
- * });
5261
- *
5262
- * // Views to add can be identities, or the reference views mentioned above
5263
- * const viewsToAdd = [outsideView.identity, ...views];
5264
- *
5265
- * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
5266
- * let stackFrom = await columnOrRow.createAdjacentStack(viewsToAdd, { position: 'right' });
5267
- * // Or
5268
- * let newStack = await stack.createAdjacentStack(viewsToAdd, { position: 'right' });
5269
- * console.log(`A new TabStack created to the right has ${newStack.length} views in it`);
5270
- *
5271
- * ```
5272
- * @experimental
5273
- */
5274
- this.createAdjacentStack = async (views, options) => {
5275
- const entityId = await __classPrivateFieldGet$c(this, _LayoutNode_client, "f").createAdjacentStack(this.entityId, views, options);
5276
- return LayoutNode.getEntity({ entityId, type: 'stack' }, __classPrivateFieldGet$c(this, _LayoutNode_client, "f"));
5277
- };
5278
- /**
5279
- * Retrieves the adjacent TabStacks of the given TabStack or ColumnOrRow.
5280
- *
5281
- * @param edge Edge whose adjacent TabStacks will be returned.
5282
- *
5283
- * @example
5284
- * ```js
5285
- * if (!fin.me.isView) {
5286
- * throw new Error('Not running in a platform View.');
5287
- * }
5288
- *
5289
- * const stack = await fin.me.getCurrentStack();
5290
- * const columnOrRow = await stack.getParent();
5291
- * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
5292
- * let rightStacks = await columnOrRow.getAdjacentStacks('right');
5293
- * let leftStacks = await columnOrRow.getAdjacentStacks('left');
5294
- * // or
5295
- * let rightStacks = await stack.getAdjacentStacks('right');
5296
- * let leftStacks = await stack.getAdjacentStacks('left');
5297
- *
5298
- * console.log(`The entity has ${rightStacks.length} stacks to the right, and ${leftStacks.length} stacks to the left`);
5299
- *
5300
- * ```
5301
- * @experimental
5302
- */
5303
- this.getAdjacentStacks = async (edge) => {
5304
- const adjacentStacks = await __classPrivateFieldGet$c(this, _LayoutNode_client, "f").getAdjacentStacks({
5305
- targetId: this.entityId,
5306
- edge
5307
- });
5308
- return adjacentStacks.map((stack) => LayoutNode.getEntity({
5309
- type: 'stack',
5310
- entityId: stack.entityId
5311
- }, __classPrivateFieldGet$c(this, _LayoutNode_client, "f")));
5312
- };
5313
- __classPrivateFieldSet$a(this, _LayoutNode_client, client, "f");
5314
- this.entityId = entityId;
5315
- }
5316
- }
5317
- layoutEntities.LayoutNode = LayoutNode;
5318
- _LayoutNode_client = new WeakMap();
5319
- /**
5320
- * @ignore
5321
- * @internal
5322
- * Encapsulates Api consumption of {@link LayoutEntitiesClient} with a relayed dispatch
5323
- * @param client
5324
- * @param controllerId
5325
- * @param identity
5326
- * @returns a new instance of {@link LayoutEntitiesClient} with bound to the controllerId
5327
- */
5328
- LayoutNode.newLayoutEntitiesClient = async (client, controllerId, identity) => {
5329
- 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.');
5330
- const consumer = new api_exposer_1.ApiConsumer(new api_exposer_1.ChannelsConsumer({ dispatch }));
5331
- return consumer.consume({ id: controllerId });
5332
- };
5333
- LayoutNode.getEntity = (definition, client) => {
5334
- const { entityId, type } = definition;
5335
- switch (type) {
5336
- case 'column':
5337
- case 'row':
5338
- return new ColumnOrRow(client, entityId, type);
5339
- case 'stack':
5340
- return new TabStack(client, entityId);
5341
- default:
5342
- throw new Error(`Unrecognised Layout Entity encountered ('${JSON.stringify(definition)})`);
5343
- }
5344
- };
5345
- /**
5346
- * A TabStack is used to manage the state of a stack of tabs within an OpenFin Layout.
5347
- */
5348
- class TabStack extends LayoutNode {
5349
- /** @internal */
5350
- constructor(client, entityId) {
5351
- super(client, entityId);
5352
- /**
5353
- * @internal
5354
- * ApiClient for {@link LayoutEntitiesController}
5355
- */
5356
- _TabStack_client.set(this, void 0);
5357
- /**
5358
- * Type of the content item. Always stack, but useful for distinguishing between a {@link TabStack} and {@link ColumnOrRow}.
5359
- */
5360
- this.type = 'stack';
5361
- /**
5362
- * Retrieves a list of all views belonging to this {@link TabStack}.
5363
- *
5364
- * Known Issue: If adding a view overflows the tab-container width, the added view will be set as active
5365
- * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
5366
- * If that happens and then getViews() is called, it will return the identities in a different order than
5367
- * than the currently rendered tab order.
5368
- *
5369
- *
5370
- * @throws If the {@link TabStack} has been destroyed.
5371
- * @example
5372
- * ```js
5373
- * if (!fin.me.isView) {
5374
- * throw new Error('Not running in a platform View.');
5375
- * }
5376
- *
5377
- * const stack = await fin.me.getCurrentStack();
5378
- * // Alternatively, you can wrap any view and get the stack from there
5379
- * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
5380
- * // const stack = await viewFromSomewhere.getCurrentStack();
5381
- * const views = await stack.getViews();
5382
- * console.log(`Stack contains ${views.length} view(s)`);
5383
- * ```
5384
- * @experimental
5385
- */
5386
- this.getViews = () => __classPrivateFieldGet$c(this, _TabStack_client, "f").getStackViews(this.entityId);
5387
- /**
5388
- * Adds or creates a view in this {@link TabStack}.
5389
- *
5390
- * @remarks Known Issue: If adding a view overflows the tab-container, the added view will be set as active
5391
- * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
5392
- *
5393
- * @param view The identity of an existing view to add, or options to create a view.
5394
- * @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)
5395
- * @returns Resolves with the {@link OpenFin.Identity identity} of the added view.
5396
- * @throws If the view does not exist or fails to create.
5397
- * @throws If the {@link TabStack} has been destroyed.
5398
- * @example
5399
- * ```js
5400
- * if (!fin.me.isView) {
5401
- * throw new Error('Not running in a platform View.');
5402
- * }
5403
- *
5404
- * const stack = await fin.me.getCurrentStack();
5405
- * // Alternatively, you can wrap any view and get the stack from there
5406
- * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
5407
- * // const stack = await viewFromSomewhere.getCurrentStack();
5408
- * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
5409
- * console.log('Identity of the google view just added', { googleViewIdentity });
5410
- * // pass in { index: number } to set the index in the stack. Here 1 means, end of the stack (defaults to 0)
5411
- * const appleViewIdentity = await stack.addView({ name: 'apple-view', url: 'http://apple.com/' }, { index: 1 });
5412
- * console.log('Identity of the apple view just added', { appleViewIdentity });
5413
- * ```
5414
- * @experimental
5415
- */
5416
- this.addView = async (view, options = { index: 0 }) => __classPrivateFieldGet$c(this, _TabStack_client, "f").addViewToStack(this.entityId, view, options);
5417
- /**
5418
- * Removes a view from this {@link TabStack}.
5419
- *
5420
- * @remarks Throws an exception if the view identity does not exist or was already destroyed.
5421
- *
5422
- * @param view - Identity of the view to remove.
5423
- * @throws If the view does not exist or does not belong to the stack.
5424
- * @throws If the {@link TabStack} has been destroyed.
5425
- *
5426
- * @example
5427
- * ```js
5428
- * if (!fin.me.isView) {
5429
- * throw new Error('Not running in a platform View.');
5430
- * }
5431
- *
5432
- * const stack = await fin.me.getCurrentStack();
5433
- * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
5434
- *
5435
- * await stack.removeView(googleViewIdentity);
5436
- *
5437
- * try {
5438
- * await stack.removeView(googleViewIdentity);
5439
- * } catch (error) {
5440
- * // Tried to remove a view ('google-view') which does not belong to the stack.
5441
- * console.log(error);
5442
- * }
5443
- * ```
5444
- */
5445
- this.removeView = async (view) => {
5446
- await __classPrivateFieldGet$c(this, _TabStack_client, "f").removeViewFromStack(this.entityId, view);
5447
- };
5448
- /**
5449
- * Sets the active view of the {@link TabStack} without focusing it.
5450
- * @param view - Identity of the view to activate.
5451
- * @returns Promise which resolves with void once the view has been activated.
5452
- * @throws If the {@link TabStack} has been destroyed.
5453
- * @throws If the view does not exist.
5454
- * @example
5455
- * Change the active tab of a known View's TabStack:
5456
- * ```js
5457
- * const targetView = fin.View.wrapSync({ uuid: 'uuid', name: 'view-name' });
5458
- * const stack = await targetView.getCurrentStack();
5459
- * await stack.setActiveView(targetView.identity);
5460
- * ```
5461
- *
5462
- * Set the current View as active within its TabStack:
5463
- * ```js
5464
- * const stack = await fin.me.getCurrentStack();
5465
- * await stack.setActiveView(fin.me.identity);
5466
- * ```
5467
- * @experimental
5468
- */
5469
- this.setActiveView = async (view) => {
5470
- await __classPrivateFieldGet$c(this, _TabStack_client, "f").setStackActiveView(this.entityId, view);
5471
- };
5472
- __classPrivateFieldSet$a(this, _TabStack_client, client, "f");
5473
- }
5474
- }
5475
- layoutEntities.TabStack = TabStack;
5476
- _TabStack_client = new WeakMap();
5477
- /**
5478
- * A ColumnOrRow is used to manage the state of Column and Rows within an OpenFin Layout.
5479
- */
5480
- class ColumnOrRow extends LayoutNode {
5481
- /**
5482
- * @internal
5483
- */
5484
- constructor(client, entityId, type) {
5485
- super(client, entityId);
5486
- /**
5487
- * @ignore
5488
- * @internal
5489
- * ApiClient for {@link LayoutEntitiesController}
5490
- */
5491
- _ColumnOrRow_client.set(this, void 0);
5492
- /**
5493
- * Retrieves the content array of the ColumnOrRow
5494
- *
5495
- * @example
5496
- * ```js
5497
- * if (!fin.me.isView) {
5498
- * throw new Error('Not running in a platform View.');
5499
- * }
5500
- *
5501
- * const stack = await fin.me.getCurrentStack();
5502
- * // Retrieves the parent ColumnOrRow
5503
- * const columnOrRow = await stack.getParent();
5504
- *
5505
- * // returns [TabStack]
5506
- * const contentArray = await columnOrRow.getContent();
5507
- * console.log(`The ColumnOrRow has ${contentArray.length} item(s)`);
5508
- * ```
5509
- */
5510
- this.getContent = async () => {
5511
- const contentItemEntities = await __classPrivateFieldGet$c(this, _ColumnOrRow_client, "f").getContent(this.entityId);
5512
- return contentItemEntities.map((entity) => LayoutNode.getEntity(entity, __classPrivateFieldGet$c(this, _ColumnOrRow_client, "f")));
5513
- };
5514
- __classPrivateFieldSet$a(this, _ColumnOrRow_client, client, "f");
5515
- this.type = type;
5516
- }
5517
- }
5518
- layoutEntities.ColumnOrRow = ColumnOrRow;
5519
- _ColumnOrRow_client = new WeakMap();
5520
-
5521
- var layout_constants = {};
5522
-
5523
- Object.defineProperty(layout_constants, "__esModule", { value: true });
5524
- layout_constants.DEFAULT_LAYOUT_KEY = layout_constants.LAYOUT_CONTROLLER_ID = void 0;
5525
- layout_constants.LAYOUT_CONTROLLER_ID = 'layout-entities';
5526
- // TODO: eventually export this somehow
5527
- layout_constants.DEFAULT_LAYOUT_KEY = '__default__';
5528
-
5529
- var main = {};
5530
-
5531
- Object.defineProperty(main, "__esModule", { value: true });
5532
- main.WebContents = void 0;
5533
- const base_1$i = base;
5534
- class WebContents extends base_1$i.EmitterBase {
5535
- /**
5536
- * @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
5537
- * @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
5538
- */
5539
- constructor(wire, identity, entityType) {
5540
- super(wire, entityType, identity.uuid, identity.name);
5541
- this.identity = identity;
5542
- this.entityType = entityType;
5543
- }
5544
- /**
5545
- * Gets a base64 encoded image of all or part of the WebContents.
5546
- * @param options Options for the capturePage call.
5547
- *
5548
- * @example
5549
- *
5550
- * View:
5551
- * ```js
5552
- * const view = fin.View.getCurrentSync();
5553
- *
5554
- * // PNG image of a full visible View
5555
- * console.log(await view.capturePage());
5556
- *
5557
- * // Low-quality JPEG image of a defined visible area of the view
5558
- * const options = {
5559
- * area: {
5560
- * height: 100,
5561
- * width: 100,
5562
- * x: 10,
5563
- * y: 10,
5564
- * },
5565
- * format: 'jpg',
5566
- * quality: 20
5567
- * }
5568
- * console.log(await view.capturePage(options));
5569
- * ```
5570
- *
5571
- * Window:
5572
- * ```js
5573
- * const wnd = await fin.Window.getCurrent();
5574
- *
5575
- * // PNG image of a full visible window
5576
- * console.log(await wnd.capturePage());
5577
- *
5578
- * // Low-quality JPEG image of a defined visible area of the window
5579
- * const options = {
5580
- * area: {
5581
- * height: 100,
5582
- * width: 100,
5583
- * x: 10,
5584
- * y: 10,
5585
- * },
5586
- * format: 'jpg',
5587
- * quality: 20
5588
- * }
5589
- * console.log(await wnd.capturePage(options));
5590
- * ```
5591
- *
5592
- * @remarks
5593
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5594
- * We do not expose an explicit superclass for this functionality, but it does have its own
5595
- * {@link OpenFin.WebContentsEvents event namespace}.
5596
- */
5597
- capturePage(options) {
5598
- return this.wire.sendAction('capture-page', { options, ...this.identity }).then(({ payload }) => payload.data);
5599
- }
5600
- /**
5601
- * Executes Javascript on the WebContents, restricted to contents you own or contents owned by
5602
- * applications you have created.
5603
- * @param code JavaScript code to be executed on the view.
5604
- *
5605
- * @example
5606
- * View:
5607
- * ```js
5608
- * async function executeJavaScript(code) {
5609
- * const view = await fin.View.wrap({uuid: 'uuid', name: 'view name'});
5610
- * return await view.executeJavaScript(code);
5611
- * }
5612
- *
5613
- * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
5614
- * ```
5615
- *
5616
- * Window:
5617
- * ```js
5618
- * async function executeJavaScript(code) {
5619
- * const app = await fin.Application.start({
5620
- * name: 'myApp',
5621
- * uuid: 'app-1',
5622
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.executeJavaScript.html',
5623
- * autoShow: true
5624
- * });
5625
- * const win = await app.getWindow();
5626
- * return await win.executeJavaScript(code);
5627
- * }
5628
- *
5629
- * executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
5630
- * ```
5631
- * @remarks
5632
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5633
- * We do not expose an explicit superclass for this functionality, but it does have its own
5634
- * {@link OpenFin.WebContentsEvents event namespace}.
5635
- */
5636
- executeJavaScript(code) {
5637
- return this.wire
5638
- .sendAction('execute-javascript-in-window', { ...this.identity, code })
5639
- .then(({ payload }) => payload.data);
5640
- }
5641
- /**
5642
- * Returns the zoom level of the WebContents.
5643
- *
5644
- * @example
5645
- * View:
5646
- * ```js
5647
- * async function getZoomLevel() {
5648
- * const view = await fin.View.getCurrent();
5649
- * return await view.getZoomLevel();
5650
- * }
5651
- *
5652
- * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
5653
- * ```
5654
- *
5655
- * Window:
5656
- * ```js
5657
- * async function createWin() {
5658
- * const app = await fin.Application.start({
5659
- * name: 'myApp',
5660
- * uuid: 'app-1',
5661
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.getZoomLevel.html',
5662
- * autoShow: true
5663
- * });
5664
- * return await app.getWindow();
5665
- * }
5666
- *
5667
- * async function getZoomLevel() {
5668
- * const win = await createWin();
5669
- * return await win.getZoomLevel();
5670
- * }
5671
- *
5672
- * getZoomLevel().then(zoomLevel => console.log(zoomLevel)).catch(err => console.log(err));
5673
- * ```
5674
- * @remarks
5675
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5676
- * We do not expose an explicit superclass for this functionality, but it does have its own
5677
- * {@link OpenFin.WebContentsEvents event namespace}.
5678
- */
5679
- getZoomLevel() {
5680
- return this.wire.sendAction('get-zoom-level', this.identity).then(({ payload }) => payload.data);
5681
- }
5682
- /**
5683
- * Sets the zoom level of the WebContents.
5684
- * @param level The zoom level
5685
- *
5686
- * @example
5687
- * View:
5688
- * ```js
5689
- * async function setZoomLevel(number) {
5690
- * const view = await fin.View.getCurrent();
5691
- * return await view.setZoomLevel(number);
5692
- * }
5693
- *
5694
- * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
5695
- * ```
5696
- *
5697
- * Window:
5698
- * ```js
5699
- * async function createWin() {
5700
- * const app = await fin.Application.start({
5701
- * name: 'myApp',
5702
- * uuid: 'app-1',
5703
- * url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.setZoomLevel.html',
5704
- * autoShow: true
5705
- * });
5706
- * return await app.getWindow();
5707
- * }
5708
- *
5709
- * async function setZoomLevel(number) {
5710
- * const win = await createWin();
5711
- * return await win.setZoomLevel(number);
5712
- * }
5713
- *
5714
- * setZoomLevel(4).then(() => console.log('Setting a zoom level')).catch(err => console.log(err));
5715
- * ```
5716
- * @remarks
5717
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5718
- * We do not expose an explicit superclass for this functionality, but it does have its own
5719
- * {@link OpenFin.WebContentsEvents event namespace}.
5720
- */
5721
- setZoomLevel(level) {
5722
- return this.wire.sendAction('set-zoom-level', { ...this.identity, level }).then(() => undefined);
5723
- }
5724
- /**
5725
- * Navigates the WebContents to a specified URL.
5726
- *
5727
- * Note: The url must contain the protocol prefix such as http:// or https://.
5728
- * @param url - The URL to navigate the WebContents to.
5729
- *
5730
- * @example
5731
- * View:
5732
- * ```js
5733
- * async function createView() {
5734
- * const me = await fin.Window.getCurrent();
5735
- * return fin.View.create({
5736
- * name: 'viewName',
5737
- * target: me.identity,
5738
- * bounds: {top: 10, left: 10, width: 200, height: 200}
5739
- * });
5740
- * }
5741
- *
5742
- * createView()
5743
- * .then(view => view.navigate('https://example.com'))
5744
- * .then(() => console.log('navigation complete'))
5745
- * .catch(err => console.log(err));
5746
- * ```
5747
- *
5748
- * Window:
5749
- * ```js
5750
- * async function navigate() {
5751
- * const win = await fin.Window.getCurrent();
5752
- * return await win.navigate('https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.navigate.html');
5753
- * }
5754
- * navigate().then(() => console.log('Navigate to tutorial')).catch(err => console.log(err));
5755
- * ```
5756
- * @experimental
5757
- * @remarks
5758
- * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5759
- * We do not expose an explicit superclass for this functionality, but it does have its own
5760
- * {@link OpenFin.WebContentsEvents event namespace}.
5065
+ * Navigates the WebContents to a specified URL.
5066
+ *
5067
+ * Note: The url must contain the protocol prefix such as http:// or https://.
5068
+ * @param url - The URL to navigate the WebContents to.
5069
+ *
5070
+ * @example
5071
+ * View:
5072
+ * ```js
5073
+ * async function createView() {
5074
+ * const me = await fin.Window.getCurrent();
5075
+ * return fin.View.create({
5076
+ * name: 'viewName',
5077
+ * target: me.identity,
5078
+ * bounds: {top: 10, left: 10, width: 200, height: 200}
5079
+ * });
5080
+ * }
5081
+ *
5082
+ * createView()
5083
+ * .then(view => view.navigate('https://example.com'))
5084
+ * .then(() => console.log('navigation complete'))
5085
+ * .catch(err => console.log(err));
5086
+ * ```
5087
+ *
5088
+ * Window:
5089
+ * ```js
5090
+ * async function navigate() {
5091
+ * const win = await fin.Window.getCurrent();
5092
+ * return await win.navigate('https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.navigate.html');
5093
+ * }
5094
+ * navigate().then(() => console.log('Navigate to tutorial')).catch(err => console.log(err));
5095
+ * ```
5096
+ * @experimental
5097
+ * @remarks
5098
+ * `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
5099
+ * We do not expose an explicit superclass for this functionality, but it does have its own
5100
+ * {@link OpenFin.WebContentsEvents event namespace}.
5761
5101
  */
5762
5102
  navigate(url) {
5763
5103
  return this.wire.sendAction('navigate-window', { ...this.identity, url }).then(() => undefined);
@@ -9229,18 +8569,11 @@ var hasRequiredInstance;
9229
8569
  function requireInstance () {
9230
8570
  if (hasRequiredInstance) return Instance$7;
9231
8571
  hasRequiredInstance = 1;
9232
- var __classPrivateFieldGet = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9233
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9234
- 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");
9235
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
9236
- };
9237
8572
  var _View_providerChannelClient;
9238
8573
  Object.defineProperty(Instance$7, "__esModule", { value: true });
9239
8574
  Instance$7.View = void 0;
9240
8575
  const transport_errors_1 = transportErrors;
9241
8576
  const lazy_1 = lazy;
9242
- const layout_entities_1 = layoutEntities;
9243
- const layout_constants_1 = layout_constants;
9244
8577
  const main_1 = main;
9245
8578
  const window_1 = requireWindow();
9246
8579
  /**
@@ -9558,7 +8891,7 @@ function requireInstance () {
9558
8891
  return ack.payload.data;
9559
8892
  };
9560
8893
  /**
9561
- * Retrieves the layout for the window the view is attached to.
8894
+ * Retrieves the OpenFin.Layout instance for the Window the View is attached to.
9562
8895
  *
9563
8896
  * @example
9564
8897
  * ```js
@@ -9574,29 +8907,7 @@ function requireInstance () {
9574
8907
  this.wire.sendAction('view-get-parent-layout', { ...this.identity }).catch(() => {
9575
8908
  // don't expose
9576
8909
  });
9577
- const layoutWindow = await this.getCurrentWindow();
9578
- let layoutWindowIdentity = layoutWindow.identity;
9579
- // TODO: CORE-1857 - when we tearout active layout or drag a view out of a window, the above identity includes the whole window info.
9580
- if (layoutWindowIdentity.identity) {
9581
- layoutWindowIdentity = layoutWindowIdentity.identity;
9582
- }
9583
- try {
9584
- const providerChannelClient = await __classPrivateFieldGet(this, _View_providerChannelClient, "f").getValue();
9585
- const client = await layout_entities_1.LayoutNode.newLayoutEntitiesClient(providerChannelClient, layout_constants_1.LAYOUT_CONTROLLER_ID, layoutWindowIdentity);
9586
- const layoutIdentity = await client.getLayoutIdentityForViewOrThrow(this.identity);
9587
- return this.fin.Platform.Layout.wrap(layoutIdentity);
9588
- }
9589
- catch (e) {
9590
- const allowedErrors = [
9591
- 'No action registered at target for',
9592
- 'getLayoutIdentityForViewOrThrow is not a function'
9593
- ];
9594
- if (!allowedErrors.some((m) => e.message.includes(m))) {
9595
- throw e;
9596
- }
9597
- // fallback logic for missing endpoint
9598
- return this.fin.Platform.Layout.wrap(layoutWindowIdentity);
9599
- }
8910
+ return this.fin.Platform.Layout.getLayoutByViewIdentity(this.identity);
9600
8911
  };
9601
8912
  /**
9602
8913
  * Gets the View's options.
@@ -9712,11 +9023,8 @@ function requireInstance () {
9712
9023
  // don't expose
9713
9024
  });
9714
9025
  try {
9715
- const layoutWindow = await this.getCurrentWindow();
9716
- const providerChannelClient = await __classPrivateFieldGet(this, _View_providerChannelClient, "f").getValue();
9717
- const client = await layout_entities_1.LayoutNode.newLayoutEntitiesClient(providerChannelClient, layout_constants_1.LAYOUT_CONTROLLER_ID, layoutWindow.identity);
9718
- const stackDefinition = (await client.getStackByView(this.identity));
9719
- return layout_entities_1.LayoutNode.getEntity(stackDefinition, client);
9026
+ const layout = await this.getParentLayout();
9027
+ return layout.getStackByViewIdentity(this.identity);
9720
9028
  }
9721
9029
  catch (error) {
9722
9030
  throw new transport_errors_1.RuntimeError({ reason: 'This view does not belong to a stack.', error });
@@ -10326,13 +9634,13 @@ function errorToPOJO(error) {
10326
9634
  }
10327
9635
  errors.errorToPOJO = errorToPOJO;
10328
9636
 
10329
- var __classPrivateFieldSet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
9637
+ var __classPrivateFieldSet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
10330
9638
  if (kind === "m") throw new TypeError("Private method is not writable");
10331
9639
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10332
9640
  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");
10333
9641
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
10334
9642
  };
10335
- var __classPrivateFieldGet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9643
+ var __classPrivateFieldGet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
10336
9644
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10337
9645
  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");
10338
9646
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -10360,19 +9668,19 @@ class Transport extends events_1$5.EventEmitter {
10360
9668
  // Typing as unknown to avoid circular dependency, should not be used directly.
10361
9669
  _Transport_fin.set(this, void 0);
10362
9670
  this.connectSync = () => {
10363
- const wire = __classPrivateFieldGet$b(this, _Transport_wire, "f");
9671
+ const wire = __classPrivateFieldGet$c(this, _Transport_wire, "f");
10364
9672
  wire.connectSync();
10365
9673
  };
10366
9674
  // This function is only used in our tests.
10367
9675
  this.getPort = () => {
10368
- const wire = __classPrivateFieldGet$b(this, _Transport_wire, "f");
9676
+ const wire = __classPrivateFieldGet$c(this, _Transport_wire, "f");
10369
9677
  return wire.getPort();
10370
9678
  };
10371
- __classPrivateFieldSet$9(this, _Transport_wire, new WireType(this.onmessage.bind(this)), "f");
9679
+ __classPrivateFieldSet$b(this, _Transport_wire, new WireType(this.onmessage.bind(this)), "f");
10372
9680
  this.environment = environment;
10373
- this.sendRaw = __classPrivateFieldGet$b(this, _Transport_wire, "f").send.bind(__classPrivateFieldGet$b(this, _Transport_wire, "f"));
9681
+ this.sendRaw = __classPrivateFieldGet$c(this, _Transport_wire, "f").send.bind(__classPrivateFieldGet$c(this, _Transport_wire, "f"));
10374
9682
  this.registerMessageHandler(this.handleMessage.bind(this));
10375
- __classPrivateFieldGet$b(this, _Transport_wire, "f").on('disconnected', () => {
9683
+ __classPrivateFieldGet$c(this, _Transport_wire, "f").on('disconnected', () => {
10376
9684
  for (const [, { handleNack }] of this.wireListeners) {
10377
9685
  handleNack({ reason: 'Remote connection has closed' });
10378
9686
  }
@@ -10384,24 +9692,24 @@ class Transport extends events_1$5.EventEmitter {
10384
9692
  this.me = (0, me_1$1.getBaseMe)(entityType, uuid, name);
10385
9693
  }
10386
9694
  getFin() {
10387
- if (!__classPrivateFieldGet$b(this, _Transport_fin, "f")) {
9695
+ if (!__classPrivateFieldGet$c(this, _Transport_fin, "f")) {
10388
9696
  throw new Error('No Fin object registered for this transport');
10389
9697
  }
10390
- return __classPrivateFieldGet$b(this, _Transport_fin, "f");
9698
+ return __classPrivateFieldGet$c(this, _Transport_fin, "f");
10391
9699
  }
10392
9700
  registerFin(_fin) {
10393
- if (__classPrivateFieldGet$b(this, _Transport_fin, "f")) {
9701
+ if (__classPrivateFieldGet$c(this, _Transport_fin, "f")) {
10394
9702
  throw new Error('Fin object has already been registered for this transport');
10395
9703
  }
10396
- __classPrivateFieldSet$9(this, _Transport_fin, _fin, "f");
9704
+ __classPrivateFieldSet$b(this, _Transport_fin, _fin, "f");
10397
9705
  }
10398
9706
  shutdown() {
10399
- const wire = __classPrivateFieldGet$b(this, _Transport_wire, "f");
9707
+ const wire = __classPrivateFieldGet$c(this, _Transport_wire, "f");
10400
9708
  return wire.shutdown();
10401
9709
  }
10402
9710
  async connect(config) {
10403
9711
  if ((0, wire_1.isConfigWithReceiver)(config)) {
10404
- await __classPrivateFieldGet$b(this, _Transport_wire, "f").connect(config.receiver);
9712
+ await __classPrivateFieldGet$c(this, _Transport_wire, "f").connect(config.receiver);
10405
9713
  return this.authorize(config);
10406
9714
  }
10407
9715
  if ((0, wire_1.isRemoteConfig)(config)) {
@@ -10417,13 +9725,13 @@ class Transport extends events_1$5.EventEmitter {
10417
9725
  return undefined;
10418
9726
  }
10419
9727
  async connectRemote(config) {
10420
- await __classPrivateFieldGet$b(this, _Transport_wire, "f").connect(new (this.environment.getWsConstructor())(config.address));
9728
+ await __classPrivateFieldGet$c(this, _Transport_wire, "f").connect(new (this.environment.getWsConstructor())(config.address));
10421
9729
  return this.authorize(config);
10422
9730
  }
10423
9731
  async connectByPort(config) {
10424
9732
  const { address, uuid } = config;
10425
9733
  const reqAuthPayload = { ...config, type: 'file-token' };
10426
- const wire = __classPrivateFieldGet$b(this, _Transport_wire, "f");
9734
+ const wire = __classPrivateFieldGet$c(this, _Transport_wire, "f");
10427
9735
  await wire.connect(new (this.environment.getWsConstructor())(config.address));
10428
9736
  const requestExtAuthRet = await this.sendAction('request-external-authorization', {
10429
9737
  uuid,
@@ -10459,7 +9767,7 @@ class Transport extends events_1$5.EventEmitter {
10459
9767
  payload,
10460
9768
  messageId
10461
9769
  };
10462
- const wire = __classPrivateFieldGet$b(this, _Transport_wire, "f");
9770
+ const wire = __classPrivateFieldGet$c(this, _Transport_wire, "f");
10463
9771
  this.addWireListener(messageId, resolve, (payload) => this.nackHandler(payload, reject, callSites), uncorrelated);
10464
9772
  return wire.send(msg).catch(reject);
10465
9773
  });
@@ -10481,7 +9789,7 @@ class Transport extends events_1$5.EventEmitter {
10481
9789
  const resolver = (data) => {
10482
9790
  resolve(data.payload);
10483
9791
  };
10484
- const wire = __classPrivateFieldGet$b(this, _Transport_wire, "f");
9792
+ const wire = __classPrivateFieldGet$c(this, _Transport_wire, "f");
10485
9793
  return wire
10486
9794
  .send(origData)
10487
9795
  .then(() => this.addWireListener(id, resolver, (payload) => this.nackHandler(payload, reject), false))
@@ -10654,13 +9962,6 @@ class System extends base_1$d.EmitterBase {
10654
9962
  constructor(wire) {
10655
9963
  super(wire, 'system');
10656
9964
  }
10657
- /**
10658
- * Dispatch an event to the webcontents that created the notification.
10659
- * Only works for notifications that have been intercepted in the same runtime.
10660
- */
10661
- async dispatchNotificationAction(notificationId, { action }) {
10662
- await this.wire.sendAction('dispatch-notification-action', { notificationId, action });
10663
- }
10664
9965
  sendExternalProcessRequest(action, options) {
10665
9966
  return new Promise((resolve, reject) => {
10666
9967
  const exitEventKey = 'external-process-exited';
@@ -10929,7 +10230,9 @@ class System extends base_1$d.EmitterBase {
10929
10230
  .then(({ payload }) => payload.data);
10930
10231
  }
10931
10232
  /**
10932
- * Get current focused window.
10233
+ * Get currently focused Window.
10234
+ * If a View currently has focus, returns the identity of View's parent Window.
10235
+ * Use {@link Window._Window#getFocusedContent Window.getFocusedContent} to directly access currently focused Window or View.
10933
10236
  *
10934
10237
  * @example
10935
10238
  * ```js
@@ -10939,6 +10242,17 @@ class System extends base_1$d.EmitterBase {
10939
10242
  getFocusedWindow() {
10940
10243
  return this.wire.sendAction('get-focused-window').then(({ payload }) => payload.data);
10941
10244
  }
10245
+ /**
10246
+ * Get currently focused content. Returns identity of entity with `entityType`.
10247
+ *
10248
+ * @example
10249
+ * ```js
10250
+ * fin.System.getFocusedContent().then(contentIdentity => console.log(contentIdentity)).catch(err => console.log(err));
10251
+ * ```
10252
+ */
10253
+ getFocusedContent() {
10254
+ return this.wire.sendAction('get-focused-content').then(({ payload }) => payload.data);
10255
+ }
10942
10256
  /**
10943
10257
  * Returns information about the given app's certification status
10944
10258
  *
@@ -12502,6 +11816,22 @@ class System extends base_1$d.EmitterBase {
12502
11816
  async setDomainSettings(domainSettings) {
12503
11817
  await this.wire.sendAction('set-domain-settings', { domainSettings, ...this.identity });
12504
11818
  }
11819
+ /**
11820
+ * Attempts to install and enable extensions for the security realm. Users may want to call this function in response
11821
+ * to an `extensions-install-failed` event. Only extensions allowed by every application on the current security realm
11822
+ * will be installed/enabled.
11823
+ */
11824
+ async refreshExtensions() {
11825
+ const { payload } = await this.wire.sendAction('refresh-extensions');
11826
+ return payload.data;
11827
+ }
11828
+ /**
11829
+ * Gets the currently-installed
11830
+ */
11831
+ async getInstalledExtensions() {
11832
+ const { payload } = await this.wire.sendAction('get-installed-extensions');
11833
+ return payload.data;
11834
+ }
12505
11835
  }
12506
11836
  system.System = System;
12507
11837
 
@@ -12923,12 +12253,12 @@ class ChannelError extends Error {
12923
12253
  }
12924
12254
  channelError.ChannelError = ChannelError;
12925
12255
 
12926
- var __classPrivateFieldGet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12256
+ var __classPrivateFieldGet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12927
12257
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
12928
12258
  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");
12929
12259
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12930
12260
  };
12931
- var __classPrivateFieldSet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12261
+ var __classPrivateFieldSet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12932
12262
  if (kind === "m") throw new TypeError("Private method is not writable");
12933
12263
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
12934
12264
  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");
@@ -12972,7 +12302,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
12972
12302
  static closeChannelByEndpointId(id) {
12973
12303
  const channel = channelClientsByEndpointId.get(id);
12974
12304
  if (channel) {
12975
- __classPrivateFieldGet$a(channel, _ChannelClient_close, "f").call(channel);
12305
+ __classPrivateFieldGet$b(channel, _ChannelClient_close, "f").call(channel);
12976
12306
  }
12977
12307
  }
12978
12308
  /**
@@ -12983,7 +12313,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
12983
12313
  for (const channelClient of channelClientsByEndpointId.values()) {
12984
12314
  if (channelClient.providerIdentity.channelId === eventPayload.channelId) {
12985
12315
  channelClient.disconnectListener(eventPayload);
12986
- __classPrivateFieldGet$a(channelClient, _ChannelClient_close, "f").call(channelClient);
12316
+ __classPrivateFieldGet$b(channelClient, _ChannelClient_close, "f").call(channelClient);
12987
12317
  }
12988
12318
  }
12989
12319
  }
@@ -12998,12 +12328,12 @@ class ChannelClient extends channel_1$1.ChannelBase {
12998
12328
  this.processAction = (action, payload, senderIdentity) => super.processAction(action, payload, senderIdentity);
12999
12329
  _ChannelClient_close.set(this, () => {
13000
12330
  channelClientsByEndpointId.delete(this.endpointId);
13001
- __classPrivateFieldGet$a(this, _ChannelClient_strategy, "f").close();
12331
+ __classPrivateFieldGet$b(this, _ChannelClient_strategy, "f").close();
13002
12332
  });
13003
- __classPrivateFieldSet$8(this, _ChannelClient_protectedObj, new channel_1$1.ProtectedItems(routingInfo, close), "f");
12333
+ __classPrivateFieldSet$a(this, _ChannelClient_protectedObj, new channel_1$1.ProtectedItems(routingInfo, close), "f");
13004
12334
  this.disconnectListener = () => undefined;
13005
12335
  this.endpointId = routingInfo.endpointId;
13006
- __classPrivateFieldSet$8(this, _ChannelClient_strategy, strategy, "f");
12336
+ __classPrivateFieldSet$a(this, _ChannelClient_strategy, strategy, "f");
13007
12337
  channelClientsByEndpointId.set(this.endpointId, this);
13008
12338
  strategy.receive(this.processAction);
13009
12339
  }
@@ -13011,7 +12341,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
13011
12341
  * a read-only provider identity
13012
12342
  */
13013
12343
  get providerIdentity() {
13014
- const protectedObj = __classPrivateFieldGet$a(this, _ChannelClient_protectedObj, "f");
12344
+ const protectedObj = __classPrivateFieldGet$b(this, _ChannelClient_protectedObj, "f");
13015
12345
  return protectedObj.providerIdentity;
13016
12346
  }
13017
12347
  /**
@@ -13040,9 +12370,9 @@ class ChannelClient extends channel_1$1.ChannelBase {
13040
12370
  * ```
13041
12371
  */
13042
12372
  async dispatch(action, payload) {
13043
- if (__classPrivateFieldGet$a(this, _ChannelClient_strategy, "f").isEndpointConnected(this.providerIdentity.channelId)) {
12373
+ if (__classPrivateFieldGet$b(this, _ChannelClient_strategy, "f").isEndpointConnected(this.providerIdentity.channelId)) {
13044
12374
  const callSites = transport_errors_1$1.RuntimeError.getCallSite();
13045
- return __classPrivateFieldGet$a(this, _ChannelClient_strategy, "f").send(this.providerIdentity.channelId, action, payload).catch((e) => {
12375
+ return __classPrivateFieldGet$b(this, _ChannelClient_strategy, "f").send(this.providerIdentity.channelId, action, payload).catch((e) => {
13046
12376
  throw new channel_error_1$1.ChannelError(e, action, payload, callSites);
13047
12377
  });
13048
12378
  }
@@ -13094,10 +12424,10 @@ class ChannelClient extends channel_1$1.ChannelBase {
13094
12424
  */
13095
12425
  async disconnect() {
13096
12426
  await this.sendDisconnectAction();
13097
- __classPrivateFieldGet$a(this, _ChannelClient_close, "f").call(this);
12427
+ __classPrivateFieldGet$b(this, _ChannelClient_close, "f").call(this);
13098
12428
  }
13099
12429
  async sendDisconnectAction() {
13100
- const protectedObj = __classPrivateFieldGet$a(this, _ChannelClient_protectedObj, "f");
12430
+ const protectedObj = __classPrivateFieldGet$b(this, _ChannelClient_protectedObj, "f");
13101
12431
  await protectedObj.close();
13102
12432
  }
13103
12433
  /**
@@ -13130,13 +12460,13 @@ exhaustive.exhaustiveCheck = exhaustiveCheck;
13130
12460
 
13131
12461
  var strategy$3 = {};
13132
12462
 
13133
- var __classPrivateFieldSet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12463
+ var __classPrivateFieldSet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13134
12464
  if (kind === "m") throw new TypeError("Private method is not writable");
13135
12465
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
13136
12466
  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");
13137
12467
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
13138
12468
  };
13139
- var __classPrivateFieldGet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12469
+ var __classPrivateFieldGet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
13140
12470
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13141
12471
  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");
13142
12472
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -13161,7 +12491,7 @@ class ClassicStrategy {
13161
12491
  // connection problems occur
13162
12492
  _ClassicStrategy_pendingMessagesByEndpointId.set(this, new Map());
13163
12493
  this.send = async (endpointId, action, payload) => {
13164
- const to = __classPrivateFieldGet$9(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
12494
+ const to = __classPrivateFieldGet$a(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
13165
12495
  if (!to) {
13166
12496
  throw new Error(`Could not locate routing info for endpoint ${endpointId}`);
13167
12497
  }
@@ -13173,13 +12503,13 @@ class ClassicStrategy {
13173
12503
  }
13174
12504
  delete cleanId.isLocalEndpointId;
13175
12505
  // grab the promise before awaiting it to save in our pending messages map
13176
- const p = __classPrivateFieldGet$9(this, _ClassicStrategy_wire, "f").sendAction('send-channel-message', {
12506
+ const p = __classPrivateFieldGet$a(this, _ClassicStrategy_wire, "f").sendAction('send-channel-message', {
13177
12507
  ...cleanId,
13178
12508
  providerIdentity: this.providerIdentity,
13179
12509
  action,
13180
12510
  payload
13181
12511
  });
13182
- __classPrivateFieldGet$9(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.add(p);
12512
+ __classPrivateFieldGet$a(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.add(p);
13183
12513
  const raw = await p
13184
12514
  .catch((error) => {
13185
12515
  if ('cause' in error) {
@@ -13189,16 +12519,16 @@ class ClassicStrategy {
13189
12519
  })
13190
12520
  .finally(() => {
13191
12521
  // clean up the pending promise
13192
- __classPrivateFieldGet$9(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.delete(p);
12522
+ __classPrivateFieldGet$a(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.delete(p);
13193
12523
  });
13194
12524
  return raw.payload.data.result;
13195
12525
  };
13196
12526
  this.close = async () => {
13197
12527
  this.messageReceiver.removeEndpoint(this.providerIdentity.channelId, this.endpointId);
13198
- [...__classPrivateFieldGet$9(this, _ClassicStrategy_endpointIdentityMap, "f").keys()].forEach((id) => this.closeEndpoint(id));
13199
- __classPrivateFieldSet$7(this, _ClassicStrategy_endpointIdentityMap, new Map(), "f");
12528
+ [...__classPrivateFieldGet$a(this, _ClassicStrategy_endpointIdentityMap, "f").keys()].forEach((id) => this.closeEndpoint(id));
12529
+ __classPrivateFieldSet$9(this, _ClassicStrategy_endpointIdentityMap, new Map(), "f");
13200
12530
  };
13201
- __classPrivateFieldSet$7(this, _ClassicStrategy_wire, wire, "f");
12531
+ __classPrivateFieldSet$9(this, _ClassicStrategy_wire, wire, "f");
13202
12532
  }
13203
12533
  onEndpointDisconnect(endpointId, listener) {
13204
12534
  // Never fires for 'classic'.
@@ -13207,20 +12537,20 @@ class ClassicStrategy {
13207
12537
  this.messageReceiver.addEndpoint(listener, this.providerIdentity.channelId, this.endpointId);
13208
12538
  }
13209
12539
  async closeEndpoint(endpointId) {
13210
- const id = __classPrivateFieldGet$9(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
13211
- __classPrivateFieldGet$9(this, _ClassicStrategy_endpointIdentityMap, "f").delete(endpointId);
13212
- const pendingSet = __classPrivateFieldGet$9(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId);
12540
+ const id = __classPrivateFieldGet$a(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
12541
+ __classPrivateFieldGet$a(this, _ClassicStrategy_endpointIdentityMap, "f").delete(endpointId);
12542
+ const pendingSet = __classPrivateFieldGet$a(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId);
13213
12543
  pendingSet?.forEach((p) => {
13214
12544
  const errorMsg = `Channel connection with identity uuid: ${id?.uuid} / name: ${id?.name} / endpointId: ${endpointId} no longer connected.`;
13215
12545
  p.cancel(new Error(errorMsg));
13216
12546
  });
13217
12547
  }
13218
12548
  isEndpointConnected(endpointId) {
13219
- return __classPrivateFieldGet$9(this, _ClassicStrategy_endpointIdentityMap, "f").has(endpointId);
12549
+ return __classPrivateFieldGet$a(this, _ClassicStrategy_endpointIdentityMap, "f").has(endpointId);
13220
12550
  }
13221
12551
  addEndpoint(endpointId, payload) {
13222
- __classPrivateFieldGet$9(this, _ClassicStrategy_endpointIdentityMap, "f").set(endpointId, payload.endpointIdentity);
13223
- __classPrivateFieldGet$9(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").set(endpointId, new Set());
12552
+ __classPrivateFieldGet$a(this, _ClassicStrategy_endpointIdentityMap, "f").set(endpointId, payload.endpointIdentity);
12553
+ __classPrivateFieldGet$a(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").set(endpointId, new Set());
13224
12554
  }
13225
12555
  isValidEndpointPayload(payload) {
13226
12556
  return (typeof payload?.endpointIdentity?.endpointId === 'string' ||
@@ -13236,12 +12566,12 @@ var strategy$2 = {};
13236
12566
 
13237
12567
  var endpoint = {};
13238
12568
 
13239
- var __classPrivateFieldGet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12569
+ var __classPrivateFieldGet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
13240
12570
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13241
12571
  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");
13242
12572
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
13243
12573
  };
13244
- var __classPrivateFieldSet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12574
+ var __classPrivateFieldSet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13245
12575
  if (kind === "m") throw new TypeError("Private method is not writable");
13246
12576
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
13247
12577
  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");
@@ -13276,8 +12606,8 @@ class RTCEndpoint {
13276
12606
  if (this.rtc.rtcClient.connectionState !== 'connected') {
13277
12607
  this.rtc.rtcClient.removeEventListener('connectionstatechange', this.connectionStateChangeHandler);
13278
12608
  this.close();
13279
- if (__classPrivateFieldGet$8(this, _RTCEndpoint_disconnectListener, "f")) {
13280
- __classPrivateFieldGet$8(this, _RTCEndpoint_disconnectListener, "f").call(this);
12609
+ if (__classPrivateFieldGet$9(this, _RTCEndpoint_disconnectListener, "f")) {
12610
+ __classPrivateFieldGet$9(this, _RTCEndpoint_disconnectListener, "f").call(this);
13281
12611
  }
13282
12612
  }
13283
12613
  };
@@ -13325,9 +12655,9 @@ class RTCEndpoint {
13325
12655
  data = new TextDecoder().decode(e.data);
13326
12656
  }
13327
12657
  const { messageId, action, payload } = JSON.parse(data);
13328
- if (__classPrivateFieldGet$8(this, _RTCEndpoint_processAction, "f")) {
12658
+ if (__classPrivateFieldGet$9(this, _RTCEndpoint_processAction, "f")) {
13329
12659
  try {
13330
- const res = await __classPrivateFieldGet$8(this, _RTCEndpoint_processAction, "f").call(this, action, payload, endpointIdentity);
12660
+ const res = await __classPrivateFieldGet$9(this, _RTCEndpoint_processAction, "f").call(this, action, payload, endpointIdentity);
13331
12661
  this.rtc.channels.response.send(JSON.stringify({
13332
12662
  messageId,
13333
12663
  payload: res,
@@ -13361,25 +12691,25 @@ class RTCEndpoint {
13361
12691
  datachannel.onclose = (e) => {
13362
12692
  [...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.')));
13363
12693
  this.close();
13364
- if (__classPrivateFieldGet$8(this, _RTCEndpoint_disconnectListener, "f")) {
13365
- __classPrivateFieldGet$8(this, _RTCEndpoint_disconnectListener, "f").call(this);
12694
+ if (__classPrivateFieldGet$9(this, _RTCEndpoint_disconnectListener, "f")) {
12695
+ __classPrivateFieldGet$9(this, _RTCEndpoint_disconnectListener, "f").call(this);
13366
12696
  }
13367
12697
  };
13368
12698
  });
13369
12699
  }
13370
12700
  onDisconnect(listener) {
13371
- if (!__classPrivateFieldGet$8(this, _RTCEndpoint_disconnectListener, "f")) {
13372
- __classPrivateFieldSet$6(this, _RTCEndpoint_disconnectListener, listener, "f");
12701
+ if (!__classPrivateFieldGet$9(this, _RTCEndpoint_disconnectListener, "f")) {
12702
+ __classPrivateFieldSet$8(this, _RTCEndpoint_disconnectListener, listener, "f");
13373
12703
  }
13374
12704
  else {
13375
12705
  throw new Error('RTCEndpoint disconnectListener cannot be set twice.');
13376
12706
  }
13377
12707
  }
13378
12708
  receive(listener) {
13379
- if (__classPrivateFieldGet$8(this, _RTCEndpoint_processAction, "f")) {
12709
+ if (__classPrivateFieldGet$9(this, _RTCEndpoint_processAction, "f")) {
13380
12710
  throw new Error('You have already set a listener for this RTC Endpoint.');
13381
12711
  }
13382
- __classPrivateFieldSet$6(this, _RTCEndpoint_processAction, listener, "f");
12712
+ __classPrivateFieldSet$8(this, _RTCEndpoint_processAction, listener, "f");
13383
12713
  }
13384
12714
  get connected() {
13385
12715
  return this.rtc.rtcClient.connectionState === 'connected';
@@ -13390,12 +12720,12 @@ _RTCEndpoint_processAction = new WeakMap(), _RTCEndpoint_disconnectListener = ne
13390
12720
 
13391
12721
  var strategy$1 = {};
13392
12722
 
13393
- var __classPrivateFieldGet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12723
+ var __classPrivateFieldGet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
13394
12724
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13395
12725
  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");
13396
12726
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
13397
12727
  };
13398
- var __classPrivateFieldSet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12728
+ var __classPrivateFieldSet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13399
12729
  if (kind === "m") throw new TypeError("Private method is not writable");
13400
12730
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
13401
12731
  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");
@@ -13416,11 +12746,11 @@ class EndpointStrategy {
13416
12746
  return this.getEndpointById(endpointId).send(action, payload);
13417
12747
  };
13418
12748
  this.close = async () => {
13419
- if (__classPrivateFieldGet$7(this, _EndpointStrategy_connected, "f")) {
13420
- __classPrivateFieldGet$7(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.close());
13421
- __classPrivateFieldSet$5(this, _EndpointStrategy_endpointMap, new Map(), "f");
12749
+ if (__classPrivateFieldGet$8(this, _EndpointStrategy_connected, "f")) {
12750
+ __classPrivateFieldGet$8(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.close());
12751
+ __classPrivateFieldSet$7(this, _EndpointStrategy_endpointMap, new Map(), "f");
13422
12752
  }
13423
- __classPrivateFieldSet$5(this, _EndpointStrategy_connected, false, "f");
12753
+ __classPrivateFieldSet$7(this, _EndpointStrategy_connected, false, "f");
13424
12754
  };
13425
12755
  this.isValidEndpointPayload = validateEndpoint;
13426
12756
  }
@@ -13428,39 +12758,39 @@ class EndpointStrategy {
13428
12758
  this.getEndpointById(endpointId).onDisconnect(listener);
13429
12759
  }
13430
12760
  receive(listener) {
13431
- if (__classPrivateFieldGet$7(this, _EndpointStrategy_processAction, "f")) {
12761
+ if (__classPrivateFieldGet$8(this, _EndpointStrategy_processAction, "f")) {
13432
12762
  throw new Error(`You have already set a listener for this ${this.StrategyName} Strategy`);
13433
12763
  }
13434
- __classPrivateFieldSet$5(this, _EndpointStrategy_processAction, listener, "f");
12764
+ __classPrivateFieldSet$7(this, _EndpointStrategy_processAction, listener, "f");
13435
12765
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
13436
- __classPrivateFieldGet$7(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.receive(__classPrivateFieldGet$7(this, _EndpointStrategy_processAction, "f")));
12766
+ __classPrivateFieldGet$8(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.receive(__classPrivateFieldGet$8(this, _EndpointStrategy_processAction, "f")));
13437
12767
  }
13438
12768
  getEndpointById(endpointId) {
13439
- const endpoint = __classPrivateFieldGet$7(this, _EndpointStrategy_endpointMap, "f").get(endpointId);
12769
+ const endpoint = __classPrivateFieldGet$8(this, _EndpointStrategy_endpointMap, "f").get(endpointId);
13440
12770
  if (!endpoint) {
13441
12771
  throw new Error(`Client with endpoint id ${endpointId} is not connected`);
13442
12772
  }
13443
12773
  return endpoint;
13444
12774
  }
13445
12775
  get connected() {
13446
- return __classPrivateFieldGet$7(this, _EndpointStrategy_connected, "f");
12776
+ return __classPrivateFieldGet$8(this, _EndpointStrategy_connected, "f");
13447
12777
  }
13448
12778
  isEndpointConnected(endpointId) {
13449
- return __classPrivateFieldGet$7(this, _EndpointStrategy_endpointMap, "f").has(endpointId);
12779
+ return __classPrivateFieldGet$8(this, _EndpointStrategy_endpointMap, "f").has(endpointId);
13450
12780
  }
13451
12781
  addEndpoint(endpointId, payload) {
13452
- if (!__classPrivateFieldGet$7(this, _EndpointStrategy_connected, "f")) {
12782
+ if (!__classPrivateFieldGet$8(this, _EndpointStrategy_connected, "f")) {
13453
12783
  console.warn(`Adding endpoint to disconnected ${this.StrategyName} Strategy`);
13454
12784
  return;
13455
12785
  }
13456
12786
  const clientStrat = new this.EndpointType(payload);
13457
- if (__classPrivateFieldGet$7(this, _EndpointStrategy_processAction, "f")) {
13458
- clientStrat.receive(__classPrivateFieldGet$7(this, _EndpointStrategy_processAction, "f"));
12787
+ if (__classPrivateFieldGet$8(this, _EndpointStrategy_processAction, "f")) {
12788
+ clientStrat.receive(__classPrivateFieldGet$8(this, _EndpointStrategy_processAction, "f"));
13459
12789
  }
13460
- __classPrivateFieldGet$7(this, _EndpointStrategy_endpointMap, "f").set(endpointId, clientStrat);
12790
+ __classPrivateFieldGet$8(this, _EndpointStrategy_endpointMap, "f").set(endpointId, clientStrat);
13461
12791
  }
13462
12792
  async closeEndpoint(endpointId) {
13463
- __classPrivateFieldGet$7(this, _EndpointStrategy_endpointMap, "f").delete(endpointId);
12793
+ __classPrivateFieldGet$8(this, _EndpointStrategy_endpointMap, "f").delete(endpointId);
13464
12794
  }
13465
12795
  }
13466
12796
  strategy$1.EndpointStrategy = EndpointStrategy;
@@ -13642,12 +12972,12 @@ function runtimeUuidMeetsMinimumRuntimeVersion(runtimeUuid, minVersion) {
13642
12972
  }
13643
12973
  runtimeVersioning.runtimeUuidMeetsMinimumRuntimeVersion = runtimeUuidMeetsMinimumRuntimeVersion;
13644
12974
 
13645
- var __classPrivateFieldGet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12975
+ var __classPrivateFieldGet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
13646
12976
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13647
12977
  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");
13648
12978
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
13649
12979
  };
13650
- var __classPrivateFieldSet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12980
+ var __classPrivateFieldSet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13651
12981
  if (kind === "m") throw new TypeError("Private method is not writable");
13652
12982
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
13653
12983
  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");
@@ -13691,18 +13021,18 @@ class ChannelProvider extends channel_1.ChannelBase {
13691
13021
  * a read-only array containing all the identities of connecting clients.
13692
13022
  */
13693
13023
  get connections() {
13694
- return [...__classPrivateFieldGet$6(this, _ChannelProvider_connections, "f")];
13024
+ return [...__classPrivateFieldGet$7(this, _ChannelProvider_connections, "f")];
13695
13025
  }
13696
13026
  static handleClientDisconnection(channel, payload) {
13697
13027
  const removeById = channel.connections.find((identity) => identity.endpointId === payload.endpointId);
13698
13028
  if (removeById) {
13699
- __classPrivateFieldGet$6(channel, _ChannelProvider_removeEndpoint, "f").call(channel, removeById);
13029
+ __classPrivateFieldGet$7(channel, _ChannelProvider_removeEndpoint, "f").call(channel, removeById);
13700
13030
  }
13701
13031
  else {
13702
13032
  const multipleRemoves = channel.connections.filter((identity) => {
13703
13033
  return identity.uuid === payload.uuid && identity.name === payload.name;
13704
13034
  });
13705
- multipleRemoves.forEach(__classPrivateFieldGet$6(channel, _ChannelProvider_removeEndpoint, "f"));
13035
+ multipleRemoves.forEach(__classPrivateFieldGet$7(channel, _ChannelProvider_removeEndpoint, "f"));
13706
13036
  }
13707
13037
  channel.disconnectListener(payload);
13708
13038
  }
@@ -13719,8 +13049,8 @@ class ChannelProvider extends channel_1.ChannelBase {
13719
13049
  _ChannelProvider_strategy.set(this, void 0);
13720
13050
  _ChannelProvider_removeEndpoint.set(this, (identity) => {
13721
13051
  const remainingConnections = this.connections.filter((clientIdentity) => clientIdentity.endpointId !== identity.endpointId);
13722
- __classPrivateFieldGet$6(this, _ChannelProvider_strategy, "f").closeEndpoint(identity.endpointId);
13723
- __classPrivateFieldSet$4(this, _ChannelProvider_connections, remainingConnections, "f");
13052
+ __classPrivateFieldGet$7(this, _ChannelProvider_strategy, "f").closeEndpoint(identity.endpointId);
13053
+ __classPrivateFieldSet$6(this, _ChannelProvider_connections, remainingConnections, "f");
13724
13054
  });
13725
13055
  // Must be bound.
13726
13056
  this.processAction = async (action, payload, senderIdentity) => {
@@ -13734,17 +13064,17 @@ class ChannelProvider extends channel_1.ChannelBase {
13734
13064
  return super.processAction(action, payload, senderIdentity);
13735
13065
  };
13736
13066
  _ChannelProvider_close.set(this, () => {
13737
- __classPrivateFieldGet$6(this, _ChannelProvider_strategy, "f").close();
13067
+ __classPrivateFieldGet$7(this, _ChannelProvider_strategy, "f").close();
13738
13068
  const remove = ChannelProvider.removalMap.get(this);
13739
13069
  if (remove) {
13740
13070
  remove();
13741
13071
  }
13742
13072
  });
13743
- __classPrivateFieldSet$4(this, _ChannelProvider_protectedObj, new channel_1.ProtectedItems(providerIdentity, close), "f");
13073
+ __classPrivateFieldSet$6(this, _ChannelProvider_protectedObj, new channel_1.ProtectedItems(providerIdentity, close), "f");
13744
13074
  this.connectListener = () => undefined;
13745
13075
  this.disconnectListener = () => undefined;
13746
- __classPrivateFieldSet$4(this, _ChannelProvider_connections, [], "f");
13747
- __classPrivateFieldSet$4(this, _ChannelProvider_strategy, strategy, "f");
13076
+ __classPrivateFieldSet$6(this, _ChannelProvider_connections, [], "f");
13077
+ __classPrivateFieldSet$6(this, _ChannelProvider_strategy, strategy, "f");
13748
13078
  strategy.receive(this.processAction);
13749
13079
  }
13750
13080
  /**
@@ -13775,16 +13105,16 @@ class ChannelProvider extends channel_1.ChannelBase {
13775
13105
  */
13776
13106
  dispatch(to, action, payload) {
13777
13107
  const endpointId = to.endpointId ?? this.getEndpointIdForOpenFinId(to, action);
13778
- if (endpointId && __classPrivateFieldGet$6(this, _ChannelProvider_strategy, "f").isEndpointConnected(endpointId)) {
13108
+ if (endpointId && __classPrivateFieldGet$7(this, _ChannelProvider_strategy, "f").isEndpointConnected(endpointId)) {
13779
13109
  const callSites = transport_errors_1.RuntimeError.getCallSite();
13780
- return __classPrivateFieldGet$6(this, _ChannelProvider_strategy, "f").send(endpointId, action, payload).catch((e) => {
13110
+ return __classPrivateFieldGet$7(this, _ChannelProvider_strategy, "f").send(endpointId, action, payload).catch((e) => {
13781
13111
  throw new channel_error_1.ChannelError(e, action, payload, callSites);
13782
13112
  });
13783
13113
  }
13784
13114
  return Promise.reject(new Error(`Client connection with identity uuid: ${to.uuid} / name: ${to.name} / endpointId: ${endpointId} no longer connected.`));
13785
13115
  }
13786
13116
  async processConnection(senderId, payload) {
13787
- __classPrivateFieldGet$6(this, _ChannelProvider_connections, "f").push(senderId);
13117
+ __classPrivateFieldGet$7(this, _ChannelProvider_connections, "f").push(senderId);
13788
13118
  return this.connectListener(senderId, payload);
13789
13119
  }
13790
13120
  /**
@@ -13807,7 +13137,7 @@ class ChannelProvider extends channel_1.ChannelBase {
13807
13137
  * ```
13808
13138
  */
13809
13139
  publish(action, payload) {
13810
- return this.connections.map((to) => __classPrivateFieldGet$6(this, _ChannelProvider_strategy, "f").send(to.endpointId, action, payload));
13140
+ return this.connections.map((to) => __classPrivateFieldGet$7(this, _ChannelProvider_strategy, "f").send(to.endpointId, action, payload));
13811
13141
  }
13812
13142
  /**
13813
13143
  * Register a listener that is called on every new client connection.
@@ -13881,11 +13211,11 @@ class ChannelProvider extends channel_1.ChannelBase {
13881
13211
  * ```
13882
13212
  */
13883
13213
  async destroy() {
13884
- const protectedObj = __classPrivateFieldGet$6(this, _ChannelProvider_protectedObj, "f");
13214
+ const protectedObj = __classPrivateFieldGet$7(this, _ChannelProvider_protectedObj, "f");
13885
13215
  protectedObj.providerIdentity;
13886
- __classPrivateFieldSet$4(this, _ChannelProvider_connections, [], "f");
13216
+ __classPrivateFieldSet$6(this, _ChannelProvider_connections, [], "f");
13887
13217
  await protectedObj.close();
13888
- __classPrivateFieldGet$6(this, _ChannelProvider_close, "f").call(this);
13218
+ __classPrivateFieldGet$7(this, _ChannelProvider_close, "f").call(this);
13889
13219
  }
13890
13220
  /**
13891
13221
  * Returns an array with info on every Client connected to the Provider
@@ -13955,7 +13285,7 @@ class ChannelProvider extends channel_1.ChannelBase {
13955
13285
  getEndpointIdForOpenFinId(clientIdentity, action) {
13956
13286
  const matchingConnections = this.connections.filter((c) => c.name === clientIdentity.name && c.uuid === clientIdentity.uuid);
13957
13287
  if (matchingConnections.length >= 2) {
13958
- const protectedObj = __classPrivateFieldGet$6(this, _ChannelProvider_protectedObj, "f");
13288
+ const protectedObj = __classPrivateFieldGet$7(this, _ChannelProvider_protectedObj, "f");
13959
13289
  const { uuid, name } = clientIdentity;
13960
13290
  const providerUuid = protectedObj?.providerIdentity.uuid;
13961
13291
  const providerName = protectedObj?.providerIdentity.name;
@@ -14167,13 +13497,13 @@ class CombinedStrategy {
14167
13497
  }
14168
13498
  strategy.default = CombinedStrategy;
14169
13499
 
14170
- var __classPrivateFieldSet$3 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13500
+ var __classPrivateFieldSet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
14171
13501
  if (kind === "m") throw new TypeError("Private method is not writable");
14172
13502
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
14173
13503
  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");
14174
13504
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
14175
13505
  };
14176
- var __classPrivateFieldGet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
13506
+ var __classPrivateFieldGet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
14177
13507
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
14178
13508
  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");
14179
13509
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -14222,8 +13552,8 @@ class ConnectionManager extends base_1$a.Base {
14222
13552
  };
14223
13553
  this.providerMap = new Map();
14224
13554
  this.protocolManager = new protocol_manager_1.ProtocolManager(this.wire.environment.type === 'node' ? ['classic'] : ['rtc', 'classic']);
14225
- __classPrivateFieldSet$3(this, _ConnectionManager_messageReceiver, new message_receiver_1.MessageReceiver(wire), "f");
14226
- __classPrivateFieldSet$3(this, _ConnectionManager_rtcConnectionManager, new ice_manager_1.RTCICEManager(wire), "f");
13555
+ __classPrivateFieldSet$5(this, _ConnectionManager_messageReceiver, new message_receiver_1.MessageReceiver(wire), "f");
13556
+ __classPrivateFieldSet$5(this, _ConnectionManager_rtcConnectionManager, new ice_manager_1.RTCICEManager(wire), "f");
14227
13557
  wire.registerMessageHandler(this.onmessage.bind(this));
14228
13558
  }
14229
13559
  createProvider(options, providerIdentity) {
@@ -14234,7 +13564,7 @@ class ConnectionManager extends base_1$a.Base {
14234
13564
  case 'rtc':
14235
13565
  return new strategy_2.RTCStrategy();
14236
13566
  case 'classic':
14237
- return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$5(this, _ConnectionManager_messageReceiver, "f"),
13567
+ return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$6(this, _ConnectionManager_messageReceiver, "f"),
14238
13568
  // Providers do not have an endpointId, use channelId as endpointId in the strategy.
14239
13569
  providerIdentity.channelId, providerIdentity);
14240
13570
  default:
@@ -14270,7 +13600,7 @@ class ConnectionManager extends base_1$a.Base {
14270
13600
  const supportedProtocols = await Promise.all(protocols.map(async (type) => {
14271
13601
  switch (type) {
14272
13602
  case 'rtc': {
14273
- const { rtcClient, channels, offer, rtcConnectionId, channelsOpened } = await __classPrivateFieldGet$5(this, _ConnectionManager_rtcConnectionManager, "f").startClientOffer();
13603
+ const { rtcClient, channels, offer, rtcConnectionId, channelsOpened } = await __classPrivateFieldGet$6(this, _ConnectionManager_rtcConnectionManager, "f").startClientOffer();
14274
13604
  rtcPacket = { rtcClient, channels, channelsOpened };
14275
13605
  return {
14276
13606
  type: 'rtc',
@@ -14297,18 +13627,18 @@ class ConnectionManager extends base_1$a.Base {
14297
13627
  routingInfo.endpointId = this.wire.environment.getNextMessageId();
14298
13628
  // For New Clients connecting to Old Providers. To prevent multi-dispatching and publishing, we delete previously-connected
14299
13629
  // clients that are in the same context as the newly-connected client.
14300
- __classPrivateFieldGet$5(this, _ConnectionManager_messageReceiver, "f").checkForPreviousClientConnection(routingInfo.channelId);
13630
+ __classPrivateFieldGet$6(this, _ConnectionManager_messageReceiver, "f").checkForPreviousClientConnection(routingInfo.channelId);
14301
13631
  }
14302
13632
  const answer = routingInfo.answer ?? {
14303
13633
  supportedProtocols: [{ type: 'classic', version: 1 }]
14304
13634
  };
14305
13635
  const createStrategyFromAnswer = async (protocol) => {
14306
13636
  if (protocol.type === 'rtc' && rtcPacket) {
14307
- await __classPrivateFieldGet$5(this, _ConnectionManager_rtcConnectionManager, "f").finishClientOffer(rtcPacket.rtcClient, protocol.payload.answer, rtcPacket.channelsOpened);
13637
+ await __classPrivateFieldGet$6(this, _ConnectionManager_rtcConnectionManager, "f").finishClientOffer(rtcPacket.rtcClient, protocol.payload.answer, rtcPacket.channelsOpened);
14308
13638
  return new strategy_2.RTCStrategy();
14309
13639
  }
14310
13640
  if (protocol.type === 'classic') {
14311
- return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$5(this, _ConnectionManager_messageReceiver, "f"), routingInfo.endpointId, routingInfo);
13641
+ return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$6(this, _ConnectionManager_messageReceiver, "f"), routingInfo.endpointId, routingInfo);
14312
13642
  }
14313
13643
  return null;
14314
13644
  };
@@ -14376,7 +13706,7 @@ class ConnectionManager extends base_1$a.Base {
14376
13706
  clientAnswer = await overlappingProtocols.reduce(async (accumP, protocolToUse) => {
14377
13707
  const answer = await accumP;
14378
13708
  if (protocolToUse.type === 'rtc') {
14379
- const { answer: rtcAnswer, rtcClient, channels } = await __classPrivateFieldGet$5(this, _ConnectionManager_rtcConnectionManager, "f").createProviderAnswer(protocolToUse.payload.rtcConnectionId, protocolToUse.payload.offer);
13709
+ const { answer: rtcAnswer, rtcClient, channels } = await __classPrivateFieldGet$6(this, _ConnectionManager_rtcConnectionManager, "f").createProviderAnswer(protocolToUse.payload.rtcConnectionId, protocolToUse.payload.offer);
14380
13710
  answer.supportedProtocols.push({
14381
13711
  type: 'rtc',
14382
13712
  version: strategy_2.RTCInfo.version,
@@ -14424,13 +13754,13 @@ _ConnectionManager_messageReceiver = new WeakMap(), _ConnectionManager_rtcConnec
14424
13754
  *
14425
13755
  * @packageDocumentation
14426
13756
  */
14427
- var __classPrivateFieldSet$2 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13757
+ var __classPrivateFieldSet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
14428
13758
  if (kind === "m") throw new TypeError("Private method is not writable");
14429
13759
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
14430
13760
  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");
14431
13761
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
14432
13762
  };
14433
- var __classPrivateFieldGet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
13763
+ var __classPrivateFieldGet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
14434
13764
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
14435
13765
  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");
14436
13766
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -14487,11 +13817,11 @@ class Channel extends base_1$9.EmitterBase {
14487
13817
  client_1.ChannelClient.handleProviderDisconnect(eventPayload);
14488
13818
  }),
14489
13819
  this.on('connected', (...args) => {
14490
- __classPrivateFieldGet$4(this, _Channel_internalEmitter, "f").emit('connected', ...args);
13820
+ __classPrivateFieldGet$5(this, _Channel_internalEmitter, "f").emit('connected', ...args);
14491
13821
  })
14492
13822
  ]).catch(() => new Error('error setting up channel connection listeners'));
14493
13823
  }));
14494
- __classPrivateFieldSet$2(this, _Channel_connectionManager, new connection_manager_1.ConnectionManager(wire), "f");
13824
+ __classPrivateFieldSet$4(this, _Channel_connectionManager, new connection_manager_1.ConnectionManager(wire), "f");
14495
13825
  }
14496
13826
  /**
14497
13827
  *
@@ -14566,7 +13896,7 @@ class Channel extends base_1$9.EmitterBase {
14566
13896
  resolve(true);
14567
13897
  }
14568
13898
  };
14569
- __classPrivateFieldGet$4(this, _Channel_internalEmitter, "f").on('connected', connectedListener);
13899
+ __classPrivateFieldGet$5(this, _Channel_internalEmitter, "f").on('connected', connectedListener);
14570
13900
  });
14571
13901
  try {
14572
13902
  if (retryInfo.count > 0) {
@@ -14598,7 +13928,7 @@ class Channel extends base_1$9.EmitterBase {
14598
13928
  finally {
14599
13929
  retryInfo.count += 1;
14600
13930
  // in case of other errors, remove our listener
14601
- __classPrivateFieldGet$4(this, _Channel_internalEmitter, "f").removeListener('connected', connectedListener);
13931
+ __classPrivateFieldGet$5(this, _Channel_internalEmitter, "f").removeListener('connected', connectedListener);
14602
13932
  }
14603
13933
  } while (shouldWait); // If we're waiting we retry the above loop
14604
13934
  // Should wait was false, no channel was found.
@@ -14657,12 +13987,12 @@ class Channel extends base_1$9.EmitterBase {
14657
13987
  async connect(channelName, options = {}) {
14658
13988
  // Make sure we don't connect before listeners are set up
14659
13989
  // This also errors if we're not in OpenFin, ensuring we don't run unnecessary code
14660
- await __classPrivateFieldGet$4(this, _Channel_readyToConnect, "f").getValue();
13990
+ await __classPrivateFieldGet$5(this, _Channel_readyToConnect, "f").getValue();
14661
13991
  if (!channelName || typeof channelName !== 'string') {
14662
13992
  throw new Error('Please provide a channelName string to connect to a channel.');
14663
13993
  }
14664
13994
  const opts = { wait: true, ...this.wire.environment.getDefaultChannelOptions().connect, ...options };
14665
- const { offer, rtc: rtcPacket } = await __classPrivateFieldGet$4(this, _Channel_connectionManager, "f").createClientOffer(opts);
13995
+ const { offer, rtc: rtcPacket } = await __classPrivateFieldGet$5(this, _Channel_connectionManager, "f").createClientOffer(opts);
14666
13996
  let connectionUrl;
14667
13997
  if (this.fin.me.isFrame || this.fin.me.isView || this.fin.me.isWindow) {
14668
13998
  connectionUrl = (await this.fin.me.getInfo()).url;
@@ -14674,7 +14004,7 @@ class Channel extends base_1$9.EmitterBase {
14674
14004
  connectionUrl
14675
14005
  };
14676
14006
  const routingInfo = await this.safeConnect(channelName, opts.wait, connectPayload);
14677
- const strategy = await __classPrivateFieldGet$4(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
14007
+ const strategy = await __classPrivateFieldGet$5(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
14678
14008
  const channel = new client_1.ChannelClient(routingInfo, () => client_1.ChannelClient.wireClose(this.wire, routingInfo, routingInfo.endpointId), strategy);
14679
14009
  // It is the client's responsibility to handle endpoint disconnection to the provider.
14680
14010
  // If the endpoint dies, the client will force a disconnection through the core.
@@ -14743,7 +14073,7 @@ class Channel extends base_1$9.EmitterBase {
14743
14073
  throw new Error('Please provide a channelName to create a channel');
14744
14074
  }
14745
14075
  const { payload: { data: providerIdentity } } = await this.wire.sendAction('create-channel', { channelName });
14746
- const channel = __classPrivateFieldGet$4(this, _Channel_connectionManager, "f").createProvider(options, providerIdentity);
14076
+ const channel = __classPrivateFieldGet$5(this, _Channel_connectionManager, "f").createProvider(options, providerIdentity);
14747
14077
  // TODO: fix typing (internal)
14748
14078
  // @ts-expect-error
14749
14079
  this.on('client-disconnected', (eventPayload) => {
@@ -15309,19 +14639,23 @@ var Factory$2 = {};
15309
14639
 
15310
14640
  var Instance$2 = {};
15311
14641
 
15312
- var __classPrivateFieldGet$3 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
14642
+ var __classPrivateFieldSet$3 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
14643
+ if (kind === "m") throw new TypeError("Private method is not writable");
14644
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
14645
+ 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");
14646
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
14647
+ };
14648
+ var __classPrivateFieldGet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
15313
14649
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
15314
14650
  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");
15315
14651
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15316
14652
  };
15317
- var _Platform_connectToProvider;
14653
+ var _Platform_channelName, _Platform_connectToProvider;
15318
14654
  Object.defineProperty(Instance$2, "__esModule", { value: true });
15319
14655
  Instance$2.Platform = void 0;
15320
14656
  /* eslint-disable import/prefer-default-export, no-undef */
15321
14657
  const base_1$5 = base;
15322
14658
  const validate_1$1 = validate;
15323
- // Reuse clients to avoid overwriting already-registered client in provider
15324
- const clientMap = new Map();
15325
14659
  /** Manages the life cycle of windows and views in the application.
15326
14660
  *
15327
14661
  * Enables taking snapshots of itself and applying them to restore a previous configuration
@@ -15332,34 +14666,40 @@ class Platform extends base_1$5.EmitterBase {
15332
14666
  * @internal
15333
14667
  */
15334
14668
  // eslint-disable-next-line no-shadow
15335
- constructor(identity, channel) {
14669
+ constructor(wire, identity, channelName = `custom-frame-${identity.uuid}`) {
15336
14670
  // we piggyback off of application event emitter because from the core's perspective platform is just an app.
15337
- super(channel.wire, 'application', identity.uuid);
15338
- this.getClient = (identity) => {
14671
+ super(wire, 'application', identity.uuid);
14672
+ /**
14673
+ * @internal
14674
+ */
14675
+ _Platform_channelName.set(this, void 0);
14676
+ this.getClient = (identity = this.identity) => {
14677
+ if (identity.uuid !== this.identity.uuid) {
14678
+ // I have no idea why we allow passing in a different identity, but we do.
14679
+ // Doing this above the analytics call so we only register one call.
14680
+ return new Platform(this.wire, identity).getClient();
14681
+ }
15339
14682
  this.wire.sendAction('platform-get-client', this.identity).catch((e) => {
15340
14683
  // don't expose
15341
14684
  });
15342
- const target = identity || this.identity;
15343
- const { uuid } = target;
15344
- if (!clientMap.has(uuid)) {
15345
- const clientPromise = __classPrivateFieldGet$3(this, _Platform_connectToProvider, "f").call(this, uuid);
15346
- clientMap.set(uuid, clientPromise);
14685
+ if (!Platform.clientMap.has(__classPrivateFieldGet$4(this, _Platform_channelName, "f"))) {
14686
+ const clientPromise = __classPrivateFieldGet$4(this, _Platform_connectToProvider, "f").call(this);
14687
+ Platform.clientMap.set(__classPrivateFieldGet$4(this, _Platform_channelName, "f"), clientPromise);
15347
14688
  }
15348
14689
  // we set it above
15349
14690
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
15350
- return clientMap.get(uuid);
14691
+ return Platform.clientMap.get(__classPrivateFieldGet$4(this, _Platform_channelName, "f"));
15351
14692
  };
15352
- _Platform_connectToProvider.set(this, async (uuid) => {
14693
+ _Platform_connectToProvider.set(this, async () => {
15353
14694
  try {
15354
- const channelName = `custom-frame-${uuid}`;
15355
- const client = await this._channel.connect(channelName, { wait: false });
14695
+ const client = await this._channel.connect(__classPrivateFieldGet$4(this, _Platform_channelName, "f"), { wait: false });
15356
14696
  client.onDisconnection(() => {
15357
- clientMap.delete(uuid);
14697
+ Platform.clientMap.delete(__classPrivateFieldGet$4(this, _Platform_channelName, "f"));
15358
14698
  });
15359
14699
  return client;
15360
14700
  }
15361
14701
  catch (e) {
15362
- clientMap.delete(uuid);
14702
+ Platform.clientMap.delete(__classPrivateFieldGet$4(this, _Platform_channelName, "f"));
15363
14703
  throw new Error('The targeted Platform is not currently running. Listen for application-started event for the given Uuid.');
15364
14704
  }
15365
14705
  });
@@ -15372,7 +14712,8 @@ class Platform extends base_1$5.EmitterBase {
15372
14712
  if (errorMsg) {
15373
14713
  throw new Error(errorMsg);
15374
14714
  }
15375
- this._channel = channel;
14715
+ __classPrivateFieldSet$3(this, _Platform_channelName, channelName, "f");
14716
+ this._channel = this.fin.InterApplicationBus.Channel;
15376
14717
  this.identity = { uuid: identity.uuid };
15377
14718
  this.Layout = this.fin.Platform.Layout;
15378
14719
  this.Application = this.fin.Application.wrapSync(this.identity);
@@ -15831,326 +15172,996 @@ class Platform extends base_1$5.EmitterBase {
15831
15172
  * }, winId);
15832
15173
  * }
15833
15174
  *
15834
- * async function createWindowWithTwoViews() {
15835
- * const platform = await fin.Platform.getCurrent();
15175
+ * async function createWindowWithTwoViews() {
15176
+ * const platform = await fin.Platform.getCurrent();
15177
+ *
15178
+ * return platform.createWindow({
15179
+ * layout: {
15180
+ * content: [
15181
+ * {
15182
+ * type: 'stack',
15183
+ * content: [
15184
+ * {
15185
+ * type: 'component',
15186
+ * componentName: 'view',
15187
+ * componentState: {
15188
+ * name: 'test_view_1',
15189
+ * url: 'https://example.com'
15190
+ * }
15191
+ * },
15192
+ * {
15193
+ * type: 'component',
15194
+ * componentName: 'view',
15195
+ * componentState: {
15196
+ * name: 'test_view_2',
15197
+ * url: 'https://yahoo.com'
15198
+ * }
15199
+ * }
15200
+ * ]
15201
+ * }
15202
+ * ]
15203
+ * }
15204
+ * });
15205
+ * }
15206
+ *
15207
+ * const win = await createWindowWithTwoViews();
15208
+ * // ... you will now see a new window with two views in it
15209
+ *
15210
+ * // we take a snapshot of the current state of the app, before changing it
15211
+ * const snapshotOfInitialAppState = await platform.getSnapshot();
15212
+ *
15213
+ * // now let's change the state of the app:
15214
+ * await addViewToWindow(win.identity);
15215
+ * // ... the window now has three views in it
15216
+ *
15217
+ * await platform.applySnapshot(snapshotOfInitialAppState, { closeExistingWindows: true });
15218
+ * // ... the window will revert to previous state, with just two views
15219
+ *
15220
+ * ```
15221
+ */
15222
+ async applySnapshot(requestedSnapshot, options) {
15223
+ this.wire.sendAction('platform-apply-snapshot', this.identity).catch((e) => {
15224
+ // don't expose
15225
+ });
15226
+ const errMsg = 'Requested snapshot must be a valid Snapshot object, or a url or filepath to such an object.';
15227
+ let snapshot;
15228
+ if (typeof requestedSnapshot === 'string') {
15229
+ // Fetch and parse snapshot
15230
+ try {
15231
+ const response = await this._channel.wire.sendAction('get-application-manifest', {
15232
+ manifestUrl: requestedSnapshot
15233
+ });
15234
+ snapshot = response.payload.data;
15235
+ }
15236
+ catch (err) {
15237
+ throw new Error(`${errMsg}: ${err}`);
15238
+ }
15239
+ }
15240
+ else {
15241
+ snapshot = requestedSnapshot;
15242
+ }
15243
+ if (!snapshot.windows) {
15244
+ throw new Error(errMsg);
15245
+ }
15246
+ const client = await this.getClient();
15247
+ await client.dispatch('apply-snapshot', {
15248
+ snapshot,
15249
+ options
15250
+ });
15251
+ return this;
15252
+ }
15253
+ /**
15254
+ * Fetches a JSON manifest using the browser process and returns a Javascript object.
15255
+ * Can be overwritten using {@link Platform.PlatformModule.init Platform.init}.
15256
+ * @param manifestUrl The URL of the manifest to fetch.
15257
+ *
15258
+ * @remarks Can be overwritten using {@link Platform#init Platform.init}.
15259
+ *
15260
+ * @example
15261
+ *
15262
+ * ```js
15263
+ * const platform = fin.Platform.getCurrentSync();
15264
+ * const manifest = await platform.fetchManifest('https://www.path-to-manifest.com/app.json');
15265
+ * console.log(manifest);
15266
+ * ```
15267
+ */
15268
+ async fetchManifest(manifestUrl) {
15269
+ const client = await this.getClient();
15270
+ return client.dispatch('platform-fetch-manifest', { manifestUrl });
15271
+ }
15272
+ /**
15273
+ * Retrieves a manifest by url and launches a legacy application manifest or snapshot into the platform. Returns a promise that
15274
+ * resolves to the wrapped Platform.
15275
+ * @param manifestUrl - The URL of the manifest that will be launched into the platform. If this app manifest
15276
+ * contains a snapshot, that will be launched into the platform. If not, the application described in startup_app options
15277
+ * will be launched into the platform. The applicable startup_app options will become {@link OpenFin.ViewCreationOptions View Options}.
15278
+ *
15279
+ * @remarks If the app manifest contains a snapshot, that will be launched into the platform. If not, the
15280
+ * application described in startup_app options will be launched into the platform as a window with a single view.
15281
+ * The applicable startup_app options will become View Options.
15282
+ *
15283
+ * @example
15284
+ * ```js
15285
+ * try {
15286
+ * const platform = fin.Platform.getCurrentSync();
15287
+ * await platform.launchContentManifest('http://localhost:5555/app.json');
15288
+ * console.log(`content launched successfully into platform`);
15289
+ * } catch(e) {
15290
+ * console.error(e);
15291
+ * }
15292
+ * // For a local manifest file:
15293
+ * try {
15294
+ * const platform = fin.Platform.getCurrentSync();
15295
+ * platform.launchContentManifest('file:///C:/somefolder/app.json');
15296
+ * console.log(`content launched successfully into platform`);
15297
+ * } catch(e) {
15298
+ * console.error(e);
15299
+ * }
15300
+ * ```
15301
+ * @experimental
15302
+ */
15303
+ async launchContentManifest(manifestUrl) {
15304
+ this.wire.sendAction('platform-launch-content-manifest', this.identity).catch(() => {
15305
+ // don't expose
15306
+ });
15307
+ const client = await this.getClient();
15308
+ const manifest = await this.fetchManifest(manifestUrl);
15309
+ client.dispatch('launch-into-platform', { manifest, manifestUrl });
15310
+ return this;
15311
+ }
15312
+ /**
15313
+ * 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.
15314
+ * It can be retrieved using {@link Platform#getWindowContext getWindowContext}.
15315
+ * @param context - A field where serializable context data can be stored to be saved in platform snapshots.
15316
+ * @param target - A target window or view may optionally be provided. If no target is provided, the update will be applied
15317
+ * to the current window (if called from a Window) or the current host window (if called from a View).
15318
+ *
15319
+ * @remarks The context data must be serializable. This can only be called from a window or view that has been launched into a
15320
+ * platform.
15321
+ * This method can be called from the window itself, or from any child view. Context data is shared by all
15322
+ * entities within a window.
15323
+ *
15324
+ * @example
15325
+ * Setting own context:
15326
+ * ```js
15327
+ * const platform = fin.Platform.getCurrentSync();
15328
+ * const contextData = {
15329
+ * security: 'STOCK',
15330
+ * currentView: 'detailed'
15331
+ * }
15332
+ *
15333
+ * await platform.setWindowContext(contextData);
15334
+ * // Context of current window is now set to `contextData`
15335
+ * ```
15336
+ *
15337
+ * Setting the context of another window or view:
15338
+ * ```js
15339
+ * const platform = fin.Platform.getCurrentSync();
15340
+ * const contextData = {
15341
+ * security: 'STOCK',
15342
+ * currentView: 'detailed'
15343
+ * }
15344
+ *
15345
+ * const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
15346
+ * await platform.setWindowContext(contextData, windowOrViewIdentity);
15347
+ * // Context of the target window or view is now set to `contextData`
15348
+ * ```
15349
+ *
15350
+ * A view can listen to changes to its host window's context by listening to the `host-context-changed` event.
15351
+ * This event will fire when a host window's context is updated or when the view is reparented to a new window:
15352
+ *
15353
+ * ```js
15354
+ * // From a view
15355
+ * const contextChangeHandler = ({ context }) => {
15356
+ * console.log('Host window\'s context has changed. New context data:', context);
15357
+ * // react to new context data here
15358
+ * }
15359
+ * await fin.me.on('host-context-changed', contextChangeHandler);
15360
+ *
15361
+ * const platform = await fin.Platform.getCurrentSync();
15362
+ * const contextData = {
15363
+ * security: 'STOCK',
15364
+ * currentView: 'detailed'
15365
+ * }
15366
+ * platform.setWindowContext(contextData) // contextChangeHandler will log the new context
15367
+ * ```
15368
+ *
15369
+ * To listen to a window's context updates, use the `context-changed` event:
15370
+ * ```js
15371
+ * // From a window
15372
+ * const contextChangeHandler = ({ context }) => {
15373
+ * console.log('This window\'s context has changed. New context data:', context);
15374
+ * // react to new context data here
15375
+ * }
15376
+ * await fin.me.on('context-changed', contextChangeHandler);
15377
+ *
15378
+ * const platform = await fin.Platform.getCurrentSync();
15379
+ * const contextData = {
15380
+ * security: 'STOCK',
15381
+ * currentView: 'detailed'
15382
+ * }
15383
+ * platform.setWindowContext(contextData) // contextChangeHandler will log the new context
15384
+ * ```
15385
+ * @experimental
15386
+ */
15387
+ async setWindowContext(context = {}, target) {
15388
+ this.wire.sendAction('platform-set-window-context', this.identity).catch((e) => {
15389
+ // don't expose
15390
+ });
15391
+ if (!context) {
15392
+ throw new Error('Please provide a serializable object or string to set the context.');
15393
+ }
15394
+ const client = await this.getClient();
15395
+ const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
15396
+ await client.dispatch('set-window-context', {
15397
+ context,
15398
+ entityType,
15399
+ target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name }
15400
+ });
15401
+ }
15402
+ /**
15403
+ * Get the context context of a host window that was previously set using {@link Platform#setWindowContext setWindowContext}.
15404
+ * The context will be saved in any platform snapshots. Returns a promise that resolves to the context.
15405
+ * @param target - A target window or view may optionally be provided. If no target is provided, target will be
15406
+ * the current window (if called from a Window) or the current host window (if called from a View).
15407
+ *
15408
+ * @remarks This method can be called from the window itself, or from any child view. Context data is shared
15409
+ * by all entities within a window.
15836
15410
  *
15837
- * return platform.createWindow({
15838
- * layout: {
15839
- * content: [
15840
- * {
15841
- * type: 'stack',
15842
- * content: [
15843
- * {
15844
- * type: 'component',
15845
- * componentName: 'view',
15846
- * componentState: {
15847
- * name: 'test_view_1',
15848
- * url: 'https://example.com'
15849
- * }
15850
- * },
15851
- * {
15852
- * type: 'component',
15853
- * componentName: 'view',
15854
- * componentState: {
15855
- * name: 'test_view_2',
15856
- * url: 'https://yahoo.com'
15857
- * }
15858
- * }
15859
- * ]
15860
- * }
15861
- * ]
15862
- * }
15863
- * });
15864
- * }
15411
+ * @example
15865
15412
  *
15866
- * const win = await createWindowWithTwoViews();
15867
- * // ... you will now see a new window with two views in it
15413
+ * Retrieving context from current window:
15414
+ * ```js
15415
+ * const platform = fin.Platform.getCurrentSync();
15416
+ * const customContext = { answer: 42 };
15417
+ * await platform.setWindowContext(customContext);
15868
15418
  *
15869
- * // we take a snapshot of the current state of the app, before changing it
15870
- * const snapshotOfInitialAppState = await platform.getSnapshot();
15419
+ * const myContext = await platform.getWindowContext();
15420
+ * console.log(myContext); // { answer: 42 }
15421
+ * ```
15871
15422
  *
15872
- * // now let's change the state of the app:
15873
- * await addViewToWindow(win.identity);
15874
- * // ... the window now has three views in it
15423
+ * Retrieving the context of another window or view:
15424
+ * ```js
15425
+ * const platform = fin.Platform.getCurrentSync();
15875
15426
  *
15876
- * await platform.applySnapshot(snapshotOfInitialAppState, { closeExistingWindows: true });
15877
- * // ... the window will revert to previous state, with just two views
15427
+ * const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
15878
15428
  *
15429
+ * const targetWindowContext = await platform.getWindowContext(windowOrViewIdentity);
15430
+ * console.log(targetWindowContext); // context of target window
15879
15431
  * ```
15432
+ * @experimental
15880
15433
  */
15881
- async applySnapshot(requestedSnapshot, options) {
15882
- this.wire.sendAction('platform-apply-snapshot', this.identity).catch((e) => {
15434
+ async getWindowContext(target) {
15435
+ this.wire.sendAction('platform-get-window-context', this.identity).catch((e) => {
15883
15436
  // don't expose
15884
15437
  });
15885
- const errMsg = 'Requested snapshot must be a valid Snapshot object, or a url or filepath to such an object.';
15886
- let snapshot;
15887
- if (typeof requestedSnapshot === 'string') {
15888
- // Fetch and parse snapshot
15889
- try {
15890
- const response = await this._channel.wire.sendAction('get-application-manifest', {
15891
- manifestUrl: requestedSnapshot
15892
- });
15893
- snapshot = response.payload.data;
15894
- }
15895
- catch (err) {
15896
- throw new Error(`${errMsg}: ${err}`);
15897
- }
15898
- }
15899
- else {
15900
- snapshot = requestedSnapshot;
15901
- }
15902
- if (!snapshot.windows) {
15903
- throw new Error(errMsg);
15904
- }
15905
15438
  const client = await this.getClient();
15906
- await client.dispatch('apply-snapshot', {
15907
- snapshot,
15908
- options
15439
+ const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
15440
+ return client.dispatch('get-window-context', {
15441
+ target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name },
15442
+ entityType
15909
15443
  });
15910
- return this;
15911
15444
  }
15912
15445
  /**
15913
- * Fetches a JSON manifest using the browser process and returns a Javascript object.
15914
- * Can be overwritten using {@link Platform.PlatformModule.init Platform.init}.
15915
- * @param manifestUrl The URL of the manifest to fetch.
15446
+ * Closes a window. If enableBeforeUnload is enabled in the Platform options, any beforeunload handler set on Views will fire
15447
+ * This behavior can be disabled by setting skipBeforeUnload to false in the options parameter.
15448
+ * @param winId
15449
+ * @param options
15916
15450
  *
15917
- * @remarks Can be overwritten using {@link Platform#init Platform.init}.
15451
+ * @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,
15452
+ * it is recommended to move that logic over to the [PlatformProvider.closeWindow]{@link PlatformProvider#closeWindow} override to ensure it runs when the Window closes.
15918
15453
  *
15919
15454
  * @example
15920
15455
  *
15921
15456
  * ```js
15922
- * const platform = fin.Platform.getCurrentSync();
15923
- * const manifest = await platform.fetchManifest('https://www.path-to-manifest.com/app.json');
15924
- * console.log(manifest);
15457
+ * // Close the current Window inside a Window context
15458
+ * const platform = await fin.Platform.getCurrent();
15459
+ * platform.closeWindow(fin.me.identity);
15460
+ *
15461
+ * // Close the Window from inside a View context
15462
+ * const platform = await fin.Platform.getCurrent();
15463
+ * const parentWindow = await fin.me.getCurrentWindow();
15464
+ * platform.closeWindow(parentWindow.identity);
15465
+ *
15466
+ * // Close the Window and do not fire the before unload handler on Views
15467
+ * const platform = await fin.Platform.getCurrent();
15468
+ * platform.closeWindow(fin.me.identity, { skipBeforeUnload: true });
15925
15469
  * ```
15470
+ * @experimental
15926
15471
  */
15927
- async fetchManifest(manifestUrl) {
15472
+ async closeWindow(windowId, options = { skipBeforeUnload: false }) {
15473
+ this.wire.sendAction('platform-close-window', this.identity).catch((e) => {
15474
+ // don't expose
15475
+ });
15928
15476
  const client = await this.getClient();
15929
- return client.dispatch('platform-fetch-manifest', { manifestUrl });
15477
+ return client.dispatch('close-window', { windowId, options });
15478
+ }
15479
+ }
15480
+ Instance$2.Platform = Platform;
15481
+ _Platform_channelName = new WeakMap(), _Platform_connectToProvider = new WeakMap();
15482
+ /**
15483
+ * @internal
15484
+ * Reuse clients to avoid overwriting already-registered client in provider
15485
+ * This ensures that only channel client is created per channel name per `fin` instance
15486
+ */
15487
+ Platform.clientMap = new Map();
15488
+
15489
+ var layout = {};
15490
+
15491
+ var Factory$1 = {};
15492
+
15493
+ var Instance$1 = {};
15494
+
15495
+ var layoutEntities = {};
15496
+
15497
+ var apiExposer$1 = {};
15498
+
15499
+ var apiConsumer = {};
15500
+
15501
+ Object.defineProperty(apiConsumer, "__esModule", { value: true });
15502
+ apiConsumer.ApiConsumer = void 0;
15503
+ /**
15504
+ * Consumer for apis exposed with {@see ApiExposer}.
15505
+ *
15506
+ * A strategy that matches the strategy used to expose a target API must be provided.
15507
+ */
15508
+ class ApiConsumer {
15509
+ // eslint-disable-next-line
15510
+ constructor(strategy) {
15511
+ this.strategy = strategy;
15512
+ /**
15513
+ * Consumes an api exposed using a given transport strategy, and generates a client
15514
+ * for easy, type safe consumption of that client.
15515
+ * @param options Strategy specific consumption options.
15516
+ * @returns An api client matching the given type.
15517
+ */
15518
+ this.consume = async (options) => {
15519
+ const exposedProperties = await this.strategy.getExposedFunctions(options);
15520
+ return exposedProperties.reduce((client, prop) => ({
15521
+ ...client,
15522
+ [prop.key]: this.strategy.createFunction(prop, options)
15523
+ }), {});
15524
+ };
15525
+ }
15526
+ }
15527
+ apiConsumer.ApiConsumer = ApiConsumer;
15528
+
15529
+ var apiExposer = {};
15530
+
15531
+ var decorators = {};
15532
+
15533
+ Object.defineProperty(decorators, "__esModule", { value: true });
15534
+ decorators.expose = decorators.getExposedProperties = void 0;
15535
+ const exposedProperties = Symbol('exposedProperties');
15536
+ const getExposedProperties = (target) => {
15537
+ return target[exposedProperties] || target.prototype[exposedProperties] || [];
15538
+ };
15539
+ decorators.getExposedProperties = getExposedProperties;
15540
+ /**
15541
+ * Indicates that a class member function can be exposed using {@link ApiExposer}.
15542
+ * @param options Options specific to the strategy used in {@link ApiExposer}
15543
+ */
15544
+ // Returns any as decorator typing is weird.
15545
+ const expose = (options) => (target, key, descriptor) => {
15546
+ target[exposedProperties] = target[exposedProperties] || [];
15547
+ target[exposedProperties].push({ key, descriptor, options });
15548
+ };
15549
+ decorators.expose = expose;
15550
+
15551
+ Object.defineProperty(apiExposer, "__esModule", { value: true });
15552
+ apiExposer.ApiExposer = void 0;
15553
+ const decorators_1 = decorators;
15554
+ /**
15555
+ * Exposes api services on the transport of choice.
15556
+ */
15557
+ class ApiExposer {
15558
+ /**
15559
+ * @param strategy The expose strategy to use to expose instances.
15560
+ */
15561
+ // eslint-disable-next-line
15562
+ constructor(strategy) {
15563
+ this.strategy = strategy;
15564
+ /**
15565
+ * Exposes an instance of a given api on
15566
+ * @param instance Instance of a class which has been decorated to indicate which functions can be exposed.
15567
+ * @param instanceOptions Transport strategy specific options to use when exposing.
15568
+ */
15569
+ this.exposeInstance = async (instance, instanceOptions) => {
15570
+ const exposableProps = (0, decorators_1.getExposedProperties)(instance);
15571
+ const exposedProps = await Promise.all(exposableProps.map(async ({ key, options }) => {
15572
+ const customConsumptionOptions = await this.strategy.exposeFunction(instance[key].bind(instance), {
15573
+ key,
15574
+ options,
15575
+ meta: instanceOptions
15576
+ });
15577
+ return {
15578
+ key,
15579
+ options: customConsumptionOptions
15580
+ };
15581
+ }));
15582
+ await this.strategy.exposeMeta(instanceOptions, exposedProps);
15583
+ };
15584
+ }
15585
+ ;
15586
+ }
15587
+ apiExposer.ApiExposer = ApiExposer;
15588
+
15589
+ var strategies = {};
15590
+
15591
+ var openfinChannels = {};
15592
+
15593
+ var channelsConsumer = {};
15594
+
15595
+ Object.defineProperty(channelsConsumer, "__esModule", { value: true });
15596
+ channelsConsumer.ChannelsConsumer = void 0;
15597
+ class ChannelsConsumer {
15598
+ // eslint-disable-next-line
15599
+ constructor(channel) {
15600
+ this.channel = channel;
15601
+ this.getExposedFunctions = async (options) => {
15602
+ const { id } = options;
15603
+ const { props } = await this.channel.dispatch(`api-meta:${id}`);
15604
+ return props;
15605
+ };
15606
+ this.createFunction = (prop) => (...args) => {
15607
+ const { action } = prop.options;
15608
+ return this.channel.dispatch(action, { args });
15609
+ };
15610
+ }
15611
+ ;
15612
+ }
15613
+ channelsConsumer.ChannelsConsumer = ChannelsConsumer;
15614
+
15615
+ var channelsExposer = {};
15616
+
15617
+ Object.defineProperty(channelsExposer, "__esModule", { value: true });
15618
+ channelsExposer.ChannelsExposer = void 0;
15619
+ class ChannelsExposer {
15620
+ // eslint-disable-next-line
15621
+ constructor(channelProviderOrClient) {
15622
+ this.channelProviderOrClient = channelProviderOrClient;
15623
+ this.exposeFunction = async (target, config) => {
15624
+ const { key, options, meta } = config;
15625
+ const { id } = meta;
15626
+ const action = `${id}.${options?.action || key}`;
15627
+ await this.channelProviderOrClient.register(action, async ({ args }) => {
15628
+ return target(...args);
15629
+ });
15630
+ return { action };
15631
+ };
15632
+ this.exposeMeta = async ({ id }, props) => {
15633
+ const action = `api-meta:${id}`;
15634
+ await this.channelProviderOrClient.register(action, () => ({ props }));
15635
+ };
15930
15636
  }
15931
- /**
15932
- * Retrieves a manifest by url and launches a legacy application manifest or snapshot into the platform. Returns a promise that
15933
- * resolves to the wrapped Platform.
15934
- * @param manifestUrl - The URL of the manifest that will be launched into the platform. If this app manifest
15935
- * contains a snapshot, that will be launched into the platform. If not, the application described in startup_app options
15936
- * will be launched into the platform. The applicable startup_app options will become {@link OpenFin.ViewCreationOptions View Options}.
15937
- *
15938
- * @remarks If the app manifest contains a snapshot, that will be launched into the platform. If not, the
15939
- * application described in startup_app options will be launched into the platform as a window with a single view.
15940
- * The applicable startup_app options will become View Options.
15941
- *
15942
- * @example
15943
- * ```js
15944
- * try {
15945
- * const platform = fin.Platform.getCurrentSync();
15946
- * await platform.launchContentManifest('http://localhost:5555/app.json');
15947
- * console.log(`content launched successfully into platform`);
15948
- * } catch(e) {
15949
- * console.error(e);
15950
- * }
15951
- * // For a local manifest file:
15952
- * try {
15953
- * const platform = fin.Platform.getCurrentSync();
15954
- * platform.launchContentManifest('file:///C:/somefolder/app.json');
15955
- * console.log(`content launched successfully into platform`);
15956
- * } catch(e) {
15957
- * console.error(e);
15958
- * }
15959
- * ```
15960
- * @experimental
15961
- */
15962
- async launchContentManifest(manifestUrl) {
15963
- this.wire.sendAction('platform-launch-content-manifest', this.identity).catch(() => {
15964
- // don't expose
15637
+ }
15638
+ channelsExposer.ChannelsExposer = ChannelsExposer;
15639
+
15640
+ (function (exports) {
15641
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15642
+ if (k2 === undefined) k2 = k;
15643
+ var desc = Object.getOwnPropertyDescriptor(m, k);
15644
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15645
+ desc = { enumerable: true, get: function() { return m[k]; } };
15646
+ }
15647
+ Object.defineProperty(o, k2, desc);
15648
+ }) : (function(o, m, k, k2) {
15649
+ if (k2 === undefined) k2 = k;
15650
+ o[k2] = m[k];
15651
+ }));
15652
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
15653
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15654
+ };
15655
+ Object.defineProperty(exports, "__esModule", { value: true });
15656
+ __exportStar(channelsConsumer, exports);
15657
+ __exportStar(channelsExposer, exports);
15658
+ } (openfinChannels));
15659
+
15660
+ (function (exports) {
15661
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15662
+ if (k2 === undefined) k2 = k;
15663
+ var desc = Object.getOwnPropertyDescriptor(m, k);
15664
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15665
+ desc = { enumerable: true, get: function() { return m[k]; } };
15666
+ }
15667
+ Object.defineProperty(o, k2, desc);
15668
+ }) : (function(o, m, k, k2) {
15669
+ if (k2 === undefined) k2 = k;
15670
+ o[k2] = m[k];
15671
+ }));
15672
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
15673
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15674
+ };
15675
+ Object.defineProperty(exports, "__esModule", { value: true });
15676
+ __exportStar(openfinChannels, exports);
15677
+ } (strategies));
15678
+
15679
+ (function (exports) {
15680
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15681
+ if (k2 === undefined) k2 = k;
15682
+ var desc = Object.getOwnPropertyDescriptor(m, k);
15683
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15684
+ desc = { enumerable: true, get: function() { return m[k]; } };
15685
+ }
15686
+ Object.defineProperty(o, k2, desc);
15687
+ }) : (function(o, m, k, k2) {
15688
+ if (k2 === undefined) k2 = k;
15689
+ o[k2] = m[k];
15690
+ }));
15691
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
15692
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15693
+ };
15694
+ Object.defineProperty(exports, "__esModule", { value: true });
15695
+ __exportStar(apiConsumer, exports);
15696
+ __exportStar(apiExposer, exports);
15697
+ __exportStar(strategies, exports);
15698
+ __exportStar(decorators, exports);
15699
+ } (apiExposer$1));
15700
+
15701
+ var channelApiRelay = {};
15702
+
15703
+ Object.defineProperty(channelApiRelay, "__esModule", { value: true });
15704
+ channelApiRelay.createRelayedDispatch = channelApiRelay.relayChannelClientApi = void 0;
15705
+ const EXPECTED_ERRORS = [
15706
+ 'no longer connected',
15707
+ 'RTCDataChannel closed unexpectedly',
15708
+ 'The client you are trying to dispatch from is disconnected from the target provider',
15709
+ ];
15710
+ // Checks possible error messages that we want to trap, client error message can originate
15711
+ // from ChannelProvider::dispatch OR ClassicStrategy::closeEndpoint OR RTCEndPoint::dataChannel::onclose
15712
+ const isDisconnectedError = (errorMsg) => {
15713
+ return EXPECTED_ERRORS.some(e => errorMsg.includes(e));
15714
+ };
15715
+ /**
15716
+ * @internal
15717
+ * Create a channel relay for a given channel exposition, allowing a single provider to route
15718
+ * actions to the designated clients.
15719
+ *
15720
+ * Designed to be used in conjunction with @expose
15721
+ *
15722
+ * @param channelProvider The channel provider to relay the actions on.
15723
+ * @param config Determines which actions to relay. Please ensure action prefix matches the exposed api.
15724
+ */
15725
+ const relayChannelClientApi = async (channelProvider, relayId) => {
15726
+ channelProvider.register(`relay:${relayId}`, ({ action, target, payload }) => {
15727
+ return channelProvider.dispatch(target, action, payload);
15728
+ });
15729
+ await Promise.resolve();
15730
+ };
15731
+ channelApiRelay.relayChannelClientApi = relayChannelClientApi;
15732
+ const createRelayedDispatch = (client, target, relayId, relayErrorMsg) => async (action, payload) => {
15733
+ try {
15734
+ return await client.dispatch(`relay:${relayId}`, {
15735
+ action,
15736
+ payload,
15737
+ target
15965
15738
  });
15966
- const client = await this.getClient();
15967
- const manifest = await this.fetchManifest(manifestUrl);
15968
- client.dispatch('launch-into-platform', { manifest, manifestUrl });
15969
- return this;
15970
15739
  }
15971
- /**
15972
- * 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.
15973
- * It can be retrieved using {@link Platform#getWindowContext getWindowContext}.
15974
- * @param context - A field where serializable context data can be stored to be saved in platform snapshots.
15975
- * @param target - A target window or view may optionally be provided. If no target is provided, the update will be applied
15976
- * to the current window (if called from a Window) or the current host window (if called from a View).
15977
- *
15978
- * @remarks The context data must be serializable. This can only be called from a window or view that has been launched into a
15979
- * platform.
15980
- * This method can be called from the window itself, or from any child view. Context data is shared by all
15981
- * entities within a window.
15982
- *
15983
- * @example
15984
- * Setting own context:
15985
- * ```js
15986
- * const platform = fin.Platform.getCurrentSync();
15987
- * const contextData = {
15988
- * security: 'STOCK',
15989
- * currentView: 'detailed'
15990
- * }
15991
- *
15992
- * await platform.setWindowContext(contextData);
15993
- * // Context of current window is now set to `contextData`
15994
- * ```
15995
- *
15996
- * Setting the context of another window or view:
15997
- * ```js
15998
- * const platform = fin.Platform.getCurrentSync();
15999
- * const contextData = {
16000
- * security: 'STOCK',
16001
- * currentView: 'detailed'
16002
- * }
16003
- *
16004
- * const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
16005
- * await platform.setWindowContext(contextData, windowOrViewIdentity);
16006
- * // Context of the target window or view is now set to `contextData`
16007
- * ```
16008
- *
16009
- * A view can listen to changes to its host window's context by listening to the `host-context-changed` event.
16010
- * This event will fire when a host window's context is updated or when the view is reparented to a new window:
16011
- *
16012
- * ```js
16013
- * // From a view
16014
- * const contextChangeHandler = ({ context }) => {
16015
- * console.log('Host window\'s context has changed. New context data:', context);
16016
- * // react to new context data here
16017
- * }
16018
- * await fin.me.on('host-context-changed', contextChangeHandler);
16019
- *
16020
- * const platform = await fin.Platform.getCurrentSync();
16021
- * const contextData = {
16022
- * security: 'STOCK',
16023
- * currentView: 'detailed'
16024
- * }
16025
- * platform.setWindowContext(contextData) // contextChangeHandler will log the new context
16026
- * ```
16027
- *
16028
- * To listen to a window's context updates, use the `context-changed` event:
16029
- * ```js
16030
- * // From a window
16031
- * const contextChangeHandler = ({ context }) => {
16032
- * console.log('This window\'s context has changed. New context data:', context);
16033
- * // react to new context data here
16034
- * }
16035
- * await fin.me.on('context-changed', contextChangeHandler);
16036
- *
16037
- * const platform = await fin.Platform.getCurrentSync();
16038
- * const contextData = {
16039
- * security: 'STOCK',
16040
- * currentView: 'detailed'
16041
- * }
16042
- * platform.setWindowContext(contextData) // contextChangeHandler will log the new context
16043
- * ```
16044
- * @experimental
16045
- */
16046
- async setWindowContext(context = {}, target) {
16047
- this.wire.sendAction('platform-set-window-context', this.identity).catch((e) => {
16048
- // don't expose
16049
- });
16050
- if (!context) {
16051
- throw new Error('Please provide a serializable object or string to set the context.');
15740
+ catch (e) {
15741
+ if (isDisconnectedError(e.message) && relayErrorMsg) {
15742
+ throw new Error(relayErrorMsg);
16052
15743
  }
16053
- const client = await this.getClient();
16054
- const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
16055
- await client.dispatch('set-window-context', {
16056
- context,
16057
- entityType,
16058
- target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name }
16059
- });
15744
+ throw e;
16060
15745
  }
15746
+ };
15747
+ channelApiRelay.createRelayedDispatch = createRelayedDispatch;
15748
+
15749
+ var __classPrivateFieldSet$2 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
15750
+ if (kind === "m") throw new TypeError("Private method is not writable");
15751
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
15752
+ 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");
15753
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
15754
+ };
15755
+ var __classPrivateFieldGet$3 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
15756
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
15757
+ 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");
15758
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15759
+ };
15760
+ var _LayoutNode_client, _TabStack_client, _ColumnOrRow_client;
15761
+ Object.defineProperty(layoutEntities, "__esModule", { value: true });
15762
+ layoutEntities.ColumnOrRow = layoutEntities.TabStack = layoutEntities.LayoutNode = void 0;
15763
+ const api_exposer_1 = apiExposer$1;
15764
+ const channel_api_relay_1 = channelApiRelay;
15765
+ /*
15766
+ This file includes LayoutNode, ColumnOrRow and TabStack classes, which are all closely
15767
+ intertwined, and share members via parent abstract class LayoutNode. To prevent circular
15768
+ refs, we define and export all the classes here.
15769
+ */
15770
+ /**
15771
+ * @ignore
15772
+ * @internal
15773
+ * Supplies an ApiClient for {@link LayoutEntitiesController} and helper methods
15774
+ * for the entities {@link TabStack} AND {@link ColumnOrRow} to use.
15775
+ */
15776
+ class LayoutNode {
16061
15777
  /**
16062
- * Get the context context of a host window that was previously set using {@link Platform#setWindowContext setWindowContext}.
16063
- * The context will be saved in any platform snapshots. Returns a promise that resolves to the context.
16064
- * @param target - A target window or view may optionally be provided. If no target is provided, target will be
16065
- * the current window (if called from a Window) or the current host window (if called from a View).
16066
- *
16067
- * @remarks This method can be called from the window itself, or from any child view. Context data is shared
16068
- * by all entities within a window.
16069
- *
16070
- * @example
16071
- *
16072
- * Retrieving context from current window:
16073
- * ```js
16074
- * const platform = fin.Platform.getCurrentSync();
16075
- * const customContext = { answer: 42 };
16076
- * await platform.setWindowContext(customContext);
16077
- *
16078
- * const myContext = await platform.getWindowContext();
16079
- * console.log(myContext); // { answer: 42 }
16080
- * ```
16081
- *
16082
- * Retrieving the context of another window or view:
16083
- * ```js
16084
- * const platform = fin.Platform.getCurrentSync();
16085
- *
16086
- * const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
16087
- *
16088
- * const targetWindowContext = await platform.getWindowContext(windowOrViewIdentity);
16089
- * console.log(targetWindowContext); // context of target window
16090
- * ```
16091
- * @experimental
15778
+ * @internal
15779
+ * @ignore
16092
15780
  */
16093
- async getWindowContext(target) {
16094
- this.wire.sendAction('platform-get-window-context', this.identity).catch((e) => {
16095
- // don't expose
16096
- });
16097
- const client = await this.getClient();
16098
- const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
16099
- return client.dispatch('get-window-context', {
16100
- target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name },
16101
- entityType
16102
- });
15781
+ constructor(client, entityId) {
15782
+ /**
15783
+ * @ignore
15784
+ * @internal
15785
+ * ApiClient for {@link LayoutEntitiesController}
15786
+ */
15787
+ _LayoutNode_client.set(this, void 0);
15788
+ /**
15789
+ * Checks if the TabStack or ColumnOrRow is the root content item
15790
+ *
15791
+ * @example
15792
+ * ```js
15793
+ * if (!fin.me.isView) {
15794
+ * throw new Error('Not running in a platform View.');
15795
+ * }
15796
+ *
15797
+ * const stack = await fin.me.getCurrentStack();
15798
+ * const isRoot = await stack.isRoot();
15799
+ * // The TabStack is root: false
15800
+ * console.log(`The TabStack is root: ${isRoot}`);
15801
+ *
15802
+ * // Retrieves the parent ColumnOrRow
15803
+ * const parent = await stack.getParent();
15804
+ * const parentIsRoot = await parent.isRoot();
15805
+ * // The parent ColumnOrRow is root: true
15806
+ * console.log(`The parent ColumnOrRow is root: ${parentIsRoot}`);
15807
+ * ```
15808
+ */
15809
+ this.isRoot = () => __classPrivateFieldGet$3(this, _LayoutNode_client, "f").isRoot(this.entityId);
15810
+ /**
15811
+ * Checks if the TabStack or ColumnOrRow exists
15812
+ *
15813
+ * @example
15814
+ * ```js
15815
+ * if (!fin.me.isView) {
15816
+ * throw new Error('Not running in a platform View.');
15817
+ * }
15818
+ *
15819
+ * const stack = await fin.me.getCurrentStack();
15820
+ * // Retrieves the parent ColumnOrRow
15821
+ * const columnOrRow = await stack.getParent();
15822
+ * let exists = await stack.exists();
15823
+ * // or
15824
+ * let exists = await columnOrRow.exists();
15825
+ * // The entity exists: true
15826
+ * console.log(`The entity exists: ${exists}`);
15827
+ * ```
15828
+ */
15829
+ this.exists = () => __classPrivateFieldGet$3(this, _LayoutNode_client, "f").exists(this.entityId);
15830
+ /**
15831
+ * Retrieves the parent of the TabStack or ColumnOrRow
15832
+ *
15833
+ * @example
15834
+ * ```js
15835
+ * if (!fin.me.isView) {
15836
+ * throw new Error('Not running in a platform View.');
15837
+ * }
15838
+ *
15839
+ * const stack = await fin.me.getCurrentStack();
15840
+ * // Retrieves the parent ColumnOrRow
15841
+ * const columnOrRow = await stack.getParent();
15842
+ *
15843
+ * // undefined if entity is the root item
15844
+ * let parent = await columnOrRow.getParent();
15845
+ * // or
15846
+ * let parent = await stack.getParent();
15847
+ * ```
15848
+ */
15849
+ this.getParent = async () => {
15850
+ const parent = await __classPrivateFieldGet$3(this, _LayoutNode_client, "f").getParent(this.entityId);
15851
+ if (!parent) {
15852
+ return undefined;
15853
+ }
15854
+ return LayoutNode.getEntity(parent, __classPrivateFieldGet$3(this, _LayoutNode_client, "f"));
15855
+ };
15856
+ /**
15857
+ * Creates a new TabStack adjacent to the given TabStack or ColumnOrRow. Inputs can be new views to create, or existing views.
15858
+ *
15859
+ * Known Issue: If the number of views to add overflows the tab-container, the added views will be set as active
15860
+ * during each render, and then placed at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
15861
+ * This means the views you pass to createAdjacentStack() may not render in the order given by the array.
15862
+ * Until fixed, this problem can be avoided only if your window is wide enough to fit creating all the views in the tabstack.
15863
+ *
15864
+ * @param views The views that will populate the new TabStack.
15865
+ * @param options Additional options that control new TabStack creation.
15866
+ * @returns The newly-created TabStack.
15867
+ *
15868
+ * @example
15869
+ * ```js
15870
+ * if (!fin.me.isView) {
15871
+ * throw new Error('Not running in a platform View.');
15872
+ * }
15873
+ *
15874
+ * const stack = await fin.me.getCurrentStack();
15875
+ * const columnOrRow = await stack.getParent();
15876
+ *
15877
+ * // Create view references by supplying a 'name' and 'url'
15878
+ * const views = [
15879
+ * // if 'name' is undefined, one will be generated
15880
+ * // if 'url' is undefined, it will default the view URL to 'about:blank'
15881
+ * { name: 'google-view', url: 'http://google.com/'},
15882
+ * { name: 'of-developers-view', url: 'http://developers.openfin.co/'},
15883
+ * ];
15884
+ *
15885
+ * // Create a view beforehand to be included in the new tab stack
15886
+ * const outsideView = await fin.View.create({
15887
+ * name: 'outside-bloomberg-view',
15888
+ * url: 'https://bloomberg.com/',
15889
+ * target: fin.me.identity,
15890
+ * });
15891
+ *
15892
+ * // Views to add can be identities, or the reference views mentioned above
15893
+ * const viewsToAdd = [outsideView.identity, ...views];
15894
+ *
15895
+ * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
15896
+ * let stackFrom = await columnOrRow.createAdjacentStack(viewsToAdd, { position: 'right' });
15897
+ * // Or
15898
+ * let newStack = await stack.createAdjacentStack(viewsToAdd, { position: 'right' });
15899
+ * console.log(`A new TabStack created to the right has ${newStack.length} views in it`);
15900
+ *
15901
+ * ```
15902
+ * @experimental
15903
+ */
15904
+ this.createAdjacentStack = async (views, options) => {
15905
+ const entityId = await __classPrivateFieldGet$3(this, _LayoutNode_client, "f").createAdjacentStack(this.entityId, views, options);
15906
+ return LayoutNode.getEntity({ entityId, type: 'stack' }, __classPrivateFieldGet$3(this, _LayoutNode_client, "f"));
15907
+ };
15908
+ /**
15909
+ * Retrieves the adjacent TabStacks of the given TabStack or ColumnOrRow.
15910
+ *
15911
+ * @param edge Edge whose adjacent TabStacks will be returned.
15912
+ *
15913
+ * @example
15914
+ * ```js
15915
+ * if (!fin.me.isView) {
15916
+ * throw new Error('Not running in a platform View.');
15917
+ * }
15918
+ *
15919
+ * const stack = await fin.me.getCurrentStack();
15920
+ * const columnOrRow = await stack.getParent();
15921
+ * // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
15922
+ * let rightStacks = await columnOrRow.getAdjacentStacks('right');
15923
+ * let leftStacks = await columnOrRow.getAdjacentStacks('left');
15924
+ * // or
15925
+ * let rightStacks = await stack.getAdjacentStacks('right');
15926
+ * let leftStacks = await stack.getAdjacentStacks('left');
15927
+ *
15928
+ * console.log(`The entity has ${rightStacks.length} stacks to the right, and ${leftStacks.length} stacks to the left`);
15929
+ *
15930
+ * ```
15931
+ * @experimental
15932
+ */
15933
+ this.getAdjacentStacks = async (edge) => {
15934
+ const adjacentStacks = await __classPrivateFieldGet$3(this, _LayoutNode_client, "f").getAdjacentStacks({
15935
+ targetId: this.entityId,
15936
+ edge
15937
+ });
15938
+ return adjacentStacks.map((stack) => LayoutNode.getEntity({
15939
+ type: 'stack',
15940
+ entityId: stack.entityId
15941
+ }, __classPrivateFieldGet$3(this, _LayoutNode_client, "f")));
15942
+ };
15943
+ __classPrivateFieldSet$2(this, _LayoutNode_client, client, "f");
15944
+ this.entityId = entityId;
15945
+ }
15946
+ }
15947
+ layoutEntities.LayoutNode = LayoutNode;
15948
+ _LayoutNode_client = new WeakMap();
15949
+ /**
15950
+ * @ignore
15951
+ * @internal
15952
+ * Encapsulates Api consumption of {@link LayoutEntitiesClient} with a relayed dispatch
15953
+ * @param client
15954
+ * @param controllerId
15955
+ * @param identity
15956
+ * @returns a new instance of {@link LayoutEntitiesClient} with bound to the controllerId
15957
+ */
15958
+ LayoutNode.newLayoutEntitiesClient = async (client, controllerId, identity) => {
15959
+ 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.');
15960
+ const consumer = new api_exposer_1.ApiConsumer(new api_exposer_1.ChannelsConsumer({ dispatch }));
15961
+ return consumer.consume({ id: controllerId });
15962
+ };
15963
+ LayoutNode.getEntity = (definition, client) => {
15964
+ const { entityId, type } = definition;
15965
+ switch (type) {
15966
+ case 'column':
15967
+ case 'row':
15968
+ return new ColumnOrRow(client, entityId, type);
15969
+ case 'stack':
15970
+ return new TabStack(client, entityId);
15971
+ default:
15972
+ throw new Error(`Unrecognised Layout Entity encountered ('${JSON.stringify(definition)})`);
15973
+ }
15974
+ };
15975
+ /**
15976
+ * A TabStack is used to manage the state of a stack of tabs within an OpenFin Layout.
15977
+ */
15978
+ class TabStack extends LayoutNode {
15979
+ /** @internal */
15980
+ constructor(client, entityId) {
15981
+ super(client, entityId);
15982
+ /**
15983
+ * @internal
15984
+ * ApiClient for {@link LayoutEntitiesController}
15985
+ */
15986
+ _TabStack_client.set(this, void 0);
15987
+ /**
15988
+ * Type of the content item. Always stack, but useful for distinguishing between a {@link TabStack} and {@link ColumnOrRow}.
15989
+ */
15990
+ this.type = 'stack';
15991
+ /**
15992
+ * Retrieves a list of all views belonging to this {@link TabStack}.
15993
+ *
15994
+ * Known Issue: If adding a view overflows the tab-container width, the added view will be set as active
15995
+ * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
15996
+ * If that happens and then getViews() is called, it will return the identities in a different order than
15997
+ * than the currently rendered tab order.
15998
+ *
15999
+ *
16000
+ * @throws If the {@link TabStack} has been destroyed.
16001
+ * @example
16002
+ * ```js
16003
+ * if (!fin.me.isView) {
16004
+ * throw new Error('Not running in a platform View.');
16005
+ * }
16006
+ *
16007
+ * const stack = await fin.me.getCurrentStack();
16008
+ * // Alternatively, you can wrap any view and get the stack from there
16009
+ * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
16010
+ * // const stack = await viewFromSomewhere.getCurrentStack();
16011
+ * const views = await stack.getViews();
16012
+ * console.log(`Stack contains ${views.length} view(s)`);
16013
+ * ```
16014
+ * @experimental
16015
+ */
16016
+ this.getViews = () => __classPrivateFieldGet$3(this, _TabStack_client, "f").getStackViews(this.entityId);
16017
+ /**
16018
+ * Adds or creates a view in this {@link TabStack}.
16019
+ *
16020
+ * @remarks Known Issue: If adding a view overflows the tab-container, the added view will be set as active
16021
+ * and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
16022
+ *
16023
+ * @param view The identity of an existing view to add, or options to create a view.
16024
+ * @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)
16025
+ * @returns Resolves with the {@link OpenFin.Identity identity} of the added view.
16026
+ * @throws If the view does not exist or fails to create.
16027
+ * @throws If the {@link TabStack} has been destroyed.
16028
+ * @example
16029
+ * ```js
16030
+ * if (!fin.me.isView) {
16031
+ * throw new Error('Not running in a platform View.');
16032
+ * }
16033
+ *
16034
+ * const stack = await fin.me.getCurrentStack();
16035
+ * // Alternatively, you can wrap any view and get the stack from there
16036
+ * // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
16037
+ * // const stack = await viewFromSomewhere.getCurrentStack();
16038
+ * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
16039
+ * console.log('Identity of the google view just added', { googleViewIdentity });
16040
+ * // pass in { index: number } to set the index in the stack. Here 1 means, end of the stack (defaults to 0)
16041
+ * const appleViewIdentity = await stack.addView({ name: 'apple-view', url: 'http://apple.com/' }, { index: 1 });
16042
+ * console.log('Identity of the apple view just added', { appleViewIdentity });
16043
+ * ```
16044
+ * @experimental
16045
+ */
16046
+ this.addView = async (view, options = { index: 0 }) => __classPrivateFieldGet$3(this, _TabStack_client, "f").addViewToStack(this.entityId, view, options);
16047
+ /**
16048
+ * Removes a view from this {@link TabStack}.
16049
+ *
16050
+ * @remarks Throws an exception if the view identity does not exist or was already destroyed.
16051
+ *
16052
+ * @param view - Identity of the view to remove.
16053
+ * @throws If the view does not exist or does not belong to the stack.
16054
+ * @throws If the {@link TabStack} has been destroyed.
16055
+ *
16056
+ * @example
16057
+ * ```js
16058
+ * if (!fin.me.isView) {
16059
+ * throw new Error('Not running in a platform View.');
16060
+ * }
16061
+ *
16062
+ * const stack = await fin.me.getCurrentStack();
16063
+ * const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
16064
+ *
16065
+ * await stack.removeView(googleViewIdentity);
16066
+ *
16067
+ * try {
16068
+ * await stack.removeView(googleViewIdentity);
16069
+ * } catch (error) {
16070
+ * // Tried to remove a view ('google-view') which does not belong to the stack.
16071
+ * console.log(error);
16072
+ * }
16073
+ * ```
16074
+ */
16075
+ this.removeView = async (view) => {
16076
+ await __classPrivateFieldGet$3(this, _TabStack_client, "f").removeViewFromStack(this.entityId, view);
16077
+ };
16078
+ /**
16079
+ * Sets the active view of the {@link TabStack} without focusing it.
16080
+ * @param view - Identity of the view to activate.
16081
+ * @returns Promise which resolves with void once the view has been activated.
16082
+ * @throws If the {@link TabStack} has been destroyed.
16083
+ * @throws If the view does not exist.
16084
+ * @example
16085
+ * Change the active tab of a known View's TabStack:
16086
+ * ```js
16087
+ * const targetView = fin.View.wrapSync({ uuid: 'uuid', name: 'view-name' });
16088
+ * const stack = await targetView.getCurrentStack();
16089
+ * await stack.setActiveView(targetView.identity);
16090
+ * ```
16091
+ *
16092
+ * Set the current View as active within its TabStack:
16093
+ * ```js
16094
+ * const stack = await fin.me.getCurrentStack();
16095
+ * await stack.setActiveView(fin.me.identity);
16096
+ * ```
16097
+ * @experimental
16098
+ */
16099
+ this.setActiveView = async (view) => {
16100
+ await __classPrivateFieldGet$3(this, _TabStack_client, "f").setStackActiveView(this.entityId, view);
16101
+ };
16102
+ __classPrivateFieldSet$2(this, _TabStack_client, client, "f");
16103
16103
  }
16104
+ }
16105
+ layoutEntities.TabStack = TabStack;
16106
+ _TabStack_client = new WeakMap();
16107
+ /**
16108
+ * A ColumnOrRow is used to manage the state of Column and Rows within an OpenFin Layout.
16109
+ */
16110
+ class ColumnOrRow extends LayoutNode {
16104
16111
  /**
16105
- * Closes a window. If enableBeforeUnload is enabled in the Platform options, any beforeunload handler set on Views will fire
16106
- * This behavior can be disabled by setting skipBeforeUnload to false in the options parameter.
16107
- * @param winId
16108
- * @param options
16109
- *
16110
- * @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,
16111
- * it is recommended to move that logic over to the [PlatformProvider.closeWindow]{@link PlatformProvider#closeWindow} override to ensure it runs when the Window closes.
16112
- *
16113
- * @example
16114
- *
16115
- * ```js
16116
- * // Close the current Window inside a Window context
16117
- * const platform = await fin.Platform.getCurrent();
16118
- * platform.closeWindow(fin.me.identity);
16119
- *
16120
- * // Close the Window from inside a View context
16121
- * const platform = await fin.Platform.getCurrent();
16122
- * const parentWindow = await fin.me.getCurrentWindow();
16123
- * platform.closeWindow(parentWindow.identity);
16124
- *
16125
- * // Close the Window and do not fire the before unload handler on Views
16126
- * const platform = await fin.Platform.getCurrent();
16127
- * platform.closeWindow(fin.me.identity, { skipBeforeUnload: true });
16128
- * ```
16129
- * @experimental
16112
+ * @internal
16130
16113
  */
16131
- async closeWindow(windowId, options = { skipBeforeUnload: false }) {
16132
- this.wire.sendAction('platform-close-window', this.identity).catch((e) => {
16133
- // don't expose
16134
- });
16135
- const client = await this.getClient();
16136
- return client.dispatch('close-window', { windowId, options });
16114
+ constructor(client, entityId, type) {
16115
+ super(client, entityId);
16116
+ /**
16117
+ * @ignore
16118
+ * @internal
16119
+ * ApiClient for {@link LayoutEntitiesController}
16120
+ */
16121
+ _ColumnOrRow_client.set(this, void 0);
16122
+ /**
16123
+ * Retrieves the content array of the ColumnOrRow
16124
+ *
16125
+ * @example
16126
+ * ```js
16127
+ * if (!fin.me.isView) {
16128
+ * throw new Error('Not running in a platform View.');
16129
+ * }
16130
+ *
16131
+ * const stack = await fin.me.getCurrentStack();
16132
+ * // Retrieves the parent ColumnOrRow
16133
+ * const columnOrRow = await stack.getParent();
16134
+ *
16135
+ * // returns [TabStack]
16136
+ * const contentArray = await columnOrRow.getContent();
16137
+ * console.log(`The ColumnOrRow has ${contentArray.length} item(s)`);
16138
+ * ```
16139
+ */
16140
+ this.getContent = async () => {
16141
+ const contentItemEntities = await __classPrivateFieldGet$3(this, _ColumnOrRow_client, "f").getContent(this.entityId);
16142
+ return contentItemEntities.map((entity) => LayoutNode.getEntity(entity, __classPrivateFieldGet$3(this, _ColumnOrRow_client, "f")));
16143
+ };
16144
+ __classPrivateFieldSet$2(this, _ColumnOrRow_client, client, "f");
16145
+ this.type = type;
16137
16146
  }
16138
16147
  }
16139
- Instance$2.Platform = Platform;
16140
- _Platform_connectToProvider = new WeakMap();
16141
-
16142
- var layout = {};
16148
+ layoutEntities.ColumnOrRow = ColumnOrRow;
16149
+ _ColumnOrRow_client = new WeakMap();
16143
16150
 
16144
- var Factory$1 = {};
16151
+ var layout_constants = {};
16145
16152
 
16146
- var Instance$1 = {};
16153
+ Object.defineProperty(layout_constants, "__esModule", { value: true });
16154
+ layout_constants.DEFAULT_LAYOUT_KEY = layout_constants.LAYOUT_CONTROLLER_ID = void 0;
16155
+ layout_constants.LAYOUT_CONTROLLER_ID = 'layout-entities';
16156
+ // TODO: eventually export this somehow
16157
+ layout_constants.DEFAULT_LAYOUT_KEY = '__default__';
16147
16158
 
16148
16159
  var __classPrivateFieldGet$2 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
16149
16160
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
16150
16161
  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");
16151
16162
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
16152
16163
  };
16153
- var _Layout_layoutClient;
16164
+ var _Layout_instances, _Layout_layoutClient, _Layout_forwardLayoutAction;
16154
16165
  Object.defineProperty(Instance$1, "__esModule", { value: true });
16155
16166
  Instance$1.Layout = void 0;
16156
16167
  const lazy_1 = lazy;
@@ -16292,12 +16303,19 @@ const layout_constants_1$1 = layout_constants;
16292
16303
  * ```
16293
16304
  */
16294
16305
  class Layout extends base_1$4.Base {
16306
+ /**
16307
+ * @internal
16308
+ */
16309
+ static getClient(layout) {
16310
+ return __classPrivateFieldGet$2(layout, _Layout_layoutClient, "f").getValue();
16311
+ }
16295
16312
  /**
16296
16313
  * @internal
16297
16314
  */
16298
16315
  // eslint-disable-next-line no-shadow
16299
16316
  constructor(identity, wire) {
16300
16317
  super(wire);
16318
+ _Layout_instances.add(this);
16301
16319
  /**
16302
16320
  * @internal
16303
16321
  * Lazily constructed {@link LayoutEntitiesClient} bound to this platform's client and identity
@@ -16516,9 +16534,71 @@ class Layout extends base_1$4.Base {
16516
16534
  const root = await client.getRoot('layoutName' in this.identity ? this.identity : undefined);
16517
16535
  return layout_entities_1.LayoutNode.getEntity(root, client);
16518
16536
  }
16537
+ /**
16538
+ * Retrieves the OpenFin.TabStack instance which the View belongs to.
16539
+ *
16540
+ * @example
16541
+ * ```js
16542
+ * const viewIdentity = { uuid: 'uuid', name: 'view-name' };
16543
+ * const stack = await fin.View.wrapSync(viewIdentity).getStackByViewIdentity(viewIdentity);
16544
+ * console.log(await stack.getViews());
16545
+ * ```
16546
+ */
16547
+ async getStackByViewIdentity(identity) {
16548
+ this.wire.sendAction('layout-get-stack-by-view').catch(() => {
16549
+ // don't expose
16550
+ });
16551
+ const client = await __classPrivateFieldGet$2(this, _Layout_layoutClient, "f").getValue();
16552
+ const stack = await client.getStackByView(identity);
16553
+ if (!stack) {
16554
+ throw new Error(`No stack found for view: ${identity.uuid}/${identity.name}`);
16555
+ }
16556
+ return layout_entities_1.LayoutNode.getEntity(stack, client);
16557
+ }
16558
+ /**
16559
+ * Adds a view to the platform layout. Behaves like @link{Platform#createView} with the current layout as the target.
16560
+ *
16561
+ * @param viewOptions - The options for creating the view.
16562
+ * @param options - Optional parameters for adding the view.
16563
+ * @param options.location - The location where the view should be added.
16564
+ * @param options.targetView - The target view to which the new view should be added.
16565
+ * @returns A promise that resolves to an object containing the identity of the added view.
16566
+ */
16567
+ async addView(viewOptions, { location, targetView } = {}) {
16568
+ this.wire.sendAction('layout-add-view').catch((e) => {
16569
+ // don't expose
16570
+ });
16571
+ const { identity } = await __classPrivateFieldGet$2(this, _Layout_instances, "m", _Layout_forwardLayoutAction).call(this, 'layout-add-view', {
16572
+ viewOptions,
16573
+ location,
16574
+ targetView
16575
+ });
16576
+ return { identity };
16577
+ }
16578
+ /**
16579
+ * Closes a view by its identity. Throws an error if the view does not belong to the current layout.
16580
+ * Behaves like @link{Platform#closeView} but only closes the view if it belongs the current layout.
16581
+ *
16582
+ * @param viewIdentity - The identity of the view to close.
16583
+ * @returns A promise that resolves when the view is closed.
16584
+ */
16585
+ async closeView(viewIdentity) {
16586
+ this.wire.sendAction('layout-close-view').catch((e) => {
16587
+ // don't expose
16588
+ });
16589
+ await __classPrivateFieldGet$2(this, _Layout_instances, "m", _Layout_forwardLayoutAction).call(this, 'layout-close-view', { viewIdentity });
16590
+ }
16519
16591
  }
16520
16592
  Instance$1.Layout = Layout;
16521
- _Layout_layoutClient = new WeakMap();
16593
+ _Layout_layoutClient = new WeakMap(), _Layout_instances = new WeakSet(), _Layout_forwardLayoutAction =
16594
+ /**
16595
+ * @internal
16596
+ * Use to type-guard actions sent to the layout via the provider.
16597
+ */
16598
+ async function _Layout_forwardLayoutAction(action, payload) {
16599
+ const client = await this.platform.getClient();
16600
+ return client.dispatch(action, { target: this.identity, opts: payload });
16601
+ };
16522
16602
 
16523
16603
  var __classPrivateFieldGet$1 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
16524
16604
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
@@ -16709,7 +16789,7 @@ class LayoutModule extends base_1$3.Base {
16709
16789
  this.wire.sendAction('layout-get-current').catch((e) => {
16710
16790
  // don't expose
16711
16791
  });
16712
- if (!this.fin.me.isWindow) {
16792
+ if (this.wire.environment.type === 'openfin' && !this.fin.me.isWindow) {
16713
16793
  throw new Error('You are not in a Window context. Only Windows can have a Layout.');
16714
16794
  }
16715
16795
  const { uuid, name } = this.fin.me;
@@ -16732,12 +16812,54 @@ class LayoutModule extends base_1$3.Base {
16732
16812
  this.wire.sendAction('layout-get-current-sync').catch((e) => {
16733
16813
  // don't expose
16734
16814
  });
16735
- if (!this.fin.me.isWindow) {
16815
+ if (this.wire.environment.type === 'openfin' && !this.fin.me.isWindow) {
16736
16816
  throw new Error('You are not in a Window context. Only Windows can have a Layout.');
16737
16817
  }
16738
16818
  const { uuid, name } = this.fin.me;
16739
16819
  return this.wrapSync({ uuid, name });
16740
16820
  }
16821
+ /**
16822
+ * Retrieves the OpenFin.Layout instance for the Window the View is attached to.
16823
+ *
16824
+ * @example
16825
+ * ```js
16826
+ * const viewIdentity = { uuid: 'uuid', name: 'view-name' };
16827
+ * const layout = await fin.Platform.Layout.getLayoutByViewIdentity(viewIdentity);
16828
+ * console.log(await layout.getCurrentViews());
16829
+ * ```
16830
+ */
16831
+ async getLayoutByViewIdentity(viewIdentity) {
16832
+ this.wire.sendAction('layout-get-by-view-identity').catch(() => {
16833
+ // don't expose
16834
+ });
16835
+ const winIdentity = await this.wire.environment.getViewWindowIdentity(this.fin, viewIdentity);
16836
+ let layoutWindowIdentity = winIdentity;
16837
+ // TODO: CORE-1857 - when we tearout active layout or drag a view out of a window, the above identity includes the whole window info.
16838
+ if (layoutWindowIdentity.identity) {
16839
+ layoutWindowIdentity = layoutWindowIdentity.identity;
16840
+ }
16841
+ try {
16842
+ const layoutWindow = this.wrapSync(layoutWindowIdentity);
16843
+ const client = await Instance_1$2.Layout.getClient(layoutWindow);
16844
+ const layoutIdentity = await client.getLayoutIdentityForViewOrThrow(viewIdentity);
16845
+ return this.wrapSync(layoutIdentity);
16846
+ }
16847
+ catch (e) {
16848
+ const allowedErrors = [
16849
+ 'No action registered at target for',
16850
+ 'getLayoutIdentityForViewOrThrow is not a function'
16851
+ ];
16852
+ if (!allowedErrors.some((m) => e.message.includes(m))) {
16853
+ throw e;
16854
+ }
16855
+ // If a view is attached to provider window, return null
16856
+ if (layoutWindowIdentity.uuid === layoutWindowIdentity.name) {
16857
+ throw new Error(`View identity ${JSON.stringify(viewIdentity)} is not attached to any layout in provider window ${JSON.stringify(layoutWindowIdentity)}.`);
16858
+ }
16859
+ // fallback logic for missing endpoint in older runtimes
16860
+ return this.wrapSync(layoutWindowIdentity);
16861
+ }
16862
+ }
16741
16863
  }
16742
16864
  Factory$1.LayoutModule = LayoutModule;
16743
16865
  _LayoutModule_layoutInitializationAttempted = new WeakMap(), _LayoutModule_layoutManager = new WeakMap(), _LayoutModule_getLayoutManagerSpy = new WeakMap(), _LayoutModule_instances = new WeakSet(), _LayoutModule_getSafeLayoutManager = function _LayoutModule_getSafeLayoutManager(method) {
@@ -16874,7 +16996,7 @@ class PlatformModule extends base_1$2.Base {
16874
16996
  this.wire.sendAction('platform-wrap').catch((e) => {
16875
16997
  // don't expose
16876
16998
  });
16877
- return new Instance_1$1.Platform({ uuid: identity.uuid }, this._channel);
16999
+ return new Instance_1$1.Platform(this.wire, { uuid: identity.uuid });
16878
17000
  }
16879
17001
  /**
16880
17002
  * Synchronously returns a Platform object that represents an existing platform.
@@ -16891,7 +17013,7 @@ class PlatformModule extends base_1$2.Base {
16891
17013
  this.wire.sendAction('platform-wrap-sync').catch((e) => {
16892
17014
  // don't expose
16893
17015
  });
16894
- return new Instance_1$1.Platform({ uuid: identity.uuid }, this._channel);
17016
+ return new Instance_1$1.Platform(this.wire, { uuid: identity.uuid });
16895
17017
  }
16896
17018
  /**
16897
17019
  * Asynchronously returns a Platform object that represents the current platform.